@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.
- 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-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-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-6EYX257T.js +23 -0
- package/dist/chunk-6EYX257T.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-A5VLMQAK.js +2780 -0
- package/dist/chunk-A5VLMQAK.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-CANRZY5A.js +87 -0
- package/dist/chunk-CANRZY5A.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-DP7SYLLI.js +206 -0
- package/dist/chunk-DP7SYLLI.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-GQHMU3AR.js +907 -0
- package/dist/chunk-GQHMU3AR.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-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-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-JA5ET6MC.js +550 -0
- package/dist/chunk-JA5ET6MC.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-KH6QWB5Y.js +51 -0
- package/dist/chunk-KH6QWB5Y.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-PCL2KNHC.js +6 -0
- package/dist/chunk-PCL2KNHC.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-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-TSKELYW7.js +55 -0
- package/dist/chunk-TSKELYW7.js.map +7 -0
- package/dist/chunk-U3YHTQHR.js +215 -0
- package/dist/chunk-U3YHTQHR.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-V5H7L5PJ.js +587 -0
- package/dist/chunk-V5H7L5PJ.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-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-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/assert.d.ts +92 -0
- package/dist/testing/assert.js +42 -0
- package/dist/testing/assert.js.map +7 -0
- package/dist/testing/form-state-container-conformance.d.ts +63 -0
- package/dist/testing/form-state-container-conformance.js +44 -0
- package/dist/testing/form-state-container-conformance.js.map +7 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.js +36 -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 +113 -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 +180 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/engine/value-validation.ts"],
|
|
4
|
+
"sourcesContent": ["import { evaluateConstraints } from '../constraints/constraint-evaluator.js';\nimport {\n\texpandContainerParentPaths,\n\texpandFieldTemplatePaths,\n\tgetValueAtPath,\n\twithoutValueAt,\n} from '../lib/path-values.js';\nimport { getElementName, walkNamedElements } from '../lib/field-scope.js';\nimport { frozenCopy } from '../lib/frozen-copy.js';\nimport type { ConstraintLogic } from '../schemas/base-field.js';\nimport {\n\tcreateValidationContext,\n\tcreateZodSchemaFromRules,\n\tgetValidationRulesForElement,\n\tisFieldRequired,\n} from '../schemas/validation/utils.js';\nimport type { BaseValidationRule, RequiredRule } from '../schemas/validation/types.js';\nimport type { ValidationRegistry } from '../schemas/validation/validation-registry.js';\nimport type { DebounceScope } from '../lib/debounce.js';\nimport { REPORTED_TEXT, ValidationSuperseded, ValidationUnavailable } from '../schemas/validation/errors.js';\nimport * as z from 'zod/mini';\n\nexport interface ValidationElement {\n\treadonly name?: string;\n\treadonly id?: string;\n\treadonly elements?: readonly ValidationElement[];\n\treadonly $type?: string;\n\treadonly rules?: readonly BaseValidationRule[];\n\treadonly constraints?: readonly ConstraintLogic[];\n\t/** Authored `disabled`: a disabled field takes no part in validation. */\n\treadonly disabled?: boolean;\n}\nexport type ValidationElementTree = ReadonlyArray<ValidationElement>;\nexport interface ValidationStep {\n\treadonly id?: string;\n\treadonly elements: readonly ValidationElement[];\n\t/** `show` and `hide` constraints on earlier steps' fields: a step they hide is skipped. */\n\treadonly constraints?: readonly ConstraintLogic[];\n}\n\nexport interface EffectiveRulesInput {\n\telement: ValidationElement;\n\tfieldPath: string;\n\tvalues: Record<string, unknown>;\n\tregistry: ValidationRegistry;\n\t/** Set when a `require` constraint of a container around the field holds. */\n\tinheritedRequired?: boolean;\n\t/**\n\t * Whether the field's own `require` constraint holds, when the caller already resolved it in order with {@link resolveParticipation}.\n\t *\n\t * @remarks Evaluated from the field's constraints against `values` when omitted.\n\t */\n\trequiredByConstraint?: boolean;\n}\n\nexport interface ValidateFieldValueInput extends EffectiveRulesInput {\n\tvalue: unknown;\n\t/**\n\t * Keyed async validation state for this caller's form lifetime.\n\t *\n\t * @remarks Required: a fresh scope per call delays debounced rules without coalescing them.\n\t */\n\tdebounceScope: DebounceScope;\n}\n\nexport interface ValidateFormValuesInput {\n\t/** The form's steps: a skipped step's fields take no part, as hidden fields do not. */\n\tsteps: readonly ValidationStep[];\n\tvalues: Record<string, unknown>;\n\tregistry: ValidationRegistry;\n\t/**\n\t * Limits validation to these paths, and to the paths below them unless `exactNames` is set.\n\t *\n\t * @remarks Omitted, every field is validated; an empty list validates nothing, as `validate([])` of the form state container does.\n\t */\n\tnames?: readonly string[];\n\t/** Match `names` as whole paths: a field below a named container is not validated. */\n\texactNames?: boolean;\n\t/** Keyed async validation state for this caller's form lifetime; see `ValidateFieldValueInput`. */\n\tdebounceScope: DebounceScope;\n}\n\n/** Whether a failed rule blocks the form (`error`) or only advises (`warning`). */\nexport type ValidationSeverity = 'error' | 'warning';\n\n/**\n * One rule a value fails, with what a translation needs to say so.\n *\n * @remarks\n * `type` is the rule's `$type`, `ruleId` the author's stable name for that rule and `params` the options its\n * registration exposes (`{ minLength: 8 }`), so a message is composed from the issue and not parsed out of\n * the text. `message` is only the text the author wrote on the rule: the schema library's generic text is\n * never used. A rule reports one issue however many checks its schema runs.\n */\nexport interface ValidationIssue {\n\treadonly type: string;\n\treadonly ruleId?: string;\n\treadonly params?: Readonly<Record<string, unknown>>;\n\treadonly message?: string;\n\treadonly severity: ValidationSeverity;\n}\n\n/**\n * A rule that could not run: its schema could not be built, or it threw while checking the value.\n *\n * @remarks\n * Not a field error. The value is neither valid nor invalid as far as this rule goes, and the cause is\n * the author's or the integration's to fix. `path` and `ruleType` say where; `cause` is what was thrown.\n */\nexport class FormValidationFailure extends Error {\n\treadonly path: string;\n\treadonly ruleType: string;\n\treadonly ruleId?: string;\n\t/** `'unavailable'` when the service the rule asks could not answer, else `'error'`. */\n\treadonly reason: 'unavailable' | 'error';\n\n\tconstructor(path: string, rule: { readonly $type: string; readonly id?: string }, cause: unknown) {\n\t\tconst reason = cause instanceof Error ? cause.message : String(cause);\n\t\tsuper(`Validation rule '${rule.$type}' could not run for '${path}': ${reason}`, { cause });\n\t\tthis.name = 'FormValidationFailure';\n\t\tthis.path = path;\n\t\tthis.ruleType = rule.$type;\n\t\tthis.reason = cause instanceof ValidationUnavailable ? 'unavailable' : 'error';\n\t\tif (rule.id !== undefined) this.ruleId = rule.id;\n\t}\n}\n\n/**\n * What validating one field found: the rules it fails, in rule order, and the rules that could not run.\n *\n * @remarks\n * `superseded` is set when a rule's check was replaced by a later one before it ran: the field was not\n * fully checked, so it is neither valid nor invalid and a caller must not decide on it. It is state, not an issue.\n */\nexport interface FieldValidationResult {\n\treadonly issues: readonly ValidationIssue[];\n\treadonly failures: readonly FormValidationFailure[];\n\treadonly superseded: boolean;\n}\n\n/** What a validation found, by the dotted path of the field; a container has its own entry. Only paths with something to report appear. */\nexport interface FormValidationOutcome {\n\treadonly issues: Readonly<Record<string, readonly ValidationIssue[]>>;\n\treadonly failures: Readonly<Record<string, readonly FormValidationFailure[]>>;\n\t/** The paths a rule of which was replaced by a later check before it ran: not decided either way. */\n\treadonly superseded: readonly string[];\n}\n\ninterface FieldElementPath {\n\treadonly element: ValidationElement;\n\treadonly fieldPath: string;\n\treadonly hasChildren: boolean;\n}\n\nfunction expandContainerTemplatePaths(values: Record<string, unknown>, templatePath: string): string[] {\n\tconst segments = templatePath.split('.');\n\tif (segments.length === 1) {\n\t\treturn [templatePath];\n\t}\n\n\tconst containerName = segments[segments.length - 1];\n\tconst parentPath = segments.slice(0, -1).join('.');\n\tif (!containerName) {\n\t\treturn [templatePath];\n\t}\n\n\treturn expandContainerParentPaths(values, parentPath).map((fieldPath) => `${fieldPath}.${containerName}`);\n}\n\nfunction expandArrayItemPaths(values: Record<string, unknown>, templatePath: string, depth: number): string[] {\n\tlet paths = expandContainerTemplatePaths(values, templatePath);\n\tfor (let level = 0; level < depth; level += 1) {\n\t\tpaths = paths.flatMap((path) => {\n\t\t\tconst value = getValueAtPath<unknown[]>(values, path);\n\t\t\treturn Array.isArray(value) ? Array.from({ length: value.length }, (_, index) => `${path}.${index}`) : [];\n\t\t});\n\t}\n\treturn paths;\n}\n\nfunction pathIsRequested(path: string, names?: readonly string[], exact = false): boolean {\n\tif (!names) {\n\t\treturn true;\n\t}\n\n\treturn names.some((name) => path === name || (!exact && path.startsWith(`${name}.`)));\n}\n\nfunction fieldElementPathsFor(\n\telements: ValidationElementTree,\n\tvalues: Record<string, unknown>,\n\tfallbackToId = false,\n): FieldElementPath[] {\n\treturn walkNamedElements(elements, '', fallbackToId).flatMap(({ path, element, hasChildren, arrayItemDepth }) => {\n\t\tconst paths = arrayItemDepth\n\t\t\t? expandArrayItemPaths(values, path, arrayItemDepth)\n\t\t\t: hasChildren\n\t\t\t\t? expandContainerTemplatePaths(values, path)\n\t\t\t\t: expandFieldTemplatePaths(values, path);\n\t\treturn paths.map((fieldPath) => ({ element, fieldPath, hasChildren }));\n\t});\n}\n\n/**\n * Lists the named paths in a step, expanding field templates for each live array row.\n *\n * @remarks\n * Container paths stay whole so their own rules can be validated, while leaf\n * paths such as `contacts.email` expand to the rendered `contacts.0.email` paths.\n */\nexport function collectStepFieldPaths(\n\tstep: ValidationStep | undefined,\n\tvalues: Record<string, unknown> = {},\n): string[] {\n\tconst paths = fieldElementPathsFor(step?.elements ?? [], values).map(({ fieldPath }) => fieldPath);\n\n\treturn [...new Set(paths)];\n}\n\n/**\n * Resolves authored rules and adds a required rule when a `require` constraint holds.\n *\n * @remarks\n * Constraint references use the rendered path, so each row of an array evaluates\n * against its own sibling values.\n */\nexport function effectiveRulesFor({\n\telement,\n\tfieldPath,\n\tvalues,\n\tregistry,\n\tinheritedRequired = false,\n\trequiredByConstraint,\n}: EffectiveRulesInput): BaseValidationRule[] {\n\tconst rules = getValidationRulesForElement<BaseValidationRule>(element, registry) ?? [];\n\tconst isRequired =\n\t\tisFieldRequired(rules) ||\n\t\tinheritedRequired ||\n\t\t(requiredByConstraint ??\n\t\t\tevaluateConstraints({ constraints: element.constraints, values, fieldPath }).isRequired);\n\n\tif (!isRequired || isFieldRequired(rules)) {\n\t\treturn [...rules];\n\t}\n\n\tconst requiredRule: RequiredRule = { $type: 'required' };\n\treturn [requiredRule, ...rules];\n}\n\n/** What a rule reports when its check was replaced before it ran. */\nconst SUPERSEDED = Symbol('superseded');\n\ntype AuthoredRule = BaseValidationRule & { readonly id?: string; readonly severity?: ValidationSeverity };\n\n/**\n * Validates one field value against each of its rules.\n *\n * @remarks\n * `issues` lists the rules the value fails in rule order, whatever order they finish in, one issue per\n * rule. A rule that cannot run is a failure rather than an issue, and the other rules still report: it\n * says nothing about the value.\n */\nexport async function validateFieldValue({\n\telement,\n\tvalue,\n\tvalues,\n\tfieldPath,\n\tregistry,\n\tdebounceScope,\n\tinheritedRequired,\n\trequiredByConstraint,\n}: ValidateFieldValueInput): Promise<FieldValidationResult> {\n\tconst rules = effectiveRulesFor({\n\t\telement,\n\t\tvalues,\n\t\tfieldPath,\n\t\tregistry,\n\t\tinheritedRequired,\n\t\trequiredByConstraint,\n\t}) as AuthoredRule[];\n\tconst context = createValidationContext({ values, fieldPath, debounceScope });\n\tconst results = await Promise.all(\n\t\trules.map(async (rule): Promise<ValidationIssue | FormValidationFailure | typeof SUPERSEDED | undefined> => {\n\t\t\ttry {\n\t\t\t\tconst result = await z.safeParseAsync(createZodSchemaFromRules([rule], context, registry), value);\n\t\t\t\tif (result.success) return undefined;\n\t\t\t\tconst params = registry.getRuleParams(rule);\n\t\t\t\tconst first = result.error.issues[0];\n\t\t\t\tconst reported = first?.code === 'custom' ? first.params?.[REPORTED_TEXT] : undefined;\n\t\t\t\tconst message = registry.getRuleMessage(rule, typeof reported === 'string' ? reported : undefined);\n\t\t\t\treturn Object.freeze({\n\t\t\t\t\ttype: rule.$type,\n\t\t\t\t\t...(rule.id === undefined ? {} : { ruleId: rule.id }),\n\t\t\t\t\t...(params === undefined ? {} : { params: frozenCopy(params) }),\n\t\t\t\t\t...(message ? { message } : {}),\n\t\t\t\t\tseverity: rule.severity ?? 'error',\n\t\t\t\t});\n\t\t\t} catch (cause) {\n\t\t\t\tif (cause instanceof ValidationSuperseded) return SUPERSEDED;\n\t\t\t\treturn new FormValidationFailure(fieldPath, rule, cause);\n\t\t\t}\n\t\t}),\n\t);\n\treturn {\n\t\tissues: results.filter(\n\t\t\t(found): found is ValidationIssue =>\n\t\t\t\tfound !== undefined && found !== SUPERSEDED && !(found instanceof Error),\n\t\t),\n\t\tfailures: results.filter((found): found is FormValidationFailure => found instanceof FormValidationFailure),\n\t\tsuperseded: results.includes(SUPERSEDED),\n\t};\n}\n\n/** Whether `path` is an excluded path or lies below one. */\nexport const isPathExcluded = (excluded: readonly string[], path: string): boolean =>\n\texcluded.some((around) => path === around || path.startsWith(`${around}.`));\n\n/**\n * What the constraints and the authored `disabled` of one field say, in order, with the value of whatever was excluded before it absent.\n *\n * @remarks `required` is the field's own `require` constraint; the rules' own `required` is not in it. Ancestors are not folded in: see {@link foldFieldParticipation}.\n */\nexport interface FieldParticipation {\n\treadonly hidden: boolean;\n\treadonly disabled: boolean;\n\treadonly required: boolean;\n}\n\n/**\n * What takes part in a form, from its steps and the current values.\n *\n * @remarks\n * `excluded` lists the paths that take no part, each with everything below it. `skippedSteps` lists the ids of\n * the steps its constraints hide, which exclude every field they hold. `fields` has an entry for each rendered\n * path that has a constraint, is disabled by authoring or is held by a skipped step. An element without a name, such as a note\n * with a constraint, is keyed by its id under its parent's path.\n */\nexport interface Participation {\n\treadonly excluded: readonly string[];\n\treadonly skippedSteps: readonly string[];\n\treadonly fields: Readonly<Record<string, FieldParticipation>>;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst NO_FIELD: FieldParticipation = Object.freeze({ hidden: false, disabled: false, required: false });\n\n/**\n * The state of a path with its ancestors folded in: hidden or disabled when it or a path around it is, required when a `require` constraint of it or, for a field, of a container around it holds.\n *\n * @remarks A container's own `required` rule does not pass down; only its `require` constraint does.\n */\nexport function foldFieldParticipation(\n\tfields: Readonly<Record<string, FieldParticipation>>,\n\tpath: string,\n\t{ inheritRequired = true }: { inheritRequired?: boolean } = {},\n): FieldParticipation {\n\tconst segments = path.split('.');\n\tlet hidden = false;\n\tlet disabled = false;\n\tlet required = false;\n\tfor (let depth = 1; depth <= segments.length; depth += 1) {\n\t\tconst at = Object.hasOwn(fields, segments.slice(0, depth).join('.'))\n\t\t\t? fields[segments.slice(0, depth).join('.')]\n\t\t\t: undefined;\n\t\tif (!at) continue;\n\t\thidden ||= at.hidden;\n\t\tdisabled ||= at.disabled;\n\t\tif (depth === segments.length || inheritRequired) required ||= at.required;\n\t}\n\treturn !hidden && !disabled && !required ? NO_FIELD : { hidden, disabled, required };\n}\n\n/**\n * Resolves which steps and paths take part, and what each constraint says, from the config and the current values.\n *\n * @remarks\n * One rule for every consumer of \"does this field count\", and the only place constraints are evaluated for a\n * form. A step a `show` or `hide` constraint hides is skipped and excludes everything it holds. A field a\n * `show` or `hide` constraint hides, and a field that is disabled, whether authored (`disabled`) or by a\n * constraint (`disable`, `enable`), is excluded together with everything below it. Show, disable and require\n * are all read in one ordered pass, against the values with whatever was excluded before absent, so a field\n * cannot stay shown or required because of an answer nobody can give. A constraint that reads a field\n * resolved later sees its value as held. A field inside an excluded container still gets its own state, read against the values from before the container was excluded. An inactive wizard step is not excluded: it is only not rendered.\n *\n * `shownStep` resolves that step as if its constraints held, so its fields get their own states: a renderer that\n * authors every step's fields once, and lets the step's host hide a skipped step, reads those states for the markup\n * of that step only. The result is no verdict on what takes part: the steps after it read the held values of the\n * step, so only that step's fields are meaningful.\n */\nexport function resolveParticipation(\n\tsteps: readonly ValidationStep[],\n\tvalues: Record<string, unknown>,\n\t{ shownStep }: { shownStep?: string } = {},\n): Participation {\n\tlet visible = values;\n\tconst excluded: string[] = [];\n\tconst skippedSteps: string[] = [];\n\tconst fields: Record<string, FieldParticipation> = {};\n\t/** The values as they were when each excluded path was excluded, which what is inside it reads for its own display. */\n\tconst visibleBefore = new Map<string, Record<string, unknown>>();\n\tconst exclude = (path: string) => {\n\t\texcluded.push(path);\n\t\tconst without = withoutValueAt(visible, path);\n\t\tif (isRecord(without)) visible = without;\n\t};\n\tfor (const step of steps) {\n\t\tif (\n\t\t\tstep.constraints?.length &&\n\t\t\tstep.id !== shownStep &&\n\t\t\t!evaluateConstraints({ constraints: step.constraints, values: visible }).shouldShow\n\t\t) {\n\t\t\tif (step.id !== undefined) skippedSteps.push(step.id);\n\t\t\tfor (const element of step.elements) {\n\t\t\t\tconst name = getElementName(element);\n\t\t\t\tif (!name) continue;\n\t\t\t\tfields[name] = { hidden: true, disabled: false, required: false };\n\t\t\t\tvisibleBefore.set(name, visible);\n\t\t\t\texclude(name);\n\t\t\t}\n\t\t\tfor (const { fieldPath } of fieldElementPathsFor(step.elements, values, true)) {\n\t\t\t\tfields[fieldPath] ??= { hidden: true, disabled: false, required: false };\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const { element, fieldPath } of fieldElementPathsFor(step.elements, values, true)) {\n\t\t\tconst authored = element.disabled === true;\n\t\t\tconst root = excluded.find((around) => isPathExcluded([around], fieldPath));\n\t\t\tif (root !== undefined) {\n\t\t\t\tconst before = visibleBefore.get(root) ?? visible;\n\t\t\t\tconst inside = element.constraints?.length\n\t\t\t\t\t? evaluateConstraints({ constraints: element.constraints, values: before, fieldPath })\n\t\t\t\t\t: undefined;\n\t\t\t\tif (authored || inside) {\n\t\t\t\t\tfields[fieldPath] = {\n\t\t\t\t\t\thidden: inside ? !inside.shouldShow : false,\n\t\t\t\t\t\tdisabled: authored || (inside?.shouldDisable ?? false),\n\t\t\t\t\t\trequired: inside?.isRequired ?? false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!authored && !element.constraints?.length) continue;\n\t\t\tconst { shouldShow, shouldDisable, isRequired } = evaluateConstraints({\n\t\t\t\tconstraints: element.constraints,\n\t\t\t\tvalues: visible,\n\t\t\t\tfieldPath,\n\t\t\t});\n\t\t\tfields[fieldPath] = { hidden: !shouldShow, disabled: authored || shouldDisable, required: isRequired };\n\t\t\tif (!shouldShow || authored || shouldDisable) {\n\t\t\t\tvisibleBefore.set(fieldPath, visible);\n\t\t\t\texclude(fieldPath);\n\t\t\t}\n\t\t}\n\t}\n\treturn { excluded: [...new Set(excluded)], skippedSteps, fields };\n}\n\n/** Whether a config has anything that can exclude a path, so a container may skip resolving participation. */\nexport function hasParticipationRules(steps: readonly ValidationStep[]): boolean {\n\treturn steps.some(\n\t\t(step) =>\n\t\t\tBoolean(step.constraints?.length) ||\n\t\t\twalkNamedElements(step.elements, '', true).some(\n\t\t\t\t({ element }) => element.disabled === true || Boolean(element.constraints?.length),\n\t\t\t),\n\t);\n}\n\n/** The fields a validation covers, and the values it was planned over. */\nexport interface ValidationPlan {\n\treadonly fields: readonly PlannedField[];\n\treadonly values: Record<string, unknown>;\n}\n\n/** One field to validate: its element, its rendered path, whether its own `require` constraint holds and whether one of a container around it does. */\nexport interface PlannedField extends FieldElementPath {\n\treadonly requiredByConstraint: boolean;\n\treadonly inheritedRequired: boolean;\n}\n\n/**\n * Lists the fields a validation of `names` covers: the requested paths that take part, expanded over live rows.\n *\n * @remarks\n * A field inside a container (fieldset or array) whose `require` constraint holds is required, at any\n * depth. The container's own `required` rule does not pass down. A planned path is one the validation\n * will report on, so a caller can say which paths are pending before it starts. `participation` is the\n * caller's own {@link resolveParticipation} of the same values, which the container keeps.\n */\nexport function planFormValidation({\n\tsteps,\n\tvalues,\n\tnames,\n\texactNames = false,\n\tparticipation = resolveParticipation(steps, values),\n}: Pick<ValidateFormValuesInput, 'steps' | 'values' | 'names' | 'exactNames'> & {\n\tparticipation?: Participation;\n}): ValidationPlan {\n\tconst { excluded, fields: states } = participation;\n\tconst fields = steps\n\t\t.flatMap((step) => fieldElementPathsFor(step.elements, values))\n\t\t.filter(\n\t\t\t({ fieldPath }) => pathIsRequested(fieldPath, names, exactNames) && !isPathExcluded(excluded, fieldPath),\n\t\t)\n\t\t.map((field) => ({\n\t\t\t...field,\n\t\t\trequiredByConstraint: foldFieldParticipation(states, field.fieldPath, { inheritRequired: false }).required,\n\t\t\tinheritedRequired:\n\t\t\t\t!field.hasChildren &&\n\t\t\t\tfoldFieldParticipation(states, field.fieldPath.split('.').slice(0, -1).join('.')).required,\n\t\t}));\n\treturn { fields, values };\n}\n\n/** Runs a plan: every planned field against its value and rules, in parallel. */\nexport async function runValidationPlan(\n\tplan: ValidationPlan,\n\t{ registry, debounceScope }: Pick<ValidateFormValuesInput, 'registry' | 'debounceScope'>,\n): Promise<FormValidationOutcome> {\n\tconst results = await Promise.all(\n\t\tplan.fields.map(async ({ element, fieldPath, inheritedRequired, requiredByConstraint }) => ({\n\t\t\tfieldPath,\n\t\t\tresult: await validateFieldValue({\n\t\t\t\telement,\n\t\t\t\tvalue: getValueAtPath(plan.values, fieldPath),\n\t\t\t\tvalues: plan.values,\n\t\t\t\tfieldPath,\n\t\t\t\tregistry,\n\t\t\t\tdebounceScope,\n\t\t\t\tinheritedRequired,\n\t\t\t\trequiredByConstraint,\n\t\t\t}),\n\t\t})),\n\t);\n\n\tconst issues: Record<string, readonly ValidationIssue[]> = {};\n\tconst failures: Record<string, readonly FormValidationFailure[]> = {};\n\tconst superseded: string[] = [];\n\tfor (const { fieldPath, result } of results) {\n\t\tif (result.issues.length > 0) issues[fieldPath] = result.issues;\n\t\tif (result.failures.length > 0) failures[fieldPath] = result.failures;\n\t\tif (result.superseded) superseded.push(fieldPath);\n\t}\n\treturn { issues, failures, superseded };\n}\n\n/**\n * Validates named fields and returns what each failed rule reported, by dotted path.\n *\n * @remarks\n * `names` limits validation to matching paths and their descendants, which lets callers validate a\n * wizard step without surfacing errors from later steps; `exactNames` limits it to the named paths\n * themselves. The results are flat so that a container and a row inside it can both fail: `contacts` and\n * `contacts.0.email` are separate keys. Paths that do not take part, see {@link resolveParticipation},\n * are not validated.\n */\nexport async function validateFormValues(input: ValidateFormValuesInput): Promise<FormValidationOutcome> {\n\treturn runValidationPlan(planFormValidation(input), input);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,YAAY,OAAO;AAyFZ,IAAM,wBAAN,cAAoC,MAAM;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EAET,YAAY,MAAc,MAAwD,OAAgB;AACjG,UAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACpE,UAAM,oBAAoB,KAAK,KAAK,wBAAwB,IAAI,MAAM,MAAM,IAAI,EAAE,MAAM,CAAC;AACzF,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW,KAAK;AACrB,SAAK,SAAS,iBAAiB,wBAAwB,gBAAgB;AACvE,QAAI,KAAK,OAAO,OAAW,MAAK,SAAS,KAAK;AAAA,EAC/C;AACD;AA6BA,SAAS,6BAA6B,QAAiC,cAAgC;AACtG,QAAM,WAAW,aAAa,MAAM,GAAG;AACvC,MAAI,SAAS,WAAW,GAAG;AAC1B,WAAO,CAAC,YAAY;AAAA,EACrB;AAEA,QAAM,gBAAgB,SAAS,SAAS,SAAS,CAAC;AAClD,QAAM,aAAa,SAAS,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG;AACjD,MAAI,CAAC,eAAe;AACnB,WAAO,CAAC,YAAY;AAAA,EACrB;AAEA,SAAO,2BAA2B,QAAQ,UAAU,EAAE,IAAI,CAA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UAAU,WAAW;AACvC;AAYA,eAAsB,mBAAmB,OAAgE;AACxG,SAAO,kBAAkB,mBAAmB,KAAK,GAAG,KAAK;AAC1D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RendererStyleSchema,
|
|
3
|
+
StepConstraintSchema
|
|
4
|
+
} from "./chunk-237BHPDH.js";
|
|
5
|
+
|
|
6
|
+
// src/schemas/form-config-shape.ts
|
|
7
|
+
import * as z from "zod/mini";
|
|
8
|
+
import { AppearanceConfigSchema, GridLayoutConfigSchema } from "@schema-engine/layout";
|
|
9
|
+
var TypedConfigEnvelopeSchema = z.looseObject({
|
|
10
|
+
$type: z.string().check(z.minLength(1))
|
|
11
|
+
});
|
|
12
|
+
function createFormStepSchema(parts) {
|
|
13
|
+
return z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
title: z.string(),
|
|
16
|
+
description: z.optional(z.string()),
|
|
17
|
+
icon: z.optional(z.string()),
|
|
18
|
+
elements: z.array(parts.elements),
|
|
19
|
+
constraints: z.optional(z.array(StepConstraintSchema)).check(
|
|
20
|
+
z.describe(
|
|
21
|
+
"Show or hide constraints on fields of earlier steps. A step they hide is skipped: it is passed over and its fields take no part. The first step has none."
|
|
22
|
+
)
|
|
23
|
+
),
|
|
24
|
+
grid: z.optional(z.lazy(() => GridLayoutConfigSchema)).check(z.describe("Grid for this step's fields; replaces the form's grid for the step.")),
|
|
25
|
+
className: z.optional(z.string()),
|
|
26
|
+
style: z.optional(RendererStyleSchema),
|
|
27
|
+
appearance: z.optional(parts.appearance ?? AppearanceConfigSchema),
|
|
28
|
+
actions: z.optional(z.array(z.union([parts.actions, z.array(parts.actions)])))
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function createFormConfigShape(parts) {
|
|
32
|
+
return z.object({
|
|
33
|
+
id: z.string().check(z.describe("Unique identifier for the form")),
|
|
34
|
+
title: z.optional(z.string()).check(z.describe("Display title of the form")),
|
|
35
|
+
description: z.optional(z.string()).check(z.describe("Description of the form purpose")),
|
|
36
|
+
steps: z.array(createFormStepSchema(parts)),
|
|
37
|
+
view: z.optional(parts.view),
|
|
38
|
+
grid: z.optional(z.lazy(() => GridLayoutConfigSchema)),
|
|
39
|
+
validationMode: z._default(z.enum(["onSubmit", "onChange", "onBlur", "onTouched", "all"]), "onSubmit").check(z.describe("When a field validates before a check of it has failed.")),
|
|
40
|
+
reValidateMode: z._default(z.enum(["onSubmit", "onChange", "onBlur"]), "onChange").check(z.describe("When a field validates again once a check of it has run.")),
|
|
41
|
+
navigation: z._default(z.enum(["linear", "free"]), "linear").check(
|
|
42
|
+
z.describe(
|
|
43
|
+
"How freely the stepper moves forward: 'linear' reaches only visited steps and validates the steps on the way, 'free' reaches any step without validating."
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
payload: z.optional(z.record(z.string(), z.unknown())).check(
|
|
47
|
+
z.describe(
|
|
48
|
+
"Serializable data that always travels with a submission, such as ids or context. It is never rendered or validated, and a key cannot name a field."
|
|
49
|
+
)
|
|
50
|
+
),
|
|
51
|
+
className: z.optional(z.string()),
|
|
52
|
+
style: z.optional(RendererStyleSchema),
|
|
53
|
+
appearance: z.optional(parts.appearance ?? AppearanceConfigSchema),
|
|
54
|
+
actions: z.optional(z.array(z.union([parts.actions, z.array(parts.actions)])))
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
TypedConfigEnvelopeSchema,
|
|
60
|
+
createFormStepSchema,
|
|
61
|
+
createFormConfigShape
|
|
62
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/schemas/form-config-shape.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/mini';\nimport { RendererStyleSchema, StepConstraintSchema } from './base-field';\nimport { AppearanceConfigSchema, GridLayoutConfigSchema } from '@schema-engine/layout';\n\n/**\n * Envelope for a registered config object. Per-item Standard Schema validation\n * runs after this parse, keyed by `$type`.\n */\nexport const TypedConfigEnvelopeSchema = z.looseObject({\n\t$type: z.string().check(z.minLength(1)),\n});\n\nexport function createFormStepSchema<TAppearance extends z.ZodMiniType = typeof AppearanceConfigSchema>(parts: {\n\telements: z.ZodMiniType;\n\tactions: z.ZodMiniType;\n\tappearance?: TAppearance;\n}) {\n\treturn z.object({\n\t\tid: z.string(),\n\t\ttitle: z.string(),\n\t\tdescription: z.optional(z.string()),\n\t\ticon: z.optional(z.string()),\n\t\telements: z.array(parts.elements),\n\t\tconstraints: z\n\t\t\t.optional(z.array(StepConstraintSchema))\n\t\t\t.check(\n\t\t\t\tz.describe(\n\t\t\t\t\t'Show or hide constraints on fields of earlier steps. A step they hide is skipped: it is passed over and its fields take no part. The first step has none.',\n\t\t\t\t),\n\t\t\t),\n\t\tgrid: z\n\t\t\t.optional(z.lazy(() => GridLayoutConfigSchema))\n\t\t\t.check(z.describe(\"Grid for this step's fields; replaces the form's grid for the step.\")),\n\t\tclassName: z.optional(z.string()),\n\t\tstyle: z.optional(RendererStyleSchema),\n\t\tappearance: z.optional((parts.appearance ?? AppearanceConfigSchema) as TAppearance),\n\t\tactions: z.optional(z.array(z.union([parts.actions, z.array(parts.actions)]))),\n\t});\n}\n\n/**\n * Shared form JSON shape. Element, action, and view slots are injected by\n * callers so envelope validation, authoring schema export, and the public\n * FormConfigSchema stay aligned.\n *\n * @remarks `appearance` is the schema of a pick on the form and its steps. It defaults to an open\n * record of axis names to values; an engine passes the schema of its theme's axes, so the JSON\n * Schema export lists them.\n */\nexport function createFormConfigShape<TAppearance extends z.ZodMiniType = typeof AppearanceConfigSchema>(parts: {\n\telements: z.ZodMiniType;\n\tview: z.ZodMiniType;\n\tactions: z.ZodMiniType;\n\tappearance?: TAppearance;\n}) {\n\treturn z.object({\n\t\tid: z.string().check(z.describe('Unique identifier for the form')),\n\t\ttitle: z.optional(z.string()).check(z.describe('Display title of the form')),\n\t\tdescription: z.optional(z.string()).check(z.describe('Description of the form purpose')),\n\t\tsteps: z.array(createFormStepSchema(parts)),\n\t\tview: z.optional(parts.view),\n\t\tgrid: z.optional(z.lazy(() => GridLayoutConfigSchema)),\n\t\tvalidationMode: z\n\t\t\t._default(z.enum(['onSubmit', 'onChange', 'onBlur', 'onTouched', 'all']), 'onSubmit')\n\t\t\t.check(z.describe('When a field validates before a check of it has failed.')),\n\t\treValidateMode: z\n\t\t\t._default(z.enum(['onSubmit', 'onChange', 'onBlur']), 'onChange')\n\t\t\t.check(z.describe('When a field validates again once a check of it has run.')),\n\t\tnavigation: z\n\t\t\t._default(z.enum(['linear', 'free']), 'linear')\n\t\t\t.check(\n\t\t\t\tz.describe(\n\t\t\t\t\t\"How freely the stepper moves forward: 'linear' reaches only visited steps and validates the steps on the way, 'free' reaches any step without validating.\",\n\t\t\t\t),\n\t\t\t),\n\t\tpayload: z\n\t\t\t.optional(z.record(z.string(), z.unknown()))\n\t\t\t.check(\n\t\t\t\tz.describe(\n\t\t\t\t\t'Serializable data that always travels with a submission, such as ids or context. It is never rendered or validated, and a key cannot name a field.',\n\t\t\t\t),\n\t\t\t),\n\t\tclassName: z.optional(z.string()),\n\t\tstyle: z.optional(RendererStyleSchema),\n\t\tappearance: z.optional((parts.appearance ?? AppearanceConfigSchema) as TAppearance),\n\t\tactions: z.optional(z.array(z.union([parts.actions, z.array(parts.actions)]))),\n\t});\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;AAAA,YAAY,OAAO;AAEnB,SAAS,wBAAwB,8BAA8B;AAMxD,IAAM,4BAA8B,cAAY;AAAA,EACtD,OAAS,SAAO,EAAE,MAAQ,YAAU,CAAC,CAAC;AACvC,CAAC;AAEM,SAAS,qBAAwF,OAIrG;AACF,SAAS,SAAO;AAAA,IACf,IAAM,SAAO;AAAA,IACb,OAAS,SAAO;AAAA,IAChB,aAAe,WAAW,SAAO,CAAC;AAAA,IAClC,MAAQ,WAAW,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AAC,CAAC,EAC1C;AAAA,MACE;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACD,WAAa,WAAW,SAAO,CAAC;AAAA,IAChC,OAAS,WAAS,mBAAmB;AAAA,IACrC,YAAc,WAAU,MAAM,cAAc,sBAAsC;AAAA,IAClF,SAAW,WAAW,QAAQ,QAAM,CAAC,MAAM,SAAW,QAAM,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;AAAA,EAC9E,CAAC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// src/schemas/validation/presets.ts
|
|
2
|
+
var ValidationPresets = {
|
|
3
|
+
string: {
|
|
4
|
+
required: (message) => ({ $type: "required", message }),
|
|
5
|
+
email: (message) => ({
|
|
6
|
+
$type: "email",
|
|
7
|
+
message
|
|
8
|
+
}),
|
|
9
|
+
minLength: (value, message) => ({
|
|
10
|
+
$type: "minLength",
|
|
11
|
+
value,
|
|
12
|
+
message
|
|
13
|
+
}),
|
|
14
|
+
maxLength: (value, message) => ({
|
|
15
|
+
$type: "maxLength",
|
|
16
|
+
value,
|
|
17
|
+
message
|
|
18
|
+
}),
|
|
19
|
+
pattern: (pattern, message) => ({
|
|
20
|
+
$type: "pattern",
|
|
21
|
+
value: pattern,
|
|
22
|
+
message
|
|
23
|
+
}),
|
|
24
|
+
url: (message) => ({ $type: "url", message }),
|
|
25
|
+
uuid: (message) => ({ $type: "uuid", message }),
|
|
26
|
+
uuidv4: (message) => ({
|
|
27
|
+
$type: "uuid",
|
|
28
|
+
version: "v4",
|
|
29
|
+
message
|
|
30
|
+
}),
|
|
31
|
+
cuid: (message) => ({ $type: "cuid", message }),
|
|
32
|
+
cuid2: (message) => ({ $type: "cuid2", message }),
|
|
33
|
+
ulid: (message) => ({ $type: "ulid", message }),
|
|
34
|
+
hex: (message) => ({ $type: "hex", message })
|
|
35
|
+
},
|
|
36
|
+
number: {
|
|
37
|
+
required: (message) => ({ $type: "required", message }),
|
|
38
|
+
min: (value, message) => ({
|
|
39
|
+
$type: "min",
|
|
40
|
+
value,
|
|
41
|
+
message
|
|
42
|
+
}),
|
|
43
|
+
max: (value, message) => ({
|
|
44
|
+
$type: "max",
|
|
45
|
+
value,
|
|
46
|
+
message
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
boolean: {
|
|
50
|
+
required: (message) => ({ $type: "required", message })
|
|
51
|
+
},
|
|
52
|
+
array: {
|
|
53
|
+
required: (message) => ({ $type: "required", message }),
|
|
54
|
+
minItems: (value, message) => ({
|
|
55
|
+
$type: "minItems",
|
|
56
|
+
value,
|
|
57
|
+
message
|
|
58
|
+
}),
|
|
59
|
+
maxItems: (value, message) => ({
|
|
60
|
+
$type: "maxItems",
|
|
61
|
+
value,
|
|
62
|
+
message
|
|
63
|
+
}),
|
|
64
|
+
nonEmpty: (message) => ({
|
|
65
|
+
$type: "minItems",
|
|
66
|
+
value: 1,
|
|
67
|
+
message
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
network: {
|
|
71
|
+
ipv4: (message) => ({
|
|
72
|
+
$type: "ipv4",
|
|
73
|
+
message
|
|
74
|
+
}),
|
|
75
|
+
ipv6: (message) => ({
|
|
76
|
+
$type: "ipv6",
|
|
77
|
+
message
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
date: {
|
|
81
|
+
datetime: (message) => ({
|
|
82
|
+
$type: "datetime",
|
|
83
|
+
message
|
|
84
|
+
}),
|
|
85
|
+
date: (message) => ({
|
|
86
|
+
$type: "date",
|
|
87
|
+
message
|
|
88
|
+
}),
|
|
89
|
+
time: (message) => ({
|
|
90
|
+
$type: "time",
|
|
91
|
+
message
|
|
92
|
+
})
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Authoring sugar over the generic `relate` rule.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* Each returns a plain rule object, so a form authored in TypeScript and one
|
|
99
|
+
* round-tripped through JSON produce the same configuration. References
|
|
100
|
+
* resolve relative to the field declaring the rule.
|
|
101
|
+
*/
|
|
102
|
+
relate: {
|
|
103
|
+
matches: (field, message) => ({
|
|
104
|
+
$type: "relate",
|
|
105
|
+
fields: [field],
|
|
106
|
+
assert: "allEqual",
|
|
107
|
+
includeSelf: true,
|
|
108
|
+
as: "auto",
|
|
109
|
+
skipWhenIncomplete: true,
|
|
110
|
+
message
|
|
111
|
+
}),
|
|
112
|
+
after: (field, message) => ({
|
|
113
|
+
$type: "relate",
|
|
114
|
+
fields: [field],
|
|
115
|
+
assert: "descending",
|
|
116
|
+
includeSelf: true,
|
|
117
|
+
as: "date",
|
|
118
|
+
skipWhenIncomplete: true,
|
|
119
|
+
message
|
|
120
|
+
}),
|
|
121
|
+
before: (field, message) => ({
|
|
122
|
+
$type: "relate",
|
|
123
|
+
fields: [field],
|
|
124
|
+
assert: "ascending",
|
|
125
|
+
includeSelf: true,
|
|
126
|
+
as: "date",
|
|
127
|
+
skipWhenIncomplete: true,
|
|
128
|
+
message
|
|
129
|
+
}),
|
|
130
|
+
atLeastOneOf: (fields, message) => ({
|
|
131
|
+
$type: "relate",
|
|
132
|
+
fields,
|
|
133
|
+
assert: "atLeastOne",
|
|
134
|
+
includeSelf: false,
|
|
135
|
+
as: "auto",
|
|
136
|
+
skipWhenIncomplete: true,
|
|
137
|
+
message
|
|
138
|
+
}),
|
|
139
|
+
mutuallyExclusive: (fields, message) => ({
|
|
140
|
+
$type: "relate",
|
|
141
|
+
fields,
|
|
142
|
+
assert: "exactlyOne",
|
|
143
|
+
includeSelf: false,
|
|
144
|
+
as: "auto",
|
|
145
|
+
skipWhenIncomplete: true,
|
|
146
|
+
message
|
|
147
|
+
}),
|
|
148
|
+
allOrNone: (fields, message) => ({
|
|
149
|
+
$type: "relate",
|
|
150
|
+
fields,
|
|
151
|
+
assert: "allOrNone",
|
|
152
|
+
includeSelf: false,
|
|
153
|
+
as: "auto",
|
|
154
|
+
skipWhenIncomplete: true,
|
|
155
|
+
message
|
|
156
|
+
})
|
|
157
|
+
},
|
|
158
|
+
custom: {
|
|
159
|
+
async: (url, options) => ({
|
|
160
|
+
$type: "async",
|
|
161
|
+
url,
|
|
162
|
+
method: options?.method || "POST",
|
|
163
|
+
headers: options?.headers,
|
|
164
|
+
extraPayload: options?.extraPayload,
|
|
165
|
+
expectedResponse: options?.expectedResponse,
|
|
166
|
+
message: options?.message,
|
|
167
|
+
dependencies: options?.dependencies
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export {
|
|
173
|
+
ValidationPresets
|
|
174
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/schemas/validation/presets.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n\tAsyncRule,\n\tCuid2Rule,\n\tCuidRule,\n\tDateRule,\n\tDateTimeRule,\n\tEmailRule,\n\tHexRule,\n\tIpv4Rule,\n\tIpv6Rule,\n\tMaxItemsRule,\n\tMaxLengthRule,\n\tMaxRule,\n\tMinItemsRule,\n\tMinLengthRule,\n\tMinRule,\n\tPatternRule,\n\tRelateRule,\n\tRequiredRule,\n\tTimeRule,\n\tUlidRule,\n\tUrlRule,\n\tUuidRule,\n} from './types.js';\n\nexport const ValidationPresets = {\n\tstring: {\n\t\trequired: (message?: string): RequiredRule => ({ $type: 'required', message }),\n\t\temail: (message?: string): EmailRule => ({\n\t\t\t$type: 'email',\n\t\t\tmessage,\n\t\t}),\n\t\tminLength: (value: number, message?: string): MinLengthRule => ({\n\t\t\t$type: 'minLength',\n\t\t\tvalue,\n\t\t\tmessage,\n\t\t}),\n\t\tmaxLength: (value: number, message?: string): MaxLengthRule => ({\n\t\t\t$type: 'maxLength',\n\t\t\tvalue,\n\t\t\tmessage,\n\t\t}),\n\t\tpattern: (pattern: string, message?: string): PatternRule => ({\n\t\t\t$type: 'pattern',\n\t\t\tvalue: pattern,\n\t\t\tmessage,\n\t\t}),\n\t\turl: (message?: string): UrlRule => ({ $type: 'url', message }),\n\t\tuuid: (message?: string): UuidRule => ({ $type: 'uuid', message }),\n\t\tuuidv4: (message?: string): UuidRule => ({\n\t\t\t$type: 'uuid',\n\t\t\tversion: 'v4',\n\t\t\tmessage,\n\t\t}),\n\t\tcuid: (message?: string): CuidRule => ({ $type: 'cuid', message }),\n\t\tcuid2: (message?: string): Cuid2Rule => ({ $type: 'cuid2', message }),\n\t\tulid: (message?: string): UlidRule => ({ $type: 'ulid', message }),\n\t\thex: (message?: string): HexRule => ({ $type: 'hex', message }),\n\t},\n\tnumber: {\n\t\trequired: (message?: string): RequiredRule => ({ $type: 'required', message }),\n\t\tmin: (value: number, message?: string): MinRule => ({\n\t\t\t$type: 'min',\n\t\t\tvalue,\n\t\t\tmessage,\n\t\t}),\n\t\tmax: (value: number, message?: string): MaxRule => ({\n\t\t\t$type: 'max',\n\t\t\tvalue,\n\t\t\tmessage,\n\t\t}),\n\t},\n\tboolean: {\n\t\trequired: (message?: string): RequiredRule => ({ $type: 'required', message }),\n\t},\n\tarray: {\n\t\trequired: (message?: string): RequiredRule => ({ $type: 'required', message }),\n\t\tminItems: (value: number, message?: string): MinItemsRule => ({\n\t\t\t$type: 'minItems',\n\t\t\tvalue,\n\t\t\tmessage,\n\t\t}),\n\t\tmaxItems: (value: number, message?: string): MaxItemsRule => ({\n\t\t\t$type: 'maxItems',\n\t\t\tvalue,\n\t\t\tmessage,\n\t\t}),\n\t\tnonEmpty: (message?: string): MinItemsRule => ({\n\t\t\t$type: 'minItems',\n\t\t\tvalue: 1,\n\t\t\tmessage,\n\t\t}),\n\t},\n\tnetwork: {\n\t\tipv4: (message?: string): Ipv4Rule => ({\n\t\t\t$type: 'ipv4',\n\t\t\tmessage,\n\t\t}),\n\t\tipv6: (message?: string): Ipv6Rule => ({\n\t\t\t$type: 'ipv6',\n\t\t\tmessage,\n\t\t}),\n\t},\n\tdate: {\n\t\tdatetime: (message?: string): DateTimeRule => ({\n\t\t\t$type: 'datetime',\n\t\t\tmessage,\n\t\t}),\n\t\tdate: (message?: string): DateRule => ({\n\t\t\t$type: 'date',\n\t\t\tmessage,\n\t\t}),\n\t\ttime: (message?: string): TimeRule => ({\n\t\t\t$type: 'time',\n\t\t\tmessage,\n\t\t}),\n\t},\n\t/**\n\t * Authoring sugar over the generic `relate` rule.\n\t *\n\t * @remarks\n\t * Each returns a plain rule object, so a form authored in TypeScript and one\n\t * round-tripped through JSON produce the same configuration. References\n\t * resolve relative to the field declaring the rule.\n\t */\n\trelate: {\n\t\tmatches: (field: string, message?: string): RelateRule => ({\n\t\t\t$type: 'relate',\n\t\t\tfields: [field],\n\t\t\tassert: 'allEqual',\n\t\t\tincludeSelf: true,\n\t\t\tas: 'auto',\n\t\t\tskipWhenIncomplete: true,\n\t\t\tmessage,\n\t\t}),\n\t\tafter: (field: string, message?: string): RelateRule => ({\n\t\t\t$type: 'relate',\n\t\t\tfields: [field],\n\t\t\tassert: 'descending',\n\t\t\tincludeSelf: true,\n\t\t\tas: 'date',\n\t\t\tskipWhenIncomplete: true,\n\t\t\tmessage,\n\t\t}),\n\t\tbefore: (field: string, message?: string): RelateRule => ({\n\t\t\t$type: 'relate',\n\t\t\tfields: [field],\n\t\t\tassert: 'ascending',\n\t\t\tincludeSelf: true,\n\t\t\tas: 'date',\n\t\t\tskipWhenIncomplete: true,\n\t\t\tmessage,\n\t\t}),\n\t\tatLeastOneOf: (fields: string[], message?: string): RelateRule => ({\n\t\t\t$type: 'relate',\n\t\t\tfields,\n\t\t\tassert: 'atLeastOne',\n\t\t\tincludeSelf: false,\n\t\t\tas: 'auto',\n\t\t\tskipWhenIncomplete: true,\n\t\t\tmessage,\n\t\t}),\n\t\tmutuallyExclusive: (fields: string[], message?: string): RelateRule => ({\n\t\t\t$type: 'relate',\n\t\t\tfields,\n\t\t\tassert: 'exactlyOne',\n\t\t\tincludeSelf: false,\n\t\t\tas: 'auto',\n\t\t\tskipWhenIncomplete: true,\n\t\t\tmessage,\n\t\t}),\n\t\tallOrNone: (fields: string[], message?: string): RelateRule => ({\n\t\t\t$type: 'relate',\n\t\t\tfields,\n\t\t\tassert: 'allOrNone',\n\t\t\tincludeSelf: false,\n\t\t\tas: 'auto',\n\t\t\tskipWhenIncomplete: true,\n\t\t\tmessage,\n\t\t}),\n\t},\n\tcustom: {\n\t\tasync: (\n\t\t\turl: string,\n\t\t\toptions?: {\n\t\t\t\tmethod?: NonNullable<AsyncRule['method']>;\n\t\t\t\theaders?: AsyncRule['headers'];\n\t\t\t\textraPayload?: AsyncRule['extraPayload'];\n\t\t\t\texpectedResponse?: AsyncRule['expectedResponse'];\n\t\t\t\tmessage?: string;\n\t\t\t\tdependencies?: string[];\n\t\t\t},\n\t\t): AsyncRule => ({\n\t\t\t$type: 'async',\n\t\t\turl,\n\t\t\tmethod: options?.method || 'POST',\n\t\t\theaders: options?.headers,\n\t\t\textraPayload: options?.extraPayload,\n\t\t\texpectedResponse: options?.expectedResponse,\n\t\t\tmessage: options?.message,\n\t\t\tdependencies: options?.dependencies,\n\t\t}),\n\t},\n} as const;\n"],
|
|
5
|
+
"mappings": ";AAyBO,IAAM,oBAAoB;AAAA,EAChC,QAAQ;AAAA,IACP,UAAU,CAAC,aAAoC,EAAE,OAAO,YAAY,QAAQ;AAAA,IAC5E,OAAO,CAAC,aAAiC;AAAA,MACxC,OAAO;AAAA,MACP;AAAA,IACD;AAAA,IACA,WAAW,CAAC,OAAe,aAAqC;AAAA,MAC/D,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IACD;AAAA,IACA,WAAW,CAAC,OAAe,aAAqC;AAAA,MAC/D,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IACD;AAAA,IACA,SAAS,CAAC,SAAiB,aAAmC;AAAA,MAC7D,OAAO;AAAA,MACP,OAAO;AAAA,MACP;AAAA,IACD;AAAA,IACA,KAAK,CAAC,aAA+B,EAAE,OAAO,OAAO,QAAQ;AAAA,IAC7D,MAAM,CAAC,aAA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MACA,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,IAAI;AAAA,MACJ,oBAAoB;AAAA,MACpB;AAAA,IACD;AAAA,EACD;AAAA,EACA,QAAQ;AAAA,IACP,OAAO,CACN,KACA,aAQgB;AAAA,MAChB,OAAO;AAAA,MACP;AAAA,MACA,QAAQ,SAAS,UAAU;AAAA,MAC3B,SAAS,SAAS;AAAA,MAClB,cAAc,SAAS;AAAA,MACvB,kBAAkB,SAAS;AAAA,MAC3B,SAAS,SAAS;AAAA,MAClB,cAAc,SAAS;AAAA,IACxB;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/lib/standard-schema.ts
|
|
2
|
+
import { safeParseStandardSchema } from "@schema-engine/registry";
|
|
3
|
+
function parseStandardSchema(schema, value) {
|
|
4
|
+
const result = safeParseStandardSchema(schema, value);
|
|
5
|
+
if (!result.success) {
|
|
6
|
+
const message = result.error.issues[0]?.message ?? "Validation failed";
|
|
7
|
+
throw new Error(message);
|
|
8
|
+
}
|
|
9
|
+
return result.data;
|
|
10
|
+
}
|
|
11
|
+
function validateRegistrationConfig(schema, config) {
|
|
12
|
+
const result = safeParseStandardSchema(schema, config);
|
|
13
|
+
if (!result.success) {
|
|
14
|
+
throw new Error(result.error.issues.map((issue) => issue.message).join(", "));
|
|
15
|
+
}
|
|
16
|
+
return result.data;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
parseStandardSchema,
|
|
21
|
+
validateRegistrationConfig
|
|
22
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/standard-schema.ts"],
|
|
4
|
+
"sourcesContent": ["import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { safeParseStandardSchema } from '@schema-engine/registry';\n\n/**\n * Validate `value` with a Standard Schema and return parsed data.\n *\n * @param schema - Any `StandardSchemaV1` implementation (for example, a Zod Mini, Valibot, or Effect Schema schema)\n * @param value - Input to validate\n * @returns Parsed output typed as `T`\n * @throws {Error} When validation fails or the schema returns async validation\n */\nexport function parseStandardSchema<TInput, TOutput>(\n\tschema: StandardSchemaV1<TInput, TOutput>,\n\tvalue: TInput,\n): TOutput {\n\tconst result = safeParseStandardSchema(schema, value);\n\tif (!result.success) {\n\t\tconst message = result.error.issues[0]?.message ?? 'Validation failed';\n\t\tthrow new Error(message);\n\t}\n\treturn result.data;\n}\n\n/**\n * Validate a registration config object against its registration schema.\n *\n * @param schema - Schema from `BaseRegistration.schema`\n * @param config - Config object; callers typically set `$type` before validating\n * @returns Parsed config typed as `T`\n * @throws {Error} Joined issue messages when validation fails\n */\nexport function validateRegistrationConfig<TInput, TOutput>(\n\tschema: StandardSchemaV1<TInput, TOutput>,\n\tconfig: TInput,\n): TOutput {\n\tconst result = safeParseStandardSchema(schema, config);\n\tif (!result.success) {\n\t\tthrow new Error(result.error.issues.map((issue) => issue.message).join(', '));\n\t}\n\treturn result.data;\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,+BAA+B;AAUjC,SAAS,oBACf,QACA,OACU;AACV,QAAM,SAAS,wBAAwB,QAAQ,KAAK;AACpD,MAAI,CAAC,OAAO,SAAS;AACpB,UAAM,UAAU,OAAO,MAAM,OAAO,CAAC,GAAG,WAAW;AACnD,UAAM,IAAI,MAAM,OAAO;AAAA,EACxB;AACA,SAAO,OAAO;AACf;AAUO,SAAS,2BACf,QACA,QACU;AACV,QAAM,SAAS,wBAAwB,QAAQ,MAAM;AACrD,MAAI,CAAC,OAAO,SAAS;AACpB,UAAM,IAAI,MAAM,OAAO,MAAM,OAAO,IAAI,CAAC,UAAU,MAAM,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,EAC7E;AACA,SAAO,OAAO;AACf;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/lib/field-ref.ts
|
|
2
|
+
function resolveFieldRef(fieldRef, fieldPath) {
|
|
3
|
+
if (!fieldPath || fieldRef.includes(".")) {
|
|
4
|
+
return fieldRef;
|
|
5
|
+
}
|
|
6
|
+
const parts = fieldPath.split(".");
|
|
7
|
+
const last = parts[parts.length - 1];
|
|
8
|
+
if (!Number.isNaN(Number(last))) {
|
|
9
|
+
return `${fieldPath}.${fieldRef}`;
|
|
10
|
+
}
|
|
11
|
+
parts.pop();
|
|
12
|
+
const parentPath = parts.join(".");
|
|
13
|
+
return parentPath ? `${parentPath}.${fieldRef}` : fieldRef;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
resolveFieldRef
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/field-ref.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Resolves a field reference written on `fieldPath` to an absolute value path.\n *\n * @remarks\n * A bare name is a sibling: `accountType` written on `contacts.0.email` resolves\n * to `contacts.0.accountType`, and on `address.street` to `address.accountType`.\n * A reference that already contains a dot is absolute from the form root, so\n * `billing.country` means the same field wherever it is written.\n *\n * Constraints and cross-field validation ask the same question of an authored\n * name, so they share one answer here; two implementations drifted once already.\n */\nexport function resolveFieldRef(fieldRef: string, fieldPath?: string): string {\n\tif (!fieldPath || fieldRef.includes('.')) {\n\t\treturn fieldRef;\n\t}\n\n\tconst parts = fieldPath.split('.');\n\tconst last = parts[parts.length - 1];\n\tif (!Number.isNaN(Number(last))) {\n\t\treturn `${fieldPath}.${fieldRef}`;\n\t}\n\n\tparts.pop();\n\tconst parentPath = parts.join('.');\n\treturn parentPath ? `${parentPath}.${fieldRef}` : fieldRef;\n}\n"],
|
|
5
|
+
"mappings": ";AAYO,SAAS,gBAAgB,UAAkB,WAA4B;AAC7E,MAAI,CAAC,aAAa,SAAS,SAAS,GAAG,GAAG;AACzC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,UAAU,MAAM,GAAG;AACjC,QAAM,OAAO,MAAM,MAAM,SAAS,CAAC;AACnC,MAAI,CAAC,OAAO,MAAM,OAAO,IAAI,CAAC,GAAG;AAChC,WAAO,GAAG,SAAS,IAAI,QAAQ;AAAA,EAChC;AAEA,QAAM,IAAI;AACV,QAAM,aAAa,MAAM,KAAK,GAAG;AACjC,SAAO,aAAa,GAAG,UAAU,IAAI,QAAQ,KAAK;AACnD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRecord,
|
|
3
|
+
issueAt
|
|
4
|
+
} from "./chunk-LMWJAD3B.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/validate-form/grid-checks.ts
|
|
7
|
+
import {
|
|
8
|
+
areaNames,
|
|
9
|
+
areaTemplateIssues,
|
|
10
|
+
cascadeValues,
|
|
11
|
+
elementAreaSlots,
|
|
12
|
+
elementHiddenSlots,
|
|
13
|
+
elementGridKeys,
|
|
14
|
+
elementUsesGridWidths,
|
|
15
|
+
GRID_TEMPLATE_KEYS,
|
|
16
|
+
gridAreaTemplates,
|
|
17
|
+
gridUsesAreas,
|
|
18
|
+
namedPlacementOverflow,
|
|
19
|
+
WIDTH_TRACKS
|
|
20
|
+
} from "@schema-engine/layout";
|
|
21
|
+
function gridKeyPath(grid, keys, slot) {
|
|
22
|
+
if (!isRecord(grid)) return void 0;
|
|
23
|
+
const entries = [
|
|
24
|
+
{ slot: "default", prefix: [], entry: grid }
|
|
25
|
+
];
|
|
26
|
+
if (isRecord(grid.responsive)) {
|
|
27
|
+
for (const [name, entry] of Object.entries(grid.responsive)) {
|
|
28
|
+
entries.push({ slot: name, prefix: ["responsive", name], entry });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const { slot: entrySlot, prefix, entry } of entries) {
|
|
32
|
+
if (slot !== void 0 && entrySlot !== slot || !isRecord(entry)) continue;
|
|
33
|
+
const key = keys.find((name) => entry[name] !== void 0);
|
|
34
|
+
if (key !== void 0) return [...prefix, key];
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
function elementGridKeyPath(item, keys, slot) {
|
|
39
|
+
const path = gridKeyPath(item.grid, keys, slot);
|
|
40
|
+
return path ? ["grid", ...path] : ["grid"];
|
|
41
|
+
}
|
|
42
|
+
function areasPath(grid, slot) {
|
|
43
|
+
return Array.isArray(grid?.areas) ? ["areas"] : ["areas", slot];
|
|
44
|
+
}
|
|
45
|
+
function elementLabel(item) {
|
|
46
|
+
if (typeof item.name === "string") return `Field '${item.name}'`;
|
|
47
|
+
return typeof item.id === "string" ? `Element '${item.id}'` : "Element";
|
|
48
|
+
}
|
|
49
|
+
var AREA_EXCLUSIVE_KEYS = ["width", "offset", "column", "row"];
|
|
50
|
+
function quotedKeys(keys) {
|
|
51
|
+
return keys.map((key) => `'${key}'`).join(" and ");
|
|
52
|
+
}
|
|
53
|
+
function namedPlacementIssue(item) {
|
|
54
|
+
const keys = elementGridKeys(item);
|
|
55
|
+
const named = ["width", "offset"].filter((key) => keys.has(key));
|
|
56
|
+
if (named.length === 0) return void 0;
|
|
57
|
+
const label = elementLabel(item);
|
|
58
|
+
if (keys.has("column")) {
|
|
59
|
+
return issueAt(
|
|
60
|
+
elementGridKeyPath(item, ["column"]),
|
|
61
|
+
`${label} sets grid ${quotedKeys(named)} and 'column'; use named widths or a raw column, not both.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const overflow = namedPlacementOverflow(item);
|
|
65
|
+
if (overflow) {
|
|
66
|
+
return issueAt(
|
|
67
|
+
elementGridKeyPath(item, ["width", "offset"], overflow.slot),
|
|
68
|
+
`${label} sets grid 'width' and 'offset' that span ${overflow.tracks} of ${WIDTH_TRACKS} tracks at ${overflow.slot === "default" ? "default" : `'${overflow.slot}'`}; together they must fit in ${WIDTH_TRACKS} tracks.`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
function atSlot(slot) {
|
|
74
|
+
return slot === "default" ? "" : ` at '${slot}'`;
|
|
75
|
+
}
|
|
76
|
+
function areaPlacementIssue(item, nested) {
|
|
77
|
+
const keys = elementGridKeys(item);
|
|
78
|
+
if (!keys.has("area")) return void 0;
|
|
79
|
+
const label = elementLabel(item);
|
|
80
|
+
if (nested) {
|
|
81
|
+
return issueAt(
|
|
82
|
+
elementGridKeyPath(item, ["area"]),
|
|
83
|
+
`${label} sets grid 'area' inside a container; a container lays its children out without areas.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const others = AREA_EXCLUSIVE_KEYS.filter((key) => keys.has(key));
|
|
87
|
+
if (others.length === 0) return void 0;
|
|
88
|
+
return issueAt(
|
|
89
|
+
elementGridKeyPath(item, others),
|
|
90
|
+
`${label} sets grid ${quotedKeys(["area", ...others])}; use an area or a width, offset or raw line, not both.`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function templateTrackKeys(grid) {
|
|
94
|
+
const entries = [grid, ...Object.values(grid?.responsive ?? {})];
|
|
95
|
+
return GRID_TEMPLATE_KEYS.filter((key) => entries.some((entry) => entry?.[key] !== void 0));
|
|
96
|
+
}
|
|
97
|
+
function templateIssues(label, grid, gridPath) {
|
|
98
|
+
if (!gridUsesAreas(grid)) return [];
|
|
99
|
+
const templates = gridAreaTemplates(grid);
|
|
100
|
+
const issues = [];
|
|
101
|
+
const tracks = templateTrackKeys(grid);
|
|
102
|
+
if (tracks.length > 0) {
|
|
103
|
+
issues.push(
|
|
104
|
+
issueAt(
|
|
105
|
+
[...gridPath, "areas"],
|
|
106
|
+
`${label} sets ${quotedKeys(["areas", ...tracks])}; a grid uses areas, widths or columns.`
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
if (templates.default === void 0) {
|
|
111
|
+
issues.push(
|
|
112
|
+
issueAt(
|
|
113
|
+
[...gridPath, "areas"],
|
|
114
|
+
`${label} 'areas' per breakpoint must include 'default', the layout below the narrowest breakpoint.`
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
for (const { path, message } of areaTemplateIssues(grid)) {
|
|
119
|
+
const slot = String(path[1] ?? "default");
|
|
120
|
+
issues.push(issueAt([...gridPath, ...path], `${label} areas${atSlot(slot)}: ${message}`));
|
|
121
|
+
}
|
|
122
|
+
return issues;
|
|
123
|
+
}
|
|
124
|
+
function fieldPlacementIssues(label, grid, scope, templatesValid, sharedBySteps) {
|
|
125
|
+
const usesAreas = gridUsesAreas(grid);
|
|
126
|
+
const issues = [];
|
|
127
|
+
const widths = scope.elements.find(({ element }) => elementUsesGridWidths(element));
|
|
128
|
+
const exclusive = usesAreas ? ["areas"] : templateTrackKeys(grid);
|
|
129
|
+
if (widths && exclusive.length > 0) {
|
|
130
|
+
const tracksPath = gridKeyPath(grid, GRID_TEMPLATE_KEYS) ?? [];
|
|
131
|
+
issues.push(
|
|
132
|
+
issueAt(
|
|
133
|
+
[...scope.gridPath, ...usesAreas ? ["areas"] : tracksPath],
|
|
134
|
+
`${label} sets ${quotedKeys(exclusive)} but ${elementLabel(widths.element)} uses 'width' or 'offset'; a grid uses areas, widths or columns.`
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
const claimants = scope.elements.filter(({ element }) => Object.keys(elementAreaSlots(element)).length > 0);
|
|
139
|
+
if (!usesAreas) {
|
|
140
|
+
for (const { element, path } of claimants) {
|
|
141
|
+
issues.push(
|
|
142
|
+
issueAt(
|
|
143
|
+
[...path, ...elementGridKeyPath(element, ["area"])],
|
|
144
|
+
`${elementLabel(element)} sets grid 'area' but the ${label.toLowerCase()} has no 'areas'.`
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
} else if (templatesValid) {
|
|
149
|
+
issues.push(...areaClaimIssues(label, grid, scope.gridPath, claimants, sharedBySteps));
|
|
150
|
+
}
|
|
151
|
+
return issues;
|
|
152
|
+
}
|
|
153
|
+
function areaClaimIssues(label, grid, gridPath, claimants, sharedBySteps) {
|
|
154
|
+
const issues = [];
|
|
155
|
+
const templates = gridAreaTemplates(grid);
|
|
156
|
+
const templateBySlot = cascadeValues(templates);
|
|
157
|
+
const claims = claimants.map(({ element, path }) => ({
|
|
158
|
+
element,
|
|
159
|
+
path,
|
|
160
|
+
authored: elementAreaSlots(element),
|
|
161
|
+
bySlot: cascadeValues(elementAreaSlots(element)),
|
|
162
|
+
hiddenBySlot: cascadeValues(elementHiddenSlots(element))
|
|
163
|
+
}));
|
|
164
|
+
for (const { element, path, authored, bySlot, hiddenBySlot } of claims) {
|
|
165
|
+
for (const [index, { slot, value: area }] of bySlot.entries()) {
|
|
166
|
+
const rows = templateBySlot[index]?.value;
|
|
167
|
+
if (area === void 0 || rows === void 0 || hiddenBySlot[index]?.value) continue;
|
|
168
|
+
const names = areaNames(rows);
|
|
169
|
+
if (names.includes(area)) continue;
|
|
170
|
+
issues.push(
|
|
171
|
+
issueAt(
|
|
172
|
+
[...path, ...elementGridKeyPath(element, ["area"], authoredSlot(authored, slot))],
|
|
173
|
+
`${elementLabel(element)} claims area '${area}'${atSlot(slot)}, which is not in the grid areas (${names.join(", ")}).`
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const hint = sharedBySteps ? "; a form template applies to every step without a grid of its own" : "";
|
|
180
|
+
const reported = /* @__PURE__ */ new Set();
|
|
181
|
+
for (const [index, { slot, value: rows }] of templateBySlot.entries()) {
|
|
182
|
+
if (rows === void 0) continue;
|
|
183
|
+
for (const name of areaNames(rows)) {
|
|
184
|
+
const claimed = claims.some(({ bySlot }) => bySlot[index]?.value === name);
|
|
185
|
+
if (claimed || reported.has(name)) continue;
|
|
186
|
+
reported.add(name);
|
|
187
|
+
issues.push(
|
|
188
|
+
issueAt(
|
|
189
|
+
[...gridPath, ...areasPath(grid, authoredSlot(templates, slot))],
|
|
190
|
+
`${label} area '${name}'${atSlot(slot)} is not claimed by any field${hint}.`
|
|
191
|
+
)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return issues;
|
|
196
|
+
}
|
|
197
|
+
function authoredSlot(authored, slot) {
|
|
198
|
+
let found = "default";
|
|
199
|
+
for (const { slot: candidate } of cascadeValues(authored)) {
|
|
200
|
+
if (authored[candidate] !== void 0) found = candidate;
|
|
201
|
+
if (candidate === slot) break;
|
|
202
|
+
}
|
|
203
|
+
return found;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
elementGridKeyPath,
|
|
208
|
+
namedPlacementIssue,
|
|
209
|
+
areaPlacementIssue,
|
|
210
|
+
templateIssues,
|
|
211
|
+
fieldPlacementIssues
|
|
212
|
+
};
|