( record: Record<string, unknown>, allowedKeys: readonly string[], label: string, )
| 507 | } |
| 508 | |
| 509 | export function assertAllowedKeys( |
| 510 | record: Record<string, unknown>, |
| 511 | allowedKeys: readonly string[], |
| 512 | label: string, |
| 513 | ): void { |
| 514 | const allowed = new Set(allowedKeys); |
| 515 | const unknownKeys = Object.keys(record).filter((key) => !allowed.has(key)); |
| 516 | if (unknownKeys.length > 0) { |
| 517 | throw new Error(`${label} has unknown field(s): ${unknownKeys.join(', ')}.`); |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | export function compactRecord(record: Record<string, unknown>): Record<string, unknown> { |
| 522 | return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)); |
no outgoing calls
no test coverage detected
searching dependent graphs…