@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,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveFieldRef
|
|
3
|
+
} from "./chunk-YDGH7DTL.js";
|
|
4
|
+
import {
|
|
5
|
+
getValueAtPath
|
|
6
|
+
} from "./chunk-QLGM2AZW.js";
|
|
7
|
+
import {
|
|
8
|
+
isEmpty
|
|
9
|
+
} from "./chunk-6NV2JDGI.js";
|
|
10
|
+
|
|
11
|
+
// src/constraints/constraint-evaluator.ts
|
|
12
|
+
function evaluateConstraint(constraint, watchedValue) {
|
|
13
|
+
const { operator, value } = constraint;
|
|
14
|
+
switch (operator) {
|
|
15
|
+
case "equals":
|
|
16
|
+
return watchedValue === value;
|
|
17
|
+
case "not_equals":
|
|
18
|
+
return watchedValue !== value;
|
|
19
|
+
case "contains":
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
return value.includes(watchedValue);
|
|
22
|
+
}
|
|
23
|
+
return evaluateTextContainment(watchedValue, value) ?? false;
|
|
24
|
+
case "not_contains": {
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
return !value.includes(watchedValue);
|
|
27
|
+
}
|
|
28
|
+
const containsText = evaluateTextContainment(watchedValue, value);
|
|
29
|
+
return containsText !== void 0 && !containsText;
|
|
30
|
+
}
|
|
31
|
+
case "greater_than":
|
|
32
|
+
return Number(watchedValue) > Number(value);
|
|
33
|
+
case "less_than":
|
|
34
|
+
return Number(watchedValue) < Number(value);
|
|
35
|
+
case "is_empty":
|
|
36
|
+
return isEmpty(watchedValue);
|
|
37
|
+
case "is_not_empty":
|
|
38
|
+
return !isEmpty(watchedValue);
|
|
39
|
+
default:
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function evaluateTextContainment(watchedValue, constraintValue) {
|
|
44
|
+
const watchedText = toConstraintText(watchedValue || "");
|
|
45
|
+
const constraintText = toConstraintText(constraintValue);
|
|
46
|
+
if (watchedText === void 0 || constraintText === void 0) return void 0;
|
|
47
|
+
return watchedText.includes(constraintText);
|
|
48
|
+
}
|
|
49
|
+
function toConstraintText(value) {
|
|
50
|
+
if (typeof value === "string") return value;
|
|
51
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
var resolveConstraintPath = resolveFieldRef;
|
|
55
|
+
function resolveConstraintPaths(constraints = [], fieldPath) {
|
|
56
|
+
return constraints.map((constraint) => resolveConstraintPath(constraint.field, fieldPath));
|
|
57
|
+
}
|
|
58
|
+
function normalizeWatchedValue(value) {
|
|
59
|
+
return Array.isArray(value) && value.length === 1 ? value[0] : value;
|
|
60
|
+
}
|
|
61
|
+
function evaluateConstraints({
|
|
62
|
+
constraints = [],
|
|
63
|
+
values,
|
|
64
|
+
fieldPath,
|
|
65
|
+
baseRequired = false
|
|
66
|
+
}) {
|
|
67
|
+
const fieldValues = {};
|
|
68
|
+
for (const constraint of constraints) {
|
|
69
|
+
fieldValues[constraint.field] = getValueAtPath(values, resolveConstraintPath(constraint.field, fieldPath));
|
|
70
|
+
}
|
|
71
|
+
return evaluateResolvedConstraints(constraints, fieldValues, baseRequired);
|
|
72
|
+
}
|
|
73
|
+
function evaluateResolvedConstraints(constraints = [], fieldValues, baseRequired = false) {
|
|
74
|
+
const normalized = {};
|
|
75
|
+
for (const constraint of constraints) {
|
|
76
|
+
normalized[constraint.field] = normalizeWatchedValue(fieldValues[constraint.field]);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
shouldShow: evaluateVisibility(constraints, normalized),
|
|
80
|
+
shouldDisable: evaluateDisabled(constraints, normalized),
|
|
81
|
+
isRequired: evaluateRequired(constraints, normalized, baseRequired)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function evaluateVisibility(constraints, fieldValues) {
|
|
85
|
+
if (constraints.length === 0) return true;
|
|
86
|
+
const showConstraints = constraints.filter((c) => c.$type === "show");
|
|
87
|
+
const hideConstraints = constraints.filter((c) => c.$type === "hide");
|
|
88
|
+
if (showConstraints.length > 0) {
|
|
89
|
+
const anyShow = showConstraints.some(
|
|
90
|
+
(constraint) => evaluateConstraint(constraint, fieldValues[constraint.field])
|
|
91
|
+
);
|
|
92
|
+
if (!anyShow) return false;
|
|
93
|
+
}
|
|
94
|
+
if (hideConstraints.length > 0) {
|
|
95
|
+
const anyHide = hideConstraints.some(
|
|
96
|
+
(constraint) => evaluateConstraint(constraint, fieldValues[constraint.field])
|
|
97
|
+
);
|
|
98
|
+
if (anyHide) return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
function evaluateDisabled(constraints, fieldValues) {
|
|
103
|
+
return constraints.some((constraint) => {
|
|
104
|
+
const conditionMet = evaluateConstraint(constraint, fieldValues[constraint.field]);
|
|
105
|
+
switch (constraint.$type) {
|
|
106
|
+
case "disable":
|
|
107
|
+
return conditionMet;
|
|
108
|
+
case "enable":
|
|
109
|
+
return !conditionMet;
|
|
110
|
+
default:
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function evaluateRequired(constraints, fieldValues, baseRequired) {
|
|
116
|
+
const hasRequireAction = constraints.some(
|
|
117
|
+
(constraint) => constraint.$type === "require" && evaluateConstraint(constraint, fieldValues[constraint.field])
|
|
118
|
+
);
|
|
119
|
+
return baseRequired || hasRequireAction;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
resolveConstraintPath,
|
|
124
|
+
resolveConstraintPaths,
|
|
125
|
+
evaluateConstraints,
|
|
126
|
+
evaluateResolvedConstraints
|
|
127
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/constraints/constraint-evaluator.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ConstraintLogic } from '../schemas';\nimport { getValueAtPath } from '@/lib/path-values';\nimport { resolveFieldRef } from '@/lib/field-ref';\nimport { isEmpty } from '@/schemas/validation/empty';\n\n/**\n * Result from evaluating constraint logic\n */\nexport interface ConstraintEvaluationResult {\n\tshouldShow: boolean;\n\tshouldDisable: boolean;\n\tisRequired: boolean;\n}\n\n/**\n * Evaluates a single constraint condition against a watched value\n * Supports various operators like equals, not_equals, contains, greater_than, less_than, is_empty, is_not_empty\n *\n * For 'contains' and 'not_contains':\n * - If the constraint value is an array, it checks if the watched value is in that array\n * - If the constraint value is a string, it checks if that string is contained within the watched value (which can also be a string)\n *\n * For empty checks:\n * - 'is_empty' returns true for null, undefined, empty string, or empty array\n * - 'is_not_empty' returns true for any non-empty value\n */\nfunction evaluateConstraint(constraint: ConstraintLogic, watchedValue: unknown): boolean {\n\tconst { operator, value } = constraint;\n\n\tswitch (operator) {\n\t\tcase 'equals':\n\t\t\treturn watchedValue === value;\n\t\tcase 'not_equals':\n\t\t\treturn watchedValue !== value;\n\t\tcase 'contains':\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\treturn value.includes(watchedValue);\n\t\t\t}\n\t\t\treturn evaluateTextContainment(watchedValue, value) ?? false;\n\t\tcase 'not_contains': {\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\treturn !value.includes(watchedValue);\n\t\t\t}\n\t\t\tconst containsText = evaluateTextContainment(watchedValue, value);\n\t\t\treturn containsText !== undefined && !containsText;\n\t\t}\n\t\tcase 'greater_than':\n\t\t\treturn Number(watchedValue) > Number(value);\n\t\tcase 'less_than':\n\t\t\treturn Number(watchedValue) < Number(value);\n\t\tcase 'is_empty':\n\t\t\treturn isEmpty(watchedValue);\n\t\tcase 'is_not_empty':\n\t\t\treturn !isEmpty(watchedValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction evaluateTextContainment(watchedValue: unknown, constraintValue: unknown): boolean | undefined {\n\tconst watchedText = toConstraintText(watchedValue || '');\n\tconst constraintText = toConstraintText(constraintValue);\n\tif (watchedText === undefined || constraintText === undefined) return undefined;\n\treturn watchedText.includes(constraintText);\n}\n\nfunction toConstraintText(value: unknown): string | undefined {\n\tif (typeof value === 'string') return value;\n\tif (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return String(value);\n\treturn undefined;\n}\n\n/**\n * Resolves an authored constraint field against the scope of the field declaring it.\n *\n * @remarks\n * Alias of {@link resolveFieldRef}. Constraints and cross-field validation ask the\n * same question of an authored name \u2014 \"what does `accountType` mean, written on\n * `contacts.0.email`?\" \u2014 so they must answer it identically. The implementation\n * lives in `lib/field-ref` because neither subsystem owns it.\n */\nexport const resolveConstraintPath = resolveFieldRef;\n\n/**\n * Every value path a constraint set depends on, in declaration order.\n *\n * @remarks\n * Renderers need the list separately from evaluation so they can react to exactly\n * those paths: React subscribes to them, and Radiant's `se-constraint` compares only\n * their values to skip evaluation when an unrelated field changes.\n */\nexport function resolveConstraintPaths(constraints: readonly ConstraintLogic[] = [], fieldPath?: string): string[] {\n\treturn constraints.map((constraint) => resolveConstraintPath(constraint.field, fieldPath));\n}\n\n/**\n * A one-element array compares as its element.\n *\n * @remarks\n * Single-selection controls (checkbox group, multi-select) hold `['sports']` rather\n * than `'sports'`, so an authored `equals: 'sports'` would never match. Radiant\n * applied this unwrap and React did not, which made the same config behave\n * differently per renderer; the shared rule is Radiant's.\n */\nfunction normalizeWatchedValue(value: unknown): unknown {\n\treturn Array.isArray(value) && value.length === 1 ? value[0] : value;\n}\n\nexport interface EvaluateConstraintsInput {\n\tconstraints?: readonly ConstraintLogic[];\n\t/** Nested value tree for the whole form. Paths are read with {@link getValueAtPath}. */\n\tvalues: Record<string, unknown>;\n\t/** Path of the field declaring the constraints; scopes sibling lookups. */\n\tfieldPath?: string;\n\tbaseRequired?: boolean;\n}\n\n/**\n * Evaluates a field's constraints against the form's value tree.\n *\n * @remarks\n * Resolution and evaluation are deliberately one call: when they were separate,\n * each renderer had to reproduce the \"map authored field name to value path\" step\n * itself, and they drifted. Callers pass the value tree, not a pre-resolved map.\n *\n * Multiple `show` constraints are OR'ed, then any matching `hide` wins. `enable`\n * disables when its condition is *not* met. `require` is OR'ed with `baseRequired`.\n */\nexport function evaluateConstraints({\n\tconstraints = [],\n\tvalues,\n\tfieldPath,\n\tbaseRequired = false,\n}: EvaluateConstraintsInput): ConstraintEvaluationResult {\n\tconst fieldValues: Record<string, unknown> = {};\n\tfor (const constraint of constraints) {\n\t\tfieldValues[constraint.field] = getValueAtPath(values, resolveConstraintPath(constraint.field, fieldPath));\n\t}\n\n\treturn evaluateResolvedConstraints(constraints, fieldValues, baseRequired);\n}\n\n/**\n * Evaluates constraints against values already keyed by authored field name.\n *\n * @remarks\n * Separate from {@link evaluateConstraints} for callers that subscribe to paths\n * themselves and therefore hold the values keyed by name, not a value tree.\n */\nexport function evaluateResolvedConstraints(\n\tconstraints: readonly ConstraintLogic[] = [],\n\tfieldValues: Record<string, unknown>,\n\tbaseRequired = false,\n): ConstraintEvaluationResult {\n\tconst normalized: Record<string, unknown> = {};\n\tfor (const constraint of constraints) {\n\t\tnormalized[constraint.field] = normalizeWatchedValue(fieldValues[constraint.field]);\n\t}\n\n\treturn {\n\t\tshouldShow: evaluateVisibility(constraints, normalized),\n\t\tshouldDisable: evaluateDisabled(constraints, normalized),\n\t\tisRequired: evaluateRequired(constraints, normalized, baseRequired),\n\t};\n}\n\nfunction evaluateVisibility(constraints: readonly ConstraintLogic[], fieldValues: Record<string, unknown>): boolean {\n\tif (constraints.length === 0) return true;\n\n\tconst showConstraints = constraints.filter((c) => c.$type === 'show');\n\tconst hideConstraints = constraints.filter((c) => c.$type === 'hide');\n\n\tif (showConstraints.length > 0) {\n\t\tconst anyShow = showConstraints.some((constraint) =>\n\t\t\tevaluateConstraint(constraint, fieldValues[constraint.field]),\n\t\t);\n\n\t\tif (!anyShow) return false;\n\t}\n\n\tif (hideConstraints.length > 0) {\n\t\tconst anyHide = hideConstraints.some((constraint) =>\n\t\t\tevaluateConstraint(constraint, fieldValues[constraint.field]),\n\t\t);\n\n\t\tif (anyHide) return false;\n\t}\n\n\treturn true;\n}\n\nfunction evaluateDisabled(constraints: readonly ConstraintLogic[], fieldValues: Record<string, unknown>): boolean {\n\treturn constraints.some((constraint) => {\n\t\tconst conditionMet = evaluateConstraint(constraint, fieldValues[constraint.field]);\n\n\t\tswitch (constraint.$type) {\n\t\t\tcase 'disable':\n\t\t\t\treturn conditionMet;\n\t\t\tcase 'enable':\n\t\t\t\treturn !conditionMet;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t});\n}\n\nfunction evaluateRequired(\n\tconstraints: readonly ConstraintLogic[],\n\tfieldValues: Record<string, unknown>,\n\tbaseRequired: boolean,\n): boolean {\n\tconst hasRequireAction = constraints.some(\n\t\t(constraint) => constraint.$type === 'require' && evaluateConstraint(constraint, fieldValues[constraint.field]),\n\t);\n\n\treturn baseRequired || hasRequireAction;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AA0BA,SAAS,mBAAmB,YAA6B,cAAgC;AACxF,QAAM,EAAE,UAAU,MAAM,IAAI;AAE5B,UAAQ,UAAU;AAAA,IACjB,KAAK;AACJ,aAAO,iBAAiB;AAAA,IACzB,KAAK;AACJ,aAAO,iBAAiB;AAAA,IACzB,KAAK;AACJ,UAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,eAAO,MAAM,SAAS,YAAY;AAAA,MACnC;AACA,aAAO,wBAAwB,cAAc,KAAK,KAAK;AAAA,IACxD,KAAK,gBAAgB;AACpB,UAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,eAAO,CAAC,MAAM,SAAS,YAAY;AAAA,MACpC;AACA,YAAM,eAAe,wBAAwB,cAAc,KAAK;AAChE,aAAO,iBAAiB,UAAa,CAAC;AAAA,IACvC;AAAA,IACA,KAAK;AACJ,aAAO,OAAO,YAAY,IAA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
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GDPRConsent
|
|
3
|
+
} from "./chunk-FUHLRG3M.js";
|
|
4
|
+
import {
|
|
5
|
+
localStorageAutoSaveStorage
|
|
6
|
+
} from "./chunk-TBDZOQ2C.js";
|
|
7
|
+
import {
|
|
8
|
+
GTMTracker
|
|
9
|
+
} from "./chunk-H4ABGAAG.js";
|
|
10
|
+
import {
|
|
11
|
+
formResetPlugin
|
|
12
|
+
} from "./chunk-LFWEJXWE.js";
|
|
13
|
+
import {
|
|
14
|
+
gtmPlugin
|
|
15
|
+
} from "./chunk-ZDEZ2FOC.js";
|
|
16
|
+
import {
|
|
17
|
+
autoSavePlugin
|
|
18
|
+
} from "./chunk-4XPLSYTK.js";
|
|
19
|
+
import {
|
|
20
|
+
logger
|
|
21
|
+
} from "./chunk-VGGERKV2.js";
|
|
22
|
+
|
|
23
|
+
// src/browser/action-registrations.ts
|
|
24
|
+
function createBrowserActionRegistrations({
|
|
25
|
+
storage = localStorageAutoSaveStorage,
|
|
26
|
+
consent = GDPRConsent,
|
|
27
|
+
confirm = (message) => window.confirm(message)
|
|
28
|
+
} = {}) {
|
|
29
|
+
const AutoSaveActionRegistration2 = autoSavePlugin({
|
|
30
|
+
storage,
|
|
31
|
+
shouldSave: () => consent.hasConsent(),
|
|
32
|
+
onSave: (data, context) => {
|
|
33
|
+
logger.info("Form data saved", { data, formId: context.formId });
|
|
34
|
+
},
|
|
35
|
+
onError: (error, context) => {
|
|
36
|
+
logger.error("Failed to save form data", { formId: context.formId, error });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const ResetActionRegistration2 = formResetPlugin({
|
|
40
|
+
storage,
|
|
41
|
+
confirm,
|
|
42
|
+
onReset: (context) => {
|
|
43
|
+
logger.info("Form reset completed", { formId: context.formId });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const GTMActionRegistration2 = gtmPlugin({
|
|
47
|
+
tracker: {
|
|
48
|
+
push: (eventName, eventData) => GTMTracker.push(eventName, eventData)
|
|
49
|
+
},
|
|
50
|
+
onPush: (eventName, eventData, context) => {
|
|
51
|
+
logger.info("Pushed GTM event", { eventName, formId: context.formId, eventData });
|
|
52
|
+
},
|
|
53
|
+
onError: (error, context) => {
|
|
54
|
+
logger.error("Failed to push GTM event", { formId: context.formId, error });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return { AutoSaveActionRegistration: AutoSaveActionRegistration2, ResetActionRegistration: ResetActionRegistration2, GTMActionRegistration: GTMActionRegistration2 };
|
|
58
|
+
}
|
|
59
|
+
var browserActionRegistrations = createBrowserActionRegistrations();
|
|
60
|
+
var { AutoSaveActionRegistration, ResetActionRegistration, GTMActionRegistration } = browserActionRegistrations;
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
createBrowserActionRegistrations,
|
|
64
|
+
AutoSaveActionRegistration,
|
|
65
|
+
ResetActionRegistration,
|
|
66
|
+
GTMActionRegistration
|
|
67
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/browser/action-registrations.ts"],
|
|
4
|
+
"sourcesContent": ["import { autoSavePlugin, AutoSaveActionSchema, type AutoSaveStorage } from '../actions/plugins/auto-save.plugin';\nimport { formResetPlugin, FormResetActionSchema } from '../actions/plugins/form-reset.plugin';\nimport { gtmPlugin, GTMEventActionSchema } from '../actions/plugins/gtm.plugin';\nimport { logger } from '@/lib/logger';\nimport type { BuilderActionRegistration } from '@/types';\nimport { GDPRConsent, type GDPRConsentTool } from './tools/gdpr-consent';\nimport { GTMTracker } from './tools/gtm-tracker';\nimport { localStorageAutoSaveStorage } from './tools/auto-save-storage';\n\nexport interface BrowserActionRegistrationsOptions {\n\tstorage?: AutoSaveStorage;\n\tconsent?: Pick<GDPRConsentTool, 'hasConsent'>;\n\tconfirm?: (message: string) => boolean | Promise<boolean>;\n}\n\n/**\n * Creates browser-oriented action registrations with injectable browser ports.\n *\n * @remarks Auto-save is consent-gated by default. Supplying a consent tool lets\n * tests and hosts use an isolated consent store.\n */\nexport function createBrowserActionRegistrations({\n\tstorage = localStorageAutoSaveStorage,\n\tconsent = GDPRConsent,\n\tconfirm = (message) => window.confirm(message),\n}: BrowserActionRegistrationsOptions = {}) {\n\tconst AutoSaveActionRegistration: BuilderActionRegistration<'auto_save', typeof AutoSaveActionSchema> =\n\t\tautoSavePlugin({\n\t\t\tstorage,\n\t\t\tshouldSave: () => consent.hasConsent(),\n\t\t\tonSave: (data, context) => {\n\t\t\t\tlogger.info('Form data saved', { data, formId: context.formId });\n\t\t\t},\n\t\t\tonError: (error, context) => {\n\t\t\t\tlogger.error('Failed to save form data', { formId: context.formId, error });\n\t\t\t},\n\t\t});\n\n\tconst ResetActionRegistration: BuilderActionRegistration<'reset', typeof FormResetActionSchema> = formResetPlugin({\n\t\tstorage,\n\t\tconfirm,\n\t\tonReset: (context) => {\n\t\t\tlogger.info('Form reset completed', { formId: context.formId });\n\t\t},\n\t});\n\n\tconst GTMActionRegistration: BuilderActionRegistration<'gtm_event', typeof GTMEventActionSchema> = gtmPlugin({\n\t\ttracker: {\n\t\t\tpush: (eventName, eventData) => GTMTracker.push(eventName, eventData),\n\t\t},\n\t\tonPush: (eventName, eventData, context) => {\n\t\t\tlogger.info('Pushed GTM event', { eventName, formId: context.formId, eventData });\n\t\t},\n\t\tonError: (error, context) => {\n\t\t\tlogger.error('Failed to push GTM event', { formId: context.formId, error });\n\t\t},\n\t});\n\n\treturn { AutoSaveActionRegistration, ResetActionRegistration, GTMActionRegistration };\n}\n\nconst browserActionRegistrations = createBrowserActionRegistrations();\n\nexport const { AutoSaveActionRegistration, ResetActionRegistration, GTMActionRegistration } =\n\tbrowserActionRegistrations;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAqBO,SAAS,iCAAiC;AAAA,EAChD,UAAU;AAAA,EACV,UA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
createMap,
|
|
3
|
+
isStructural,
|
|
4
|
+
join,
|
|
5
|
+
toInternalRecord
|
|
6
|
+
} from "./chunk-K5TMXCMY.js";
|
|
7
|
+
import {
|
|
8
|
+
isPlainObject
|
|
9
|
+
} from "./chunk-CMPOBBRV.js";
|
|
10
|
+
|
|
11
|
+
// src/state-container/hydration.ts
|
|
12
|
+
var toHydration = (snapshot) => ({
|
|
13
|
+
values: snapshot.values,
|
|
14
|
+
rowIds: snapshot.rowIds
|
|
15
|
+
});
|
|
16
|
+
function readHydration(hydration) {
|
|
17
|
+
if (!isPlainObject(hydration) || !isPlainObject(hydration.values) || !isPlainObject(hydration.rowIds)) {
|
|
18
|
+
throw new Error("A hydration is an object with the values and the rowIds of a snapshot.");
|
|
19
|
+
}
|
|
20
|
+
const given = hydration.rowIds;
|
|
21
|
+
const taken = /* @__PURE__ */ new Set();
|
|
22
|
+
const used = /* @__PURE__ */ new Set();
|
|
23
|
+
const idsOf = (value, path) => {
|
|
24
|
+
if (!isStructural(value)) return void 0;
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
const ids2 = Object.hasOwn(given, path) ? given[path] : void 0;
|
|
27
|
+
if (!Array.isArray(ids2)) throw new Error(`The hydration has no row ids for '${path}'.`);
|
|
28
|
+
if (ids2.length !== value.length) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`The hydration has ${ids2.length} row ids for '${path}', which has ${value.length} rows.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
used.add(path);
|
|
34
|
+
return value.map((row, index) => {
|
|
35
|
+
const id = ids2[index];
|
|
36
|
+
if (typeof id !== "string" || id === "" || taken.has(id)) {
|
|
37
|
+
throw new Error(`The hydration has an invalid or repeated row id for '${path}'.`);
|
|
38
|
+
}
|
|
39
|
+
taken.add(id);
|
|
40
|
+
const below = idsOf(row, join(path, String(index)));
|
|
41
|
+
return below === void 0 ? { id } : { id, below };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const children = createMap();
|
|
45
|
+
for (const key of Object.keys(value)) {
|
|
46
|
+
const child = idsOf(value[key], join(path, key));
|
|
47
|
+
if (child !== void 0) children[key] = child;
|
|
48
|
+
}
|
|
49
|
+
return Object.keys(children).length === 0 ? void 0 : children;
|
|
50
|
+
};
|
|
51
|
+
const values = toInternalRecord(hydration.values);
|
|
52
|
+
const ids = idsOf(values, "");
|
|
53
|
+
for (const path of Object.keys(given)) {
|
|
54
|
+
if (!used.has(path)) {
|
|
55
|
+
throw new Error(`The hydration has row ids for '${path}', which is not an array in its values.`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { values, ids, taken };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
toHydration,
|
|
63
|
+
readHydration
|
|
64
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/state-container/hydration.ts"],
|
|
4
|
+
"sourcesContent": ["import { isPlainObject } from '@/lib/is-plain-object';\nimport type { IdTree, RowNode } from './row-ids';\nimport type { FormStateHydration, FormStateSnapshot } from './types';\nimport { createMap, isStructural, join, toInternalRecord, type NullMap } from './value-tree';\n\n/** What a client needs of a server's snapshot to start from the same state: its values and row ids, both plain and serializable. */\nexport const toHydration = (snapshot: FormStateSnapshot): FormStateHydration => ({\n\tvalues: snapshot.values,\n\trowIds: snapshot.rowIds,\n});\n\n/** A hydration as the container holds it: the values, the ids tree they carry, and every id used. */\nexport interface ReadHydration {\n\treadonly values: NullMap;\n\treadonly ids: IdTree | undefined;\n\treadonly taken: ReadonlySet<string>;\n}\n\n/**\n * The values and row ids of a hydration, checked against each other in one walk of the values.\n *\n * @remarks\n * Every array of the values must have exactly one entry in `rowIds`, with one id for each of its rows and no id\n * used twice in the hydration, and there must be no entry for anything else. Arrays that hold opaque values, such\n * as files, have no row ids and no entry. The ids tree takes each row's id from `rowIds[path][index]` as the walk\n * reaches it.\n */\nexport function readHydration(hydration: FormStateHydration): ReadHydration {\n\tif (!isPlainObject(hydration) || !isPlainObject(hydration.values) || !isPlainObject(hydration.rowIds)) {\n\t\tthrow new Error('A hydration is an object with the values and the rowIds of a snapshot.');\n\t}\n\tconst given = hydration.rowIds;\n\tconst taken = new Set<string>();\n\tconst used = new Set<string>();\n\tconst idsOf = (value: unknown, path: string): IdTree | undefined => {\n\t\tif (!isStructural(value)) return undefined;\n\t\tif (Array.isArray(value)) {\n\t\t\tconst ids: unknown = Object.hasOwn(given, path) ? given[path] : undefined;\n\t\t\tif (!Array.isArray(ids)) throw new Error(`The hydration has no row ids for '${path}'.`);\n\t\t\tif (ids.length !== value.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The hydration has ${ids.length} row ids for '${path}', which has ${value.length} rows.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tused.add(path);\n\t\t\treturn value.map((row, index): RowNode => {\n\t\t\t\tconst id: unknown = ids[index];\n\t\t\t\tif (typeof id !== 'string' || id === '' || taken.has(id)) {\n\t\t\t\t\tthrow new Error(`The hydration has an invalid or repeated row id for '${path}'.`);\n\t\t\t\t}\n\t\t\t\ttaken.add(id);\n\t\t\t\tconst below = idsOf(row, join(path, String(index)));\n\t\t\t\treturn below === undefined ? { id } : { id, below };\n\t\t\t});\n\t\t}\n\t\tconst children = createMap<IdTree>();\n\t\tfor (const key of Object.keys(value)) {\n\t\t\tconst child = idsOf(value[key], join(path, key));\n\t\t\tif (child !== undefined) children[key] = child;\n\t\t}\n\t\treturn Object.keys(children).length === 0 ? undefined : children;\n\t};\n\tconst values = toInternalRecord(hydration.values);\n\tconst ids = idsOf(values, '');\n\tfor (const path of Object.keys(given)) {\n\t\tif (!used.has(path)) {\n\t\t\tthrow new Error(`The hydration has row ids for '${path}', which is not an array in its values.`);\n\t\t}\n\t}\n\treturn { values, ids, taken };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAMO,IAAM,cAAc,CAAC,cAAqD;AAAA,EAChF,QAA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AAM,GAAG,CAAC;AAC/C,UAAI,UAAU,OAAW,UAAS,GAAG,IAAI;AAAA,IAC1C;AACA,WAAO,OAAO,KAAK,QAAQ,EAAE,WAAW,IAAI,SAAY;AAAA,EACzD;AACA,QAAM,SAAS,iBAAiB,UAAU,MAAM;AAChD,QAAM,MAAM,MAAM,QAAQ,EAAE;AAC5B,aAAW,QAAQ,OAAO,KAAK,KAAK,GAAG;AACtC,QAAI,CAAC,KAAK,IAAI,IAAI,GAAG;AACpB,YAAM,IAAI,MAAM,kCAAkC,IAAI,yCAAyC;AAAA,IAChG;AAAA,EACD;AACA,SAAO,EAAE,QAAQ,KAAK,MAAM;AAC7B;",
|
|
6
|
+
"names": ["ids"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/lib/resolve-appearance.ts
|
|
2
|
+
import {
|
|
3
|
+
checkAppearance,
|
|
4
|
+
mergeAppearance,
|
|
5
|
+
pickSupportedAppearance
|
|
6
|
+
} from "@schema-engine/layout";
|
|
7
|
+
function resolveAppearance(authored, scope, owner) {
|
|
8
|
+
const checked = checkAppearance(authored, {
|
|
9
|
+
axes: scope.axes,
|
|
10
|
+
subject: owner.subject,
|
|
11
|
+
supported: owner.supported
|
|
12
|
+
});
|
|
13
|
+
const own = mergeAppearance(scope.inherited, checked.appearance);
|
|
14
|
+
return {
|
|
15
|
+
issues: checked.issues.map((issue) => ({ ...issue, path: [...owner.path, ...issue.path] })),
|
|
16
|
+
selection: owner.supported === void 0 ? own : pickSupportedAppearance(own, owner.supported),
|
|
17
|
+
childScope: { axes: scope.axes, inherited: own }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function withAppearance(config, selection) {
|
|
21
|
+
if (Object.keys(selection).length === 0) return withoutAppearanceKey(config);
|
|
22
|
+
return { ...withoutAppearanceKey(config), appearance: selection };
|
|
23
|
+
}
|
|
24
|
+
function withoutAppearanceKey(config) {
|
|
25
|
+
if (!("appearance" in config)) return config;
|
|
26
|
+
const { appearance: _authored, ...rest } = config;
|
|
27
|
+
return rest;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
resolveAppearance,
|
|
32
|
+
withAppearance,
|
|
33
|
+
withoutAppearanceKey
|
|
34
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/resolve-appearance.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n\tcheckAppearance,\n\tmergeAppearance,\n\tpickSupportedAppearance,\n\ttype LayoutIssue,\n\ttype LayoutTheme,\n} from '@schema-engine/layout';\n\n/**\n * Appearance picks that reach a part of the form: the vocabulary, and what the form, step and\n * containing elements chose.\n */\nexport interface AppearanceScope {\n\treadonly axes: LayoutTheme['axes'];\n\treadonly inherited: Readonly<Record<string, string>>;\n}\n\n/** What {@link resolveAppearance} found for one owner in the form tree. */\nexport interface ResolvedAppearance {\n\t/** One issue per problem, with the path of the owner's `appearance` key in the form. */\n\treadonly issues: LayoutIssue[];\n\t/** The pick the owner renders with. Empty means the owner carries no `appearance` key. */\n\treadonly selection: Record<string, string>;\n\t/** The scope for the owner's children: what it inherited, with its own pick laid over it. */\n\treadonly childScope: AppearanceScope;\n}\n\n/**\n * Walks one step of the appearance inheritance down the form tree: checks an owner's authored pick,\n * merges it over what it inherits, and keeps the axes the owner supports.\n *\n * @param owner.subject Names the owner in a message, for example `Element 'fieldSet'`.\n * @param owner.path Where the owner sits in the form, prefixed to each issue's path. Empty for the form and a standalone element.\n * @param owner.supported The axes the owner declares; an owner that declares none passes `[]`. Omit it\n * for the form and its steps, which accept every axis.\n *\n * @remarks\n * The one place the form's inheritance rule lives (form, then step, then element or view slot, a\n * closer pick winning), so the form, steps, elements and slots cannot drift apart. Walking the tree\n * stays here because only forms know its shape; the checks and merges are pure helpers in\n * `@schema-engine/layout`.\n */\nexport function resolveAppearance(\n\tauthored: unknown,\n\tscope: AppearanceScope,\n\towner: { subject: string; path: ReadonlyArray<PropertyKey>; supported?: readonly string[] },\n): ResolvedAppearance {\n\tconst checked = checkAppearance(authored, {\n\t\taxes: scope.axes,\n\t\tsubject: owner.subject,\n\t\tsupported: owner.supported,\n\t});\n\tconst own = mergeAppearance(scope.inherited, checked.appearance);\n\treturn {\n\t\tissues: checked.issues.map((issue) => ({ ...issue, path: [...owner.path, ...issue.path] })),\n\t\tselection: owner.supported === undefined ? own : pickSupportedAppearance(own, owner.supported),\n\t\tchildScope: { axes: scope.axes, inherited: own },\n\t};\n}\n\n/**\n * `config` without any authored `appearance`, plus the resolved selection when it is not empty.\n *\n * @remarks\n * An owner without a pick carries no `appearance` key at all, so a normalized config only mentions\n * appearance where it applies.\n */\nexport function withAppearance<T extends object>(config: T, selection: Readonly<Record<string, string>>): T {\n\tif (Object.keys(selection).length === 0) return withoutAppearanceKey(config);\n\treturn { ...withoutAppearanceKey(config), appearance: selection };\n}\n\n/** `config` without an authored `appearance`, or `config` itself when it has none. */\nexport function withoutAppearanceKey<T extends object>(config: T): T {\n\tif (!('appearance' in config)) return config;\n\tconst { appearance: _authored, ...rest } = config as T & { appearance?: unknown };\n\treturn rest as T;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAoCA,SAAS,kBACf,UACA,OACA,OACqB;AACrB,QAAM,UAAU,gBAAgB,UAAU;AAAA,IACzC,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,IACf,WAAW,MAAM;AAAA,EAClB,CAAC;AACD,QAAM,MAAM,gBAAgB,MAAM,WAAW,QAAQ,UAAU;AAC/D,SAAO;AAAA,IACN,QAAQ,QAAQ,OAAO,IAAI,CAAC,WAAW,EAAE,GAAG,OAAO,MAAM,CAAC,GAAG,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,EAAE;AAAA,IAC1F,WAAW,MAAM,cAAc,SAAY,MAAM,wBAAwB,KAAK,MAAM,SAAS;AAAA,IAC7F,YAAY,EAAE,MAAM,MAAM,MAAM,WAAW,IAAI;AAAA,EAChD;AACD;AASO,SAAS,eAAiC,QAAW,WAAgD;AAC3G,MAAI,OAAO,KAAK,SAAS,EAAE,WAAW,EAAG,QAAO,qBAAqB,MAAM;AAC3E,SAAO,EAAE,GAAG,qBAAqB,MAAM,GAAG,YAAY,UAAU;AACjE;AAGO,SAAS,qBAAuC,QAAc;AACpE,MAAI,EAAE,gBAAgB,QAAS,QAAO;AACtC,QAAM,EAAE,YAAY,WAAW,GAAG,KAAK,IAAI;AAC3C,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/lib/exported-rules.ts
|
|
2
|
+
import * as z from "zod/mini";
|
|
3
|
+
var RULES_KEY = "rules";
|
|
4
|
+
function isMiniSchema(schema) {
|
|
5
|
+
return "check" in schema && typeof schema.check === "function";
|
|
6
|
+
}
|
|
7
|
+
function isArraySchema(schema) {
|
|
8
|
+
return schema._zod.def.type === "array";
|
|
9
|
+
}
|
|
10
|
+
function isObjectSchema(schema) {
|
|
11
|
+
return schema._zod.def.type === "object";
|
|
12
|
+
}
|
|
13
|
+
function isPipeSchema(schema) {
|
|
14
|
+
return schema._zod.def.type === "pipe";
|
|
15
|
+
}
|
|
16
|
+
function isOptionalSchema(schema) {
|
|
17
|
+
return schema._zod.def.type === "optional";
|
|
18
|
+
}
|
|
19
|
+
function withArrayItem(schema, item) {
|
|
20
|
+
if (isArraySchema(schema)) {
|
|
21
|
+
return z.core.clone(schema, { ...schema._zod.def, element: item });
|
|
22
|
+
}
|
|
23
|
+
if (isOptionalSchema(schema)) {
|
|
24
|
+
const inner = schema._zod.def.innerType;
|
|
25
|
+
return isMiniSchema(inner) ? z.core.clone(schema, { ...schema._zod.def, innerType: withArrayItem(inner, item) }) : schema;
|
|
26
|
+
}
|
|
27
|
+
if (isPipeSchema(schema)) {
|
|
28
|
+
const input = schema._zod.def.in;
|
|
29
|
+
return isMiniSchema(input) ? z.core.clone(schema, { ...schema._zod.def, in: withArrayItem(input, item) }) : schema;
|
|
30
|
+
}
|
|
31
|
+
return schema;
|
|
32
|
+
}
|
|
33
|
+
function withExportedRules(schema, rule) {
|
|
34
|
+
if (isObjectSchema(schema)) {
|
|
35
|
+
const { shape } = schema._zod.def;
|
|
36
|
+
const rules = shape[RULES_KEY];
|
|
37
|
+
if (!rules || !isMiniSchema(rules)) return schema;
|
|
38
|
+
const typed = withArrayItem(rules, rule);
|
|
39
|
+
if (typed === rules) return schema;
|
|
40
|
+
return z.core.clone(schema, { ...schema._zod.def, shape: { ...shape, [RULES_KEY]: typed } }, { parent: true });
|
|
41
|
+
}
|
|
42
|
+
if (isPipeSchema(schema)) {
|
|
43
|
+
const input = schema._zod.def.in;
|
|
44
|
+
if (!isMiniSchema(input)) return schema;
|
|
45
|
+
const next = withExportedRules(input, rule);
|
|
46
|
+
return next === input ? schema : z.core.clone(schema, { ...schema._zod.def, in: next }, { parent: true });
|
|
47
|
+
}
|
|
48
|
+
return schema;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
withExportedRules
|
|
53
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/exported-rules.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/mini';\n\nconst RULES_KEY = 'rules' as const;\n\nfunction isMiniSchema(schema: z.core.$ZodType): schema is z.ZodMiniType {\n\treturn 'check' in schema && typeof schema.check === 'function';\n}\n\nfunction isArraySchema(schema: z.ZodMiniType): schema is z.ZodMiniArray {\n\treturn schema._zod.def.type === 'array';\n}\n\nfunction isObjectSchema(schema: z.ZodMiniType): schema is z.ZodMiniObject {\n\treturn schema._zod.def.type === 'object';\n}\n\nfunction isPipeSchema(schema: z.ZodMiniType): schema is z.ZodMiniPipe {\n\treturn schema._zod.def.type === 'pipe';\n}\n\nfunction isOptionalSchema(schema: z.ZodMiniType): schema is z.ZodMiniOptional {\n\treturn schema._zod.def.type === 'optional';\n}\n\n/** The schema with the items of the array it holds replaced, looking through the wrappers an element puts around `rules`. */\nfunction withArrayItem(schema: z.ZodMiniType, item: z.ZodMiniType): z.ZodMiniType {\n\tif (isArraySchema(schema)) {\n\t\treturn z.core.clone(schema, { ...schema._zod.def, element: item });\n\t}\n\tif (isOptionalSchema(schema)) {\n\t\tconst inner = schema._zod.def.innerType;\n\t\treturn isMiniSchema(inner)\n\t\t\t? z.core.clone(schema, { ...schema._zod.def, innerType: withArrayItem(inner, item) })\n\t\t\t: schema;\n\t}\n\tif (isPipeSchema(schema)) {\n\t\tconst input = schema._zod.def.in;\n\t\treturn isMiniSchema(input)\n\t\t\t? z.core.clone(schema, { ...schema._zod.def, in: withArrayItem(input, item) })\n\t\t\t: schema;\n\t}\n\treturn schema;\n}\n\n/**\n * Types the rules of an element schema for a JSON Schema export.\n *\n * @param rule The schema of one rule, the union of every registered rule's schema.\n *\n * @remarks\n * An element's own `rules` accepts any rule shape, because the validation registry decides what a rule\n * is. The export lists the registered rules instead, so an editor offers each one with its options. A\n * schema without a `rules` key, or whose `rules` is not an array, comes back as it is. The result is for\n * export only: parse with the original. The outer schemas are cloned with the original as their parent, so\n * the title and description registered for them still apply.\n */\nexport function withExportedRules(schema: z.ZodMiniType, rule: z.ZodMiniType): z.ZodMiniType {\n\tif (isObjectSchema(schema)) {\n\t\tconst { shape } = schema._zod.def;\n\t\tconst rules = shape[RULES_KEY];\n\t\tif (!rules || !isMiniSchema(rules)) return schema;\n\t\tconst typed = withArrayItem(rules, rule);\n\t\tif (typed === rules) return schema;\n\t\treturn z.core.clone(schema, { ...schema._zod.def, shape: { ...shape, [RULES_KEY]: typed } }, { parent: true });\n\t}\n\tif (isPipeSchema(schema)) {\n\t\tconst input = schema._zod.def.in;\n\t\tif (!isMiniSchema(input)) return schema;\n\t\tconst next = withExportedRules(input, rule);\n\t\treturn next === input ? schema : z.core.clone(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