Skip to content

refactor(web_core): resolve catalog definitions before building Zod - #50

Draft
louis-bompart wants to merge 1 commit into
claude/zod4/05-json-schema-viewsfrom
claude/zod4/06-definition-resolution
Draft

louis-bompart wants to merge 1 commit into
claude/zod4/05-json-schema-viewsfrom
claude/zod4/06-definition-resolution

Conversation

@louis-bompart

Copy link
Copy Markdown
Collaborator

Description

The catalog loader resolved references while it built Zod schemas, so the two concerns were mixed in one file. This PR resolves an entry's definition first, without Zod, and builds the Zod schema from the result. It changes no public API.

  1. catalog_references.ts: JSON Pointer traversal and resolveDefinition(), which resolves the references an entry reaches and bundles every local definition it reaches under defs, keeping its references named. A reference resolves against the catalog's own document and common_types.json only.
  2. catalog_definitions.ts: resolveComponentDefinition, resolveFunctionArgumentsDefinition and resolveThemeDefinition return an object definition as ordered pieces (common types or own properties), with its required names, omitted envelope fields and closure.
  3. schema_loader.ts converts those definitions to Zod 3 and keeps upstream's v1.0 reference checks (assertSupportedV10Refs).

Validation

  1. yarn build in typescript/core/web_core, then node --test "dist/**/*.test.js": 1367 tests, 0 failing.
  2. node tests/conformance/conformance_test.mjs: every vector passes.
  3. yarn lint in typescript/core/web_core: 0 errors.
  4. yarn build and yarn test in typescript/catalogs/mcp, typescript/catalogs/vegachart, typescript/renderers/markdown-it, typescript/renderers/lit, typescript/renderers/react and typescript/agents/a2ui_agent: all pass.
  5. yarn build in typescript/renderers/angular, tools/composer, tools/editor and tools/inspector. The Angular tests were not run: the local Java is too old for the Closure Compiler step.

Regroups #27 and #28.

Part of a2ui-project#2160.

🤖 Generated with Claude Code

Moves catalog reference resolution out of the schema loader into
catalog_references.ts, and resolves each entry's definition (its
references, mixins, allOf members and closure rules) in
catalog_definitions.ts before the loader builds a Zod schema from it.

A catalog's references resolve against its own document and
common_types.json only, as upstream reverted cross-catalog peers.

Regroups #27 and #28.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant