You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, both modules independently access private Zod _def internals (typeName, innerType, description, options, shape()) and implement separate unwrapping loops for ZodOptional, ZodNullable, ZodDefault, and ZodEffects.
Goals & Motivation
Centralize Zod Introspection: Consolidate schema unwrapping and property reflection into a dedicated utility module (e.g. renderers/web_core/src/v0_9/schema/schema-reflection.ts).
Eliminate Raw _def Leaks: Provide clean helper functions (unwrapSchema, getSchemaDescriptions, isZodUnion, isZodObject) so binders and resolvers do not couple to Zod internals.
Extend Schema Metadata Stamping: Broaden the a2uiChildRef metadata pattern introduced in PR feat(react): render A2uiSurface through the node layer #2393 (markChildRef / childRefKindOf) to cover Action and Dynamic* schemas (a2uiKind: 'action' | 'dynamic' | 'child-list' | 'component-id'). This completely eliminates fragile string parsing of description pointers (REF:common_types.json#/$defs/...) when inspecting schemas.
Proposed Changes
New Utility Module (schema-reflection.ts):
unwrapSchema(schema: z.ZodTypeAny): Recursively unwraps wrappers while aggregating metadata and descriptions.
Overview
Several areas within
@a2ui/web_coreinspect and traverse Zod schemas to classify properties for reactive binding and child lifecycle management:GenericBinder/scrapeSchemaBehavior(renderers/web_core/src/v0_9/rendering/generic-binder.ts): inspects schemas to build a behavior tree (DYNAMIC,ACTION,STRUCTURAL,CHECKABLE,STATIC).NodeResolver/extractRefFields(renderers/web_core/src/v0_9/nodes/ref-fields.ts): inspects schemas to classify child component references (single,list,nested).Currently, both modules independently access private Zod
_definternals (typeName,innerType,description,options,shape()) and implement separate unwrapping loops forZodOptional,ZodNullable,ZodDefault, andZodEffects.Goals & Motivation
renderers/web_core/src/v0_9/schema/schema-reflection.ts)._defLeaks: Provide clean helper functions (unwrapSchema,getSchemaDescriptions,isZodUnion,isZodObject) so binders and resolvers do not couple to Zod internals.a2uiChildRefmetadata pattern introduced in PR feat(react): render A2uiSurface through the node layer #2393 (markChildRef/childRefKindOf) to coverActionandDynamic*schemas (a2uiKind: 'action' | 'dynamic' | 'child-list' | 'component-id'). This completely eliminates fragile string parsing ofdescriptionpointers (REF:common_types.json#/$defs/...) when inspecting schemas.Proposed Changes
schema-reflection.ts):unwrapSchema(schema: z.ZodTypeAny): Recursively unwraps wrappers while aggregating metadata and descriptions.getSchemaKind(schema: z.ZodTypeAny): Resolves stamped A2UI schema kinds.ref-fields.tsto useunwrapSchema.generic-binder.tsto useunwrapSchemaand the shared reflection helpers.common-types.ts):markSchemaKindtoActionSchema,DynamicValueSchema,DataBindingSchema.References
3a2f5f24)