diff --git a/scripts/lib/preprocess.mjs b/scripts/lib/preprocess.mjs index ef6f41f..45e9847 100644 --- a/scripts/lib/preprocess.mjs +++ b/scripts/lib/preprocess.mjs @@ -346,7 +346,7 @@ export function relaxResponseEnumsInSpec(spec) { if (/^[a-z]/.test(name)) return false; if (/(Request|Params)$/.test(name)) return false; return ( - /(Dto|Response)$/.test(name) || + /(Dto|Response|DisplayConfig)$/.test(name) || /^(SingleValueResponse|TableValueResult|CursorPage)/.test(name) ); } @@ -447,10 +447,12 @@ export function relaxResponseStrict(source) { const strictRe = /\.strict\(\)/g; function isResponseShape(name) { + // Nested response-only metadata (*DisplayConfig) must be tolerant too — + // parent *Dto `.passthrough()` does not relax nested `.strict()` objects. if (/^[a-z]/.test(name)) return false; if (/(Request|Params)$/.test(name)) return false; return ( - /(Dto|Response)$/.test(name) || + /(Dto|Response|DisplayConfig)$/.test(name) || /^(SingleValueResponse|TableValueResult|CursorPage)/.test(name) ); } diff --git a/src/lib/api-zod.generated.ts b/src/lib/api-zod.generated.ts index 53163f9..cbd263a 100644 --- a/src/lib/api-zod.generated.ts +++ b/src/lib/api-zod.generated.ts @@ -1445,7 +1445,7 @@ const AlertChannelDisplayConfig = z projectKey: z.string().nullable(), }) .partial() - .strict(); + .passthrough(); const AlertChannelDto = z .object({ id: z.string().uuid(), diff --git a/test/lib/display-config-passthrough.test.ts b/test/lib/display-config-passthrough.test.ts new file mode 100644 index 0000000..c79f956 --- /dev/null +++ b/test/lib/display-config-passthrough.test.ts @@ -0,0 +1,19 @@ +import {describe, expect, it} from 'vitest' +import {schemas} from '../../src/lib/api-zod.generated.js' + +describe('AlertChannelDisplayConfig Postel tolerance', () => { + it('accepts additive SMS/phone keys unknown to this CLI pin', () => { + const parsed = schemas.AlertChannelDisplayConfig.parse({ + recipients: ['ops@example.com'], + phoneNumber: '+14155550123', + verifiedPhoneNumberId: 7, + phoneNumbers: ['+14155550123'], + voiceLanguage: 'en-US', + preferredLanguage: 'de-DE', + futureCarrierField: 'kept', + }) + expect(parsed.recipients).toEqual(['ops@example.com']) + expect((parsed as {phoneNumber?: string}).phoneNumber).toBe('+14155550123') + expect((parsed as {futureCarrierField?: string}).futureCarrierField).toBe('kept') + }) +})