Repository navigation
feat(web_core): write the v1.0 basic catalog with Zod 4 - #34
Closed
louis-bompart wants to merge 1 commit into
Closed
louis-bompart wants to merge 1 commit into
louis-bompart wants to merge 1 commit into
Conversation
The v1.0 basic catalog's components and functions are now generated as
Zod 4 schemas annotated with specMeta(), on Zod 4 versions of the v1.0
common types. basicCatalog.toJson() and validationSchema are byte-identical
to before, so the catalog still publishes the same catalog.json.
The catalog generator takes a zod option. With 'v4' it imports zod/v4 and
specMeta, writes a reference to a common type as
X.meta({$ref, description}), clearing an inherited description when the
reference has none of its own, an annotation as .meta(specMeta(...)), a
component as a z.strictObject, and a record with an explicit key schema.
It rejects a catalog mixin model, which metadata cannot name.
The v1.0 common types generator also writes src/v1_0/zod4/common-types.ts
with toZod4Code: the same compiled types importing zod/v4, naming their
definitions with .meta({$ref}) instead of REF: markers, without
markChildRef, and with Child naming its own definition. It formats the
file to a fixed point, which Prettier reaches in two passes. The common
types @a2ui/web_core/v1_0 exports, and the protocol's schemas, stay Zod 3.
The fromZod3 parity test now wraps the v0.9 basic catalog, which is still
written with Zod 3 and spec().
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.
Description
This PR completes the original proof, stacked on #33: the v1.0 basic catalog is now written with Zod 4. Its components and functions are generated as Zod 4 schemas annotated with
specMeta(), on Zod 4 versions of the v1.0 common types.basicCatalog.toJson()andbasicCatalog.validationSchemaare byte-identical to before, so it still publishes the samecatalog.json.Generators.
The catalog generator (
scripts/generate-catalog-schemas.mjs) takes azodoption. With'v4'it:zod/v4andspecMeta;X.meta({$ref: '#/$defs/X', description}), instead ofX.describe('REF:#/$defs/X|…');.meta(specMeta({...}))instead ofspec(..., {...});z.strictObject, and a record with an explicit key schema.It rejects a catalog mixin model such as v0.9's
CatalogComponentCommon, which metadata can only name. v1.0 has none. The rest of the generator, including how it predicts what the shaper derives, is shared with Zod 3. refactor(web_core): shape catalog documents from the JSON Schema view #32 and feat(web_core): annotate library schemas with specMeta #33 made the shaper read both the same way.The v1.0 common-types generator also writes
src/v1_0/zod4/common-types.ts, using a newtoZod4Codeinzod-generator-core.mjs. These are the same compiled types, except that they:zod/v4;.meta({$ref})instead ofREF:markers, somarkChildRefisn't needed, since views find child references by name;Childits own$refinstead of aliasingComponentId.The module is internal for now. The v1.0 common types that
@a2ui/web_core/v1_0exports, and the protocol's own message schemas, stay Zod 3.Two Zod 4 behaviours the generators handle.
description: undefined, to clear the common type's. Without that,Button.actionand others would gain a description the document doesn't have.zod4/common-types.tsto a fixed point, so the build's single Prettier pass leaves it unchanged andformat:checkpasses after a clean build.What changes for consumers (marked breaking in the changelog).
.parseor.safeParse.Dividervalidated with{}yields{axis: 'horizontal'}. The core doesn't use a component's output. No basic function has an argument with a default, so what functions receive is unchanged.The
fromZod3parity test now wraps the v0.9 basic catalog, which is still written with Zod 3 andspec(), catalog mixins included.Validation
yarn buildfrom clean, including all generatorsnode --test "dist/**/*.test.js": 1430 passing, 0 failing, 42 todo (the known cases)node tests/conformance/conformance_test.mjs: all vectors passingyarn lint: 0 errors, no new warningsyarn format:checkafter a clean buildyarn testintypescript/catalogs/{mcp,vegachart},typescript/renderers/{lit,react,markdown-it}andtypescript/agents/a2ui_agent. Angular passes apart fromtest:closure-compiler, which needs Java 21.basicCatalog.toJson()equals the publishedcatalogs/basic/v1/catalog.jsonpasses. Beyond that, thetoJson()andvalidationSchemaof the basic v0.8, v0.9 and v1.0 catalogs and the vegachart catalogs are byte-identical to before, key order included.Dividerdefault described above.Part of a2ui-project#2160
Pre-launch Checklist
One time:
For this PR:
🤖 Generated with Claude Code