refactor(web_core): decouple GenericBinder and separate catalog-agnostic package entrypoints - #2353
Conversation
…ation and catalog fallback
…ip all conformance tests
Add dedicated basic catalog component packages for protocol versions v0.8 and v1.0 in TypeScript web_core, reusing compatible v0.9 component definitions. Update conformance_test.mjs to use versioned basic catalog implementations instead of defaulting to v0.9 for all versions.
… catalog Define dedicated Zod component schemas for v1.0 basic catalog (VideoApi with posterUrl, TextFieldApi with placeholder, SliderApi with steps) according to specification/v1_0/catalogs/basic/catalog.json.
… property aliases Add comprehensive v0.8 specification property definitions and aliases (distribution/alignment for Row/Column/List, minValue/maxValue for Slider, textFieldType/text for TextField, entryPointChild/contentChild for Modal, tabItems for Tabs, MultipleChoice) to src/v0_8/basic_catalog/components/basic_components.ts.
…int in FunctionDefinitionSchema Enforce in FunctionDefinitionSchema and catalog_definition.json that functions with requiresUserActivation=true must have allowedCallers='rendererOnly'. Added dedicated unit tests in src/v1_0/schema/verify-schema.test.ts.
…dapter, and regex flags
…atalog generation
…er, and tests for Python parity
…rs, string coercion, and redundant traversal optimization
…cross validating module
…rray path indices, function recursion depth, and stream accumulation
…nces, validateComponentIntegrity, and analyzeTopology
…le allowMissingRoot in validator
…opes in validating module
… and @index function
…, context optional chaining, and index regex parsing
…ndler - Add validation for call and call.call in callAgentFunction - Add defensive options and catalogs fallback initialization in RpcHandler constructor - Add non-null message check in handleCallRendererFunction and handleAgentFunctionResponse - Add unit tests for null/undefined message and call validation edge cases
… fix catalogId test fallback
…fallback ID generation
…nd decouple v1.0 core barrel
…ation and catalog fallback
…Action - Ensure dispatchAction validates that the payload contains a valid event wrapper, functionCall wrapper, or flat name/call property - Return early if eventPayload or name is missing or invalid - Add unit tests for malformed and missing action payloads in surface-model.test.ts
…nd DataModel lifecycle
…tic package entrypoints
adc8ce7 to
121daab
Compare
There was a problem hiding this comment.
Code Review
This pull request restructures the @a2ui/web_core package to export multiple subpaths, introduces v1.0 features including bidirectional RPC handling via RpcHandler, system functions like @index, and validation functions. It also adds robust validators for component integrity, path syntax, and graph topology, and updates SurfaceModel and GenericBinder to support these new structures. A review comment points out a performance optimization in MessageProcessor.getRendererCapabilities to avoid redundant calls to generateInlineCatalog when generating inline catalogs.
I am having trouble creating individual review comments. Click here to see my feedback.
typescript/web_core/src/processing/message-processor.ts (177-193)
When options?.includeInlineCatalogs is enabled, generateInlineCatalog is called twice for each catalog: once to populate versionCaps.inlineCatalogs and once to populate the root-level inlineCatalogs property in the returned object. Since generateInlineCatalog performs relatively expensive Zod-to-JSON-schema conversions, we should generate the inline catalogs once and reuse the array to improve performance.
let inlineCatalogs: Record<string, unknown>[] | undefined;
if (options?.includeInlineCatalogs) {
inlineCatalogs = this.catalogs.map(c =>
this.generateInlineCatalog(c, options?.componentEnvelopeRef),
);
versionCaps.inlineCatalogs = inlineCatalogs;
}
return {
supportedCatalogIds: this.catalogs.map(c => c.id),
...(inlineCatalogs
? {
inlineCatalogs,
}
: {}),
[version]: versionCaps,
};
68d805b to
f26cfcb
Compare
f26cfcb to
8239223
Compare
Summary
This PR completes the catalog agnosticism refactor by addressing the remaining architectural decoupling recommendations:
GenericBinder Decoupling & ValidationResult Support:
checks) inGenericBinder.getFieldBehaviorwith schema introspection viaisCheckableField.GenericBindercheck evaluation to natively support v1.0ValidationResultobjects ({ valid: boolean, message?: string }) in addition to boolean condition expressions.generic-binder.test.tsverifying dynamic validation messages and custom check property schemas.Catalog-Agnostic Package Entrypoints:
src/index.tsexporting only catalog-agnostic core modules (catalog,state,processing,rendering,validating,reactivity,expressions,errors,events).src/catalog/index.ts,src/state/index.ts,src/rendering/index.ts,src/expressions/index.ts,src/reactivity/index.ts).package.jsonmain,types, andexports["."], plus subpath exports (./catalog,./state,./processing,./rendering,./validating,./reactivity,./expressions,./adapters).src/v0_9/index.tsby removing transitivebasic_catalogre-exports.renderers/markdown/markdown-itandrenderers/litthat specifically required v0.8 styles/types to explicitly import from@a2ui/web_core/v0_8.Testing