@schema-engine/forms 0.0.0-stage → 0.5.1

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 (614) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -2
  3. package/dist/actions/index.d.ts +3 -0
  4. package/dist/actions/index.js +50 -0
  5. package/dist/actions/index.js.map +7 -0
  6. package/dist/actions/plugins/auto-save.plugin.d.ts +39 -0
  7. package/dist/actions/plugins/auto-save.plugin.js +10 -0
  8. package/dist/actions/plugins/auto-save.plugin.js.map +7 -0
  9. package/dist/actions/plugins/form-reset.plugin.d.ts +23 -0
  10. package/dist/actions/plugins/form-reset.plugin.js +9 -0
  11. package/dist/actions/plugins/form-reset.plugin.js.map +7 -0
  12. package/dist/actions/plugins/form-submit.plugin.d.ts +31 -0
  13. package/dist/actions/plugins/form-submit.plugin.js +9 -0
  14. package/dist/actions/plugins/form-submit.plugin.js.map +7 -0
  15. package/dist/actions/plugins/form-submit.registration.d.ts +22 -0
  16. package/dist/actions/plugins/form-submit.registration.js +8 -0
  17. package/dist/actions/plugins/form-submit.registration.js.map +7 -0
  18. package/dist/actions/plugins/gtm.plugin.d.ts +30 -0
  19. package/dist/actions/plugins/gtm.plugin.js +8 -0
  20. package/dist/actions/plugins/gtm.plugin.js.map +7 -0
  21. package/dist/actions/plugins/index.d.ts +16 -0
  22. package/dist/actions/plugins/index.js +45 -0
  23. package/dist/actions/plugins/index.js.map +7 -0
  24. package/dist/actions/plugins/notification.plugin.d.ts +32 -0
  25. package/dist/actions/plugins/notification.plugin.js +9 -0
  26. package/dist/actions/plugins/notification.plugin.js.map +7 -0
  27. package/dist/actions/plugins/notification.registration.d.ts +22 -0
  28. package/dist/actions/plugins/notification.registration.js +8 -0
  29. package/dist/actions/plugins/notification.registration.js.map +7 -0
  30. package/dist/actions/plugins/registrations.d.ts +17 -0
  31. package/dist/actions/plugins/registrations.js +14 -0
  32. package/dist/actions/plugins/registrations.js.map +7 -0
  33. package/dist/actions/triggers.d.ts +42 -0
  34. package/dist/actions/triggers.js +6 -0
  35. package/dist/actions/triggers.js.map +7 -0
  36. package/dist/actions/types.d.ts +16 -0
  37. package/dist/actions/types.js +1 -0
  38. package/dist/actions/types.js.map +7 -0
  39. package/dist/agent-tool/index.d.ts +54 -0
  40. package/dist/agent-tool/index.js +128 -0
  41. package/dist/agent-tool/index.js.map +7 -0
  42. package/dist/browser/action-registrations.d.ts +46 -0
  43. package/dist/browser/action-registrations.js +19 -0
  44. package/dist/browser/action-registrations.js.map +7 -0
  45. package/dist/browser/index.d.ts +4 -0
  46. package/dist/browser/index.js +36 -0
  47. package/dist/browser/index.js.map +7 -0
  48. package/dist/browser/tools/auto-save-storage.d.ts +20 -0
  49. package/dist/browser/tools/auto-save-storage.js +12 -0
  50. package/dist/browser/tools/auto-save-storage.js.map +7 -0
  51. package/dist/browser/tools/gdpr-consent.d.ts +32 -0
  52. package/dist/browser/tools/gdpr-consent.js +11 -0
  53. package/dist/browser/tools/gdpr-consent.js.map +7 -0
  54. package/dist/browser/tools/gtm-tracker.d.ts +7 -0
  55. package/dist/browser/tools/gtm-tracker.js +7 -0
  56. package/dist/browser/tools/gtm-tracker.js.map +7 -0
  57. package/dist/builder/form-authoring.d.ts +159 -0
  58. package/dist/builder/form-authoring.js +1 -0
  59. package/dist/builder/form-authoring.js.map +7 -0
  60. package/dist/builder/form-values.d.ts +158 -0
  61. package/dist/builder/form-values.js +0 -0
  62. package/dist/builder/form-values.js.map +7 -0
  63. package/dist/builder/index.d.ts +5 -0
  64. package/dist/builder/index.js +2 -0
  65. package/dist/builder/index.js.map +7 -0
  66. package/dist/builder/types.utils.d.ts +137 -0
  67. package/dist/builder/types.utils.js +1 -0
  68. package/dist/builder/types.utils.js.map +7 -0
  69. package/dist/chunk-237BHPDH.js +88 -0
  70. package/dist/chunk-237BHPDH.js.map +7 -0
  71. package/dist/chunk-25PLQDKN.js +45 -0
  72. package/dist/chunk-25PLQDKN.js.map +7 -0
  73. package/dist/chunk-2XWISGGM.js +8 -0
  74. package/dist/chunk-2XWISGGM.js.map +7 -0
  75. package/dist/chunk-2YKQAVI2.js +8 -0
  76. package/dist/chunk-2YKQAVI2.js.map +7 -0
  77. package/dist/chunk-3B7CJOF6.js +18 -0
  78. package/dist/chunk-3B7CJOF6.js.map +7 -0
  79. package/dist/chunk-3YLRJVVN.js +17 -0
  80. package/dist/chunk-3YLRJVVN.js.map +7 -0
  81. package/dist/chunk-4CUGHU36.js +58 -0
  82. package/dist/chunk-4CUGHU36.js.map +7 -0
  83. package/dist/chunk-4FELFUCD.js +0 -0
  84. package/dist/chunk-4FELFUCD.js.map +7 -0
  85. package/dist/chunk-4XPLSYTK.js +82 -0
  86. package/dist/chunk-4XPLSYTK.js.map +7 -0
  87. package/dist/chunk-5Y6U3MR3.js +54 -0
  88. package/dist/chunk-5Y6U3MR3.js.map +7 -0
  89. package/dist/chunk-6BAJHAGL.js +29 -0
  90. package/dist/chunk-6BAJHAGL.js.map +7 -0
  91. package/dist/chunk-6EYX257T.js +23 -0
  92. package/dist/chunk-6EYX257T.js.map +7 -0
  93. package/dist/chunk-6FUGK5HQ.js +26 -0
  94. package/dist/chunk-6FUGK5HQ.js.map +7 -0
  95. package/dist/chunk-6IZYNHZ3.js +118 -0
  96. package/dist/chunk-6IZYNHZ3.js.map +7 -0
  97. package/dist/chunk-6NV2JDGI.js +8 -0
  98. package/dist/chunk-6NV2JDGI.js.map +7 -0
  99. package/dist/chunk-6R2MBQPL.js +19 -0
  100. package/dist/chunk-6R2MBQPL.js.map +7 -0
  101. package/dist/chunk-7EQJUI5N.js +40 -0
  102. package/dist/chunk-7EQJUI5N.js.map +7 -0
  103. package/dist/chunk-A5VLMQAK.js +2780 -0
  104. package/dist/chunk-A5VLMQAK.js.map +7 -0
  105. package/dist/chunk-AUZ45XPE.js +27 -0
  106. package/dist/chunk-AUZ45XPE.js.map +7 -0
  107. package/dist/chunk-BIHEIJG3.js +0 -0
  108. package/dist/chunk-BIHEIJG3.js.map +7 -0
  109. package/dist/chunk-BKNWW4PK.js +0 -0
  110. package/dist/chunk-BKNWW4PK.js.map +7 -0
  111. package/dist/chunk-BLFLCSG3.js +71 -0
  112. package/dist/chunk-BLFLCSG3.js.map +7 -0
  113. package/dist/chunk-BYYGAGNH.js +0 -0
  114. package/dist/chunk-BYYGAGNH.js.map +7 -0
  115. package/dist/chunk-CANRZY5A.js +87 -0
  116. package/dist/chunk-CANRZY5A.js.map +7 -0
  117. package/dist/chunk-CAZPWBQ4.js +18 -0
  118. package/dist/chunk-CAZPWBQ4.js.map +7 -0
  119. package/dist/chunk-CMPOBBRV.js +10 -0
  120. package/dist/chunk-CMPOBBRV.js.map +7 -0
  121. package/dist/chunk-CRQWKC67.js +118 -0
  122. package/dist/chunk-CRQWKC67.js.map +7 -0
  123. package/dist/chunk-CRVXBWSY.js +70 -0
  124. package/dist/chunk-CRVXBWSY.js.map +7 -0
  125. package/dist/chunk-D6ZHV6AT.js +0 -0
  126. package/dist/chunk-D6ZHV6AT.js.map +7 -0
  127. package/dist/chunk-DP7SYLLI.js +206 -0
  128. package/dist/chunk-DP7SYLLI.js.map +7 -0
  129. package/dist/chunk-DVDKPY2A.js +12 -0
  130. package/dist/chunk-DVDKPY2A.js.map +7 -0
  131. package/dist/chunk-E4VONSLO.js +15 -0
  132. package/dist/chunk-E4VONSLO.js.map +7 -0
  133. package/dist/chunk-EEYGPPLU.js +185 -0
  134. package/dist/chunk-EEYGPPLU.js.map +7 -0
  135. package/dist/chunk-EI5TMJDC.js +56 -0
  136. package/dist/chunk-EI5TMJDC.js.map +7 -0
  137. package/dist/chunk-EQ5AIF3T.js +117 -0
  138. package/dist/chunk-EQ5AIF3T.js.map +7 -0
  139. package/dist/chunk-EZZHO6DQ.js +26 -0
  140. package/dist/chunk-EZZHO6DQ.js.map +7 -0
  141. package/dist/chunk-FUHLRG3M.js +130 -0
  142. package/dist/chunk-FUHLRG3M.js.map +7 -0
  143. package/dist/chunk-FVOL3ZOJ.js +101 -0
  144. package/dist/chunk-FVOL3ZOJ.js.map +7 -0
  145. package/dist/chunk-G33EUV7N.js +288 -0
  146. package/dist/chunk-G33EUV7N.js.map +7 -0
  147. package/dist/chunk-GH34XFCC.js +56 -0
  148. package/dist/chunk-GH34XFCC.js.map +7 -0
  149. package/dist/chunk-GKWRJ6H4.js +27 -0
  150. package/dist/chunk-GKWRJ6H4.js.map +7 -0
  151. package/dist/chunk-GQHMU3AR.js +907 -0
  152. package/dist/chunk-GQHMU3AR.js.map +7 -0
  153. package/dist/chunk-GRZU6F7Q.js +80 -0
  154. package/dist/chunk-GRZU6F7Q.js.map +7 -0
  155. package/dist/chunk-GT2LARKT.js +107 -0
  156. package/dist/chunk-GT2LARKT.js.map +7 -0
  157. package/dist/chunk-H4ABGAAG.js +60 -0
  158. package/dist/chunk-H4ABGAAG.js.map +7 -0
  159. package/dist/chunk-H63UHX42.js +93 -0
  160. package/dist/chunk-H63UHX42.js.map +7 -0
  161. package/dist/chunk-HIS4MGIR.js +8 -0
  162. package/dist/chunk-HIS4MGIR.js.map +7 -0
  163. package/dist/chunk-HPPFSWIV.js +213 -0
  164. package/dist/chunk-HPPFSWIV.js.map +7 -0
  165. package/dist/chunk-J2FC5K4B.js +87 -0
  166. package/dist/chunk-J2FC5K4B.js.map +7 -0
  167. package/dist/chunk-J5BSFDVK.js +123 -0
  168. package/dist/chunk-J5BSFDVK.js.map +7 -0
  169. package/dist/chunk-J7GSNWXT.js +151 -0
  170. package/dist/chunk-J7GSNWXT.js.map +7 -0
  171. package/dist/chunk-JA5ET6MC.js +550 -0
  172. package/dist/chunk-JA5ET6MC.js.map +7 -0
  173. package/dist/chunk-K22S7IZR.js +12 -0
  174. package/dist/chunk-K22S7IZR.js.map +7 -0
  175. package/dist/chunk-K5TMXCMY.js +139 -0
  176. package/dist/chunk-K5TMXCMY.js.map +7 -0
  177. package/dist/chunk-KE53GN4Q.js +246 -0
  178. package/dist/chunk-KE53GN4Q.js.map +7 -0
  179. package/dist/chunk-KFQEDSYI.js +24 -0
  180. package/dist/chunk-KFQEDSYI.js.map +7 -0
  181. package/dist/chunk-KH6QWB5Y.js +51 -0
  182. package/dist/chunk-KH6QWB5Y.js.map +7 -0
  183. package/dist/chunk-KLATKWUA.js +116 -0
  184. package/dist/chunk-KLATKWUA.js.map +7 -0
  185. package/dist/chunk-KSKWSUOB.js +17 -0
  186. package/dist/chunk-KSKWSUOB.js.map +7 -0
  187. package/dist/chunk-LFWEJXWE.js +68 -0
  188. package/dist/chunk-LFWEJXWE.js.map +7 -0
  189. package/dist/chunk-LMWJAD3B.js +24 -0
  190. package/dist/chunk-LMWJAD3B.js.map +7 -0
  191. package/dist/chunk-MD23VADH.js +92 -0
  192. package/dist/chunk-MD23VADH.js.map +7 -0
  193. package/dist/chunk-MKMJT3XR.js +0 -0
  194. package/dist/chunk-MKMJT3XR.js.map +7 -0
  195. package/dist/chunk-NJTLBSTR.js +82 -0
  196. package/dist/chunk-NJTLBSTR.js.map +7 -0
  197. package/dist/chunk-NJXKMF67.js +182 -0
  198. package/dist/chunk-NJXKMF67.js.map +7 -0
  199. package/dist/chunk-OBQBIOGN.js +16 -0
  200. package/dist/chunk-OBQBIOGN.js.map +7 -0
  201. package/dist/chunk-OLYHNFKC.js +82 -0
  202. package/dist/chunk-OLYHNFKC.js.map +7 -0
  203. package/dist/chunk-OR2L7EKO.js +33 -0
  204. package/dist/chunk-OR2L7EKO.js.map +7 -0
  205. package/dist/chunk-OUF57UZ7.js +28 -0
  206. package/dist/chunk-OUF57UZ7.js.map +7 -0
  207. package/dist/chunk-PBMM2N77.js +56 -0
  208. package/dist/chunk-PBMM2N77.js.map +7 -0
  209. package/dist/chunk-PCL2KNHC.js +6 -0
  210. package/dist/chunk-PCL2KNHC.js.map +7 -0
  211. package/dist/chunk-PH3LWLYN.js +49 -0
  212. package/dist/chunk-PH3LWLYN.js.map +7 -0
  213. package/dist/chunk-PHNMDWSK.js +9 -0
  214. package/dist/chunk-PHNMDWSK.js.map +7 -0
  215. package/dist/chunk-PN5EH6DM.js +36 -0
  216. package/dist/chunk-PN5EH6DM.js.map +7 -0
  217. package/dist/chunk-POCAINUE.js +42 -0
  218. package/dist/chunk-POCAINUE.js.map +7 -0
  219. package/dist/chunk-Q5LEK7CI.js +64 -0
  220. package/dist/chunk-Q5LEK7CI.js.map +7 -0
  221. package/dist/chunk-QH7VW7IY.js +0 -0
  222. package/dist/chunk-QH7VW7IY.js.map +7 -0
  223. package/dist/chunk-QLGM2AZW.js +173 -0
  224. package/dist/chunk-QLGM2AZW.js.map +7 -0
  225. package/dist/chunk-QT3EYUL5.js +85 -0
  226. package/dist/chunk-QT3EYUL5.js.map +7 -0
  227. package/dist/chunk-QYHOFLRX.js +43 -0
  228. package/dist/chunk-QYHOFLRX.js.map +7 -0
  229. package/dist/chunk-R3MBVWVI.js +127 -0
  230. package/dist/chunk-R3MBVWVI.js.map +7 -0
  231. package/dist/chunk-R6V3LH7F.js +67 -0
  232. package/dist/chunk-R6V3LH7F.js.map +7 -0
  233. package/dist/chunk-RB22U6HI.js +64 -0
  234. package/dist/chunk-RB22U6HI.js.map +7 -0
  235. package/dist/chunk-RQRQYYTB.js +34 -0
  236. package/dist/chunk-RQRQYYTB.js.map +7 -0
  237. package/dist/chunk-S5D2QE4G.js +53 -0
  238. package/dist/chunk-S5D2QE4G.js.map +7 -0
  239. package/dist/chunk-S7I76ISM.js +245 -0
  240. package/dist/chunk-S7I76ISM.js.map +7 -0
  241. package/dist/chunk-TBDZOQ2C.js +66 -0
  242. package/dist/chunk-TBDZOQ2C.js.map +7 -0
  243. package/dist/chunk-TSKELYW7.js +55 -0
  244. package/dist/chunk-TSKELYW7.js.map +7 -0
  245. package/dist/chunk-U3YHTQHR.js +215 -0
  246. package/dist/chunk-U3YHTQHR.js.map +7 -0
  247. package/dist/chunk-UGL3KNOT.js +42 -0
  248. package/dist/chunk-UGL3KNOT.js.map +7 -0
  249. package/dist/chunk-UN3DARLG.js +35 -0
  250. package/dist/chunk-UN3DARLG.js.map +7 -0
  251. package/dist/chunk-V5H7L5PJ.js +587 -0
  252. package/dist/chunk-V5H7L5PJ.js.map +7 -0
  253. package/dist/chunk-VGGERKV2.js +7 -0
  254. package/dist/chunk-VGGERKV2.js.map +7 -0
  255. package/dist/chunk-VVFXYY65.js +0 -0
  256. package/dist/chunk-VVFXYY65.js.map +7 -0
  257. package/dist/chunk-WLDCYUN6.js +161 -0
  258. package/dist/chunk-WLDCYUN6.js.map +7 -0
  259. package/dist/chunk-WMDTQS36.js +0 -0
  260. package/dist/chunk-WMDTQS36.js.map +7 -0
  261. package/dist/chunk-WUTGZYP4.js +290 -0
  262. package/dist/chunk-WUTGZYP4.js.map +7 -0
  263. package/dist/chunk-XKN3WWK3.js +0 -0
  264. package/dist/chunk-XKN3WWK3.js.map +7 -0
  265. package/dist/chunk-XQ5VJ4QO.js +62 -0
  266. package/dist/chunk-XQ5VJ4QO.js.map +7 -0
  267. package/dist/chunk-XQVKX47O.js +174 -0
  268. package/dist/chunk-XQVKX47O.js.map +7 -0
  269. package/dist/chunk-Y5CNB57V.js +22 -0
  270. package/dist/chunk-Y5CNB57V.js.map +7 -0
  271. package/dist/chunk-YDGH7DTL.js +18 -0
  272. package/dist/chunk-YDGH7DTL.js.map +7 -0
  273. package/dist/chunk-YIFUBPJ3.js +0 -0
  274. package/dist/chunk-YIFUBPJ3.js.map +7 -0
  275. package/dist/chunk-YUUDXRBW.js +212 -0
  276. package/dist/chunk-YUUDXRBW.js.map +7 -0
  277. package/dist/chunk-Z6DQLJS2.js +23 -0
  278. package/dist/chunk-Z6DQLJS2.js.map +7 -0
  279. package/dist/chunk-ZDEZ2FOC.js +81 -0
  280. package/dist/chunk-ZDEZ2FOC.js.map +7 -0
  281. package/dist/chunk-ZUYSGCEH.js +65 -0
  282. package/dist/chunk-ZUYSGCEH.js.map +7 -0
  283. package/dist/chunk-ZYP3MIH3.js +115 -0
  284. package/dist/chunk-ZYP3MIH3.js.map +7 -0
  285. package/dist/constraints/constraint-evaluator.d.ts +57 -0
  286. package/dist/constraints/constraint-evaluator.js +17 -0
  287. package/dist/constraints/constraint-evaluator.js.map +7 -0
  288. package/dist/constraints/index.d.ts +1 -0
  289. package/dist/constraints/index.js +17 -0
  290. package/dist/constraints/index.js.map +7 -0
  291. package/dist/csrf/index.d.ts +43 -0
  292. package/dist/csrf/index.js +43 -0
  293. package/dist/csrf/index.js.map +7 -0
  294. package/dist/engine/build-form-engine.d.ts +27 -0
  295. package/dist/engine/build-form-engine.js +58 -0
  296. package/dist/engine/build-form-engine.js.map +7 -0
  297. package/dist/engine/component-type.d.ts +19 -0
  298. package/dist/engine/component-type.js +6 -0
  299. package/dist/engine/component-type.js.map +7 -0
  300. package/dist/engine/create-form-engine.d.ts +100 -0
  301. package/dist/engine/create-form-engine.js +59 -0
  302. package/dist/engine/create-form-engine.js.map +7 -0
  303. package/dist/engine/form-action-context.d.ts +70 -0
  304. package/dist/engine/form-action-context.js +10 -0
  305. package/dist/engine/form-action-context.js.map +7 -0
  306. package/dist/engine/form-engine.d.ts +236 -0
  307. package/dist/engine/form-engine.js +61 -0
  308. package/dist/engine/form-engine.js.map +7 -0
  309. package/dist/engine/index.d.ts +12 -0
  310. package/dist/engine/index.js +124 -0
  311. package/dist/engine/index.js.map +7 -0
  312. package/dist/engine/schema-artifacts.d.ts +87 -0
  313. package/dist/engine/schema-artifacts.js +14 -0
  314. package/dist/engine/schema-artifacts.js.map +7 -0
  315. package/dist/engine/schema-metadata-catalog.d.ts +41 -0
  316. package/dist/engine/schema-metadata-catalog.js +6 -0
  317. package/dist/engine/schema-metadata-catalog.js.map +7 -0
  318. package/dist/engine/step-machine.d.ts +59 -0
  319. package/dist/engine/step-machine.js +32 -0
  320. package/dist/engine/step-machine.js.map +7 -0
  321. package/dist/engine/submission-schema.d.ts +53 -0
  322. package/dist/engine/submission-schema.js +22 -0
  323. package/dist/engine/submission-schema.js.map +7 -0
  324. package/dist/engine/value-validation.d.ts +237 -0
  325. package/dist/engine/value-validation.js +39 -0
  326. package/dist/engine/value-validation.js.map +7 -0
  327. package/dist/index.d.ts +76 -0
  328. package/dist/index.js +283 -0
  329. package/dist/index.js.map +7 -0
  330. package/dist/lib/authoring-catalog.d.ts +5 -0
  331. package/dist/lib/authoring-catalog.js +11 -0
  332. package/dist/lib/authoring-catalog.js.map +7 -0
  333. package/dist/lib/container-kind-of.d.ts +5 -0
  334. package/dist/lib/container-kind-of.js +6 -0
  335. package/dist/lib/container-kind-of.js.map +7 -0
  336. package/dist/lib/debounce.d.ts +19 -0
  337. package/dist/lib/debounce.js +6 -0
  338. package/dist/lib/debounce.js.map +7 -0
  339. package/dist/lib/deep-readonly.d.ts +12 -0
  340. package/dist/lib/deep-readonly.js +0 -0
  341. package/dist/lib/deep-readonly.js.map +7 -0
  342. package/dist/lib/element-children.d.ts +35 -0
  343. package/dist/lib/element-children.js +16 -0
  344. package/dist/lib/element-children.js.map +7 -0
  345. package/dist/lib/exported-action-envelope.d.ts +11 -0
  346. package/dist/lib/exported-action-envelope.js +7 -0
  347. package/dist/lib/exported-action-envelope.js.map +7 -0
  348. package/dist/lib/exported-rules.d.ts +14 -0
  349. package/dist/lib/exported-rules.js +6 -0
  350. package/dist/lib/exported-rules.js.map +7 -0
  351. package/dist/lib/field-ref.d.ts +13 -0
  352. package/dist/lib/field-ref.js +6 -0
  353. package/dist/lib/field-ref.js.map +7 -0
  354. package/dist/lib/field-scope.d.ts +121 -0
  355. package/dist/lib/field-scope.js +41 -0
  356. package/dist/lib/field-scope.js.map +7 -0
  357. package/dist/lib/form-fetch.d.ts +36 -0
  358. package/dist/lib/form-fetch.js +10 -0
  359. package/dist/lib/form-fetch.js.map +7 -0
  360. package/dist/lib/form-view.d.ts +33 -0
  361. package/dist/lib/form-view.js +12 -0
  362. package/dist/lib/form-view.js.map +7 -0
  363. package/dist/lib/frozen-copy.d.ts +9 -0
  364. package/dist/lib/frozen-copy.js +7 -0
  365. package/dist/lib/frozen-copy.js.map +7 -0
  366. package/dist/lib/is-plain-object.d.ts +2 -0
  367. package/dist/lib/is-plain-object.js +6 -0
  368. package/dist/lib/is-plain-object.js.map +7 -0
  369. package/dist/lib/logger.d.ts +2 -0
  370. package/dist/lib/logger.js +6 -0
  371. package/dist/lib/logger.js.map +7 -0
  372. package/dist/lib/normalized-form-config.d.ts +106 -0
  373. package/dist/lib/normalized-form-config.js +19 -0
  374. package/dist/lib/normalized-form-config.js.map +7 -0
  375. package/dist/lib/omit-paths.d.ts +11 -0
  376. package/dist/lib/omit-paths.js +7 -0
  377. package/dist/lib/omit-paths.js.map +7 -0
  378. package/dist/lib/path-values.d.ts +47 -0
  379. package/dist/lib/path-values.js +22 -0
  380. package/dist/lib/path-values.js.map +7 -0
  381. package/dist/lib/renderer-data-attributes.d.ts +10 -0
  382. package/dist/lib/renderer-data-attributes.js +6 -0
  383. package/dist/lib/renderer-data-attributes.js.map +7 -0
  384. package/dist/lib/reserved-path-keys.d.ts +10 -0
  385. package/dist/lib/reserved-path-keys.js +10 -0
  386. package/dist/lib/reserved-path-keys.js.map +7 -0
  387. package/dist/lib/resolve-appearance.d.ts +48 -0
  388. package/dist/lib/resolve-appearance.js +10 -0
  389. package/dist/lib/resolve-appearance.js.map +7 -0
  390. package/dist/lib/standard-json-schema.d.ts +27 -0
  391. package/dist/lib/standard-json-schema.js +8 -0
  392. package/dist/lib/standard-json-schema.js.map +7 -0
  393. package/dist/lib/standard-schema.d.ts +19 -0
  394. package/dist/lib/standard-schema.js +8 -0
  395. package/dist/lib/standard-schema.js.map +7 -0
  396. package/dist/lib/submission-shape.d.ts +60 -0
  397. package/dist/lib/submission-shape.js +14 -0
  398. package/dist/lib/submission-shape.js.map +7 -0
  399. package/dist/lib/validate-form/grid-checks.d.ts +57 -0
  400. package/dist/lib/validate-form/grid-checks.js +16 -0
  401. package/dist/lib/validate-form/grid-checks.js.map +7 -0
  402. package/dist/lib/validate-form/issues.d.ts +43 -0
  403. package/dist/lib/validate-form/issues.js +13 -0
  404. package/dist/lib/validate-form/issues.js.map +7 -0
  405. package/dist/lib/validate-form/options.d.ts +22 -0
  406. package/dist/lib/validate-form/options.js +0 -0
  407. package/dist/lib/validate-form/options.js.map +7 -0
  408. package/dist/lib/validate-form/parse-elements.d.ts +23 -0
  409. package/dist/lib/validate-form/parse-elements.js +21 -0
  410. package/dist/lib/validate-form/parse-elements.js.map +7 -0
  411. package/dist/lib/validate-form/parse-owner-actions.d.ts +14 -0
  412. package/dist/lib/validate-form/parse-owner-actions.js +10 -0
  413. package/dist/lib/validate-form/parse-owner-actions.js.map +7 -0
  414. package/dist/lib/validate-form/parse-view.d.ts +11 -0
  415. package/dist/lib/validate-form/parse-view.js +11 -0
  416. package/dist/lib/validate-form/parse-view.js.map +7 -0
  417. package/dist/lib/validate-form/schema-issues.d.ts +16 -0
  418. package/dist/lib/validate-form/schema-issues.js +8 -0
  419. package/dist/lib/validate-form/schema-issues.js.map +7 -0
  420. package/dist/lib/validate-form/step-checks.d.ts +18 -0
  421. package/dist/lib/validate-form/step-checks.js +15 -0
  422. package/dist/lib/validate-form/step-checks.js.map +7 -0
  423. package/dist/lib/validate-form/validation-error.d.ts +26 -0
  424. package/dist/lib/validate-form/validation-error.js +8 -0
  425. package/dist/lib/validate-form/validation-error.js.map +7 -0
  426. package/dist/lib/validate-form.d.ts +34 -0
  427. package/dist/lib/validate-form.js +62 -0
  428. package/dist/lib/validate-form.js.map +7 -0
  429. package/dist/lib/zod-json-schema.d.ts +33 -0
  430. package/dist/lib/zod-json-schema.js +10 -0
  431. package/dist/lib/zod-json-schema.js.map +7 -0
  432. package/dist/recipes/built-in-specs.d.ts +1832 -0
  433. package/dist/recipes/built-in-specs.js +28 -0
  434. package/dist/recipes/built-in-specs.js.map +7 -0
  435. package/dist/recipes/built-in.d.ts +2 -0
  436. package/dist/recipes/built-in.js +49 -0
  437. package/dist/recipes/built-in.js.map +7 -0
  438. package/dist/recipes/define-form-recipe.d.ts +10 -0
  439. package/dist/recipes/define-form-recipe.js +6 -0
  440. package/dist/recipes/define-form-recipe.js.map +7 -0
  441. package/dist/recipes/define-recipe-spec.d.ts +13 -0
  442. package/dist/recipes/define-recipe-spec.js +8 -0
  443. package/dist/recipes/define-recipe-spec.js.map +7 -0
  444. package/dist/recipes/index.d.ts +6 -0
  445. package/dist/recipes/index.js +43 -0
  446. package/dist/recipes/index.js.map +7 -0
  447. package/dist/recipes/protocol.d.ts +24 -0
  448. package/dist/recipes/protocol.js +11 -0
  449. package/dist/recipes/protocol.js.map +7 -0
  450. package/dist/recipes/slot-schemas.d.ts +128 -0
  451. package/dist/recipes/slot-schemas.js +24 -0
  452. package/dist/recipes/slot-schemas.js.map +7 -0
  453. package/dist/recipes/types.d.ts +55 -0
  454. package/dist/recipes/types.js +1 -0
  455. package/dist/recipes/types.js.map +7 -0
  456. package/dist/recipes/view-model.d.ts +93 -0
  457. package/dist/recipes/view-model.js +29 -0
  458. package/dist/recipes/view-model.js.map +7 -0
  459. package/dist/registries/index.d.ts +8 -0
  460. package/dist/registries/index.js +0 -0
  461. package/dist/registries/index.js.map +7 -0
  462. package/dist/runtime/create-form-runtime.d.ts +43 -0
  463. package/dist/runtime/create-form-runtime.js +41 -0
  464. package/dist/runtime/create-form-runtime.js.map +7 -0
  465. package/dist/runtime/index.d.ts +3 -0
  466. package/dist/runtime/index.js +44 -0
  467. package/dist/runtime/index.js.map +7 -0
  468. package/dist/runtime/submission-lifecycle.d.ts +65 -0
  469. package/dist/runtime/submission-lifecycle.js +6 -0
  470. package/dist/runtime/submission-lifecycle.js.map +7 -0
  471. package/dist/runtime/types.d.ts +172 -0
  472. package/dist/runtime/types.js +6 -0
  473. package/dist/runtime/types.js.map +7 -0
  474. package/dist/schemas/base-field.d.ts +450 -0
  475. package/dist/schemas/base-field.js +36 -0
  476. package/dist/schemas/base-field.js.map +7 -0
  477. package/dist/schemas/field-config.d.ts +36 -0
  478. package/dist/schemas/field-config.js +1 -0
  479. package/dist/schemas/field-config.js.map +7 -0
  480. package/dist/schemas/form-config-shape.d.ts +763 -0
  481. package/dist/schemas/form-config-shape.js +35 -0
  482. package/dist/schemas/form-config-shape.js.map +7 -0
  483. package/dist/schemas/form-config.d.ts +1288 -0
  484. package/dist/schemas/form-config.js +41 -0
  485. package/dist/schemas/form-config.js.map +7 -0
  486. package/dist/schemas/html-attributes.d.ts +12 -0
  487. package/dist/schemas/html-attributes.js +12 -0
  488. package/dist/schemas/html-attributes.js.map +7 -0
  489. package/dist/schemas/index.d.ts +5 -0
  490. package/dist/schemas/index.js +165 -0
  491. package/dist/schemas/index.js.map +7 -0
  492. package/dist/schemas/validation/async/cache.d.ts +39 -0
  493. package/dist/schemas/validation/async/cache.js +6 -0
  494. package/dist/schemas/validation/async/cache.js.map +7 -0
  495. package/dist/schemas/validation/async/handler.d.ts +21 -0
  496. package/dist/schemas/validation/async/handler.js +11 -0
  497. package/dist/schemas/validation/async/handler.js.map +7 -0
  498. package/dist/schemas/validation/async/index.d.ts +8 -0
  499. package/dist/schemas/validation/async/index.js +14 -0
  500. package/dist/schemas/validation/async/index.js.map +7 -0
  501. package/dist/schemas/validation/defaults.d.ts +6 -0
  502. package/dist/schemas/validation/defaults.js +12 -0
  503. package/dist/schemas/validation/defaults.js.map +7 -0
  504. package/dist/schemas/validation/dependencies.d.ts +52 -0
  505. package/dist/schemas/validation/dependencies.js +17 -0
  506. package/dist/schemas/validation/dependencies.js.map +7 -0
  507. package/dist/schemas/validation/empty.d.ts +1 -0
  508. package/dist/schemas/validation/empty.js +6 -0
  509. package/dist/schemas/validation/empty.js.map +7 -0
  510. package/dist/schemas/validation/errors.d.ts +44 -0
  511. package/dist/schemas/validation/errors.js +12 -0
  512. package/dist/schemas/validation/errors.js.map +7 -0
  513. package/dist/schemas/validation/index.d.ts +9 -0
  514. package/dist/schemas/validation/index.js +130 -0
  515. package/dist/schemas/validation/index.js.map +7 -0
  516. package/dist/schemas/validation/presets.d.ts +66 -0
  517. package/dist/schemas/validation/presets.js +6 -0
  518. package/dist/schemas/validation/presets.js.map +7 -0
  519. package/dist/schemas/validation/relations.d.ts +12 -0
  520. package/dist/schemas/validation/relations.js +8 -0
  521. package/dist/schemas/validation/relations.js.map +7 -0
  522. package/dist/schemas/validation/types.d.ts +817 -0
  523. package/dist/schemas/validation/types.js +64 -0
  524. package/dist/schemas/validation/types.js.map +7 -0
  525. package/dist/schemas/validation/utils.d.ts +76 -0
  526. package/dist/schemas/validation/utils.js +24 -0
  527. package/dist/schemas/validation/utils.js.map +7 -0
  528. package/dist/schemas/validation/validation-registry.d.ts +124 -0
  529. package/dist/schemas/validation/validation-registry.js +27 -0
  530. package/dist/schemas/validation/validation-registry.js.map +7 -0
  531. package/dist/server-errors/from-json-api-errors.d.ts +13 -0
  532. package/dist/server-errors/from-json-api-errors.js +10 -0
  533. package/dist/server-errors/from-json-api-errors.js.map +7 -0
  534. package/dist/server-errors/from-problem-details.d.ts +15 -0
  535. package/dist/server-errors/from-problem-details.js +10 -0
  536. package/dist/server-errors/from-problem-details.js.map +7 -0
  537. package/dist/server-errors/index.d.ts +8 -0
  538. package/dist/server-errors/index.js +17 -0
  539. package/dist/server-errors/index.js.map +7 -0
  540. package/dist/server-errors/shared.d.ts +34 -0
  541. package/dist/server-errors/shared.js +23 -0
  542. package/dist/server-errors/shared.js.map +7 -0
  543. package/dist/state-container/create-form-state-container.d.ts +17 -0
  544. package/dist/state-container/create-form-state-container.js +31 -0
  545. package/dist/state-container/create-form-state-container.js.map +7 -0
  546. package/dist/state-container/dirty.d.ts +11 -0
  547. package/dist/state-container/dirty.js +9 -0
  548. package/dist/state-container/dirty.js.map +7 -0
  549. package/dist/state-container/field-array.d.ts +41 -0
  550. package/dist/state-container/field-array.js +8 -0
  551. package/dist/state-container/field-array.js.map +7 -0
  552. package/dist/state-container/hydration.d.ts +21 -0
  553. package/dist/state-container/hydration.js +11 -0
  554. package/dist/state-container/hydration.js.map +7 -0
  555. package/dist/state-container/index.d.ts +16 -0
  556. package/dist/state-container/index.js +51 -0
  557. package/dist/state-container/index.js.map +7 -0
  558. package/dist/state-container/issue-text.d.ts +11 -0
  559. package/dist/state-container/issue-text.js +6 -0
  560. package/dist/state-container/issue-text.js.map +7 -0
  561. package/dist/state-container/row-ids.d.ts +34 -0
  562. package/dist/state-container/row-ids.js +19 -0
  563. package/dist/state-container/row-ids.js.map +7 -0
  564. package/dist/state-container/selectors.d.ts +33 -0
  565. package/dist/state-container/selectors.js +22 -0
  566. package/dist/state-container/selectors.js.map +7 -0
  567. package/dist/state-container/stale-results.d.ts +28 -0
  568. package/dist/state-container/stale-results.js +9 -0
  569. package/dist/state-container/stale-results.js.map +7 -0
  570. package/dist/state-container/state-tree.d.ts +56 -0
  571. package/dist/state-container/state-tree.js +33 -0
  572. package/dist/state-container/state-tree.js.map +7 -0
  573. package/dist/state-container/submission.d.ts +45 -0
  574. package/dist/state-container/submission.js +26 -0
  575. package/dist/state-container/submission.js.map +7 -0
  576. package/dist/state-container/types.d.ts +404 -0
  577. package/dist/state-container/types.js +6 -0
  578. package/dist/state-container/types.js.map +7 -0
  579. package/dist/state-container/value-tree.d.ts +56 -0
  580. package/dist/state-container/value-tree.js +34 -0
  581. package/dist/state-container/value-tree.js.map +7 -0
  582. package/dist/testing/assert.d.ts +92 -0
  583. package/dist/testing/assert.js +42 -0
  584. package/dist/testing/assert.js.map +7 -0
  585. package/dist/testing/form-state-container-conformance.d.ts +63 -0
  586. package/dist/testing/form-state-container-conformance.js +44 -0
  587. package/dist/testing/form-state-container-conformance.js.map +7 -0
  588. package/dist/testing/index.d.ts +8 -0
  589. package/dist/testing/index.js +36 -0
  590. package/dist/testing/index.js.map +7 -0
  591. package/dist/types/actions.d.ts +75 -0
  592. package/dist/types/actions.js +1 -0
  593. package/dist/types/actions.js.map +7 -0
  594. package/dist/types/categories.d.ts +21 -0
  595. package/dist/types/categories.js +8 -0
  596. package/dist/types/categories.js.map +7 -0
  597. package/dist/types/define-element.d.ts +73 -0
  598. package/dist/types/define-element.js +8 -0
  599. package/dist/types/define-element.js.map +7 -0
  600. package/dist/types/index.d.ts +10 -0
  601. package/dist/types/index.js +17 -0
  602. package/dist/types/index.js.map +7 -0
  603. package/dist/types/metadata.d.ts +14 -0
  604. package/dist/types/metadata.js +1 -0
  605. package/dist/types/metadata.js.map +7 -0
  606. package/dist/types/registration.d.ts +142 -0
  607. package/dist/types/registration.js +1 -0
  608. package/dist/types/registration.js.map +7 -0
  609. package/package.json +113 -3
  610. package/skill/SKILL.md +79 -0
  611. package/skill/reference/forms-actions.md +51 -0
  612. package/skill/reference/forms-submission.md +44 -0
  613. package/skill/reference/forms-validation.md +91 -0
  614. package/skill/reference/forms.md +180 -0
