@mailwoman/core 10.1.0 → 10.2.1
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/api/APIClient.ts
CHANGED
|
@@ -27,8 +27,6 @@ import {
|
|
|
27
27
|
} from "#api/retry"
|
|
28
28
|
import { ConsoleLogger, type IRuntimeLogger } from "#logging"
|
|
29
29
|
|
|
30
|
-
export { type IRuntimeLogger } from "#logging"
|
|
31
|
-
|
|
32
30
|
const MS_PER_MINUTE = 60_000
|
|
33
31
|
|
|
34
32
|
/**
|
|
@@ -50,7 +48,8 @@ export interface APIClientConfig {
|
|
|
50
48
|
|
|
51
49
|
/**
|
|
52
50
|
* This option transfers cache storage ownership to the client.
|
|
53
|
-
*
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue `false`
|
|
54
53
|
*/
|
|
55
54
|
disposeCacheStorage?: boolean
|
|
56
55
|
|
|
@@ -92,7 +91,7 @@ export interface APIClientConfig {
|
|
|
92
91
|
/**
|
|
93
92
|
* Time source for the pacer, cooldown timer and retry backoff.
|
|
94
93
|
*
|
|
95
|
-
*
|
|
94
|
+
* @defaultValue {@linkcode systemClock}
|
|
96
95
|
* Tests inject a fake clock to make timing deterministic and instant.
|
|
97
96
|
*/
|
|
98
97
|
clock?: ClockLike
|
|
@@ -139,7 +138,7 @@ export class APIClient<C extends APIClientConfig = APIClientConfig> extends Even
|
|
|
139
138
|
this.config = config
|
|
140
139
|
this.logger = config.logger ?? ConsoleLogger.prefix(config.displayName)
|
|
141
140
|
this.#clock = config.clock ?? systemClock
|
|
142
|
-
this.#retryPolicy = resolveRetryPolicy(config.retry)
|
|
141
|
+
this.#retryPolicy = resolveRetryPolicy(config.retry ?? null)
|
|
143
142
|
this.#pacer = config.minRequestIntervalMs ? new RequestPacer(config.minRequestIntervalMs, this.#clock) : null
|
|
144
143
|
|
|
145
144
|
// The pacing limit lives IN the adapter rather than in `fetch()`: `axios-cache-interceptor`
|
|
@@ -263,7 +262,7 @@ export class APIClient<C extends APIClientConfig = APIClientConfig> extends Even
|
|
|
263
262
|
|
|
264
263
|
if (this.#shutdown.signal.aborted || !directive.retryable || attempt >= this.#retryPolicy.maxAttempts) {
|
|
265
264
|
// Always throws — `Promise<never>` is assignable to this method's return type.
|
|
266
|
-
return
|
|
265
|
+
return delegateAxiosError(error)
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
const waitMs = retryDelayMs(attempt, directive, this.#retryPolicy)
|
package/lib/api/arcgis.ts
CHANGED
|
@@ -37,20 +37,20 @@ export class ArcGISServiceError extends Error {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Returns the error envelope in an ArcGIS JSON body, or `
|
|
40
|
+
* Returns the error envelope in an ArcGIS JSON body, or `null` when the body is a normal response.
|
|
41
41
|
*
|
|
42
42
|
* The body counts as an error only when its `error` object has a string `message`.
|
|
43
43
|
*/
|
|
44
|
-
export function readArcGISError(payload: unknown): ArcGISErrorEnvelope |
|
|
45
|
-
if (typeof payload !== "object" || payload
|
|
44
|
+
export function readArcGISError(payload: unknown): ArcGISErrorEnvelope | null {
|
|
45
|
+
if (typeof payload !== "object" || !payload) return null
|
|
46
46
|
|
|
47
47
|
const error = (payload as { error?: unknown }).error
|
|
48
48
|
|
|
49
|
-
if (typeof error !== "object" || error
|
|
49
|
+
if (typeof error !== "object" || !error) return null
|
|
50
50
|
|
|
51
51
|
const { code, message, details } = error as { code?: unknown; message?: unknown; details?: unknown }
|
|
52
52
|
|
|
53
|
-
if (typeof message !== "string") return
|
|
53
|
+
if (typeof message !== "string") return null
|
|
54
54
|
|
|
55
55
|
return {
|
|
56
56
|
...(typeof code === "number" ? { code } : {}),
|
package/lib/api/ckan.ts
CHANGED
|
@@ -66,7 +66,8 @@ export interface ReadCKANPackageRecordOptions {
|
|
|
66
66
|
context: string
|
|
67
67
|
/**
|
|
68
68
|
* The catalogue API base URL.
|
|
69
|
-
*
|
|
69
|
+
*
|
|
70
|
+
* @defaultValue {@linkcode CKAN_CATALOGUE_API_BASE_URL}
|
|
70
71
|
*/
|
|
71
72
|
baseURL?: string
|
|
72
73
|
}
|
package/lib/api/disk-storage.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface DiskStorageOptions {
|
|
|
55
55
|
/**
|
|
56
56
|
* Where rejected writes and unreadable entries are reported.
|
|
57
57
|
*
|
|
58
|
-
*
|
|
58
|
+
* @defaultValue a `disk-storage`-prefixed console logger.
|
|
59
59
|
*/
|
|
60
60
|
logger?: IRuntimeLogger
|
|
61
61
|
}
|
|
@@ -170,7 +170,7 @@ export function buildDiskStorage(options: DiskStorageOptions): AxiosStorage {
|
|
|
170
170
|
|
|
171
171
|
const parsed = tryParsingJSON<StorageValue>(raw)
|
|
172
172
|
|
|
173
|
-
if (parsed
|
|
173
|
+
if (!parsed) {
|
|
174
174
|
// A truncated or hand-edited entry is a miss rather than a crash — re-fetching is always safe.
|
|
175
175
|
logger.warn(`Discarding an unreadable cache entry for ${key}.`)
|
|
176
176
|
|
|
@@ -191,7 +191,7 @@ export function buildDiskStorage(options: DiskStorageOptions): AxiosStorage {
|
|
|
191
191
|
|
|
192
192
|
const serialized = serializeIfValid(key, value)
|
|
193
193
|
|
|
194
|
-
if (serialized
|
|
194
|
+
if (!serialized) {
|
|
195
195
|
// Drop any older entry too: the interceptor is telling us this key's content just changed.
|
|
196
196
|
// A superseded body would turn this changed response into a stale cache hit.
|
|
197
197
|
await removeEntry(key)
|
package/lib/api/ogc.ts
CHANGED
|
@@ -49,7 +49,7 @@ export class OGCServiceError extends Error {
|
|
|
49
49
|
const EXCEPTION_OPEN = "<ServiceException"
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* The element a WFS 2.0 service
|
|
52
|
+
* The element a WFS 2.0 service states its message in, with an optional namespace prefix.
|
|
53
53
|
*
|
|
54
54
|
* OGC 1.x answers `<ServiceExceptionReport>` holding `<ServiceException>`.
|
|
55
55
|
* WFS 2.0 answers `<ows:ExceptionReport>` holding `<ows:Exception exceptionCode="…">`
|
|
@@ -81,13 +81,13 @@ const OWS_EXCEPTION_CODE = /exceptionCode\s*=\s*"([^"]*)"/u
|
|
|
81
81
|
* The entire report would become the message if the parser matched that tag.
|
|
82
82
|
* An unclosed element reads as unreadable rather than as empty.
|
|
83
83
|
*/
|
|
84
|
-
function exceptionText(body: string): string |
|
|
84
|
+
function exceptionText(body: string): string | null {
|
|
85
85
|
let cursor = 0
|
|
86
86
|
|
|
87
87
|
for (;;) {
|
|
88
88
|
const start = body.indexOf(EXCEPTION_OPEN, cursor)
|
|
89
89
|
|
|
90
|
-
if (start === -1) return
|
|
90
|
+
if (start === -1) return null
|
|
91
91
|
|
|
92
92
|
const after = start + EXCEPTION_OPEN.length
|
|
93
93
|
|
|
@@ -100,11 +100,11 @@ function exceptionText(body: string): string | undefined {
|
|
|
100
100
|
|
|
101
101
|
const contentStart = body.indexOf(">", after)
|
|
102
102
|
|
|
103
|
-
if (contentStart === -1) return
|
|
103
|
+
if (contentStart === -1) return null
|
|
104
104
|
|
|
105
105
|
const end = body.indexOf("</ServiceException>", contentStart)
|
|
106
106
|
|
|
107
|
-
if (end === -1) return
|
|
107
|
+
if (end === -1) return null
|
|
108
108
|
|
|
109
109
|
return body.slice(contentStart + 1, end)
|
|
110
110
|
}
|
|
@@ -113,26 +113,26 @@ function exceptionText(body: string): string | undefined {
|
|
|
113
113
|
/**
|
|
114
114
|
* The text of an `ExceptionText` element, with or without a namespace prefix.
|
|
115
115
|
*
|
|
116
|
-
* The prefix is captured so the closing tag matches the one the document opened
|
|
117
|
-
*
|
|
116
|
+
* The prefix is captured so the closing tag matches the one the document opened.
|
|
117
|
+
* A prefixed element therefore never closes on an unprefixed one.
|
|
118
118
|
*/
|
|
119
|
-
function owsExceptionText(body: string): string |
|
|
119
|
+
function owsExceptionText(body: string): string | null {
|
|
120
120
|
const open = OWS_EXCEPTION_TEXT_OPEN.exec(body)
|
|
121
121
|
|
|
122
|
-
if (!open) return
|
|
122
|
+
if (!open) return null
|
|
123
123
|
|
|
124
124
|
const prefix = open[1]
|
|
125
125
|
const contentStart = open.index + open[0].length
|
|
126
126
|
const end = body.indexOf(prefix ? `</${prefix}:ExceptionText>` : "</ExceptionText>", contentStart)
|
|
127
127
|
|
|
128
128
|
// An unclosed element reads as unreadable rather than as empty, as the 1.x path does.
|
|
129
|
-
if (end === -1) return
|
|
129
|
+
if (end === -1) return null
|
|
130
130
|
|
|
131
131
|
return body.slice(contentStart, end)
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* The exception message inside an OGC or OWS exception report, or `
|
|
135
|
+
* The exception message inside an OGC or OWS exception report, or `null` for a body that is neither.
|
|
136
136
|
*
|
|
137
137
|
* Both dialects are read, because a report shares the HTTP status a real answer arrives on
|
|
138
138
|
* and a caller that recognizes one spelling parses the other as data.
|
|
@@ -144,8 +144,8 @@ function owsExceptionText(body: string): string | undefined {
|
|
|
144
144
|
*
|
|
145
145
|
* Split from the request so the detection is testable against captured bodies.
|
|
146
146
|
*/
|
|
147
|
-
export function readOGCServiceException(body: string): string |
|
|
148
|
-
if (!body.includes("ExceptionReport")) return
|
|
147
|
+
export function readOGCServiceException(body: string): string | null {
|
|
148
|
+
if (!body.includes("ExceptionReport")) return null
|
|
149
149
|
|
|
150
150
|
if (body.includes("ServiceExceptionReport")) {
|
|
151
151
|
// A body remains an exception report when its exception element cannot be read.
|
|
@@ -169,7 +169,7 @@ export function readOGCServiceException(body: string): string | undefined {
|
|
|
169
169
|
export function assertNoOGCServiceException(body: string, context: string): void {
|
|
170
170
|
const exception = readOGCServiceException(body)
|
|
171
171
|
|
|
172
|
-
if (exception
|
|
172
|
+
if (exception) {
|
|
173
173
|
throw new OGCServiceError(context, exception)
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -198,6 +198,14 @@ export interface CreateOGCFeaturesBBoxReaderOptions {
|
|
|
198
198
|
limit: number
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* One feature as an OGC API Features service publishes it, reduced to the fields a comparison reads.
|
|
203
|
+
*/
|
|
204
|
+
export interface OGCFeature<Properties = Record<string, unknown>> {
|
|
205
|
+
properties?: Properties
|
|
206
|
+
geometry?: { type: string; coordinates: unknown }
|
|
207
|
+
}
|
|
208
|
+
|
|
201
209
|
/**
|
|
202
210
|
* A reader answering an OGC API Features bbox query around a point.
|
|
203
211
|
*
|
|
@@ -250,7 +258,7 @@ export async function readOGCCollectionBBox(
|
|
|
250
258
|
|
|
251
259
|
if (!bbox || bbox.length < BBOX_ORDINATES) {
|
|
252
260
|
throw new TypeError(
|
|
253
|
-
`${options.context}: the OGC collection${options.subject
|
|
261
|
+
`${options.context}: the OGC collection${options.subject ? ` ${options.subject}` : ""} carried no spatial extent`
|
|
254
262
|
)
|
|
255
263
|
}
|
|
256
264
|
|
|
@@ -281,7 +289,7 @@ export interface ReadWFSFeatureCountOptions {
|
|
|
281
289
|
async function readReportedNumberMatched(
|
|
282
290
|
client: Pick<APIClient, "fetch">,
|
|
283
291
|
options: ReadWFSFeatureCountOptions & { startIndex?: number }
|
|
284
|
-
): Promise<string |
|
|
292
|
+
): Promise<string | null> {
|
|
285
293
|
const { data } = await client.fetch<string>({
|
|
286
294
|
method: "GET",
|
|
287
295
|
url: options.wfsURL,
|
|
@@ -304,11 +312,12 @@ async function readReportedNumberMatched(
|
|
|
304
312
|
/**
|
|
305
313
|
* The feature count a WFS reports for one type.
|
|
306
314
|
*
|
|
307
|
-
* `resultType=hits
|
|
315
|
+
* `resultType=hits` returns the count without a single geometry.
|
|
308
316
|
*
|
|
309
317
|
* This takes the service's word for the count.
|
|
310
318
|
* A caller that cannot check the number against the publisher's own figure reads
|
|
311
|
-
* {@linkcode readCheckedWFSFeatureCount} instead
|
|
319
|
+
* {@linkcode readCheckedWFSFeatureCount} instead.
|
|
320
|
+
* That reader asks a second time.
|
|
312
321
|
*
|
|
313
322
|
* @param options.subject Names the layer in the refusal, where the caller reads more than one.
|
|
314
323
|
*/
|
|
@@ -317,9 +326,9 @@ export async function readWFSFeatureCount(
|
|
|
317
326
|
options: ReadWFSFeatureCountOptions
|
|
318
327
|
): Promise<number> {
|
|
319
328
|
const numberMatched = await readReportedNumberMatched(client, options)
|
|
320
|
-
const subject = options.subject
|
|
329
|
+
const subject = options.subject ? ` for ${options.subject}` : ""
|
|
321
330
|
|
|
322
|
-
if (numberMatched
|
|
331
|
+
if (!numberMatched) {
|
|
323
332
|
throw new Error(`${options.context}: the WFS hits response${subject} carried no numberMatched attribute`)
|
|
324
333
|
}
|
|
325
334
|
|
|
@@ -339,7 +348,7 @@ export async function readWFSFeatureCount(
|
|
|
339
348
|
/**
|
|
340
349
|
* How much a service's own feature count is worth.
|
|
341
350
|
*
|
|
342
|
-
* `reported` is the number the service stated, and `usable`
|
|
351
|
+
* `reported` is the number the service stated, and `usable` records whether a second read agreed with it.
|
|
343
352
|
* A caller records the count only where `usable` is true and records `because` otherwise,
|
|
344
353
|
* so that a service which cannot count is told apart from one that counted a small number.
|
|
345
354
|
*/
|
|
@@ -360,34 +369,27 @@ const COUNT_PROBE_SIZE = 10
|
|
|
360
369
|
/**
|
|
361
370
|
* The feature count a WFS reports for one type, checked against a page of that type.
|
|
362
371
|
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
* Flanders (`geo.api.vlaanderen.be/ad/wfs`) answers `numberMatched="10000"` without a `startIndex`
|
|
367
|
-
* and `4563062` with one, so the first request meets a per-request cap rather than counting the type.
|
|
368
|
-
* This asks past index 0 for that reason.
|
|
372
|
+
* A bare `resultType=hits` request over a capped service answers with the cap,
|
|
373
|
+
* so the number cannot tell a reader whether it describes the type.
|
|
374
|
+
* This asks past index 0 and then probes a page.
|
|
369
375
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* A bare request answers `numberMatched="1000"`, which is MapServer's default feature cap.
|
|
376
|
+
* Flanders (`geo.api.vlaanderen.be/ad/wfs`) answers `numberMatched="10000"` without a
|
|
377
|
+
* `startIndex` and its real count with one, so this asks past index 0.
|
|
373
378
|
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* Its type
|
|
379
|
+
* Poland (`mapy.geoportal.gov.pl/wss/service/INSPIRE/Addresses`) reports MapServer's feature
|
|
380
|
+
* cap for a bare request, `unknown` for a feature page, and another number at `startIndex=1`.
|
|
381
|
+
* Its type held 8,625,921 features.
|
|
377
382
|
*
|
|
378
383
|
* The tell is that a page of the same type returns more features than the count admits,
|
|
379
384
|
* so this asks for one page and refuses a count that page contradicts.
|
|
380
|
-
*
|
|
381
|
-
* `startIndex` that still returns a feature, which a doubling search followed by a bisection
|
|
382
|
-
* finds in about 2·log2(n) requests, and a page straddling that index confirms the boundary.
|
|
385
|
+
* Such a service is counted by paging instead: {@linkcode countWFSFeaturesByPaging}.
|
|
383
386
|
*
|
|
384
387
|
* A missing `numberMatched` can also be transient.
|
|
385
|
-
* Slovakia's `rageo.minv.sk/geoserver/ad/wfs` answered one request out of nine with
|
|
386
|
-
* no such attribute and the other eight with `1704196`.
|
|
388
|
+
* Slovakia's `rageo.minv.sk/geoserver/ad/wfs` answered one request out of nine with no such attribute.
|
|
387
389
|
*
|
|
388
390
|
* This reports that response as unusable rather than inventing a count,
|
|
389
391
|
* so a caller that needs the number retries, through `APIClient`'s `retry` configuration
|
|
390
|
-
* or by reading the `numberMatched` a feature page
|
|
392
|
+
* or by reading the `numberMatched` a feature page holds.
|
|
391
393
|
*
|
|
392
394
|
* @param options.subject Names the layer in the reason, where the caller reads more than one.
|
|
393
395
|
*/
|
|
@@ -398,7 +400,7 @@ export async function readCheckedWFSFeatureCount(
|
|
|
398
400
|
const probeSize = options.probeSize ?? COUNT_PROBE_SIZE
|
|
399
401
|
const numberMatched = await readReportedNumberMatched(client, { ...options, startIndex: 1 })
|
|
400
402
|
|
|
401
|
-
if (numberMatched
|
|
403
|
+
if (!numberMatched) {
|
|
402
404
|
return { reported: null, usable: false, because: "the hits response carried no numberMatched attribute" }
|
|
403
405
|
}
|
|
404
406
|
|
|
@@ -430,7 +432,7 @@ export async function readCheckedWFSFeatureCount(
|
|
|
430
432
|
assertNoOGCServiceException(probe, options.context)
|
|
431
433
|
|
|
432
434
|
const returned = rootAttribute(probe, "numberReturned", { xml: true })
|
|
433
|
-
const observed = returned
|
|
435
|
+
const observed = returned && /^\d+$/u.test(returned) ? Number(returned) : null
|
|
434
436
|
|
|
435
437
|
if (observed !== null && observed > reported) {
|
|
436
438
|
return {
|
|
@@ -441,12 +443,13 @@ export async function readCheckedWFSFeatureCount(
|
|
|
441
443
|
}
|
|
442
444
|
|
|
443
445
|
// A page no larger than the reported count agrees with it whatever the truth is,
|
|
444
|
-
// so agreement
|
|
445
|
-
//
|
|
446
|
+
// so agreement does not establish that the count describes the type.
|
|
447
|
+
// One request does: asking for one feature at the reported index.
|
|
448
|
+
// A service holding exactly that many returns none there.
|
|
446
449
|
//
|
|
447
450
|
// Poland's address service is why this request exists.
|
|
448
|
-
// It answers `numberMatched="1000"`,
|
|
449
|
-
//
|
|
451
|
+
// It answers `numberMatched="1000"`, MapServer's own feature cap, and its pages cap at 1,000 too.
|
|
452
|
+
// A 10-feature probe therefore agreed with 1,000 while the type held 8,626,951.
|
|
450
453
|
// A caller trusting that would have stored 1,000 features and recorded the type as read whole.
|
|
451
454
|
const { data: beyond } = await client.fetch<string>({
|
|
452
455
|
method: "GET",
|
|
@@ -466,7 +469,7 @@ export async function readCheckedWFSFeatureCount(
|
|
|
466
469
|
|
|
467
470
|
const beyondReturned = rootAttribute(beyond, "numberReturned", { xml: true })
|
|
468
471
|
|
|
469
|
-
if (beyondReturned
|
|
472
|
+
if (beyondReturned && /^[1-9]\d*$/u.test(beyondReturned)) {
|
|
470
473
|
return {
|
|
471
474
|
reported,
|
|
472
475
|
usable: false,
|
|
@@ -487,7 +490,8 @@ export async function readCheckedWFSFeatureCount(
|
|
|
487
490
|
export interface PagedWFSFeatureCount {
|
|
488
491
|
count: number
|
|
489
492
|
/**
|
|
490
|
-
* Requests this measurement sent
|
|
493
|
+
* Requests this measurement sent.
|
|
494
|
+
* This is the cost a caller is choosing to pay.
|
|
491
495
|
*/
|
|
492
496
|
requests: number
|
|
493
497
|
/**
|
|
@@ -508,8 +512,8 @@ const PAGING_COUNT_CEILING = 2 ** 34
|
|
|
508
512
|
/**
|
|
509
513
|
* The feature count a type holds, measured by asking which indices hold a feature.
|
|
510
514
|
*
|
|
511
|
-
*
|
|
512
|
-
* {@linkcode readCheckedWFSFeatureCount} reports as `usable: false`.
|
|
515
|
+
* This serves a service whose own `resultType=hits` cannot be trusted.
|
|
516
|
+
* {@linkcode readCheckedWFSFeatureCount} reports that condition as `usable: false`.
|
|
513
517
|
* What such a service still answers truthfully is whether a feature exists at a given
|
|
514
518
|
* `startIndex`, so the count is the largest index that returns one, plus one.
|
|
515
519
|
*
|
|
@@ -517,7 +521,7 @@ const PAGING_COUNT_CEILING = 2 ** 34
|
|
|
517
521
|
* It costs about 2·log2(n) requests: 51 for Poland's 8,625,921 features.
|
|
518
522
|
*
|
|
519
523
|
* A page straddling the last index then confirms the boundary.
|
|
520
|
-
* `confirmed`
|
|
524
|
+
* `confirmed` reports that answer to the caller, because a service that caps a
|
|
521
525
|
* page would make the bisection stop early.
|
|
522
526
|
*
|
|
523
527
|
* The measurement means something only where paging works.
|
|
@@ -560,7 +564,7 @@ export async function countWFSFeaturesByPaging(
|
|
|
560
564
|
|
|
561
565
|
const returned = rootAttribute(data, "numberReturned", { xml: true })
|
|
562
566
|
|
|
563
|
-
return { returned: returned
|
|
567
|
+
return { returned: returned && /^\d+$/u.test(returned) ? Number(returned) : null, body: data }
|
|
564
568
|
}
|
|
565
569
|
|
|
566
570
|
const leading = options.identify ?? ((body: string) => /gml:id="([^"]+)"/u.exec(body)?.[1] ?? null)
|
|
@@ -572,7 +576,7 @@ export async function countWFSFeaturesByPaging(
|
|
|
572
576
|
|
|
573
577
|
const second = await read(2, 2)
|
|
574
578
|
|
|
575
|
-
if (leading(first.body)
|
|
579
|
+
if (leading(first.body) && leading(first.body) === leading(second.body)) {
|
|
576
580
|
throw new Error(
|
|
577
581
|
`${options.context}: the service answered startIndex 0 and startIndex 2 with the same leading feature, so it is ignoring startIndex and a count measured by paging it would be this service's page cap rather than its feature count`
|
|
578
582
|
)
|
package/lib/api/pacer.ts
CHANGED
|
@@ -48,7 +48,7 @@ export class RequestPacer {
|
|
|
48
48
|
* A zero-interval pacer would never actually pace.
|
|
49
49
|
* Silently accepting one would make a misconfigured caller look throttled when it isn't.
|
|
50
50
|
* @param clock Time source.
|
|
51
|
-
*
|
|
51
|
+
* @defaultValue {@linkcode systemClock}
|
|
52
52
|
*/
|
|
53
53
|
constructor(intervalMs: number, clock: ClockLike = systemClock) {
|
|
54
54
|
if (!Number.isFinite(intervalMs) || intervalMs <= 0) {
|
package/lib/api/retry.ts
CHANGED
|
@@ -180,7 +180,8 @@ export interface RetryOptions {
|
|
|
180
180
|
* Total attempts, including the first, before giving up.
|
|
181
181
|
*
|
|
182
182
|
* A stated ceiling rather than "until it works".
|
|
183
|
-
*
|
|
183
|
+
*
|
|
184
|
+
* @defaultValue {@linkcode DEFAULT_MAX_ATTEMPTS}
|
|
184
185
|
*/
|
|
185
186
|
maxAttempts?: number
|
|
186
187
|
/**
|
|
@@ -188,7 +189,8 @@ export interface RetryOptions {
|
|
|
188
189
|
*
|
|
189
190
|
* Attempt `n`'s wait is `baseDelayMs * 2^(n-1)`, unless the response includes a `Retry-After` header.
|
|
190
191
|
* The client honors that delay instead.
|
|
191
|
-
*
|
|
192
|
+
*
|
|
193
|
+
* @defaultValue {@linkcode DEFAULT_BASE_RETRY_DELAY_MS}
|
|
192
194
|
*/
|
|
193
195
|
baseDelayMs?: number
|
|
194
196
|
}
|
|
@@ -204,9 +206,9 @@ export interface ResolvedRetryPolicy {
|
|
|
204
206
|
/**
|
|
205
207
|
* Fill in {@linkcode RetryOptions}' defaults.
|
|
206
208
|
*
|
|
207
|
-
* `
|
|
209
|
+
* `null` (the absent option) resolves to a single attempt — no retry.
|
|
208
210
|
*/
|
|
209
|
-
export function resolveRetryPolicy(options: RetryOptions | boolean |
|
|
211
|
+
export function resolveRetryPolicy(options: RetryOptions | boolean | null): ResolvedRetryPolicy {
|
|
210
212
|
if (!options) return { maxAttempts: 1, baseDelayMs: DEFAULT_BASE_RETRY_DELAY_MS }
|
|
211
213
|
|
|
212
214
|
const provided = options === true ? {} : options
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
*
|
|
16
16
|
* Everything here is built structurally with `isAxiosError: true` and `config`/`code`/`response`.
|
|
17
17
|
* The adapter uses `APIClientConfig["axios"]` because the packages under test reach Axios integrations through
|
|
18
|
-
* `@mailwoman/core`.
|
|
19
|
-
*
|
|
18
|
+
* `@mailwoman/core`. The axios type {@linkcode stubFetchingBodies} resolves is stated here
|
|
19
|
+
* rather than by the calling test,
|
|
20
20
|
* so a workspace that stubs a request needs no `axios` dependency of its own.
|
|
21
21
|
*/
|
|
22
22
|
|
|
@@ -51,9 +51,9 @@ export interface StubRequestConfig {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* One scripted adapter
|
|
54
|
+
* One scripted adapter result.
|
|
55
55
|
*/
|
|
56
|
-
export interface
|
|
56
|
+
export interface StubResult {
|
|
57
57
|
status?: number
|
|
58
58
|
statusText?: string
|
|
59
59
|
/**
|
|
@@ -110,9 +110,9 @@ export interface StubTransportOptions {
|
|
|
110
110
|
*/
|
|
111
111
|
clock?: { now(): number }
|
|
112
112
|
/**
|
|
113
|
-
* The body served when
|
|
113
|
+
* The body served when a result names none.
|
|
114
114
|
*
|
|
115
|
-
*
|
|
115
|
+
* @defaultValue `{ ok: true }`; pass the envelope the client under test expects
|
|
116
116
|
* when it validates one (BDC's `{ data: [] }`, say).
|
|
117
117
|
*/
|
|
118
118
|
defaultBody?: unknown
|
|
@@ -122,11 +122,11 @@ export interface StubTransportOptions {
|
|
|
122
122
|
* A client answering each `fetch` with the next of `bodies`, holding on the last once exhausted.
|
|
123
123
|
*
|
|
124
124
|
* A reader that takes `Pick<APIClient, "fetch">` reads only `data`, so the stub states
|
|
125
|
-
* that field
|
|
126
|
-
*
|
|
125
|
+
* that field only rather than building headers and a config.
|
|
126
|
+
* Several bodies script a reader that asks twice, such as a count checked against a page.
|
|
127
127
|
*
|
|
128
128
|
* This lives beside {@linkcode stubTransport} so that a workspace which does not
|
|
129
|
-
* depend on `axios` can still stub the method: the axios type is
|
|
129
|
+
* depend on `axios` can still stub the method: the axios type is stated here,
|
|
130
130
|
* in core, rather than by the test that calls this.
|
|
131
131
|
*/
|
|
132
132
|
export function stubFetchingBodies(...bodies: string[]): Pick<APIClient, "fetch"> {
|
|
@@ -165,7 +165,7 @@ export function axiosLikeError(message: string, code: string, config: StubReques
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
-
* A stub Axios adapter that replays `
|
|
168
|
+
* A stub Axios adapter that replays `results` (holding on the last entry once exhausted)
|
|
169
169
|
* and records every dispatch.
|
|
170
170
|
*
|
|
171
171
|
* It reproduces what Axios's real adapters do on a failing status — reject with an
|
|
@@ -173,7 +173,7 @@ export function axiosLikeError(message: string, code: string, config: StubReques
|
|
|
173
173
|
* by the adapter rather than by the interceptor chain.
|
|
174
174
|
* A test that resolves with a 4xx instead would exercise a path the real transport never takes.
|
|
175
175
|
*/
|
|
176
|
-
export function stubTransport(
|
|
176
|
+
export function stubTransport(results: StubResult[], options: StubTransportOptions = {}): StubTransport {
|
|
177
177
|
const { clock, defaultBody = { ok: true } } = options
|
|
178
178
|
const calls: string[] = []
|
|
179
179
|
const configs: StubRequestConfig[] = []
|
|
@@ -188,15 +188,15 @@ export function stubTransport(outcomes: StubOutcome[], options: StubTransportOpt
|
|
|
188
188
|
dispatchTimes.push(clock.now())
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
const
|
|
191
|
+
const stub = results[Math.min(index, results.length - 1)]!
|
|
192
192
|
|
|
193
193
|
index++
|
|
194
194
|
|
|
195
|
-
if (
|
|
196
|
-
throw axiosLikeError(
|
|
195
|
+
if (stub.throws) {
|
|
196
|
+
throw axiosLikeError(stub.throws.message, stub.throws.code, config)
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
const status =
|
|
199
|
+
const status = stub.status ?? HTTP_OK
|
|
200
200
|
|
|
201
201
|
const response = {
|
|
202
202
|
// Axios's `transformResponse` runs on the raw body, so the stub passes
|
|
@@ -205,12 +205,12 @@ export function stubTransport(outcomes: StubOutcome[], options: StubTransportOpt
|
|
|
205
205
|
// Bytes also pass through unchanged.
|
|
206
206
|
// The stub serializes other values as a JSON endpoint would.
|
|
207
207
|
data:
|
|
208
|
-
typeof
|
|
209
|
-
?
|
|
210
|
-
: stringifyJSON(
|
|
208
|
+
typeof stub.body === "string" || Buffer.isBuffer(stub.body)
|
|
209
|
+
? stub.body
|
|
210
|
+
: stringifyJSON(stub.body ?? defaultBody),
|
|
211
211
|
status,
|
|
212
|
-
statusText:
|
|
213
|
-
headers:
|
|
212
|
+
statusText: stub.statusText ?? "OK",
|
|
213
|
+
headers: stub.headers ?? {},
|
|
214
214
|
config,
|
|
215
215
|
}
|
|
216
216
|
|
package/lib/api.ts
CHANGED
|
@@ -129,13 +129,14 @@ export function isOffMapHandled(prediction: CoarsePrediction): boolean {
|
|
|
129
129
|
export interface CoarsePlacerOpts {
|
|
130
130
|
/**
|
|
131
131
|
* The minimum confidence for a prediction.
|
|
132
|
-
*
|
|
132
|
+
*
|
|
133
|
+
* @defaultValue `0.5`
|
|
133
134
|
*/
|
|
134
135
|
abstainBelow?: number
|
|
135
136
|
/**
|
|
136
137
|
* Abstains on the total probability of in-map classes and otherwise returns the top in-map class.
|
|
137
138
|
*
|
|
138
|
-
*
|
|
139
|
+
* @defaultValue `false`, which abstains on the top-class probability.
|
|
139
140
|
*/
|
|
140
141
|
openSet?: boolean
|
|
141
142
|
}
|
|
@@ -303,7 +304,7 @@ export function inMapPosterior(
|
|
|
303
304
|
epsilonFloor?: number
|
|
304
305
|
}
|
|
305
306
|
): Record<string, number> | null {
|
|
306
|
-
if (prediction.country
|
|
307
|
+
if (!prediction.country || prediction.country === "OTHER") return null
|
|
307
308
|
const floor = opts?.epsilonFloor ?? 0
|
|
308
309
|
const posterior: Record<string, number> = {}
|
|
309
310
|
|
package/lib/crypto/node.ts
CHANGED
|
@@ -55,8 +55,7 @@ export function normalizeSHASeeds(input: SHA3Input): string[] {
|
|
|
55
55
|
* Each normalized seed is fed into the hash sequentially.
|
|
56
56
|
*
|
|
57
57
|
* @param seeds - Values to hash.
|
|
58
|
-
* @param outputLength - Length of the digest in **bytes
|
|
59
|
-
* Defaults to `32` (256-bit output).
|
|
58
|
+
* @param outputLength - [32] Length of the digest in **bytes** (256-bit output).
|
|
60
59
|
*
|
|
61
60
|
* @returns Uppercase hexadecimal digest.
|
|
62
61
|
*/
|
|
@@ -128,11 +128,11 @@ function flush(open: OpenSpan | null, raw: string, out: AddressNode[], attributi
|
|
|
128
128
|
const confidence = attribution.calibrate ? attribution.calibrate(rawConfidence) : rawConfidence
|
|
129
129
|
const node: AddressNode = { tag: open.tag, start, end, value, confidence, children: [] }
|
|
130
130
|
|
|
131
|
-
if (attribution.source
|
|
131
|
+
if (attribution.source) {
|
|
132
132
|
node.source = attribution.source
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
if (attribution.sourceID
|
|
135
|
+
if (attribution.sourceID) {
|
|
136
136
|
node.sourceID = attribution.sourceID
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -156,13 +156,13 @@ function emitSpans(raw: string, tokens: DecoderToken[], attribution: BuildTreeOp
|
|
|
156
156
|
// The span stays open so the following same-tag `B-` token can merge in
|
|
157
157
|
// (see the spurious-boundary repair below).
|
|
158
158
|
// A non-whitespace `O` (comma, slash, …) is a genuine separator and still flushes.
|
|
159
|
-
if (open
|
|
159
|
+
if (open && /^\s*$/.test(raw.slice(tok.start, tok.end))) continue
|
|
160
160
|
open = flush(open, raw, out, attribution)
|
|
161
161
|
|
|
162
162
|
continue
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
if (prefix === "B" || open
|
|
165
|
+
if (prefix === "B" || !open || open.tag !== tag) {
|
|
166
166
|
// Spurious-boundary repair: a `B-X` token that is whitespace-adjacent to an
|
|
167
167
|
// already-open `X` span is the model fragmenting a multi-word value, e.g. "Saint
|
|
168
168
|
// Paul" emitted as B-locality B-locality, where the second tag continues the first.
|
|
@@ -172,7 +172,7 @@ function emitSpans(raw: string, tokens: DecoderToken[], attribution: BuildTreeOp
|
|
|
172
172
|
// A comma or any other separator keeps them distinct.
|
|
173
173
|
// An intervening O or different-tag token already nulls or replaces `open` above.
|
|
174
174
|
// Two separate same-tag spans (e.g. "Springfield, Chicago") are never merged.
|
|
175
|
-
if (prefix === "B" && open
|
|
175
|
+
if (prefix === "B" && open && open.tag === tag && /^\s*$/.test(raw.slice(open.end, tok.start))) {
|
|
176
176
|
open.end = tok.end
|
|
177
177
|
open.confidences.push(tok.confidence)
|
|
178
178
|
|