@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
|
@@ -37,21 +37,21 @@ export type SpanDeltaKind = "added" | "removed" | "retagged" | "moved" | "confid
|
|
|
37
37
|
export interface SpanDelta {
|
|
38
38
|
kind: SpanDeltaKind
|
|
39
39
|
/**
|
|
40
|
-
* The tag on each side: equal unless `kind` is `retagged`, and one side is
|
|
40
|
+
* The tag on each side: equal unless `kind` is `retagged`, and one side is `null` for `added`/`removed`.
|
|
41
41
|
*/
|
|
42
|
-
tagBefore
|
|
43
|
-
tagAfter
|
|
44
|
-
valueBefore
|
|
45
|
-
valueAfter
|
|
46
|
-
spanBefore
|
|
47
|
-
spanAfter
|
|
48
|
-
confidenceBefore
|
|
49
|
-
confidenceAfter
|
|
42
|
+
tagBefore: string | null
|
|
43
|
+
tagAfter: string | null
|
|
44
|
+
valueBefore: string | null
|
|
45
|
+
valueAfter: string | null
|
|
46
|
+
spanBefore: [number, number] | null
|
|
47
|
+
spanAfter: [number, number] | null
|
|
48
|
+
confidenceBefore: number | null
|
|
49
|
+
confidenceAfter: number | null
|
|
50
50
|
/**
|
|
51
|
-
* `after - before`,
|
|
51
|
+
* `after - before`, `null` unless both sides are present.
|
|
52
52
|
* Negative means the arm under test is less sure.
|
|
53
53
|
*/
|
|
54
|
-
confidenceDelta
|
|
54
|
+
confidenceDelta: number | null
|
|
55
55
|
/**
|
|
56
56
|
* Where the assertion came from — `rule`, `neural`, `resolver`.
|
|
57
57
|
*
|
|
@@ -59,10 +59,10 @@ export interface SpanDelta {
|
|
|
59
59
|
* That change removes its gazetteer backing.
|
|
60
60
|
* A tag-level diff cannot show it.
|
|
61
61
|
*/
|
|
62
|
-
sourceBefore
|
|
63
|
-
sourceAfter
|
|
64
|
-
sourceIDBefore
|
|
65
|
-
sourceIDAfter
|
|
62
|
+
sourceBefore: string | null
|
|
63
|
+
sourceAfter: string | null
|
|
64
|
+
sourceIDBefore: string | null
|
|
65
|
+
sourceIDAfter: string | null
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -84,8 +84,8 @@ export interface ParseDiff {
|
|
|
84
84
|
* A parse that changed no other component but moved its country confidence across
|
|
85
85
|
* the scope threshold will geocode somewhere else entirely.
|
|
86
86
|
*/
|
|
87
|
-
localeCountryBefore
|
|
88
|
-
localeCountryAfter
|
|
87
|
+
localeCountryBefore: { country: string; confidence: number } | null
|
|
88
|
+
localeCountryAfter: { country: string; confidence: number } | null
|
|
89
89
|
/**
|
|
90
90
|
* True when no span changed and the locale call is identical — the arms agree on this input.
|
|
91
91
|
*/
|
|
@@ -98,8 +98,8 @@ interface Flat {
|
|
|
98
98
|
start: number
|
|
99
99
|
end: number
|
|
100
100
|
confidence: number
|
|
101
|
-
source
|
|
102
|
-
sourceID
|
|
101
|
+
source: string | null
|
|
102
|
+
sourceID: string | null
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function toFlat(tree: AddressTree | null | undefined): Flat[] {
|
|
@@ -109,8 +109,8 @@ function toFlat(tree: AddressTree | null | undefined): Flat[] {
|
|
|
109
109
|
start: node.start,
|
|
110
110
|
end: node.end,
|
|
111
111
|
confidence: node.confidence,
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
source: node.source ?? null,
|
|
113
|
+
sourceID: node.sourceID ?? null,
|
|
114
114
|
}))
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -201,10 +201,10 @@ export function diffParse(
|
|
|
201
201
|
confidenceBefore: left.confidence,
|
|
202
202
|
confidenceAfter: right.confidence,
|
|
203
203
|
confidenceDelta: right.confidence - left.confidence,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
sourceBefore: left.source,
|
|
205
|
+
sourceAfter: right.source,
|
|
206
|
+
sourceIDBefore: left.sourceID,
|
|
207
|
+
sourceIDAfter: right.sourceID,
|
|
208
208
|
})
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -214,10 +214,18 @@ export function diffParse(
|
|
|
214
214
|
spans.push({
|
|
215
215
|
kind: "removed",
|
|
216
216
|
tagBefore: left.tag,
|
|
217
|
+
tagAfter: null,
|
|
217
218
|
valueBefore: left.value,
|
|
219
|
+
valueAfter: null,
|
|
218
220
|
spanBefore: [left.start, left.end],
|
|
221
|
+
spanAfter: null,
|
|
219
222
|
confidenceBefore: left.confidence,
|
|
220
|
-
|
|
223
|
+
confidenceAfter: null,
|
|
224
|
+
confidenceDelta: null,
|
|
225
|
+
sourceBefore: left.source,
|
|
226
|
+
sourceAfter: null,
|
|
227
|
+
sourceIDBefore: left.sourceID,
|
|
228
|
+
sourceIDAfter: null,
|
|
221
229
|
})
|
|
222
230
|
}
|
|
223
231
|
|
|
@@ -226,11 +234,19 @@ export function diffParse(
|
|
|
226
234
|
|
|
227
235
|
spans.push({
|
|
228
236
|
kind: "added",
|
|
237
|
+
tagBefore: null,
|
|
229
238
|
tagAfter: right.tag,
|
|
239
|
+
valueBefore: null,
|
|
230
240
|
valueAfter: right.value,
|
|
241
|
+
spanBefore: null,
|
|
231
242
|
spanAfter: [right.start, right.end],
|
|
243
|
+
confidenceBefore: null,
|
|
232
244
|
confidenceAfter: right.confidence,
|
|
233
|
-
|
|
245
|
+
confidenceDelta: null,
|
|
246
|
+
sourceBefore: null,
|
|
247
|
+
sourceAfter: right.source,
|
|
248
|
+
sourceIDBefore: null,
|
|
249
|
+
sourceIDAfter: right.sourceID,
|
|
234
250
|
})
|
|
235
251
|
}
|
|
236
252
|
|
|
@@ -243,8 +259,8 @@ export function diffParse(
|
|
|
243
259
|
return {
|
|
244
260
|
input,
|
|
245
261
|
spans,
|
|
246
|
-
|
|
247
|
-
|
|
262
|
+
localeCountryBefore: locale?.before ?? null,
|
|
263
|
+
localeCountryAfter: locale?.after ?? null,
|
|
248
264
|
identical: !spans.some(isChange) && !localeMoved,
|
|
249
265
|
}
|
|
250
266
|
}
|
|
@@ -269,7 +285,7 @@ export function renderParseDiff(diff: ParseDiff, options: { context?: boolean }
|
|
|
269
285
|
return lines.join("\n")
|
|
270
286
|
}
|
|
271
287
|
|
|
272
|
-
const conf = (value
|
|
288
|
+
const conf = (value: number | null): string => (value === null ? "—" : value.toFixed(2))
|
|
273
289
|
|
|
274
290
|
for (const span of diff.spans) {
|
|
275
291
|
if (span.kind === "unchanged" && !options.context) continue
|
|
@@ -331,7 +347,7 @@ export function renderParseDiff(diff: ParseDiff, options: { context?: boolean }
|
|
|
331
347
|
|
|
332
348
|
if (moved) {
|
|
333
349
|
lines.push(
|
|
334
|
-
` ! locale country ${lb?.country ?? "—"} (${conf(lb?.confidence)}) → ${la?.country ?? "—"} (${conf(la?.confidence)})`
|
|
350
|
+
` ! locale country ${lb?.country ?? "—"} (${conf(lb?.confidence ?? null)}) → ${la?.country ?? "—"} (${conf(la?.confidence ?? null)})`
|
|
335
351
|
)
|
|
336
352
|
}
|
|
337
353
|
}
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type { ComponentTag } from "@mailwoman/codex/component"
|
|
19
|
+
import { z } from "zod"
|
|
19
20
|
|
|
20
21
|
import { slotNodes } from "#decoder/tree/walk"
|
|
21
|
-
import type
|
|
22
|
+
import { type AddressNode, type AddressTree, ComponentTagSchema } from "#decoder/types"
|
|
22
23
|
import { type UnknownSpan, unknownSpans } from "#decoder/unknown-spans"
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -31,22 +32,24 @@ import { type UnknownSpan, unknownSpans } from "#decoder/unknown-spans"
|
|
|
31
32
|
* `region: null` can mean the input had no region.
|
|
32
33
|
* It can also mean the projection dropped an input region.
|
|
33
34
|
*/
|
|
34
|
-
export
|
|
35
|
+
export const DroppedSpanSchema = z.object({
|
|
35
36
|
/**
|
|
36
37
|
* The tag stored on the span.
|
|
37
38
|
*
|
|
38
39
|
* It is always one already present in the output, because a drop happens only when the slot was taken.
|
|
39
40
|
*/
|
|
40
|
-
tag:
|
|
41
|
+
tag: ComponentTagSchema,
|
|
41
42
|
/**
|
|
42
43
|
* The value that was discarded.
|
|
43
44
|
*/
|
|
44
|
-
value: string
|
|
45
|
+
value: z.string(),
|
|
45
46
|
/**
|
|
46
47
|
* The value that held the slot, so a reader can see which of the two survived without re-walking the tree.
|
|
47
48
|
*/
|
|
48
|
-
kept: string
|
|
49
|
-
}
|
|
49
|
+
kept: z.string(),
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export type DroppedSpan = z.infer<typeof DroppedSpanSchema>
|
|
50
53
|
|
|
51
54
|
/**
|
|
52
55
|
* Options for {@link decodeAsJSON}.
|
|
@@ -22,8 +22,9 @@ export interface SerializeTuplesOpts {
|
|
|
22
22
|
/**
|
|
23
23
|
* Interleave `["unknown", value]` tuples for the all-O spans the model left unclassified, in source order.
|
|
24
24
|
*
|
|
25
|
-
* Default false keeps the tag-only shape.
|
|
26
25
|
* The caller can request the gaps.
|
|
26
|
+
*
|
|
27
|
+
* @defaultValue `false`, which keeps the tag-only shape.
|
|
27
28
|
*/
|
|
28
29
|
includeUnknown?: boolean
|
|
29
30
|
}
|
|
@@ -33,37 +33,37 @@ export interface SerializeXMLOpts {
|
|
|
33
33
|
/**
|
|
34
34
|
* Pretty-print with line breaks and indentation.
|
|
35
35
|
*
|
|
36
|
-
*
|
|
36
|
+
* @defaultValue `true`
|
|
37
37
|
*/
|
|
38
38
|
pretty?: boolean
|
|
39
39
|
/**
|
|
40
40
|
* Include `conf` attribute on every component.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
42
|
+
* @defaultValue `true`
|
|
43
43
|
*/
|
|
44
44
|
includeConf?: boolean
|
|
45
45
|
/**
|
|
46
46
|
* Include `start` + `end` char-offset attributes.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
48
|
+
* @defaultValue `true`
|
|
49
49
|
*/
|
|
50
50
|
includeOffsets?: boolean
|
|
51
51
|
/**
|
|
52
52
|
* Include `src` provenance attribute when the node has source info.
|
|
53
53
|
*
|
|
54
|
-
*
|
|
54
|
+
* @defaultValue `true`
|
|
55
55
|
*/
|
|
56
56
|
includeSrc?: boolean
|
|
57
57
|
/**
|
|
58
58
|
* Include `lat` + `lon` resolver-supplied centroid attrs when set on the node.
|
|
59
59
|
*
|
|
60
|
-
*
|
|
60
|
+
* @defaultValue `true`
|
|
61
61
|
*/
|
|
62
62
|
includeGeo?: boolean
|
|
63
63
|
/**
|
|
64
64
|
* Include `place` resolver-supplied normalized place URI when set.
|
|
65
65
|
*
|
|
66
|
-
*
|
|
66
|
+
* @defaultValue `true`
|
|
67
67
|
*/
|
|
68
68
|
includePlace?: boolean
|
|
69
69
|
/**
|
|
@@ -71,17 +71,18 @@ export interface SerializeXMLOpts {
|
|
|
71
71
|
*
|
|
72
72
|
* When set and `node.alternatives` is populated, each runner-up is emitted as a
|
|
73
73
|
* self-closing element with `place`, `name`, `lat`, `lon`, `score` attributes.
|
|
74
|
-
*
|
|
74
|
+
*
|
|
75
|
+
* @defaultValue `false`, which keeps the output libpostal-compatible unless the caller asks.
|
|
75
76
|
*/
|
|
76
77
|
includeAlternatives?: boolean
|
|
77
78
|
/**
|
|
78
79
|
* Emit `<unknown start end>…</unknown>` elements for all-O runs that no node covers.
|
|
79
80
|
* Those runs contain input the model left unclassified.
|
|
80
81
|
*
|
|
81
|
-
* Interleaved with the root components in source order, so the `<address>`
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
82
|
+
* Interleaved with the root components in source order, so the `<address>` children
|
|
83
|
+
* tile the raw input exactly. {@link includeAlternatives} uses the same default.
|
|
84
|
+
*
|
|
85
|
+
* @defaultValue `false`, which keeps the output libpostal-compatible unless the caller asks.
|
|
85
86
|
*/
|
|
86
87
|
includeUnknown?: boolean
|
|
87
88
|
}
|
|
@@ -129,7 +130,7 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
|
|
|
129
130
|
if (opts.includeSrc) {
|
|
130
131
|
const src = srcAttrValue(node)
|
|
131
132
|
|
|
132
|
-
if (src
|
|
133
|
+
if (src) {
|
|
133
134
|
parts.push(`src="${escapeXml(src)}"`)
|
|
134
135
|
}
|
|
135
136
|
}
|
|
@@ -141,7 +142,7 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
|
|
|
141
142
|
parts.push(`lat="${node.lat.toFixed(GEO_PRECISION)}"`, `lon="${node.lon.toFixed(GEO_PRECISION)}"`)
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
if (opts.includePlace && node.placeID
|
|
145
|
+
if (opts.includePlace && node.placeID) {
|
|
145
146
|
parts.push(`place="${escapeXml(node.placeID)}"`)
|
|
146
147
|
}
|
|
147
148
|
|
|
@@ -153,7 +154,7 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
|
|
|
153
154
|
parts.push(`roles="${escapeXml(roles.join(" "))}"`)
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
return
|
|
157
|
+
return parts.length ? " " + parts.join(" ") : ""
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
interface AlternativeLike {
|
|
@@ -48,8 +48,8 @@ export function loneValueNode(tree: AddressTree): AddressNode | null {
|
|
|
48
48
|
let lone: AddressNode | null = null
|
|
49
49
|
|
|
50
50
|
for (const node of walkNodes(tree.roots)) {
|
|
51
|
-
if (node.value.trim()
|
|
52
|
-
if (lone
|
|
51
|
+
if (node.value.trim()) {
|
|
52
|
+
if (lone) return null
|
|
53
53
|
lone = node
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -77,8 +77,8 @@ export interface FlatTreeNode {
|
|
|
77
77
|
* source moves from `resolver` to `neural` has lost its gazetteer backing.
|
|
78
78
|
* A projection that drops this reports that span as unchanged.
|
|
79
79
|
*/
|
|
80
|
-
source
|
|
81
|
-
sourceID
|
|
80
|
+
source: string | null
|
|
81
|
+
sourceID: string | null
|
|
82
82
|
/**
|
|
83
83
|
* The resolver's answer for this span, when one won.
|
|
84
84
|
*
|
|
@@ -91,10 +91,10 @@ export interface FlatTreeNode {
|
|
|
91
91
|
*
|
|
92
92
|
* Candidate objects would invite a walk that this projection already performed.
|
|
93
93
|
*/
|
|
94
|
-
placeID
|
|
95
|
-
lat
|
|
96
|
-
lon
|
|
97
|
-
alternatives
|
|
94
|
+
placeID: string | null
|
|
95
|
+
lat: number | null
|
|
96
|
+
lon: number | null
|
|
97
|
+
alternatives: number | null
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -123,12 +123,12 @@ export function flattenTreeNodes(tree?: AddressTree | null): FlatTreeNode[] {
|
|
|
123
123
|
confidence: node.confidence,
|
|
124
124
|
start: node.start,
|
|
125
125
|
end: node.end,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
source: node.source ?? null,
|
|
127
|
+
sourceID: node.sourceID ?? null,
|
|
128
|
+
placeID: node.placeID ?? null,
|
|
129
|
+
lat: node.lat ?? null,
|
|
130
|
+
lon: node.lon ?? null,
|
|
131
|
+
alternatives: node.alternatives?.length ?? null,
|
|
132
132
|
}))
|
|
133
133
|
.toSorted((a, b) => a.start - b.start)
|
|
134
134
|
}
|
package/lib/decoder/tree/walk.ts
CHANGED
|
@@ -119,6 +119,6 @@ export function slotNodes(roots: readonly AddressNode[]): AddressNode[] {
|
|
|
119
119
|
export function firstNodeWhere(
|
|
120
120
|
roots: readonly AddressNode[],
|
|
121
121
|
predicate: (node: AddressNode) => unknown
|
|
122
|
-
): AddressNode |
|
|
123
|
-
return walkNodes(roots).find(predicate)
|
|
122
|
+
): AddressNode | null {
|
|
123
|
+
return walkNodes(roots).find(predicate) ?? null
|
|
124
124
|
}
|
package/lib/decoder/types.ts
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* Types for decoded address trees and the labeled tokens they are built from.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type
|
|
9
|
+
import { type BIOLabel, COMPONENT_TAGS, type ComponentTag } from "@mailwoman/codex/component"
|
|
10
|
+
import { z } from "zod"
|
|
11
|
+
|
|
12
|
+
import { isRecordLike } from "#objects"
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* One token with its predicted label, confidence and offsets into the original input.
|
|
@@ -108,6 +111,48 @@ export interface Interpretation {
|
|
|
108
111
|
metadata?: Record<string, unknown>
|
|
109
112
|
}
|
|
110
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Every recognized address component tag, as a schema.
|
|
116
|
+
*/
|
|
117
|
+
export const ComponentTagSchema = z
|
|
118
|
+
.enum(COMPONENT_TAGS)
|
|
119
|
+
.meta({ id: "ComponentTag", description: "A recognized address component tag." })
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The wire schema of an {@link AddressNode}.
|
|
123
|
+
*
|
|
124
|
+
* The node is recursive, so the schema checks only that the value is an object and documents the rest.
|
|
125
|
+
*/
|
|
126
|
+
export const AddressNodeSchema = z.custom<AddressNode>(isRecordLike).meta({
|
|
127
|
+
id: "AddressNode",
|
|
128
|
+
type: "object",
|
|
129
|
+
additionalProperties: true,
|
|
130
|
+
description: "A decoded address-tree node: a tag, its span, and its children.",
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The wire schema of an {@link AddressTree}.
|
|
135
|
+
*/
|
|
136
|
+
export const AddressTreeSchema = z.custom<AddressTree>(isRecordLike).meta({
|
|
137
|
+
id: "AddressTree",
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: { raw: { type: "string" }, roots: { type: "array", items: { type: "object" } } },
|
|
140
|
+
required: ["raw", "roots"],
|
|
141
|
+
additionalProperties: true,
|
|
142
|
+
description: "A decoded address: the raw input and its top-level component nodes.",
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* One parsed component in reading order: a `ComponentTag` and the text it covers.
|
|
147
|
+
*
|
|
148
|
+
* HTTP surfaces put a list of these beside the full {@link AddressTree}.
|
|
149
|
+
*/
|
|
150
|
+
export const ParseComponentSchema = z
|
|
151
|
+
.object({ tag: z.string(), value: z.string() })
|
|
152
|
+
.meta({ id: "ParseComponent", description: "One parsed component in reading order." })
|
|
153
|
+
|
|
154
|
+
export type ParseComponent = z.infer<typeof ParseComponentSchema>
|
|
155
|
+
|
|
111
156
|
/**
|
|
112
157
|
* A decoded address with its top-level components in source order.
|
|
113
158
|
*/
|
|
@@ -119,7 +164,8 @@ export interface AddressTree {
|
|
|
119
164
|
roots: AddressNode[]
|
|
120
165
|
/**
|
|
121
166
|
* The addressing system that selects the containment hierarchy.
|
|
122
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* @defaultValue the Western hierarchy.
|
|
123
169
|
*/
|
|
124
170
|
system?: AddressSystem
|
|
125
171
|
/**
|
package/lib/env/schema.ts
CHANGED
|
@@ -7,45 +7,45 @@
|
|
|
7
7
|
* that reads its own variables declares them beside its readers and extends these views with `liveEnv`.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { object, string } from "zod"
|
|
11
11
|
|
|
12
12
|
import { DefaultMailwomanPaths } from "#env/paths"
|
|
13
13
|
import { blankAsAbsent } from "#env/utils"
|
|
14
14
|
|
|
15
15
|
// #region Public
|
|
16
16
|
|
|
17
|
-
const StorageEnvSchema =
|
|
17
|
+
const StorageEnvSchema = object({
|
|
18
18
|
// Platform-native application directories.
|
|
19
19
|
// Environment values override these defaults.
|
|
20
20
|
//
|
|
21
21
|
// A bare `.default()` fires only on `undefined`, so a present-but-empty variable passes validation intact.
|
|
22
|
-
MAILWOMAN_DATA_ROOT: blankAsAbsent(
|
|
22
|
+
MAILWOMAN_DATA_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.data)).meta({
|
|
23
23
|
title: "Data root",
|
|
24
24
|
description: "Root directory for downloaded Mailwoman data and runtime artifacts.",
|
|
25
25
|
}),
|
|
26
|
-
MAILWOMAN_CONFIG_ROOT: blankAsAbsent(
|
|
26
|
+
MAILWOMAN_CONFIG_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.config)).meta({
|
|
27
27
|
title: "Config root",
|
|
28
28
|
description: "Directory for Mailwoman configuration files.",
|
|
29
29
|
}),
|
|
30
|
-
MAILWOMAN_CACHE_ROOT: blankAsAbsent(
|
|
30
|
+
MAILWOMAN_CACHE_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.cache)).meta({
|
|
31
31
|
title: "Cache root",
|
|
32
32
|
description: "Directory for reusable downloaded and generated caches.",
|
|
33
33
|
}),
|
|
34
|
-
MAILWOMAN_TEMP_ROOT: blankAsAbsent(
|
|
34
|
+
MAILWOMAN_TEMP_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.temp)).meta({
|
|
35
35
|
title: "Temporary root",
|
|
36
36
|
description: "Directory for named temporary outputs and evaluation staging.",
|
|
37
37
|
}),
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
-
const RuntimeEnvSchema =
|
|
41
|
-
MAILWOMAN_COARSE_PLACER_DIR:
|
|
40
|
+
const RuntimeEnvSchema = object({
|
|
41
|
+
MAILWOMAN_COARSE_PLACER_DIR: string().optional().meta({
|
|
42
42
|
title: "Coarse placer directory",
|
|
43
43
|
description: "Directory containing the coarse country-placement model artifacts.",
|
|
44
44
|
}),
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
const LicenseEnvSchema =
|
|
48
|
-
MAILWOMAN_DOCS_URL:
|
|
47
|
+
const LicenseEnvSchema = object({
|
|
48
|
+
MAILWOMAN_DOCS_URL: string().optional().meta({
|
|
49
49
|
title: "Documentation URL",
|
|
50
50
|
description: "Base URL used by documentation and demo tooling.",
|
|
51
51
|
}),
|
|
@@ -61,7 +61,7 @@ const LicenseEnvSchema = z.object({
|
|
|
61
61
|
* Public in the sense that it is a signed assertion rather than a secret,
|
|
62
62
|
* but the doctor prints the licensee and expiry rather than the token.
|
|
63
63
|
*/
|
|
64
|
-
MAILWOMAN_LICENSE_KEY: blankAsAbsent(
|
|
64
|
+
MAILWOMAN_LICENSE_KEY: blankAsAbsent(string().min(1).optional()).meta({
|
|
65
65
|
title: "Commercial license key",
|
|
66
66
|
description: "Signed commercial license assertion used by `mailwoman doctor`; it does not change runtime behavior.",
|
|
67
67
|
}),
|
|
@@ -71,7 +71,7 @@ const LicenseEnvSchema = z.object({
|
|
|
71
71
|
*
|
|
72
72
|
* Pointed at a sandbox deploy or a test stub.
|
|
73
73
|
*/
|
|
74
|
-
MAILWOMAN_LICENSE_URL: blankAsAbsent(
|
|
74
|
+
MAILWOMAN_LICENSE_URL: blankAsAbsent(string().min(1).optional()).meta({
|
|
75
75
|
title: "License service URL",
|
|
76
76
|
description: "License-service origin used by license refresh and online status checks.",
|
|
77
77
|
}),
|
|
@@ -82,16 +82,14 @@ const LicenseEnvSchema = z.object({
|
|
|
82
82
|
*
|
|
83
83
|
* The schema strips any other key from `process.env` during parsing.
|
|
84
84
|
*/
|
|
85
|
-
export const PublicEnvSchema =
|
|
86
|
-
.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
description: "Non-secret operational configuration exposed through `$public`.",
|
|
94
|
-
})
|
|
85
|
+
export const PublicEnvSchema = object({
|
|
86
|
+
...StorageEnvSchema.shape,
|
|
87
|
+
...RuntimeEnvSchema.shape,
|
|
88
|
+
...LicenseEnvSchema.shape,
|
|
89
|
+
}).meta({
|
|
90
|
+
title: "Public environment configuration",
|
|
91
|
+
description: "Non-secret operational configuration exposed through `$public`.",
|
|
92
|
+
})
|
|
95
93
|
|
|
96
94
|
// #endregion
|
|
97
95
|
|
|
@@ -103,7 +101,7 @@ export const PublicEnvSchema = z
|
|
|
103
101
|
* Core reads none: this is the base every package's private view extends,
|
|
104
102
|
* so a credential is declared once, beside the code that sends it.
|
|
105
103
|
*/
|
|
106
|
-
export const PrivateEnvSchema =
|
|
104
|
+
export const PrivateEnvSchema = object({}).meta({
|
|
107
105
|
title: "Private environment configuration",
|
|
108
106
|
description: "Secrets and credentials exposed through `$private`; never log their values.",
|
|
109
107
|
})
|
package/lib/env/utils.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* Utility functions for working with the runtime environment.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { preprocess } from "zod"
|
|
10
|
+
import type { ZodType } from "zod"
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Wrap a coerced schema so a blank value means the same as an absent one: a shell `export FOO=`,
|
|
@@ -17,6 +18,6 @@ import { z } from "zod"
|
|
|
17
18
|
* The `.optional()`/`.default()` must be applied to `inner` before it reaches here,
|
|
18
19
|
* because the outer value is present and an outer `.optional()` never fires.
|
|
19
20
|
*/
|
|
20
|
-
export function blankAsAbsent<T extends
|
|
21
|
-
return
|
|
21
|
+
export function blankAsAbsent<T extends ZodType>(inner: T) {
|
|
22
|
+
return preprocess((v) => (v === "" ? undefined : v), inner)
|
|
22
23
|
}
|
package/lib/env.ts
CHANGED
|
@@ -56,8 +56,8 @@ export function liveEnv<Shape extends z.ZodRawShape, Base extends object = Recor
|
|
|
56
56
|
// Keep the object wrapper so validation issues still identify the environment variable by name.
|
|
57
57
|
const fieldSchema = schema.pick({ [key]: true } as Parameters<typeof schema.pick>[0])
|
|
58
58
|
|
|
59
|
-
let previous: string |
|
|
60
|
-
let cached: ReturnType<typeof fieldSchema.safeParse> |
|
|
59
|
+
let previous: string | null = null
|
|
60
|
+
let cached: ReturnType<typeof fieldSchema.safeParse> | null = null
|
|
61
61
|
|
|
62
62
|
Object.defineProperty(view, key, {
|
|
63
63
|
enumerable: true,
|
|
@@ -65,9 +65,9 @@ export function liveEnv<Shape extends z.ZodRawShape, Base extends object = Recor
|
|
|
65
65
|
// oxlint-disable-next-line sister-software/no-process-globals -- this module is the typed process.env boundary
|
|
66
66
|
const raw = process.env[key]
|
|
67
67
|
|
|
68
|
-
if (!cached || raw !== previous) {
|
|
68
|
+
if (!cached || (raw ?? null) !== previous) {
|
|
69
69
|
cached = fieldSchema.safeParse({ [key]: raw })
|
|
70
|
-
previous = raw
|
|
70
|
+
previous = raw ?? null
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
if (!cached.success) throw cached.error
|
package/lib/fs/delimited.ts
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* Downstream counts cannot distinguish this result from a small source file.
|
|
12
12
|
*
|
|
13
13
|
* The GeoNames country dumps are unquoted TSV and contain `"` in place names (`Ovrag Kyzylak"on`).
|
|
14
|
+
*
|
|
15
|
+
* A quote-aware reader of CSV text indexes its header with {@linkcode headerColumnIndex} and passes its
|
|
16
|
+
* record count to {@linkcode checkRecordCount}. A quote that never closes shortens that read in the same way.
|
|
14
17
|
*/
|
|
15
18
|
|
|
16
19
|
import { createReadStream } from "node:fs"
|
|
@@ -61,7 +64,7 @@ export async function readUnquotedTSVChecked(path: PathBuilderLike): Promise<str
|
|
|
61
64
|
|
|
62
65
|
// Streamed rather than split, so the check stays cheap enough that a build step always runs it.
|
|
63
66
|
for await (const line of TextSpliterator.fromAsync(path)) {
|
|
64
|
-
if (line
|
|
67
|
+
if (line) {
|
|
65
68
|
expected++
|
|
66
69
|
}
|
|
67
70
|
}
|
|
@@ -83,6 +86,37 @@ export async function readUnquotedTSVChecked(path: PathBuilderLike): Promise<str
|
|
|
83
86
|
return rows
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Maps each label of a header row to its column index, and throws when a label repeats.
|
|
91
|
+
*
|
|
92
|
+
* `file` identifies the file in the error message.
|
|
93
|
+
*/
|
|
94
|
+
export function headerColumnIndex(file: string, header: readonly string[]): Map<string, number> {
|
|
95
|
+
const columns = new Map<string, number>()
|
|
96
|
+
|
|
97
|
+
for (const [index, label] of header.entries()) {
|
|
98
|
+
if (columns.has(label)) throw new Error(`${file} repeats the header column "${label}".`)
|
|
99
|
+
|
|
100
|
+
columns.set(label, index)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return columns
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Throws when the count of records parsed from a delimited text differs from the text's count of data lines.
|
|
108
|
+
*
|
|
109
|
+
* The first non-empty line of `text` is its header, and each later non-empty line is a data line.
|
|
110
|
+
*
|
|
111
|
+
* A quote-aware reader joins every line after a quote that never closes into one record.
|
|
112
|
+
* The read then answers short with no other sign, so a reader of quoted text compares the two counts.
|
|
113
|
+
*/
|
|
114
|
+
export function checkRecordCount(file: string, text: string, records: number): void {
|
|
115
|
+
const dataLines = TextSpliterator.from(text).toArray().length - 1
|
|
116
|
+
|
|
117
|
+
if (records !== dataLines) throw new Error(`${file}: read ${records} records from ${dataLines} data lines.`)
|
|
118
|
+
}
|
|
119
|
+
|
|
86
120
|
/**
|
|
87
121
|
* The extension that marks a delimited file as zstd-compressed at rest.
|
|
88
122
|
*/
|