Allow setting createdAt, emoji properties through documents.create (#5864)

This commit is contained in:
Tom Moor
2023-09-21 22:37:27 -04:00
committed by GitHub
parent 8833e578f1
commit 76862b626b
4 changed files with 60 additions and 11 deletions

View File

@@ -280,28 +280,39 @@ export type DocumentsImportReq = z.infer<typeof DocumentsImportSchema>;
export const DocumentsCreateSchema = BaseSchema.extend({
body: z.object({
/** Doc title */
/** Document title */
title: z.string().default(""),
/** Doc text */
/** Document text */
text: z.string().default(""),
/** Emoji displayed alongside doc title */
emoji: z.string().regex(emojiRegex()).optional(),
/** Boolean to denote if the doc should be published */
publish: z.boolean().optional(),
/** Create Doc under this collection */
/** Collection to create document within */
collectionId: z.string().uuid().nullish(),
/** Create Doc under this parent */
/** Parent document to create within */
parentDocumentId: z.string().uuid().nullish(),
/** Create doc with this template */
/** A template to create the document from */
templateId: z.string().uuid().optional(),
/** Boolean to denote if the doc should occupy full width */
/** Optionally set the created date in the past */
createdAt: z.coerce
.date()
.optional()
.refine((data) => !data || data < new Date(), {
message: "createdAt must be in the past",
}),
/** Boolean to denote if the document should occupy full width */
fullWidth: z.boolean().optional(),
/** Whether to create a template doc */
/** Whether this should be considered a template */
template: z.boolean().optional(),
}),
})