@@ -0,0 +1,206 @@
1
+ import {
2
+ brandElementTree,
3
+ parseElementList,
4
+ parseElementNode
5
+ } from "./chunk-NJXKMF67.js";
6
+ import {
7
+ parseOwnerActions
8
+ } from "./chunk-6R2MBQPL.js";
9
+ import {
10
+ parseView
11
+ } from "./chunk-GRZU6F7Q.js";
12
+ import {
13
+ stepStructureIssues
14
+ } from "./chunk-Q5LEK7CI.js";
15
+ import {
16
+ FormValidationError
17
+ } from "./chunk-PN5EH6DM.js";
18
+ import {
19
+ fieldPlacementIssues,
20
+ templateIssues
21
+ } from "./chunk-YUUDXRBW.js";
22
+ import {
23
+ resolveAppearance,
24
+ withAppearance
25
+ } from "./chunk-RQRQYYTB.js";
26
+ import {
27
+ stepGrid
28
+ } from "./chunk-EZZHO6DQ.js";
29
+ import {
30
+ formConfigEnvelopeSchema
31
+ } from "./chunk-7EQJUI5N.js";
32
+ import {
33
+ fromSchemaIssues
34
+ } from "./chunk-FVOL3ZOJ.js";
35
+ import {
36
+ childPath,
37
+ issueAt
38
+ } from "./chunk-LMWJAD3B.js";
39
+ import {
40
+ walkNamedElements
41
+ } from "./chunk-S7I76ISM.js";
42
+ import {
43
+ getNormalizedFormOwner,
44
+ markNormalizedFormConfig
45
+ } from "./chunk-CRQWKC67.js";
46
+ import {
47
+ ENGINE_KEY_PREFIX,
48
+ isReservedPathKey
49
+ } from "./chunk-3YLRJVVN.js";
50
+
51
+ // src/lib/validate-form.ts
52
+ import { safeParseStandardSchema } from "@schema-engine/registry";
53
+ import { getDefaultLayoutTheme } from "@schema-engine/layout";
54
+ function validateElementConfig(config, options) {
55
+ const parsed = parseElementNode(config, options.getElement, options.checkRule, [], {
56
+ axes: options.axes ?? getDefaultLayoutTheme().axes,
57
+ inherited: {}
58
+ });
59
+ if (parsed.issues.length > 0 || !parsed.item) {
60
+ throw new FormValidationError(
61
+ parsed.issues.length > 0 ? parsed.issues : [issueAt(["$type"], "Invalid element configuration: missing $type.")],
62
+ config
63
+ );
64
+ }
65
+ return brandElementTree(parsed.item, options.getElement);
66
+ }
67
+ function validateFormConfig(config, options) {
68
+ const result = safeValidateFormConfig(config, options);
69
+ if (!result.success) throw new FormValidationError(result.issues, config);
70
+ return result.data;
71
+ }
72
+ function safeValidateFormConfig(config, options) {
73
+ const existingOwner = getNormalizedFormOwner(config);
74
+ if (existingOwner) {
75
+ if (existingOwner === options.owner) {
76
+ return {
77
+ success: true,
78
+ data: markNormalizedFormConfig(config, options.owner, options.values)
79
+ };
80
+ }
81
+ const formId = typeof config === "object" && config !== null && "id" in config ? String(config.id) : "unknown";
82
+ return {
83
+ success: false,
84
+ issues: [
85
+ issueAt(
86
+ [],
87
+ `Form '${formId}' was already normalized by a different engine. Pass the original authoring input or JSON to this engine instead.`
88
+ )
89
+ ]
90
+ };
91
+ }
92
+ const parsedEnvelope = parseEnvelope(config);
93
+ if (!parsedEnvelope.ok) return { success: false, issues: parsedEnvelope.issues };
94
+ const envelope = parsedEnvelope.data;
95
+ const issues = [];
96
+ const axes = options.axes ?? getDefaultLayoutTheme().axes;
97
+ const formScope = { axes, inherited: {} };
98
+ const formAppearance = resolveAppearance(envelope.appearance, formScope, { subject: "The form", path: [] });
99
+ issues.push(...formAppearance.issues);
100
+ const placed = [];
101
+ const steps = envelope.steps.map((step, stepIndex) => {
102
+ const stepPath = ["steps", stepIndex];
103
+ const stepAppearance = resolveAppearance(step.appearance, formAppearance.childScope, {
104
+ subject: "The step",
105
+ path: stepPath
106
+ });
107
+ issues.push(...stepAppearance.issues);
108
+ const elements = parseElementList(
109
+ step.elements,
110
+ options.getElement,
111
+ options.checkRule,
112
+ stepPath,
113
+ stepAppearance.childScope
114
+ );
115
+ const actions = parseOwnerActions(step.actions, options, stepPath);
116
+ issues.push(...elements.issues, ...actions.issues);
117
+ placed.push(
118
+ elements.byIndex.flatMap(
119
+ (element, index) => element ? [{ element, path: childPath(stepPath, index) }] : []
120
+ )
121
+ );
122
+ return {
123
+ ...withAppearance(step, stepAppearance.selection),
124
+ elements: elements.items ?? step.elements,
125
+ actions: actions.items ?? step.actions
126
+ };
127
+ });
128
+ issues.push(...stepStructureIssues(steps, options.getElement));
129
+ issues.push(
130
+ ...payloadIssues(
131
+ envelope.payload,
132
+ steps.flatMap((step) => step.elements)
133
+ )
134
+ );
135
+ const formShape = templateIssues("Form grid", envelope.grid, ["grid"]);
136
+ issues.push(...formShape);
137
+ steps.forEach((step, index) => {
138
+ const own = step.grid !== void 0;
139
+ const label = own ? "Step grid" : "Form grid";
140
+ const gridPath = own ? ["steps", index, "grid"] : ["grid"];
141
+ const shape = own ? templateIssues(label, step.grid, gridPath) : formShape;
142
+ if (own) issues.push(...shape);
143
+ const scope = { gridPath, elements: placed[index] ?? [] };
144
+ issues.push(...fieldPlacementIssues(label, stepGrid(envelope, step), scope, shape.length === 0, !own));
145
+ });
146
+ const view = parseView(
147
+ envelope.view && typeof envelope.view.$type === "string" ? envelope.view : void 0,
148
+ { id: envelope.id, stepCount: envelope.steps.length },
149
+ options,
150
+ formAppearance.childScope
151
+ );
152
+ const formActions = parseOwnerActions(envelope.actions, options, []);
153
+ issues.push(...view.issues, ...formActions.issues);
154
+ if (issues.length > 0) {
155
+ return { success: false, issues };
156
+ }
157
+ return {
158
+ success: true,
159
+ data: markNormalizedFormConfig(
160
+ {
161
+ ...withAppearance(envelope, formAppearance.selection),
162
+ steps: steps.map((step) => ({
163
+ ...step,
164
+ elements: step.elements.map(
165
+ (element) => brandElementTree(element, options.getElement)
166
+ )
167
+ })),
168
+ view: view.view ?? envelope.view,
169
+ actions: formActions.items ?? envelope.actions
170
+ },
171
+ options.owner,
172
+ options.values
173
+ )
174
+ };
175
+ }
176
+ function payloadIssues(payload, elements) {
177
+ if (!payload) return [];
178
+ const fieldNames = new Set(walkNamedElements(elements).map(({ path }) => path.split(".")[0]));
179
+ return Object.keys(payload).flatMap((key) => {
180
+ if (isReservedPathKey(key)) {
181
+ return [
182
+ issueAt(
183
+ ["payload", key],
184
+ `Payload key '${key}' is reserved: a key cannot start with '${ENGINE_KEY_PREFIX}' or be one of __proto__, constructor and prototype.`
185
+ )
186
+ ];
187
+ }
188
+ return fieldNames.has(key) ? [
189
+ issueAt(
190
+ ["payload", key],
191
+ `Payload key '${key}' names a field of the form; a payload key cannot be a field.`
192
+ )
193
+ ] : [];
194
+ });
195
+ }
196
+ function parseEnvelope(config) {
197
+ const result = safeParseStandardSchema(formConfigEnvelopeSchema, config);
198
+ if (!result.success) return { ok: false, issues: fromSchemaIssues(result.error.issues, []) };
199
+ return { ok: true, data: result.data };
200
+ }
201
+
202
+ export {
203
+ validateElementConfig,
204
+ validateFormConfig,
205
+ safeValidateFormConfig
206
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/validate-form.ts"],
4
+ "sourcesContent": ["import type { FormConfig, FormConfigEnvelope, FormTaggedConfig } from '@/schemas/form-config';\nimport { formConfigEnvelopeSchema } from '@/schemas/form-config';\nimport { safeParseStandardSchema } from '@schema-engine/registry';\nimport {\n\tmarkNormalizedFormConfig,\n\tgetNormalizedFormOwner,\n\ttype NormalizedElementConfig,\n\ttype NormalizedFormConfig,\n} from '@/lib/normalized-form-config';\nimport { stepGrid } from '@/lib/form-view';\nimport { walkNamedElements } from '@/lib/field-scope';\nimport { ENGINE_KEY_PREFIX, isReservedPathKey } from '@/lib/reserved-path-keys';\nimport { getDefaultLayoutTheme } from '@schema-engine/layout';\nimport { resolveAppearance, withAppearance, type AppearanceScope } from '@/lib/resolve-appearance';\nimport { fieldPlacementIssues, templateIssues, type PlacedElement } from './validate-form/grid-checks';\nimport {\n\tchildPath,\n\tissueAt,\n\ttype FormValidationIssue,\n\ttype FormValidationResult,\n\ttype ParseResult,\n\ttype Path,\n} from './validate-form/issues';\nimport type { ValidateFormOptions } from './validate-form/options';\nimport { brandElementTree, parseElementList, parseElementNode } from './validate-form/parse-elements';\nimport { parseOwnerActions } from './validate-form/parse-owner-actions';\nimport { parseView } from './validate-form/parse-view';\nimport { stepStructureIssues } from './validate-form/step-checks';\nimport { fromSchemaIssues } from './validate-form/schema-issues';\nimport { FormValidationError } from './validate-form/validation-error';\n\nexport type { FormConfigView, NormalizedElementConfig, NormalizedFormConfig } from '@/lib/normalized-form-config';\nexport { DEFAULT_WIZARD_RECIPE, assertFormEngine, getRenderableSteps, stepGrid } from '@/lib/form-view';\nexport type { FormValidationIssue, FormValidationResult } from './validate-form/issues';\nexport type { ValidateFormOptions } from './validate-form/options';\nexport { FormValidationError, formatIssuePath } from './validate-form/validation-error';\n\n/**\n * Validate a single element against its registration schema, including nested child elements.\n * Use this before rendering a field that is not already part of a {@link NormalizedFormConfig}.\n * The normalized marker is applied only after this element and its children succeed.\n *\n * @throws {FormValidationError} Issue paths are relative to the element, for example `['grid', 'width']`\n * or `['elements', 0, 'rules', 1, '$type']`.\n */\nexport function validateElementConfig(\n\tconfig: unknown,\n\toptions: Pick<ValidateFormOptions, 'getElement' | 'checkRule' | 'axes'>,\n): NormalizedElementConfig {\n\tconst parsed = parseElementNode(config, options.getElement, options.checkRule, [], {\n\t\taxes: options.axes ?? getDefaultLayoutTheme().axes,\n\t\tinherited: {},\n\t});\n\tif (parsed.issues.length > 0 || !parsed.item) {\n\t\tthrow new FormValidationError(\n\t\t\tparsed.issues.length > 0\n\t\t\t\t? parsed.issues\n\t\t\t\t: [issueAt(['$type'], 'Invalid element configuration: missing $type.')],\n\t\t\tconfig,\n\t\t);\n\t}\n\treturn brandElementTree(parsed.item, options.getElement);\n}\n\n/**\n * Strict validation for a form configuration against the engine's registered recipes and schema.\n * Returns a frozen {@link NormalizedFormConfig}: schema defaults and transforms are kept, the input object is not mutated.\n *\n * @throws {FormValidationError} With the issues found. {@link safeValidateFormConfig} returns them instead.\n */\nexport function validateFormConfig(config: unknown, options: ValidateFormOptions): NormalizedFormConfig {\n\tconst result = safeValidateFormConfig(config, options);\n\tif (!result.success) throw new FormValidationError(result.issues, config);\n\treturn result.data;\n}\n\n/**\n * Same validation as {@link validateFormConfig}, reported as a result: the normalized form, or the\n * issues found, each with the config path it is about.\n *\n * @remarks\n * A malformed envelope (the form's own shape) stops the deeper checks, so it comes back on its own;\n * once the envelope parses, the issues of every element, action, grid and view are reported together.\n * Still throws for a misuse of the API, such as a registration whose Standard Schema is async.\n */\nexport function safeValidateFormConfig(\n\tconfig: unknown,\n\toptions: ValidateFormOptions,\n): FormValidationResult<NormalizedFormConfig> {\n\tconst existingOwner = getNormalizedFormOwner(config);\n\tif (existingOwner) {\n\t\tif (existingOwner === options.owner) {\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: markNormalizedFormConfig(config as FormConfig, options.owner, options.values),\n\t\t\t};\n\t\t}\n\t\tconst formId = typeof config === 'object' && config !== null && 'id' in config ? String(config.id) : 'unknown';\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tissues: [\n\t\t\t\tissueAt(\n\t\t\t\t\t[],\n\t\t\t\t\t`Form '${formId}' was already normalized by a different engine. Pass the original authoring input or JSON to this engine instead.`,\n\t\t\t\t),\n\t\t\t],\n\t\t};\n\t}\n\n\tconst parsedEnvelope = parseEnvelope(config);\n\tif (!parsedEnvelope.ok) return { success: false, issues: parsedEnvelope.issues };\n\tconst envelope = parsedEnvelope.data;\n\n\tconst issues: FormValidationIssue[] = [];\n\tconst axes = options.axes ?? getDefaultLayoutTheme().axes;\n\tconst formScope: AppearanceScope = { axes, inherited: {} };\n\tconst formAppearance = resolveAppearance(envelope.appearance, formScope, { subject: 'The form', path: [] });\n\tissues.push(...formAppearance.issues);\n\n\tconst placed: PlacedElement[][] = [];\n\tconst steps = envelope.steps.map((step, stepIndex) => {\n\t\tconst stepPath: Path = ['steps', stepIndex];\n\t\tconst stepAppearance = resolveAppearance(step.appearance, formAppearance.childScope, {\n\t\t\tsubject: 'The step',\n\t\t\tpath: stepPath,\n\t\t});\n\t\tissues.push(...stepAppearance.issues);\n\t\tconst elements = parseElementList(\n\t\t\tstep.elements,\n\t\t\toptions.getElement,\n\t\t\toptions.checkRule,\n\t\t\tstepPath,\n\t\t\tstepAppearance.childScope,\n\t\t);\n\t\tconst actions = parseOwnerActions(step.actions, options, stepPath);\n\t\tissues.push(...elements.issues, ...actions.issues);\n\t\tplaced.push(\n\t\t\telements.byIndex.flatMap((element, index) =>\n\t\t\t\telement ? [{ element, path: childPath(stepPath, index) }] : [],\n\t\t\t),\n\t\t);\n\t\treturn {\n\t\t\t...withAppearance(step, stepAppearance.selection),\n\t\t\telements: elements.items ?? step.elements,\n\t\t\tactions: actions.items ?? step.actions,\n\t\t};\n\t});\n\n\tissues.push(...stepStructureIssues(steps, options.getElement));\n\tissues.push(\n\t\t...payloadIssues(\n\t\t\tenvelope.payload,\n\t\t\tsteps.flatMap((step) => step.elements),\n\t\t),\n\t);\n\n\tconst formShape = templateIssues('Form grid', envelope.grid, ['grid']);\n\tissues.push(...formShape);\n\tsteps.forEach((step, index) => {\n\t\tconst own = step.grid !== undefined;\n\t\tconst label = own ? 'Step grid' : 'Form grid';\n\t\tconst gridPath: Path = own ? ['steps', index, 'grid'] : ['grid'];\n\t\tconst shape = own ? templateIssues(label, step.grid, gridPath) : formShape;\n\t\tif (own) issues.push(...shape);\n\t\tconst scope = { gridPath, elements: placed[index] ?? [] };\n\t\tissues.push(...fieldPlacementIssues(label, stepGrid(envelope, step), scope, shape.length === 0, !own));\n\t});\n\n\tconst view = parseView(\n\t\tenvelope.view && typeof envelope.view.$type === 'string' ? envelope.view : undefined,\n\t\t{ id: envelope.id, stepCount: envelope.steps.length },\n\t\toptions,\n\t\tformAppearance.childScope,\n\t);\n\tconst formActions = parseOwnerActions(envelope.actions, options, []);\n\tissues.push(...view.issues, ...formActions.issues);\n\n\tif (issues.length > 0) {\n\t\treturn { success: false, issues };\n\t}\n\n\treturn {\n\t\tsuccess: true,\n\t\tdata: markNormalizedFormConfig(\n\t\t\t{\n\t\t\t\t...withAppearance(envelope, formAppearance.selection),\n\t\t\t\tsteps: steps.map((step) => ({\n\t\t\t\t\t...step,\n\t\t\t\t\telements: step.elements.map((element) =>\n\t\t\t\t\t\tbrandElementTree(element as FormTaggedConfig, options.getElement),\n\t\t\t\t\t),\n\t\t\t\t})),\n\t\t\t\tview: view.view ?? envelope.view,\n\t\t\t\tactions: formActions.items ?? envelope.actions,\n\t\t\t} as unknown as FormConfig,\n\t\t\toptions.owner,\n\t\t\toptions.values,\n\t\t),\n\t};\n}\n\n/**\n * The payload keys that cannot travel: a reserved segment, or the name of a field.\n *\n * @remarks\n * The payload is data that travels with a submission and is never a value of the form, so a key that is\n * also a field would make one name mean two things in `submission.values`.\n */\nfunction payloadIssues(\n\tpayload: Readonly<Record<string, unknown>> | undefined,\n\telements: readonly object[],\n): FormValidationIssue[] {\n\tif (!payload) return [];\n\tconst fieldNames = new Set(walkNamedElements(elements).map(({ path }) => path.split('.')[0]));\n\treturn Object.keys(payload).flatMap((key) => {\n\t\tif (isReservedPathKey(key)) {\n\t\t\treturn [\n\t\t\t\tissueAt(\n\t\t\t\t\t['payload', key],\n\t\t\t\t\t`Payload key '${key}' is reserved: a key cannot start with '${ENGINE_KEY_PREFIX}' or be one of __proto__, constructor and prototype.`,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t\treturn fieldNames.has(key)\n\t\t\t? [\n\t\t\t\t\tissueAt(\n\t\t\t\t\t\t['payload', key],\n\t\t\t\t\t\t`Payload key '${key}' names a field of the form; a payload key cannot be a field.`,\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: [];\n\t});\n}\n\n/**\n * Parses the form's own shape (its id, steps, view and the like). Nothing deeper is checked when this\n * fails, so a malformed envelope is reported on its own.\n */\nfunction parseEnvelope(config: unknown): ParseResult<FormConfigEnvelope> {\n\tconst result = safeParseStandardSchema(formConfigEnvelopeSchema, config);\n\tif (!result.success) return { ok: false, issues: fromSchemaIssues(result.error.issues, []) };\n\treturn { ok: true, data: result.data as FormConfigEnvelope };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,+BAA+B;AAUxC,SAAS,6BAA6B;AAiC/B,SAAS,sBACf,QACA,SAC0B;AAC1B,QAAM,SAAS,iBAAiB,QAAQ,QAAQ,YAAY,QAAQ,WAAW,CAAC,GAAG;AAAA,IAClF,MAAM,QAAQ,QAAQ,sBAAsB,EAAE;AAAA,IAC9C,WAAW,CAAC;AAAA,EACb,CAAC;AACD,MAAI,OAAO,OAAO,SAAS,KAAK,CAAC,OAAO,MAAM;AAC7C,UAAM,IAAI;AAAA,MACT,OAAO,OAAO,SAAS,IACpB,OAAO,SACP,CAAC,QAAQ,CAAC,OAAO,GAAG,+CAA+C,CAAC;AAAA,MACvE;AAAA,IACD;AAAA,EACD;AACA,SAAO,iBAAiB,OAAO,MAAM,QAAQ,UAAU;AACxD;AAQO,SAAS,mBAAmB,QAAiB,SAAoD;AACvG,QAAM,SAAS,uBAAuB,QAAQ,OAAO;AACrD,MAAI,CAAC,OAAO,QAAS,OAAM,IAAI,oBAAoB,OAAO,QAAQ,MAAM;AACxE,SAAO,OAAO;AACf;AAWO,SAAS,uBACf,QACA,SAC6C;AAC7C,QAAM,gBAAgB,uBAAuB,MAAM;AACnD,MAAI,eAAe;AAClB,QAAI,kBAAkB,QAAQ,OAAO;AACpC,aAAO;AAAA,QACN,SAAS;AAAA,QACT,MAAM,yBAAyB,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M,QAAQ,CAAC,CAAC,EAAE;AAC3F,SAAO,EAAE,IAAI,MAAM,MAAM,OAAO,KAA2B;AAC5D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ // src/engine/component-type.ts
2
+ var ComponentType = {
3
+ Element: "element",
4
+ Recipe: "recipe",
5
+ Action: "action",
6
+ Axis: "axis",
7
+ Validation: "validation"
8
+ };
9
+
10
+ export {
11
+ ComponentType
12
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/engine/component-type.ts"],
4
+ "sourcesContent": ["/**\n * Stable component kind identifiers shared across registries, builders, and\n * schema metadata.\n *\n * Keeping this outside `form-engine` prevents lower-level schema helpers from\n * depending on the runtime engine module, which keeps the extraction boundary\n * cleaner.\n */\nexport const ComponentType = {\n\tElement: 'element',\n\tRecipe: 'recipe',\n\tAction: 'action',\n\tAxis: 'axis',\n\tValidation: 'validation',\n} as const;\n\n/**\n * Union of all supported component kind identifiers.\n */\nexport type ComponentType = (typeof ComponentType)[keyof typeof ComponentType];\n"],
5
+ "mappings": ";AAQO,IAAM,gBAAgB;AAAA,EAC5B,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AACb;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ formRecipeProtocol
3
+ } from "./chunk-UGL3KNOT.js";
4
+
5
+ // src/recipes/define-recipe-spec.ts
6
+ import {
7
+ defineProtocolRecipeSpec
8
+ } from "@schema-engine/layout";
9
+ function defineRecipeSpec(definition) {
10
+ return defineProtocolRecipeSpec(formRecipeProtocol, definition);
11
+ }
12
+
13
+ export {
14
+ defineRecipeSpec
15
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/recipes/define-recipe-spec.ts"],
4
+ "sourcesContent": ["import {\n\tdefineProtocolRecipeSpec,\n\ttype ProtocolRecipeSpecDefinition,\n\ttype RecipeViewSchema,\n} from '@schema-engine/layout';\nimport { formRecipeProtocol, type RecipeKind, type RecipeSlot } from './protocol';\nimport type { RecipeSlotSchemas, RecipeSpec } from './types';\n\nexport type { RecipeViewSchema } from '@schema-engine/layout';\n\n/**\n * Declares a form recipe's `$type`, kind, slot schemas, and metadata.\n *\n * @remarks\n * `defineProtocolRecipeSpec` from `@schema-engine/layout` on {@link formRecipeProtocol}: single-step\n * recipes cannot declare `progress` (their `actions` slot is the submit-only bar), and wizard\n * recipes must declare `actions`.\n */\nexport function defineRecipeSpec<\n\tconst TType extends string,\n\tconst TSlots extends RecipeSlotSchemas = Record<never, never>,\n>(\n\tdefinition: ProtocolRecipeSpecDefinition<RecipeSlot, RecipeKind, TType, TSlots>,\n): RecipeSpec<TType, RecipeViewSchema<TType, TSlots>, TSlots> {\n\treturn defineProtocolRecipeSpec(formRecipeProtocol, definition);\n}\n"],
5
+ "mappings": ";;;;;AAAA;AAAA,EACC;AAAA,OAGM;AAcA,SAAS,iBAIf,YAC6D;AAC7D,SAAO,yBAAyB,oBAAoB,UAAU;AAC/D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,185 @@
1
+ import {
2
+ createMap,
3
+ isOpaque,
4
+ join
5
+ } from "./chunk-K5TMXCMY.js";
6
+
7
+ // src/state-container/state-tree.ts
8
+ var segmentsOf = (path) => path ? path.split(".") : [];
9
+ function childAt(node2, segment) {
10
+ const children = node2?.children;
11
+ if (!children) return void 0;
12
+ if (Array.isArray(children)) return children[Number(segment)];
13
+ return Object.hasOwn(children, segment) ? children[segment] : void 0;
14
+ }
15
+ function node(self, children) {
16
+ if (self === void 0 && children === void 0) return void 0;
17
+ return children === void 0 ? { self } : self === void 0 ? { children } : { self, children };
18
+ }
19
+ function withChild(parent, segment, child, isArray) {
20
+ const children = parent?.children;
21
+ if (Array.isArray(children) || !children && isArray) {
22
+ const rows = children ?? [];
23
+ const index = Number(segment);
24
+ const next2 = Array.from({ length: Math.max(rows.length, index + 1) }, (_, i) => rows[i]);
25
+ next2[index] = child;
26
+ return node(parent?.self, trimmed(next2));
27
+ }
28
+ const next = createMap();
29
+ for (const [key, value] of Object.entries(children ?? {})) next[key] = value;
30
+ if (child === void 0) delete next[segment];
31
+ else next[segment] = child;
32
+ return node(parent?.self, Object.keys(next).length === 0 ? void 0 : next);
33
+ }
34
+ function trimmed(rows) {
35
+ let length = rows.length;
36
+ while (length > 0 && rows[length - 1] === void 0) length -= 1;
37
+ return length === 0 ? void 0 : rows.length === length ? rows : rows.slice(0, length);
38
+ }
39
+ function update(tree, path, isArrayAt, change) {
40
+ const segments = segmentsOf(path);
41
+ const write = (current, depth, prefix) => {
42
+ if (depth === segments.length) return change(current);
43
+ const existing = childAt(current, segments[depth]);
44
+ const child = write(existing, depth + 1, join(prefix, segments[depth]));
45
+ if (Object.is(child, existing)) return current;
46
+ return withChild(current, segments[depth], child, isArrayAt(prefix));
47
+ };
48
+ return write(tree, 0, "");
49
+ }
50
+ function nodeAt(tree, path) {
51
+ return segmentsOf(path).reduce((current, segment) => childAt(current, segment), tree);
52
+ }
53
+ function selfAt(tree, path) {
54
+ return nodeAt(tree, path)?.self;
55
+ }
56
+ function coveredAt(tree, path) {
57
+ let current = tree;
58
+ if (current?.self !== void 0) return true;
59
+ for (const segment of segmentsOf(path)) {
60
+ current = childAt(current, segment);
61
+ if (current === void 0) return false;
62
+ if (current.self !== void 0) return true;
63
+ }
64
+ return false;
65
+ }
66
+ function setSelfAt(tree, path, self, isArrayAt) {
67
+ return update(tree, path, isArrayAt, (current) => node(self, current?.children));
68
+ }
69
+ function markAt(tree, path, isArrayAt) {
70
+ return coveredAt(tree, path) ? tree : setSelfAt(tree, path, true, isArrayAt);
71
+ }
72
+ function clearAt(tree, path) {
73
+ return update(
74
+ tree,
75
+ path,
76
+ () => false,
77
+ () => void 0
78
+ );
79
+ }
80
+ function clearSelfAt(tree, path) {
81
+ return update(
82
+ tree,
83
+ path,
84
+ () => false,
85
+ (current) => node(void 0, current?.children)
86
+ );
87
+ }
88
+ function clearAround(tree, path) {
89
+ const segments = segmentsOf(path);
90
+ return segments.reduce(
91
+ (current, _, depth) => clearSelfAt(current, segments.slice(0, depth).join(".")),
92
+ tree
93
+ );
94
+ }
95
+ function reorderAt(tree, path, order) {
96
+ return update(
97
+ tree,
98
+ path,
99
+ () => false,
100
+ (current) => {
101
+ const rows = current?.children;
102
+ if (!Array.isArray(rows)) return current;
103
+ return node(current?.self, trimmed(order.map((from) => from === void 0 ? void 0 : rows[from])));
104
+ }
105
+ );
106
+ }
107
+ function conform(current, value) {
108
+ const children = current.children;
109
+ if (!children) return current;
110
+ const container = value !== null && typeof value === "object" && !isOpaque(value);
111
+ if (!container || Array.isArray(children) !== Array.isArray(value)) return node(current.self, void 0);
112
+ if (Array.isArray(children)) {
113
+ const rows = value.length;
114
+ return node(
115
+ current.self,
116
+ trimmed(
117
+ children.slice(0, rows).map((child, index) => child && conform(child, value[index]))
118
+ )
119
+ );
120
+ }
121
+ const next = createMap();
122
+ for (const [key, child] of Object.entries(children)) {
123
+ const kept = conform(child, value[key]);
124
+ if (kept) next[key] = kept;
125
+ }
126
+ return node(current.self, Object.keys(next).length === 0 ? void 0 : next);
127
+ }
128
+ function conformAt(tree, path, value) {
129
+ return update(
130
+ tree,
131
+ path,
132
+ () => false,
133
+ (current) => current ? conform(current, value) : current
134
+ );
135
+ }
136
+ function entries(tree, path = "", out = []) {
137
+ if (!tree) return out;
138
+ if (tree.self !== void 0) out.push([path, tree.self]);
139
+ const children = tree.children;
140
+ if (Array.isArray(children)) {
141
+ children.forEach((child, index) => entries(child, join(path, String(index)), out));
142
+ } else if (children) {
143
+ for (const [key, child] of Object.entries(children)) {
144
+ entries(child, join(path, key), out);
145
+ }
146
+ }
147
+ return out;
148
+ }
149
+ function fromEntries(marks, isArrayAt) {
150
+ return marks.reduce((tree, [path, self]) => setSelfAt(tree, path, self, isArrayAt), void 0);
151
+ }
152
+ function stable(previous, next) {
153
+ if (Object.is(previous, next) || !previous || !next) return next;
154
+ const before = previous.children;
155
+ const after = next.children;
156
+ let children = after;
157
+ if (Array.isArray(before) && Array.isArray(after)) {
158
+ const merged = after.map((child, index) => stable(before[index], child));
159
+ children = merged.length === before.length && merged.every((child, index) => child === before[index]) ? before : merged;
160
+ } else if (before && after && !Array.isArray(before) && !Array.isArray(after)) {
161
+ const prior = before;
162
+ const merged = createMap();
163
+ for (const [key, child] of Object.entries(after)) {
164
+ merged[key] = stable(prior[key], child);
165
+ }
166
+ children = Object.keys(merged).length === Object.keys(prior).length && Object.keys(merged).every((key) => merged[key] === prior[key]) ? before : merged;
167
+ }
168
+ return Object.is(previous.self, next.self) && children === before ? previous : node(next.self, children);
169
+ }
170
+
171
+ export {
172
+ nodeAt,
173
+ selfAt,
174
+ coveredAt,
175
+ setSelfAt,
176
+ markAt,
177
+ clearAt,
178
+ clearSelfAt,
179
+ clearAround,
180
+ reorderAt,
181
+ conformAt,
182
+ entries,
183
+ fromEntries,
184
+ stable
185
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/state-container/state-tree.ts"],
4
+ "sourcesContent": ["import { isOpaque, join, createMap, type NullMap } from './value-tree';\n\n/**\n * Field state kept in the shape of the values, one slot per node.\n *\n * @remarks\n * A node holds the state of its own path in `self` and the state of the paths below it in `children`: an\n * array with one element per row where the value is an array, a null-prototype map where it is an object.\n * A node's `self` is never inferred from its children or its parent, so `contacts` and `contacts.0.email`\n * each hold their own, and the form itself is the root node. A row operation is one splice of the\n * `children` array, which moves each row's state with it. Nodes with nothing in them are never stored.\n */\nexport interface Node<T> {\n\treadonly self?: T;\n\treadonly children?: Children<T>;\n}\n\nexport type Children<T> = readonly (Node<T> | undefined)[] | { readonly [key: string]: Node<T> };\n\nexport type Tree<T> = Node<T> | undefined;\n\n/** Whether the value at a path is an array, which decides the kind of children its state node gets. */\nexport type IsArrayAt = (path: string) => boolean;\n\nconst segmentsOf = (path: string): string[] => (path ? path.split('.') : []);\n\nfunction childAt<T>(node: Node<T> | undefined, segment: string): Node<T> | undefined {\n\tconst children = node?.children;\n\tif (!children) return undefined;\n\tif (Array.isArray(children)) return children[Number(segment)];\n\treturn Object.hasOwn(children, segment) ? (children as Record<string, Node<T>>)[segment] : undefined;\n}\n\nfunction node<T>(self: T | undefined, children: Children<T> | undefined): Node<T> | undefined {\n\tif (self === undefined && children === undefined) return undefined;\n\treturn children === undefined ? { self } : self === undefined ? { children } : { self, children };\n}\n\nfunction withChild<T>(\n\tparent: Node<T> | undefined,\n\tsegment: string,\n\tchild: Node<T> | undefined,\n\tisArray: boolean,\n): Node<T> | undefined {\n\tconst children = parent?.children;\n\tif (Array.isArray(children) || (!children && isArray)) {\n\t\tconst rows = (children ?? []) as readonly (Node<T> | undefined)[];\n\t\tconst index = Number(segment);\n\t\tconst next = Array.from({ length: Math.max(rows.length, index + 1) }, (_, i) => rows[i]);\n\t\tnext[index] = child;\n\t\treturn node(parent?.self, trimmed(next));\n\t}\n\tconst next = createMap<Node<T>>();\n\tfor (const [key, value] of Object.entries((children ?? {}) as Record<string, Node<T>>)) next[key] = value;\n\tif (child === undefined) delete next[segment];\n\telse next[segment] = child;\n\treturn node(parent?.self, Object.keys(next).length === 0 ? undefined : next);\n}\n\nfunction trimmed<T>(rows: readonly (Node<T> | undefined)[]): Children<T> | undefined {\n\tlet length = rows.length;\n\twhile (length > 0 && rows[length - 1] === undefined) length -= 1;\n\treturn length === 0 ? undefined : rows.length === length ? rows : rows.slice(0, length);\n}\n\n/** Rewrites the node at `path`, copying only the nodes along the path; nothing is created for `undefined`. */\nfunction update<T>(\n\ttree: Tree<T>,\n\tpath: string,\n\tisArrayAt: IsArrayAt,\n\tchange: (current: Node<T> | undefined) => Node<T> | undefined,\n): Tree<T> {\n\tconst segments = segmentsOf(path);\n\tconst write = (current: Node<T> | undefined, depth: number, prefix: string): Node<T> | undefined => {\n\t\tif (depth === segments.length) return change(current);\n\t\tconst existing = childAt(current, segments[depth]);\n\t\tconst child = write(existing, depth + 1, join(prefix, segments[depth]));\n\t\tif (Object.is(child, existing)) return current;\n\t\treturn withChild(current, segments[depth], child, isArrayAt(prefix));\n\t};\n\treturn write(tree, 0, '');\n}\n\n/** The node at `path`. */\nexport function nodeAt<T>(tree: Tree<T>, path: string): Node<T> | undefined {\n\treturn segmentsOf(path).reduce<Node<T> | undefined>((current, segment) => childAt(current, segment), tree);\n}\n\n/** The state of exactly `path`. */\nexport function selfAt<T>(tree: Tree<T>, path: string): T | undefined {\n\treturn nodeAt(tree, path)?.self;\n}\n\n/** Whether `path` or a path around it, the form included, holds a mark. */\nexport function coveredAt<T>(tree: Tree<T>, path: string): boolean {\n\tlet current = tree;\n\tif (current?.self !== undefined) return true;\n\tfor (const segment of segmentsOf(path)) {\n\t\tcurrent = childAt(current, segment);\n\t\tif (current === undefined) return false;\n\t\tif (current.self !== undefined) return true;\n\t}\n\treturn false;\n}\n\n/** Sets the state of exactly `path`; `undefined` clears it. */\nexport function setSelfAt<T>(tree: Tree<T>, path: string, self: T | undefined, isArrayAt: IsArrayAt): Tree<T> {\n\treturn update(tree, path, isArrayAt, (current) => node(self, current?.children));\n}\n\n/** Marks `path` unless it is already covered. */\nexport function markAt(tree: Tree<true>, path: string, isArrayAt: IsArrayAt): Tree<true> {\n\treturn coveredAt(tree, path) ? tree : setSelfAt(tree, path, true, isArrayAt);\n}\n\n/** Clears the state of `path` and of everything below it. */\nexport function clearAt<T>(tree: Tree<T>, path: string): Tree<T> {\n\treturn update(\n\t\ttree,\n\t\tpath,\n\t\t() => false,\n\t\t() => undefined,\n\t);\n}\n\n/** Clears the state of exactly `path`, keeping what is below it. */\nexport function clearSelfAt<T>(tree: Tree<T>, path: string): Tree<T> {\n\treturn update(\n\t\ttree,\n\t\tpath,\n\t\t() => false,\n\t\t(current) => node(undefined, current?.children),\n\t);\n}\n\n/** Clears the state of the paths around `path`, the form included, keeping `path` and what is below it. */\nexport function clearAround<T>(tree: Tree<T>, path: string): Tree<T> {\n\tconst segments = segmentsOf(path);\n\treturn segments.reduce<Tree<T>>(\n\t\t(current, _, depth) => clearSelfAt(current, segments.slice(0, depth).join('.')),\n\t\ttree,\n\t);\n}\n\n/**\n * Rebuilds the array at `path` from its old rows: element `i` becomes old row `order[i]`, or nothing for a new row.\n *\n * @remarks This is the splice of a row operation, applied to one tree.\n */\nexport function reorderAt<T>(tree: Tree<T>, path: string, order: ReadonlyArray<number | undefined>): Tree<T> {\n\treturn update(\n\t\ttree,\n\t\tpath,\n\t\t() => false,\n\t\t(current) => {\n\t\t\tconst rows = current?.children;\n\t\t\tif (!Array.isArray(rows)) return current;\n\t\t\treturn node(current?.self, trimmed(order.map((from) => (from === undefined ? undefined : rows[from]))));\n\t\t},\n\t);\n}\n\nfunction conform<T>(current: Node<T>, value: unknown): Node<T> | undefined {\n\tconst children = current.children;\n\tif (!children) return current;\n\tconst container = value !== null && typeof value === 'object' && !isOpaque(value);\n\tif (!container || Array.isArray(children) !== Array.isArray(value)) return node(current.self, undefined);\n\tif (Array.isArray(children)) {\n\t\tconst rows = (value as unknown[]).length;\n\t\treturn node(\n\t\t\tcurrent.self,\n\t\t\ttrimmed(\n\t\t\t\tchildren.slice(0, rows).map((child, index) => child && conform(child, (value as unknown[])[index])),\n\t\t\t),\n\t\t);\n\t}\n\tconst next = createMap<Node<T>>();\n\tfor (const [key, child] of Object.entries(children as Record<string, Node<T>>)) {\n\t\tconst kept = conform(child, (value as NullMap)[key]);\n\t\tif (kept) next[key] = kept;\n\t}\n\treturn node(current.self, Object.keys(next).length === 0 ? undefined : next);\n}\n\n/**\n * Cuts the state at `path` down to the shape of `value`, which was just written there.\n *\n * @remarks\n * Rows past the end of an array, and branches that are no longer a container of their kind, lose their\n * state; the state of `path` itself and of fields an object does not currently hold is kept.\n */\nexport function conformAt<T>(tree: Tree<T>, path: string, value: unknown): Tree<T> {\n\treturn update(\n\t\ttree,\n\t\tpath,\n\t\t() => false,\n\t\t(current) => (current ? conform(current, value) : current),\n\t);\n}\n\n/** Every mark of the tree by dotted path; the form's own is at `''`. */\nexport function entries<T>(tree: Tree<T>, path = '', out: [string, T][] = []): [string, T][] {\n\tif (!tree) return out;\n\tif (tree.self !== undefined) out.push([path, tree.self]);\n\tconst children = tree.children;\n\tif (Array.isArray(children)) {\n\t\tchildren.forEach((child, index) => entries(child, join(path, String(index)), out));\n\t} else if (children) {\n\t\tfor (const [key, child] of Object.entries(children as Record<string, Node<T>>)) {\n\t\t\tentries(child, join(path, key), out);\n\t\t}\n\t}\n\treturn out;\n}\n\n/** A tree from marks by dotted path. */\nexport function fromEntries<T>(marks: ReadonlyArray<readonly [string, T]>, isArrayAt: IsArrayAt): Tree<T> {\n\treturn marks.reduce<Tree<T>>((tree, [path, self]) => setSelfAt(tree, path, self, isArrayAt), undefined);\n}\n\n/** The previous tree when `next` holds the same state, else `next` with every unchanged branch shared. */\nexport function stable<T>(previous: Tree<T>, next: Tree<T>): Tree<T> {\n\tif (Object.is(previous, next) || !previous || !next) return next;\n\tconst before = previous.children;\n\tconst after = next.children;\n\tlet children = after;\n\tif (Array.isArray(before) && Array.isArray(after)) {\n\t\tconst merged = after.map((child, index) => stable(before[index], child));\n\t\tchildren =\n\t\t\tmerged.length === before.length && merged.every((child, index) => child === before[index])\n\t\t\t\t? before\n\t\t\t\t: merged;\n\t} else if (before && after && !Array.isArray(before) && !Array.isArray(after)) {\n\t\tconst prior = before as Record<string, Node<T>>;\n\t\tconst merged = createMap<Node<T>>();\n\t\tfor (const [key, child] of Object.entries(after as Record<string, Node<T>>)) {\n\t\t\tmerged[key] = stable(prior[key], child) as Node<T>;\n\t\t}\n\t\tchildren =\n\t\t\tObject.keys(merged).length === Object.keys(prior).length &&\n\t\t\tObject.keys(merged).every((key) => merged[key] === prior[key])\n\t\t\t\t? before\n\t\t\t\t: merged;\n\t}\n\treturn Object.is(previous.self, next.self) && children === before ? previous : node(next.self, children);\n}\n"],
5
+ "mappings": ";;;;;;;AAwBA,IAAM,aAAa,CAAC,SAA4B,OAAO,KAAK,MAAM,GAAG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AC5D,QAAM,SAAS,SAAS;AACxB,QAAM,QAAQ,KAAK;AACnB,MAAI,WAAW;AACf,MAAI,MAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,KAAK,GAAG;AAClD,UAAM,SAAS,MAAM,IAAI,CAAC,OAAO,UAAU,OAAO,OAAO,KAAK,GAAG,KAAK,CAAC;AACvE,eACC,OAAO,WAAW,OAAO,UAAU,OAAO,MAAM,CAAC,OAAO,UAAU,UAAU,OAAO,KAAK,CAAC,IACtF,SACA;AAAA,EACL,WAAW,UAAU,SAAS,CAAC,MAAM,QAAQ,MAAM,KAAK,CAAC,MAAM,QAAQ,KAAK,GAAG;AAC9E,UAAM,QAAQ;AACd,UAAM,SAAS,UAAmB;AAClC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAgC,GAAG;AAC5E,aAAO,GAAG,IAAI,OAAO,MAAM,GAAG,GAAG,KAAK;AAAA,IACvC;AACA,eACC,OAAO,KAAK,MAAM,EAAE,WAAW,OAAO,KAAK,KAAK,EAAE,UAClD,OAAO,KAAK,MAAM,EAAE,MAAM,CAAC,QAAQ,OAAO,GAAG,MAAM,MAAM,GAAG,CAAC,IAC1D,SACA;AAAA,EACL;AACA,SAAO,OAAO,GAAG,SAAS,MAAM,KAAK,IAAI,KAAK,aAAa,SAAS,WAAW,KAAK,KAAK,MAAM,QAAQ;AACxG;",
6
+ "names": ["node", "next"]
7
+ }
@@ -0,0 +1,56 @@
1
+ import {
2
+ DEFAULT_WIZARD_RECIPE
3
+ } from "./chunk-EZZHO6DQ.js";
4
+
5
+ // src/lib/authoring-catalog.ts
6
+ function recipeToDescriptor(recipe, viewSchema) {
7
+ return {
8
+ $type: recipe.$type,
9
+ kind: recipe.kind,
10
+ slots: [...recipe.slots],
11
+ metadata: recipe.metadata,
12
+ viewSchema: viewSchema ?? {}
13
+ };
14
+ }
15
+ function describeRecipeFromRegistration(recipe, generateViewSchema) {
16
+ return recipeToDescriptor(recipe, generateViewSchema?.(recipe));
17
+ }
18
+ function describeViewCatalogFromRecipes(recipes, generateViewSchema) {
19
+ return {
20
+ recipes: recipes.map((recipe) => describeRecipeFromRegistration(recipe, generateViewSchema)),
21
+ rules: {
22
+ noViewSingleStep: "Omit view for a single-step form to render fields only.",
23
+ noViewMultiStep: `Omit view for a multi-step form and validateForm writes the engine's default wizard recipe as its view (${DEFAULT_WIZARD_RECIPE} unless createFormEngine({ defaultWizardRecipe }) names another). If that recipe is not registered, validateForm still succeeds and warns, then every step renders on a single page without chrome.`,
24
+ oneViewPerForm: "Each form has at most one view. Recipes are code-defined; forms select view.$type and pass slot config."
25
+ }
26
+ };
27
+ }
28
+ function getAuthoringInstructionsFromCatalog(catalog) {
29
+ const lines = [
30
+ "# Schema Engine form authoring",
31
+ "",
32
+ "## Rules",
33
+ `- ${catalog.rules.oneViewPerForm}`,
34
+ `- ${catalog.rules.noViewSingleStep}`,
35
+ `- ${catalog.rules.noViewMultiStep}`,
36
+ "- Invalid view.$type, malformed slot config, or kind/step mismatch throws at validateForm and render.",
37
+ "- content is engine-owned and never appears in view JSON.",
38
+ "- Slot config has no $type; the recipe fixes block identity.",
39
+ "",
40
+ "## Registered recipes",
41
+ ""
42
+ ];
43
+ for (const recipe of catalog.recipes) {
44
+ lines.push(`### ${recipe.$type} (${recipe.kind})`);
45
+ lines.push(`- ${recipe.metadata.description}`);
46
+ lines.push(`- Slots: ${recipe.slots.join(", ") || "(shell only)"}`);
47
+ lines.push("");
48
+ }
49
+ return lines.join("\n");
50
+ }
51
+
52
+ export {
53
+ describeRecipeFromRegistration,
54
+ describeViewCatalogFromRecipes,
55
+ getAuthoringInstructionsFromCatalog
56
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/authoring-catalog.ts"],
4
+ "sourcesContent": ["import type { AnyRecipeRegistration } from '@/types/registration';\nimport { DEFAULT_WIZARD_RECIPE } from '@/lib/form-view';\nimport type { RecipeDescriptor, ViewCatalog } from '@/recipes/types';\n\nfunction recipeToDescriptor(recipe: AnyRecipeRegistration, viewSchema?: Record<string, unknown>): RecipeDescriptor {\n\treturn {\n\t\t$type: recipe.$type,\n\t\tkind: recipe.kind,\n\t\tslots: [...recipe.slots],\n\t\tmetadata: recipe.metadata,\n\t\tviewSchema: viewSchema ?? {},\n\t};\n}\n\nexport function describeRecipeFromRegistration(\n\trecipe: AnyRecipeRegistration,\n\tgenerateViewSchema?: (recipe: AnyRecipeRegistration) => Record<string, unknown>,\n): RecipeDescriptor {\n\treturn recipeToDescriptor(recipe, generateViewSchema?.(recipe));\n}\n\nexport function describeViewCatalogFromRecipes(\n\trecipes: AnyRecipeRegistration[],\n\tgenerateViewSchema?: (recipe: AnyRecipeRegistration) => Record<string, unknown>,\n): ViewCatalog {\n\treturn {\n\t\trecipes: recipes.map((recipe) => describeRecipeFromRegistration(recipe, generateViewSchema)),\n\t\trules: {\n\t\t\tnoViewSingleStep: 'Omit view for a single-step form to render fields only.',\n\t\t\tnoViewMultiStep: `Omit view for a multi-step form and validateForm writes the engine's default wizard recipe as its view (${DEFAULT_WIZARD_RECIPE} unless createFormEngine({ defaultWizardRecipe }) names another). If that recipe is not registered, validateForm still succeeds and warns, then every step renders on a single page without chrome.`,\n\t\t\toneViewPerForm:\n\t\t\t\t'Each form has at most one view. Recipes are code-defined; forms select view.$type and pass slot config.',\n\t\t},\n\t};\n}\n\nexport function getAuthoringInstructionsFromCatalog(catalog: ViewCatalog): string {\n\tconst lines = [\n\t\t'# Schema Engine form authoring',\n\t\t'',\n\t\t'## Rules',\n\t\t`- ${catalog.rules.oneViewPerForm}`,\n\t\t`- ${catalog.rules.noViewSingleStep}`,\n\t\t`- ${catalog.rules.noViewMultiStep}`,\n\t\t'- Invalid view.$type, malformed slot config, or kind/step mismatch throws at validateForm and render.',\n\t\t'- content is engine-owned and never appears in view JSON.',\n\t\t'- Slot config has no $type; the recipe fixes block identity.',\n\t\t'',\n\t\t'## Registered recipes',\n\t\t'',\n\t];\n\n\tfor (const recipe of catalog.recipes) {\n\t\tlines.push(`### ${recipe.$type} (${recipe.kind})`);\n\t\tlines.push(`- ${recipe.metadata.description}`);\n\t\tlines.push(`- Slots: ${recipe.slots.join(', ') || '(shell only)'}`);\n\t\tlines.push('');\n\t}\n\n\treturn lines.join('\\n');\n}\n"],
5
+ "mappings": ";;;;;AAIA,SAAS,mBAAmB,QAA+B,YAAwD;AAClH,SAAO;AAAA,IACN,OAAO,OAAO;AAAA,IACd,MAAM,OAAO;AAAA,IACb,OAAO,CAAC,GAAG,OAAO,KAAK;AAAA,IACvB,UAAU,OAAO;AAAA,IACjB,YAAY,cAAc,CAAC;AAAA,EAC5B;AACD;AAEO,SAAS,+BACf,QACA,oBACmB;AACnB,SAAO,mBAAmB,QAAQ,qBAAqB,MAAM,CAAC;AAC/D;AAEO,SAAS,+BACf,SACA,oBACc;AACd,SAAO;AAAA,IACN,SAAS,QAAQ,IAAI,CAAC,WAAW,+BAA+B,QAAQ,kBAAkB,CAAC;AAAA,IAC3F,OAAO;AAAA,MACN,kBAAkB;AAAA,MAClB,iBAAiB,2GAA2G,qBAAqB;AAAA,MACjJ,gBACC;AAAA,IACF;AAAA,EACD;AACD;AAEO,SAAS,oCAAoC,SAA8B;AACjF,QAAM,QAAQ;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK,QAAQ,MAAM,cAAc;AAAA,IACjC,KAAK,QAAQ,MAAM,gBAAgB;AAAA,IACnC,KAAK,QAAQ,MAAM,eAAe;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,aAAW,UAAU,QAAQ,SAAS;AACrC,UAAM,KAAK,OAAO,OAAO,KAAK,KAAK,OAAO,IAAI,GAAG;AACjD,UAAM,KAAK,KAAK,OAAO,SAAS,WAAW,EAAE;AAC7C,UAAM,KAAK,YAAY,OAAO,MAAM,KAAK,IAAI,KAAK,cAAc,EAAE;AAClE,UAAM,KAAK,EAAE;AAAA,EACd;AAEA,SAAO,MAAM,KAAK,IAAI;AACvB;",
6
+ "names": []
7
+ }