Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
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(),
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-28 02:35:36 +02:00
|
|
|
export const documentsHubTabs = [
|
|
|
|
|
'all',
|
|
|
|
|
'awaiting_them',
|
|
|
|
|
'awaiting_me',
|
|
|
|
|
'completed',
|
|
|
|
|
'expired',
|
|
|
|
|
] as const;
|
|
|
|
|
export type DocumentsHubTab = (typeof documentsHubTabs)[number];
|
|
|
|
|
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
export const listDocumentsSchema = baseListQuerySchema.extend({
|
|
|
|
|
interestId: z.string().optional(),
|
|
|
|
|
clientId: z.string().optional(),
|
|
|
|
|
documentType: z.string().optional(),
|
|
|
|
|
status: z.string().optional(),
|
2026-04-28 02:35:36 +02:00
|
|
|
/** 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(),
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const uploadSignedSchema = z.object({
|
|
|
|
|
documentId: z.string().min(1),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type CreateDocumentInput = z.infer<typeof createDocumentSchema>;
|
|
|
|
|
export type UpdateDocumentInput = z.infer<typeof updateDocumentSchema>;
|
|
|
|
|
export type ListDocumentsInput = z.infer<typeof listDocumentsSchema>;
|