mirror of
https://github.com/morten-olsen/reservoir.git
synced 2026-02-08 01:46:24 +01:00
23 lines
724 B
TypeScript
23 lines
724 B
TypeScript
import { z } from 'zod';
|
|
|
|
const upsertDocumentRequestSchema = z.object({
|
|
id: z.string().min(1).optional(),
|
|
type: z.string().min(1),
|
|
source: z.string().min(1).nullable(),
|
|
data: z.unknown(),
|
|
});
|
|
|
|
type UpsertDocumentRequest = z.infer<typeof upsertDocumentRequestSchema>;
|
|
|
|
const upsertDocumentResponseSchema = upsertDocumentRequestSchema.extend({
|
|
createdAt: z.iso.datetime(),
|
|
updatedAt: z.iso.datetime(),
|
|
deletedAt: z.iso.datetime().nullable(),
|
|
action: z.enum(['inserted', 'updated', 'skipped']),
|
|
});
|
|
|
|
type UpsertDocumentResponse = z.input<typeof upsertDocumentResponseSchema>;
|
|
|
|
export type { UpsertDocumentRequest, UpsertDocumentResponse };
|
|
export { upsertDocumentRequestSchema, upsertDocumentResponseSchema };
|