@mailwoman/core 11.2.0 → 11.4.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 +2 -2
- package/lib/api/ckan.ts +1 -1
- package/lib/api/disk-storage.ts +2 -2
- package/lib/api/ogc.ts +1 -1
- package/lib/api/retry.ts +7 -2
- package/lib/api/test/transport.ts +1 -1
- package/lib/{binary-frame.ts → asset/binary-frame.ts} +1 -1
- package/lib/async/abort.ts +100 -0
- package/lib/{memoize.ts → async/memoize.ts} +2 -2
- package/lib/{promises.ts → async/promises.ts} +1 -1
- package/lib/cloudflare/tokens.ts +1 -1
- package/lib/cloudflare/wrangler.ts +3 -3
- package/lib/crypto/digest.ts +1 -1
- package/lib/crypto/ed25519.ts +8 -0
- package/lib/{hash.ts → crypto/hash.ts} +16 -1
- package/lib/crypto/node.ts +1 -1
- package/lib/data-root.ts +16 -3
- package/lib/decoder/containment.ts +4 -1
- package/lib/decoder/serialize/outline.ts +19 -6
- package/lib/decoder/types.ts +9 -1
- package/lib/env/schema.ts +5 -0
- package/lib/fs/deflate64.ts +1 -1
- package/lib/fs/lock.ts +183 -25
- package/lib/fs/readers.ts +1 -1
- package/lib/fs/writers.ts +18 -1
- package/lib/geocode/result.ts +50 -6
- package/lib/html/text.ts +2 -2
- package/lib/index.ts +0 -1
- package/lib/layers/artifact.ts +2 -2
- package/lib/layers/coverage.ts +1 -1
- package/lib/layers/manifest.ts +94 -2
- package/lib/layers/provenance.ts +246 -0
- package/lib/layers/publication.ts +4 -3
- package/lib/layers/selection.ts +2 -2
- package/lib/license/branch.ts +66 -0
- package/lib/license/configured.ts +4 -2
- package/lib/license/declaration.ts +1 -1
- package/lib/license/key/file.ts +1 -1
- package/lib/license/key.ts +148 -201
- package/lib/license/provenance.ts +193 -0
- package/lib/license/register.ts +7 -78
- package/lib/license/stamp.ts +8 -2
- package/lib/license/text-url.ts +55 -0
- package/lib/license/training.ts +67 -0
- package/lib/license.ts +7 -6
- package/lib/locale/registry.ts +1 -1
- package/lib/locale/zh-cn-units.ts +1 -1
- package/lib/module/workspace.ts +1 -1
- package/lib/{routing.ts → network/routing.ts} +1 -1
- package/lib/pipeline/result.ts +6 -25
- package/lib/pipeline/runtime-pipeline.ts +129 -144
- package/lib/pipeline/stage.ts +290 -0
- package/lib/pipeline/types.ts +33 -14
- package/lib/pipeline.ts +14 -2
- package/lib/{git.ts → repo/git.ts} +21 -1
- package/lib/{release-config.ts → repo/release-config.ts} +8 -0
- package/lib/{spdx-header.ts → repo/spdx-header.ts} +8 -0
- package/lib/{workspaces.ts → repo/workspaces.ts} +1 -1
- package/lib/resolver/lookup-types.ts +1 -1
- package/lib/resolver/region-database-provider.ts +33 -0
- package/lib/resolver/synthetic-id-ranges.ts +19 -9
- package/lib/resolver/types.ts +220 -7
- package/lib/resolver.ts +14 -1
- package/lib/state-machine.ts +1 -1
- package/lib/strings/python-json.ts +3 -2
- package/lib/utils/chunk-process.ts +2 -2
- package/lib/utils/geodatabase-archive.ts +1 -1
- package/lib/utils/time.ts +136 -12
- package/lib/utils.ts +4 -4
- package/out/api/ckan.js +1 -1
- package/out/api/ckan.js.map +1 -1
- package/out/api/disk-storage.d.ts.map +1 -1
- package/out/api/disk-storage.js +2 -2
- package/out/api/disk-storage.js.map +1 -1
- package/out/api/ogc.js +1 -1
- package/out/api/ogc.js.map +1 -1
- package/out/api/retry.d.ts.map +1 -1
- package/out/api/retry.js +6 -2
- package/out/api/retry.js.map +1 -1
- package/out/api/test/transport.js +1 -1
- package/out/api/test/transport.js.map +1 -1
- package/out/asset/binary-frame.d.ts.map +1 -0
- package/out/{binary-frame.js → asset/binary-frame.js} +1 -1
- package/out/asset/binary-frame.js.map +1 -0
- package/out/asset/load-ledger.d.ts.map +1 -0
- package/out/asset/load-ledger.js.map +1 -0
- package/out/asset/overture-pins.d.ts.map +1 -0
- package/out/asset/overture-pins.js.map +1 -0
- package/out/asset/postcode-prefix-files.d.ts.map +1 -0
- package/out/asset/postcode-prefix-files.js.map +1 -0
- package/out/async/abort.d.ts +57 -0
- package/out/async/abort.d.ts.map +1 -0
- package/out/async/abort.js +89 -0
- package/out/async/abort.js.map +1 -0
- package/out/async/memoize.d.ts.map +1 -0
- package/out/{memoize.js → async/memoize.js} +2 -2
- package/out/async/memoize.js.map +1 -0
- package/out/{promises.d.ts → async/promises.d.ts} +1 -1
- package/out/async/promises.d.ts.map +1 -0
- package/out/{promises.js → async/promises.js} +1 -1
- package/out/async/promises.js.map +1 -0
- package/out/cloudflare/tokens.js +1 -1
- package/out/cloudflare/tokens.js.map +1 -1
- package/out/cloudflare/wrangler.js +3 -3
- package/out/cloudflare/wrangler.js.map +1 -1
- package/out/crypto/digest.d.ts +1 -1
- package/out/crypto/digest.js +1 -1
- package/out/crypto/ed25519.d.ts +7 -0
- package/out/crypto/ed25519.d.ts.map +1 -1
- package/out/crypto/ed25519.js +7 -0
- package/out/crypto/ed25519.js.map +1 -1
- package/out/{hash.d.ts → crypto/hash.d.ts} +12 -0
- package/out/crypto/hash.d.ts.map +1 -0
- package/out/{hash.js → crypto/hash.js} +15 -1
- package/out/crypto/hash.js.map +1 -0
- package/out/crypto/node.js +1 -1
- package/out/crypto/node.js.map +1 -1
- package/out/data-root.d.ts +11 -3
- package/out/data-root.d.ts.map +1 -1
- package/out/data-root.js +14 -3
- package/out/data-root.js.map +1 -1
- package/out/decoder/containment.d.ts.map +1 -1
- package/out/decoder/containment.js +1 -1
- package/out/decoder/containment.js.map +1 -1
- package/out/decoder/serialize/outline.d.ts +9 -0
- package/out/decoder/serialize/outline.d.ts.map +1 -1
- package/out/decoder/serialize/outline.js +16 -6
- package/out/decoder/serialize/outline.js.map +1 -1
- package/out/decoder/types.d.ts +8 -0
- package/out/decoder/types.d.ts.map +1 -1
- package/out/decoder/types.js +1 -1
- package/out/decoder/types.js.map +1 -1
- package/out/env/schema.d.ts +1 -0
- package/out/env/schema.d.ts.map +1 -1
- package/out/env/schema.js +4 -0
- package/out/env/schema.js.map +1 -1
- package/out/env.d.ts +1 -0
- package/out/env.d.ts.map +1 -1
- package/out/fs/deflate64.js +1 -1
- package/out/fs/deflate64.js.map +1 -1
- package/out/fs/lock.d.ts +73 -4
- package/out/fs/lock.d.ts.map +1 -1
- package/out/fs/lock.js +96 -19
- package/out/fs/lock.js.map +1 -1
- package/out/fs/readers.js +1 -1
- package/out/fs/readers.js.map +1 -1
- package/out/fs/writers.d.ts +9 -1
- package/out/fs/writers.d.ts.map +1 -1
- package/out/fs/writers.js +15 -2
- package/out/fs/writers.js.map +1 -1
- package/out/geocode/result.d.ts +25 -1
- package/out/geocode/result.d.ts.map +1 -1
- package/out/geocode/result.js +49 -6
- package/out/geocode/result.js.map +1 -1
- package/out/html/text.js +2 -2
- package/out/html/trust-policies.d.ts.map +1 -0
- package/out/html/trust-policies.js.map +1 -0
- package/out/index.d.ts +0 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +0 -1
- package/out/index.js.map +1 -1
- package/out/layers/artifact.js +2 -2
- package/out/layers/artifact.js.map +1 -1
- package/out/layers/coverage.d.ts.map +1 -1
- package/out/layers/coverage.js +1 -1
- package/out/layers/coverage.js.map +1 -1
- package/out/layers/manifest.d.ts +53 -0
- package/out/layers/manifest.d.ts.map +1 -1
- package/out/layers/manifest.js +68 -2
- package/out/layers/manifest.js.map +1 -1
- package/out/layers/provenance.d.ts +127 -0
- package/out/layers/provenance.d.ts.map +1 -0
- package/out/layers/provenance.js +122 -0
- package/out/layers/provenance.js.map +1 -0
- package/out/layers/publication.d.ts.map +1 -1
- package/out/layers/publication.js +3 -3
- package/out/layers/publication.js.map +1 -1
- package/out/layers/selection.d.ts.map +1 -1
- package/out/layers/selection.js +2 -2
- package/out/layers/selection.js.map +1 -1
- package/out/license/branch.d.ts +33 -0
- package/out/license/branch.d.ts.map +1 -0
- package/out/license/branch.js +52 -0
- package/out/license/branch.js.map +1 -0
- package/out/license/configured.d.ts +1 -1
- package/out/license/configured.d.ts.map +1 -1
- package/out/license/configured.js +1 -9
- package/out/license/configured.js.map +1 -1
- package/out/license/declaration.d.ts +1 -1
- package/out/license/declaration.d.ts.map +1 -1
- package/out/license/key/file.js +1 -1
- package/out/license/key/file.js.map +1 -1
- package/out/license/key.d.ts +27 -115
- package/out/license/key.d.ts.map +1 -1
- package/out/license/key.js +98 -164
- package/out/license/key.js.map +1 -1
- package/out/license/provenance.d.ts +47 -0
- package/out/license/provenance.d.ts.map +1 -0
- package/out/license/provenance.js +134 -0
- package/out/license/provenance.js.map +1 -0
- package/out/license/register.d.ts +6 -47
- package/out/license/register.d.ts.map +1 -1
- package/out/license/register.js +7 -58
- package/out/license/register.js.map +1 -1
- package/out/license/stamp.d.ts +7 -1
- package/out/license/stamp.d.ts.map +1 -1
- package/out/license/stamp.js +2 -2
- package/out/license/stamp.js.map +1 -1
- package/out/license/text-url.d.ts +9 -0
- package/out/license/text-url.d.ts.map +1 -0
- package/out/license/text-url.js +49 -0
- package/out/license/text-url.js.map +1 -0
- package/out/license/training.d.ts +29 -0
- package/out/license/training.d.ts.map +1 -0
- package/out/license/training.js +52 -0
- package/out/license/training.js.map +1 -0
- package/out/license.d.ts +7 -6
- package/out/license.d.ts.map +1 -1
- package/out/license.js +7 -6
- package/out/license.js.map +1 -1
- package/out/locale/registry.d.ts.map +1 -1
- package/out/locale/registry.js +1 -1
- package/out/locale/registry.js.map +1 -1
- package/out/locale/zh-cn-units.js +1 -1
- package/out/locale/zh-cn-units.js.map +1 -1
- package/out/math/numeric.d.ts.map +1 -0
- package/out/math/numeric.js.map +1 -0
- package/out/math/random.d.ts.map +1 -0
- package/out/math/random.js.map +1 -0
- package/out/math/stats.d.ts.map +1 -0
- package/out/math/stats.js.map +1 -0
- package/out/module/workspace.js +1 -1
- package/out/module/workspace.js.map +1 -1
- package/out/network/routing.d.ts.map +1 -0
- package/out/{routing.js → network/routing.js} +1 -1
- package/out/network/routing.js.map +1 -0
- package/out/pipeline/result.d.ts +7 -24
- package/out/pipeline/result.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.d.ts +7 -2
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +56 -103
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/stage.d.ts +180 -0
- package/out/pipeline/stage.d.ts.map +1 -0
- package/out/pipeline/stage.js +130 -0
- package/out/pipeline/stage.js.map +1 -0
- package/out/pipeline/types.d.ts +31 -12
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +0 -8
- package/out/pipeline/types.js.map +1 -1
- package/out/pipeline.d.ts +5 -3
- package/out/pipeline.d.ts.map +1 -1
- package/out/pipeline.js +2 -1
- package/out/pipeline.js.map +1 -1
- package/out/{git.d.ts → repo/git.d.ts} +10 -1
- package/out/repo/git.d.ts.map +1 -0
- package/out/{git.js → repo/git.js} +14 -1
- package/out/repo/git.js.map +1 -0
- package/out/{release-config.d.ts → repo/release-config.d.ts} +8 -0
- package/out/repo/release-config.d.ts.map +1 -0
- package/out/repo/release-config.js.map +1 -0
- package/out/repo/scope-config.d.ts.map +1 -0
- package/out/repo/scope-config.js.map +1 -0
- package/out/repo/spdx-header.d.ts.map +1 -0
- package/out/{spdx-header.js → repo/spdx-header.js} +7 -0
- package/out/repo/spdx-header.js.map +1 -0
- package/out/repo/vale.d.ts.map +1 -0
- package/out/repo/vale.js.map +1 -0
- package/out/repo/workspaces.d.ts.map +1 -0
- package/out/{workspaces.js → repo/workspaces.js} +1 -1
- package/out/repo/workspaces.js.map +1 -0
- package/out/resolver/lookup-types.d.ts +1 -1
- package/out/resolver/region-database-provider.d.ts +30 -0
- package/out/resolver/region-database-provider.d.ts.map +1 -1
- package/out/resolver/synthetic-id-ranges.d.ts +15 -8
- package/out/resolver/synthetic-id-ranges.d.ts.map +1 -1
- package/out/resolver/synthetic-id-ranges.js +18 -9
- package/out/resolver/synthetic-id-ranges.js.map +1 -1
- package/out/resolver/types.d.ts +192 -8
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js +56 -0
- package/out/resolver/types.js.map +1 -1
- package/out/resolver.d.ts +3 -3
- package/out/resolver.d.ts.map +1 -1
- package/out/resolver.js +1 -1
- package/out/resolver.js.map +1 -1
- package/out/scripting/process.d.ts.map +1 -0
- package/out/scripting/process.js.map +1 -0
- package/out/scripting/workers.d.ts.map +1 -0
- package/out/scripting/workers.js.map +1 -0
- package/out/state-machine.d.ts +1 -1
- package/out/strings/python-json.d.ts +2 -1
- package/out/strings/python-json.d.ts.map +1 -1
- package/out/strings/python-json.js +1 -1
- package/out/strings/python-json.js.map +1 -1
- package/out/tools/build-deflate64-wasm.run.js +2 -2
- package/out/tools/build-deflate64-wasm.run.js.map +1 -1
- package/out/tools/coarse-placer/build/dataset.js +1 -1
- package/out/tools/coarse-placer/build/dataset.js.map +1 -1
- package/out/tools/coarse-placer/build/outlier/exposure.js +1 -1
- package/out/tools/coarse-placer/build/outlier/exposure.js.map +1 -1
- package/out/tools/coarse-placer/build/outlier/latin.d.ts.map +1 -1
- package/out/tools/coarse-placer/build/outlier/latin.js +5 -1
- package/out/tools/coarse-placer/build/outlier/latin.js.map +1 -1
- package/out/tools/coarse-placer/country-sets.d.ts +2 -2
- package/out/tools/coarse-placer/country-sets.js +2 -2
- package/out/tools/coarse-placer/outlier-rows.js +2 -2
- package/out/tools/coarse-placer/outlier-rows.js.map +1 -1
- package/out/tools/coarse-placer/train.js +1 -1
- package/out/tools/coarse-placer/train.js.map +1 -1
- package/out/tools/generate-language-types.js +2 -2
- package/out/tools/generate-language-types.js.map +1 -1
- package/out/tools/license/product-fixtures.run.d.ts +2 -0
- package/out/tools/license/product-fixtures.run.d.ts.map +1 -0
- package/out/tools/license/product-fixtures.run.js +350 -0
- package/out/tools/license/product-fixtures.run.js.map +1 -0
- package/out/utils/chunk-process.js +2 -2
- package/out/utils/chunk-process.js.map +1 -1
- package/out/utils/geodatabase-archive.js +1 -1
- package/out/utils/geodatabase-archive.js.map +1 -1
- package/out/utils/time.d.ts +15 -4
- package/out/utils/time.d.ts.map +1 -1
- package/out/utils/time.js +114 -12
- package/out/utils/time.js.map +1 -1
- package/out/utils.d.ts +4 -4
- package/out/utils.d.ts.map +1 -1
- package/out/utils.js +4 -4
- package/out/utils.js.map +1 -1
- package/out/values/identical.d.ts.map +1 -0
- package/out/values/identical.js.map +1 -0
- package/out/values/json.d.ts.map +1 -0
- package/out/values/json.js.map +1 -0
- package/out/values/objects.d.ts.map +1 -0
- package/out/values/objects.js.map +1 -0
- package/package.json +278 -243
- package/tools/build-deflate64-wasm.run.ts +2 -2
- package/tools/coarse-placer/build/dataset.ts +1 -1
- package/tools/coarse-placer/build/outlier/exposure.ts +1 -1
- package/tools/coarse-placer/build/outlier/latin.ts +5 -1
- package/tools/coarse-placer/country-sets.ts +2 -2
- package/tools/coarse-placer/outlier-rows.ts +2 -2
- package/tools/coarse-placer/train.ts +1 -1
- package/tools/generate-language-types.ts +2 -2
- package/tools/license/product-fixtures.run.ts +449 -0
- package/lib/collections.ts +0 -5
- package/lib/license/decision.ts +0 -329
- package/lib/license/obligations.ts +0 -256
- package/lib/license/record.ts +0 -277
- package/lib/scripting/ingest-chunk-script.ts +0 -87
- package/out/binary-frame.d.ts.map +0 -1
- package/out/binary-frame.js.map +0 -1
- package/out/collections.d.ts +0 -2
- package/out/collections.d.ts.map +0 -1
- package/out/collections.js +0 -5
- package/out/collections.js.map +0 -1
- package/out/git.d.ts.map +0 -1
- package/out/git.js.map +0 -1
- package/out/hash.d.ts.map +0 -1
- package/out/hash.js.map +0 -1
- package/out/identical.d.ts.map +0 -1
- package/out/identical.js.map +0 -1
- package/out/json.d.ts.map +0 -1
- package/out/json.js.map +0 -1
- package/out/license/decision.d.ts +0 -179
- package/out/license/decision.d.ts.map +0 -1
- package/out/license/decision.js +0 -169
- package/out/license/decision.js.map +0 -1
- package/out/license/obligations.d.ts +0 -102
- package/out/license/obligations.d.ts.map +0 -1
- package/out/license/obligations.js +0 -188
- package/out/license/obligations.js.map +0 -1
- package/out/license/record.d.ts +0 -136
- package/out/license/record.d.ts.map +0 -1
- package/out/license/record.js +0 -222
- package/out/license/record.js.map +0 -1
- package/out/load-ledger.d.ts.map +0 -1
- package/out/load-ledger.js.map +0 -1
- package/out/memoize.d.ts.map +0 -1
- package/out/memoize.js.map +0 -1
- package/out/numeric.d.ts.map +0 -1
- package/out/numeric.js.map +0 -1
- package/out/objects.d.ts.map +0 -1
- package/out/objects.js.map +0 -1
- package/out/overture-pins.d.ts.map +0 -1
- package/out/overture-pins.js.map +0 -1
- package/out/postcode-prefix-files.d.ts.map +0 -1
- package/out/postcode-prefix-files.js.map +0 -1
- package/out/process.d.ts.map +0 -1
- package/out/process.js.map +0 -1
- package/out/promises.d.ts.map +0 -1
- package/out/promises.js.map +0 -1
- package/out/random.d.ts.map +0 -1
- package/out/random.js.map +0 -1
- package/out/release-config.d.ts.map +0 -1
- package/out/release-config.js.map +0 -1
- package/out/routing.d.ts.map +0 -1
- package/out/routing.js.map +0 -1
- package/out/scope-config.d.ts.map +0 -1
- package/out/scope-config.js.map +0 -1
- package/out/scripting/ingest-chunk-script.d.ts +0 -58
- package/out/scripting/ingest-chunk-script.d.ts.map +0 -1
- package/out/scripting/ingest-chunk-script.js +0 -47
- package/out/scripting/ingest-chunk-script.js.map +0 -1
- package/out/spdx-header.d.ts.map +0 -1
- package/out/spdx-header.js.map +0 -1
- package/out/stats.d.ts.map +0 -1
- package/out/stats.js.map +0 -1
- package/out/trust-policies.d.ts.map +0 -1
- package/out/trust-policies.js.map +0 -1
- package/out/vale.d.ts.map +0 -1
- package/out/vale.js.map +0 -1
- package/out/workers.d.ts.map +0 -1
- package/out/workers.js.map +0 -1
- package/out/workspaces.d.ts.map +0 -1
- package/out/workspaces.js.map +0 -1
- /package/lib/{load-ledger.ts → asset/load-ledger.ts} +0 -0
- /package/lib/{overture-pins.ts → asset/overture-pins.ts} +0 -0
- /package/lib/{postcode-prefix-files.ts → asset/postcode-prefix-files.ts} +0 -0
- /package/lib/{trust-policies.ts → html/trust-policies.ts} +0 -0
- /package/lib/{numeric.ts → math/numeric.ts} +0 -0
- /package/lib/{random.ts → math/random.ts} +0 -0
- /package/lib/{stats.ts → math/stats.ts} +0 -0
- /package/lib/{scope-config.ts → repo/scope-config.ts} +0 -0
- /package/lib/{vale.ts → repo/vale.ts} +0 -0
- /package/lib/{process.ts → scripting/process.ts} +0 -0
- /package/lib/{workers.ts → scripting/workers.ts} +0 -0
- /package/lib/{identical.ts → values/identical.ts} +0 -0
- /package/lib/{json.ts → values/json.ts} +0 -0
- /package/lib/{objects.ts → values/objects.ts} +0 -0
- /package/out/{binary-frame.d.ts → asset/binary-frame.d.ts} +0 -0
- /package/out/{load-ledger.d.ts → asset/load-ledger.d.ts} +0 -0
- /package/out/{load-ledger.js → asset/load-ledger.js} +0 -0
- /package/out/{overture-pins.d.ts → asset/overture-pins.d.ts} +0 -0
- /package/out/{overture-pins.js → asset/overture-pins.js} +0 -0
- /package/out/{postcode-prefix-files.d.ts → asset/postcode-prefix-files.d.ts} +0 -0
- /package/out/{postcode-prefix-files.js → asset/postcode-prefix-files.js} +0 -0
- /package/out/{memoize.d.ts → async/memoize.d.ts} +0 -0
- /package/out/{trust-policies.d.ts → html/trust-policies.d.ts} +0 -0
- /package/out/{trust-policies.js → html/trust-policies.js} +0 -0
- /package/out/{numeric.d.ts → math/numeric.d.ts} +0 -0
- /package/out/{numeric.js → math/numeric.js} +0 -0
- /package/out/{random.d.ts → math/random.d.ts} +0 -0
- /package/out/{random.js → math/random.js} +0 -0
- /package/out/{stats.d.ts → math/stats.d.ts} +0 -0
- /package/out/{stats.js → math/stats.js} +0 -0
- /package/out/{routing.d.ts → network/routing.d.ts} +0 -0
- /package/out/{release-config.js → repo/release-config.js} +0 -0
- /package/out/{scope-config.d.ts → repo/scope-config.d.ts} +0 -0
- /package/out/{scope-config.js → repo/scope-config.js} +0 -0
- /package/out/{spdx-header.d.ts → repo/spdx-header.d.ts} +0 -0
- /package/out/{vale.d.ts → repo/vale.d.ts} +0 -0
- /package/out/{vale.js → repo/vale.js} +0 -0
- /package/out/{workspaces.d.ts → repo/workspaces.d.ts} +0 -0
- /package/out/{process.d.ts → scripting/process.d.ts} +0 -0
- /package/out/{process.js → scripting/process.js} +0 -0
- /package/out/{workers.d.ts → scripting/workers.d.ts} +0 -0
- /package/out/{workers.js → scripting/workers.js} +0 -0
- /package/out/{identical.d.ts → values/identical.d.ts} +0 -0
- /package/out/{identical.js → values/identical.js} +0 -0
- /package/out/{json.d.ts → values/json.d.ts} +0 -0
- /package/out/{json.js → values/json.js} +0 -0
- /package/out/{objects.d.ts → values/objects.d.ts} +0 -0
- /package/out/{objects.js → values/objects.js} +0 -0
package/lib/fs/lock.ts
CHANGED
|
@@ -5,17 +5,20 @@
|
|
|
5
5
|
* @file An exclusive lock held as a directory for as long as its owner runs.
|
|
6
6
|
*
|
|
7
7
|
* The lock is a directory created with a non-recursive `mkdir`, an atomic test-and-set, holding the owner's
|
|
8
|
-
* pid, host and start time. A second process refuses while the owner
|
|
9
|
-
* on this host that no longer exists was left by a killed process, and
|
|
10
|
-
*
|
|
8
|
+
* pid, host, start time and the kernel's start time for that pid. A second process refuses while the owner
|
|
9
|
+
* lives. A lock whose owner was a process on this host that no longer exists was left by a killed process, and
|
|
10
|
+
* the next caller takes it over. So is a lock whose pid now belongs to a process that started at another time,
|
|
11
|
+
* because the kernel reused the pid. A lock held from another host is never taken over, because its owner's
|
|
12
|
+
* liveness cannot be read from here.
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
15
|
import type { PathBuilderLike } from "path-ts"
|
|
14
16
|
|
|
15
|
-
import {
|
|
17
|
+
import { type ClockLike, systemClock } from "#api/clock"
|
|
18
|
+
import { readLocalTextFile, tryReadLocalJSONFile } from "#fs/readers"
|
|
16
19
|
import { makeDirectoryExclusive, removePathIfPresent, writeLocalJSONFile } from "#fs/writers"
|
|
17
|
-
import { stringifyJSON } from "#json"
|
|
18
20
|
import { hostName } from "#utils/system"
|
|
21
|
+
import { stringifyJSON } from "#values/json"
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* What a lock directory records about the process holding it.
|
|
@@ -24,6 +27,31 @@ export interface DirectoryLockOwner {
|
|
|
24
27
|
pid: number
|
|
25
28
|
host: string
|
|
26
29
|
started_at: string
|
|
30
|
+
/**
|
|
31
|
+
* The kernel's start time for `pid`, from {@link processStartTime}, so a reused pid reads as stale.
|
|
32
|
+
*
|
|
33
|
+
* `null` on a platform without `/proc`, and absent in a record written before the field existed.
|
|
34
|
+
* Either way only the pid's existence is checked.
|
|
35
|
+
*/
|
|
36
|
+
process_started?: string | null
|
|
37
|
+
/**
|
|
38
|
+
* What the holder states about its work, such as the command it runs, for a waiter to report.
|
|
39
|
+
*/
|
|
40
|
+
detail?: Record<string, unknown>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Options for {@link acquireDirectoryLock} and {@link waitForDirectoryLock}.
|
|
45
|
+
*/
|
|
46
|
+
export interface DirectoryLockOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Recorded in the owner file as {@link DirectoryLockOwner.detail}.
|
|
49
|
+
*/
|
|
50
|
+
detail?: Record<string, unknown>
|
|
51
|
+
/**
|
|
52
|
+
* Called when a stale owner's lock is removed, with the reason it was judged stale.
|
|
53
|
+
*/
|
|
54
|
+
onStaleRelease?: (held: DirectoryLockOwner, reason: string) => void
|
|
27
55
|
}
|
|
28
56
|
|
|
29
57
|
/**
|
|
@@ -53,20 +81,75 @@ export function processExists(pid: number): boolean {
|
|
|
53
81
|
}
|
|
54
82
|
|
|
55
83
|
/**
|
|
56
|
-
*
|
|
84
|
+
* The kernel's start time for a process, in clock ticks since boot, read from `/proc/<pid>/stat`.
|
|
57
85
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* or an owner whose record cannot be read holds the lock.
|
|
86
|
+
* Two processes that held one pid at different times have different start times.
|
|
87
|
+
*
|
|
88
|
+
* @returns `null` when the process doesn't exist or the platform has no `/proc`.
|
|
62
89
|
*/
|
|
63
|
-
|
|
90
|
+
async function processStartTime(pid: number): Promise<string | null> {
|
|
91
|
+
let stat: string
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
stat = await readLocalTextFile(`/proc/${pid}/stat`)
|
|
95
|
+
} catch {
|
|
96
|
+
return null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// The second field is the command name in parentheses and may itself hold spaces
|
|
100
|
+
// or parentheses, so the fields are counted from the last closing parenthesis.
|
|
101
|
+
// The start time is field 22, the 20th after it.
|
|
102
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ")
|
|
103
|
+
|
|
104
|
+
return fields[19] ?? null
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Why a lock's owner no longer holds it, or `null` when the owner may still be running.
|
|
109
|
+
*
|
|
110
|
+
* Only an owner on this host can be judged.
|
|
111
|
+
* The calling process never judges its own record stale.
|
|
112
|
+
*/
|
|
113
|
+
export async function staleOwnerReason(held: DirectoryLockOwner): Promise<string | null> {
|
|
114
|
+
if (held.host !== hostName() || held.pid === process.pid) return null
|
|
115
|
+
|
|
116
|
+
if (!processExists(held.pid)) return `process ${held.pid} no longer exists`
|
|
117
|
+
|
|
118
|
+
if (typeof held.process_started === "string") {
|
|
119
|
+
const current = await processStartTime(held.pid)
|
|
120
|
+
|
|
121
|
+
if (typeof current === "string" && current !== held.process_started) {
|
|
122
|
+
return `process ${held.pid} started at tick ${current}, not at the recorded tick ${held.process_started}, so the pid was reused`
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return null
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* One attempt at the lock: the held lock, or the record of the owner that refused it.
|
|
131
|
+
*
|
|
132
|
+
* `held` is `null` when the owner record is absent or unreadable.
|
|
133
|
+
*/
|
|
134
|
+
type DirectoryLockAttempt = { lock: DirectoryLock; held?: never } | { lock?: never; held: DirectoryLockOwner | null }
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Try the lock at `lockDir` once, removing a stale owner's lock first.
|
|
138
|
+
*/
|
|
139
|
+
async function tryAcquireDirectoryLock(
|
|
64
140
|
lockDir: PathBuilderLike,
|
|
65
|
-
|
|
66
|
-
): Promise<
|
|
141
|
+
options: DirectoryLockOptions = {}
|
|
142
|
+
): Promise<DirectoryLockAttempt> {
|
|
67
143
|
const path = lockDir.toString()
|
|
68
144
|
const ownerPath = `${path}/owner.json`
|
|
69
|
-
|
|
145
|
+
|
|
146
|
+
const owner: DirectoryLockOwner = {
|
|
147
|
+
pid: process.pid,
|
|
148
|
+
host: hostName(),
|
|
149
|
+
started_at: new Date().toISOString(),
|
|
150
|
+
process_started: await processStartTime(process.pid),
|
|
151
|
+
...(options.detail ? { detail: options.detail } : {}),
|
|
152
|
+
}
|
|
70
153
|
|
|
71
154
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
72
155
|
try {
|
|
@@ -80,30 +163,105 @@ export async function acquireDirectoryLock(
|
|
|
80
163
|
// An owner file that's absent or unreadable belongs to a process between its `mkdir`
|
|
81
164
|
// and its write, or to one killed in that window.
|
|
82
165
|
// Neither can be told apart from here, so the caller refuses.
|
|
83
|
-
|
|
166
|
+
const reason = held ? await staleOwnerReason(held) : null
|
|
167
|
+
|
|
168
|
+
if (held && reason) {
|
|
84
169
|
await removePathIfPresent(path)
|
|
170
|
+
options.onStaleRelease?.(held, reason)
|
|
85
171
|
|
|
86
172
|
continue
|
|
87
173
|
}
|
|
88
174
|
|
|
89
|
-
|
|
175
|
+
return { held }
|
|
90
176
|
}
|
|
91
177
|
|
|
92
178
|
await writeLocalJSONFile(owner, ownerPath)
|
|
93
179
|
|
|
94
180
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
181
|
+
lock: {
|
|
182
|
+
owner,
|
|
183
|
+
path,
|
|
184
|
+
[Symbol.asyncDispose]: async () => {
|
|
185
|
+
const current = await tryReadLocalJSONFile<DirectoryLockOwner>(ownerPath)
|
|
186
|
+
|
|
187
|
+
// Released only by its owner, so a process whose lock was removed by hand never deletes a successor's.
|
|
188
|
+
if (current && stringifyJSON(current) === stringifyJSON(owner)) {
|
|
189
|
+
await removePathIfPresent(path)
|
|
190
|
+
}
|
|
191
|
+
},
|
|
104
192
|
},
|
|
105
193
|
}
|
|
106
194
|
}
|
|
107
195
|
|
|
108
196
|
throw new Error(`the lock ${path} reappeared while a stale one was removed`)
|
|
109
197
|
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Take the lock at `lockDir`.
|
|
201
|
+
*
|
|
202
|
+
* @param refusal The message thrown when another live process holds the lock.
|
|
203
|
+
* `held` is the owner record, or `null` when it is absent or unreadable.
|
|
204
|
+
* @throws The `refusal` message when a live process, a process on another host,
|
|
205
|
+
* or an owner whose record cannot be read holds the lock.
|
|
206
|
+
*/
|
|
207
|
+
export async function acquireDirectoryLock(
|
|
208
|
+
lockDir: PathBuilderLike,
|
|
209
|
+
refusal: (held: DirectoryLockOwner | null) => string,
|
|
210
|
+
options: DirectoryLockOptions = {}
|
|
211
|
+
): Promise<DirectoryLock> {
|
|
212
|
+
const attempt = await tryAcquireDirectoryLock(lockDir, options)
|
|
213
|
+
|
|
214
|
+
if (attempt.lock) return attempt.lock
|
|
215
|
+
|
|
216
|
+
throw new Error(refusal(attempt.held))
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Options for {@link waitForDirectoryLock}.
|
|
221
|
+
*/
|
|
222
|
+
export interface WaitForDirectoryLockOptions extends DirectoryLockOptions {
|
|
223
|
+
/**
|
|
224
|
+
* How long to wait for a live owner to release the lock.
|
|
225
|
+
* Zero tries once.
|
|
226
|
+
*/
|
|
227
|
+
maxWaitMs: number
|
|
228
|
+
/**
|
|
229
|
+
* The interval between attempts.
|
|
230
|
+
*/
|
|
231
|
+
pollMs: number
|
|
232
|
+
clock?: ClockLike
|
|
233
|
+
/**
|
|
234
|
+
* Called after each refused attempt, with the owner that refused it.
|
|
235
|
+
*/
|
|
236
|
+
onWait?: (held: DirectoryLockOwner | null, waitedMs: number) => void
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* How a bounded wait for a lock ended: the held lock, or the owner still holding it when the bound expired.
|
|
241
|
+
*/
|
|
242
|
+
export type DirectoryLockWait =
|
|
243
|
+
| { lock: DirectoryLock; waitedMs: number; held?: never }
|
|
244
|
+
| { lock?: never; waitedMs: number; held: DirectoryLockOwner | null }
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Take the lock at `lockDir`, polling while a live owner holds it, for at most `maxWaitMs`.
|
|
248
|
+
*/
|
|
249
|
+
export async function waitForDirectoryLock(
|
|
250
|
+
lockDir: PathBuilderLike,
|
|
251
|
+
options: WaitForDirectoryLockOptions
|
|
252
|
+
): Promise<DirectoryLockWait> {
|
|
253
|
+
const clock = options.clock ?? systemClock
|
|
254
|
+
const startedAt = clock.now()
|
|
255
|
+
|
|
256
|
+
for (;;) {
|
|
257
|
+
const attempt = await tryAcquireDirectoryLock(lockDir, options)
|
|
258
|
+
const waitedMs = clock.now() - startedAt
|
|
259
|
+
|
|
260
|
+
if (attempt.lock) return { lock: attempt.lock, waitedMs }
|
|
261
|
+
|
|
262
|
+
if (waitedMs >= options.maxWaitMs) return { held: attempt.held, waitedMs }
|
|
263
|
+
|
|
264
|
+
options.onWait?.(attempt.held, waitedMs)
|
|
265
|
+
await clock.sleep(Math.min(options.pollMs, options.maxWaitMs - waitedMs))
|
|
266
|
+
}
|
|
267
|
+
}
|
package/lib/fs/readers.ts
CHANGED
|
@@ -15,8 +15,8 @@ import { type PathBuilderLike, resolvePath } from "path-ts"
|
|
|
15
15
|
import { Globerator } from "spliterator/node/fs"
|
|
16
16
|
|
|
17
17
|
import { isDirectory, open } from "#fs/readers/stat"
|
|
18
|
-
import { parseJSONStrict } from "#json"
|
|
19
18
|
import { compareByScalarValue } from "#strings/compare"
|
|
19
|
+
import { parseJSONStrict } from "#values/json"
|
|
20
20
|
|
|
21
21
|
export type { Dirent, PathLike, Stats } from "node:fs"
|
|
22
22
|
export type { FileHandle } from "node:fs/promises"
|
package/lib/fs/writers.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import {
|
|
11
11
|
appendFile,
|
|
12
12
|
chmod,
|
|
13
|
+
constants,
|
|
13
14
|
copyFile,
|
|
14
15
|
cp,
|
|
15
16
|
mkdir,
|
|
@@ -27,7 +28,7 @@ import { createNewlineWriter } from "spliterator"
|
|
|
27
28
|
|
|
28
29
|
import type { Stats } from "#fs/readers"
|
|
29
30
|
import { statPath } from "#fs/readers/stat"
|
|
30
|
-
import { prettyJSON, stringifyJSON, type StringifiedJSON } from "#json"
|
|
31
|
+
import { prettyJSON, stringifyJSON, type StringifiedJSON } from "#values/json"
|
|
31
32
|
|
|
32
33
|
// #region Directories
|
|
33
34
|
|
|
@@ -382,6 +383,22 @@ export async function copyFileTo(source: PathBuilderLike, destination: PathBuild
|
|
|
382
383
|
return copyFile(source.toString(), target)
|
|
383
384
|
}
|
|
384
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Copies one file as {@linkcode copyFileTo} does, sharing the source's blocks where the filesystem can.
|
|
388
|
+
*
|
|
389
|
+
* On btrfs and XFS the copy is a clone.
|
|
390
|
+
* A clone writes metadata only, so a multi-gigabyte copy finishes at once.
|
|
391
|
+
* On a filesystem without clones the bytes are copied.
|
|
392
|
+
*/
|
|
393
|
+
export async function cloneFileTo(source: PathBuilderLike, destination: PathBuilderLike): Promise<void> {
|
|
394
|
+
const target = destination.toString()
|
|
395
|
+
|
|
396
|
+
await mkdir(dirname(target), { recursive: true })
|
|
397
|
+
await rm(target, { force: true })
|
|
398
|
+
|
|
399
|
+
return copyFile(source.toString(), target, constants.COPYFILE_FICLONE)
|
|
400
|
+
}
|
|
401
|
+
|
|
385
402
|
/**
|
|
386
403
|
* The path of a staging file beside `destination`, unique to this process and call.
|
|
387
404
|
*
|
package/lib/geocode/result.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { z } from "zod"
|
|
|
15
15
|
import { DroppedSpanSchema } from "#decoder/serialize/json"
|
|
16
16
|
import { ComponentTagSchema } from "#decoder/types"
|
|
17
17
|
import { QueryIntentMarkerSchema } from "#pipeline/types"
|
|
18
|
+
import { ScoreUnmeasuredReason } from "#resolver/types"
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* The geocoder resolution tier that produced a coordinate.
|
|
@@ -51,12 +52,33 @@ export const HierarchyEntrySchema = z
|
|
|
51
52
|
export type HierarchyEntry = z.infer<typeof HierarchyEntrySchema>
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
+
* Why a candidate's `score` is null.
|
|
56
|
+
*/
|
|
57
|
+
export const ScoreUnmeasuredReasonSchema = z
|
|
58
|
+
.enum(Object.values(ScoreUnmeasuredReason))
|
|
59
|
+
.meta({ id: "ScoreUnmeasuredReason", description: "Why a candidate's score is null." })
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* One place the resolver weighed for a parsed span: the winner first, then the places it passed over.
|
|
55
63
|
*/
|
|
56
64
|
export const GeocodeCandidateSchema = z
|
|
57
65
|
.object({
|
|
66
|
+
/**
|
|
67
|
+
* The resolved gazetteer name.
|
|
68
|
+
*/
|
|
58
69
|
name: z.string(),
|
|
70
|
+
/**
|
|
71
|
+
* The parsed span's component tag.
|
|
72
|
+
*/
|
|
59
73
|
tag: z.string(),
|
|
74
|
+
/**
|
|
75
|
+
* The raw parsed span.
|
|
76
|
+
*/
|
|
77
|
+
value: z.string(),
|
|
78
|
+
/**
|
|
79
|
+
* The gazetteer placetype of the place, such as `locality` or `region`.
|
|
80
|
+
*/
|
|
81
|
+
placetype: z.string(),
|
|
60
82
|
lat: z.number(),
|
|
61
83
|
lon: z.number(),
|
|
62
84
|
countryCode: z.string().nullable(),
|
|
@@ -64,18 +86,33 @@ export const GeocodeCandidateSchema = z
|
|
|
64
86
|
/**
|
|
65
87
|
* The resolver's ranking score for this candidate, larger ranking higher.
|
|
66
88
|
*
|
|
67
|
-
* Scores compare candidates within one
|
|
68
|
-
* The field is null when the
|
|
89
|
+
* Scores compare candidates within one span and have no unit across spans or answers.
|
|
90
|
+
* The field is null when the score is a rank without a measurement behind it.
|
|
91
|
+
* `scoreUnmeasured` then holds the reason.
|
|
69
92
|
*/
|
|
70
93
|
score: z.number().nullable(),
|
|
94
|
+
/**
|
|
95
|
+
* Why `score` is null: `population_unrecorded` when the gazetteer ranks by a population
|
|
96
|
+
* it doesn't record for the place, `unrecorded` when the resolver recorded no score.
|
|
97
|
+
*
|
|
98
|
+
* The field is absent when `score` holds a value.
|
|
99
|
+
*/
|
|
100
|
+
scoreUnmeasured: ScoreUnmeasuredReasonSchema.optional(),
|
|
71
101
|
/**
|
|
72
102
|
* True when the input matched an alias of this place, such as a former name, and differs from `name`.
|
|
73
103
|
*
|
|
74
104
|
* The field is absent when the input matched the primary name.
|
|
75
105
|
*/
|
|
76
106
|
matchedAlias: z.literal(true).optional(),
|
|
107
|
+
/**
|
|
108
|
+
* True when a hard scope excluded this place: it lies outside the default country
|
|
109
|
+
* or the caller's parent place, so it couldn't answer.
|
|
110
|
+
*
|
|
111
|
+
* The field is absent for a place inside the scope.
|
|
112
|
+
*/
|
|
113
|
+
outsideScope: z.literal(true).optional(),
|
|
77
114
|
})
|
|
78
|
-
.meta({ id: "GeocodeCandidate", description: "A
|
|
115
|
+
.meta({ id: "GeocodeCandidate", description: "A place the resolver weighed for one parsed span." })
|
|
79
116
|
|
|
80
117
|
export type GeocodeCandidate = z.infer<typeof GeocodeCandidateSchema>
|
|
81
118
|
|
|
@@ -348,9 +385,16 @@ export const GeocodeResultSchema = z
|
|
|
348
385
|
hierarchy: z.array(HierarchyEntrySchema),
|
|
349
386
|
|
|
350
387
|
/**
|
|
351
|
-
*
|
|
388
|
+
* The places the resolver weighed, grouped by parsed span.
|
|
389
|
+
*
|
|
390
|
+
* The primary place's span comes first, its winner at the head of the list.
|
|
391
|
+
* Each other resolved span follows with the places it passed over.
|
|
392
|
+
*
|
|
393
|
+
* Within a span, the resolver's ranked runner-ups come first, then the side-probe
|
|
394
|
+
* winners and the places a later pass replaced.
|
|
395
|
+
* A place appears once, under the first span that weighed it.
|
|
352
396
|
*
|
|
353
|
-
*
|
|
397
|
+
* A span lists at most 10 places and the list holds at most 25.
|
|
354
398
|
*/
|
|
355
399
|
candidates: z.array(GeocodeCandidateSchema),
|
|
356
400
|
|
package/lib/html/text.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* This module reads an HTML fragment as text through `htmlparser2`, using one rule in two ways.
|
|
6
6
|
*
|
|
7
|
-
* `stripHTMLToText` (`@mailwoman/core/trust-policies`) decodes entities, survives a
|
|
8
|
-
* inside an attribute value and leaves source whitespace runs intact, but `textContent`
|
|
7
|
+
* `stripHTMLToText` (`@mailwoman/core/html/trust-policies`) decodes entities, survives a
|
|
8
|
+
* `<` inside an attribute value and leaves source whitespace runs intact, but `textContent`
|
|
9
9
|
* inserts no separator at an element boundary, so `<td>a</td><td>b</td>` reads as `"ab"` and
|
|
10
10
|
* `<p>Acme Fiber</p><p>LLC</p>` as `"Acme FiberLLC"`, a name that appears nowhere in the document.
|
|
11
11
|
*
|
package/lib/index.ts
CHANGED
package/lib/layers/artifact.ts
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* record stays `null`.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { sha256Hex } from "#hash"
|
|
21
|
-
import { canonicalJSON, stringifyJSON } from "#json"
|
|
20
|
+
import { sha256Hex } from "#crypto/hash"
|
|
21
|
+
import { canonicalJSON, stringifyJSON } from "#values/json"
|
|
22
22
|
|
|
23
23
|
const SHA256_HEX = /^[0-9a-f]{64}$/
|
|
24
24
|
|
package/lib/layers/coverage.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import { supportsExclusion, CoverageBasis } from "@mailwoman/evidence"
|
|
9
9
|
|
|
10
|
-
import { stringifyJSON } from "#json"
|
|
11
10
|
import type { CoverageCell } from "#layers/manifest"
|
|
11
|
+
import { stringifyJSON } from "#values/json"
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A `source_present` layer has one coverage row for each cell reached by the authority's polygons.
|
package/lib/layers/manifest.ts
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { supportsExclusion, CoverageBasis } from "@mailwoman/evidence"
|
|
9
|
+
import { assertAdmissibleLicenseExpression } from "@mailwoman/license/obligations"
|
|
10
|
+
import { sql } from "kysely"
|
|
9
11
|
|
|
10
|
-
import { parseJSONStrict, stringifyJSON } from "#json"
|
|
11
12
|
import { assertTierMatchesLicense } from "#layers/publication"
|
|
12
13
|
import { LayerFreshnessPolicy, LayerTier, type layerschemahandle } from "#layers/schema"
|
|
13
|
-
import {
|
|
14
|
+
import { parseJSONStrict, stringifyJSON } from "#values/json"
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Join keys available in a layer.
|
|
@@ -370,10 +371,78 @@ export async function writeLayerManifest(db: layerschemahandle, manifest: LayerM
|
|
|
370
371
|
.execute()
|
|
371
372
|
}
|
|
372
373
|
|
|
374
|
+
/**
|
|
375
|
+
* Whether a layer database holds a `layer_manifest` table.
|
|
376
|
+
*/
|
|
377
|
+
export const LayerManifestState = {
|
|
378
|
+
/**
|
|
379
|
+
* The table holds one valid row.
|
|
380
|
+
*/
|
|
381
|
+
Present: "present",
|
|
382
|
+
/**
|
|
383
|
+
* The database has no `layer_manifest` table, so it records no identity, license or provenance.
|
|
384
|
+
*
|
|
385
|
+
* An artifact built before the layer interface reads this way until it is rebuilt.
|
|
386
|
+
*/
|
|
387
|
+
Absent: "absent",
|
|
388
|
+
} as const
|
|
389
|
+
|
|
390
|
+
export type LayerManifestState = (typeof LayerManifestState)[keyof typeof LayerManifestState]
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* The result of {@linkcode probeLayerManifest}.
|
|
394
|
+
*/
|
|
395
|
+
export type LayerManifestRead =
|
|
396
|
+
| { state: typeof LayerManifestState.Present; manifest: LayerManifest }
|
|
397
|
+
| {
|
|
398
|
+
state: typeof LayerManifestState.Absent
|
|
399
|
+
/**
|
|
400
|
+
* Why no manifest was read.
|
|
401
|
+
* A report prints it beside the file's path.
|
|
402
|
+
*/
|
|
403
|
+
reason: string
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Read and validate the manifest, or report that the database has no manifest table.
|
|
408
|
+
*
|
|
409
|
+
* Only a missing table reads as {@link LayerManifestState.Absent}.
|
|
410
|
+
* An empty table, several rows or an invalid row throws, as {@linkcode readLayerManifest} does.
|
|
411
|
+
*
|
|
412
|
+
* @throws When the table exists and its contents can't be read as one valid manifest.
|
|
413
|
+
*/
|
|
414
|
+
export async function probeLayerManifest(db: layerschemahandle): Promise<LayerManifestRead> {
|
|
415
|
+
const table = await db
|
|
416
|
+
.selectFrom(sql<{ type: string; name: string }>`sqlite_master`.as("master"))
|
|
417
|
+
.select("master.name")
|
|
418
|
+
.where("master.type", "=", "table")
|
|
419
|
+
.where("master.name", "=", "layer_manifest")
|
|
420
|
+
.executeTakeFirst()
|
|
421
|
+
|
|
422
|
+
if (!table) {
|
|
423
|
+
return { state: LayerManifestState.Absent, reason: "the database has no layer_manifest table" }
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return { state: LayerManifestState.Present, manifest: await readManifestRow(db) }
|
|
427
|
+
}
|
|
428
|
+
|
|
373
429
|
/**
|
|
374
430
|
* Read and validate the manifest.
|
|
431
|
+
*
|
|
432
|
+
* @throws When the database has no `layer_manifest` table, or the table holds other than one
|
|
433
|
+
* valid row. {@linkcode probeLayerManifest} reports the missing table as a state instead.
|
|
375
434
|
*/
|
|
376
435
|
export async function readLayerManifest(db: layerschemahandle): Promise<LayerManifest> {
|
|
436
|
+
const read = await probeLayerManifest(db)
|
|
437
|
+
|
|
438
|
+
if (read.state === LayerManifestState.Absent) {
|
|
439
|
+
throw new Error(`layer manifest: ${read.reason}`)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return read.manifest
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
async function readManifestRow(db: layerschemahandle): Promise<LayerManifest> {
|
|
377
446
|
const rows = await db.selectFrom("layer_manifest").selectAll().execute()
|
|
378
447
|
|
|
379
448
|
if (rows.length !== 1) {
|
|
@@ -460,3 +529,26 @@ export async function readLayerCoverage(db: layerschemahandle, h3Cell: number):
|
|
|
460
529
|
|
|
461
530
|
return cell
|
|
462
531
|
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* The source names in a manifest's `source`, which a build joins with `+`.
|
|
535
|
+
*
|
|
536
|
+
* Each name drops a version after `@`, as in `admin-global-priority@2026-11-18`, and a scope
|
|
537
|
+
* after `:`, as in `openstreetmap:de`, because the bare name is what a reader looks up:
|
|
538
|
+
* another layer's manifest name, or a source's location.
|
|
539
|
+
*
|
|
540
|
+
* A `:` that begins `://` belongs to a URL the build recorded as its source,
|
|
541
|
+
* such as `https://api.os.uk/downloads/v1/products/OpenUPRN`, and the name keeps it.
|
|
542
|
+
*/
|
|
543
|
+
export function manifestSourceNames(source: string): string[] {
|
|
544
|
+
return source
|
|
545
|
+
.split("+")
|
|
546
|
+
.map((part) =>
|
|
547
|
+
part
|
|
548
|
+
.trim()
|
|
549
|
+
.split("@")[0]!
|
|
550
|
+
.split(/:(?!\/\/)/)[0]!
|
|
551
|
+
.trim()
|
|
552
|
+
)
|
|
553
|
+
.filter((part) => part.length > 0)
|
|
554
|
+
}
|