@mailwoman/core 9.3.0 → 10.0.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/lib/coarse-placer/tools/{build-dataset.ts → build/dataset.ts} +2 -1
- package/lib/coarse-placer/tools/{build-outlier-latin.ts → build/outlier/latin.ts} +4 -3
- package/lib/coarse-placer/tools/{eval-openset.ts → eval/openset.ts} +11 -7
- package/lib/coarse-placer/tools/{eval-quant-compare.ts → eval/quant-compare.ts} +2 -1
- package/lib/coarse-placer/tools/eval.ts +2 -2
- package/lib/coarse-placer/tools/index.ts +7 -7
- package/lib/coarse-placer/tools/train.ts +4 -6
- package/lib/decoder/build-tree.ts +2 -1
- package/lib/decoder/containment.ts +2 -1
- package/lib/decoder/index.ts +5 -5
- package/lib/decoder/parse-diff.ts +1 -1
- package/lib/decoder/proposals-to-tree.ts +3 -1
- package/lib/decoder/{serialize-json.ts → serialize/json.ts} +3 -2
- package/lib/decoder/{serialize-tuples.ts → serialize/tuples.ts} +2 -1
- package/lib/decoder/{tree-shape.ts → tree/shape.ts} +7 -10
- package/lib/decoder/types.ts +1 -3
- package/lib/decoder/unknown-spans.ts +1 -1
- package/lib/decoder/validate-tree.ts +2 -1
- package/lib/fs/readers/stat.ts +244 -0
- package/lib/fs/readers.ts +38 -270
- package/lib/fs/streams.ts +58 -0
- package/lib/fs/writers.ts +5 -5
- package/lib/fs/zip.ts +64 -8
- package/lib/git.ts +26 -0
- package/lib/layers/coverage.ts +3 -2
- package/lib/layers/manifest.ts +2 -4
- package/lib/layers/schema.ts +0 -1
- package/lib/license/configured.ts +2 -2
- package/lib/license/docs-site.ts +1 -15
- package/lib/license/index.ts +2 -2
- package/lib/license/obligations.ts +4 -1
- package/lib/license/stamp.ts +1 -1
- package/lib/license/status.ts +1 -1
- package/lib/locale/locale.ts +2 -1
- package/lib/locale/registry.ts +2 -1
- package/lib/module/resolve-from.ts +16 -4
- package/lib/objects.ts +9 -1
- package/lib/overture-pins.ts +24 -0
- package/lib/pipeline/client-result.ts +82 -0
- package/lib/pipeline/index.ts +1 -1
- package/lib/pipeline/preferences.ts +13 -0
- package/lib/pipeline/result.ts +84 -0
- package/lib/pipeline/runtime-pipeline.ts +10 -17
- package/lib/pipeline/types.ts +28 -88
- package/lib/policy/defaults.ts +2 -1
- package/lib/policy/policy.ts +3 -1
- package/lib/policy/registry.ts +3 -1
- package/lib/process.ts +3 -1
- package/lib/resolver/authoritative-provider.ts +1 -1
- package/lib/resolver/index.ts +1 -8
- package/lib/resolver/lookup-types.ts +8 -0
- package/lib/resolver/synthetic-id-ranges.ts +83 -0
- package/lib/resolver/types.ts +2 -9
- package/lib/resources/whosonfirst/placetypes/Placetype.ts +7 -6
- package/lib/scripting/arguments.ts +34 -0
- package/lib/scripting/utils/index.ts +1 -1
- package/lib/strings/case.ts +13 -2
- package/lib/strings/format.ts +15 -0
- package/lib/tokenization/Graph.ts +3 -4
- package/lib/tools/{download-libpostal-resources.ts → download/libpostal-resources.ts} +3 -2
- package/lib/tools/generate-language-types.ts +3 -4
- package/lib/tools/index.ts +2 -2
- package/lib/types/classifier.ts +2 -1
- package/lib/types/index.ts +0 -1
- package/lib/types/mapping.ts +2 -1
- package/lib/workspaces.ts +104 -0
- package/out/api/APIClient.d.ts.map +1 -1
- package/out/api/arcgis.d.ts.map +1 -1
- package/out/api/defaults.d.ts.map +1 -1
- package/out/api/headless.d.ts.map +1 -1
- package/out/api/ogc.d.ts.map +1 -1
- package/out/api/paced-client.js.map +1 -1
- package/out/api/pacer.d.ts.map +1 -1
- package/out/api/pacer.js.map +1 -1
- package/out/api/responses.d.ts.map +1 -1
- package/out/api/{test-clocks.d.ts → test/clocks.d.ts} +1 -1
- package/out/api/test/clocks.d.ts.map +1 -0
- package/out/api/{test-clocks.js → test/clocks.js} +1 -1
- package/out/api/test/clocks.js.map +1 -0
- package/out/api/{test-transport.d.ts → test/transport.d.ts} +1 -1
- package/out/api/test/transport.d.ts.map +1 -0
- package/out/api/{test-transport.js → test/transport.js} +1 -1
- package/out/api/test/transport.js.map +1 -0
- package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
- package/out/coarse-placer/coarse-placer.js.map +1 -1
- package/out/coarse-placer/featurize.d.ts.map +1 -1
- package/out/coarse-placer/tools/{build-dataset.d.ts → build/dataset.d.ts} +1 -1
- package/out/coarse-placer/tools/build/dataset.d.ts.map +1 -0
- package/out/coarse-placer/tools/{build-dataset.js → build/dataset.js} +3 -2
- package/out/coarse-placer/tools/build/dataset.js.map +1 -0
- package/out/coarse-placer/tools/{build-outlier-exposure.d.ts → build/outlier/exposure.d.ts} +1 -1
- package/out/coarse-placer/tools/build/outlier/exposure.d.ts.map +1 -0
- package/out/coarse-placer/tools/{build-outlier-exposure.js → build/outlier/exposure.js} +1 -1
- package/out/coarse-placer/tools/build/outlier/exposure.js.map +1 -0
- package/out/coarse-placer/tools/{build-outlier-latin.d.ts → build/outlier/latin.d.ts} +3 -3
- package/out/coarse-placer/tools/build/outlier/latin.d.ts.map +1 -0
- package/out/coarse-placer/tools/{build-outlier-latin.js → build/outlier/latin.js} +4 -3
- package/out/coarse-placer/tools/build/outlier/latin.js.map +1 -0
- package/out/coarse-placer/tools/{build-outlier-oa.d.ts → build/outlier/oa.d.ts} +1 -1
- package/out/coarse-placer/tools/build/outlier/oa.d.ts.map +1 -0
- package/out/coarse-placer/tools/{build-outlier-oa.js → build/outlier/oa.js} +1 -1
- package/out/coarse-placer/tools/build/outlier/oa.js.map +1 -0
- package/out/coarse-placer/tools/country-sets.d.ts.map +1 -1
- package/out/coarse-placer/tools/{eval-latin-offmap.d.ts → eval/latin-offmap.d.ts} +1 -1
- package/out/coarse-placer/tools/eval/latin-offmap.d.ts.map +1 -0
- package/out/coarse-placer/tools/{eval-latin-offmap.js → eval/latin-offmap.js} +1 -1
- package/out/coarse-placer/tools/eval/latin-offmap.js.map +1 -0
- package/out/coarse-placer/tools/{eval-openset.d.ts → eval/openset.d.ts} +1 -1
- package/out/coarse-placer/tools/eval/openset.d.ts.map +1 -0
- package/out/coarse-placer/tools/{eval-openset.js → eval/openset.js} +10 -7
- package/out/coarse-placer/tools/eval/openset.js.map +1 -0
- package/out/coarse-placer/tools/{eval-quant-compare.d.ts → eval/quant-compare.d.ts} +1 -1
- package/out/coarse-placer/tools/eval/quant-compare.d.ts.map +1 -0
- package/out/coarse-placer/tools/{eval-quant-compare.js → eval/quant-compare.js} +2 -2
- package/out/coarse-placer/tools/eval/quant-compare.js.map +1 -0
- package/out/coarse-placer/tools/eval.js +2 -2
- package/out/coarse-placer/tools/eval.js.map +1 -1
- package/out/coarse-placer/tools/index.d.ts +7 -7
- package/out/coarse-placer/tools/index.js +7 -7
- package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
- package/out/coarse-placer/tools/quantize.js.map +1 -1
- package/out/coarse-placer/tools/train.d.ts.map +1 -1
- package/out/coarse-placer/tools/train.js +2 -3
- package/out/coarse-placer/tools/train.js.map +1 -1
- package/out/data-root.js.map +1 -1
- package/out/decoder/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js.map +1 -1
- package/out/decoder/containment.d.ts +2 -2
- package/out/decoder/containment.d.ts.map +1 -1
- package/out/decoder/containment.js.map +1 -1
- package/out/decoder/index.d.ts +5 -5
- package/out/decoder/index.js +5 -5
- package/out/decoder/parse-diff.js +1 -1
- package/out/decoder/parse-diff.js.map +1 -1
- package/out/decoder/proposals-to-tree.d.ts +2 -1
- package/out/decoder/proposals-to-tree.d.ts.map +1 -1
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/{serialize-json.d.ts → serialize/json.d.ts} +2 -2
- package/out/decoder/serialize/json.d.ts.map +1 -0
- package/out/decoder/{serialize-json.js → serialize/json.js} +2 -2
- package/out/decoder/serialize/json.js.map +1 -0
- package/out/decoder/{serialize-tuples.d.ts → serialize/tuples.d.ts} +2 -2
- package/out/decoder/serialize/tuples.d.ts.map +1 -0
- package/out/decoder/{serialize-tuples.js → serialize/tuples.js} +1 -1
- package/out/decoder/serialize/tuples.js.map +1 -0
- package/out/decoder/{serialize-xml.d.ts → serialize/xml.d.ts} +1 -1
- package/out/decoder/serialize/xml.d.ts.map +1 -0
- package/out/decoder/{serialize-xml.js → serialize/xml.js} +1 -1
- package/out/decoder/serialize/xml.js.map +1 -0
- package/out/decoder/{tree-shape.d.ts → tree/shape.d.ts} +5 -9
- package/out/decoder/tree/shape.d.ts.map +1 -0
- package/out/decoder/{tree-shape.js → tree/shape.js} +6 -10
- package/out/decoder/tree/shape.js.map +1 -0
- package/out/decoder/{tree-walk.d.ts → tree/walk.d.ts} +1 -1
- package/out/decoder/tree/walk.d.ts.map +1 -0
- package/out/decoder/{tree-walk.js → tree/walk.js} +1 -1
- package/out/decoder/tree/walk.js.map +1 -0
- package/out/decoder/types.d.ts +1 -2
- 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/decoder/unknown-spans.js +1 -1
- package/out/decoder/validate-tree.d.ts +1 -1
- package/out/decoder/validate-tree.d.ts.map +1 -1
- package/out/decoder/validate-tree.js.map +1 -1
- package/out/env/index.d.ts +1 -1
- package/out/env/schema.d.ts +4 -4
- package/out/errors/schema.d.ts.map +1 -1
- package/out/errors/schema.js.map +1 -1
- package/out/fs/formatters.d.ts.map +1 -1
- package/out/fs/formatters.js.map +1 -1
- package/out/fs/readers/stat.d.ts +126 -0
- package/out/fs/readers/stat.d.ts.map +1 -0
- package/out/fs/readers/stat.js +202 -0
- package/out/fs/readers/stat.js.map +1 -0
- package/out/fs/readers.d.ts +16 -149
- package/out/fs/readers.d.ts.map +1 -1
- package/out/fs/readers.js +19 -230
- package/out/fs/readers.js.map +1 -1
- package/out/fs/streams.d.ts +33 -0
- package/out/fs/streams.d.ts.map +1 -1
- package/out/fs/streams.js +49 -0
- package/out/fs/streams.js.map +1 -1
- package/out/fs/writers.d.ts +5 -5
- package/out/fs/writers.js +5 -5
- package/out/fs/zip.d.ts +21 -2
- package/out/fs/zip.d.ts.map +1 -1
- package/out/fs/zip.js +36 -8
- package/out/fs/zip.js.map +1 -1
- package/out/git.d.ts +15 -0
- package/out/git.d.ts.map +1 -1
- package/out/git.js +22 -0
- package/out/git.js.map +1 -1
- package/out/html/document.js.map +1 -1
- package/out/json.d.ts.map +1 -1
- package/out/layers/coverage.d.ts +1 -1
- package/out/layers/coverage.d.ts.map +1 -1
- package/out/layers/coverage.js +1 -2
- package/out/layers/coverage.js.map +1 -1
- package/out/layers/manifest.d.ts +2 -2
- package/out/layers/manifest.d.ts.map +1 -1
- package/out/layers/manifest.js +2 -3
- package/out/layers/manifest.js.map +1 -1
- package/out/layers/schema.d.ts +0 -1
- package/out/layers/schema.d.ts.map +1 -1
- package/out/layers/schema.js +0 -3
- package/out/layers/schema.js.map +1 -1
- package/out/license/configured.d.ts +1 -1
- package/out/license/configured.d.ts.map +1 -1
- package/out/license/configured.js +2 -2
- package/out/license/configured.js.map +1 -1
- package/out/license/docs-site.d.ts +0 -6
- package/out/license/docs-site.d.ts.map +1 -1
- package/out/license/docs-site.js +1 -12
- package/out/license/docs-site.js.map +1 -1
- package/out/license/index.d.ts +2 -2
- package/out/license/index.d.ts.map +1 -1
- package/out/license/index.js +2 -2
- package/out/license/index.js.map +1 -1
- package/out/license/{key-file.d.ts → key/file.d.ts} +1 -1
- package/out/license/key/file.d.ts.map +1 -0
- package/out/license/{key-file.js → key/file.js} +1 -1
- package/out/license/key/file.js.map +1 -0
- package/out/license/{key.d.ts → key/index.d.ts} +1 -1
- package/out/license/key/index.d.ts.map +1 -0
- package/out/license/{key.js → key/index.js} +1 -1
- package/out/license/key/index.js.map +1 -0
- package/out/license/obligations.d.ts +1 -1
- package/out/license/obligations.d.ts.map +1 -1
- package/out/license/obligations.js +3 -0
- package/out/license/obligations.js.map +1 -1
- package/out/license/publication.js.map +1 -1
- package/out/license/register.d.ts.map +1 -1
- package/out/license/stamp.d.ts +1 -1
- package/out/license/stamp.d.ts.map +1 -1
- package/out/license/status.js +1 -1
- package/out/license/status.js.map +1 -1
- package/out/locale/locale.d.ts +1 -1
- package/out/locale/locale.d.ts.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.d.ts.map +1 -1
- package/out/logging/shared.d.ts.map +1 -1
- package/out/module/resolve-from.d.ts +12 -3
- package/out/module/resolve-from.d.ts.map +1 -1
- package/out/module/resolve-from.js.map +1 -1
- package/out/module/resolvers.js.map +1 -1
- package/out/objects.d.ts +6 -0
- package/out/objects.d.ts.map +1 -1
- package/out/objects.js +8 -1
- package/out/objects.js.map +1 -1
- package/out/overture-pins.d.ts +24 -0
- package/out/overture-pins.d.ts.map +1 -0
- package/out/overture-pins.js +24 -0
- package/out/overture-pins.js.map +1 -0
- package/out/paths.js.map +1 -1
- package/out/pipeline/client-result.d.ts +84 -0
- package/out/pipeline/client-result.d.ts.map +1 -0
- package/out/pipeline/client-result.js +12 -0
- package/out/pipeline/client-result.js.map +1 -0
- package/out/pipeline/index.d.ts +1 -1
- package/out/pipeline/index.d.ts.map +1 -1
- package/out/pipeline/preferences.d.ts +13 -0
- package/out/pipeline/preferences.d.ts.map +1 -0
- package/out/pipeline/preferences.js +7 -0
- package/out/pipeline/preferences.js.map +1 -0
- package/out/pipeline/result.d.ts +72 -0
- package/out/pipeline/result.d.ts.map +1 -0
- package/out/pipeline/result.js +7 -0
- package/out/pipeline/result.js.map +1 -0
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +7 -13
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/span-proposer.js.map +1 -1
- package/out/pipeline/types.d.ts +23 -85
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +2 -0
- package/out/pipeline/types.js.map +1 -1
- package/out/policy/defaults.d.ts +1 -1
- package/out/policy/defaults.d.ts.map +1 -1
- package/out/policy/defaults.js +1 -1
- package/out/policy/defaults.js.map +1 -1
- package/out/policy/policy.d.ts +2 -1
- package/out/policy/policy.d.ts.map +1 -1
- package/out/policy/proposal-collection.js.map +1 -1
- package/out/policy/registry.d.ts +2 -1
- package/out/policy/registry.d.ts.map +1 -1
- package/out/policy/registry.js.map +1 -1
- package/out/process.d.ts +2 -2
- package/out/process.d.ts.map +1 -1
- package/out/process.js.map +1 -1
- package/out/random.d.ts.map +1 -1
- package/out/release-config.js.map +1 -1
- package/out/resolver/authoritative-provider.d.ts +1 -1
- package/out/resolver/authoritative-provider.d.ts.map +1 -1
- package/out/resolver/fixture-authoritative-provider.js.map +1 -1
- package/out/resolver/index.d.ts +2 -2
- package/out/resolver/index.d.ts.map +1 -1
- package/out/resolver/index.js +1 -1
- package/out/resolver/index.js.map +1 -1
- package/out/resolver/lookup-types.d.ts +8 -0
- package/out/resolver/lookup-types.d.ts.map +1 -1
- package/out/resolver/synthetic-id-ranges.d.ts +66 -0
- package/out/resolver/synthetic-id-ranges.d.ts.map +1 -0
- package/out/resolver/synthetic-id-ranges.js +73 -0
- package/out/resolver/synthetic-id-ranges.js.map +1 -0
- package/out/resolver/types.d.ts +1 -2
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js +0 -1
- package/out/resolver/types.js.map +1 -1
- package/out/resources/languages/index.js.map +1 -1
- package/out/resources/languages/types.gen.d.ts.map +1 -1
- package/out/resources/locale.d.ts.map +1 -1
- package/out/resources/set.d.ts.map +1 -1
- package/out/resources/set.js.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.js +7 -6
- package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts +1 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
- package/out/routing/index.d.ts.map +1 -1
- package/out/routing/index.js.map +1 -1
- package/out/scripting/arguments.d.ts +7 -0
- package/out/scripting/arguments.d.ts.map +1 -1
- package/out/scripting/arguments.js +29 -0
- package/out/scripting/arguments.js.map +1 -1
- package/out/scripting/command.d.ts.map +1 -1
- package/out/scripting/ingest-chunk-script.d.ts.map +1 -1
- package/out/scripting/utils/index.d.ts +1 -1
- package/out/scripting/utils/index.d.ts.map +1 -1
- package/out/scripting/utils/index.js +1 -1
- package/out/scripting/utils/index.js.map +1 -1
- package/out/strings/case.d.ts +3 -0
- package/out/strings/case.d.ts.map +1 -1
- package/out/strings/case.js +12 -2
- package/out/strings/case.js.map +1 -1
- package/out/strings/format.d.ts +6 -0
- package/out/strings/format.d.ts.map +1 -1
- package/out/strings/format.js +12 -0
- package/out/strings/format.js.map +1 -1
- package/out/strings/python-json.js.map +1 -1
- package/out/tokenization/Graph.d.ts +3 -0
- package/out/tokenization/Graph.d.ts.map +1 -1
- package/out/tokenization/Graph.js +0 -4
- package/out/tokenization/Graph.js.map +1 -1
- package/out/tokenization/Span.d.ts.map +1 -1
- package/out/tokenization/Span.js.map +1 -1
- package/out/tokenization/normalizer.d.ts.map +1 -1
- package/out/tokenization/normalizer.js.map +1 -1
- package/out/tools/{download-libpostal-resources.d.ts → download/libpostal-resources.d.ts} +1 -1
- package/out/tools/download/libpostal-resources.d.ts.map +1 -0
- package/out/tools/{download-libpostal-resources.js → download/libpostal-resources.js} +4 -3
- package/out/tools/download/libpostal-resources.js.map +1 -0
- package/out/tools/{download-ssl-address.d.ts → download/ssl-address.d.ts} +1 -1
- package/out/tools/download/ssl-address.d.ts.map +1 -0
- package/out/tools/{download-ssl-address.js → download/ssl-address.js} +1 -1
- package/out/tools/download/ssl-address.js.map +1 -0
- package/out/tools/generate-language-types.d.ts.map +1 -1
- package/out/tools/generate-language-types.js +3 -4
- package/out/tools/generate-language-types.js.map +1 -1
- package/out/tools/index.d.ts +2 -2
- package/out/tools/index.js +2 -2
- package/out/types/Classification.d.ts +2 -2
- package/out/types/Classification.d.ts.map +1 -1
- package/out/types/classifier.d.ts +1 -1
- package/out/types/classifier.d.ts.map +1 -1
- package/out/types/index.d.ts +0 -1
- package/out/types/index.d.ts.map +1 -1
- package/out/types/index.js +0 -1
- package/out/types/index.js.map +1 -1
- package/out/types/mapping.d.ts +1 -1
- package/out/types/mapping.d.ts.map +1 -1
- package/out/types/mapping.js.map +1 -1
- package/out/utils/time.js.map +1 -1
- package/out/workspaces.d.ts +31 -0
- package/out/workspaces.d.ts.map +1 -0
- package/out/workspaces.js +72 -0
- package/out/workspaces.js.map +1 -0
- package/package.json +84 -55
- package/lib/resolver/placetype-map.ts +0 -130
- package/lib/types/component.ts +0 -96
- package/out/api/test-clocks.d.ts.map +0 -1
- package/out/api/test-clocks.js.map +0 -1
- package/out/api/test-transport.d.ts.map +0 -1
- package/out/api/test-transport.js.map +0 -1
- package/out/coarse-placer/tools/build-dataset.d.ts.map +0 -1
- package/out/coarse-placer/tools/build-dataset.js.map +0 -1
- package/out/coarse-placer/tools/build-outlier-exposure.d.ts.map +0 -1
- package/out/coarse-placer/tools/build-outlier-exposure.js.map +0 -1
- package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +0 -1
- package/out/coarse-placer/tools/build-outlier-latin.js.map +0 -1
- package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +0 -1
- package/out/coarse-placer/tools/build-outlier-oa.js.map +0 -1
- package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +0 -1
- package/out/coarse-placer/tools/eval-latin-offmap.js.map +0 -1
- package/out/coarse-placer/tools/eval-openset.d.ts.map +0 -1
- package/out/coarse-placer/tools/eval-openset.js.map +0 -1
- package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +0 -1
- package/out/coarse-placer/tools/eval-quant-compare.js.map +0 -1
- package/out/decoder/serialize-json.d.ts.map +0 -1
- package/out/decoder/serialize-json.js.map +0 -1
- package/out/decoder/serialize-tuples.d.ts.map +0 -1
- package/out/decoder/serialize-tuples.js.map +0 -1
- package/out/decoder/serialize-xml.d.ts.map +0 -1
- package/out/decoder/serialize-xml.js.map +0 -1
- package/out/decoder/tree-shape.d.ts.map +0 -1
- package/out/decoder/tree-shape.js.map +0 -1
- package/out/decoder/tree-walk.d.ts.map +0 -1
- package/out/decoder/tree-walk.js.map +0 -1
- package/out/license/key-file.d.ts.map +0 -1
- package/out/license/key-file.js.map +0 -1
- package/out/license/key.d.ts.map +0 -1
- package/out/license/key.js.map +0 -1
- package/out/resolver/placetype-map.d.ts +0 -76
- package/out/resolver/placetype-map.d.ts.map +0 -1
- package/out/resolver/placetype-map.js +0 -106
- package/out/resolver/placetype-map.js.map +0 -1
- package/out/tools/download-libpostal-resources.d.ts.map +0 -1
- package/out/tools/download-libpostal-resources.js.map +0 -1
- package/out/tools/download-ssl-address.d.ts.map +0 -1
- package/out/tools/download-ssl-address.js.map +0 -1
- package/out/types/component.d.ts +0 -50
- package/out/types/component.d.ts.map +0 -1
- package/out/types/component.js +0 -84
- package/out/types/component.js.map +0 -1
- /package/lib/api/{test-clocks.ts → test/clocks.ts} +0 -0
- /package/lib/api/{test-transport.ts → test/transport.ts} +0 -0
- /package/lib/coarse-placer/tools/{build-outlier-exposure.ts → build/outlier/exposure.ts} +0 -0
- /package/lib/coarse-placer/tools/{build-outlier-oa.ts → build/outlier/oa.ts} +0 -0
- /package/lib/coarse-placer/tools/{eval-latin-offmap.ts → eval/latin-offmap.ts} +0 -0
- /package/lib/decoder/{serialize-xml.ts → serialize/xml.ts} +0 -0
- /package/lib/decoder/{tree-walk.ts → tree/walk.ts} +0 -0
- /package/lib/license/{key-file.ts → key/file.ts} +0 -0
- /package/lib/license/{key.ts → key/index.ts} +0 -0
- /package/lib/tools/{download-ssl-address.ts → download/ssl-address.ts} +0 -0
|
@@ -25,6 +25,7 @@ import { COUNTRIES, IN_MAP_EU, NEW_EU } from "#coarse-placer/tools/country-sets"
|
|
|
25
25
|
import { defaultDataDir } from "#coarse-placer/tools/paths"
|
|
26
26
|
import { errorMessage } from "#errors/schema"
|
|
27
27
|
import { writeLocalTextFile, makeDirectories } from "#fs/writers"
|
|
28
|
+
import { OVERTURE_ADDRESSES_RELEASE } from "#overture-pins"
|
|
28
29
|
import { dataRootPath } from "#utils"
|
|
29
30
|
|
|
30
31
|
interface DatasetRow {
|
|
@@ -108,7 +109,7 @@ export async function buildDataset(
|
|
|
108
109
|
"*.parquet"
|
|
109
110
|
)
|
|
110
111
|
|
|
111
|
-
const OVERTURE_DIR = dataRootPath("overture",
|
|
112
|
+
const OVERTURE_DIR = dataRootPath("overture", OVERTURE_ADDRESSES_RELEASE)
|
|
112
113
|
await makeDirectories(OUT_DIR)
|
|
113
114
|
|
|
114
115
|
// Heavy dep (devDependency — operator tooling), lazy-imported so loading the tools barrel stays cheap.
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* without rebuilding train/val).
|
|
21
21
|
*
|
|
22
22
|
* Run: `mailwoman placer build-dataset --outliers latin [--per-country 6000] [--overture
|
|
23
|
-
* $MAILWOMAN_DATA_ROOT/overture
|
|
23
|
+
* $MAILWOMAN_DATA_ROOT/overture/<release>]` (default: the addresses-theme pin, `OVERTURE_ADDRESSES_RELEASE`)
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { type PathBuilderLike, resolvePath } from "path-ts"
|
|
@@ -30,6 +30,7 @@ import { assembleOutlierRow, collectOutlierRows, otherRowsJSONL } from "#coarse-
|
|
|
30
30
|
import { defaultDataDir } from "#coarse-placer/tools/paths"
|
|
31
31
|
import { errorMessage } from "#errors/schema"
|
|
32
32
|
import { writeLocalTextFile, appendLocalTextFile } from "#fs/writers"
|
|
33
|
+
import { OVERTURE_ADDRESSES_RELEASE } from "#overture-pins"
|
|
33
34
|
import { dataRootPath } from "#utils"
|
|
34
35
|
|
|
35
36
|
interface LatinTestRow {
|
|
@@ -48,7 +49,7 @@ export interface BuildOutlierLatinOptions {
|
|
|
48
49
|
*/
|
|
49
50
|
perCountry?: number
|
|
50
51
|
/**
|
|
51
|
-
* Overture release dir. Default `$MAILWOMAN_DATA_ROOT/overture
|
|
52
|
+
* Overture release dir. Default `$MAILWOMAN_DATA_ROOT/overture/<OVERTURE_ADDRESSES_RELEASE>`.
|
|
52
53
|
*/
|
|
53
54
|
overture?: PathBuilderLike
|
|
54
55
|
/**
|
|
@@ -116,7 +117,7 @@ export async function buildOutlierLatin(
|
|
|
116
117
|
report?: (line: string) => void
|
|
117
118
|
): Promise<BuildOutlierLatinResult> {
|
|
118
119
|
const PER = options.perCountry ?? 6000
|
|
119
|
-
const overtureDir = options.overture || dataRootPath("overture",
|
|
120
|
+
const overtureDir = options.overture || dataRootPath("overture", OVERTURE_ADDRESSES_RELEASE)
|
|
120
121
|
const dataDir = options.data || defaultDataDir()
|
|
121
122
|
|
|
122
123
|
// Heavy dep (devDependency — operator tooling), lazy-imported so loading the tools barrel stays cheap.
|
|
@@ -204,17 +204,17 @@ export async function evalOpenSet(
|
|
|
204
204
|
*/
|
|
205
205
|
const inVec = (z: Float64Array): number[] => IN.map((c) => z[c]!)
|
|
206
206
|
|
|
207
|
-
function load(file: string)
|
|
208
|
-
return
|
|
207
|
+
function load(file: string) {
|
|
208
|
+
return JSONSpliterator.fromAsync<DataRow>(resolvePath(dataDir, file))
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
// Fit the Mahalanobis params on IN-MAP TRAIN logits (no test leak): per-class
|
|
212
212
|
// mean in the nIn-dim in-map-logit space + a tied (shared) covariance.
|
|
213
213
|
report?.("fitting Mahalanobis on in-map train logits…")
|
|
214
|
-
const trainRows =
|
|
214
|
+
const trainRows = load("train.jsonl")
|
|
215
215
|
const byClass = new Map<string, string[]>(COARSE_CLASSES.map((c): [string, string[]] => [c, []]))
|
|
216
216
|
|
|
217
|
-
for (const r of trainRows) {
|
|
217
|
+
for await (const r of trainRows) {
|
|
218
218
|
if (r.country === "OTHER") continue
|
|
219
219
|
const arr = byClass.get(r.country)
|
|
220
220
|
|
|
@@ -361,10 +361,14 @@ export async function evalOpenSet(
|
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
|
|
364
|
+
// the 11 countries only
|
|
365
|
+
const inmapScored = await load("test.jsonl")
|
|
366
|
+
.filter((r) => r.country !== "OTHER")
|
|
367
|
+
.map((r) => scoreRow(r.raw, r.country))
|
|
368
|
+
.toArray()
|
|
369
|
+
|
|
365
370
|
const heldout = (await readLatinOffmapRows<DataRow>(dataDir)).filter((r) => r.group === "heldout")
|
|
366
371
|
|
|
367
|
-
const inmapScored = inmapTest.map((r) => scoreRow(r.raw, r.country))
|
|
368
372
|
const heldoutScored = heldout.map((r) => scoreRow(r.raw, undefined))
|
|
369
373
|
|
|
370
374
|
// Honest threshold protocol: split each probe 50/50 (deterministic by index parity) into DEV + TEST.
|
|
@@ -459,7 +463,7 @@ export async function evalOpenSet(
|
|
|
459
463
|
const lines: string[] = [
|
|
460
464
|
`# Coarse-placer M2 Phase 1 — post-hoc open-set score comparison (#244)`,
|
|
461
465
|
"",
|
|
462
|
-
`_Frozen shipped model (\`${basename(modelDir)}\`), NO retrain. In-map test ${
|
|
466
|
+
`_Frozen shipped model (\`${basename(modelDir)}\`), NO retrain. In-map test ${inmapScored.length} rows ` +
|
|
463
467
|
`(11 countries); off-map HELDOUT ${heldout.length} rows (never-trained families: baltic/oceania/middle-east). ` +
|
|
464
468
|
`Mahalanobis fit on ≤${fitPerClass}/class in-map train logits. The 11-way routing is fixed; each score only ` +
|
|
465
469
|
`changes the reject decision._`,
|
|
@@ -76,9 +76,10 @@ export async function evalQuantCompare(options: EvalQuantCompareOptions = {}): P
|
|
|
76
76
|
const fp32 = await CoarsePlacer.fromArtifactDir(resolvePath(fp32Dir), { abstainBelow })
|
|
77
77
|
const int8 = await CoarsePlacer.fromArtifactDir(resolvePath(int8Dir), { abstainBelow })
|
|
78
78
|
|
|
79
|
-
const test = await
|
|
79
|
+
const test = await JSONSpliterator.fromAsync<TestRow>(resolvePath(dataDir, "test.jsonl")).toArray()
|
|
80
80
|
|
|
81
81
|
const classes = (await readLocalJSONFile<CoarsePlacerMeta>(resolvePath(fp32Dir, "meta.json"))).classes
|
|
82
|
+
|
|
82
83
|
let okF = 0
|
|
83
84
|
let okI = 0
|
|
84
85
|
let agree = 0
|
|
@@ -85,7 +85,7 @@ export async function evalCoarsePlacer(options: EvalCoarsePlacerOptions = {}): P
|
|
|
85
85
|
const meta = await readLocalJSONFile<CoarsePlacerMeta>(resolvePath(modelDir, "meta.json"))
|
|
86
86
|
const placer = await CoarsePlacer.fromArtifactDir(resolvePath(modelDir), { abstainBelow: abstain })
|
|
87
87
|
|
|
88
|
-
//
|
|
88
|
+
// Measure in-distribution accuracy, per-class results, and ECE.
|
|
89
89
|
let testN = 0
|
|
90
90
|
let correct = 0
|
|
91
91
|
const perClass: Record<string, { n: number; ok: number }> = {} // country → {n, ok}
|
|
@@ -160,7 +160,7 @@ export async function evalCoarsePlacer(options: EvalCoarsePlacerOptions = {}): P
|
|
|
160
160
|
console.log(confLines.toSorted().join("\n"))
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
//
|
|
163
|
+
// Measure abstention for multi-script inputs outside the map.
|
|
164
164
|
const msPath = repoRootPath("data", "eval", "multi-script", "v0.5.0-a0.jsonl")
|
|
165
165
|
|
|
166
166
|
try {
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
* `fnv-hash.ts` lives at the coarse-placer root because `featurize` hashes through it.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
export * from "#coarse-placer/tools/build
|
|
15
|
-
export * from "#coarse-placer/tools/build
|
|
16
|
-
export * from "#coarse-placer/tools/build
|
|
17
|
-
export * from "#coarse-placer/tools/build
|
|
14
|
+
export * from "#coarse-placer/tools/build/dataset"
|
|
15
|
+
export * from "#coarse-placer/tools/build/outlier/exposure"
|
|
16
|
+
export * from "#coarse-placer/tools/build/outlier/latin"
|
|
17
|
+
export * from "#coarse-placer/tools/build/outlier/oa"
|
|
18
18
|
export * from "#coarse-placer/tools/eval"
|
|
19
|
-
export * from "#coarse-placer/tools/eval
|
|
20
|
-
export * from "#coarse-placer/tools/eval
|
|
21
|
-
export * from "#coarse-placer/tools/eval
|
|
19
|
+
export * from "#coarse-placer/tools/eval/latin-offmap"
|
|
20
|
+
export * from "#coarse-placer/tools/eval/openset"
|
|
21
|
+
export * from "#coarse-placer/tools/eval/quant-compare"
|
|
22
22
|
export * from "#coarse-placer/tools/probe-frontier"
|
|
23
23
|
export * from "#coarse-placer/tools/quantize"
|
|
24
24
|
export * from "#coarse-placer/tools/train"
|
|
@@ -95,14 +95,12 @@ export async function trainCoarsePlacer(
|
|
|
95
95
|
const classIdx = new Map<string, number>(COARSE_CLASSES.map((c, i): [string, number] => [c, i]))
|
|
96
96
|
|
|
97
97
|
async function load(split: string): Promise<Sample[]> {
|
|
98
|
-
const rows = await Array.fromAsync(
|
|
99
|
-
JSONSpliterator.fromAsync<{ raw: string; country: string }>(resolvePath(dataDir, `${split}.jsonl`))
|
|
100
|
-
)
|
|
101
|
-
|
|
102
98
|
// Precompute features once: Int32Array of active indices + label id per row.
|
|
103
99
|
const out: Sample[] = []
|
|
104
100
|
|
|
105
|
-
for (const r of
|
|
101
|
+
for await (const r of JSONSpliterator.fromAsync<{ raw: string; country: string }>(
|
|
102
|
+
resolvePath(dataDir, `${split}.jsonl`)
|
|
103
|
+
)) {
|
|
106
104
|
const y = classIdx.get(r.country)
|
|
107
105
|
|
|
108
106
|
if (y === undefined) continue
|
|
@@ -199,7 +197,7 @@ export async function trainCoarsePlacer(
|
|
|
199
197
|
)
|
|
200
198
|
}
|
|
201
199
|
|
|
202
|
-
//
|
|
200
|
+
// Calibrate temperature by minimizing validation NLL through coarse and fine one-dimensional search.
|
|
203
201
|
function valNLL(T: number): number {
|
|
204
202
|
let nll = 0
|
|
205
203
|
|
|
@@ -23,10 +23,11 @@
|
|
|
23
23
|
* exposes as attributes.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
import type { BIOLabel, ComponentTag } from "@mailwoman/codex/component"
|
|
27
|
+
|
|
26
28
|
import type { Calibrator } from "#decoder/calibration"
|
|
27
29
|
import { containmentFor } from "#decoder/containment"
|
|
28
30
|
import type { AddressNode, AddressSystem, AddressTree, DecoderToken } from "#decoder/types"
|
|
29
|
-
import type { BIOLabel, ComponentTag } from "#types/component"
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Optional caller-supplied attribution stamped on every emitted node. The BIO stream comes from a single model, so
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
* call-site churn. See `AddressSystem` in `./types.ts`.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
+
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
32
|
+
|
|
31
33
|
import type { AddressSystem } from "#decoder/types"
|
|
32
|
-
import type { ComponentTag } from "#types/component"
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Preferred-parent ordering for each tag. Empty / missing = always root.
|
package/lib/decoder/index.ts
CHANGED
|
@@ -9,11 +9,11 @@ export * from "#decoder/calibration"
|
|
|
9
9
|
export * from "#decoder/containment"
|
|
10
10
|
export * from "#decoder/proposals-to-tree"
|
|
11
11
|
export * from "#decoder/resolve-proposal-overlaps"
|
|
12
|
-
export * from "#decoder/serialize
|
|
13
|
-
export * from "#decoder/tree
|
|
14
|
-
export * from "#decoder/tree
|
|
15
|
-
export * from "#decoder/serialize
|
|
16
|
-
export * from "#decoder/serialize
|
|
12
|
+
export * from "#decoder/serialize/json"
|
|
13
|
+
export * from "#decoder/tree/shape"
|
|
14
|
+
export * from "#decoder/tree/walk"
|
|
15
|
+
export * from "#decoder/serialize/tuples"
|
|
16
|
+
export * from "#decoder/serialize/xml"
|
|
17
17
|
export * from "#decoder/types"
|
|
18
18
|
export * from "#decoder/unknown-spans"
|
|
19
19
|
export * from "#decoder/validate-tree"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* its answer but lost 0.3 of confidence on the deciding span is a row about to flip, and an aggregate cannot say so.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import { flattenTreeNodes } from "#decoder/tree
|
|
30
|
+
import { flattenTreeNodes } from "#decoder/tree/shape"
|
|
31
31
|
import type { AddressTree } from "#decoder/types"
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
* pipeline.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
18
|
+
|
|
17
19
|
import type { AddressNode, AddressTree } from "#decoder/types"
|
|
18
20
|
import type { Span } from "#tokenization/index"
|
|
19
|
-
import type { ClassificationProposal, ClassificationProposalSource
|
|
21
|
+
import type { ClassificationProposal, ClassificationProposalSource } from "#types/index"
|
|
20
22
|
|
|
21
23
|
export function proposalsToTree(raw: string, proposals: readonly ClassificationProposal[]): AddressTree {
|
|
22
24
|
const roots: AddressNode[] = proposals.map((p) => ({
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* city-state. The shared span means every role gets the same `value`.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
17
|
+
|
|
18
|
+
import { slotNodes } from "#decoder/tree/walk"
|
|
17
19
|
import type { AddressNode, AddressTree } from "#decoder/types"
|
|
18
20
|
import { type UnknownSpan, unknownSpans } from "#decoder/unknown-spans"
|
|
19
|
-
import type { ComponentTag } from "#types/component"
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* A span the flat projection could not represent, and why.
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* use `decodeAsXML` when containment matters.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
14
|
+
|
|
13
15
|
import type { AddressNode, AddressTree } from "#decoder/types"
|
|
14
16
|
import { unknownSpans } from "#decoder/unknown-spans"
|
|
15
|
-
import type { ComponentTag } from "#types/component"
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Options for {@link decodeAsTuples}.
|
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
* and both behaviors are pinned by their consumers' boards.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
|
|
19
|
+
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
20
|
+
|
|
21
|
+
import { flatten } from "#decoder/serialize/tuples"
|
|
22
|
+
import { walkNodes } from "#decoder/tree/walk"
|
|
21
23
|
import type { AddressNode, AddressTree } from "#decoder/types"
|
|
22
|
-
import type { ComponentTag } from "#types/component"
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* True when every node in the tree either carries `tag` or bears no value — i.e. the only EVIDENCE in the parse is
|
|
@@ -93,10 +94,9 @@ export interface FlatTreeNode {
|
|
|
93
94
|
/**
|
|
94
95
|
* Flatten a tree to its nodes in SOURCE order — sorted by `start`, the same order `decodeAsTuples` means by it.
|
|
95
96
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* of 10** ordinary addresses, always with a child ahead of its parent:
|
|
97
|
+
* A traversal-order walk (depth-first onto a stack, then reversed) is the obvious implementation and is wrong here: it
|
|
98
|
+
* coincides with source order only while every parent's span precedes its children's, and the decoder does not promise
|
|
99
|
+
* it — measured, the two orders disagree on **7 of 10** ordinary addresses, always with a child ahead of its parent:
|
|
100
100
|
*
|
|
101
101
|
* Queen Street, Bristol street_suffix@6 before street@0
|
|
102
102
|
* Via Roma, 5, 50123 Firenze, … house_number@10 before street@0
|
|
@@ -104,9 +104,6 @@ export interface FlatTreeNode {
|
|
|
104
104
|
*
|
|
105
105
|
* Sorting is what the tuple projection already does, so this makes a rendered span list and `decodeAsTuples` agree by
|
|
106
106
|
* construction rather than by luck.
|
|
107
|
-
*
|
|
108
|
-
* The smoke test could not import the demo's copy (that would be a `mailwoman` → `docs` project reference, and `docs`
|
|
109
|
-
* already depends on `mailwoman`), which is why a third home was the only way to collapse them.
|
|
110
107
|
*/
|
|
111
108
|
export function flattenTreeNodes(tree?: AddressTree | null): FlatTreeNode[] {
|
|
112
109
|
if (!tree) return []
|
package/lib/decoder/types.ts
CHANGED
|
@@ -26,9 +26,7 @@
|
|
|
26
26
|
* essential.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
import type { BIOLabel, ComponentTag } from "
|
|
30
|
-
|
|
31
|
-
export { type BIOLabel, type ComponentTag } from "#types/component"
|
|
29
|
+
import type { BIOLabel, ComponentTag } from "@mailwoman/codex/component"
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
* A single token emitted by the model, paired with its predicted label and confidence.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* It mutates nothing and changes no serializer — wiring `unknown` into the JSON/XML/tuple contracts + the
|
|
13
13
|
* demo is the focused follow-up (#493). Byte-stable by construction, so it ships ahead of that work.
|
|
14
14
|
*/
|
|
15
|
-
import { walkNodes } from "#decoder/tree
|
|
15
|
+
import { walkNodes } from "#decoder/tree/walk"
|
|
16
16
|
import type { AddressTree } from "#decoder/types"
|
|
17
17
|
|
|
18
18
|
export interface UnknownSpan {
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
* postcode-only or city-only input is a degenerate-but-valid parse, not a violation.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
27
|
+
|
|
26
28
|
import { containmentFor } from "#decoder/containment"
|
|
27
29
|
import type { AddressNode, AddressTree } from "#decoder/types"
|
|
28
|
-
import type { ComponentTag } from "#types/component"
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Tags that cannot stand alone: each is a sub-component of a specific structural anchor (street / locality / venue /
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @file Filesystem metadata readers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { AssertionError } from "node:assert"
|
|
8
|
+
import type { Dirent, Mode, Stats } from "node:fs"
|
|
9
|
+
import {
|
|
10
|
+
open as openNative,
|
|
11
|
+
access,
|
|
12
|
+
constants,
|
|
13
|
+
lstat,
|
|
14
|
+
readlink,
|
|
15
|
+
realpath,
|
|
16
|
+
stat,
|
|
17
|
+
type FileHandle,
|
|
18
|
+
} from "node:fs/promises"
|
|
19
|
+
|
|
20
|
+
import { type PathBuilderLike, resolvePath } from "path-ts"
|
|
21
|
+
|
|
22
|
+
import { ByteFormatter, type ByteFormatterOptions } from "#fs/formatters"
|
|
23
|
+
|
|
24
|
+
// #region Stat utils
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Attempts to stat a file or directory.
|
|
28
|
+
*
|
|
29
|
+
* A `URL` is passed through rather than stringified: `node:fs` accepts a `file:` URL object, and rejects the string it
|
|
30
|
+
* prints — `stat("file:///etc/hostname")` is ENOENT, which this function reports as absence. Every caller that looks a
|
|
31
|
+
* file up by URL therefore read "not there" for everything, and `cli-native/command-router.ts` answered `Unknown
|
|
32
|
+
* command` for every command it has.
|
|
33
|
+
*
|
|
34
|
+
* @throws If the path exists but cannot be statted for some reason other than non-existence.
|
|
35
|
+
*/
|
|
36
|
+
export function tryStat(pathBuilderLike: PathBuilderLike | URL): Promise<Stats | null> {
|
|
37
|
+
const target = pathBuilderLike instanceof URL ? pathBuilderLike : pathBuilderLike.toString()
|
|
38
|
+
|
|
39
|
+
return stat(target).catch((error) => {
|
|
40
|
+
if (error.code === "ENOENT") return null
|
|
41
|
+
|
|
42
|
+
throw error
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Stat a file or directory, raising ENOENT when nothing is there.
|
|
48
|
+
*
|
|
49
|
+
* The throwing counterpart to {@linkcode tryStat}. Reach for this one where absence is a defect the caller wants
|
|
50
|
+
* reported, and for {@linkcode tryStat} where absence is an answer.
|
|
51
|
+
*/
|
|
52
|
+
export function statPath(path: PathBuilderLike | URL): Promise<Stats> {
|
|
53
|
+
return stat(path instanceof URL ? path : path.toString())
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Stat a path without following a symbolic link, so the answer describes the link itself.
|
|
58
|
+
*/
|
|
59
|
+
export function statLink(path: PathBuilderLike | URL): Promise<Stats> {
|
|
60
|
+
return lstat(path instanceof URL ? path : path.toString())
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Stat a path without following a symbolic link, answering `null` when nothing is there.
|
|
65
|
+
*
|
|
66
|
+
* The link-level counterpart to {@linkcode tryStat}.
|
|
67
|
+
*/
|
|
68
|
+
export function tryStatLink(path: PathBuilderLike | URL): Promise<Stats | null> {
|
|
69
|
+
return lstat(path instanceof URL ? path : path.toString()).catch((error) => {
|
|
70
|
+
if (error.code === "ENOENT") return null
|
|
71
|
+
|
|
72
|
+
throw error
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Whether a path exists, whatever it is.
|
|
78
|
+
*
|
|
79
|
+
* The asynchronous answer to `existsSync`, which is the single most-called synchronous builtin in the repository.
|
|
80
|
+
* Prefer {@linkcode isFile} or {@linkcode isDirectory} where the caller goes on to assume one or the other: a directory
|
|
81
|
+
* where a file was expected passes this check and fails the next line.
|
|
82
|
+
*/
|
|
83
|
+
export function pathExists(path: PathBuilderLike | URL): Promise<boolean> {
|
|
84
|
+
return tryStat(path).then((stats) => stats !== null)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Assert that a path exists, throwing an error if it does not.
|
|
89
|
+
*/
|
|
90
|
+
export function assertPathExists(path: PathBuilderLike | URL, message?: string): Promise<void> {
|
|
91
|
+
return pathExists(path).then((exists) => {
|
|
92
|
+
if (exists) return void 0
|
|
93
|
+
|
|
94
|
+
throw new AssertionError({
|
|
95
|
+
message: message ?? `Expected path to exist`,
|
|
96
|
+
expected: path.toString(),
|
|
97
|
+
actual: "not found",
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Whether a path exists and is a directory.
|
|
104
|
+
*/
|
|
105
|
+
export function isDirectory(path: PathBuilderLike | URL): Promise<boolean> {
|
|
106
|
+
return tryStat(path).then((stats) => stats?.isDirectory() ?? false)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Assert that a path exists and is a directory, throwing an error if it does not.
|
|
111
|
+
*
|
|
112
|
+
* @category Files
|
|
113
|
+
* @throws AssertionError if the path does not exist or is not a directory.
|
|
114
|
+
* @runtime node
|
|
115
|
+
*/
|
|
116
|
+
export function assertIsDirectory(path: PathBuilderLike | URL, message?: string): Promise<void> {
|
|
117
|
+
return statPath(path).then((stats) => {
|
|
118
|
+
if (stats.isDirectory()) {
|
|
119
|
+
return void 0
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
throw new AssertionError({
|
|
123
|
+
message: message ?? `Expected path to be a directory`,
|
|
124
|
+
expected: path.toString(),
|
|
125
|
+
actual: "not a directory",
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Whether a path exists and is a file.
|
|
132
|
+
*/
|
|
133
|
+
export function isFile(path: PathBuilderLike | URL): Promise<boolean> {
|
|
134
|
+
return tryStat(path).then((stats) => stats?.isFile() ?? false)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Whether a path exists and is a symbolic link.
|
|
139
|
+
*/
|
|
140
|
+
export function isSymbolicLink(path: PathBuilderLike | URL): Promise<boolean> {
|
|
141
|
+
return tryStatLink(path).then((stats) => stats?.isSymbolicLink() ?? false)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Whether a directory entry leads to a directory, symbolic links included.
|
|
146
|
+
*
|
|
147
|
+
* `Dirent.isDirectory()` is FALSE for a symbolic link to a directory, so a walk keyed on it alone skips every linked
|
|
148
|
+
* tree. A glob only descends into them when its `followSymlinks` option is `true`; a caller that walks links must use
|
|
149
|
+
* this helper so both traversals describe the same tree. A link is resolved through `stat`, which also answers `false`
|
|
150
|
+
* for a dangling one.
|
|
151
|
+
*/
|
|
152
|
+
export function entryLeadsToDirectory(entry: Dirent): Promise<boolean> {
|
|
153
|
+
if (entry.isDirectory()) return Promise.resolve(true)
|
|
154
|
+
|
|
155
|
+
if (!entry.isSymbolicLink()) return Promise.resolve(false)
|
|
156
|
+
|
|
157
|
+
return isDirectory(resolvePath(entry.parentPath, entry.name))
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The size of a file in bytes.
|
|
162
|
+
*
|
|
163
|
+
* @throws ENOENT when the file does not exist.
|
|
164
|
+
*/
|
|
165
|
+
export function readFileSize(path: PathBuilderLike | URL): Promise<number> {
|
|
166
|
+
return statPath(path).then((stats) => stats.size)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The size of a file, rendered in IEC units (`12.3 MiB`) — the unit for anything a machine measured.
|
|
171
|
+
*
|
|
172
|
+
* @throws ENOENT when the file does not exist.
|
|
173
|
+
*/
|
|
174
|
+
export async function formatFileSize(path: PathBuilderLike | URL, options?: ByteFormatterOptions): Promise<string> {
|
|
175
|
+
return ByteFormatter.formatIEC(await readFileSize(path), options)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Resolve a path to its canonical location, following every symbolic link.
|
|
180
|
+
*
|
|
181
|
+
* @throws ENOENT when nothing is there. {@linkcode tryRealPath} answers `null` instead.
|
|
182
|
+
*/
|
|
183
|
+
export function realPath(path: PathBuilderLike): Promise<string> {
|
|
184
|
+
return realpath(path.toString())
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Resolve a path to its canonical location, following every symbolic link.
|
|
189
|
+
*
|
|
190
|
+
* @returns The canonical path, or `null` when nothing is there.
|
|
191
|
+
*/
|
|
192
|
+
export function tryRealPath(path: PathBuilderLike): Promise<string | null> {
|
|
193
|
+
return realpath(path.toString()).catch((error) => {
|
|
194
|
+
if (error.code === "ENOENT") return null
|
|
195
|
+
|
|
196
|
+
throw error
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function open(path: PathBuilderLike | URL, flags?: string | number, mode?: Mode): Promise<FileHandle> {
|
|
201
|
+
return openNative(path instanceof URL ? path : path.toString(), flags, mode)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The target a symbolic link points at, verbatim — relative if it was written relative.
|
|
206
|
+
*
|
|
207
|
+
* @throws EINVAL when the path is not a link, ENOENT when nothing is there.
|
|
208
|
+
*/
|
|
209
|
+
export function readLink(path: PathBuilderLike): Promise<string> {
|
|
210
|
+
return readlink(path.toString())
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Whether the process may WRITE to a path.
|
|
215
|
+
*
|
|
216
|
+
* A permission question, not an existence one: `access` answers about the caller's credentials against the file as it
|
|
217
|
+
* stands, where a stat answers about the file. Absence reads as `false` here, which is what a caller checking "can I
|
|
218
|
+
* write here" means by it.
|
|
219
|
+
*/
|
|
220
|
+
export function isWritable(path: PathBuilderLike): Promise<boolean> {
|
|
221
|
+
return access(path.toString(), constants.W_OK).then(
|
|
222
|
+
() => true,
|
|
223
|
+
() => false
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Whether the process may EXECUTE a path.
|
|
229
|
+
*/
|
|
230
|
+
export function isExecutable(path: PathBuilderLike): Promise<boolean> {
|
|
231
|
+
return access(path.toString(), constants.X_OK).then(
|
|
232
|
+
() => true,
|
|
233
|
+
() => false
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A `file:` URL is passed through whole: `node:fs` accepts the object and rejects the string it prints.
|
|
239
|
+
*/
|
|
240
|
+
export function asTarget(path: PathBuilderLike | URL): URL | string {
|
|
241
|
+
return path instanceof URL ? path : path.toString()
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// #endregion
|