@mailwoman/resolver-wof-sqlite 9.1.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -20
- package/lib/address/index.ts +9 -0
- package/{address-point-interpolation.ts → lib/address/point-interpolation.ts} +40 -28
- package/{address-point-schema.ts → lib/address/point-schema.ts} +34 -8
- package/lib/address/point.ts +280 -0
- package/{ancestry-backfill.ts → lib/ancestry/backfill.ts} +14 -19
- package/{ancestry.ts → lib/ancestry/index.ts} +13 -8
- package/{build-candidate.ts → lib/build-candidate.ts} +243 -199
- package/{build-slim.ts → lib/build-slim.ts} +153 -168
- package/lib/candidate/alias-bags.ts +56 -0
- package/lib/candidate/ancestors-sidecar.ts +204 -0
- package/lib/candidate/country-display-names.ts +79 -0
- package/lib/candidate/extract-fold.ts +138 -0
- package/lib/candidate/name-roles.ts +238 -0
- package/lib/candidate/own-name.ts +146 -0
- package/lib/candidate/place-attrs.ts +44 -0
- package/lib/candidate-ancestors-schema.ts +195 -0
- package/{candidate-fts.ts → lib/candidate-fts.ts} +7 -5
- package/{candidate-importance.ts → lib/candidate-importance.ts} +54 -57
- package/lib/candidate-lookup.ts +976 -0
- package/{candidate-schema.ts → lib/candidate-schema.ts} +34 -6
- package/lib/candidate-scoring.ts +261 -0
- package/lib/capital-schema.ts +89 -0
- package/lib/capitals.ts +148 -0
- package/{coincident-roles.ts → lib/coincident-roles.ts} +75 -19
- package/{convention.ts → lib/convention/index.ts} +5 -5
- package/lib/convention/schema.ts +72 -0
- package/{coverage-manifest-schema.ts → lib/coverage-manifest-schema.ts} +15 -16
- package/lib/currency-backfill.ts +334 -0
- package/lib/env.ts +50 -0
- package/lib/exact-match.ts +113 -0
- package/{sharding.ts → lib/extracts.ts} +63 -60
- package/lib/fst/autocomplete.ts +176 -0
- package/{fst-builder.ts → lib/fst/builder.ts} +30 -27
- package/{fst-deserialize-web.ts → lib/fst/deserialize-web.ts} +27 -87
- package/lib/fst/format.ts +106 -0
- package/{fst-freshness.ts → lib/fst/freshness.ts} +42 -75
- package/lib/fst/index.ts +14 -0
- package/{fst-matcher.ts → lib/fst/matcher.ts} +1 -1
- package/{fst-serialize.ts → lib/fst/serialize.ts} +37 -115
- package/{fst-types.ts → lib/fst/types.ts} +4 -2
- package/{fts.ts → lib/fts/index.ts} +28 -23
- package/{fts-query.ts → lib/fts/query.ts} +2 -2
- package/{geonames-aliases.ts → lib/geonames/aliases.ts} +13 -13
- package/lib/geonames/index.ts +8 -0
- package/{geonames-postal.ts → lib/geonames/postal.ts} +16 -15
- package/{index.ts → lib/index.ts} +52 -48
- package/{interpolation.ts → lib/interpolation.ts} +137 -41
- package/lib/lookup.ts +861 -0
- package/{name-score.ts → lib/name-score.ts} +6 -4
- package/lib/nsul/index.ts +8 -0
- package/lib/nsul/lookup.ts +144 -0
- package/lib/nsul/schema.ts +130 -0
- package/{place-importance-schema.ts → lib/place-importance-schema.ts} +70 -22
- package/lib/poi/index.ts +8 -0
- package/{poi-lookup.ts → lib/poi/lookup.ts} +32 -39
- package/{poi-schema.ts → lib/poi/schema.ts} +10 -6
- package/lib/polygon-schema.ts +47 -0
- package/{postal-city-alias-lookup.ts → lib/postal/city-alias-lookup.ts} +15 -21
- package/{postal-city-candidate-schema.ts → lib/postal/city-candidate-schema.ts} +4 -2
- package/lib/postal/index.ts +9 -0
- package/{postcode-point-lookup.ts → lib/postcode-point-lookup.ts} +17 -15
- package/lib/primary-preference.ts +226 -0
- package/lib/proximity-rerank.ts +120 -0
- package/{ranking-weights.ts → lib/ranking-weights.ts} +30 -4
- package/lib/region-keys.ts +144 -0
- package/{reverse.ts → lib/reverse.ts} +45 -56
- package/{schema.ts → lib/schema.ts} +11 -1
- package/lib/search-fetch.ts +257 -0
- package/{sqlite-convention-source.ts → lib/sqlite-convention-source.ts} +9 -10
- package/lib/sqlite-utils.ts +83 -0
- package/{street-centroid-schema.ts → lib/street/centroid-schema.ts} +12 -6
- package/{street-centroid.ts → lib/street/centroid.ts} +26 -28
- package/lib/street/index.ts +13 -0
- package/{street-morphology-fst-builder.ts → lib/street/morphology-fst-builder.ts} +24 -14
- package/{street-morphology-fst-loader.ts → lib/street/morphology-fst-loader.ts} +14 -12
- package/{street-name-lookup.ts → lib/street/name-lookup.ts} +14 -30
- package/lib/street/normalize.ts +572 -0
- package/{street-segment-schema.ts → lib/street/segment-schema.ts} +13 -8
- package/{types.ts → lib/types.ts} +49 -9
- package/{unified-schema.ts → lib/unified-schema.ts} +21 -25
- package/lib/uprn/existence.ts +84 -0
- package/lib/uprn/index.ts +9 -0
- package/lib/uprn/lookup.ts +206 -0
- package/lib/uprn/schema.ts +124 -0
- package/lib/weights-overlay-linker.ts +878 -0
- package/out/address/index.d.ts +9 -0
- package/out/address/index.d.ts.map +1 -0
- package/out/address/index.js +9 -0
- package/out/address/index.js.map +1 -0
- package/out/{address-point-interpolation.d.ts → address/point-interpolation.d.ts} +11 -10
- package/out/address/point-interpolation.d.ts.map +1 -0
- package/out/{address-point-interpolation.js → address/point-interpolation.js} +29 -23
- package/out/address/point-interpolation.js.map +1 -0
- package/out/{address-point-schema.d.ts → address/point-schema.d.ts} +30 -10
- package/out/address/point-schema.d.ts.map +1 -0
- package/out/{address-point-schema.js → address/point-schema.js} +7 -3
- package/out/address/point-schema.js.map +1 -0
- package/out/{address-point.d.ts → address/point.d.ts} +16 -8
- package/out/address/point.d.ts.map +1 -0
- package/out/address/point.js +191 -0
- package/out/address/point.js.map +1 -0
- package/out/{ancestry-backfill.d.ts → ancestry/backfill.d.ts} +7 -5
- package/out/ancestry/backfill.d.ts.map +1 -0
- package/out/{ancestry-backfill.js → ancestry/backfill.js} +12 -16
- package/out/ancestry/backfill.js.map +1 -0
- package/out/{ancestry.d.ts → ancestry/index.d.ts} +6 -5
- package/out/ancestry/index.d.ts.map +1 -0
- package/out/{ancestry.js → ancestry/index.js} +7 -7
- package/out/ancestry/index.js.map +1 -0
- package/out/build-candidate.d.ts +88 -7
- package/out/build-candidate.d.ts.map +1 -1
- package/out/build-candidate.js +145 -149
- package/out/build-candidate.js.map +1 -1
- package/out/build-slim.d.ts +5 -5
- package/out/build-slim.d.ts.map +1 -1
- package/out/build-slim.js +127 -142
- package/out/build-slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +19 -0
- package/out/candidate/alias-bags.d.ts.map +1 -0
- package/out/candidate/alias-bags.js +39 -0
- package/out/candidate/alias-bags.js.map +1 -0
- package/out/candidate/ancestors-sidecar.d.ts +32 -0
- package/out/candidate/ancestors-sidecar.d.ts.map +1 -0
- package/out/candidate/ancestors-sidecar.js +140 -0
- package/out/candidate/ancestors-sidecar.js.map +1 -0
- package/out/candidate/country-display-names.d.ts +35 -0
- package/out/candidate/country-display-names.d.ts.map +1 -0
- package/out/candidate/country-display-names.js +59 -0
- package/out/candidate/country-display-names.js.map +1 -0
- package/out/candidate/extract-fold.d.ts +32 -0
- package/out/candidate/extract-fold.d.ts.map +1 -0
- package/out/candidate/extract-fold.js +104 -0
- package/out/candidate/extract-fold.js.map +1 -0
- package/out/candidate/name-roles.d.ts +57 -0
- package/out/candidate/name-roles.d.ts.map +1 -0
- package/out/candidate/name-roles.js +166 -0
- package/out/candidate/name-roles.js.map +1 -0
- package/out/candidate/own-name.d.ts +50 -0
- package/out/candidate/own-name.d.ts.map +1 -0
- package/out/candidate/own-name.js +132 -0
- package/out/candidate/own-name.js.map +1 -0
- package/out/candidate/place-attrs.d.ts +43 -0
- package/out/candidate/place-attrs.d.ts.map +1 -0
- package/out/candidate/place-attrs.js +15 -0
- package/out/candidate/place-attrs.js.map +1 -0
- package/out/candidate-ancestors-schema.d.ts +150 -0
- package/out/candidate-ancestors-schema.d.ts.map +1 -0
- package/out/candidate-ancestors-schema.js +123 -0
- package/out/candidate-ancestors-schema.js.map +1 -0
- package/out/candidate-fts.d.ts +7 -5
- package/out/candidate-fts.d.ts.map +1 -1
- package/out/candidate-fts.js +5 -3
- package/out/candidate-fts.js.map +1 -1
- package/out/candidate-importance.d.ts +16 -16
- package/out/candidate-importance.d.ts.map +1 -1
- package/out/candidate-importance.js +47 -52
- package/out/candidate-importance.js.map +1 -1
- package/out/candidate-lookup.d.ts +31 -52
- package/out/candidate-lookup.d.ts.map +1 -1
- package/out/candidate-lookup.js +380 -172
- package/out/candidate-lookup.js.map +1 -1
- package/out/candidate-schema.d.ts +31 -7
- package/out/candidate-schema.d.ts.map +1 -1
- package/out/candidate-schema.js +3 -0
- package/out/candidate-schema.js.map +1 -1
- package/out/candidate-scoring.d.ts +34 -0
- package/out/candidate-scoring.d.ts.map +1 -0
- package/out/candidate-scoring.js +196 -0
- package/out/candidate-scoring.js.map +1 -0
- package/out/capital-schema.d.ts +51 -0
- package/out/capital-schema.d.ts.map +1 -0
- package/out/capital-schema.js +63 -0
- package/out/capital-schema.js.map +1 -0
- package/out/capitals.d.ts +69 -0
- package/out/capitals.d.ts.map +1 -0
- package/out/capitals.js +98 -0
- package/out/capitals.js.map +1 -0
- package/out/coincident-roles.d.ts +12 -4
- package/out/coincident-roles.d.ts.map +1 -1
- package/out/coincident-roles.js +43 -11
- package/out/coincident-roles.js.map +1 -1
- package/out/{convention.d.ts → convention/index.d.ts} +5 -5
- package/out/convention/index.d.ts.map +1 -0
- package/out/{convention.js → convention/index.js} +4 -4
- package/out/convention/index.js.map +1 -0
- package/out/convention/schema.d.ts +51 -0
- package/out/convention/schema.d.ts.map +1 -0
- package/out/convention/schema.js +34 -0
- package/out/convention/schema.js.map +1 -0
- package/out/coverage-manifest-schema.d.ts +8 -8
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +6 -10
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/currency-backfill.d.ts +90 -0
- package/out/currency-backfill.d.ts.map +1 -0
- package/out/currency-backfill.js +196 -0
- package/out/currency-backfill.js.map +1 -0
- package/out/env.d.ts +43 -0
- package/out/env.d.ts.map +1 -0
- package/out/env.js +48 -0
- package/out/env.js.map +1 -0
- package/out/exact-match.d.ts +25 -0
- package/out/exact-match.d.ts.map +1 -0
- package/out/exact-match.js +88 -0
- package/out/exact-match.js.map +1 -0
- package/out/extracts.d.ts +114 -0
- package/out/extracts.d.ts.map +1 -0
- package/out/{sharding.js → extracts.js} +38 -38
- package/out/extracts.js.map +1 -0
- package/out/{fst-autocomplete.d.ts → fst/autocomplete.d.ts} +13 -13
- package/out/fst/autocomplete.d.ts.map +1 -0
- package/out/fst/autocomplete.js +113 -0
- package/out/fst/autocomplete.js.map +1 -0
- package/out/{fst-builder.d.ts → fst/builder.d.ts} +5 -5
- package/out/fst/builder.d.ts.map +1 -0
- package/out/{fst-builder.js → fst/builder.js} +24 -24
- package/out/fst/builder.js.map +1 -0
- package/out/{fst-deserialize-web.d.ts → fst/deserialize-web.d.ts} +3 -3
- package/out/fst/deserialize-web.d.ts.map +1 -0
- package/out/{fst-deserialize-web.js → fst/deserialize-web.js} +10 -74
- package/out/fst/deserialize-web.js.map +1 -0
- package/out/fst/format.d.ts +80 -0
- package/out/fst/format.d.ts.map +1 -0
- package/out/fst/format.js +91 -0
- package/out/fst/format.js.map +1 -0
- package/out/{fst-freshness.d.ts → fst/freshness.d.ts} +11 -14
- package/out/fst/freshness.d.ts.map +1 -0
- package/out/{fst-freshness.js → fst/freshness.js} +42 -74
- package/out/fst/freshness.js.map +1 -0
- package/out/fst/index.d.ts +14 -0
- package/out/fst/index.d.ts.map +1 -0
- package/out/fst/index.js +14 -0
- package/out/fst/index.js.map +1 -0
- package/out/{fst-matcher.d.ts → fst/matcher.d.ts} +2 -2
- package/out/fst/matcher.d.ts.map +1 -0
- package/out/{fst-matcher.js → fst/matcher.js} +1 -1
- package/out/fst/matcher.js.map +1 -0
- package/out/{fst-serialize.d.ts → fst/serialize.d.ts} +5 -10
- package/out/fst/serialize.d.ts.map +1 -0
- package/out/{fst-serialize.js → fst/serialize.js} +18 -98
- package/out/fst/serialize.js.map +1 -0
- package/out/{fst-types.d.ts → fst/types.d.ts} +4 -3
- package/out/fst/types.d.ts.map +1 -0
- package/out/{fst-types.js → fst/types.js} +1 -1
- package/out/fst/types.js.map +1 -0
- package/out/{fts.d.ts → fts/index.d.ts} +20 -13
- package/out/fts/index.d.ts.map +1 -0
- package/out/{fts.js → fts/index.js} +20 -15
- package/out/fts/index.js.map +1 -0
- package/out/{fts-query.d.ts → fts/query.d.ts} +2 -2
- package/out/fts/query.d.ts.map +1 -0
- package/out/{fts-query.js → fts/query.js} +2 -2
- package/out/fts/query.js.map +1 -0
- package/out/{geonames-aliases.d.ts → geonames/aliases.d.ts} +8 -6
- package/out/geonames/aliases.d.ts.map +1 -0
- package/out/{geonames-aliases.js → geonames/aliases.js} +7 -7
- package/out/geonames/aliases.js.map +1 -0
- package/out/geonames/index.d.ts +8 -0
- package/out/geonames/index.d.ts.map +1 -0
- package/out/geonames/index.js +8 -0
- package/out/geonames/index.js.map +1 -0
- package/out/{geonames-postal.d.ts → geonames/postal.d.ts} +12 -10
- package/out/geonames/postal.d.ts.map +1 -0
- package/out/{geonames-postal.js → geonames/postal.js} +11 -11
- package/out/geonames/postal.js.map +1 -0
- package/out/index.d.ts +32 -31
- package/out/index.d.ts.map +1 -1
- package/out/index.js +24 -24
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +18 -9
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +108 -36
- package/out/interpolation.js.map +1 -1
- package/out/lookup.d.ts +25 -25
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +174 -558
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts +0 -10
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js +6 -4
- package/out/name-score.js.map +1 -1
- package/out/nsul/index.d.ts +8 -0
- package/out/nsul/index.d.ts.map +1 -0
- package/out/nsul/index.js +8 -0
- package/out/nsul/index.js.map +1 -0
- package/out/nsul/lookup.d.ts +83 -0
- package/out/nsul/lookup.d.ts.map +1 -0
- package/out/nsul/lookup.js +80 -0
- package/out/nsul/lookup.js.map +1 -0
- package/out/nsul/schema.d.ts +100 -0
- package/out/nsul/schema.d.ts.map +1 -0
- package/out/nsul/schema.js +78 -0
- package/out/nsul/schema.js.map +1 -0
- package/out/place-importance-schema.d.ts +47 -10
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +56 -10
- package/out/place-importance-schema.js.map +1 -1
- package/out/poi/index.d.ts +8 -0
- package/out/poi/index.d.ts.map +1 -0
- package/out/poi/index.js +8 -0
- package/out/poi/index.js.map +1 -0
- package/out/{poi-lookup.d.ts → poi/lookup.d.ts} +8 -10
- package/out/poi/lookup.d.ts.map +1 -0
- package/out/{poi-lookup.js → poi/lookup.js} +24 -29
- package/out/poi/lookup.js.map +1 -0
- package/out/{poi-schema.d.ts → poi/schema.d.ts} +10 -6
- package/out/poi/schema.d.ts.map +1 -0
- package/out/{poi-schema.js → poi/schema.js} +1 -1
- package/out/poi/schema.js.map +1 -0
- package/out/polygon-schema.d.ts +37 -0
- package/out/polygon-schema.d.ts.map +1 -0
- package/out/polygon-schema.js +23 -0
- package/out/polygon-schema.js.map +1 -0
- package/out/{postal-city-alias-lookup.d.ts → postal/city-alias-lookup.d.ts} +7 -6
- package/out/postal/city-alias-lookup.d.ts.map +1 -0
- package/out/{postal-city-alias-lookup.js → postal/city-alias-lookup.js} +12 -16
- package/out/postal/city-alias-lookup.js.map +1 -0
- package/out/{postal-city-alias-schema.d.ts → postal/city-alias-schema.d.ts} +1 -1
- package/out/{postal-city-alias-schema.d.ts.map → postal/city-alias-schema.d.ts.map} +1 -1
- package/out/{postal-city-alias-schema.js → postal/city-alias-schema.js} +1 -1
- package/out/{postal-city-alias-schema.js.map → postal/city-alias-schema.js.map} +1 -1
- package/out/{postal-city-candidate-schema.d.ts → postal/city-candidate-schema.d.ts} +4 -3
- package/out/postal/city-candidate-schema.d.ts.map +1 -0
- package/out/{postal-city-candidate-schema.js → postal/city-candidate-schema.js} +2 -2
- package/out/{postal-city-candidate-schema.js.map → postal/city-candidate-schema.js.map} +1 -1
- package/out/postal/index.d.ts +9 -0
- package/out/postal/index.d.ts.map +1 -0
- package/out/postal/index.js +9 -0
- package/out/postal/index.js.map +1 -0
- package/out/postcode-point-lookup.d.ts +10 -10
- package/out/postcode-point-lookup.d.ts.map +1 -1
- package/out/postcode-point-lookup.js +13 -13
- package/out/postcode-point-lookup.js.map +1 -1
- package/out/primary-preference.d.ts +133 -0
- package/out/primary-preference.d.ts.map +1 -0
- package/out/primary-preference.js +146 -0
- package/out/primary-preference.js.map +1 -0
- package/out/proximity-rerank.d.ts +77 -0
- package/out/proximity-rerank.d.ts.map +1 -0
- package/out/proximity-rerank.js +86 -0
- package/out/proximity-rerank.js.map +1 -0
- package/out/ranking-weights.d.ts +15 -3
- package/out/ranking-weights.d.ts.map +1 -1
- package/out/ranking-weights.js +21 -3
- package/out/ranking-weights.js.map +1 -1
- package/out/region-keys.d.ts +47 -0
- package/out/region-keys.d.ts.map +1 -0
- package/out/region-keys.js +121 -0
- package/out/region-keys.js.map +1 -0
- package/out/reverse.d.ts +6 -6
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +23 -35
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +10 -1
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +59 -0
- package/out/search-fetch.d.ts.map +1 -0
- package/out/search-fetch.js +184 -0
- package/out/search-fetch.js.map +1 -0
- package/out/sqlite-convention-source.d.ts +7 -7
- package/out/sqlite-convention-source.d.ts.map +1 -1
- package/out/sqlite-convention-source.js +5 -5
- package/out/sqlite-convention-source.js.map +1 -1
- package/out/sqlite-utils.d.ts +24 -6
- package/out/sqlite-utils.d.ts.map +1 -1
- package/out/sqlite-utils.js +24 -7
- package/out/sqlite-utils.js.map +1 -1
- package/out/{street-centroid-schema.d.ts → street/centroid-schema.d.ts} +12 -7
- package/out/street/centroid-schema.d.ts.map +1 -0
- package/out/{street-centroid-schema.js → street/centroid-schema.js} +5 -5
- package/out/{street-centroid-schema.js.map → street/centroid-schema.js.map} +1 -1
- package/out/{street-centroid.d.ts → street/centroid.d.ts} +6 -6
- package/out/street/centroid.d.ts.map +1 -0
- package/out/{street-centroid.js → street/centroid.js} +18 -24
- package/out/street/centroid.js.map +1 -0
- package/out/street/index.d.ts +13 -0
- package/out/street/index.d.ts.map +1 -0
- package/out/street/index.js +13 -0
- package/out/street/index.js.map +1 -0
- package/out/{street-morphology-fst-builder.d.ts → street/morphology-fst-builder.d.ts} +4 -4
- package/out/street/morphology-fst-builder.d.ts.map +1 -0
- package/out/{street-morphology-fst-builder.js → street/morphology-fst-builder.js} +18 -13
- package/out/street/morphology-fst-builder.js.map +1 -0
- package/out/{street-morphology-fst-loader.d.ts → street/morphology-fst-loader.d.ts} +5 -5
- package/out/street/morphology-fst-loader.d.ts.map +1 -0
- package/out/{street-morphology-fst-loader.js → street/morphology-fst-loader.js} +11 -10
- package/out/street/morphology-fst-loader.js.map +1 -0
- package/out/{street-name-lookup.d.ts → street/name-lookup.d.ts} +4 -7
- package/out/street/name-lookup.d.ts.map +1 -0
- package/out/{street-name-lookup.js → street/name-lookup.js} +9 -23
- package/out/street/name-lookup.js.map +1 -0
- package/out/street/normalize.d.ts +179 -0
- package/out/street/normalize.d.ts.map +1 -0
- package/out/street/normalize.js +457 -0
- package/out/street/normalize.js.map +1 -0
- package/out/{street-segment-schema.d.ts → street/segment-schema.d.ts} +13 -9
- package/out/street/segment-schema.d.ts.map +1 -0
- package/out/{street-segment-schema.js → street/segment-schema.js} +4 -4
- package/out/{street-segment-schema.js.map → street/segment-schema.js.map} +1 -1
- package/out/types.d.ts +49 -9
- package/out/types.d.ts.map +1 -1
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +6 -5
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +16 -19
- package/out/unified-schema.js.map +1 -1
- package/out/uprn/existence.d.ts +53 -0
- package/out/uprn/existence.d.ts.map +1 -0
- package/out/uprn/existence.js +61 -0
- package/out/uprn/existence.js.map +1 -0
- package/out/uprn/index.d.ts +9 -0
- package/out/uprn/index.d.ts.map +1 -0
- package/out/uprn/index.js +9 -0
- package/out/uprn/index.js.map +1 -0
- package/out/uprn/lookup.d.ts +85 -0
- package/out/uprn/lookup.d.ts.map +1 -0
- package/out/uprn/lookup.js +149 -0
- package/out/uprn/lookup.js.map +1 -0
- package/out/uprn/schema.d.ts +93 -0
- package/out/uprn/schema.d.ts.map +1 -0
- package/out/uprn/schema.js +78 -0
- package/out/uprn/schema.js.map +1 -0
- package/out/weights-overlay-linker.d.ts +299 -0
- package/out/weights-overlay-linker.d.ts.map +1 -0
- package/out/weights-overlay-linker.js +511 -0
- package/out/weights-overlay-linker.js.map +1 -0
- package/package.json +622 -154
- package/address-point.ts +0 -125
- package/candidate-lookup.ts +0 -720
- package/fst-autocomplete.ts +0 -204
- package/geo.ts +0 -121
- package/lookup.ts +0 -1354
- package/out/address-point-interpolation.d.ts.map +0 -1
- package/out/address-point-interpolation.js.map +0 -1
- package/out/address-point-schema.d.ts.map +0 -1
- package/out/address-point-schema.js.map +0 -1
- package/out/address-point.d.ts.map +0 -1
- package/out/address-point.js +0 -84
- package/out/address-point.js.map +0 -1
- package/out/ancestry-backfill.d.ts.map +0 -1
- package/out/ancestry-backfill.js.map +0 -1
- package/out/ancestry.d.ts.map +0 -1
- package/out/ancestry.js.map +0 -1
- package/out/convention.d.ts.map +0 -1
- package/out/convention.js.map +0 -1
- package/out/fst-autocomplete.d.ts.map +0 -1
- package/out/fst-autocomplete.js +0 -130
- package/out/fst-autocomplete.js.map +0 -1
- package/out/fst-builder.d.ts.map +0 -1
- package/out/fst-builder.js.map +0 -1
- package/out/fst-deserialize-web.d.ts.map +0 -1
- package/out/fst-deserialize-web.js.map +0 -1
- package/out/fst-freshness.d.ts.map +0 -1
- package/out/fst-freshness.js.map +0 -1
- package/out/fst-matcher.d.ts.map +0 -1
- package/out/fst-matcher.js.map +0 -1
- package/out/fst-serialize.d.ts.map +0 -1
- package/out/fst-serialize.js.map +0 -1
- package/out/fst-types.d.ts.map +0 -1
- package/out/fst-types.js.map +0 -1
- package/out/fts-query.d.ts.map +0 -1
- package/out/fts-query.js.map +0 -1
- package/out/fts.d.ts.map +0 -1
- package/out/fts.js.map +0 -1
- package/out/geo.d.ts +0 -74
- package/out/geo.d.ts.map +0 -1
- package/out/geo.js +0 -71
- package/out/geo.js.map +0 -1
- package/out/geonames-aliases.d.ts.map +0 -1
- package/out/geonames-aliases.js.map +0 -1
- package/out/geonames-postal.d.ts.map +0 -1
- package/out/geonames-postal.js.map +0 -1
- package/out/poi-lookup.d.ts.map +0 -1
- package/out/poi-lookup.js.map +0 -1
- package/out/poi-schema.d.ts.map +0 -1
- package/out/poi-schema.js.map +0 -1
- package/out/postal-city-alias-lookup.d.ts.map +0 -1
- package/out/postal-city-alias-lookup.js.map +0 -1
- package/out/postal-city-candidate-schema.d.ts.map +0 -1
- package/out/sharding.d.ts +0 -114
- package/out/sharding.d.ts.map +0 -1
- package/out/sharding.js.map +0 -1
- package/out/street-centroid-schema.d.ts.map +0 -1
- package/out/street-centroid.d.ts.map +0 -1
- package/out/street-centroid.js.map +0 -1
- package/out/street-morphology-fst-builder.d.ts.map +0 -1
- package/out/street-morphology-fst-builder.js.map +0 -1
- package/out/street-morphology-fst-loader.d.ts.map +0 -1
- package/out/street-morphology-fst-loader.js.map +0 -1
- package/out/street-name-lookup.d.ts.map +0 -1
- package/out/street-name-lookup.js.map +0 -1
- package/out/street-normalize.d.ts +0 -95
- package/out/street-normalize.d.ts.map +0 -1
- package/out/street-normalize.js +0 -272
- package/out/street-normalize.js.map +0 -1
- package/out/street-segment-schema.d.ts.map +0 -1
- package/sqlite-utils.ts +0 -46
- package/street-normalize.ts +0 -318
- /package/{postal-city-alias-schema.ts → lib/postal/city-alias-schema.ts} +0 -0
package/out/reverse.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
6
|
* Reverse geocoding (#484): `(lat, lon)` → the containing admin hierarchy. Assembly over existing
|
|
7
|
-
*
|
|
7
|
+
* implementation, per the 2026-06-11 scoping notes:
|
|
8
8
|
*
|
|
9
9
|
* 1. **Candidate fetch** — the admin DB's `place_bbox` R*Tree (built by `fts.ts`) for places whose
|
|
10
10
|
* bbox contains the point, smallest-area-first (so the FIRST polygon confirmation is the
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
* Reverse quality is country-dependent (polygon coverage: see the #292 JP finding); `containment`
|
|
28
28
|
* says so per result rather than pretending.
|
|
29
29
|
*/
|
|
30
|
-
import {
|
|
31
|
-
import type {
|
|
30
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
31
|
+
import type { WOFDatabase } from "#schema";
|
|
32
|
+
import type { PlaceCandidate, WOFPlacetype } from "#types";
|
|
32
33
|
/**
|
|
33
34
|
* How the deepest returned place was confirmed:
|
|
34
35
|
*
|
|
@@ -59,7 +60,7 @@ export interface WOFReverseGeocoderOpts {
|
|
|
59
60
|
/**
|
|
60
61
|
* Pre-opened admin DB — primarily for tests against an inline fixture.
|
|
61
62
|
*/
|
|
62
|
-
adminDatabase?:
|
|
63
|
+
adminDatabase?: DatabaseClient<WOFDatabase>;
|
|
63
64
|
/**
|
|
64
65
|
* Path to the polygon sidecar DB (`wof-polygons.db`, table `polygons(id, geom)`). OPTIONAL — without it every result
|
|
65
66
|
* is `containment: "approximate"` (centroid-only mode). Mutually exclusive with `polygonDatabase`.
|
|
@@ -68,7 +69,7 @@ export interface WOFReverseGeocoderOpts {
|
|
|
68
69
|
/**
|
|
69
70
|
* Pre-opened polygon DB — primarily for tests.
|
|
70
71
|
*/
|
|
71
|
-
polygonDatabase?:
|
|
72
|
+
polygonDatabase?: DatabaseClient<WOFDatabase>;
|
|
72
73
|
}
|
|
73
74
|
export interface ReverseGeocodeOpts {
|
|
74
75
|
/**
|
|
@@ -103,7 +104,6 @@ export declare class WOFReverseGeocoder implements Disposable {
|
|
|
103
104
|
* whose `POIIntentOutcome` return type is synchronous by contract — see `poi-intent.ts`'s `deps.execute`).
|
|
104
105
|
*/
|
|
105
106
|
reverseGeocodeSync(lat: number, lon: number, opts?: ReverseGeocodeOpts): ReverseGeocodeResult;
|
|
106
|
-
close(): void;
|
|
107
107
|
[Symbol.dispose](): void;
|
|
108
108
|
}
|
|
109
109
|
//# sourceMappingURL=reverse.d.ts.map
|
package/out/reverse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../reverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;
|
|
1
|
+
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../lib/reverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAKzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAY1D;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,aAAa,CAAA;AAEvD,MAAM,WAAW,oBAAoB;IACpC;;;;OAIG;IACH,SAAS,EAAE,cAAc,EAAE,CAAA;IAC3B;;OAEG;IACH,WAAW,EAAE,eAAe,CAAA;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAA;IAC3C;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAA;CAC7C;AAED,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,YAAY,EAAE,CAAA;IAC3B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAkDD,qBAAa,kBAAmB,YAAW,UAAU;;gBAcxC,IAAI,EAAE,sBAAsB;IAuCxC;;;OAGG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI5G;;;;;OAKG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,oBAAoB;IA6NjG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CASxB"}
|
package/out/reverse.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
6
|
* Reverse geocoding (#484): `(lat, lon)` → the containing admin hierarchy. Assembly over existing
|
|
7
|
-
*
|
|
7
|
+
* implementation, per the 2026-06-11 scoping notes:
|
|
8
8
|
*
|
|
9
9
|
* 1. **Candidate fetch** — the admin DB's `place_bbox` R*Tree (built by `fts.ts`) for places whose
|
|
10
10
|
* bbox contains the point, smallest-area-first (so the FIRST polygon confirmation is the
|
|
@@ -27,11 +27,13 @@
|
|
|
27
27
|
* Reverse quality is country-dependent (polygon coverage: see the #292 JP finding); `containment`
|
|
28
28
|
* says so per result rather than pretending.
|
|
29
29
|
*/
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
30
|
+
import { tryParsingJSON } from "@mailwoman/core/json";
|
|
31
|
+
import { bboxAround, geometryContains, haversineKm } from "@mailwoman/spatial";
|
|
32
|
+
import { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
33
|
+
import { tableExists } from "@mailwoman/sqlite/introspection";
|
|
34
|
+
import { ancestorLineage, placetypeDepth } from "#ancestry/index";
|
|
35
|
+
import { PLACE_BBOX_TABLE } from "#fts/index";
|
|
36
|
+
import { allRows } from "#sqlite-utils";
|
|
35
37
|
/**
|
|
36
38
|
* Largest absolute latitude in WGS-84 degrees.
|
|
37
39
|
*/
|
|
@@ -93,28 +95,21 @@ export class WOFReverseGeocoder {
|
|
|
93
95
|
if (opts.polygonDatabase && opts.polygonDBPath) {
|
|
94
96
|
throw new Error("WOFReverseGeocoder: pass either `polygonDatabase` or `polygonDBPath`, not both");
|
|
95
97
|
}
|
|
96
|
-
this.#admin = opts.adminDatabase ?? new
|
|
98
|
+
this.#admin = opts.adminDatabase ?? new DatabaseClient(opts.adminDBPath, { readOnly: true });
|
|
97
99
|
this.#ownsAdmin = !opts.adminDatabase;
|
|
98
100
|
this.#polygons =
|
|
99
|
-
opts.polygonDatabase ??
|
|
101
|
+
opts.polygonDatabase ??
|
|
102
|
+
(opts.polygonDBPath ? new DatabaseClient(opts.polygonDBPath, { readOnly: true }) : null);
|
|
100
103
|
this.#ownsPolygons = !opts.polygonDatabase && Boolean(opts.polygonDBPath);
|
|
101
104
|
// Fail loudly up front — the R*Tree is a build artifact, not part of the upstream WOF
|
|
102
105
|
// distribution, and a missing index would otherwise surface as an opaque SQL error per query.
|
|
103
|
-
|
|
104
|
-
.prepare(`SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?`)
|
|
105
|
-
.get(PLACE_BBOX_TABLE);
|
|
106
|
-
if (!hasBbox) {
|
|
106
|
+
if (!tableExists(this.#admin, PLACE_BBOX_TABLE)) {
|
|
107
107
|
throw new Error(`WOFReverseGeocoder: the admin DB has no \`${PLACE_BBOX_TABLE}\` R*Tree. Build it with ` +
|
|
108
108
|
"`mailwoman gazetteer build fts <path-to-wof.db>` (see resolver-wof-sqlite/README.md).");
|
|
109
109
|
}
|
|
110
|
-
if (this.#polygons) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.get();
|
|
114
|
-
if (!hasPolygons) {
|
|
115
|
-
throw new Error("WOFReverseGeocoder: the polygon DB has no `polygons` table. Expected a `wof-polygons.db` " +
|
|
116
|
-
"built by scripts/build-wof-polygons.mjs.");
|
|
117
|
-
}
|
|
110
|
+
if (this.#polygons && !tableExists(this.#polygons, "polygons")) {
|
|
111
|
+
throw new Error("WOFReverseGeocoder: the polygon DB has no `polygons` table. Expected a `wof-polygons.db` " +
|
|
112
|
+
"built by scripts/build-wof-polygons.mjs.");
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
115
|
/**
|
|
@@ -254,14 +249,12 @@ export class WOFReverseGeocoder {
|
|
|
254
249
|
params.push(...opts.placetypes);
|
|
255
250
|
}
|
|
256
251
|
params.push(opts.maxCandidates ?? DEFAULT_MAX_CANDIDATES);
|
|
257
|
-
return this.#admin
|
|
258
|
-
.prepare(`SELECT spr.id AS id, spr.name AS name, spr.placetype AS placetype, spr.country AS country,
|
|
252
|
+
return allRows(this.#admin.prepare(`SELECT spr.id AS id, spr.name AS name, spr.placetype AS placetype, spr.country AS country,
|
|
259
253
|
spr.parent_id AS parent_id, spr.latitude AS lat, spr.longitude AS lon
|
|
260
254
|
FROM ${PLACE_BBOX_TABLE} bbox JOIN spr ON spr.id = bbox.id
|
|
261
255
|
WHERE ${where.join(" AND ")}
|
|
262
256
|
ORDER BY (bbox.max_lat - bbox.min_lat) * (bbox.max_lon - bbox.min_lon) ASC
|
|
263
|
-
LIMIT ?`)
|
|
264
|
-
.all(...params);
|
|
257
|
+
LIMIT ?`), ...params);
|
|
265
258
|
}
|
|
266
259
|
/**
|
|
267
260
|
* Descendants of `parentID` at one placetype tier, pre-filtered to a centroid window around the query point (a
|
|
@@ -269,14 +262,12 @@ export class WOFReverseGeocoder {
|
|
|
269
262
|
* consolidated city; the precise cap is applied per-candidate in the caller, and only to centroid-fallback steps).
|
|
270
263
|
*/
|
|
271
264
|
#descendants(parentID, placetype, lat, lon, maxApproximateKm) {
|
|
272
|
-
const
|
|
273
|
-
return this.#admin
|
|
274
|
-
.prepare(`SELECT s.id AS id, s.name AS name, s.placetype AS placetype, s.country AS country,
|
|
265
|
+
const window = bboxAround(lat, lon, maxApproximateKm * 4);
|
|
266
|
+
return allRows(this.#admin.prepare(`SELECT s.id AS id, s.name AS name, s.placetype AS placetype, s.country AS country,
|
|
275
267
|
s.parent_id AS parent_id, s.latitude AS lat, s.longitude AS lon
|
|
276
268
|
FROM ancestors a JOIN spr s ON s.id = a.id
|
|
277
269
|
WHERE a.ancestor_id = ? AND s.placetype = ? AND s.is_current != 0 AND s.is_deprecated = 0
|
|
278
|
-
AND s.latitude BETWEEN ? AND ? AND s.longitude BETWEEN ? AND ?`)
|
|
279
|
-
.all(parentID, placetype, lat - windowDeg, lat + windowDeg, lon - windowDeg, lon + windowDeg);
|
|
270
|
+
AND s.latitude BETWEEN ? AND ? AND s.longitude BETWEEN ? AND ?`), parentID, placetype, window.minLat, window.maxLat, window.minLon, window.maxLon);
|
|
280
271
|
}
|
|
281
272
|
/**
|
|
282
273
|
* Parsed GeoJSON geometry for a WOF id, or null when absent / unparseable / no polygon DB.
|
|
@@ -296,16 +287,13 @@ export class WOFReverseGeocoder {
|
|
|
296
287
|
this.#geometryCache.set(id, geometry);
|
|
297
288
|
return geometry;
|
|
298
289
|
}
|
|
299
|
-
|
|
290
|
+
[Symbol.dispose]() {
|
|
300
291
|
if (this.#ownsAdmin) {
|
|
301
|
-
this.#admin.
|
|
292
|
+
this.#admin.destroy();
|
|
302
293
|
}
|
|
303
294
|
if (this.#ownsPolygons) {
|
|
304
|
-
this.#polygons?.
|
|
295
|
+
this.#polygons?.destroy();
|
|
305
296
|
}
|
|
306
297
|
}
|
|
307
|
-
[Symbol.dispose]() {
|
|
308
|
-
this.close();
|
|
309
|
-
}
|
|
310
298
|
}
|
|
311
299
|
//# sourceMappingURL=reverse.js.map
|
package/out/reverse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../reverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../lib/reverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAuB,MAAM,oBAAoB,CAAA;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAE7D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC;;GAEG;AACH,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAE3B;;GAEG;AACH,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAiE7B,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAClC,MAAM,0BAA0B,GAAG,EAAE,CAAA;AAErC;;;GAGG;AACH,MAAM,aAAa,GAA4B;IAC9C,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,SAAS;IACT,eAAe;IACf,WAAW;CACX,CAAA;AAeD,SAAS,gBAAgB,CAAC,GAAiB,EAAE,UAAmB;IAC/D,MAAM,CAAC,GAAmB;QACzB,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,SAAS,EAAE,GAAG,CAAC,SAAyB;QACxC,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE;QAC1B,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,G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C,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,kBAAkB,CAAC,mBAAmB,EAAE,CAAC;YACxE,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;QAC5B,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAiC,CAAA;QACpH,oFAAoF;QACpF,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,cAAc,CAAiB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAEtE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;QAErC,OAAO,QAAQ,CAAA;IAChB,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACf,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QACtB,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAA;QAC1B,CAAC;IACF,CAAC"}
|
package/out/schema.d.ts
CHANGED
|
@@ -149,11 +149,20 @@ export interface CoincidentRolesTable {
|
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* The full schema we hand to `Kysely<WOFDatabase>` / `new DatabaseClient<WOFDatabase>(...)`. Tables not listed here
|
|
152
|
-
* will fail type-checked queries — by design. The reader ({@link
|
|
152
|
+
* will fail type-checked queries — by design. The reader ({@link WOFSQLitePlaceLookup}) already consumes this; the
|
|
153
153
|
* build/augment WRITERS adopt it so a column rename is a compile error on both sides (the drift that bit the corpus
|
|
154
154
|
* TIGER adapter).
|
|
155
155
|
*/
|
|
156
|
+
/**
|
|
157
|
+
* The provenance row every built extract carries: source fingerprints travelling WITH the database rather than in a
|
|
158
|
+
* document that can drift from it. Written by the postcode builders in `mailwoman/gazetteer-pipeline`.
|
|
159
|
+
*/
|
|
160
|
+
export interface ExtractMetaTable {
|
|
161
|
+
key: string;
|
|
162
|
+
value: string | null;
|
|
163
|
+
}
|
|
156
164
|
export interface WOFDatabase {
|
|
165
|
+
meta: ExtractMetaTable;
|
|
157
166
|
place_search: PlaceSearchTable;
|
|
158
167
|
spr: SprTable;
|
|
159
168
|
names: NamesTable;
|
package/out/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CA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,EAAE,cAAc,CAAA;IAC1B,YAAY,EAAE,iBAAiB,CAAA;IAC/B,gBAAgB,EAAE,oBAAoB,CAAA;CACtC"}
|
package/out/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../lib/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The FTS5 candidate fetch behind the fuzzy name match: the schema-qualified `place_search`
|
|
7
|
+
* MATCH, its population-ordered companion fetch, and the raw row shape both of them return.
|
|
8
|
+
*
|
|
9
|
+
* Bbox and near-with-radius narrow at the SQL level through SQLite's built-in `rtree`, whose index name and schema
|
|
10
|
+
* live in `fts.ts` beside the FTS5 build. That is why this package pulls neither SpatiaLite nor turf: the R*Tree does
|
|
11
|
+
* the narrowing, and the passes downstream of it operate on ≤ a few hundred candidates per query rather than the
|
|
12
|
+
* whole corpus, so an exact haversine over the survivors is cheap.
|
|
13
|
+
*/
|
|
14
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
15
|
+
import type { RankingWeights } from "#ranking-weights";
|
|
16
|
+
import type { FindPlaceQuery, WOFPlacetype } from "#types";
|
|
17
|
+
export interface RawSearchRow {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
placetype: string;
|
|
21
|
+
country: string | null;
|
|
22
|
+
parent_id: number | null;
|
|
23
|
+
rank: number;
|
|
24
|
+
lat: number | null;
|
|
25
|
+
lon: number | null;
|
|
26
|
+
min_latitude: number | null;
|
|
27
|
+
max_latitude: number | null;
|
|
28
|
+
min_longitude: number | null;
|
|
29
|
+
max_longitude: number | null;
|
|
30
|
+
population: number | null;
|
|
31
|
+
/**
|
|
32
|
+
* From `place_importance.encyclopedic` when the extract's table carries the two-score split columns. NULL means the
|
|
33
|
+
* place has no Wikipedia article, or the extract predates the split — absence either way, and never 0 (ROAD_TO_V9
|
|
34
|
+
* §2).
|
|
35
|
+
*/
|
|
36
|
+
encyclopedic: number | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fetch the raw candidate rows for a name match on one extract: the BM25-ordered window over `place_search` (widened
|
|
40
|
+
* for short queries), plus the population-ordered companion fetch that keeps the prominent holders of a name
|
|
41
|
+
* pool-complete. `schemaName` is the routed extract's bare schema name — validated at construction, so it is
|
|
42
|
+
* interpolated directly.
|
|
43
|
+
*/
|
|
44
|
+
export declare function fetchSearchRows<DB>(options: {
|
|
45
|
+
db: DatabaseClient<DB>;
|
|
46
|
+
schemaName: string;
|
|
47
|
+
query: FindPlaceQuery;
|
|
48
|
+
placetypes: WOFPlacetype[] | null;
|
|
49
|
+
ftsQuery: string;
|
|
50
|
+
limit: number;
|
|
51
|
+
hasBboxIndex: ReadonlyMap<string, boolean>;
|
|
52
|
+
hasPopulationIndex: ReadonlyMap<string, boolean>;
|
|
53
|
+
encyclopedicClauses: ReadonlyMap<string, {
|
|
54
|
+
select: string;
|
|
55
|
+
join: string;
|
|
56
|
+
}>;
|
|
57
|
+
weights: RankingWeights;
|
|
58
|
+
}): RawSearchRow[];
|
|
59
|
+
//# sourceMappingURL=search-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-fetch.d.ts","sourceRoot":"","sources":["../lib/search-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAA;AAG7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,KAAK,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KjB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The FTS5 candidate fetch behind the fuzzy name match: the schema-qualified `place_search`
|
|
7
|
+
* MATCH, its population-ordered companion fetch, and the raw row shape both of them return.
|
|
8
|
+
*
|
|
9
|
+
* Bbox and near-with-radius narrow at the SQL level through SQLite's built-in `rtree`, whose index name and schema
|
|
10
|
+
* live in `fts.ts` beside the FTS5 build. That is why this package pulls neither SpatiaLite nor turf: the R*Tree does
|
|
11
|
+
* the narrowing, and the passes downstream of it operate on ≤ a few hundred candidates per query rather than the
|
|
12
|
+
* whole corpus, so an exact haversine over the survivors is cheap.
|
|
13
|
+
*/
|
|
14
|
+
import { bboxAround } from "@mailwoman/spatial";
|
|
15
|
+
import { PLACE_BBOX_TABLE, PLACE_POPULATION_TABLE } from "#fts/index";
|
|
16
|
+
import { allRows } from "#sqlite-utils";
|
|
17
|
+
/**
|
|
18
|
+
* Query length at or below which the FTS window is widened. A two- or three-character query is almost always a region
|
|
19
|
+
* abbreviation, where the exact match can otherwise fall outside the window behind higher-bm25 partial hits — "NY"
|
|
20
|
+
* losing to "New York".
|
|
21
|
+
*/
|
|
22
|
+
const SHORT_QUERY_MAX_LENGTH = 3;
|
|
23
|
+
/**
|
|
24
|
+
* Over-fetch floor for SHORT (≤3-char) queries — region abbreviations like "NY"/"VT". An exact-abbrev holder's BM25 is
|
|
25
|
+
* poor (long multilingual alt-name document), so the normal `limit * 4` window can drop it before `exactMatchTiering`
|
|
26
|
+
* promotes it. 200 comfortably covers every same-abbrev region across the 12-country gazetteer (a 2-letter token
|
|
27
|
+
* matches a few dozen regions at most) while staying a cheap region-placetype fetch. See the `#fuzzyNameMatch`
|
|
28
|
+
* over-fetch comment.
|
|
29
|
+
*/
|
|
30
|
+
const SHORT_QUERY_OVERFETCH = 200;
|
|
31
|
+
/**
|
|
32
|
+
* How many rows the population-ordered companion fetch (#905) adds to the candidate pool. Small on purpose: its only
|
|
33
|
+
* job is to guarantee the FAMOUS holders of a name enter the pool at all — for "Paris"-class floods the bm25 window is
|
|
34
|
+
* saturated by thousands of tiny same-name rows and no boost inside the bm25-based ORDER BY can rescue a candidate
|
|
35
|
+
* whose bm25 is length-poisoned by ~15 points (see the fetch-site comment).
|
|
36
|
+
*/
|
|
37
|
+
const POPULATION_FETCH_LIMIT = 15;
|
|
38
|
+
/**
|
|
39
|
+
* Fetch the raw candidate rows for a name match on one extract: the BM25-ordered window over `place_search` (widened
|
|
40
|
+
* for short queries), plus the population-ordered companion fetch that keeps the prominent holders of a name
|
|
41
|
+
* pool-complete. `schemaName` is the routed extract's bare schema name — validated at construction, so it is
|
|
42
|
+
* interpolated directly.
|
|
43
|
+
*/
|
|
44
|
+
export function fetchSearchRows(options) {
|
|
45
|
+
const { db, schemaName: sch, query, placetypes, ftsQuery, limit, hasBboxIndex, hasPopulationIndex, encyclopedicClauses, weights, } = options;
|
|
46
|
+
// Over-fetch so post-scoring + exact-match tiering have room to re-rank. SHORT queries (a 2–3-char
|
|
47
|
+
// region abbreviation like "NY"/"VT") are the danger case the `exactMatchTiering` docstring flags:
|
|
48
|
+
// the exact-abbrev holder's BM25 is poor (its long multilingual alt-name document tanks the score),
|
|
49
|
+
// so under the normal `limit * 4` window it drops OUT of the candidate pool BEFORE tiering can
|
|
50
|
+
// promote it — "NY" then resolves to a token-matching foreign region (Highland, GB) instead of New
|
|
51
|
+
// York. Widen the window for short queries so the exact match is always present to be tiered.
|
|
52
|
+
// (Cross-country abbrev collisions — "VT" is BOTH Vermont and Viterbo — still need a country/
|
|
53
|
+
// postcode signal to disambiguate; this only rescues the window-drop class, not genuine ambiguity.
|
|
54
|
+
// With a `country` hint every abbrev resolves; bare + no-context lifts 7→10/15 US states.)
|
|
55
|
+
const ftsLimit = query.text.trim().length <= SHORT_QUERY_MAX_LENGTH ? Math.max(limit * 4, SHORT_QUERY_OVERFETCH) : limit * 4;
|
|
56
|
+
// Filter out historical / superseded / deprecated places by default — they live in the same
|
|
57
|
+
// spr table but should never win a contemporary lookup. `is_current = 0` is the only WOF
|
|
58
|
+
// value that means "not current"; both `-1` (modern) and `1` (legacy) mean current. See #91.
|
|
59
|
+
// Note: with schema-qualified FROM the bare `place_search` reference in MATCH resolves to
|
|
60
|
+
// the FROM table — required by FTS5 parser, see extracts.ts header comment.
|
|
61
|
+
const where = ["place_search MATCH ?", "spr.is_current != 0", "spr.is_deprecated = 0"];
|
|
62
|
+
const params = [ftsQuery];
|
|
63
|
+
if (placetypes && placetypes.length) {
|
|
64
|
+
where.push(`spr.placetype IN (${placetypes.map(() => "?").join(", ")})`);
|
|
65
|
+
params.push(...placetypes);
|
|
66
|
+
}
|
|
67
|
+
if (query.country) {
|
|
68
|
+
where.push("spr.country = ?");
|
|
69
|
+
params.push(query.country);
|
|
70
|
+
}
|
|
71
|
+
if (query.parentID !== undefined) {
|
|
72
|
+
where.push(`(spr.parent_id = ? OR spr.id IN (SELECT id FROM ${sch}.ancestors WHERE ancestor_id = ?))`);
|
|
73
|
+
params.push(query.parentID, query.parentID);
|
|
74
|
+
}
|
|
75
|
+
// Bbox + near-with-radius are SQL-level filters via the R*Tree. We only emit the JOIN when
|
|
76
|
+
// the active extract has the R*Tree; missing-but-requested is silently treated as no-bbox-
|
|
77
|
+
// filter so legacy DBs / extracts-without-bbox don't crash.
|
|
78
|
+
const extractHasBbox = hasBboxIndex.get(sch) === true;
|
|
79
|
+
const useBboxJoin = (query.bbox || query.near?.maxDistanceKm !== undefined) && extractHasBbox;
|
|
80
|
+
let joinClause = `JOIN ${sch}.spr ON spr.id = place_search.wof_id`;
|
|
81
|
+
if (useBboxJoin) {
|
|
82
|
+
joinClause += ` JOIN ${sch}.${PLACE_BBOX_TABLE} bbox ON bbox.id = spr.id`;
|
|
83
|
+
// AABB intersection — both bbox sides must overlap. R*Tree handles this in O(log n).
|
|
84
|
+
const filterBox = query.bbox || bboxAround(query.near.lat, query.near.lon, query.near.maxDistanceKm);
|
|
85
|
+
where.push("bbox.min_lat <= ? AND bbox.max_lat >= ?", "bbox.min_lon <= ? AND bbox.max_lon >= ?");
|
|
86
|
+
params.push(filterBox.maxLat, filterBox.minLat, filterBox.maxLon, filterBox.minLon);
|
|
87
|
+
}
|
|
88
|
+
// LEFT JOIN the population aux table when present. Missing-on-this-extract means the SELECT
|
|
89
|
+
// just doesn't include the population column; the post-scoring loop treats it as 0.
|
|
90
|
+
const extractHasPopulation = hasPopulationIndex.get(sch) === true;
|
|
91
|
+
const populationSelect = extractHasPopulation
|
|
92
|
+
? `${PLACE_POPULATION_TABLE}.population AS population`
|
|
93
|
+
: `NULL AS population`;
|
|
94
|
+
const populationJoin = extractHasPopulation
|
|
95
|
+
? `LEFT JOIN ${sch}.${PLACE_POPULATION_TABLE} ON ${PLACE_POPULATION_TABLE}.id = spr.id`
|
|
96
|
+
: "";
|
|
97
|
+
// The encyclopedic score is CARRIED, never ranked on (ROAD_TO_V9 §2, ratified 2026-08-06) — it
|
|
98
|
+
// appears in the SELECT and in no ORDER BY, here or in the companion fetch below. Conditioned on the
|
|
99
|
+
// split column, so a pre-split extract emits a literal NULL and builds no join at all.
|
|
100
|
+
const { select: encyclopedicSelect, join: encyclopedicJoin } = encyclopedicClauses.get(sch);
|
|
101
|
+
// Push the population boost into the ORDER BY when the index is available, so famous places
|
|
102
|
+
// (whose long alt-name lists hurt BM25) actually make it into the over-fetch window. The TS
|
|
103
|
+
// post-scoring will still compute the same boost for the final score; this just ensures the
|
|
104
|
+
// candidate set is right.
|
|
105
|
+
//
|
|
106
|
+
// Formula: rank_adjusted = bm25 - populationBoost * min(1.0, log10(1 + pop) / scaleLog10)
|
|
107
|
+
// Lower rank_adjusted = better (matches SQLite's bm25 convention of "more negative = better").
|
|
108
|
+
//
|
|
109
|
+
// #905 — do NOT reach for bm25 column weights here. Measured falsification (2026-07-02): FTS5's
|
|
110
|
+
// bm25 length normalization is polluted by the row's TOTAL document size, so identical 1-token
|
|
111
|
+
// `name` docs read −16.0 (empty alt_names) vs −0.43 (2.7 KB alt_names) EVEN with the alt_names
|
|
112
|
+
// column weighted to zero — no weighting isolates name relevance in this schema. The famous-
|
|
113
|
+
// holder guarantee lives in the population-ordered companion fetch below instead, and the
|
|
114
|
+
// exact tier breaks ties by population in the post-scoring sort.
|
|
115
|
+
const orderByExpr = extractHasPopulation
|
|
116
|
+
? `(bm25(place_search) - ? * MIN(1.0, COALESCE(log10(1.0 + ${PLACE_POPULATION_TABLE}.population), 0) / ?))`
|
|
117
|
+
: "bm25(place_search)";
|
|
118
|
+
// Schema-qualified FROM with bare-name MATCH — required syntax for FTS5 on attached schemas.
|
|
119
|
+
// See extracts.ts header for the failure mode that drove this design.
|
|
120
|
+
const stmt = db.prepare(`
|
|
121
|
+
SELECT
|
|
122
|
+
spr.id AS id,
|
|
123
|
+
spr.name,
|
|
124
|
+
spr.placetype,
|
|
125
|
+
spr.country,
|
|
126
|
+
spr.parent_id,
|
|
127
|
+
bm25(place_search) AS rank,
|
|
128
|
+
spr.latitude AS lat,
|
|
129
|
+
spr.longitude AS lon,
|
|
130
|
+
spr.min_latitude, spr.max_latitude, spr.min_longitude, spr.max_longitude,
|
|
131
|
+
${populationSelect},
|
|
132
|
+
${encyclopedicSelect}
|
|
133
|
+
FROM ${sch}.place_search
|
|
134
|
+
${joinClause}
|
|
135
|
+
${populationJoin}
|
|
136
|
+
${encyclopedicJoin}
|
|
137
|
+
WHERE ${where.join(" AND ")}
|
|
138
|
+
ORDER BY ${orderByExpr} ASC
|
|
139
|
+
LIMIT ?
|
|
140
|
+
`);
|
|
141
|
+
if (extractHasPopulation) {
|
|
142
|
+
params.push(weights.populationBoost, weights.populationScaleLog10);
|
|
143
|
+
}
|
|
144
|
+
params.push(ftsLimit);
|
|
145
|
+
const rawRows = allRows(stmt, ...params);
|
|
146
|
+
// #905 companion fetch: the same MATCH, ordered by population alone. For name floods
|
|
147
|
+
// ("Paris" matches thousands of gap-fill villages) the bm25-based window above cannot admit
|
|
148
|
+
// the famous holder — its bm25 is length-poisoned by the row's alias bulk (measured ~15 pts,
|
|
149
|
+
// vs a +4.0 boost cap), so FR Paris never even reaches post-scoring. This fetch makes the
|
|
150
|
+
// prominent holders of a name pool-complete BY CONSTRUCTION; the exact-tier sort below
|
|
151
|
+
// decides whether they win. Skipped without a population index (nothing to order by).
|
|
152
|
+
if (extractHasPopulation) {
|
|
153
|
+
const popStmt = db.prepare(`
|
|
154
|
+
SELECT
|
|
155
|
+
spr.id AS id,
|
|
156
|
+
spr.name,
|
|
157
|
+
spr.placetype,
|
|
158
|
+
spr.country,
|
|
159
|
+
spr.parent_id,
|
|
160
|
+
bm25(place_search) AS rank,
|
|
161
|
+
spr.latitude AS lat,
|
|
162
|
+
spr.longitude AS lon,
|
|
163
|
+
spr.min_latitude, spr.max_latitude, spr.min_longitude, spr.max_longitude,
|
|
164
|
+
${populationSelect},
|
|
165
|
+
${encyclopedicSelect}
|
|
166
|
+
FROM ${sch}.place_search
|
|
167
|
+
${joinClause}
|
|
168
|
+
${populationJoin}
|
|
169
|
+
${encyclopedicJoin}
|
|
170
|
+
WHERE ${where.join(" AND ")}
|
|
171
|
+
ORDER BY COALESCE(${PLACE_POPULATION_TABLE}.population, 0) DESC
|
|
172
|
+
LIMIT ?
|
|
173
|
+
`);
|
|
174
|
+
const popParams = params.slice(0, -3); // drop the two boost params + ftsLimit
|
|
175
|
+
const seen = new Set(rawRows.map((r) => r.id));
|
|
176
|
+
for (const row of allRows(popStmt, ...popParams, POPULATION_FETCH_LIMIT)) {
|
|
177
|
+
if (!seen.has(row.id)) {
|
|
178
|
+
rawRows.push(row);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return rawRows;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=search-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search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,IAAI,oBAAoB,EAAE,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACnE,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAErB,MAAM,OAAO,GAAG,OAAO,CAAe,IAAI,EAAE,GAAG,MAAM,CAAC,CAAA;IAEtD,qFAAqF;IACrF,4FAA4F;IAC5F,6FAA6F;IAC7F,0FAA0F;IAC1F,uFAAuF;IACvF,sFAAsF;IACtF,IAAI,oBAAoB,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;;;;;;;;;;;MAWvB,gBAAgB;MAChB,kBAAkB;UACd,GAAG;KACR,UAAU;KACV,cAAc;KACd,gBAAgB;WACV,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;uBACP,sBAAsB;;GAE1C,CAAC,CAAA;QAEF,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA,CAAC,uCAAuC;QAC7E,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAE9C,KAAK,MAAM,GAAG,IAAI,OAAO,CAAe,OAAO,EAAE,GAAG,SAAS,EAAE,sBAAsB,CAAC,EAAE,CAAC;YACxF,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAClB,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,OAAO,CAAA;AACf,CAAC"}
|
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
* table keyed by WOF polygon id; this source queries them ON DEMAND by id (one indexed lookup,
|
|
9
9
|
* memoized) rather than paging the whole table into memory as a code constant — the deliberate
|
|
10
10
|
* counter to the Pelias "giant dictionary in RAM, no provenance" pattern (see the operator design
|
|
11
|
-
* value in memory `feedback-no-
|
|
11
|
+
* value in memory `feedback-no-irrelevant-trivia`).
|
|
12
12
|
*
|
|
13
13
|
* The asset is the queryable, distributable artifact; the strategy IMPLEMENTATIONS stay in code. An
|
|
14
14
|
* unknown strategy NAME is surfaced loudly at dispatch (see `lookup.ts`), not silently
|
|
15
15
|
* swallowed.
|
|
16
16
|
*/
|
|
17
|
-
import type {
|
|
18
|
-
import { type Convention, type ConventionSource } from "
|
|
19
|
-
export declare class SqliteConventionSource implements ConventionSource {
|
|
17
|
+
import type { DatabaseClient } from "@mailwoman/sqlite/client";
|
|
18
|
+
import { type Convention, type ConventionSource } from "#convention/index";
|
|
19
|
+
export declare class SqliteConventionSource<DB> implements ConventionSource {
|
|
20
20
|
#private;
|
|
21
21
|
/**
|
|
22
22
|
* @param db An open handle to a DB that has the convention asset attached (or is it).
|
|
23
|
-
* @param schema The schema name the `address_convention` table lives under (`main` or an ATTACHed
|
|
24
|
-
* `
|
|
23
|
+
* @param schema The schema name the `address_convention` table lives under (`main` or an ATTACHed extract name —
|
|
24
|
+
* `WOFSQLitePlaceLookup` auto-detects which extract carries the table).
|
|
25
25
|
*/
|
|
26
|
-
constructor(db:
|
|
26
|
+
constructor(db: DatabaseClient<DB>, schema: string);
|
|
27
27
|
get(wofID: number): Convention | undefined;
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=sqlite-convention-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-convention-source.d.ts","sourceRoot":"","sources":["../sqlite-convention-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"sqlite-convention-source.d.ts","sourceRoot":"","sources":["../lib/sqlite-convention-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,EAA4B,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpG,qBAAa,sBAAsB,CAAC,EAAE,CAAE,YAAW,gBAAgB;;IAQlE;;;;OAIG;gBACS,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM;IAKlD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;CAwB1C"}
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
* table keyed by WOF polygon id; this source queries them ON DEMAND by id (one indexed lookup,
|
|
9
9
|
* memoized) rather than paging the whole table into memory as a code constant — the deliberate
|
|
10
10
|
* counter to the Pelias "giant dictionary in RAM, no provenance" pattern (see the operator design
|
|
11
|
-
* value in memory `feedback-no-
|
|
11
|
+
* value in memory `feedback-no-irrelevant-trivia`).
|
|
12
12
|
*
|
|
13
13
|
* The asset is the queryable, distributable artifact; the strategy IMPLEMENTATIONS stay in code. An
|
|
14
14
|
* unknown strategy NAME is surfaced loudly at dispatch (see `lookup.ts`), not silently
|
|
15
15
|
* swallowed.
|
|
16
16
|
*/
|
|
17
|
-
import { tryParsingJSON } from "@mailwoman/core/
|
|
18
|
-
import { ADDRESS_CONVENTION_TABLE } from "
|
|
17
|
+
import { tryParsingJSON } from "@mailwoman/core/json";
|
|
18
|
+
import { ADDRESS_CONVENTION_TABLE } from "#convention/index";
|
|
19
19
|
export class SqliteConventionSource {
|
|
20
20
|
#db;
|
|
21
21
|
#schema;
|
|
@@ -25,8 +25,8 @@ export class SqliteConventionSource {
|
|
|
25
25
|
#cache = new Map();
|
|
26
26
|
/**
|
|
27
27
|
* @param db An open handle to a DB that has the convention asset attached (or is it).
|
|
28
|
-
* @param schema The schema name the `address_convention` table lives under (`main` or an ATTACHed
|
|
29
|
-
* `
|
|
28
|
+
* @param schema The schema name the `address_convention` table lives under (`main` or an ATTACHed extract name —
|
|
29
|
+
* `WOFSQLitePlaceLookup` auto-detects which extract carries the table).
|
|
30
30
|
*/
|
|
31
31
|
constructor(db, schema) {
|
|
32
32
|
this.#db = db;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-convention-source.js","sourceRoot":"","sources":["../sqlite-convention-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"sqlite-convention-source.js","sourceRoot":"","sources":["../lib/sqlite-convention-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAAE,wBAAwB,EAA0C,MAAM,mBAAmB,CAAA;AAEpG,MAAM,OAAO,sBAAsB;IACzB,GAAG,CAAoB;IACvB,OAAO,CAAQ;IACxB;;OAEG;IACM,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAA;IAEtD;;;;OAIG;IACH,YAAY,EAAsB,EAAE,MAAc;QACjD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,GAAG,CAAC,KAAa;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAErC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,IAAI,SAAS,CAAA;QACpD,IAAI,KAAK,GAAsB,IAAI,CAAA;QAEnC,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG;iBAClB,OAAO,CAAC,0BAA0B,IAAI,CAAC,OAAO,IAAI,wBAAwB,mBAAmB,CAAC;iBAC9F,GAAG,CAAC,KAAK,CAAuC,CAAA;YAElD,IAAI,GAAG,EAAE,UAAU,EAAE,CAAC;gBACrB,KAAK,GAAG,cAAc,CAAa,GAAG,CAAC,UAAU,CAAC,CAAA;YACnD,CAAC;Q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