@mailwoman/core 10.1.0 → 10.2.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/api/APIClient.ts +5 -6
- package/lib/api/arcgis.ts +5 -5
- package/lib/api/ckan.ts +2 -1
- package/lib/api/disk-storage.ts +3 -3
- package/lib/api/ogc.ts +56 -52
- package/lib/api/pacer.ts +1 -1
- package/lib/api/retry.ts +6 -4
- package/lib/api/test/transport.ts +20 -20
- package/lib/api.ts +1 -0
- package/lib/coarse-placer/coarse-placer.ts +4 -3
- package/lib/crypto/node.ts +1 -2
- package/lib/decoder/build-tree.ts +5 -5
- package/lib/decoder/parse-diff.ts +47 -31
- package/lib/decoder/proposals-to-tree.ts +1 -0
- package/lib/decoder/serialize/json.ts +9 -6
- package/lib/decoder/serialize/tuples.ts +2 -1
- package/lib/decoder/serialize/xml.ts +15 -14
- package/lib/decoder/tree/shape.ts +14 -14
- package/lib/decoder/tree/walk.ts +2 -2
- package/lib/decoder/types.ts +48 -2
- package/lib/env/schema.ts +21 -23
- package/lib/env/utils.ts +4 -3
- package/lib/env.ts +4 -4
- package/lib/fs/delimited.ts +35 -1
- package/lib/fs/readers.ts +2 -5
- package/lib/fs/zip.ts +1 -1
- package/lib/geocode/result.ts +337 -0
- package/lib/git.ts +1 -1
- package/lib/html/document.ts +6 -6
- package/lib/html/elements.ts +26 -23
- package/lib/identical.ts +20 -0
- package/lib/json.ts +5 -7
- package/lib/layers/coverage.ts +28 -1
- package/lib/layers/feature-count.ts +3 -3
- package/lib/layers/manifest.ts +22 -21
- package/lib/layers/schema.ts +25 -1
- package/lib/license/configured.ts +3 -3
- package/lib/license/key/file.ts +2 -1
- package/lib/license/key.ts +3 -3
- package/lib/license/stamp.ts +4 -4
- package/lib/locale/locale.ts +1 -1
- package/lib/locale/registry.ts +2 -2
- package/lib/module/compiled-freshness.ts +1 -1
- package/lib/module/package-command.ts +4 -2
- package/lib/module/packaged-data.ts +1 -1
- package/lib/module/resolve-from.ts +1 -1
- package/lib/numeric.ts +4 -4
- package/lib/objects.ts +3 -0
- package/lib/paths.ts +16 -1
- package/lib/pipeline/client-result.ts +14 -14
- package/lib/pipeline/result.ts +5 -4
- package/lib/pipeline/runtime-pipeline.ts +65 -42
- package/lib/pipeline/span-proposer.ts +1 -1
- package/lib/pipeline/types.ts +328 -161
- package/lib/pipeline.ts +32 -7
- package/lib/policy/proposal-collection.ts +1 -1
- package/lib/policy/registry.ts +5 -3
- package/lib/resolver/authoritative-provider.ts +17 -17
- package/lib/resolver/coverage-facts.ts +3 -3
- package/lib/resolver/fixture-authoritative-provider.ts +4 -0
- package/lib/resolver/lookup-types.ts +54 -14
- package/lib/resolver/postcode-format.ts +9 -9
- package/lib/resolver/referential.ts +2 -2
- package/lib/resolver/types.ts +155 -51
- package/lib/resolver.ts +22 -20
- package/lib/resources/git.ts +1 -1
- package/lib/resources/languages.ts +0 -2
- package/lib/resources/libpostal.ts +1 -1
- package/lib/resources/whosonfirst/PlacetypeDataSource.ts +2 -6
- package/lib/resources/whosonfirst/extract-repo.ts +2 -1
- package/lib/resources/whosonfirst/placetypes/admin.ts +20 -25
- package/lib/resources/whosonfirst/placetypes/mermaid.ts +4 -3
- package/lib/resources/whosonfirst/placetypes/specificity.ts +7 -7
- package/lib/resources.ts +1 -0
- package/lib/scripting/arguments.ts +6 -5
- package/lib/scripting/command.ts +3 -2
- package/lib/scripting/operation.ts +2 -2
- package/lib/scripting/utils.ts +3 -5
- package/lib/strings/python-json.ts +1 -1
- package/lib/tokenization/Span.ts +1 -1
- package/lib/trust-policies.ts +0 -2
- package/lib/types/Classification.ts +1 -1
- package/lib/types/classifier.ts +1 -1
- package/lib/utils/geodatabase-archive.ts +13 -5
- package/lib/utils/sqlite-rows.ts +3 -3
- package/lib/utils/stream-to-disk.ts +1 -3
- package/lib/utils/union-find.ts +1 -1
- package/lib/vale.ts +1 -1
- package/lib/workspaces.ts +2 -2
- package/out/api/APIClient.d.ts +3 -3
- package/out/api/APIClient.d.ts.map +1 -1
- package/out/api/APIClient.js +2 -3
- package/out/api/APIClient.js.map +1 -1
- package/out/api/arcgis.d.ts +2 -2
- package/out/api/arcgis.d.ts.map +1 -1
- package/out/api/arcgis.js +6 -6
- package/out/api/arcgis.js.map +1 -1
- package/out/api/ckan.d.ts +2 -1
- package/out/api/ckan.d.ts.map +1 -1
- package/out/api/ckan.js.map +1 -1
- package/out/api/disk-storage.d.ts +1 -1
- package/out/api/disk-storage.js +2 -2
- package/out/api/disk-storage.js.map +1 -1
- package/out/api/ogc.d.ts +32 -27
- package/out/api/ogc.d.ts.map +1 -1
- package/out/api/ogc.js +41 -46
- package/out/api/ogc.js.map +1 -1
- package/out/api/pacer.d.ts +1 -1
- package/out/api/pacer.js +1 -1
- package/out/api/retry.d.ts +6 -4
- package/out/api/retry.d.ts.map +1 -1
- package/out/api/retry.js +1 -1
- package/out/api/retry.js.map +1 -1
- package/out/api/test/transport.d.ts +11 -11
- package/out/api/test/transport.d.ts.map +1 -1
- package/out/api/test/transport.js +16 -16
- package/out/api/test/transport.js.map +1 -1
- package/out/api.d.ts +1 -0
- package/out/api.d.ts.map +1 -1
- package/out/api.js +1 -0
- package/out/api.js.map +1 -1
- package/out/coarse-placer/coarse-placer.d.ts +3 -2
- package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
- package/out/coarse-placer/coarse-placer.js +1 -1
- package/out/coarse-placer/coarse-placer.js.map +1 -1
- package/out/crypto/node.d.ts +1 -2
- package/out/crypto/node.d.ts.map +1 -1
- package/out/crypto/node.js +1 -2
- package/out/crypto/node.js.map +1 -1
- package/out/decoder/build-tree.js +5 -5
- package/out/decoder/build-tree.js.map +1 -1
- package/out/decoder/parse-diff.d.ts +19 -19
- package/out/decoder/parse-diff.d.ts.map +1 -1
- package/out/decoder/parse-diff.js +28 -12
- package/out/decoder/parse-diff.js.map +1 -1
- package/out/decoder/proposals-to-tree.d.ts.map +1 -1
- package/out/decoder/proposals-to-tree.js +1 -0
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/serialize/json.d.ts +35 -17
- package/out/decoder/serialize/json.d.ts.map +1 -1
- package/out/decoder/serialize/json.js +28 -0
- package/out/decoder/serialize/json.js.map +1 -1
- package/out/decoder/serialize/tuples.d.ts +2 -1
- package/out/decoder/serialize/tuples.d.ts.map +1 -1
- package/out/decoder/serialize/tuples.js.map +1 -1
- package/out/decoder/serialize/xml.d.ts +12 -11
- package/out/decoder/serialize/xml.d.ts.map +1 -1
- package/out/decoder/serialize/xml.js +3 -3
- package/out/decoder/serialize/xml.js.map +1 -1
- package/out/decoder/tree/shape.d.ts +6 -6
- package/out/decoder/tree/shape.d.ts.map +1 -1
- package/out/decoder/tree/shape.js +8 -8
- package/out/decoder/tree/shape.js.map +1 -1
- package/out/decoder/tree/walk.d.ts +1 -1
- package/out/decoder/tree/walk.d.ts.map +1 -1
- package/out/decoder/tree/walk.js +1 -1
- package/out/decoder/tree/walk.js.map +1 -1
- package/out/decoder/types.d.ts +55 -2
- package/out/decoder/types.d.ts.map +1 -1
- package/out/decoder/types.js +39 -1
- package/out/decoder/types.js.map +1 -1
- package/out/env/schema.d.ts +11 -12
- package/out/env/schema.d.ts.map +1 -1
- package/out/env/schema.js +15 -17
- package/out/env/schema.js.map +1 -1
- package/out/env/utils.d.ts +2 -2
- package/out/env/utils.d.ts.map +1 -1
- package/out/env/utils.js +2 -2
- package/out/env/utils.js.map +1 -1
- package/out/env.js +4 -4
- package/out/env.js.map +1 -1
- package/out/fs/delimited.d.ts +18 -0
- package/out/fs/delimited.d.ts.map +1 -1
- package/out/fs/delimited.js +31 -1
- package/out/fs/delimited.js.map +1 -1
- package/out/fs/readers.d.ts +2 -4
- package/out/fs/readers.d.ts.map +1 -1
- package/out/fs/readers.js +2 -4
- package/out/fs/readers.js.map +1 -1
- package/out/fs/zip.js +1 -1
- package/out/fs/zip.js.map +1 -1
- package/out/geocode/result.d.ts +475 -0
- package/out/geocode/result.d.ts.map +1 -0
- package/out/geocode/result.js +280 -0
- package/out/geocode/result.js.map +1 -0
- package/out/git.js +1 -1
- package/out/git.js.map +1 -1
- package/out/html/document.d.ts +3 -3
- package/out/html/document.d.ts.map +1 -1
- package/out/html/document.js +4 -4
- package/out/html/document.js.map +1 -1
- package/out/html/elements.d.ts +18 -15
- package/out/html/elements.d.ts.map +1 -1
- package/out/html/elements.js +17 -16
- package/out/html/elements.js.map +1 -1
- package/out/identical.d.ts +16 -0
- package/out/identical.d.ts.map +1 -0
- package/out/identical.js +19 -0
- package/out/identical.js.map +1 -0
- package/out/json.d.ts +3 -5
- package/out/json.d.ts.map +1 -1
- package/out/json.js +3 -5
- package/out/json.js.map +1 -1
- package/out/layers/coverage.d.ts +26 -1
- package/out/layers/coverage.d.ts.map +1 -1
- package/out/layers/coverage.js.map +1 -1
- package/out/layers/feature-count.d.ts +1 -1
- package/out/layers/feature-count.d.ts.map +1 -1
- package/out/layers/feature-count.js +2 -2
- package/out/layers/feature-count.js.map +1 -1
- package/out/layers/manifest.d.ts +11 -10
- package/out/layers/manifest.d.ts.map +1 -1
- package/out/layers/manifest.js +12 -13
- package/out/layers/manifest.js.map +1 -1
- package/out/layers/schema.d.ts +23 -0
- package/out/layers/schema.d.ts.map +1 -1
- package/out/layers/schema.js +1 -1
- 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/key/file.d.ts.map +1 -1
- package/out/license/key/file.js +2 -1
- package/out/license/key/file.js.map +1 -1
- package/out/license/key.d.ts +1 -1
- package/out/license/key.d.ts.map +1 -1
- package/out/license/key.js +2 -2
- package/out/license/key.js.map +1 -1
- package/out/license/stamp.d.ts +2 -2
- package/out/license/stamp.d.ts.map +1 -1
- package/out/license/stamp.js +2 -2
- package/out/license/stamp.js.map +1 -1
- package/out/locale/locale.d.ts +1 -1
- package/out/locale/locale.d.ts.map +1 -1
- package/out/locale/registry.d.ts +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/module/compiled-freshness.js +1 -1
- package/out/module/compiled-freshness.js.map +1 -1
- package/out/module/package-command.d.ts +3 -2
- package/out/module/package-command.d.ts.map +1 -1
- package/out/module/package-command.js +3 -2
- package/out/module/package-command.js.map +1 -1
- package/out/module/packaged-data.js +1 -1
- package/out/module/packaged-data.js.map +1 -1
- package/out/module/resolve-from.js +1 -1
- package/out/module/resolve-from.js.map +1 -1
- package/out/numeric.d.ts +1 -1
- package/out/numeric.d.ts.map +1 -1
- package/out/numeric.js +3 -3
- package/out/numeric.js.map +1 -1
- package/out/objects.d.ts +3 -0
- package/out/objects.d.ts.map +1 -1
- package/out/objects.js +3 -0
- package/out/objects.js.map +1 -1
- package/out/paths.d.ts +20 -1
- package/out/paths.d.ts.map +1 -1
- package/out/paths.js +1 -1
- package/out/paths.js.map +1 -1
- package/out/pipeline/client-result.d.ts +15 -15
- package/out/pipeline/client-result.d.ts.map +1 -1
- package/out/pipeline/client-result.js +1 -1
- package/out/pipeline/result.d.ts +4 -3
- package/out/pipeline/result.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.d.ts +16 -9
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +43 -27
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/span-proposer.js +1 -1
- package/out/pipeline/span-proposer.js.map +1 -1
- package/out/pipeline/types.d.ts +394 -175
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +199 -4
- package/out/pipeline/types.js.map +1 -1
- package/out/pipeline.d.ts +4 -2
- package/out/pipeline.d.ts.map +1 -1
- package/out/pipeline.js +1 -1
- package/out/pipeline.js.map +1 -1
- package/out/policy/proposal-collection.d.ts +1 -1
- package/out/policy/proposal-collection.d.ts.map +1 -1
- package/out/policy/proposal-collection.js.map +1 -1
- package/out/policy/registry.d.ts +3 -1
- package/out/policy/registry.d.ts.map +1 -1
- package/out/policy/registry.js +4 -2
- package/out/policy/registry.js.map +1 -1
- package/out/resolver/authoritative-provider.d.ts +17 -17
- package/out/resolver/authoritative-provider.d.ts.map +1 -1
- package/out/resolver/authoritative-provider.js +2 -2
- package/out/resolver/coverage-facts.d.ts +3 -3
- package/out/resolver/coverage-facts.d.ts.map +1 -1
- package/out/resolver/fixture-authoritative-provider.d.ts.map +1 -1
- package/out/resolver/fixture-authoritative-provider.js +4 -0
- package/out/resolver/fixture-authoritative-provider.js.map +1 -1
- package/out/resolver/lookup-types.d.ts +52 -15
- package/out/resolver/lookup-types.d.ts.map +1 -1
- package/out/resolver/postcode-format.d.ts +3 -3
- package/out/resolver/postcode-format.d.ts.map +1 -1
- package/out/resolver/postcode-format.js +7 -7
- package/out/resolver/postcode-format.js.map +1 -1
- package/out/resolver/referential.d.ts +2 -2
- package/out/resolver/referential.d.ts.map +1 -1
- package/out/resolver/types.d.ts +126 -40
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js +43 -1
- package/out/resolver/types.js.map +1 -1
- package/out/resolver.d.ts +5 -3
- package/out/resolver.d.ts.map +1 -1
- package/out/resolver.js +2 -2
- package/out/resolver.js.map +1 -1
- package/out/resources/git.js +1 -1
- package/out/resources/git.js.map +1 -1
- package/out/resources/languages.d.ts +0 -1
- package/out/resources/languages.d.ts.map +1 -1
- package/out/resources/languages.js +0 -1
- package/out/resources/languages.js.map +1 -1
- package/out/resources/libpostal.d.ts +1 -1
- package/out/resources/libpostal.d.ts.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/PlacetypeDataSource.js +2 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
- package/out/resources/whosonfirst/extract-repo.d.ts.map +1 -1
- package/out/resources/whosonfirst/extract-repo.js +2 -1
- package/out/resources/whosonfirst/extract-repo.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts +12 -12
- package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.js +9 -8
- package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.d.ts +2 -1
- package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.js +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/specificity.d.ts +3 -3
- package/out/resources/whosonfirst/placetypes/specificity.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/specificity.js +6 -6
- package/out/resources/whosonfirst/placetypes/specificity.js.map +1 -1
- package/out/resources.d.ts +1 -0
- package/out/resources.d.ts.map +1 -1
- package/out/resources.js +1 -0
- package/out/resources.js.map +1 -1
- package/out/scripting/arguments.d.ts +5 -4
- package/out/scripting/arguments.d.ts.map +1 -1
- package/out/scripting/arguments.js +5 -4
- package/out/scripting/arguments.js.map +1 -1
- package/out/scripting/command.d.ts +2 -2
- package/out/scripting/command.d.ts.map +1 -1
- package/out/scripting/command.js +1 -0
- package/out/scripting/command.js.map +1 -1
- package/out/scripting/operation.d.ts +1 -1
- package/out/scripting/operation.d.ts.map +1 -1
- package/out/scripting/operation.js +1 -1
- package/out/scripting/operation.js.map +1 -1
- package/out/scripting/utils.d.ts +3 -4
- package/out/scripting/utils.d.ts.map +1 -1
- package/out/scripting/utils.js +3 -4
- package/out/scripting/utils.js.map +1 -1
- package/out/strings/python-json.js +1 -1
- package/out/strings/python-json.js.map +1 -1
- package/out/tokenization/Span.d.ts +1 -1
- package/out/tokenization/Span.d.ts.map +1 -1
- package/out/tools/coarse-placer/build/dataset.d.ts +4 -2
- package/out/tools/coarse-placer/build/dataset.d.ts.map +1 -1
- package/out/tools/coarse-placer/build/dataset.js.map +1 -1
- package/out/tools/coarse-placer/build/outlier/exposure.d.ts +5 -3
- package/out/tools/coarse-placer/build/outlier/exposure.d.ts.map +1 -1
- package/out/tools/coarse-placer/build/outlier/exposure.js.map +1 -1
- package/out/tools/coarse-placer/build/outlier/latin.d.ts +3 -3
- package/out/tools/coarse-placer/build/outlier/oa.d.ts +3 -3
- package/out/tools/coarse-placer/eval/latin-offmap.d.ts +3 -3
- package/out/tools/coarse-placer/eval/openset.js +2 -2
- package/out/tools/coarse-placer/eval/openset.js.map +1 -1
- package/out/tools/coarse-placer/eval/quant-compare.d.ts +4 -4
- package/out/tools/coarse-placer/eval.d.ts +3 -3
- package/out/tools/coarse-placer/paths.js +1 -1
- package/out/tools/coarse-placer/paths.js.map +1 -1
- package/out/tools/coarse-placer/probe-frontier.d.ts +2 -2
- package/out/tools/coarse-placer/quantize.d.ts +2 -2
- package/out/tools/coarse-placer/train.d.ts +5 -5
- package/out/tools/download/libpostal-resources.d.ts.map +1 -1
- package/out/tools/download/libpostal-resources.js +2 -1
- package/out/tools/download/libpostal-resources.js.map +1 -1
- package/out/tools/download/ssl-address.d.ts +2 -2
- package/out/tools/generate-language-types.d.ts +1 -1
- package/out/tools/generate-language-types.js +1 -1
- package/out/tools/generate-language-types.js.map +1 -1
- package/out/trust-policies.d.ts +0 -1
- package/out/trust-policies.d.ts.map +1 -1
- package/out/trust-policies.js +0 -1
- package/out/trust-policies.js.map +1 -1
- package/out/types/Classification.d.ts +1 -1
- 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/utils/geodatabase-archive.d.ts +11 -4
- package/out/utils/geodatabase-archive.d.ts.map +1 -1
- package/out/utils/geodatabase-archive.js +1 -1
- package/out/utils/geodatabase-archive.js.map +1 -1
- package/out/utils/sqlite-rows.d.ts +2 -2
- package/out/utils/sqlite-rows.d.ts.map +1 -1
- package/out/utils/sqlite-rows.js +2 -2
- package/out/utils/sqlite-rows.js.map +1 -1
- package/out/utils/stream-to-disk.d.ts.map +1 -1
- package/out/utils/stream-to-disk.js +1 -1
- package/out/utils/stream-to-disk.js.map +1 -1
- package/out/utils/union-find.js +1 -1
- package/out/utils/union-find.js.map +1 -1
- package/out/vale.js +1 -1
- package/out/vale.js.map +1 -1
- package/out/workspaces.d.ts +1 -1
- package/out/workspaces.js +1 -1
- package/out/workspaces.js.map +1 -1
- package/package.json +46 -14
- package/tools/coarse-placer/build/dataset.ts +4 -2
- package/tools/coarse-placer/build/outlier/exposure.ts +5 -3
- package/tools/coarse-placer/build/outlier/latin.ts +3 -3
- package/tools/coarse-placer/build/outlier/oa.ts +3 -3
- package/tools/coarse-placer/eval/latin-offmap.ts +3 -3
- package/tools/coarse-placer/eval/openset.ts +3 -3
- package/tools/coarse-placer/eval/quant-compare.ts +4 -4
- package/tools/coarse-placer/eval.ts +3 -3
- package/tools/coarse-placer/paths.ts +1 -1
- package/tools/coarse-placer/probe-frontier.ts +2 -2
- package/tools/coarse-placer/quantize.ts +2 -2
- package/tools/coarse-placer/train.ts +5 -5
- package/tools/download/libpostal-resources.ts +2 -1
- package/tools/download/ssl-address.ts +2 -2
- package/tools/generate-language-types.ts +3 -3
package/lib/fs/readers.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @file The asynchronous read surface. Every reader here takes a {@linkcode PathBuilderLike} and answers a promise.
|
|
6
6
|
*
|
|
7
7
|
* Repository code accesses `node:fs` through this directory. Every reader returns a promise, so executable code
|
|
8
|
-
* makes no blocking filesystem calls. The `debt` check in `
|
|
8
|
+
* makes no blocking filesystem calls. The `debt` check in `lib/repo-health` counts any violations.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { readFile } from "node:fs/promises"
|
|
@@ -15,8 +15,6 @@ import { type PathBuilderLike, resolvePath } from "path-ts"
|
|
|
15
15
|
import { open } from "#fs/readers/stat"
|
|
16
16
|
import { parseJSONStrict } from "#json"
|
|
17
17
|
|
|
18
|
-
export * from "#fs/readers/stat"
|
|
19
|
-
|
|
20
18
|
export type { Dirent, PathLike, Stats } from "node:fs"
|
|
21
19
|
export type { FileHandle } from "node:fs/promises"
|
|
22
20
|
|
|
@@ -26,8 +24,7 @@ export type { FileHandle } from "node:fs/promises"
|
|
|
26
24
|
* Read the first `byteSize` bytes of a file, or the whole file if it is smaller.
|
|
27
25
|
*
|
|
28
26
|
* @param path The file to read.
|
|
29
|
-
* @param byteSize How many bytes to read.
|
|
30
|
-
* Defaults to 65,536 bytes.
|
|
27
|
+
* @param byteSize [65536] How many bytes to read.
|
|
31
28
|
* That size is enough to sniff a file's format.
|
|
32
29
|
*
|
|
33
30
|
* @returns The bytes read, as a UTF-8 string.
|
package/lib/fs/zip.ts
CHANGED
|
@@ -24,7 +24,7 @@ import iconv from "iconv-lite"
|
|
|
24
24
|
import { resolvePath, dirname, basename, type PathBuilderLike } from "path-ts"
|
|
25
25
|
import { open as openArchive, type Entry, type ZipFileOptions } from "yauzl-promise"
|
|
26
26
|
|
|
27
|
-
import { tryStat } from "#fs/readers"
|
|
27
|
+
import { tryStat } from "#fs/readers/stat"
|
|
28
28
|
import { openWriteStream } from "#fs/streams"
|
|
29
29
|
import { makeDirectories } from "#fs/writers"
|
|
30
30
|
import { once } from "#utils/events"
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The geocode result: the data shape one geocoded input projects to.
|
|
7
|
+
*
|
|
8
|
+
* The schemas here are the source of truth and each type is inferred from its schema.
|
|
9
|
+
* The `mailwoman` package computes the result and the HTTP surfaces serve it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { RESOLUTION_TIERS } from "@mailwoman/annotations/geo"
|
|
13
|
+
import { DerivationProjectionSchema, EpistemicStatusSchema } from "@mailwoman/evidence"
|
|
14
|
+
import { z } from "zod"
|
|
15
|
+
|
|
16
|
+
import { DroppedSpanSchema } from "#decoder/serialize/json"
|
|
17
|
+
import { ComponentTagSchema } from "#decoder/types"
|
|
18
|
+
import { QueryIntentMarkerSchema } from "#pipeline/types"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The geocoder resolution tier that produced a coordinate.
|
|
22
|
+
*/
|
|
23
|
+
export const ResolutionTierSchema = z
|
|
24
|
+
.enum(RESOLUTION_TIERS)
|
|
25
|
+
.meta({ id: "ResolutionTier", description: "The geocoder tier that produced the coordinate." })
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* One entry of {@link GeocodeResult.hierarchy}, locality to country, most specific first.
|
|
29
|
+
*/
|
|
30
|
+
export const HierarchyEntrySchema = z
|
|
31
|
+
.object({
|
|
32
|
+
tag: z.string(),
|
|
33
|
+
/**
|
|
34
|
+
* The raw parsed span.
|
|
35
|
+
*/
|
|
36
|
+
value: z.string(),
|
|
37
|
+
/**
|
|
38
|
+
* The resolved gazetteer name.
|
|
39
|
+
*/
|
|
40
|
+
name: z.string(),
|
|
41
|
+
lat: z.number().nullable(),
|
|
42
|
+
lon: z.number().nullable(),
|
|
43
|
+
placeID: z.string().nullable(),
|
|
44
|
+
/**
|
|
45
|
+
* `true` when the winner's ancestor chain vouches for this entry, `false` when it
|
|
46
|
+
* resolved outside the winner's lineage, and `null` when the lineage is unverifiable.
|
|
47
|
+
*/
|
|
48
|
+
in_winner_lineage: z.boolean().nullable(),
|
|
49
|
+
})
|
|
50
|
+
.meta({ id: "HierarchyEntry", description: "One resolved admin level, most specific first." })
|
|
51
|
+
|
|
52
|
+
export type HierarchyEntry = z.infer<typeof HierarchyEntrySchema>
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* One ranked alternative place: the winner first, then same-query runner-ups.
|
|
56
|
+
*/
|
|
57
|
+
export const GeocodeCandidateSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
name: z.string(),
|
|
60
|
+
tag: z.string(),
|
|
61
|
+
lat: z.number(),
|
|
62
|
+
lon: z.number(),
|
|
63
|
+
countryCode: z.string().nullable(),
|
|
64
|
+
placeID: z.string().nullable(),
|
|
65
|
+
})
|
|
66
|
+
.meta({ id: "GeocodeCandidate", description: "A ranked candidate place." })
|
|
67
|
+
|
|
68
|
+
export type GeocodeCandidate = z.infer<typeof GeocodeCandidateSchema>
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The verdict for one parsed admin qualifier.
|
|
72
|
+
*/
|
|
73
|
+
export const AdminCoherenceVerdictSchema = z.enum(["confirmed", "contradicted", "unstated", "unverifiable"])
|
|
74
|
+
|
|
75
|
+
export type AdminCoherenceVerdict = z.infer<typeof AdminCoherenceVerdictSchema>
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Whether the variant-alias exemption lifted a node's winner past the cross-country alias penalty.
|
|
79
|
+
*/
|
|
80
|
+
export const VariantAliasExemptionSchema = z
|
|
81
|
+
.enum(["applied", "not_applied"])
|
|
82
|
+
.meta({ id: "VariantAliasExemption", description: "Whether the variant-alias exemption chose a node's winner." })
|
|
83
|
+
|
|
84
|
+
export type VariantAliasExemption = z.infer<typeof VariantAliasExemptionSchema>
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Whether the winner's resolved ancestry confirms, contradicts or cannot check
|
|
88
|
+
* the parsed `region` and `country`.
|
|
89
|
+
*
|
|
90
|
+
* `unstated` is the explicit claim that the input had no such qualifier.
|
|
91
|
+
*/
|
|
92
|
+
export const AdminCoherenceReportSchema = z
|
|
93
|
+
.object({ region: AdminCoherenceVerdictSchema, country: AdminCoherenceVerdictSchema })
|
|
94
|
+
.meta({ id: "AdminCoherenceReport", description: "Flag-only verdicts for the parsed region and country." })
|
|
95
|
+
|
|
96
|
+
export type AdminCoherenceReport = z.infer<typeof AdminCoherenceReportSchema>
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* One authoritative-provider match, field for field from the provider's answer.
|
|
100
|
+
*/
|
|
101
|
+
export const AuthoritativeAssertionMatchSchema = z.object({
|
|
102
|
+
provider_place_id: z.string(),
|
|
103
|
+
object_ids: z.record(z.string(), z.string()).nullable(),
|
|
104
|
+
canonical_fields: z.record(z.string(), z.string()).nullable(),
|
|
105
|
+
lat: z.number().nullable(),
|
|
106
|
+
lon: z.number().nullable(),
|
|
107
|
+
precision: z.string().nullable(),
|
|
108
|
+
match_status: z.enum(["exact", "approximate"]),
|
|
109
|
+
provider_score: z.number().nullable(),
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
export type AuthoritativeAssertionMatch = z.infer<typeof AuthoritativeAssertionMatchSchema>
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A configured authoritative provider's answer.
|
|
116
|
+
*
|
|
117
|
+
* `status` is the provider's response status plus `transport_error`.
|
|
118
|
+
* `matches` is non-null exactly when the provider returned candidates: one for `matched`,
|
|
119
|
+
* all of them in the provider's order for `ambiguous`.
|
|
120
|
+
*/
|
|
121
|
+
export const AuthoritativeAssertionSchema = z
|
|
122
|
+
.object({
|
|
123
|
+
provider: z.string(),
|
|
124
|
+
status: z.enum(["matched", "ambiguous", "refused", "transport_error"]),
|
|
125
|
+
matches: z.array(AuthoritativeAssertionMatchSchema).nullable(),
|
|
126
|
+
attribution: z.string().nullable(),
|
|
127
|
+
license: z.string().nullable(),
|
|
128
|
+
retrieved_at: z.string().nullable(),
|
|
129
|
+
dataset_version: z.string().nullable(),
|
|
130
|
+
/**
|
|
131
|
+
* `transport_error` only: the thrown message, verbatim.
|
|
132
|
+
*/
|
|
133
|
+
error: z.string().nullable(),
|
|
134
|
+
})
|
|
135
|
+
.meta({ id: "AuthoritativeAssertion", description: "A configured authoritative provider's answer." })
|
|
136
|
+
|
|
137
|
+
export type AuthoritativeAssertion = z.infer<typeof AuthoritativeAssertionSchema>
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A parsed component that the answer's coordinate ignored.
|
|
141
|
+
*
|
|
142
|
+
* The only current `reason`, `postcode_move_refused`, means the postcode resolved
|
|
143
|
+
* too far from the selected locality.
|
|
144
|
+
*/
|
|
145
|
+
export const UnfollowedComponentSchema = z.object({
|
|
146
|
+
tag: ComponentTagSchema,
|
|
147
|
+
value: z.string(),
|
|
148
|
+
reason: z.literal("postcode_move_refused"),
|
|
149
|
+
/**
|
|
150
|
+
* The distance in kilometers that following this component would have moved the answer.
|
|
151
|
+
*/
|
|
152
|
+
distance_km: z.number(),
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
export type UnfollowedComponent = z.infer<typeof UnfollowedComponentSchema>
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The locality key and postcode stored on the matched address-point row.
|
|
159
|
+
*/
|
|
160
|
+
export const RooftopSchema = z.object({ localityNorm: z.string().nullable(), postcode: z.string().nullable() })
|
|
161
|
+
|
|
162
|
+
export type Rooftop = z.infer<typeof RooftopSchema>
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The poi.db entity that supplied a `venue`-tier coordinate.
|
|
166
|
+
*/
|
|
167
|
+
export const GeocodeEntitySchema = z.object({
|
|
168
|
+
name: z.string(),
|
|
169
|
+
categoryID: z.string().nullable(),
|
|
170
|
+
confidence: z.number(),
|
|
171
|
+
country: z.string(),
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
export type GeocodeEntity = z.infer<typeof GeocodeEntitySchema>
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The result of geocoding one input.
|
|
178
|
+
*/
|
|
179
|
+
export const GeocodeResultSchema = z
|
|
180
|
+
.object({
|
|
181
|
+
input: z.string(),
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Every parsed component, projected from the resolved tree.
|
|
185
|
+
*
|
|
186
|
+
* It includes locale-specific tags, such as `prefecture` and `block`, that the fixed fields omit.
|
|
187
|
+
*/
|
|
188
|
+
components: z.partialRecord(ComponentTagSchema, z.string()),
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Spans that the one-value-per-tag projection dropped.
|
|
192
|
+
* The field is null unless some were dropped.
|
|
193
|
+
*/
|
|
194
|
+
dropped_components: z.array(DroppedSpanSchema).nullable(),
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Components in `components` that the coordinate ignored.
|
|
198
|
+
* The field is null unless some exist.
|
|
199
|
+
*/
|
|
200
|
+
unfollowed_components: z.array(UnfollowedComponentSchema).nullable(),
|
|
201
|
+
lat: z.number().nullable(),
|
|
202
|
+
lon: z.number().nullable(),
|
|
203
|
+
resolution_tier: ResolutionTierSchema,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* What may be claimed about the coordinate.
|
|
207
|
+
*
|
|
208
|
+
* It varies independently of `resolution_tier`.
|
|
209
|
+
* A rooftop answer is `designated` when its register is declared complete
|
|
210
|
+
* and `observed` when it comes from a crowdsourced extract.
|
|
211
|
+
*/
|
|
212
|
+
epistemic_status: EpistemicStatusSchema,
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The derivation behind this answer.
|
|
216
|
+
*
|
|
217
|
+
* It is null unless the caller supplied a resolver trace sink.
|
|
218
|
+
*/
|
|
219
|
+
derivation: DerivationProjectionSchema.nullable(),
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The poi.db entity that supplied the coordinate.
|
|
223
|
+
* It is null unless the `venue` tier answered.
|
|
224
|
+
*/
|
|
225
|
+
entity: GeocodeEntitySchema.nullable(),
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The locality key and postcode stored on the matched address-point row.
|
|
229
|
+
*
|
|
230
|
+
* These values describe the rooftop rather than the query.
|
|
231
|
+
* Consumers may display them but must not filter on them.
|
|
232
|
+
*/
|
|
233
|
+
rooftop: RooftopSchema.nullable(),
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The uncertainty radius in meters, or null when the tier reports none.
|
|
237
|
+
*/
|
|
238
|
+
uncertainty_m: z.number().nullable(),
|
|
239
|
+
locality: z.string().nullable(),
|
|
240
|
+
region: z.string().nullable(),
|
|
241
|
+
postcode: z.string().nullable(),
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The parsed house number, filled on every tier.
|
|
245
|
+
*
|
|
246
|
+
* Only the `address_point` and `interpolated` tiers place the coordinate at the house.
|
|
247
|
+
*/
|
|
248
|
+
house_number: z.string().nullable(),
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The parsed street name, reassembled from prefix, base and suffix.
|
|
252
|
+
*/
|
|
253
|
+
street: z.string().nullable(),
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The parsed venue span.
|
|
257
|
+
*/
|
|
258
|
+
venue: z.string().nullable(),
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The parsed dependent-locality span.
|
|
262
|
+
*
|
|
263
|
+
* It appears here even when `hierarchy` omits it for lack of a gazetteer match.
|
|
264
|
+
*/
|
|
265
|
+
dependent_locality: z.string().nullable(),
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* The parsed unit or sub-venue span, such as `Suite 300` or `Apt 4B`.
|
|
269
|
+
*/
|
|
270
|
+
unit: z.string().nullable(),
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The uppercase ISO 3166-1 alpha-2 code from the first node that includes a resolver country.
|
|
274
|
+
*/
|
|
275
|
+
countryCode: z.string().nullable(),
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The admin hierarchy from the resolver, most specific first.
|
|
279
|
+
*/
|
|
280
|
+
hierarchy: z.array(HierarchyEntrySchema),
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Candidate places for the query's primary place.
|
|
284
|
+
*
|
|
285
|
+
* The winner comes first, followed by the resolver's alternatives with distinct coordinates.
|
|
286
|
+
*/
|
|
287
|
+
candidates: z.array(GeocodeCandidateSchema),
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The country that the postcode-country coherence pass scoped the resolve to.
|
|
291
|
+
*
|
|
292
|
+
* It is null unless the pass overrode the default country.
|
|
293
|
+
*/
|
|
294
|
+
postcode_country_scope: z.string().nullable(),
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* The promoted candidate's country.
|
|
298
|
+
*
|
|
299
|
+
* It is null unless capital promotion changed a node's leading candidate.
|
|
300
|
+
*/
|
|
301
|
+
capital_promotion: z.string().nullable(),
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* `applied` when the variant-alias exemption lifted a node's winner past
|
|
305
|
+
* the cross-country alias penalty.
|
|
306
|
+
*/
|
|
307
|
+
variant_alias_exemption: VariantAliasExemptionSchema,
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Query-intent advisories.
|
|
311
|
+
* They never change the answer.
|
|
312
|
+
*
|
|
313
|
+
* The field is always present.
|
|
314
|
+
* An empty array means no intent marker matched.
|
|
315
|
+
*/
|
|
316
|
+
intent_markers: z.array(QueryIntentMarkerSchema),
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Whether the winner's resolved ancestry confirms, contradicts or cannot
|
|
320
|
+
* check the parsed `region` and `country`.
|
|
321
|
+
*
|
|
322
|
+
* It is non-null whenever a winner resolved.
|
|
323
|
+
* Downstream ranking does not read it.
|
|
324
|
+
*/
|
|
325
|
+
admin_coherence: AdminCoherenceReportSchema.nullable(),
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* The answer from a configured authoritative provider, reported alongside Mailwoman's own answer.
|
|
329
|
+
*
|
|
330
|
+
* The field is null when no provider is configured.
|
|
331
|
+
* Every value inside comes from the provider, including `refused` and `transport_error`.
|
|
332
|
+
*/
|
|
333
|
+
authoritative: AuthoritativeAssertionSchema.nullable(),
|
|
334
|
+
})
|
|
335
|
+
.meta({ id: "GeocodeResult", description: "One geocoded input: its coordinate, tier, components and evidence." })
|
|
336
|
+
|
|
337
|
+
export type GeocodeResult = z.infer<typeof GeocodeResultSchema>
|
package/lib/git.ts
CHANGED
package/lib/html/document.ts
CHANGED
|
@@ -111,10 +111,10 @@ export function elementTexts(markup: string, name: string, options: MarkupQueryO
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* The text of the first element with the tag `name`, or `
|
|
114
|
+
* The text of the first element with the tag `name`, or `null` when the document states none.
|
|
115
115
|
*/
|
|
116
|
-
export function elementText(markup: string, name: string, options: MarkupQueryOptions = {}): string |
|
|
117
|
-
return elementTexts(markup, name, options).at(0)
|
|
116
|
+
export function elementText(markup: string, name: string, options: MarkupQueryOptions = {}): string | null {
|
|
117
|
+
return elementTexts(markup, name, options).at(0) ?? null
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -125,11 +125,11 @@ export function elementText(markup: string, name: string, options: MarkupQueryOp
|
|
|
125
125
|
*
|
|
126
126
|
* A regex over the whole body cannot distinguish that count from a repeated descendant value.
|
|
127
127
|
*/
|
|
128
|
-
export function rootAttribute(markup: string, attribute: string, options: MarkupQueryOptions = {}): string |
|
|
128
|
+
export function rootAttribute(markup: string, attribute: string, options: MarkupQueryOptions = {}): string | null {
|
|
129
129
|
const document = parseDocument(markup, { decodeEntities: true, xmlMode: options.xml ?? false })
|
|
130
130
|
const root = findAll(() => true, document).at(0)
|
|
131
131
|
|
|
132
|
-
if (!root) return
|
|
132
|
+
if (!root) return null
|
|
133
133
|
|
|
134
134
|
const wanted = attribute.toLowerCase()
|
|
135
135
|
|
|
@@ -137,5 +137,5 @@ export function rootAttribute(markup: string, attribute: string, options: Markup
|
|
|
137
137
|
if (localName(key) === wanted) return value
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
return
|
|
140
|
+
return null
|
|
141
141
|
}
|
package/lib/html/elements.ts
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* a page. It does not fit a feature collection: one INSPIRE Addresses download inflates to roughly 32
|
|
10
10
|
* GB of GML, and the caller wants each `ad:Address` subtree rather than the document.
|
|
11
11
|
*
|
|
12
|
-
* This module yields one
|
|
13
|
-
* holds only the elements a single chunk completed. A caller reads an attribute
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* This module yields one matching element at a time, with its attributes and its nested children, and
|
|
13
|
+
* holds only the elements a single chunk completed. A caller reads an attribute. `./document.ts`
|
|
14
|
+
* cannot do that except on the root. A caller also walks a nested path. `elementTexts` flattens
|
|
15
|
+
* that path.
|
|
16
16
|
*
|
|
17
17
|
* It decodes bytes with a streaming `TextDecoder`, so a multi-byte character split across two chunks
|
|
18
18
|
* survives.
|
|
@@ -48,7 +48,7 @@ export interface MarkupElement {
|
|
|
48
48
|
/**
|
|
49
49
|
* The text directly inside this element, trimmed, with no text from its children.
|
|
50
50
|
*
|
|
51
|
-
*
|
|
51
|
+
* A child's text stays out, so a caller reading a leaf gets that leaf's value
|
|
52
52
|
* rather than a concatenation of everything beneath its parent.
|
|
53
53
|
*/
|
|
54
54
|
readonly text: string
|
|
@@ -66,10 +66,12 @@ interface MutableElement {
|
|
|
66
66
|
*/
|
|
67
67
|
export interface StreamMarkupOptions {
|
|
68
68
|
/**
|
|
69
|
-
* Parse as XML
|
|
69
|
+
* Parse as XML.
|
|
70
|
+
* It preserves tag case and requires every element to close.
|
|
70
71
|
*
|
|
71
72
|
* GML and every other INSPIRE payload needs this.
|
|
72
|
-
*
|
|
73
|
+
*
|
|
74
|
+
* @defaultValue `false`, matching `./document.ts`
|
|
73
75
|
*/
|
|
74
76
|
xml?: boolean
|
|
75
77
|
|
|
@@ -83,7 +85,7 @@ export interface StreamMarkupOptions {
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
/**
|
|
86
|
-
* The elements
|
|
88
|
+
* The elements matching `name`, each complete, in document order.
|
|
87
89
|
*
|
|
88
90
|
* A nested element of the same name is not yielded separately: capture starts at the
|
|
89
91
|
* outermost occurrence and ends when that one closes, so one `ad:Address` arrives
|
|
@@ -128,9 +130,9 @@ export async function* streamMarkupElements(
|
|
|
128
130
|
* With several requested names, the close that ends a capture is the one matching
|
|
129
131
|
* the tag capture began on, rather than any requested name.
|
|
130
132
|
*/
|
|
131
|
-
let capturing: string |
|
|
133
|
+
let capturing: string | null = null
|
|
132
134
|
let depth = 0
|
|
133
|
-
let failure: Error |
|
|
135
|
+
let failure: Error | null = null
|
|
134
136
|
|
|
135
137
|
const parser = new Parser(
|
|
136
138
|
{
|
|
@@ -176,7 +178,7 @@ export async function* streamMarkupElements(
|
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
completed.push(open.pop()!)
|
|
179
|
-
capturing =
|
|
181
|
+
capturing = null
|
|
180
182
|
|
|
181
183
|
return
|
|
182
184
|
}
|
|
@@ -223,7 +225,7 @@ export async function* streamMarkupElements(
|
|
|
223
225
|
*
|
|
224
226
|
* A caller that buffers a whole document and yields it once would otherwise
|
|
225
227
|
* ask for a string past V8's maximum length.
|
|
226
|
-
* The decoder's state
|
|
228
|
+
* The decoder's state persists across the pieces, so a multi-byte character spanning
|
|
227
229
|
* a slice boundary survives, as it does across chunks.
|
|
228
230
|
*/
|
|
229
231
|
const decodePieces = (chunk: Uint8Array): string[] => {
|
|
@@ -262,14 +264,14 @@ export async function* streamMarkupElements(
|
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
/**
|
|
265
|
-
* The first child of `element`
|
|
267
|
+
* The first child of `element` with the tag `name`, or null.
|
|
266
268
|
*/
|
|
267
|
-
export function childElement(element: MarkupElement, name: string): MarkupElement |
|
|
268
|
-
return element.children.find((child) => child.name === name)
|
|
269
|
+
export function childElement(element: MarkupElement, name: string): MarkupElement | null {
|
|
270
|
+
return element.children.find((child) => child.name === name) ?? null
|
|
269
271
|
}
|
|
270
272
|
|
|
271
273
|
/**
|
|
272
|
-
* Every child of `element`
|
|
274
|
+
* Every child of `element` with the tag `name`, in document order.
|
|
273
275
|
*/
|
|
274
276
|
export function childElements(element: MarkupElement, name: string): readonly MarkupElement[] {
|
|
275
277
|
return element.children.filter((child) => child.name === name)
|
|
@@ -281,11 +283,11 @@ export function childElements(element: MarkupElement, name: string): readonly Ma
|
|
|
281
283
|
* An INSPIRE value sits five or six elements down, so the path form reads better than
|
|
282
284
|
* a chain of `childElement` calls and reports the same absence.
|
|
283
285
|
*/
|
|
284
|
-
export function elementAtPath(element: MarkupElement, ...path: readonly string[]): MarkupElement |
|
|
285
|
-
let current: MarkupElement |
|
|
286
|
+
export function elementAtPath(element: MarkupElement, ...path: readonly string[]): MarkupElement | null {
|
|
287
|
+
let current: MarkupElement | null = element
|
|
286
288
|
|
|
287
289
|
for (const step of path) {
|
|
288
|
-
if (!current) return
|
|
290
|
+
if (!current) return null
|
|
289
291
|
|
|
290
292
|
current = childElement(current, step)
|
|
291
293
|
}
|
|
@@ -296,9 +298,10 @@ export function elementAtPath(element: MarkupElement, ...path: readonly string[]
|
|
|
296
298
|
/**
|
|
297
299
|
* The text at `path`, or undefined when any step of the path is absent.
|
|
298
300
|
*
|
|
299
|
-
* An empty element answers an empty string
|
|
300
|
-
*
|
|
301
|
+
* An empty element answers an empty string.
|
|
302
|
+
* A caller distinguishes that from undefined: the publisher wrote the element
|
|
303
|
+
* and left it blank, rather than omitting it.
|
|
301
304
|
*/
|
|
302
|
-
export function textAtPath(element: MarkupElement, ...path: readonly string[]): string |
|
|
303
|
-
return elementAtPath(element, ...path)?.text
|
|
305
|
+
export function textAtPath(element: MarkupElement, ...path: readonly string[]): string | null {
|
|
306
|
+
return elementAtPath(element, ...path)?.text ?? null
|
|
304
307
|
}
|
package/lib/identical.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Deep identity for JSON-shaped values, wrapping the runtime's `isDeepStrictEqual` so a record whose
|
|
7
|
+
* fields were reordered no longer reads as changed. Node-only: `node:util` has no browser build, and
|
|
8
|
+
* `objects.ts` stays on the browser client's static import path.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { isDeepStrictEqual } from "node:util"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Predicate to check if two values are deeply identical.
|
|
15
|
+
*
|
|
16
|
+
* Not a type predicate: asserting one would narrow the arguments at call sites that keep both values.
|
|
17
|
+
*/
|
|
18
|
+
export function isIdentical<A, E>(actual: A, expected: E): boolean {
|
|
19
|
+
return isDeepStrictEqual(actual, expected)
|
|
20
|
+
}
|
package/lib/json.ts
CHANGED
|
@@ -26,10 +26,8 @@ export type StringifiedJSON<T = unknown> = Tagged<string, "JSON", T>
|
|
|
26
26
|
* It also allows for optional newline and indentation settings.
|
|
27
27
|
*
|
|
28
28
|
* @param input The object to be pretty-printed.
|
|
29
|
-
* @param newline Whether to append a newline character at the end of the output.
|
|
30
|
-
*
|
|
31
|
-
* @param space The indent: a string to repeat, or a count of spaces.
|
|
32
|
-
* Defaults to a tab character (`"\t"`).
|
|
29
|
+
* @param newline [true] Whether to append a newline character at the end of the output.
|
|
30
|
+
* @param space ["\t"] The indent: a string to repeat, or a count of spaces.
|
|
33
31
|
* The builtin accepts a string or number for indentation.
|
|
34
32
|
* This parameter handles the conversion from `2` to `" "` for callers that need it.
|
|
35
33
|
*
|
|
@@ -58,7 +56,7 @@ export function prettyJSON<T = unknown>(input: T, newline = true, space: string
|
|
|
58
56
|
* @see {@linkcode prettyJSON} for human-friendly JSON output.
|
|
59
57
|
*/
|
|
60
58
|
export function stringifyJSON<T>(input: T, keys?: readonly string[]): StringifiedJSON<T> {
|
|
61
|
-
return JSON.stringify(input, keys as string[] |
|
|
59
|
+
return JSON.stringify(input, keys as string[] | null) as StringifiedJSON<T>
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
/**
|
|
@@ -120,8 +118,8 @@ export function parseJSONStrict<T = unknown>(input: string): T {
|
|
|
120
118
|
*
|
|
121
119
|
* @param scope Names the reader in the error, e.g. `coastal client`.
|
|
122
120
|
*/
|
|
123
|
-
export function parseJSONArray<T>(raw: string | undefined, scope: string): T[] {
|
|
124
|
-
if (raw
|
|
121
|
+
export function parseJSONArray<T>(raw: string | null | undefined, scope: string): T[] {
|
|
122
|
+
if (!raw) return []
|
|
125
123
|
|
|
126
124
|
const parsed = parseJSONStrict<unknown>(raw)
|
|
127
125
|
|
package/lib/layers/coverage.ts
CHANGED
|
@@ -144,6 +144,33 @@ export interface ResolutionMeasurementOptions {
|
|
|
144
144
|
progressEvery?: number
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* What a resolution instrument reports for a single-layer source: the features it streamed,
|
|
149
|
+
* the count the source declares for itself, and one measurement per candidate resolution.
|
|
150
|
+
*
|
|
151
|
+
* A streamed total that differs from the declared count means a truncated read.
|
|
152
|
+
*/
|
|
153
|
+
export interface ResolutionMeasurementReport<Measurement> {
|
|
154
|
+
features: number
|
|
155
|
+
declaredFeatureCount: number
|
|
156
|
+
measurements: Measurement[]
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A verification sample point outside the authority's published coverage.
|
|
161
|
+
*
|
|
162
|
+
* `passed` is true when the artifact answered `unknown` with no designation,
|
|
163
|
+
* the only acceptable reading there.
|
|
164
|
+
*/
|
|
165
|
+
export interface OutsideCoverageRow {
|
|
166
|
+
label: string
|
|
167
|
+
latitude: number
|
|
168
|
+
longitude: number
|
|
169
|
+
kind: string
|
|
170
|
+
designations: number
|
|
171
|
+
passed: boolean
|
|
172
|
+
}
|
|
173
|
+
|
|
147
174
|
/**
|
|
148
175
|
* The area a build streamed, beside the area the source reports for itself.
|
|
149
176
|
*/
|
|
@@ -196,7 +223,7 @@ export type AreaAgreementReading =
|
|
|
196
223
|
* Both readings of a build's streamed ring areas against the source's own figure,
|
|
197
224
|
* or the stated absence of one.
|
|
198
225
|
*/
|
|
199
|
-
export function areaAgreementFrom(streamed: StreamedAreaTotals, sourceM2: number |
|
|
226
|
+
export function areaAgreementFrom(streamed: StreamedAreaTotals, sourceM2: number | null): AreaAgreementReading {
|
|
200
227
|
const nestedKM2 = streamed.nestedM2 / M2_PER_KM2
|
|
201
228
|
const allExteriorKM2 = streamed.allExteriorM2 / M2_PER_KM2
|
|
202
229
|
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* the layer's count rather than the limit's: a builder that compares streamed count to
|
|
12
12
|
* the limit as strict equality would otherwise refuse a complete download as short.
|
|
13
13
|
*/
|
|
14
|
-
export function limitedFeatureCount(layerCount: number, limit: number |
|
|
15
|
-
return limit ===
|
|
14
|
+
export function limitedFeatureCount(layerCount: number, limit: number | null): number {
|
|
15
|
+
return limit === null ? layerCount : Math.min(limit, layerCount)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface DeclaredFeatureCountInput {
|
|
@@ -33,5 +33,5 @@ export interface DeclaredFeatureCountInput {
|
|
|
33
33
|
* else the layer's count bounded by the limit.
|
|
34
34
|
*/
|
|
35
35
|
export function declaredFeatureCount(input: DeclaredFeatureCountInput): number {
|
|
36
|
-
return input.declared ?? limitedFeatureCount(input.layerCount, input.limit)
|
|
36
|
+
return input.declared ?? limitedFeatureCount(input.layerCount, input.limit ?? null)
|
|
37
37
|
}
|