@fieldia/core 0.26.1 → 0.27.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 +307 -3
- package/package.json +1 -1
- package/schema/page.schema.json +227 -23
- package/src/index.d.mts +8 -2
- package/src/index.d.ts +8 -2
- package/src/index.js +22 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +9 -2
- package/src/index.mjs.map +1 -1
- package/src/lib/expression/app-functions.d.mts +47 -0
- package/src/lib/expression/app-functions.d.ts +47 -0
- package/src/lib/expression/app-functions.js +64 -0
- package/src/lib/expression/app-functions.js.map +1 -0
- package/src/lib/expression/app-functions.mjs +58 -0
- package/src/lib/expression/app-functions.mjs.map +1 -0
- package/src/lib/expression/dates.d.mts +21 -0
- package/src/lib/expression/dates.d.ts +21 -0
- package/src/lib/expression/dates.js +73 -0
- package/src/lib/expression/dates.js.map +1 -0
- package/src/lib/expression/dates.mjs +67 -0
- package/src/lib/expression/dates.mjs.map +1 -0
- package/src/lib/expression/evaluator.js +12 -6
- package/src/lib/expression/evaluator.js.map +1 -1
- package/src/lib/expression/evaluator.mjs +12 -6
- package/src/lib/expression/evaluator.mjs.map +1 -1
- package/src/lib/expression/expression.d.mts +7 -3
- package/src/lib/expression/expression.d.ts +7 -3
- package/src/lib/expression/expression.js +8 -2
- package/src/lib/expression/expression.js.map +1 -1
- package/src/lib/expression/expression.mjs +7 -2
- package/src/lib/expression/expression.mjs.map +1 -1
- package/src/lib/expression/functions-part.d.mts +7 -0
- package/src/lib/expression/functions-part.d.ts +7 -0
- package/src/lib/expression/functions-part.js +13 -0
- package/src/lib/expression/functions-part.js.map +1 -0
- package/src/lib/expression/functions-part.mjs +8 -0
- package/src/lib/expression/functions-part.mjs.map +1 -0
- package/src/lib/expression/functions.d.mts +60 -3
- package/src/lib/expression/functions.d.ts +60 -3
- package/src/lib/expression/functions.js +109 -15
- package/src/lib/expression/functions.js.map +1 -1
- package/src/lib/expression/functions.mjs +103 -16
- package/src/lib/expression/functions.mjs.map +1 -1
- package/src/lib/expression/kinds.d.mts +31 -0
- package/src/lib/expression/kinds.d.ts +31 -0
- package/src/lib/expression/kinds.js +159 -0
- package/src/lib/expression/kinds.js.map +1 -0
- package/src/lib/expression/kinds.mjs +151 -0
- package/src/lib/expression/kinds.mjs.map +1 -0
- package/src/lib/expression/modifier.d.mts +4 -3
- package/src/lib/expression/modifier.d.ts +4 -3
- package/src/lib/expression/modifier.js +4 -3
- package/src/lib/expression/modifier.js.map +1 -1
- package/src/lib/expression/modifier.mjs +4 -3
- package/src/lib/expression/modifier.mjs.map +1 -1
- package/src/lib/expression/more-functions.d.mts +8 -0
- package/src/lib/expression/more-functions.d.ts +8 -0
- package/src/lib/expression/more-functions.js +235 -0
- package/src/lib/expression/more-functions.js.map +1 -0
- package/src/lib/expression/more-functions.mjs +230 -0
- package/src/lib/expression/more-functions.mjs.map +1 -0
- package/src/lib/expression/parser.d.mts +4 -1
- package/src/lib/expression/parser.d.ts +4 -1
- package/src/lib/expression/parser.js +6 -3
- package/src/lib/expression/parser.js.map +1 -1
- package/src/lib/expression/parser.mjs +6 -3
- package/src/lib/expression/parser.mjs.map +1 -1
- package/src/lib/expression/reads.d.mts +2 -2
- package/src/lib/expression/reads.d.ts +2 -2
- package/src/lib/expression/reads.js +6 -4
- package/src/lib/expression/reads.js.map +1 -1
- package/src/lib/expression/reads.mjs +6 -4
- package/src/lib/expression/reads.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/check-page.d.mts +7 -2
- package/src/lib/format/check-page.d.ts +7 -2
- package/src/lib/format/check-page.js +10 -4
- package/src/lib/format/check-page.js.map +1 -1
- package/src/lib/format/check-page.mjs +10 -4
- package/src/lib/format/check-page.mjs.map +1 -1
- package/src/lib/format/choice-options.d.mts +34 -0
- package/src/lib/format/choice-options.d.ts +34 -0
- package/src/lib/format/choice-options.js +60 -0
- package/src/lib/format/choice-options.js.map +1 -0
- package/src/lib/format/choice-options.mjs +51 -0
- package/src/lib/format/choice-options.mjs.map +1 -0
- package/src/lib/format/endings-checks.d.mts +8 -0
- package/src/lib/format/endings-checks.d.ts +8 -0
- package/src/lib/format/endings-checks.js +23 -0
- package/src/lib/format/endings-checks.js.map +1 -0
- package/src/lib/format/endings-checks.mjs +20 -0
- package/src/lib/format/endings-checks.mjs.map +1 -0
- package/src/lib/format/endings.d.mts +40 -0
- package/src/lib/format/endings.d.ts +40 -0
- package/src/lib/format/endings.js +15 -0
- package/src/lib/format/endings.js.map +1 -0
- package/src/lib/format/endings.mjs +12 -0
- package/src/lib/format/endings.mjs.map +1 -0
- package/src/lib/format/field.d.mts +151 -16
- package/src/lib/format/field.d.ts +151 -16
- package/src/lib/format/field.js +64 -11
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +63 -10
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/head-checks.d.mts +2 -0
- package/src/lib/format/head-checks.d.ts +2 -0
- package/src/lib/format/head-checks.js +2 -59
- package/src/lib/format/head-checks.js.map +1 -1
- package/src/lib/format/head-checks.mjs +1 -58
- package/src/lib/format/head-checks.mjs.map +1 -1
- package/src/lib/format/later-checks.d.mts +17 -0
- package/src/lib/format/later-checks.d.ts +17 -0
- package/src/lib/format/later-checks.js +20 -0
- package/src/lib/format/later-checks.js.map +1 -0
- package/src/lib/format/later-checks.mjs +17 -0
- package/src/lib/format/later-checks.mjs.map +1 -0
- package/src/lib/format/layout.d.mts +241 -188
- package/src/lib/format/layout.d.ts +241 -188
- package/src/lib/format/layout.js +33 -28
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +13 -3
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +2 -1
- package/src/lib/format/layout.types.d.ts +2 -1
- package/src/lib/format/limits-checks.d.mts +14 -0
- package/src/lib/format/limits-checks.d.ts +14 -0
- package/src/lib/format/limits-checks.js +36 -0
- package/src/lib/format/limits-checks.js.map +1 -0
- package/src/lib/format/limits-checks.mjs +33 -0
- package/src/lib/format/limits-checks.mjs.map +1 -0
- package/src/lib/format/limits.d.mts +24 -0
- package/src/lib/format/limits.d.ts +24 -0
- package/src/lib/format/limits.js +35 -0
- package/src/lib/format/limits.js.map +1 -0
- package/src/lib/format/limits.mjs +32 -0
- package/src/lib/format/limits.mjs.map +1 -0
- package/src/lib/format/list-checks.d.mts +44 -0
- package/src/lib/format/list-checks.d.ts +44 -0
- package/src/lib/format/list-checks.js +340 -0
- package/src/lib/format/list-checks.js.map +1 -0
- package/src/lib/format/list-checks.mjs +336 -0
- package/src/lib/format/list-checks.mjs.map +1 -0
- package/src/lib/format/map-checks.d.mts +33 -0
- package/src/lib/format/map-checks.d.ts +33 -0
- package/src/lib/format/map-checks.js +180 -0
- package/src/lib/format/map-checks.js.map +1 -0
- package/src/lib/format/map-checks.mjs +175 -0
- package/src/lib/format/map-checks.mjs.map +1 -0
- package/src/lib/format/mapchecks-part.d.mts +5 -0
- package/src/lib/format/mapchecks-part.d.ts +5 -0
- package/src/lib/format/mapchecks-part.js +11 -0
- package/src/lib/format/mapchecks-part.js.map +1 -0
- package/src/lib/format/mapchecks-part.mjs +6 -0
- package/src/lib/format/mapchecks-part.mjs.map +1 -0
- package/src/lib/format/option-checks.d.mts +16 -0
- package/src/lib/format/option-checks.d.ts +16 -0
- package/src/lib/format/option-checks.js +39 -0
- package/src/lib/format/option-checks.js.map +1 -0
- package/src/lib/format/option-checks.mjs +36 -0
- package/src/lib/format/option-checks.mjs.map +1 -0
- package/src/lib/format/options-part.d.mts +6 -0
- package/src/lib/format/options-part.d.ts +6 -0
- package/src/lib/format/options-part.js +11 -0
- package/src/lib/format/options-part.js.map +1 -0
- package/src/lib/format/options-part.mjs +7 -0
- package/src/lib/format/options-part.mjs.map +1 -0
- package/src/lib/format/page.d.mts +147 -71
- package/src/lib/format/page.d.ts +147 -71
- package/src/lib/format/page.js +5 -0
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +5 -0
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/part-checks.d.mts +20 -0
- package/src/lib/format/part-checks.d.ts +20 -0
- package/src/lib/format/part-checks.js +3 -0
- package/src/lib/format/part-checks.js.map +1 -0
- package/src/lib/format/part-checks.mjs +2 -0
- package/src/lib/format/part-checks.mjs.map +1 -0
- package/src/lib/format/references.d.mts +71 -65
- package/src/lib/format/references.d.ts +71 -65
- package/src/lib/format/references.js +194 -631
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +194 -631
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/seats-checks.d.mts +3 -0
- package/src/lib/format/seats-checks.d.ts +3 -0
- package/src/lib/format/seats-checks.js +13 -0
- package/src/lib/format/seats-checks.js.map +1 -0
- package/src/lib/format/seats-checks.mjs +10 -0
- package/src/lib/format/seats-checks.mjs.map +1 -0
- package/src/lib/format/sheet-head-checks.d.mts +4 -0
- package/src/lib/format/sheet-head-checks.d.ts +4 -0
- package/src/lib/format/sheet-head-checks.js +68 -0
- package/src/lib/format/sheet-head-checks.js.map +1 -0
- package/src/lib/format/sheet-head-checks.mjs +65 -0
- package/src/lib/format/sheet-head-checks.mjs.map +1 -0
- package/src/lib/format/signature-checks.d.mts +7 -0
- package/src/lib/format/signature-checks.d.ts +7 -0
- package/src/lib/format/signature-checks.js +32 -0
- package/src/lib/format/signature-checks.js.map +1 -0
- package/src/lib/format/signature-checks.mjs +29 -0
- package/src/lib/format/signature-checks.mjs.map +1 -0
- package/src/lib/format/signature-options.d.mts +24 -0
- package/src/lib/format/signature-options.d.ts +24 -0
- package/src/lib/format/signature-options.js +30 -0
- package/src/lib/format/signature-options.js.map +1 -0
- package/src/lib/format/signature-options.mjs +26 -0
- package/src/lib/format/signature-options.mjs.map +1 -0
- package/src/lib/format/slots-checks.d.mts +4 -0
- package/src/lib/format/slots-checks.d.ts +4 -0
- package/src/lib/format/slots-checks.js +21 -0
- package/src/lib/format/slots-checks.js.map +1 -0
- package/src/lib/format/slots-checks.mjs +18 -0
- package/src/lib/format/slots-checks.mjs.map +1 -0
- package/src/lib/format/statusbar-checks.d.mts +8 -0
- package/src/lib/format/statusbar-checks.d.ts +8 -0
- package/src/lib/format/statusbar-checks.js +35 -0
- package/src/lib/format/statusbar-checks.js.map +1 -0
- package/src/lib/format/statusbar-checks.mjs +32 -0
- package/src/lib/format/statusbar-checks.mjs.map +1 -0
- package/src/lib/format/table-checks.d.mts +21 -0
- package/src/lib/format/table-checks.d.ts +21 -0
- package/src/lib/format/table-checks.js +86 -0
- package/src/lib/format/table-checks.js.map +1 -0
- package/src/lib/format/table-checks.mjs +82 -0
- package/src/lib/format/table-checks.mjs.map +1 -0
- package/src/lib/format/translate.js +2 -2
- package/src/lib/format/translate.js.map +1 -1
- package/src/lib/format/translate.mjs +2 -2
- package/src/lib/format/translate.mjs.map +1 -1
- package/src/lib/format/upgrade.d.mts +6 -3
- package/src/lib/format/upgrade.d.ts +6 -3
- package/src/lib/format/upgrade.js +6 -3
- package/src/lib/format/upgrade.js.map +1 -1
- package/src/lib/format/upgrade.mjs +6 -3
- package/src/lib/format/upgrade.mjs.map +1 -1
- package/src/lib/format/validate.d.mts +18 -2
- package/src/lib/format/validate.d.ts +18 -2
- package/src/lib/format/validate.js +36 -3
- package/src/lib/format/validate.js.map +1 -1
- package/src/lib/format/validate.mjs +35 -3
- package/src/lib/format/validate.mjs.map +1 -1
- 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/words.d.mts +6 -2
- package/src/lib/format/words.d.ts +6 -2
- package/src/lib/format/words.js +13 -7
- package/src/lib/format/words.js.map +1 -1
- package/src/lib/format/words.mjs +13 -7
- package/src/lib/format/words.mjs.map +1 -1
- package/src/lib/parts.d.mts +45 -0
- package/src/lib/parts.d.ts +45 -0
- package/src/lib/parts.js +60 -0
- package/src/lib/parts.js.map +1 -0
- package/src/lib/parts.mjs +53 -0
- package/src/lib/parts.mjs.map +1 -0
- package/src/lib/record/cells.d.mts +3 -3
- package/src/lib/record/cells.d.ts +3 -3
- package/src/lib/record/cells.js +16 -15
- package/src/lib/record/cells.js.map +1 -1
- package/src/lib/record/cells.mjs +16 -15
- package/src/lib/record/cells.mjs.map +1 -1
- package/src/lib/record/compute.d.mts +16 -5
- package/src/lib/record/compute.d.ts +16 -5
- package/src/lib/record/compute.js +57 -16
- package/src/lib/record/compute.js.map +1 -1
- package/src/lib/record/compute.mjs +57 -16
- package/src/lib/record/compute.mjs.map +1 -1
- package/src/lib/record/data-source.d.mts +140 -3
- package/src/lib/record/data-source.d.ts +140 -3
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/drafts.d.mts +19 -0
- package/src/lib/record/drafts.d.ts +19 -0
- package/src/lib/record/drafts.js +35 -0
- package/src/lib/record/drafts.js.map +1 -0
- package/src/lib/record/drafts.mjs +31 -0
- package/src/lib/record/drafts.mjs.map +1 -0
- package/src/lib/record/env.d.mts +5 -1
- package/src/lib/record/env.d.ts +5 -1
- package/src/lib/record/env.js +9 -1
- package/src/lib/record/env.js.map +1 -1
- package/src/lib/record/env.mjs +8 -1
- package/src/lib/record/env.mjs.map +1 -1
- package/src/lib/record/form-limits.d.mts +81 -0
- package/src/lib/record/form-limits.d.ts +81 -0
- package/src/lib/record/form-limits.js +231 -0
- package/src/lib/record/form-limits.js.map +1 -0
- package/src/lib/record/form-limits.mjs +224 -0
- package/src/lib/record/form-limits.mjs.map +1 -0
- package/src/lib/record/form.d.mts +173 -4
- package/src/lib/record/form.d.ts +173 -4
- package/src/lib/record/form.js +792 -88
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +792 -88
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/limits-part.d.mts +6 -0
- package/src/lib/record/limits-part.d.ts +6 -0
- package/src/lib/record/limits-part.js +12 -0
- package/src/lib/record/limits-part.js.map +1 -0
- package/src/lib/record/limits-part.mjs +7 -0
- package/src/lib/record/limits-part.mjs.map +1 -0
- package/src/lib/record/line-choices.d.mts +30 -0
- package/src/lib/record/line-choices.d.ts +30 -0
- package/src/lib/record/line-choices.js +42 -0
- package/src/lib/record/line-choices.js.map +1 -0
- package/src/lib/record/line-choices.mjs +36 -0
- package/src/lib/record/line-choices.mjs.map +1 -0
- package/src/lib/record/locales/ar.js +10 -0
- package/src/lib/record/locales/ar.js.map +1 -1
- package/src/lib/record/locales/ar.mjs +10 -0
- package/src/lib/record/locales/ar.mjs.map +1 -1
- package/src/lib/record/locales/de.js +10 -0
- package/src/lib/record/locales/de.js.map +1 -1
- package/src/lib/record/locales/de.mjs +10 -0
- package/src/lib/record/locales/de.mjs.map +1 -1
- package/src/lib/record/locales/fr.js +10 -0
- package/src/lib/record/locales/fr.js.map +1 -1
- package/src/lib/record/locales/fr.mjs +10 -0
- package/src/lib/record/locales/fr.mjs.map +1 -1
- package/src/lib/record/memory-data-source.d.mts +44 -3
- package/src/lib/record/memory-data-source.d.ts +44 -3
- package/src/lib/record/memory-data-source.js +102 -40
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +101 -40
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/memory-kept.d.mts +20 -0
- package/src/lib/record/memory-kept.d.ts +20 -0
- package/src/lib/record/memory-kept.js +46 -0
- package/src/lib/record/memory-kept.js.map +1 -0
- package/src/lib/record/memory-kept.mjs +43 -0
- package/src/lib/record/memory-kept.mjs.map +1 -0
- package/src/lib/record/memory-later.d.mts +19 -0
- package/src/lib/record/memory-later.d.ts +19 -0
- package/src/lib/record/memory-later.js +39 -0
- package/src/lib/record/memory-later.js.map +1 -0
- package/src/lib/record/memory-later.mjs +35 -0
- package/src/lib/record/memory-later.mjs.map +1 -0
- package/src/lib/record/memory-part.d.mts +7 -0
- package/src/lib/record/memory-part.d.ts +7 -0
- package/src/lib/record/memory-part.js +13 -0
- package/src/lib/record/memory-part.js.map +1 -0
- package/src/lib/record/memory-part.mjs +8 -0
- package/src/lib/record/memory-part.mjs.map +1 -0
- package/src/lib/record/messages.d.mts +17 -0
- package/src/lib/record/messages.d.ts +17 -0
- package/src/lib/record/messages.js +10 -0
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +10 -0
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/option-rules.d.mts +50 -0
- package/src/lib/record/option-rules.d.ts +50 -0
- package/src/lib/record/option-rules.js +137 -0
- package/src/lib/record/option-rules.js.map +1 -0
- package/src/lib/record/option-rules.mjs +134 -0
- package/src/lib/record/option-rules.mjs.map +1 -0
- package/src/lib/record/rules.d.mts +2 -2
- package/src/lib/record/rules.d.ts +2 -2
- package/src/lib/record/rules.js +3 -3
- package/src/lib/record/rules.js.map +1 -1
- package/src/lib/record/rules.mjs +3 -3
- package/src/lib/record/rules.mjs.map +1 -1
- package/src/lib/record/run.js +9 -7
- package/src/lib/record/run.js.map +1 -1
- package/src/lib/record/run.mjs +9 -7
- package/src/lib/record/run.mjs.map +1 -1
- package/src/lib/record/search.d.mts +12 -2
- package/src/lib/record/search.d.ts +12 -2
- package/src/lib/record/search.js +29 -4
- package/src/lib/record/search.js.map +1 -1
- package/src/lib/record/search.mjs +29 -4
- package/src/lib/record/search.mjs.map +1 -1
- package/src/lib/record/set-when.d.mts +3 -3
- package/src/lib/record/set-when.d.ts +3 -3
- package/src/lib/record/set-when.js +9 -9
- package/src/lib/record/set-when.js.map +1 -1
- package/src/lib/record/set-when.mjs +9 -9
- package/src/lib/record/set-when.mjs.map +1 -1
- package/src/lib/record/signed.d.mts +21 -0
- package/src/lib/record/signed.d.ts +21 -0
- package/src/lib/record/signed.js +62 -0
- package/src/lib/record/signed.js.map +1 -0
- package/src/lib/record/signed.mjs +57 -0
- package/src/lib/record/signed.mjs.map +1 -0
- package/src/lib/record/taking.d.mts +60 -0
- package/src/lib/record/taking.d.ts +60 -0
- package/src/lib/record/taking.js +58 -0
- package/src/lib/record/taking.js.map +1 -0
- package/src/lib/record/taking.mjs +50 -0
- package/src/lib/record/taking.mjs.map +1 -0
- package/src/lib/record/value-map.js +11 -4
- package/src/lib/record/value-map.js.map +1 -1
- package/src/lib/record/value-map.mjs +11 -4
- package/src/lib/record/value-map.mjs.map +1 -1
- package/src/lib/record/values.d.mts +20 -0
- package/src/lib/record/values.d.ts +20 -0
- package/src/lib/record/values.js.map +1 -1
- package/src/lib/record/values.mjs.map +1 -1
- package/src/lib/record/waits.d.mts +6 -1
- package/src/lib/record/waits.d.ts +6 -1
- package/src/lib/record/waits.js +2 -2
- package/src/lib/record/waits.js.map +1 -1
- package/src/lib/record/waits.mjs +2 -2
- package/src/lib/record/waits.mjs.map +1 -1
- package/src/runtime.d.mts +16 -5
- package/src/runtime.d.ts +16 -5
- package/src/runtime.js +41 -3
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +13 -0
- package/src/runtime.mjs.map +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ASTNode } from './parser.mjs';
|
|
2
|
+
import { type Part } from '../parts.mjs';
|
|
3
|
+
import type * as FunctionsModule from './functions-part.mjs';
|
|
2
4
|
/**
|
|
3
5
|
* The functions an expression may call. Each says how many values it takes,
|
|
4
6
|
* so a call with too many or too few is refused when the page is read; and
|
|
@@ -13,25 +15,80 @@ export interface ExpressionEnv {
|
|
|
13
15
|
lines?(field: string): readonly Readonly<Record<string, unknown>>[] | undefined;
|
|
14
16
|
/** Today, as YYYY-MM-DD. The computer's own clock when left out. */
|
|
15
17
|
today?(): string;
|
|
18
|
+
/** The app's own functions, by name, besides Fieldia's (`functions` on the form, the viewer and its wrappers). */
|
|
19
|
+
functions?: FunctionTable;
|
|
20
|
+
/**
|
|
21
|
+
* The answer an app's function that asks (its call a promise) gave for these values, by its key — the function
|
|
22
|
+
* and its values: `{ value }`, or `'asking'` while it is on its way. Handed the promise the first time, the form
|
|
23
|
+
* keeps the answer for the record shown, and works its values out again as it comes. Left out, such a function
|
|
24
|
+
* gives null and is not asked.
|
|
25
|
+
*/
|
|
26
|
+
answer?(key: string, asked?: PromiseLike<unknown>): Answered | 'asking' | undefined;
|
|
27
|
+
/** The name of the record a link field holds (`currency_id`: "EGP"), for what reads a record by its name. */
|
|
28
|
+
nameOf?(field: string): string | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** What an app's function that asks answered: its value, or — empty — why it did not come (`failed`). */
|
|
31
|
+
export interface Answered {
|
|
32
|
+
value: unknown;
|
|
33
|
+
failed?: string;
|
|
16
34
|
}
|
|
17
35
|
/** One call, as a function sees it: its values unread, a way to read each, and the env. */
|
|
18
|
-
interface Call {
|
|
36
|
+
export interface Call {
|
|
19
37
|
args: readonly ASTNode[];
|
|
20
38
|
value(node: ASTNode): unknown;
|
|
21
39
|
env: ExpressionEnv;
|
|
22
40
|
/** Whether a condition, written in quotes, holds for one line's values. */
|
|
23
41
|
holds(condition: string, row: Readonly<Record<string, unknown>>): boolean;
|
|
24
42
|
}
|
|
25
|
-
|
|
43
|
+
/** A function an expression may call: Fieldia's own, or the app's (`FunctionTable`). */
|
|
44
|
+
export interface ExpressionFunction {
|
|
26
45
|
/** How many values it takes: at least, at most. */
|
|
27
46
|
readonly takes: readonly [number, number];
|
|
28
47
|
/** What is wrong with the values it was given, found as the expression is read. */
|
|
29
48
|
check?(args: readonly ASTNode[]): string | undefined;
|
|
30
49
|
call(call: Call): unknown;
|
|
31
50
|
}
|
|
51
|
+
/** The functions an expression may call besides Fieldia's own, by name: the app's (`functionTable`). */
|
|
52
|
+
export type FunctionTable = ReadonlyMap<string, ExpressionFunction>;
|
|
53
|
+
/**
|
|
54
|
+
* Thrown while an app's function that asks is waiting for its answer: the expression has no value yet. A value
|
|
55
|
+
* worked out from it waits (null meanwhile), a condition reading it does not hold yet.
|
|
56
|
+
*/
|
|
57
|
+
export declare class Asking extends Error {
|
|
58
|
+
constructor();
|
|
59
|
+
}
|
|
32
60
|
/** A day as YYYY-MM-DD, in the computer's own time zone. */
|
|
33
61
|
export declare function localDay(date: Date): string;
|
|
62
|
+
/** The list a function counts or adds up: the rows of a one2many named by its field, or any list. */
|
|
63
|
+
export declare function listOf(call: Call): unknown;
|
|
64
|
+
/** A condition given in quotes as the value at `at`: refused when it is anything else. */
|
|
65
|
+
export declare function conditionAt(args: readonly ASTNode[], at: number, name: string, example: string): string | undefined;
|
|
66
|
+
/** The numbers of a list a function adds up: its items, or a field of its rows (`sum(lines, 'x')`), where a condition holds. */
|
|
67
|
+
export declare function numbersOf(call: Call, list: unknown[]): number[];
|
|
68
|
+
/** The values given, lists opened, empty ones left out. */
|
|
69
|
+
export declare function opened(call: Call, args?: readonly ASTNode[]): unknown[];
|
|
70
|
+
/** The functions part: the bodies of Fieldia's functions beyond the plain ones (more-functions.ts). */
|
|
71
|
+
export type FunctionsPart = typeof FunctionsModule;
|
|
72
|
+
/**
|
|
73
|
+
* The bodies of Fieldia's functions beyond the plain ones — a person's age, days and months added, text tested and
|
|
74
|
+
* joined, an average, money rounded to its currency, the first that is not empty — and the calls of the app's own
|
|
75
|
+
* (`functions`, app-functions.ts): loaded before a page that calls one of Fieldia's is drawn (`callsPartFunctions`), or
|
|
76
|
+
* a viewer given the app's: a page that calls none never downloads them. Their names, and what each takes, are known
|
|
77
|
+
* without it, so a page is read and checked as ever.
|
|
78
|
+
*/
|
|
79
|
+
export declare const functionsPart: Part<FunctionsPart>;
|
|
80
|
+
/**
|
|
81
|
+
* A call of a function the functions part works out — one of Fieldia's beyond the plain ones, or the app's own — made
|
|
82
|
+
* before the part has come: it waits for it, as an app's function that asks does, or — where nothing can wait (no
|
|
83
|
+
* form) — gives nothing meanwhile, the part asked for.
|
|
84
|
+
*/
|
|
85
|
+
export declare function partComing(call: Call): null;
|
|
86
|
+
/**
|
|
87
|
+
* Whether a page (or any part of one) calls a function the functions part works out — one of Fieldia's beyond the
|
|
88
|
+
* plain ones, or one of the app's own named in `app` — its formulas name one. Read over the whole page, so words that
|
|
89
|
+
* look like a call ("Your age (in years)") ask for the part too, which is no harm; one never missed.
|
|
90
|
+
*/
|
|
91
|
+
export declare function callsPartFunctions(page: unknown, app?: readonly string[]): boolean;
|
|
34
92
|
export declare const FUNCTIONS: ReadonlyMap<string, ExpressionFunction>;
|
|
35
93
|
/** How many values a function takes, in words: "round takes 1 or 2 values". */
|
|
36
94
|
export declare function takesInWords(name: string, [least, most]: readonly [number, number]): string;
|
|
37
|
-
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ASTNode } from './parser';
|
|
2
|
+
import { type Part } from '../parts';
|
|
3
|
+
import type * as FunctionsModule from './functions-part';
|
|
2
4
|
/**
|
|
3
5
|
* The functions an expression may call. Each says how many values it takes,
|
|
4
6
|
* so a call with too many or too few is refused when the page is read; and
|
|
@@ -13,25 +15,80 @@ export interface ExpressionEnv {
|
|
|
13
15
|
lines?(field: string): readonly Readonly<Record<string, unknown>>[] | undefined;
|
|
14
16
|
/** Today, as YYYY-MM-DD. The computer's own clock when left out. */
|
|
15
17
|
today?(): string;
|
|
18
|
+
/** The app's own functions, by name, besides Fieldia's (`functions` on the form, the viewer and its wrappers). */
|
|
19
|
+
functions?: FunctionTable;
|
|
20
|
+
/**
|
|
21
|
+
* The answer an app's function that asks (its call a promise) gave for these values, by its key — the function
|
|
22
|
+
* and its values: `{ value }`, or `'asking'` while it is on its way. Handed the promise the first time, the form
|
|
23
|
+
* keeps the answer for the record shown, and works its values out again as it comes. Left out, such a function
|
|
24
|
+
* gives null and is not asked.
|
|
25
|
+
*/
|
|
26
|
+
answer?(key: string, asked?: PromiseLike<unknown>): Answered | 'asking' | undefined;
|
|
27
|
+
/** The name of the record a link field holds (`currency_id`: "EGP"), for what reads a record by its name. */
|
|
28
|
+
nameOf?(field: string): string | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** What an app's function that asks answered: its value, or — empty — why it did not come (`failed`). */
|
|
31
|
+
export interface Answered {
|
|
32
|
+
value: unknown;
|
|
33
|
+
failed?: string;
|
|
16
34
|
}
|
|
17
35
|
/** One call, as a function sees it: its values unread, a way to read each, and the env. */
|
|
18
|
-
interface Call {
|
|
36
|
+
export interface Call {
|
|
19
37
|
args: readonly ASTNode[];
|
|
20
38
|
value(node: ASTNode): unknown;
|
|
21
39
|
env: ExpressionEnv;
|
|
22
40
|
/** Whether a condition, written in quotes, holds for one line's values. */
|
|
23
41
|
holds(condition: string, row: Readonly<Record<string, unknown>>): boolean;
|
|
24
42
|
}
|
|
25
|
-
|
|
43
|
+
/** A function an expression may call: Fieldia's own, or the app's (`FunctionTable`). */
|
|
44
|
+
export interface ExpressionFunction {
|
|
26
45
|
/** How many values it takes: at least, at most. */
|
|
27
46
|
readonly takes: readonly [number, number];
|
|
28
47
|
/** What is wrong with the values it was given, found as the expression is read. */
|
|
29
48
|
check?(args: readonly ASTNode[]): string | undefined;
|
|
30
49
|
call(call: Call): unknown;
|
|
31
50
|
}
|
|
51
|
+
/** The functions an expression may call besides Fieldia's own, by name: the app's (`functionTable`). */
|
|
52
|
+
export type FunctionTable = ReadonlyMap<string, ExpressionFunction>;
|
|
53
|
+
/**
|
|
54
|
+
* Thrown while an app's function that asks is waiting for its answer: the expression has no value yet. A value
|
|
55
|
+
* worked out from it waits (null meanwhile), a condition reading it does not hold yet.
|
|
56
|
+
*/
|
|
57
|
+
export declare class Asking extends Error {
|
|
58
|
+
constructor();
|
|
59
|
+
}
|
|
32
60
|
/** A day as YYYY-MM-DD, in the computer's own time zone. */
|
|
33
61
|
export declare function localDay(date: Date): string;
|
|
62
|
+
/** The list a function counts or adds up: the rows of a one2many named by its field, or any list. */
|
|
63
|
+
export declare function listOf(call: Call): unknown;
|
|
64
|
+
/** A condition given in quotes as the value at `at`: refused when it is anything else. */
|
|
65
|
+
export declare function conditionAt(args: readonly ASTNode[], at: number, name: string, example: string): string | undefined;
|
|
66
|
+
/** The numbers of a list a function adds up: its items, or a field of its rows (`sum(lines, 'x')`), where a condition holds. */
|
|
67
|
+
export declare function numbersOf(call: Call, list: unknown[]): number[];
|
|
68
|
+
/** The values given, lists opened, empty ones left out. */
|
|
69
|
+
export declare function opened(call: Call, args?: readonly ASTNode[]): unknown[];
|
|
70
|
+
/** The functions part: the bodies of Fieldia's functions beyond the plain ones (more-functions.ts). */
|
|
71
|
+
export type FunctionsPart = typeof FunctionsModule;
|
|
72
|
+
/**
|
|
73
|
+
* The bodies of Fieldia's functions beyond the plain ones — a person's age, days and months added, text tested and
|
|
74
|
+
* joined, an average, money rounded to its currency, the first that is not empty — and the calls of the app's own
|
|
75
|
+
* (`functions`, app-functions.ts): loaded before a page that calls one of Fieldia's is drawn (`callsPartFunctions`), or
|
|
76
|
+
* a viewer given the app's: a page that calls none never downloads them. Their names, and what each takes, are known
|
|
77
|
+
* without it, so a page is read and checked as ever.
|
|
78
|
+
*/
|
|
79
|
+
export declare const functionsPart: Part<FunctionsPart>;
|
|
80
|
+
/**
|
|
81
|
+
* A call of a function the functions part works out — one of Fieldia's beyond the plain ones, or the app's own — made
|
|
82
|
+
* before the part has come: it waits for it, as an app's function that asks does, or — where nothing can wait (no
|
|
83
|
+
* form) — gives nothing meanwhile, the part asked for.
|
|
84
|
+
*/
|
|
85
|
+
export declare function partComing(call: Call): null;
|
|
86
|
+
/**
|
|
87
|
+
* Whether a page (or any part of one) calls a function the functions part works out — one of Fieldia's beyond the
|
|
88
|
+
* plain ones, or one of the app's own named in `app` — its formulas name one. Read over the whole page, so words that
|
|
89
|
+
* look like a call ("Your age (in years)") ask for the part too, which is no harm; one never missed.
|
|
90
|
+
*/
|
|
91
|
+
export declare function callsPartFunctions(page: unknown, app?: readonly string[]): boolean;
|
|
34
92
|
export declare const FUNCTIONS: ReadonlyMap<string, ExpressionFunction>;
|
|
35
93
|
/** How many values a function takes, in words: "round takes 1 or 2 values". */
|
|
36
94
|
export declare function takesInWords(name: string, [least, most]: readonly [number, number]): string;
|
|
37
|
-
export {};
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FUNCTIONS = void 0;
|
|
3
|
+
exports.FUNCTIONS = exports.functionsPart = exports.Asking = void 0;
|
|
4
4
|
exports.localDay = localDay;
|
|
5
|
+
exports.listOf = listOf;
|
|
6
|
+
exports.conditionAt = conditionAt;
|
|
7
|
+
exports.numbersOf = numbersOf;
|
|
8
|
+
exports.opened = opened;
|
|
9
|
+
exports.partComing = partComing;
|
|
10
|
+
exports.callsPartFunctions = callsPartFunctions;
|
|
5
11
|
exports.takesInWords = takesInWords;
|
|
6
12
|
const operations_1 = require("./operations");
|
|
13
|
+
const parts_1 = require("../parts");
|
|
14
|
+
/**
|
|
15
|
+
* Thrown while an app's function that asks is waiting for its answer: the expression has no value yet. A value
|
|
16
|
+
* worked out from it waits (null meanwhile), a condition reading it does not hold yet.
|
|
17
|
+
*/
|
|
18
|
+
class Asking extends Error {
|
|
19
|
+
constructor() {
|
|
20
|
+
super('waiting for an answer');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Asking = Asking;
|
|
7
24
|
/** A day as YYYY-MM-DD, in the computer's own time zone. */
|
|
8
25
|
function localDay(date) {
|
|
9
26
|
const pad = (n) => String(n).padStart(2, '0');
|
|
@@ -28,6 +45,13 @@ function rowsWhere(call, list, at) {
|
|
|
28
45
|
const source = condition.value;
|
|
29
46
|
return list.filter((row) => row !== null && typeof row === 'object' && call.holds(source, row));
|
|
30
47
|
}
|
|
48
|
+
/** The numbers of a list a function adds up: its items, or a field of its rows (`sum(lines, 'x')`), where a condition holds. */
|
|
49
|
+
function numbersOf(call, list) {
|
|
50
|
+
const field = call.args[1]?.type === 'Literal' ? call.args[1].value : undefined;
|
|
51
|
+
return rowsWhere(call, list, 2)
|
|
52
|
+
.map((item) => (field === undefined ? item : item?.[field]))
|
|
53
|
+
.filter(operations_1.isNumber);
|
|
54
|
+
}
|
|
31
55
|
/** A day from a date or a datetime, as days since 1970: null when it is not one. */
|
|
32
56
|
function dayNumber(value) {
|
|
33
57
|
if (typeof value !== 'string')
|
|
@@ -35,14 +59,16 @@ function dayNumber(value) {
|
|
|
35
59
|
const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);
|
|
36
60
|
return match ? Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])) / 86_400_000 : null;
|
|
37
61
|
}
|
|
38
|
-
/** The
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
.flatMap((arg) => {
|
|
62
|
+
/** The values given, lists opened, empty ones left out. */
|
|
63
|
+
function opened(call, args = call.args) {
|
|
64
|
+
return args.flatMap((arg) => {
|
|
42
65
|
const value = call.value(arg);
|
|
43
66
|
return Array.isArray(value) ? value : [value];
|
|
44
|
-
})
|
|
45
|
-
|
|
67
|
+
}).filter((value) => value !== null && value !== undefined);
|
|
68
|
+
}
|
|
69
|
+
/** The smallest or largest of the values, lists opened: empty ones left out, numbers or text but not both. */
|
|
70
|
+
function extreme(call, smaller) {
|
|
71
|
+
const items = opened(call);
|
|
46
72
|
if (!items.length)
|
|
47
73
|
return null;
|
|
48
74
|
if (!items.every(operations_1.isNumber) && !items.every((value) => typeof value === 'string'))
|
|
@@ -50,6 +76,78 @@ function extreme(call, smaller) {
|
|
|
50
76
|
const ordered = items;
|
|
51
77
|
return ordered.reduce((best, value) => ((smaller ? value < best : value > best) ? value : best));
|
|
52
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* The bodies of Fieldia's functions beyond the plain ones — a person's age, days and months added, text tested and
|
|
81
|
+
* joined, an average, money rounded to its currency, the first that is not empty — and the calls of the app's own
|
|
82
|
+
* (`functions`, app-functions.ts): loaded before a page that calls one of Fieldia's is drawn (`callsPartFunctions`), or
|
|
83
|
+
* a viewer given the app's: a page that calls none never downloads them. Their names, and what each takes, are known
|
|
84
|
+
* without it, so a page is read and checked as ever.
|
|
85
|
+
*/
|
|
86
|
+
exports.functionsPart = (0, parts_1.lazyPart)('functions', () => Promise.resolve().then(() => require('./functions-part')));
|
|
87
|
+
/** The key the functions part is asked by, as an app's function that asks is (`ExpressionEnv.answer`). */
|
|
88
|
+
const PART_ASKED = 'fieldia:functions';
|
|
89
|
+
/**
|
|
90
|
+
* One of Fieldia's functions whose body is in the functions part. Before the part has come, a value worked out from it
|
|
91
|
+
* waits for it as for an app's function that asks — shown as asked, a condition reading it not holding, a save waiting
|
|
92
|
+
* for it — and is worked out as it comes; where nothing can wait (no form), it gives nothing meanwhile, the part asked
|
|
93
|
+
* for.
|
|
94
|
+
*/
|
|
95
|
+
function inPart(name, takes, check) {
|
|
96
|
+
return { takes, ...(check ? { check } : {}), call: (call) => (exports.functionsPart.loaded ? exports.functionsPart.loaded.functionBody(name)(call) : partComing(call)) };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A call of a function the functions part works out — one of Fieldia's beyond the plain ones, or the app's own — made
|
|
100
|
+
* before the part has come: it waits for it, as an app's function that asks does, or — where nothing can wait (no
|
|
101
|
+
* form) — gives nothing meanwhile, the part asked for.
|
|
102
|
+
*/
|
|
103
|
+
function partComing(call) {
|
|
104
|
+
const coming = exports.functionsPart.load();
|
|
105
|
+
const asked = call.env.answer?.(PART_ASKED, coming);
|
|
106
|
+
if (asked === 'asking')
|
|
107
|
+
throw new Asking();
|
|
108
|
+
if (!call.env.answer)
|
|
109
|
+
coming.catch(() => undefined);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
/** The functions whose bodies are in the functions part, each with how many values it takes: at least, at most. */
|
|
113
|
+
const IN_PART = [
|
|
114
|
+
['age', 1, 2],
|
|
115
|
+
['years', 2, 2],
|
|
116
|
+
['months', 2, 2],
|
|
117
|
+
['addDays', 2, 2],
|
|
118
|
+
['addMonths', 2, 2],
|
|
119
|
+
['addYears', 2, 2],
|
|
120
|
+
['contains', 2, 2],
|
|
121
|
+
['startsWith', 2, 2],
|
|
122
|
+
['endsWith', 2, 2],
|
|
123
|
+
['upper', 1, 1],
|
|
124
|
+
['lower', 1, 1],
|
|
125
|
+
['join', 2, Infinity],
|
|
126
|
+
['average', 1, Infinity],
|
|
127
|
+
['roundMoney', 2, 2],
|
|
128
|
+
['empty', 1, 1],
|
|
129
|
+
['firstOf', 1, Infinity],
|
|
130
|
+
];
|
|
131
|
+
/** What is wrong with the values `average` is given, found as the expression is read: of the lines, a field and a condition. */
|
|
132
|
+
function averageCheck(args) {
|
|
133
|
+
if (!(args[1]?.type === 'Literal' && typeof args[1].value === 'string'))
|
|
134
|
+
return undefined;
|
|
135
|
+
if (args.length > 3)
|
|
136
|
+
return `average of the lines takes the lines, a field and a condition: average(lines, 'price', "qty > 0")`;
|
|
137
|
+
return conditionAt(args, 2, 'average', `average(lines, 'price', "qty > 0")`);
|
|
138
|
+
}
|
|
139
|
+
/** A call of one of these functions. */
|
|
140
|
+
const callOf = (names) => new RegExp(`\\b(${names.join('|')})\\s*\\(`);
|
|
141
|
+
const CALLS_IN_PART = callOf(IN_PART.map(([name]) => name));
|
|
142
|
+
/**
|
|
143
|
+
* Whether a page (or any part of one) calls a function the functions part works out — one of Fieldia's beyond the
|
|
144
|
+
* plain ones, or one of the app's own named in `app` — its formulas name one. Read over the whole page, so words that
|
|
145
|
+
* look like a call ("Your age (in years)") ask for the part too, which is no harm; one never missed.
|
|
146
|
+
*/
|
|
147
|
+
function callsPartFunctions(page, app = []) {
|
|
148
|
+
const words = JSON.stringify(page) ?? '';
|
|
149
|
+
return CALLS_IN_PART.test(words) || (app.length > 0 && callOf(app).test(words));
|
|
150
|
+
}
|
|
53
151
|
exports.FUNCTIONS = new Map([
|
|
54
152
|
[
|
|
55
153
|
'round',
|
|
@@ -104,14 +202,8 @@ exports.FUNCTIONS = new Map([
|
|
|
104
202
|
return 0;
|
|
105
203
|
if (!Array.isArray(list))
|
|
106
204
|
return null;
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
for (const item of rowsWhere(call, list, 2)) {
|
|
110
|
-
const n = field === undefined ? item : item?.[field];
|
|
111
|
-
if ((0, operations_1.isNumber)(n))
|
|
112
|
-
total += n;
|
|
113
|
-
}
|
|
114
|
-
return (0, operations_1.tidy)(total);
|
|
205
|
+
const numbers = numbersOf(call, list);
|
|
206
|
+
return (0, operations_1.tidy)(numbers.reduce((total, n) => total + n, 0));
|
|
115
207
|
},
|
|
116
208
|
},
|
|
117
209
|
],
|
|
@@ -148,6 +240,8 @@ exports.FUNCTIONS = new Map([
|
|
|
148
240
|
call: ({ args, value }) => ((0, operations_1.truthy)(value(args[0])) ? value(args[1]) : value(args[2])),
|
|
149
241
|
},
|
|
150
242
|
],
|
|
243
|
+
// Fieldia's functions beyond the plain ones: their bodies in the functions part, loaded for a page that calls them.
|
|
244
|
+
...IN_PART.map(([name, least, most]) => [name, inPart(name, [least, most], name === 'average' ? averageCheck : undefined)]),
|
|
151
245
|
]);
|
|
152
246
|
/** How many values a function takes, in words: "round takes 1 or 2 values". */
|
|
153
247
|
function takesInWords(name, [least, most]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/expression/functions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/expression/functions.ts"],"names":[],"mappings":";;;AAuEA,4BAGC;AAGD,wBAIC;AAGD,kCAGC;AAWD,8BAKC;AAUD,wBAKC;AAyCD,gCAMC;AAsCD,gDAGC;AA+FD,oCAKC;AAjTD,6CAA+D;AAC/D,oCAA+C;AA0D/C;;;GAGG;AACH,MAAa,MAAO,SAAQ,KAAK;IAC/B;QACE,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACjC,CAAC;CACF;AAJD,wBAIC;AAED,4DAA4D;AAC5D,SAAgB,QAAQ,CAAC,IAAU;IACjC,MAAM,GAAG,G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AAI,KAAK,QAAQ;QAAE,OAAO,GAAG,IAAI,UAAU,KAAK,iBAAiB,CAAC;IACtE,OAAO,GAAG,IAAI,UAAU,KAAK,OAAO,IAAI,SAAS,CAAC;AACpD,CAAC"}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { isNumber, roundTo, tidy, truthy } from './operations.mjs';
|
|
2
|
+
import { lazyPart } from '../parts.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown while an app's function that asks is waiting for its answer: the expression has no value yet. A value
|
|
5
|
+
* worked out from it waits (null meanwhile), a condition reading it does not hold yet.
|
|
6
|
+
*/
|
|
7
|
+
export class Asking extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super('waiting for an answer');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
2
12
|
/** A day as YYYY-MM-DD, in the computer's own time zone. */
|
|
3
13
|
export function localDay(date) {
|
|
4
14
|
const pad = (n) => String(n).padStart(2, '0');
|
|
5
15
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
6
16
|
}
|
|
7
17
|
/** The list a function counts or adds up: the rows of a one2many named by its field, or any list. */
|
|
8
|
-
function listOf(call) {
|
|
18
|
+
export function listOf(call) {
|
|
9
19
|
const first = call.args[0];
|
|
10
20
|
const rows = first.type === 'Identifier' ? call.env.lines?.(first.name) : undefined;
|
|
11
21
|
return rows ?? call.value(first);
|
|
12
22
|
}
|
|
13
23
|
/** A condition given in quotes as the value at `at`: refused when it is anything else. */
|
|
14
|
-
function conditionAt(args, at, name, example) {
|
|
24
|
+
export function conditionAt(args, at, name, example) {
|
|
15
25
|
const arg = args[at];
|
|
16
26
|
return arg && !(arg.type === 'Literal' && typeof arg.value === 'string') ? `${name} takes a condition, in quotes, on the lines: ${example}` : undefined;
|
|
17
27
|
}
|
|
@@ -23,6 +33,13 @@ function rowsWhere(call, list, at) {
|
|
|
23
33
|
const source = condition.value;
|
|
24
34
|
return list.filter((row) => row !== null && typeof row === 'object' && call.holds(source, row));
|
|
25
35
|
}
|
|
36
|
+
/** The numbers of a list a function adds up: its items, or a field of its rows (`sum(lines, 'x')`), where a condition holds. */
|
|
37
|
+
export function numbersOf(call, list) {
|
|
38
|
+
const field = call.args[1]?.type === 'Literal' ? call.args[1].value : undefined;
|
|
39
|
+
return rowsWhere(call, list, 2)
|
|
40
|
+
.map((item) => (field === undefined ? item : item?.[field]))
|
|
41
|
+
.filter(isNumber);
|
|
42
|
+
}
|
|
26
43
|
/** A day from a date or a datetime, as days since 1970: null when it is not one. */
|
|
27
44
|
function dayNumber(value) {
|
|
28
45
|
if (typeof value !== 'string')
|
|
@@ -30,14 +47,16 @@ function dayNumber(value) {
|
|
|
30
47
|
const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);
|
|
31
48
|
return match ? Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])) / 86_400_000 : null;
|
|
32
49
|
}
|
|
33
|
-
/** The
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
.flatMap((arg) => {
|
|
50
|
+
/** The values given, lists opened, empty ones left out. */
|
|
51
|
+
export function opened(call, args = call.args) {
|
|
52
|
+
return args.flatMap((arg) => {
|
|
37
53
|
const value = call.value(arg);
|
|
38
54
|
return Array.isArray(value) ? value : [value];
|
|
39
|
-
})
|
|
40
|
-
|
|
55
|
+
}).filter((value) => value !== null && value !== undefined);
|
|
56
|
+
}
|
|
57
|
+
/** The smallest or largest of the values, lists opened: empty ones left out, numbers or text but not both. */
|
|
58
|
+
function extreme(call, smaller) {
|
|
59
|
+
const items = opened(call);
|
|
41
60
|
if (!items.length)
|
|
42
61
|
return null;
|
|
43
62
|
if (!items.every(isNumber) && !items.every((value) => typeof value === 'string'))
|
|
@@ -45,6 +64,78 @@ function extreme(call, smaller) {
|
|
|
45
64
|
const ordered = items;
|
|
46
65
|
return ordered.reduce((best, value) => ((smaller ? value < best : value > best) ? value : best));
|
|
47
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The bodies of Fieldia's functions beyond the plain ones — a person's age, days and months added, text tested and
|
|
69
|
+
* joined, an average, money rounded to its currency, the first that is not empty — and the calls of the app's own
|
|
70
|
+
* (`functions`, app-functions.ts): loaded before a page that calls one of Fieldia's is drawn (`callsPartFunctions`), or
|
|
71
|
+
* a viewer given the app's: a page that calls none never downloads them. Their names, and what each takes, are known
|
|
72
|
+
* without it, so a page is read and checked as ever.
|
|
73
|
+
*/
|
|
74
|
+
export const functionsPart = lazyPart('functions', () => import('./functions-part.mjs'));
|
|
75
|
+
/** The key the functions part is asked by, as an app's function that asks is (`ExpressionEnv.answer`). */
|
|
76
|
+
const PART_ASKED = 'fieldia:functions';
|
|
77
|
+
/**
|
|
78
|
+
* One of Fieldia's functions whose body is in the functions part. Before the part has come, a value worked out from it
|
|
79
|
+
* waits for it as for an app's function that asks — shown as asked, a condition reading it not holding, a save waiting
|
|
80
|
+
* for it — and is worked out as it comes; where nothing can wait (no form), it gives nothing meanwhile, the part asked
|
|
81
|
+
* for.
|
|
82
|
+
*/
|
|
83
|
+
function inPart(name, takes, check) {
|
|
84
|
+
return { takes, ...(check ? { check } : {}), call: (call) => (functionsPart.loaded ? functionsPart.loaded.functionBody(name)(call) : partComing(call)) };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A call of a function the functions part works out — one of Fieldia's beyond the plain ones, or the app's own — made
|
|
88
|
+
* before the part has come: it waits for it, as an app's function that asks does, or — where nothing can wait (no
|
|
89
|
+
* form) — gives nothing meanwhile, the part asked for.
|
|
90
|
+
*/
|
|
91
|
+
export function partComing(call) {
|
|
92
|
+
const coming = functionsPart.load();
|
|
93
|
+
const asked = call.env.answer?.(PART_ASKED, coming);
|
|
94
|
+
if (asked === 'asking')
|
|
95
|
+
throw new Asking();
|
|
96
|
+
if (!call.env.answer)
|
|
97
|
+
coming.catch(() => undefined);
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
/** The functions whose bodies are in the functions part, each with how many values it takes: at least, at most. */
|
|
101
|
+
const IN_PART = [
|
|
102
|
+
['age', 1, 2],
|
|
103
|
+
['years', 2, 2],
|
|
104
|
+
['months', 2, 2],
|
|
105
|
+
['addDays', 2, 2],
|
|
106
|
+
['addMonths', 2, 2],
|
|
107
|
+
['addYears', 2, 2],
|
|
108
|
+
['contains', 2, 2],
|
|
109
|
+
['startsWith', 2, 2],
|
|
110
|
+
['endsWith', 2, 2],
|
|
111
|
+
['upper', 1, 1],
|
|
112
|
+
['lower', 1, 1],
|
|
113
|
+
['join', 2, Infinity],
|
|
114
|
+
['average', 1, Infinity],
|
|
115
|
+
['roundMoney', 2, 2],
|
|
116
|
+
['empty', 1, 1],
|
|
117
|
+
['firstOf', 1, Infinity],
|
|
118
|
+
];
|
|
119
|
+
/** What is wrong with the values `average` is given, found as the expression is read: of the lines, a field and a condition. */
|
|
120
|
+
function averageCheck(args) {
|
|
121
|
+
if (!(args[1]?.type === 'Literal' && typeof args[1].value === 'string'))
|
|
122
|
+
return undefined;
|
|
123
|
+
if (args.length > 3)
|
|
124
|
+
return `average of the lines takes the lines, a field and a condition: average(lines, 'price', "qty > 0")`;
|
|
125
|
+
return conditionAt(args, 2, 'average', `average(lines, 'price', "qty > 0")`);
|
|
126
|
+
}
|
|
127
|
+
/** A call of one of these functions. */
|
|
128
|
+
const callOf = (names) => new RegExp(`\\b(${names.join('|')})\\s*\\(`);
|
|
129
|
+
const CALLS_IN_PART = callOf(IN_PART.map(([name]) => name));
|
|
130
|
+
/**
|
|
131
|
+
* Whether a page (or any part of one) calls a function the functions part works out — one of Fieldia's beyond the
|
|
132
|
+
* plain ones, or one of the app's own named in `app` — its formulas name one. Read over the whole page, so words that
|
|
133
|
+
* look like a call ("Your age (in years)") ask for the part too, which is no harm; one never missed.
|
|
134
|
+
*/
|
|
135
|
+
export function callsPartFunctions(page, app = []) {
|
|
136
|
+
const words = JSON.stringify(page) ?? '';
|
|
137
|
+
return CALLS_IN_PART.test(words) || (app.length > 0 && callOf(app).test(words));
|
|
138
|
+
}
|
|
48
139
|
export const FUNCTIONS = new Map([
|
|
49
140
|
[
|
|
50
141
|
'round',
|
|
@@ -99,14 +190,8 @@ export const FUNCTIONS = new Map([
|
|
|
99
190
|
return 0;
|
|
100
191
|
if (!Array.isArray(list))
|
|
101
192
|
return null;
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
for (const item of rowsWhere(call, list, 2)) {
|
|
105
|
-
const n = field === undefined ? item : item?.[field];
|
|
106
|
-
if (isNumber(n))
|
|
107
|
-
total += n;
|
|
108
|
-
}
|
|
109
|
-
return tidy(total);
|
|
193
|
+
const numbers = numbersOf(call, list);
|
|
194
|
+
return tidy(numbers.reduce((total, n) => total + n, 0));
|
|
110
195
|
},
|
|
111
196
|
},
|
|
112
197
|
],
|
|
@@ -143,6 +228,8 @@ export const FUNCTIONS = new Map([
|
|
|
143
228
|
call: ({ args, value }) => (truthy(value(args[0])) ? value(args[1]) : value(args[2])),
|
|
144
229
|
},
|
|
145
230
|
],
|
|
231
|
+
// Fieldia's functions beyond the plain ones: their bodies in the functions part, loaded for a page that calls them.
|
|
232
|
+
...IN_PART.map(([name, least, most]) => [name, inPart(name, [least, most], name === 'average' ? averageCheck : undefined)]),
|
|
146
233
|
]);
|
|
147
234
|
/** How many values a function takes, in words: "round takes 1 or 2 values". */
|
|
148
235
|
export function takesInWords(name, [least, most]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/expression/functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"functions.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/expression/functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC/D,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AA4B;IACjF,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,IAAI,kBAAkB,CAAC;IACjD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,GAAG,IAAI,UAAU,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACnF,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,GAAG,IAAI,UAAU,KAAK,iBAAiB,CAAC;IACtE,OAAO,GAAG,IAAI,UAAU,KAAK,OAAO,IAAI,SAAS,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Field, LineField } from '../format/field.mjs';
|
|
2
|
+
import { type FunctionsKnown, type ValueKind } from './app-functions.mjs';
|
|
3
|
+
import type { ASTNode } from './parser.mjs';
|
|
4
|
+
/** The kind a field's value is, as expressions read it. */
|
|
5
|
+
export declare function fieldKind(def: Field | LineField | undefined): ValueKind;
|
|
6
|
+
/** A value handed to a function of a kind it does not take. */
|
|
7
|
+
export interface KindProblem {
|
|
8
|
+
/** The function. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Which of its values, from 0. */
|
|
11
|
+
at: number;
|
|
12
|
+
/** The kinds it takes there. */
|
|
13
|
+
wants: readonly ValueKind[];
|
|
14
|
+
/** The kind it was given. */
|
|
15
|
+
got: ValueKind;
|
|
16
|
+
/** What was given, as written. */
|
|
17
|
+
given: ASTNode;
|
|
18
|
+
}
|
|
19
|
+
/** Where an expression's names are found: its fields, and on a line the record it is on (`parent`). */
|
|
20
|
+
export interface KindScope {
|
|
21
|
+
fields: Readonly<Record<string, Field | LineField>>;
|
|
22
|
+
parent?: Readonly<Record<string, Field | LineField>>;
|
|
23
|
+
}
|
|
24
|
+
/** Every value in the expression handed to a function of a kind it does not take, the outer call first. */
|
|
25
|
+
export declare function kindProblems(ast: ASTNode, scope: KindScope, functions?: FunctionsKnown): KindProblem[];
|
|
26
|
+
/** A kind in English words, as a page's checks say them: "a number", "a date or text". */
|
|
27
|
+
export declare const kindWords: (kinds: readonly ValueKind[]) => string;
|
|
28
|
+
/** A part of an expression as it is written, shortly: a field by its name, words in quotes, a call by its function. */
|
|
29
|
+
export declare function writtenAs(node: ASTNode): string;
|
|
30
|
+
/** A problem in a page's check's words: `age takes a date as its first value; "notes" is text`. */
|
|
31
|
+
export declare function kindProblemWords(problem: KindProblem): string;
|