@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,404 @@
|
|
|
1
|
+
import type { FieldParticipation, ValidationStep } from '../engine/value-validation.js';
|
|
2
|
+
import type { ValidationRegistry } from '../schemas/validation/validation-registry.js';
|
|
3
|
+
import type { FieldArrayCommands } from './field-array';
|
|
4
|
+
/**
|
|
5
|
+
* The internal form state contract: what a form's state container owns, and what it leaves to others.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The container owns the nested value tree, field state (errors, touched, dirty), field-array row ids and
|
|
9
|
+
* the atomic updates that keep them consistent. A path is a plain dotted path with the row index in it
|
|
10
|
+
* (`contacts.1.email`) wherever the API takes one, and {@link FORM_ROOT} names the form itself. It holds
|
|
11
|
+
* no submission state (`isSubmitting`, `submitCount`, a submit guard): the runtime owns those. Focus,
|
|
12
|
+
* native controls and native submit belong to the host, and there is no control registration: a host
|
|
13
|
+
* bridges a control into the container with {@link FormStateContainer.setValue} and
|
|
14
|
+
* {@link FormStateContainer.blur}, reports the control's native validity with
|
|
15
|
+
* {@link FormStateContainer.reportNative}, and submits with {@link FormStateContainer.submit}, whose result
|
|
16
|
+
* carries the way to hand back the server's answer.
|
|
17
|
+
*
|
|
18
|
+
* The container is named for what it holds, not `FormStore`, which is a class of Radiant UI. The contract is
|
|
19
|
+
* public through `@schema-engine/forms/state-container`, with `@schema-engine/forms/csrf` and
|
|
20
|
+
* `@schema-engine/forms/server-errors` beside it. Its conformance suite is `formStateContainerConformance` from
|
|
21
|
+
* `@schema-engine/forms/testing`, which takes the `describe` and `test` of any test runner.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The key of an error about the form itself rather than a field, in `snapshot.errors` and in `setServerErrors`.
|
|
25
|
+
*
|
|
26
|
+
* @remarks Path segments that start with `__` are reserved, so no field can have this name.
|
|
27
|
+
*/
|
|
28
|
+
export declare const FORM_ROOT = "__root__";
|
|
29
|
+
/**
|
|
30
|
+
* When a field validates before a check of it has failed: on `change`, on `blur`, on both (`all`), on the
|
|
31
|
+
* first `blur` and on every change after it (`onTouched`, as React Hook Form's mode of that name) or only on
|
|
32
|
+
* an explicit {@link FormStateContainer.validate}.
|
|
33
|
+
*/
|
|
34
|
+
export type FormValidationMode = 'onSubmit' | 'onChange' | 'onBlur' | 'onTouched' | 'all';
|
|
35
|
+
/** When a field validates once a {@link FormStateContainer.validate} over it has failed. */
|
|
36
|
+
export type FormReValidateMode = 'onSubmit' | 'onChange' | 'onBlur';
|
|
37
|
+
/** Who reported an issue. */
|
|
38
|
+
export type FormStateSource = 'server' | 'validation' | 'native';
|
|
39
|
+
/**
|
|
40
|
+
* One thing wrong with a path, who said so, and what a translation needs to say it.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* `type` names the problem for a program: the rule's type (`'minLength'`), the `ValidityState` flag of a
|
|
44
|
+
* native control (`'typeMismatch'`) or the server's code. `ruleId` is the author's stable name for the
|
|
45
|
+
* rule, so two `pattern` rules stay distinguishable. `params` are the numbers and names the text is
|
|
46
|
+
* built from, serializable (`{ minLength: 8 }` for a rule, `{ minLength: 8 }` for a native control).
|
|
47
|
+
* `message` is only the text the author wrote on the rule, or the server or control sent, for a host with no
|
|
48
|
+
* translation of the issue, and may be absent. Text the schema library would make up is never used.
|
|
49
|
+
*/
|
|
50
|
+
export interface FormStateIssue {
|
|
51
|
+
readonly type: string;
|
|
52
|
+
readonly source: FormStateSource;
|
|
53
|
+
readonly ruleId?: string;
|
|
54
|
+
readonly params?: Readonly<Record<string, unknown>>;
|
|
55
|
+
readonly message?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The error of a path: the issue to show, and every issue the path has.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* The fields of the issue are those of `all[0]`, so the error reads like a single issue, and `all` is
|
|
62
|
+
* never empty. `all` lists, in this order, what the server said, then each rule the value fails in
|
|
63
|
+
* authored order (never the order the checks finished in), then what the platform's own control reports.
|
|
64
|
+
* The same error object comes back while none of that changes.
|
|
65
|
+
*/
|
|
66
|
+
export interface FormStateError extends FormStateIssue {
|
|
67
|
+
readonly all: readonly FormStateIssue[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Advice about a path: shaped and timed exactly like an error, and never blocking.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* It comes from rules declared with `severity: 'warning'`, so its issues have the source `'validation'`.
|
|
74
|
+
* It never affects `isValid`, `validate` or `checkValidity`. A server cannot send warnings yet.
|
|
75
|
+
*/
|
|
76
|
+
export type FormStateWarning = FormStateError;
|
|
77
|
+
/**
|
|
78
|
+
* Why a submission as a whole failed, in the shape of an issue, so a host words it with the one formatter.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* It is not a {@link FormStateIssue}: a submission failure (the action that threw, the callback that
|
|
82
|
+
* rejected, the service that was down) concerns no field and the snapshot never holds one. `type` names the
|
|
83
|
+
* failure for a program, `params` fill the text, and `message` is only the text the failure itself carried.
|
|
84
|
+
*/
|
|
85
|
+
export interface FormSubmissionIssue {
|
|
86
|
+
readonly type: string;
|
|
87
|
+
readonly source: 'submission';
|
|
88
|
+
readonly params?: Readonly<Record<string, unknown>>;
|
|
89
|
+
readonly message?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Turns an issue into the text to show, for the field at `field.path`.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* The one seam between the engine, which reports what is wrong (`type`, `ruleId`, `params`), and the text
|
|
96
|
+
* of the application's language, which the engine does not own. A binding takes one from its host and
|
|
97
|
+
* calls it for the issue to show (an error or warning is itself an issue) and for each of `all` it lists,
|
|
98
|
+
* falling back to `issue.message` when the host gives none or the formatter returns nothing worth showing.
|
|
99
|
+
* `ruleId` picks a text of one rule, `type` a text of a kind of rule, and `params` fill its numbers. The
|
|
100
|
+
* action context and the bindings use this same issue type, so one formatter serves them all. A
|
|
101
|
+
* {@link FormSubmissionIssue} goes through it too, with the path of the form ({@link FORM_ROOT}).
|
|
102
|
+
*/
|
|
103
|
+
export type FormIssueFormatter = (issue: FormStateIssue | FormSubmissionIssue, field: {
|
|
104
|
+
readonly path: string;
|
|
105
|
+
}) => string;
|
|
106
|
+
/**
|
|
107
|
+
* An issue as a caller of `setServerErrors` may give it.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* Every part is optional, as a server response may carry only a code or only a message. A missing `type`
|
|
111
|
+
* is kept as `'server'`. An issue with nothing but a type still counts as an error: it blocks
|
|
112
|
+
* {@link FormStateContainer.validate}.
|
|
113
|
+
*/
|
|
114
|
+
export interface FormStateErrorInput {
|
|
115
|
+
readonly type?: string;
|
|
116
|
+
readonly params?: Readonly<Record<string, unknown>>;
|
|
117
|
+
readonly message?: string;
|
|
118
|
+
}
|
|
119
|
+
/** What `setServerErrors` takes: one issue or a list of them for each path. */
|
|
120
|
+
export type FormStateErrorsInput = Readonly<Record<string, FormStateErrorInput | readonly FormStateErrorInput[]>>;
|
|
121
|
+
/**
|
|
122
|
+
* What a platform control reports about its value.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* `type` is the `ValidityState` flag (`'valueMissing'`, `'typeMismatch'`, `'tooShort'`), `params` the
|
|
126
|
+
* constraint behind it that a text needs (`{ minLength: 8 }`, `{ pattern: '[0-9]+' }`), `message` the
|
|
127
|
+
* control's own text, a fallback only.
|
|
128
|
+
*/
|
|
129
|
+
export interface NativeValidity {
|
|
130
|
+
readonly type: string;
|
|
131
|
+
readonly params?: Readonly<Record<string, unknown>>;
|
|
132
|
+
readonly message?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* How a check of the form ended, and what the host may do next.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* `'passed'`: the scope was current and no error from any source remains at the paths that take part.
|
|
139
|
+
* `'invalid'`: the scope was current and an error blocks. `'overtaken'`: an edit, a row move or a reset outran the
|
|
140
|
+
* check, and the retry over the same rows was outrun too or the rows are gone, so there is no verdict and nothing
|
|
141
|
+
* stale was written: ask again, and do not show errors the user did not cause. A {@link FormSubmitResult} is built on
|
|
142
|
+
* it, so the outcomes are listed here only.
|
|
143
|
+
*/
|
|
144
|
+
export type FormValidateResult = {
|
|
145
|
+
readonly outcome: 'passed';
|
|
146
|
+
} | {
|
|
147
|
+
readonly outcome: 'invalid';
|
|
148
|
+
} | {
|
|
149
|
+
readonly outcome: 'overtaken';
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* How a submission ended, and what the host may do next.
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* `'passed'`: the scope was current and nothing blocks; `values` are exactly the values that passed, frozen,
|
|
156
|
+
* nested like `snapshot.values`, without the paths that took no part and with the config's `payload`. An
|
|
157
|
+
* edit during the check followed by a retry that passes leaves the edit in them. `setServerErrors` hands back
|
|
158
|
+
* the server's answer to that submission. `'invalid'`: the scope was current and an error blocks, so show the
|
|
159
|
+
* errors and focus. `'overtaken'`: an edit, a row move, a reset, a later submission or a superseded check outran
|
|
160
|
+
* it, so there is no verdict on anything: ask again, and do not show errors the user did not cause.
|
|
161
|
+
*/
|
|
162
|
+
export type FormSubmitResult = Exclude<FormValidateResult, {
|
|
163
|
+
readonly outcome: 'passed';
|
|
164
|
+
}> | {
|
|
165
|
+
readonly outcome: 'passed';
|
|
166
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
167
|
+
/**
|
|
168
|
+
* Shows the server's answer to this submission, replacing the answer shown so far.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* Each path takes one issue or a list, and {@link FORM_ROOT} stands for the form. Throws for a path with
|
|
172
|
+
* a reserved `__` segment other than `FORM_ROOT`, and for a path that names a row the submitted values
|
|
173
|
+
* did not have. Paths are as they are in `values`: an index counts only the rows that took part, and the container maps it to the form's row (so with the middle one of three rows left out, `rows.1` is the third row). An error for `contacts.0.email` lands
|
|
174
|
+
* on that row wherever it is now, and is dropped when the row is gone. A path no field declares cannot be
|
|
175
|
+
* shown at a field, so its issues move to `FORM_ROOT`, keeping their type, params and message. An error is applied only when its
|
|
176
|
+
* target, and every value its rules read, are unchanged since the submission, and only while this is the
|
|
177
|
+
* latest submission and no reset came between: otherwise the call does nothing. An error is cleared
|
|
178
|
+
* when its path, or a path its rules read, is edited.
|
|
179
|
+
*/
|
|
180
|
+
readonly setServerErrors: (errors: FormStateErrorsInput) => void;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* The immutable state a subscriber reads.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
* Stable: {@link FormStateContainer.getSnapshot} returns the same object until something changes, and a
|
|
187
|
+
* branch that did not change keeps its reference, in `values` and in every map. Maps are plain records,
|
|
188
|
+
* frozen, keyed by dotted path. An opaque value, such as an array holding `File` objects, is kept and
|
|
189
|
+
* compared by reference: it is never copied, frozen or diffed.
|
|
190
|
+
*
|
|
191
|
+
* Paths that take no part in validation (hidden or disabled fields, and what is inside them) are absent
|
|
192
|
+
* from `errors`, `warnings` and `validating`.
|
|
193
|
+
*/
|
|
194
|
+
export interface FormStateSnapshot {
|
|
195
|
+
/** The nested value tree. */
|
|
196
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
197
|
+
/**
|
|
198
|
+
* The error of each path, with every issue it has in `all`.
|
|
199
|
+
*
|
|
200
|
+
* @remarks
|
|
201
|
+
* Never inherited: an error on `contacts` is not an error on `contacts.0.email`, and both can be present.
|
|
202
|
+
* An error about the form itself is at {@link FORM_ROOT}.
|
|
203
|
+
*/
|
|
204
|
+
readonly errors: Readonly<Record<string, FormStateError>>;
|
|
205
|
+
/** The advice of each path, shaped like `errors` and never blocking. */
|
|
206
|
+
readonly warnings: Readonly<Record<string, FormStateWarning>>;
|
|
207
|
+
/** The paths the user has blurred; a mark on a container covers the fields below it. Moves with its row. */
|
|
208
|
+
readonly touched: Readonly<Record<string, true>>;
|
|
209
|
+
/**
|
|
210
|
+
* The paths whose value differs from the defaults.
|
|
211
|
+
*
|
|
212
|
+
* @remarks An array's own mark means its row count changed; its rows are compared by index, so appending a row does not make the existing rows dirty.
|
|
213
|
+
*/
|
|
214
|
+
readonly dirty: Readonly<Record<string, true>>;
|
|
215
|
+
/** The ids of an array's rows, by array path, in row order. */
|
|
216
|
+
readonly rowIds: Readonly<Record<string, readonly string[]>>;
|
|
217
|
+
/**
|
|
218
|
+
* The paths a check the container started is still running for.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* A path is listed while the latest check that asked for it is running: a check overtaken by a later one
|
|
222
|
+
* for the same path does not keep it pending. Pending is state, never an issue. It moves with its row.
|
|
223
|
+
*/
|
|
224
|
+
readonly validating: Readonly<Record<string, true>>;
|
|
225
|
+
/** Whether no error from any source is recorded for a path that takes part. Cheap, and not a fresh check. */
|
|
226
|
+
readonly isValid: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* How many times the form was reset: it goes up by one on every {@link FormStateContainer.reset} and on nothing else.
|
|
229
|
+
*
|
|
230
|
+
* @remarks
|
|
231
|
+
* It lets what lives around the container, such as a runtime's submission and step state, notice a reset
|
|
232
|
+
* that no one told it about, since `reset` is the only way back and any caller may use it.
|
|
233
|
+
*/
|
|
234
|
+
readonly generation: number;
|
|
235
|
+
/**
|
|
236
|
+
* What the form's constraints say, resolved in order against the values with whatever took no part absent.
|
|
237
|
+
*
|
|
238
|
+
* @remarks
|
|
239
|
+
* `skippedSteps` lists the ids of the steps its constraints hide. `fields` has an entry for each rendered path that has a constraint,
|
|
240
|
+
* is disabled by authoring or is held by a skipped step; `selectFieldState` folds the ancestors in. The same object comes back
|
|
241
|
+
* while nothing in it changes, however much else does.
|
|
242
|
+
*/
|
|
243
|
+
readonly participation: {
|
|
244
|
+
readonly skippedSteps: readonly string[];
|
|
245
|
+
readonly fields: Readonly<Record<string, FieldParticipation>>;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* The commands over a form's state, and the stable reads a binding builds on.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* Every command is one atomic update: subscribers are notified once, and never see an array's values
|
|
253
|
+
* and its row state out of step. No member depends on how it is called, so a binding may pass any of
|
|
254
|
+
* them as a callback. Read state with `getSnapshot` and the selectors of `selectors.ts`.
|
|
255
|
+
*/
|
|
256
|
+
export interface FormStateContainer {
|
|
257
|
+
/** Registers a listener for every snapshot change; returns the function that removes it. */
|
|
258
|
+
subscribe(listener: () => void): () => void;
|
|
259
|
+
getSnapshot(): FormStateSnapshot;
|
|
260
|
+
/** The snapshot to render on the server and during hydration: the initial state, never replaced. */
|
|
261
|
+
getServerSnapshot(): FormStateSnapshot;
|
|
262
|
+
/** The value at a dotted path, from the current state. */
|
|
263
|
+
getValue(path: string): unknown;
|
|
264
|
+
/**
|
|
265
|
+
* Replaces the whole branch at `path`.
|
|
266
|
+
*
|
|
267
|
+
* @remarks
|
|
268
|
+
* Throws for a path with a reserved segment (one that starts with `__`, or `constructor`, `prototype`, `__proto__`) and for a path that names a row its array does not
|
|
269
|
+
* have: rows are made with `fieldArray`, so a write cannot leave holes or rows without an id. It is a change: it validates when the mode says so, re-validates dependents, and drops what describes
|
|
270
|
+
* a value that is gone: the errors a server answered with at the path and below, and on the paths around it, the form included,
|
|
271
|
+
* and the native facts of the value. The state of rows and objects the branch no longer holds is dropped with
|
|
272
|
+
* them. A write that leaves the value as it is changes nothing.
|
|
273
|
+
*/
|
|
274
|
+
setValue(path: string, value: unknown): void;
|
|
275
|
+
/**
|
|
276
|
+
* Marks `path` touched, and validates it when the mode says so.
|
|
277
|
+
*
|
|
278
|
+
* @remarks
|
|
279
|
+
* The path is checked as in `setValue`. A control whose value the host has not written yet is written with
|
|
280
|
+
* `setValue` first: the two are separate commands, and the end state is the one a single command would
|
|
281
|
+
* leave.
|
|
282
|
+
*/
|
|
283
|
+
blur(path: string): void;
|
|
284
|
+
/**
|
|
285
|
+
* Reports what the platform's controls say about the values the container holds, with no input from the user.
|
|
286
|
+
*
|
|
287
|
+
* @remarks
|
|
288
|
+
* The one channel for native validity, for a host that owns controls: a path with its fact, `null` for a
|
|
289
|
+
* control that reports itself valid or goes away, which withdraws the fact. A host reports a fact on a
|
|
290
|
+
* change, a blur, a reset, or when a control's constraints change, and withdraws it when its control
|
|
291
|
+
* disconnects. A fact is bound to the value held now and is dropped when that value changes, and it moves with
|
|
292
|
+
* its row. A fact that is already held is a no-op. Reporting is no change: nothing becomes dirty or touched,
|
|
293
|
+
* and one call is one commit that re-validates, in a single run, only the changed paths that were validated
|
|
294
|
+
* before, are in a failed scope, or have a check in flight, never to start validating a pristine one. A path no field
|
|
295
|
+
* of the config expands to for the values held (a name no field has, a removed row, anything below a scalar) is
|
|
296
|
+
* ignored. A reserved path throws, for the whole
|
|
297
|
+
* call and before anything is written. A fact is not part of the snapshot, so reporting alone notifies nobody.
|
|
298
|
+
*/
|
|
299
|
+
reportNative(facts: Readonly<Record<string, NativeValidity | null>>): void;
|
|
300
|
+
/**
|
|
301
|
+
* Replaces the defaults with `values` when given, then restores the values to the defaults and clears
|
|
302
|
+
* every error, native fact, touched and dirty mark and the failed-check state.
|
|
303
|
+
*
|
|
304
|
+
* @remarks Validation still running when this is called is dropped and not run again, and so are the submissions begun before it; every row gets a new id.
|
|
305
|
+
*/
|
|
306
|
+
reset(values?: Record<string, unknown>): void;
|
|
307
|
+
/**
|
|
308
|
+
* Validates `paths` (the whole form when omitted, nothing when empty), records the findings and says how that ended.
|
|
309
|
+
*
|
|
310
|
+
* @remarks
|
|
311
|
+
* Every check records the scope it covered: the values it read, the values its rules depend on, the
|
|
312
|
+
* native facts, the reset generation and the rows by id. It is `'passed'` only when no error from any
|
|
313
|
+
* source remains at the paths that take part and that scope was still current when it finished. A check
|
|
314
|
+
* overtaken by an edit, a row move or a reset runs once more over the same rows, wherever they are now,
|
|
315
|
+
* and one that is overtaken again, or whose rows are gone, is `'overtaken'` without writing anything stale:
|
|
316
|
+
* it is not `'invalid'`, so the host must not read it as a failed field.
|
|
317
|
+
* It rejects with a `FormValidationFailure` naming the path and rule when a rule could not run. A failure
|
|
318
|
+
* of its own validation starts the failed-check state for those paths, so they re-validate by
|
|
319
|
+
* `reValidateMode` from then on. It does not mark anything submitted or touched.
|
|
320
|
+
*/
|
|
321
|
+
validate(paths?: readonly string[]): Promise<FormValidateResult>;
|
|
322
|
+
/**
|
|
323
|
+
* Whether the form is valid for the state at the moment of the call, by the same count as `validate`, without its writes.
|
|
324
|
+
*
|
|
325
|
+
* @remarks
|
|
326
|
+
* It answers for the values, native facts, server errors and participation current when it was called,
|
|
327
|
+
* and for no later state: it is never retried and never mixes those with errors set afterwards, so the
|
|
328
|
+
* answer may already be out of date when it resolves. It writes no error and
|
|
329
|
+
* changes no state. Errors recorded earlier do not count, as the check validates afresh. It rejects with
|
|
330
|
+
* a `FormValidationFailure`, which keeps the `reason` and the `cause`, when a rule could not run.
|
|
331
|
+
*/
|
|
332
|
+
checkValidity(): Promise<boolean>;
|
|
333
|
+
/**
|
|
334
|
+
* Submits the form: clears the server's answer to the last submission, validates the whole form and says how that ended.
|
|
335
|
+
*
|
|
336
|
+
* @remarks
|
|
337
|
+
* It validates as `validate()` does, with the same freshness and the one retry over the same rows, and
|
|
338
|
+
* captures the submission the result speaks for: a later `submit` or a `reset` supersedes it, and the
|
|
339
|
+
* earlier one ends `'overtaken'` or has its `setServerErrors` ignored. Like `validate`, it rejects with a
|
|
340
|
+
* `FormValidationFailure` when a rule could not run, and a rejected call is no outcome.
|
|
341
|
+
*/
|
|
342
|
+
submit(): Promise<FormSubmitResult>;
|
|
343
|
+
/**
|
|
344
|
+
* The commands of the array at `path`, the same object each time.
|
|
345
|
+
*
|
|
346
|
+
* @remarks
|
|
347
|
+
* Cached per path, and a path names a position: `contacts.0.phones` is whatever row is at index 0 now,
|
|
348
|
+
* not the row that was there when the commands were first asked for. Rows are read from
|
|
349
|
+
* `snapshot.rowIds[path]`; `toFieldArrayValue` combines the two for a widget.
|
|
350
|
+
*/
|
|
351
|
+
fieldArray(path: string): FieldArrayCommands;
|
|
352
|
+
}
|
|
353
|
+
/** What {@link createFormStateContainer} reads from a normalized form config. */
|
|
354
|
+
export interface FormStateContainerConfig {
|
|
355
|
+
/**
|
|
356
|
+
* The steps whose elements make up the form: fields, rules and constraints.
|
|
357
|
+
*
|
|
358
|
+
* @remarks A step's own `constraints` decide whether it is skipped; a skipped step's fields take no part, as hidden fields do not.
|
|
359
|
+
*/
|
|
360
|
+
readonly steps: readonly ValidationStep[];
|
|
361
|
+
/** When a field validates before a check of it has failed; the config schema always fills it. */
|
|
362
|
+
readonly validationMode: FormValidationMode;
|
|
363
|
+
/** When a field validates once a check of it has run; the config schema always fills it. */
|
|
364
|
+
readonly reValidateMode: FormReValidateMode;
|
|
365
|
+
/**
|
|
366
|
+
* Data that travels with every submission.
|
|
367
|
+
*
|
|
368
|
+
* @remarks It is merged into the `values` of a passed submission and is never a value of the form: not in the snapshot, not dirty, not validated. Its keys cannot name fields, which the config validation checks.
|
|
369
|
+
*/
|
|
370
|
+
readonly payload?: Readonly<Record<string, unknown>>;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The part of a snapshot that a server hands to a client so the client starts from the same state.
|
|
374
|
+
*
|
|
375
|
+
* @remarks
|
|
376
|
+
* The `values` and `rowIds` of a snapshot are plain, frozen and serializable (but for opaque values such as
|
|
377
|
+
* files), so `JSON.stringify(toHydration(container.getServerSnapshot()))` is the payload, and a snapshot is itself
|
|
378
|
+
* accepted. The rest of a snapshot is derived from what the server's container did, not state to restore.
|
|
379
|
+
*/
|
|
380
|
+
export interface FormStateHydration {
|
|
381
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
382
|
+
readonly rowIds: Readonly<Record<string, readonly string[]>>;
|
|
383
|
+
}
|
|
384
|
+
/** What {@link FormStateContainerFactory} builds a container from. */
|
|
385
|
+
export interface FormStateContainerOptions {
|
|
386
|
+
/** The normalized form config: the elements, the validation timing and the payload all come from it, so no renderer can differ. */
|
|
387
|
+
readonly config: FormStateContainerConfig;
|
|
388
|
+
readonly registry: ValidationRegistry;
|
|
389
|
+
readonly defaults?: Record<string, unknown>;
|
|
390
|
+
/**
|
|
391
|
+
* The snapshot of a container that rendered the form elsewhere, to start from: its values and its row ids.
|
|
392
|
+
*
|
|
393
|
+
* @remarks
|
|
394
|
+
* Without it the container starts from `defaults` and mints deterministic row ids (walk order, one counter per
|
|
395
|
+
* container). With it the container starts from the values of the snapshot and adopts its row ids, so a client
|
|
396
|
+
* keeps the identity a server rendered, whatever rows the user had added there. Values and ids come from the same
|
|
397
|
+
* object, so there is nothing to compare; one whose ids do not match its own values cannot come from a real
|
|
398
|
+
* snapshot and throws. `defaults` still say what the form started from, and what
|
|
399
|
+
* `reset` restores, so pass the same ones the server used: the fields that differ from them are dirty.
|
|
400
|
+
*/
|
|
401
|
+
readonly snapshot?: FormStateHydration;
|
|
402
|
+
}
|
|
403
|
+
/** What `formStateContainerConformance` builds the container under test with. */
|
|
404
|
+
export type FormStateContainerFactory = (options: FormStateContainerOptions) => FormStateContainer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** A map held by the container: null-prototype, replaced rather than mutated. */
|
|
2
|
+
export type NullMap<T = unknown> = Record<string, T>;
|
|
3
|
+
export declare const isStructural: (node: unknown) => node is NullMap | unknown[];
|
|
4
|
+
export declare function createMap<T = unknown>(): NullMap<T>;
|
|
5
|
+
/**
|
|
6
|
+
* Whether a value is compared by reference and never copied, frozen or diffed.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Plain records and primitives are structural. An array is structural only when each of its items is,
|
|
10
|
+
* so `string[]` and arrays of rows are, and a `File[]` from a drop zone is not: copying it would break
|
|
11
|
+
* the identity a control holds on to.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isOpaque(value: unknown): boolean;
|
|
14
|
+
/** The frozen plain-record view of an internal record. */
|
|
15
|
+
export declare function toPlainRecord(record: NullMap): Readonly<Record<string, unknown>>;
|
|
16
|
+
/** Copies the structural part of `record` into a null-prototype map; opaque values are kept as they are. */
|
|
17
|
+
export declare function toInternalRecord(record: Readonly<Record<string, unknown>>): NullMap;
|
|
18
|
+
/** Copies the structural part of `value` into null-prototype maps; opaque values are kept as they are. */
|
|
19
|
+
export declare function toInternal(value: unknown): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* The frozen plain-record view of an internal value.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Memoized per internal node, so a branch that did not change comes back as the same object.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toPlain(value: unknown): unknown;
|
|
27
|
+
/** Frozen plain view of a flat map; entries are carried over as they are. */
|
|
28
|
+
export declare function toPlainMap<T>(map: NullMap<T>): Readonly<Record<string, T>>;
|
|
29
|
+
/**
|
|
30
|
+
* The previous value when `next` has the same keys holding the same references, else `next`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function stabilize<T extends NullMap>(previous: T, next: T): T;
|
|
33
|
+
/**
|
|
34
|
+
* Merges `next` into `previous`, keeping every branch that holds the same content as its old reference.
|
|
35
|
+
*/
|
|
36
|
+
export declare function reconcile(previous: unknown, next: unknown): unknown;
|
|
37
|
+
/**
|
|
38
|
+
* Writes `value` at `path` without mutating `root`: only the containers along the path are copied.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* A missing or non-container parent becomes an array when the next segment is an index and a map
|
|
42
|
+
* otherwise. Returns `root` itself when the value at `path` is already `value`. An empty `path` replaces the root,
|
|
43
|
+
* but only with a plain record; anything else leaves `root` as it is.
|
|
44
|
+
*/
|
|
45
|
+
export declare function setIn(root: NullMap, path: string, value: unknown): NullMap;
|
|
46
|
+
/** Whether `path` is `scope` or lies below it. */
|
|
47
|
+
export declare function isWithin(path: string, scope: string): boolean;
|
|
48
|
+
export declare function join(path: string, segment: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Lists the paths whose value differs between two internal trees, stopping at the first differing node
|
|
51
|
+
* along each branch that is not a container on both sides.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* Branches shared by reference are skipped, so the walk costs what changed, not the size of the form.
|
|
55
|
+
*/
|
|
56
|
+
export declare function changedPaths(before: unknown, after: unknown, path?: string, out?: string[]): string[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
changedPaths,
|
|
3
|
+
createMap,
|
|
4
|
+
isOpaque,
|
|
5
|
+
isStructural,
|
|
6
|
+
isWithin,
|
|
7
|
+
join,
|
|
8
|
+
reconcile,
|
|
9
|
+
setIn,
|
|
10
|
+
stabilize,
|
|
11
|
+
toInternal,
|
|
12
|
+
toInternalRecord,
|
|
13
|
+
toPlain,
|
|
14
|
+
toPlainMap,
|
|
15
|
+
toPlainRecord
|
|
16
|
+
} from "../chunk-K5TMXCMY.js";
|
|
17
|
+
import "../chunk-3YLRJVVN.js";
|
|
18
|
+
import "../chunk-CMPOBBRV.js";
|
|
19
|
+
export {
|
|
20
|
+
changedPaths,
|
|
21
|
+
createMap,
|
|
22
|
+
isOpaque,
|
|
23
|
+
isStructural,
|
|
24
|
+
isWithin,
|
|
25
|
+
join,
|
|
26
|
+
reconcile,
|
|
27
|
+
setIn,
|
|
28
|
+
stabilize,
|
|
29
|
+
toInternal,
|
|
30
|
+
toInternalRecord,
|
|
31
|
+
toPlain,
|
|
32
|
+
toPlainMap,
|
|
33
|
+
toPlainRecord
|
|
34
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The assertions, spy and timing helpers the conformance suite runs on.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Internal to the suite and not exported from the entry. They use no test runner, `node:assert` or any other
|
|
6
|
+
* Node-only module, so a case runs the same under Vitest, Jest, Bun, `node:test` or in a browser: a failed check
|
|
7
|
+
* throws an {@link AssertionError} and the runner reports it as a failed test.
|
|
8
|
+
*/
|
|
9
|
+
/** The error a failed check throws; its message shows what was received and what was expected. */
|
|
10
|
+
export declare class AssertionError extends Error {
|
|
11
|
+
readonly name = "AssertionError";
|
|
12
|
+
}
|
|
13
|
+
/** Fails unless the values are deeply equal; a property set to `undefined` equals a missing one. */
|
|
14
|
+
export declare function assertEqual(actual: unknown, expected: unknown, label?: string): void;
|
|
15
|
+
/** Fails unless the values are the same, by `Object.is`. */
|
|
16
|
+
export declare function assertSame(actual: unknown, expected: unknown, label?: string): void;
|
|
17
|
+
/** Fails when the values are the same, by `Object.is`. */
|
|
18
|
+
export declare function assertNotSame(actual: unknown, unexpected: unknown, label?: string): void;
|
|
19
|
+
/** Fails unless `actual` has every key and value `partial` names, however many more it has. */
|
|
20
|
+
export declare function assertMatches(actual: unknown, partial: unknown, label?: string): void;
|
|
21
|
+
/** Fails unless the value is `undefined`. */
|
|
22
|
+
export declare function assertUndefined(actual: unknown, label?: string): void;
|
|
23
|
+
/** Fails when the value is `undefined`. */
|
|
24
|
+
export declare function assertDefined(actual: unknown, label?: string): void;
|
|
25
|
+
/** Fails unless the array has `length` items. */
|
|
26
|
+
export declare function assertLength(actual: ArrayLike<unknown>, length: number, label?: string): void;
|
|
27
|
+
/** Fails when the text matches `pattern`. */
|
|
28
|
+
export declare function assertNotMatches(actual: string, pattern: RegExp, label?: string): void;
|
|
29
|
+
/** Fails when the object has the property, own or inherited. */
|
|
30
|
+
export declare function assertNoProperty(actual: object, key: string, label?: string): void;
|
|
31
|
+
/** Fails when the array holds the item, by `Object.is`. */
|
|
32
|
+
export declare function assertNotIncludes(actual: readonly unknown[], item: unknown, label?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Fails unless `run` throws.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* `expected` narrows what it throws: an error class, or a pattern its message must match.
|
|
38
|
+
*/
|
|
39
|
+
export declare function assertThrows(run: () => unknown, expected?: RegExp | (new (...args: never[]) => Error)): void;
|
|
40
|
+
/** Fails when `run` throws, and shows what it threw. */
|
|
41
|
+
export declare function assertDoesNotThrow(run: () => unknown): void;
|
|
42
|
+
/** A function that records each call it receives; see {@link createSpy}. */
|
|
43
|
+
export interface Spy<Args extends unknown[] = unknown[], Result = unknown> {
|
|
44
|
+
(...args: Args): Result;
|
|
45
|
+
/** The arguments of every call, oldest first. */
|
|
46
|
+
readonly calls: Args[];
|
|
47
|
+
/** Swaps what the spy does from now on; calls already recorded stay. */
|
|
48
|
+
implement(implementation: (...args: Args) => Result): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A function that records its calls and runs `implementation`, if given.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* Without an implementation the spy returns `undefined`, so give one whenever the caller reads the result.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createSpy<Args extends unknown[] = unknown[], Result = unknown>(implementation?: (...args: Args) => Result): Spy<Args, Result>;
|
|
57
|
+
/** Fails unless the spy was called exactly `times` times. */
|
|
58
|
+
export declare function assertCallCount(spy: {
|
|
59
|
+
readonly calls: readonly unknown[];
|
|
60
|
+
}, times: number, label?: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Puts `value` on `target` under `key` and returns what undoes it.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* A property that was inherited or missing before is removed again instead of being left behind as an own one.
|
|
66
|
+
*/
|
|
67
|
+
export declare function replaceProperty(target: object, key: PropertyKey, value: unknown): () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Replaces a global, such as `fetch`, and returns what restores it.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Call the restore function in a `finally`, so a failing case cannot leak the stub into the next test.
|
|
73
|
+
*/
|
|
74
|
+
export declare function stubGlobal(name: string, value: unknown): () => void;
|
|
75
|
+
/** Replaces `target[key]` with a {@link Spy} that calls `implementation`, and returns the spy with what restores the original. */
|
|
76
|
+
export declare function spyOn<Args extends unknown[], Result>(target: object, key: PropertyKey, implementation?: (...args: Args) => Result): {
|
|
77
|
+
readonly spy: Spy<Args, Result>;
|
|
78
|
+
readonly restore: () => void;
|
|
79
|
+
};
|
|
80
|
+
/** How long {@link waitFor} keeps trying, and how long it waits between tries. */
|
|
81
|
+
export interface WaitForOptions {
|
|
82
|
+
readonly timeout?: number;
|
|
83
|
+
readonly interval?: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Calls `check` until it stops throwing and resolves with what it returned.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Defaults to the 1000 ms timeout and 50 ms interval of Vitest's `vi.waitFor`. Rethrows the last error `check`
|
|
90
|
+
* threw once the timeout passes, so the failure names the assertion that never held.
|
|
91
|
+
*/
|
|
92
|
+
export declare function waitFor<Result>(check: () => Result | Promise<Result>, { timeout, interval }?: WaitForOptions): Promise<Result>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssertionError,
|
|
3
|
+
assertCallCount,
|
|
4
|
+
assertDefined,
|
|
5
|
+
assertDoesNotThrow,
|
|
6
|
+
assertEqual,
|
|
7
|
+
assertLength,
|
|
8
|
+
assertMatches,
|
|
9
|
+
assertNoProperty,
|
|
10
|
+
assertNotIncludes,
|
|
11
|
+
assertNotMatches,
|
|
12
|
+
assertNotSame,
|
|
13
|
+
assertSame,
|
|
14
|
+
assertThrows,
|
|
15
|
+
assertUndefined,
|
|
16
|
+
createSpy,
|
|
17
|
+
replaceProperty,
|
|
18
|
+
spyOn,
|
|
19
|
+
stubGlobal,
|
|
20
|
+
waitFor
|
|
21
|
+
} from "../chunk-U3YHTQHR.js";
|
|
22
|
+
export {
|
|
23
|
+
AssertionError,
|
|
24
|
+
assertCallCount,
|
|
25
|
+
assertDefined,
|
|
26
|
+
assertDoesNotThrow,
|
|
27
|
+
assertEqual,
|
|
28
|
+
assertLength,
|
|
29
|
+
assertMatches,
|
|
30
|
+
assertNoProperty,
|
|
31
|
+
assertNotIncludes,
|
|
32
|
+
assertNotMatches,
|
|
33
|
+
assertNotSame,
|
|
34
|
+
assertSame,
|
|
35
|
+
assertThrows,
|
|
36
|
+
assertUndefined,
|
|
37
|
+
createSpy,
|
|
38
|
+
replaceProperty,
|
|
39
|
+
spyOn,
|
|
40
|
+
stubGlobal,
|
|
41
|
+
waitFor
|
|
42
|
+
};
|