@schema-engine/forms 0.0.0-stage → 0.5.0
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.
- package/LICENSE +21 -0
- package/README.md +69 -2
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.js +50 -0
- package/dist/actions/index.js.map +7 -0
- package/dist/actions/plugins/auto-save.plugin.d.ts +39 -0
- package/dist/actions/plugins/auto-save.plugin.js +10 -0
- package/dist/actions/plugins/auto-save.plugin.js.map +7 -0
- package/dist/actions/plugins/form-reset.plugin.d.ts +23 -0
- package/dist/actions/plugins/form-reset.plugin.js +9 -0
- package/dist/actions/plugins/form-reset.plugin.js.map +7 -0
- package/dist/actions/plugins/form-submit.plugin.d.ts +31 -0
- package/dist/actions/plugins/form-submit.plugin.js +9 -0
- package/dist/actions/plugins/form-submit.plugin.js.map +7 -0
- package/dist/actions/plugins/form-submit.registration.d.ts +22 -0
- package/dist/actions/plugins/form-submit.registration.js +8 -0
- package/dist/actions/plugins/form-submit.registration.js.map +7 -0
- package/dist/actions/plugins/gtm.plugin.d.ts +30 -0
- package/dist/actions/plugins/gtm.plugin.js +8 -0
- package/dist/actions/plugins/gtm.plugin.js.map +7 -0
- package/dist/actions/plugins/index.d.ts +16 -0
- package/dist/actions/plugins/index.js +45 -0
- package/dist/actions/plugins/index.js.map +7 -0
- package/dist/actions/plugins/notification.plugin.d.ts +32 -0
- package/dist/actions/plugins/notification.plugin.js +9 -0
- package/dist/actions/plugins/notification.plugin.js.map +7 -0
- package/dist/actions/plugins/notification.registration.d.ts +22 -0
- package/dist/actions/plugins/notification.registration.js +8 -0
- package/dist/actions/plugins/notification.registration.js.map +7 -0
- package/dist/actions/plugins/registrations.d.ts +17 -0
- package/dist/actions/plugins/registrations.js +14 -0
- package/dist/actions/plugins/registrations.js.map +7 -0
- package/dist/actions/triggers.d.ts +42 -0
- package/dist/actions/triggers.js +6 -0
- package/dist/actions/triggers.js.map +7 -0
- package/dist/actions/types.d.ts +16 -0
- package/dist/actions/types.js +1 -0
- package/dist/actions/types.js.map +7 -0
- package/dist/agent-tool/index.d.ts +54 -0
- package/dist/agent-tool/index.js +128 -0
- package/dist/agent-tool/index.js.map +7 -0
- package/dist/browser/action-registrations.d.ts +46 -0
- package/dist/browser/action-registrations.js +19 -0
- package/dist/browser/action-registrations.js.map +7 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.js +36 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/tools/auto-save-storage.d.ts +20 -0
- package/dist/browser/tools/auto-save-storage.js +12 -0
- package/dist/browser/tools/auto-save-storage.js.map +7 -0
- package/dist/browser/tools/gdpr-consent.d.ts +32 -0
- package/dist/browser/tools/gdpr-consent.js +11 -0
- package/dist/browser/tools/gdpr-consent.js.map +7 -0
- package/dist/browser/tools/gtm-tracker.d.ts +7 -0
- package/dist/browser/tools/gtm-tracker.js +7 -0
- package/dist/browser/tools/gtm-tracker.js.map +7 -0
- package/dist/builder/form-authoring.d.ts +159 -0
- package/dist/builder/form-authoring.js +1 -0
- package/dist/builder/form-authoring.js.map +7 -0
- package/dist/builder/form-values.d.ts +158 -0
- package/dist/builder/form-values.js +0 -0
- package/dist/builder/form-values.js.map +7 -0
- package/dist/builder/index.d.ts +5 -0
- package/dist/builder/index.js +2 -0
- package/dist/builder/index.js.map +7 -0
- package/dist/builder/types.utils.d.ts +137 -0
- package/dist/builder/types.utils.js +1 -0
- package/dist/builder/types.utils.js.map +7 -0
- package/dist/chunk-237BHPDH.js +88 -0
- package/dist/chunk-237BHPDH.js.map +7 -0
- package/dist/chunk-25PLQDKN.js +45 -0
- package/dist/chunk-25PLQDKN.js.map +7 -0
- package/dist/chunk-2PTM54FQ.js +51 -0
- package/dist/chunk-2PTM54FQ.js.map +7 -0
- package/dist/chunk-2VKEOE2L.js +907 -0
- package/dist/chunk-2VKEOE2L.js.map +7 -0
- package/dist/chunk-2XWISGGM.js +8 -0
- package/dist/chunk-2XWISGGM.js.map +7 -0
- package/dist/chunk-2YKQAVI2.js +8 -0
- package/dist/chunk-2YKQAVI2.js.map +7 -0
- package/dist/chunk-3B7CJOF6.js +18 -0
- package/dist/chunk-3B7CJOF6.js.map +7 -0
- package/dist/chunk-3YLRJVVN.js +17 -0
- package/dist/chunk-3YLRJVVN.js.map +7 -0
- package/dist/chunk-4CUGHU36.js +58 -0
- package/dist/chunk-4CUGHU36.js.map +7 -0
- package/dist/chunk-4FELFUCD.js +0 -0
- package/dist/chunk-4FELFUCD.js.map +7 -0
- package/dist/chunk-4XPLSYTK.js +82 -0
- package/dist/chunk-4XPLSYTK.js.map +7 -0
- package/dist/chunk-56CJ2UZ7.js +55 -0
- package/dist/chunk-56CJ2UZ7.js.map +7 -0
- package/dist/chunk-5QXT7YAJ.js +87 -0
- package/dist/chunk-5QXT7YAJ.js.map +7 -0
- package/dist/chunk-5Y6U3MR3.js +54 -0
- package/dist/chunk-5Y6U3MR3.js.map +7 -0
- package/dist/chunk-6BAJHAGL.js +29 -0
- package/dist/chunk-6BAJHAGL.js.map +7 -0
- package/dist/chunk-6FUGK5HQ.js +26 -0
- package/dist/chunk-6FUGK5HQ.js.map +7 -0
- package/dist/chunk-6IZYNHZ3.js +118 -0
- package/dist/chunk-6IZYNHZ3.js.map +7 -0
- package/dist/chunk-6NV2JDGI.js +8 -0
- package/dist/chunk-6NV2JDGI.js.map +7 -0
- package/dist/chunk-6R2MBQPL.js +19 -0
- package/dist/chunk-6R2MBQPL.js.map +7 -0
- package/dist/chunk-7EQJUI5N.js +40 -0
- package/dist/chunk-7EQJUI5N.js.map +7 -0
- package/dist/chunk-AUZ45XPE.js +27 -0
- package/dist/chunk-AUZ45XPE.js.map +7 -0
- package/dist/chunk-BIHEIJG3.js +0 -0
- package/dist/chunk-BIHEIJG3.js.map +7 -0
- package/dist/chunk-BKNWW4PK.js +0 -0
- package/dist/chunk-BKNWW4PK.js.map +7 -0
- package/dist/chunk-BLFLCSG3.js +71 -0
- package/dist/chunk-BLFLCSG3.js.map +7 -0
- package/dist/chunk-BYYGAGNH.js +0 -0
- package/dist/chunk-BYYGAGNH.js.map +7 -0
- package/dist/chunk-CAZPWBQ4.js +18 -0
- package/dist/chunk-CAZPWBQ4.js.map +7 -0
- package/dist/chunk-CMPOBBRV.js +10 -0
- package/dist/chunk-CMPOBBRV.js.map +7 -0
- package/dist/chunk-CRQWKC67.js +118 -0
- package/dist/chunk-CRQWKC67.js.map +7 -0
- package/dist/chunk-CRVXBWSY.js +70 -0
- package/dist/chunk-CRVXBWSY.js.map +7 -0
- package/dist/chunk-D6ZHV6AT.js +0 -0
- package/dist/chunk-D6ZHV6AT.js.map +7 -0
- package/dist/chunk-DVDKPY2A.js +12 -0
- package/dist/chunk-DVDKPY2A.js.map +7 -0
- package/dist/chunk-E4VONSLO.js +15 -0
- package/dist/chunk-E4VONSLO.js.map +7 -0
- package/dist/chunk-EEYGPPLU.js +185 -0
- package/dist/chunk-EEYGPPLU.js.map +7 -0
- package/dist/chunk-EI5TMJDC.js +56 -0
- package/dist/chunk-EI5TMJDC.js.map +7 -0
- package/dist/chunk-EQ5AIF3T.js +117 -0
- package/dist/chunk-EQ5AIF3T.js.map +7 -0
- package/dist/chunk-EZZHO6DQ.js +26 -0
- package/dist/chunk-EZZHO6DQ.js.map +7 -0
- package/dist/chunk-FUHLRG3M.js +130 -0
- package/dist/chunk-FUHLRG3M.js.map +7 -0
- package/dist/chunk-FVOL3ZOJ.js +101 -0
- package/dist/chunk-FVOL3ZOJ.js.map +7 -0
- package/dist/chunk-G33EUV7N.js +288 -0
- package/dist/chunk-G33EUV7N.js.map +7 -0
- package/dist/chunk-GH34XFCC.js +56 -0
- package/dist/chunk-GH34XFCC.js.map +7 -0
- package/dist/chunk-GKWRJ6H4.js +27 -0
- package/dist/chunk-GKWRJ6H4.js.map +7 -0
- package/dist/chunk-GRZU6F7Q.js +80 -0
- package/dist/chunk-GRZU6F7Q.js.map +7 -0
- package/dist/chunk-GT2LARKT.js +107 -0
- package/dist/chunk-GT2LARKT.js.map +7 -0
- package/dist/chunk-GY657L56.js +206 -0
- package/dist/chunk-GY657L56.js.map +7 -0
- package/dist/chunk-H4ABGAAG.js +60 -0
- package/dist/chunk-H4ABGAAG.js.map +7 -0
- package/dist/chunk-H63UHX42.js +93 -0
- package/dist/chunk-H63UHX42.js.map +7 -0
- package/dist/chunk-HEAKWS27.js +2730 -0
- package/dist/chunk-HEAKWS27.js.map +7 -0
- package/dist/chunk-HIS4MGIR.js +8 -0
- package/dist/chunk-HIS4MGIR.js.map +7 -0
- package/dist/chunk-HPPFSWIV.js +213 -0
- package/dist/chunk-HPPFSWIV.js.map +7 -0
- package/dist/chunk-J2FC5K4B.js +87 -0
- package/dist/chunk-J2FC5K4B.js.map +7 -0
- package/dist/chunk-J5BSFDVK.js +123 -0
- package/dist/chunk-J5BSFDVK.js.map +7 -0
- package/dist/chunk-J7GSNWXT.js +151 -0
- package/dist/chunk-J7GSNWXT.js.map +7 -0
- package/dist/chunk-K22S7IZR.js +12 -0
- package/dist/chunk-K22S7IZR.js.map +7 -0
- package/dist/chunk-K5TMXCMY.js +139 -0
- package/dist/chunk-K5TMXCMY.js.map +7 -0
- package/dist/chunk-KE53GN4Q.js +246 -0
- package/dist/chunk-KE53GN4Q.js.map +7 -0
- package/dist/chunk-KFQEDSYI.js +24 -0
- package/dist/chunk-KFQEDSYI.js.map +7 -0
- package/dist/chunk-KLATKWUA.js +116 -0
- package/dist/chunk-KLATKWUA.js.map +7 -0
- package/dist/chunk-KSKWSUOB.js +17 -0
- package/dist/chunk-KSKWSUOB.js.map +7 -0
- package/dist/chunk-LFWEJXWE.js +68 -0
- package/dist/chunk-LFWEJXWE.js.map +7 -0
- package/dist/chunk-LMWJAD3B.js +24 -0
- package/dist/chunk-LMWJAD3B.js.map +7 -0
- package/dist/chunk-MD23VADH.js +92 -0
- package/dist/chunk-MD23VADH.js.map +7 -0
- package/dist/chunk-MKMJT3XR.js +0 -0
- package/dist/chunk-MKMJT3XR.js.map +7 -0
- package/dist/chunk-NJTLBSTR.js +82 -0
- package/dist/chunk-NJTLBSTR.js.map +7 -0
- package/dist/chunk-NJXKMF67.js +182 -0
- package/dist/chunk-NJXKMF67.js.map +7 -0
- package/dist/chunk-OBQBIOGN.js +16 -0
- package/dist/chunk-OBQBIOGN.js.map +7 -0
- package/dist/chunk-OLYHNFKC.js +82 -0
- package/dist/chunk-OLYHNFKC.js.map +7 -0
- package/dist/chunk-OR2L7EKO.js +33 -0
- package/dist/chunk-OR2L7EKO.js.map +7 -0
- package/dist/chunk-OUF57UZ7.js +28 -0
- package/dist/chunk-OUF57UZ7.js.map +7 -0
- package/dist/chunk-PBMM2N77.js +56 -0
- package/dist/chunk-PBMM2N77.js.map +7 -0
- package/dist/chunk-PH3LWLYN.js +49 -0
- package/dist/chunk-PH3LWLYN.js.map +7 -0
- package/dist/chunk-PHNMDWSK.js +9 -0
- package/dist/chunk-PHNMDWSK.js.map +7 -0
- package/dist/chunk-PN5EH6DM.js +36 -0
- package/dist/chunk-PN5EH6DM.js.map +7 -0
- package/dist/chunk-POCAINUE.js +42 -0
- package/dist/chunk-POCAINUE.js.map +7 -0
- package/dist/chunk-PXWVKJGF.js +6 -0
- package/dist/chunk-PXWVKJGF.js.map +7 -0
- package/dist/chunk-Q5LEK7CI.js +64 -0
- package/dist/chunk-Q5LEK7CI.js.map +7 -0
- package/dist/chunk-QH7VW7IY.js +0 -0
- package/dist/chunk-QH7VW7IY.js.map +7 -0
- package/dist/chunk-QLGM2AZW.js +173 -0
- package/dist/chunk-QLGM2AZW.js.map +7 -0
- package/dist/chunk-QT3EYUL5.js +85 -0
- package/dist/chunk-QT3EYUL5.js.map +7 -0
- package/dist/chunk-QYHOFLRX.js +43 -0
- package/dist/chunk-QYHOFLRX.js.map +7 -0
- package/dist/chunk-R3MBVWVI.js +127 -0
- package/dist/chunk-R3MBVWVI.js.map +7 -0
- package/dist/chunk-R6V3LH7F.js +67 -0
- package/dist/chunk-R6V3LH7F.js.map +7 -0
- package/dist/chunk-RB22U6HI.js +64 -0
- package/dist/chunk-RB22U6HI.js.map +7 -0
- package/dist/chunk-RQRQYYTB.js +34 -0
- package/dist/chunk-RQRQYYTB.js.map +7 -0
- package/dist/chunk-S5D2QE4G.js +53 -0
- package/dist/chunk-S5D2QE4G.js.map +7 -0
- package/dist/chunk-S7I76ISM.js +245 -0
- package/dist/chunk-S7I76ISM.js.map +7 -0
- package/dist/chunk-TBDZOQ2C.js +66 -0
- package/dist/chunk-TBDZOQ2C.js.map +7 -0
- package/dist/chunk-U2X3IYSD.js +23 -0
- package/dist/chunk-U2X3IYSD.js.map +7 -0
- package/dist/chunk-UGL3KNOT.js +42 -0
- package/dist/chunk-UGL3KNOT.js.map +7 -0
- package/dist/chunk-UN3DARLG.js +35 -0
- package/dist/chunk-UN3DARLG.js.map +7 -0
- package/dist/chunk-VGGERKV2.js +7 -0
- package/dist/chunk-VGGERKV2.js.map +7 -0
- package/dist/chunk-VVFXYY65.js +0 -0
- package/dist/chunk-VVFXYY65.js.map +7 -0
- package/dist/chunk-WLDCYUN6.js +161 -0
- package/dist/chunk-WLDCYUN6.js.map +7 -0
- package/dist/chunk-WMDTQS36.js +0 -0
- package/dist/chunk-WMDTQS36.js.map +7 -0
- package/dist/chunk-WS7SLVXL.js +550 -0
- package/dist/chunk-WS7SLVXL.js.map +7 -0
- package/dist/chunk-WUTGZYP4.js +290 -0
- package/dist/chunk-WUTGZYP4.js.map +7 -0
- package/dist/chunk-XKN3WWK3.js +0 -0
- package/dist/chunk-XKN3WWK3.js.map +7 -0
- package/dist/chunk-XPQRHO5E.js +587 -0
- package/dist/chunk-XPQRHO5E.js.map +7 -0
- package/dist/chunk-XQ5VJ4QO.js +62 -0
- package/dist/chunk-XQ5VJ4QO.js.map +7 -0
- package/dist/chunk-XQVKX47O.js +174 -0
- package/dist/chunk-XQVKX47O.js.map +7 -0
- package/dist/chunk-Y5CNB57V.js +22 -0
- package/dist/chunk-Y5CNB57V.js.map +7 -0
- package/dist/chunk-YDGH7DTL.js +18 -0
- package/dist/chunk-YDGH7DTL.js.map +7 -0
- package/dist/chunk-YIFUBPJ3.js +0 -0
- package/dist/chunk-YIFUBPJ3.js.map +7 -0
- package/dist/chunk-YUUDXRBW.js +212 -0
- package/dist/chunk-YUUDXRBW.js.map +7 -0
- package/dist/chunk-Z6DQLJS2.js +23 -0
- package/dist/chunk-Z6DQLJS2.js.map +7 -0
- package/dist/chunk-ZDEZ2FOC.js +81 -0
- package/dist/chunk-ZDEZ2FOC.js.map +7 -0
- package/dist/chunk-ZUYSGCEH.js +65 -0
- package/dist/chunk-ZUYSGCEH.js.map +7 -0
- package/dist/chunk-ZYP3MIH3.js +115 -0
- package/dist/chunk-ZYP3MIH3.js.map +7 -0
- package/dist/constraints/constraint-evaluator.d.ts +57 -0
- package/dist/constraints/constraint-evaluator.js +17 -0
- package/dist/constraints/constraint-evaluator.js.map +7 -0
- package/dist/constraints/index.d.ts +1 -0
- package/dist/constraints/index.js +17 -0
- package/dist/constraints/index.js.map +7 -0
- package/dist/csrf/index.d.ts +43 -0
- package/dist/csrf/index.js +43 -0
- package/dist/csrf/index.js.map +7 -0
- package/dist/engine/build-form-engine.d.ts +27 -0
- package/dist/engine/build-form-engine.js +58 -0
- package/dist/engine/build-form-engine.js.map +7 -0
- package/dist/engine/component-type.d.ts +19 -0
- package/dist/engine/component-type.js +6 -0
- package/dist/engine/component-type.js.map +7 -0
- package/dist/engine/create-form-engine.d.ts +100 -0
- package/dist/engine/create-form-engine.js +59 -0
- package/dist/engine/create-form-engine.js.map +7 -0
- package/dist/engine/form-action-context.d.ts +70 -0
- package/dist/engine/form-action-context.js +10 -0
- package/dist/engine/form-action-context.js.map +7 -0
- package/dist/engine/form-engine.d.ts +236 -0
- package/dist/engine/form-engine.js +61 -0
- package/dist/engine/form-engine.js.map +7 -0
- package/dist/engine/index.d.ts +12 -0
- package/dist/engine/index.js +124 -0
- package/dist/engine/index.js.map +7 -0
- package/dist/engine/schema-artifacts.d.ts +87 -0
- package/dist/engine/schema-artifacts.js +14 -0
- package/dist/engine/schema-artifacts.js.map +7 -0
- package/dist/engine/schema-metadata-catalog.d.ts +41 -0
- package/dist/engine/schema-metadata-catalog.js +6 -0
- package/dist/engine/schema-metadata-catalog.js.map +7 -0
- package/dist/engine/step-machine.d.ts +59 -0
- package/dist/engine/step-machine.js +32 -0
- package/dist/engine/step-machine.js.map +7 -0
- package/dist/engine/submission-schema.d.ts +53 -0
- package/dist/engine/submission-schema.js +22 -0
- package/dist/engine/submission-schema.js.map +7 -0
- package/dist/engine/value-validation.d.ts +237 -0
- package/dist/engine/value-validation.js +39 -0
- package/dist/engine/value-validation.js.map +7 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +283 -0
- package/dist/index.js.map +7 -0
- package/dist/lib/authoring-catalog.d.ts +5 -0
- package/dist/lib/authoring-catalog.js +11 -0
- package/dist/lib/authoring-catalog.js.map +7 -0
- package/dist/lib/container-kind-of.d.ts +5 -0
- package/dist/lib/container-kind-of.js +6 -0
- package/dist/lib/container-kind-of.js.map +7 -0
- package/dist/lib/debounce.d.ts +19 -0
- package/dist/lib/debounce.js +6 -0
- package/dist/lib/debounce.js.map +7 -0
- package/dist/lib/deep-readonly.d.ts +12 -0
- package/dist/lib/deep-readonly.js +0 -0
- package/dist/lib/deep-readonly.js.map +7 -0
- package/dist/lib/element-children.d.ts +35 -0
- package/dist/lib/element-children.js +16 -0
- package/dist/lib/element-children.js.map +7 -0
- package/dist/lib/exported-action-envelope.d.ts +11 -0
- package/dist/lib/exported-action-envelope.js +7 -0
- package/dist/lib/exported-action-envelope.js.map +7 -0
- package/dist/lib/exported-rules.d.ts +14 -0
- package/dist/lib/exported-rules.js +6 -0
- package/dist/lib/exported-rules.js.map +7 -0
- package/dist/lib/field-ref.d.ts +13 -0
- package/dist/lib/field-ref.js +6 -0
- package/dist/lib/field-ref.js.map +7 -0
- package/dist/lib/field-scope.d.ts +121 -0
- package/dist/lib/field-scope.js +41 -0
- package/dist/lib/field-scope.js.map +7 -0
- package/dist/lib/form-fetch.d.ts +36 -0
- package/dist/lib/form-fetch.js +10 -0
- package/dist/lib/form-fetch.js.map +7 -0
- package/dist/lib/form-view.d.ts +33 -0
- package/dist/lib/form-view.js +12 -0
- package/dist/lib/form-view.js.map +7 -0
- package/dist/lib/frozen-copy.d.ts +9 -0
- package/dist/lib/frozen-copy.js +7 -0
- package/dist/lib/frozen-copy.js.map +7 -0
- package/dist/lib/is-plain-object.d.ts +2 -0
- package/dist/lib/is-plain-object.js +6 -0
- package/dist/lib/is-plain-object.js.map +7 -0
- package/dist/lib/logger.d.ts +2 -0
- package/dist/lib/logger.js +6 -0
- package/dist/lib/logger.js.map +7 -0
- package/dist/lib/normalized-form-config.d.ts +106 -0
- package/dist/lib/normalized-form-config.js +19 -0
- package/dist/lib/normalized-form-config.js.map +7 -0
- package/dist/lib/omit-paths.d.ts +11 -0
- package/dist/lib/omit-paths.js +7 -0
- package/dist/lib/omit-paths.js.map +7 -0
- package/dist/lib/path-values.d.ts +47 -0
- package/dist/lib/path-values.js +22 -0
- package/dist/lib/path-values.js.map +7 -0
- package/dist/lib/renderer-data-attributes.d.ts +10 -0
- package/dist/lib/renderer-data-attributes.js +6 -0
- package/dist/lib/renderer-data-attributes.js.map +7 -0
- package/dist/lib/reserved-path-keys.d.ts +10 -0
- package/dist/lib/reserved-path-keys.js +10 -0
- package/dist/lib/reserved-path-keys.js.map +7 -0
- package/dist/lib/resolve-appearance.d.ts +48 -0
- package/dist/lib/resolve-appearance.js +10 -0
- package/dist/lib/resolve-appearance.js.map +7 -0
- package/dist/lib/standard-json-schema.d.ts +27 -0
- package/dist/lib/standard-json-schema.js +8 -0
- package/dist/lib/standard-json-schema.js.map +7 -0
- package/dist/lib/standard-schema.d.ts +19 -0
- package/dist/lib/standard-schema.js +8 -0
- package/dist/lib/standard-schema.js.map +7 -0
- package/dist/lib/submission-shape.d.ts +60 -0
- package/dist/lib/submission-shape.js +14 -0
- package/dist/lib/submission-shape.js.map +7 -0
- package/dist/lib/validate-form/grid-checks.d.ts +57 -0
- package/dist/lib/validate-form/grid-checks.js +16 -0
- package/dist/lib/validate-form/grid-checks.js.map +7 -0
- package/dist/lib/validate-form/issues.d.ts +43 -0
- package/dist/lib/validate-form/issues.js +13 -0
- package/dist/lib/validate-form/issues.js.map +7 -0
- package/dist/lib/validate-form/options.d.ts +22 -0
- package/dist/lib/validate-form/options.js +0 -0
- package/dist/lib/validate-form/options.js.map +7 -0
- package/dist/lib/validate-form/parse-elements.d.ts +23 -0
- package/dist/lib/validate-form/parse-elements.js +21 -0
- package/dist/lib/validate-form/parse-elements.js.map +7 -0
- package/dist/lib/validate-form/parse-owner-actions.d.ts +14 -0
- package/dist/lib/validate-form/parse-owner-actions.js +10 -0
- package/dist/lib/validate-form/parse-owner-actions.js.map +7 -0
- package/dist/lib/validate-form/parse-view.d.ts +11 -0
- package/dist/lib/validate-form/parse-view.js +11 -0
- package/dist/lib/validate-form/parse-view.js.map +7 -0
- package/dist/lib/validate-form/schema-issues.d.ts +16 -0
- package/dist/lib/validate-form/schema-issues.js +8 -0
- package/dist/lib/validate-form/schema-issues.js.map +7 -0
- package/dist/lib/validate-form/step-checks.d.ts +18 -0
- package/dist/lib/validate-form/step-checks.js +15 -0
- package/dist/lib/validate-form/step-checks.js.map +7 -0
- package/dist/lib/validate-form/validation-error.d.ts +26 -0
- package/dist/lib/validate-form/validation-error.js +8 -0
- package/dist/lib/validate-form/validation-error.js.map +7 -0
- package/dist/lib/validate-form.d.ts +34 -0
- package/dist/lib/validate-form.js +62 -0
- package/dist/lib/validate-form.js.map +7 -0
- package/dist/lib/zod-json-schema.d.ts +33 -0
- package/dist/lib/zod-json-schema.js +10 -0
- package/dist/lib/zod-json-schema.js.map +7 -0
- package/dist/recipes/built-in-specs.d.ts +1832 -0
- package/dist/recipes/built-in-specs.js +28 -0
- package/dist/recipes/built-in-specs.js.map +7 -0
- package/dist/recipes/built-in.d.ts +2 -0
- package/dist/recipes/built-in.js +49 -0
- package/dist/recipes/built-in.js.map +7 -0
- package/dist/recipes/define-form-recipe.d.ts +10 -0
- package/dist/recipes/define-form-recipe.js +6 -0
- package/dist/recipes/define-form-recipe.js.map +7 -0
- package/dist/recipes/define-recipe-spec.d.ts +13 -0
- package/dist/recipes/define-recipe-spec.js +8 -0
- package/dist/recipes/define-recipe-spec.js.map +7 -0
- package/dist/recipes/index.d.ts +6 -0
- package/dist/recipes/index.js +43 -0
- package/dist/recipes/index.js.map +7 -0
- package/dist/recipes/protocol.d.ts +24 -0
- package/dist/recipes/protocol.js +11 -0
- package/dist/recipes/protocol.js.map +7 -0
- package/dist/recipes/slot-schemas.d.ts +128 -0
- package/dist/recipes/slot-schemas.js +24 -0
- package/dist/recipes/slot-schemas.js.map +7 -0
- package/dist/recipes/types.d.ts +55 -0
- package/dist/recipes/types.js +1 -0
- package/dist/recipes/types.js.map +7 -0
- package/dist/recipes/view-model.d.ts +93 -0
- package/dist/recipes/view-model.js +29 -0
- package/dist/recipes/view-model.js.map +7 -0
- package/dist/registries/index.d.ts +8 -0
- package/dist/registries/index.js +0 -0
- package/dist/registries/index.js.map +7 -0
- package/dist/runtime/create-form-runtime.d.ts +43 -0
- package/dist/runtime/create-form-runtime.js +41 -0
- package/dist/runtime/create-form-runtime.js.map +7 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +44 -0
- package/dist/runtime/index.js.map +7 -0
- package/dist/runtime/submission-lifecycle.d.ts +65 -0
- package/dist/runtime/submission-lifecycle.js +6 -0
- package/dist/runtime/submission-lifecycle.js.map +7 -0
- package/dist/runtime/types.d.ts +172 -0
- package/dist/runtime/types.js +6 -0
- package/dist/runtime/types.js.map +7 -0
- package/dist/schemas/base-field.d.ts +450 -0
- package/dist/schemas/base-field.js +36 -0
- package/dist/schemas/base-field.js.map +7 -0
- package/dist/schemas/field-config.d.ts +36 -0
- package/dist/schemas/field-config.js +1 -0
- package/dist/schemas/field-config.js.map +7 -0
- package/dist/schemas/form-config-shape.d.ts +763 -0
- package/dist/schemas/form-config-shape.js +35 -0
- package/dist/schemas/form-config-shape.js.map +7 -0
- package/dist/schemas/form-config.d.ts +1288 -0
- package/dist/schemas/form-config.js +41 -0
- package/dist/schemas/form-config.js.map +7 -0
- package/dist/schemas/html-attributes.d.ts +12 -0
- package/dist/schemas/html-attributes.js +12 -0
- package/dist/schemas/html-attributes.js.map +7 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +165 -0
- package/dist/schemas/index.js.map +7 -0
- package/dist/schemas/validation/async/cache.d.ts +39 -0
- package/dist/schemas/validation/async/cache.js +6 -0
- package/dist/schemas/validation/async/cache.js.map +7 -0
- package/dist/schemas/validation/async/handler.d.ts +21 -0
- package/dist/schemas/validation/async/handler.js +11 -0
- package/dist/schemas/validation/async/handler.js.map +7 -0
- package/dist/schemas/validation/async/index.d.ts +8 -0
- package/dist/schemas/validation/async/index.js +14 -0
- package/dist/schemas/validation/async/index.js.map +7 -0
- package/dist/schemas/validation/defaults.d.ts +6 -0
- package/dist/schemas/validation/defaults.js +12 -0
- package/dist/schemas/validation/defaults.js.map +7 -0
- package/dist/schemas/validation/dependencies.d.ts +52 -0
- package/dist/schemas/validation/dependencies.js +17 -0
- package/dist/schemas/validation/dependencies.js.map +7 -0
- package/dist/schemas/validation/empty.d.ts +1 -0
- package/dist/schemas/validation/empty.js +6 -0
- package/dist/schemas/validation/empty.js.map +7 -0
- package/dist/schemas/validation/errors.d.ts +44 -0
- package/dist/schemas/validation/errors.js +12 -0
- package/dist/schemas/validation/errors.js.map +7 -0
- package/dist/schemas/validation/index.d.ts +9 -0
- package/dist/schemas/validation/index.js +130 -0
- package/dist/schemas/validation/index.js.map +7 -0
- package/dist/schemas/validation/presets.d.ts +66 -0
- package/dist/schemas/validation/presets.js +6 -0
- package/dist/schemas/validation/presets.js.map +7 -0
- package/dist/schemas/validation/relations.d.ts +12 -0
- package/dist/schemas/validation/relations.js +8 -0
- package/dist/schemas/validation/relations.js.map +7 -0
- package/dist/schemas/validation/types.d.ts +817 -0
- package/dist/schemas/validation/types.js +64 -0
- package/dist/schemas/validation/types.js.map +7 -0
- package/dist/schemas/validation/utils.d.ts +76 -0
- package/dist/schemas/validation/utils.js +24 -0
- package/dist/schemas/validation/utils.js.map +7 -0
- package/dist/schemas/validation/validation-registry.d.ts +124 -0
- package/dist/schemas/validation/validation-registry.js +27 -0
- package/dist/schemas/validation/validation-registry.js.map +7 -0
- package/dist/server-errors/from-json-api-errors.d.ts +13 -0
- package/dist/server-errors/from-json-api-errors.js +10 -0
- package/dist/server-errors/from-json-api-errors.js.map +7 -0
- package/dist/server-errors/from-problem-details.d.ts +15 -0
- package/dist/server-errors/from-problem-details.js +10 -0
- package/dist/server-errors/from-problem-details.js.map +7 -0
- package/dist/server-errors/index.d.ts +8 -0
- package/dist/server-errors/index.js +17 -0
- package/dist/server-errors/index.js.map +7 -0
- package/dist/server-errors/shared.d.ts +34 -0
- package/dist/server-errors/shared.js +23 -0
- package/dist/server-errors/shared.js.map +7 -0
- package/dist/state-container/create-form-state-container.d.ts +17 -0
- package/dist/state-container/create-form-state-container.js +31 -0
- package/dist/state-container/create-form-state-container.js.map +7 -0
- package/dist/state-container/dirty.d.ts +11 -0
- package/dist/state-container/dirty.js +9 -0
- package/dist/state-container/dirty.js.map +7 -0
- package/dist/state-container/field-array.d.ts +41 -0
- package/dist/state-container/field-array.js +8 -0
- package/dist/state-container/field-array.js.map +7 -0
- package/dist/state-container/hydration.d.ts +21 -0
- package/dist/state-container/hydration.js +11 -0
- package/dist/state-container/hydration.js.map +7 -0
- package/dist/state-container/index.d.ts +16 -0
- package/dist/state-container/index.js +51 -0
- package/dist/state-container/index.js.map +7 -0
- package/dist/state-container/issue-text.d.ts +11 -0
- package/dist/state-container/issue-text.js +6 -0
- package/dist/state-container/issue-text.js.map +7 -0
- package/dist/state-container/row-ids.d.ts +34 -0
- package/dist/state-container/row-ids.js +19 -0
- package/dist/state-container/row-ids.js.map +7 -0
- package/dist/state-container/selectors.d.ts +33 -0
- package/dist/state-container/selectors.js +22 -0
- package/dist/state-container/selectors.js.map +7 -0
- package/dist/state-container/stale-results.d.ts +28 -0
- package/dist/state-container/stale-results.js +9 -0
- package/dist/state-container/stale-results.js.map +7 -0
- package/dist/state-container/state-tree.d.ts +56 -0
- package/dist/state-container/state-tree.js +33 -0
- package/dist/state-container/state-tree.js.map +7 -0
- package/dist/state-container/submission.d.ts +45 -0
- package/dist/state-container/submission.js +26 -0
- package/dist/state-container/submission.js.map +7 -0
- package/dist/state-container/types.d.ts +404 -0
- package/dist/state-container/types.js +6 -0
- package/dist/state-container/types.js.map +7 -0
- package/dist/state-container/value-tree.d.ts +56 -0
- package/dist/state-container/value-tree.js +34 -0
- package/dist/state-container/value-tree.js.map +7 -0
- package/dist/testing/form-state-container-conformance.d.ts +51 -0
- package/dist/testing/form-state-container-conformance.js +43 -0
- package/dist/testing/form-state-container-conformance.js.map +7 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +35 -0
- package/dist/testing/index.js.map +7 -0
- package/dist/types/actions.d.ts +75 -0
- package/dist/types/actions.js +1 -0
- package/dist/types/actions.js.map +7 -0
- package/dist/types/categories.d.ts +21 -0
- package/dist/types/categories.js +8 -0
- package/dist/types/categories.js.map +7 -0
- package/dist/types/define-element.d.ts +73 -0
- package/dist/types/define-element.js +8 -0
- package/dist/types/define-element.js.map +7 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +7 -0
- package/dist/types/metadata.d.ts +14 -0
- package/dist/types/metadata.js +1 -0
- package/dist/types/metadata.js.map +7 -0
- package/dist/types/registration.d.ts +142 -0
- package/dist/types/registration.js +1 -0
- package/dist/types/registration.js.map +7 -0
- package/package.json +119 -3
- package/skill/SKILL.md +79 -0
- package/skill/reference/forms-actions.md +51 -0
- package/skill/reference/forms-submission.md +44 -0
- package/skill/reference/forms-validation.md +91 -0
- package/skill/reference/forms.md +179 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/schemas/validation/async/handler.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/mini';\nimport { asyncValidationCache } from './cache';\nimport type { AsyncRule, ValidationContext } from '../types.js';\nimport { isEmpty } from '../empty.js';\nimport { REPORTED_TEXT, ValidationSuperseded, ValidationUnavailable } from '../errors.js';\n\n/**\n * HTTP methods supported for async validation requests\n */\nexport type AsyncValidationMethod = NonNullable<AsyncRule['method']>;\n\n/**\n * Expected response format for validation success determination\n */\nexport type AsyncValidationResponse = NonNullable<AsyncRule['expectedResponse']>;\n\n/**\n * Cached validation result structure\n */\ninterface CachedValidationResult {\n\tvalid: boolean;\n\tmessage?: string;\n}\n\n/**\n * Cache TTL for an answer of the service; an outage is never cached\n */\nexport const CACHE_TTL = {\n\tDEFAULT: 5 * 60 * 1000,\n} as const;\n\n/**\n * Resolves dependency values through the field's validation context.\n *\n * @remarks\n * Dependencies are field *references*, so they resolve like any other: a bare\n * name is a sibling and a dotted name is absolute. Reading them off a flat map\n * instead \u2014 as this did \u2014 dropped every nested dependency and pinned every\n * array-row dependency to row zero.\n */\nfunction resolveDependencies(dependencies: string[] | undefined, context: ValidationContext): Record<string, unknown> {\n\tif (!dependencies?.length) {\n\t\treturn {};\n\t}\n\n\treturn Object.fromEntries(\n\t\tdependencies.map((dep) => [dep, context.resolve(dep)] as const).filter(([, value]) => value !== undefined),\n\t);\n}\n\n/**\n * Creates the validation request payload with value, dependencies, and extra payload.\n */\nfunction createValidationPayload(\n\tvalue: unknown,\n\tdependsOn: Record<string, unknown>,\n\textraPayload?: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst payload: Record<string, unknown> = {\n\t\tvalue,\n\t};\n\n\tif (Object.keys(dependsOn).length > 0) {\n\t\tpayload.dependsOn = dependsOn;\n\t}\n\n\tif (extraPayload) {\n\t\tObject.assign(payload, extraPayload);\n\t}\n\n\treturn payload;\n}\n\n/** Whether two answers hold the same data, whatever the order of their keys. */\nfunction sameData(a: unknown, b: unknown): boolean {\n\tif (Object.is(a, b)) return true;\n\tif (Array.isArray(a) || Array.isArray(b)) {\n\t\treturn (\n\t\t\tArray.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, i) => sameData(item, b[i]))\n\t\t);\n\t}\n\tif (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n\tconst left = a as Record<string, unknown>;\n\tconst right = b as Record<string, unknown>;\n\tconst keys = Object.keys(left);\n\treturn (\n\t\tkeys.length === Object.keys(right).length &&\n\t\tkeys.every((key) => Object.hasOwn(right, key) && sameData(left[key], right[key]))\n\t);\n}\n\n/**\n * Whether the answer of the endpoint says the value is valid.\n *\n * @remarks\n * With `expectedResponse` the answer must equal it structurally. Without, an answer is a boolean, or an\n * object whose `valid` (else `success`) is a boolean. Anything else is no answer about the value: it throws\n * `ValidationUnavailable`, so it is never a field error and never cached.\n */\nfunction isValidationSuccessful(data: unknown, expectedResponse?: AsyncValidationResponse): boolean {\n\tif (expectedResponse) return sameData(data, expectedResponse);\n\tif (typeof data === 'boolean') return data;\n\tif (typeof data === 'object' && data !== null) {\n\t\tconst { valid, success } = data as Record<string, unknown>;\n\t\tif (typeof valid === 'boolean') return valid;\n\t\tif (typeof success === 'boolean') return success;\n\t}\n\tthrow new ValidationUnavailable();\n}\n\n/**\n * Extracts error message from validation response with proper priority.\n */\nfunction getErrorMessage(data: unknown, fallbackMessage?: string): string | undefined {\n\tif (typeof data === 'object' && data !== null) {\n\t\tconst obj = data as Record<string, unknown>;\n\t\treturn (obj.message as string) || (obj.error as string) || fallbackMessage;\n\t}\n\treturn fallbackMessage;\n}\n\n/**\n * Handles validation failure by adding an issue to the Zod Mini context.\n */\nfunction handleValidationFailure(ctx: z.core.$RefinementCtx, text: string | undefined): void {\n\tctx.addIssue({\n\t\tcode: 'custom',\n\t\t...(text === undefined ? {} : { params: { [REPORTED_TEXT]: text } }),\n\t});\n}\n\n/**\n * Creates a Zod Mini async validation handler for server-side validation.\n * Includes debouncing, dependency resolution, and performance optimizations.\n */\nexport function createAsyncValidationHandler(rule: AsyncRule, context: ValidationContext) {\n\treturn z.unknown().check(\n\t\tz.superRefine(async (value: unknown, ctx) => {\n\t\t\tif (isEmpty(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst dependsOn = resolveDependencies(rule.dependencies, context);\n\n\t\t\t/**\n\t\t\t * Skip validation if any dependency field is empty.\n\t\t\t * This ensures all required context is available before making API calls.\n\t\t\t */\n\t\t\tif (rule.dependencies?.length) {\n\t\t\t\tconst hasEmptyDependencies = rule.dependencies.some((dep) => {\n\t\t\t\t\tconst depValue = context.resolve(dep);\n\t\t\t\t\treturn isEmpty(depValue);\n\t\t\t\t});\n\n\t\t\t\tif (hasEmptyDependencies) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst payload = createValidationPayload(value, dependsOn, rule.extraPayload);\n\n\t\t\t/** Check cache first to avoid unnecessary delays for cached results */\n\t\t\tif (!rule.disableCache) {\n\t\t\t\tconst cachedResult = asyncValidationCache.get(rule.url, payload) as CachedValidationResult | null;\n\t\t\t\tif (cachedResult !== null) {\n\t\t\t\t\tif (!cachedResult.valid) {\n\t\t\t\t\t\thandleValidationFailure(ctx, cachedResult.message);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Create unique debounce key excluding the changing value to ensure proper debouncing.\n\t\t\t */\n\t\t\tconst stablePayload = { dependsOn, ...rule.extraPayload };\n\t\t\tconst debounceKey = `async-validation:${context.fieldPath}:${rule.url}:${JSON.stringify(stablePayload)}`;\n\n\t\t\t/** Core validation function that performs the HTTP request and processes the response */\n\t\t\tconst performValidation = async (): Promise<CachedValidationResult> => {\n\t\t\t\tconst method = rule.method ?? 'POST';\n\t\t\t\tconst hasBody = method !== 'GET';\n\t\t\t\tlet data: unknown;\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await context.fetch(rule.url, {\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t...(hasBody ? { 'Content-Type': 'application/json' } : {}),\n\t\t\t\t\t\t\t...rule.headers,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...(hasBody ? { body: JSON.stringify(payload) } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tif (!response.ok) throw new Error(`HTTP ${response.status}`);\n\t\t\t\t\tdata = await response.json();\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tthrow new ValidationUnavailable({ cause });\n\t\t\t\t}\n\n\t\t\t\tconst isValid = isValidationSuccessful(data, rule.expectedResponse);\n\t\t\t\tconst cacheResult: CachedValidationResult = {\n\t\t\t\t\tvalid: isValid,\n\t\t\t\t\tmessage: isValid ? undefined : getErrorMessage(data, rule.message),\n\t\t\t\t};\n\n\t\t\t\tif (!rule.disableCache) {\n\t\t\t\t\tasyncValidationCache.set(rule.url, payload, cacheResult, rule.cacheTTL);\n\t\t\t\t}\n\n\t\t\t\treturn cacheResult;\n\t\t\t};\n\n\t\t\t/** Execute validation with optional debouncing based on rule configuration */\n\t\t\tlet result: CachedValidationResult;\n\t\t\tif (rule.debounce && rule.debounce > 0) {\n\t\t\t\tconst outcome = await context.debounceScope.debounce(\n\t\t\t\t\tperformValidation,\n\t\t\t\t\trule.debounce,\n\t\t\t\t\tdebounceKey,\n\t\t\t\t\tJSON.stringify(value),\n\t\t\t\t);\n\t\t\t\tif (outcome.status !== 'completed') throw new ValidationSuperseded();\n\t\t\t\tresult = outcome.value;\n\t\t\t} else {\n\t\t\t\tresult = await performValidation();\n\t\t\t}\n\n\t\t\tif (!result.valid) {\n\t\t\t\thandleValidationFailure(ctx, result.message);\n\t\t\t}\n\t\t}),\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAAA,YAAY,OAAO;AA2BZ,IAAM,YAAY;AAAA,EACxB,SAA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AQ;AAAA,MAClB,OAAO;AACN,iBAAS,MAAM,kBAAkB;AAAA,MAClC;AAEA,UAAI,CAAC,OAAO,OAAO;AAClB,gCAAwB,KAAK,OAAO,OAAO;AAAA,MAC5C;AAAA,IACD,CAAC;AAAA,EACF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/types/define-element.ts
|
|
2
|
+
function defineInput(registration) {
|
|
3
|
+
return { ...registration, kind: "input" };
|
|
4
|
+
}
|
|
5
|
+
function defineStatic(registration) {
|
|
6
|
+
return { ...registration, kind: "static" };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
defineInput,
|
|
11
|
+
defineStatic
|
|
12
|
+
};
|
|
@@ -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,SAAO;AACR;AAGO,SAAS,WAAW,OAAyB;AACnD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AI;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,W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AAQ,YAAU,CAAC,GAAK,WAAS,2EAA2E,CAAC;AAAA,EAC/G,QAAQ;AAAA,EACR,aACE,WAAW,UAAQ,GAAG,IAAI,EAC1B,MAAQ,WAAS,8EAA8E,CAAC;AAAA,EAClG,IACE,WAAW,OAAK,CAAC,QAAQ,UAAU,UAAU,QAAQ,SAAS,CAAC,GAAG,MAAM,EACxE,MAAQ,WAAS,uDAAuD,CAAC;AAAA,EAC3E,oBACE,WAAW,UAAQ,GAAG,IAAI,EAC1B;AAAA,IACE;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACD,GAAG;AACJ,CAAC;AAEM,IAAM,uBAAyB,QAAM;AAAA,EAC3C;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;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
|
+
}
|