@fieldia/core 0.30.1 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +362 -1
- package/package.json +1 -1
- package/schema/page.schema.json +758 -1
- package/src/index.d.mts +13 -2
- package/src/index.d.ts +13 -2
- package/src/index.js +45 -2
- package/src/index.js.map +1 -1
- package/src/index.mjs +18 -2
- package/src/index.mjs.map +1 -1
- package/src/lib/format/actions.d.mts +16 -16
- package/src/lib/format/actions.d.ts +16 -16
- package/src/lib/format/actions.js +3 -0
- package/src/lib/format/actions.js.map +1 -1
- package/src/lib/format/actions.mjs +3 -0
- package/src/lib/format/actions.mjs.map +1 -1
- package/src/lib/format/address-search.js +3 -0
- package/src/lib/format/address-search.js.map +1 -1
- package/src/lib/format/address-search.mjs +3 -0
- package/src/lib/format/address-search.mjs.map +1 -1
- package/src/lib/format/duplicates.js +3 -0
- package/src/lib/format/duplicates.js.map +1 -1
- package/src/lib/format/duplicates.mjs +3 -0
- package/src/lib/format/duplicates.mjs.map +1 -1
- package/src/lib/format/endings.js +3 -0
- package/src/lib/format/endings.js.map +1 -1
- package/src/lib/format/endings.mjs +3 -0
- package/src/lib/format/endings.mjs.map +1 -1
- package/src/lib/format/field.d.mts +669 -0
- package/src/lib/format/field.d.ts +669 -0
- package/src/lib/format/field.js +42 -4
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +42 -4
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/flow-checks.d.mts +14 -0
- package/src/lib/format/flow-checks.d.ts +14 -0
- package/src/lib/format/flow-checks.js +61 -0
- package/src/lib/format/flow-checks.js.map +1 -0
- package/src/lib/format/flow-checks.mjs +58 -0
- package/src/lib/format/flow-checks.mjs.map +1 -0
- package/src/lib/format/flow.d.mts +43 -0
- package/src/lib/format/flow.d.ts +43 -0
- package/src/lib/format/flow.js +22 -0
- package/src/lib/format/flow.js.map +1 -0
- package/src/lib/format/flow.mjs +19 -0
- package/src/lib/format/flow.mjs.map +1 -0
- package/src/lib/format/from-schema.d.mts +70 -0
- package/src/lib/format/from-schema.d.ts +70 -0
- package/src/lib/format/from-schema.js +599 -0
- package/src/lib/format/from-schema.js.map +1 -0
- package/src/lib/format/from-schema.mjs +591 -0
- package/src/lib/format/from-schema.mjs.map +1 -0
- package/src/lib/format/jitless.d.mts +1 -0
- package/src/lib/format/jitless.d.ts +1 -0
- package/src/lib/format/jitless.js +27 -0
- package/src/lib/format/jitless.js.map +1 -0
- package/src/lib/format/jitless.mjs +24 -0
- package/src/lib/format/jitless.mjs.map +1 -0
- package/src/lib/format/json-schema.js +3 -0
- package/src/lib/format/json-schema.js.map +1 -1
- package/src/lib/format/json-schema.mjs +3 -0
- package/src/lib/format/json-schema.mjs.map +1 -1
- package/src/lib/format/json.js +3 -0
- package/src/lib/format/json.js.map +1 -1
- package/src/lib/format/json.mjs +3 -0
- package/src/lib/format/json.mjs.map +1 -1
- package/src/lib/format/languages-checks.d.mts +2 -1
- package/src/lib/format/languages-checks.d.ts +2 -1
- package/src/lib/format/languages-checks.js +8 -2
- package/src/lib/format/languages-checks.js.map +1 -1
- package/src/lib/format/languages-checks.mjs +8 -2
- package/src/lib/format/languages-checks.mjs.map +1 -1
- package/src/lib/format/later-checks.d.mts +3 -1
- package/src/lib/format/later-checks.d.ts +3 -1
- package/src/lib/format/later-checks.js +3 -1
- package/src/lib/format/later-checks.js.map +1 -1
- package/src/lib/format/later-checks.mjs +3 -1
- package/src/lib/format/later-checks.mjs.map +1 -1
- package/src/lib/format/layout.d.mts +13192 -7550
- package/src/lib/format/layout.d.ts +13192 -7550
- package/src/lib/format/layout.js +61 -3
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +59 -1
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +3 -1
- package/src/lib/format/layout.types.d.ts +3 -1
- package/src/lib/format/limits.js +3 -0
- package/src/lib/format/limits.js.map +1 -1
- package/src/lib/format/limits.mjs +3 -0
- package/src/lib/format/limits.mjs.map +1 -1
- package/src/lib/format/list-checks.d.mts +1 -1
- package/src/lib/format/list-checks.d.ts +1 -1
- package/src/lib/format/list-checks.js +67 -22
- package/src/lib/format/list-checks.js.map +1 -1
- package/src/lib/format/list-checks.mjs +67 -22
- package/src/lib/format/list-checks.mjs.map +1 -1
- package/src/lib/format/list-rows-checks.d.mts +11 -0
- package/src/lib/format/list-rows-checks.d.ts +11 -0
- package/src/lib/format/list-rows-checks.js +62 -0
- package/src/lib/format/list-rows-checks.js.map +1 -0
- package/src/lib/format/list-rows-checks.mjs +59 -0
- package/src/lib/format/list-rows-checks.mjs.map +1 -0
- package/src/lib/format/media-options.d.mts +84 -0
- package/src/lib/format/media-options.d.ts +84 -0
- package/src/lib/format/media-options.js +86 -0
- package/src/lib/format/media-options.js.map +1 -0
- package/src/lib/format/media-options.mjs +80 -0
- package/src/lib/format/media-options.mjs.map +1 -0
- package/src/lib/format/outbox-checks.d.mts +11 -0
- package/src/lib/format/outbox-checks.d.ts +11 -0
- package/src/lib/format/outbox-checks.js +12 -0
- package/src/lib/format/outbox-checks.js.map +1 -0
- package/src/lib/format/outbox-checks.mjs +9 -0
- package/src/lib/format/outbox-checks.mjs.map +1 -0
- package/src/lib/format/page.d.mts +3057 -966
- package/src/lib/format/page.d.ts +3057 -966
- package/src/lib/format/page.js +15 -0
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +15 -0
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/part-checks.d.mts +3 -0
- package/src/lib/format/part-checks.d.ts +3 -0
- package/src/lib/format/payment-checks.d.mts +13 -0
- package/src/lib/format/payment-checks.d.ts +13 -0
- package/src/lib/format/payment-checks.js +30 -0
- package/src/lib/format/payment-checks.js.map +1 -0
- package/src/lib/format/payment-checks.mjs +27 -0
- package/src/lib/format/payment-checks.mjs.map +1 -0
- package/src/lib/format/payment.d.mts +37 -0
- package/src/lib/format/payment.d.ts +37 -0
- package/src/lib/format/payment.js +15 -0
- package/src/lib/format/payment.js.map +1 -0
- package/src/lib/format/payment.mjs +12 -0
- package/src/lib/format/payment.mjs.map +1 -0
- package/src/lib/format/phone.js +3 -0
- package/src/lib/format/phone.js.map +1 -1
- package/src/lib/format/phone.mjs +3 -0
- package/src/lib/format/phone.mjs.map +1 -1
- package/src/lib/format/picker-options.d.mts +12 -0
- package/src/lib/format/picker-options.d.ts +12 -0
- package/src/lib/format/picker-options.js +21 -3
- package/src/lib/format/picker-options.js.map +1 -1
- package/src/lib/format/picker-options.mjs +20 -2
- package/src/lib/format/picker-options.mjs.map +1 -1
- package/src/lib/format/prefill-checks.d.mts +13 -0
- package/src/lib/format/prefill-checks.d.ts +13 -0
- package/src/lib/format/prefill-checks.js +35 -0
- package/src/lib/format/prefill-checks.js.map +1 -0
- package/src/lib/format/prefill-checks.mjs +32 -0
- package/src/lib/format/prefill-checks.mjs.map +1 -0
- package/src/lib/format/prefill.d.mts +33 -0
- package/src/lib/format/prefill.d.ts +33 -0
- package/src/lib/format/prefill.js +20 -0
- package/src/lib/format/prefill.js.map +1 -0
- package/src/lib/format/prefill.mjs +17 -0
- package/src/lib/format/prefill.mjs.map +1 -0
- package/src/lib/format/quiz.d.mts +58 -0
- package/src/lib/format/quiz.d.ts +58 -0
- package/src/lib/format/quiz.js +24 -0
- package/src/lib/format/quiz.js.map +1 -0
- package/src/lib/format/quiz.mjs +21 -0
- package/src/lib/format/quiz.mjs.map +1 -0
- package/src/lib/format/records.js +3 -0
- package/src/lib/format/records.js.map +1 -1
- package/src/lib/format/records.mjs +3 -0
- package/src/lib/format/records.mjs.map +1 -1
- package/src/lib/format/references.d.mts +1 -1
- package/src/lib/format/references.d.ts +1 -1
- package/src/lib/format/references.js +56 -7
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +57 -8
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/schedule-checks.d.mts +8 -0
- package/src/lib/format/schedule-checks.d.ts +8 -0
- package/src/lib/format/schedule-checks.js +16 -0
- package/src/lib/format/schedule-checks.js.map +1 -0
- package/src/lib/format/schedule-checks.mjs +13 -0
- package/src/lib/format/schedule-checks.mjs.map +1 -0
- package/src/lib/format/signature-checks.d.mts +8 -0
- package/src/lib/format/signature-checks.d.ts +8 -0
- package/src/lib/format/signature-checks.js +21 -0
- package/src/lib/format/signature-checks.js.map +1 -1
- package/src/lib/format/signature-checks.mjs +20 -0
- package/src/lib/format/signature-checks.mjs.map +1 -1
- package/src/lib/format/signature-options.js +3 -0
- package/src/lib/format/signature-options.js.map +1 -1
- package/src/lib/format/signature-options.mjs +3 -0
- package/src/lib/format/signature-options.mjs.map +1 -1
- package/src/lib/format/slots-options.js +3 -0
- package/src/lib/format/slots-options.js.map +1 -1
- package/src/lib/format/slots-options.mjs +3 -0
- package/src/lib/format/slots-options.mjs.map +1 -1
- package/src/lib/format/templates-checks.d.mts +6 -0
- package/src/lib/format/templates-checks.d.ts +6 -0
- package/src/lib/format/templates-checks.js +16 -0
- package/src/lib/format/templates-checks.js.map +1 -0
- package/src/lib/format/templates-checks.mjs +13 -0
- package/src/lib/format/templates-checks.mjs.map +1 -0
- package/src/lib/format/translate.d.mts +2 -0
- package/src/lib/format/translate.d.ts +2 -0
- package/src/lib/format/translate.js +6 -2
- package/src/lib/format/translate.js.map +1 -1
- package/src/lib/format/translate.mjs +4 -2
- package/src/lib/format/translate.mjs.map +1 -1
- package/src/lib/format/typed-options.d.mts +43 -0
- package/src/lib/format/typed-options.d.ts +43 -0
- package/src/lib/format/typed-options.js +50 -0
- package/src/lib/format/typed-options.js.map +1 -0
- package/src/lib/format/typed-options.mjs +46 -0
- package/src/lib/format/typed-options.mjs.map +1 -0
- package/src/lib/format/upgrade.d.mts +5 -1
- package/src/lib/format/upgrade.d.ts +5 -1
- package/src/lib/format/upgrade.js +5 -1
- package/src/lib/format/upgrade.js.map +1 -1
- package/src/lib/format/upgrade.mjs +5 -1
- package/src/lib/format/upgrade.mjs.map +1 -1
- package/src/lib/format/validate.js +3 -0
- package/src/lib/format/validate.js.map +1 -1
- package/src/lib/format/validate.mjs +3 -0
- package/src/lib/format/validate.mjs.map +1 -1
- package/src/lib/format/verify-checks.d.mts +10 -0
- package/src/lib/format/verify-checks.d.ts +10 -0
- package/src/lib/format/verify-checks.js +44 -0
- package/src/lib/format/verify-checks.js.map +1 -0
- package/src/lib/format/verify-checks.mjs +41 -0
- package/src/lib/format/verify-checks.mjs.map +1 -0
- package/src/lib/format/version.d.mts +2 -2
- package/src/lib/format/version.d.ts +2 -2
- package/src/lib/format/version.js +2 -2
- package/src/lib/format/version.js.map +1 -1
- package/src/lib/format/version.mjs +2 -2
- package/src/lib/format/version.mjs.map +1 -1
- package/src/lib/format/week.d.mts +18 -0
- package/src/lib/format/week.d.ts +18 -0
- package/src/lib/format/week.js +58 -0
- package/src/lib/format/week.js.map +1 -0
- package/src/lib/format/week.mjs +55 -0
- package/src/lib/format/week.mjs.map +1 -0
- package/src/lib/record/approvals-part.d.mts +1 -1
- package/src/lib/record/approvals-part.d.ts +1 -1
- package/src/lib/record/approvals-part.js +2 -2
- package/src/lib/record/approvals-part.js.map +1 -1
- package/src/lib/record/approvals-part.mjs +1 -1
- package/src/lib/record/approvals-part.mjs.map +1 -1
- package/src/lib/record/data-source.d.mts +331 -0
- package/src/lib/record/data-source.d.ts +331 -0
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/day-words.d.mts +22 -1
- package/src/lib/record/day-words.d.ts +22 -1
- package/src/lib/record/day-words.js +29 -2
- package/src/lib/record/day-words.js.map +1 -1
- package/src/lib/record/day-words.mjs +24 -2
- package/src/lib/record/day-words.mjs.map +1 -1
- package/src/lib/record/files-part.d.mts +1 -0
- package/src/lib/record/files-part.d.ts +1 -0
- package/src/lib/record/files-part.js +7 -1
- package/src/lib/record/files-part.js.map +1 -1
- package/src/lib/record/files-part.mjs +5 -1
- package/src/lib/record/files-part.mjs.map +1 -1
- package/src/lib/record/form-approvals.d.mts +12 -17
- package/src/lib/record/form-approvals.d.ts +12 -17
- package/src/lib/record/form-approvals.js +14 -8
- package/src/lib/record/form-approvals.js.map +1 -1
- package/src/lib/record/form-approvals.mjs +13 -7
- package/src/lib/record/form-approvals.mjs.map +1 -1
- package/src/lib/record/form-limits.d.mts +4 -28
- package/src/lib/record/form-limits.d.ts +4 -28
- package/src/lib/record/form-limits.js +8 -5
- package/src/lib/record/form-limits.js.map +1 -1
- package/src/lib/record/form-limits.mjs +8 -5
- package/src/lib/record/form-limits.mjs.map +1 -1
- package/src/lib/record/form.d.mts +115 -3
- package/src/lib/record/form.d.ts +115 -3
- package/src/lib/record/form.js +262 -65
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +263 -66
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/history-steps.d.mts +38 -0
- package/src/lib/record/history-steps.d.ts +38 -0
- package/src/lib/record/history-steps.js +63 -0
- package/src/lib/record/history-steps.js.map +1 -0
- package/src/lib/record/history-steps.mjs +58 -0
- package/src/lib/record/history-steps.mjs.map +1 -0
- package/src/lib/record/history.d.mts +16 -0
- package/src/lib/record/history.d.ts +16 -0
- package/src/lib/record/history.js +3 -0
- package/src/lib/record/history.js.map +1 -0
- package/src/lib/record/history.mjs +2 -0
- package/src/lib/record/history.mjs.map +1 -0
- package/src/lib/record/input-rules.d.mts +2 -0
- package/src/lib/record/input-rules.d.ts +2 -0
- package/src/lib/record/input-rules.js +4 -1
- package/src/lib/record/input-rules.js.map +1 -1
- package/src/lib/record/input-rules.mjs +2 -0
- package/src/lib/record/input-rules.mjs.map +1 -1
- package/src/lib/record/joins.d.mts +143 -0
- package/src/lib/record/joins.d.ts +143 -0
- package/src/lib/record/joins.js +28 -0
- package/src/lib/record/joins.js.map +1 -0
- package/src/lib/record/joins.mjs +24 -0
- package/src/lib/record/joins.mjs.map +1 -0
- package/src/lib/record/limits.js +7 -4
- package/src/lib/record/limits.js.map +1 -1
- package/src/lib/record/limits.mjs +8 -5
- package/src/lib/record/limits.mjs.map +1 -1
- package/src/lib/record/link-values.d.mts +31 -0
- package/src/lib/record/link-values.d.ts +31 -0
- package/src/lib/record/link-values.js +132 -0
- package/src/lib/record/link-values.js.map +1 -0
- package/src/lib/record/link-values.mjs +125 -0
- package/src/lib/record/link-values.mjs.map +1 -0
- package/src/lib/record/live-later.d.mts +15 -0
- package/src/lib/record/live-later.d.ts +15 -0
- package/src/lib/record/live-later.js +10 -0
- package/src/lib/record/live-later.js.map +1 -0
- package/src/lib/record/live-later.mjs +7 -0
- package/src/lib/record/live-later.mjs.map +1 -0
- package/src/lib/record/live-part.d.mts +6 -0
- package/src/lib/record/live-part.d.ts +6 -0
- package/src/lib/record/live-part.js +12 -0
- package/src/lib/record/live-part.js.map +1 -0
- package/src/lib/record/live-part.mjs +7 -0
- package/src/lib/record/live-part.mjs.map +1 -0
- package/src/lib/record/live.d.mts +8 -0
- package/src/lib/record/live.d.ts +8 -0
- package/src/lib/record/live.js +133 -0
- package/src/lib/record/live.js.map +1 -0
- package/src/lib/record/live.mjs +129 -0
- package/src/lib/record/live.mjs.map +1 -0
- package/src/lib/record/locales/all.d.mts +5 -5
- package/src/lib/record/locales/all.d.ts +5 -5
- package/src/lib/record/locales/all.js +3 -3
- package/src/lib/record/locales/all.js.map +1 -1
- package/src/lib/record/locales/all.mjs +3 -3
- package/src/lib/record/locales/all.mjs.map +1 -1
- package/src/lib/record/locales/ar.js +8 -0
- package/src/lib/record/locales/ar.js.map +1 -1
- package/src/lib/record/locales/ar.mjs +8 -0
- package/src/lib/record/locales/ar.mjs.map +1 -1
- package/src/lib/record/locales/de.js +8 -0
- package/src/lib/record/locales/de.js.map +1 -1
- package/src/lib/record/locales/de.mjs +8 -0
- package/src/lib/record/locales/de.mjs.map +1 -1
- package/src/lib/record/locales/es.d.mts +8 -0
- package/src/lib/record/locales/es.d.ts +8 -0
- package/src/lib/record/locales/es.js +111 -0
- package/src/lib/record/locales/es.js.map +1 -0
- package/src/lib/record/locales/es.mjs +108 -0
- package/src/lib/record/locales/es.mjs.map +1 -0
- package/src/lib/record/locales/fa.d.mts +5 -0
- package/src/lib/record/locales/fa.d.ts +5 -0
- package/src/lib/record/locales/fa.js +117 -0
- package/src/lib/record/locales/fa.js.map +1 -0
- package/src/lib/record/locales/fa.mjs +114 -0
- package/src/lib/record/locales/fa.mjs.map +1 -0
- package/src/lib/record/locales/fr.js +8 -0
- package/src/lib/record/locales/fr.js.map +1 -1
- package/src/lib/record/locales/fr.mjs +8 -0
- package/src/lib/record/locales/fr.mjs.map +1 -1
- package/src/lib/record/locales/later.d.mts +8 -0
- package/src/lib/record/locales/later.d.ts +8 -0
- package/src/lib/record/locales/later.js +16 -0
- package/src/lib/record/locales/later.js.map +1 -0
- package/src/lib/record/locales/later.mjs +13 -0
- package/src/lib/record/locales/later.mjs.map +1 -0
- package/src/lib/record/locales/tr.d.mts +6 -0
- package/src/lib/record/locales/tr.d.ts +6 -0
- package/src/lib/record/locales/tr.js +118 -0
- package/src/lib/record/locales/tr.js.map +1 -0
- package/src/lib/record/locales/tr.mjs +115 -0
- package/src/lib/record/locales/tr.mjs.map +1 -0
- package/src/lib/record/locales/ur.d.mts +9 -0
- package/src/lib/record/locales/ur.d.ts +9 -0
- package/src/lib/record/locales/ur.js +118 -0
- package/src/lib/record/locales/ur.js.map +1 -0
- package/src/lib/record/locales/ur.mjs +115 -0
- package/src/lib/record/locales/ur.mjs.map +1 -0
- package/src/lib/record/memory-codes.d.mts +37 -0
- package/src/lib/record/memory-codes.d.ts +37 -0
- package/src/lib/record/memory-codes.js +50 -0
- package/src/lib/record/memory-codes.js.map +1 -0
- package/src/lib/record/memory-codes.mjs +47 -0
- package/src/lib/record/memory-codes.mjs.map +1 -0
- package/src/lib/record/memory-data-source.d.mts +56 -2
- package/src/lib/record/memory-data-source.d.ts +56 -2
- package/src/lib/record/memory-data-source.js +67 -1
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +67 -1
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/memory-kept.d.mts +3 -1
- package/src/lib/record/memory-kept.d.ts +3 -1
- package/src/lib/record/memory-kept.js +7 -2
- package/src/lib/record/memory-kept.js.map +1 -1
- package/src/lib/record/memory-kept.mjs +7 -2
- package/src/lib/record/memory-kept.mjs.map +1 -1
- package/src/lib/record/memory-later.d.mts +3 -1
- package/src/lib/record/memory-later.d.ts +3 -1
- package/src/lib/record/memory-later.js +9 -5
- package/src/lib/record/memory-later.js.map +1 -1
- package/src/lib/record/memory-later.mjs +8 -4
- package/src/lib/record/memory-later.mjs.map +1 -1
- package/src/lib/record/memory-live.d.mts +8 -0
- package/src/lib/record/memory-live.d.ts +8 -0
- package/src/lib/record/memory-live.js +70 -0
- package/src/lib/record/memory-live.js.map +1 -0
- package/src/lib/record/memory-live.mjs +67 -0
- package/src/lib/record/memory-live.mjs.map +1 -0
- package/src/lib/record/memory-views.d.mts +11 -0
- package/src/lib/record/memory-views.d.ts +11 -0
- package/src/lib/record/memory-views.js +60 -0
- package/src/lib/record/memory-views.js.map +1 -0
- package/src/lib/record/memory-views.mjs +57 -0
- package/src/lib/record/memory-views.mjs.map +1 -0
- package/src/lib/record/messages.d.mts +21 -3
- package/src/lib/record/messages.d.ts +21 -3
- package/src/lib/record/messages.js +15 -2
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +15 -2
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/order.d.mts +21 -0
- package/src/lib/record/order.d.ts +21 -0
- package/src/lib/record/order.js +129 -0
- package/src/lib/record/order.js.map +1 -0
- package/src/lib/record/order.mjs +122 -0
- package/src/lib/record/order.mjs.map +1 -0
- package/src/lib/record/outbox-form.d.mts +79 -0
- package/src/lib/record/outbox-form.d.ts +79 -0
- package/src/lib/record/outbox-form.js +291 -0
- package/src/lib/record/outbox-form.js.map +1 -0
- package/src/lib/record/outbox-form.mjs +286 -0
- package/src/lib/record/outbox-form.mjs.map +1 -0
- package/src/lib/record/outbox-part.d.mts +6 -0
- package/src/lib/record/outbox-part.d.ts +6 -0
- package/src/lib/record/outbox-part.js +13 -0
- package/src/lib/record/outbox-part.js.map +1 -0
- package/src/lib/record/outbox-part.mjs +7 -0
- package/src/lib/record/outbox-part.mjs.map +1 -0
- package/src/lib/record/pay-part.d.mts +6 -0
- package/src/lib/record/pay-part.d.ts +6 -0
- package/src/lib/record/pay-part.js +11 -0
- package/src/lib/record/pay-part.js.map +1 -0
- package/src/lib/record/pay-part.mjs +7 -0
- package/src/lib/record/pay-part.mjs.map +1 -0
- package/src/lib/record/payment-form.d.mts +25 -0
- package/src/lib/record/payment-form.d.ts +25 -0
- package/src/lib/record/payment-form.js +98 -0
- package/src/lib/record/payment-form.js.map +1 -0
- package/src/lib/record/payment-form.mjs +95 -0
- package/src/lib/record/payment-form.mjs.map +1 -0
- package/src/lib/record/prefill-part.d.mts +7 -0
- package/src/lib/record/prefill-part.d.ts +7 -0
- package/src/lib/record/prefill-part.js +15 -0
- package/src/lib/record/prefill-part.js.map +1 -0
- package/src/lib/record/prefill-part.mjs +8 -0
- package/src/lib/record/prefill-part.mjs.map +1 -0
- package/src/lib/record/press-undo.d.mts +42 -0
- package/src/lib/record/press-undo.d.ts +42 -0
- package/src/lib/record/press-undo.js +115 -0
- package/src/lib/record/press-undo.js.map +1 -0
- package/src/lib/record/press-undo.mjs +110 -0
- package/src/lib/record/press-undo.mjs.map +1 -0
- package/src/lib/record/quiz.d.mts +36 -0
- package/src/lib/record/quiz.d.ts +36 -0
- package/src/lib/record/quiz.js +90 -0
- package/src/lib/record/quiz.js.map +1 -0
- package/src/lib/record/quiz.mjs +87 -0
- package/src/lib/record/quiz.mjs.map +1 -0
- package/src/lib/record/record-words.js +1 -1
- package/src/lib/record/record-words.js.map +1 -1
- package/src/lib/record/record-words.mjs +1 -1
- package/src/lib/record/record-words.mjs.map +1 -1
- package/src/lib/record/run.d.mts +54 -2
- package/src/lib/record/run.d.ts +54 -2
- package/src/lib/record/run.js +30 -6
- package/src/lib/record/run.js.map +1 -1
- package/src/lib/record/run.mjs +28 -5
- package/src/lib/record/run.mjs.map +1 -1
- package/src/lib/record/survey-kit.d.mts +37 -0
- package/src/lib/record/survey-kit.d.ts +37 -0
- package/src/lib/record/survey-kit.js +99 -0
- package/src/lib/record/survey-kit.js.map +1 -0
- package/src/lib/record/survey-kit.mjs +96 -0
- package/src/lib/record/survey-kit.mjs.map +1 -0
- package/src/lib/record/survey.d.mts +16 -0
- package/src/lib/record/survey.d.ts +16 -0
- package/src/lib/record/survey.js +17 -0
- package/src/lib/record/survey.js.map +1 -0
- package/src/lib/record/survey.mjs +13 -0
- package/src/lib/record/survey.mjs.map +1 -0
- package/src/lib/record/surveyflow-part.d.mts +9 -0
- package/src/lib/record/surveyflow-part.d.ts +9 -0
- package/src/lib/record/surveyflow-part.js +20 -0
- package/src/lib/record/surveyflow-part.js.map +1 -0
- package/src/lib/record/surveyflow-part.mjs +10 -0
- package/src/lib/record/surveyflow-part.mjs.map +1 -0
- package/src/lib/record/timing.d.mts +76 -0
- package/src/lib/record/timing.d.ts +76 -0
- package/src/lib/record/timing.js +112 -0
- package/src/lib/record/timing.js.map +1 -0
- package/src/lib/record/timing.mjs +104 -0
- package/src/lib/record/timing.mjs.map +1 -0
- package/src/lib/record/undo-later.d.mts +9 -0
- package/src/lib/record/undo-later.d.ts +9 -0
- package/src/lib/record/undo-later.js +10 -0
- package/src/lib/record/undo-later.js.map +1 -0
- package/src/lib/record/undo-later.mjs +7 -0
- package/src/lib/record/undo-later.mjs.map +1 -0
- package/src/lib/record/undo-part.d.mts +8 -0
- package/src/lib/record/undo-part.d.ts +8 -0
- package/src/lib/record/undo-part.js +17 -0
- package/src/lib/record/undo-part.js.map +1 -0
- package/src/lib/record/undo-part.mjs +9 -0
- package/src/lib/record/undo-part.mjs.map +1 -0
- package/src/lib/record/upload-to-later.d.mts +10 -0
- package/src/lib/record/upload-to-later.d.ts +10 -0
- package/src/lib/record/upload-to-later.js +15 -0
- package/src/lib/record/upload-to-later.js.map +1 -0
- package/src/lib/record/upload-to-later.mjs +12 -0
- package/src/lib/record/upload-to-later.mjs.map +1 -0
- package/src/lib/record/uploads.d.mts +5 -0
- package/src/lib/record/uploads.d.ts +5 -0
- package/src/lib/record/uploads.js.map +1 -1
- package/src/lib/record/uploads.mjs.map +1 -1
- package/src/lib/record/values.d.mts +6 -0
- package/src/lib/record/values.d.ts +6 -0
- package/src/lib/record/values.js.map +1 -1
- package/src/lib/record/values.mjs.map +1 -1
- package/src/lib/record/verify-form.d.mts +24 -0
- package/src/lib/record/verify-form.d.ts +24 -0
- package/src/lib/record/verify-form.js +65 -0
- package/src/lib/record/verify-form.js.map +1 -0
- package/src/lib/record/verify-form.mjs +62 -0
- package/src/lib/record/verify-form.mjs.map +1 -0
- package/src/lib/record/verify-part.d.mts +6 -0
- package/src/lib/record/verify-part.d.ts +6 -0
- package/src/lib/record/verify-part.js +11 -0
- package/src/lib/record/verify-part.js.map +1 -0
- package/src/lib/record/verify-part.mjs +7 -0
- package/src/lib/record/verify-part.mjs.map +1 -0
- package/src/lib/record/words-chunks.d.mts +37 -0
- package/src/lib/record/words-chunks.d.ts +37 -0
- package/src/lib/record/words-chunks.js +94 -0
- package/src/lib/record/words-chunks.js.map +1 -0
- package/src/lib/record/words-chunks.mjs +86 -0
- package/src/lib/record/words-chunks.mjs.map +1 -0
- package/src/runtime.d.mts +28 -6
- package/src/runtime.d.ts +28 -6
- package/src/runtime.js +35 -6
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +15 -3
- package/src/runtime.mjs.map +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { functionTable } from '../expression/app-functions.mjs';
|
|
2
|
+
import { compileModifier } from '../expression/modifier.mjs';
|
|
3
|
+
/** A key no other payment has: the provider's idempotency key, the same for every try of one response's payment. */
|
|
4
|
+
const newKey = () => `pay-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
5
|
+
/**
|
|
6
|
+
* The pay part's side of a form (`payment` on its page): what is due — the amount, a number or a field's; its currency,
|
|
7
|
+
* a code or a field's, else a money field's own; while `when` holds, above 0 — taken before the answers go, once the
|
|
8
|
+
* form's own checks found nothing; not taken, nothing is sent; taken, the send carries it (`payment`).
|
|
9
|
+
*/
|
|
10
|
+
export function join(host) {
|
|
11
|
+
const { form, page, options, messages, set } = host;
|
|
12
|
+
const payment = page.payment;
|
|
13
|
+
const source = options.dataSource;
|
|
14
|
+
let key = newKey();
|
|
15
|
+
let shown;
|
|
16
|
+
let when;
|
|
17
|
+
/** A field's value by name, where the page has that field; else the setting itself. */
|
|
18
|
+
const read = (setting) => (typeof setting === 'string' && setting in page.fields ? form.getState().values[setting] : setting);
|
|
19
|
+
const kit = {
|
|
20
|
+
due() {
|
|
21
|
+
if (!payment || !source?.pay)
|
|
22
|
+
return null;
|
|
23
|
+
if (payment.when) {
|
|
24
|
+
const { context, env } = host.reading();
|
|
25
|
+
if (!(when ??= compileModifier(payment.when, functionTable(options.functions))).evaluate(context, env))
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const amount = read(payment.amount);
|
|
29
|
+
if (typeof amount !== 'number' || !Number.isFinite(amount) || amount <= 0)
|
|
30
|
+
return null;
|
|
31
|
+
const field = typeof payment.amount === 'string' ? page.fields[payment.amount] : undefined;
|
|
32
|
+
const own = field?.type === 'monetary' ? (field.currency ?? (field.currencyField ? form.getState().values[field.currencyField] : undefined)) : undefined;
|
|
33
|
+
const written = payment.currency !== undefined ? read(payment.currency) : own;
|
|
34
|
+
const currency = typeof written === 'string' ? written : written && typeof written === 'object' && 'label' in written ? String(written.label) : '';
|
|
35
|
+
if (!/^[A-Z]{3}$/.test(currency))
|
|
36
|
+
return null;
|
|
37
|
+
return { amount, currency, label: payment.label, ...(payment.description ? { description: payment.description } : {}), key };
|
|
38
|
+
},
|
|
39
|
+
covered(due) {
|
|
40
|
+
const paid = form.getState().paid;
|
|
41
|
+
return !!paid && paid.key === due.key && paid.amount === due.amount && paid.currency === due.currency;
|
|
42
|
+
},
|
|
43
|
+
async pay(due) {
|
|
44
|
+
const state = form.getState();
|
|
45
|
+
const request = {
|
|
46
|
+
pageId: page.id,
|
|
47
|
+
model: page.data.kind === 'record' ? page.data.model : '',
|
|
48
|
+
recordId: state.recordId ?? null,
|
|
49
|
+
amount: due.amount,
|
|
50
|
+
currency: due.currency,
|
|
51
|
+
label: due.label,
|
|
52
|
+
...(due.description ? { description: due.description } : {}),
|
|
53
|
+
key: due.key,
|
|
54
|
+
// The values as the send will carry them — hidden fields and those a link filled among them: what a checkout
|
|
55
|
+
// fills its own boxes from, and a campaign's code it may price by.
|
|
56
|
+
values: host.sending(),
|
|
57
|
+
language: page.language ?? messages.locale,
|
|
58
|
+
};
|
|
59
|
+
let paid = null;
|
|
60
|
+
const step = shown ?? options.host?.pay;
|
|
61
|
+
if (step)
|
|
62
|
+
paid = await step(due, request);
|
|
63
|
+
else if (source?.pay) {
|
|
64
|
+
const answer = await source.pay(request);
|
|
65
|
+
paid = answer.status === 'paid' ? { amount: due.amount, currency: due.currency, key: due.key, ...(answer.reference ? { reference: answer.reference } : {}) } : null;
|
|
66
|
+
}
|
|
67
|
+
if (paid)
|
|
68
|
+
set({ paid });
|
|
69
|
+
return paid;
|
|
70
|
+
},
|
|
71
|
+
step(step) {
|
|
72
|
+
shown = step;
|
|
73
|
+
},
|
|
74
|
+
// Before a send the form's own checks let go: what is due taken, or nothing sent.
|
|
75
|
+
async before(problems) {
|
|
76
|
+
if (Object.keys(problems).length)
|
|
77
|
+
return;
|
|
78
|
+
const due = kit.due();
|
|
79
|
+
if (due && !kit.covered(due) && !(await kit.pay(due)))
|
|
80
|
+
return false;
|
|
81
|
+
return undefined;
|
|
82
|
+
},
|
|
83
|
+
around(kind, sent, go) {
|
|
84
|
+
const paid = form.getState().paid;
|
|
85
|
+
return go(kind !== 'upload' && paid ? { ...sent, payment: paid } : sent);
|
|
86
|
+
},
|
|
87
|
+
// Another response, or another record: a payment of its own, by a new key.
|
|
88
|
+
reset() {
|
|
89
|
+
key = newKey();
|
|
90
|
+
set({ paid: null });
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
return kit;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=payment-form.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-form.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/payment-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAuBhF,oHAAoH;AACpH,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAEjG;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,IAAe;IAClC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACpD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAClC,IAAI,GAAG,GAAG,MAAM,EAAE,CAAC;IACnB,IAAI,KAA0B,CAAC;IAC/B,IAAI,IAAkC,CAAC;IACvC,uFAAuF;IACvF,MAAM,IAAI,GAAG,CAAC,OAAoC,EAAE,EAAE,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,OAAO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C;QACf,CAAC;QACD,kFAAkF;QAClF,KAAK,CAAC,MAAM,CAAC,QAAQ;YACnB,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM;gBAAE,OAAO;YACzC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;YACtB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;YACpE,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YACnB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3E,CAAC;QACD,2EAA2E;QAC3E,KAAK;YACH,GAAG,GAAG,MAAM,EAAE,CAAC;YACf,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACtB,CAAC;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prefill part (joins.ts): a link's parameters read as the fields they fill, and its side of a form — those fields
|
|
3
|
+
* laid where it starts, the hidden ones sent with the answers (link-values.ts). In the one-tag script it comes as
|
|
4
|
+
* fieldia.prefill.js, with the page checks of a page's `prefill` (prefill-checks.ts), asked for by a form whose page
|
|
5
|
+
* fills fields from its link.
|
|
6
|
+
*/
|
|
7
|
+
export { join, linkParams, linkValue, linkValues } from './link-values.mjs';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prefill part (joins.ts): a link's parameters read as the fields they fill, and its side of a form — those fields
|
|
3
|
+
* laid where it starts, the hidden ones sent with the answers (link-values.ts). In the one-tag script it comes as
|
|
4
|
+
* fieldia.prefill.js, with the page checks of a page's `prefill` (prefill-checks.ts), asked for by a form whose page
|
|
5
|
+
* fills fields from its link.
|
|
6
|
+
*/
|
|
7
|
+
export { join, linkParams, linkValue, linkValues } from './link-values';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.linkValues = exports.linkValue = exports.linkParams = exports.join = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The prefill part (joins.ts): a link's parameters read as the fields they fill, and its side of a form — those fields
|
|
6
|
+
* laid where it starts, the hidden ones sent with the answers (link-values.ts). In the one-tag script it comes as
|
|
7
|
+
* fieldia.prefill.js, with the page checks of a page's `prefill` (prefill-checks.ts), asked for by a form whose page
|
|
8
|
+
* fills fields from its link.
|
|
9
|
+
*/
|
|
10
|
+
var link_values_1 = require("./link-values");
|
|
11
|
+
Object.defineProperty(exports, "join", { enumerable: true, get: function () { return link_values_1.join; } });
|
|
12
|
+
Object.defineProperty(exports, "linkParams", { enumerable: true, get: function () { return link_values_1.linkParams; } });
|
|
13
|
+
Object.defineProperty(exports, "linkValue", { enumerable: true, get: function () { return link_values_1.linkValue; } });
|
|
14
|
+
Object.defineProperty(exports, "linkValues", { enumerable: true, get: function () { return link_values_1.linkValues; } });
|
|
15
|
+
//# sourceMappingURL=prefill-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefill-part.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/prefill-part.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6CAAwE;AAA/D,mGAAA,IAAI,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,wGAAA,SAAS,OAAA;AAAE,yGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prefill part (joins.ts): a link's parameters read as the fields they fill, and its side of a form — those fields
|
|
3
|
+
* laid where it starts, the hidden ones sent with the answers (link-values.ts). In the one-tag script it comes as
|
|
4
|
+
* fieldia.prefill.js, with the page checks of a page's `prefill` (prefill-checks.ts), asked for by a form whose page
|
|
5
|
+
* fills fields from its link.
|
|
6
|
+
*/
|
|
7
|
+
export { join, linkParams, linkValue, linkValues } from './link-values.mjs';
|
|
8
|
+
//# sourceMappingURL=prefill-part.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefill-part.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/prefill-part.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ButtonNode, MenuItem, PressUndo, StatButton } from '../format/layout.mjs';
|
|
2
|
+
import { type PressTaken, type RunResult, type RunScope, type UndoKit } from './run.mjs';
|
|
3
|
+
import type { Fields } from '../format/field.mjs';
|
|
4
|
+
import type { FormInner } from './joins.mjs';
|
|
5
|
+
import { type Value, type Values } from './values.mjs';
|
|
6
|
+
/** What a press did, as Undo takes it back: the values it changed (each before and after), and whether it saved them. */
|
|
7
|
+
export interface PressDone extends Pick<PressTaken, 'app' | 'archived'> {
|
|
8
|
+
wrote: Map<string, {
|
|
9
|
+
before: Value;
|
|
10
|
+
after: Value;
|
|
11
|
+
}>;
|
|
12
|
+
saved?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What a press did, read as it ends against the values it began with (`PressTaken.at`): each field it changed — a
|
|
16
|
+
* value worked out aside, which follows — and whether it saved them (the record holds no change left to save).
|
|
17
|
+
*/
|
|
18
|
+
export declare function pressDone(taken: PressTaken, now: Values, fields: Fields, saved: boolean): PressDone;
|
|
19
|
+
/**
|
|
20
|
+
* Take back what a press did (`PressTaken`), as its toast's Undo asks: the app's own undos, latest first, each
|
|
21
|
+
* answered as a call is; the record it archived brought back, or the reverse; then the values its steps and the
|
|
22
|
+
* app's answers wrote put back — each only while it holds what they left, a change made since by anyone else staying
|
|
23
|
+
* — and saved again where the press saved. On the record the press was on: another shown since, nothing is done.
|
|
24
|
+
*/
|
|
25
|
+
export declare function takeBack(kit: UndoKit, taken: PressDone, scope: RunScope): Promise<RunResult>;
|
|
26
|
+
/** What a press that offered Undo is said with once it ends, and what Undo is handed (form.ts). */
|
|
27
|
+
export interface OfferContext {
|
|
28
|
+
kit: UndoKit;
|
|
29
|
+
source: ButtonNode | StatButton | MenuItem;
|
|
30
|
+
scope: RunScope;
|
|
31
|
+
taken: PressTaken;
|
|
32
|
+
result: RunResult;
|
|
33
|
+
offers: PressUndo | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A press that offers Undo has ended: the words it held are said — the last, once it ran whole, with Undo, where what
|
|
37
|
+
* it did can be taken back (its button's steps for it; else Fieldia's own taking back, where nothing it did is beyond
|
|
38
|
+
* it — a copy, a delete, a page opened, a post, the app's call answered with no undo; else the app's own undos) — or,
|
|
39
|
+
* with nothing said, "Done: {label}". Undo runs on the record the press ended on: another shown since, only the app's
|
|
40
|
+
* own undos run.
|
|
41
|
+
*/
|
|
42
|
+
export declare function offerUndo(inner: FormInner, context: OfferContext): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ButtonNode, MenuItem, PressUndo, StatButton } from '../format/layout';
|
|
2
|
+
import { type PressTaken, type RunResult, type RunScope, type UndoKit } from './run';
|
|
3
|
+
import type { Fields } from '../format/field';
|
|
4
|
+
import type { FormInner } from './joins';
|
|
5
|
+
import { type Value, type Values } from './values';
|
|
6
|
+
/** What a press did, as Undo takes it back: the values it changed (each before and after), and whether it saved them. */
|
|
7
|
+
export interface PressDone extends Pick<PressTaken, 'app' | 'archived'> {
|
|
8
|
+
wrote: Map<string, {
|
|
9
|
+
before: Value;
|
|
10
|
+
after: Value;
|
|
11
|
+
}>;
|
|
12
|
+
saved?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What a press did, read as it ends against the values it began with (`PressTaken.at`): each field it changed — a
|
|
16
|
+
* value worked out aside, which follows — and whether it saved them (the record holds no change left to save).
|
|
17
|
+
*/
|
|
18
|
+
export declare function pressDone(taken: PressTaken, now: Values, fields: Fields, saved: boolean): PressDone;
|
|
19
|
+
/**
|
|
20
|
+
* Take back what a press did (`PressTaken`), as its toast's Undo asks: the app's own undos, latest first, each
|
|
21
|
+
* answered as a call is; the record it archived brought back, or the reverse; then the values its steps and the
|
|
22
|
+
* app's answers wrote put back — each only while it holds what they left, a change made since by anyone else staying
|
|
23
|
+
* — and saved again where the press saved. On the record the press was on: another shown since, nothing is done.
|
|
24
|
+
*/
|
|
25
|
+
export declare function takeBack(kit: UndoKit, taken: PressDone, scope: RunScope): Promise<RunResult>;
|
|
26
|
+
/** What a press that offered Undo is said with once it ends, and what Undo is handed (form.ts). */
|
|
27
|
+
export interface OfferContext {
|
|
28
|
+
kit: UndoKit;
|
|
29
|
+
source: ButtonNode | StatButton | MenuItem;
|
|
30
|
+
scope: RunScope;
|
|
31
|
+
taken: PressTaken;
|
|
32
|
+
result: RunResult;
|
|
33
|
+
offers: PressUndo | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A press that offers Undo has ended: the words it held are said — the last, once it ran whole, with Undo, where what
|
|
37
|
+
* it did can be taken back (its button's steps for it; else Fieldia's own taking back, where nothing it did is beyond
|
|
38
|
+
* it — a copy, a delete, a page opened, a post, the app's call answered with no undo; else the app's own undos) — or,
|
|
39
|
+
* with nothing said, "Done: {label}". Undo runs on the record the press ended on: another shown since, only the app's
|
|
40
|
+
* own undos run.
|
|
41
|
+
*/
|
|
42
|
+
export declare function offerUndo(inner: FormInner, context: OfferContext): void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pressDone = pressDone;
|
|
4
|
+
exports.takeBack = takeBack;
|
|
5
|
+
exports.offerUndo = offerUndo;
|
|
6
|
+
const messages_1 = require("./messages");
|
|
7
|
+
const run_1 = require("./run");
|
|
8
|
+
const values_1 = require("./values");
|
|
9
|
+
const wordsOf = (error) => (error instanceof Error ? error.message : String(error));
|
|
10
|
+
/** The steps a press does that Fieldia cannot take back by itself: a copy, a delete, a form put back or closed, a page opened, an address, a post. */
|
|
11
|
+
const BEYOND = /"do":"(duplicate|delete|reset|close|open|openUrl|post)"/;
|
|
12
|
+
/**
|
|
13
|
+
* What a press did, read as it ends against the values it began with (`PressTaken.at`): each field it changed — a
|
|
14
|
+
* value worked out aside, which follows — and whether it saved them (the record holds no change left to save).
|
|
15
|
+
*/
|
|
16
|
+
function pressDone(taken, now, fields, saved) {
|
|
17
|
+
const wrote = new Map();
|
|
18
|
+
for (const name of new Set([...Object.keys(taken.at), ...Object.keys(now)])) {
|
|
19
|
+
if (fields[name]?.compute || (0, values_1.sameValue)(taken.at[name], now[name]))
|
|
20
|
+
continue;
|
|
21
|
+
wrote.set(name, { before: (taken.at[name] ?? null), after: (0, values_1.structuredCopy)(now[name] ?? null) });
|
|
22
|
+
}
|
|
23
|
+
return { app: taken.app, ...(taken.archived !== undefined ? { archived: taken.archived } : {}), wrote, ...(wrote.size && saved ? { saved } : {}) };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Take back what a press did (`PressTaken`), as its toast's Undo asks: the app's own undos, latest first, each
|
|
27
|
+
* answered as a call is; the record it archived brought back, or the reverse; then the values its steps and the
|
|
28
|
+
* app's answers wrote put back — each only while it holds what they left, a change made since by anyone else staying
|
|
29
|
+
* — and saved again where the press saved. On the record the press was on: another shown since, nothing is done.
|
|
30
|
+
*/
|
|
31
|
+
async function takeBack(kit, taken, scope) {
|
|
32
|
+
const { form, answered, recordStep, replaced, tell } = kit;
|
|
33
|
+
scope.generation ??= form.generation();
|
|
34
|
+
const ended = (stopped) => stopped ? { done: false, reason: stopped.reason, ...(stopped.message !== undefined ? { message: stopped.message } : {}), ...(stopped.error !== undefined ? { error: stopped.error } : {}) } : run_1.DONE;
|
|
35
|
+
try {
|
|
36
|
+
// The app's own, whatever record is shown now: what it answers is laid only on the one the press ended on.
|
|
37
|
+
for (const undo of [...taken.app].reverse()) {
|
|
38
|
+
let answer;
|
|
39
|
+
try {
|
|
40
|
+
answer = await undo();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return ended({ reason: 'app', message: wordsOf(error), error });
|
|
44
|
+
}
|
|
45
|
+
if (!answer)
|
|
46
|
+
continue;
|
|
47
|
+
if (replaced(scope)) {
|
|
48
|
+
if (answer.say !== undefined)
|
|
49
|
+
tell(null, typeof answer.say === 'string' ? answer.say : answer.say.message, (typeof answer.say === 'object' && answer.say.tone) || 'info');
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const stopped = await answered(answer, scope);
|
|
53
|
+
if (stopped)
|
|
54
|
+
return ended(stopped);
|
|
55
|
+
}
|
|
56
|
+
if (taken.archived === undefined && !taken.wrote.size)
|
|
57
|
+
return run_1.DONE;
|
|
58
|
+
if (replaced(scope))
|
|
59
|
+
return ended(form.gone());
|
|
60
|
+
if (taken.archived !== undefined) {
|
|
61
|
+
const stopped = await recordStep(taken.archived ? 'unarchive' : 'archive', scope);
|
|
62
|
+
if (stopped)
|
|
63
|
+
return ended(stopped);
|
|
64
|
+
}
|
|
65
|
+
if (!taken.wrote.size)
|
|
66
|
+
return run_1.DONE;
|
|
67
|
+
const back = {};
|
|
68
|
+
for (const [name, { before, after }] of taken.wrote)
|
|
69
|
+
if ((0, values_1.sameValue)(form.values()[name], after))
|
|
70
|
+
back[name] = before;
|
|
71
|
+
if (Object.keys(back).length)
|
|
72
|
+
form.write(back, scope.chain);
|
|
73
|
+
return ended(taken.saved ? await form.save(scope.chain) : null);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return ended({ reason: 'cannot', message: wordsOf(error), error });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A press that offers Undo has ended: the words it held are said — the last, once it ran whole, with Undo, where what
|
|
81
|
+
* it did can be taken back (its button's steps for it; else Fieldia's own taking back, where nothing it did is beyond
|
|
82
|
+
* it — a copy, a delete, a page opened, a post, the app's call answered with no undo; else the app's own undos) — or,
|
|
83
|
+
* with nothing said, "Done: {label}". Undo runs on the record the press ended on: another shown since, only the app's
|
|
84
|
+
* own undos run.
|
|
85
|
+
*/
|
|
86
|
+
function offerUndo(inner, context) {
|
|
87
|
+
const { kit, source, scope, taken, result, offers } = context;
|
|
88
|
+
const { messages } = inner;
|
|
89
|
+
const host = kit.form.host;
|
|
90
|
+
const done = pressDone(taken, kit.form.values(), inner.fields, !kit.form.changed());
|
|
91
|
+
const beyond = taken.beyond ?? BEYOND.exec(JSON.stringify([source.steps ?? [], 'builtin' in source ? { do: source.builtin } : {}]))?.[1];
|
|
92
|
+
const did = taken.app.length > 0 || taken.archived !== undefined || done.wrote.size > 0;
|
|
93
|
+
const can = result.done && (Array.isArray(offers) || (offers === true ? did && beyond === undefined : taken.app.length > 0));
|
|
94
|
+
const said = [...taken.said];
|
|
95
|
+
const builtin = 'builtin' in source ? source.builtin : undefined;
|
|
96
|
+
const plain = builtin === 'archive' ? messages.pressArchived : builtin === 'unarchive' ? messages.pressUnarchived : (0, messages_1.fillMessage)(messages, messages.pressDone, { label: source.label ?? '' });
|
|
97
|
+
const last = can ? (said.pop() ?? { message: plain, tone: 'success' }) : null;
|
|
98
|
+
for (const words of said)
|
|
99
|
+
host?.say(words.message, words.tone);
|
|
100
|
+
if (!last)
|
|
101
|
+
return;
|
|
102
|
+
const on = kit.form.generation();
|
|
103
|
+
const id = `${scope.id}.undo`;
|
|
104
|
+
host?.say(last.message, last.tone, {
|
|
105
|
+
undo: () => inner.track((async () => {
|
|
106
|
+
const again = { id, chain: [], typed: 'first', generation: on, ...(scope.recordIds ? { recordIds: [...scope.recordIds] } : {}) };
|
|
107
|
+
const steps = Array.isArray(offers) ? offers : [];
|
|
108
|
+
// Its steps, on the record the press ended on; else what it did, taken back.
|
|
109
|
+
const ended = Array.isArray(offers) ? (on === kit.form.generation() ? await kit.runSteps(offers, again) : { done: false, ...inner.replaced() }) : await takeBack(kit, offers === true ? done : { app: taken.app, wrote: new Map() }, again);
|
|
110
|
+
inner.emit('run', { id, steps, result: ended });
|
|
111
|
+
return ended;
|
|
112
|
+
})()),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=press-undo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press-undo.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/press-undo.ts"],"names":[],"mappings":";;AAsBA,8BAOC;AAQD,4BAoCC;AAmBD,8BA6BC;AAxHD,yCAAyC;AACzC,+BAA4H;AAG5H,qCAA8E;AAE9E,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAQ7F,sJAAsJ;AACtJ,MAAM,MAAM,GAAG,yDAAyD,CAAC;AAEzE;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAiB,EAAE,GAAW,EAAE,MAAc,EAAE,KAAc;IACtF,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2C,CAAC;IACjE,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,IAAI,M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,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YAClD,6EAA6E;YAC7E,MAAM,KAAK,GAAc,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;YACvP,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,EAAE,CACL;KACJ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { fillMessage } from './messages.mjs';
|
|
2
|
+
import { DONE } from './run.mjs';
|
|
3
|
+
import { sameValue, structuredCopy } from './values.mjs';
|
|
4
|
+
const wordsOf = (error) => (error instanceof Error ? error.message : String(error));
|
|
5
|
+
/** The steps a press does that Fieldia cannot take back by itself: a copy, a delete, a form put back or closed, a page opened, an address, a post. */
|
|
6
|
+
const BEYOND = /"do":"(duplicate|delete|reset|close|open|openUrl|post)"/;
|
|
7
|
+
/**
|
|
8
|
+
* What a press did, read as it ends against the values it began with (`PressTaken.at`): each field it changed — a
|
|
9
|
+
* value worked out aside, which follows — and whether it saved them (the record holds no change left to save).
|
|
10
|
+
*/
|
|
11
|
+
export function pressDone(taken, now, fields, saved) {
|
|
12
|
+
const wrote = new Map();
|
|
13
|
+
for (const name of new Set([...Object.keys(taken.at), ...Object.keys(now)])) {
|
|
14
|
+
if (fields[name]?.compute || sameValue(taken.at[name], now[name]))
|
|
15
|
+
continue;
|
|
16
|
+
wrote.set(name, { before: (taken.at[name] ?? null), after: structuredCopy(now[name] ?? null) });
|
|
17
|
+
}
|
|
18
|
+
return { app: taken.app, ...(taken.archived !== undefined ? { archived: taken.archived } : {}), wrote, ...(wrote.size && saved ? { saved } : {}) };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Take back what a press did (`PressTaken`), as its toast's Undo asks: the app's own undos, latest first, each
|
|
22
|
+
* answered as a call is; the record it archived brought back, or the reverse; then the values its steps and the
|
|
23
|
+
* app's answers wrote put back — each only while it holds what they left, a change made since by anyone else staying
|
|
24
|
+
* — and saved again where the press saved. On the record the press was on: another shown since, nothing is done.
|
|
25
|
+
*/
|
|
26
|
+
export async function takeBack(kit, taken, scope) {
|
|
27
|
+
const { form, answered, recordStep, replaced, tell } = kit;
|
|
28
|
+
scope.generation ??= form.generation();
|
|
29
|
+
const ended = (stopped) => stopped ? { done: false, reason: stopped.reason, ...(stopped.message !== undefined ? { message: stopped.message } : {}), ...(stopped.error !== undefined ? { error: stopped.error } : {}) } : DONE;
|
|
30
|
+
try {
|
|
31
|
+
// The app's own, whatever record is shown now: what it answers is laid only on the one the press ended on.
|
|
32
|
+
for (const undo of [...taken.app].reverse()) {
|
|
33
|
+
let answer;
|
|
34
|
+
try {
|
|
35
|
+
answer = await undo();
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return ended({ reason: 'app', message: wordsOf(error), error });
|
|
39
|
+
}
|
|
40
|
+
if (!answer)
|
|
41
|
+
continue;
|
|
42
|
+
if (replaced(scope)) {
|
|
43
|
+
if (answer.say !== undefined)
|
|
44
|
+
tell(null, typeof answer.say === 'string' ? answer.say : answer.say.message, (typeof answer.say === 'object' && answer.say.tone) || 'info');
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const stopped = await answered(answer, scope);
|
|
48
|
+
if (stopped)
|
|
49
|
+
return ended(stopped);
|
|
50
|
+
}
|
|
51
|
+
if (taken.archived === undefined && !taken.wrote.size)
|
|
52
|
+
return DONE;
|
|
53
|
+
if (replaced(scope))
|
|
54
|
+
return ended(form.gone());
|
|
55
|
+
if (taken.archived !== undefined) {
|
|
56
|
+
const stopped = await recordStep(taken.archived ? 'unarchive' : 'archive', scope);
|
|
57
|
+
if (stopped)
|
|
58
|
+
return ended(stopped);
|
|
59
|
+
}
|
|
60
|
+
if (!taken.wrote.size)
|
|
61
|
+
return DONE;
|
|
62
|
+
const back = {};
|
|
63
|
+
for (const [name, { before, after }] of taken.wrote)
|
|
64
|
+
if (sameValue(form.values()[name], after))
|
|
65
|
+
back[name] = before;
|
|
66
|
+
if (Object.keys(back).length)
|
|
67
|
+
form.write(back, scope.chain);
|
|
68
|
+
return ended(taken.saved ? await form.save(scope.chain) : null);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return ended({ reason: 'cannot', message: wordsOf(error), error });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A press that offers Undo has ended: the words it held are said — the last, once it ran whole, with Undo, where what
|
|
76
|
+
* it did can be taken back (its button's steps for it; else Fieldia's own taking back, where nothing it did is beyond
|
|
77
|
+
* it — a copy, a delete, a page opened, a post, the app's call answered with no undo; else the app's own undos) — or,
|
|
78
|
+
* with nothing said, "Done: {label}". Undo runs on the record the press ended on: another shown since, only the app's
|
|
79
|
+
* own undos run.
|
|
80
|
+
*/
|
|
81
|
+
export function offerUndo(inner, context) {
|
|
82
|
+
const { kit, source, scope, taken, result, offers } = context;
|
|
83
|
+
const { messages } = inner;
|
|
84
|
+
const host = kit.form.host;
|
|
85
|
+
const done = pressDone(taken, kit.form.values(), inner.fields, !kit.form.changed());
|
|
86
|
+
const beyond = taken.beyond ?? BEYOND.exec(JSON.stringify([source.steps ?? [], 'builtin' in source ? { do: source.builtin } : {}]))?.[1];
|
|
87
|
+
const did = taken.app.length > 0 || taken.archived !== undefined || done.wrote.size > 0;
|
|
88
|
+
const can = result.done && (Array.isArray(offers) || (offers === true ? did && beyond === undefined : taken.app.length > 0));
|
|
89
|
+
const said = [...taken.said];
|
|
90
|
+
const builtin = 'builtin' in source ? source.builtin : undefined;
|
|
91
|
+
const plain = builtin === 'archive' ? messages.pressArchived : builtin === 'unarchive' ? messages.pressUnarchived : fillMessage(messages, messages.pressDone, { label: source.label ?? '' });
|
|
92
|
+
const last = can ? (said.pop() ?? { message: plain, tone: 'success' }) : null;
|
|
93
|
+
for (const words of said)
|
|
94
|
+
host?.say(words.message, words.tone);
|
|
95
|
+
if (!last)
|
|
96
|
+
return;
|
|
97
|
+
const on = kit.form.generation();
|
|
98
|
+
const id = `${scope.id}.undo`;
|
|
99
|
+
host?.say(last.message, last.tone, {
|
|
100
|
+
undo: () => inner.track((async () => {
|
|
101
|
+
const again = { id, chain: [], typed: 'first', generation: on, ...(scope.recordIds ? { recordIds: [...scope.recordIds] } : {}) };
|
|
102
|
+
const steps = Array.isArray(offers) ? offers : [];
|
|
103
|
+
// Its steps, on the record the press ended on; else what it did, taken back.
|
|
104
|
+
const ended = Array.isArray(offers) ? (on === kit.form.generation() ? await kit.runSteps(offers, again) : { done: false, ...inner.replaced() }) : await takeBack(kit, offers === true ? done : { app: taken.app, wrote: new Map() }, again);
|
|
105
|
+
inner.emit('run', { id, steps, result: ended });
|
|
106
|
+
return ended;
|
|
107
|
+
})()),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=press-undo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press-undo.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/press-undo.ts"],"names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AAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;YACvP,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,EAAE,CACL;KACJ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Page } from '../format/page.mjs';
|
|
2
|
+
import type { Value, Values } from './values.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* A quiz's results (`quiz` on a page): each question asked marked — right or wrong where it has right answers, its
|
|
5
|
+
* points of its most — and the score of them all. The form works them out as the answers are sent (`state.sent.quiz`),
|
|
6
|
+
* unless the app's source answered the send with its own (`SubmitResult.quiz`): a test that keeps its right answers out
|
|
7
|
+
* of the page marks them on its server.
|
|
8
|
+
*/
|
|
9
|
+
export interface QuizResults {
|
|
10
|
+
/** The points earned, of the most the questions asked could earn. */
|
|
11
|
+
score: number;
|
|
12
|
+
max: number;
|
|
13
|
+
/** Each question asked that earns points or has right answers, in the order it was asked. */
|
|
14
|
+
questions: QuizMark[];
|
|
15
|
+
}
|
|
16
|
+
/** One question's mark. */
|
|
17
|
+
export interface QuizMark {
|
|
18
|
+
field: string;
|
|
19
|
+
/** Its points, of its most. */
|
|
20
|
+
points: number;
|
|
21
|
+
max: number;
|
|
22
|
+
/** Right or wrong where the question has right answers; null for one of points alone (its options' `score`). */
|
|
23
|
+
right: boolean | null;
|
|
24
|
+
/** Whether it was answered at all. */
|
|
25
|
+
answered: boolean;
|
|
26
|
+
/** The right answer, as a value of the field (a list of them for several), where the page shows it: for one answered wrongly or not at all. */
|
|
27
|
+
rightAnswer?: Value;
|
|
28
|
+
/** The question's own words for its answer: its feedback when right, or when wrong. */
|
|
29
|
+
feedback?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A quiz's results for the answers sent, in the order the questions were asked (`asked`, the fields whose answers were
|
|
33
|
+
* sent: a question not shown, its step skipped, is none). Null where no question asked earns points or has right
|
|
34
|
+
* answers.
|
|
35
|
+
*/
|
|
36
|
+
export declare function quizResults(page: Page, values: Values, asked?: readonly string[]): QuizResults | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Page } from '../format/page';
|
|
2
|
+
import type { Value, Values } from './values';
|
|
3
|
+
/**
|
|
4
|
+
* A quiz's results (`quiz` on a page): each question asked marked — right or wrong where it has right answers, its
|
|
5
|
+
* points of its most — and the score of them all. The form works them out as the answers are sent (`state.sent.quiz`),
|
|
6
|
+
* unless the app's source answered the send with its own (`SubmitResult.quiz`): a test that keeps its right answers out
|
|
7
|
+
* of the page marks them on its server.
|
|
8
|
+
*/
|
|
9
|
+
export interface QuizResults {
|
|
10
|
+
/** The points earned, of the most the questions asked could earn. */
|
|
11
|
+
score: number;
|
|
12
|
+
max: number;
|
|
13
|
+
/** Each question asked that earns points or has right answers, in the order it was asked. */
|
|
14
|
+
questions: QuizMark[];
|
|
15
|
+
}
|
|
16
|
+
/** One question's mark. */
|
|
17
|
+
export interface QuizMark {
|
|
18
|
+
field: string;
|
|
19
|
+
/** Its points, of its most. */
|
|
20
|
+
points: number;
|
|
21
|
+
max: number;
|
|
22
|
+
/** Right or wrong where the question has right answers; null for one of points alone (its options' `score`). */
|
|
23
|
+
right: boolean | null;
|
|
24
|
+
/** Whether it was answered at all. */
|
|
25
|
+
answered: boolean;
|
|
26
|
+
/** The right answer, as a value of the field (a list of them for several), where the page shows it: for one answered wrongly or not at all. */
|
|
27
|
+
rightAnswer?: Value;
|
|
28
|
+
/** The question's own words for its answer: its feedback when right, or when wrong. */
|
|
29
|
+
feedback?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A quiz's results for the answers sent, in the order the questions were asked (`asked`, the fields whose answers were
|
|
33
|
+
* sent: a question not shown, its step skipped, is none). Null where no question asked earns points or has right
|
|
34
|
+
* answers.
|
|
35
|
+
*/
|
|
36
|
+
export declare function quizResults(page: Page, values: Values, asked?: readonly string[]): QuizResults | null;
|