@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,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types/define-element.ts"],
4
+ "sourcesContent": ["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { ElementMetadata } from './metadata';\nimport type { ContainerKind, InputRegistration, StaticRegistration, ValueDeclaration } from './registration';\nimport type { NormalizedElementConfig } from '@/lib/normalized-form-config';\nimport type { ValidationRegistrationConstraint } from '@/schemas/validation/types';\nimport type { AppearanceAxisList } from '@schema-engine/layout';\n\ntype InferOutput<TSchema> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : never;\n\n/**\n * Rewrite container `elements` to the normalized children the renderer receives.\n * Parent schemas only require `$type`; the engine supplies frozen, validated children.\n */\nexport type WithNormalizedChildren<T> = T extends { elements: unknown[] }\n\t? Omit<T, 'elements'> & { readonly elements: ReadonlyArray<NormalizedElementConfig> }\n\t: T;\n\nexport type ElementRenderProps<TSchema extends StandardSchemaV1, THandlers = unknown> = WithNormalizedChildren<\n\tInferOutput<TSchema>\n> & {\n\t/** Stable array-item identity overlaid at render time. Not part of authoring. */\n\tinstanceId?: string;\n} & THandlers;\n\ntype DefineElementRegistration<\n\tTType extends string,\n\tTSchema extends StandardSchemaV1,\n\tTProps,\n\tTKind extends ContainerKind | undefined = ContainerKind | undefined,\n> = {\n\t$type: TType;\n\tschema: TSchema;\n\tmetadata: ElementMetadata;\n\tcontainerKind?: TKind;\n\tappearanceAxes?: AppearanceAxisList;\n\trender: (props: TProps) => unknown;\n};\n\n/**\n * What an input declares about its value, by one rule: `value` is required exactly when its schema output has no `elements`.\n *\n * @remarks\n * A schema that declares `elements` makes the element a container, whose value the engine composes from its children,\n * so it declares no `value` and may set `containerKind` (`'object'` when it does not). Any other input must declare\n * `value`, which is how a registration whose control writes a value the engine cannot check is a type error. A schema\n * that merely allows any key (an index signature) does not declare `elements`.\n */\ntype InputValueDeclaration<TSchema extends StandardSchemaV1, TValue extends StandardSchemaV1> =\n\tDeclaresChildren<InferOutput<TSchema>> extends true\n\t\t? { containerKind?: ContainerKind; value?: never }\n\t\t: { containerKind?: undefined; value: ValueDeclaration<WithNormalizedChildren<InferOutput<TSchema>>, TValue> };\n\n/** Whether a schema output declares `elements`: a key of its own, or an array typed beside an index signature. */\ntype DeclaresChildren<TOutput> = 'elements' extends keyof TOutput\n\t? string extends keyof TOutput\n\t\t? TOutput extends { elements?: readonly unknown[] }\n\t\t\t? true\n\t\t\t: false\n\t\t: true\n\t: false;\n\ntype DefineInputRegistration<\n\tTType extends string,\n\tTSchema extends StandardSchemaV1,\n\tTProps,\n\tTValue extends StandardSchemaV1,\n\tTKind extends ContainerKind | undefined,\n> = DefineElementRegistration<TType, TSchema, TProps, TKind> & {\n\tvalidations?: readonly ValidationRegistrationConstraint[];\n} & InputValueDeclaration<TSchema, TValue>;\n\ntype DefineElementArg<TType extends string, TSchema extends StandardSchemaV1, TProps> =\n\tWithNormalizedChildren<InferOutput<TSchema>> extends TProps\n\t\t? DefineElementRegistration<TType, TSchema, TProps>\n\t\t: never;\n\ntype DefineInputArg<\n\tTType extends string,\n\tTSchema extends StandardSchemaV1,\n\tTProps,\n\tTValue extends StandardSchemaV1,\n\tTKind extends ContainerKind | undefined,\n> =\n\tWithNormalizedChildren<InferOutput<TSchema>> extends TProps\n\t\t? DefineInputRegistration<TType, TSchema, TProps, TValue, TKind>\n\t\t: never;\n\n/**\n * Register an input element while preserving schema input/output inference.\n *\n * Form authors supply schema input (defaults stay optional). The render function\n * must accept schema output, with container `elements` already normalized.\n * `validations` are registered when the element is added to a form engine.\n *\n * `value` declares the value the control writes, as a function of the configured element\n * (see {@link ValueDeclaration}); it is required unless the schema has `elements`.\n *\n * It sets the registration's `kind` to `'input'`, which is what the engine reads to require `value`, not the metadata category.\n */\nexport function defineInput<\n\tconst TType extends string,\n\tTSchema extends StandardSchemaV1,\n\tTProps = WithNormalizedChildren<InferOutput<TSchema>>,\n\tTValue extends StandardSchemaV1 = never,\n\tconst TKind extends ContainerKind | undefined = undefined,\n>(\n\tregistration: DefineInputArg<TType, TSchema, TProps, TValue, TKind>,\n): InputRegistration<TType, TSchema, TProps, TValue, TKind> {\n\treturn { ...registration, kind: 'input' } as unknown as InputRegistration<TType, TSchema, TProps, TValue, TKind>;\n}\n\n/**\n * Register a display-only element while preserving schema input/output inference.\n *\n * It sets the registration's `kind` to `'static'`, so the engine asks it for no `value`, whatever its metadata category.\n */\nexport function defineStatic<\n\tconst TType extends string,\n\tTSchema extends StandardSchemaV1,\n\tTProps = WithNormalizedChildren<InferOutput<TSchema>>,\n>(registration: DefineElementArg<TType, TSchema, TProps>): StaticRegistration<TType, TSchema, TProps> {\n\treturn { ...registration, kind: 'static' } as StaticRegistration<TType, TSchema, TProps>;\n}\n"],
5
+ "mappings": ";AAmGO,SAAS,YAOf,cAC2D;AAC3D,SAAO,EAAE,GAAG,cAAc,MAAM,QAAQ;AACzC;AAOO,SAAS,aAId,cAAoG;AACrG,SAAO,EAAE,GAAG,cAAc,MAAM,SAAS;AAC1C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,139 @@
1
+ import {
2
+ assertWritablePathKey,
3
+ isReservedPathKey
4
+ } from "./chunk-3YLRJVVN.js";
5
+ import {
6
+ isPlainObject
7
+ } from "./chunk-CMPOBBRV.js";
8
+
9
+ // src/state-container/value-tree.ts
10
+ var isStructural = (node) => node !== null && typeof node === "object" && !isOpaque(node);
11
+ function createMap() {
12
+ return /* @__PURE__ */ Object.create(null);
13
+ }
14
+ function isOpaque(value) {
15
+ if (value === null || typeof value !== "object") return false;
16
+ if (Array.isArray(value)) return value.some(isOpaque);
17
+ return !isPlainObject(value);
18
+ }
19
+ function toPlainRecord(record) {
20
+ const plain = toPlain(record);
21
+ return isPlainObject(plain) ? plain : {};
22
+ }
23
+ function toInternalRecord(record) {
24
+ const copy = createMap();
25
+ for (const [key, child] of Object.entries(record)) {
26
+ if (!isReservedPathKey(key)) copy[key] = toInternal(child);
27
+ }
28
+ return copy;
29
+ }
30
+ function toInternal(value) {
31
+ if (isOpaque(value)) return value;
32
+ if (Array.isArray(value)) return value.map(toInternal);
33
+ if (isPlainObject(value)) return toInternalRecord(value);
34
+ return value;
35
+ }
36
+ var plainCache = /* @__PURE__ */ new WeakMap();
37
+ function toPlain(value) {
38
+ if (value === null || typeof value !== "object") return value;
39
+ const cached = plainCache.get(value);
40
+ if (cached !== void 0) return cached;
41
+ let plain = value;
42
+ if (!isOpaque(value)) {
43
+ if (Array.isArray(value)) {
44
+ plain = Object.freeze(value.map(toPlain));
45
+ } else {
46
+ const copy = {};
47
+ for (const [key, child] of Object.entries(value)) copy[key] = toPlain(child);
48
+ plain = Object.freeze(copy);
49
+ }
50
+ }
51
+ plainCache.set(value, plain);
52
+ return plain;
53
+ }
54
+ function toPlainMap(map) {
55
+ const cached = plainCache.get(map);
56
+ if (cached !== void 0) return cached;
57
+ const plain = Object.freeze({ ...map });
58
+ plainCache.set(map, plain);
59
+ return plain;
60
+ }
61
+ function stabilize(previous, next) {
62
+ const nextKeys = Object.keys(next);
63
+ if (nextKeys.length !== Object.keys(previous).length) return next;
64
+ return nextKeys.every((key) => Object.hasOwn(previous, key) && Object.is(previous[key], next[key])) ? previous : next;
65
+ }
66
+ function reconcile(previous, next) {
67
+ if (Object.is(previous, next)) return previous;
68
+ if (Array.isArray(previous) && Array.isArray(next) && !isOpaque(previous) && !isOpaque(next)) {
69
+ const merged = next.map((item, index) => reconcile(previous[index], item));
70
+ return merged.length === previous.length && merged.every((item, index) => item === previous[index]) ? previous : merged;
71
+ }
72
+ if (isPlainObject(previous) && isPlainObject(next) && !Array.isArray(previous) && !Array.isArray(next)) {
73
+ const keys = Object.keys(next);
74
+ const merged = createMap();
75
+ for (const key of keys) {
76
+ merged[key] = Object.hasOwn(previous, key) ? reconcile(previous[key], next[key]) : next[key];
77
+ }
78
+ return keys.length === Object.keys(previous).length && keys.every((key) => Object.hasOwn(previous, key) && merged[key] === previous[key]) ? previous : merged;
79
+ }
80
+ return next;
81
+ }
82
+ function setIn(root, path, value) {
83
+ if (!path) return isPlainObject(value) ? value : root;
84
+ const segments = path.split(".");
85
+ segments.forEach(assertWritablePathKey);
86
+ const write = (node, depth) => {
87
+ const segment = segments[depth];
88
+ const isLast = depth === segments.length - 1;
89
+ const container = node !== null && typeof node === "object" && !isOpaque(node) ? node : /^\d+$/.test(segment) ? [] : createMap();
90
+ const current = container[segment];
91
+ const child = isLast ? value : write(current, depth + 1);
92
+ if (Object.is(child, current) && container === node) return node;
93
+ if (Array.isArray(container)) {
94
+ const copy2 = [...container];
95
+ copy2[Number(segment)] = child;
96
+ return copy2;
97
+ }
98
+ const copy = createMap();
99
+ for (const key of Object.keys(container)) copy[key] = container[key];
100
+ copy[segment] = child;
101
+ return copy;
102
+ };
103
+ return write(root, 0);
104
+ }
105
+ function isWithin(path, scope) {
106
+ return scope === "" || path === scope || path.startsWith(`${scope}.`);
107
+ }
108
+ function join(path, segment) {
109
+ return path ? `${path}.${segment}` : segment;
110
+ }
111
+ function changedPaths(before, after, path = "", out = []) {
112
+ if (Object.is(before, after)) return out;
113
+ if (isStructural(before) && isStructural(after) && Array.isArray(before) === Array.isArray(after)) {
114
+ if (Array.isArray(before) && Array.isArray(after) && before.length !== after.length) out.push(path);
115
+ for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
116
+ changedPaths(before[key], after[key], join(path, key), out);
117
+ }
118
+ } else {
119
+ out.push(path);
120
+ }
121
+ return out;
122
+ }
123
+
124
+ export {
125
+ isStructural,
126
+ createMap,
127
+ isOpaque,
128
+ toPlainRecord,
129
+ toInternalRecord,
130
+ toInternal,
131
+ toPlain,
132
+ toPlainMap,
133
+ stabilize,
134
+ reconcile,
135
+ setIn,
136
+ isWithin,
137
+ join,
138
+ changedPaths
139
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/state-container/value-tree.ts"],
4
+ "sourcesContent": ["import { isPlainObject } from '@/lib/is-plain-object';\nimport { assertWritablePathKey, isReservedPathKey } from '@/lib/reserved-path-keys';\n\n/** A map held by the container: null-prototype, replaced rather than mutated. */\nexport type NullMap<T = unknown> = Record<string, T>;\n\nexport const isStructural = (node: unknown): node is NullMap | unknown[] =>\n\tnode !== null && typeof node === 'object' && !isOpaque(node);\n\nexport function createMap<T = unknown>(): NullMap<T> {\n\treturn Object.create(null) as NullMap<T>;\n}\n\n/**\n * Whether a value is compared by reference and never copied, frozen or diffed.\n *\n * @remarks\n * Plain records and primitives are structural. An array is structural only when each of its items is,\n * so `string[]` and arrays of rows are, and a `File[]` from a drop zone is not: copying it would break\n * the identity a control holds on to.\n */\nexport function isOpaque(value: unknown): boolean {\n\tif (value === null || typeof value !== 'object') return false;\n\tif (Array.isArray(value)) return value.some(isOpaque);\n\treturn !isPlainObject(value);\n}\n\n/** The frozen plain-record view of an internal record. */\nexport function toPlainRecord(record: NullMap): Readonly<Record<string, unknown>> {\n\tconst plain = toPlain(record);\n\treturn isPlainObject(plain) ? plain : {};\n}\n\n/** Copies the structural part of `record` into a null-prototype map; opaque values are kept as they are. */\nexport function toInternalRecord(record: Readonly<Record<string, unknown>>): NullMap {\n\tconst copy = createMap();\n\tfor (const [key, child] of Object.entries(record)) {\n\t\tif (!isReservedPathKey(key)) copy[key] = toInternal(child);\n\t}\n\treturn copy;\n}\n\n/** Copies the structural part of `value` into null-prototype maps; opaque values are kept as they are. */\nexport function toInternal(value: unknown): unknown {\n\tif (isOpaque(value)) return value;\n\tif (Array.isArray(value)) return value.map(toInternal);\n\tif (isPlainObject(value)) return toInternalRecord(value);\n\treturn value;\n}\n\nconst plainCache = new WeakMap<object, unknown>();\n\n/**\n * The frozen plain-record view of an internal value.\n *\n * @remarks\n * Memoized per internal node, so a branch that did not change comes back as the same object.\n */\nexport function toPlain(value: unknown): unknown {\n\tif (value === null || typeof value !== 'object') return value;\n\tconst cached = plainCache.get(value);\n\tif (cached !== undefined) return cached;\n\tlet plain: unknown = value;\n\tif (!isOpaque(value)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tplain = Object.freeze(value.map(toPlain));\n\t\t} else {\n\t\t\tconst copy: Record<string, unknown> = {};\n\t\t\tfor (const [key, child] of Object.entries(value)) copy[key] = toPlain(child);\n\t\t\tplain = Object.freeze(copy);\n\t\t}\n\t}\n\tplainCache.set(value, plain);\n\treturn plain;\n}\n\n/** Frozen plain view of a flat map; entries are carried over as they are. */\nexport function toPlainMap<T>(map: NullMap<T>): Readonly<Record<string, T>> {\n\tconst cached = plainCache.get(map);\n\tif (cached !== undefined) return cached as Readonly<Record<string, T>>;\n\tconst plain = Object.freeze({ ...map });\n\tplainCache.set(map, plain);\n\treturn plain;\n}\n\n/**\n * The previous value when `next` has the same keys holding the same references, else `next`.\n */\nexport function stabilize<T extends NullMap>(previous: T, next: T): T {\n\tconst nextKeys = Object.keys(next);\n\tif (nextKeys.length !== Object.keys(previous).length) return next;\n\treturn nextKeys.every((key) => Object.hasOwn(previous, key) && Object.is(previous[key], next[key]))\n\t\t? previous\n\t\t: next;\n}\n\n/**\n * Merges `next` into `previous`, keeping every branch that holds the same content as its old reference.\n */\nexport function reconcile(previous: unknown, next: unknown): unknown {\n\tif (Object.is(previous, next)) return previous;\n\tif (Array.isArray(previous) && Array.isArray(next) && !isOpaque(previous) && !isOpaque(next)) {\n\t\tconst merged = next.map((item, index) => reconcile(previous[index], item));\n\t\treturn merged.length === previous.length && merged.every((item, index) => item === previous[index])\n\t\t\t? previous\n\t\t\t: merged;\n\t}\n\tif (isPlainObject(previous) && isPlainObject(next) && !Array.isArray(previous) && !Array.isArray(next)) {\n\t\tconst keys = Object.keys(next);\n\t\tconst merged = createMap();\n\t\tfor (const key of keys) {\n\t\t\tmerged[key] = Object.hasOwn(previous, key) ? reconcile(previous[key], next[key]) : next[key];\n\t\t}\n\t\treturn keys.length === Object.keys(previous).length &&\n\t\t\tkeys.every((key) => Object.hasOwn(previous, key) && merged[key] === previous[key])\n\t\t\t? previous\n\t\t\t: merged;\n\t}\n\treturn next;\n}\n\n/**\n * Writes `value` at `path` without mutating `root`: only the containers along the path are copied.\n *\n * @remarks\n * A missing or non-container parent becomes an array when the next segment is an index and a map\n * otherwise. Returns `root` itself when the value at `path` is already `value`. An empty `path` replaces the root,\n * but only with a plain record; anything else leaves `root` as it is.\n */\nexport function setIn(root: NullMap, path: string, value: unknown): NullMap {\n\tif (!path) return isPlainObject(value) ? (value as NullMap) : root;\n\tconst segments = path.split('.');\n\tsegments.forEach(assertWritablePathKey);\n\tconst write = (node: unknown, depth: number): unknown => {\n\t\tconst segment = segments[depth];\n\t\tconst isLast = depth === segments.length - 1;\n\t\tconst container =\n\t\t\tnode !== null && typeof node === 'object' && !isOpaque(node)\n\t\t\t\t? node\n\t\t\t\t: /^\\d+$/.test(segment)\n\t\t\t\t\t? []\n\t\t\t\t\t: createMap();\n\t\tconst current = (container as Record<string, unknown>)[segment];\n\t\tconst child = isLast ? value : write(current, depth + 1);\n\t\tif (Object.is(child, current) && container === node) return node;\n\t\tif (Array.isArray(container)) {\n\t\t\tconst copy = [...container];\n\t\t\tcopy[Number(segment)] = child;\n\t\t\treturn copy;\n\t\t}\n\t\tconst copy = createMap();\n\t\tfor (const key of Object.keys(container)) copy[key] = (container as NullMap)[key];\n\t\tcopy[segment] = child;\n\t\treturn copy;\n\t};\n\treturn write(root, 0) as NullMap;\n}\n\n/** Whether `path` is `scope` or lies below it. */\nexport function isWithin(path: string, scope: string): boolean {\n\treturn scope === '' || path === scope || path.startsWith(`${scope}.`);\n}\n\nexport function join(path: string, segment: string): string {\n\treturn path ? `${path}.${segment}` : segment;\n}\n\n/**\n * Lists the paths whose value differs between two internal trees, stopping at the first differing node\n * along each branch that is not a container on both sides.\n *\n * @remarks\n * Branches shared by reference are skipped, so the walk costs what changed, not the size of the form.\n */\nexport function changedPaths(before: unknown, after: unknown, path = '', out: string[] = []): string[] {\n\tif (Object.is(before, after)) return out;\n\tif (isStructural(before) && isStructural(after) && Array.isArray(before) === Array.isArray(after)) {\n\t\tif (Array.isArray(before) && Array.isArray(after) && before.length !== after.length) out.push(path);\n\t\tfor (const key of new Set([...Object.keys(before), ...Object.keys(after)])) {\n\t\t\tchangedPaths((before as NullMap)[key], (after as NullMap)[key], join(path, key), out);\n\t\t}\n\t} else {\n\t\tout.push(path);\n\t}\n\treturn out;\n}\n"],
5
+ "mappings": ";;;;;;;;;AAMO,IAAM,eAAe,CAAC,SAC5B,SAAS,QAAQ,OAAO,SAAS,YAAY,CAAC,SAAS,IAAI;AAErD,SAAS,YAAqC;AACpD,SAAO,uBAAO,OAAO,IAAI;AAC1B;AAUO,SAAS,SAAS,OAAyB;AACjD,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,KAAK,QAAQ;AACpD,SAAO,CAAC,cAAc,KAAK;AAC5B;AAGO,SAAS,cAAc,QAAoD;AACjF,QAAM,QAAQ,QAAQ,MAAM;AAC5B,SAAO,cAAc,KAAK,IAAI,QAAQ,CAAC;AACxC;AAGO,SAAS,iBAAiB,QAAoD;AACpF,QAAM,OAAO,UAAU;AACvB,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,CAAC,kBAAkB,GAAG,EAAG,MAAK,GAAG,IAAI,WAAW,KAAK;AAAA,EAC1D;AACA,SA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F;AAAA,EACD,OAAO;AACN,QAAI,KAAK,IAAI;AAAA,EACd;AACA,SAAO;AACR;",
6
+ "names": ["copy"]
7
+ }
@@ -0,0 +1,246 @@
1
+ // src/schemas/validation/types.ts
2
+ import * as z from "zod/mini";
3
+ var RegexPatternSchema = z.string().check(
4
+ z.refine((value) => {
5
+ try {
6
+ RegExp(value);
7
+ return true;
8
+ } catch {
9
+ return false;
10
+ }
11
+ }, "Must be a valid regular expression")
12
+ );
13
+ var ruleFields = {
14
+ message: z.optional(z.string()),
15
+ id: z.optional(z.string()),
16
+ severity: z.optional(z.enum(["error", "warning"]))
17
+ };
18
+ var BaseValidationRuleSchema = z.looseObject({
19
+ $type: z.string(),
20
+ ...ruleFields
21
+ });
22
+ var RequiredRuleSchema = z.object({
23
+ $type: z.literal("required"),
24
+ ...ruleFields
25
+ });
26
+ var MinLengthRuleSchema = z.object({
27
+ $type: z.literal("minLength"),
28
+ value: z.number(),
29
+ ...ruleFields
30
+ });
31
+ var MaxLengthRuleSchema = z.object({
32
+ $type: z.literal("maxLength"),
33
+ value: z.number(),
34
+ ...ruleFields
35
+ });
36
+ var EmailRuleSchema = z.object({
37
+ $type: z.literal("email"),
38
+ pattern: z.optional(RegexPatternSchema),
39
+ ...ruleFields
40
+ });
41
+ var PhoneRuleSchema = z.object({
42
+ $type: z.literal("phone"),
43
+ ...ruleFields
44
+ });
45
+ var PatternRuleSchema = z.object({
46
+ $type: z.literal("pattern"),
47
+ value: RegexPatternSchema,
48
+ ...ruleFields
49
+ });
50
+ var UrlRuleSchema = z.object({
51
+ $type: z.literal("url"),
52
+ protocol: z.optional(RegexPatternSchema),
53
+ hostname: z.optional(RegexPatternSchema),
54
+ ...ruleFields
55
+ });
56
+ var UuidRuleSchema = z.object({
57
+ $type: z.literal("uuid"),
58
+ version: z.optional(z.enum(["v1", "v2", "v3", "v4", "v5"])),
59
+ ...ruleFields
60
+ });
61
+ var Ipv4RuleSchema = z.object({
62
+ $type: z.literal("ipv4"),
63
+ ...ruleFields
64
+ });
65
+ var Ipv6RuleSchema = z.object({
66
+ $type: z.literal("ipv6"),
67
+ ...ruleFields
68
+ });
69
+ var CidrRuleSchema = z.object({
70
+ $type: z.literal("cidr"),
71
+ version: z.optional(z.enum(["v4", "v6"])),
72
+ ...ruleFields
73
+ });
74
+ var JwtRuleSchema = z.object({
75
+ $type: z.literal("jwt"),
76
+ alg: z.optional(z.string()),
77
+ ...ruleFields
78
+ });
79
+ var HashRuleSchema = z.object({
80
+ $type: z.literal("hash"),
81
+ algorithm: z.enum(["md5", "sha1", "sha256", "sha384", "sha512"]),
82
+ ...ruleFields
83
+ });
84
+ var Base64RuleSchema = z.object({
85
+ $type: z.literal("base64"),
86
+ urlSafe: z.optional(z.boolean()),
87
+ ...ruleFields
88
+ });
89
+ var CuidRuleSchema = z.object({
90
+ $type: z.literal("cuid"),
91
+ ...ruleFields
92
+ });
93
+ var Cuid2RuleSchema = z.object({
94
+ $type: z.literal("cuid2"),
95
+ ...ruleFields
96
+ });
97
+ var UlidRuleSchema = z.object({
98
+ $type: z.literal("ulid"),
99
+ ...ruleFields
100
+ });
101
+ var HexRuleSchema = z.object({
102
+ $type: z.literal("hex"),
103
+ ...ruleFields
104
+ });
105
+ var MinRuleSchema = z.object({
106
+ $type: z.literal("min"),
107
+ value: z.number(),
108
+ ...ruleFields
109
+ });
110
+ var MaxRuleSchema = z.object({
111
+ $type: z.literal("max"),
112
+ value: z.number(),
113
+ ...ruleFields
114
+ });
115
+ var MinItemsRuleSchema = z.object({
116
+ $type: z.literal("minItems"),
117
+ value: z.number(),
118
+ ...ruleFields
119
+ });
120
+ var MaxItemsRuleSchema = z.object({
121
+ $type: z.literal("maxItems"),
122
+ value: z.number(),
123
+ ...ruleFields
124
+ });
125
+ var DateTimeRuleSchema = z.object({
126
+ $type: z.literal("datetime"),
127
+ precision: z.optional(z.number()),
128
+ offset: z.optional(z.boolean()),
129
+ local: z.optional(z.boolean()),
130
+ ...ruleFields
131
+ });
132
+ var DateRuleSchema = z.object({
133
+ $type: z.literal("date"),
134
+ ...ruleFields
135
+ });
136
+ var TimeRuleSchema = z.object({
137
+ $type: z.literal("time"),
138
+ precision: z.optional(z.number()),
139
+ ...ruleFields
140
+ });
141
+ var AsyncRuleSchema = z.object({
142
+ $type: z.literal("async"),
143
+ url: z.string(),
144
+ method: z.optional(z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"])),
145
+ headers: z.optional(z.record(z.string(), z.string())),
146
+ extraPayload: z.optional(z.record(z.string(), z.unknown())),
147
+ expectedResponse: z.optional(
148
+ z.object({
149
+ valid: z.optional(z.boolean()),
150
+ success: z.optional(z.boolean()),
151
+ message: z.optional(z.string()),
152
+ error: z.optional(z.string())
153
+ })
154
+ ),
155
+ ...ruleFields,
156
+ dependencies: z.optional(z.array(z.string())),
157
+ debounce: z.optional(z.number()),
158
+ cacheTTL: z.optional(z.number()),
159
+ disableCache: z.optional(z.boolean())
160
+ });
161
+ var RelationAssertSchema = z.enum([
162
+ "allEqual",
163
+ "allDifferent",
164
+ "ascending",
165
+ "strictlyAscending",
166
+ "descending",
167
+ "strictlyDescending",
168
+ "atLeastOne",
169
+ "exactlyOne",
170
+ "allOrNone"
171
+ ]);
172
+ var RelateRuleSchema = z.object({
173
+ $type: z.literal("relate"),
174
+ fields: z.array(z.string()).check(z.minLength(1), z.describe("Field references, each resolved relative to the field declaring the rule.")),
175
+ assert: RelationAssertSchema,
176
+ includeSelf: z._default(z.boolean(), true).check(z.describe("Own value participates, first in the list. Off for assertions about a group.")),
177
+ as: z._default(z.enum(["auto", "string", "number", "date", "boolean"]), "auto").check(z.describe("Comparison basis. `auto` compares values as they are.")),
178
+ skipWhenIncomplete: z._default(z.boolean(), true).check(
179
+ z.describe(
180
+ "Stay quiet while any participating value is empty. Ignored by the assertions about emptiness: `atLeastOne`, `exactlyOne`, `allOrNone`."
181
+ )
182
+ ),
183
+ ...ruleFields
184
+ });
185
+ var ValidationRuleSchema = z.union([
186
+ RequiredRuleSchema,
187
+ MinLengthRuleSchema,
188
+ MaxLengthRuleSchema,
189
+ MinRuleSchema,
190
+ MaxRuleSchema,
191
+ MinItemsRuleSchema,
192
+ MaxItemsRuleSchema,
193
+ EmailRuleSchema,
194
+ PhoneRuleSchema,
195
+ PatternRuleSchema,
196
+ UrlRuleSchema,
197
+ UuidRuleSchema,
198
+ DateTimeRuleSchema,
199
+ DateRuleSchema,
200
+ TimeRuleSchema,
201
+ Ipv4RuleSchema,
202
+ Ipv6RuleSchema,
203
+ CidrRuleSchema,
204
+ JwtRuleSchema,
205
+ HashRuleSchema,
206
+ Base64RuleSchema,
207
+ CuidRuleSchema,
208
+ Cuid2RuleSchema,
209
+ UlidRuleSchema,
210
+ HexRuleSchema,
211
+ AsyncRuleSchema,
212
+ RelateRuleSchema
213
+ ]);
214
+
215
+ export {
216
+ BaseValidationRuleSchema,
217
+ RequiredRuleSchema,
218
+ MinLengthRuleSchema,
219
+ MaxLengthRuleSchema,
220
+ EmailRuleSchema,
221
+ PhoneRuleSchema,
222
+ PatternRuleSchema,
223
+ UrlRuleSchema,
224
+ UuidRuleSchema,
225
+ Ipv4RuleSchema,
226
+ Ipv6RuleSchema,
227
+ CidrRuleSchema,
228
+ JwtRuleSchema,
229
+ HashRuleSchema,
230
+ Base64RuleSchema,
231
+ CuidRuleSchema,
232
+ Cuid2RuleSchema,
233
+ UlidRuleSchema,
234
+ HexRuleSchema,
235
+ MinRuleSchema,
236
+ MaxRuleSchema,
237
+ MinItemsRuleSchema,
238
+ MaxItemsRuleSchema,
239
+ DateTimeRuleSchema,
240
+ DateRuleSchema,
241
+ TimeRuleSchema,
242
+ AsyncRuleSchema,
243
+ RelationAssertSchema,
244
+ RelateRuleSchema,
245
+ ValidationRuleSchema
246
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/schemas/validation/types.ts"],
4
+ "sourcesContent": ["import type { FormFetch } from '@/lib/form-fetch';\nimport * as z from 'zod/mini';\nimport type { BaseRegistration, RegistrationMetadata } from '@schema-engine/registry';\nimport type { DebounceScope } from '../../lib/debounce.js';\n\nconst RegexPatternSchema = z.string().check(\n\tz.refine((value) => {\n\t\ttry {\n\t\t\tRegExp(value);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}, 'Must be a valid regular expression'),\n);\n\n/**\n * What every rule can say about itself besides its `$type`.\n *\n * @remarks\n * `message` is the fallback text of the issue the rule reports. `id` is the author's stable name for the\n * rule, so two rules of one `$type` (two `pattern`s) stay distinguishable and a translation can be keyed to\n * one of them. A `severity` of `'warning'` makes the rule advice: its issue goes to `warnings`, and never\n * decides whether the form is valid.\n */\nconst ruleFields = {\n\tmessage: z.optional(z.string()),\n\tid: z.optional(z.string()),\n\tseverity: z.optional(z.enum(['error', 'warning'])),\n};\n\n/**\n * What an element's `rules` accepts: the `$type` and the fields every rule has, and whatever else the\n * rule's registration describes.\n *\n * @remarks\n * Loose, and the only shape of a rule in an element's schema: the validation registry owns the rest.\n * The engine checks each rule against its registration when it validates a form config\n * ({@link ValidationRegistry.check}), so a `$type` nothing registers and options the registration\n * refuses are rejected there, and a registration that replaces a built-in decides that rule's options.\n * The JSON Schema export lists each registered rule with its options instead of this shape.\n */\nexport const BaseValidationRuleSchema = z.looseObject({\n\t$type: z.string(),\n\t...ruleFields,\n});\n\nexport const RequiredRuleSchema = z.object({\n\t$type: z.literal('required'),\n\t...ruleFields,\n});\n\nexport const MinLengthRuleSchema = z.object({\n\t$type: z.literal('minLength'),\n\tvalue: z.number(),\n\t...ruleFields,\n});\n\nexport const MaxLengthRuleSchema = z.object({\n\t$type: z.literal('maxLength'),\n\tvalue: z.number(),\n\t...ruleFields,\n});\n\nexport const EmailRuleSchema = z.object({\n\t$type: z.literal('email'),\n\tpattern: z.optional(RegexPatternSchema),\n\t...ruleFields,\n});\n\nexport const PhoneRuleSchema = z.object({\n\t$type: z.literal('phone'),\n\t...ruleFields,\n});\n\nexport const PatternRuleSchema = z.object({\n\t$type: z.literal('pattern'),\n\tvalue: RegexPatternSchema,\n\t...ruleFields,\n});\n\nexport const UrlRuleSchema = z.object({\n\t$type: z.literal('url'),\n\tprotocol: z.optional(RegexPatternSchema),\n\thostname: z.optional(RegexPatternSchema),\n\t...ruleFields,\n});\n\nexport const UuidRuleSchema = z.object({\n\t$type: z.literal('uuid'),\n\tversion: z.optional(z.enum(['v1', 'v2', 'v3', 'v4', 'v5'])),\n\t...ruleFields,\n});\n\nexport const Ipv4RuleSchema = z.object({\n\t$type: z.literal('ipv4'),\n\t...ruleFields,\n});\n\nexport const Ipv6RuleSchema = z.object({\n\t$type: z.literal('ipv6'),\n\t...ruleFields,\n});\n\nexport const CidrRuleSchema = z.object({\n\t$type: z.literal('cidr'),\n\tversion: z.optional(z.enum(['v4', 'v6'])),\n\t...ruleFields,\n});\n\nexport const JwtRuleSchema = z.object({\n\t$type: z.literal('jwt'),\n\talg: z.optional(z.string()),\n\t...ruleFields,\n});\n\nexport const HashRuleSchema = z.object({\n\t$type: z.literal('hash'),\n\talgorithm: z.enum(['md5', 'sha1', 'sha256', 'sha384', 'sha512']),\n\t...ruleFields,\n});\n\nexport const Base64RuleSchema = z.object({\n\t$type: z.literal('base64'),\n\turlSafe: z.optional(z.boolean()),\n\t...ruleFields,\n});\n\nexport const CuidRuleSchema = z.object({\n\t$type: z.literal('cuid'),\n\t...ruleFields,\n});\n\nexport const Cuid2RuleSchema = z.object({\n\t$type: z.literal('cuid2'),\n\t...ruleFields,\n});\n\nexport const UlidRuleSchema = z.object({\n\t$type: z.literal('ulid'),\n\t...ruleFields,\n});\n\nexport const HexRuleSchema = z.object({\n\t$type: z.literal('hex'),\n\t...ruleFields,\n});\n\nexport const MinRuleSchema = z.object({\n\t$type: z.literal('min'),\n\tvalue: z.number(),\n\t...ruleFields,\n});\n\nexport const MaxRuleSchema = z.object({\n\t$type: z.literal('max'),\n\tvalue: z.number(),\n\t...ruleFields,\n});\n\nexport const MinItemsRuleSchema = z.object({\n\t$type: z.literal('minItems'),\n\tvalue: z.number(),\n\t...ruleFields,\n});\n\nexport const MaxItemsRuleSchema = z.object({\n\t$type: z.literal('maxItems'),\n\tvalue: z.number(),\n\t...ruleFields,\n});\n\nexport const DateTimeRuleSchema = z.object({\n\t$type: z.literal('datetime'),\n\tprecision: z.optional(z.number()),\n\toffset: z.optional(z.boolean()),\n\tlocal: z.optional(z.boolean()),\n\t...ruleFields,\n});\n\nexport const DateRuleSchema = z.object({\n\t$type: z.literal('date'),\n\t...ruleFields,\n});\n\nexport const TimeRuleSchema = z.object({\n\t$type: z.literal('time'),\n\tprecision: z.optional(z.number()),\n\t...ruleFields,\n});\n\nexport const AsyncRuleSchema = z.object({\n\t$type: z.literal('async'),\n\turl: z.string(),\n\tmethod: z.optional(z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE'])),\n\theaders: z.optional(z.record(z.string(), z.string())),\n\textraPayload: z.optional(z.record(z.string(), z.unknown())),\n\texpectedResponse: z.optional(\n\t\tz.object({\n\t\t\tvalid: z.optional(z.boolean()),\n\t\t\tsuccess: z.optional(z.boolean()),\n\t\t\tmessage: z.optional(z.string()),\n\t\t\terror: z.optional(z.string()),\n\t\t}),\n\t),\n\t...ruleFields,\n\tdependencies: z.optional(z.array(z.string())),\n\tdebounce: z.optional(z.number()),\n\tcacheTTL: z.optional(z.number()),\n\tdisableCache: z.optional(z.boolean()),\n});\n\n/**\n * Named comparisons a {@link RelateRuleSchema} can make over the referenced values.\n *\n * @remarks\n * Ordering assertions read left to right over `fields` (with the declaring\n * field's own value first, unless `includeSelf` is off), so `descending` on\n * `[endDate, startDate]` asserts that the end date is the later one.\n */\nexport const RelationAssertSchema = z.enum([\n\t'allEqual',\n\t'allDifferent',\n\t'ascending',\n\t'strictlyAscending',\n\t'descending',\n\t'strictlyDescending',\n\t'atLeastOne',\n\t'exactlyOne',\n\t'allOrNone',\n]);\n\nexport const RelateRuleSchema = z.object({\n\t$type: z.literal('relate'),\n\tfields: z\n\t\t.array(z.string())\n\t\t.check(z.minLength(1), z.describe('Field references, each resolved relative to the field declaring the rule.')),\n\tassert: RelationAssertSchema,\n\tincludeSelf: z\n\t\t._default(z.boolean(), true)\n\t\t.check(z.describe('Own value participates, first in the list. Off for assertions about a group.')),\n\tas: z\n\t\t._default(z.enum(['auto', 'string', 'number', 'date', 'boolean']), 'auto')\n\t\t.check(z.describe('Comparison basis. `auto` compares values as they are.')),\n\tskipWhenIncomplete: z\n\t\t._default(z.boolean(), true)\n\t\t.check(\n\t\t\tz.describe(\n\t\t\t\t'Stay quiet while any participating value is empty. Ignored by the assertions about emptiness: `atLeastOne`, `exactlyOne`, `allOrNone`.',\n\t\t\t),\n\t\t),\n\t...ruleFields,\n});\n\nexport const ValidationRuleSchema = z.union([\n\tRequiredRuleSchema,\n\tMinLengthRuleSchema,\n\tMaxLengthRuleSchema,\n\tMinRuleSchema,\n\tMaxRuleSchema,\n\tMinItemsRuleSchema,\n\tMaxItemsRuleSchema,\n\tEmailRuleSchema,\n\tPhoneRuleSchema,\n\tPatternRuleSchema,\n\tUrlRuleSchema,\n\tUuidRuleSchema,\n\tDateTimeRuleSchema,\n\tDateRuleSchema,\n\tTimeRuleSchema,\n\tIpv4RuleSchema,\n\tIpv6RuleSchema,\n\tCidrRuleSchema,\n\tJwtRuleSchema,\n\tHashRuleSchema,\n\tBase64RuleSchema,\n\tCuidRuleSchema,\n\tCuid2RuleSchema,\n\tUlidRuleSchema,\n\tHexRuleSchema,\n\tAsyncRuleSchema,\n\tRelateRuleSchema,\n]);\n\nexport type BaseValidationRule = z.infer<typeof BaseValidationRuleSchema>;\nexport type RequiredRule = z.infer<typeof RequiredRuleSchema>;\nexport type MinLengthRule = z.infer<typeof MinLengthRuleSchema>;\nexport type MaxLengthRule = z.infer<typeof MaxLengthRuleSchema>;\nexport type MinRule = z.infer<typeof MinRuleSchema>;\nexport type MaxRule = z.infer<typeof MaxRuleSchema>;\nexport type MinItemsRule = z.infer<typeof MinItemsRuleSchema>;\nexport type MaxItemsRule = z.infer<typeof MaxItemsRuleSchema>;\nexport type EmailRule = z.infer<typeof EmailRuleSchema>;\nexport type PhoneRule = z.infer<typeof PhoneRuleSchema>;\nexport type PatternRule = z.infer<typeof PatternRuleSchema>;\nexport type UrlRule = z.infer<typeof UrlRuleSchema>;\nexport type UuidRule = z.infer<typeof UuidRuleSchema>;\nexport type DateTimeRule = z.infer<typeof DateTimeRuleSchema>;\nexport type DateRule = z.infer<typeof DateRuleSchema>;\nexport type TimeRule = z.infer<typeof TimeRuleSchema>;\nexport type Ipv4Rule = z.infer<typeof Ipv4RuleSchema>;\nexport type Ipv6Rule = z.infer<typeof Ipv6RuleSchema>;\nexport type CidrRule = z.infer<typeof CidrRuleSchema>;\nexport type JwtRule = z.infer<typeof JwtRuleSchema>;\nexport type HashRule = z.infer<typeof HashRuleSchema>;\nexport type Base64Rule = z.infer<typeof Base64RuleSchema>;\nexport type CuidRule = z.infer<typeof CuidRuleSchema>;\nexport type Cuid2Rule = z.infer<typeof Cuid2RuleSchema>;\nexport type UlidRule = z.infer<typeof UlidRuleSchema>;\nexport type HexRule = z.infer<typeof HexRuleSchema>;\nexport type AsyncRule = z.infer<typeof AsyncRuleSchema>;\nexport type RelationAssert = z.infer<typeof RelationAssertSchema>;\nexport type RelateRule = z.infer<typeof RelateRuleSchema>;\nexport type ValidationRule = z.infer<typeof ValidationRuleSchema>;\n\n/**\n * Everything a validation handler may read beyond the value under test.\n *\n * @remarks\n * `fieldPath` is the field's *rendered* path (`contacts.0.email`), not the\n * authored template, which is what lets a rule address a sibling inside its own\n * array row. Prefer {@link ValidationContext.resolve} over reading\n * {@link ValidationContext.values} directly: it applies that scoping, and it is\n * the same resolution constraints use, so one authored name cannot mean two\n * different fields.\n */\nexport interface ValidationContext {\n\t/** Nested value tree for the whole form. */\n\treadonly values: Record<string, unknown>;\n\t/** Rendered path of the field being validated, e.g. `contacts.0.email`. */\n\treadonly fieldPath: string;\n\t/**\n\t * Reads another field relative to this one: a bare name is a sibling, a\n\t * dotted name is absolute from the form root.\n\t */\n\treadonly resolve: (fieldRef: string) => unknown;\n\t/** Debounced work shared by parses that receive this scope. */\n\treadonly debounceScope: DebounceScope;\n\t/** Makes the requests of a rule: the engine's `fetch`, with its CSRF policy applied. The registry sets it, and it is the only way to set it. */\n\treadonly fetch: FormFetch;\n}\n\n/** What a caller of `createSchema` gives: a {@link ValidationContext} without `fetch`, which the registry supplies. */\nexport type ValidationScope = Omit<ValidationContext, 'fetch'>;\n\n/**\n * Validation rule registration: the shared registration shape plus the handler that builds the rule's schema.\n *\n * @remarks\n * `$type` is the `$type` authors write in a field's `rules`, so a registration with\n * `$type: 'postcode'` handles `{ $type: 'postcode' }`; `schema` describes the rule objects.\n *\n * @template TRule - Specific rule type for type-safe handler\n */\nexport interface ValidationRegistration<\n\tTRule extends { $type: string } = { $type: string } & Record<string, unknown>,\n> extends BaseRegistration<TRule, RegistrationMetadata> {\n\t$type: TRule['$type'];\n\tcategory: 'string' | 'number' | 'array' | 'boolean' | 'date' | 'generic' | 'cross-field';\n\t/**\n\t * Validation handler function\n\t * @param rule - The validation rule configuration (typed to specific rule type)\n\t * @param context - The form context, for rules that read fields other than the one under test\n\t * @returns Zod Mini schema for validation\n\t */\n\thandler: (rule: TRule, context: ValidationContext) => z.ZodMiniType;\n\t/**\n\t * Field references this rule reads besides the value under test.\n\t *\n\t * @remarks\n\t * Renderers re-validate the declaring field when any of these change. Returned\n\t * as authored references; the caller resolves them against the field's path,\n\t * so a rule inside an array row watches that row.\n\t */\n\tdependsOn?: (rule: TRule) => readonly string[];\n\t/**\n\t * The options of this rule that a message can be built from, named like the native constraint they match.\n\t *\n\t * @remarks\n\t * They reach every issue the rule reports, and so a snapshot, an action context and a formatter: a\n\t * registration decides what it shows. `minLength` returns `{ minLength: 8 }`, as the native\n\t * `ValidityState` constraint is named, and a rule whose options are configuration (`async`'s url and\n\t * headers, `relate`'s field list) returns nothing. Values must be serializable.\n\t */\n\tparams?: (rule: TRule) => Readonly<Record<string, unknown>> | undefined;\n\t/**\n\t * The fallback text of an issue this rule reports, given the text its schema reported.\n\t *\n\t * @remarks\n\t * By default the text is the author's own `message` on the rule. Text a registration makes up is the\n\t * application's language and belongs above the engine, as does the schema library's generic text, so a\n\t * registration reports a `type` and `params` and never default English. Return `reported` only for text\n\t * that genuinely comes from outside the engine, such as the message an `async` rule's endpoint answers with.\n\t */\n\tmessage?: (rule: TRule, reported: string | undefined) => string | undefined;\n\t/**\n\t * Field `$type` values that receive this rule when the author omitted it.\n\t *\n\t * @remarks Lets an integration attach a rule (for example `phone` on\n\t * `phone-input`) without putting that field type or its library into the\n\t * forms package.\n\t */\n\tdefaultFor?: readonly string[];\n}\n\n/**\n * Union of all possible validation registrations based on ValidationRule union.\n * This allows heterogeneous arrays (like defaultValidations) to be typed without 'any'.\n */\nexport type AnyValidationRegistration =\n\t| (ValidationRule extends infer T ? (T extends ValidationRule ? ValidationRegistration<T> : never) : never)\n\t| ValidationRegistration;\n\n/**\n * A validation registration as `createFormEngine({ validations })`, an element's `validations` and the\n * registry factories accept it.\n *\n * @remarks\n * `handler` and `dependsOn` take `never`, so a registration typed for one rule shape, such as\n * `ValidationRegistration<PostcodeRule>`, is accepted without widening its rule type. `handler` still\n * has to return a Zod Mini schema: a handler that returns anything else does not compile.\n */\nexport type ValidationRegistrationConstraint = {\n\treadonly $type: string;\n\treadonly schema: { readonly '~standard': { readonly validate: (value: unknown) => unknown } };\n\treadonly metadata: { readonly name: string };\n\treadonly category: ValidationRegistration['category'];\n\treadonly handler: (rule: never, context: ValidationContext) => z.ZodMiniType;\n\treadonly dependsOn?: (rule: never) => readonly string[];\n\treadonly params?: (rule: never) => Readonly<Record<string, unknown>> | undefined;\n\treadonly message?: (rule: never, reported: string | undefined) => string | undefined;\n\treadonly defaultFor?: readonly string[];\n};\n\n/**\n * Mapping of validation rule types to their specific rule interfaces.\n */\nexport type ValidationTypeMap = {\n\t[K in ValidationRule['$type']]: Extract<ValidationRule, { $type: K }>;\n};\n\n/**\n * Mapping of validation rule types to their specific registrations.\n */\nexport type ValidationRegistrationMap = {\n\t[K in ValidationRule['$type']]: ValidationRegistration<ValidationTypeMap[K]>;\n};\n"],
5
+ "mappings": ";AACA,YAAY,OAAO;AAInB,IAAM,qBAAuB,SAAO,EAAE;AAAA,EACnC,SAAO,CAAC,UAAU;AACnB,QAAI;AACH,aAAO,KAAK;AACZ,aAAO;AAAA,IACR,QAAQ;AACP,aAAO;AAAA,IACR;AAAA,EACD,GAAG,oCAAoC;AACxC;AAWA,IAAM,aAAa;AAAA,EAClB,SAAW,WAAW,SAAO,CAAC;AAAA,EAC9B,IAAM,WAAW,SAAO,CAAC;AAAA,EACzB,UAAY,WAAW,OAAK,CAAC,SAAS,SAAS,CAAC,CAAC;AAClD;AAaO,IAAM,2BAA6B,cAAY;AAAA,EACrD,OAAS,SAAO;AAAA,EAChB,GAAG;AACJ,CAAC;AAEM,IAAM,qBAAuB,SAAO;AAAA,EAC1C,OAAS,UAAQ,UAAU;AAAA,EAC3B,GAAG;AACJ,CAAC;AAEM,IAAM,sBAAwB,SAAO;AAAA,EAC3C,OAAS,UAAQ,WAAW;AAAA,EAC5B,OAAS,SAAO;AAAA,EAChB,GAAG;AACJ,CAAC;AAEM,IAAM,sBAAwB,SAAO;AAAA,EAC3C,OAAS,UAAQ,WAAW;AAAA,EAC5B,OAAS,SAAO;AAAA,EAChB,GAAG;AACJ,CAAC;AAEM,IAAM,kBAAoB,SAAO;AAAA,EACvC,OAAS,UAAQ,OAAO;AAAA,EACxB,SAAW,WAAS,kBAAkB;AAAA,EACtC,GAAG;AACJ,CAAC;AAEM,IAAM,kBAAoB,SAAO;AAAA,EACvC,OAAS,UAAQ,OAAO;AAAA,EACxB,GAAG;AACJ,CAAC;AAEM,IAAM,oBAAsB,SAAO;AAAA,EACzC,OAAS,UAAQ,SAAS;AAAA,EAC1B,OAAO;AAAA,EACP,GAAG;AACJ,CAAC;AAEM,IAAM,gBAAkB,SAAO;AAAA,EACrC,OAAS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AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,24 @@
1
+ // src/state-container/field-array.ts
2
+ var NO_FIELDS = Object.freeze([]);
3
+ var fieldsByIds = /* @__PURE__ */ new WeakMap();
4
+ function selectFields(rowIds) {
5
+ if (!rowIds) return NO_FIELDS;
6
+ let fields = fieldsByIds.get(rowIds);
7
+ if (!fields) fieldsByIds.set(rowIds, fields = rowIds.map((id) => ({ id })));
8
+ return fields;
9
+ }
10
+ var NO_ROW_IDS = Object.freeze([]);
11
+ var valuesByCommands = /* @__PURE__ */ new WeakMap();
12
+ function toFieldArrayValue(rowIds, commands) {
13
+ let byRows = valuesByCommands.get(commands);
14
+ if (!byRows) valuesByCommands.set(commands, byRows = /* @__PURE__ */ new WeakMap());
15
+ const key = rowIds ?? NO_ROW_IDS;
16
+ let value = byRows.get(key);
17
+ if (!value) byRows.set(key, value = { fields: selectFields(rowIds), ...commands });
18
+ return value;
19
+ }
20
+
21
+ export {
22
+ selectFields,
23
+ toFieldArrayValue
24
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/state-container/field-array.ts"],
4
+ "sourcesContent": ["/**\n * Field-array operations shared by React and Radiant form adapters.\n *\n * @remarks\n * Errors and touched state move with their rows. An operation naming a row that\n * does not exist does nothing (`insert` also accepts the index past the last\n * row), and `remove` removes each listed row once, however often it is listed.\n */\nexport interface FieldArrayValue {\n\tfields: Array<{ id: string }>;\n\tappend: (value: unknown) => void;\n\tprepend: (value: unknown) => void;\n\tinsert: (index: number, value: unknown) => void;\n\tswap: (indexA: number, indexB: number) => void;\n\tmove: (indexA: number, indexB: number) => void;\n\tupdate: (index: number, value: unknown) => void;\n\treplace: (value: unknown[]) => void;\n\tremove: (index?: number | number[]) => void;\n}\n\n/** The operations of a field array, which a container keeps one set of per array path. */\nexport type FieldArrayCommands = Omit<FieldArrayValue, 'fields'>;\n\nconst NO_FIELDS: ReadonlyArray<{ id: string }> = Object.freeze([]);\nconst fieldsByIds = new WeakMap<readonly string[], Array<{ id: string }>>();\n\n/**\n * The `fields` of a field array: one `{ id }` per row, in row order.\n *\n * @remarks\n * The same array comes back for the same row ids, so a binding can compare it by reference.\n */\nexport function selectFields(rowIds: readonly string[] | undefined): Array<{ id: string }> {\n\tif (!rowIds) return NO_FIELDS as Array<{ id: string }>;\n\tlet fields = fieldsByIds.get(rowIds);\n\tif (!fields) fieldsByIds.set(rowIds, (fields = rowIds.map((id) => ({ id }))));\n\treturn fields;\n}\n\nconst NO_ROW_IDS: readonly string[] = Object.freeze([]);\nconst valuesByCommands = new WeakMap<FieldArrayCommands, WeakMap<readonly string[], FieldArrayValue>>();\n\n/**\n * Builds the React Hook Form style field array a binding hands to its widgets.\n *\n * @param rowIds - The ids of the array's rows, from `snapshot.rowIds[path]`.\n * @param commands - The container's commands for the array, from `fieldArray(path)`.\n *\n * @remarks Memoized by the commands and the row ids array, so the same object comes back until the rows change.\n */\nexport function toFieldArrayValue(\n\trowIds: readonly string[] | undefined,\n\tcommands: FieldArrayCommands,\n): FieldArrayValue {\n\tlet byRows = valuesByCommands.get(commands);\n\tif (!byRows) valuesByCommands.set(commands, (byRows = new WeakMap()));\n\tconst key = rowIds ?? NO_ROW_IDS;\n\tlet value = byRows.get(key);\n\tif (!value) byRows.set(key, (value = { fields: selectFields(rowIds), ...commands }));\n\treturn value;\n}\n"],
5
+ "mappings": ";AAuBA,IAAM,YAA2C,OAAO,OAAO,CAAC,CAAC;AACjE,IAAM,cAAc,oBAAI,QAAkD;AAQnE,SAAS,aAAa,QAA8D;AAC1F,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,SAAS,YAAY,IAAI,MAAM;AACnC,MAAI,CAAC,OAAQ,aAAY,IAAI,QAAS,SAAS,OAAO,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAE;AAC5E,SAAO;AACR;AAEA,IAAM,aAAgC,OAAO,OAAO,CAAC,CAAC;AACtD,IAAM,mBAAmB,oBAAI,QAAyE;AAU/F,SAAS,kBACf,QACA,UACkB;AAClB,MAAI,SAAS,iBAAiB,IAAI,QAAQ;AAC1C,MAAI,CAAC,OAAQ,kBAAiB,IAAI,UAAW,SAAS,oBAAI,QAAQ,CAAE;AACpE,QAAM,MAAM,UAAU;AACtB,MAAI,QAAQ,OAAO,IAAI,GAAG;AAC1B,MAAI,CAAC,MAAO,QAAO,IAAI,KAAM,QAAQ,EAAE,QAAQ,aAAa,MAAM,GAAG,GAAG,SAAS,CAAE;AACnF,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ import {
2
+ ServerErrorsInputError,
3
+ groupByPath,
4
+ isRecord,
5
+ issueOf,
6
+ pointerToPath,
7
+ recordsAt,
8
+ serializableParams,
9
+ textOf
10
+ } from "./chunk-CANRZY5A.js";
11
+ import {
12
+ FORM_ROOT
13
+ } from "./chunk-PCL2KNHC.js";
14
+
15
+ // src/server-errors/from-json-api-errors.ts
16
+ var ATTRIBUTES = ["data", "attributes"];
17
+ function fromJsonApiErrors(document) {
18
+ const entries = isRecord(document) ? recordsAt(document, "errors", "JSON:API member") : void 0;
19
+ if (entries === void 0)
20
+ throw new ServerErrorsInputError("A JSON:API error document is an object with an errors list.");
21
+ return groupByPath(
22
+ entries.map((entry) => {
23
+ const source = entry.source;
24
+ if (source !== void 0 && !isRecord(source)) {
25
+ throw new ServerErrorsInputError("A JSON:API error 'source' must be an object.");
26
+ }
27
+ const given = isRecord(source) ? source.pointer : void 0;
28
+ if (given !== void 0 && typeof given !== "string") {
29
+ throw new ServerErrorsInputError("A JSON:API error 'source.pointer' must be a string.");
30
+ }
31
+ if (given === void 0 && entry.detail === void 0 && entry.code === void 0) {
32
+ throw new ServerErrorsInputError(
33
+ "A JSON:API error has none of 'source.pointer', 'detail' and 'code': nothing says what it is about."
34
+ );
35
+ }
36
+ const pointer = textOf(given);
37
+ return [
38
+ pointer === void 0 ? FORM_ROOT : pointerToPath(pointer, ATTRIBUTES),
39
+ issueOf({
40
+ type: textOf(entry.code),
41
+ message: textOf(entry.detail),
42
+ params: isRecord(entry.meta) ? serializableParams(entry.meta, /* @__PURE__ */ new Set()) : void 0
43
+ })
44
+ ];
45
+ })
46
+ );
47
+ }
48
+
49
+ export {
50
+ fromJsonApiErrors
51
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/server-errors/from-json-api-errors.ts"],
4
+ "sourcesContent": ["import { FORM_ROOT, type FormStateErrorsInput } from '@/state-container/types';\nimport {\n\tgroupByPath,\n\tisRecord,\n\tissueOf,\n\tpointerToPath,\n\trecordsAt,\n\tserializableParams,\n\tServerErrorsInputError,\n\ttextOf,\n} from './shared';\n\n/** The members of a JSON Pointer that locate an attribute in a JSON:API resource, which are not part of a field's path. */\nconst ATTRIBUTES = ['data', 'attributes'];\n\n/**\n * The input of `setServerErrors` for a JSON:API error document.\n *\n * @remarks\n * Reads `errors[]`: `source.pointer` is a JSON Pointer to the dotted path, without a leading `/data/attributes`,\n * and no pointer means the form ({@link FORM_ROOT}). An issue's `type` is its `code`, its `message` its `detail`,\n * and the plain serializable members of its `meta` become `params`. Several errors on one path become a list.\n * Reads no text of its own: `title` and `status` are not carried.\n *\n * @throws {ServerErrorsInputError} For input that is not an object with an `errors` list of objects, for an error with none of `source.pointer`, `detail` and `code`, for a `source` that is not an object, for a `source.pointer` that is not a string, and for a pointer that is not one or names a reserved segment.\n */\nexport function fromJsonApiErrors(document: unknown): FormStateErrorsInput {\n\tconst entries = isRecord(document) ? recordsAt(document, 'errors', 'JSON:API member') : undefined;\n\tif (entries === undefined)\n\t\tthrow new ServerErrorsInputError('A JSON:API error document is an object with an errors list.');\n\treturn groupByPath(\n\t\tentries.map((entry) => {\n\t\t\tconst source: unknown = entry.source;\n\t\t\tif (source !== undefined && !isRecord(source)) {\n\t\t\t\tthrow new ServerErrorsInputError(\"A JSON:API error 'source' must be an object.\");\n\t\t\t}\n\t\t\tconst given: unknown = isRecord(source) ? source.pointer : undefined;\n\t\t\tif (given !== undefined && typeof given !== 'string') {\n\t\t\t\tthrow new ServerErrorsInputError(\"A JSON:API error 'source.pointer' must be a string.\");\n\t\t\t}\n\t\t\tif (given === undefined && entry.detail === undefined && entry.code === undefined) {\n\t\t\t\tthrow new ServerErrorsInputError(\n\t\t\t\t\t\"A JSON:API error has none of 'source.pointer', 'detail' and 'code': nothing says what it is about.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst pointer = textOf(given);\n\t\t\treturn [\n\t\t\t\tpointer === undefined ? FORM_ROOT : pointerToPath(pointer, ATTRIBUTES),\n\t\t\t\tissueOf({\n\t\t\t\t\ttype: textOf(entry.code),\n\t\t\t\t\tmessage: textOf(entry.detail),\n\t\t\t\t\tparams: isRecord(entry.meta) ? serializableParams(entry.meta, new Set()) : undefined,\n\t\t\t\t}),\n\t\t\t] as const;\n\t\t}),\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAaA,IAAM,aAAa,CAAC,QAAQ,YAAY;AAajC,SAAS,kBAAkB,UAAyC;AAC1E,QAAM,UAAU,SAAS,QAAQ,IAAI,UAAU,UAAU,UAAU,iBAAiB,IAAI;AACxF,MAAI,YAAY;AACf,UAAM,IAAI,uBAAuB,6DAA6D;AAC/F,SAAO;AAAA,IACN,QAAQ,IAAI,CAAC,UAAU;AACtB,YAAM,SAAkB,MAAM;AAC9B,UAAI,WAAW,UAAa,CAAC,SAAS,MAAM,GAAG;AAC9C,cAAM,IAAI,uBAAuB,8CAA8C;AAAA,MAChF;AACA,YAAM,QAAiB,SAAS,MAAM,IAAI,OAAO,UAAU;AAC3D,UAAI,UAAU,UAAa,OAAO,UAAU,UAAU;AACrD,cAAM,IAAI,uBAAuB,qDAAqD;AAAA,MACvF;AACA,UAAI,UAAU,UAAa,MAAM,WAAW,UAAa,MAAM,SAAS,QAAW;AAClF,cAAM,IAAI;AAAA,UACT;AAAA,QACD;AAAA,MACD;AACA,YAAM,UAAU,OAAO,KAAK;AAC5B,aAAO;AAAA,QACN,YAAY,SAAY,YAAY,cAAc,SAAS,UAAU;AAAA,QACrE,QAAQ;AAAA,UACP,MAAM,OAAO,MAAM,IAAI;AAAA,UACvB,SAAS,OAAO,MAAM,MAAM;AAAA,UAC5B,QAAQ,SAAS,MAAM,IAAI,IAAI,mBAAmB,MAAM,MAAM,oBAAI,IAAI,CAAC,IAAI;AAAA,QAC5E,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,EACF;AACD;",
6
+ "names": []
7
+ }