@mailwoman/corpus 9.3.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/lib/adapters/geonames/adapter.ts +3 -3
- package/lib/adapters/geonames/postal/adapter.ts +122 -0
- package/lib/adapters/index.ts +39 -32
- package/lib/adapters/openaddresses/adapter.ts +4 -7
- package/lib/adapters/osm/adapter.ts +278 -0
- package/lib/adapters/overture/adapter.ts +22 -7
- package/lib/adapters/utils/index.ts +1 -1
- package/lib/adapters/wof/admin/json/adapter.ts +239 -0
- package/lib/adapters/wof/json-rows.ts +181 -0
- package/lib/adapters/wof/postalcode-json/adapter.ts +196 -0
- package/lib/au/adapters/gnaf/adapter.ts +152 -0
- package/lib/au/adapters/gnaf/assemble.ts +225 -0
- package/lib/cz/recipes/pcfirst-preposition.ts +112 -0
- package/lib/de/recipes/locale.ts +360 -0
- package/lib/fr/adapters/ban/adapter.ts +159 -0
- package/lib/fr/recipes/admin-split.ts +243 -0
- package/lib/fr/recipes/bare-street.ts +171 -0
- package/lib/fr/recipes/fragment.ts +334 -0
- package/lib/fr/recipes/lieudit.ts +274 -0
- package/lib/fr/recipes/order.ts +246 -0
- package/lib/fr/tools/fetch/ban.ts +289 -0
- package/lib/index.ts +1 -1
- package/lib/international/recipes/locale.ts +598 -0
- package/lib/jp/tools/fetch/houjin.ts +141 -0
- package/lib/kr/adapters/juso/label-rows.ts +259 -0
- package/lib/kr/adapters/localdata/align.ts +299 -0
- package/lib/kr/adapters/localdata/key-index.ts +185 -0
- package/lib/kr/adapters/localdata/permit-rows.ts +186 -0
- package/lib/kr/tools/fetch/juso.ts +172 -0
- package/lib/kr/tools/fetch/localdata.ts +206 -0
- package/lib/nl/recipes/postcode.ts +117 -0
- package/lib/no/recipes/fragment.ts +213 -0
- package/lib/no/recipes/street/index.ts +91 -0
- package/lib/no/recipes/street/led.ts +135 -0
- package/lib/recipes/anchor-absorption.ts +2 -2
- package/lib/recipes/bare/country.ts +95 -0
- package/lib/recipes/bare/postcode/eval.ts +99 -0
- package/lib/recipes/bare/postcode/index.ts +327 -0
- package/lib/recipes/boundary-stress.ts +3 -1
- package/lib/recipes/country-balanced.ts +3 -2
- package/lib/recipes/house-venue.ts +2 -1
- package/lib/recipes/index.ts +28 -21
- package/lib/recipes/intersection.ts +3 -2
- package/lib/recipes/po/box/cedex/au-nz.ts +82 -0
- package/lib/recipes/po/box/cedex/ca.ts +58 -0
- package/lib/recipes/po/box/cedex/fr.ts +76 -0
- package/lib/recipes/po/box/cedex/phrases.ts +108 -0
- package/lib/recipes/po/box/cedex/recipe.ts +203 -0
- package/lib/recipes/po/box/cedex/sources.ts +189 -0
- package/lib/recipes/po/box/cedex/types.ts +35 -0
- package/lib/recipes/po/box/cedex/us.ts +69 -0
- package/lib/recipes/po/box/cedex/vocabulary.ts +106 -0
- package/lib/recipes/po/box/cedex.ts +9 -0
- package/lib/recipes/po/box/index.ts +128 -0
- package/lib/recipes/scaffold.ts +18 -42
- package/lib/recipes/street/affix.ts +807 -0
- package/lib/recipes/street/bare.ts +102 -0
- package/lib/recipes/street.ts +3 -1
- package/lib/recipes/sub/venue/context.ts +149 -0
- package/lib/recipes/sub/venue/index.ts +997 -0
- package/lib/recipes/sub/venue/sources.ts +739 -0
- package/lib/recipes/trailing-region.ts +9 -9
- package/lib/recipes/unit.ts +3 -3
- package/lib/sg/recipes/register.ts +270 -0
- package/lib/sg/tools/fetch/acra.ts +179 -0
- package/lib/si/recipes/bare-village.ts +99 -0
- package/lib/south-asia/recipes/register.ts +214 -0
- package/lib/synthesizers/anchor-absorption.ts +1 -1
- package/lib/synthesizers/locale.ts +261 -0
- package/lib/synthesizers/street.ts +1 -1
- package/lib/synthesizers/utils.ts +2 -2
- package/lib/tools/audit.ts +3 -2
- package/lib/tools/corpus-stats.ts +3 -3
- package/lib/tools/fetch/download/index.ts +10 -0
- package/lib/tools/fetch/download/manifest.ts +102 -0
- package/lib/tools/fetch/download/network.ts +226 -0
- package/lib/tools/fetch/download/retry.ts +173 -0
- package/lib/tools/fetch/geonames/dump.ts +257 -0
- package/lib/tools/fetch/geonames/postal.ts +180 -0
- package/lib/tools/fetch/index.ts +47 -20
- package/lib/tools/fetch/openaddresses.ts +2 -2
- package/lib/tools/fetch/ourairports.ts +2 -2
- package/lib/tools/fetch/ppd.ts +1 -3
- package/lib/tools/fetch/wikidata-subvenue.ts +2 -2
- package/lib/tools/golden/promote.ts +340 -0
- package/lib/tools/golden/relabel-street/directory.ts +340 -0
- package/lib/tools/golden/relabel-street/index.ts +9 -0
- package/lib/tools/golden/relabel-street/row.ts +361 -0
- package/lib/tools/index.ts +10 -10
- package/lib/tools/ingest-csv.ts +5 -7
- package/lib/tools/lint/slice/vocab.ts +376 -0
- package/lib/tools/overlay-manifest.ts +92 -25
- package/lib/tools/overture-subvenue.ts +1 -1
- package/lib/tools/postcode-triples.ts +138 -14
- package/lib/tools/sub/venue/harvest.ts +234 -0
- package/lib/tools/sub/venue/head-nouns.ts +245 -0
- package/lib/tools/sub/venue/lexicon.ts +429 -0
- package/lib/tools/sub/venue/surfaces.ts +95 -0
- package/lib/tools/sub/venue/table.ts +281 -0
- package/lib/tools/sub/venue/wikidata.ts +85 -0
- package/lib/tw/tools/fetch/gcis.ts +180 -0
- package/lib/types.ts +1 -1
- package/lib/us/adapters/fcc-bdc/adapter.ts +173 -0
- package/lib/us/adapters/state/hi-schools/adapter.ts +160 -0
- package/lib/us/adapters/state/ia-contractors/adapter.ts +136 -0
- package/lib/us/adapters/state/ny-notaries/adapter.ts +133 -0
- package/lib/us/adapters/state/tx-notaries/adapter.ts +149 -0
- package/lib/us/adapters/tiger/adapter.ts +250 -0
- package/lib/us/adapters/usgov/hrsa-fqhc/adapter.ts +156 -0
- package/lib/us/adapters/usgov/imls-pls/adapter.ts +134 -0
- package/lib/us/adapters/usgov/irs-bmf/adapter.ts +145 -0
- package/lib/us/adapters/usgov/nad/adapter.ts +324 -0
- package/lib/us/adapters/usgov/nppes/adapter.ts +143 -0
- package/lib/us/adapters/usgov/samhsa-treatment-locator/adapter.ts +182 -0
- package/lib/us/tools/fetch/hrsa.ts +59 -0
- package/lib/us/tools/fetch/imls-pls.ts +149 -0
- package/lib/us/tools/fetch/nad.ts +341 -0
- package/lib/us/tools/fetch/nppes.ts +165 -0
- package/lib/us/tools/fetch/state/hi-schools.ts +161 -0
- package/lib/us/tools/fetch/state/sources.ts +146 -0
- package/lib/us/tools/fetch/tiger-full.ts +308 -0
- package/lib/utils/align.ts +1 -1
- package/lib/utils/golden.ts +12 -8
- package/lib/utils/wof-json.ts +7 -13
- package/out/adapters/geonames/adapter.d.ts +1 -1
- package/out/adapters/geonames/adapter.js +3 -3
- package/out/adapters/geonames/adapter.js.map +1 -1
- package/out/adapters/geonames/postal/adapter.d.ts.map +1 -0
- package/out/adapters/geonames/postal/adapter.js +107 -0
- package/out/adapters/geonames/postal/adapter.js.map +1 -0
- package/out/adapters/index.d.ts +16 -16
- package/out/adapters/index.d.ts.map +1 -1
- package/out/adapters/index.js +34 -32
- package/out/adapters/index.js.map +1 -1
- package/out/adapters/openaddresses/adapter.d.ts.map +1 -1
- package/out/adapters/openaddresses/adapter.js +4 -6
- package/out/adapters/openaddresses/adapter.js.map +1 -1
- package/out/adapters/osm/adapter.d.ts +95 -0
- package/out/adapters/osm/adapter.d.ts.map +1 -0
- package/out/adapters/osm/adapter.js +211 -0
- package/out/adapters/osm/adapter.js.map +1 -0
- package/out/adapters/overture/adapter.d.ts +10 -0
- package/out/adapters/overture/adapter.d.ts.map +1 -1
- package/out/adapters/overture/adapter.js +20 -7
- package/out/adapters/overture/adapter.js.map +1 -1
- package/out/adapters/synth-po-box/adapter.js.map +1 -1
- package/out/adapters/utils/index.d.ts +1 -1
- package/out/adapters/utils/index.d.ts.map +1 -1
- package/out/adapters/utils/index.js.map +1 -1
- package/out/adapters/wof/admin/json/adapter.d.ts +79 -0
- package/out/adapters/wof/admin/json/adapter.d.ts.map +1 -0
- package/out/adapters/wof/admin/json/adapter.js +204 -0
- package/out/adapters/wof/admin/json/adapter.js.map +1 -0
- package/out/adapters/wof/json-rows.d.ts +73 -0
- package/out/adapters/wof/json-rows.d.ts.map +1 -0
- package/out/adapters/wof/json-rows.js +115 -0
- package/out/adapters/wof/json-rows.js.map +1 -0
- package/out/adapters/wof/postalcode-json/adapter.d.ts +65 -0
- package/out/adapters/wof/postalcode-json/adapter.d.ts.map +1 -0
- package/out/adapters/wof/postalcode-json/adapter.js +167 -0
- package/out/adapters/wof/postalcode-json/adapter.js.map +1 -0
- package/out/au/adapters/gnaf/adapter.d.ts.map +1 -0
- package/out/au/adapters/gnaf/adapter.js +127 -0
- package/out/au/adapters/gnaf/adapter.js.map +1 -0
- package/out/au/adapters/gnaf/assemble.d.ts +65 -0
- package/out/au/adapters/gnaf/assemble.d.ts.map +1 -0
- package/out/au/adapters/gnaf/assemble.js +154 -0
- package/out/au/adapters/gnaf/assemble.js.map +1 -0
- package/out/cn/recipes/organizational-units.d.ts +36 -0
- package/out/cn/recipes/organizational-units.d.ts.map +1 -0
- package/out/cn/recipes/organizational-units.js +159 -0
- package/out/cn/recipes/organizational-units.js.map +1 -0
- package/out/cz/recipes/pcfirst-preposition.d.ts +22 -0
- package/out/cz/recipes/pcfirst-preposition.d.ts.map +1 -0
- package/out/cz/recipes/pcfirst-preposition.js +101 -0
- package/out/cz/recipes/pcfirst-preposition.js.map +1 -0
- package/out/de/recipes/locale.d.ts +44 -0
- package/out/de/recipes/locale.d.ts.map +1 -0
- package/out/de/recipes/locale.js +289 -0
- package/out/de/recipes/locale.js.map +1 -0
- package/out/env.d.ts +1 -1
- package/out/fr/adapters/ban/adapter.d.ts.map +1 -0
- package/out/fr/adapters/ban/adapter.js +123 -0
- package/out/fr/adapters/ban/adapter.js.map +1 -0
- package/out/fr/adapters/ban/street-decompose.d.ts.map +1 -0
- package/out/fr/adapters/ban/street-decompose.js.map +1 -0
- package/out/fr/recipes/admin-split.d.ts +38 -0
- package/out/fr/recipes/admin-split.d.ts.map +1 -0
- package/out/fr/recipes/admin-split.js +192 -0
- package/out/fr/recipes/admin-split.js.map +1 -0
- package/out/fr/recipes/bare-street.d.ts +28 -0
- package/out/fr/recipes/bare-street.d.ts.map +1 -0
- package/out/fr/recipes/bare-street.js +144 -0
- package/out/fr/recipes/bare-street.js.map +1 -0
- package/out/fr/recipes/fragment.d.ts +77 -0
- package/out/fr/recipes/fragment.d.ts.map +1 -0
- package/out/fr/recipes/fragment.js +277 -0
- package/out/fr/recipes/fragment.js.map +1 -0
- package/out/fr/recipes/lieudit.d.ts +32 -0
- package/out/fr/recipes/lieudit.d.ts.map +1 -0
- package/out/fr/recipes/lieudit.js +211 -0
- package/out/fr/recipes/lieudit.js.map +1 -0
- package/out/fr/recipes/order.d.ts +38 -0
- package/out/fr/recipes/order.d.ts.map +1 -0
- package/out/fr/recipes/order.js +198 -0
- package/out/fr/recipes/order.js.map +1 -0
- package/out/fr/tools/fetch/ban.d.ts +31 -0
- package/out/fr/tools/fetch/ban.d.ts.map +1 -0
- package/out/fr/tools/fetch/ban.js +239 -0
- package/out/fr/tools/fetch/ban.js.map +1 -0
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -1
- package/out/index.js.map +1 -1
- package/out/international/recipes/locale.d.ts +136 -0
- package/out/international/recipes/locale.d.ts.map +1 -0
- package/out/international/recipes/locale.js +458 -0
- package/out/international/recipes/locale.js.map +1 -0
- package/out/jp/adapters/wof-admin/adapter.d.ts.map +1 -0
- package/out/jp/adapters/wof-admin/adapter.js.map +1 -0
- package/out/jp/tools/fetch/houjin.d.ts +24 -0
- package/out/jp/tools/fetch/houjin.d.ts.map +1 -0
- package/out/jp/tools/fetch/houjin.js +102 -0
- package/out/jp/tools/fetch/houjin.js.map +1 -0
- package/out/kr/adapters/juso/label-rows.d.ts +76 -0
- package/out/kr/adapters/juso/label-rows.d.ts.map +1 -0
- package/out/kr/adapters/juso/label-rows.js +194 -0
- package/out/kr/adapters/juso/label-rows.js.map +1 -0
- package/out/kr/adapters/localdata/align.d.ts +43 -0
- package/out/kr/adapters/localdata/align.d.ts.map +1 -0
- package/out/kr/adapters/localdata/align.js +223 -0
- package/out/kr/adapters/localdata/align.js.map +1 -0
- package/out/kr/adapters/localdata/key-index.d.ts +71 -0
- package/out/kr/adapters/localdata/key-index.d.ts.map +1 -0
- package/out/kr/adapters/localdata/key-index.js +133 -0
- package/out/kr/adapters/localdata/key-index.js.map +1 -0
- package/out/kr/adapters/localdata/permit-rows.d.ts +66 -0
- package/out/kr/adapters/localdata/permit-rows.d.ts.map +1 -0
- package/out/kr/adapters/localdata/permit-rows.js +131 -0
- package/out/kr/adapters/localdata/permit-rows.js.map +1 -0
- package/out/kr/tools/fetch/juso.d.ts +30 -0
- package/out/kr/tools/fetch/juso.d.ts.map +1 -0
- package/out/kr/tools/fetch/juso.js +120 -0
- package/out/kr/tools/fetch/juso.js.map +1 -0
- package/out/kr/tools/fetch/localdata.d.ts +30 -0
- package/out/kr/tools/fetch/localdata.d.ts.map +1 -0
- package/out/kr/tools/fetch/localdata.js +139 -0
- package/out/kr/tools/fetch/localdata.js.map +1 -0
- package/out/nl/recipes/postcode.d.ts +26 -0
- package/out/nl/recipes/postcode.d.ts.map +1 -0
- package/out/nl/recipes/postcode.js +103 -0
- package/out/nl/recipes/postcode.js.map +1 -0
- package/out/no/recipes/fragment.d.ts +43 -0
- package/out/no/recipes/fragment.d.ts.map +1 -0
- package/out/no/recipes/fragment.js +183 -0
- package/out/no/recipes/fragment.js.map +1 -0
- package/out/no/recipes/street/index.d.ts +18 -0
- package/out/no/recipes/street/index.d.ts.map +1 -0
- package/out/no/recipes/street/index.js +72 -0
- package/out/no/recipes/street/index.js.map +1 -0
- package/out/no/recipes/street/led.d.ts +24 -0
- package/out/no/recipes/street/led.d.ts.map +1 -0
- package/out/no/recipes/street/led.js +114 -0
- package/out/no/recipes/street/led.js.map +1 -0
- package/out/recipes/anchor-absorption.d.ts.map +1 -1
- package/out/recipes/anchor-absorption.js +2 -1
- package/out/recipes/anchor-absorption.js.map +1 -1
- package/out/recipes/bare/country.d.ts +25 -0
- package/out/recipes/bare/country.d.ts.map +1 -0
- package/out/recipes/bare/country.js +88 -0
- package/out/recipes/bare/country.js.map +1 -0
- package/out/recipes/bare/postcode/eval.d.ts +29 -0
- package/out/recipes/bare/postcode/eval.d.ts.map +1 -0
- package/out/recipes/bare/postcode/eval.js +85 -0
- package/out/recipes/bare/postcode/eval.js.map +1 -0
- package/out/recipes/bare/postcode/index.d.ts +62 -0
- package/out/recipes/bare/postcode/index.d.ts.map +1 -0
- package/out/recipes/bare/postcode/index.js +267 -0
- package/out/recipes/bare/postcode/index.js.map +1 -0
- package/out/recipes/boundary-stress.d.ts.map +1 -1
- package/out/recipes/boundary-stress.js +2 -1
- package/out/recipes/boundary-stress.js.map +1 -1
- package/out/recipes/country-balanced.d.ts.map +1 -1
- package/out/recipes/country-balanced.js +2 -1
- package/out/recipes/country-balanced.js.map +1 -1
- package/out/recipes/house-venue.d.ts.map +1 -1
- package/out/recipes/house-venue.js +2 -1
- package/out/recipes/house-venue.js.map +1 -1
- package/out/recipes/index.d.ts.map +1 -1
- package/out/recipes/index.js +28 -21
- package/out/recipes/index.js.map +1 -1
- package/out/recipes/intersection.d.ts.map +1 -1
- package/out/recipes/intersection.js +2 -1
- package/out/recipes/intersection.js.map +1 -1
- package/out/recipes/po/box/cedex/au-nz.d.ts +7 -0
- package/out/recipes/po/box/cedex/au-nz.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/au-nz.js +56 -0
- package/out/recipes/po/box/cedex/au-nz.js.map +1 -0
- package/out/recipes/po/box/cedex/ca.d.ts +7 -0
- package/out/recipes/po/box/cedex/ca.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/ca.js +38 -0
- package/out/recipes/po/box/cedex/ca.js.map +1 -0
- package/out/recipes/po/box/cedex/fr.d.ts +7 -0
- package/out/recipes/po/box/cedex/fr.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/fr.js +57 -0
- package/out/recipes/po/box/cedex/fr.js.map +1 -0
- package/out/recipes/po/box/cedex/phrases.d.ts +8 -0
- package/out/recipes/po/box/cedex/phrases.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/phrases.js +76 -0
- package/out/recipes/po/box/cedex/phrases.js.map +1 -0
- package/out/recipes/po/box/cedex/recipe.d.ts +9 -0
- package/out/recipes/po/box/cedex/recipe.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/recipe.js +153 -0
- package/out/recipes/po/box/cedex/recipe.js.map +1 -0
- package/out/recipes/po/box/cedex/sources.d.ts +86 -0
- package/out/recipes/po/box/cedex/sources.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/sources.js +143 -0
- package/out/recipes/po/box/cedex/sources.js.map +1 -0
- package/out/recipes/po/box/cedex/types.d.ts +31 -0
- package/out/recipes/po/box/cedex/types.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/types.js +5 -0
- package/out/recipes/po/box/cedex/types.js.map +1 -0
- package/out/recipes/po/box/cedex/us.d.ts +7 -0
- package/out/recipes/po/box/cedex/us.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/us.js +51 -0
- package/out/recipes/po/box/cedex/us.js.map +1 -0
- package/out/recipes/po/box/cedex/vocabulary.d.ts +68 -0
- package/out/recipes/po/box/cedex/vocabulary.d.ts.map +1 -0
- package/out/recipes/po/box/cedex/vocabulary.js +90 -0
- package/out/recipes/po/box/cedex/vocabulary.js.map +1 -0
- package/out/recipes/po/box/cedex.d.ts +9 -0
- package/out/recipes/po/box/cedex.d.ts.map +1 -0
- package/out/recipes/po/box/cedex.js +9 -0
- package/out/recipes/po/box/cedex.js.map +1 -0
- package/out/recipes/po/box/index.d.ts +17 -0
- package/out/recipes/po/box/index.d.ts.map +1 -0
- package/out/recipes/po/box/index.js +105 -0
- package/out/recipes/po/box/index.js.map +1 -0
- package/out/recipes/scaffold.d.ts +20 -1
- package/out/recipes/scaffold.d.ts.map +1 -1
- package/out/recipes/scaffold.js +18 -49
- package/out/recipes/scaffold.js.map +1 -1
- package/out/recipes/street/affix.d.ts +89 -0
- package/out/recipes/street/affix.d.ts.map +1 -0
- package/out/recipes/street/affix.js +565 -0
- package/out/recipes/street/affix.js.map +1 -0
- package/out/recipes/street/bare.d.ts +25 -0
- package/out/recipes/street/bare.d.ts.map +1 -0
- package/out/recipes/street/bare.js +87 -0
- package/out/recipes/street/bare.js.map +1 -0
- package/out/recipes/street.d.ts.map +1 -1
- package/out/recipes/street.js +2 -1
- package/out/recipes/street.js.map +1 -1
- package/out/recipes/sub/venue/context.d.ts +29 -0
- package/out/recipes/sub/venue/context.d.ts.map +1 -0
- package/out/recipes/sub/venue/context.js +106 -0
- package/out/recipes/sub/venue/context.js.map +1 -0
- package/out/recipes/sub/venue/index.d.ts +270 -0
- package/out/recipes/sub/venue/index.d.ts.map +1 -0
- package/out/recipes/sub/venue/index.js +728 -0
- package/out/recipes/sub/venue/index.js.map +1 -0
- package/out/recipes/sub/venue/sources.d.ts +209 -0
- package/out/recipes/sub/venue/sources.d.ts.map +1 -0
- package/out/recipes/sub/venue/sources.js +555 -0
- package/out/recipes/sub/venue/sources.js.map +1 -0
- package/out/recipes/trailing-region.d.ts.map +1 -1
- package/out/recipes/trailing-region.js +8 -2
- package/out/recipes/trailing-region.js.map +1 -1
- package/out/recipes/unit.d.ts.map +1 -1
- package/out/recipes/unit.js +2 -1
- package/out/recipes/unit.js.map +1 -1
- package/out/sg/recipes/register.d.ts +69 -0
- package/out/sg/recipes/register.d.ts.map +1 -0
- package/out/sg/recipes/register.js +211 -0
- package/out/sg/recipes/register.js.map +1 -0
- package/out/sg/tools/fetch/acra.d.ts +23 -0
- package/out/sg/tools/fetch/acra.d.ts.map +1 -0
- package/out/sg/tools/fetch/acra.js +126 -0
- package/out/sg/tools/fetch/acra.js.map +1 -0
- package/out/si/recipes/bare-village.d.ts +32 -0
- package/out/si/recipes/bare-village.d.ts.map +1 -0
- package/out/si/recipes/bare-village.js +89 -0
- package/out/si/recipes/bare-village.js.map +1 -0
- package/out/south-asia/recipes/register.d.ts +51 -0
- package/out/south-asia/recipes/register.d.ts.map +1 -0
- package/out/south-asia/recipes/register.js +154 -0
- package/out/south-asia/recipes/register.js.map +1 -0
- package/out/synthesizers/anchor-absorption.d.ts +1 -1
- package/out/synthesizers/anchor-absorption.d.ts.map +1 -1
- package/out/synthesizers/anchor-absorption.js.map +1 -1
- package/out/synthesizers/boundary-stress.js.map +1 -1
- package/out/synthesizers/house-venue.js.map +1 -1
- package/out/synthesizers/intersection.js.map +1 -1
- package/out/synthesizers/locale.d.ts +116 -0
- package/out/synthesizers/locale.d.ts.map +1 -0
- package/out/synthesizers/locale.js +150 -0
- package/out/synthesizers/locale.js.map +1 -0
- package/out/synthesizers/no-street.d.ts.map +1 -1
- package/out/synthesizers/no-street.js.map +1 -1
- package/out/synthesizers/po-box.js.map +1 -1
- package/out/synthesizers/street.d.ts.map +1 -1
- package/out/synthesizers/street.js +1 -1
- package/out/synthesizers/street.js.map +1 -1
- package/out/synthesizers/utils.js +1 -1
- package/out/synthesizers/utils.js.map +1 -1
- package/out/test-kit/corpus-recipe.d.ts.map +1 -1
- package/out/test-kit/corpus-recipe.js.map +1 -1
- package/out/tools/audit.d.ts.map +1 -1
- package/out/tools/audit.js +3 -2
- package/out/tools/audit.js.map +1 -1
- package/out/tools/corpus-stats.js +3 -3
- package/out/tools/corpus-stats.js.map +1 -1
- package/out/tools/fetch/download/index.d.ts +10 -0
- package/out/tools/fetch/download/index.d.ts.map +1 -0
- package/out/tools/fetch/download/index.js +10 -0
- package/out/tools/fetch/download/index.js.map +1 -0
- package/out/tools/fetch/download/manifest.d.ts +47 -0
- package/out/tools/fetch/download/manifest.d.ts.map +1 -0
- package/out/tools/fetch/download/manifest.js +74 -0
- package/out/tools/fetch/download/manifest.js.map +1 -0
- package/out/tools/fetch/download/network.d.ts +105 -0
- package/out/tools/fetch/download/network.d.ts.map +1 -0
- package/out/tools/fetch/download/network.js +130 -0
- package/out/tools/fetch/download/network.js.map +1 -0
- package/out/tools/fetch/download/retry.d.ts +45 -0
- package/out/tools/fetch/download/retry.d.ts.map +1 -0
- package/out/tools/fetch/download/retry.js +136 -0
- package/out/tools/fetch/download/retry.js.map +1 -0
- package/out/tools/fetch/geonames/dump.d.ts +91 -0
- package/out/tools/fetch/geonames/dump.d.ts.map +1 -0
- package/out/tools/fetch/geonames/dump.js +171 -0
- package/out/tools/fetch/geonames/dump.js.map +1 -0
- package/out/tools/fetch/geonames/postal.d.ts +76 -0
- package/out/tools/fetch/geonames/postal.d.ts.map +1 -0
- package/out/tools/fetch/geonames/postal.js +126 -0
- package/out/tools/fetch/geonames/postal.js.map +1 -0
- package/out/tools/fetch/index.d.ts +47 -20
- package/out/tools/fetch/index.d.ts.map +1 -1
- package/out/tools/fetch/index.js +47 -20
- package/out/tools/fetch/index.js.map +1 -1
- package/out/tools/fetch/openaddresses.d.ts +1 -1
- package/out/tools/fetch/openaddresses.d.ts.map +1 -1
- package/out/tools/fetch/openaddresses.js +1 -1
- package/out/tools/fetch/openaddresses.js.map +1 -1
- package/out/tools/fetch/ourairports.d.ts +1 -1
- package/out/tools/fetch/ourairports.d.ts.map +1 -1
- package/out/tools/fetch/ourairports.js +1 -1
- package/out/tools/fetch/ourairports.js.map +1 -1
- package/out/tools/fetch/ppd.js +1 -3
- package/out/tools/fetch/ppd.js.map +1 -1
- package/out/tools/fetch/wikidata-subvenue.d.ts +1 -1
- package/out/tools/fetch/wikidata-subvenue.d.ts.map +1 -1
- package/out/tools/fetch/wikidata-subvenue.js +1 -1
- package/out/tools/fetch/wikidata-subvenue.js.map +1 -1
- package/out/tools/golden/expand.d.ts +90 -0
- package/out/tools/golden/expand.d.ts.map +1 -0
- package/out/tools/golden/expand.js +406 -0
- package/out/tools/golden/expand.js.map +1 -0
- package/out/tools/golden/promote.d.ts +72 -0
- package/out/tools/golden/promote.d.ts.map +1 -0
- package/out/tools/golden/promote.js +243 -0
- package/out/tools/golden/promote.js.map +1 -0
- package/out/tools/golden/relabel-street/directory.d.ts +83 -0
- package/out/tools/golden/relabel-street/directory.d.ts.map +1 -0
- package/out/tools/golden/relabel-street/directory.js +216 -0
- package/out/tools/golden/relabel-street/directory.js.map +1 -0
- package/out/tools/golden/relabel-street/index.d.ts +9 -0
- package/out/tools/golden/relabel-street/index.d.ts.map +1 -0
- package/out/tools/golden/relabel-street/index.js +9 -0
- package/out/tools/golden/relabel-street/index.js.map +1 -0
- package/out/tools/golden/relabel-street/row.d.ts +121 -0
- package/out/tools/golden/relabel-street/row.d.ts.map +1 -0
- package/out/tools/golden/relabel-street/row.js +232 -0
- package/out/tools/golden/relabel-street/row.js.map +1 -0
- package/out/tools/index.d.ts +10 -10
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +10 -10
- package/out/tools/index.js.map +1 -1
- package/out/tools/ingest-csv.d.ts.map +1 -1
- package/out/tools/ingest-csv.js +5 -7
- package/out/tools/ingest-csv.js.map +1 -1
- package/out/tools/lint/slice/index.d.ts +93 -0
- package/out/tools/lint/slice/index.d.ts.map +1 -0
- package/out/tools/lint/slice/index.js +322 -0
- package/out/tools/lint/slice/index.js.map +1 -0
- package/out/tools/lint/slice/vocab.d.ts +90 -0
- package/out/tools/lint/slice/vocab.d.ts.map +1 -0
- package/out/tools/lint/slice/vocab.js +254 -0
- package/out/tools/lint/slice/vocab.js.map +1 -0
- package/out/tools/overlay-manifest.d.ts +56 -6
- package/out/tools/overlay-manifest.d.ts.map +1 -1
- package/out/tools/overlay-manifest.js +56 -15
- package/out/tools/overlay-manifest.js.map +1 -1
- package/out/tools/overture-subvenue.d.ts +1 -1
- package/out/tools/postcode-triples.d.ts +36 -0
- package/out/tools/postcode-triples.d.ts.map +1 -1
- package/out/tools/postcode-triples.js +91 -12
- package/out/tools/postcode-triples.js.map +1 -1
- package/out/tools/slice/kryptonite.d.ts +32 -0
- package/out/tools/slice/kryptonite.d.ts.map +1 -0
- package/out/tools/slice/kryptonite.js +99 -0
- package/out/tools/slice/kryptonite.js.map +1 -0
- package/out/tools/slice/translit.d.ts +51 -0
- package/out/tools/slice/translit.d.ts.map +1 -0
- package/out/tools/slice/translit.js +166 -0
- package/out/tools/slice/translit.js.map +1 -0
- package/out/tools/sub/venue/harvest.d.ts +100 -0
- package/out/tools/sub/venue/harvest.d.ts.map +1 -0
- package/out/tools/sub/venue/harvest.js +168 -0
- package/out/tools/sub/venue/harvest.js.map +1 -0
- package/out/tools/sub/venue/head-nouns.d.ts +50 -0
- package/out/tools/sub/venue/head-nouns.d.ts.map +1 -0
- package/out/tools/sub/venue/head-nouns.js.map +1 -0
- package/out/tools/sub/venue/lexicon.d.ts +156 -0
- package/out/tools/sub/venue/lexicon.d.ts.map +1 -0
- package/out/tools/sub/venue/lexicon.js +283 -0
- package/out/tools/sub/venue/lexicon.js.map +1 -0
- package/out/tools/sub/venue/promotions.d.ts +94 -0
- package/out/tools/sub/venue/promotions.d.ts.map +1 -0
- package/out/tools/sub/venue/promotions.js +266 -0
- package/out/tools/sub/venue/promotions.js.map +1 -0
- package/out/tools/sub/venue/surfaces.d.ts +45 -0
- package/out/tools/sub/venue/surfaces.d.ts.map +1 -0
- package/out/tools/sub/venue/surfaces.js.map +1 -0
- package/out/tools/sub/venue/table.d.ts +229 -0
- package/out/tools/sub/venue/table.d.ts.map +1 -0
- package/out/tools/sub/venue/table.js.map +1 -0
- package/out/tools/sub/venue/wikidata.d.ts +26 -0
- package/out/tools/sub/venue/wikidata.d.ts.map +1 -0
- package/out/tools/sub/venue/wikidata.js +62 -0
- package/out/tools/sub/venue/wikidata.js.map +1 -0
- package/out/tw/tools/fetch/gcis.d.ts +23 -0
- package/out/tw/tools/fetch/gcis.d.ts.map +1 -0
- package/out/tw/tools/fetch/gcis.js +135 -0
- package/out/tw/tools/fetch/gcis.js.map +1 -0
- package/out/types.d.ts +1 -1
- package/out/types.d.ts.map +1 -1
- package/out/us/adapters/fcc-bdc/adapter.d.ts.map +1 -0
- package/out/us/adapters/fcc-bdc/adapter.js +142 -0
- package/out/us/adapters/fcc-bdc/adapter.js.map +1 -0
- package/out/us/adapters/state/hi-schools/adapter.d.ts.map +1 -0
- package/out/us/adapters/state/hi-schools/adapter.js +136 -0
- package/out/us/adapters/state/hi-schools/adapter.js.map +1 -0
- package/out/us/adapters/state/hi-schools/workbook.d.ts.map +1 -0
- package/out/us/adapters/state/hi-schools/workbook.js.map +1 -0
- package/out/us/adapters/state/ia-contractors/adapter.d.ts.map +1 -0
- package/out/us/adapters/state/ia-contractors/adapter.js +104 -0
- package/out/us/adapters/state/ia-contractors/adapter.js.map +1 -0
- package/out/us/adapters/state/ny-notaries/adapter.d.ts.map +1 -0
- package/out/us/adapters/state/ny-notaries/adapter.js +112 -0
- package/out/us/adapters/state/ny-notaries/adapter.js.map +1 -0
- package/out/us/adapters/state/tx-notaries/adapter.d.ts.map +1 -0
- package/out/us/adapters/state/tx-notaries/adapter.js +118 -0
- package/out/us/adapters/state/tx-notaries/adapter.js.map +1 -0
- package/out/us/adapters/tiger/adapter.d.ts +55 -0
- package/out/us/adapters/tiger/adapter.d.ts.map +1 -0
- package/out/us/adapters/tiger/adapter.js +197 -0
- package/out/us/adapters/tiger/adapter.js.map +1 -0
- package/out/us/adapters/tiger/street-decompose.d.ts.map +1 -0
- package/out/us/adapters/tiger/street-decompose.js.map +1 -0
- package/out/us/adapters/usgov/hrsa-fqhc/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/hrsa-fqhc/adapter.js +121 -0
- package/out/us/adapters/usgov/hrsa-fqhc/adapter.js.map +1 -0
- package/out/us/adapters/usgov/imls-pls/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/imls-pls/adapter.js +106 -0
- package/out/us/adapters/usgov/imls-pls/adapter.js.map +1 -0
- package/out/us/adapters/usgov/irs-bmf/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/irs-bmf/adapter.js +116 -0
- package/out/us/adapters/usgov/irs-bmf/adapter.js.map +1 -0
- package/out/us/adapters/usgov/nad/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/nad/adapter.js +239 -0
- package/out/us/adapters/usgov/nad/adapter.js.map +1 -0
- package/out/us/adapters/usgov/nppes/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/nppes/adapter.js +110 -0
- package/out/us/adapters/usgov/nppes/adapter.js.map +1 -0
- package/out/us/adapters/usgov/samhsa-treatment-locator/adapter.d.ts.map +1 -0
- package/out/us/adapters/usgov/samhsa-treatment-locator/adapter.js +143 -0
- package/out/us/adapters/usgov/samhsa-treatment-locator/adapter.js.map +1 -0
- package/out/us/fips-state.d.ts +41 -0
- package/out/us/fips-state.d.ts.map +1 -0
- package/out/us/fips-state.js +100 -0
- package/out/us/fips-state.js.map +1 -0
- package/out/us/tools/fetch/hrsa.d.ts +18 -0
- package/out/us/tools/fetch/hrsa.d.ts.map +1 -0
- package/out/us/tools/fetch/hrsa.js +46 -0
- package/out/us/tools/fetch/hrsa.js.map +1 -0
- package/out/us/tools/fetch/imls-pls.d.ts +25 -0
- package/out/us/tools/fetch/imls-pls.d.ts.map +1 -0
- package/out/us/tools/fetch/imls-pls.js +108 -0
- package/out/us/tools/fetch/imls-pls.js.map +1 -0
- package/out/us/tools/fetch/nad.d.ts +70 -0
- package/out/us/tools/fetch/nad.d.ts.map +1 -0
- package/out/us/tools/fetch/nad.js +234 -0
- package/out/us/tools/fetch/nad.js.map +1 -0
- package/out/us/tools/fetch/nppes.d.ts +26 -0
- package/out/us/tools/fetch/nppes.d.ts.map +1 -0
- package/out/us/tools/fetch/nppes.js +126 -0
- package/out/us/tools/fetch/nppes.js.map +1 -0
- package/out/us/tools/fetch/state/hi-schools.d.ts +26 -0
- package/out/us/tools/fetch/state/hi-schools.d.ts.map +1 -0
- package/out/us/tools/fetch/state/hi-schools.js +112 -0
- package/out/us/tools/fetch/state/hi-schools.js.map +1 -0
- package/out/us/tools/fetch/state/sources.d.ts +26 -0
- package/out/us/tools/fetch/state/sources.d.ts.map +1 -0
- package/out/us/tools/fetch/state/sources.js +111 -0
- package/out/us/tools/fetch/state/sources.js.map +1 -0
- package/out/us/tools/fetch/tiger-full.d.ts +22 -0
- package/out/us/tools/fetch/tiger-full.d.ts.map +1 -0
- package/out/us/tools/fetch/tiger-full.js +217 -0
- package/out/us/tools/fetch/tiger-full.js.map +1 -0
- package/out/utils/align.d.ts +1 -1
- package/out/utils/align.d.ts.map +1 -1
- package/out/utils/align.js.map +1 -1
- package/out/utils/golden.d.ts +7 -3
- package/out/utils/golden.d.ts.map +1 -1
- package/out/utils/golden.js +12 -8
- package/out/utils/golden.js.map +1 -1
- package/out/utils/parquet.d.ts.map +1 -1
- package/out/utils/split.js.map +1 -1
- package/out/utils/wof-json.d.ts.map +1 -1
- package/out/utils/wof-json.js +7 -12
- package/out/utils/wof-json.js.map +1 -1
- package/out/ve/recipes/reviewed-postcode-tail.d.ts.map +1 -0
- package/out/ve/recipes/reviewed-postcode-tail.js.map +1 -0
- package/package.json +196 -46
- package/lib/adapters/ban/adapter.ts +0 -190
- package/lib/adapters/fcc-bdc/adapter.ts +0 -174
- package/lib/adapters/geonames-postal/adapter.ts +0 -122
- package/lib/adapters/gnaf/adapter.ts +0 -149
- package/lib/adapters/gnaf/assemble.ts +0 -225
- package/lib/adapters/state-hi-schools/adapter.ts +0 -170
- package/lib/adapters/state-ia-contractors/adapter.ts +0 -144
- package/lib/adapters/state-ny-notaries/adapter.ts +0 -141
- package/lib/adapters/state-tx-notaries/adapter.ts +0 -157
- package/lib/adapters/tiger/adapter.ts +0 -252
- package/lib/adapters/usgov-hrsa-fqhc/adapter.ts +0 -167
- package/lib/adapters/usgov-imls-pls/adapter.ts +0 -143
- package/lib/adapters/usgov-irs-bmf/adapter.ts +0 -151
- package/lib/adapters/usgov-nad/adapter.ts +0 -334
- package/lib/adapters/usgov-nppes/adapter.ts +0 -151
- package/lib/adapters/usgov-samhsa-treatment-locator/adapter.ts +0 -193
- package/lib/adapters/wof-admin-json/adapter.ts +0 -231
- package/lib/adapters/wof-json-rows.ts +0 -129
- package/lib/adapters/wof-postalcode-json/adapter.ts +0 -176
- package/lib/name-prone-us-suffixes.ts +0 -12
- package/lib/recipes/bare-country.ts +0 -95
- package/lib/recipes/cz-pcfirst-preposition.ts +0 -111
- package/lib/recipes/fr-admin-split.ts +0 -242
- package/lib/recipes/fr-bare-street.ts +0 -170
- package/lib/recipes/fr-fragment.ts +0 -333
- package/lib/recipes/fr-lieudit.ts +0 -301
- package/lib/recipes/fr-order.ts +0 -245
- package/lib/recipes/german.ts +0 -359
- package/lib/recipes/locale.ts +0 -599
- package/lib/recipes/nl-postcode.ts +0 -115
- package/lib/recipes/no-fragment.ts +0 -219
- package/lib/recipes/no-street-led.ts +0 -141
- package/lib/recipes/no-street.ts +0 -90
- package/lib/recipes/po-box-cedex.ts +0 -976
- package/lib/recipes/po-box.ts +0 -123
- package/lib/recipes/si-bare-village.ts +0 -97
- package/lib/recipes/street-affix.ts +0 -804
- package/lib/recipes/street-bare.ts +0 -100
- package/lib/recipes/sub-venue-sources.ts +0 -877
- package/lib/recipes/sub-venue.ts +0 -997
- package/lib/synthesizers/german.ts +0 -260
- package/lib/tools/fetch/ban.ts +0 -289
- package/lib/tools/fetch/download.ts +0 -262
- package/lib/tools/fetch/geonames-dump.ts +0 -257
- package/lib/tools/fetch/geonames-postal.ts +0 -180
- package/lib/tools/fetch/hrsa.ts +0 -59
- package/lib/tools/fetch/imls-pls.ts +0 -149
- package/lib/tools/fetch/nad.ts +0 -341
- package/lib/tools/fetch/nppes.ts +0 -165
- package/lib/tools/fetch/state-hi-schools.ts +0 -161
- package/lib/tools/fetch/state-sources.ts +0 -146
- package/lib/tools/fetch/tiger-full.ts +0 -308
- package/lib/tools/golden-promote.ts +0 -337
- package/lib/tools/golden-relabel-street.ts +0 -683
- package/lib/tools/lint-slice-vocab.ts +0 -388
- package/lib/tools/sub-venue/harvest.ts +0 -234
- package/lib/tools/sub-venue/head-nouns.ts +0 -245
- package/lib/tools/sub-venue/surfaces.ts +0 -95
- package/lib/tools/sub-venue/table.ts +0 -281
- package/lib/tools/sub-venue/wikidata.ts +0 -85
- package/lib/tools/sub-venue-lexicon.ts +0 -429
- package/out/adapters/ban/adapter.d.ts.map +0 -1
- package/out/adapters/ban/adapter.js +0 -149
- package/out/adapters/ban/adapter.js.map +0 -1
- package/out/adapters/ban/street-decompose.d.ts.map +0 -1
- package/out/adapters/ban/street-decompose.js.map +0 -1
- package/out/adapters/fcc-bdc/adapter.d.ts.map +0 -1
- package/out/adapters/fcc-bdc/adapter.js +0 -144
- package/out/adapters/fcc-bdc/adapter.js.map +0 -1
- package/out/adapters/geonames-postal/adapter.d.ts.map +0 -1
- package/out/adapters/geonames-postal/adapter.js +0 -107
- package/out/adapters/geonames-postal/adapter.js.map +0 -1
- package/out/adapters/gnaf/adapter.d.ts.map +0 -1
- package/out/adapters/gnaf/adapter.js +0 -124
- package/out/adapters/gnaf/adapter.js.map +0 -1
- package/out/adapters/gnaf/assemble.d.ts +0 -65
- package/out/adapters/gnaf/assemble.d.ts.map +0 -1
- package/out/adapters/gnaf/assemble.js +0 -154
- package/out/adapters/gnaf/assemble.js.map +0 -1
- package/out/adapters/state-hi-schools/adapter.d.ts.map +0 -1
- package/out/adapters/state-hi-schools/adapter.js +0 -145
- package/out/adapters/state-hi-schools/adapter.js.map +0 -1
- package/out/adapters/state-hi-schools/workbook.d.ts.map +0 -1
- package/out/adapters/state-hi-schools/workbook.js.map +0 -1
- package/out/adapters/state-ia-contractors/adapter.d.ts.map +0 -1
- package/out/adapters/state-ia-contractors/adapter.js +0 -111
- package/out/adapters/state-ia-contractors/adapter.js.map +0 -1
- package/out/adapters/state-ny-notaries/adapter.d.ts.map +0 -1
- package/out/adapters/state-ny-notaries/adapter.js +0 -119
- package/out/adapters/state-ny-notaries/adapter.js.map +0 -1
- package/out/adapters/state-tx-notaries/adapter.d.ts.map +0 -1
- package/out/adapters/state-tx-notaries/adapter.js +0 -125
- package/out/adapters/state-tx-notaries/adapter.js.map +0 -1
- package/out/adapters/tiger/adapter.d.ts +0 -55
- package/out/adapters/tiger/adapter.d.ts.map +0 -1
- package/out/adapters/tiger/adapter.js +0 -201
- package/out/adapters/tiger/adapter.js.map +0 -1
- package/out/adapters/tiger/street-decompose.d.ts.map +0 -1
- package/out/adapters/tiger/street-decompose.js.map +0 -1
- package/out/adapters/usgov-hrsa-fqhc/adapter.d.ts.map +0 -1
- package/out/adapters/usgov-hrsa-fqhc/adapter.js +0 -132
- package/out/adapters/usgov-hrsa-fqhc/adapter.js.map +0 -1
- package/out/adapters/usgov-imls-pls/adapter.d.ts.map +0 -1
- package/out/adapters/usgov-imls-pls/adapter.js +0 -114
- package/out/adapters/usgov-imls-pls/adapter.js.map +0 -1
- package/out/adapters/usgov-irs-bmf/adapter.d.ts.map +0 -1
- package/out/adapters/usgov-irs-bmf/adapter.js +0 -120
- package/out/adapters/usgov-irs-bmf/adapter.js.map +0 -1
- package/out/adapters/usgov-nad/adapter.d.ts.map +0 -1
- package/out/adapters/usgov-nad/adapter.js +0 -249
- package/out/adapters/usgov-nad/adapter.js.map +0 -1
- package/out/adapters/usgov-nppes/adapter.d.ts.map +0 -1
- package/out/adapters/usgov-nppes/adapter.js +0 -118
- package/out/adapters/usgov-nppes/adapter.js.map +0 -1
- package/out/adapters/usgov-samhsa-treatment-locator/adapter.d.ts.map +0 -1
- package/out/adapters/usgov-samhsa-treatment-locator/adapter.js +0 -154
- package/out/adapters/usgov-samhsa-treatment-locator/adapter.js.map +0 -1
- package/out/adapters/wof-admin-jp/adapter.d.ts.map +0 -1
- package/out/adapters/wof-admin-jp/adapter.js.map +0 -1
- package/out/adapters/wof-admin-json/adapter.d.ts +0 -79
- package/out/adapters/wof-admin-json/adapter.d.ts.map +0 -1
- package/out/adapters/wof-admin-json/adapter.js +0 -197
- package/out/adapters/wof-admin-json/adapter.js.map +0 -1
- package/out/adapters/wof-json-rows.d.ts +0 -62
- package/out/adapters/wof-json-rows.d.ts.map +0 -1
- package/out/adapters/wof-json-rows.js +0 -83
- package/out/adapters/wof-json-rows.js.map +0 -1
- package/out/adapters/wof-postalcode-json/adapter.d.ts +0 -65
- package/out/adapters/wof-postalcode-json/adapter.d.ts.map +0 -1
- package/out/adapters/wof-postalcode-json/adapter.js +0 -151
- package/out/adapters/wof-postalcode-json/adapter.js.map +0 -1
- package/out/codex/us-fips-state.d.ts +0 -41
- package/out/codex/us-fips-state.d.ts.map +0 -1
- package/out/codex/us-fips-state.js +0 -100
- package/out/codex/us-fips-state.js.map +0 -1
- package/out/name-prone-us-suffixes.d.ts +0 -12
- package/out/name-prone-us-suffixes.d.ts.map +0 -1
- package/out/name-prone-us-suffixes.js +0 -12
- package/out/name-prone-us-suffixes.js.map +0 -1
- package/out/recipes/bare-country.d.ts +0 -25
- package/out/recipes/bare-country.d.ts.map +0 -1
- package/out/recipes/bare-country.js +0 -87
- package/out/recipes/bare-country.js.map +0 -1
- package/out/recipes/cn-organizational-units.d.ts +0 -36
- package/out/recipes/cn-organizational-units.d.ts.map +0 -1
- package/out/recipes/cn-organizational-units.js +0 -159
- package/out/recipes/cn-organizational-units.js.map +0 -1
- package/out/recipes/cz-pcfirst-preposition.d.ts +0 -22
- package/out/recipes/cz-pcfirst-preposition.d.ts.map +0 -1
- package/out/recipes/cz-pcfirst-preposition.js +0 -100
- package/out/recipes/cz-pcfirst-preposition.js.map +0 -1
- package/out/recipes/fr-admin-split.d.ts +0 -38
- package/out/recipes/fr-admin-split.d.ts.map +0 -1
- package/out/recipes/fr-admin-split.js +0 -192
- package/out/recipes/fr-admin-split.js.map +0 -1
- package/out/recipes/fr-bare-street.d.ts +0 -28
- package/out/recipes/fr-bare-street.d.ts.map +0 -1
- package/out/recipes/fr-bare-street.js +0 -143
- package/out/recipes/fr-bare-street.js.map +0 -1
- package/out/recipes/fr-fragment.d.ts +0 -77
- package/out/recipes/fr-fragment.d.ts.map +0 -1
- package/out/recipes/fr-fragment.js +0 -276
- package/out/recipes/fr-fragment.js.map +0 -1
- package/out/recipes/fr-lieudit.d.ts +0 -32
- package/out/recipes/fr-lieudit.d.ts.map +0 -1
- package/out/recipes/fr-lieudit.js +0 -227
- package/out/recipes/fr-lieudit.js.map +0 -1
- package/out/recipes/fr-order.d.ts +0 -38
- package/out/recipes/fr-order.d.ts.map +0 -1
- package/out/recipes/fr-order.js +0 -197
- package/out/recipes/fr-order.js.map +0 -1
- package/out/recipes/german.d.ts +0 -44
- package/out/recipes/german.d.ts.map +0 -1
- package/out/recipes/german.js +0 -288
- package/out/recipes/german.js.map +0 -1
- package/out/recipes/locale.d.ts +0 -136
- package/out/recipes/locale.d.ts.map +0 -1
- package/out/recipes/locale.js +0 -460
- package/out/recipes/locale.js.map +0 -1
- package/out/recipes/nl-postcode.d.ts +0 -26
- package/out/recipes/nl-postcode.d.ts.map +0 -1
- package/out/recipes/nl-postcode.js +0 -102
- package/out/recipes/nl-postcode.js.map +0 -1
- package/out/recipes/no-fragment.d.ts +0 -43
- package/out/recipes/no-fragment.d.ts.map +0 -1
- package/out/recipes/no-fragment.js +0 -182
- package/out/recipes/no-fragment.js.map +0 -1
- package/out/recipes/no-street-led.d.ts +0 -24
- package/out/recipes/no-street-led.d.ts.map +0 -1
- package/out/recipes/no-street-led.js +0 -113
- package/out/recipes/no-street-led.js.map +0 -1
- package/out/recipes/no-street.d.ts +0 -18
- package/out/recipes/no-street.d.ts.map +0 -1
- package/out/recipes/no-street.js +0 -71
- package/out/recipes/no-street.js.map +0 -1
- package/out/recipes/po-box-cedex.d.ts +0 -38
- package/out/recipes/po-box-cedex.d.ts.map +0 -1
- package/out/recipes/po-box-cedex.js +0 -767
- package/out/recipes/po-box-cedex.js.map +0 -1
- package/out/recipes/po-box.d.ts +0 -17
- package/out/recipes/po-box.d.ts.map +0 -1
- package/out/recipes/po-box.js +0 -100
- package/out/recipes/po-box.js.map +0 -1
- package/out/recipes/reviewed-postcode-tail.d.ts.map +0 -1
- package/out/recipes/reviewed-postcode-tail.js.map +0 -1
- package/out/recipes/si-bare-village.d.ts +0 -32
- package/out/recipes/si-bare-village.d.ts.map +0 -1
- package/out/recipes/si-bare-village.js +0 -88
- package/out/recipes/si-bare-village.js.map +0 -1
- package/out/recipes/street-affix.d.ts +0 -89
- package/out/recipes/street-affix.d.ts.map +0 -1
- package/out/recipes/street-affix.js +0 -563
- package/out/recipes/street-affix.js.map +0 -1
- package/out/recipes/street-bare.d.ts +0 -25
- package/out/recipes/street-bare.d.ts.map +0 -1
- package/out/recipes/street-bare.js +0 -86
- package/out/recipes/street-bare.js.map +0 -1
- package/out/recipes/sub-venue-sources.d.ts +0 -229
- package/out/recipes/sub-venue-sources.d.ts.map +0 -1
- package/out/recipes/sub-venue-sources.js +0 -653
- package/out/recipes/sub-venue-sources.js.map +0 -1
- package/out/recipes/sub-venue.d.ts +0 -269
- package/out/recipes/sub-venue.d.ts.map +0 -1
- package/out/recipes/sub-venue.js +0 -725
- package/out/recipes/sub-venue.js.map +0 -1
- package/out/synthesizers/german.d.ts +0 -115
- package/out/synthesizers/german.d.ts.map +0 -1
- package/out/synthesizers/german.js +0 -149
- package/out/synthesizers/german.js.map +0 -1
- package/out/tools/fetch/ban.d.ts +0 -31
- package/out/tools/fetch/ban.d.ts.map +0 -1
- package/out/tools/fetch/ban.js +0 -239
- package/out/tools/fetch/ban.js.map +0 -1
- package/out/tools/fetch/download.d.ts +0 -117
- package/out/tools/fetch/download.d.ts.map +0 -1
- package/out/tools/fetch/download.js +0 -160
- package/out/tools/fetch/download.js.map +0 -1
- package/out/tools/fetch/geonames-dump.d.ts +0 -91
- package/out/tools/fetch/geonames-dump.d.ts.map +0 -1
- package/out/tools/fetch/geonames-dump.js +0 -171
- package/out/tools/fetch/geonames-dump.js.map +0 -1
- package/out/tools/fetch/geonames-postal.d.ts +0 -76
- package/out/tools/fetch/geonames-postal.d.ts.map +0 -1
- package/out/tools/fetch/geonames-postal.js +0 -126
- package/out/tools/fetch/geonames-postal.js.map +0 -1
- package/out/tools/fetch/hrsa.d.ts +0 -18
- package/out/tools/fetch/hrsa.d.ts.map +0 -1
- package/out/tools/fetch/hrsa.js +0 -46
- package/out/tools/fetch/hrsa.js.map +0 -1
- package/out/tools/fetch/imls-pls.d.ts +0 -25
- package/out/tools/fetch/imls-pls.d.ts.map +0 -1
- package/out/tools/fetch/imls-pls.js +0 -108
- package/out/tools/fetch/imls-pls.js.map +0 -1
- package/out/tools/fetch/nad.d.ts +0 -70
- package/out/tools/fetch/nad.d.ts.map +0 -1
- package/out/tools/fetch/nad.js +0 -234
- package/out/tools/fetch/nad.js.map +0 -1
- package/out/tools/fetch/nppes.d.ts +0 -26
- package/out/tools/fetch/nppes.d.ts.map +0 -1
- package/out/tools/fetch/nppes.js +0 -126
- package/out/tools/fetch/nppes.js.map +0 -1
- package/out/tools/fetch/state-hi-schools.d.ts +0 -26
- package/out/tools/fetch/state-hi-schools.d.ts.map +0 -1
- package/out/tools/fetch/state-hi-schools.js +0 -112
- package/out/tools/fetch/state-hi-schools.js.map +0 -1
- package/out/tools/fetch/state-sources.d.ts +0 -26
- package/out/tools/fetch/state-sources.d.ts.map +0 -1
- package/out/tools/fetch/state-sources.js +0 -111
- package/out/tools/fetch/state-sources.js.map +0 -1
- package/out/tools/fetch/tiger-full.d.ts +0 -22
- package/out/tools/fetch/tiger-full.d.ts.map +0 -1
- package/out/tools/fetch/tiger-full.js +0 -217
- package/out/tools/fetch/tiger-full.js.map +0 -1
- package/out/tools/golden-expand.d.ts +0 -90
- package/out/tools/golden-expand.d.ts.map +0 -1
- package/out/tools/golden-expand.js +0 -406
- package/out/tools/golden-expand.js.map +0 -1
- package/out/tools/golden-promote.d.ts +0 -72
- package/out/tools/golden-promote.d.ts.map +0 -1
- package/out/tools/golden-promote.js +0 -240
- package/out/tools/golden-promote.js.map +0 -1
- package/out/tools/golden-relabel-street.d.ts +0 -196
- package/out/tools/golden-relabel-street.d.ts.map +0 -1
- package/out/tools/golden-relabel-street.js +0 -440
- package/out/tools/golden-relabel-street.js.map +0 -1
- package/out/tools/lint-slice-vocab.d.ts +0 -90
- package/out/tools/lint-slice-vocab.d.ts.map +0 -1
- package/out/tools/lint-slice-vocab.js +0 -267
- package/out/tools/lint-slice-vocab.js.map +0 -1
- package/out/tools/lint-slice.d.ts +0 -93
- package/out/tools/lint-slice.d.ts.map +0 -1
- package/out/tools/lint-slice.js +0 -322
- package/out/tools/lint-slice.js.map +0 -1
- package/out/tools/slice-kryptonite.d.ts +0 -32
- package/out/tools/slice-kryptonite.d.ts.map +0 -1
- package/out/tools/slice-kryptonite.js +0 -99
- package/out/tools/slice-kryptonite.js.map +0 -1
- package/out/tools/slice-translit.d.ts +0 -51
- package/out/tools/slice-translit.d.ts.map +0 -1
- package/out/tools/slice-translit.js +0 -166
- package/out/tools/slice-translit.js.map +0 -1
- package/out/tools/sub-venue/harvest.d.ts +0 -100
- package/out/tools/sub-venue/harvest.d.ts.map +0 -1
- package/out/tools/sub-venue/harvest.js +0 -168
- package/out/tools/sub-venue/harvest.js.map +0 -1
- package/out/tools/sub-venue/head-nouns.d.ts +0 -50
- package/out/tools/sub-venue/head-nouns.d.ts.map +0 -1
- package/out/tools/sub-venue/head-nouns.js.map +0 -1
- package/out/tools/sub-venue/surfaces.d.ts +0 -45
- package/out/tools/sub-venue/surfaces.d.ts.map +0 -1
- package/out/tools/sub-venue/surfaces.js.map +0 -1
- package/out/tools/sub-venue/table.d.ts +0 -229
- package/out/tools/sub-venue/table.d.ts.map +0 -1
- package/out/tools/sub-venue/table.js.map +0 -1
- package/out/tools/sub-venue/wikidata.d.ts +0 -26
- package/out/tools/sub-venue/wikidata.d.ts.map +0 -1
- package/out/tools/sub-venue/wikidata.js +0 -62
- package/out/tools/sub-venue/wikidata.js.map +0 -1
- package/out/tools/sub-venue-lexicon.d.ts +0 -156
- package/out/tools/sub-venue-lexicon.d.ts.map +0 -1
- package/out/tools/sub-venue-lexicon.js +0 -283
- package/out/tools/sub-venue-lexicon.js.map +0 -1
- package/out/tools/sub-venue-promotions.d.ts +0 -94
- package/out/tools/sub-venue-promotions.d.ts.map +0 -1
- package/out/tools/sub-venue-promotions.js +0 -266
- package/out/tools/sub-venue-promotions.js.map +0 -1
- /package/lib/{recipes/cn-organizational-units.ts → cn/recipes/organizational-units.ts} +0 -0
- /package/lib/{adapters → fr/adapters}/ban/street-decompose.ts +0 -0
- /package/lib/{adapters/wof-admin-jp → jp/adapters/wof-admin}/adapter.ts +0 -0
- /package/lib/tools/{golden-expand.ts → golden/expand.ts} +0 -0
- /package/lib/tools/{lint-slice.ts → lint/slice/index.ts} +0 -0
- /package/lib/tools/{slice-kryptonite.ts → slice/kryptonite.ts} +0 -0
- /package/lib/tools/{slice-translit.ts → slice/translit.ts} +0 -0
- /package/lib/tools/{sub-venue-promotions.ts → sub/venue/promotions.ts} +0 -0
- /package/lib/{adapters/state-hi-schools → us/adapters/state/hi-schools}/workbook.ts +0 -0
- /package/lib/{adapters → us/adapters}/tiger/street-decompose.ts +0 -0
- /package/lib/{codex/us-fips-state.ts → us/fips-state.ts} +0 -0
- /package/lib/{recipes → ve/recipes}/reviewed-postcode-tail.ts +0 -0
- /package/out/adapters/{geonames-postal → geonames/postal}/adapter.d.ts +0 -0
- /package/out/{adapters → au/adapters}/gnaf/adapter.d.ts +0 -0
- /package/out/{adapters → fr/adapters}/ban/adapter.d.ts +0 -0
- /package/out/{adapters → fr/adapters}/ban/street-decompose.d.ts +0 -0
- /package/out/{adapters → fr/adapters}/ban/street-decompose.js +0 -0
- /package/out/{adapters/wof-admin-jp → jp/adapters/wof-admin}/adapter.d.ts +0 -0
- /package/out/{adapters/wof-admin-jp → jp/adapters/wof-admin}/adapter.js +0 -0
- /package/out/tools/{sub-venue → sub/venue}/head-nouns.js +0 -0
- /package/out/tools/{sub-venue → sub/venue}/surfaces.js +0 -0
- /package/out/tools/{sub-venue → sub/venue}/table.js +0 -0
- /package/out/{adapters → us/adapters}/fcc-bdc/adapter.d.ts +0 -0
- /package/out/{adapters/state-hi-schools → us/adapters/state/hi-schools}/adapter.d.ts +0 -0
- /package/out/{adapters/state-hi-schools → us/adapters/state/hi-schools}/workbook.d.ts +0 -0
- /package/out/{adapters/state-hi-schools → us/adapters/state/hi-schools}/workbook.js +0 -0
- /package/out/{adapters/state-ia-contractors → us/adapters/state/ia-contractors}/adapter.d.ts +0 -0
- /package/out/{adapters/state-ny-notaries → us/adapters/state/ny-notaries}/adapter.d.ts +0 -0
- /package/out/{adapters/state-tx-notaries → us/adapters/state/tx-notaries}/adapter.d.ts +0 -0
- /package/out/{adapters → us/adapters}/tiger/street-decompose.d.ts +0 -0
- /package/out/{adapters → us/adapters}/tiger/street-decompose.js +0 -0
- /package/out/{adapters/usgov-hrsa-fqhc → us/adapters/usgov/hrsa-fqhc}/adapter.d.ts +0 -0
- /package/out/{adapters/usgov-imls-pls → us/adapters/usgov/imls-pls}/adapter.d.ts +0 -0
- /package/out/{adapters/usgov-irs-bmf → us/adapters/usgov/irs-bmf}/adapter.d.ts +0 -0
- /package/out/{adapters/usgov-nad → us/adapters/usgov/nad}/adapter.d.ts +0 -0
- /package/out/{adapters/usgov-nppes → us/adapters/usgov/nppes}/adapter.d.ts +0 -0
- /package/out/{adapters/usgov-samhsa-treatment-locator → us/adapters/usgov/samhsa-treatment-locator}/adapter.d.ts +0 -0
- /package/out/{recipes → ve/recipes}/reviewed-postcode-tail.d.ts +0 -0
- /package/out/{recipes → ve/recipes}/reviewed-postcode-tail.js +0 -0
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Download and manifest utilities for `mailwoman corpus fetch <source>`.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { pathExists, readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
10
|
-
import { openWriteStream, pipeline, Readable } from "@mailwoman/core/fs/streams"
|
|
11
|
-
import { writeLocalFile, writeLocalTextFile } from "@mailwoman/core/fs/writers"
|
|
12
|
-
import { tryParsingJSON } from "@mailwoman/core/json"
|
|
13
|
-
import { sleep } from "@mailwoman/core/utils/sleep"
|
|
14
|
-
import type { PathBuilderLike } from "path-ts"
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Rate limited — retryable, the server is asking us to back off.
|
|
18
|
-
*/
|
|
19
|
-
const HTTP_TOO_MANY_REQUESTS = 429
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Lowest 5xx status. Server-side failures are retryable; 4xx are not.
|
|
23
|
-
*/
|
|
24
|
-
const HTTP_SERVER_ERROR_MIN = 500
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Highest 5xx status.
|
|
28
|
-
*/
|
|
29
|
-
const HTTP_SERVER_ERROR_MAX = 599
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The option base every `mailwoman corpus fetch <source>` module extends.
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* How long a failed transfer waits before the next attempt.
|
|
36
|
-
*/
|
|
37
|
-
export const DEFAULT_RETRY_DELAY_MS = 5000
|
|
38
|
-
|
|
39
|
-
export interface BaseFetchOptions {
|
|
40
|
-
/**
|
|
41
|
-
* Destination root for downloaded source data. Each source writes its own subdirectory.
|
|
42
|
-
*/
|
|
43
|
-
outRoot: PathBuilderLike
|
|
44
|
-
/**
|
|
45
|
-
* Pause between transfer retries, in milliseconds. Defaults to {@linkcode DEFAULT_RETRY_DELAY_MS}.
|
|
46
|
-
*
|
|
47
|
-
* A test that exercises the failure path pays this delay once per retry in real time — measured at 20.1 s for the two
|
|
48
|
-
* failing-transfer cases in `geonames-postal.test.ts`, which is the whole cost of that file. The retry COUNT is the
|
|
49
|
-
* behaviour under test there; the pause between attempts is not, so it is a caller's to shorten.
|
|
50
|
-
*/
|
|
51
|
-
retryDelayMs?: number
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* The per-run result every fetch module returns; the command maps `failed > 0` to exit code 1.
|
|
56
|
-
*/
|
|
57
|
-
export interface FetchSummary {
|
|
58
|
-
fetched: number
|
|
59
|
-
skipped: number
|
|
60
|
-
failed: number
|
|
61
|
-
failedCodes: string[]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The sibling `MANIFEST.json` shape the single-file fetch modules write: origin URL + fetch timestamp + byte count +
|
|
66
|
-
* sha256, so downstream adapters can verify provenance.
|
|
67
|
-
*/
|
|
68
|
-
export interface SourceManifest {
|
|
69
|
-
source_url: string
|
|
70
|
-
downloaded_at: string
|
|
71
|
-
filename: string
|
|
72
|
-
sha256: string
|
|
73
|
-
bytes: number
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* A status worth retrying: rate limiting or a server-side failure.
|
|
78
|
-
*/
|
|
79
|
-
/**
|
|
80
|
-
* An HTTP failure that CARRIES its status, so callers branch on `error.status` rather than on message prose. The prose
|
|
81
|
-
* route shipped a real flake: a caller classified "not published upstream" with `message.includes("404")`, and the
|
|
82
|
-
* message contains the URL — an ephemeral test-server port such as `:40453` satisfies it while the actual status is 500.
|
|
83
|
-
* Roughly 1–2% of ephemeral ports contain the substring, which is exactly the kind of sometimes-failure that burns a CI
|
|
84
|
-
* run and vanishes locally.
|
|
85
|
-
*/
|
|
86
|
-
export class HTTPStatusError extends Error {
|
|
87
|
-
readonly status: number
|
|
88
|
-
|
|
89
|
-
constructor(status: number, message: string) {
|
|
90
|
-
super(message)
|
|
91
|
-
this.name = "HTTPStatusError"
|
|
92
|
-
this.status = status
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function isTransientStatus(status: number): boolean {
|
|
97
|
-
return status === HTTP_TOO_MANY_REQUESTS || (status >= HTTP_SERVER_ERROR_MIN && status <= HTTP_SERVER_ERROR_MAX)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface DownloadOptions {
|
|
101
|
-
url: string
|
|
102
|
-
dest: string
|
|
103
|
-
/**
|
|
104
|
-
* Per-attempt timeout. Default 10 minutes — these are multi-GB government dumps.
|
|
105
|
-
*/
|
|
106
|
-
timeoutMs?: number
|
|
107
|
-
/**
|
|
108
|
-
* Extra attempts after the first, taken only on transient statuses or network errors. Default 0.
|
|
109
|
-
*/
|
|
110
|
-
retries?: number
|
|
111
|
-
/**
|
|
112
|
-
* Delay between attempts. Default 5s.
|
|
113
|
-
*/
|
|
114
|
-
retryDelayMs?: number
|
|
115
|
-
headers?: Record<string, string>
|
|
116
|
-
report?: (line: string) => void
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Download `url` to `dest` with per-attempt timeout and transient-status retry. Throws on a non-transient HTTP status
|
|
121
|
-
* or once retries are exhausted. Returns the byte count written.
|
|
122
|
-
*/
|
|
123
|
-
export async function downloadToFile(options: DownloadOptions): Promise<{ bytes: number }> {
|
|
124
|
-
const {
|
|
125
|
-
url,
|
|
126
|
-
dest,
|
|
127
|
-
timeoutMs = 600_000,
|
|
128
|
-
retries = 0,
|
|
129
|
-
retryDelayMs = DEFAULT_RETRY_DELAY_MS,
|
|
130
|
-
headers,
|
|
131
|
-
report,
|
|
132
|
-
} = options
|
|
133
|
-
|
|
134
|
-
let lastError: unknown
|
|
135
|
-
|
|
136
|
-
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
137
|
-
if (attempt > 0) {
|
|
138
|
-
report?.(`retry ${attempt}/${retries} after ${retryDelayMs}ms — ${url}`)
|
|
139
|
-
await sleep(retryDelayMs)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
let res: Response
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
// Raw `fetch`, deliberately: this is the shared FILE downloader and the body is piped to disk below.
|
|
146
|
-
// `APIClient` is the repo default for API requests — small bodies, repeated calls — and buffers a
|
|
147
|
-
// non-stream response in memory, which is the one thing a multi-gigabyte transfer must not do.
|
|
148
|
-
res = await fetch(url, { headers, signal: AbortSignal.timeout(timeoutMs) })
|
|
149
|
-
} catch (error) {
|
|
150
|
-
// AbortSignal timeouts and network-level failures are retryable.
|
|
151
|
-
lastError = error
|
|
152
|
-
|
|
153
|
-
continue
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!res.ok) {
|
|
157
|
-
const error = new HTTPStatusError(res.status, `HTTP ${res.status} ${res.statusText} — ${url}`)
|
|
158
|
-
|
|
159
|
-
if (!isTransientStatus(res.status)) throw error
|
|
160
|
-
lastError = error
|
|
161
|
-
|
|
162
|
-
continue
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
const buffer = Buffer.from(await res.arrayBuffer())
|
|
167
|
-
await writeLocalFile(buffer, dest)
|
|
168
|
-
|
|
169
|
-
return { bytes: buffer.byteLength }
|
|
170
|
-
} catch (error) {
|
|
171
|
-
// A mid-stream abort while reading the body is retryable too.
|
|
172
|
-
lastError = error
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
throw lastError instanceof Error ? lastError : new Error(String(lastError))
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface StreamDownloadOptions {
|
|
180
|
-
headers?: Record<string, string>
|
|
181
|
-
timeoutMs: number
|
|
182
|
-
retries: number
|
|
183
|
-
retryDelayMs: number
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Stream an HTTP download to disk, returning the final HTTP status (0 on network error after retries). Follows
|
|
188
|
-
* redirects (the Census and OpenAddresses endpoints both 302 to their real hosts).
|
|
189
|
-
*
|
|
190
|
-
* Kept separate from {@link downloadToFile} on purpose: this one streams a multi-GB body to disk (the buffered helper
|
|
191
|
-
* reads via `arrayBuffer()`) and returns the HTTP status instead of throwing, which the per-file result collectors and
|
|
192
|
-
* two-URL fallback ladders consume.
|
|
193
|
-
*/
|
|
194
|
-
export async function streamDownload(url: string, dest: string, opts: StreamDownloadOptions): Promise<number> {
|
|
195
|
-
for (let attempt = 0; attempt <= opts.retries; attempt++) {
|
|
196
|
-
try {
|
|
197
|
-
const res = await fetch(url, {
|
|
198
|
-
headers: opts.headers ?? {},
|
|
199
|
-
redirect: "follow",
|
|
200
|
-
signal: AbortSignal.timeout(opts.timeoutMs),
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
if (res.ok && res.body) {
|
|
204
|
-
await pipeline(Readable.fromWeb(res.body), openWriteStream(dest))
|
|
205
|
-
|
|
206
|
-
return res.status
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (attempt < opts.retries && isTransientStatus(res.status)) {
|
|
210
|
-
await sleep(opts.retryDelayMs)
|
|
211
|
-
|
|
212
|
-
continue
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return res.status
|
|
216
|
-
} catch {
|
|
217
|
-
if (attempt < opts.retries) {
|
|
218
|
-
await sleep(opts.retryDelayMs)
|
|
219
|
-
|
|
220
|
-
continue
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return 0
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return 0
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Read a MANIFEST.json; `null` when missing or corrupt (callers re-fetch from scratch).
|
|
232
|
-
*/
|
|
233
|
-
export async function readManifest<T>(path: string): Promise<T | null> {
|
|
234
|
-
if (!(await pathExists(path))) return null
|
|
235
|
-
|
|
236
|
-
// A read failure (e.g. the file vanished after the existsSync probe) maps to null like corrupt
|
|
237
|
-
// JSON does; tryParsingJSON returns null for the non-string sentinel.
|
|
238
|
-
const text = await readLocalTextFile(path).catch(() => null)
|
|
239
|
-
|
|
240
|
-
return tryParsingJSON<T>(text)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Load manifest entries into a map so untouched keys survive a partial re-fetch.
|
|
245
|
-
*/
|
|
246
|
-
export async function loadManifestEntries<T>(path: string, key: (entry: T) => string): Promise<Map<string, T>> {
|
|
247
|
-
const entries = new Map<string, T>()
|
|
248
|
-
const parsed = await readManifest<T[]>(path)
|
|
249
|
-
|
|
250
|
-
for (const entry of parsed ?? []) {
|
|
251
|
-
entries.set(key(entry), entry)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return entries
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Write a MANIFEST.json in the house shape: pretty-printed, trailing newline.
|
|
259
|
-
*/
|
|
260
|
-
export async function writeManifest(path: string, manifest: unknown): Promise<void> {
|
|
261
|
-
await writeLocalTextFile(JSON.stringify(manifest, null, 2) + "\n", path)
|
|
262
|
-
}
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Fetch GeoNames per-country GAZETTEER dumps — the 19-column `<CC>.txt` files under
|
|
7
|
-
* `https://download.geonames.org/export/dump/` (NOT the postal exports; those are `export/zip/` and
|
|
8
|
-
* `geonames-postal.ts`'s job). The dumps carry feature classes and codes (column 8: `PPLC` national capital,
|
|
9
|
-
* `PPLA` first-order administrative seat), which is what the capitals reference build consumes (#1880).
|
|
10
|
-
*
|
|
11
|
-
* The catalog question is answered by the SOURCE, not by an ISO list: `countryInfo.txt` in the same directory
|
|
12
|
-
* enumerates every country GeoNames publishes, one row per ISO alpha-2 code, and also names each country's
|
|
13
|
-
* capital — the cross-check the capitals build grades its `PPLC` extraction against. Fetch that first; derive
|
|
14
|
-
* the country set from it; then a dump absent from disk is a measured gap against the source's own catalog
|
|
15
|
-
* rather than a silent hole. The dump directory may hold files this tool did not fetch: present files are never
|
|
16
|
-
* overwritten, and a present `<CC>.txt` that is NOT a 19-column gazetteer dump (GeoNames' postal exports share
|
|
17
|
-
* the basename) is reported as `wrong_format_present`, never counted as coverage.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { pathExists, readFileHead, readLocalBuffer, readLocalTextFile } from "@mailwoman/core/fs/readers"
|
|
21
|
-
import { makeDirectories, removePathIfPresent } from "@mailwoman/core/fs/writers"
|
|
22
|
-
import { extractZipEntry } from "@mailwoman/core/fs/zip"
|
|
23
|
-
import { sha256File } from "@mailwoman/core/hash"
|
|
24
|
-
import { join } from "path-ts"
|
|
25
|
-
|
|
26
|
-
import type { BaseFetchOptions, FetchSummary } from "#tools/fetch/download"
|
|
27
|
-
import { downloadToFile, HTTPStatusError, writeManifest } from "#tools/fetch/download"
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The one status that means "the source does not publish this country" rather than "the transfer failed".
|
|
31
|
-
*/
|
|
32
|
-
const HTTP_NOT_FOUND = 404
|
|
33
|
-
|
|
34
|
-
const SLUG = "geonames-dump"
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* GeoNames' gazetteer-dump directory — one zip per ISO alpha-2 code holding `<CC>.txt`, plus `countryInfo.txt` as a
|
|
38
|
-
* bare text file.
|
|
39
|
-
*/
|
|
40
|
-
const BASE_URL = "https://download.geonames.org/export/dump"
|
|
41
|
-
|
|
42
|
-
export interface FetchGeonamesDumpOptions extends BaseFetchOptions {
|
|
43
|
-
/**
|
|
44
|
-
* ISO alpha-2 codes, any casing. Absent → every country `countryInfo.txt` enumerates.
|
|
45
|
-
*/
|
|
46
|
-
countries?: readonly string[]
|
|
47
|
-
/**
|
|
48
|
-
* Dump directory to read from. Defaults to GeoNames' own; exists so the 404 and coverage behaviour can be exercised
|
|
49
|
-
* against a local server.
|
|
50
|
-
*/
|
|
51
|
-
baseURL?: string
|
|
52
|
-
/**
|
|
53
|
-
* Refetch a dump whose `<CC>.txt` already exists. Default false — the tool fills gaps.
|
|
54
|
-
*/
|
|
55
|
-
force?: boolean
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
interface GeonamesDumpFileEntry {
|
|
59
|
-
country: string
|
|
60
|
-
filename: string
|
|
61
|
-
source_url: string
|
|
62
|
-
sha256: string
|
|
63
|
-
bytes: number
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface GeonamesDumpManifest {
|
|
67
|
-
source: string
|
|
68
|
-
base_url: string
|
|
69
|
-
license: string
|
|
70
|
-
attribution: string
|
|
71
|
-
downloaded_at: string
|
|
72
|
-
files: GeonamesDumpFileEntry[]
|
|
73
|
-
/**
|
|
74
|
-
* `<CC>.txt` files already on disk and left alone — the hand-fetched population this tool extends.
|
|
75
|
-
*/
|
|
76
|
-
skipped_present: string[]
|
|
77
|
-
/**
|
|
78
|
-
* Countries in the source catalog that the source's dump directory nonetheless 404s — a fact about the source,
|
|
79
|
-
* recorded so a later reader does not spend the fetch to rediscover it.
|
|
80
|
-
*/
|
|
81
|
-
unavailable: string[]
|
|
82
|
-
/**
|
|
83
|
-
* Present `<CC>.txt` files that are NOT 19-column gazetteer dumps — GeoNames' postal exports share the same basename,
|
|
84
|
-
* and seven tier-1 postal files sat at these paths reading as "present" until the capitals build found them
|
|
85
|
-
* capital-less. Left in place (this tool never overwrites data it did not fetch); the fix is to move the file to its
|
|
86
|
-
* own home and rerun.
|
|
87
|
-
*/
|
|
88
|
-
wrong_format_present: string[]
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Column count of a gazetteer dump row — the discriminator against GeoNames' 12-column postal exports, which share the
|
|
93
|
-
* `<CC>.txt` basename.
|
|
94
|
-
*/
|
|
95
|
-
const GAZETTEER_DUMP_COLUMNS = 19
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* True when the first non-empty line carries the gazetteer dump's 19 tab-separated columns. Accepts a partial head read
|
|
99
|
-
* — the first line is the whole question, so callers need not hand it a resident 350 MB dump.
|
|
100
|
-
*
|
|
101
|
-
* Walk the string directly rather than constructing a spliterator: the capitals builder already holds whole country
|
|
102
|
-
* dumps as strings, and a byte-oriented spliterator would UTF-8 encode that input — allocating up to another 350 MB —
|
|
103
|
-
* merely to inspect its first non-empty line.
|
|
104
|
-
*/
|
|
105
|
-
export function looksLikeGazetteerDump(text: string): boolean {
|
|
106
|
-
let start = 0
|
|
107
|
-
|
|
108
|
-
while (start < text.length) {
|
|
109
|
-
const end = text.indexOf("\n", start)
|
|
110
|
-
const line = end === -1 ? text.slice(start) : text.slice(start, end)
|
|
111
|
-
|
|
112
|
-
if (line.trim()) {
|
|
113
|
-
let tabs = 0
|
|
114
|
-
|
|
115
|
-
for (let i = line.indexOf("\t"); i !== -1; i = line.indexOf("\t", i + 1)) {
|
|
116
|
-
tabs++
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return tabs === GAZETTEER_DUMP_COLUMNS - 1
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (end === -1) break
|
|
123
|
-
|
|
124
|
-
start = end + 1
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return false
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Parse the ISO codes (column 1) and capital names (column 6) out of `countryInfo.txt` — `#`-prefixed lines are the
|
|
132
|
-
* file's own commentary.
|
|
133
|
-
*/
|
|
134
|
-
export function parseCountryInfo(text: string): Array<{ country: string; capital: string }> {
|
|
135
|
-
const rows: Array<{ country: string; capital: string }> = []
|
|
136
|
-
|
|
137
|
-
// oxlint-disable-next-line mailwoman/prefer-spliterator -- countryInfo.txt is ~40 KB, one row per country on Earth; it cannot grow past that
|
|
138
|
-
for (const line of text.split("\n")) {
|
|
139
|
-
if (line.startsWith("#") || !line.trim()) continue
|
|
140
|
-
|
|
141
|
-
// oxlint-disable-next-line mailwoman/prefer-spliterator -- one bounded 19-column catalog row
|
|
142
|
-
const cols = line.split("\t")
|
|
143
|
-
const country = cols[0]?.trim().toUpperCase()
|
|
144
|
-
|
|
145
|
-
if (country?.length === 2) {
|
|
146
|
-
rows.push({ country, capital: cols[5]?.trim() ?? "" })
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return rows
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Bytes read to classify a present file: enough to cover a first dump row whose alternate-names column runs long (they
|
|
155
|
-
* reach several KB), a fraction of the largest dumps (US.txt is ~350 MB).
|
|
156
|
-
*/
|
|
157
|
-
const FORMAT_SNIFF_BYTES = 65_536
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Download `countryInfo.txt` plus every missing `<CC>.zip`, extracting each to `<outRoot>/<CC>.txt` beside the
|
|
161
|
-
* hand-fetched dumps, with a `MANIFEST.json` naming fetched, skipped-present, and source-unavailable countries.
|
|
162
|
-
*/
|
|
163
|
-
export async function fetchGeonamesDumps(
|
|
164
|
-
options: FetchGeonamesDumpOptions,
|
|
165
|
-
report?: (line: string) => void
|
|
166
|
-
): Promise<FetchSummary & { skippedPresent: string[] }> {
|
|
167
|
-
await makeDirectories(options.outRoot)
|
|
168
|
-
|
|
169
|
-
const baseURL = options.baseURL ?? BASE_URL
|
|
170
|
-
const countryInfoDest = join(options.outRoot, "countryInfo.txt")
|
|
171
|
-
|
|
172
|
-
await downloadToFile({
|
|
173
|
-
url: `${baseURL}/countryInfo.txt`,
|
|
174
|
-
dest: countryInfoDest,
|
|
175
|
-
timeoutMs: 120_000,
|
|
176
|
-
retries: 2,
|
|
177
|
-
report,
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
const catalog = parseCountryInfo(await readLocalTextFile(countryInfoDest))
|
|
181
|
-
const countries = options.countries?.map((code) => code.trim().toUpperCase()) ?? catalog.map((row) => row.country)
|
|
182
|
-
|
|
183
|
-
const entries: GeonamesDumpFileEntry[] = []
|
|
184
|
-
const failedCodes: string[] = []
|
|
185
|
-
const unavailable: string[] = []
|
|
186
|
-
const skippedPresent: string[] = []
|
|
187
|
-
const wrongFormatPresent: string[] = []
|
|
188
|
-
let fetched = 0
|
|
189
|
-
|
|
190
|
-
for (const country of countries) {
|
|
191
|
-
const txtDest = join(options.outRoot, `${country}.txt`)
|
|
192
|
-
|
|
193
|
-
if (!options.force && (await pathExists(txtDest))) {
|
|
194
|
-
if (looksLikeGazetteerDump(await readFileHead(txtDest, FORMAT_SNIFF_BYTES))) {
|
|
195
|
-
skippedPresent.push(country)
|
|
196
|
-
} else {
|
|
197
|
-
report?.(`✗ ${country}.txt is present but is not a 19-column gazetteer dump — move it aside and rerun`)
|
|
198
|
-
wrongFormatPresent.push(country)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
continue
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const filename = `${country}.zip`
|
|
205
|
-
const url = `${baseURL}/${filename}`
|
|
206
|
-
const zipDest = join(options.outRoot, filename)
|
|
207
|
-
|
|
208
|
-
report?.(`=== ${SLUG} / ${country}`)
|
|
209
|
-
|
|
210
|
-
try {
|
|
211
|
-
await downloadToFile({ url, dest: zipDest, timeoutMs: 300_000, retries: 2, report })
|
|
212
|
-
await extractZipEntry(zipDest, `${country}.txt`, txtDest)
|
|
213
|
-
await removePathIfPresent(zipDest)
|
|
214
|
-
|
|
215
|
-
entries.push({
|
|
216
|
-
country,
|
|
217
|
-
filename: `${country}.txt`,
|
|
218
|
-
source_url: url,
|
|
219
|
-
sha256: await sha256File(txtDest),
|
|
220
|
-
bytes: (await readLocalBuffer(txtDest)).byteLength,
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
fetched++
|
|
224
|
-
} catch (error) {
|
|
225
|
-
await removePathIfPresent(zipDest)
|
|
226
|
-
|
|
227
|
-
const message = error instanceof Error ? error.message : String(error)
|
|
228
|
-
|
|
229
|
-
// Branch on the TYPED status (the geonames-postal lesson): message prose contains the URL, and a URL
|
|
230
|
-
// can contain any substring.
|
|
231
|
-
if (error instanceof HTTPStatusError && error.status === HTTP_NOT_FOUND) {
|
|
232
|
-
report?.(`✗ ${country}: GeoNames publishes no gazetteer dump for this country`)
|
|
233
|
-
unavailable.push(country)
|
|
234
|
-
} else {
|
|
235
|
-
report?.(`✗ ${country}: ${message}`)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
failedCodes.push(country)
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const manifest: GeonamesDumpManifest = {
|
|
243
|
-
source: SLUG,
|
|
244
|
-
base_url: baseURL,
|
|
245
|
-
license: "CC-BY-4.0",
|
|
246
|
-
attribution: "GeoNames",
|
|
247
|
-
downloaded_at: new Date().toISOString(),
|
|
248
|
-
files: entries,
|
|
249
|
-
skipped_present: skippedPresent.toSorted(),
|
|
250
|
-
unavailable,
|
|
251
|
-
wrong_format_present: wrongFormatPresent.toSorted(),
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
await writeManifest(join(options.outRoot, "MANIFEST.json"), manifest)
|
|
255
|
-
|
|
256
|
-
return { fetched, skipped: skippedPresent.length, failed: failedCodes.length, failedCodes, skippedPresent }
|
|
257
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license AGPL-3.0
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* Fetch the GeoNames per-country postal-code exports — the only source in this family that carries a
|
|
7
|
-
* `(postcode, locality, region)` triple with the NAMES inline.
|
|
8
|
-
*
|
|
9
|
-
* Source : https://download.geonames.org/export/zip/<CC>.zip
|
|
10
|
-
* License: CC-BY-4.0, attribute "GeoNames". Tier B.
|
|
11
|
-
*
|
|
12
|
-
* ## Why this source and not a join
|
|
13
|
-
*
|
|
14
|
-
* A postcode slice is only useful to the corpus if a postcode reaches a locality and a region. Two routes exist and
|
|
15
|
-
* only one of them works everywhere:
|
|
16
|
-
*
|
|
17
|
-
* - **`parent_id`** — `postalcode-intl.db` carries a real parent that resolves in the admin gazetteer (measured: NL
|
|
18
|
-
* 97.5% of rows linked, FR 90.7%, DE 66.1%, ES 34.9%, IT 27.4%, and 93.8–100% of those resolve to a
|
|
19
|
-
* `locality`/`localadmin`). It is also the ONLY slice that does: `postalcode-geonames-intl.db` and every
|
|
20
|
-
* `postalcode-<cc>-overture.db` carry `parent_id = 0` on every row, so five countries have this route and the rest
|
|
21
|
-
* have none.
|
|
22
|
-
* - **Nearest locality centroid** — the obvious fallback, and it does not work. Scored against the `parent_id` truth
|
|
23
|
-
* on 1,000–1,500 postcodes per country: NL 81.1%, DE 44.7%, ES 35.1%, FR 29.0%, IT 13.5%. A locality's centroid
|
|
24
|
-
* sits at its middle, so a postcode near the edge is routinely closer to a neighbouring town's centroid than to its
|
|
25
|
-
* own. Under 50% for four of the five, which is not a join.
|
|
26
|
-
*
|
|
27
|
-
* The GeoNames export sidesteps both: columns 3 and 4 ARE the place and admin1 names, so there is nothing to join and
|
|
28
|
-
* nothing to approximate. `@mailwoman/corpus`'s `geonames-postal` adapter consumes it directly.
|
|
29
|
-
*
|
|
30
|
-
* ## Coverage is not universal, and the gap is the point
|
|
31
|
-
*
|
|
32
|
-
* GeoNames publishes ~80 countries, NOT all of them. Venezuela returns 404 — so a VE postcode slice cannot be built
|
|
33
|
-
* from this source at any effort, and that is an acquisition question rather than a build one. Ask for a country
|
|
34
|
-
* before assuming it is there; an absent country fails as one entry, never as the whole run.
|
|
35
|
-
*
|
|
36
|
-
* ## Row counts from this source overstate, for some countries by exactly 2×
|
|
37
|
-
*
|
|
38
|
-
* Countries whose postcode format contains a hyphen are published TWICE — once `3750-000`, once `3750000`. Measured
|
|
39
|
-
* on the slice built from this source: PT 395,544 rows over 197,772 distinct codes and PL 40,598 over 20,299, both
|
|
40
|
-
* exactly 2.00×, while AU, CZ and AT (no hyphen in the format) are 1.00×. A consumer sizing a slice from the row
|
|
41
|
-
* count doubles its estimate for those countries.
|
|
42
|
-
*
|
|
43
|
-
* ## Why `downloadToFile` and not `APIClient`
|
|
44
|
-
*
|
|
45
|
-
* Same split `AGENTS.md` draws and the `ourairports` sibling explains: these are static file transfers from a plain
|
|
46
|
-
* file host, run once per refresh. The pacing, retry and caching `APIClient` exists for have nothing to act on here.
|
|
47
|
-
*
|
|
48
|
-
* Invoke via `mailwoman corpus fetch geonames-postal --countries pt,au,nz`.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
import { makeDirectories } from "@mailwoman/core/fs/writers"
|
|
52
|
-
import { sha256File } from "@mailwoman/core/hash"
|
|
53
|
-
import { join } from "path-ts"
|
|
54
|
-
|
|
55
|
-
import type { BaseFetchOptions, FetchSummary } from "#tools/fetch/download"
|
|
56
|
-
import { downloadToFile, HTTPStatusError, writeManifest } from "#tools/fetch/download"
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The one status that means "the source does not publish this country" rather than "the transfer failed".
|
|
60
|
-
*/
|
|
61
|
-
const HTTP_NOT_FOUND = 404
|
|
62
|
-
|
|
63
|
-
const SLUG = "geonames-postal"
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* GeoNames' own export directory. One zip per ISO alpha-2 code, each holding `<CC>.txt` plus the shared `readme.txt`.
|
|
67
|
-
*/
|
|
68
|
-
const BASE_URL = "https://download.geonames.org/export/zip"
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Countries fetched when the caller names none.
|
|
72
|
-
*
|
|
73
|
-
* These are the ones the corpus wants and cannot get from `postalcode-intl.db`'s `parent_id` route — see the header for
|
|
74
|
-
* why that route covers exactly five countries. Venezuela is deliberately absent because GeoNames does not publish it.
|
|
75
|
-
*/
|
|
76
|
-
export const GEONAMES_POSTAL_DEFAULT_COUNTRIES = ["PT", "AU", "NZ", "IE", "BR", "ZA", "MX"] as const
|
|
77
|
-
|
|
78
|
-
export interface FetchGeonamesPostalOptions extends BaseFetchOptions {
|
|
79
|
-
/**
|
|
80
|
-
* ISO alpha-2 codes, in any casing. Defaults to {@linkcode GEONAMES_POSTAL_DEFAULT_COUNTRIES}.
|
|
81
|
-
*/
|
|
82
|
-
countries?: readonly string[]
|
|
83
|
-
/**
|
|
84
|
-
* Export directory to read from. Defaults to GeoNames' own. Exists so the 404-is-a-coverage-finding behaviour can be
|
|
85
|
-
* exercised against a local server rather than by asking GeoNames for a country it does not have.
|
|
86
|
-
*/
|
|
87
|
-
baseURL?: string
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
interface GeonamesPostalFileEntry {
|
|
91
|
-
country: string
|
|
92
|
-
filename: string
|
|
93
|
-
source_url: string
|
|
94
|
-
sha256: string
|
|
95
|
-
bytes: number
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
interface GeonamesPostalManifest {
|
|
99
|
-
source: string
|
|
100
|
-
base_url: string
|
|
101
|
-
license: string
|
|
102
|
-
attribution: string
|
|
103
|
-
downloaded_at: string
|
|
104
|
-
files: GeonamesPostalFileEntry[]
|
|
105
|
-
/**
|
|
106
|
-
* Countries asked for and NOT published by GeoNames, recorded so a later reader does not spend the fetch again to
|
|
107
|
-
* rediscover it. An absence here is a fact about the source, not about the run.
|
|
108
|
-
*/
|
|
109
|
-
unavailable: string[]
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Download the requested GeoNames postal zips into `<outRoot>/geonames-postal/`, with a sibling `MANIFEST.json`
|
|
114
|
-
* carrying each file's origin URL, sha256 and byte count, plus the countries the source does not publish.
|
|
115
|
-
*
|
|
116
|
-
* A country the source does not carry is counted as failed and named in `failedCodes` — it does not stop the rest.
|
|
117
|
-
*/
|
|
118
|
-
export async function fetchGeonamesPostal(
|
|
119
|
-
options: FetchGeonamesPostalOptions,
|
|
120
|
-
report?: (line: string) => void
|
|
121
|
-
): Promise<FetchSummary> {
|
|
122
|
-
const destDir = join(options.outRoot, SLUG)
|
|
123
|
-
await makeDirectories(destDir)
|
|
124
|
-
|
|
125
|
-
const countries = (options.countries ?? GEONAMES_POSTAL_DEFAULT_COUNTRIES).map((code) => code.trim().toUpperCase())
|
|
126
|
-
const baseURL = options.baseURL ?? BASE_URL
|
|
127
|
-
const retryDelayMs = options.retryDelayMs
|
|
128
|
-
const entries: GeonamesPostalFileEntry[] = []
|
|
129
|
-
const failedCodes: string[] = []
|
|
130
|
-
const unavailable: string[] = []
|
|
131
|
-
let fetched = 0
|
|
132
|
-
let failed = 0
|
|
133
|
-
|
|
134
|
-
for (const country of countries) {
|
|
135
|
-
const filename = `${country}.zip`
|
|
136
|
-
const url = `${baseURL}/${filename}`
|
|
137
|
-
const dest = join(destDir, filename)
|
|
138
|
-
|
|
139
|
-
report?.(`=== ${SLUG} / ${country}`)
|
|
140
|
-
|
|
141
|
-
try {
|
|
142
|
-
const { bytes } = await downloadToFile({ url, dest, timeoutMs: 300_000, retries: 2, retryDelayMs, report })
|
|
143
|
-
|
|
144
|
-
entries.push({ country, filename, source_url: url, sha256: await sha256File(dest), bytes })
|
|
145
|
-
|
|
146
|
-
fetched++
|
|
147
|
-
} catch (error) {
|
|
148
|
-
const message = error instanceof Error ? error.message : String(error)
|
|
149
|
-
|
|
150
|
-
// A 404 here means GeoNames does not publish the country at all, which is a different finding from a failed
|
|
151
|
-
// transfer and the one a caller planning a slice needs to see. Branch on the TYPED status: matching message
|
|
152
|
-
// prose classified a 500 as "unpublished" whenever the URL happened to contain the substring 404 — an
|
|
153
|
-
// ephemeral test-server port did exactly that in CI.
|
|
154
|
-
if (error instanceof HTTPStatusError && error.status === HTTP_NOT_FOUND) {
|
|
155
|
-
report?.(`✗ ${country}: GeoNames does not publish a postal export for this country`)
|
|
156
|
-
unavailable.push(country)
|
|
157
|
-
} else {
|
|
158
|
-
report?.(`✗ ${country}: ${message}`)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
failedCodes.push(country)
|
|
162
|
-
|
|
163
|
-
failed++
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const manifest: GeonamesPostalManifest = {
|
|
168
|
-
source: "GeoNames postal codes",
|
|
169
|
-
base_url: baseURL,
|
|
170
|
-
license: "CC-BY-4.0",
|
|
171
|
-
attribution: "GeoNames",
|
|
172
|
-
downloaded_at: new Date().toISOString(),
|
|
173
|
-
files: entries,
|
|
174
|
-
unavailable,
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
await writeManifest(join(destDir, "MANIFEST.json"), manifest)
|
|
178
|
-
|
|
179
|
-
return { fetched, skipped: 0, failed, failedCodes }
|
|
180
|
-
}
|