44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
|
|
import { z } from 'zod';
|
||
|
|
|
||
|
|
const recipientSchema = z
|
||
|
|
.object({
|
||
|
|
clientId: z.string().min(1).optional(),
|
||
|
|
email: z.string().email().optional(),
|
||
|
|
interestId: z.string().min(1).optional(),
|
||
|
|
})
|
||
|
|
.refine((v) => v.clientId !== undefined || v.email !== undefined, {
|
||
|
|
message: 'recipient.clientId or recipient.email is required',
|
||
|
|
});
|
||
|
|
|
||
|
|
export const sendBerthPdfSchema = z.object({
|
||
|
|
berthId: z.string().min(1),
|
||
|
|
recipient: recipientSchema,
|
||
|
|
customBodyMarkdown: z.string().max(50_000).optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export const sendBrochureSchema = z.object({
|
||
|
|
brochureId: z.string().min(1).optional(),
|
||
|
|
recipient: recipientSchema,
|
||
|
|
customBodyMarkdown: z.string().max(50_000).optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export const previewBodySchema = z.object({
|
||
|
|
documentKind: z.enum(['berth_pdf', 'brochure']),
|
||
|
|
recipient: recipientSchema,
|
||
|
|
berthId: z.string().min(1).optional(),
|
||
|
|
brochureId: z.string().min(1).optional(),
|
||
|
|
customBodyMarkdown: z.string().max(50_000).optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export const listSendsQuerySchema = z.object({
|
||
|
|
clientId: z.string().min(1).optional(),
|
||
|
|
interestId: z.string().min(1).optional(),
|
||
|
|
berthId: z.string().min(1).optional(),
|
||
|
|
limit: z.coerce.number().int().min(1).max(500).optional(),
|
||
|
|
});
|
||
|
|
|
||
|
|
export type SendBerthPdfInput = z.infer<typeof sendBerthPdfSchema>;
|
||
|
|
export type SendBrochureInput = z.infer<typeof sendBrochureSchema>;
|
||
|
|
export type PreviewBodyInput = z.infer<typeof previewBodySchema>;
|
||
|
|
export type ListSendsQuery = z.infer<typeof listSendsQuerySchema>;
|