import { z } from "zod"; export const UpdateProfileDto = z.object({ name: z.string().min(1).max(100).optional(), displayName: z.string().min(1).max(50).optional(), email: z.string().email().max(254).optional(), password: z.string().min(8).max(72).optional(), currentPassword: z.string().min(1).max(72).optional(), avatarUrl: z.string().url().max(2048).nullable().optional(), locale: z.string().max(10).optional(), timezone: z.string().max(50).optional(), theme: z.enum(["light", "dark", "system"]).optional() }); export type UpdateProfileInput = z.infer; export const ListUsersQuery = z.object({ workspaceId: z.string().min(1), search: z.string().max(100).optional(), cursor: z.string().optional(), limit: z.string().optional() }); export type ListUsersInput = z.infer; // ---------- T-153: recently-viewed items ---------- export const RECENT_ITEM_TYPES = ["page", "database", "whiteboard", "task"] as const; export const RecordRecentItemDto = z.object({ itemType: z.enum(RECENT_ITEM_TYPES), refId: z.string().min(1) }); export type RecordRecentItemInput = z.infer; // ---------- T-154: saved searches ---------- const isoDate = z.string().refine((v) => Number.isFinite(Date.parse(v)), { message: "invalid ISO-8601 date" }); const SEARCH_TYPES = ["page", "block", "database", "record", "comment", "file", "user"] as const; // Mirrors the search controller's `SearchBody` (the same query shape the // client sends to POST /search). Duplicated here rather than imported from // the search controller (a controller file, not a module) so this module // stays self-contained; the two are intentionally in lockstep. const SavedSearchQuery = z.object({ q: z.string().trim().min(1).max(200), types: z.array(z.enum(SEARCH_TYPES)).max(7).optional(), workspaceId: z.string().min(1).optional(), teamId: z.string().min(1).optional(), createdBy: z.string().min(1).optional(), updatedAfter: isoDate.optional(), updatedBefore: isoDate.optional(), cursor: z.string().min(1).optional(), limit: z.number().int().min(1).max(50).optional() }); export const SavedSearchCreateDto = z.object({ name: z.string().min(1).max(100), workspaceId: z.string().min(1).nullable().optional(), query: SavedSearchQuery }); export type SavedSearchCreateInput = z.infer; export const SavedSearchUpdateDto = z.object({ name: z.string().min(1).max(100).optional(), workspaceId: z.string().min(1).nullable().optional(), query: SavedSearchQuery.optional() }); export type SavedSearchUpdateInput = z.infer;