Skip to content

The Open Source DocuSign Alternative.

fix: document audit log field security migration (#1081)

David Nguyen8fe6533ef580
diff --git a/packages/lib/types/document-audit-logs.ts b/packages/lib/types/document-audit-logs.ts
index 4b37aa485..cfdedd462 100644
--- a/packages/lib/types/document-audit-logs.ts
+++ b/packages/lib/types/document-audit-logs.ts
@@ -236,11 +236,29 @@ export const ZDocumentAuditLogEventDocumentFieldInsertedSchema = z.object({
data: z.string(),
}),
]),
- fieldSecurity: z
- .object({
- type: ZRecipientActionAuthTypesSchema,
- })
- .optional(),
+ fieldSecurity: z.preprocess(
+ (input) => {
+ const legacyNoneSecurityType = JSON.stringify({
+ type: 'NONE',
+ });
+
+ // Replace legacy 'NONE' field security type with undefined.
+ if (
+ typeof input === 'object' &&
+ input !== null &&
+ JSON.stringify(input) === legacyNoneSecurityType
+ ) {
+ return undefined;
+ }
+
+ return input;
+ },
+ z
+ .object({
+ type: ZRecipientActionAuthTypesSchema,
+ })
+ .optional(),
+ ),
}),
});