import { z } from 'zod'; import { baseListQuerySchema } from '@/lib/api/route-helpers'; import { DOCUMENT_TYPES, DOCUMENT_STATUSES } from '@/lib/constants'; export const createDocumentSchema = z.object({ interestId: z.string().optional(), clientId: z.string().optional(), documentType: z.enum(DOCUMENT_TYPES), title: z.string().min(1).max(200), notes: z.string().optional(), }); export const updateDocumentSchema = z.object({ title: z.string().min(1).max(200).optional(), notes: z.string().optional(), status: z.enum(DOCUMENT_STATUSES).optional(), }); export const documentsHubTabs = [ 'all', 'awaiting_them', 'awaiting_me', 'completed', 'expired', ] as const; export type DocumentsHubTab = (typeof documentsHubTabs)[number]; export const listDocumentsSchema = baseListQuerySchema.extend({ interestId: z.string().optional(), clientId: z.string().optional(), documentType: z.string().optional(), status: z.string().optional(), /** Hub tab filter — applies tab-specific status / signer-membership constraints. */ tab: z.enum(documentsHubTabs).optional(), /** Restrict to docs being watched by this user id. */ watcherUserId: z.string().optional(), /** When true, only docs intended for signing (default true on hub). */ signatureOnly: z .enum(['true', 'false']) .optional() .transform((v) => (v === undefined ? undefined : v === 'true')), sentSince: z.string().datetime().optional(), sentUntil: z.string().datetime().optional(), }); export const uploadSignedSchema = z.object({ documentId: z.string().min(1), }); export type CreateDocumentInput = z.infer; export type UpdateDocumentInput = z.infer; export type ListDocumentsInput = z.infer;