This commit is contained in:
David Nguyen
2025-08-22 22:30:02 +10:00
parent e7e2aa9bd8
commit e1464ac2d3
17 changed files with 787 additions and 258 deletions

View File

@ -0,0 +1,59 @@
/**
* Legacy Document schema to confirm backwards API compatibility since
* we migrated Documents to Envelopes.
*/
import { z } from 'zod';
import { ZDocumentAuthOptionsSchema } from '@documenso/lib/types/document-auth';
import { ZDocumentFormValuesSchema } from '@documenso/lib/types/document-form-values';
import DocumentStatusSchema from '../generated/zod/inputTypeSchemas/DocumentStatusSchema';
import DocumentVisibilitySchema from '../generated/zod/inputTypeSchemas/DocumentVisibilitySchema';
const DocumentSourceSchema = z.enum(['DOCUMENT', 'TEMPLATE', 'TEMPLATE_DIRECT_LINK']);
const DocumentTypeSchema = z.enum(['DOCUMENT', 'PUBLIC_TEMPLATE', 'PRIVATE_TEMPLATE']);
/////////////////////////////////////////
// DOCUMENT SCHEMA
/////////////////////////////////////////
export const LegacyDocumentSchema = z.object({
type: DocumentTypeSchema,
visibility: DocumentVisibilitySchema,
status: DocumentStatusSchema,
source: DocumentSourceSchema,
id: z.number(),
qrToken: z
.string()
.describe('The token for viewing the document using the QR code on the certificate.')
.nullable(),
externalId: z
.string()
.describe('A custom external ID you can use to identify the document.')
.nullable(),
secondaryDocumentId: z.number(),
secondaryTemplateId: z.number(),
publicTitle: z.string(),
publicDescription: z.string(),
createdFromDocumentId: z.number().nullable(),
userId: z.number().describe('The ID of the user that created this document.'),
teamId: z.number(),
/**
* [DocumentAuthOptions]
*/
authOptions: ZDocumentAuthOptionsSchema.nullable(),
/**
* [DocumentFormValues]
*/
formValues: ZDocumentFormValuesSchema.nullable(),
title: z.string(),
documentDataId: z.string(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
completedAt: z.coerce.date().nullable(),
deletedAt: z.coerce.date().nullable(),
useLegacyFieldInsertion: z.boolean(),
folderId: z.string().nullable(),
});
export type Document = z.infer<typeof LegacyDocumentSchema>;

View File

@ -0,0 +1,36 @@
/**
* Legacy Template schema to confirm backwards API compatibility since
* we removed the "Template" prisma schema model.
*/
import { z } from 'zod';
import { ZDocumentAuthOptionsSchema } from '@documenso/lib/types/document-auth';
import { DocumentVisibilitySchema } from '../generated/zod/inputTypeSchemas/DocumentVisibilitySchema';
export const TemplateTypeSchema = z.enum(['PUBLIC', 'PRIVATE']);
export type TemplateTypeType = `${z.infer<typeof TemplateTypeSchema>}`;
export const TemplateSchema = z.object({
type: TemplateTypeSchema,
visibility: DocumentVisibilitySchema,
id: z.number(),
externalId: z.string().nullable(),
title: z.string(),
/**
* [DocumentAuthOptions]
*/
authOptions: ZDocumentAuthOptionsSchema.nullable(),
templateDocumentDataId: z.string(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
publicTitle: z.string(),
publicDescription: z.string(),
useLegacyFieldInsertion: z.boolean(),
userId: z.number(),
teamId: z.number(),
folderId: z.string().nullable(),
});
export type Template = z.infer<typeof TemplateSchema>;