@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,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quizResults = quizResults;
|
|
4
|
+
/** Sums of tenths and the like without a computer's crumbs: 0.1 + 0.2 is 0.3. */
|
|
5
|
+
const tidy = (n) => Math.round(n * 1e9) / 1e9;
|
|
6
|
+
const empty = (value) => value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0);
|
|
7
|
+
/** A word as a person may write it: its case and the spaces round and inside it aside. */
|
|
8
|
+
const plain = (value) => String(value).trim().replace(/\s+/g, ' ').toLocaleLowerCase();
|
|
9
|
+
/** What a question's quiz says, by its kind: its right answers and points, or null for a question that is none. */
|
|
10
|
+
function quizOf(def) {
|
|
11
|
+
if (!def)
|
|
12
|
+
return null;
|
|
13
|
+
if (def.type === 'selection') {
|
|
14
|
+
const marked = def.options.some((option) => option.correct === true || option.score !== undefined);
|
|
15
|
+
return marked ? { options: def.options, answers: null, several: def.multiple === true } : null;
|
|
16
|
+
}
|
|
17
|
+
if ((def.type === 'char' || def.type === 'integer' || def.type === 'float') && def.quiz?.answers?.length)
|
|
18
|
+
return { options: null, answers: def.quiz.answers, several: false };
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
/** Whether a typed answer is one the question takes: a number by its value, words whatever their case and spaces. */
|
|
22
|
+
function takes(answers, value, numeric) {
|
|
23
|
+
if (empty(value))
|
|
24
|
+
return false;
|
|
25
|
+
if (numeric)
|
|
26
|
+
return answers.some((answer) => Number(answer) === Number(value));
|
|
27
|
+
return answers.some((answer) => plain(answer) === plain(value));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A quiz's results for the answers sent, in the order the questions were asked (`asked`, the fields whose answers were
|
|
31
|
+
* sent: a question not shown, its step skipped, is none). Null where no question asked earns points or has right
|
|
32
|
+
* answers.
|
|
33
|
+
*/
|
|
34
|
+
function quizResults(page, values, asked = Object.keys(values)) {
|
|
35
|
+
const each = page.quiz?.points ?? 1;
|
|
36
|
+
const showRight = page.quiz?.rightAnswers !== false;
|
|
37
|
+
const questions = [];
|
|
38
|
+
for (const field of asked) {
|
|
39
|
+
const def = page.fields[field];
|
|
40
|
+
const quiz = quizOf(def);
|
|
41
|
+
if (!quiz || !def)
|
|
42
|
+
continue;
|
|
43
|
+
const answer = values[field];
|
|
44
|
+
const answered = !empty(answer);
|
|
45
|
+
const worth = def.quiz?.points ?? each;
|
|
46
|
+
let points = 0;
|
|
47
|
+
let max = 0;
|
|
48
|
+
let right = null;
|
|
49
|
+
let rightAnswer;
|
|
50
|
+
if (quiz.options) {
|
|
51
|
+
const chosen = quiz.several ? (Array.isArray(answer) ? answer : []) : answered ? [answer] : [];
|
|
52
|
+
const scored = quiz.options.some((option) => option.score !== undefined);
|
|
53
|
+
const correct = quiz.options.filter((option) => option.correct === true);
|
|
54
|
+
if (correct.length) {
|
|
55
|
+
// Several: right when exactly the right ones are chosen; one: right when the one chosen is a right one.
|
|
56
|
+
right = quiz.several ? chosen.length === correct.length && correct.every((option) => chosen.includes(option.value)) : chosen.length === 1 && correct.some((option) => option.value === chosen[0]);
|
|
57
|
+
rightAnswer = quiz.several ? correct.map((option) => option.value) : correct[0].value;
|
|
58
|
+
}
|
|
59
|
+
if (scored) {
|
|
60
|
+
// Points by the options chosen, as `scoreOf` counts them: the best of one, every one worth something of several.
|
|
61
|
+
points = chosen.reduce((sum, value) => sum + (quiz.options?.find((option) => option.value === value)?.score ?? 0), 0);
|
|
62
|
+
max = quiz.several ? quiz.options.reduce((sum, option) => sum + Math.max(0, option.score ?? 0), 0) : quiz.options.reduce((most, option) => Math.max(most, option.score ?? 0), 0);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
points = right ? worth : 0;
|
|
66
|
+
max = worth;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (quiz.answers) {
|
|
70
|
+
right = takes(quiz.answers, answer, def.type !== 'char');
|
|
71
|
+
points = right ? worth : 0;
|
|
72
|
+
max = worth;
|
|
73
|
+
rightAnswer = quiz.answers[0];
|
|
74
|
+
}
|
|
75
|
+
const feedback = right === null ? undefined : def.quiz?.feedback?.[right ? 'right' : 'wrong'];
|
|
76
|
+
questions.push({
|
|
77
|
+
field,
|
|
78
|
+
points: tidy(points),
|
|
79
|
+
max: tidy(max),
|
|
80
|
+
right,
|
|
81
|
+
answered,
|
|
82
|
+
...(right === false && showRight && rightAnswer !== undefined ? { rightAnswer } : {}),
|
|
83
|
+
...(feedback ? { feedback } : {}),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (!questions.length)
|
|
87
|
+
return null;
|
|
88
|
+
return { score: tidy(questions.reduce((sum, mark) => sum + mark.points, 0)), max: tidy(questions.reduce((sum, mark) => sum + mark.max, 0)), questions };
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=quiz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quiz.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/quiz.ts"],"names":[],"mappings":";;AA+DA,kCAmDC;AAhFD,iFAAiF;AACjF,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACtD,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;AACxI,0FAA0F;AAC1F,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC;AAEhG,mHAAmH;AACnH,SAAS,MAAM,CAAC,GAAsB;IACpC,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,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I,CAAC,SAAS,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;AAC1J,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Sums of tenths and the like without a computer's crumbs: 0.1 + 0.2 is 0.3. */
|
|
2
|
+
const tidy = (n) => Math.round(n * 1e9) / 1e9;
|
|
3
|
+
const empty = (value) => value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0);
|
|
4
|
+
/** A word as a person may write it: its case and the spaces round and inside it aside. */
|
|
5
|
+
const plain = (value) => String(value).trim().replace(/\s+/g, ' ').toLocaleLowerCase();
|
|
6
|
+
/** What a question's quiz says, by its kind: its right answers and points, or null for a question that is none. */
|
|
7
|
+
function quizOf(def) {
|
|
8
|
+
if (!def)
|
|
9
|
+
return null;
|
|
10
|
+
if (def.type === 'selection') {
|
|
11
|
+
const marked = def.options.some((option) => option.correct === true || option.score !== undefined);
|
|
12
|
+
return marked ? { options: def.options, answers: null, several: def.multiple === true } : null;
|
|
13
|
+
}
|
|
14
|
+
if ((def.type === 'char' || def.type === 'integer' || def.type === 'float') && def.quiz?.answers?.length)
|
|
15
|
+
return { options: null, answers: def.quiz.answers, several: false };
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/** Whether a typed answer is one the question takes: a number by its value, words whatever their case and spaces. */
|
|
19
|
+
function takes(answers, value, numeric) {
|
|
20
|
+
if (empty(value))
|
|
21
|
+
return false;
|
|
22
|
+
if (numeric)
|
|
23
|
+
return answers.some((answer) => Number(answer) === Number(value));
|
|
24
|
+
return answers.some((answer) => plain(answer) === plain(value));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A quiz's results for the answers sent, in the order the questions were asked (`asked`, the fields whose answers were
|
|
28
|
+
* sent: a question not shown, its step skipped, is none). Null where no question asked earns points or has right
|
|
29
|
+
* answers.
|
|
30
|
+
*/
|
|
31
|
+
export function quizResults(page, values, asked = Object.keys(values)) {
|
|
32
|
+
const each = page.quiz?.points ?? 1;
|
|
33
|
+
const showRight = page.quiz?.rightAnswers !== false;
|
|
34
|
+
const questions = [];
|
|
35
|
+
for (const field of asked) {
|
|
36
|
+
const def = page.fields[field];
|
|
37
|
+
const quiz = quizOf(def);
|
|
38
|
+
if (!quiz || !def)
|
|
39
|
+
continue;
|
|
40
|
+
const answer = values[field];
|
|
41
|
+
const answered = !empty(answer);
|
|
42
|
+
const worth = def.quiz?.points ?? each;
|
|
43
|
+
let points = 0;
|
|
44
|
+
let max = 0;
|
|
45
|
+
let right = null;
|
|
46
|
+
let rightAnswer;
|
|
47
|
+
if (quiz.options) {
|
|
48
|
+
const chosen = quiz.several ? (Array.isArray(answer) ? answer : []) : answered ? [answer] : [];
|
|
49
|
+
const scored = quiz.options.some((option) => option.score !== undefined);
|
|
50
|
+
const correct = quiz.options.filter((option) => option.correct === true);
|
|
51
|
+
if (correct.length) {
|
|
52
|
+
// Several: right when exactly the right ones are chosen; one: right when the one chosen is a right one.
|
|
53
|
+
right = quiz.several ? chosen.length === correct.length && correct.every((option) => chosen.includes(option.value)) : chosen.length === 1 && correct.some((option) => option.value === chosen[0]);
|
|
54
|
+
rightAnswer = quiz.several ? correct.map((option) => option.value) : correct[0].value;
|
|
55
|
+
}
|
|
56
|
+
if (scored) {
|
|
57
|
+
// Points by the options chosen, as `scoreOf` counts them: the best of one, every one worth something of several.
|
|
58
|
+
points = chosen.reduce((sum, value) => sum + (quiz.options?.find((option) => option.value === value)?.score ?? 0), 0);
|
|
59
|
+
max = quiz.several ? quiz.options.reduce((sum, option) => sum + Math.max(0, option.score ?? 0), 0) : quiz.options.reduce((most, option) => Math.max(most, option.score ?? 0), 0);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
points = right ? worth : 0;
|
|
63
|
+
max = worth;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (quiz.answers) {
|
|
67
|
+
right = takes(quiz.answers, answer, def.type !== 'char');
|
|
68
|
+
points = right ? worth : 0;
|
|
69
|
+
max = worth;
|
|
70
|
+
rightAnswer = quiz.answers[0];
|
|
71
|
+
}
|
|
72
|
+
const feedback = right === null ? undefined : def.quiz?.feedback?.[right ? 'right' : 'wrong'];
|
|
73
|
+
questions.push({
|
|
74
|
+
field,
|
|
75
|
+
points: tidy(points),
|
|
76
|
+
max: tidy(max),
|
|
77
|
+
right,
|
|
78
|
+
answered,
|
|
79
|
+
...(right === false && showRight && rightAnswer !== undefined ? { rightAnswer } : {}),
|
|
80
|
+
...(feedback ? { feedback } : {}),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (!questions.length)
|
|
84
|
+
return null;
|
|
85
|
+
return { score: tidy(questions.reduce((sum, mark) => sum + mark.points, 0)), max: tidy(questions.reduce((sum, mark) => sum + mark.max, 0)), questions };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=quiz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quiz.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/quiz.ts"],"names":[],"mappings":"AAkCA,iFAAiF;AACjF,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACtD,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,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AAE,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAChK,SAAS,CAAC,IAAI,CAAC;YACb,KAAK;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;YACpB,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;YACd,KAAK;YACL,QAAQ;YACR,GAAG,CAAC,KAAK,KAAK,KAAK,IAAI,SAAS,IAAI,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrF,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,SAAS,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;AAC1J,CAAC"}
|
|
@@ -37,7 +37,7 @@ function isQuestion(label) {
|
|
|
37
37
|
return /([?؟?⸮]|…|\.\.\.)\s*$/u.test(label);
|
|
38
38
|
}
|
|
39
39
|
/** Each language's quotation marks round a question its sentence names: “…” where it has none of its own here. */
|
|
40
|
-
const QUOTES = { de: ['„', '“'], fr: ['« ', ' »'], ar: ['«', '»'] };
|
|
40
|
+
const QUOTES = { de: ['„', '“'], fr: ['« ', ' »'], ar: ['«', '»'], fa: ['«', '»'] };
|
|
41
41
|
/**
|
|
42
42
|
* A label as a sentence names it: a question (`isQuestion`) between the language's quotation marks — "Please answer
|
|
43
43
|
* “How was your visit?”", "“How many days?” must be at most 5" — and a name as written.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-words.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/record-words.ts"],"names":[],"mappings":";;AAoBA,wCAMC;AAQD,gCAEC;AASD,kCAIC;AAwBD,0BAIC;AA5ED,mDAAoD;AAEpD,iGAAiG;AACjG,MAAM,KAAK,GAAG,+BAA+B,CAAC;AAE9C,uGAAuG;AACvG,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAEvC,2FAA2F;AAC3F,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACvG,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjI;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,OAAgC,EAAE,KAAyB,EAAE,KAAa,EAAE,MAAM,GAAG,IAAI;IACtH,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACpD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CA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AAE,MAAM,CAAC,CAAC;IACpD,kEAAkE;IAClE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,SAAS,OAAO,CAAC,QAAgB,EAAE,GAAW,EAAE,KAA0B,EAAE,MAAc;IACxF,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAA,yBAAa,EAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACpF,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;IACzC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACvC,iIAAiI;IACjI,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GAAG,EAAY,CAAC,CAAC,CAAC;IACxJ,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5C,CAAC"}
|
|
@@ -31,7 +31,7 @@ export function isQuestion(label) {
|
|
|
31
31
|
return /([?؟?⸮]|…|\.\.\.)\s*$/u.test(label);
|
|
32
32
|
}
|
|
33
33
|
/** Each language's quotation marks round a question its sentence names: “…” where it has none of its own here. */
|
|
34
|
-
const QUOTES = { de: ['„', '“'], fr: ['« ', ' »'], ar: ['«', '»'] };
|
|
34
|
+
const QUOTES = { de: ['„', '“'], fr: ['« ', ' »'], ar: ['«', '»'], fa: ['«', '»'] };
|
|
35
35
|
/**
|
|
36
36
|
* A label as a sentence names it: a question (`isQuestion`) between the language's quotation marks — "Please answer
|
|
37
37
|
* “How was your visit?”", "“How many days?” must be at most 5" — and a name as written.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-words.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/record-words.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,iGAAiG;AACjG,MAAM,KAAK,GAAG,+BAA+B,CAAC;AAE9C,uGAAuG;AACvG,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAEvC,2FAA2F;AAC3F,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACvG,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjI;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgC,EAAE,KAAyB,EAAE,KAAa,EAAE,MAAM,GAAG,IAAI;IACtH,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CA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';
|
|
4
4
|
import type { MenuItem, Tone } from '../format/layout.mjs';
|
|
5
5
|
import { type ExpressionEnv } from '../expression/expression.mjs';
|
|
6
|
-
import type { ResolvedFilter } from './data-source.mjs';
|
|
6
|
+
import type { PaidPayment, PaymentDue, PayRequest, ResolvedFilter } from './data-source.mjs';
|
|
7
7
|
import type { Facet } from './search.mjs';
|
|
8
8
|
import { type RecordId, type Value, type Values } from './values.mjs';
|
|
9
9
|
/**
|
|
@@ -89,6 +89,46 @@ export interface ActionResult {
|
|
|
89
89
|
* own, each pressed as theirs are. Read only by that menu; any other call's is left alone.
|
|
90
90
|
*/
|
|
91
91
|
menu?: MenuItem[];
|
|
92
|
+
/**
|
|
93
|
+
* How to take back what the app just did, for a one-tap press (a follow-up marked done, a message sent with a few
|
|
94
|
+
* seconds to call it back): its words are said with Undo, and Undo calls this — the app reopens the follow-up,
|
|
95
|
+
* cancels the send — answering as a call is answered (values, words, a reload…). Offered for a few seconds.
|
|
96
|
+
*/
|
|
97
|
+
undo?: AppUndo;
|
|
98
|
+
}
|
|
99
|
+
/** The app's own way to take back what it did for a press (`ActionResult.undo`): answered as a call is. */
|
|
100
|
+
export type AppUndo = () => void | ActionResult | Promise<void | ActionResult>;
|
|
101
|
+
/** The runner's own ways a press's Undo takes it back with (press-undo.ts, the undo part). */
|
|
102
|
+
export interface UndoKit {
|
|
103
|
+
form: RunForm;
|
|
104
|
+
answered(answer: ActionResult, scope: RunScope): Promise<Stopped | null>;
|
|
105
|
+
recordStep(name: 'archive' | 'unarchive' | 'duplicate' | 'delete', scope: RunScope): Promise<Stopped | null>;
|
|
106
|
+
replaced(scope: RunScope): boolean;
|
|
107
|
+
tell(scope: RunScope | null, message: string, tone: Tone): void;
|
|
108
|
+
runSteps(steps: readonly ActionStep[], scope: RunScope, inner?: boolean): Promise<RunResult>;
|
|
109
|
+
}
|
|
110
|
+
/** Undo, offered with the words a press said (`ActionHost.say`'s third): pressed, it takes back what the press did. */
|
|
111
|
+
export interface SayUndo {
|
|
112
|
+
undo(): Promise<RunResult>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What a press that offers Undo keeps as it runs (a button's or a menu item's `undo`, or the app answering with one):
|
|
116
|
+
* the words it says, held to be said as it ends — the last with Undo — and what Fieldia needs to take it back. What it
|
|
117
|
+
* wrote is read by the undo part as it ends (press-undo.ts), against the values it began with.
|
|
118
|
+
*/
|
|
119
|
+
export interface PressTaken {
|
|
120
|
+
said: {
|
|
121
|
+
message: string;
|
|
122
|
+
tone: Tone;
|
|
123
|
+
}[];
|
|
124
|
+
/** The app's own undos, from its answers, in the order given. */
|
|
125
|
+
app: AppUndo[];
|
|
126
|
+
/** The form's values as the press began. */
|
|
127
|
+
at: Values;
|
|
128
|
+
/** It archived the record (true) or brought it back (false). */
|
|
129
|
+
archived?: boolean;
|
|
130
|
+
/** The app's call answered with no undo: Fieldia cannot take that back by itself. */
|
|
131
|
+
beyond?: string;
|
|
92
132
|
}
|
|
93
133
|
/**
|
|
94
134
|
* A file the app hands back from an action: its name and kind, and where it is — its address on the app's server, its
|
|
@@ -163,7 +203,8 @@ export interface OpenResult {
|
|
|
163
203
|
*/
|
|
164
204
|
export interface ActionHost {
|
|
165
205
|
open(request: OpenRequest): Promise<OpenResult>;
|
|
166
|
-
say
|
|
206
|
+
/** Words to say, in a tone; with `undo`, a one-tap press's: Undo beside them for a few seconds, pressed, takes it back. */
|
|
207
|
+
say(message: string, tone: Tone, undo?: SayUndo): void;
|
|
167
208
|
/** A question, answered Yes (true) or No; `how` says what kind, for a host that asks some differently. */
|
|
168
209
|
ask(message: string, how?: AskHow): Promise<boolean>;
|
|
169
210
|
/** Close the dialog or panel this form was opened in. */
|
|
@@ -182,6 +223,12 @@ export interface ActionHost {
|
|
|
182
223
|
* is given one that posts in that record's. False: nothing heard them.
|
|
183
224
|
*/
|
|
184
225
|
post?(message: PostedMessage): boolean | void | Promise<boolean | void>;
|
|
226
|
+
/**
|
|
227
|
+
* The payment step a send waits on (a page's `payment`): show what is due, and settle once it is paid — through the
|
|
228
|
+
* data source's `pay`, in the person's press — or with null once the person goes back to the answers: nothing is sent.
|
|
229
|
+
* Left out, the form asks the source's `pay` itself.
|
|
230
|
+
*/
|
|
231
|
+
pay?(due: PaymentDue, request: PayRequest): Promise<PaidPayment | null>;
|
|
185
232
|
}
|
|
186
233
|
/**
|
|
187
234
|
* How a question is asked. `discard`: its Yes lets go of the person's work not
|
|
@@ -276,6 +323,8 @@ export interface RunScope {
|
|
|
276
323
|
mine: boolean;
|
|
277
324
|
after: Value;
|
|
278
325
|
}>;
|
|
326
|
+
/** A press that offers Undo: what it said and did, to be taken back (`PressTaken`). */
|
|
327
|
+
taken?: PressTaken;
|
|
279
328
|
}
|
|
280
329
|
/** What a run reaches its form by: the form gives these. */
|
|
281
330
|
export interface RunForm {
|
|
@@ -373,10 +422,13 @@ export interface RunForm {
|
|
|
373
422
|
barred?(right: 'edit' | 'archive' | 'duplicate' | 'delete'): string | null;
|
|
374
423
|
}
|
|
375
424
|
export declare const DONE: RunResult;
|
|
425
|
+
/** What a press that offers Undo starts keeping (`RunScope.taken`), from the values it begins with. */
|
|
426
|
+
export declare const takenNow: (at?: Values) => PressTaken;
|
|
376
427
|
/** Steps run against one form. Expressions are read once and kept. */
|
|
377
428
|
export declare function createRunner(form: RunForm): {
|
|
378
429
|
runSteps: (steps: readonly ActionStep[], scope: RunScope, inner?: boolean) => Promise<RunResult>;
|
|
379
430
|
ask: (message: string, yes?: string) => Promise<boolean>;
|
|
431
|
+
kit: UndoKit;
|
|
380
432
|
};
|
|
381
433
|
/**
|
|
382
434
|
* One run of each moment at a time. A moment set off by a step of its own
|
package/src/lib/record/run.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Field } from '../format/field';
|
|
|
3
3
|
import type { JsonValue } from '../format/json';
|
|
4
4
|
import type { MenuItem, Tone } from '../format/layout';
|
|
5
5
|
import { type ExpressionEnv } from '../expression/expression';
|
|
6
|
-
import type { ResolvedFilter } from './data-source';
|
|
6
|
+
import type { PaidPayment, PaymentDue, PayRequest, ResolvedFilter } from './data-source';
|
|
7
7
|
import type { Facet } from './search';
|
|
8
8
|
import { type RecordId, type Value, type Values } from './values';
|
|
9
9
|
/**
|
|
@@ -89,6 +89,46 @@ export interface ActionResult {
|
|
|
89
89
|
* own, each pressed as theirs are. Read only by that menu; any other call's is left alone.
|
|
90
90
|
*/
|
|
91
91
|
menu?: MenuItem[];
|
|
92
|
+
/**
|
|
93
|
+
* How to take back what the app just did, for a one-tap press (a follow-up marked done, a message sent with a few
|
|
94
|
+
* seconds to call it back): its words are said with Undo, and Undo calls this — the app reopens the follow-up,
|
|
95
|
+
* cancels the send — answering as a call is answered (values, words, a reload…). Offered for a few seconds.
|
|
96
|
+
*/
|
|
97
|
+
undo?: AppUndo;
|
|
98
|
+
}
|
|
99
|
+
/** The app's own way to take back what it did for a press (`ActionResult.undo`): answered as a call is. */
|
|
100
|
+
export type AppUndo = () => void | ActionResult | Promise<void | ActionResult>;
|
|
101
|
+
/** The runner's own ways a press's Undo takes it back with (press-undo.ts, the undo part). */
|
|
102
|
+
export interface UndoKit {
|
|
103
|
+
form: RunForm;
|
|
104
|
+
answered(answer: ActionResult, scope: RunScope): Promise<Stopped | null>;
|
|
105
|
+
recordStep(name: 'archive' | 'unarchive' | 'duplicate' | 'delete', scope: RunScope): Promise<Stopped | null>;
|
|
106
|
+
replaced(scope: RunScope): boolean;
|
|
107
|
+
tell(scope: RunScope | null, message: string, tone: Tone): void;
|
|
108
|
+
runSteps(steps: readonly ActionStep[], scope: RunScope, inner?: boolean): Promise<RunResult>;
|
|
109
|
+
}
|
|
110
|
+
/** Undo, offered with the words a press said (`ActionHost.say`'s third): pressed, it takes back what the press did. */
|
|
111
|
+
export interface SayUndo {
|
|
112
|
+
undo(): Promise<RunResult>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What a press that offers Undo keeps as it runs (a button's or a menu item's `undo`, or the app answering with one):
|
|
116
|
+
* the words it says, held to be said as it ends — the last with Undo — and what Fieldia needs to take it back. What it
|
|
117
|
+
* wrote is read by the undo part as it ends (press-undo.ts), against the values it began with.
|
|
118
|
+
*/
|
|
119
|
+
export interface PressTaken {
|
|
120
|
+
said: {
|
|
121
|
+
message: string;
|
|
122
|
+
tone: Tone;
|
|
123
|
+
}[];
|
|
124
|
+
/** The app's own undos, from its answers, in the order given. */
|
|
125
|
+
app: AppUndo[];
|
|
126
|
+
/** The form's values as the press began. */
|
|
127
|
+
at: Values;
|
|
128
|
+
/** It archived the record (true) or brought it back (false). */
|
|
129
|
+
archived?: boolean;
|
|
130
|
+
/** The app's call answered with no undo: Fieldia cannot take that back by itself. */
|
|
131
|
+
beyond?: string;
|
|
92
132
|
}
|
|
93
133
|
/**
|
|
94
134
|
* A file the app hands back from an action: its name and kind, and where it is — its address on the app's server, its
|
|
@@ -163,7 +203,8 @@ export interface OpenResult {
|
|
|
163
203
|
*/
|
|
164
204
|
export interface ActionHost {
|
|
165
205
|
open(request: OpenRequest): Promise<OpenResult>;
|
|
166
|
-
say
|
|
206
|
+
/** Words to say, in a tone; with `undo`, a one-tap press's: Undo beside them for a few seconds, pressed, takes it back. */
|
|
207
|
+
say(message: string, tone: Tone, undo?: SayUndo): void;
|
|
167
208
|
/** A question, answered Yes (true) or No; `how` says what kind, for a host that asks some differently. */
|
|
168
209
|
ask(message: string, how?: AskHow): Promise<boolean>;
|
|
169
210
|
/** Close the dialog or panel this form was opened in. */
|
|
@@ -182,6 +223,12 @@ export interface ActionHost {
|
|
|
182
223
|
* is given one that posts in that record's. False: nothing heard them.
|
|
183
224
|
*/
|
|
184
225
|
post?(message: PostedMessage): boolean | void | Promise<boolean | void>;
|
|
226
|
+
/**
|
|
227
|
+
* The payment step a send waits on (a page's `payment`): show what is due, and settle once it is paid — through the
|
|
228
|
+
* data source's `pay`, in the person's press — or with null once the person goes back to the answers: nothing is sent.
|
|
229
|
+
* Left out, the form asks the source's `pay` itself.
|
|
230
|
+
*/
|
|
231
|
+
pay?(due: PaymentDue, request: PayRequest): Promise<PaidPayment | null>;
|
|
185
232
|
}
|
|
186
233
|
/**
|
|
187
234
|
* How a question is asked. `discard`: its Yes lets go of the person's work not
|
|
@@ -276,6 +323,8 @@ export interface RunScope {
|
|
|
276
323
|
mine: boolean;
|
|
277
324
|
after: Value;
|
|
278
325
|
}>;
|
|
326
|
+
/** A press that offers Undo: what it said and did, to be taken back (`PressTaken`). */
|
|
327
|
+
taken?: PressTaken;
|
|
279
328
|
}
|
|
280
329
|
/** What a run reaches its form by: the form gives these. */
|
|
281
330
|
export interface RunForm {
|
|
@@ -373,10 +422,13 @@ export interface RunForm {
|
|
|
373
422
|
barred?(right: 'edit' | 'archive' | 'duplicate' | 'delete'): string | null;
|
|
374
423
|
}
|
|
375
424
|
export declare const DONE: RunResult;
|
|
425
|
+
/** What a press that offers Undo starts keeping (`RunScope.taken`), from the values it begins with. */
|
|
426
|
+
export declare const takenNow: (at?: Values) => PressTaken;
|
|
376
427
|
/** Steps run against one form. Expressions are read once and kept. */
|
|
377
428
|
export declare function createRunner(form: RunForm): {
|
|
378
429
|
runSteps: (steps: readonly ActionStep[], scope: RunScope, inner?: boolean) => Promise<RunResult>;
|
|
379
430
|
ask: (message: string, yes?: string) => Promise<boolean>;
|
|
431
|
+
kit: UndoKit;
|
|
380
432
|
};
|
|
381
433
|
/**
|
|
382
434
|
* One run of each moment at a time. A moment set off by a step of its own
|
package/src/lib/record/run.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DONE = void 0;
|
|
3
|
+
exports.takenNow = exports.DONE = void 0;
|
|
4
4
|
exports.createRunner = createRunner;
|
|
5
5
|
exports.createMoments = createMoments;
|
|
6
6
|
const expression_1 = require("../expression/expression");
|
|
@@ -11,6 +11,9 @@ const compute_1 = require("./compute");
|
|
|
11
11
|
const filter_1 = require("./filter");
|
|
12
12
|
const values_1 = require("./values");
|
|
13
13
|
exports.DONE = Object.freeze({ done: true });
|
|
14
|
+
/** What a press that offers Undo starts keeping (`RunScope.taken`), from the values it begins with. */
|
|
15
|
+
const takenNow = (at = {}) => ({ said: [], app: [], at: (0, values_1.structuredCopy)(at) });
|
|
16
|
+
exports.takenNow = takenNow;
|
|
14
17
|
/** The kinds of field an expression gives a value to; the rest hold records, lines or files, and take a field named alone whole. */
|
|
15
18
|
const EXPRESSIBLE = new Set(['char', 'text', 'html', 'integer', 'float', 'monetary', 'boolean', 'date', 'datetime', 'selection', 'json']);
|
|
16
19
|
const wordsOf = (error) => (error instanceof Error ? error.message : String(error));
|
|
@@ -100,6 +103,13 @@ function createRunner(form) {
|
|
|
100
103
|
journal.set(name, { before: first.before, mine: first.mine, after: (0, values_1.structuredCopy)(form.values()[name] ?? null) });
|
|
101
104
|
}
|
|
102
105
|
}
|
|
106
|
+
/** Words a run says: held, for a press that offers Undo, to be said as it ends; else said now. */
|
|
107
|
+
function tell(scope, message, tone) {
|
|
108
|
+
if (scope?.taken)
|
|
109
|
+
scope.taken.said.push({ message, tone });
|
|
110
|
+
else
|
|
111
|
+
form.host?.say(message, tone);
|
|
112
|
+
}
|
|
103
113
|
/**
|
|
104
114
|
* The run's save was refused: what its steps wrote since its last save is put back, each field only while it
|
|
105
115
|
* still holds what they wrote — a change made since by anyone else stays.
|
|
@@ -227,14 +237,24 @@ function createRunner(form) {
|
|
|
227
237
|
return { reason: 'app', message: wordsOf(error), error };
|
|
228
238
|
}
|
|
229
239
|
form.answered(request, answer);
|
|
240
|
+
// A press offering Undo whose call the app answered with no way back: Fieldia cannot take it back by itself.
|
|
241
|
+
if (scope.taken && !answer?.undo)
|
|
242
|
+
scope.taken.beyond = 'call';
|
|
230
243
|
if (!answer)
|
|
231
244
|
return null;
|
|
245
|
+
// The app's own undo for what it did: its words are held to be said with Undo.
|
|
246
|
+
if (answer.undo)
|
|
247
|
+
(scope.taken ??= (0, exports.takenNow)()).app.push(answer.undo);
|
|
248
|
+
return answered(answer, scope);
|
|
249
|
+
}
|
|
250
|
+
/** The app's answer to a call, or to its own undo, laid over the form: values, words, a reload, another record… */
|
|
251
|
+
async function answered(answer, scope) {
|
|
232
252
|
// Answered for a record no longer shown: nothing of it is laid over the one shown now. Its words to the person are
|
|
233
253
|
// laid over no record, and are said still — a dialog's "Payment … posted", answered as it closed, as before.
|
|
234
254
|
if (replaced(scope)) {
|
|
235
255
|
if (answer.say !== undefined) {
|
|
236
256
|
const said = typeof answer.say === 'string' ? { message: answer.say } : answer.say;
|
|
237
|
-
|
|
257
|
+
tell(scope, said.message, said.tone ?? 'info');
|
|
238
258
|
}
|
|
239
259
|
return form.gone();
|
|
240
260
|
}
|
|
@@ -260,7 +280,7 @@ function createRunner(form) {
|
|
|
260
280
|
}
|
|
261
281
|
if (answer.say !== undefined) {
|
|
262
282
|
const said = typeof answer.say === 'string' ? { message: answer.say } : answer.say;
|
|
263
|
-
|
|
283
|
+
tell(scope, said.message, said.tone ?? 'info');
|
|
264
284
|
}
|
|
265
285
|
if (answer.post !== undefined) {
|
|
266
286
|
const posted = typeof answer.post === 'string' ? { message: answer.post } : answer.post;
|
|
@@ -289,7 +309,7 @@ function createRunner(form) {
|
|
|
289
309
|
}
|
|
290
310
|
if (answer.stop) {
|
|
291
311
|
if (typeof answer.stop === 'string')
|
|
292
|
-
|
|
312
|
+
tell(scope, answer.stop, 'warning');
|
|
293
313
|
return { reason: 'app', ...(typeof answer.stop === 'string' ? { message: answer.stop } : {}) };
|
|
294
314
|
}
|
|
295
315
|
return null;
|
|
@@ -328,6 +348,8 @@ function createRunner(form) {
|
|
|
328
348
|
if (kept)
|
|
329
349
|
return kept;
|
|
330
350
|
await form.archive(name === 'archive');
|
|
351
|
+
if (scope.taken)
|
|
352
|
+
scope.taken.archived = scope.taken.archived === undefined ? name === 'archive' : undefined;
|
|
331
353
|
form.told({ archived: name === 'archive' }, id);
|
|
332
354
|
// Archived once another record is shown: that one is not loaded again over what is typed in it.
|
|
333
355
|
if (replaced(scope))
|
|
@@ -445,7 +467,7 @@ function createRunner(form) {
|
|
|
445
467
|
return null;
|
|
446
468
|
}
|
|
447
469
|
case 'say':
|
|
448
|
-
|
|
470
|
+
tell(scope, step.message, step.tone ?? 'info');
|
|
449
471
|
return null;
|
|
450
472
|
case 'ask':
|
|
451
473
|
// Yes goes on with what was pressed: its words.
|
|
@@ -554,7 +576,9 @@ function createRunner(form) {
|
|
|
554
576
|
}
|
|
555
577
|
return exports.DONE;
|
|
556
578
|
}
|
|
557
|
-
|
|
579
|
+
/** What a press's Undo takes back with, in the undo part (press-undo.ts): the runner's own ways, on this form. */
|
|
580
|
+
const kit = { form, answered, recordStep, replaced, tell, runSteps };
|
|
581
|
+
return { runSteps, ask, kit };
|
|
558
582
|
}
|
|
559
583
|
/**
|
|
560
584
|
* Whether a step reads the form's values or hands them on — what is typed is read before it, for a run the person or
|