feat: add versioned all-available source export catalog

This commit is contained in:
Aleksandr Meshchryakov
2026-10-22 21:30:18 +02:00
parent 1ffdcd0aaf
commit 63872e86fe
28 changed files with 5754 additions and 240 deletions

View File

@@ -0,0 +1,26 @@
/** Validate actual new-scope responses using the generated client validators. */
import { readFileSync } from 'node:fs';
import { isDeepStrictEqual } from 'node:util';
import {
V2OrganizationSourceRecordsExportCatalogList200Response,
V2OrganizationSourceRecordsExportCatalogRead200Response,
V2OrganizationSourceRecordsExportTicket201Response,
V2OrganizationSourceRecordsExportCatalogList400Response,
} from './generated-zod/contract.ts';
const validators = {
catalog: V2OrganizationSourceRecordsExportCatalogList200Response,
detail: V2OrganizationSourceRecordsExportCatalogRead200Response,
'file-ticket': V2OrganizationSourceRecordsExportTicket201Response,
'archive-ticket': V2OrganizationSourceRecordsExportTicket201Response,
invalid: V2OrganizationSourceRecordsExportCatalogList400Response,
};
const cases = JSON.parse(readFileSync(process.argv[2], 'utf8'));
const seen = new Set();
for (const fixture of cases) {
if (seen.has(fixture.name) || !validators[fixture.name]) throw new Error('Unexpected fixture');
seen.add(fixture.name);
const value = validators[fixture.name].parse(fixture.body);
if (!isDeepStrictEqual(value, fixture.body)) throw new Error(`Lossy generated validator: ${fixture.name}`);
}
if (seen.size !== Object.keys(validators).length) throw new Error('Missing fixtures');
console.log(`Source export generated Zod: ${seen.size} actual API responses passed`);