@sourcey/catalog-verifier 1.1.3 → 1.1.5
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/SBOM.cdx.json +16 -16
- package/SOURCEY-CLOSURE.json +580 -580
- package/SOURCEY-DISTRIBUTION.json +1 -1
- package/THIRD_PARTY_NOTICES.json +6 -6
- package/dist/contracts/agent-readiness/src/authority.d.ts +51 -0
- package/dist/contracts/agent-readiness/src/authority.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/authority.js +36 -0
- package/dist/contracts/agent-readiness/src/authority.js.map +1 -0
- package/dist/contracts/agent-readiness/src/binding.d.ts +600 -0
- package/dist/contracts/agent-readiness/src/binding.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/binding.js +466 -0
- package/dist/contracts/agent-readiness/src/binding.js.map +1 -0
- package/dist/contracts/agent-readiness/src/declaration-acquisition.d.ts +484 -202
- package/dist/contracts/agent-readiness/src/declaration-acquisition.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration-acquisition.js +13 -11
- package/dist/contracts/agent-readiness/src/declaration-acquisition.js.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration-reference.d.ts +4 -7
- package/dist/contracts/agent-readiness/src/declaration-reference.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration-reference.js +3 -6
- package/dist/contracts/agent-readiness/src/declaration-reference.js.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration.d.ts +1930 -334
- package/dist/contracts/agent-readiness/src/declaration.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration.js +73 -78
- package/dist/contracts/agent-readiness/src/declaration.js.map +1 -1
- package/dist/contracts/agent-readiness/src/index.d.ts +3512 -4412
- package/dist/contracts/agent-readiness/src/index.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/index.js +227 -936
- package/dist/contracts/agent-readiness/src/index.js.map +1 -1
- package/dist/contracts/agent-readiness/src/jobs.d.ts +199 -0
- package/dist/contracts/agent-readiness/src/jobs.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/jobs.js +125 -0
- package/dist/contracts/agent-readiness/src/jobs.js.map +1 -0
- package/dist/contracts/agent-readiness/src/operate-policy.d.ts +251 -0
- package/dist/contracts/agent-readiness/src/operate-policy.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/operate-policy.js +86 -0
- package/dist/contracts/agent-readiness/src/operate-policy.js.map +1 -0
- package/dist/contracts/agent-readiness/src/run.d.ts +485 -0
- package/dist/contracts/agent-readiness/src/run.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/run.js +308 -0
- package/dist/contracts/agent-readiness/src/run.js.map +1 -0
- package/dist/contracts/agent-readiness/src/shared.d.ts +53 -62
- package/dist/contracts/agent-readiness/src/shared.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/shared.js +51 -85
- package/dist/contracts/agent-readiness/src/shared.js.map +1 -1
- package/dist/contracts/api/src/index.d.ts +15206 -15810
- package/dist/contracts/api/src/index.d.ts.map +1 -1
- package/dist/contracts/api/src/index.js +93 -80
- package/dist/contracts/api/src/index.js.map +1 -1
- package/dist/contracts/artifact/src/index.d.ts +135 -71
- package/dist/contracts/artifact/src/index.d.ts.map +1 -1
- package/dist/contracts/artifact/src/index.js +16 -12
- package/dist/contracts/artifact/src/index.js.map +1 -1
- package/dist/contracts/assets/src/index.d.ts +0 -129
- package/dist/contracts/assets/src/index.d.ts.map +1 -1
- package/dist/contracts/assets/src/index.js +4 -4
- package/dist/contracts/assets/src/index.js.map +1 -1
- package/dist/contracts/assurance/src/index.d.ts +0 -1
- package/dist/contracts/assurance/src/index.d.ts.map +1 -1
- package/dist/contracts/authoring/src/index.d.ts +48 -247
- package/dist/contracts/authoring/src/index.d.ts.map +1 -1
- package/dist/contracts/authoring/src/index.js +4 -7
- package/dist/contracts/authoring/src/index.js.map +1 -1
- package/dist/contracts/authority/src/index.d.ts +0 -3
- package/dist/contracts/authority/src/index.d.ts.map +1 -1
- package/dist/contracts/authority/src/index.js +1 -2
- package/dist/contracts/authority/src/index.js.map +1 -1
- package/dist/contracts/billing/src/index.d.ts +0 -124
- package/dist/contracts/billing/src/index.d.ts.map +1 -1
- package/dist/contracts/billing/src/index.js +2 -58
- package/dist/contracts/billing/src/index.js.map +1 -1
- package/dist/contracts/catalog-verifier/src/index.d.ts +0 -3
- package/dist/contracts/catalog-verifier/src/index.d.ts.map +1 -1
- package/dist/contracts/company-authoring/src/index.d.ts +72 -0
- package/dist/contracts/company-authoring/src/index.d.ts.map +1 -0
- package/dist/contracts/company-authoring/src/index.js +41 -0
- package/dist/contracts/company-authoring/src/index.js.map +1 -0
- package/dist/contracts/company-standing/src/index.d.ts +106 -0
- package/dist/contracts/company-standing/src/index.d.ts.map +1 -0
- package/dist/contracts/company-standing/src/index.js +114 -0
- package/dist/contracts/company-standing/src/index.js.map +1 -0
- package/dist/contracts/company-verification/src/index.d.ts +94 -0
- package/dist/contracts/company-verification/src/index.d.ts.map +1 -0
- package/dist/contracts/company-verification/src/index.js +138 -0
- package/dist/contracts/company-verification/src/index.js.map +1 -0
- package/dist/contracts/datasets/src/index.d.ts +80 -129
- package/dist/contracts/datasets/src/index.d.ts.map +1 -1
- package/dist/contracts/events/src/index.d.ts +41 -5
- package/dist/contracts/events/src/index.d.ts.map +1 -1
- package/dist/contracts/events/src/index.js +51 -12
- package/dist/contracts/events/src/index.js.map +1 -1
- package/dist/contracts/evidence/src/index.d.ts +10 -267
- package/dist/contracts/evidence/src/index.d.ts.map +1 -1
- package/dist/contracts/evidence/src/index.js +29 -93
- package/dist/contracts/evidence/src/index.js.map +1 -1
- package/dist/contracts/feed/src/index.d.ts +0 -3
- package/dist/contracts/feed/src/index.d.ts.map +1 -1
- package/dist/contracts/observations/src/index.d.ts +0 -1
- package/dist/contracts/observations/src/index.d.ts.map +1 -1
- package/dist/contracts/observations/src/index.js +1 -4
- package/dist/contracts/observations/src/index.js.map +1 -1
- package/dist/contracts/policies/src/index.d.ts +0 -13
- package/dist/contracts/policies/src/index.d.ts.map +1 -1
- package/dist/contracts/policies/src/index.js +3 -2
- package/dist/contracts/policies/src/index.js.map +1 -1
- package/dist/contracts/publication/src/index.d.ts +282 -1285
- package/dist/contracts/publication/src/index.d.ts.map +1 -1
- package/dist/contracts/publication/src/index.js +22 -162
- package/dist/contracts/publication/src/index.js.map +1 -1
- package/dist/contracts/release/src/index.d.ts +120 -21
- package/dist/contracts/release/src/index.d.ts.map +1 -1
- package/dist/contracts/release/src/index.js +14 -2
- package/dist/contracts/release/src/index.js.map +1 -1
- package/dist/contracts/revisions/src/index.d.ts +107 -69
- package/dist/contracts/revisions/src/index.d.ts.map +1 -1
- package/dist/contracts/revisions/src/index.js +26 -8
- package/dist/contracts/revisions/src/index.js.map +1 -1
- package/dist/contracts/routes/src/index.d.ts +1 -17
- package/dist/contracts/routes/src/index.d.ts.map +1 -1
- package/dist/contracts/routes/src/index.js +7 -7
- package/dist/contracts/routes/src/index.js.map +1 -1
- package/dist/contracts/sourcey-publication/src/ownership.d.ts.map +1 -1
- package/dist/contracts/sourcey-publication/src/ownership.js +3 -1
- package/dist/contracts/sourcey-publication/src/ownership.js.map +1 -1
- package/dist/contracts/standards/src/index.d.ts +0 -1552
- package/dist/contracts/standards/src/index.d.ts.map +1 -1
- package/dist/contracts/standards/src/index.js +1 -723
- package/dist/contracts/standards/src/index.js.map +1 -1
- package/dist/contracts/startup-credits-commercial/src/index.d.ts +53 -382
- package/dist/contracts/startup-credits-commercial/src/index.d.ts.map +1 -1
- package/dist/contracts/startup-credits-commercial/src/index.js +30 -267
- package/dist/contracts/startup-credits-commercial/src/index.js.map +1 -1
- package/dist/modules/agent-readiness-engine/src/assertions.d.ts +24 -0
- package/dist/modules/agent-readiness-engine/src/assertions.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/assertions.js +145 -0
- package/dist/modules/agent-readiness-engine/src/assertions.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/binding.d.ts +12 -0
- package/dist/modules/agent-readiness-engine/src/binding.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/binding.js +104 -0
- package/dist/modules/agent-readiness-engine/src/binding.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/checks.d.ts +57 -0
- package/dist/modules/agent-readiness-engine/src/checks.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/checks.js +126 -0
- package/dist/modules/agent-readiness-engine/src/checks.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/path.d.ts +24 -0
- package/dist/modules/agent-readiness-engine/src/path.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/path.js +308 -0
- package/dist/modules/agent-readiness-engine/src/path.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/rate.d.ts +23 -0
- package/dist/modules/agent-readiness-engine/src/rate.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/rate.js +57 -0
- package/dist/modules/agent-readiness-engine/src/rate.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/run.d.ts +9 -0
- package/dist/modules/agent-readiness-engine/src/run.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/run.js +45 -0
- package/dist/modules/agent-readiness-engine/src/run.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/templates.d.ts +21 -0
- package/dist/modules/agent-readiness-engine/src/templates.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/templates.js +89 -0
- package/dist/modules/agent-readiness-engine/src/templates.js.map +1 -0
- package/dist/modules/agent-readiness-jobs/src/index.d.ts +196 -0
- package/dist/modules/agent-readiness-jobs/src/index.d.ts.map +1 -0
- package/dist/modules/agent-readiness-jobs/src/index.js +186 -0
- package/dist/modules/agent-readiness-jobs/src/index.js.map +1 -0
- package/dist/modules/agent-readiness-policy/src/current-policy.d.ts +64 -235
- package/dist/modules/agent-readiness-policy/src/current-policy.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/current-policy.js +10 -466
- package/dist/modules/agent-readiness-policy/src/current-policy.js.map +1 -1
- package/dist/modules/agent-readiness-policy/src/declaration-jobs.d.ts +20 -0
- package/dist/modules/agent-readiness-policy/src/declaration-jobs.d.ts.map +1 -0
- package/dist/modules/agent-readiness-policy/src/declaration-jobs.js +32 -0
- package/dist/modules/agent-readiness-policy/src/declaration-jobs.js.map +1 -0
- package/dist/modules/agent-readiness-policy/src/impact.d.ts +1 -80
- package/dist/modules/agent-readiness-policy/src/impact.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/impact.js +2 -189
- package/dist/modules/agent-readiness-policy/src/impact.js.map +1 -1
- package/dist/modules/agent-readiness-policy/src/index.d.ts +21 -788
- package/dist/modules/agent-readiness-policy/src/index.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/index.js +137 -451
- package/dist/modules/agent-readiness-policy/src/index.js.map +1 -1
- package/dist/modules/agent-readiness-policy/src/offer-relations.d.ts +0 -5
- package/dist/modules/agent-readiness-policy/src/offer-relations.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/offer-relations.js +2 -4
- package/dist/modules/agent-readiness-policy/src/offer-relations.js.map +1 -1
- package/dist/modules/agent-readiness-policy/src/operate-policy.d.ts +16 -0
- package/dist/modules/agent-readiness-policy/src/operate-policy.d.ts.map +1 -0
- package/dist/modules/agent-readiness-policy/src/operate-policy.js +110 -0
- package/dist/modules/agent-readiness-policy/src/operate-policy.js.map +1 -0
- package/dist/modules/agent-readiness-policy/src/prior-projection.d.ts +3 -0
- package/dist/modules/agent-readiness-policy/src/prior-projection.d.ts.map +1 -0
- package/dist/modules/agent-readiness-policy/src/prior-projection.js +11 -0
- package/dist/modules/agent-readiness-policy/src/prior-projection.js.map +1 -0
- package/dist/modules/agent-readiness-policy/src/revision.d.ts +13 -2
- package/dist/modules/agent-readiness-policy/src/revision.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/revision.js +79 -38
- package/dist/modules/agent-readiness-policy/src/revision.js.map +1 -1
- package/dist/modules/agent-readiness-repository/src/change.d.ts +3 -4
- package/dist/modules/agent-readiness-repository/src/change.d.ts.map +1 -1
- package/dist/modules/agent-readiness-repository/src/change.js +4 -4
- package/dist/modules/agent-readiness-repository/src/change.js.map +1 -1
- package/dist/modules/agent-readiness-repository/src/declaration-blob.d.ts +0 -5
- package/dist/modules/agent-readiness-repository/src/declaration-blob.d.ts.map +1 -1
- package/dist/modules/agent-readiness-repository/src/declaration-blob.js +2 -9
- package/dist/modules/agent-readiness-repository/src/declaration-blob.js.map +1 -1
- package/dist/modules/agent-readiness-repository/src/index.d.ts +1 -51
- package/dist/modules/agent-readiness-repository/src/index.d.ts.map +1 -1
- package/dist/modules/agent-readiness-repository/src/index.js +4 -113
- package/dist/modules/agent-readiness-repository/src/index.js.map +1 -1
- package/dist/modules/artifact/src/agent-readiness-closure.d.ts +4 -7
- package/dist/modules/artifact/src/agent-readiness-closure.d.ts.map +1 -1
- package/dist/modules/artifact/src/agent-readiness-closure.js +5 -22
- package/dist/modules/artifact/src/agent-readiness-closure.js.map +1 -1
- package/dist/modules/artifact/src/index.d.ts +5 -4
- package/dist/modules/artifact/src/index.d.ts.map +1 -1
- package/dist/modules/artifact/src/index.js +47 -45
- package/dist/modules/artifact/src/index.js.map +1 -1
- package/dist/modules/artifact/src/policy-closure.js +2 -2
- package/dist/modules/artifact/src/policy-closure.js.map +1 -1
- package/dist/modules/assets/src/authority-bundle.d.ts +2 -5
- package/dist/modules/assets/src/authority-bundle.d.ts.map +1 -1
- package/dist/modules/assets/src/authority-bundle.js +1 -9
- package/dist/modules/assets/src/authority-bundle.js.map +1 -1
- package/dist/modules/assets/src/delta.d.ts +0 -5
- package/dist/modules/assets/src/delta.d.ts.map +1 -1
- package/dist/modules/assets/src/delta.js +1 -38
- package/dist/modules/assets/src/delta.js.map +1 -1
- package/dist/modules/assets/src/index.d.ts +1 -1
- package/dist/modules/assets/src/index.d.ts.map +1 -1
- package/dist/modules/assets/src/ingestion.d.ts +2 -1
- package/dist/modules/assets/src/ingestion.d.ts.map +1 -1
- package/dist/modules/authority/src/index.d.ts +3 -10
- package/dist/modules/authority/src/index.d.ts.map +1 -1
- package/dist/modules/authority/src/index.js +113 -201
- package/dist/modules/authority/src/index.js.map +1 -1
- package/dist/modules/authority-state/src/index.d.ts +2 -1
- package/dist/modules/authority-state/src/index.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/admission-conflicts.d.ts +5 -7
- package/dist/modules/catalog-admission/src/admission-conflicts.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/admission-conflicts.js +1 -1
- package/dist/modules/catalog-admission/src/admission-conflicts.js.map +1 -1
- package/dist/modules/catalog-admission/src/change-analysis.d.ts +1 -2
- package/dist/modules/catalog-admission/src/change-analysis.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/change-analysis.js +0 -4
- package/dist/modules/catalog-admission/src/change-analysis.js.map +1 -1
- package/dist/modules/catalog-admission/src/index.d.ts +2 -9
- package/dist/modules/catalog-admission/src/index.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/index.js +28 -13
- package/dist/modules/catalog-admission/src/index.js.map +1 -1
- package/dist/modules/catalog-admission/src/machine-admission.d.ts +65 -19
- package/dist/modules/catalog-admission/src/machine-admission.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/machine-admission.js +5 -331
- package/dist/modules/catalog-admission/src/machine-admission.js.map +1 -1
- package/dist/modules/catalog-admission/src/publication-composition.d.ts +17 -1
- package/dist/modules/catalog-admission/src/publication-composition.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/publication-dependencies.d.ts +1 -6
- package/dist/modules/catalog-admission/src/publication-dependencies.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/publication-dependencies.js +5 -33
- package/dist/modules/catalog-admission/src/publication-dependencies.js.map +1 -1
- package/dist/modules/catalog-admission/src/publication-entities.d.ts +0 -1
- package/dist/modules/catalog-admission/src/publication-entities.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/publication-entities.js +1 -1
- package/dist/modules/catalog-admission/src/publication-entities.js.map +1 -1
- package/dist/modules/catalog-admission/src/publication.d.ts +3 -8
- package/dist/modules/catalog-admission/src/publication.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/publication.js +0 -13
- package/dist/modules/catalog-admission/src/publication.js.map +1 -1
- package/dist/modules/catalog-admission/src/submission.js +1 -1
- package/dist/modules/catalog-admission/src/submission.js.map +1 -1
- package/dist/modules/catalog-admission/src/taxonomy.d.ts +3 -0
- package/dist/modules/catalog-admission/src/taxonomy.d.ts.map +1 -0
- package/dist/modules/catalog-admission/src/taxonomy.js +7 -0
- package/dist/modules/catalog-admission/src/taxonomy.js.map +1 -0
- package/dist/modules/catalog-authoring-validation/src/index.d.ts +0 -1
- package/dist/modules/catalog-authoring-validation/src/index.d.ts.map +1 -1
- package/dist/modules/catalog-authoring-validation/src/index.js +1 -1
- package/dist/modules/catalog-authoring-validation/src/index.js.map +1 -1
- package/dist/modules/catalog-model/src/index.d.ts +2 -2
- package/dist/modules/catalog-model/src/index.d.ts.map +1 -1
- package/dist/modules/catalog-primitives/src/index.d.ts +2 -4
- package/dist/modules/catalog-primitives/src/index.d.ts.map +1 -1
- package/dist/modules/catalog-primitives/src/index.js +24 -0
- package/dist/modules/catalog-primitives/src/index.js.map +1 -1
- package/dist/modules/catalog-read-port/src/index.d.ts +3 -3
- package/dist/modules/catalog-read-port/src/index.d.ts.map +1 -1
- package/dist/modules/evidence-comparison/src/domains.d.ts +8 -0
- package/dist/modules/evidence-comparison/src/domains.d.ts.map +1 -0
- package/dist/modules/evidence-comparison/src/domains.js +16 -0
- package/dist/modules/evidence-comparison/src/domains.js.map +1 -0
- package/dist/modules/evidence-operations/src/attested-capture.d.ts +75 -0
- package/dist/modules/evidence-operations/src/attested-capture.d.ts.map +1 -0
- package/dist/modules/evidence-operations/src/attested-capture.js +227 -0
- package/dist/modules/evidence-operations/src/attested-capture.js.map +1 -0
- package/dist/modules/evidence-operations/src/configuration.d.ts +2 -163
- package/dist/modules/evidence-operations/src/configuration.d.ts.map +1 -1
- package/dist/modules/evidence-operations/src/configuration.js +7 -7
- package/dist/modules/evidence-operations/src/configuration.js.map +1 -1
- package/dist/modules/evidence-operations/src/evidence-authority-materialization.d.ts +53 -0
- package/dist/modules/evidence-operations/src/evidence-authority-materialization.d.ts.map +1 -0
- package/dist/modules/evidence-operations/src/evidence-authority-materialization.js +161 -0
- package/dist/modules/evidence-operations/src/evidence-authority-materialization.js.map +1 -0
- package/dist/modules/evidence-operations/src/evidence-authority.d.ts +27 -2000
- package/dist/modules/evidence-operations/src/evidence-authority.d.ts.map +1 -1
- package/dist/modules/evidence-operations/src/evidence-authority.js +46 -206
- package/dist/modules/evidence-operations/src/evidence-authority.js.map +1 -1
- package/dist/modules/evidence-operations/src/evidence-normalization.d.ts +10 -96
- package/dist/modules/evidence-operations/src/evidence-normalization.d.ts.map +1 -1
- package/dist/modules/evidence-operations/src/evidence-normalization.js +32 -329
- package/dist/modules/evidence-operations/src/evidence-normalization.js.map +1 -1
- package/dist/modules/evidence-operations/src/evidence-revision.d.ts +5 -0
- package/dist/modules/evidence-operations/src/evidence-revision.d.ts.map +1 -0
- package/dist/modules/evidence-operations/src/evidence-revision.js +12 -0
- package/dist/modules/evidence-operations/src/evidence-revision.js.map +1 -0
- package/dist/modules/evidence-operations/src/proof-graph.d.ts +13 -6
- package/dist/modules/evidence-operations/src/proof-graph.d.ts.map +1 -1
- package/dist/modules/evidence-operations/src/proof-graph.js +82 -59
- package/dist/modules/evidence-operations/src/proof-graph.js.map +1 -1
- package/dist/modules/evidence-operations/src/retained-revision.d.ts +7 -5
- package/dist/modules/evidence-operations/src/retained-revision.d.ts.map +1 -1
- package/dist/modules/evidence-operations/src/retained-revision.js +14 -16
- package/dist/modules/evidence-operations/src/retained-revision.js.map +1 -1
- package/dist/modules/evidence-operations/src/source-authority.js +1 -1
- package/dist/modules/evidence-operations/src/source-authority.js.map +1 -1
- package/dist/modules/evidence-operations/src/submission-verifier.d.ts +13 -23
- package/dist/modules/evidence-operations/src/submission-verifier.d.ts.map +1 -1
- package/dist/modules/evidence-operations/src/submission-verifier.js +5 -20
- package/dist/modules/evidence-operations/src/submission-verifier.js.map +1 -1
- package/dist/modules/provenance/src/evidence-bindings.d.ts +2 -1
- package/dist/modules/provenance/src/evidence-bindings.d.ts.map +1 -1
- package/dist/modules/provenance/src/evidence-coverage.d.ts +2 -1
- package/dist/modules/provenance/src/evidence-coverage.d.ts.map +1 -1
- package/dist/modules/provenance/src/index.d.ts +17 -11
- package/dist/modules/provenance/src/index.d.ts.map +1 -1
- package/dist/modules/provenance/src/index.js +62 -62
- package/dist/modules/provenance/src/index.js.map +1 -1
- package/dist/modules/provenance/src/material-claims.d.ts +7 -136
- package/dist/modules/provenance/src/material-claims.d.ts.map +1 -1
- package/dist/modules/provenance/src/material-claims.js +8 -10
- package/dist/modules/provenance/src/material-claims.js.map +1 -1
- package/dist/modules/release/src/agent-readiness-authority.d.ts +71 -0
- package/dist/modules/release/src/agent-readiness-authority.d.ts.map +1 -0
- package/dist/modules/release/src/agent-readiness-authority.js +164 -0
- package/dist/modules/release/src/agent-readiness-authority.js.map +1 -0
- package/dist/modules/release/src/agent-readiness-publication-inputs.d.ts +1 -2
- package/dist/modules/release/src/agent-readiness-publication-inputs.d.ts.map +1 -1
- package/dist/modules/release/src/agent-readiness-publication-inputs.js +3 -6
- package/dist/modules/release/src/agent-readiness-publication-inputs.js.map +1 -1
- package/dist/modules/release/src/agent-readiness-regrade-evidence.d.ts +13 -89
- package/dist/modules/release/src/agent-readiness-regrade-evidence.d.ts.map +1 -1
- package/dist/modules/release/src/agent-readiness-regrade-evidence.js +14 -46
- package/dist/modules/release/src/agent-readiness-regrade-evidence.js.map +1 -1
- package/dist/modules/release/src/changes.d.ts +3 -3
- package/dist/modules/release/src/changes.d.ts.map +1 -1
- package/dist/modules/release/src/changes.js +1 -2
- package/dist/modules/release/src/changes.js.map +1 -1
- package/dist/modules/release/src/evidence-admission.d.ts +10 -10
- package/dist/modules/release/src/evidence-admission.d.ts.map +1 -1
- package/dist/modules/release/src/evidence-admission.js +52 -60
- package/dist/modules/release/src/evidence-admission.js.map +1 -1
- package/dist/modules/release/src/evidence-bundle-tree.d.ts +7 -7
- package/dist/modules/release/src/evidence-bundle-tree.d.ts.map +1 -1
- package/dist/modules/release/src/evidence-bundle-tree.js +15 -15
- package/dist/modules/release/src/evidence-bundle-tree.js.map +1 -1
- package/dist/modules/release/src/identity.d.ts +2 -1
- package/dist/modules/release/src/identity.d.ts.map +1 -1
- package/dist/modules/release/src/identity.js.map +1 -1
- package/dist/modules/release/src/inputs.d.ts +12 -11
- package/dist/modules/release/src/inputs.d.ts.map +1 -1
- package/dist/modules/release/src/inputs.js +30 -202
- package/dist/modules/release/src/inputs.js.map +1 -1
- package/dist/modules/release/src/publication-inputs.d.ts +2 -1
- package/dist/modules/release/src/publication-inputs.d.ts.map +1 -1
- package/dist/modules/release/src/transition.d.ts +2 -2
- package/dist/modules/release/src/transition.d.ts.map +1 -1
- package/dist/modules/release/src/transition.js.map +1 -1
- package/dist/modules/release/src/verification-policies.d.ts +59 -232
- package/dist/modules/release/src/verification-policies.d.ts.map +1 -1
- package/dist/modules/release/src/verification-policies.js +2 -2
- package/dist/modules/release/src/verification-policies.js.map +1 -1
- package/dist/modules/sourcey-publication/src/verifier.d.ts +4 -3
- package/dist/modules/sourcey-publication/src/verifier.d.ts.map +1 -1
- package/dist/modules/sourcey-publication/src/verifier.js +53 -50
- package/dist/modules/sourcey-publication/src/verifier.js.map +1 -1
- package/dist/packages/catalog-verifier/src/application.d.ts +2 -5
- package/dist/packages/catalog-verifier/src/application.d.ts.map +1 -1
- package/dist/packages/catalog-verifier/src/application.js +2 -5
- package/dist/packages/catalog-verifier/src/application.js.map +1 -1
- package/dist/packages/catalog-verifier/src/program.js +1 -1
- package/dist/packages/catalog-verifier/src/program.js.map +1 -1
- package/package.json +2 -3
- package/dist/contracts/agent-readiness/src/evidence.d.ts +0 -190
- package/dist/contracts/agent-readiness/src/evidence.d.ts.map +0 -1
- package/dist/contracts/agent-readiness/src/evidence.js +0 -177
- package/dist/contracts/agent-readiness/src/evidence.js.map +0 -1
- package/dist/contracts/agent-readiness/src/interaction.d.ts +0 -26
- package/dist/contracts/agent-readiness/src/interaction.d.ts.map +0 -1
- package/dist/contracts/agent-readiness/src/interaction.js +0 -24
- package/dist/contracts/agent-readiness/src/interaction.js.map +0 -1
- package/dist/contracts/agent-readiness/src/method-pack.d.ts +0 -386
- package/dist/contracts/agent-readiness/src/method-pack.d.ts.map +0 -1
- package/dist/contracts/agent-readiness/src/method-pack.js +0 -181
- package/dist/contracts/agent-readiness/src/method-pack.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/current-policy-metrics.d.ts +0 -22
- package/dist/modules/agent-readiness-policy/src/current-policy-metrics.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/current-policy-metrics.js +0 -565
- package/dist/modules/agent-readiness-policy/src/current-policy-metrics.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/current-policy-standards.d.ts +0 -99
- package/dist/modules/agent-readiness-policy/src/current-policy-standards.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/current-policy-standards.js +0 -99
- package/dist/modules/agent-readiness-policy/src/current-policy-standards.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/current-policy-validation.d.ts +0 -4
- package/dist/modules/agent-readiness-policy/src/current-policy-validation.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/current-policy-validation.js +0 -11
- package/dist/modules/agent-readiness-policy/src/current-policy-validation.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/grading.d.ts +0 -39
- package/dist/modules/agent-readiness-policy/src/grading.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/grading.js +0 -40
- package/dist/modules/agent-readiness-policy/src/grading.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/policy-validation.d.ts +0 -3
- package/dist/modules/agent-readiness-policy/src/policy-validation.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/policy-validation.js +0 -39
- package/dist/modules/agent-readiness-policy/src/policy-validation.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/projection-lineage.d.ts +0 -3
- package/dist/modules/agent-readiness-policy/src/projection-lineage.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/projection-lineage.js +0 -12
- package/dist/modules/agent-readiness-policy/src/projection-lineage.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/standard-mapping.d.ts +0 -7
- package/dist/modules/agent-readiness-policy/src/standard-mapping.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/standard-mapping.js +0 -14
- package/dist/modules/agent-readiness-policy/src/standard-mapping.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/surface-selection.d.ts +0 -53
- package/dist/modules/agent-readiness-policy/src/surface-selection.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/surface-selection.js +0 -262
- package/dist/modules/agent-readiness-policy/src/surface-selection.js.map +0 -1
- package/dist/modules/agent-readiness-repository/src/admission.d.ts +0 -35
- package/dist/modules/agent-readiness-repository/src/admission.d.ts.map +0 -1
- package/dist/modules/agent-readiness-repository/src/admission.js +0 -56
- package/dist/modules/agent-readiness-repository/src/admission.js.map +0 -1
- package/dist/modules/authority/src/retained-capture-receipt.d.ts +0 -95
- package/dist/modules/authority/src/retained-capture-receipt.d.ts.map +0 -1
- package/dist/modules/authority/src/retained-capture-receipt.js +0 -76
- package/dist/modules/authority/src/retained-capture-receipt.js.map +0 -1
- package/dist/modules/catalog-admission/src/publication-recomposition.d.ts +0 -42
- package/dist/modules/catalog-admission/src/publication-recomposition.d.ts.map +0 -1
- package/dist/modules/catalog-admission/src/publication-recomposition.js +0 -163
- package/dist/modules/catalog-admission/src/publication-recomposition.js.map +0 -1
- package/dist/modules/evidence-comparison/src/values.d.ts +0 -75
- package/dist/modules/evidence-comparison/src/values.d.ts.map +0 -1
- package/dist/modules/evidence-comparison/src/values.js +0 -283
- package/dist/modules/evidence-comparison/src/values.js.map +0 -1
- package/dist/modules/evidence-grounding/src/figures.d.ts +0 -56
- package/dist/modules/evidence-grounding/src/figures.d.ts.map +0 -1
- package/dist/modules/evidence-grounding/src/figures.js +0 -727
- package/dist/modules/evidence-grounding/src/figures.js.map +0 -1
- package/dist/modules/evidence-grounding/src/index.d.ts +0 -4
- package/dist/modules/evidence-grounding/src/index.d.ts.map +0 -1
- package/dist/modules/evidence-grounding/src/index.js +0 -4
- package/dist/modules/evidence-grounding/src/index.js.map +0 -1
- package/dist/modules/evidence-grounding/src/locator.d.ts +0 -50
- package/dist/modules/evidence-grounding/src/locator.d.ts.map +0 -1
- package/dist/modules/evidence-grounding/src/locator.js +0 -162
- package/dist/modules/evidence-grounding/src/locator.js.map +0 -1
- package/dist/modules/evidence-grounding/src/written.d.ts +0 -29
- package/dist/modules/evidence-grounding/src/written.d.ts.map +0 -1
- package/dist/modules/evidence-grounding/src/written.js +0 -111
- package/dist/modules/evidence-grounding/src/written.js.map +0 -1
- package/dist/modules/evidence-operations/src/dependency-versions.d.ts +0 -2
- package/dist/modules/evidence-operations/src/dependency-versions.d.ts.map +0 -1
- package/dist/modules/evidence-operations/src/dependency-versions.js +0 -17
- package/dist/modules/evidence-operations/src/dependency-versions.js.map +0 -1
- package/dist/modules/evidence-operations/src/html-document.d.ts +0 -4
- package/dist/modules/evidence-operations/src/html-document.d.ts.map +0 -1
- package/dist/modules/evidence-operations/src/html-document.js +0 -99
- package/dist/modules/evidence-operations/src/html-document.js.map +0 -1
- package/dist/modules/policy-identity/src/index.d.ts +0 -7
- package/dist/modules/policy-identity/src/index.d.ts.map +0 -1
- package/dist/modules/policy-identity/src/index.js +0 -23
- package/dist/modules/policy-identity/src/index.js.map +0 -1
- package/dist/modules/release/src/publication-authorities.d.ts +0 -271
- package/dist/modules/release/src/publication-authorities.d.ts.map +0 -1
- package/dist/modules/release/src/publication-authorities.js +0 -56
- package/dist/modules/release/src/publication-authorities.js.map +0 -1
- package/dist/modules/standard-adapter-runtime/src/index.d.ts +0 -16
- package/dist/modules/standard-adapter-runtime/src/index.d.ts.map +0 -1
- package/dist/modules/standard-adapter-runtime/src/index.js +0 -43
- package/dist/modules/standard-adapter-runtime/src/index.js.map +0 -1
- package/dist/modules/standard-evidence/src/index.d.ts +0 -33
- package/dist/modules/standard-evidence/src/index.d.ts.map +0 -1
- package/dist/modules/standard-evidence/src/index.js +0 -149
- package/dist/modules/standard-evidence/src/index.js.map +0 -1
|
@@ -1,727 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The figures a passage writes, read by one strict grammar so that a value a
|
|
3
|
-
* reader reported can be checked against the passage it cited. The grammar
|
|
4
|
-
* reads amounts in US dollars, euros and pounds (`$`, `US$`, `€`, `£`) or an
|
|
5
|
-
* ISO code, percentages, periods, dates with their year and counts, written
|
|
6
|
-
* with comma thousands and point decimals, each on its own line. Everything
|
|
7
|
-
* else that looks like a figure (another number format, currency, scale word,
|
|
8
|
-
* fraction, range or rate, or a marker on the next line) is unread: it keeps
|
|
9
|
-
* its extent, so no quote can cut a figure out of it, but gives no token, and
|
|
10
|
-
* the text is incomplete. The detector of what is unread is deliberately
|
|
11
|
-
* broad: reading too little only leaves a value unchecked, never admits one.
|
|
12
|
-
* This parses written form; it never judges what a passage means.
|
|
13
|
-
*/
|
|
14
|
-
/** ISO 4217 minor-unit exponents other than two. */
|
|
15
|
-
const CURRENCY_EXPONENT = {
|
|
16
|
-
BHD: 3,
|
|
17
|
-
CLP: 0,
|
|
18
|
-
ISK: 0,
|
|
19
|
-
JOD: 3,
|
|
20
|
-
JPY: 0,
|
|
21
|
-
KRW: 0,
|
|
22
|
-
KWD: 3,
|
|
23
|
-
OMR: 3,
|
|
24
|
-
TND: 3,
|
|
25
|
-
VND: 0,
|
|
26
|
-
};
|
|
27
|
-
/** The symbols the grammar reads, each naming one currency. */
|
|
28
|
-
const SYMBOLS = { US$: "USD", $: "USD", "€": "EUR", "£": "GBP" };
|
|
29
|
-
/** ISO 4217 codes; a code that is also an English word never reads as money ("TOP 10"). */
|
|
30
|
-
const SUPPORTED_CURRENCIES = new Set(Intl.supportedValuesOf("currency"));
|
|
31
|
-
const WORD_CODES = new Set(["ALL", "BOB", "CUP", "GEL", "MAD", "MOP", "PEN", "SOS", "TOP", "TRY"]);
|
|
32
|
-
const MULTIPLIERS = {
|
|
33
|
-
k: 1_000,
|
|
34
|
-
K: 1_000,
|
|
35
|
-
M: 1_000_000,
|
|
36
|
-
B: 1_000_000_000,
|
|
37
|
-
bn: 1_000_000_000,
|
|
38
|
-
mn: 1_000_000,
|
|
39
|
-
thousand: 1_000,
|
|
40
|
-
million: 1_000_000,
|
|
41
|
-
billion: 1_000_000_000,
|
|
42
|
-
};
|
|
43
|
-
/** Glued letters read as a multiplier ("10k", "$1.5M"); the words may also stand one space apart. */
|
|
44
|
-
const MULTIPLIER = /^(?:(k|K|M|B|bn|mn)|[ \t]?(thousand|million|billion))(?![\p{L}\p{N}])/u;
|
|
45
|
-
const PERIOD_UNITS = {
|
|
46
|
-
day: "D",
|
|
47
|
-
days: "D",
|
|
48
|
-
week: "W",
|
|
49
|
-
weeks: "W",
|
|
50
|
-
month: "M",
|
|
51
|
-
months: "M",
|
|
52
|
-
mo: "M",
|
|
53
|
-
mos: "M",
|
|
54
|
-
year: "Y",
|
|
55
|
-
years: "Y",
|
|
56
|
-
yr: "Y",
|
|
57
|
-
yrs: "Y",
|
|
58
|
-
};
|
|
59
|
-
const UNIT = Object.keys(PERIOD_UNITS).join("|");
|
|
60
|
-
const PERIOD_AFTER = new RegExp(String.raw `^[ \t-]?(${UNIT})(?![\p{L}\p{N}])`, "iu");
|
|
61
|
-
const PERCENT_AFTER = /^[ \t]?(?:%|percent(?![\p{L}])|per[ \t]?cent(?![\p{L}]))/iu;
|
|
62
|
-
/**
|
|
63
|
-
* Words that can change what a figure beside them means, in any language: a
|
|
64
|
-
* currency, a scale, a letter currency, a nationality or a fraction the
|
|
65
|
-
* grammar does not read. Broad by design: one beside a figure leaves it
|
|
66
|
-
* unread, which can only leave a value unchecked.
|
|
67
|
-
*/
|
|
68
|
-
const MARKER_WORD = /^(?:dollars?|d[oó]lar(?:es)?|dollari?|euros?|pounds?|sterling|yen|yuan|renminbi|rmb|rs|rp|rm|rupees?|rupias?|rupiahs?|pesos?|reais|real|rand|won|ringgits?|baht|dong|liras?|lire|francs?|kron(?:a|e|or|er)|zlot(?:y|ys|ych)|forints?|korun(?:a|y)|shekels?|dirhams?|riyals?|nairas?|cedis?|shillings?|thousands|millions|billions|trillions?|lakhs?|lacs?|crores?|crs?|mil|mill|mln|mio|mrd|bln|tsd|millionen|milliarden|mill[oó]n(?:es)?|milh(?:ão|ões)|milion[ei]|milliards?|miliar|juta|ribu|тыс|млн|млрд|руб\p{L}*|canadian|australian|mexican|jamaican|canadien\p{L}*|australien\p{L}*|am[ée]ricain\p{L}*|estadounidense\p{L}*|canadiense\p{L}*|australian[oa]s?|mexican[oa]s?|americano\p{L}*|half|halves|quarters?|thirds?|[万萬億亿千百円元圆원만억천]|लाख|करोड़)$/iu;
|
|
69
|
-
/** Country prefixes that make a dollar sign another country's: "AU $", "$5,000 CDN". */
|
|
70
|
-
const COUNTRY_PREFIXES = new Set("US USA AU AUS CA CAN CDN NZ HK SG NT MX RD CN UK EU".split(" "));
|
|
71
|
-
const MONTHS = {
|
|
72
|
-
january: 1,
|
|
73
|
-
jan: 1,
|
|
74
|
-
february: 2,
|
|
75
|
-
feb: 2,
|
|
76
|
-
march: 3,
|
|
77
|
-
mar: 3,
|
|
78
|
-
april: 4,
|
|
79
|
-
apr: 4,
|
|
80
|
-
may: 5,
|
|
81
|
-
june: 6,
|
|
82
|
-
jun: 6,
|
|
83
|
-
july: 7,
|
|
84
|
-
jul: 7,
|
|
85
|
-
august: 8,
|
|
86
|
-
aug: 8,
|
|
87
|
-
september: 9,
|
|
88
|
-
sept: 9,
|
|
89
|
-
sep: 9,
|
|
90
|
-
october: 10,
|
|
91
|
-
oct: 10,
|
|
92
|
-
november: 11,
|
|
93
|
-
nov: 11,
|
|
94
|
-
december: 12,
|
|
95
|
-
dec: 12,
|
|
96
|
-
};
|
|
97
|
-
/** Figures written as words. */
|
|
98
|
-
const NUMBER_WORDS = {
|
|
99
|
-
zero: 0,
|
|
100
|
-
one: 1,
|
|
101
|
-
two: 2,
|
|
102
|
-
three: 3,
|
|
103
|
-
four: 4,
|
|
104
|
-
five: 5,
|
|
105
|
-
six: 6,
|
|
106
|
-
seven: 7,
|
|
107
|
-
eight: 8,
|
|
108
|
-
nine: 9,
|
|
109
|
-
ten: 10,
|
|
110
|
-
eleven: 11,
|
|
111
|
-
twelve: 12,
|
|
112
|
-
thirteen: 13,
|
|
113
|
-
fourteen: 14,
|
|
114
|
-
fifteen: 15,
|
|
115
|
-
sixteen: 16,
|
|
116
|
-
seventeen: 17,
|
|
117
|
-
eighteen: 18,
|
|
118
|
-
nineteen: 19,
|
|
119
|
-
twenty: 20,
|
|
120
|
-
thirty: 30,
|
|
121
|
-
forty: 40,
|
|
122
|
-
fifty: 50,
|
|
123
|
-
sixty: 60,
|
|
124
|
-
seventy: 70,
|
|
125
|
-
eighty: 80,
|
|
126
|
-
ninety: 90,
|
|
127
|
-
};
|
|
128
|
-
const SCALE_WORDS = {
|
|
129
|
-
hundred: 100,
|
|
130
|
-
thousand: 1_000,
|
|
131
|
-
million: 1_000_000,
|
|
132
|
-
billion: 1_000_000_000,
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Words that write a quantity the grammar does not value: a number word that
|
|
136
|
-
* is not one figure ("two three"), a magnitude, multiple, fraction or long
|
|
137
|
-
* period ("thousands", "twice", "half", "a dozen", "a decade"). "one" is left
|
|
138
|
-
* out, since it is prose far more often, and so is "third" ("third-party").
|
|
139
|
-
*/
|
|
140
|
-
const UNVALUED_WORDS = new Set([
|
|
141
|
-
...Object.keys(NUMBER_WORDS).filter((word) => word !== "one"),
|
|
142
|
-
...Object.keys(SCALE_WORDS),
|
|
143
|
-
...Object.keys(SCALE_WORDS).map((word) => `${word}s`),
|
|
144
|
-
..."tens half halves quarter quarters thirds double twice triple thrice quadruple dozen dozens".split(" "),
|
|
145
|
-
..."fortnight fortnights decade decades century centuries semester semesters biennium".split(" "),
|
|
146
|
-
]);
|
|
147
|
-
const longestFirst = (words) => [...words].sort((left, right) => right.length - left.length).join("|");
|
|
148
|
-
const NUMBER = /(?<![\p{N}])(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?)(?![\p{N}])/gu;
|
|
149
|
-
const WORD = longestFirst([...Object.keys(NUMBER_WORDS), ...Object.keys(SCALE_WORDS)]);
|
|
150
|
-
const SCALE = longestFirst(Object.keys(SCALE_WORDS));
|
|
151
|
-
// An article counts one only before a scale word ("a million"); "a six-month trial" is six.
|
|
152
|
-
const WORD_FIGURE = new RegExp(String.raw `(?<![\p{L}-])(?:an?[ \t-]+(?=(?:${SCALE})(?![\p{L}])))?(?:${WORD})(?:[ \t-]+(?:and[ \t-]+)?(?:${WORD}))*(?![\p{L}])`, "giu");
|
|
153
|
-
/** "a year", "an extra month" is not one: only an article or "first" right before a singular unit counts. */
|
|
154
|
-
const ARTICLE_PERIOD = /(?<![\p{L}-])(a|an|first)[ \t-]+(day|week|month|mo|year|yr)(?![\p{L}\p{N}])/giu;
|
|
155
|
-
const FRACTION = "half|halves|quarters?|thirds?";
|
|
156
|
-
const FRACTION_BEFORE = new RegExp(String.raw `(?<![\p{L}])(?:${FRACTION})\s+(?:(?:of|an?)\s+)*$`, "iu");
|
|
157
|
-
const FRACTION_AFTER = new RegExp(String.raw `^\s+and\s+(?:an?\s+)?(?:${FRACTION})(?![\p{L}-])`, "iu");
|
|
158
|
-
const UNVALUED_WORD = new RegExp(String.raw `(?<![\p{L}])(?:${longestFirst([...UNVALUED_WORDS])})(?![\p{L}])`, "giu");
|
|
159
|
-
// A period unit counted by no figure states a period the text does not value ("for months"),
|
|
160
|
-
// unless it names a rate ("per month", "/year").
|
|
161
|
-
const PERIOD_WORD = new RegExp(String.raw `(?<![\p{L}])((?:per|each|every)[ \t]+|\/[ \t]?)?(?:${UNIT})(?![\p{L}])`, "giu");
|
|
162
|
-
const HALF_PRICE = /(?<![\p{L}-])half[ \t-]+(?:price|priced|off)(?![\p{L}])/giu;
|
|
163
|
-
const MONTH = longestFirst(Object.keys(MONTHS));
|
|
164
|
-
const ORDINAL = "(?:st|nd|rd|th)?";
|
|
165
|
-
const ISO_DATE = /(?<![\p{N}-])(\d{4})-(\d{2})-(\d{2})(?![\p{N}])/gu;
|
|
166
|
-
const MONTH_FIRST_DATE = new RegExp(String.raw `(?<![\p{L}])(${MONTH})\.?[ \t]+(\d{1,2})${ORDINAL},?[ \t]+(\d{4})(?![\p{N}])`, "giu");
|
|
167
|
-
const DAY_FIRST_DATE = new RegExp(String.raw `(?<![\p{N}])(\d{1,2})${ORDINAL}[ \t]+(?:of[ \t]+)?(${MONTH})\.?,?[ \t]+(\d{4})(?![\p{N}])`, "giu");
|
|
168
|
-
/** What joins digits into one written figure the grammar reads whole or not at all. */
|
|
169
|
-
const JOINER = /[.,'’/⁄:-]/u;
|
|
170
|
-
/** What after a space continues the figure before it: a group of three digits, or a fraction. */
|
|
171
|
-
const SPACE_GROUP = /^(?:\d{3}(?!\d)|\d+[/⁄]\d)/u;
|
|
172
|
-
/** Superscript and subscript digits: footnote marks after words, part of a figure beside one. */
|
|
173
|
-
const MARK_DIGIT = /[²³¹⁰-⁹₀-₉]/u;
|
|
174
|
-
const OTHER_FRACTION = /[¼-¾⅐-⅞↉⁄]/u;
|
|
175
|
-
const UNREAD_MARK = "\u0000";
|
|
176
|
-
/** A frequency or fraction before an article makes "a year" a rate or a fraction: "once a year", "half a year". */
|
|
177
|
-
const BEFORE_ARTICLE = new RegExp(String.raw `(?:(?<![\p{L}])(once|twice|thrice|times|half|halves|quarters?|thirds?)|(${UNREAD_MARK}))\s+(?:of\s+)?$`, "iu");
|
|
178
|
-
const LETTER = /\p{L}/u;
|
|
179
|
-
const ALPHANUMERIC = /[\p{L}\p{N}]/u;
|
|
180
|
-
const DIGIT = /\p{N}/u;
|
|
181
|
-
/** Every numeric token written in `text`, in order of appearance. */
|
|
182
|
-
export function numericTokens(text) {
|
|
183
|
-
return writtenFigures(text).tokens;
|
|
184
|
-
}
|
|
185
|
-
/** Where every figure in `text` is written, in its own indexes, in order. */
|
|
186
|
-
export function figureSpans(text) {
|
|
187
|
-
return writtenFigures(text).spans;
|
|
188
|
-
}
|
|
189
|
-
/** The minor units of `major` whole units of `currency`. */
|
|
190
|
-
export function minorUnitsOf(currency, major) {
|
|
191
|
-
return Math.round(major * 10 ** (CURRENCY_EXPONENT[currency] ?? 2));
|
|
192
|
-
}
|
|
193
|
-
/** Periods compare by the months or days they denote, so P12M equals P1Y. */
|
|
194
|
-
export function periodsEqual(left, right) {
|
|
195
|
-
const a = periodLength(left);
|
|
196
|
-
const b = periodLength(right);
|
|
197
|
-
return a !== null && b !== null && a.unit === b.unit && a.value === b.value;
|
|
198
|
-
}
|
|
199
|
-
export function writtenFigures(text) {
|
|
200
|
-
const { source, origins } = foldedSource(text);
|
|
201
|
-
const figures = [];
|
|
202
|
-
const identifiers = [];
|
|
203
|
-
const read = new Uint8Array(source.length + 1);
|
|
204
|
-
const figure = (at, end, token) => {
|
|
205
|
-
figures.push({ at, end, token });
|
|
206
|
-
read.fill(1, at, end);
|
|
207
|
-
};
|
|
208
|
-
const name = (at, from) => {
|
|
209
|
-
let end = from;
|
|
210
|
-
while (end < source.length && ALPHANUMERIC.test(source[end]))
|
|
211
|
-
end += 1;
|
|
212
|
-
identifiers.push({ at, end, text: source.slice(at, end) });
|
|
213
|
-
read.fill(1, at, end);
|
|
214
|
-
return end;
|
|
215
|
-
};
|
|
216
|
-
for (const date of writtenDates(source))
|
|
217
|
-
figure(date.at, date.end, date.token);
|
|
218
|
-
for (const match of source.matchAll(NUMBER)) {
|
|
219
|
-
const start = match.index ?? 0;
|
|
220
|
-
const end = start + match[0].length;
|
|
221
|
-
if (read[start] === 1)
|
|
222
|
-
continue;
|
|
223
|
-
let lettersStart = start;
|
|
224
|
-
while (lettersStart > 0 && LETTER.test(source[lettersStart - 1]))
|
|
225
|
-
lettersStart -= 1;
|
|
226
|
-
const letters = source.slice(lettersStart, start);
|
|
227
|
-
if (letters && !isCurrencyCode(letters)) {
|
|
228
|
-
// Digits glued to letters that name no currency are part of a name: "H100", "Q3", "A320".
|
|
229
|
-
name(lettersStart, end);
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
const run = figureRun(source, start, end);
|
|
233
|
-
if (run.at < start || run.end > end) {
|
|
234
|
-
// The figure goes on past what the grammar reads ("1/2", "5.000", "20,00,000"): unread.
|
|
235
|
-
figure(run.at, run.end, null);
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
const reading = readFigure(source, start, end, match[0]);
|
|
239
|
-
if (reading === "name") {
|
|
240
|
-
name(start, end);
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
figure(reading.at, reading.end, reading.token);
|
|
244
|
-
}
|
|
245
|
-
for (const match of source.matchAll(WORD_FIGURE)) {
|
|
246
|
-
for (const segment of wordSegments(match[0], match.index ?? 0)) {
|
|
247
|
-
if (read[segment.start] === 1)
|
|
248
|
-
continue;
|
|
249
|
-
const value = wordNumber(segment.words);
|
|
250
|
-
if (value === null)
|
|
251
|
-
continue;
|
|
252
|
-
const scaled = segment.words.some((word) => SCALE_WORDS[word] !== undefined);
|
|
253
|
-
const unit = unitAfter(source, segment.start, segment.end, value, scaled);
|
|
254
|
-
if (unit !== "name" && (scaled || unit.token?.kind !== "number" || unit.end > segment.end)) {
|
|
255
|
-
figure(unit.at, unit.end, unit.token);
|
|
256
|
-
}
|
|
257
|
-
else if (!(segment.words.length === 1 && segment.words[0] === "one")) {
|
|
258
|
-
// A counted quantity ("seven providers") is a number; "one of our partners" is prose.
|
|
259
|
-
figure(segment.start, segment.end, { kind: "number", value });
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
for (const match of source.matchAll(HALF_PRICE)) {
|
|
264
|
-
const at = match.index ?? 0;
|
|
265
|
-
figure(at, at + match[0].length, { kind: "percentage", basisPoints: 5_000 });
|
|
266
|
-
}
|
|
267
|
-
const rates = articlePeriods(source, figures, figure);
|
|
268
|
-
unreadFractions(source, figures);
|
|
269
|
-
unreadRanges(source, figures);
|
|
270
|
-
// A digit no figure, date or name read is unread, with the whole figure it is written in.
|
|
271
|
-
for (let index = 0; index < source.length; index += 1) {
|
|
272
|
-
if (read[index] === 1 || !DIGIT.test(source[index]))
|
|
273
|
-
continue;
|
|
274
|
-
const run = figureRun(source, index, index + 1);
|
|
275
|
-
figure(run.at, run.end, null);
|
|
276
|
-
}
|
|
277
|
-
const tokens = figures
|
|
278
|
-
.filter((candidate) => candidate.token !== null)
|
|
279
|
-
.sort((left, right) => left.at - right.at);
|
|
280
|
-
let complete = tokens.length === figures.length && !source.includes(UNREAD_MARK);
|
|
281
|
-
const covered = new Uint8Array(source.length + 1);
|
|
282
|
-
for (const { at, end } of [...tokens, ...rates])
|
|
283
|
-
covered.fill(1, at, end);
|
|
284
|
-
for (const match of source.matchAll(UNVALUED_WORD)) {
|
|
285
|
-
if (covered[match.index ?? 0] !== 1)
|
|
286
|
-
complete = false;
|
|
287
|
-
}
|
|
288
|
-
for (const match of source.matchAll(PERIOD_WORD)) {
|
|
289
|
-
if (match[1] === undefined && covered[match.index ?? 0] !== 1)
|
|
290
|
-
complete = false;
|
|
291
|
-
}
|
|
292
|
-
return {
|
|
293
|
-
tokens: tokens.map(({ token }) => token),
|
|
294
|
-
identifiers: identifiers.map(({ text: identifier }) => identifier),
|
|
295
|
-
complete,
|
|
296
|
-
spans: [...figures, ...rates, ...identifiers]
|
|
297
|
-
.map(({ at, end }) => ({ start: origins[at], end: origins[end] }))
|
|
298
|
-
.sort((left, right) => left.start - right.start || left.end - right.end),
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* The figure written from `[start, end)` with its markers and unit, or
|
|
303
|
-
* "name" when letters glued after it make it part of one ("5G", "10x").
|
|
304
|
-
*/
|
|
305
|
-
function readFigure(source, start, end, written) {
|
|
306
|
-
// A point before exactly three digits groups thousands in some locales ("5.000 €") and ends a
|
|
307
|
-
// decimal in others ("$1.008"); a figure starting after a point continues one ("Rs.5", ".5").
|
|
308
|
-
const unreadable = /^\d+\.\d{3}$/u.test(written) || source[start - 1] === ".";
|
|
309
|
-
const multiplier = MULTIPLIER.exec(source.slice(end, end + 12));
|
|
310
|
-
const numberEnd = end + (multiplier?.[0].length ?? 0);
|
|
311
|
-
const factor = multiplier ? (MULTIPLIERS[multiplier[1] ?? multiplier[2] ?? ""] ?? 1) : 1;
|
|
312
|
-
const value = Number(written.replaceAll(",", "")) * factor;
|
|
313
|
-
const unit = unitAfter(source, start, numberEnd, value, multiplier !== null);
|
|
314
|
-
if (unit === "name")
|
|
315
|
-
return "name";
|
|
316
|
-
// An unread figure after a point keeps the point in its extent, so no quote takes "5%" from ".5%".
|
|
317
|
-
const at = source[start - 1] === "." ? Math.min(unit.at, start - 1) : unit.at;
|
|
318
|
-
return unreadable || !Number.isFinite(value) ? { ...unit, at, token: null } : unit;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* The token a figure of `value` at `[start, end)` writes with the markers on
|
|
322
|
-
* its own line: a percent sign, a currency before or after it, or a period
|
|
323
|
-
* unit. Its extent grows over every marker read. The figure is unread when a
|
|
324
|
-
* marker it does not read stands beside it, on its line or at the edge of the
|
|
325
|
-
* next line, or its value is finer than its unit counts.
|
|
326
|
-
*/
|
|
327
|
-
function unitAfter(source, start, end, value, scaled) {
|
|
328
|
-
const after = source.slice(end, end + 48);
|
|
329
|
-
const before = source.slice(Math.max(0, start - 24), start);
|
|
330
|
-
const unread = (extent) => ({ ...extent, token: null });
|
|
331
|
-
const percent = PERCENT_AFTER.exec(after);
|
|
332
|
-
const prefix = currencyBefore(before);
|
|
333
|
-
const suffix = currencyAfter(after);
|
|
334
|
-
const period = PERIOD_AFTER.exec(after);
|
|
335
|
-
// Letters glued after a figure that no unit reads make it part of a name: "5G", "10x".
|
|
336
|
-
if (!percent && !suffix && !period && LETTER.test(after[0] ?? ""))
|
|
337
|
-
return "name";
|
|
338
|
-
if (percent) {
|
|
339
|
-
const stop = end + percent[0].length;
|
|
340
|
-
const basisPoints = wholeCount(value * 100);
|
|
341
|
-
const widened = beside(source, start, stop);
|
|
342
|
-
return scaled || basisPoints === null || widened
|
|
343
|
-
? unread(widened ?? { at: start, end: stop })
|
|
344
|
-
: { at: start, end: stop, token: { kind: "percentage", basisPoints } };
|
|
345
|
-
}
|
|
346
|
-
if (prefix || suffix) {
|
|
347
|
-
const at = start - (prefix?.length ?? 0);
|
|
348
|
-
const stop = end + (suffix?.length ?? 0);
|
|
349
|
-
// Every marker must name the one currency: "USD $5,000" is dollars, "$5,000 CAD" is unread,
|
|
350
|
-
// and so is an amount that a period unit also claims ("USD 14 DAYS").
|
|
351
|
-
const named = [prefix, suffix].flatMap((marker) => (marker ? [marker.currency] : []));
|
|
352
|
-
const currency = named.every((candidate) => candidate === named[0]) ? named[0] : null;
|
|
353
|
-
const minorUnits = currency
|
|
354
|
-
? wholeCount(value * 10 ** (CURRENCY_EXPONENT[currency] ?? 2))
|
|
355
|
-
: null;
|
|
356
|
-
const claimed = suffix ? null : period;
|
|
357
|
-
const widened = beside(source, at, stop + (claimed?.[0].length ?? 0));
|
|
358
|
-
return !currency || minorUnits === null || claimed || widened
|
|
359
|
-
? unread(widened ?? { at, end: stop + (claimed?.[0].length ?? 0) })
|
|
360
|
-
: { at, end: stop, token: { kind: "money", currency, minorUnits } };
|
|
361
|
-
}
|
|
362
|
-
if (period) {
|
|
363
|
-
const stop = end + period[0].length;
|
|
364
|
-
const unit = PERIOD_UNITS[(period[1] ?? "").toLowerCase()];
|
|
365
|
-
const widened = beside(source, start, stop);
|
|
366
|
-
return scaled || !unit || !Number.isInteger(value) || widened
|
|
367
|
-
? unread(widened ?? { at: start, end: stop })
|
|
368
|
-
: { at: start, end: stop, token: { kind: "period", iso: `P${value}${unit}` } };
|
|
369
|
-
}
|
|
370
|
-
const widened = beside(source, start, end);
|
|
371
|
-
return widened ? unread(widened) : { at: start, end, token: { kind: "number", value } };
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* The figure at `[at, end)` widened over what the grammar does not read
|
|
375
|
-
* beside it, or null when nothing stands there. It looks on the figure's own
|
|
376
|
-
* line and at the edge of the next line or the line before, where an inline
|
|
377
|
-
* tag may have split a marker off: a code, country prefix, currency, scale or
|
|
378
|
-
* fraction word, another currency sign or an unreadable fraction, and across
|
|
379
|
-
* a line break also a unit, a percent sign, a multiplier or the rest of a
|
|
380
|
-
* decimal ("$29" / ".99"). The widened extent keeps any quote from taking the
|
|
381
|
-
* figure without it.
|
|
382
|
-
*/
|
|
383
|
-
function beside(source, at, end) {
|
|
384
|
-
let widened = null;
|
|
385
|
-
const gapAfter = /^[ \t]*(?:\n[ \t]*)?/u.exec(source.slice(end, end + 64))?.[0] ?? "";
|
|
386
|
-
const next = source.slice(end + gapAfter.length, end + gapAfter.length + 32);
|
|
387
|
-
const opened = next.startsWith("(") ? 1 : 0;
|
|
388
|
-
const following = (next[opened] === UNREAD_MARK ? 1 : 0) ||
|
|
389
|
-
markerLength(next.slice(opened)) ||
|
|
390
|
-
(gapAfter === " " ? (/^[kmbl](?![\p{L}])/iu.exec(next)?.[0].length ?? 0) : 0) ||
|
|
391
|
-
(gapAfter.includes("\n")
|
|
392
|
-
? ((PERIOD_AFTER.exec(next) ??
|
|
393
|
-
PERCENT_AFTER.exec(next) ??
|
|
394
|
-
MULTIPLIER.exec(next) ??
|
|
395
|
-
/^[.,]\p{N}+/u.exec(next))?.[0].length ?? 0)
|
|
396
|
-
: 0);
|
|
397
|
-
if (following > 0)
|
|
398
|
-
widened = { at, end: end + gapAfter.length + opened + following };
|
|
399
|
-
const head = source.slice(Math.max(0, at - 32), at);
|
|
400
|
-
const gapBefore = /(?:[ \t]*\n)?[ \t]*$/u.exec(head)?.[0] ?? "";
|
|
401
|
-
const previous = head.slice(0, head.length - gapBefore.length);
|
|
402
|
-
const token = previous.endsWith(UNREAD_MARK)
|
|
403
|
-
? UNREAD_MARK
|
|
404
|
-
: /(?:[\p{L}\p{M}]*\p{Sc}|[\p{L}\p{M}]+|[万萬億亿千百円元圆원만억천])\)?:?$/u.exec(previous)?.[0];
|
|
405
|
-
const bare = token?.replace(/[():]/gu, "");
|
|
406
|
-
// A sign glued before a figure, with any letters glued to it, is a compound the grammar does
|
|
407
|
-
// not read ("CA$5,000", "R$5").
|
|
408
|
-
if (bare &&
|
|
409
|
-
(bare === UNREAD_MARK || /\p{Sc}/u.test(bare) || markerLength(bare) === bare.length)) {
|
|
410
|
-
widened = {
|
|
411
|
-
at: at - gapBefore.length - (token?.length ?? 0),
|
|
412
|
-
end: widened?.end ?? end,
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
return widened;
|
|
416
|
-
}
|
|
417
|
-
/** The length of the word or sign starting `text` that can change a figure beside it, or 0. */
|
|
418
|
-
function markerLength(text) {
|
|
419
|
-
if (/^\p{Sc}(?![ \t]?\p{N})/u.test(text))
|
|
420
|
-
return 1;
|
|
421
|
-
const code = /^([A-Z]{2,3})(?![\p{L}])/u.exec(text)?.[1];
|
|
422
|
-
if (code)
|
|
423
|
-
return COUNTRY_PREFIXES.has(code) || isCurrencyCode(code) ? code.length : 0;
|
|
424
|
-
const word = /^(?:[\p{L}\p{M}]+|[万萬億亿千百円元圆원만억천])/u.exec(text)?.[0];
|
|
425
|
-
return word !== undefined && MARKER_WORD.test(word) ? word.length : 0;
|
|
426
|
-
}
|
|
427
|
-
function isCurrencyCode(letters) {
|
|
428
|
-
return (/^[A-Z]{3}$/u.test(letters) && SUPPORTED_CURRENCIES.has(letters) && !WORD_CODES.has(letters));
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* The currency written directly before a figure on its line: a read symbol,
|
|
432
|
-
* a code, or a code and a symbol. A word before a symbol that is no code is
|
|
433
|
-
* prose ("AWS $5,000").
|
|
434
|
-
*/
|
|
435
|
-
function currencyBefore(before) {
|
|
436
|
-
const symbol = /(?<![\p{L}\p{N}\p{Sc}])(US\$|[$€£])[ \t]?$/u.exec(before);
|
|
437
|
-
const rest = symbol ? before.slice(0, before.length - symbol[0].length) : before;
|
|
438
|
-
const code = /(?<![\p{L}\p{N}])([A-Z]{3})[ \t]?$/u.exec(rest);
|
|
439
|
-
const coded = code && isCurrencyCode(code[1]) ? code : null;
|
|
440
|
-
if (!symbol && !coded)
|
|
441
|
-
return null;
|
|
442
|
-
const named = symbol ? (SYMBOLS[symbol[1]] ?? null) : null;
|
|
443
|
-
const currency = coded?.[1] ?? named;
|
|
444
|
-
return {
|
|
445
|
-
currency: coded && named && coded[1] !== named ? null : currency,
|
|
446
|
-
length: (symbol?.[0].length ?? 0) + (coded?.[0].length ?? 0),
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
/** The currency written directly after a figure on its line: a code, "(code)", or a euro or pound sign. */
|
|
450
|
-
function currencyAfter(after) {
|
|
451
|
-
const marker = /^[ \t]?(?:(\(?)([A-Z]{3})(\)?)(?![\p{L}])|([€£]))/u.exec(after);
|
|
452
|
-
if (!marker)
|
|
453
|
-
return null;
|
|
454
|
-
const [written, open, code, close, symbol] = marker;
|
|
455
|
-
if (code) {
|
|
456
|
-
return isCurrencyCode(code) && (open === "") === (close === "")
|
|
457
|
-
? { currency: code, length: written.length }
|
|
458
|
-
: null;
|
|
459
|
-
}
|
|
460
|
-
return { currency: SYMBOLS[symbol] ?? null, length: written.length };
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* `scaled` as the whole count it writes, or null when the figure is written
|
|
464
|
-
* finer than its unit counts ("$0.0035", "0.125%").
|
|
465
|
-
*/
|
|
466
|
-
function wholeCount(scaled) {
|
|
467
|
-
const count = Math.round(scaled);
|
|
468
|
-
return Math.abs(scaled - count) < 1e-6 ? count : null;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* The whole written figure around the digits at `[start, end)`: every digit
|
|
472
|
-
* joined to them by a separator, slash, colon or hyphen, or by a space
|
|
473
|
-
* before a group of exactly three digits ("10 000") or a fraction ("1 1/2").
|
|
474
|
-
*/
|
|
475
|
-
function figureRun(source, start, end) {
|
|
476
|
-
const joins = (index) => DIGIT.test(source[index - 1] ?? "") &&
|
|
477
|
-
(JOINER.test(source[index] ?? "")
|
|
478
|
-
? DIGIT.test(source[index + 1] ?? "")
|
|
479
|
-
: source[index] === " " && SPACE_GROUP.test(source.slice(index + 1, index + 8)));
|
|
480
|
-
let at = start;
|
|
481
|
-
while (DIGIT.test(source[at - 1] ?? ""))
|
|
482
|
-
at -= 1;
|
|
483
|
-
while (joins(at - 1)) {
|
|
484
|
-
at -= 1;
|
|
485
|
-
while (DIGIT.test(source[at - 1] ?? ""))
|
|
486
|
-
at -= 1;
|
|
487
|
-
}
|
|
488
|
-
let stop = end;
|
|
489
|
-
while (DIGIT.test(source[stop] ?? ""))
|
|
490
|
-
stop += 1;
|
|
491
|
-
while (joins(stop)) {
|
|
492
|
-
stop += 1;
|
|
493
|
-
while (DIGIT.test(source[stop] ?? ""))
|
|
494
|
-
stop += 1;
|
|
495
|
-
}
|
|
496
|
-
return { at, end: stop };
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* "a", "an" and "first" count one period ("a year", "your first month"). A
|
|
500
|
-
* figure, frequency or fraction right before them, even across a line break,
|
|
501
|
-
* makes "a month" a rate ("$100 a month", "once a year") or a fraction ("½ a
|
|
502
|
-
* year"): an amount keeps its token and takes the rate into its extent, a
|
|
503
|
-
* bare figure is unread with it, and a frequency's rate is returned so its
|
|
504
|
-
* unit counts as read.
|
|
505
|
-
*/
|
|
506
|
-
function articlePeriods(source, figures, figure) {
|
|
507
|
-
const rates = [];
|
|
508
|
-
const endingAt = new Map(figures.map((candidate) => [candidate.end, candidate]));
|
|
509
|
-
for (const match of source.matchAll(ARTICLE_PERIOD)) {
|
|
510
|
-
const at = match.index ?? 0;
|
|
511
|
-
const end = at + match[0].length;
|
|
512
|
-
const head = source.slice(Math.max(0, at - 16), at);
|
|
513
|
-
const gap = /\s+(?:of\s+)?$/iu.exec(head)?.[0].length ?? 0;
|
|
514
|
-
const figureBefore = gap > 0 ? endingAt.get(at - gap) : undefined;
|
|
515
|
-
if (figureBefore) {
|
|
516
|
-
// An amount's rate joins its extent; a bare figure before "a year" is a fraction of it.
|
|
517
|
-
if (figureBefore.token === null || figureBefore.token.kind === "number") {
|
|
518
|
-
figureBefore.token = null;
|
|
519
|
-
}
|
|
520
|
-
figureBefore.end = end;
|
|
521
|
-
continue;
|
|
522
|
-
}
|
|
523
|
-
const lead = BEFORE_ARTICLE.exec(head);
|
|
524
|
-
if (lead) {
|
|
525
|
-
if (/^(?:once|twice|thrice|times)/iu.test(lead[1] ?? ""))
|
|
526
|
-
rates.push({ at, end });
|
|
527
|
-
else
|
|
528
|
-
figure(at - lead[0].length, end, null);
|
|
529
|
-
continue;
|
|
530
|
-
}
|
|
531
|
-
const unit = PERIOD_UNITS[(match[2] ?? "").toLowerCase()];
|
|
532
|
-
if (unit)
|
|
533
|
-
figure(at, end, { kind: "period", iso: `P1${unit}` });
|
|
534
|
-
}
|
|
535
|
-
return rates;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* A fraction word beside a figure changes its value ("half a year", "a year
|
|
539
|
-
* and a half", "5 and a half years", "a quarter of a million"), so the
|
|
540
|
-
* figure is unread, with the words in its extent.
|
|
541
|
-
*/
|
|
542
|
-
function unreadFractions(source, figures) {
|
|
543
|
-
for (const candidate of figures) {
|
|
544
|
-
const before = FRACTION_BEFORE.exec(source.slice(Math.max(0, candidate.at - 24), candidate.at));
|
|
545
|
-
const after = FRACTION_AFTER.exec(source.slice(candidate.end, candidate.end + 24));
|
|
546
|
-
if (!before && !after)
|
|
547
|
-
continue;
|
|
548
|
-
candidate.token = null;
|
|
549
|
-
candidate.at -= before?.[0].length ?? 0;
|
|
550
|
-
candidate.end += after?.[0].length ?? 0;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Two figures joined by a range ("5-10k", "$1 to $5 million", "between $1
|
|
555
|
-
* and $5 million") share what only one of them writes, so both are unread,
|
|
556
|
-
* as one extent.
|
|
557
|
-
*/
|
|
558
|
-
function unreadRanges(source, figures) {
|
|
559
|
-
figures.sort((left, right) => left.at - right.at || left.end - right.end);
|
|
560
|
-
for (let index = 1; index < figures.length; index += 1) {
|
|
561
|
-
const low = figures[index - 1];
|
|
562
|
-
const high = figures[index];
|
|
563
|
-
if (low.end > high.at)
|
|
564
|
-
continue;
|
|
565
|
-
const joiner = source.slice(low.end, high.at);
|
|
566
|
-
const between = /(?<![\p{L}])between\s+$/iu.test(source.slice(Math.max(0, low.at - 12), low.at));
|
|
567
|
-
if (!/^\s*(?:\p{Pd}|to|through|and)\s*$/iu.test(joiner))
|
|
568
|
-
continue;
|
|
569
|
-
if (/and/iu.test(joiner) && !between)
|
|
570
|
-
continue;
|
|
571
|
-
low.token = null;
|
|
572
|
-
high.token = null;
|
|
573
|
-
low.end = high.end;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* The text as the tokenizer reads it, one code point at a time under
|
|
578
|
-
* compatibility folding (so full-width digits and no-break spaces read as
|
|
579
|
-
* their plain forms), and the index in the original text of every character
|
|
580
|
-
* read. A superscript or subscript digit after a word is a footnote mark and
|
|
581
|
-
* reads as a space; beside a figure or a fraction slash it is part of that
|
|
582
|
-
* figure ("$4⁹⁹", "¹⁄₂") and, like every fraction character, unreadable.
|
|
583
|
-
*/
|
|
584
|
-
function foldedSource(text) {
|
|
585
|
-
const parts = [];
|
|
586
|
-
const origins = [];
|
|
587
|
-
let last = "";
|
|
588
|
-
for (let index = 0; index < text.length;) {
|
|
589
|
-
const character = String.fromCodePoint(text.codePointAt(index));
|
|
590
|
-
const following = String.fromCodePoint(text.codePointAt(index + character.length) ?? 32);
|
|
591
|
-
const folded = MARK_DIGIT.test(character)
|
|
592
|
-
? DIGIT.test(last) ||
|
|
593
|
-
OTHER_FRACTION.test(last) ||
|
|
594
|
-
last === UNREAD_MARK ||
|
|
595
|
-
OTHER_FRACTION.test(following)
|
|
596
|
-
? UNREAD_MARK
|
|
597
|
-
: " "
|
|
598
|
-
: OTHER_FRACTION.test(character)
|
|
599
|
-
? UNREAD_MARK
|
|
600
|
-
: character.normalize("NFKC");
|
|
601
|
-
for (let unit = 0; unit < folded.length; unit += 1)
|
|
602
|
-
origins.push(index);
|
|
603
|
-
parts.push(folded);
|
|
604
|
-
last = folded.at(-1) ?? last;
|
|
605
|
-
index += character.length;
|
|
606
|
-
}
|
|
607
|
-
origins.push(text.length);
|
|
608
|
-
return { source: parts.join(""), origins: Uint32Array.from(origins) };
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Calendar dates written with their year, in ISO, month-first and day-first
|
|
612
|
-
* forms, as tokens. A numeric date in any other form ("05/06/2026",
|
|
613
|
-
* "31-12-2026") is not read: its digits are unread as one figure.
|
|
614
|
-
*/
|
|
615
|
-
function writtenDates(source) {
|
|
616
|
-
const dates = [];
|
|
617
|
-
const add = (match, year, month, day) => {
|
|
618
|
-
const iso = month === undefined ? null : calendarDate(year, month, day);
|
|
619
|
-
const at = match.index ?? 0;
|
|
620
|
-
if (iso)
|
|
621
|
-
dates.push({ at, end: at + match[0].length, token: { kind: "date", iso } });
|
|
622
|
-
};
|
|
623
|
-
for (const match of source.matchAll(ISO_DATE)) {
|
|
624
|
-
add(match, Number(match[1]), Number(match[2]), Number(match[3]));
|
|
625
|
-
}
|
|
626
|
-
for (const match of source.matchAll(MONTH_FIRST_DATE)) {
|
|
627
|
-
add(match, Number(match[3]), MONTHS[(match[1] ?? "").toLowerCase()], Number(match[2]));
|
|
628
|
-
}
|
|
629
|
-
for (const match of source.matchAll(DAY_FIRST_DATE)) {
|
|
630
|
-
add(match, Number(match[3]), MONTHS[(match[2] ?? "").toLowerCase()], Number(match[1]));
|
|
631
|
-
}
|
|
632
|
-
return dates;
|
|
633
|
-
}
|
|
634
|
-
function calendarDate(year, month, day) {
|
|
635
|
-
const date = new Date(Date.UTC(year, month - 1, day));
|
|
636
|
-
if (date.getUTCFullYear() !== year ||
|
|
637
|
-
date.getUTCMonth() !== month - 1 ||
|
|
638
|
-
date.getUTCDate() !== day) {
|
|
639
|
-
return null;
|
|
640
|
-
}
|
|
641
|
-
return date.toISOString().slice(0, 10);
|
|
642
|
-
}
|
|
643
|
-
/** A written figure's words split into figures: "one and three years" is two, "one hundred and five" one. */
|
|
644
|
-
function wordSegments(written, offset) {
|
|
645
|
-
const segments = [];
|
|
646
|
-
let current;
|
|
647
|
-
for (const match of written.matchAll(/[a-z]+/giu)) {
|
|
648
|
-
const word = (match[0] ?? "").toLowerCase();
|
|
649
|
-
const start = offset + (match.index ?? 0);
|
|
650
|
-
const end = start + word.length;
|
|
651
|
-
const previous = current?.words.at(-1);
|
|
652
|
-
if (word === "and" && (previous === undefined || SCALE_WORDS[previous] === undefined)) {
|
|
653
|
-
if (current)
|
|
654
|
-
segments.push(current);
|
|
655
|
-
current = undefined;
|
|
656
|
-
continue;
|
|
657
|
-
}
|
|
658
|
-
current ??= { words: [], start, end };
|
|
659
|
-
current.words.push(word);
|
|
660
|
-
current.end = end;
|
|
661
|
-
}
|
|
662
|
-
if (current)
|
|
663
|
-
segments.push(current);
|
|
664
|
-
return segments;
|
|
665
|
-
}
|
|
666
|
-
/** The value of a figure written in words, or null when the words are not one figure. */
|
|
667
|
-
function wordNumber(words) {
|
|
668
|
-
let total = 0;
|
|
669
|
-
let current = 0;
|
|
670
|
-
let last = null;
|
|
671
|
-
for (const word of words) {
|
|
672
|
-
if (word === "and") {
|
|
673
|
-
if (last !== "hundred" && last !== "scale")
|
|
674
|
-
return null;
|
|
675
|
-
continue;
|
|
676
|
-
}
|
|
677
|
-
if (word === "a" || word === "an") {
|
|
678
|
-
if (last !== null)
|
|
679
|
-
return null;
|
|
680
|
-
current = 1;
|
|
681
|
-
last = "article";
|
|
682
|
-
continue;
|
|
683
|
-
}
|
|
684
|
-
const scale = SCALE_WORDS[word];
|
|
685
|
-
if (scale !== undefined) {
|
|
686
|
-
if (current === 0)
|
|
687
|
-
return null;
|
|
688
|
-
if (scale === 100) {
|
|
689
|
-
if (current >= 100)
|
|
690
|
-
return null;
|
|
691
|
-
current *= 100;
|
|
692
|
-
last = "hundred";
|
|
693
|
-
}
|
|
694
|
-
else {
|
|
695
|
-
total += current * scale;
|
|
696
|
-
current = 0;
|
|
697
|
-
last = "scale";
|
|
698
|
-
}
|
|
699
|
-
continue;
|
|
700
|
-
}
|
|
701
|
-
const value = NUMBER_WORDS[word];
|
|
702
|
-
if (value === undefined || last === "article" || last === "unit")
|
|
703
|
-
return null;
|
|
704
|
-
if (last === "tens" && (value >= 10 || value === 0))
|
|
705
|
-
return null;
|
|
706
|
-
current += value;
|
|
707
|
-
last = value >= 20 ? "tens" : "unit";
|
|
708
|
-
}
|
|
709
|
-
return last === "article" ? null : total + current;
|
|
710
|
-
}
|
|
711
|
-
function periodLength(iso) {
|
|
712
|
-
const match = /^P(\d+(?:\.\d+)?)([DWMY])$/u.exec(iso);
|
|
713
|
-
if (!match)
|
|
714
|
-
return null;
|
|
715
|
-
const count = Number(match[1]);
|
|
716
|
-
switch (match[2]) {
|
|
717
|
-
case "Y":
|
|
718
|
-
return { unit: "months", value: count * 12 };
|
|
719
|
-
case "M":
|
|
720
|
-
return { unit: "months", value: count };
|
|
721
|
-
case "W":
|
|
722
|
-
return { unit: "days", value: count * 7 };
|
|
723
|
-
default:
|
|
724
|
-
return { unit: "days", value: count };
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
//# sourceMappingURL=figures.js.map
|