Repository navigation
refactor(web_core): resolve catalog definitions before building Zod - #28
Closed
louis-bompart wants to merge 6 commits into
Closed
louis-bompart wants to merge 6 commits into
louis-bompart wants to merge 6 commits into
Conversation
Check that every basic v0.9 and v1.0 catalog entry resolves to itself with its local definitions bundled, and that inlining the result matches the loader's inlining. Cover same-named definitions of two peers, a peer that references a second peer, and the sibling-keyword merge rule, which the inliner's documentation now states. Name a bundled root component target `component_<name>` without reusing a root definition name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the loader's resolution of components, function arguments and themes into the Zod-neutral catalog_definitions module. Each resolves its definition with resolveDefinition, then into an object model: its pieces in override order (common-type mixins, referenced definitions, inline allOf members, own properties), the required names, the omitted envelope fields and whether the object is open. The ComponentCommon version rule and the component, theme and function-argument closure rules live there too. The Zod builder now only translates that model, against the entry's bundle, so it no longer resolves peers. Two resolveDefinition options keep the loader's behavior: a component mixin from the same catalog keeps its envelope, and a reference outside the root catalog's own $defs whose definition name is a common type stays that common type. Every entry of the 61 catalog documents in the repository, loaded alone, at v0.9 and v1.0, and linked to each other, converts to the same Zod schema as before, with the same load errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is Layer 2 of the loader work: the loader resolves a catalog entry's definition without Zod, then converts the result to Zod. It changes no public API.
Reference resolution (
catalog_references.ts):$refinlining moved here fromschema_loader.ts.resolveDefinition()resolves the references an entry schema reaches without flattening them. It returns the schema with its named references kept, every local or peer definition it reaches bundled underdefs, and the names of the root catalog's own definitions:$defsentry keeps its name and its#/$defs/...reference.peer_<n>_<name>, and its reference is rewritten to point there.component_<name>. Bundled names never reuse a root definition name.defs.$defswhose definition name is a common type stays that common type.inlineResolvedDefinition()inlines a resolved definition for the consumers that still need flat schemas, andinlinePeerAndLocalRefsnow resolves, then inlines. Sibling keywords beside an inlined reference are merged: object keywords shallowly, with the sibling winning, and arrays as a union.Object resolution (new
catalog_definitions.ts):resolveComponentDefinition(),resolveFunctionArgumentsDefinition()andresolveThemeDefinition()resolve a definition into the object it validates:allOfmembers, then own properties;metadatatoComponentCommonfrom v1.0 lives here, as do the closure rules for components, themes and function arguments.Zod building (
schema_loader.ts):Layer 3 comes next: keep each loaded entry's resolved definition, and derive the binding views from it instead of from the compiled Zod schema.
Edge cases that can differ
None of these appears in any catalog in the repository:
allOfmixin that points at the peer's own definition named after a common type now uses the common type.allOfcontributes once. The result is the same.if/then/elsenow fails at load. Before, the loader ignored it.Validation
yarn buildnode --test "dist/**/*.test.js": 1278 passing, 0 failing, 21 todonode tests/conformance/conformance_test.mjs: all vectors passingyarn lint: 0 errorsyarn format:checkyarn testintypescript/catalogs/{mcp,vegachart},typescript/renderers/{lit,react}andtypescript/agents/a2ui_agent. Angular passes apart fromtest:closure-compiler, which needs Java 21.inlinePeerAndLocalRefsoutput for every entry of the basic v0.9 and v1.0 catalogs and vegachart v0.9 and v1.0, in both modes, is byte-identical to the output before this PR (132 outputs).ComponentCommonversion rule, and the closure rules;Part of a2ui-project#2160