fix: additional backwards compat

This commit is contained in:
David Nguyen
2025-10-14 15:19:09 +11:00
parent bddaa5ec66
commit 0eef4cd7e6
32 changed files with 288 additions and 92 deletions

View File

@ -40,6 +40,9 @@ export const ZDocumentSchema = LegacyDocumentSchema.pick({
.nullish()
.describe('The ID of the template that the document was created from, if any.'),
// Backwards compatibility.
documentDataId: z.string().default(''),
// Todo: Maybe we want to alter this a bit since this returns a lot of data.
documentData: DocumentDataSchema.pick({
type: true,
@ -66,7 +69,11 @@ export const ZDocumentSchema = LegacyDocumentSchema.pick({
emailSettings: true,
emailId: true,
emailReplyTo: true,
}).nullable(),
}).extend({
password: z.string().nullable().default(null),
documentId: z.number().default(-1).optional(),
}),
folder: FolderSchema.pick({
id: true,
name: true,
@ -108,6 +115,9 @@ export const ZDocumentLiteSchema = LegacyDocumentSchema.pick({
}).extend({
envelopeId: z.string(),
// Backwards compatibility.
documentDataId: z.string().default(''),
// Which "Template" the document was created from.
templateId: z
.number()
@ -140,6 +150,9 @@ export const ZDocumentManySchema = LegacyDocumentSchema.pick({
}).extend({
envelopeId: z.string(),
// Backwards compatibility.
documentDataId: z.string().default(''),
// Which "Template" the document was created from.
templateId: z
.number()

View File

@ -35,6 +35,9 @@ export const ZTemplateSchema = TemplateSchema.pick({
}).extend({
envelopeId: z.string(),
// Backwards compatibility.
templateDocumentDataId: z.string().default(''),
// Todo: Maybe we want to alter this a bit since this returns a lot of data.
templateDocumentData: DocumentDataSchema.pick({
type: true,
@ -61,6 +64,8 @@ export const ZTemplateSchema = TemplateSchema.pick({
emailSettings: true,
emailId: true,
emailReplyTo: true,
}).extend({
templateId: z.number().nullable(),
}),
directLink: LegacyTemplateDirectLinkSchema.nullable(),
user: UserSchema.pick({
@ -106,6 +111,9 @@ export const ZTemplateLiteSchema = TemplateSchema.pick({
useLegacyFieldInsertion: true,
}).extend({
envelopeId: z.string(),
// Backwards compatibility.
templateDocumentDataId: z.string().default(''),
});
export type TTemplateLite = z.infer<typeof ZTemplateLiteSchema>;
@ -144,6 +152,8 @@ export const ZTemplateManySchema = TemplateSchema.pick({
token: true,
enabled: true,
}).nullable(),
// Backwards compatibility.
templateDocumentDataId: z.string().default(''),
});
export type TTemplateMany = z.infer<typeof ZTemplateManySchema>;