a2ui-project / a2ui-project/a2ui
Add `catalogFromJsonSchema()` utility to convert JSON Schema catalogs to Zod
- Ngôn ngữ chính
- TypeScript
- Star
- 16.4k
- Fork
- 1.3k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 134
Mô tả
JSON Schema catalog definitions (`basic_catalog.json`) and the Zod component schemas in `basic_components.ts` are currently maintained independently by hand. This has already caused drift — see #1384.
It would be useful to have a utility in `@a2ui/web_core/v0_9` that converts a JSON Schema catalog into a `Catalog` instance with proper Zod schemas, mapping `$ref`s (e.g. `common_types.json#/$defs/DynamicString`) to the real common-type Zod schemas so `GenericBinder` classifies props correctly.
This would:
- Let catalog authors work in JSON Schema (the canonical A2UI format) while renderers get Zod automatically
- Enable catalog parity tests extending the `verify-schema.test.ts` pattern to catch drift like #1384
- Benefit all downstream renderers (React, Angular, Lit) facing the same duplication
Given that Zod v3 will remain in use for some time (see #1263 re: CSP constraints blocking v4 adoption), this would work with the current Zod v3 codebase and wouldn't depend on the v4 migration timeline.
Happy to contribute a PR.
Hướng dẫn đóng góp
Hướng nghiên cứu
Look at the existing JSON Schema catalog file (`basic_catalog.json`) and the corresponding Zod component schemas in `basic_components.ts`. Study the `verify-schema.test.ts` pattern to understand how schema parity is currently checked. The utility should be added to `@a2ui/web_core/v0_9`, mapping `$ref`s to the real common-type Zod schemas. Start by examining how `GenericBinder` classifies props to understand the required output format. 'Done' means the utility successfully converts a JSON Schema catalog to a `Catalog` instance with proper Zod schemas, enabling automated parity tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- json, typescript
- Lĩnh vực
- backend-api-design, tooling
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100