@copilotkit/shared 1.84.2-canary.1793809041 → 1.84.2-canary.openbot-intel-fixes

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/README.md +1 -1
  2. package/dist/a2ui-catalog-schema.cjs +14 -5
  3. package/dist/a2ui-catalog-schema.cjs.map +1 -1
  4. package/dist/a2ui-catalog-schema.d.cts +4 -2
  5. package/dist/a2ui-catalog-schema.d.cts.map +1 -1
  6. package/dist/a2ui-catalog-schema.d.mts +4 -2
  7. package/dist/a2ui-catalog-schema.d.mts.map +1 -1
  8. package/dist/a2ui-catalog-schema.mjs +14 -5
  9. package/dist/a2ui-catalog-schema.mjs.map +1 -1
  10. package/dist/event-transforms/open-generative-ui-middleware.cjs +7 -6
  11. package/dist/event-transforms/open-generative-ui-middleware.cjs.map +1 -1
  12. package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +1 -1
  13. package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +1 -1
  14. package/dist/event-transforms/open-generative-ui-middleware.mjs +7 -6
  15. package/dist/event-transforms/open-generative-ui-middleware.mjs.map +1 -1
  16. package/dist/generative-ui/catalog/catalog-export.cjs +329 -0
  17. package/dist/generative-ui/catalog/catalog-export.cjs.map +1 -0
  18. package/dist/generative-ui/catalog/catalog-export.d.cts +92 -0
  19. package/dist/generative-ui/catalog/catalog-export.d.cts.map +1 -0
  20. package/dist/generative-ui/catalog/catalog-export.d.mts +92 -0
  21. package/dist/generative-ui/catalog/catalog-export.d.mts.map +1 -0
  22. package/dist/generative-ui/catalog/catalog-export.mjs +328 -0
  23. package/dist/generative-ui/catalog/catalog-export.mjs.map +1 -0
  24. package/dist/generative-ui/catalog/catalog.cjs +314 -0
  25. package/dist/generative-ui/catalog/catalog.cjs.map +1 -0
  26. package/dist/generative-ui/catalog/catalog.d.cts +407 -0
  27. package/dist/generative-ui/catalog/catalog.d.cts.map +1 -0
  28. package/dist/generative-ui/catalog/catalog.d.mts +407 -0
  29. package/dist/generative-ui/catalog/catalog.d.mts.map +1 -0
  30. package/dist/generative-ui/catalog/catalog.mjs +311 -0
  31. package/dist/generative-ui/catalog/catalog.mjs.map +1 -0
  32. package/dist/generative-ui/catalog/errors.cjs +13 -0
  33. package/dist/generative-ui/catalog/errors.cjs.map +1 -0
  34. package/dist/generative-ui/catalog/errors.d.cts +46 -0
  35. package/dist/generative-ui/catalog/errors.d.cts.map +1 -0
  36. package/dist/generative-ui/catalog/errors.d.mts +46 -0
  37. package/dist/generative-ui/catalog/errors.d.mts.map +1 -0
  38. package/dist/generative-ui/catalog/errors.mjs +12 -0
  39. package/dist/generative-ui/catalog/errors.mjs.map +1 -0
  40. package/dist/generative-ui/catalog/index.d.mts +6 -0
  41. package/dist/generative-ui/catalog/json-schema.cjs +19 -0
  42. package/dist/generative-ui/catalog/json-schema.cjs.map +1 -0
  43. package/dist/generative-ui/catalog/json-schema.d.cts +13 -0
  44. package/dist/generative-ui/catalog/json-schema.d.cts.map +1 -0
  45. package/dist/generative-ui/catalog/json-schema.d.mts +13 -0
  46. package/dist/generative-ui/catalog/json-schema.d.mts.map +1 -0
  47. package/dist/generative-ui/catalog/json-schema.mjs +18 -0
  48. package/dist/generative-ui/catalog/json-schema.mjs.map +1 -0
  49. package/dist/generative-ui/catalog/refs.cjs +20 -0
  50. package/dist/generative-ui/catalog/refs.cjs.map +1 -0
  51. package/dist/generative-ui/catalog/refs.d.cts +54 -0
  52. package/dist/generative-ui/catalog/refs.d.cts.map +1 -0
  53. package/dist/generative-ui/catalog/refs.d.mts +54 -0
  54. package/dist/generative-ui/catalog/refs.d.mts.map +1 -0
  55. package/dist/generative-ui/catalog/refs.mjs +18 -0
  56. package/dist/generative-ui/catalog/refs.mjs.map +1 -0
  57. package/dist/generative-ui/catalog/schema.cjs +74 -0
  58. package/dist/generative-ui/catalog/schema.cjs.map +1 -0
  59. package/dist/generative-ui/catalog/schema.d.cts +43 -0
  60. package/dist/generative-ui/catalog/schema.d.cts.map +1 -0
  61. package/dist/generative-ui/catalog/schema.d.mts +43 -0
  62. package/dist/generative-ui/catalog/schema.d.mts.map +1 -0
  63. package/dist/generative-ui/catalog/schema.mjs +68 -0
  64. package/dist/generative-ui/catalog/schema.mjs.map +1 -0
  65. package/dist/generative-ui/index.cjs +247 -0
  66. package/dist/generative-ui/index.d.cts +33 -0
  67. package/dist/generative-ui/index.d.mts +35 -0
  68. package/dist/generative-ui/index.mjs +34 -0
  69. package/dist/generative-ui/is-record.cjs +6 -1
  70. package/dist/generative-ui/is-record.cjs.map +1 -1
  71. package/dist/generative-ui/is-record.d.cts +6 -0
  72. package/dist/generative-ui/is-record.d.cts.map +1 -0
  73. package/dist/generative-ui/is-record.d.mts +6 -0
  74. package/dist/generative-ui/is-record.d.mts.map +1 -0
  75. package/dist/generative-ui/is-record.mjs +6 -2
  76. package/dist/generative-ui/is-record.mjs.map +1 -1
  77. package/dist/generative-ui/standard/chart.cjs +56 -0
  78. package/dist/generative-ui/standard/chart.cjs.map +1 -0
  79. package/dist/generative-ui/standard/chart.d.cts +142 -0
  80. package/dist/generative-ui/standard/chart.d.cts.map +1 -0
  81. package/dist/generative-ui/standard/chart.d.mts +142 -0
  82. package/dist/generative-ui/standard/chart.d.mts.map +1 -0
  83. package/dist/generative-ui/standard/chart.mjs +54 -0
  84. package/dist/generative-ui/standard/chart.mjs.map +1 -0
  85. package/dist/generative-ui/standard/checks.cjs +74 -0
  86. package/dist/generative-ui/standard/checks.cjs.map +1 -0
  87. package/dist/generative-ui/standard/checks.d.cts +74 -0
  88. package/dist/generative-ui/standard/checks.d.cts.map +1 -0
  89. package/dist/generative-ui/standard/checks.d.mts +74 -0
  90. package/dist/generative-ui/standard/checks.d.mts.map +1 -0
  91. package/dist/generative-ui/standard/checks.mjs +71 -0
  92. package/dist/generative-ui/standard/checks.mjs.map +1 -0
  93. package/dist/generative-ui/standard/components.cjs +23 -0
  94. package/dist/generative-ui/standard/components.cjs.map +1 -0
  95. package/dist/generative-ui/standard/components.d.cts +24 -0
  96. package/dist/generative-ui/standard/components.d.cts.map +1 -0
  97. package/dist/generative-ui/standard/components.d.mts +24 -0
  98. package/dist/generative-ui/standard/components.d.mts.map +1 -0
  99. package/dist/generative-ui/standard/components.mjs +22 -0
  100. package/dist/generative-ui/standard/components.mjs.map +1 -0
  101. package/dist/generative-ui/standard/composites.cjs +143 -0
  102. package/dist/generative-ui/standard/composites.cjs.map +1 -0
  103. package/dist/generative-ui/standard/composites.d.cts +500 -0
  104. package/dist/generative-ui/standard/composites.d.cts.map +1 -0
  105. package/dist/generative-ui/standard/composites.d.mts +500 -0
  106. package/dist/generative-ui/standard/composites.d.mts.map +1 -0
  107. package/dist/generative-ui/standard/composites.mjs +132 -0
  108. package/dist/generative-ui/standard/composites.mjs.map +1 -0
  109. package/dist/generative-ui/standard/data.cjs +176 -0
  110. package/dist/generative-ui/standard/data.cjs.map +1 -0
  111. package/dist/generative-ui/standard/data.d.cts +745 -0
  112. package/dist/generative-ui/standard/data.d.cts.map +1 -0
  113. package/dist/generative-ui/standard/data.d.mts +745 -0
  114. package/dist/generative-ui/standard/data.d.mts.map +1 -0
  115. package/dist/generative-ui/standard/data.mjs +167 -0
  116. package/dist/generative-ui/standard/data.mjs.map +1 -0
  117. package/dist/generative-ui/standard/declarations.cjs +40 -0
  118. package/dist/generative-ui/standard/declarations.cjs.map +1 -0
  119. package/dist/generative-ui/standard/declarations.d.cts +4604 -0
  120. package/dist/generative-ui/standard/declarations.d.cts.map +1 -0
  121. package/dist/generative-ui/standard/declarations.d.mts +4605 -0
  122. package/dist/generative-ui/standard/declarations.d.mts.map +1 -0
  123. package/dist/generative-ui/standard/declarations.mjs +39 -0
  124. package/dist/generative-ui/standard/declarations.mjs.map +1 -0
  125. package/dist/generative-ui/standard/feedback.cjs +97 -0
  126. package/dist/generative-ui/standard/feedback.cjs.map +1 -0
  127. package/dist/generative-ui/standard/feedback.d.cts +227 -0
  128. package/dist/generative-ui/standard/feedback.d.cts.map +1 -0
  129. package/dist/generative-ui/standard/feedback.d.mts +227 -0
  130. package/dist/generative-ui/standard/feedback.d.mts.map +1 -0
  131. package/dist/generative-ui/standard/feedback.mjs +90 -0
  132. package/dist/generative-ui/standard/feedback.mjs.map +1 -0
  133. package/dist/generative-ui/standard/index.d.mts +16 -0
  134. package/dist/generative-ui/standard/inputs.cjs +333 -0
  135. package/dist/generative-ui/standard/inputs.cjs.map +1 -0
  136. package/dist/generative-ui/standard/inputs.d.cts +2658 -0
  137. package/dist/generative-ui/standard/inputs.d.cts.map +1 -0
  138. package/dist/generative-ui/standard/inputs.d.mts +2658 -0
  139. package/dist/generative-ui/standard/inputs.d.mts.map +1 -0
  140. package/dist/generative-ui/standard/inputs.mjs +318 -0
  141. package/dist/generative-ui/standard/inputs.mjs.map +1 -0
  142. package/dist/generative-ui/standard/layout.cjs +289 -0
  143. package/dist/generative-ui/standard/layout.cjs.map +1 -0
  144. package/dist/generative-ui/standard/layout.d.cts +2854 -0
  145. package/dist/generative-ui/standard/layout.d.cts.map +1 -0
  146. package/dist/generative-ui/standard/layout.d.mts +2854 -0
  147. package/dist/generative-ui/standard/layout.d.mts.map +1 -0
  148. package/dist/generative-ui/standard/layout.mjs +269 -0
  149. package/dist/generative-ui/standard/layout.mjs.map +1 -0
  150. package/dist/generative-ui/standard/map.cjs +27 -0
  151. package/dist/generative-ui/standard/map.cjs.map +1 -0
  152. package/dist/generative-ui/standard/map.d.cts +93 -0
  153. package/dist/generative-ui/standard/map.d.cts.map +1 -0
  154. package/dist/generative-ui/standard/map.d.mts +93 -0
  155. package/dist/generative-ui/standard/map.d.mts.map +1 -0
  156. package/dist/generative-ui/standard/map.mjs +25 -0
  157. package/dist/generative-ui/standard/map.mjs.map +1 -0
  158. package/dist/generative-ui/standard/media.cjs +215 -0
  159. package/dist/generative-ui/standard/media.cjs.map +1 -0
  160. package/dist/generative-ui/standard/media.d.cts +968 -0
  161. package/dist/generative-ui/standard/media.d.cts.map +1 -0
  162. package/dist/generative-ui/standard/media.d.mts +968 -0
  163. package/dist/generative-ui/standard/media.d.mts.map +1 -0
  164. package/dist/generative-ui/standard/media.mjs +205 -0
  165. package/dist/generative-ui/standard/media.mjs.map +1 -0
  166. package/dist/generative-ui/standard/parameter-order.cjs +231 -0
  167. package/dist/generative-ui/standard/parameter-order.cjs.map +1 -0
  168. package/dist/generative-ui/standard/parameter-order.d.cts +84 -0
  169. package/dist/generative-ui/standard/parameter-order.d.cts.map +1 -0
  170. package/dist/generative-ui/standard/parameter-order.d.mts +84 -0
  171. package/dist/generative-ui/standard/parameter-order.d.mts.map +1 -0
  172. package/dist/generative-ui/standard/parameter-order.mjs +230 -0
  173. package/dist/generative-ui/standard/parameter-order.mjs.map +1 -0
  174. package/dist/generative-ui/standard/styles.cjs +62 -0
  175. package/dist/generative-ui/standard/styles.cjs.map +1 -0
  176. package/dist/generative-ui/standard/styles.d.cts +17 -0
  177. package/dist/generative-ui/standard/styles.d.cts.map +1 -0
  178. package/dist/generative-ui/standard/styles.d.mts +17 -0
  179. package/dist/generative-ui/standard/styles.d.mts.map +1 -0
  180. package/dist/generative-ui/standard/styles.mjs +60 -0
  181. package/dist/generative-ui/standard/styles.mjs.map +1 -0
  182. package/dist/generative-ui/standard/text.cjs +226 -0
  183. package/dist/generative-ui/standard/text.cjs.map +1 -0
  184. package/dist/generative-ui/standard/text.d.cts +687 -0
  185. package/dist/generative-ui/standard/text.d.cts.map +1 -0
  186. package/dist/generative-ui/standard/text.d.mts +687 -0
  187. package/dist/generative-ui/standard/text.d.mts.map +1 -0
  188. package/dist/generative-ui/standard/text.mjs +209 -0
  189. package/dist/generative-ui/standard/text.mjs.map +1 -0
  190. package/dist/generative-ui/standard/theme.cjs +115 -0
  191. package/dist/generative-ui/standard/theme.cjs.map +1 -0
  192. package/dist/generative-ui/standard/theme.d.cts +60 -0
  193. package/dist/generative-ui/standard/theme.d.cts.map +1 -0
  194. package/dist/generative-ui/standard/theme.d.mts +60 -0
  195. package/dist/generative-ui/standard/theme.d.mts.map +1 -0
  196. package/dist/generative-ui/standard/theme.mjs +112 -0
  197. package/dist/generative-ui/standard/theme.mjs.map +1 -0
  198. package/dist/generative-ui/standard/tokens.cjs +336 -0
  199. package/dist/generative-ui/standard/tokens.cjs.map +1 -0
  200. package/dist/generative-ui/standard/tokens.d.cts +76 -0
  201. package/dist/generative-ui/standard/tokens.d.cts.map +1 -0
  202. package/dist/generative-ui/standard/tokens.d.mts +76 -0
  203. package/dist/generative-ui/standard/tokens.d.mts.map +1 -0
  204. package/dist/generative-ui/standard/tokens.mjs +305 -0
  205. package/dist/generative-ui/standard/tokens.mjs.map +1 -0
  206. package/dist/index.cjs.map +1 -1
  207. package/dist/index.d.cts +10 -10
  208. package/dist/index.d.mts +10 -10
  209. package/dist/index.mjs.map +1 -1
  210. package/dist/index.umd.js +16 -7
  211. package/dist/index.umd.js.map +1 -1
  212. package/dist/package.cjs +1 -1
  213. package/dist/package.mjs +1 -1
  214. package/package.json +7 -3
  215. package/src/__tests__/a2ui-catalog-schema.test.ts +26 -0
  216. package/src/a2ui-catalog-schema.ts +14 -5
  217. package/src/event-transforms/open-generative-ui-middleware.ts +19 -10
  218. package/src/generative-ui/base.ts +9 -0
  219. package/src/generative-ui/catalog/catalog-export.ts +478 -0
  220. package/src/generative-ui/catalog/catalog.ts +1166 -0
  221. package/src/generative-ui/catalog/errors.ts +102 -0
  222. package/src/generative-ui/catalog/index.ts +6 -0
  223. package/src/generative-ui/catalog/json-schema.ts +23 -0
  224. package/src/generative-ui/catalog/refs.ts +86 -0
  225. package/src/generative-ui/catalog/schema.ts +107 -0
  226. package/src/generative-ui/index.ts +7 -0
  227. package/src/generative-ui/is-record.ts +6 -1
  228. package/src/generative-ui/standard/__tests__/theme.test.ts +61 -0
  229. package/src/generative-ui/standard/__tests__/tokens.test.ts +139 -0
  230. package/src/generative-ui/standard/chart.ts +79 -0
  231. package/src/generative-ui/standard/checks.ts +98 -0
  232. package/src/generative-ui/standard/components.ts +35 -0
  233. package/src/generative-ui/standard/composites.ts +158 -0
  234. package/src/generative-ui/standard/data.ts +213 -0
  235. package/src/generative-ui/standard/declarations.ts +57 -0
  236. package/src/generative-ui/standard/feedback.ts +105 -0
  237. package/src/generative-ui/standard/index.ts +19 -0
  238. package/src/generative-ui/standard/inputs.ts +423 -0
  239. package/src/generative-ui/standard/layout.ts +312 -0
  240. package/src/generative-ui/standard/map.ts +32 -0
  241. package/src/generative-ui/standard/media.ts +265 -0
  242. package/src/generative-ui/standard/parameter-order.ts +155 -0
  243. package/src/generative-ui/standard/styles.ts +79 -0
  244. package/src/generative-ui/standard/text.ts +210 -0
  245. package/src/generative-ui/standard/theme.ts +198 -0
  246. package/src/generative-ui/standard/tokens.ts +317 -0
  247. package/src/index.ts +1 -1
  248. package/tsdown.config.ts +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema.d.cts","names":[],"sources":["../../../src/generative-ui/catalog/json-schema.ts"],"mappings":";;;;;;AAWA;;;iBAAgB,YAAA,CAAa,MAAA,EAAQ,gBAAA,GAAmB,sBAAA"}
