(root: string)
| 529 | }; |
| 530 | |
| 531 | export const validateRegistry = async (root: string): Promise<void> => { |
| 532 | await validateCanonicalJson(join(root, 'upstreams.json'), upstreamsSchema); |
| 533 | const familyKeys = await listFamilyKeys(root); |
| 534 | const subsetIds = await listSubsetIds(root); |
| 535 | const subsets = new Map( |
| 536 | await Promise.all( |
| 537 | subsetIds.map( |
| 538 | async (id) => [id, await validateSubset(root, id)] as const, |
| 539 | ), |
| 540 | ), |
| 541 | ); |
| 542 | const familyIds = new Set<string>(); |
| 543 | for (const family of familyKeys) { |
| 544 | const { id } = parseFamilyKey(family); |
| 545 | assert(!familyIds.has(id), `Duplicate registry family ID ${id}`); |
| 546 | familyIds.add(id); |
| 547 | } |
| 548 | const replacements = await validateCanonicalJson( |
| 549 | join(root, 'replacements.json'), |
| 550 | replacementRegistrySchema, |
| 551 | ); |
| 552 | const taxonomy = await validateCanonicalJson( |
| 553 | join(root, 'taxonomy.json'), |
| 554 | taxonomySchema, |
| 555 | ); |
| 556 | const familyTags = await validateCanonicalJson( |
| 557 | join(root, 'family-tags.json'), |
| 558 | familyTagsSchema, |
| 559 | ); |
| 560 | const familyOverrides = await validateCanonicalJson( |
| 561 | join(root, 'family-overrides.json'), |
| 562 | familyOverridesSchema, |
| 563 | ); |
| 564 | const languages = await validateCanonicalJson( |
| 565 | join(root, 'languages.json'), |
| 566 | languageCatalogSchema, |
| 567 | ); |
| 568 | for (const [id, language] of Object.entries(languages)) { |
| 569 | if (!language.requiredCodepoints) continue; |
| 570 | deepStrictEqual( |
| 571 | language.requiredCodepoints, |
| 572 | Array.from(new Set(language.requiredCodepoints)).toSorted( |
| 573 | (left, right) => left - right, |
| 574 | ), |
| 575 | `${id} required codepoints must be sorted and unique`, |
| 576 | ); |
| 577 | } |
| 578 | for (const tag of Object.keys(taxonomy.tags)) { |
| 579 | const group = tag.split('/')[0] as string; |
| 580 | assert( |
| 581 | taxonomy.tagGroups[group], |
| 582 | `${tag} references unknown group ${group}`, |
| 583 | ); |
| 584 | } |
| 585 | |
| 586 | let validated = 0; |
| 587 | const families = await Promise.all( |
| 588 | familyKeys.map(async (family) => { |
no test coverage detected