mirror of
https://github.com/documenso/documenso.git
synced 2025-11-17 10:11:35 +10:00
Merge branch 'main' into feat/bin-tab
This commit is contained in:
53
packages/lib/types/document-meta.ts
Normal file
53
packages/lib/types/document-meta.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { DocumentMetaSchema } from '@documenso/prisma/generated/zod/modelSchema/DocumentMetaSchema';
|
||||
|
||||
/**
|
||||
* The full document response schema.
|
||||
*
|
||||
* Mainly used for returning a single document from the API.
|
||||
*/
|
||||
export const ZDocumentMetaSchema = DocumentMetaSchema.pick({
|
||||
signingOrder: true,
|
||||
distributionMethod: true,
|
||||
id: true,
|
||||
subject: true,
|
||||
message: true,
|
||||
timezone: true,
|
||||
password: true,
|
||||
dateFormat: true,
|
||||
documentId: true,
|
||||
redirectUrl: true,
|
||||
typedSignatureEnabled: true,
|
||||
uploadSignatureEnabled: true,
|
||||
drawSignatureEnabled: true,
|
||||
language: true,
|
||||
emailSettings: true,
|
||||
});
|
||||
|
||||
export type TDocumentMeta = z.infer<typeof ZDocumentMetaSchema>;
|
||||
|
||||
/**
|
||||
* If you update this, you must also update the schema.prisma @default value for
|
||||
* - Template meta
|
||||
* - Document meta
|
||||
*/
|
||||
export const ZDocumentSignatureSettingsSchema = z
|
||||
.object({
|
||||
typedSignatureEnabled: z.boolean(),
|
||||
uploadSignatureEnabled: z.boolean(),
|
||||
drawnSignatureEnabled: z.boolean(),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
return (
|
||||
data.typedSignatureEnabled || data.uploadSignatureEnabled || data.drawnSignatureEnabled
|
||||
);
|
||||
},
|
||||
{
|
||||
message: msg`At least one signature type must be enabled`.id,
|
||||
},
|
||||
);
|
||||
|
||||
export type TDocumentSignatureSettings = z.infer<typeof ZDocumentSignatureSettingsSchema>;
|
||||
@ -51,6 +51,9 @@ export const ZDocumentSchema = DocumentSchema.pick({
|
||||
documentId: true,
|
||||
redirectUrl: true,
|
||||
typedSignatureEnabled: true,
|
||||
uploadSignatureEnabled: true,
|
||||
drawSignatureEnabled: true,
|
||||
allowDictateNextSigner: true,
|
||||
language: true,
|
||||
emailSettings: true,
|
||||
}).nullable(),
|
||||
|
||||
@ -45,6 +45,9 @@ export const ZTemplateSchema = TemplateSchema.pick({
|
||||
dateFormat: true,
|
||||
signingOrder: true,
|
||||
typedSignatureEnabled: true,
|
||||
uploadSignatureEnabled: true,
|
||||
drawSignatureEnabled: true,
|
||||
allowDictateNextSigner: true,
|
||||
distributionMethod: true,
|
||||
templateId: true,
|
||||
redirectUrl: true,
|
||||
|
||||
@ -46,7 +46,10 @@ export const ZWebhookDocumentMetaSchema = z.object({
|
||||
dateFormat: z.string(),
|
||||
redirectUrl: z.string().nullable(),
|
||||
signingOrder: z.nativeEnum(DocumentSigningOrder),
|
||||
allowDictateNextSigner: z.boolean(),
|
||||
typedSignatureEnabled: z.boolean(),
|
||||
uploadSignatureEnabled: z.boolean(),
|
||||
drawSignatureEnabled: z.boolean(),
|
||||
language: z.string(),
|
||||
distributionMethod: z.nativeEnum(DocumentDistributionMethod),
|
||||
emailSettings: z.any().nullable(),
|
||||
|
||||
Reference in New Issue
Block a user