@@ -0,0 +1,13 @@
1
+ import { GenerativeUIJSONSchema } from "../types.mjs";
2
+ import { StandardSchemaV1 } from "../../standard-schema.mjs";
3
+
4
+ //#region src/generative-ui/catalog/json-schema.d.ts
5
+ /**
6
+ * JSON Schema for a Standard Schema (zod v3 via zod-to-json-schema),
7
+ * inlined, no `$schema`. A prop marked by `child()` or `childList()`
8
+ * becomes an A2UI `$ref` to `ComponentId` or `ChildList`.
9
+ */
10
+ declare function toJsonSchema(schema: StandardSchemaV1): GenerativeUIJSONSchema;
11
+ //#endregion
12
+ export { toJsonSchema };
13
+ //# sourceMappingURL=json-schema.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema.d.mts","names":[],"sources":["../../../src/generative-ui/catalog/json-schema.ts"],"mappings":";;;;;;AAWA;;;iBAAgB,YAAA,CAAa,MAAA,EAAQ,gBAAA,GAAmB,sBAAA"}
@@ -0,0 +1,18 @@
1
+ import { schemaToJsonSchema } from "../../standard-schema.mjs";
2
+ import { applyChildRefMarks } from "../child-refs.mjs";
3
+ import { zodToJsonSchema } from "zod-to-json-schema";
4
+
5
+ //#region src/generative-ui/catalog/json-schema.ts
6
+ /**
7
+ * JSON Schema for a Standard Schema (zod v3 via zod-to-json-schema),
8
+ * inlined, no `$schema`. A prop marked by `child()` or `childList()`
9
+ * becomes an A2UI `$ref` to `ComponentId` or `ChildList`.
10
+ */
11
+ function toJsonSchema(schema) {
12
+ const { $schema: _omit, ...rest } = schemaToJsonSchema(schema, { zodToJsonSchema: (s) => zodToJsonSchema(s, { $refStrategy: "none" }) });
13
+ return applyChildRefMarks(rest);
14
+ }
15
+
16
+ //#endregion
17
+ export { toJsonSchema };
18
+ //# sourceMappingURL=json-schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema.mjs","names":[],"sources":["../../../src/generative-ui/catalog/json-schema.ts"],"sourcesContent":["import { schemaToJsonSchema } from \"../../standard-schema\";\nimport { applyChildRefMarks } from \"../base\";\nimport type { StandardSchemaV1 } from \"../../standard-schema\";\nimport type { GenerativeUIJSONSchema } from \"../base\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\n\n/**\n * JSON Schema for a Standard Schema (zod v3 via zod-to-json-schema),\n * inlined, no `$schema`. A prop marked by `child()` or `childList()`\n * becomes an A2UI `$ref` to `ComponentId` or `ChildList`.\n */\nexport function toJsonSchema(schema: StandardSchemaV1): GenerativeUIJSONSchema {\n const json = schemaToJsonSchema(schema, {\n // The cast through the parameter type keeps TypeScript from expanding\n // the zod type, which is \"excessively deep\" in this package.\n zodToJsonSchema: (s: unknown) =>\n zodToJsonSchema(s as Parameters<typeof zodToJsonSchema>[0], {\n $refStrategy: \"none\",\n }) as Record<string, unknown>,\n });\n const { $schema: _omit, ...rest } = json as Record<string, unknown>;\n return applyChildRefMarks(rest);\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,aAAa,QAAkD;CAS7E,MAAM,EAAE,SAAS,OAAO,GAAG,SARd,mBAAmB,QAAQ,EAGtC,kBAAkB,MAChB,gBAAgB,GAA4C,EAC1D,cAAc,QACf,CAAC,EACL,CAAC;AAEF,QAAO,mBAAmB,KAAK"}
@@ -0,0 +1,20 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_child_refs = require('../child-refs.cjs');
3
+ let zod = require("zod");
4
+
5
+ //#region src/generative-ui/catalog/refs.ts
6
+ const mark = (prefix, description) => description ? `${prefix} ${description}` : prefix;
7
+ function child(description) {
8
+ return zod.z.string().min(1).describe(mark(require_child_refs.A2UI_COMPONENT_ID_MARK, description)).transform((value) => value);
9
+ }
10
+ function childList(description) {
11
+ return zod.z.union([zod.z.array(zod.z.string().min(1)), zod.z.object({
12
+ componentId: zod.z.string().min(1),
13
+ path: zod.z.string().min(1)
14
+ })]).describe(mark(require_child_refs.A2UI_CHILD_LIST_MARK, description)).transform((value) => value);
15
+ }
16
+
17
+ //#endregion
18
+ exports.child = child;
19
+ exports.childList = childList;
20
+ //# sourceMappingURL=refs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.cjs","names":["z","A2UI_COMPONENT_ID_MARK","A2UI_CHILD_LIST_MARK"],"sources":["../../../src/generative-ui/catalog/refs.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { A2UI_CHILD_LIST_MARK, A2UI_COMPONENT_ID_MARK } from \"../base\";\n\n/**\n * Schema helpers that mark a prop as a component reference, the way A2UI\n * 1.0 marks it with the `ComponentId` and `ChildList` common types. The\n * engine finds every marked prop in the props schema, at any depth, renders\n * the referenced components, and hands the component the rendered nodes in\n * place of the ids. The model sees the prop as `componentId` or as a list\n * of ids or a template.\n *\n * @example\n * ```ts\n * const tabsSchema = z.object({\n * tabs: z.array(z.object({ title: z.string(), child: child() })),\n * });\n * // A React component gets `tabs: { title: string; child: ReactNode }[]`.\n * ```\n *\n * `TNode` is the type of a rendered child in the framework that renders the\n * UI. Each framework package exports `child` and `childList` with it set.\n * Without it, the output is `GenerativeUIChildNode`, which\n * `GenerativeUIComponentProps` replaces with the node type of the framework.\n */\n\ndeclare const childNodeBrand: unique symbol;\n\n/**\n * A rendered child in a framework-free schema. `GenerativeUIComponentProps`\n * replaces it with the node type that the framework passes.\n */\nexport interface GenerativeUIChildNode {\n readonly [childNodeBrand]: true;\n}\n\ntype ChildSchema<TNode> = z.ZodEffects<z.ZodString, TNode, string>;\ntype ChildListSchema<TNode> = z.ZodEffects<\n z.ZodUnion<\n [\n z.ZodArray<z.ZodString>,\n z.ZodObject<{ componentId: z.ZodString; path: z.ZodString }>,\n ]\n >,\n TNode\n>;\n\n// Without a type argument, `child()` gives `GenerativeUIChildNode`. A\n// generic default is not enough: inside `z.object({ ... })`, TypeScript\n// would infer `TNode` from the shape and give `any`.\n\nconst mark = (prefix: string, description: string | undefined) =>\n description ? `${prefix} ${description}` : prefix;\n\n/**\n * One component id. The component receives the rendered child. Pass the\n * description here, not with `.describe()`, which would replace the mark.\n */\nexport function child(description?: string): ChildSchema<GenerativeUIChildNode>;\nexport function child<TNode>(description?: string): ChildSchema<TNode>;\nexport function child(description?: string): ChildSchema<unknown> {\n return z\n .string()\n .min(1)\n .describe(mark(A2UI_COMPONENT_ID_MARK, description))\n .transform((value) => value as unknown);\n}\n\n/**\n * A list of component ids, or a template `{ componentId, path }` that\n * repeats one component for each item of the list at `path`. The\n * component receives the rendered children. Pass the description here,\n * not with `.describe()`.\n */\nexport function childList(\n description?: string,\n): ChildListSchema<GenerativeUIChildNode>;\nexport function childList<TNode>(description?: string): ChildListSchema<TNode>;\nexport function childList(description?: string): ChildListSchema<unknown> {\n return z\n .union([\n z.array(z.string().min(1)),\n z.object({ componentId: z.string().min(1), path: z.string().min(1) }),\n ])\n .describe(mark(A2UI_CHILD_LIST_MARK, description))\n .transform((value) => value as unknown);\n}\n"],"mappings":";;;;;AAkDA,MAAM,QAAQ,QAAgB,gBAC5B,cAAc,GAAG,OAAO,GAAG,gBAAgB;AAQ7C,SAAgB,MAAM,aAA4C;AAChE,QAAOA,MACJ,QAAQ,CACR,IAAI,EAAE,CACN,SAAS,KAAKC,2CAAwB,YAAY,CAAC,CACnD,WAAW,UAAU,MAAiB;;AAa3C,SAAgB,UAAU,aAAgD;AACxE,QAAOD,MACJ,MAAM,CACLA,MAAE,MAAMA,MAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,EAC1BA,MAAE,OAAO;EAAE,aAAaA,MAAE,QAAQ,CAAC,IAAI,EAAE;EAAE,MAAMA,MAAE,QAAQ,CAAC,IAAI,EAAE;EAAE,CAAC,CACtE,CAAC,CACD,SAAS,KAAKE,yCAAsB,YAAY,CAAC,CACjD,WAAW,UAAU,MAAiB"}
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/generative-ui/catalog/refs.d.ts
4
+ /**
5
+ * Schema helpers that mark a prop as a component reference, the way A2UI
6
+ * 1.0 marks it with the `ComponentId` and `ChildList` common types. The
7
+ * engine finds every marked prop in the props schema, at any depth, renders
8
+ * the referenced components, and hands the component the rendered nodes in
9
+ * place of the ids. The model sees the prop as `componentId` or as a list
10
+ * of ids or a template.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const tabsSchema = z.object({
15
+ * tabs: z.array(z.object({ title: z.string(), child: child() })),
16
+ * });
17
+ * // A React component gets `tabs: { title: string; child: ReactNode }[]`.
18
+ * ```
19
+ *
20
+ * `TNode` is the type of a rendered child in the framework that renders the
21
+ * UI. Each framework package exports `child` and `childList` with it set.
22
+ * Without it, the output is `GenerativeUIChildNode`, which
23
+ * `GenerativeUIComponentProps` replaces with the node type of the framework.
24
+ */
25
+ declare const childNodeBrand: unique symbol;
26
+ /**
27
+ * A rendered child in a framework-free schema. `GenerativeUIComponentProps`
28
+ * replaces it with the node type that the framework passes.
29
+ */
30
+ interface GenerativeUIChildNode {
31
+ readonly [childNodeBrand]: true;
32
+ }
33
+ type ChildSchema<TNode> = z.ZodEffects<z.ZodString, TNode, string>;
34
+ type ChildListSchema<TNode> = z.ZodEffects<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodObject<{
35
+ componentId: z.ZodString;
36
+ path: z.ZodString;
37
+ }>]>, TNode>;
38
+ /**
39
+ * One component id. The component receives the rendered child. Pass the
40
+ * description here, not with `.describe()`, which would replace the mark.
41
+ */
42
+ declare function child(description?: string): ChildSchema<GenerativeUIChildNode>;
43
+ declare function child<TNode>(description?: string): ChildSchema<TNode>;
44
+ /**
45
+ * A list of component ids, or a template `{ componentId, path }` that
46
+ * repeats one component for each item of the list at `path`. The
47
+ * component receives the rendered children. Pass the description here,
48
+ * not with `.describe()`.
49
+ */
50
+ declare function childList(description?: string): ChildListSchema<GenerativeUIChildNode>;
51
+ declare function childList<TNode>(description?: string): ChildListSchema<TNode>;
52
+ //#endregion
53
+ export { GenerativeUIChildNode, child, childList };
54
+ //# sourceMappingURL=refs.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.cts","names":[],"sources":["../../../src/generative-ui/catalog/refs.ts"],"mappings":";;;;;AAAwB;;;;;AA+BxB;;;;;AAEC;;;;;;;;;cARa,cAAA;;;;;UAMG,qBAAA;EAAA,UACL,cAAA;AAAA;AAAA,KAGP,WAAA,UAAqB,CAAA,CAAE,UAAA,CAAW,CAAA,CAAE,SAAA,EAAW,KAAA;AAAA,KAC/C,eAAA,UAAyB,CAAA,CAAE,UAAA,CAC9B,CAAA,CAAE,QAAA,EAEE,CAAA,CAAE,QAAA,CAAS,CAAA,CAAE,SAAA,GACb,CAAA,CAAE,SAAA;EAAY,WAAA,EAAa,CAAA,CAAE,SAAA;EAAW,IAAA,EAAM,CAAA,CAAE,SAAA;AAAA,MAGpD,KAAA;;;;;iBAcc,KAAA,CAAM,WAAA,YAAuB,WAAA,CAAY,qBAAA;AAAA,iBACzC,KAAA,OAAA,CAAa,WAAA,YAAuB,WAAA,CAAY,KAAA;;;;;;;iBAehD,SAAA,CACd,WAAA,YACC,eAAA,CAAgB,qBAAA;AAAA,iBACH,SAAA,OAAA,CAAiB,WAAA,YAAuB,eAAA,CAAgB,KAAA"}
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/generative-ui/catalog/refs.d.ts
4
+ /**
5
+ * Schema helpers that mark a prop as a component reference, the way A2UI
6
+ * 1.0 marks it with the `ComponentId` and `ChildList` common types. The
7
+ * engine finds every marked prop in the props schema, at any depth, renders
8
+ * the referenced components, and hands the component the rendered nodes in
9
+ * place of the ids. The model sees the prop as `componentId` or as a list
10
+ * of ids or a template.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const tabsSchema = z.object({
15
+ * tabs: z.array(z.object({ title: z.string(), child: child() })),
16
+ * });
17
+ * // A React component gets `tabs: { title: string; child: ReactNode }[]`.
18
+ * ```
19
+ *
20
+ * `TNode` is the type of a rendered child in the framework that renders the
21
+ * UI. Each framework package exports `child` and `childList` with it set.
22
+ * Without it, the output is `GenerativeUIChildNode`, which
23
+ * `GenerativeUIComponentProps` replaces with the node type of the framework.
24
+ */
25
+ declare const childNodeBrand: unique symbol;
26
+ /**
27
+ * A rendered child in a framework-free schema. `GenerativeUIComponentProps`
28
+ * replaces it with the node type that the framework passes.
29
+ */
30
+ interface GenerativeUIChildNode {
31
+ readonly [childNodeBrand]: true;
32
+ }
33
+ type ChildSchema<TNode> = z.ZodEffects<z.ZodString, TNode, string>;
34
+ type ChildListSchema<TNode> = z.ZodEffects<z.ZodUnion<[z.ZodArray<z.ZodString>, z.ZodObject<{
35
+ componentId: z.ZodString;
36
+ path: z.ZodString;
37
+ }>]>, TNode>;
38
+ /**
39
+ * One component id. The component receives the rendered child. Pass the
40
+ * description here, not with `.describe()`, which would replace the mark.
41
+ */
42
+ declare function child(description?: string): ChildSchema<GenerativeUIChildNode>;
43
+ declare function child<TNode>(description?: string): ChildSchema<TNode>;
44
+ /**
45
+ * A list of component ids, or a template `{ componentId, path }` that
46
+ * repeats one component for each item of the list at `path`. The
47
+ * component receives the rendered children. Pass the description here,
48
+ * not with `.describe()`.
49
+ */
50
+ declare function childList(description?: string): ChildListSchema<GenerativeUIChildNode>;
51
+ declare function childList<TNode>(description?: string): ChildListSchema<TNode>;
52
+ //#endregion
53
+ export { GenerativeUIChildNode, child, childList };
54
+ //# sourceMappingURL=refs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.mts","names":[],"sources":["../../../src/generative-ui/catalog/refs.ts"],"mappings":";;;;;AAAwB;;;;;AA+BxB;;;;;AAEC;;;;;;;;;cARa,cAAA;;;;;UAMG,qBAAA;EAAA,UACL,cAAA;AAAA;AAAA,KAGP,WAAA,UAAqB,CAAA,CAAE,UAAA,CAAW,CAAA,CAAE,SAAA,EAAW,KAAA;AAAA,KAC/C,eAAA,UAAyB,CAAA,CAAE,UAAA,CAC9B,CAAA,CAAE,QAAA,EAEE,CAAA,CAAE,QAAA,CAAS,CAAA,CAAE,SAAA,GACb,CAAA,CAAE,SAAA;EAAY,WAAA,EAAa,CAAA,CAAE,SAAA;EAAW,IAAA,EAAM,CAAA,CAAE,SAAA;AAAA,MAGpD,KAAA;;;;;iBAcc,KAAA,CAAM,WAAA,YAAuB,WAAA,CAAY,qBAAA;AAAA,iBACzC,KAAA,OAAA,CAAa,WAAA,YAAuB,WAAA,CAAY,KAAA;;;;;;;iBAehD,SAAA,CACd,WAAA,YACC,eAAA,CAAgB,qBAAA;AAAA,iBACH,SAAA,OAAA,CAAiB,WAAA,YAAuB,eAAA,CAAgB,KAAA"}
@@ -0,0 +1,18 @@
1
+ import { A2UI_CHILD_LIST_MARK, A2UI_COMPONENT_ID_MARK } from "../child-refs.mjs";
2
+ import { z } from "zod";
3
+
4
+ //#region src/generative-ui/catalog/refs.ts
5
+ const mark = (prefix, description) => description ? `${prefix} ${description}` : prefix;
6
+ function child(description) {
7
+ return z.string().min(1).describe(mark(A2UI_COMPONENT_ID_MARK, description)).transform((value) => value);
8
+ }
9
+ function childList(description) {
10
+ return z.union([z.array(z.string().min(1)), z.object({
11
+ componentId: z.string().min(1),
12
+ path: z.string().min(1)
13
+ })]).describe(mark(A2UI_CHILD_LIST_MARK, description)).transform((value) => value);
14
+ }
15
+
16
+ //#endregion
17
+ export { child, childList };
18
+ //# sourceMappingURL=refs.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.mjs","names":[],"sources":["../../../src/generative-ui/catalog/refs.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { A2UI_CHILD_LIST_MARK, A2UI_COMPONENT_ID_MARK } from \"../base\";\n\n/**\n * Schema helpers that mark a prop as a component reference, the way A2UI\n * 1.0 marks it with the `ComponentId` and `ChildList` common types. The\n * engine finds every marked prop in the props schema, at any depth, renders\n * the referenced components, and hands the component the rendered nodes in\n * place of the ids. The model sees the prop as `componentId` or as a list\n * of ids or a template.\n *\n * @example\n * ```ts\n * const tabsSchema = z.object({\n * tabs: z.array(z.object({ title: z.string(), child: child() })),\n * });\n * // A React component gets `tabs: { title: string; child: ReactNode }[]`.\n * ```\n *\n * `TNode` is the type of a rendered child in the framework that renders the\n * UI. Each framework package exports `child` and `childList` with it set.\n * Without it, the output is `GenerativeUIChildNode`, which\n * `GenerativeUIComponentProps` replaces with the node type of the framework.\n */\n\ndeclare const childNodeBrand: unique symbol;\n\n/**\n * A rendered child in a framework-free schema. `GenerativeUIComponentProps`\n * replaces it with the node type that the framework passes.\n */\nexport interface GenerativeUIChildNode {\n readonly [childNodeBrand]: true;\n}\n\ntype ChildSchema<TNode> = z.ZodEffects<z.ZodString, TNode, string>;\ntype ChildListSchema<TNode> = z.ZodEffects<\n z.ZodUnion<\n [\n z.ZodArray<z.ZodString>,\n z.ZodObject<{ componentId: z.ZodString; path: z.ZodString }>,\n ]\n >,\n TNode\n>;\n\n// Without a type argument, `child()` gives `GenerativeUIChildNode`. A\n// generic default is not enough: inside `z.object({ ... })`, TypeScript\n// would infer `TNode` from the shape and give `any`.\n\nconst mark = (prefix: string, description: string | undefined) =>\n description ? `${prefix} ${description}` : prefix;\n\n/**\n * One component id. The component receives the rendered child. Pass the\n * description here, not with `.describe()`, which would replace the mark.\n */\nexport function child(description?: string): ChildSchema<GenerativeUIChildNode>;\nexport function child<TNode>(description?: string): ChildSchema<TNode>;\nexport function child(description?: string): ChildSchema<unknown> {\n return z\n .string()\n .min(1)\n .describe(mark(A2UI_COMPONENT_ID_MARK, description))\n .transform((value) => value as unknown);\n}\n\n/**\n * A list of component ids, or a template `{ componentId, path }` that\n * repeats one component for each item of the list at `path`. The\n * component receives the rendered children. Pass the description here,\n * not with `.describe()`.\n */\nexport function childList(\n description?: string,\n): ChildListSchema<GenerativeUIChildNode>;\nexport function childList<TNode>(description?: string): ChildListSchema<TNode>;\nexport function childList(description?: string): ChildListSchema<unknown> {\n return z\n .union([\n z.array(z.string().min(1)),\n z.object({ componentId: z.string().min(1), path: z.string().min(1) }),\n ])\n .describe(mark(A2UI_CHILD_LIST_MARK, description))\n .transform((value) => value as unknown);\n}\n"],"mappings":";;;;AAkDA,MAAM,QAAQ,QAAgB,gBAC5B,cAAc,GAAG,OAAO,GAAG,gBAAgB;AAQ7C,SAAgB,MAAM,aAA4C;AAChE,QAAO,EACJ,QAAQ,CACR,IAAI,EAAE,CACN,SAAS,KAAK,wBAAwB,YAAY,CAAC,CACnD,WAAW,UAAU,MAAiB;;AAa3C,SAAgB,UAAU,aAAgD;AACxE,QAAO,EACJ,MAAM,CACL,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,EAC1B,EAAE,OAAO;EAAE,aAAa,EAAE,QAAQ,CAAC,IAAI,EAAE;EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE;EAAE,CAAC,CACtE,CAAC,CACD,SAAS,KAAK,sBAAsB,YAAY,CAAC,CACjD,WAAW,UAAU,MAAiB"}
@@ -0,0 +1,74 @@
1
+
2
+ //#region src/generative-ui/catalog/schema.ts
3
+ const ASYNC_ISSUE = { message: "the schema validates asynchronously; component props and state need a schema that validates synchronously" };
4
+ function toResult(result) {
5
+ return result.issues ? {
6
+ success: false,
7
+ issues: result.issues
8
+ } : {
9
+ success: true,
10
+ data: result.value
11
+ };
12
+ }
13
+ /**
14
+ * Validates `value` with `schema`. The result comes back at once when the
15
+ * schema validates synchronously, else as a promise.
16
+ */
17
+ function validateSchema(schema, value) {
18
+ const result = schema["~standard"].validate(value);
19
+ return result instanceof Promise ? result.then(toResult) : toResult(result);
20
+ }
21
+ /**
22
+ * Validates `value` synchronously, for code that runs during render. A
23
+ * schema that validates asynchronously fails with an issue that says so.
24
+ */
25
+ function validateSchemaSync(schema, value) {
26
+ const result = validateSchema(schema, value);
27
+ if (!(result instanceof Promise)) return result;
28
+ result.catch(() => {});
29
+ return {
30
+ success: false,
31
+ issues: [ASYNC_ISSUE]
32
+ };
33
+ }
34
+ /** True for the issue that `validateSchemaSync` gives for an async schema. */
35
+ function isAsyncIssue(issue) {
36
+ return issue === ASYNC_ISSUE;
37
+ }
38
+ /** The first key of an issue path: the prop the issue is about. */
39
+ function issueKey(issue) {
40
+ const first = issue.path?.[0];
41
+ const key = typeof first === "object" ? first.key : first;
42
+ return key === void 0 ? void 0 : String(key);
43
+ }
44
+ /**
45
+ * `props` without the top-level props whose `null` the schema rejected, or
46
+ * `undefined` when there are none. A model writes `null` for "not set" (an
47
+ * empty selection, a value it has not filled yet), and A2UI deletes a data
48
+ * model key that is set to `null`, so a rejected `null` is read as an unset
49
+ * prop. A prop whose schema accepts `null` keeps it.
50
+ */
51
+ function withoutRejectedNulls(props, issues) {
52
+ const rejected = /* @__PURE__ */ new Set();
53
+ for (const issue of issues) {
54
+ const key = issueKey(issue);
55
+ if (key !== void 0 && issue.path?.length === 1 && props[key] === null) rejected.add(key);
56
+ }
57
+ if (rejected.size === 0) return void 0;
58
+ return Object.fromEntries(Object.entries(props).filter(([key]) => !rejected.has(key)));
59
+ }
60
+ /** `"a.b: message; c: message"`. A path-less issue gets `fallback`. */
61
+ function formatIssues(issues, fallback = "props") {
62
+ return issues.map((issue) => {
63
+ return `${(issue.path ?? []).map((segment) => String(typeof segment === "object" ? segment.key : segment)).join(".") || fallback}: ${issue.message}`;
64
+ }).join("; ");
65
+ }
66
+
67
+ //#endregion
68
+ exports.formatIssues = formatIssues;
69
+ exports.isAsyncIssue = isAsyncIssue;
70
+ exports.issueKey = issueKey;
71
+ exports.validateSchema = validateSchema;
72
+ exports.validateSchemaSync = validateSchemaSync;
73
+ exports.withoutRejectedNulls = withoutRejectedNulls;
74
+ //# sourceMappingURL=schema.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.cjs","names":[],"sources":["../../../src/generative-ui/catalog/schema.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"../../standard-schema\";\n\n/** Any Standard Schema: zod, Valibot, ArkType, and more. */\nexport type GenerativeUISchema = StandardSchemaV1;\n\n/** The output type of a schema: what validation gives back. */\nexport type SchemaOutput<Schema> =\n Schema extends StandardSchemaV1<any, infer Output> ? Output : never;\n\n/** The input type of a schema: what validation takes. */\nexport type SchemaInput<Schema> =\n Schema extends StandardSchemaV1<infer Input, any> ? Input : never;\n\nexport type ValidationResult =\n | { success: true; data: unknown }\n | { success: false; issues: readonly StandardSchemaV1.Issue[] };\n\nconst ASYNC_ISSUE: StandardSchemaV1.Issue = {\n message:\n \"the schema validates asynchronously; component props and state need a schema that validates synchronously\",\n};\n\nfunction toResult(result: StandardSchemaV1.Result<unknown>): ValidationResult {\n return result.issues\n ? { success: false, issues: result.issues }\n : { success: true, data: result.value };\n}\n\n/**\n * Validates `value` with `schema`. The result comes back at once when the\n * schema validates synchronously, else as a promise.\n */\nexport function validateSchema(\n schema: StandardSchemaV1,\n value: unknown,\n): ValidationResult | Promise<ValidationResult> {\n const result = schema[\"~standard\"].validate(value);\n return result instanceof Promise ? result.then(toResult) : toResult(result);\n}\n\n/**\n * Validates `value` synchronously, for code that runs during render. A\n * schema that validates asynchronously fails with an issue that says so.\n */\nexport function validateSchemaSync(\n schema: StandardSchemaV1,\n value: unknown,\n): ValidationResult {\n const result = validateSchema(schema, value);\n if (!(result instanceof Promise)) return result;\n // ponytail: the async result is dropped, because render cannot wait for it.\n result.catch(() => {});\n return { success: false, issues: [ASYNC_ISSUE] };\n}\n\n/** True for the issue that `validateSchemaSync` gives for an async schema. */\nexport function isAsyncIssue(issue: StandardSchemaV1.Issue) {\n return issue === ASYNC_ISSUE;\n}\n\n/** The first key of an issue path: the prop the issue is about. */\nexport function issueKey(issue: StandardSchemaV1.Issue) {\n const first = issue.path?.[0];\n const key = typeof first === \"object\" ? first.key : first;\n return key === undefined ? undefined : String(key);\n}\n\n/**\n * `props` without the top-level props whose `null` the schema rejected, or\n * `undefined` when there are none. A model writes `null` for \"not set\" (an\n * empty selection, a value it has not filled yet), and A2UI deletes a data\n * model key that is set to `null`, so a rejected `null` is read as an unset\n * prop. A prop whose schema accepts `null` keeps it.\n */\nexport function withoutRejectedNulls(\n props: Record<string, unknown>,\n issues: readonly StandardSchemaV1.Issue[],\n): Record<string, unknown> | undefined {\n const rejected = new Set<string>();\n for (const issue of issues) {\n const key = issueKey(issue);\n if (key !== undefined && issue.path?.length === 1 && props[key] === null) {\n rejected.add(key);\n }\n }\n if (rejected.size === 0) return undefined;\n return Object.fromEntries(\n Object.entries(props).filter(([key]) => !rejected.has(key)),\n );\n}\n\n/** `\"a.b: message; c: message\"`. A path-less issue gets `fallback`. */\nexport function formatIssues(\n issues: readonly StandardSchemaV1.Issue[],\n fallback = \"props\",\n) {\n return issues\n .map((issue) => {\n const path = (issue.path ?? [])\n .map((segment) =>\n String(typeof segment === \"object\" ? segment.key : segment),\n )\n .join(\".\");\n return `${path || fallback}: ${issue.message}`;\n })\n .join(\"; \");\n}\n"],"mappings":";;AAiBA,MAAM,cAAsC,EAC1C,SACE,6GACH;AAED,SAAS,SAAS,QAA4D;AAC5E,QAAO,OAAO,SACV;EAAE,SAAS;EAAO,QAAQ,OAAO;EAAQ,GACzC;EAAE,SAAS;EAAM,MAAM,OAAO;EAAO;;;;;;AAO3C,SAAgB,eACd,QACA,OAC8C;CAC9C,MAAM,SAAS,OAAO,aAAa,SAAS,MAAM;AAClD,QAAO,kBAAkB,UAAU,OAAO,KAAK,SAAS,GAAG,SAAS,OAAO;;;;;;AAO7E,SAAgB,mBACd,QACA,OACkB;CAClB,MAAM,SAAS,eAAe,QAAQ,MAAM;AAC5C,KAAI,EAAE,kBAAkB,SAAU,QAAO;AAEzC,QAAO,YAAY,GAAG;AACtB,QAAO;EAAE,SAAS;EAAO,QAAQ,CAAC,YAAY;EAAE;;;AAIlD,SAAgB,aAAa,OAA+B;AAC1D,QAAO,UAAU;;;AAInB,SAAgB,SAAS,OAA+B;CACtD,MAAM,QAAQ,MAAM,OAAO;CAC3B,MAAM,MAAM,OAAO,UAAU,WAAW,MAAM,MAAM;AACpD,QAAO,QAAQ,SAAY,SAAY,OAAO,IAAI;;;;;;;;;AAUpD,SAAgB,qBACd,OACA,QACqC;CACrC,MAAM,2BAAW,IAAI,KAAa;AAClC,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,MAAM,SAAS,MAAM;AAC3B,MAAI,QAAQ,UAAa,MAAM,MAAM,WAAW,KAAK,MAAM,SAAS,KAClE,UAAS,IAAI,IAAI;;AAGrB,KAAI,SAAS,SAAS,EAAG,QAAO;AAChC,QAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC,CAC5D;;;AAIH,SAAgB,aACd,QACA,WAAW,SACX;AACA,QAAO,OACJ,KAAK,UAAU;AAMd,SAAO,IALO,MAAM,QAAQ,EAAE,EAC3B,KAAK,YACJ,OAAO,OAAO,YAAY,WAAW,QAAQ,MAAM,QAAQ,CAC5D,CACA,KAAK,IAAI,IACM,SAAS,IAAI,MAAM;GACrC,CACD,KAAK,KAAK"}
@@ -0,0 +1,43 @@
1
+ import { StandardSchemaV1 } from "../../standard-schema.cjs";
2
+
3
+ //#region src/generative-ui/catalog/schema.d.ts
4
+ /** Any Standard Schema: zod, Valibot, ArkType, and more. */
5
+ type GenerativeUISchema = StandardSchemaV1;
6
+ /** The output type of a schema: what validation gives back. */
7
+ type SchemaOutput<Schema> = Schema extends StandardSchemaV1<any, infer Output> ? Output : never;
8
+ /** The input type of a schema: what validation takes. */
9
+ type SchemaInput<Schema> = Schema extends StandardSchemaV1<infer Input, any> ? Input : never;
10
+ type ValidationResult = {
11
+ success: true;
12
+ data: unknown;
13
+ } | {
14
+ success: false;
15
+ issues: readonly StandardSchemaV1.Issue[];
16
+ };
17
+ /**
18
+ * Validates `value` with `schema`. The result comes back at once when the
19
+ * schema validates synchronously, else as a promise.
20
+ */
21
+ declare function validateSchema(schema: StandardSchemaV1, value: unknown): ValidationResult | Promise<ValidationResult>;
22
+ /**
23
+ * Validates `value` synchronously, for code that runs during render. A
24
+ * schema that validates asynchronously fails with an issue that says so.
25
+ */
26
+ declare function validateSchemaSync(schema: StandardSchemaV1, value: unknown): ValidationResult;
27
+ /** True for the issue that `validateSchemaSync` gives for an async schema. */
28
+ declare function isAsyncIssue(issue: StandardSchemaV1.Issue): boolean;
29
+ /** The first key of an issue path: the prop the issue is about. */
30
+ declare function issueKey(issue: StandardSchemaV1.Issue): string | undefined;
31
+ /**
32
+ * `props` without the top-level props whose `null` the schema rejected, or
33
+ * `undefined` when there are none. A model writes `null` for "not set" (an
34
+ * empty selection, a value it has not filled yet), and A2UI deletes a data
35
+ * model key that is set to `null`, so a rejected `null` is read as an unset
36
+ * prop. A prop whose schema accepts `null` keeps it.
37
+ */
38
+ declare function withoutRejectedNulls(props: Record<string, unknown>, issues: readonly StandardSchemaV1.Issue[]): Record<string, unknown> | undefined;
39
+ /** `"a.b: message; c: message"`. A path-less issue gets `fallback`. */
40
+ declare function formatIssues(issues: readonly StandardSchemaV1.Issue[], fallback?: string): string;
41
+ //#endregion
42
+ export { GenerativeUISchema, SchemaInput, SchemaOutput, ValidationResult, formatIssues, isAsyncIssue, issueKey, validateSchema, validateSchemaSync, withoutRejectedNulls };
43
+ //# sourceMappingURL=schema.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.cts","names":[],"sources":["../../../src/generative-ui/catalog/schema.ts"],"mappings":";;;;KAGY,kBAAA,GAAqB,gBAAA;AAAjC;AAAA,KAGY,YAAA,WACV,MAAA,SAAe,gBAAA,sBAAsC,MAAA;;KAG3C,WAAA,WACV,MAAA,SAAe,gBAAA,qBAAqC,KAAA;AAAA,KAE1C,gBAAA;EACN,OAAA;EAAe,IAAA;AAAA;EACf,OAAA;EAAgB,MAAA,WAAiB,gBAAA,CAAiB,KAAA;AAAA;;;;;iBAiBxC,cAAA,CACd,MAAA,EAAQ,gBAAA,EACR,KAAA,YACC,gBAAA,GAAmB,OAAA,CAAQ,gBAAA;AAzB9B;;;;AAAA,iBAkCgB,kBAAA,CACd,MAAA,EAAQ,gBAAA,EACR,KAAA,YACC,gBAAA;;iBASa,YAAA,CAAa,KAAA,EAAO,gBAAA,CAAiB,KAAA;;iBAKrC,QAAA,CAAS,KAAA,EAAO,gBAAA,CAAiB,KAAA;;;AAhDjD;;;;;iBA6DgB,oBAAA,CACd,KAAA,EAAO,MAAA,mBACP,MAAA,WAAiB,gBAAA,CAAiB,KAAA,KACjC,MAAA;;iBAea,YAAA,CACd,MAAA,WAAiB,gBAAA,CAAiB,KAAA,IAClC,QAAA"}
@@ -0,0 +1,43 @@
1
+ import { StandardSchemaV1 } from "../../standard-schema.mjs";
2
+
3
+ //#region src/generative-ui/catalog/schema.d.ts
4
+ /** Any Standard Schema: zod, Valibot, ArkType, and more. */
5
+ type GenerativeUISchema = StandardSchemaV1;
6
+ /** The output type of a schema: what validation gives back. */
7
+ type SchemaOutput<Schema> = Schema extends StandardSchemaV1<any, infer Output> ? Output : never;
8
+ /** The input type of a schema: what validation takes. */
9
+ type SchemaInput<Schema> = Schema extends StandardSchemaV1<infer Input, any> ? Input : never;
10
+ type ValidationResult = {
11
+ success: true;
12
+ data: unknown;
13
+ } | {
14
+ success: false;
15
+ issues: readonly StandardSchemaV1.Issue[];
16
+ };
17
+ /**
18
+ * Validates `value` with `schema`. The result comes back at once when the
19
+ * schema validates synchronously, else as a promise.
20
+ */
21
+ declare function validateSchema(schema: StandardSchemaV1, value: unknown): ValidationResult | Promise<ValidationResult>;
22
+ /**
23
+ * Validates `value` synchronously, for code that runs during render. A
24
+ * schema that validates asynchronously fails with an issue that says so.
25
+ */
26
+ declare function validateSchemaSync(schema: StandardSchemaV1, value: unknown): ValidationResult;
27
+ /** True for the issue that `validateSchemaSync` gives for an async schema. */
28
+ declare function isAsyncIssue(issue: StandardSchemaV1.Issue): boolean;
29
+ /** The first key of an issue path: the prop the issue is about. */
30
+ declare function issueKey(issue: StandardSchemaV1.Issue): string | undefined;
31
+ /**
32
+ * `props` without the top-level props whose `null` the schema rejected, or
33
+ * `undefined` when there are none. A model writes `null` for "not set" (an
34
+ * empty selection, a value it has not filled yet), and A2UI deletes a data
35
+ * model key that is set to `null`, so a rejected `null` is read as an unset
36
+ * prop. A prop whose schema accepts `null` keeps it.
37
+ */
38
+ declare function withoutRejectedNulls(props: Record<string, unknown>, issues: readonly StandardSchemaV1.Issue[]): Record<string, unknown> | undefined;
39
+ /** `"a.b: message; c: message"`. A path-less issue gets `fallback`. */
40
+ declare function formatIssues(issues: readonly StandardSchemaV1.Issue[], fallback?: string): string;
41
+ //#endregion
42
+ export { GenerativeUISchema, SchemaInput, SchemaOutput, ValidationResult, formatIssues, isAsyncIssue, issueKey, validateSchema, validateSchemaSync, withoutRejectedNulls };
43
+ //# sourceMappingURL=schema.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.mts","names":[],"sources":["../../../src/generative-ui/catalog/schema.ts"],"mappings":";;;;KAGY,kBAAA,GAAqB,gBAAA;AAAjC;AAAA,KAGY,YAAA,WACV,MAAA,SAAe,gBAAA,sBAAsC,MAAA;;KAG3C,WAAA,WACV,MAAA,SAAe,gBAAA,qBAAqC,KAAA;AAAA,KAE1C,gBAAA;EACN,OAAA;EAAe,IAAA;AAAA;EACf,OAAA;EAAgB,MAAA,WAAiB,gBAAA,CAAiB,KAAA;AAAA;;;;;iBAiBxC,cAAA,CACd,MAAA,EAAQ,gBAAA,EACR,KAAA,YACC,gBAAA,GAAmB,OAAA,CAAQ,gBAAA;AAzB9B;;;;AAAA,iBAkCgB,kBAAA,CACd,MAAA,EAAQ,gBAAA,EACR,KAAA,YACC,gBAAA;;iBASa,YAAA,CAAa,KAAA,EAAO,gBAAA,CAAiB,KAAA;;iBAKrC,QAAA,CAAS,KAAA,EAAO,gBAAA,CAAiB,KAAA;;;AAhDjD;;;;;iBA6DgB,oBAAA,CACd,KAAA,EAAO,MAAA,mBACP,MAAA,WAAiB,gBAAA,CAAiB,KAAA,KACjC,MAAA;;iBAea,YAAA,CACd,MAAA,WAAiB,gBAAA,CAAiB,KAAA,IAClC,QAAA"}
@@ -0,0 +1,68 @@
1
+ //#region src/generative-ui/catalog/schema.ts
2
+ const ASYNC_ISSUE = { message: "the schema validates asynchronously; component props and state need a schema that validates synchronously" };
3
+ function toResult(result) {
4
+ return result.issues ? {
5
+ success: false,
6
+ issues: result.issues
7
+ } : {
8
+ success: true,
9
+ data: result.value
10
+ };
11
+ }
12
+ /**
13
+ * Validates `value` with `schema`. The result comes back at once when the
14
+ * schema validates synchronously, else as a promise.
15
+ */
16
+ function validateSchema(schema, value) {
17
+ const result = schema["~standard"].validate(value);
18
+ return result instanceof Promise ? result.then(toResult) : toResult(result);
19
+ }
20
+ /**
21
+ * Validates `value` synchronously, for code that runs during render. A
22
+ * schema that validates asynchronously fails with an issue that says so.
23
+ */
24
+ function validateSchemaSync(schema, value) {
25
+ const result = validateSchema(schema, value);
26
+ if (!(result instanceof Promise)) return result;
27
+ result.catch(() => {});
28
+ return {
29
+ success: false,
30
+ issues: [ASYNC_ISSUE]
31
+ };
32
+ }
33
+ /** True for the issue that `validateSchemaSync` gives for an async schema. */
34
+ function isAsyncIssue(issue) {
35
+ return issue === ASYNC_ISSUE;
36
+ }
37
+ /** The first key of an issue path: the prop the issue is about. */
38
+ function issueKey(issue) {
39
+ const first = issue.path?.[0];
40
+ const key = typeof first === "object" ? first.key : first;
41
+ return key === void 0 ? void 0 : String(key);
42
+ }
43
+ /**
44
+ * `props` without the top-level props whose `null` the schema rejected, or
45
+ * `undefined` when there are none. A model writes `null` for "not set" (an
46
+ * empty selection, a value it has not filled yet), and A2UI deletes a data
47
+ * model key that is set to `null`, so a rejected `null` is read as an unset
48
+ * prop. A prop whose schema accepts `null` keeps it.
49
+ */
50
+ function withoutRejectedNulls(props, issues) {
51
+ const rejected = /* @__PURE__ */ new Set();
52
+ for (const issue of issues) {
53
+ const key = issueKey(issue);
54
+ if (key !== void 0 && issue.path?.length === 1 && props[key] === null) rejected.add(key);
55
+ }
56
+ if (rejected.size === 0) return void 0;
57
+ return Object.fromEntries(Object.entries(props).filter(([key]) => !rejected.has(key)));
58
+ }
59
+ /** `"a.b: message; c: message"`. A path-less issue gets `fallback`. */
60
+ function formatIssues(issues, fallback = "props") {
61
+ return issues.map((issue) => {
62
+ return `${(issue.path ?? []).map((segment) => String(typeof segment === "object" ? segment.key : segment)).join(".") || fallback}: ${issue.message}`;
63
+ }).join("; ");
64
+ }
65
+
66
+ //#endregion
67
+ export { formatIssues, isAsyncIssue, issueKey, validateSchema, validateSchemaSync, withoutRejectedNulls };
68
+ //# sourceMappingURL=schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.mjs","names":[],"sources":["../../../src/generative-ui/catalog/schema.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"../../standard-schema\";\n\n/** Any Standard Schema: zod, Valibot, ArkType, and more. */\nexport type GenerativeUISchema = StandardSchemaV1;\n\n/** The output type of a schema: what validation gives back. */\nexport type SchemaOutput<Schema> =\n Schema extends StandardSchemaV1<any, infer Output> ? Output : never;\n\n/** The input type of a schema: what validation takes. */\nexport type SchemaInput<Schema> =\n Schema extends StandardSchemaV1<infer Input, any> ? Input : never;\n\nexport type ValidationResult =\n | { success: true; data: unknown }\n | { success: false; issues: readonly StandardSchemaV1.Issue[] };\n\nconst ASYNC_ISSUE: StandardSchemaV1.Issue = {\n message:\n \"the schema validates asynchronously; component props and state need a schema that validates synchronously\",\n};\n\nfunction toResult(result: StandardSchemaV1.Result<unknown>): ValidationResult {\n return result.issues\n ? { success: false, issues: result.issues }\n : { success: true, data: result.value };\n}\n\n/**\n * Validates `value` with `schema`. The result comes back at once when the\n * schema validates synchronously, else as a promise.\n */\nexport function validateSchema(\n schema: StandardSchemaV1,\n value: unknown,\n): ValidationResult | Promise<ValidationResult> {\n const result = schema[\"~standard\"].validate(value);\n return result instanceof Promise ? result.then(toResult) : toResult(result);\n}\n\n/**\n * Validates `value` synchronously, for code that runs during render. A\n * schema that validates asynchronously fails with an issue that says so.\n */\nexport function validateSchemaSync(\n schema: StandardSchemaV1,\n value: unknown,\n): ValidationResult {\n const result = validateSchema(schema, value);\n if (!(result instanceof Promise)) return result;\n // ponytail: the async result is dropped, because render cannot wait for it.\n result.catch(() => {});\n return { success: false, issues: [ASYNC_ISSUE] };\n}\n\n/** True for the issue that `validateSchemaSync` gives for an async schema. */\nexport function isAsyncIssue(issue: StandardSchemaV1.Issue) {\n return issue === ASYNC_ISSUE;\n}\n\n/** The first key of an issue path: the prop the issue is about. */\nexport function issueKey(issue: StandardSchemaV1.Issue) {\n const first = issue.path?.[0];\n const key = typeof first === \"object\" ? first.key : first;\n return key === undefined ? undefined : String(key);\n}\n\n/**\n * `props` without the top-level props whose `null` the schema rejected, or\n * `undefined` when there are none. A model writes `null` for \"not set\" (an\n * empty selection, a value it has not filled yet), and A2UI deletes a data\n * model key that is set to `null`, so a rejected `null` is read as an unset\n * prop. A prop whose schema accepts `null` keeps it.\n */\nexport function withoutRejectedNulls(\n props: Record<string, unknown>,\n issues: readonly StandardSchemaV1.Issue[],\n): Record<string, unknown> | undefined {\n const rejected = new Set<string>();\n for (const issue of issues) {\n const key = issueKey(issue);\n if (key !== undefined && issue.path?.length === 1 && props[key] === null) {\n rejected.add(key);\n }\n }\n if (rejected.size === 0) return undefined;\n return Object.fromEntries(\n Object.entries(props).filter(([key]) => !rejected.has(key)),\n );\n}\n\n/** `\"a.b: message; c: message\"`. A path-less issue gets `fallback`. */\nexport function formatIssues(\n issues: readonly StandardSchemaV1.Issue[],\n fallback = \"props\",\n) {\n return issues\n .map((issue) => {\n const path = (issue.path ?? [])\n .map((segment) =>\n String(typeof segment === \"object\" ? segment.key : segment),\n )\n .join(\".\");\n return `${path || fallback}: ${issue.message}`;\n })\n .join(\"; \");\n}\n"],"mappings":";AAiBA,MAAM,cAAsC,EAC1C,SACE,6GACH;AAED,SAAS,SAAS,QAA4D;AAC5E,QAAO,OAAO,SACV;EAAE,SAAS;EAAO,QAAQ,OAAO;EAAQ,GACzC;EAAE,SAAS;EAAM,MAAM,OAAO;EAAO;;;;;;AAO3C,SAAgB,eACd,QACA,OAC8C;CAC9C,MAAM,SAAS,OAAO,aAAa,SAAS,MAAM;AAClD,QAAO,kBAAkB,UAAU,OAAO,KAAK,SAAS,GAAG,SAAS,OAAO;;;;;;AAO7E,SAAgB,mBACd,QACA,OACkB;CAClB,MAAM,SAAS,eAAe,QAAQ,MAAM;AAC5C,KAAI,EAAE,kBAAkB,SAAU,QAAO;AAEzC,QAAO,YAAY,GAAG;AACtB,QAAO;EAAE,SAAS;EAAO,QAAQ,CAAC,YAAY;EAAE;;;AAIlD,SAAgB,aAAa,OAA+B;AAC1D,QAAO,UAAU;;;AAInB,SAAgB,SAAS,OAA+B;CACtD,MAAM,QAAQ,MAAM,OAAO;CAC3B,MAAM,MAAM,OAAO,UAAU,WAAW,MAAM,MAAM;AACpD,QAAO,QAAQ,SAAY,SAAY,OAAO,IAAI;;;;;;;;;AAUpD,SAAgB,qBACd,OACA,QACqC;CACrC,MAAM,2BAAW,IAAI,KAAa;AAClC,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,MAAM,SAAS,MAAM;AAC3B,MAAI,QAAQ,UAAa,MAAM,MAAM,WAAW,KAAK,MAAM,SAAS,KAClE,UAAS,IAAI,IAAI;;AAGrB,KAAI,SAAS,SAAS,EAAG,QAAO;AAChC,QAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC,CAC5D;;;AAIH,SAAgB,aACd,QACA,WAAW,SACX;AACA,QAAO,OACJ,KAAK,UAAU;AAMd,SAAO,IALO,MAAM,QAAQ,EAAE,EAC3B,KAAK,YACJ,OAAO,OAAO,YAAY,WAAW,QAAQ,MAAM,QAAQ,CAC5D,CACA,KAAK,IAAI,IACM,SAAS,IAAI,MAAM;GACrC,CACD,KAAK,KAAK"}