@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,45 @@
|
|
|
1
|
+
// src/lib/zod-json-schema.ts
|
|
2
|
+
import * as z from "zod/mini";
|
|
3
|
+
function isZodType(schema) {
|
|
4
|
+
return typeof schema === "object" && schema !== null && typeof schema.parse === "function" && typeof schema.safeParse === "function";
|
|
5
|
+
}
|
|
6
|
+
function generateZodJSONSchemaCollection(metadataRegistry, options) {
|
|
7
|
+
return z.toJSONSchema(metadataRegistry, {
|
|
8
|
+
target: options?.target || "draft-2020-12",
|
|
9
|
+
io: options?.io || "input",
|
|
10
|
+
uri: options?.uri || ((id) => `#/definitions/${id}`)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
var LayeredMetadataRegistry = class extends z.core.$ZodRegistry {
|
|
14
|
+
constructor(primary) {
|
|
15
|
+
super();
|
|
16
|
+
this.primary = primary;
|
|
17
|
+
}
|
|
18
|
+
primary;
|
|
19
|
+
get(schema) {
|
|
20
|
+
const own = z.globalRegistry.get(schema);
|
|
21
|
+
const layered = this.primary.get(schema);
|
|
22
|
+
if (!layered) {
|
|
23
|
+
return own;
|
|
24
|
+
}
|
|
25
|
+
const defined = Object.fromEntries(Object.entries(layered).filter(([, value]) => value !== void 0));
|
|
26
|
+
return { ...own, ...defined };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function generateZodJSONSchemaDocument(validator, metadataRegistry, options) {
|
|
30
|
+
const schema = z.toJSONSchema(validator, {
|
|
31
|
+
target: options?.target || "draft-2020-12",
|
|
32
|
+
io: options?.io || "input",
|
|
33
|
+
metadata: new LayeredMetadataRegistry(metadataRegistry)
|
|
34
|
+
});
|
|
35
|
+
if (options?.schemaId) {
|
|
36
|
+
schema.$id = options.schemaId;
|
|
37
|
+
}
|
|
38
|
+
return schema;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
isZodType,
|
|
43
|
+
generateZodJSONSchemaCollection,
|
|
44
|
+
generateZodJSONSchemaDocument
|
|
45
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/zod-json-schema.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/mini';\nimport type { JSONSchemaObject, JSONSchemaTarget } from '@/lib/standard-json-schema';\n\n/**\n * Duck-type a Zod validator. Native Standard Schema objects only expose `~standard`.\n */\nexport function isZodType(schema: unknown): schema is z.ZodMiniType {\n\treturn (\n\t\ttypeof schema === 'object' &&\n\t\tschema !== null &&\n\t\ttypeof (schema as { parse?: unknown }).parse === 'function' &&\n\t\ttypeof (schema as { safeParse?: unknown }).safeParse === 'function'\n\t);\n}\n\n/**\n * Shared alias for the Zod registry type used during JSON Schema generation.\n * Keeping this in one place reduces the amount of Zod-specific typing that\n * leaks into higher-level schema artifact code.\n * @remarks Zod accepts heterogeneous metadata through this existential registry.\n */\nexport type ZodJSONSchemaRegistry = ReturnType<typeof z.registry<Record<string, any>>>;\n\n/**\n * Generate a JSON Schema collection from a Zod metadata registry.\n * This is the lowest-level adapter around `z.toJSONSchema(...)` for registry\n * collections and is intended to stay reusable if the artifact layer moves.\n */\nexport function generateZodJSONSchemaCollection(\n\tmetadataRegistry: ZodJSONSchemaRegistry,\n\toptions?: {\n\t\ttarget?: JSONSchemaTarget;\n\t\turi?: (id: string) => string;\n\t\tio?: 'input' | 'output';\n\t},\n): JSONSchemaObject {\n\treturn z.toJSONSchema(metadataRegistry, {\n\t\ttarget: options?.target || 'draft-2020-12',\n\t\tio: options?.io || 'input',\n\t\turi: options?.uri || ((id: string) => `#/definitions/${id}`),\n\t}) as JSONSchemaObject;\n}\n\n/**\n * Registry that answers metadata lookups from a primary registry laid over `z.globalRegistry`.\n *\n * @remarks\n * `z.toJSONSchema` reads metadata from the single registry passed as `metadata`, which replaces\n * `z.globalRegistry`. That is where `.describe(...)` and `.meta(...)` store a schema's own\n * description, so passing only the catalog registry dropped every author-written description.\n * Entries of the primary registry win key by key, except that an undefined value (a catalog entry\n * without a description) does not hide the one the schema declares.\n */\nclass LayeredMetadataRegistry extends z.core.$ZodRegistry<Record<string, unknown>> {\n\tconstructor(private readonly primary: ZodJSONSchemaRegistry) {\n\t\tsuper();\n\t}\n\n\toverride get(schema: z.core.$ZodType): Record<string, unknown> | undefined {\n\t\tconst own = z.globalRegistry.get(schema);\n\t\tconst layered = this.primary.get(schema);\n\t\tif (!layered) {\n\t\t\treturn own;\n\t\t}\n\t\tconst defined = Object.fromEntries(Object.entries(layered).filter(([, value]) => value !== undefined));\n\t\treturn { ...own, ...defined };\n\t}\n}\n\n/**\n * Generate a JSON Schema document from a Zod validator using registry metadata.\n * An optional `$id` can be applied centrally so higher layers do not repeat that\n * concern for each emitted schema.\n */\nexport function generateZodJSONSchemaDocument(\n\tvalidator: z.ZodMiniType,\n\tmetadataRegistry: ZodJSONSchemaRegistry,\n\toptions?: {\n\t\ttarget?: JSONSchemaTarget;\n\t\tschemaId?: string;\n\t\tio?: 'input' | 'output';\n\t},\n): JSONSchemaObject {\n\tconst schema = z.toJSONSchema(validator, {\n\t\ttarget: options?.target || 'draft-2020-12',\n\t\tio: options?.io || 'input',\n\t\tmetadata: new LayeredMetadataRegistry(metadataRegistry),\n\t}) as JSONSchemaObject & { $id?: string };\n\n\tif (options?.schemaId) {\n\t\tschema.$id = options.schemaId;\n\t}\n\n\treturn schema;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,OAAO;AAMZ,SAAS,UAAU,QAA0C;AACnE,SACC,OAAO,WAAW,YAClB,WAAW,QACX,OAAQ,OAA+B,UAAU,cACjD,OAAQ,OAAmC,cAAc;AAE3D;AAeO,SAAS,gCACf,kBACA,SAKmB;AACnB,SAAS,eAAa,kBAAkB;AAAA,IACvC,QAAQ,SAAS,UAAU;AAAA,IAC3B,IAAI,SAAS,MAAM;AAAA,IACnB,KAAK,SAAS,QAAQ,CAAC,OAAe,iBAAiB,EAAE;AAAA,EAC1D,CAAC;AACF;AAYA,IAAM,0BAAN,cAAwC,OAAK,aAAsC;AAAA,EAClF,YAA6B,SAAgC;AAC5D,UAAM;AADsB;AAAA,EAE7B;AAAA,EAF6B;AAAA,EAIpB,IAAI,QAA8D;AAC1E,UAAM,MAAQ,iBAAe,IAAI,MAAM;AACvC,UAAM,UAAU,KAAK,QAAQ,IAAI,MAAM;AACvC,QAAI,CAAC,SAAS;AACb,aAAO;AAAA,IACR;AACA,UAAM,UAAU,OAAO,YAAY,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,CAAC;AACrG,WAAO,EAAE,GAAG,KAAK,GAAG,QAAQ;AAAA,EAC7B;AACD;AAOO,SAAS,8BACf,WACA,kBACA,SAKmB;AACnB,QAAM,SAAW,eAAa,WAAW;AAAA,IACxC,QAAQ,SAAS,UAAU;AAAA,IAC3B,IAAI,SAAS,MAAM;AAAA,IACnB,UAAU,IAAI,wBAAwB,gBAAgB;AAAA,EACvD,CAAC;AAED,MAAI,SAAS,UAAU;AACtB,WAAO,MAAM,QAAQ;AAAA,EACtB;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/runtime/types.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ParsedActionSequence } from '@schema-engine/actions';\nimport type { FormEngineRuntime } from '@/engine/form-engine';\nimport type { FormActionConfig, SubmissionActionResult } from '@/runtime/submission-lifecycle';\nimport type { FormStepState, StepNavigationMode } from '@/engine/step-machine';\nimport type { ValidationStep } from '@/engine/value-validation';\nimport type { SubmissionSchema } from '@/engine/submission-schema';\nimport type { FormFetch } from '@/lib/form-fetch';\nimport type { FormActionTrigger } from '@/actions';\nimport type { DefaultValuesOf } from '@/builder/form-values';\nimport type { ValuesBrand } from '@/lib/normalized-form-config';\nimport type {\n\tFormStateContainer,\n\tFormStateContainerConfig,\n\tFormStateErrorsInput,\n\tFormIssueFormatter,\n\tFormStateHydration,\n\tFormSubmissionIssue,\n} from '@/state-container/types';\n\n/** The nested values of a form, as the container holds them and a submission hands them over. */\nexport type FormValues = Readonly<Record<string, unknown>>;\n\n/** What `onSubmit` is given besides the values that passed. */\nexport interface FormSubmitHelpers {\n\t/** Shows the server's answer to this submission, by path; `FORM_ROOT` stands for the form. */\n\tsetServerErrors: (errors: FormStateErrorsInput) => void;\n\t/**\n\t * The engine's `fetch`: the request to send the values with.\n\t *\n\t * @remarks It applies the engine's CSRF policy to a same-origin unsafe request, so a submit callback adds no token itself.\n\t */\n\tfetch: FormFetch;\n}\n\n/**\n * How a command ended.\n *\n * @remarks\n * - `moved`: the current step changed.\n * - `submitted` and `failed`: a submission ran and its actions and `onSubmit` succeeded or did not. Why it\n * failed is in `snapshot.submission.failures`, never in the return value.\n * - `invalid`: validation found errors, which are shown and focused.\n * - `overtaken`: an edit or a row move outran the check, so there is no verdict: nothing is shown or focused.\n * - `refused`: there was nowhere to go, or the step is unknown, skipped or not reachable.\n * - `busy`: another command was running.\n * - `cancelled`: a reset or an unmount revoked the command, which then wrote nothing.\n */\nexport type FormRuntimeOutcome =\n\t'moved' | 'submitted' | 'failed' | 'invalid' | 'overtaken' | 'refused' | 'busy' | 'cancelled';\n\n/** How `next()`, `back()` and `goTo()` ended. */\nexport type NavigationOutcome = Extract<\n\tFormRuntimeOutcome,\n\t'moved' | 'failed' | 'invalid' | 'overtaken' | 'refused' | 'busy' | 'cancelled'\n>;\n\n/** How `submit()` ended: before the last active step it acts as `next()`, so it can end `moved`. */\nexport type SubmitOutcome = Extract<\n\tFormRuntimeOutcome,\n\t'moved' | 'submitted' | 'failed' | 'invalid' | 'overtaken' | 'refused' | 'busy' | 'cancelled'\n>;\n\n/**\n * Where a submission is: `idle` until one starts, `validating` while its validation runs, `submitting` once it passed and the actions and `onSubmit` run, then how it ended.\n *\n * @remarks A submission that is `invalid` or `overtaken` goes from `validating` back to `idle` and is never `submitting`: submission starts, for the `form_submit_start` trigger and for a renderer's own start event, once it passed validation.\n */\nexport type SubmissionStatus = 'idle' | 'validating' | 'submitting' | 'success' | 'error';\n\n/**\n * Whether a submission is in progress: its validation or its actions are running.\n *\n * @remarks The one definition of busy, which the runtime's revoke and every renderer's submit button, label and busy state share.\n */\nexport function isSubmissionBusy(status: SubmissionStatus): boolean {\n\treturn status === 'validating' || status === 'submitting';\n}\n\n/**\n * What the form reports about its submissions.\n *\n * @remarks `failures` explain an `error` status and are empty otherwise. They are issues, so the form's one formatter words them.\n */\nexport interface FormSubmissionState {\n\treadonly status: SubmissionStatus;\n\treadonly failures: readonly FormSubmissionIssue[];\n\t/** The submissions that ended, whether they passed or failed validation, since the form was created or reset. */\n\treadonly submitCount: number;\n}\n\n/** What a runtime reports: its submission, and its steps. */\nexport interface FormRuntimeSnapshot {\n\treadonly submission: FormSubmissionState;\n\t/** The id of the current step. */\n\treadonly current: string;\n\t/** A `next`, `back`, `goTo` or a submit that acts as `next` is running. */\n\treadonly navigating: boolean;\n\t/** Every step in config order, skipped ones included. */\n\treadonly steps: readonly FormStepState[];\n}\n\n/** What only the renderer can do. */\nexport interface FormRuntimeHost {\n\t/**\n\t * Focuses the first control with an error among `paths`.\n\t *\n\t * @remarks The paths are those of the fields that have an error; the host picks the first in the document. The list may be empty (a rule that could not run records no field error), and the host then focuses nothing.\n\t */\n\tfocus(paths: readonly string[]): void;\n\t/** Writes the controls' values to the container and reports their native validity, as a submit does, before a check. */\n\tsync?(): void;\n\t/**\n\t * Called once a submission succeeded, after its actions and `onSubmit`, with the values the form declares, so a host whose form can post natively may do it with them.\n\t *\n\t * @remarks The values are what the form's elements write, checked by the schema derived from them, and not what the application's schema made of them (a `Date`, a class): a form posts what its fields hold. The host decides whether it posts, because a renderer always passes a stable `onSubmit` wrapper and the runtime cannot tell whether the application gave one: Radiant posts when it did not. The navigation cannot cut off the success and complete triggers, which ran first.\n\t */\n\tsubmitNatively?(values: FormValues): void;\n}\n\n/** A step of the config the runtime reads. */\nexport interface FormRuntimeStep<TAction extends FormActionConfig = FormActionConfig> extends ValidationStep {\n\treadonly id: string;\n\t/** Actions dispatched after the form's on every trigger while this step is current. */\n\treadonly actions?: ParsedActionSequence<TAction>;\n}\n\n/** The normalized form config, in the shape the runtime reads. */\nexport interface FormRuntimeConfig<\n\tTAction extends FormActionConfig = FormActionConfig,\n> extends FormStateContainerConfig {\n\treadonly id?: string;\n\treadonly navigation?: StepNavigationMode;\n\treadonly actions?: ParsedActionSequence<TAction>;\n\treadonly steps: readonly FormRuntimeStep<TAction>[];\n}\n\n/**\n * What {@link createFormRuntime} builds a runtime from.\n *\n * @template TValues - The values a submission holds, which the form's config carries ({@link ValuesBrand}); {@link FormValues} when it is not typed. It is inferred from `config`, which the runtime has parsed every submission against before it reaches a callback.\n */\nexport interface CreateFormRuntimeOptions<TAction extends FormActionConfig = FormActionConfig, TValues = FormValues> {\n\t/** The engine, for its validation registry, its actions and its `fetch`. */\n\tengine: FormEngineRuntime;\n\tconfig: FormRuntimeConfig<TAction> & ValuesBrand<TValues>;\n\t/** Values the form starts from, over the defaults of its fields. */\n\tdefaults?: DefaultValuesOf<TValues>;\n\t/** The snapshot of a container that rendered the form on the server, to start from. */\n\tsnapshot?: FormStateHydration;\n\thost: FormRuntimeHost;\n\t/** Called with the values that passed validation and matched the form's value schemas, after the submit actions and before the success trigger. */\n\tonSubmit?: (data: TValues, helpers: FormSubmitHelpers) => void | Promise<void>;\n\t/** Called when the values change, never for an error, a touch or a validation result. */\n\tonChange?: (data: FormValues) => void;\n\t/** Called with each submit action that succeeded, and the values that passed. Typed by the engine's actions. */\n\tonAction?: (action: TAction, data: TValues) => void | Promise<void>;\n\t/**\n\t * Takes the page to the `redirectUrl` a submit action asked for, once the whole submission succeeded.\n\t *\n\t * @remarks\n\t * Called at most once, after every submit action and `onSubmit` succeeded and the success trigger ran, with the\n\t * `redirectUrl` of the last successful submit action that set one. It replaces\n\t * {@link FormRuntimeHost.submitNatively} for that submission, since a native post would load a page of its own.\n\t * Defaults to {@link defaultNavigate}: `location.assign` where `globalThis.location` exists, and nothing on a server.\n\t */\n\tnavigate?: (url: string) => void;\n\t/** Called with the results of every trigger that ran actions, and once with those of the submit actions. */\n\tonActionResults?: (results: readonly SubmissionActionResult[], trigger: FormActionTrigger) => void | Promise<void>;\n}\n\n/** One instance of a form's lifecycle and wizard navigation, shared by every renderer. */\nexport interface FormRuntime {\n\t/** The form state: values, field state, validation and the captured submission. */\n\treadonly container: FormStateContainer;\n\t/** The normalized config the runtime was created from. */\n\treadonly config: FormRuntimeConfig;\n\t/**\n\t * The submitted values of the form as a Standard Schema, composed once from the config's elements.\n\t *\n\t * @remarks The schema every submission is checked against, so a tool that builds values for the form reads it from here and cannot drift from the runtime's.\n\t */\n\treadonly submissionSchema: SubmissionSchema;\n\t/** The engine's `formatIssue`, which a form without one of its own words its issues with. */\n\treadonly formatIssue: FormIssueFormatter | undefined;\n\t/**\n\t * Starts the runtime: dispatches `form_mount` the first time, and watches the values for `form_change` and `onChange`.\n\t *\n\t * @remarks The returned function stops the watch and revokes any command in flight (`next`, `back`, `goTo`, `submit`), which ends `'cancelled'`. Mounting again is allowed and dispatches `form_mount` no more.\n\t */\n\tmount: () => () => void;\n\tgetSnapshot: () => FormRuntimeSnapshot;\n\tgetServerSnapshot: () => FormRuntimeSnapshot;\n\tsubscribe: (listener: () => void) => () => void;\n\t/** Validates the current step and moves to the next active one. */\n\tnext: () => Promise<NavigationOutcome>;\n\t/** Moves to the previous active step, without validating. */\n\tback: () => Promise<NavigationOutcome>;\n\t/** Moves to the step `id`: back always, forward as the form's `navigation` allows. */\n\tgoTo: (id: string) => Promise<NavigationOutcome>;\n\t/** Acts as `next()` before the last active step; on it, validates every active step, runs the actions and `onSubmit`. */\n\tsubmit: () => Promise<SubmitOutcome>;\n\t/** Hides the outcome of the last submission: the status goes back to `idle` and the failures are dropped. */\n\tclearSubmission: () => void;\n}\n"],
|
|
5
|
+
"mappings": ";AA0EO,SAAS,iBAAiB,QAAmC;AACnE,SAAO,WAAW,gBAAgB,WAAW;AAC9C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/container-kind-of.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AnyElementRegistration, ContainerKind } from '@/types/registration';\n\n/**\n * The container semantics an element registration declares: only an input can hold children, so a static element has none.\n */\nexport function containerKindOf(registration: AnyElementRegistration | undefined): ContainerKind | undefined {\n\treturn registration?.kind === 'input' ? registration.containerKind : undefined;\n}\n"],
|
|
5
|
+
"mappings": ";AAKO,SAAS,gBAAgB,cAA6E;AAC5G,SAAO,cAAc,SAAS,UAAU,aAAa,gBAAgB;AACtE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPlainObject
|
|
3
|
+
} from "./chunk-CMPOBBRV.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/frozen-copy.ts
|
|
6
|
+
function frozenCopy(value) {
|
|
7
|
+
if (Array.isArray(value)) return Object.freeze(value.map(frozenCopy));
|
|
8
|
+
if (isPlainObject(value)) {
|
|
9
|
+
return Object.freeze(
|
|
10
|
+
Object.fromEntries(Object.entries(value).map(([key, child]) => [key, frozenCopy(child)]))
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
frozenCopy
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/frozen-copy.ts"],
|
|
4
|
+
"sourcesContent": ["import { isPlainObject } from './is-plain-object';\n\n/**\n * A deep, frozen copy of a serializable value.\n *\n * @remarks\n * For data that crosses into an immutable snapshot, such as the `params` of an issue: a caller that keeps\n * the original and changes it later must not change what a snapshot says. Plain records and arrays are\n * copied; anything else (a primitive, or a value that is not data) is kept as it is.\n */\nexport function frozenCopy<T>(value: T): T {\n\tif (Array.isArray(value)) return Object.freeze(value.map(frozenCopy)) as T;\n\tif (isPlainObject(value)) {\n\t\treturn Object.freeze(\n\t\t\tObject.fromEntries(Object.entries(value).map(([key, child]) => [key, frozenCopy(child)])),\n\t\t) as T;\n\t}\n\treturn value;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAUO,SAAS,WAAc,OAAa;AAC1C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,OAAO,OAAO,MAAM,IAAI,UAAU,CAAC;AACpE,MAAI,cAAc,KAAK,GAAG;AACzB,WAAO,OAAO;AAAA,MACb,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,WAAW,KAAK,CAAC,CAAC,CAAC;AAAA,IACzF;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/lib/reserved-path-keys.ts
|
|
2
|
+
var RESERVED_PATH_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
3
|
+
var ENGINE_KEY_PREFIX = "__";
|
|
4
|
+
function isReservedPathKey(key) {
|
|
5
|
+
return RESERVED_PATH_KEYS.has(key) || key.startsWith(ENGINE_KEY_PREFIX);
|
|
6
|
+
}
|
|
7
|
+
function assertWritablePathKey(key) {
|
|
8
|
+
if (isReservedPathKey(key)) {
|
|
9
|
+
throw new Error(`Rejected path segment '${key}'`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
ENGINE_KEY_PREFIX,
|
|
15
|
+
isReservedPathKey,
|
|
16
|
+
assertWritablePathKey
|
|
17
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lib/reserved-path-keys.ts"],
|
|
4
|
+
"sourcesContent": ["const RESERVED_PATH_KEYS: ReadonlySet<string> = new Set(['__proto__', 'constructor', 'prototype']);\n\n/** The prefix the engine keeps for its own path segments, such as the form's own error key. */\nexport const ENGINE_KEY_PREFIX = '__';\n\n/**\n * Whether a path segment is reserved: one that would reach an object's prototype, or one the engine keeps for itself.\n *\n * @remarks Every segment that starts with `__` is reserved, so a field can never collide with a key the engine adds, such as the form's own error key.\n */\nexport function isReservedPathKey(key: string): boolean {\n\treturn RESERVED_PATH_KEYS.has(key) || key.startsWith(ENGINE_KEY_PREFIX);\n}\n\n/** @throws {Error} When `key` is a reserved path segment. */\nexport function assertWritablePathKey(key: string): void {\n\tif (isReservedPathKey(key)) {\n\t\tthrow new Error(`Rejected path segment '${key}'`);\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,IAAM,qBAA0C,oBAAI,IAAI,CAAC,aAAa,eAAe,WAAW,CAAC;AAG1F,IAAM,oBAAoB;AAO1B,SAAS,kBAAkB,KAAsB;AACvD,SAAO,mBAAmB,IAAI,GAAG,KAAK,IAAI,WAAW,iBAAiB;AACvE;AAGO,SAAS,sBAAsB,KAAmB;AACxD,MAAI,kBAAkB,GAAG,GAAG;AAC3B,UAAM,IAAI,MAAM,0BAA0B,GAAG,GAAG;AAAA,EACjD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/schemas/html-attributes.ts
|
|
2
|
+
import * as z from "zod/mini";
|
|
3
|
+
var RESERVED_HTML_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
|
|
4
|
+
"$type",
|
|
5
|
+
"name",
|
|
6
|
+
"id",
|
|
7
|
+
"value",
|
|
8
|
+
"defaultValue",
|
|
9
|
+
"checked",
|
|
10
|
+
"defaultChecked",
|
|
11
|
+
"type",
|
|
12
|
+
"disabled",
|
|
13
|
+
"readonly",
|
|
14
|
+
"readOnly",
|
|
15
|
+
"required",
|
|
16
|
+
"className",
|
|
17
|
+
"class",
|
|
18
|
+
"style",
|
|
19
|
+
"ref",
|
|
20
|
+
"key",
|
|
21
|
+
"children",
|
|
22
|
+
"dangerouslySetInnerHTML"
|
|
23
|
+
]);
|
|
24
|
+
var HtmlAttributeValueSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
25
|
+
function htmlAttributesAreAllowed(record2) {
|
|
26
|
+
for (const key of Object.keys(record2)) {
|
|
27
|
+
if (RESERVED_HTML_ATTRIBUTE_KEYS.has(key)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (/^on[a-z]/i.test(key)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
var HtmlAttributesSchema = z.record(z.string(), z.optional(HtmlAttributeValueSchema)).check(
|
|
37
|
+
z.refine(htmlAttributesAreAllowed, {
|
|
38
|
+
message: "htmlAttributes cannot contain reserved control props or event handlers"
|
|
39
|
+
})
|
|
40
|
+
).check(z.describe("Extra attributes forwarded to the focusable control (for example data-testid)"));
|
|
41
|
+
function mergeControlProps(controlProps, htmlAttributes) {
|
|
42
|
+
if (!htmlAttributes) {
|
|
43
|
+
return controlProps;
|
|
44
|
+
}
|
|
45
|
+
const passthrough = Object.fromEntries(
|
|
46
|
+
Object.entries(htmlAttributes).filter((entry) => {
|
|
47
|
+
return entry[1] !== void 0;
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
return { ...passthrough, ...controlProps };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
RESERVED_HTML_ATTRIBUTE_KEYS,
|
|
55
|
+
HtmlAttributeValueSchema,
|
|
56
|
+
HtmlAttributesSchema,
|
|
57
|
+
mergeControlProps
|
|
58
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/schemas/html-attributes.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/mini';\n\nexport const RESERVED_HTML_ATTRIBUTE_KEYS = new Set([\n\t'$type',\n\t'name',\n\t'id',\n\t'value',\n\t'defaultValue',\n\t'checked',\n\t'defaultChecked',\n\t'type',\n\t'disabled',\n\t'readonly',\n\t'readOnly',\n\t'required',\n\t'className',\n\t'class',\n\t'style',\n\t'ref',\n\t'key',\n\t'children',\n\t'dangerouslySetInnerHTML',\n]);\n\nexport const HtmlAttributeValueSchema = z.union([z.string(), z.number(), z.boolean()]);\n\nfunction htmlAttributesAreAllowed(record: Record<string, unknown>): boolean {\n\tfor (const key of Object.keys(record)) {\n\t\tif (RESERVED_HTML_ATTRIBUTE_KEYS.has(key)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (/^on[a-z]/i.test(key)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nexport const HtmlAttributesSchema = z\n\t.record(z.string(), z.optional(HtmlAttributeValueSchema))\n\t.check(\n\t\tz.refine(htmlAttributesAreAllowed, {\n\t\t\tmessage: 'htmlAttributes cannot contain reserved control props or event handlers',\n\t\t}),\n\t)\n\t.check(z.describe('Extra attributes forwarded to the focusable control (for example data-testid)'));\n\nexport type HtmlAttributes = z.infer<typeof HtmlAttributesSchema>;\n\n/**\n * Merges optional field `htmlAttributes` under engine control props (identity, a11y, disabled).\n *\n * @remarks\n * Pass static control props only. Wire event handlers on the JSX node after spreading the result.\n */\nexport function mergeControlProps<const TControl extends Record<string, unknown>>(\n\tcontrolProps: TControl,\n\thtmlAttributes?: HtmlAttributes | null,\n): TControl {\n\tif (!htmlAttributes) {\n\t\treturn controlProps;\n\t}\n\n\tconst passthrough = Object.fromEntries(\n\t\tObject.entries(htmlAttributes).filter((entry): entry is [string, string | number | boolean] => {\n\t\t\treturn entry[1] !== undefined;\n\t\t}),\n\t);\n\n\treturn { ...passthrough, ...controlProps };\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,OAAO;AAEZ,IAAM,+BAA+B,oBAAI,IAAI;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAEM,IAAM,2BAA6B,QAAM,CAAG,SAAO,GAAK,SAAO,GAAK,UAAQ,CAAC,CAAC;AAErF,SAAS,yBAAyBA,SAA0C;AAC3E,aAAW,OAAO,OAAO,KAAKA,OAAM,GAAG;AACtC,QAAI,6BAA6B,IAAI,GAAG,GAAG;AAC1C,aAAO;AAAA,IACR;AACA,QAAI,YAAY,KAAK,GAAG,GAAG;AAC1B,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;AAEO,IAAM,uBACX,SAAS,SAAO,GAAK,WAAS,wBAAwB,CAAC,EACvD;AAAA,EACE,SAAO,0BAA0B;AAAA,IAClC,SAAS;AAAA,EACV,CAAC;AACF,EACC,MAAQ,WAAS,+EAA+E,CAAC;AAU5F,SAAS,kBACf,cACA,gBACW;AACX,MAAI,CAAC,gBAAgB;AACpB,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,OAAO;AAAA,IAC1B,OAAO,QAAQ,cAAc,EAAE,OAAO,CAAC,UAAwD;AAC9F,aAAO,MAAM,CAAC,MAAM;AAAA,IACrB,CAAC;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,aAAa,GAAG,aAAa;AAC1C;",
|
|
6
|
+
"names": ["record"]
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/actions/plugins/auto-save.plugin.ts
|
|
2
|
+
import * as z from "zod/mini";
|
|
3
|
+
var AutoSaveActionSchema = z.object({
|
|
4
|
+
/** Optional description for documentation and debugging purposes */
|
|
5
|
+
description: z.optional(z.string()),
|
|
6
|
+
/** Storage key to use (will use generated key if not provided) */
|
|
7
|
+
storageKey: z.optional(z.string()),
|
|
8
|
+
/** Whether to include sensitive fields in auto-save */
|
|
9
|
+
includeSensitive: z.optional(z._default(z.boolean(), false))
|
|
10
|
+
});
|
|
11
|
+
var autoSaveDraftKeyPrefix = "autosave_";
|
|
12
|
+
function getAutoSaveDraftStorageKey(formId) {
|
|
13
|
+
return `${autoSaveDraftKeyPrefix}${formId}`;
|
|
14
|
+
}
|
|
15
|
+
function autoSavePlugin(config) {
|
|
16
|
+
const { storage } = config;
|
|
17
|
+
const handler = async (context) => {
|
|
18
|
+
const action = context.config;
|
|
19
|
+
try {
|
|
20
|
+
if (config.shouldSave && !await config.shouldSave()) {
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
message: "Auto-save skipped because permission was not granted",
|
|
24
|
+
shouldContinue: true
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const storageKey = action.storageKey || config.getStorageKey?.(context) || getAutoSaveDraftStorageKey(context.formId);
|
|
28
|
+
const formData = context.formData;
|
|
29
|
+
if (!formData || Object.keys(formData).length === 0) {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
error: "No form data available for auto-save",
|
|
33
|
+
shouldContinue: true
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
let dataToSave = formData;
|
|
37
|
+
if (!action.includeSensitive) {
|
|
38
|
+
dataToSave = Object.fromEntries(
|
|
39
|
+
Object.entries(formData).filter(
|
|
40
|
+
([key]) => !key.toLowerCase().includes("password") && !key.toLowerCase().includes("secret") && !key.toLowerCase().includes("token")
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
await storage.save(storageKey, dataToSave);
|
|
45
|
+
if (config.onSave) {
|
|
46
|
+
await config.onSave(dataToSave, context);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
success: true,
|
|
50
|
+
message: `Form data auto-saved to ${storageKey}`,
|
|
51
|
+
shouldContinue: true
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to auto-save";
|
|
55
|
+
if (config.onError) {
|
|
56
|
+
await config.onError(errorMessage, context);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: errorMessage,
|
|
61
|
+
shouldContinue: true
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
$type: "auto_save",
|
|
67
|
+
schema: AutoSaveActionSchema,
|
|
68
|
+
metadata: {
|
|
69
|
+
name: "Auto Save",
|
|
70
|
+
description: "Automatically save form data to storage",
|
|
71
|
+
icon: "save",
|
|
72
|
+
defaultTriggers: ["form_change"]
|
|
73
|
+
},
|
|
74
|
+
execute: handler
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
AutoSaveActionSchema,
|
|
80
|
+
getAutoSaveDraftStorageKey,
|
|
81
|
+
autoSavePlugin
|
|
82
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/actions/plugins/auto-save.plugin.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/mini';\nimport type { BuilderActionRuntimeContext, BuilderActionRegistration, BuilderActionConfig } from '@/types';\n\n/**\n * Storage Interface for Auto-Save Plugin\n */\nexport interface AutoSaveStorage {\n\t/** Save form data to storage */\n\tsave: (key: string, data: unknown) => Promise<void> | void;\n\t/** Load form data from storage, synchronously or as a promise. */\n\tload: (key: string) => unknown;\n\t/** Remove form data from storage */\n\tremove: (key: string) => Promise<void> | void;\n}\n\n/**\n * Auto-Save Plugin Configuration\n */\nexport interface AutoSavePluginConfig {\n\t/** Custom storage implementation */\n\tstorage: AutoSaveStorage;\n\t/** Checks whether saving is currently allowed, for example by a consent tool. */\n\tshouldSave?: () => boolean | Promise<boolean>;\n\t/** Called when auto-save succeeds */\n\tonSave?: (data: unknown, context: BuilderActionRuntimeContext<AutoSaveAction>) => void | Promise<void>;\n\t/** Called when auto-save fails */\n\tonError?: (error: string, context: BuilderActionRuntimeContext<AutoSaveAction>) => void | Promise<void>;\n\t/** Custom storage key generator */\n\tgetStorageKey?: (context: BuilderActionRuntimeContext<AutoSaveAction>) => string;\n}\n\n/** Schema for the `auto_save` action configuration. */\nexport const AutoSaveActionSchema = z.object({\n\t/** Optional description for documentation and debugging purposes */\n\tdescription: z.optional(z.string()),\n\t/** Storage key to use (will use generated key if not provided) */\n\tstorageKey: z.optional(z.string()),\n\t/** Whether to include sensitive fields in auto-save */\n\tincludeSensitive: z.optional(z._default(z.boolean(), false)),\n});\n\nexport type AutoSaveAction = BuilderActionConfig<'auto_save', typeof AutoSaveActionSchema>;\n\nconst autoSaveDraftKeyPrefix = 'autosave_';\n\n/** Builds the default storage key shared by auto-save and reset actions. */\nexport function getAutoSaveDraftStorageKey(formId: string): string {\n\treturn `${autoSaveDraftKeyPrefix}${formId}`;\n}\n\n/** Creates a configured `auto_save` action registration. */\nexport function autoSavePlugin(\n\tconfig: AutoSavePluginConfig,\n): BuilderActionRegistration<'auto_save', typeof AutoSaveActionSchema> {\n\tconst { storage } = config;\n\n\tconst handler = async (context: BuilderActionRuntimeContext<AutoSaveAction>) => {\n\t\tconst action = context.config;\n\t\ttry {\n\t\t\tif (config.shouldSave && !(await config.shouldSave())) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tmessage: 'Auto-save skipped because permission was not granted',\n\t\t\t\t\tshouldContinue: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst storageKey =\n\t\t\t\taction.storageKey || config.getStorageKey?.(context) || getAutoSaveDraftStorageKey(context.formId);\n\n\t\t\tconst formData = context.formData;\n\n\t\t\tif (!formData || Object.keys(formData).length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: 'No form data available for auto-save',\n\t\t\t\t\tshouldContinue: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet dataToSave = formData;\n\t\t\tif (!action.includeSensitive) {\n\t\t\t\tdataToSave = Object.fromEntries(\n\t\t\t\t\tObject.entries(formData).filter(\n\t\t\t\t\t\t([key]) =>\n\t\t\t\t\t\t\t!key.toLowerCase().includes('password') &&\n\t\t\t\t\t\t\t!key.toLowerCase().includes('secret') &&\n\t\t\t\t\t\t\t!key.toLowerCase().includes('token'),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait storage.save(storageKey, dataToSave);\n\n\t\t\tif (config.onSave) {\n\t\t\t\tawait config.onSave(dataToSave, context);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tmessage: `Form data auto-saved to ${storageKey}`,\n\t\t\t\tshouldContinue: true,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : 'Failed to auto-save';\n\n\t\t\tif (config.onError) {\n\t\t\t\tawait config.onError(errorMessage, context);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: errorMessage,\n\t\t\t\tshouldContinue: true,\n\t\t\t};\n\t\t}\n\t};\n\n\treturn {\n\t\t$type: 'auto_save',\n\t\tschema: AutoSaveActionSchema,\n\t\tmetadata: {\n\t\t\tname: 'Auto Save',\n\t\t\tdescription: 'Automatically save form data to storage',\n\t\t\ticon: 'save',\n\t\t\tdefaultTriggers: ['form_change'],\n\t\t},\n\t\texecute: handler,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAY,OAAO;AAgCZ,IAAM,uBAAyB,SAAO;AAAA;AAAA,EAE5C,aAAe,WAAW,SAAO,CAAC;AAAA;AAAA,EAElC,YAAc,WAAW,SAAO,CAAC;AAAA;AAAA,EAEjC,kBAAoB,WAAW,WAAW,UAAQ,GAAG,KAAK,CAAC;AAC5D,CAAC;AAID,IAAM,yBAAyB;AAGxB,SAAS,2BAA2B,QAAwB;AAClE,SAAO,GAAG,sBAAsB,GAAG,MAAM;AAC1C;AAGO,SAAS,eACf,QACsE;AACtE,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,UAAU,OAAO,YAAyD;AAC/E,UAAM,SAAS,QAAQ;AACvB,QAAI;AACH,UAAI,OAAO,cAAc,CAAE,MAAM,OAAO,WAAW,GAAI;AACtD,eAAO;AAAA,UACN,SAAS;AAAA,UACT,SAAS;AAAA,UACT,gBAAgB;AAAA,QACjB;AAAA,MACD;AAEA,YAAM,aACL,OAAO,cAAc,OAAO,gBAAgB,OAAO,KAAK,2BAA2B,QAAQ,MAAM;AAElG,YAAM,WAAW,QAAQ;AAEzB,UAAI,CAAC,YAAY,OAAO,KAAK,QAAQ,EAAE,WAAW,GAAG;AACpD,eAAO;AAAA,UACN,SAAS;AAAA,UACT,OAAO;AAAA,UACP,gBAAgB;AAAA,QACjB;AAAA,MACD;AAEA,UAAI,aAAa;AACjB,UAAI,CAAC,OAAO,kBAAkB;AAC7B,qBAAa,OAAO;AAAA,UACnB,OAAO,QAAQ,QAAQ,EAAE;AAAA,YACxB,CAAC,CAAC,GAAG,MACJ,CAAC,IAAI,YAAY,EAAE,SAAS,UAAU,KACtC,CAAC,IAAI,YAAY,EAAE,SAAS,QAAQ,KACpC,CAAC,IAAI,YAAY,EAAE,SAAS,OAAO;AAAA,UACrC;AAAA,QACD;AAAA,MACD;AAEA,YAAM,QAAQ,KAAK,YAAY,UAAU;AAEzC,UAAI,OAAO,QAAQ;AAClB,cAAM,OAAO,OAAO,YAAY,OAAO;AAAA,MACxC;AAEA,aAAO;AAAA,QACN,SAAS;AAAA,QACT,SAAS,2BAA2B,UAAU;AAAA,QAC9C,gBAAgB;AAAA,MACjB;AAAA,IACD,SAAS,OAAO;AACf,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAE9D,UAAI,OAAO,SAAS;AACnB,cAAM,OAAO,QAAQ,cAAc,OAAO;AAAA,MAC3C;AAEA,aAAO;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,gBAAgB;AAAA,MACjB;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU;AAAA,MACT,MAAM;AAAA,MACN,aAAa;AAAA,MACb,MAAM;AAAA,MACN,iBAAiB,CAAC,aAAa;AAAA,IAChC;AAAA,IACA,SAAS;AAAA,EACV;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/engine/form-action-context.ts
|
|
2
|
+
var stepTimings = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
var countTouched = (touched) => Object.values(touched).filter((isTouched) => isTouched === true).length;
|
|
4
|
+
function getStepStartTime(form, stepId, mountedAt, now) {
|
|
5
|
+
const timing = stepTimings.get(form);
|
|
6
|
+
if (!timing || timing.mountedAt !== mountedAt) {
|
|
7
|
+
stepTimings.set(form, { mountedAt, stepId, stepStartTime: mountedAt });
|
|
8
|
+
return mountedAt;
|
|
9
|
+
}
|
|
10
|
+
if (timing.stepId !== stepId) {
|
|
11
|
+
timing.stepId = stepId;
|
|
12
|
+
timing.stepStartTime = now;
|
|
13
|
+
}
|
|
14
|
+
return timing.stepStartTime;
|
|
15
|
+
}
|
|
16
|
+
function buildFormActionContext({
|
|
17
|
+
config,
|
|
18
|
+
values,
|
|
19
|
+
formState,
|
|
20
|
+
step,
|
|
21
|
+
mountedAt,
|
|
22
|
+
form,
|
|
23
|
+
fetch
|
|
24
|
+
}) {
|
|
25
|
+
const now = Date.now();
|
|
26
|
+
return {
|
|
27
|
+
formId: config.id || "unnamed-form",
|
|
28
|
+
formData: values,
|
|
29
|
+
stepId: step.id,
|
|
30
|
+
currentStep: step.position,
|
|
31
|
+
totalSteps: step.total,
|
|
32
|
+
isValid: formState.isValid,
|
|
33
|
+
errors: formState.errors,
|
|
34
|
+
metadata: {
|
|
35
|
+
stepStartTime: getStepStartTime(form, step.id, mountedAt, now),
|
|
36
|
+
totalFormTime: now - mountedAt,
|
|
37
|
+
userInteractions: countTouched(formState.touched) + formState.submitCount
|
|
38
|
+
},
|
|
39
|
+
form,
|
|
40
|
+
fetch
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function collectStepActions(config, stepId) {
|
|
44
|
+
return [...config.actions ?? [], ...config.steps.find((step) => step.id === stepId)?.actions ?? []];
|
|
45
|
+
}
|
|
46
|
+
function hasConfiguredActions(config) {
|
|
47
|
+
return Boolean(config.actions?.length) || config.steps.some((step) => Boolean(step.actions?.length));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
buildFormActionContext,
|
|
52
|
+
collectStepActions,
|
|
53
|
+
hasConfiguredActions
|
|
54
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/engine/form-action-context.ts"],
|
|
4
|
+
"sourcesContent": ["import type { FormFetch } from '../lib/form-fetch';\nimport type { BuilderActionBaseContext } from '@/types';\nimport type { FormStateError } from '@/state-container/types';\n\n/**\n * Renderer form state in the engine's shape.\n *\n * @remarks\n * `errors` is flat, one entry per dotted field path, so `address.street` is read as\n * `errors['address.street']` in every renderer and a container and a row inside it\n * can both fail, and `touched` is flat the same way. A renderer that keeps them in another shape\n * converts them before building the context.\n *\n * `isValid` is the snapshot's: true when no error is recorded, in every renderer. It says\n * nothing about fields no validation has reached; `context.form.checkValidity()` answers for\n * the current values.\n */\nexport interface FormActionContextFormState {\n\t/** Whether no error is recorded for a path that takes part, as `snapshot.isValid` says. */\n\tisValid: boolean;\n\t/** Errors by dotted field path, as `validateFormValues` returns them. */\n\terrors: Readonly<Record<string, FormStateError>>;\n\t/** Touched fields by dotted path, `true` at each field the user has touched. */\n\ttouched: Readonly<Partial<Record<string, boolean>>>;\n\tsubmitCount: number;\n}\n\ninterface StepTiming {\n\tmountedAt: number;\n\tstepId: string;\n\tstepStartTime: number;\n}\n\ninterface BuildFormActionContextOptions<TForm extends BuilderActionBaseContext['form']> {\n\tconfig: { id?: string };\n\tvalues: Record<string, unknown>;\n\tformState: FormActionContextFormState;\n\t/** The current step: its id, its position among the steps that are not skipped and how many there are. */\n\tstep: { id: string; position: number; total: number };\n\tmountedAt: number;\n\tform: TForm;\n\t/** The engine's `fetch`, which the context hands to actions. */\n\tfetch: FormFetch;\n}\n\nconst stepTimings = new WeakMap<object, StepTiming>();\n\nconst countTouched = (touched: Readonly<Partial<Record<string, boolean>>>): number =>\n\tObject.values(touched).filter((isTouched) => isTouched === true).length;\n\nfunction getStepStartTime(form: object, stepId: string, mountedAt: number, now: number): number {\n\tconst timing = stepTimings.get(form);\n\tif (!timing || timing.mountedAt !== mountedAt) {\n\t\tstepTimings.set(form, { mountedAt, stepId, stepStartTime: mountedAt });\n\t\treturn mountedAt;\n\t}\n\n\tif (timing.stepId !== stepId) {\n\t\ttiming.stepId = stepId;\n\t\ttiming.stepStartTime = now;\n\t}\n\n\treturn timing.stepStartTime;\n}\n\n/**\n * Builds the framework-neutral action context used by form action dispatch.\n *\n * @remarks\n * Step start times are kept per form instance and reset when its current step changes.\n * `userInteractions` counts touched fields plus submissions.\n */\nexport function buildFormActionContext<TForm extends BuilderActionBaseContext['form']>({\n\tconfig,\n\tvalues,\n\tformState,\n\tstep,\n\tmountedAt,\n\tform,\n\tfetch,\n}: BuildFormActionContextOptions<TForm>): BuilderActionBaseContext {\n\tconst now = Date.now();\n\n\treturn {\n\t\tformId: config.id || 'unnamed-form',\n\t\tformData: values,\n\t\tstepId: step.id,\n\t\tcurrentStep: step.position,\n\t\ttotalSteps: step.total,\n\t\tisValid: formState.isValid,\n\t\terrors: formState.errors,\n\t\tmetadata: {\n\t\t\tstepStartTime: getStepStartTime(form, step.id, mountedAt, now),\n\t\t\ttotalFormTime: now - mountedAt,\n\t\t\tuserInteractions: countTouched(formState.touched) + formState.submitCount,\n\t\t},\n\t\tform,\n\t\tfetch,\n\t};\n}\n\ninterface ActionScopes<TAction> {\n\tactions?: readonly TAction[];\n\tsteps: readonly { id: string; actions?: readonly TAction[] }[];\n}\n\n/**\n * Lists the actions a trigger dispatches while the step `stepId` is current: the form's `actions`,\n * then that step's.\n *\n * @remarks\n * The runtime dispatches `step_leave` while the step being left is current and `step_change` and\n * `step_enter` once the entered step is, so a step's actions see the step triggers of navigation\n * into and out of that step, plus every other trigger fired while it is current.\n */\nexport function collectStepActions<TAction>(config: ActionScopes<TAction>, stepId: string): TAction[] {\n\treturn [...(config.actions ?? []), ...(config.steps.find((step) => step.id === stepId)?.actions ?? [])];\n}\n\n/** Whether the form or any of its steps configures an action. */\nexport function hasConfiguredActions(config: ActionScopes<unknown>): boolean {\n\treturn Boolean(config.actions?.length) || config.steps.some((step) => Boolean(step.actions?.length));\n}\n"],
|
|
5
|
+
"mappings": ";AA6CA,IAAM,cAAc,oBAAI,QAA4B;AAEpD,IAAM,eAAe,CAAC,YACrB,OAAO,OAAO,OAAO,EAAE,OAAO,CAAC,cAAc,cAAc,IAAI,EAAE;AAElE,SAAS,iBAAiB,MAAc,QAAgB,WAAmB,KAAqB;AAC/F,QAAM,SAAS,YAAY,IAAI,IAAI;AACnC,MAAI,CAAC,UAAU,OAAO,cAAc,WAAW;AAC9C,gBAAY,IAAI,MAAM,EAAE,WAAW,QAAQ,eAAe,UAAU,CAAC;AACrE,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,WAAW,QAAQ;AAC7B,WAAO,SAAS;AAChB,WAAO,gBAAgB;AAAA,EACxB;AAEA,SAAO,OAAO;AACf;AASO,SAAS,uBAAuE;AAAA,EACtF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAmE;AAClE,QAAM,MAAM,KAAK,IAAI;AAErB,SAAO;AAAA,IACN,QAAQ,OAAO,MAAM;AAAA,IACrB,UAAU;AAAA,IACV,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,YAAY,KAAK;AAAA,IACjB,SAAS,UAAU;AAAA,IACnB,QAAQ,UAAU;AAAA,IAClB,UAAU;AAAA,MACT,eAAe,iBAAiB,MAAM,KAAK,IAAI,WAAW,GAAG;AAAA,MAC7D,eAAe,MAAM;AAAA,MACrB,kBAAkB,aAAa,UAAU,OAAO,IAAI,UAAU;AAAA,IAC/D;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAgBO,SAAS,mBAA4B,QAA+B,QAA2B;AACrG,SAAO,CAAC,GAAI,OAAO,WAAW,CAAC,GAAI,GAAI,OAAO,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,MAAM,GAAG,WAAW,CAAC,CAAE;AACvG;AAGO,SAAS,qBAAqB,QAAwC;AAC5E,SAAO,QAAQ,OAAO,SAAS,MAAM,KAAK,OAAO,MAAM,KAAK,CAAC,SAAS,QAAQ,KAAK,SAAS,MAAM,CAAC;AACpG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/schemas/validation/errors.ts
|
|
2
|
+
var ValidationRuleError = class extends Error {
|
|
3
|
+
ruleType;
|
|
4
|
+
constructor(ruleType, message, options) {
|
|
5
|
+
super(message, options);
|
|
6
|
+
this.name = "ValidationRuleError";
|
|
7
|
+
this.ruleType = ruleType;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var ValidationSuperseded = class extends Error {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("The validation was replaced by a later one before it ran.");
|
|
13
|
+
this.name = "ValidationSuperseded";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var ValidationUnavailable = class extends Error {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super("The service that validates the value could not answer.", options);
|
|
19
|
+
this.name = "ValidationUnavailable";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var REPORTED_TEXT = "schemaEngineReportedText";
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
ValidationRuleError,
|
|
26
|
+
ValidationSuperseded,
|
|
27
|
+
ValidationUnavailable,
|
|
28
|
+
REPORTED_TEXT
|
|
29
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/schemas/validation/errors.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * A validation rule that cannot be turned into a schema.\n *\n * @remarks\n * Thrown by `ValidationRegistry.createSchema` for a type nobody registered or a handler that throws on\n * the rule it was given. `cause` is the handler's own error.\n */\nexport class ValidationRuleError extends Error {\n\treadonly ruleType: string;\n\n\tconstructor(ruleType: string, message: string, options?: { cause?: unknown }) {\n\t\tsuper(message, options);\n\t\tthis.name = 'ValidationRuleError';\n\t\tthis.ruleType = ruleType;\n\t}\n}\n\n/**\n * Thrown by a rule's schema when the check it started was replaced before it ran, so it has no result.\n *\n * @remarks\n * Distinct from a pass and from a failure: the value was never checked, and a later check owns the answer.\n * It is state, never an issue. `validateFieldValue` reports it as `superseded`, and a caller must not take\n * the field for valid.\n */\nexport class ValidationSuperseded extends Error {\n\tconstructor() {\n\t\tsuper('The validation was replaced by a later one before it ran.');\n\t\tthis.name = 'ValidationSuperseded';\n\t}\n}\n\n/**\n * Thrown by a rule's schema when the service it asks cannot answer: a non-ok response, a network failure or a body that is not an answer.\n *\n * @remarks\n * Operational, not a field error and never cached: the value was not judged, and asking again may succeed.\n * `validateFieldValue` reports it as a `FormValidationFailure`, keeping this as its cause.\n */\nexport class ValidationUnavailable extends Error {\n\tconstructor(options?: { cause?: unknown }) {\n\t\tsuper('The service that validates the value could not answer.', options);\n\t\tthis.name = 'ValidationUnavailable';\n\t}\n}\n\n/**\n * The key of an issue's `params` under which a schema reports text that comes from outside the engine.\n *\n * @remarks\n * The library's own text for an issue (such as 'Invalid input') is never read. Text a service answered with is\n * put here by the schema, and only this reaches a registration's `message` hook.\n */\nexport const REPORTED_TEXT = 'schemaEngineReportedText';\n"],
|
|
5
|
+
"mappings": ";AAOO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACrC;AAAA,EAET,YAAY,UAAkB,SAAiB,SAA+B;AAC7E,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EACjB;AACD;AAUO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC/C,cAAc;AACb,UAAM,2DAA2D;AACjE,SAAK,OAAO;AAAA,EACb;AACD;AASO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAChD,YAAY,SAA+B;AAC1C,UAAM,0DAA0D,OAAO;AACvE,SAAK,OAAO;AAAA,EACb;AACD;AASO,IAAM,gBAAgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildFormEngine
|
|
3
|
+
} from "./chunk-V5H7L5PJ.js";
|
|
4
|
+
|
|
5
|
+
// src/engine/create-form-engine.ts
|
|
6
|
+
function createFormEngine(options) {
|
|
7
|
+
return buildFormEngine({
|
|
8
|
+
elements: options?.elements,
|
|
9
|
+
recipes: options?.recipes,
|
|
10
|
+
actions: options?.actions,
|
|
11
|
+
validations: options?.validations,
|
|
12
|
+
catalog: options?.catalog,
|
|
13
|
+
layout: options?.layout,
|
|
14
|
+
defaultWizardRecipe: options?.defaultWizardRecipe,
|
|
15
|
+
formatIssue: options?.formatIssue,
|
|
16
|
+
fetch: options?.fetch,
|
|
17
|
+
csrf: options?.csrf
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
createFormEngine
|
|
23
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/engine/create-form-engine.ts"],
|
|
4
|
+
"sourcesContent": ["import type { CsrfPolicy, FormFetch } from '@/lib/form-fetch';\nimport type { FormIssueFormatter } from '@/state-container/types';\nimport { buildFormEngine } from './build-form-engine';\nimport type {\n\tMergedRegistrationMap,\n\tMergedOutputMap,\n\tMergedValueMap,\n\tMergedActionRegistrationMap,\n\tElementRegistrationConstraint,\n\tRecipeRegistrationConstraint,\n\tActionRegistrationConstraint,\n\tValidationRegistrationConstraint,\n} from '@/builder/types.utils';\nimport type { FormEngine } from './form-engine';\nimport type { SchemaMetadataCatalog } from './schema-metadata-catalog';\nimport type { LayoutAxes, LayoutInput } from '@schema-engine/layout';\n\nexport interface CreateFormEngineOptions<\n\tTElements extends readonly ElementRegistrationConstraint[] = readonly [],\n\tTRecipes extends readonly RecipeRegistrationConstraint[] = readonly [],\n\tTActions extends readonly ActionRegistrationConstraint[] = readonly [],\n\tTLayout extends LayoutInput = Record<never, never>,\n> {\n\telements?: TElements;\n\trecipes?: TRecipes;\n\tactions?: TActions;\n\t/**\n\t * Validation rules to add to the built-in ones and those the elements declare.\n\t *\n\t * @remarks\n\t * Stored with the other validations in a read-only registry: a later registration with the same\n\t * `$type` replaces an earlier one without a warning, and each `schema` must be a Standard Schema or\n\t * the build throws. These come after the validations elements declare, so they win over them.\n\t * {@link FormEngine.extend} inherits them. Rule configs are not typed per engine: the rule objects in\n\t * a field's `rules` keep their `$type` string.\n\t */\n\tvalidations?: readonly ValidationRegistrationConstraint[];\n\t/**\n\t * Extra schema metadata entries. The engine copies the catalog and writes every\n\t * registration's entry over it, so an entry with a registration's id is replaced.\n\t */\n\tcatalog?: SchemaMetadataCatalog;\n\t/**\n\t * Recipe `validateForm` writes as `view` for a multi-step form that omits one. Defaults to `'bare-controls'`.\n\t *\n\t * @remarks\n\t * Must name a registered `wizard`-kind recipe, or the engine build throws. {@link FormEngine.extend}\n\t * inherits it. Without this option and without a registered `bare-controls`, a multi-step form\n\t * without `view` stays without one and `validateForm` warns.\n\t */\n\tdefaultWizardRecipe?: string;\n\t/**\n\t * Turns an issue into the text to show: the one formatter both renderer bindings read.\n\t *\n\t * @remarks\n\t * The engine reports what is wrong (`type`, `ruleId`, `params`) and owns no text, so the application's\n\t * i18n layer supplies it here once, as `(issue, { path }) => string`. A renderer or provider may still pass\n\t * its own for one form, and the issue's own `message` is the fallback. {@link FormEngine.extend} inherits it.\n\t */\n\tformatIssue?: FormIssueFormatter;\n\t/**\n\t * The layout theme: a compiled theme from `createLayoutTheme`, or inline `{ grid, appearance }` options.\n\t *\n\t * @remarks\n\t * `grid` is the grid vocabulary (breakpoint thresholds, gap tokens, default min column width).\n\t * `appearance` is the named axes a form picks values on, over the built-in `size`\n\t * (`compact | default | comfortable`) and `surface` (`flat | outlined | elevated`); an axis lists\n\t * its values by name, or maps each value to the CSS custom properties it sets. Elements and\n\t * recipe slots declare which axes they support.\n\t *\n\t * Pass one compiled theme to several engines and they share its `data-se-theme` and stylesheet,\n\t * so an embedded form matches its page. Inline options compile a theme of the engine's own, with\n\t * the renderer's `data-se-*` attribute names reserved so an axis cannot reuse one.\n\t * {@link FormEngine.extend} inherits it.\n\t */\n\tlayout?: TLayout;\n\t/**\n\t * The request function every request the engine makes goes through; the global `fetch` by default.\n\t *\n\t * @remarks\n\t * Today that is the `async` validation rule, and actions receive it as `context.fetch`. It is exposed as\n\t * {@link FormEngine.fetch}, with the CSRF policy applied. {@link FormEngine.extend} inherits it.\n\t */\n\tfetch?: FormFetch;\n\t/**\n\t * Where a CSRF token comes from, from `csrf.fromMeta`, `csrf.fromCookie` or `csrf.custom` of `@schema-engine/forms/csrf`.\n\t *\n\t * @remarks\n\t * Off unless set. The engine's `fetch` then adds the token as the policy's header to same-origin requests with an\n\t * unsafe method, and a binding reads the policy with {@link FormEngine.getCsrf} to add a hidden input to a native\n\t * post. The token is read at request time and is never part of the config, the payload or the submitted values.\n\t * {@link FormEngine.extend} inherits it.\n\t */\n\tcsrf?: CsrfPolicy;\n}\n\n/** Options for {@link FormEngine.extend}; layout theme and default wizard recipe are always inherited from the source engine. */\nexport type ExtendFormEngineOptions<\n\tTElements extends readonly ElementRegistrationConstraint[] = readonly [],\n\tTRecipes extends readonly RecipeRegistrationConstraint[] = readonly [],\n\tTActions extends readonly ActionRegistrationConstraint[] = readonly [],\n> = Omit<\n\tCreateFormEngineOptions<TElements, TRecipes, TActions>,\n\t'layout' | 'defaultWizardRecipe' | 'formatIssue' | 'fetch' | 'csrf'\n>;\n\n/** {@link FormEngine} specialization produced from registration lists. */\nexport type FormEngineFromOptions<\n\tTElements extends readonly ElementRegistrationConstraint[],\n\tTRecipes extends readonly RecipeRegistrationConstraint[],\n\tTActions extends readonly ActionRegistrationConstraint[],\n\tTLayout extends LayoutInput = Record<never, never>,\n> = FormEngine<\n\tMergedRegistrationMap<TElements>,\n\tMergedRegistrationMap<TRecipes>,\n\tMergedActionRegistrationMap<TActions>,\n\t{\n\t\telements: MergedOutputMap<TElements>;\n\t\trecipes: MergedOutputMap<TRecipes>;\n\t\tactions: MergedOutputMap<TActions>;\n\t\tvalues: MergedValueMap<TElements>;\n\t},\n\tLayoutAxes<TLayout>\n>;\n\n/**\n * Create an immutable {@link FormEngine} from declarative registration arrays.\n *\n * Duplicate `$type` values follow last-wins semantics at runtime. For typing,\n * last-wins applies to tuples and inline arrays; open `T[]` values use a union\n * of configs for the same `$type`. Spread shared barrels and append overrides:\n *\n * ```ts\n * createFormEngine({ elements: [...schemaFormRegistrations, customInput] });\n * ```\n */\nexport function createFormEngine<\n\tconst TElements extends readonly ElementRegistrationConstraint[] = readonly [],\n\tconst TRecipes extends readonly RecipeRegistrationConstraint[] = readonly [],\n\tconst TActions extends readonly ActionRegistrationConstraint[] = readonly [],\n\tconst TLayout extends LayoutInput = Record<never, never>,\n>(\n\toptions?: CreateFormEngineOptions<TElements, TRecipes, TActions, TLayout>,\n): FormEngineFromOptions<TElements, TRecipes, TActions, TLayout> {\n\treturn buildFormEngine({\n\t\telements: options?.elements,\n\t\trecipes: options?.recipes,\n\t\tactions: options?.actions,\n\t\tvalidations: options?.validations,\n\t\tcatalog: options?.catalog,\n\t\tlayout: options?.layout,\n\t\tdefaultWizardRecipe: options?.defaultWizardRecipe,\n\t\tformatIssue: options?.formatIssue,\n\t\tfetch: options?.fetch,\n\t\tcsrf: options?.csrf,\n\t}) as unknown as FormEngineFromOptions<TElements, TRecipes, TActions, TLayout>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAwIO,SAAS,iBAMf,SACgE;AAChE,SAAO,gBAAgB;AAAA,IACtB,UAAU,SAAS;AAAA,IACnB,SAAS,SAAS;AAAA,IAClB,SAAS,SAAS;AAAA,IAClB,aAAa,SAAS;AAAA,IACtB,SAAS,SAAS;AAAA,IAClB,QAAQ,SAAS;AAAA,IACjB,qBAAqB,SAAS;AAAA,IAC9B,aAAa,SAAS;AAAA,IACtB,OAAO,SAAS;AAAA,IAChB,MAAM,SAAS;AAAA,EAChB,CAAC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
notificationPlugin
|
|
3
|
+
} from "./chunk-QT3EYUL5.js";
|
|
4
|
+
import {
|
|
5
|
+
logger
|
|
6
|
+
} from "./chunk-VGGERKV2.js";
|
|
7
|
+
|
|
8
|
+
// src/actions/plugins/notification.registration.ts
|
|
9
|
+
var NotificationActionRegistration = notificationPlugin({
|
|
10
|
+
onSuccess: (message, context) => {
|
|
11
|
+
logger.info(`[Success] ${message}`, { formId: context.formId });
|
|
12
|
+
},
|
|
13
|
+
onError: (message, context) => {
|
|
14
|
+
logger.error(`[Error] ${message}`, { formId: context.formId });
|
|
15
|
+
},
|
|
16
|
+
onWarning: (message, context) => {
|
|
17
|
+
logger.warn(`[Warning] ${message}`, { formId: context.formId });
|
|
18
|
+
},
|
|
19
|
+
onInfo: (message, context) => {
|
|
20
|
+
logger.info(`[Info] ${message}`, { formId: context.formId });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
NotificationActionRegistration
|
|
26
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/actions/plugins/notification.registration.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Notification Action Registration\n *\n * Pre-configured notification action.\n * Register this declaration on your engine to enable the notification action type and get a default configuration.\n *\n * @example\n * ```typescript\n * import { createFormEngine, NotificationActionRegistration } from '@schema-engine/forms';\n *\n * const engine = createFormEngine({\n * actions: [NotificationActionRegistration],\n * });\n * ```\n */\n\nimport { notificationPlugin, NotificationActionSchema } from './notification.plugin';\nimport { logger } from '@/lib/logger';\nimport type { BuilderActionRegistration } from '@/types';\n\n/**\n * Default Notification Action Registration\n * Logs notifications via logger (override with toast library in your app)\n */\nexport const NotificationActionRegistration: BuilderActionRegistration<\n\t'show_notification',\n\ttypeof NotificationActionSchema\n> = notificationPlugin({\n\tonSuccess: (message, context) => {\n\t\tlogger.info(`[Success] ${message}`, { formId: context.formId });\n\t},\n\tonError: (message, context) => {\n\t\tlogger.error(`[Error] ${message}`, { formId: context.formId });\n\t},\n\tonWarning: (message, context) => {\n\t\tlogger.warn(`[Warning] ${message}`, { formId: context.formId });\n\t},\n\tonInfo: (message, context) => {\n\t\tlogger.info(`[Info] ${message}`, { formId: context.formId });\n\t},\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAwBO,IAAM,iCAGT,mBAAmB;AAAA,EACtB,WAAW,CAAC,SAAS,YAAY;AAChC,WAAO,KAAK,aAAa,OAAO,IAAI,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EAC/D;AAAA,EACA,SAAS,CAAC,SAAS,YAAY;AAC9B,WAAO,MAAM,WAAW,OAAO,IAAI,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EAC9D;AAAA,EACA,WAAW,CAAC,SAAS,YAAY;AAChC,WAAO,KAAK,aAAa,OAAO,IAAI,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EAC/D;AAAA,EACA,QAAQ,CAAC,SAAS,YAAY;AAC7B,WAAO,KAAK,UAAU,OAAO,IAAI,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAAA,EAC5D;AACD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|