chore: merge main, resolve biome formatting conflicts

Merge origin/main into feat/document-file-conversion. Conflicts were
format-only (Tailwind class ordering, single-line vs multi-line) plus
two semantic merges:

- files.helpers.ts: combine main's pending-PDF download path with the
  branch's original-source-file (DOCX/PNG/JPEG) download path
- download-pdf.ts: combine main's versionToFilenameSuffix helper with
  the branch's server-provided Content-Disposition filename support
This commit is contained in:
ephraimduncan
2026-05-12 11:28:47 +00:00
1495 changed files with 22068 additions and 33465 deletions
+13 -1
View File
@@ -1,5 +1,13 @@
import { z } from 'zod';
/**
* A CSS length value: `0`, or a positive number followed by a length unit.
* Used for the radius field, which is interpolated raw into a `<style>`
* block at render time. Anything outside this shape is a CSS-injection
* vector — DO NOT loosen without re-checking `toNativeCssVars`.
*/
export const CSS_LENGTH_REGEX = /^(0|\d+(\.\d+)?(rem|px|em|%|pt|))$/i;
export const ZCssVarsSchema = z
.object({
background: z.string().optional().describe('Base background color'),
@@ -28,7 +36,11 @@ export const ZCssVarsSchema = z
destructive: z.string().optional().describe('Destructive/danger action color'),
destructiveForeground: z.string().optional().describe('Destructive/danger text color'),
ring: z.string().optional().describe('Focus ring color'),
radius: z.string().optional().describe('Border radius size in REM units'),
radius: z
.string()
.regex(CSS_LENGTH_REGEX, 'Must be a CSS length such as 0.5rem, 8px, or 0')
.optional()
.describe('Border radius — must be a CSS length (rem/px/em/%/pt or 0)'),
warning: z.string().optional().describe('Warning/alert color'),
envelopeEditorBackground: z.string().optional().describe('Envelope editor background color'),
})
+7 -31
View File
@@ -79,13 +79,7 @@ export const ZDocumentMetaDiffTypeSchema = z.enum([
]);
export const ZFieldDiffTypeSchema = z.enum(['DIMENSION', 'POSITION']);
export const ZRecipientDiffTypeSchema = z.enum([
'NAME',
'ROLE',
'EMAIL',
'ACCESS_AUTH',
'ACTION_AUTH',
]);
export const ZRecipientDiffTypeSchema = z.enum(['NAME', 'ROLE', 'EMAIL', 'ACCESS_AUTH', 'ACTION_AUTH']);
export const DOCUMENT_AUDIT_LOG_TYPE = ZDocumentAuditLogTypeSchema.Enum;
export const DOCUMENT_EMAIL_TYPE = ZDocumentAuditLogEmailTypeSchema.Enum;
@@ -139,10 +133,7 @@ export const ZDocumentAuditLogDocumentMetaSchema = z.union([
}),
]);
export const ZDocumentAuditLogFieldDiffSchema = z.union([
ZFieldDiffDimensionSchema,
ZFieldDiffPositionSchema,
]);
export const ZDocumentAuditLogFieldDiffSchema = z.union([ZFieldDiffDimensionSchema, ZFieldDiffPositionSchema]);
export const ZGenericFromToSchema = z.object({
from: z.union([z.string(), z.array(z.string())]).nullable(),
@@ -356,11 +347,7 @@ export const ZDocumentAuditLogEventDocumentFieldInsertedSchema = z.object({
});
// Replace legacy 'NONE' field security type with undefined.
if (
typeof input === 'object' &&
input !== null &&
JSON.stringify(input) === legacyNoneSecurityType
) {
if (typeof input === 'object' && input !== null && JSON.stringify(input) === legacyNoneSecurityType) {
return undefined;
}
@@ -460,11 +447,7 @@ export const ZDocumentAuditLogEventDocumentFieldPrefilledSchema = z.object({
});
// Replace legacy 'NONE' field security type with undefined.
if (
typeof input === 'object' &&
input !== null &&
JSON.stringify(input) === legacyNoneSecurityType
) {
if (typeof input === 'object' && input !== null && JSON.stringify(input) === legacyNoneSecurityType) {
return undefined;
}
@@ -795,17 +778,10 @@ export type TDocumentAuditLogType = z.infer<typeof ZDocumentAuditLogTypeSchema>;
export type TDocumentAuditLogFieldDiffSchema = z.infer<typeof ZDocumentAuditLogFieldDiffSchema>;
export type TDocumentAuditLogDocumentMetaDiffSchema = z.infer<
typeof ZDocumentAuditLogDocumentMetaSchema
>;
export type TDocumentAuditLogDocumentMetaDiffSchema = z.infer<typeof ZDocumentAuditLogDocumentMetaSchema>;
export type TDocumentAuditLogRecipientDiffSchema = z.infer<
typeof ZDocumentAuditLogRecipientDiffSchema
>;
export type TDocumentAuditLogRecipientDiffSchema = z.infer<typeof ZDocumentAuditLogRecipientDiffSchema>;
export type DocumentAuditLogByType<T = TDocumentAuditLog['type']> = Extract<
TDocumentAuditLog,
{ type: T }
>;
export type DocumentAuditLogByType<T = TDocumentAuditLog['type']> = Extract<TDocumentAuditLog, { type: T }>;
export type TDocumentAuditLogBaseSchema = z.infer<typeof ZDocumentAuditLogBaseSchema>;
+6 -21
View File
@@ -5,13 +5,7 @@ import { ZAuthenticationResponseJSONSchema } from './webauthn';
/**
* All the available types of document authentication options for both access and action.
*/
export const ZDocumentAuthTypesSchema = z.enum([
'ACCOUNT',
'PASSKEY',
'TWO_FACTOR_AUTH',
'PASSWORD',
'EXPLICIT_NONE',
]);
export const ZDocumentAuthTypesSchema = z.enum(['ACCOUNT', 'PASSKEY', 'TWO_FACTOR_AUTH', 'PASSWORD', 'EXPLICIT_NONE']);
export const DocumentAuth = ZDocumentAuthTypesSchema.Enum;
@@ -76,12 +70,7 @@ export const ZDocumentActionAuthSchema = z.discriminatedUnion('type', [
ZDocumentAuthPasswordSchema,
]);
export const ZDocumentActionAuthTypesSchema = z
.enum([
DocumentAuth.ACCOUNT,
DocumentAuth.PASSKEY,
DocumentAuth.TWO_FACTOR_AUTH,
DocumentAuth.PASSWORD,
])
.enum([DocumentAuth.ACCOUNT, DocumentAuth.PASSKEY, DocumentAuth.TWO_FACTOR_AUTH, DocumentAuth.PASSWORD])
.describe(
'The type of authentication required for the recipient to sign the document. This field is restricted to Enterprise plan users only.',
);
@@ -138,10 +127,8 @@ export const ZDocumentAuthOptionsSchema = z.preprocess(
};
}
const globalAccessAuth =
'globalAccessAuth' in unknownValue ? processAuthValue(unknownValue.globalAccessAuth) : [];
const globalActionAuth =
'globalActionAuth' in unknownValue ? processAuthValue(unknownValue.globalActionAuth) : [];
const globalAccessAuth = 'globalAccessAuth' in unknownValue ? processAuthValue(unknownValue.globalAccessAuth) : [];
const globalActionAuth = 'globalActionAuth' in unknownValue ? processAuthValue(unknownValue.globalActionAuth) : [];
return {
globalAccessAuth,
@@ -166,10 +153,8 @@ export const ZRecipientAuthOptionsSchema = z.preprocess(
};
}
const accessAuth =
'accessAuth' in unknownValue ? processAuthValue(unknownValue.accessAuth) : [];
const actionAuth =
'actionAuth' in unknownValue ? processAuthValue(unknownValue.actionAuth) : [];
const accessAuth = 'accessAuth' in unknownValue ? processAuthValue(unknownValue.accessAuth) : [];
const actionAuth = 'actionAuth' in unknownValue ? processAuthValue(unknownValue.actionAuth) : [];
return {
accessAuth,
+8 -25
View File
@@ -18,21 +18,15 @@ export const ZDocumentEmailSettingsSchema = z
.object({
recipientSigningRequest: z
.boolean()
.describe(
'Whether to send an email to all recipients that the document is ready for them to sign.',
)
.describe('Whether to send an email to all recipients that the document is ready for them to sign.')
.default(true),
recipientRemoved: z
.boolean()
.describe(
'Whether to send an email to the recipient who was removed from a pending document.',
)
.describe('Whether to send an email to the recipient who was removed from a pending document.')
.default(true),
recipientSigned: z
.boolean()
.describe(
'Whether to send an email to the document owner when a recipient has signed the document.',
)
.describe('Whether to send an email to the document owner when a recipient has signed the document.')
.default(true),
documentPending: z
.boolean()
@@ -46,9 +40,7 @@ export const ZDocumentEmailSettingsSchema = z
.default(true),
documentDeleted: z
.boolean()
.describe(
'Whether to send an email to all recipients if a pending document has been deleted.',
)
.describe('Whether to send an email to all recipients if a pending document has been deleted.')
.default(true),
ownerDocumentCompleted: z
.boolean()
@@ -56,15 +48,11 @@ export const ZDocumentEmailSettingsSchema = z
.default(true),
ownerRecipientExpired: z
.boolean()
.describe(
"Whether to send an email to the document owner when a recipient's signing window has expired.",
)
.describe("Whether to send an email to the document owner when a recipient's signing window has expired.")
.default(true),
ownerDocumentCreated: z
.boolean()
.describe(
'Whether to send an email to the document owner when a document is created from a direct template.',
)
.describe('Whether to send an email to the document owner when a document is created from a direct template.')
.default(true),
})
.strip()
@@ -72,15 +60,10 @@ export const ZDocumentEmailSettingsSchema = z
export type TDocumentEmailSettings = z.infer<typeof ZDocumentEmailSettingsSchema>;
export const extractDerivedDocumentEmailSettings = (
documentMeta?: DocumentMeta | null,
): TDocumentEmailSettings => {
export const extractDerivedDocumentEmailSettings = (documentMeta?: DocumentMeta | null): TDocumentEmailSettings => {
const emailSettings = ZDocumentEmailSettingsSchema.parse(documentMeta?.emailSettings ?? {});
if (
!documentMeta?.distributionMethod ||
documentMeta?.distributionMethod === DocumentDistributionMethod.EMAIL
) {
if (!documentMeta?.distributionMethod || documentMeta?.distributionMethod === DocumentDistributionMethod.EMAIL) {
return emailSettings;
}
+1 -4
View File
@@ -1,8 +1,5 @@
import { z } from 'zod';
export const ZDocumentFormValuesSchema = z.record(
z.string(),
z.union([z.string(), z.boolean(), z.number()]),
);
export const ZDocumentFormValuesSchema = z.record(z.string(), z.union([z.string(), z.boolean(), z.number()]));
export type TDocumentFormValues = z.infer<typeof ZDocumentFormValuesSchema>;
+5 -10
View File
@@ -1,7 +1,3 @@
import { msg } from '@lingui/core/macro';
import { DocumentDistributionMethod, DocumentSigningOrder } from '@prisma/client';
import { z } from 'zod';
import { VALID_DATE_FORMAT_VALUES } from '@documenso/lib/constants/date-formats';
import { ZEnvelopeExpirationPeriod } from '@documenso/lib/constants/envelope-expiration';
import { ZEnvelopeReminderSettings } from '@documenso/lib/constants/envelope-reminder';
@@ -9,6 +5,9 @@ import { SUPPORTED_LANGUAGE_CODES } from '@documenso/lib/constants/i18n';
import { isValidRedirectUrl } from '@documenso/lib/utils/is-valid-redirect-url';
import { zEmail } from '@documenso/lib/utils/zod';
import { DocumentMetaSchema } from '@documenso/prisma/generated/zod/modelSchema/DocumentMetaSchema';
import { msg } from '@lingui/core/macro';
import { DocumentDistributionMethod, DocumentSigningOrder } from '@prisma/client';
import { z } from 'zod';
import { ZDocumentEmailSettingsSchema } from './document-email';
@@ -48,9 +47,7 @@ export const ZDocumentSignatureSettingsSchema = z
})
.refine(
(data) => {
return (
data.typedSignatureEnabled || data.uploadSignatureEnabled || data.drawnSignatureEnabled
);
return data.typedSignatureEnabled || data.uploadSignatureEnabled || data.drawnSignatureEnabled;
},
{
message: msg`At least one signature type must be enabled`.id,
@@ -61,9 +58,7 @@ export type TDocumentSignatureSettings = z.infer<typeof ZDocumentSignatureSettin
export const ZDocumentMetaTimezoneSchema = z
.string()
.describe(
'The timezone to use for date fields and signing the document. Example Etc/UTC, Australia/Melbourne',
);
.describe('The timezone to use for date fields and signing the document. Example Etc/UTC, Australia/Melbourne');
export type TDocumentMetaTimezone = z.infer<typeof ZDocumentMetaTimezoneSchema>;
+4 -14
View File
@@ -1,5 +1,3 @@
import { z } from 'zod';
import { DocumentDataSchema } from '@documenso/prisma/generated/zod/modelSchema/DocumentDataSchema';
import { DocumentMetaSchema } from '@documenso/prisma/generated/zod/modelSchema/DocumentMetaSchema';
import EnvelopeItemSchema from '@documenso/prisma/generated/zod/modelSchema/EnvelopeItemSchema';
@@ -7,6 +5,7 @@ import { FolderSchema } from '@documenso/prisma/generated/zod/modelSchema/Folder
import { TeamSchema } from '@documenso/prisma/generated/zod/modelSchema/TeamSchema';
import { UserSchema } from '@documenso/prisma/generated/zod/modelSchema/UserSchema';
import { LegacyDocumentSchema } from '@documenso/prisma/types/document-legacy-schema';
import { z } from 'zod';
import { ZFieldSchema } from './field';
import { ZRecipientLiteSchema } from './recipient';
@@ -37,10 +36,7 @@ export const ZDocumentSchema = LegacyDocumentSchema.pick({
internalVersion: z.number(),
// Which "Template" the document was created from.
templateId: z
.number()
.nullish()
.describe('The ID of the template that the document was created from, if any.'),
templateId: z.number().nullish().describe('The ID of the template that the document was created from, if any.'),
// Backwards compatibility.
documentDataId: z.string().default(''),
@@ -129,10 +125,7 @@ export const ZDocumentLiteSchema = LegacyDocumentSchema.pick({
documentDataId: z.string().default(''),
// Which "Template" the document was created from.
templateId: z
.number()
.nullish()
.describe('The ID of the template that the document was created from, if any.'),
templateId: z.number().nullish().describe('The ID of the template that the document was created from, if any.'),
});
export type TDocumentLite = z.infer<typeof ZDocumentLiteSchema>;
@@ -165,10 +158,7 @@ export const ZDocumentManySchema = LegacyDocumentSchema.pick({
documentDataId: z.string().default(''),
// Which "Template" the document was created from.
templateId: z
.number()
.nullish()
.describe('The ID of the template that the document was created from, if any.'),
templateId: z.number().nullish().describe('The ID of the template that the document was created from, if any.'),
user: UserSchema.pick({
id: true,
+1 -2
View File
@@ -1,6 +1,5 @@
import type { z } from 'zod';
import { EmailDomainSchema } from '@documenso/prisma/generated/zod/modelSchema/EmailDomainSchema';
import type { z } from 'zod';
import { ZOrganisationEmailLiteSchema } from './organisation-email';
+1 -2
View File
@@ -1,6 +1,5 @@
import { z } from 'zod';
import { ZSupportedLanguageCodeSchema } from '@documenso/lib/constants/locales';
import { z } from 'zod';
import { ZCssVarsSchema } from './css-vars';
+18 -3
View File
@@ -1,6 +1,3 @@
import { EnvelopeType } from '@prisma/client';
import { z } from 'zod';
import { ZBaseEmbedDataSchema } from '@documenso/lib/types/embed-base-schemas';
import { ZEnvelopeFieldSchema } from '@documenso/lib/types/field';
import { ZEnvelopeRecipientLiteSchema } from '@documenso/lib/types/recipient';
@@ -10,6 +7,8 @@ import { EnvelopeItemSchema } from '@documenso/prisma/generated/zod/modelSchema/
import { EnvelopeSchema } from '@documenso/prisma/generated/zod/modelSchema/EnvelopeSchema';
import { TeamSchema } from '@documenso/prisma/generated/zod/modelSchema/TeamSchema';
import { TemplateDirectLinkSchema } from '@documenso/prisma/generated/zod/modelSchema/TemplateDirectLinkSchema';
import { EnvelopeType } from '@prisma/client';
import { z } from 'zod';
/**
* DO NOT MAKE ANY BREAKING BACKWARD CHANGES HERE UNLESS YOU'RE SURE
@@ -220,11 +219,23 @@ export const ZEmbedCreateEnvelopeAuthoringSchema = ZBaseEmbedDataSchema.extend({
externalId: z.string().optional(),
type: z.nativeEnum(EnvelopeType),
folderId: z.string().optional(),
user: z
.object({
email: z.string().email().optional(),
name: z.string().optional(),
})
.optional(),
features: z.object({}).passthrough().optional().default(DEFAULT_EMBEDDED_EDITOR_CONFIG),
});
export const ZEmbedEditEnvelopeAuthoringSchema = ZBaseEmbedDataSchema.extend({
externalId: z.string().optional(),
user: z
.object({
email: z.string().email().optional(),
name: z.string().optional(),
})
.optional(),
features: z.object({}).passthrough().optional().default(DEFAULT_EMBEDDED_EDITOR_CONFIG),
});
@@ -323,5 +334,9 @@ export type EnvelopeEditorConfig = TEnvelopeEditorSettings & {
onCreate?: (envelope: Omit<TEditorEnvelope, 'id'>) => void;
onUpdate?: (envelope: TEditorEnvelope) => void;
customBrandingLogo?: boolean;
user?: {
email?: string;
name?: string;
};
};
};
+1 -2
View File
@@ -1,10 +1,9 @@
import { z } from 'zod';
import { DocumentMetaSchema } from '@documenso/prisma/generated/zod/modelSchema/DocumentMetaSchema';
import { EnvelopeItemSchema } from '@documenso/prisma/generated/zod/modelSchema/EnvelopeItemSchema';
import { EnvelopeSchema } from '@documenso/prisma/generated/zod/modelSchema/EnvelopeSchema';
import { TeamSchema } from '@documenso/prisma/generated/zod/modelSchema/TeamSchema';
import TemplateDirectLinkSchema from '@documenso/prisma/generated/zod/modelSchema/TemplateDirectLinkSchema';
import { z } from 'zod';
import { ZEnvelopeFieldSchema } from './field';
import { ZEnvelopeRecipientLiteSchema } from './recipient';
+35 -7
View File
@@ -16,6 +16,32 @@ export const FIELD_MAX_LETTER_SPACING = 100;
export const DEFAULT_FIELD_FONT_SIZE = 12;
export const DEFAULT_SIGNATURE_OVERFLOW_MODE = 'auto';
export const DEFAULT_DATE_OVERFLOW_MODE = 'auto';
export const DEFAULT_EMAIL_OVERFLOW_MODE = 'auto';
/**
* The overflow mode for a field.
*
* - 'auto': Will overflow horizontally if no room to wrap vertically.
* - 'horizontal': Overflow horizontally, will not wrap at all.
* - 'vertical': Overflow vertically, will wrap at the field width.
* - 'crop': Crop the text to the field bounds, will not overflow at all.
*
* @default 'crop'
*/
export const ZFieldOverflowMode = z.enum(['auto', 'horizontal', 'vertical', 'crop']);
export type TFieldOverflowMode = z.infer<typeof ZFieldOverflowMode>;
/**
* Resolves the overflow mode for a field.
*
* Returns 'crop' when undefined (the default for most fields).
*/
export const resolveFieldOverflowMode = (fieldMeta?: { overflow?: TFieldOverflowMode } | null): TFieldOverflowMode => {
return fieldMeta?.overflow ?? 'crop';
};
/**
* Grouped field types that use the same generic text rendering function.
*/
@@ -37,9 +63,7 @@ const ZFieldMetaLetterSpacing = z.coerce
.min(FIELD_MIN_LETTER_SPACING)
.max(FIELD_MAX_LETTER_SPACING)
.describe('The spacing between each character');
const ZFieldMetaVerticalAlign = z
.enum(['top', 'middle', 'bottom'])
.describe('The vertical alignment of the text');
const ZFieldMetaVerticalAlign = z.enum(['top', 'middle', 'bottom']).describe('The vertical alignment of the text');
export const ZBaseFieldMeta = z.object({
label: z.string().optional(),
@@ -47,6 +71,7 @@ export const ZBaseFieldMeta = z.object({
required: z.boolean().optional(),
readOnly: z.boolean().optional(),
fontSize: z.number().min(8).max(96).default(DEFAULT_FIELD_FONT_SIZE).optional(),
overflow: ZFieldOverflowMode.optional(),
});
export type TBaseFieldMeta = z.infer<typeof ZBaseFieldMeta>;
@@ -72,6 +97,7 @@ export type TNameFieldMeta = z.infer<typeof ZNameFieldMeta>;
export const ZEmailFieldMeta = ZBaseFieldMeta.extend({
type: z.literal('email'),
textAlign: ZFieldTextAlignSchema.optional(),
overflow: ZFieldOverflowMode.optional().default(DEFAULT_EMAIL_OVERFLOW_MODE),
});
export type TEmailFieldMeta = z.infer<typeof ZEmailFieldMeta>;
@@ -79,6 +105,7 @@ export type TEmailFieldMeta = z.infer<typeof ZEmailFieldMeta>;
export const ZDateFieldMeta = ZBaseFieldMeta.extend({
type: z.literal('date'),
textAlign: ZFieldTextAlignSchema.optional(),
overflow: ZFieldOverflowMode.optional().default(DEFAULT_DATE_OVERFLOW_MODE),
});
export type TDateFieldMeta = z.infer<typeof ZDateFieldMeta>;
@@ -86,10 +113,7 @@ export type TDateFieldMeta = z.infer<typeof ZDateFieldMeta>;
export const ZTextFieldMeta = ZBaseFieldMeta.extend({
type: z.literal('text'),
text: z.string().optional(),
characterLimit: z.coerce
.number({ invalid_type_error: 'Value must be a number' })
.min(0)
.optional(),
characterLimit: z.coerce.number({ invalid_type_error: 'Value must be a number' }).min(0).optional(),
textAlign: ZFieldTextAlignSchema.optional(),
lineHeight: ZFieldMetaLineHeight.nullish(),
letterSpacing: ZFieldMetaLetterSpacing.nullish(),
@@ -156,6 +180,7 @@ export type TDropdownFieldMeta = z.infer<typeof ZDropdownFieldMeta>;
export const ZSignatureFieldMeta = ZBaseFieldMeta.extend({
type: z.literal('signature'),
overflow: ZFieldOverflowMode.optional().default(DEFAULT_SIGNATURE_OVERFLOW_MODE),
});
export type TSignatureFieldMeta = z.infer<typeof ZSignatureFieldMeta>;
@@ -283,6 +308,7 @@ export const FIELD_DATE_META_DEFAULT_VALUES: TDateFieldMeta = {
type: 'date',
fontSize: DEFAULT_FIELD_FONT_SIZE,
textAlign: 'left',
overflow: DEFAULT_DATE_OVERFLOW_MODE,
};
export const FIELD_TEXT_META_DEFAULT_VALUES: TTextFieldMeta = {
@@ -322,6 +348,7 @@ export const FIELD_EMAIL_META_DEFAULT_VALUES: TEmailFieldMeta = {
type: 'email',
fontSize: DEFAULT_FIELD_FONT_SIZE,
textAlign: 'left',
overflow: DEFAULT_EMAIL_OVERFLOW_MODE,
};
export const FIELD_RADIO_META_DEFAULT_VALUES: TRadioFieldMeta = {
@@ -356,6 +383,7 @@ export const FIELD_DROPDOWN_META_DEFAULT_VALUES: TDropdownFieldMeta = {
export const FIELD_SIGNATURE_META_DEFAULT_VALUES: TSignatureFieldMeta = {
type: 'signature',
fontSize: DEFAULT_SIGNATURE_TEXT_FONT_SIZE,
overflow: DEFAULT_SIGNATURE_OVERFLOW_MODE,
};
export const FIELD_META_DEFAULT_VALUES: Record<FieldType, TFieldMetaSchema> = {
+4 -14
View File
@@ -1,8 +1,7 @@
import { FieldSchema } from '@documenso/prisma/generated/zod/modelSchema/FieldSchema';
import { FieldType, Prisma } from '@prisma/client';
import { z } from 'zod';
import { FieldSchema } from '@documenso/prisma/generated/zod/modelSchema/FieldSchema';
import {
FIELD_SIGNATURE_META_DEFAULT_VALUES,
ZCheckboxFieldMeta,
@@ -55,20 +54,11 @@ export const ZEnvelopeFieldSchema = ZFieldSchema.omit({
templateId: true,
});
export const ZFieldPageNumberSchema = z
.number()
.min(1)
.describe('The page number the field will be on.');
export const ZFieldPageNumberSchema = z.number().min(1).describe('The page number the field will be on.');
export const ZFieldPageXSchema = z
.number()
.min(0)
.describe('The X coordinate of where the field will be placed.');
export const ZFieldPageXSchema = z.number().min(0).describe('The X coordinate of where the field will be placed.');
export const ZFieldPageYSchema = z
.number()
.min(0)
.describe('The Y coordinate of where the field will be placed.');
export const ZFieldPageYSchema = z.number().min(0).describe('The Y coordinate of where the field will be placed.');
export const ZFieldWidthSchema = z.number().min(1).describe('The width of the field.');
+1 -2
View File
@@ -1,8 +1,7 @@
import { OrganisationEmailSchema } from '@documenso/prisma/generated/zod/modelSchema/OrganisationEmailSchema';
import { EmailDomainStatus } from '@prisma/client';
import { z } from 'zod';
import { OrganisationEmailSchema } from '@documenso/prisma/generated/zod/modelSchema/OrganisationEmailSchema';
export const ZOrganisationEmailSchema = OrganisationEmailSchema.pick({
id: true,
createdAt: true,
+2 -5
View File
@@ -1,7 +1,6 @@
import { z } from 'zod';
import OrganisationClaimSchema from '@documenso/prisma/generated/zod/modelSchema/OrganisationClaimSchema';
import { OrganisationSchema } from '@documenso/prisma/generated/zod/modelSchema/OrganisationSchema';
import { z } from 'zod';
export const ZOrganisationSchema = OrganisationSchema.pick({
id: true,
@@ -56,6 +55,4 @@ export const ZOrganisationAccountLinkMetadataSchema = z.object({
}),
});
export type TOrganisationAccountLinkMetadata = z.infer<
typeof ZOrganisationAccountLinkMetadataSchema
>;
export type TOrganisationAccountLinkMetadata = z.infer<typeof ZOrganisationAccountLinkMetadataSchema>;
+2 -6
View File
@@ -1,8 +1,7 @@
import { z } from 'zod';
import { RecipientSchema } from '@documenso/prisma/generated/zod/modelSchema/RecipientSchema';
import { TeamSchema } from '@documenso/prisma/generated/zod/modelSchema/TeamSchema';
import { UserSchema } from '@documenso/prisma/generated/zod/modelSchema/UserSchema';
import { z } from 'zod';
import { zEmail } from '../utils/zod';
import { ZFieldSchema } from './field';
@@ -125,7 +124,4 @@ export type TEnvelopeRecipientSchema = z.infer<typeof ZEnvelopeRecipientSchema>;
export type TEnvelopeRecipientLite = z.infer<typeof ZEnvelopeRecipientLiteSchema>;
export type TEnvelopeRecipientMany = z.infer<typeof ZEnvelopeRecipientManySchema>;
export const ZRecipientEmailSchema = z.union([
z.literal(''),
zEmail('Invalid email').trim().toLowerCase().max(254),
]);
export const ZRecipientEmailSchema = z.union([z.literal(''), zEmail('Invalid email').trim().toLowerCase().max(254)]);
+13 -5
View File
@@ -1,8 +1,7 @@
import { ZOrganisationNameSchema } from '@documenso/trpc/server/organisation-router/create-organisation.types';
import type { SubscriptionClaim } from '@prisma/client';
import { z } from 'zod';
import { ZOrganisationNameSchema } from '@documenso/trpc/server/organisation-router/create-organisation.types';
/**
* README:
* - If you update this you MUST update the `backport-subscription-claims` schema as well.
@@ -34,6 +33,8 @@ export const ZClaimFlagsSchema = z.object({
authenticationPortal: z.boolean().optional(),
allowLegacyEnvelopes: z.boolean().optional(),
signingReminders: z.boolean().optional(),
});
export type TClaimFlags = z.infer<typeof ZClaimFlagsSchema>;
@@ -101,6 +102,10 @@ export const SUBSCRIPTION_CLAIM_FEATURE_FLAGS: Record<
key: 'allowLegacyEnvelopes',
label: 'Allow Legacy Envelopes',
},
signingReminders: {
key: 'signingReminders',
label: 'Signing reminders',
},
};
export enum INTERNAL_CLAIM_ID {
@@ -137,6 +142,7 @@ export const internalClaims: InternalClaims = {
locked: true,
flags: {
unlimitedDocuments: true,
signingReminders: true,
},
},
[INTERNAL_CLAIM_ID.TEAM]: {
@@ -150,6 +156,7 @@ export const internalClaims: InternalClaims = {
unlimitedDocuments: true,
allowCustomBranding: true,
embedSigning: true,
signingReminders: true,
},
},
[INTERNAL_CLAIM_ID.PLATFORM]: {
@@ -168,6 +175,7 @@ export const internalClaims: InternalClaims = {
embedAuthoringWhiteLabel: true,
embedSigning: false,
embedSigningWhiteLabel: true,
signingReminders: true,
},
},
[INTERNAL_CLAIM_ID.ENTERPRISE]: {
@@ -188,6 +196,7 @@ export const internalClaims: InternalClaims = {
embedSigningWhiteLabel: true,
cfr21: true,
authenticationPortal: true,
signingReminders: true,
},
},
[INTERNAL_CLAIM_ID.EARLY_ADOPTER]: {
@@ -203,6 +212,7 @@ export const internalClaims: InternalClaims = {
hidePoweredBy: true,
embedSigning: true,
embedSigningWhiteLabel: true,
signingReminders: true,
},
},
} as const;
@@ -212,6 +222,4 @@ export const ZStripeOrganisationCreateMetadataSchema = z.object({
userId: z.number(),
});
export type StripeOrganisationCreateMetadata = z.infer<
typeof ZStripeOrganisationCreateMetadataSchema
>;
export type StripeOrganisationCreateMetadata = z.infer<typeof ZStripeOrganisationCreateMetadataSchema>;
+2 -6
View File
@@ -1,15 +1,11 @@
import { z } from 'zod';
import { DocumentDataSchema } from '@documenso/prisma/generated/zod/modelSchema/DocumentDataSchema';
import { DocumentMetaSchema } from '@documenso/prisma/generated/zod/modelSchema/DocumentMetaSchema';
import EnvelopeItemSchema from '@documenso/prisma/generated/zod/modelSchema/EnvelopeItemSchema';
import { FolderSchema } from '@documenso/prisma/generated/zod/modelSchema/FolderSchema';
import TeamSchema from '@documenso/prisma/generated/zod/modelSchema/TeamSchema';
import { UserSchema } from '@documenso/prisma/generated/zod/modelSchema/UserSchema';
import {
LegacyTemplateDirectLinkSchema,
TemplateSchema,
} from '@documenso/prisma/types/template-legacy-schema';
import { LegacyTemplateDirectLinkSchema, TemplateSchema } from '@documenso/prisma/types/template-legacy-schema';
import { z } from 'zod';
import { ZFieldSchema } from './field';
import { ZRecipientLiteSchema } from './recipient';
+22 -16
View File
@@ -1,4 +1,4 @@
import type { DocumentMeta, Envelope, Recipient, WebhookTriggerEvents } from '@prisma/client';
import type { DocumentMeta, Envelope, Recipient } from '@prisma/client';
import {
DocumentDistributionMethod,
DocumentSigningOrder,
@@ -10,6 +10,7 @@ import {
RecipientRole,
SendStatus,
SigningStatus,
WebhookTriggerEvents,
} from '@prisma/client';
import { z } from 'zod';
@@ -25,10 +26,10 @@ export const ZWebhookRecipientSchema = z.object({
email: z.string(),
name: z.string(),
token: z.string(),
documentDeletedAt: z.date().nullable(),
expiresAt: z.date().nullable(),
expirationNotifiedAt: z.date().nullable(),
signedAt: z.date().nullable(),
documentDeletedAt: z.coerce.date().nullable(),
expiresAt: z.coerce.date().nullable(),
expirationNotifiedAt: z.coerce.date().nullable(),
signedAt: z.coerce.date().nullable(),
authOptions: z.any().nullable(),
signingOrder: z.number().nullable(),
rejectionReason: z.string().nullable(),
@@ -70,10 +71,10 @@ export const ZWebhookDocumentSchema = z.object({
visibility: z.nativeEnum(DocumentVisibility),
title: z.string(),
status: z.nativeEnum(DocumentStatus),
createdAt: z.date(),
updatedAt: z.date(),
completedAt: z.date().nullable(),
deletedAt: z.date().nullable(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
completedAt: z.coerce.date().nullable(),
deletedAt: z.coerce.date().nullable(),
teamId: z.number().nullable(),
templateId: z.number().nullable(),
source: z.nativeEnum(DocumentSource),
@@ -86,15 +87,20 @@ export const ZWebhookDocumentSchema = z.object({
Recipient: z.array(ZWebhookRecipientSchema),
});
/**
* Schema for the full webhook delivery envelope (what receivers see on the wire
* and what is persisted to `WebhookCall.requestBody`).
*/
export const ZWebhookPayloadSchema = z.object({
event: z.nativeEnum(WebhookTriggerEvents),
payload: ZWebhookDocumentSchema,
createdAt: z.string(),
webhookEndpoint: z.string(),
});
export type TWebhookRecipient = z.infer<typeof ZWebhookRecipientSchema>;
export type TWebhookDocument = z.infer<typeof ZWebhookDocumentSchema>;
export type WebhookPayload = {
event: WebhookTriggerEvents;
payload: TWebhookDocument;
createdAt: string;
webhookEndpoint: string;
};
export type WebhookPayload = z.infer<typeof ZWebhookPayloadSchema>;
export const mapEnvelopeToWebhookDocumentPayload = (
envelope: Envelope & {