Repository navigation
feat(web_core): write the v0.9 basic catalog in Zod 4 - #37
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 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>
This was referenced Oct 29, 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 is the first step of porting the Zod 3 authoring support, stacked on #36. The v0.9 basic catalog moves to Zod 4, as #34 did for v1.0. Its document,
validationSchema, binding and validation messages are unchanged.The catalog.
src/v0_9/scripts/generate-catalog.mjspasseszod: 'v4'. It imports the Zod 4 v0.9 common types from feat(web_core): compile loaded catalogs to Zod 4 #35.CatalogComponentCommonSchemaandThemeDefSchema, are now Zod 4 objects named with.meta(specMeta({defName}))instead ofspecDef().themeSchema(the sharedBasicCatalogThemeSchema) and the exported v0.9 common types stay Zod 3. They move later in the authoring port.Catalog mixins with
specMeta. v0.9 components mix inCatalogComponentCommon, a definition from the catalog itself. #34 left that gap:specMetacould only name common types.defModels, broke reuse. A v0.9 basic component used in another catalog wrote a$refto a definition that catalog didn't have. The composite-catalog tests caught it.specMeta({mixins: [...]})now takes the model itself, asspec()does.defNameinto the JSON, and keeps the model, keyed by the annotation object.SpecShaperfinds the model through the schema'smeta(), so the component brings its mixin along, as a Zod 3 component did.defModels. This is for libraries whose schemas don't report their metadata.CatalogDocumentOptions.defModelsnow takes anyEntrySchema.SpecMetaAnnotation.Zod 4 and cycles. Zod 4's
toJSONSchemafails on the v0.9 common types: "Error converting schema to JSON".DynamicValueandFunctionCallrefer to each other, and both name their definition with.meta({$ref}). Zod 4 doesn't extract a schema that already has a$refinto$defs, so the output object stays cyclic.normalizeSchemapasses Zod anoverride, through Standard JSON SchemalibraryOptions. It writes a schema named by its metadata$refas that reference and its metadata alone.Named types. The Zod 4 v0.9 common types now reuse the exported
FunctionCallandDynamicValuetypes instead of declaring their own copies. Otherwise, Angular's declaration emit can't name the props types it infers from the catalog (TS2742).Tests.
defModels;fromZod3catalog test now builds its own small Zod 3 catalog with a catalog mixin, since the v0.9 basic catalog is no longer Zod 3.Breaking, per the changelog.
Divider.axis.Next: the v0.8 basic catalog, then the exported common types and helpers,
spec(),exclusiveUnionandfromZod3, and then removing Zod 3.Validation
yarn buildfrom clean, with the generators rerun (stable output)node --test "dist/**/*.test.js": 1453 passing, 0 failing, 42 todo (the known cases)node tests/conformance/conformance_test.mjs: all vectors passingyarn lint: 0 errors, same warning countyarn format:checkyarn testintypescript/catalogs/{mcp,vegachart},typescript/renderers/{lit,react,markdown-it}andtypescript/agents/a2ui_agent, plus the agent SDK conformance suite (478). Angular builds and passestest:unit(328) andtest:integration(222);test:closure-compilerneeds Java 21.toJson()andvalidationSchemaof every code catalog (basic v0.8, v0.9, v1, vegachart v0.9 and v1): byte for byte identical;Divider{}now parses to{axis: "horizontal"}through its own schema), which the core doesn't use.Part of a2ui-project#2160
Pre-launch Checklist
One time:
For this PR:
🤖 Generated with Claude Code