@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
package/lib/fs/readers.ts
CHANGED
|
@@ -8,224 +8,18 @@
|
|
|
8
8
|
* code makes a blocking filesystem call, and the `debt` check in `packages/repo-health` counts any that appears.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
open as openNative,
|
|
14
|
-
access,
|
|
15
|
-
constants,
|
|
16
|
-
glob,
|
|
17
|
-
lstat,
|
|
18
|
-
readFile,
|
|
19
|
-
readdir,
|
|
20
|
-
readlink,
|
|
21
|
-
realpath,
|
|
22
|
-
stat,
|
|
23
|
-
type FileHandle,
|
|
24
|
-
} from "node:fs/promises"
|
|
11
|
+
import { readFile } from "node:fs/promises"
|
|
25
12
|
|
|
26
13
|
import { type PathBuilderLike, resolvePath } from "path-ts"
|
|
27
14
|
|
|
28
|
-
import {
|
|
15
|
+
import { open } from "#fs/readers/stat"
|
|
29
16
|
import { parseJSONStrict } from "#json"
|
|
30
17
|
|
|
18
|
+
export * from "#fs/readers/stat"
|
|
19
|
+
|
|
31
20
|
export type { Dirent, PathLike, Stats } from "node:fs"
|
|
32
21
|
export type { FileHandle } from "node:fs/promises"
|
|
33
22
|
|
|
34
|
-
// #region Stat utils
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Attempts to stat a file or directory.
|
|
38
|
-
*
|
|
39
|
-
* A `URL` is passed through rather than stringified: `node:fs` accepts a `file:` URL object, and rejects the string it
|
|
40
|
-
* prints — `stat("file:///etc/hostname")` is ENOENT, which this function reports as absence. Every caller that looks a
|
|
41
|
-
* file up by URL therefore read "not there" for everything, and `cli-native/command-router.ts` answered `Unknown
|
|
42
|
-
* command` for every command it has.
|
|
43
|
-
*
|
|
44
|
-
* @throws If the path exists but cannot be statted for some reason other than non-existence.
|
|
45
|
-
*/
|
|
46
|
-
export function tryStat(pathBuilderLike: PathBuilderLike | URL): Promise<Stats | null> {
|
|
47
|
-
const target = pathBuilderLike instanceof URL ? pathBuilderLike : pathBuilderLike.toString()
|
|
48
|
-
|
|
49
|
-
return stat(target).catch((error) => {
|
|
50
|
-
if (error.code === "ENOENT") return null
|
|
51
|
-
|
|
52
|
-
throw error
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Stat a file or directory, raising ENOENT when nothing is there.
|
|
58
|
-
*
|
|
59
|
-
* The throwing counterpart to {@linkcode tryStat}. Reach for this one where absence is a defect the caller wants
|
|
60
|
-
* reported, and for {@linkcode tryStat} where absence is an answer.
|
|
61
|
-
*/
|
|
62
|
-
export function statPath(path: PathBuilderLike | URL): Promise<Stats> {
|
|
63
|
-
return stat(path instanceof URL ? path : path.toString())
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Stat a path without following a symbolic link, so the answer describes the link itself.
|
|
68
|
-
*/
|
|
69
|
-
export function statLink(path: PathBuilderLike | URL): Promise<Stats> {
|
|
70
|
-
return lstat(path instanceof URL ? path : path.toString())
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Stat a path without following a symbolic link, answering `null` when nothing is there.
|
|
75
|
-
*
|
|
76
|
-
* The link-level counterpart to {@linkcode tryStat}.
|
|
77
|
-
*/
|
|
78
|
-
export function tryStatLink(path: PathBuilderLike | URL): Promise<Stats | null> {
|
|
79
|
-
return lstat(path instanceof URL ? path : path.toString()).catch((error) => {
|
|
80
|
-
if (error.code === "ENOENT") return null
|
|
81
|
-
|
|
82
|
-
throw error
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Whether a path exists, whatever it is.
|
|
88
|
-
*
|
|
89
|
-
* The asynchronous answer to `existsSync`, which is the single most-called synchronous builtin in the repository.
|
|
90
|
-
* Prefer {@linkcode isFile} or {@linkcode isDirectory} where the caller goes on to assume one or the other: a directory
|
|
91
|
-
* where a file was expected passes this check and fails the next line.
|
|
92
|
-
*/
|
|
93
|
-
export function pathExists(path: PathBuilderLike | URL): Promise<boolean> {
|
|
94
|
-
return tryStat(path).then((stats) => stats !== null)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Whether a path exists and is a directory.
|
|
99
|
-
*/
|
|
100
|
-
export function isDirectory(path: PathBuilderLike | URL): Promise<boolean> {
|
|
101
|
-
return tryStat(path).then((stats) => stats?.isDirectory() ?? false)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Whether a path exists and is a file.
|
|
106
|
-
*/
|
|
107
|
-
export function isFile(path: PathBuilderLike | URL): Promise<boolean> {
|
|
108
|
-
return tryStat(path).then((stats) => stats?.isFile() ?? false)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Whether a path exists and is a symbolic link.
|
|
113
|
-
*/
|
|
114
|
-
export function isSymbolicLink(path: PathBuilderLike | URL): Promise<boolean> {
|
|
115
|
-
return tryStatLink(path).then((stats) => stats?.isSymbolicLink() ?? false)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Whether a directory entry leads to a directory, symbolic links included.
|
|
120
|
-
*
|
|
121
|
-
* `Dirent.isDirectory()` is FALSE for a symbolic link to a directory, so a walk keyed on it alone skips every linked
|
|
122
|
-
* tree — while a glob with `followSymbolicLinks` (the default) descends into them, and the two then describe different
|
|
123
|
-
* trees. A link is resolved through `stat`, which also answers `false` for a dangling one.
|
|
124
|
-
*/
|
|
125
|
-
export function entryLeadsToDirectory(entry: Dirent): Promise<boolean> {
|
|
126
|
-
if (entry.isDirectory()) return Promise.resolve(true)
|
|
127
|
-
|
|
128
|
-
if (!entry.isSymbolicLink()) return Promise.resolve(false)
|
|
129
|
-
|
|
130
|
-
return isDirectory(resolvePath(entry.parentPath, entry.name))
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* The size of a file in bytes.
|
|
135
|
-
*
|
|
136
|
-
* @throws ENOENT when the file does not exist.
|
|
137
|
-
*/
|
|
138
|
-
export function readFileSize(path: PathBuilderLike | URL): Promise<number> {
|
|
139
|
-
return statPath(path).then((stats) => stats.size)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* The size of a file, rendered in IEC units (`12.3 MiB`) — the unit for anything a machine measured.
|
|
144
|
-
*
|
|
145
|
-
* @throws ENOENT when the file does not exist.
|
|
146
|
-
*/
|
|
147
|
-
export async function formatFileSize(path: PathBuilderLike | URL, options?: ByteFormatterOptions): Promise<string> {
|
|
148
|
-
return ByteFormatter.formatIEC(await readFileSize(path), options)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Resolve a path to its canonical location, following every symbolic link.
|
|
153
|
-
*
|
|
154
|
-
* @throws ENOENT when nothing is there. {@linkcode tryRealPath} answers `null` instead.
|
|
155
|
-
*/
|
|
156
|
-
export function realPath(path: PathBuilderLike): Promise<string> {
|
|
157
|
-
return realpath(path.toString())
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Resolve a path to its canonical location, following every symbolic link.
|
|
162
|
-
*
|
|
163
|
-
* @returns The canonical path, or `null` when nothing is there.
|
|
164
|
-
*/
|
|
165
|
-
export function tryRealPath(path: PathBuilderLike): Promise<string | null> {
|
|
166
|
-
return realpath(path.toString()).catch((error) => {
|
|
167
|
-
if (error.code === "ENOENT") return null
|
|
168
|
-
|
|
169
|
-
throw error
|
|
170
|
-
})
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export function open(path: PathBuilderLike | URL, flags?: string | number, mode?: Mode): Promise<FileHandle> {
|
|
174
|
-
return openNative(path instanceof URL ? path : path.toString(), flags, mode)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* The target a symbolic link points at, verbatim — relative if it was written relative.
|
|
179
|
-
*
|
|
180
|
-
* @throws EINVAL when the path is not a link, ENOENT when nothing is there.
|
|
181
|
-
*/
|
|
182
|
-
export function readLink(path: PathBuilderLike): Promise<string> {
|
|
183
|
-
return readlink(path.toString())
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Whether the process may WRITE to a path.
|
|
188
|
-
*
|
|
189
|
-
* A permission question, not an existence one: `access` answers about the caller's credentials against the file as it
|
|
190
|
-
* stands, where a stat answers about the file. Absence reads as `false` here, which is what a caller checking "can I
|
|
191
|
-
* write here" means by it.
|
|
192
|
-
*/
|
|
193
|
-
export function isWritable(path: PathBuilderLike): Promise<boolean> {
|
|
194
|
-
return access(path.toString(), constants.W_OK).then(
|
|
195
|
-
() => true,
|
|
196
|
-
() => false
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Whether the process may EXECUTE a path.
|
|
202
|
-
*/
|
|
203
|
-
export function isExecutable(path: PathBuilderLike): Promise<boolean> {
|
|
204
|
-
return access(path.toString(), constants.X_OK).then(
|
|
205
|
-
() => true,
|
|
206
|
-
() => false
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Every path matching a glob pattern.
|
|
212
|
-
*
|
|
213
|
-
* Sorted, because `glob` answers in directory order and a build that names its inputs in a receipt should name them the
|
|
214
|
-
* same way twice.
|
|
215
|
-
*/
|
|
216
|
-
export async function globPaths(pattern: string | string[]): Promise<string[]> {
|
|
217
|
-
return (await Array.fromAsync(glob(pattern))).toSorted()
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* A `file:` URL is passed through whole: `node:fs` accepts the object and rejects the string it prints.
|
|
222
|
-
*/
|
|
223
|
-
function asTarget(path: PathBuilderLike | URL): URL | string {
|
|
224
|
-
return path instanceof URL ? path : path.toString()
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// #endregion
|
|
228
|
-
|
|
229
23
|
// #region File Readers
|
|
230
24
|
|
|
231
25
|
/**
|
|
@@ -295,8 +89,8 @@ function readTarget(pathSegments: Array<PathBuilderLike | URL>): URL | string {
|
|
|
295
89
|
/**
|
|
296
90
|
* Read a local text file.
|
|
297
91
|
*
|
|
298
|
-
* @category Node
|
|
299
92
|
* @category Files
|
|
93
|
+
* @runtime node
|
|
300
94
|
*/
|
|
301
95
|
export function readLocalTextFile<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<string> {
|
|
302
96
|
if (!pathSegments.length) {
|
|
@@ -306,14 +100,26 @@ export function readLocalTextFile<S extends Array<PathBuilderLike | URL>>(...pat
|
|
|
306
100
|
return readFile(readTarget(pathSegments), "utf8")
|
|
307
101
|
}
|
|
308
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated Use `readPackageJSONFile` instead
|
|
105
|
+
*/
|
|
106
|
+
export function readLocalJSONFile<_T = Record<string, unknown>>(path: `${string}/package.json`): Promise<never>
|
|
107
|
+
|
|
309
108
|
/**
|
|
310
109
|
* Read a local JSON file.
|
|
311
110
|
*
|
|
312
111
|
* Parsing is strict: a file that is not JSON throws here rather than answering `undefined` several frames later.
|
|
313
112
|
*
|
|
314
|
-
* @category Node
|
|
315
113
|
* @category Files
|
|
114
|
+
* @runtime node
|
|
115
|
+
* @see `readPackageJSON` in `#module/resolve-from` for a `package.json`, which answers the manifest shape and takes a
|
|
116
|
+
* package name as readily as a path.
|
|
316
117
|
*/
|
|
118
|
+
export function readLocalJSONFile<
|
|
119
|
+
T = Record<string, unknown>,
|
|
120
|
+
S extends Array<PathBuilderLike | URL> = Array<PathBuilderLike | URL>,
|
|
121
|
+
>(...pathSegments: S): Promise<T>
|
|
122
|
+
|
|
317
123
|
export function readLocalJSONFile<
|
|
318
124
|
T = Record<string, unknown>,
|
|
319
125
|
S extends Array<PathBuilderLike | URL> = Array<PathBuilderLike | URL>,
|
|
@@ -322,76 +128,38 @@ export function readLocalJSONFile<
|
|
|
322
128
|
}
|
|
323
129
|
|
|
324
130
|
/**
|
|
325
|
-
* Read a local file
|
|
131
|
+
* Read a local JSON file, answering `null` when the file does not exist.
|
|
326
132
|
*
|
|
327
|
-
*
|
|
328
|
-
* @category Files
|
|
329
|
-
*/
|
|
330
|
-
export function readLocalBuffer<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<Buffer> {
|
|
331
|
-
if (!pathSegments.length) {
|
|
332
|
-
throw new Error("No file path segments provided.")
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
return readFile(readTarget(pathSegments))
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* List the entry names directly inside a directory.
|
|
133
|
+
* Parsing is strict: a file that is not JSON throws here rather than answering `null` several frames later.
|
|
340
134
|
*
|
|
341
|
-
* @category Node
|
|
342
135
|
* @category Files
|
|
136
|
+
* @runtime node
|
|
343
137
|
*/
|
|
344
|
-
export function
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
* @category Files
|
|
353
|
-
*/
|
|
354
|
-
export function readDirectoryEntries(path: PathBuilderLike | URL): Promise<Dirent[]> {
|
|
355
|
-
return readdir(asTarget(path), { withFileTypes: true })
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* List every entry under a directory, at any depth, as paths relative to it.
|
|
360
|
-
*
|
|
361
|
-
* The recursive counterpart to {@linkcode readDirectory}. It walks the whole tree before answering, so it is the wrong
|
|
362
|
-
* reader for a directory whose size is unknown — reach for it where the tree is a build artifact you produced.
|
|
363
|
-
*
|
|
364
|
-
* @category Node
|
|
365
|
-
* @category Files
|
|
366
|
-
*/
|
|
367
|
-
export function readDirectoryRecursive(path: PathBuilderLike | URL): Promise<string[]> {
|
|
368
|
-
return readdir(asTarget(path), { recursive: true })
|
|
369
|
-
}
|
|
138
|
+
export function tryReadLocalJSONFile<
|
|
139
|
+
T = Record<string, unknown>,
|
|
140
|
+
S extends Array<PathBuilderLike | URL> = Array<PathBuilderLike | URL>,
|
|
141
|
+
>(...pathSegments: S): Promise<T | null> {
|
|
142
|
+
return readLocalTextFile(...pathSegments)
|
|
143
|
+
.then((content) => parseJSONStrict<T>(content))
|
|
144
|
+
.catch((error) => {
|
|
145
|
+
if (error.code === "ENOENT") return null
|
|
370
146
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
* found in, which a plain recursive read leaves the caller to reconstruct.
|
|
374
|
-
*/
|
|
375
|
-
export function readDirectoryEntriesRecursive(path: PathBuilderLike | URL): Promise<Dirent[]> {
|
|
376
|
-
return readdir(asTarget(path), { recursive: true, withFileTypes: true })
|
|
147
|
+
throw error
|
|
148
|
+
})
|
|
377
149
|
}
|
|
378
150
|
|
|
379
151
|
/**
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
* The distinction is the caller's to make and this function makes ONE of the two available: an absent directory and an
|
|
383
|
-
* empty one are the same answer here. Where absence means something — an unbuilt artifact, a missing extract — use
|
|
384
|
-
* {@linkcode readDirectory} and let the ENOENT reach you.
|
|
152
|
+
* Read a local file's bytes.
|
|
385
153
|
*
|
|
386
|
-
* @category Node
|
|
387
154
|
* @category Files
|
|
155
|
+
* @runtime node
|
|
388
156
|
*/
|
|
389
|
-
export function
|
|
390
|
-
|
|
391
|
-
|
|
157
|
+
export function readLocalBuffer<S extends Array<PathBuilderLike | URL>>(...pathSegments: S): Promise<Buffer> {
|
|
158
|
+
if (!pathSegments.length) {
|
|
159
|
+
throw new Error("No file path segments provided.")
|
|
160
|
+
}
|
|
392
161
|
|
|
393
|
-
|
|
394
|
-
})
|
|
162
|
+
return readFile(readTarget(pathSegments))
|
|
395
163
|
}
|
|
396
164
|
|
|
397
165
|
// #endregion
|
package/lib/fs/streams.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { createReadStream, createWriteStream, type ReadStream, type WriteStream } from "node:fs"
|
|
17
17
|
|
|
18
|
+
import iconv from "iconv-lite"
|
|
18
19
|
import type { PathBuilderLike } from "path-ts"
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -41,6 +42,63 @@ export function openReadStream(path: PathBuilderLike, options?: Parameters<typeo
|
|
|
41
42
|
* first chunk rather than at open time reports the missing directory somewhere the caller is no longer looking. Call
|
|
42
43
|
* `makeDirectories` first where the parent may be absent.
|
|
43
44
|
*/
|
|
45
|
+
/**
|
|
46
|
+
* Re-encode a byte stream from a legacy encoding into UTF-8, so a UTF-8 reader can consume it.
|
|
47
|
+
*
|
|
48
|
+
* The national registers this repository reads are not all UTF-8: Korea's address portal ships CP949, Japan's postcode
|
|
49
|
+
* file Shift_JIS. `spliterator` splits UTF-8 bytes, so the decode happens upstream of the split rather than after it —
|
|
50
|
+
* a line boundary found in CP949 bytes is not a line boundary.
|
|
51
|
+
*
|
|
52
|
+
* NOT `TextDecoder`, AND THE DIFFERENCE IS NOT SMALL. Node's WHATWG `euc-kr` implements EUC-KR proper (KS X 1001) and
|
|
53
|
+
* not the UHC extension CP949 adds in lead bytes 0x81–0xA0. Of the 17,048 two-byte sequences Python's `cp949` accepts,
|
|
54
|
+
* `TextDecoder('euc-kr')` reads 8,824 differently: 6,475 become U+FFFD and 2,349 become a DIFFERENT character with no
|
|
55
|
+
* error raised. `iconv-lite` disagrees with `cp949` on none of the 17,048.
|
|
56
|
+
*
|
|
57
|
+
* It is not a rare corner. One row in 48,000 of the Korean address register carries such a sequence — `더샾오피스텔`, bytes
|
|
58
|
+
* `b4 f5 98 de bf c0 c7 c7 bd ba c5 da`, which `TextDecoder` reads as `더乍의퓰뵀�`.
|
|
59
|
+
*
|
|
60
|
+
* The decoder is STREAMING for the same reason a `TextDecoder` would need `{ stream: true }`: a multi-byte character
|
|
61
|
+
* split across two chunks must be held until its tail arrives, where a per-chunk decode emits a replacement character
|
|
62
|
+
* and corrupts the row. `iconv-lite`'s stream decoder holds that state, and `end()` flushes what is left.
|
|
63
|
+
*
|
|
64
|
+
* @category Files
|
|
65
|
+
* @param encoding An `iconv-lite` label — `cp949`, `shift_jis`, `gbk`.
|
|
66
|
+
*/
|
|
67
|
+
export async function* decodeByteStream(
|
|
68
|
+
source: AsyncIterable<Uint8Array>,
|
|
69
|
+
encoding: string
|
|
70
|
+
): AsyncGenerator<Uint8Array> {
|
|
71
|
+
const decoder = iconv.getDecoder(encoding)
|
|
72
|
+
const encoder = new TextEncoder()
|
|
73
|
+
|
|
74
|
+
for await (const chunk of source) {
|
|
75
|
+
const text = decoder.write(Buffer.from(chunk))
|
|
76
|
+
|
|
77
|
+
if (text) {
|
|
78
|
+
yield encoder.encode(text)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const tail = decoder.end()
|
|
83
|
+
|
|
84
|
+
if (tail) {
|
|
85
|
+
yield encoder.encode(tail)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Decode bytes already in memory from a legacy encoding, the one-shot sibling of {@link decodeByteStream}.
|
|
91
|
+
*
|
|
92
|
+
* Same reasoning, same reason not to reach for `TextDecoder`, and it lives here so a reader that finds one finds the
|
|
93
|
+
* other. Use this when the whole file is a bounded size the publisher fixes; use the stream when it is not.
|
|
94
|
+
*
|
|
95
|
+
* @category Files
|
|
96
|
+
* @param encoding An `iconv-lite` label — `cp949`, `cp932`, `gbk`.
|
|
97
|
+
*/
|
|
98
|
+
export function decodeBytes(bytes: Uint8Array, encoding: string): string {
|
|
99
|
+
return iconv.decode(Buffer.from(bytes), encoding)
|
|
100
|
+
}
|
|
101
|
+
|
|
44
102
|
export function openWriteStream(path: PathBuilderLike, options?: Parameters<typeof createWriteStream>[1]): WriteStream {
|
|
45
103
|
return createWriteStream(path.toString(), options)
|
|
46
104
|
}
|
package/lib/fs/writers.ts
CHANGED
|
@@ -59,8 +59,8 @@ export type BufferLike =
|
|
|
59
59
|
/**
|
|
60
60
|
* Write a local text file, creating its parent directory first.
|
|
61
61
|
*
|
|
62
|
-
* @category Node
|
|
63
62
|
* @category Files
|
|
63
|
+
* @runtime node
|
|
64
64
|
*/
|
|
65
65
|
export async function writeLocalTextFile<S extends PathBuilderLike[]>(
|
|
66
66
|
content: string | Promise<string>,
|
|
@@ -82,8 +82,8 @@ export async function writeLocalTextFile<S extends PathBuilderLike[]>(
|
|
|
82
82
|
/**
|
|
83
83
|
* Write a local JSON file, tab-indented, creating its parent directory first.
|
|
84
84
|
*
|
|
85
|
-
* @category Node
|
|
86
85
|
* @category Files
|
|
86
|
+
* @runtime node
|
|
87
87
|
*/
|
|
88
88
|
export function writeLocalJSONFile<T = Record<string, unknown>, S extends PathBuilderLike[] = PathBuilderLike[]>(
|
|
89
89
|
content: T,
|
|
@@ -97,8 +97,8 @@ export function writeLocalJSONFile<T = Record<string, unknown>, S extends PathBu
|
|
|
97
97
|
/**
|
|
98
98
|
* Write a local file's bytes, creating its parent directory first.
|
|
99
99
|
*
|
|
100
|
-
* @category Node
|
|
101
100
|
* @category Files
|
|
101
|
+
* @runtime node
|
|
102
102
|
*/
|
|
103
103
|
export async function writeLocalBuffer<S extends PathBuilderLike[]>(
|
|
104
104
|
content: BufferLike,
|
|
@@ -122,8 +122,8 @@ export async function writeLocalBuffer<S extends PathBuilderLike[]>(
|
|
|
122
122
|
* then says so, and a reader does not have to follow the value back to its producer. This overload exists for the sites
|
|
123
123
|
* where it genuinely does not: a payload that is a string on one branch and bytes on another.
|
|
124
124
|
*
|
|
125
|
-
* @category Node
|
|
126
125
|
* @category Files
|
|
126
|
+
* @runtime node
|
|
127
127
|
*/
|
|
128
128
|
/**
|
|
129
129
|
* Write a UTF-8 text file readable and writable by its owner alone (`0600`), creating the parent directory. The mode is
|
|
@@ -169,8 +169,8 @@ export async function writeLocalFile<S extends PathBuilderLike[]>(
|
|
|
169
169
|
/**
|
|
170
170
|
* Append text to a local file, creating it and its parent directory when neither exists.
|
|
171
171
|
*
|
|
172
|
-
* @category Node
|
|
173
172
|
* @category Files
|
|
173
|
+
* @runtime node
|
|
174
174
|
*/
|
|
175
175
|
export async function appendLocalTextFile<S extends PathBuilderLike[]>(
|
|
176
176
|
content: string,
|
package/lib/fs/zip.ts
CHANGED
|
@@ -20,11 +20,13 @@ import { pipeline } from "node:stream/promises"
|
|
|
20
20
|
import { crc32 } from "node:zlib"
|
|
21
21
|
|
|
22
22
|
import ADMZip from "adm-zip"
|
|
23
|
+
import iconv from "iconv-lite"
|
|
23
24
|
import { resolvePath, dirname, basename, type PathBuilderLike } from "path-ts"
|
|
24
25
|
import { open as openArchive, type Entry, type ZipFileOptions } from "yauzl-promise"
|
|
25
26
|
|
|
26
27
|
import { tryStat } from "#fs/readers"
|
|
27
28
|
import { makeDirectories } from "#fs/writers"
|
|
29
|
+
import { once } from "#utils/events"
|
|
28
30
|
|
|
29
31
|
type StreamingArchive = Awaited<ReturnType<typeof openArchive>>
|
|
30
32
|
|
|
@@ -34,12 +36,52 @@ type EntryStream = Awaited<ReturnType<Entry["openReadStream"]>>
|
|
|
34
36
|
* The one place this package touches yauzl's own lifecycle. Every reader below ends an archive by leaving scope, so
|
|
35
37
|
* `close()` is called here and nowhere else.
|
|
36
38
|
*/
|
|
37
|
-
async function openStreamingArchive(
|
|
38
|
-
|
|
39
|
+
async function openStreamingArchive(
|
|
40
|
+
archivePath: PathBuilderLike,
|
|
41
|
+
options?: ZipNameOptions
|
|
42
|
+
): Promise<StreamingArchive & AsyncDisposable> {
|
|
43
|
+
// `decodeStrings: false` hands back the central directory's raw name bytes, which is the only way to read a name the
|
|
44
|
+
// archive never said the encoding of. See {@link ZipNameOptions}.
|
|
45
|
+
const archive = await openArchive(String(archivePath), options?.filenameEncoding ? { decodeStrings: false } : {})
|
|
39
46
|
|
|
40
47
|
return Object.assign(archive, { [Symbol.asyncDispose]: () => archive.close() })
|
|
41
48
|
}
|
|
42
49
|
|
|
50
|
+
/**
|
|
51
|
+
* How to read member names that the archive does not declare an encoding for.
|
|
52
|
+
*
|
|
53
|
+
* A zip flags UTF-8 names with bit 11, and yauzl decodes those correctly. Without the flag the format says CP437, so a
|
|
54
|
+
* publisher writing CP949, Shift_JIS or GBK names produces bytes that decode to mojibake and match no selector —
|
|
55
|
+
* Korea's address portal writes `주소_서울특별시.txt` and the reader sees `┴╓╝╥_╝¡┐ïÆ╣▌╗π.txt`.
|
|
56
|
+
*
|
|
57
|
+
* Naming an encoding decodes the RAW bytes instead, which is not the same as recoding the mojibake back through CP437:
|
|
58
|
+
* that round trip needs a 256-entry table and silently mangles any byte CP437 maps to a character it cannot invert.
|
|
59
|
+
*
|
|
60
|
+
* @category Files
|
|
61
|
+
*/
|
|
62
|
+
export interface ZipNameOptions {
|
|
63
|
+
/**
|
|
64
|
+
* An `iconv-lite` label — `cp949`, `shift_jis`, `gbk`. Omit when the archive's names are ASCII or properly flagged
|
|
65
|
+
* UTF-8, which is every other archive this repository reads.
|
|
66
|
+
*/
|
|
67
|
+
filenameEncoding?: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A member's name, decoded as {@link ZipNameOptions} asks.
|
|
72
|
+
*
|
|
73
|
+
* `iconv-lite` rather than `TextDecoder` for the reason `decodeByteStream` gives: Node's WHATWG `euc-kr` is EUC-KR
|
|
74
|
+
* proper and reads 8,824 of CP949's 17,048 two-byte sequences differently, so a member whose name uses the UHC
|
|
75
|
+
* extension would be looked for under a name that does not exist.
|
|
76
|
+
*/
|
|
77
|
+
function entryName(entry: Entry, options?: ZipNameOptions): string {
|
|
78
|
+
const raw = entry.filename as unknown
|
|
79
|
+
|
|
80
|
+
if (typeof raw === "string") return raw
|
|
81
|
+
|
|
82
|
+
return iconv.decode(Buffer.from(raw as Uint8Array), options?.filenameEncoding ?? "utf8")
|
|
83
|
+
}
|
|
84
|
+
|
|
43
85
|
/**
|
|
44
86
|
* One member's decompressed byte stream, ended when the owning scope exits.
|
|
45
87
|
*
|
|
@@ -52,7 +94,20 @@ async function openEntryStream(entry: Entry, options?: ZipFileOptions): Promise<
|
|
|
52
94
|
|
|
53
95
|
return Object.assign(contents, {
|
|
54
96
|
[Symbol.asyncDispose]: async () => {
|
|
97
|
+
// A member read to its end has already released yauzl's read, and its `close` has already been delivered — so
|
|
98
|
+
// waiting for that event here would wait forever. `readableEnded` is the test that separates the two paths:
|
|
99
|
+
// true after a full read, false after a `take` or a `break`. `closed` is NOT the test, because Node sets it when
|
|
100
|
+
// the close event is queued rather than delivered, so a guard on it skips the wait on the path that needs it.
|
|
101
|
+
if (contents.readableEnded) return
|
|
102
|
+
|
|
103
|
+
const closed = once(contents, "close").catch(() => undefined)
|
|
104
|
+
|
|
55
105
|
contents.destroy()
|
|
106
|
+
|
|
107
|
+
// Wait for the teardown to finish, not merely to start. `destroy()` returns before yauzl has released its read,
|
|
108
|
+
// and the archive's own disposer runs next: it then raises `Cannot close while reading in progress` on the
|
|
109
|
+
// early-exit path this reader documents as supported.
|
|
110
|
+
await closed
|
|
56
111
|
},
|
|
57
112
|
})
|
|
58
113
|
}
|
|
@@ -133,13 +188,13 @@ function selectorMatches(selector: ZipEntrySelector, name: string): boolean {
|
|
|
133
188
|
*
|
|
134
189
|
* @category Files
|
|
135
190
|
*/
|
|
136
|
-
export async function listZipEntries(archivePath: PathBuilderLike): Promise<ZipEntryInfo[]> {
|
|
137
|
-
await using archive = await openStreamingArchive(archivePath)
|
|
191
|
+
export async function listZipEntries(archivePath: PathBuilderLike, options?: ZipNameOptions): Promise<ZipEntryInfo[]> {
|
|
192
|
+
await using archive = await openStreamingArchive(archivePath, options)
|
|
138
193
|
const entries: ZipEntryInfo[] = []
|
|
139
194
|
|
|
140
195
|
for await (const entry of archive) {
|
|
141
196
|
entries.push({
|
|
142
|
-
name: entry
|
|
197
|
+
name: entryName(entry, options),
|
|
143
198
|
compressedSize: entry.compressedSize,
|
|
144
199
|
uncompressedSize: entry.uncompressedSize,
|
|
145
200
|
})
|
|
@@ -160,12 +215,13 @@ export async function listZipEntries(archivePath: PathBuilderLike): Promise<ZipE
|
|
|
160
215
|
*/
|
|
161
216
|
export async function* readZipEntry(
|
|
162
217
|
archivePath: PathBuilderLike,
|
|
163
|
-
selector: ZipEntrySelector
|
|
218
|
+
selector: ZipEntrySelector,
|
|
219
|
+
options?: ZipNameOptions
|
|
164
220
|
): AsyncGenerator<Uint8Array> {
|
|
165
|
-
await using archive = await openStreamingArchive(archivePath)
|
|
221
|
+
await using archive = await openStreamingArchive(archivePath, options)
|
|
166
222
|
|
|
167
223
|
for await (const entry of archive) {
|
|
168
|
-
if (!selectorMatches(selector, entry
|
|
224
|
+
if (!selectorMatches(selector, entryName(entry, options))) continue
|
|
169
225
|
|
|
170
226
|
await using contents = await openEntryStream(entry)
|
|
171
227
|
|
package/lib/git.ts
CHANGED
|
@@ -48,6 +48,32 @@ export async function dirtyTrackedFiles(repoRoot: PathBuilderLike, pathspecs: st
|
|
|
48
48
|
return [...TextSpliterator.from(output)].map((line) => line.trimEnd()).filter((line) => line.length > 0)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Every `git status --porcelain` line, staged and unstaged and untracked alike.
|
|
53
|
+
*
|
|
54
|
+
* The sibling {@linkcode dirtyTrackedFiles} answers a publish path's question — which committed files have moved — and
|
|
55
|
+
* excludes what a build creates. This answers a CACHE's question: has anything at all changed since a derived artifact
|
|
56
|
+
* was built. A key built from the narrower reading goes stale over a staged edit and over a new file, and a stale index
|
|
57
|
+
* reports that a helper written an hour ago does not exist.
|
|
58
|
+
*/
|
|
59
|
+
export async function workingTreeStatus(repoRoot: PathBuilderLike, pathspecs: string[] = []): Promise<string[]> {
|
|
60
|
+
const scope = pathspecs.length ? ["--", ...pathspecs] : []
|
|
61
|
+
const output = await git(repoRoot, ["status", "--porcelain", ...scope])
|
|
62
|
+
|
|
63
|
+
return [...TextSpliterator.from(output)].map((line) => line.trimEnd()).filter((line) => line.length > 0)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The repo-relative paths that differ between two commits, added, modified, renamed or deleted alike, read
|
|
68
|
+
* NUL-delimited so an unusual path survives. Both commits must be present in the checkout: a shallow clone that lacks
|
|
69
|
+
* `base` fails here with git's own message rather than answering an empty list.
|
|
70
|
+
*/
|
|
71
|
+
export async function changedFiles(repoRoot: PathBuilderLike, base: string, head: string): Promise<string[]> {
|
|
72
|
+
const output = await git(repoRoot, ["diff", "--name-only", "-z", base, head], 64 * 1024 * 1024)
|
|
73
|
+
|
|
74
|
+
return output.split("\0").filter((path) => path.length > 0)
|
|
75
|
+
}
|
|
76
|
+
|
|
51
77
|
/**
|
|
52
78
|
* Every tracked path, repo-relative, optionally narrowed by git pathspecs. Read NUL-delimited so a path with a newline
|
|
53
79
|
* or a non-ASCII byte survives; the 64 MiB buffer covers this repository's listing several times over.
|
package/lib/layers/coverage.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* @file Coverage rows and the area check shared by the polygon-layer builders.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { supportsExclusion,
|
|
9
|
-
|
|
8
|
+
import { supportsExclusion, CoverageBasis } from "@mailwoman/evidence"
|
|
9
|
+
|
|
10
|
+
import type { CoverageCell } from "#layers/manifest"
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* The coverage rows for a layer whose coverage is `source_present`: one per cell the authority's own polygons reach,
|
package/lib/layers/manifest.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* corrupted layer fails loudly at open time rather than misbehaving downstream.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { supportsExclusion } from "@mailwoman/evidence"
|
|
11
|
+
import { supportsExclusion, CoverageBasis } from "@mailwoman/evidence"
|
|
12
12
|
|
|
13
13
|
import { parseJSONStrict } from "#json"
|
|
14
|
-
import {
|
|
14
|
+
import { LayerFreshnessPolicy, LayerTier, type LayerContractHandle } from "#layers/schema"
|
|
15
15
|
import { assertAdmissibleLicenseExpression } from "#license/obligations"
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -70,8 +70,6 @@ export interface CoverageCell {
|
|
|
70
70
|
observedRows: number
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export { requireExclusionBasis, supportsExclusion } from "@mailwoman/evidence"
|
|
74
|
-
|
|
75
73
|
const BASES = new Set<string>(Object.values(CoverageBasis))
|
|
76
74
|
|
|
77
75
|
/**
|
package/lib/layers/schema.ts
CHANGED
|
@@ -85,7 +85,6 @@ export interface LayerManifestTable {
|
|
|
85
85
|
|
|
86
86
|
// Owned by @mailwoman/evidence so bdc, resolver and filer can check on the SAME FUNCTION rather than on matching copies
|
|
87
87
|
// of the same three strings. The layer_coverage schema and its IO stay here.
|
|
88
|
-
export { CoverageBasis } from "@mailwoman/evidence"
|
|
89
88
|
|
|
90
89
|
export interface LayerCoverageTable {
|
|
91
90
|
/**
|