Skip to content

feat(web_core)!: write the common types and the v0.8 and v0.9 basic catalogs in Zod 4 - #53

Draft
louis-bompart wants to merge 4 commits into
claude/zod4/08-zod4-corefrom
claude/zod4/09-zod4-public-types
Draft

louis-bompart wants to merge 4 commits into
claude/zod4/08-zod4-corefrom
claude/zod4/09-zod4-public-types

Conversation

@louis-bompart

Copy link
Copy Markdown
Collaborator

Description

This PR moves the rest of the public schemas to Zod 4: the exported common types and helpers, and the v0.9 and v0.8 basic catalogs. The generators write Zod 4 directly. Accepted payloads and every catalog's toJson() are unchanged; validation messages use Zod 4's wording.

  1. The common types and helpers that @a2ui/web_core/v0_9 and @a2ui/web_core/v1_0 export are Zod 4, and each names its definition with .meta({$ref}) instead of a REF: description.
  2. The v0.9 basic catalog is Zod 4. specMeta() takes a mixin model as well as a common type's name, such as CatalogComponentCommonSchema, and a Zod 4 schema on a cycle is read through its $ref.
  3. The v0.8 basic catalog is Zod 4.
  4. The generators write Zod 4 code directly, and the superset common types lose stray backslashes in two descriptions.
  5. The ValidationResult coercion reads every function schema through its JSON Schema view. ResolveA2uiProp keeps a Record<string, unknown> property as it is: under Zod 4 such a record matched the binding and call types and resolved to undefined.
  6. mcp: CallMcpToolApi and McpAppApi are Zod 4. The function call that returns the whole arguments object is a strict object of call, args and returnType instead of z.custom, which has no JSON Schema. vegachart: VegaChartApi and VegaChartV1Api are Zod 4.

Validation

  1. yarn build in typescript/core/web_core, then node --test "dist/**/*.test.js": 1541 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 #37, #38, #39 and #43.

Part of a2ui-project#2160.

🤖 Generated with Claude Code

louis-bompart and others added 4 commits October 29, 2026 12:43
The v0.9 basic catalog's components, functions and definition models are
generated in Zod 4, on the Zod 4 v0.9 common types, like the v1.0 catalog.

specMeta() takes a mixin model, named with specMeta({defName}), and A2UI
finds it through the schema's meta(), so a component reused in another
catalog still writes its CatalogComponentCommon mixin. A mixin name can also
name one of the catalog's defModels. Zod 4 converts a schema named with
.meta({$ref}) to its reference and metadata, which also lets it convert the
v0.9 DynamicValue/FunctionCall cycle. The Zod 4 v0.9 common types reuse the
exported recursive types so inferred types can be named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The v0.8 catalog generator writes strict Zod 4 objects annotated with
specMeta() instead of Zod 3 objects annotated with spec(). The catalog's
document, validation schema and accepted payloads are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The superset, v0.9 and v1.0 common types are generated in Zod 4 into the
files the packages export, which replace the internal zod4/ copies. The
v0.9, v1.0 and superset authoring helpers, IndexApi and the payload
validator's envelope checks move to Zod 4 too; the helpers now write the
description they are given.

With expandReferences, a Zod 4 schema named by .meta({$ref}) keeps its
contents unless it names an opaque definition. The generator recognizes
the common types' own descriptions through their metadata.

VegaChart, callMcpTool, the explorer components and the tests that compose
the common types move to Zod 4; tests of Zod 3 support use Zod 3 stand-ins.

With the common types in Zod 4, the ValidationResult coercion reads every schema through its JSON Schema view, and callMcpTool writes its function-call arguments as a strict object rather than z.custom, which has no JSON Schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The catalog generator drops its Zod 3 mode. compileDefToZod names a
definition with .meta({$ref}) itself, through a ref option, and the v0.9,
v1.0 and superset generators write Zod 4 templates, so toZod4Code is gone.
Every generated file is unchanged, except that two superset common types
lose stray backslashes in their descriptions.

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