a2ui-project / a2ui-project/a2ui
refactor(web_core): extract shared Zod schema introspection and metadata utilities
- Lingua principale
- TypeScript
- Stelle
- 16.4k
- Fork
- 1.3k
- Merge medio
- 3g 15h
- PR unite (30g)
- 134
Descrizione
## Overview
`GenericBinder` (`renderers/web_core/src/v0_9/rendering/generic-binder.ts`) and `NodeResolver` (`renderers/web_core/src/v0_9/nodes/ref-fields.ts`) both independently inspect Zod schemas:
1. Accessing private `_def` internals (`typeName`, `innerType`, `description`, `options`, `shape()`).
2. Duplicating unwrapping loops for `ZodOptional`, `ZodNullable`, `ZodDefault`, and `ZodEffects`.
3. Defining duplicate schema reference strings (`REF:common_types.json#/$defs/...`).
## Goals
- **Centralize Schema Constants**: Export canonical reference constants (`CHILD_LIST_REF`, `COMPONENT_ID_REF`, `ACTION_REF`, `DATA_BINDING_REF`) from a central location (`renderers/web_core/src/v0_9/schema/constants.ts` or `common-types.ts`).
- **Shared Schema Introspection Utility**: Consolidate unwrapping logic into a dedicated helper module (`renderers/web_core/src/v0_9/schema/schema-reflection.ts`) so callers avoid accessing `_def` directly.
- **Extend Schema Metadata**: Broaden the `a2uiChildRef` metadata pattern introduced in PR #2393 (`markChildRef` / `childRefKindOf`) to `Action` and `Dynamic*` schemas (`a2uiKind: 'action' | 'dynamic' | 'child-list' | 'component-id'`).
## References
- PR #2359: https://github.com/a2ui-project/a2ui/pull/2359
- PR #2393: Node layer schema metadata implementation (commit `3a2f5f24`)
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia leggendo i due file menzionati: `renderers/web_core/src/v0_9/rendering/generic-binder.ts` e `renderers/web_core/src/v0_9/nodes/ref-fields.ts`. Esamina come ispezionano gli schemi Zod tramite `_def`. Guarda la PR #2393 per comprendere il pattern di metadati `a2uiChildRef` esistente. L’obiettivo è estrarre la logica condivisa in nuovi moduli di utilità, probabilmente in `renderers/web_core/src/v0_9/schema/`. Il lavoro è completato quando il codice di introspezione duplicato viene rimosso dai file originali e sostituito da chiamate ai nuovi utilità condivisi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- backend-api-design, tooling
- Tipo di issue
- Refactoring
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 55/100