Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/lib/preprocess.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
Expand Down Expand Up @@ -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)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api-zod.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ const AlertChannelDisplayConfig = z
projectKey: z.string().nullable(),
})
.partial()
.strict();
.passthrough();
const AlertChannelDto = z
.object({
id: z.string().uuid(),
Expand Down
19 changes: 19 additions & 0 deletions test/lib/display-config-passthrough.test.ts
Original file line number Diff line number Diff line change
@@ -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')
})
})
Loading