@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,290 @@
|
|
|
1
|
+
import {
|
|
2
|
+
evaluateConstraints
|
|
3
|
+
} from "./chunk-R3MBVWVI.js";
|
|
4
|
+
import {
|
|
5
|
+
frozenCopy
|
|
6
|
+
} from "./chunk-3B7CJOF6.js";
|
|
7
|
+
import {
|
|
8
|
+
createValidationContext,
|
|
9
|
+
createZodSchemaFromRules,
|
|
10
|
+
getValidationRulesForElement,
|
|
11
|
+
isFieldRequired
|
|
12
|
+
} from "./chunk-KLATKWUA.js";
|
|
13
|
+
import {
|
|
14
|
+
getElementName,
|
|
15
|
+
walkNamedElements
|
|
16
|
+
} from "./chunk-S7I76ISM.js";
|
|
17
|
+
import {
|
|
18
|
+
expandContainerParentPaths,
|
|
19
|
+
expandFieldTemplatePaths,
|
|
20
|
+
getValueAtPath,
|
|
21
|
+
withoutValueAt
|
|
22
|
+
} from "./chunk-QLGM2AZW.js";
|
|
23
|
+
import {
|
|
24
|
+
REPORTED_TEXT,
|
|
25
|
+
ValidationSuperseded,
|
|
26
|
+
ValidationUnavailable
|
|
27
|
+
} from "./chunk-6BAJHAGL.js";
|
|
28
|
+
|
|
29
|
+
// src/engine/value-validation.ts
|
|
30
|
+
import * as z from "zod/mini";
|
|
31
|
+
var FormValidationFailure = class extends Error {
|
|
32
|
+
path;
|
|
33
|
+
ruleType;
|
|
34
|
+
ruleId;
|
|
35
|
+
/** `'unavailable'` when the service the rule asks could not answer, else `'error'`. */
|
|
36
|
+
reason;
|
|
37
|
+
constructor(path, rule, cause) {
|
|
38
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
39
|
+
super(`Validation rule '${rule.$type}' could not run for '${path}': ${reason}`, { cause });
|
|
40
|
+
this.name = "FormValidationFailure";
|
|
41
|
+
this.path = path;
|
|
42
|
+
this.ruleType = rule.$type;
|
|
43
|
+
this.reason = cause instanceof ValidationUnavailable ? "unavailable" : "error";
|
|
44
|
+
if (rule.id !== void 0) this.ruleId = rule.id;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function expandContainerTemplatePaths(values, templatePath) {
|
|
48
|
+
const segments = templatePath.split(".");
|
|
49
|
+
if (segments.length === 1) {
|
|
50
|
+
return [templatePath];
|
|
51
|
+
}
|
|
52
|
+
const containerName = segments[segments.length - 1];
|
|
53
|
+
const parentPath = segments.slice(0, -1).join(".");
|
|
54
|
+
if (!containerName) {
|
|
55
|
+
return [templatePath];
|
|
56
|
+
}
|
|
57
|
+
return expandContainerParentPaths(values, parentPath).map((fieldPath) => `${fieldPath}.${containerName}`);
|
|
58
|
+
}
|
|
59
|
+
function expandArrayItemPaths(values, templatePath, depth) {
|
|
60
|
+
let paths = expandContainerTemplatePaths(values, templatePath);
|
|
61
|
+
for (let level = 0; level < depth; level += 1) {
|
|
62
|
+
paths = paths.flatMap((path) => {
|
|
63
|
+
const value = getValueAtPath(values, path);
|
|
64
|
+
return Array.isArray(value) ? Array.from({ length: value.length }, (_, index) => `${path}.${index}`) : [];
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return paths;
|
|
68
|
+
}
|
|
69
|
+
function pathIsRequested(path, names, exact = false) {
|
|
70
|
+
if (!names) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return names.some((name) => path === name || !exact && path.startsWith(`${name}.`));
|
|
74
|
+
}
|
|
75
|
+
function fieldElementPathsFor(elements, values, fallbackToId = false) {
|
|
76
|
+
return walkNamedElements(elements, "", fallbackToId).flatMap(({ path, element, hasChildren, arrayItemDepth }) => {
|
|
77
|
+
const paths = arrayItemDepth ? expandArrayItemPaths(values, path, arrayItemDepth) : hasChildren ? expandContainerTemplatePaths(values, path) : expandFieldTemplatePaths(values, path);
|
|
78
|
+
return paths.map((fieldPath) => ({ element, fieldPath, hasChildren }));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function collectStepFieldPaths(step, values = {}) {
|
|
82
|
+
const paths = fieldElementPathsFor(step?.elements ?? [], values).map(({ fieldPath }) => fieldPath);
|
|
83
|
+
return [...new Set(paths)];
|
|
84
|
+
}
|
|
85
|
+
function effectiveRulesFor({
|
|
86
|
+
element,
|
|
87
|
+
fieldPath,
|
|
88
|
+
values,
|
|
89
|
+
registry,
|
|
90
|
+
inheritedRequired = false,
|
|
91
|
+
requiredByConstraint
|
|
92
|
+
}) {
|
|
93
|
+
const rules = getValidationRulesForElement(element, registry) ?? [];
|
|
94
|
+
const isRequired = isFieldRequired(rules) || inheritedRequired || (requiredByConstraint ?? evaluateConstraints({ constraints: element.constraints, values, fieldPath }).isRequired);
|
|
95
|
+
if (!isRequired || isFieldRequired(rules)) {
|
|
96
|
+
return [...rules];
|
|
97
|
+
}
|
|
98
|
+
const requiredRule = { $type: "required" };
|
|
99
|
+
return [requiredRule, ...rules];
|
|
100
|
+
}
|
|
101
|
+
var SUPERSEDED = /* @__PURE__ */ Symbol("superseded");
|
|
102
|
+
async function validateFieldValue({
|
|
103
|
+
element,
|
|
104
|
+
value,
|
|
105
|
+
values,
|
|
106
|
+
fieldPath,
|
|
107
|
+
registry,
|
|
108
|
+
debounceScope,
|
|
109
|
+
inheritedRequired,
|
|
110
|
+
requiredByConstraint
|
|
111
|
+
}) {
|
|
112
|
+
const rules = effectiveRulesFor({
|
|
113
|
+
element,
|
|
114
|
+
values,
|
|
115
|
+
fieldPath,
|
|
116
|
+
registry,
|
|
117
|
+
inheritedRequired,
|
|
118
|
+
requiredByConstraint
|
|
119
|
+
});
|
|
120
|
+
const context = createValidationContext({ values, fieldPath, debounceScope });
|
|
121
|
+
const results = await Promise.all(
|
|
122
|
+
rules.map(async (rule) => {
|
|
123
|
+
try {
|
|
124
|
+
const result = await z.safeParseAsync(createZodSchemaFromRules([rule], context, registry), value);
|
|
125
|
+
if (result.success) return void 0;
|
|
126
|
+
const params = registry.getRuleParams(rule);
|
|
127
|
+
const first = result.error.issues[0];
|
|
128
|
+
const reported = first?.code === "custom" ? first.params?.[REPORTED_TEXT] : void 0;
|
|
129
|
+
const message = registry.getRuleMessage(rule, typeof reported === "string" ? reported : void 0);
|
|
130
|
+
return Object.freeze({
|
|
131
|
+
type: rule.$type,
|
|
132
|
+
...rule.id === void 0 ? {} : { ruleId: rule.id },
|
|
133
|
+
...params === void 0 ? {} : { params: frozenCopy(params) },
|
|
134
|
+
...message ? { message } : {},
|
|
135
|
+
severity: rule.severity ?? "error"
|
|
136
|
+
});
|
|
137
|
+
} catch (cause) {
|
|
138
|
+
if (cause instanceof ValidationSuperseded) return SUPERSEDED;
|
|
139
|
+
return new FormValidationFailure(fieldPath, rule, cause);
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
return {
|
|
144
|
+
issues: results.filter(
|
|
145
|
+
(found) => found !== void 0 && found !== SUPERSEDED && !(found instanceof Error)
|
|
146
|
+
),
|
|
147
|
+
failures: results.filter((found) => found instanceof FormValidationFailure),
|
|
148
|
+
superseded: results.includes(SUPERSEDED)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
var isPathExcluded = (excluded, path) => excluded.some((around) => path === around || path.startsWith(`${around}.`));
|
|
152
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
153
|
+
var NO_FIELD = Object.freeze({ hidden: false, disabled: false, required: false });
|
|
154
|
+
function foldFieldParticipation(fields, path, { inheritRequired = true } = {}) {
|
|
155
|
+
const segments = path.split(".");
|
|
156
|
+
let hidden = false;
|
|
157
|
+
let disabled = false;
|
|
158
|
+
let required = false;
|
|
159
|
+
for (let depth = 1; depth <= segments.length; depth += 1) {
|
|
160
|
+
const at = Object.hasOwn(fields, segments.slice(0, depth).join(".")) ? fields[segments.slice(0, depth).join(".")] : void 0;
|
|
161
|
+
if (!at) continue;
|
|
162
|
+
hidden ||= at.hidden;
|
|
163
|
+
disabled ||= at.disabled;
|
|
164
|
+
if (depth === segments.length || inheritRequired) required ||= at.required;
|
|
165
|
+
}
|
|
166
|
+
return !hidden && !disabled && !required ? NO_FIELD : { hidden, disabled, required };
|
|
167
|
+
}
|
|
168
|
+
function resolveParticipation(steps, values, { shownStep } = {}) {
|
|
169
|
+
let visible = values;
|
|
170
|
+
const excluded = [];
|
|
171
|
+
const skippedSteps = [];
|
|
172
|
+
const fields = {};
|
|
173
|
+
const visibleBefore = /* @__PURE__ */ new Map();
|
|
174
|
+
const exclude = (path) => {
|
|
175
|
+
excluded.push(path);
|
|
176
|
+
const without = withoutValueAt(visible, path);
|
|
177
|
+
if (isRecord(without)) visible = without;
|
|
178
|
+
};
|
|
179
|
+
for (const step of steps) {
|
|
180
|
+
if (step.constraints?.length && step.id !== shownStep && !evaluateConstraints({ constraints: step.constraints, values: visible }).shouldShow) {
|
|
181
|
+
if (step.id !== void 0) skippedSteps.push(step.id);
|
|
182
|
+
for (const element of step.elements) {
|
|
183
|
+
const name = getElementName(element);
|
|
184
|
+
if (!name) continue;
|
|
185
|
+
fields[name] = { hidden: true, disabled: false, required: false };
|
|
186
|
+
visibleBefore.set(name, visible);
|
|
187
|
+
exclude(name);
|
|
188
|
+
}
|
|
189
|
+
for (const { fieldPath } of fieldElementPathsFor(step.elements, values, true)) {
|
|
190
|
+
fields[fieldPath] ??= { hidden: true, disabled: false, required: false };
|
|
191
|
+
}
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (const { element, fieldPath } of fieldElementPathsFor(step.elements, values, true)) {
|
|
195
|
+
const authored = element.disabled === true;
|
|
196
|
+
const root = excluded.find((around) => isPathExcluded([around], fieldPath));
|
|
197
|
+
if (root !== void 0) {
|
|
198
|
+
const before = visibleBefore.get(root) ?? visible;
|
|
199
|
+
const inside = element.constraints?.length ? evaluateConstraints({ constraints: element.constraints, values: before, fieldPath }) : void 0;
|
|
200
|
+
if (authored || inside) {
|
|
201
|
+
fields[fieldPath] = {
|
|
202
|
+
hidden: inside ? !inside.shouldShow : false,
|
|
203
|
+
disabled: authored || (inside?.shouldDisable ?? false),
|
|
204
|
+
required: inside?.isRequired ?? false
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (!authored && !element.constraints?.length) continue;
|
|
210
|
+
const { shouldShow, shouldDisable, isRequired } = evaluateConstraints({
|
|
211
|
+
constraints: element.constraints,
|
|
212
|
+
values: visible,
|
|
213
|
+
fieldPath
|
|
214
|
+
});
|
|
215
|
+
fields[fieldPath] = { hidden: !shouldShow, disabled: authored || shouldDisable, required: isRequired };
|
|
216
|
+
if (!shouldShow || authored || shouldDisable) {
|
|
217
|
+
visibleBefore.set(fieldPath, visible);
|
|
218
|
+
exclude(fieldPath);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return { excluded: [...new Set(excluded)], skippedSteps, fields };
|
|
223
|
+
}
|
|
224
|
+
function hasParticipationRules(steps) {
|
|
225
|
+
return steps.some(
|
|
226
|
+
(step) => Boolean(step.constraints?.length) || walkNamedElements(step.elements, "", true).some(
|
|
227
|
+
({ element }) => element.disabled === true || Boolean(element.constraints?.length)
|
|
228
|
+
)
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
function planFormValidation({
|
|
232
|
+
steps,
|
|
233
|
+
values,
|
|
234
|
+
names,
|
|
235
|
+
exactNames = false,
|
|
236
|
+
participation = resolveParticipation(steps, values)
|
|
237
|
+
}) {
|
|
238
|
+
const { excluded, fields: states } = participation;
|
|
239
|
+
const fields = steps.flatMap((step) => fieldElementPathsFor(step.elements, values)).filter(
|
|
240
|
+
({ fieldPath }) => pathIsRequested(fieldPath, names, exactNames) && !isPathExcluded(excluded, fieldPath)
|
|
241
|
+
).map((field) => ({
|
|
242
|
+
...field,
|
|
243
|
+
requiredByConstraint: foldFieldParticipation(states, field.fieldPath, { inheritRequired: false }).required,
|
|
244
|
+
inheritedRequired: !field.hasChildren && foldFieldParticipation(states, field.fieldPath.split(".").slice(0, -1).join(".")).required
|
|
245
|
+
}));
|
|
246
|
+
return { fields, values };
|
|
247
|
+
}
|
|
248
|
+
async function runValidationPlan(plan, { registry, debounceScope }) {
|
|
249
|
+
const results = await Promise.all(
|
|
250
|
+
plan.fields.map(async ({ element, fieldPath, inheritedRequired, requiredByConstraint }) => ({
|
|
251
|
+
fieldPath,
|
|
252
|
+
result: await validateFieldValue({
|
|
253
|
+
element,
|
|
254
|
+
value: getValueAtPath(plan.values, fieldPath),
|
|
255
|
+
values: plan.values,
|
|
256
|
+
fieldPath,
|
|
257
|
+
registry,
|
|
258
|
+
debounceScope,
|
|
259
|
+
inheritedRequired,
|
|
260
|
+
requiredByConstraint
|
|
261
|
+
})
|
|
262
|
+
}))
|
|
263
|
+
);
|
|
264
|
+
const issues = {};
|
|
265
|
+
const failures = {};
|
|
266
|
+
const superseded = [];
|
|
267
|
+
for (const { fieldPath, result } of results) {
|
|
268
|
+
if (result.issues.length > 0) issues[fieldPath] = result.issues;
|
|
269
|
+
if (result.failures.length > 0) failures[fieldPath] = result.failures;
|
|
270
|
+
if (result.superseded) superseded.push(fieldPath);
|
|
271
|
+
}
|
|
272
|
+
return { issues, failures, superseded };
|
|
273
|
+
}
|
|
274
|
+
async function validateFormValues(input) {
|
|
275
|
+
return runValidationPlan(planFormValidation(input), input);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export {
|
|
279
|
+
FormValidationFailure,
|
|
280
|
+
collectStepFieldPaths,
|
|
281
|
+
effectiveRulesFor,
|
|
282
|
+
validateFieldValue,
|
|
283
|
+
isPathExcluded,
|
|
284
|
+
foldFieldParticipation,
|
|
285
|
+
resolveParticipation,
|
|
286
|
+
hasParticipationRules,
|
|
287
|
+
planFormValidation,
|
|
288
|
+
runValidationPlan,
|
|
289
|
+
validateFormValues
|
|
290
|
+
};
|
|
@@ -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 runVal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