@mailwoman/resolver-wof-sqlite 10.0.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/lib/address/point/interpolation.ts +45 -39
- package/lib/address/point/schema.ts +17 -40
- package/lib/address/point.ts +316 -0
- package/lib/{address/index.ts → address.ts} +1 -1
- package/lib/ancestry/backfill.ts +20 -86
- package/lib/{ancestry/index.ts → ancestry.ts} +19 -15
- package/lib/build/candidate.ts +122 -174
- package/lib/build/population-corrections.ts +64 -0
- package/lib/build/slim.ts +44 -114
- package/lib/candidate/alias-bags.ts +16 -17
- package/lib/candidate/ancestors/schema.ts +77 -61
- package/lib/candidate/ancestors/sidecar.ts +15 -22
- package/lib/candidate/country-display-names.ts +6 -20
- package/lib/candidate/extract-fold.ts +10 -55
- package/lib/candidate/fts.ts +5 -23
- package/lib/candidate/importance.ts +65 -68
- package/lib/candidate/lookup.ts +124 -415
- package/lib/candidate/name-roles.ts +15 -33
- package/lib/candidate/own-name.ts +35 -32
- package/lib/candidate/place-attrs.ts +20 -13
- package/lib/candidate/schema.ts +29 -65
- package/lib/candidate/scoring.ts +54 -93
- package/lib/capital-schema.ts +21 -17
- package/lib/capitals.ts +29 -27
- package/lib/coincident-roles.ts +85 -55
- package/lib/convention/schema.ts +15 -16
- package/lib/convention.ts +144 -0
- package/lib/coverage-manifest-schema.ts +40 -45
- package/lib/currency-backfill.ts +34 -79
- package/lib/env.ts +1 -1
- package/lib/exact-match.ts +32 -21
- package/lib/extracts.ts +97 -74
- package/lib/fst/autocomplete.ts +54 -37
- package/lib/fst/builder.ts +37 -41
- package/lib/fst/deserialize-web.ts +16 -17
- package/lib/fst/format.ts +41 -23
- package/lib/fst/freshness.ts +43 -120
- package/lib/fst/matcher.ts +7 -5
- package/lib/fst/serialize.ts +54 -74
- package/lib/fst/types.ts +78 -75
- package/lib/{fst/index.ts → fst.ts} +1 -0
- package/lib/fts/query.ts +5 -36
- package/lib/fts.ts +280 -0
- package/lib/geonames/aliases.ts +73 -144
- package/lib/geonames/postal.ts +162 -71
- package/lib/index.ts +9 -8
- package/lib/interpolation.ts +48 -100
- package/lib/lookup.ts +155 -270
- package/lib/name-score.ts +9 -7
- package/lib/nsul/lookup.ts +37 -54
- package/lib/nsul/schema.ts +16 -43
- package/lib/paths.ts +159 -0
- package/lib/place-importance-schema.ts +62 -169
- package/lib/poi/lookup.ts +104 -121
- package/lib/poi/schema.ts +42 -26
- package/lib/polygon-schema.ts +10 -6
- package/lib/postal/city/alias/lookup.ts +22 -40
- package/lib/postal/city/alias/schema.ts +14 -10
- package/lib/postal/city/candidate-schema.ts +26 -20
- package/lib/postcode-point-lookup.ts +8 -27
- package/lib/primary-preference.ts +46 -126
- package/lib/proximity-rerank.ts +44 -33
- package/lib/ranking-weights.ts +105 -78
- package/lib/region-keys.ts +70 -42
- package/lib/reverse.ts +149 -86
- package/lib/schema.ts +73 -50
- package/lib/search-fetch.ts +90 -68
- package/lib/sqlite/convention-source.ts +15 -23
- package/lib/sqlite/utils.ts +19 -22
- package/lib/street/centroid/schema.ts +37 -42
- package/lib/street/{centroid/index.ts → centroid.ts} +16 -25
- package/lib/street/morphology/fst/builder.ts +60 -42
- package/lib/street/morphology/fst/loader.ts +40 -32
- package/lib/street/name-lookup.ts +45 -41
- package/lib/street/normalize.ts +88 -219
- package/lib/street/segment-schema.ts +116 -43
- package/lib/{street/index.ts → street.ts} +1 -1
- package/lib/types.ts +109 -150
- package/lib/unified-schema.ts +29 -29
- package/lib/uprn/existence.ts +30 -19
- package/lib/uprn/lookup.ts +29 -68
- package/lib/uprn/schema.ts +18 -40
- package/lib/weights-overlay-linker.ts +236 -252
- package/out/address/point/interpolation.d.ts +20 -23
- package/out/address/point/interpolation.d.ts.map +1 -1
- package/out/address/point/interpolation.js +42 -39
- package/out/address/point/interpolation.js.map +1 -1
- package/out/address/point/schema.d.ts +12 -35
- package/out/address/point/schema.d.ts.map +1 -1
- package/out/address/point/schema.js +3 -19
- package/out/address/point/schema.js.map +1 -1
- package/out/address/point.d.ts +57 -0
- package/out/address/point.d.ts.map +1 -0
- package/out/address/point.js +206 -0
- package/out/address/point.js.map +1 -0
- package/out/{address/index.js → address.d.ts} +2 -2
- package/out/address.d.ts.map +1 -0
- package/out/{address/index.d.ts → address.js} +2 -2
- package/out/address.js.map +1 -0
- package/out/ancestry/backfill.d.ts +11 -64
- package/out/ancestry/backfill.d.ts.map +1 -1
- package/out/ancestry/backfill.js +14 -74
- package/out/ancestry/backfill.js.map +1 -1
- package/out/ancestry.d.ts +49 -0
- package/out/ancestry.d.ts.map +1 -0
- package/out/ancestry.js +59 -0
- package/out/ancestry.js.map +1 -0
- package/out/build/candidate.d.ts +82 -112
- package/out/build/candidate.d.ts.map +1 -1
- package/out/build/candidate.js +17 -100
- package/out/build/candidate.js.map +1 -1
- package/out/build/population-corrections.d.ts +52 -0
- package/out/build/population-corrections.d.ts.map +1 -0
- package/out/build/population-corrections.js +40 -0
- package/out/build/population-corrections.js.map +1 -0
- package/out/build/slim.d.ts +8 -44
- package/out/build/slim.d.ts.map +1 -1
- package/out/build/slim.js +33 -94
- package/out/build/slim.js.map +1 -1
- package/out/candidate/alias-bags.d.ts +6 -6
- package/out/candidate/alias-bags.d.ts.map +1 -1
- package/out/candidate/alias-bags.js +16 -17
- package/out/candidate/alias-bags.js.map +1 -1
- package/out/candidate/ancestors/schema.d.ts +73 -57
- package/out/candidate/ancestors/schema.d.ts.map +1 -1
- package/out/candidate/ancestors/schema.js +56 -48
- package/out/candidate/ancestors/schema.js.map +1 -1
- package/out/candidate/ancestors/sidecar.d.ts +3 -8
- package/out/candidate/ancestors/sidecar.d.ts.map +1 -1
- package/out/candidate/ancestors/sidecar.js +15 -22
- package/out/candidate/ancestors/sidecar.js.map +1 -1
- package/out/candidate/country-display-names.d.ts +5 -15
- package/out/candidate/country-display-names.d.ts.map +1 -1
- package/out/candidate/country-display-names.js +6 -20
- package/out/candidate/country-display-names.js.map +1 -1
- package/out/candidate/extract-fold.d.ts +7 -15
- package/out/candidate/extract-fold.d.ts.map +1 -1
- package/out/candidate/extract-fold.js +5 -47
- package/out/candidate/extract-fold.js.map +1 -1
- package/out/candidate/fts.d.ts +5 -23
- package/out/candidate/fts.d.ts.map +1 -1
- package/out/candidate/fts.js +5 -23
- package/out/candidate/fts.js.map +1 -1
- package/out/candidate/importance.d.ts +60 -65
- package/out/candidate/importance.d.ts.map +1 -1
- package/out/candidate/importance.js +56 -63
- package/out/candidate/importance.js.map +1 -1
- package/out/candidate/lookup.d.ts +18 -55
- package/out/candidate/lookup.d.ts.map +1 -1
- package/out/candidate/lookup.js +82 -385
- package/out/candidate/lookup.js.map +1 -1
- package/out/candidate/name-roles.d.ts +9 -21
- package/out/candidate/name-roles.d.ts.map +1 -1
- package/out/candidate/name-roles.js +15 -33
- package/out/candidate/name-roles.js.map +1 -1
- package/out/candidate/own-name.d.ts +23 -25
- package/out/candidate/own-name.d.ts.map +1 -1
- package/out/candidate/own-name.js +35 -32
- package/out/candidate/own-name.js.map +1 -1
- package/out/candidate/place-attrs.d.ts +20 -13
- package/out/candidate/place-attrs.d.ts.map +1 -1
- package/out/candidate/place-attrs.js +4 -5
- package/out/candidate/place-attrs.js.map +1 -1
- package/out/candidate/schema.d.ts +27 -62
- package/out/candidate/schema.d.ts.map +1 -1
- package/out/candidate/schema.js +10 -22
- package/out/candidate/schema.js.map +1 -1
- package/out/candidate/scoring.d.ts +7 -8
- package/out/candidate/scoring.d.ts.map +1 -1
- package/out/candidate/scoring.js +52 -89
- package/out/candidate/scoring.js.map +1 -1
- package/out/capital-schema.d.ts +21 -17
- package/out/capital-schema.d.ts.map +1 -1
- package/out/capital-schema.js +17 -15
- package/out/capital-schema.js.map +1 -1
- package/out/capitals.d.ts +27 -25
- package/out/capitals.d.ts.map +1 -1
- package/out/capitals.js +23 -21
- package/out/capitals.js.map +1 -1
- package/out/coincident-roles.d.ts +60 -43
- package/out/coincident-roles.d.ts.map +1 -1
- package/out/coincident-roles.js +72 -50
- package/out/coincident-roles.js.map +1 -1
- package/out/convention/schema.d.ts +14 -14
- package/out/convention/schema.d.ts.map +1 -1
- package/out/convention/schema.js +6 -4
- package/out/convention/schema.js.map +1 -1
- package/out/convention.d.ts +97 -0
- package/out/convention.d.ts.map +1 -0
- package/out/convention.js +81 -0
- package/out/convention.js.map +1 -0
- package/out/coverage-manifest-schema.d.ts +34 -39
- package/out/coverage-manifest-schema.d.ts.map +1 -1
- package/out/coverage-manifest-schema.js +25 -34
- package/out/coverage-manifest-schema.js.map +1 -1
- package/out/currency-backfill.d.ts +16 -38
- package/out/currency-backfill.d.ts.map +1 -1
- package/out/currency-backfill.js +19 -46
- package/out/currency-backfill.js.map +1 -1
- package/out/env.d.ts +1 -1
- package/out/env.js +1 -1
- package/out/exact-match.d.ts +19 -10
- package/out/exact-match.d.ts.map +1 -1
- package/out/exact-match.js +32 -21
- package/out/exact-match.js.map +1 -1
- package/out/extracts.d.ts +66 -55
- package/out/extracts.d.ts.map +1 -1
- package/out/extracts.js +63 -55
- package/out/extracts.js.map +1 -1
- package/out/fst/autocomplete.d.ts +29 -21
- package/out/fst/autocomplete.d.ts.map +1 -1
- package/out/fst/autocomplete.js +39 -28
- package/out/fst/autocomplete.js.map +1 -1
- package/out/fst/builder.d.ts.map +1 -1
- package/out/fst/builder.js +37 -41
- package/out/fst/builder.js.map +1 -1
- package/out/fst/deserialize-web.d.ts +4 -4
- package/out/fst/deserialize-web.d.ts.map +1 -1
- package/out/fst/deserialize-web.js +15 -16
- package/out/fst/deserialize-web.js.map +1 -1
- package/out/fst/format.d.ts +41 -23
- package/out/fst/format.d.ts.map +1 -1
- package/out/fst/format.js +41 -23
- package/out/fst/format.js.map +1 -1
- package/out/fst/freshness.d.ts +19 -81
- package/out/fst/freshness.d.ts.map +1 -1
- package/out/fst/freshness.js +31 -94
- package/out/fst/freshness.js.map +1 -1
- package/out/fst/matcher.d.ts +5 -4
- package/out/fst/matcher.d.ts.map +1 -1
- package/out/fst/matcher.js +2 -2
- package/out/fst/matcher.js.map +1 -1
- package/out/fst/serialize.d.ts +28 -28
- package/out/fst/serialize.d.ts.map +1 -1
- package/out/fst/serialize.js +53 -71
- package/out/fst/serialize.js.map +1 -1
- package/out/fst/types.d.ts +78 -74
- package/out/fst/types.d.ts.map +1 -1
- package/out/fst/types.js +1 -4
- package/out/fst/types.js.map +1 -1
- package/out/{fst/index.js → fst.d.ts} +2 -1
- package/out/fst.d.ts.map +1 -0
- package/out/{fst/index.d.ts → fst.js} +2 -1
- package/out/fst.js.map +1 -0
- package/out/fts/query.d.ts +2 -27
- package/out/fts/query.d.ts.map +1 -1
- package/out/fts/query.js +5 -36
- package/out/fts/query.js.map +1 -1
- package/out/fts.d.ts +126 -0
- package/out/fts.d.ts.map +1 -0
- package/out/fts.js +188 -0
- package/out/fts.js.map +1 -0
- package/out/geonames/aliases.d.ts +26 -62
- package/out/geonames/aliases.d.ts.map +1 -1
- package/out/geonames/aliases.js +45 -117
- package/out/geonames/aliases.js.map +1 -1
- package/out/geonames/postal.d.ts +84 -44
- package/out/geonames/postal.d.ts.map +1 -1
- package/out/geonames/postal.js +115 -73
- package/out/geonames/postal.js.map +1 -1
- package/out/{geonames/index.js → geonames.d.ts} +1 -1
- package/out/geonames.d.ts.map +1 -0
- package/out/{geonames/index.d.ts → geonames.js} +1 -1
- package/out/geonames.js.map +1 -0
- package/out/index.d.ts +9 -8
- package/out/index.d.ts.map +1 -1
- package/out/index.js +6 -5
- package/out/index.js.map +1 -1
- package/out/interpolation.d.ts +18 -55
- package/out/interpolation.d.ts.map +1 -1
- package/out/interpolation.js +27 -69
- package/out/interpolation.js.map +1 -1
- package/out/lookup.d.ts +23 -51
- package/out/lookup.d.ts.map +1 -1
- package/out/lookup.js +136 -234
- package/out/lookup.js.map +1 -1
- package/out/name-score.d.ts +2 -2
- package/out/name-score.d.ts.map +1 -1
- package/out/name-score.js +9 -7
- package/out/name-score.js.map +1 -1
- package/out/nsul/lookup.d.ts +33 -34
- package/out/nsul/lookup.d.ts.map +1 -1
- package/out/nsul/lookup.js +26 -40
- package/out/nsul/lookup.js.map +1 -1
- package/out/nsul/schema.d.ts +16 -43
- package/out/nsul/schema.d.ts.map +1 -1
- package/out/nsul/schema.js +9 -35
- package/out/nsul/schema.js.map +1 -1
- package/out/{nsul/index.d.ts → nsul.d.ts} +1 -1
- package/out/nsul.d.ts.map +1 -0
- package/out/{nsul/index.js → nsul.js} +1 -1
- package/out/nsul.js.map +1 -0
- package/out/paths.d.ts +124 -0
- package/out/paths.d.ts.map +1 -0
- package/out/paths.js +104 -0
- package/out/paths.js.map +1 -0
- package/out/place-importance-schema.d.ts +51 -143
- package/out/place-importance-schema.d.ts.map +1 -1
- package/out/place-importance-schema.js +28 -143
- package/out/place-importance-schema.js.map +1 -1
- package/out/poi/lookup.d.ts +40 -47
- package/out/poi/lookup.d.ts.map +1 -1
- package/out/poi/lookup.js +69 -96
- package/out/poi/lookup.js.map +1 -1
- package/out/poi/schema.d.ts +41 -25
- package/out/poi/schema.d.ts.map +1 -1
- package/out/poi/schema.js +25 -17
- package/out/poi/schema.js.map +1 -1
- package/out/{poi/index.js → poi.d.ts} +1 -1
- package/out/poi.d.ts.map +1 -0
- package/out/{poi/index.d.ts → poi.js} +1 -1
- package/out/poi.js.map +1 -0
- package/out/polygon-schema.d.ts +10 -6
- package/out/polygon-schema.d.ts.map +1 -1
- package/out/polygon-schema.js +2 -2
- package/out/polygon-schema.js.map +1 -1
- package/out/postal/city/alias/lookup.d.ts +20 -23
- package/out/postal/city/alias/lookup.d.ts.map +1 -1
- package/out/postal/city/alias/lookup.js +17 -30
- package/out/postal/city/alias/lookup.js.map +1 -1
- package/out/postal/city/alias/schema.d.ts +14 -10
- package/out/postal/city/alias/schema.d.ts.map +1 -1
- package/out/postal/city/alias/schema.js +10 -8
- package/out/postal/city/alias/schema.js.map +1 -1
- package/out/postal/city/candidate-schema.d.ts +25 -19
- package/out/postal/city/candidate-schema.d.ts.map +1 -1
- package/out/postal/city/candidate-schema.js +21 -17
- package/out/postal/city/candidate-schema.js.map +1 -1
- package/out/{postal/index.d.ts → postal.d.ts} +1 -1
- package/out/postal.d.ts.map +1 -0
- package/out/{postal/index.js → postal.js} +1 -1
- package/out/postal.js.map +1 -0
- package/out/postcode-point-lookup.d.ts +6 -24
- package/out/postcode-point-lookup.d.ts.map +1 -1
- package/out/postcode-point-lookup.js +5 -17
- package/out/postcode-point-lookup.js.map +1 -1
- package/out/primary-preference.d.ts +38 -92
- package/out/primary-preference.d.ts.map +1 -1
- package/out/primary-preference.js +15 -99
- package/out/primary-preference.js.map +1 -1
- package/out/proximity-rerank.d.ts +41 -30
- package/out/proximity-rerank.d.ts.map +1 -1
- package/out/proximity-rerank.js +38 -29
- package/out/proximity-rerank.js.map +1 -1
- package/out/ranking-weights.d.ts +98 -64
- package/out/ranking-weights.d.ts.map +1 -1
- package/out/ranking-weights.js +26 -25
- package/out/ranking-weights.js.map +1 -1
- package/out/region-keys.d.ts +50 -31
- package/out/region-keys.d.ts.map +1 -1
- package/out/region-keys.js +68 -40
- package/out/region-keys.js.map +1 -1
- package/out/reverse.d.ts +78 -50
- package/out/reverse.d.ts.map +1 -1
- package/out/reverse.js +98 -61
- package/out/reverse.js.map +1 -1
- package/out/schema.d.ts +72 -49
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +4 -5
- package/out/schema.js.map +1 -1
- package/out/search-fetch.d.ts +16 -12
- package/out/search-fetch.d.ts.map +1 -1
- package/out/search-fetch.js +83 -63
- package/out/search-fetch.js.map +1 -1
- package/out/sqlite/convention-source.d.ts +12 -16
- package/out/sqlite/convention-source.d.ts.map +1 -1
- package/out/sqlite/convention-source.js +13 -22
- package/out/sqlite/convention-source.js.map +1 -1
- package/out/sqlite/utils.d.ts +19 -19
- package/out/sqlite/utils.d.ts.map +1 -1
- package/out/sqlite/utils.js +14 -15
- package/out/sqlite/utils.js.map +1 -1
- package/out/street/centroid/schema.d.ts +37 -42
- package/out/street/centroid/schema.d.ts.map +1 -1
- package/out/street/centroid/schema.js +9 -21
- package/out/street/centroid/schema.js.map +1 -1
- package/out/street/centroid.d.ts +30 -0
- package/out/street/centroid.d.ts.map +1 -0
- package/out/street/{centroid/index.js → centroid.js} +13 -24
- package/out/street/centroid.js.map +1 -0
- package/out/street/morphology/fst/builder.d.ts +20 -10
- package/out/street/morphology/fst/builder.d.ts.map +1 -1
- package/out/street/morphology/fst/builder.js +44 -34
- package/out/street/morphology/fst/builder.js.map +1 -1
- package/out/street/morphology/fst/loader.d.ts +33 -26
- package/out/street/morphology/fst/loader.d.ts.map +1 -1
- package/out/street/morphology/fst/loader.js +23 -22
- package/out/street/morphology/fst/loader.js.map +1 -1
- package/out/street/name-lookup.d.ts +24 -18
- package/out/street/name-lookup.d.ts.map +1 -1
- package/out/street/name-lookup.js +34 -35
- package/out/street/name-lookup.js.map +1 -1
- package/out/street/normalize.d.ts +35 -136
- package/out/street/normalize.d.ts.map +1 -1
- package/out/street/normalize.js +77 -194
- package/out/street/normalize.js.map +1 -1
- package/out/street/segment-schema.d.ts +79 -39
- package/out/street/segment-schema.d.ts.map +1 -1
- package/out/street/segment-schema.js +71 -21
- package/out/street/segment-schema.js.map +1 -1
- package/out/{street/index.js → street.d.ts} +2 -2
- package/out/street.d.ts.map +1 -0
- package/out/{street/index.d.ts → street.js} +2 -2
- package/out/street.js.map +1 -0
- package/out/types.d.ts +84 -149
- package/out/types.d.ts.map +1 -1
- package/out/types.js +0 -6
- package/out/types.js.map +1 -1
- package/out/unified-schema.d.ts +8 -12
- package/out/unified-schema.d.ts.map +1 -1
- package/out/unified-schema.js +29 -29
- package/out/unified-schema.js.map +1 -1
- package/out/uprn/existence.d.ts +28 -17
- package/out/uprn/existence.d.ts.map +1 -1
- package/out/uprn/existence.js +26 -16
- package/out/uprn/existence.js.map +1 -1
- package/out/uprn/lookup.d.ts +14 -44
- package/out/uprn/lookup.d.ts.map +1 -1
- package/out/uprn/lookup.js +21 -57
- package/out/uprn/lookup.js.map +1 -1
- package/out/uprn/schema.d.ts +18 -40
- package/out/uprn/schema.d.ts.map +1 -1
- package/out/uprn/schema.js +10 -32
- package/out/uprn/schema.js.map +1 -1
- package/out/{uprn/index.d.ts → uprn.d.ts} +1 -1
- package/out/uprn.d.ts.map +1 -0
- package/out/{uprn/index.js → uprn.js} +1 -1
- package/out/uprn.js.map +1 -0
- package/out/weights-overlay-linker.d.ts +138 -144
- package/out/weights-overlay-linker.d.ts.map +1 -1
- package/out/weights-overlay-linker.js +105 -159
- package/out/weights-overlay-linker.js.map +1 -1
- package/package.json +91 -596
- package/lib/address/point/index.ts +0 -328
- package/lib/convention/index.ts +0 -154
- package/lib/fts/index.ts +0 -361
- package/out/address/index.d.ts.map +0 -1
- package/out/address/index.js.map +0 -1
- package/out/address/point/index.d.ts +0 -53
- package/out/address/point/index.d.ts.map +0 -1
- package/out/address/point/index.js +0 -222
- package/out/address/point/index.js.map +0 -1
- package/out/ancestry/index.d.ts +0 -45
- package/out/ancestry/index.d.ts.map +0 -1
- package/out/ancestry/index.js +0 -55
- package/out/ancestry/index.js.map +0 -1
- package/out/convention/index.d.ts +0 -106
- package/out/convention/index.d.ts.map +0 -1
- package/out/convention/index.js +0 -93
- package/out/convention/index.js.map +0 -1
- package/out/fst/index.d.ts.map +0 -1
- package/out/fst/index.js.map +0 -1
- package/out/fts/index.d.ts +0 -184
- package/out/fts/index.d.ts.map +0 -1
- package/out/fts/index.js +0 -277
- package/out/fts/index.js.map +0 -1
- package/out/geonames/index.d.ts.map +0 -1
- package/out/geonames/index.js.map +0 -1
- package/out/nsul/index.d.ts.map +0 -1
- package/out/nsul/index.js.map +0 -1
- package/out/poi/index.d.ts.map +0 -1
- package/out/poi/index.js.map +0 -1
- package/out/postal/index.d.ts.map +0 -1
- package/out/postal/index.js.map +0 -1
- package/out/street/centroid/index.d.ts +0 -40
- package/out/street/centroid/index.d.ts.map +0 -1
- package/out/street/centroid/index.js.map +0 -1
- package/out/street/index.d.ts.map +0 -1
- package/out/street/index.js.map +0 -1
- package/out/uprn/index.d.ts.map +0 -1
- package/out/uprn/index.js.map +0 -1
- /package/lib/{geonames/index.ts → geonames.ts} +0 -0
- /package/lib/{nsul/index.ts → nsul.ts} +0 -0
- /package/lib/{poi/index.ts → poi.ts} +0 -0
- /package/lib/{postal/index.ts → postal.ts} +0 -0
- /package/lib/{uprn/index.ts → uprn.ts} +0 -0
package/out/fst/format.js
CHANGED
|
@@ -4,22 +4,29 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
6
|
* The FST binary-format constants, shared by the Node serializer/deserializer (`fst-serialize.ts`)
|
|
7
|
-
* and the browser deserializer (`fst-deserialize-web.ts`).
|
|
8
|
-
* module scope
|
|
7
|
+
* and the browser deserializer (`fst-deserialize-web.ts`). This module stays platform-free.
|
|
8
|
+
* It uses no Buffer at module scope. Both runtimes convert {@link FST_MAGIC_BYTES} themselves.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Format version this tree
|
|
12
|
-
* an older artifact format-stale without re-typing the number
|
|
13
|
-
* see `fst-freshness.ts`).
|
|
11
|
+
* Format version this tree writes and the maximum either deserializer accepts, published
|
|
12
|
+
* so a freshness guard can call an older artifact format-stale without re-typing the number
|
|
13
|
+
* (mirrors `REQUIRED_PAIR_INDEX_SCHEMA`'s role for PIX1 — see `fst-freshness.ts`).
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* One constant for the writer and both readers, deliberately.
|
|
16
|
+
* The browser reader once kept a separate `MAX_VERSION` from the layout branches.
|
|
17
|
+
*
|
|
18
|
+
* It drifted twice.
|
|
19
|
+
* It stayed at 2 after the v4 wide-state layout shipped and rejected every real artifact.
|
|
20
|
+
*
|
|
21
|
+
* It later stayed at 4 through the v5 two-score split until someone updated it by hand.
|
|
22
|
+
*
|
|
23
|
+
* A check that is the writer's version cannot drift from it.
|
|
19
24
|
*/
|
|
20
25
|
export const FST_FORMAT_VERSION = 5;
|
|
21
26
|
/**
|
|
22
|
-
* Fixed header size in bytes
|
|
27
|
+
* Fixed header size in bytes.
|
|
28
|
+
*
|
|
29
|
+
* It stores the magic and version, followed by section offsets.
|
|
23
30
|
*/
|
|
24
31
|
export const HEADER_SIZE = 32;
|
|
25
32
|
/**
|
|
@@ -27,8 +34,10 @@ export const HEADER_SIZE = 32;
|
|
|
27
34
|
*/
|
|
28
35
|
export const EDGE_ENTRY_SIZE = 8;
|
|
29
36
|
/**
|
|
30
|
-
* Format version that widened the per-state edge and place counters from 16 to 32 bits,
|
|
31
|
-
*
|
|
37
|
+
* Format version that widened the per-state edge and place counters from 16 to 32 bits,
|
|
38
|
+
* growing the state entry from 12 to 16 bytes.
|
|
39
|
+
*
|
|
40
|
+
* Readers branch on it to stay backward-compatible with v2/v3 files.
|
|
32
41
|
*/
|
|
33
42
|
export const VERSION_WIDE_STATE_COUNTERS = 4;
|
|
34
43
|
/**
|
|
@@ -40,13 +49,14 @@ export const WIDE_STATE_ENTRY_SIZE = 16;
|
|
|
40
49
|
*/
|
|
41
50
|
export const NARROW_STATE_ENTRY_SIZE = 12;
|
|
42
51
|
/**
|
|
43
|
-
* First format version carrying the trailing metadata block
|
|
52
|
+
* First format version carrying the trailing metadata block.
|
|
53
|
+
* Older files simply have none.
|
|
44
54
|
*/
|
|
45
55
|
export const VERSION_WITH_METADATA = 3;
|
|
46
56
|
/**
|
|
47
|
-
* Format version that split the single `importance` float into `referential` +
|
|
48
|
-
* growing the place entry from 56 to 60 bytes
|
|
49
|
-
* {@link PLACE_FLAG_HAS_ENCYCLOPEDIC}.
|
|
57
|
+
* Format version that split the single `importance` float into `referential` +
|
|
58
|
+
* `encyclopedic` (ROAD_TO_V9 §2 R1), growing the place entry from 56 to 60 bytes
|
|
59
|
+
* and claiming the previously-reserved `pp+7` byte as {@link PLACE_FLAG_HAS_ENCYCLOPEDIC}.
|
|
50
60
|
*/
|
|
51
61
|
export const VERSION_TWO_SCORE_SPLIT = 5;
|
|
52
62
|
/**
|
|
@@ -58,22 +68,30 @@ export const SPLIT_PLACE_ENTRY_SIZE = 60;
|
|
|
58
68
|
*/
|
|
59
69
|
export const LEGACY_PLACE_ENTRY_SIZE = 56;
|
|
60
70
|
/**
|
|
61
|
-
* Byte offset of the encyclopedic float inside a v5 place entry — immediately
|
|
71
|
+
* Byte offset of the encyclopedic float inside a v5 place entry — immediately
|
|
72
|
+
* after the 8-slot parent chain.
|
|
62
73
|
*/
|
|
63
74
|
export const ENCYCLOPEDIC_OFFSET = 56;
|
|
64
75
|
/**
|
|
65
|
-
* `placeFlags` bit 0 (byte `pp+7`, v5+): this place
|
|
66
|
-
*
|
|
67
|
-
*
|
|
76
|
+
* `placeFlags` bit 0 (byte `pp+7`, v5+): this place has an encyclopedic score.
|
|
77
|
+
*
|
|
78
|
+
* Per-place rather than per-file because absence is the common case — roughly 89% of
|
|
79
|
+
* the 2026-08-05 gazetteer has no Wikipedia article — and a file-level flag would
|
|
80
|
+
* force every one of those rows to claim a 0 it never had.
|
|
68
81
|
*/
|
|
69
82
|
export const PLACE_FLAG_HAS_ENCYCLOPEDIC = 1;
|
|
70
83
|
/**
|
|
71
|
-
* File magic, "FST\0" as bytes.
|
|
84
|
+
* File magic, "FST\0" as bytes.
|
|
85
|
+
*
|
|
86
|
+
* A reader rejects anything not starting with these four bytes before parsing further.
|
|
72
87
|
*/
|
|
73
88
|
export const FST_MAGIC_BYTES = [0x46, 0x53, 0x54, 0x00];
|
|
74
89
|
/**
|
|
75
|
-
* Placetypes in hierarchy order, largest first.
|
|
76
|
-
*
|
|
90
|
+
* Placetypes in hierarchy order, largest first.
|
|
91
|
+
*
|
|
92
|
+
* The writer stores each placetype's index in a place entry.
|
|
93
|
+
* A different array order invalidates every existing file.
|
|
94
|
+
* Append entries and bump the version.
|
|
77
95
|
*/
|
|
78
96
|
export const PLACETYPE_ORDER = [
|
|
79
97
|
"country",
|
package/out/fst/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../lib/fst/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../lib/fst/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAA;AAE7B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAA;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAErC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE1E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,SAAS;IACT,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,cAAc;CACd,CAAA"}
|
package/out/fst/freshness.d.ts
CHANGED
|
@@ -3,43 +3,17 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* WHY THIS EXISTS. Every FST artifact is a projection of one WOF admin database, and the admin
|
|
9
|
-
* database is a sealed readonly artifact that a rebuild REPLACES. Nothing mechanically tied the two
|
|
10
|
-
* together: the 2026-08-04 admin swap (4.87M rows, ancestry repaired, macrohood/microhood ingested)
|
|
11
|
-
* left `fst-global-priority.bin` at its 2026-05-28 build and the per-locale set at 2026-07-26, and
|
|
12
|
-
* the only way to notice was to compare mtimes by hand. The artifacts kept loading, kept answering
|
|
13
|
-
* queries, and answered them from a gazetteer that no longer exists.
|
|
14
|
-
*
|
|
15
|
-
* `FSTProvenance` already recorded `sourceDB` — the source's PATH, which is exactly the field that
|
|
16
|
-
* cannot change when the bytes behind it do. So the stamp gains the source's IDENTITY (md5 + byte
|
|
17
|
-
* size) and this module compares it. The shape deliberately mirrors
|
|
18
|
-
* `@mailwoman/resolver-wof-sqlite/weights-overlay-linker`'s `pairIndexStaleReason`: one function returning a reason
|
|
19
|
-
* string or `undefined`, so a fact added to the stamp cannot be checked by some callers and not
|
|
20
|
-
* others — which is how three of the four base linkers ended up unable to notice a PIX1 schema bump.
|
|
21
|
-
*
|
|
22
|
-
* FORMAT IS PART OF FRESHNESS. The check compares the serializer version too, not just the source
|
|
23
|
-
* md5. A guard that checks only the source reads a format-obsolete binary as "current" (the R5
|
|
24
|
-
* freshness-guard lesson, format edition), and a file below {@link MIN_STAMPED_FORMAT_VERSION}
|
|
25
|
-
* cannot carry a stamp at all — reported as its own reason rather than silently passing.
|
|
26
|
-
*
|
|
27
|
-
* STALE IS A WARNING, NOT A FAULT. A dev tree with an old FST must still run; the artifact is a
|
|
28
|
-
* decode-time bias list, not a correctness dependency. Callers print {@link formatFSTStaleWarning}
|
|
29
|
-
* and continue.
|
|
6
|
+
* Does an `fst-*.bin` still match the gazetteer it was built from?
|
|
30
7
|
*/
|
|
31
8
|
import { type PathBuilderLike } from "path-ts";
|
|
32
9
|
import type { FSTProvenance } from "#fst/types";
|
|
33
10
|
/**
|
|
34
|
-
* First serializer version carrying the trailing provenance block.
|
|
35
|
-
*
|
|
11
|
+
* First serializer version carrying the trailing provenance block. below it
|
|
12
|
+
* a file has no place to put a stamp.
|
|
36
13
|
*/
|
|
37
14
|
export declare const MIN_STAMPED_FORMAT_VERSION = 3;
|
|
38
15
|
/**
|
|
39
16
|
* What an FST was built from, recorded so a later reader can tell whether that thing still exists.
|
|
40
|
-
*
|
|
41
|
-
* `bytes` is not redundant with `md5` — it is the field that survives a truncated or half-written source and makes the
|
|
42
|
-
* mismatch legible in the warning ("5,273,722,880 → 5,372,076,032" names the rebuild; a hex delta does not).
|
|
43
17
|
*/
|
|
44
18
|
export interface FSTSourceIdentity {
|
|
45
19
|
md5: string;
|
|
@@ -47,87 +21,51 @@ export interface FSTSourceIdentity {
|
|
|
47
21
|
}
|
|
48
22
|
/**
|
|
49
23
|
* The stamp fields a freshness guard reads off an artifact, plus the format version it was written at.
|
|
50
|
-
*
|
|
51
|
-
* Every field is optional because every one of them can be legitimately absent on an artifact that predates it, and the
|
|
52
|
-
* meaning-of-zero rule applies to all of them: absent is a distinct state from "matches", and the reasons below say so
|
|
53
|
-
* in different words.
|
|
54
24
|
*/
|
|
55
25
|
export interface FSTStampFields {
|
|
56
26
|
formatVersion: number;
|
|
57
|
-
provenance: FSTProvenance |
|
|
27
|
+
provenance: FSTProvenance | null;
|
|
58
28
|
}
|
|
59
29
|
/**
|
|
60
30
|
* What a caller expects the artifact to have been built from.
|
|
61
|
-
*
|
|
62
|
-
* `exclusionPolicy` is optional and caller-supplied on purpose. The policy id lives in
|
|
63
|
-
* `mailwoman/gazetteer-pipeline/fst.ts` (which depends on this package, not the other way round), so only the caller
|
|
64
|
-
* knows which policy it means — the same split as the pair-index guard, where the format+magnitude half is shared and
|
|
65
|
-
* the source-md5 half stays with the script that knows its sources.
|
|
66
31
|
*/
|
|
67
32
|
export interface FSTExpectation {
|
|
68
33
|
source: FSTSourceIdentity;
|
|
69
34
|
/**
|
|
70
|
-
* Serializer version to require
|
|
71
|
-
* cannot forget the format half of the comparison. Override only to check against a specific older floor.
|
|
35
|
+
* Serializer version to require, defaulting to {@link FST_FORMAT_VERSION}.
|
|
72
36
|
*/
|
|
73
|
-
formatVersion?: number;
|
|
74
|
-
exclusionPolicy?: string;
|
|
37
|
+
formatVersion?: number | null;
|
|
38
|
+
exclusionPolicy?: string | null;
|
|
75
39
|
}
|
|
76
40
|
/**
|
|
77
|
-
* Read an artifact's stamp
|
|
78
|
-
* kilobytes. The distinction matters: `fst-global-priority.bin` is 317 MB and this runs on every `yarn test` via the
|
|
79
|
-
* weights linkers, so `readFileSync` + `readFSTProvenance` would trade a freshness guard for a slower test suite and
|
|
80
|
-
* nobody would keep it.
|
|
81
|
-
*
|
|
82
|
-
* Returns `undefined` for a file that is absent, too small, or not an FST at all — none of which is this function's
|
|
83
|
-
* business to diagnose.
|
|
84
|
-
*/
|
|
85
|
-
export declare function peekFSTStampFields(path: string): Promise<FSTStampFields | undefined>;
|
|
86
|
-
/**
|
|
87
|
-
* Re-exported from `@mailwoman/core/hash`. This package's own test imports it from here, and the sidecar convention
|
|
88
|
-
* below is what it is for.
|
|
41
|
+
* Read an artifact's stamp without deserializing it.
|
|
89
42
|
*/
|
|
43
|
+
export declare function peekFSTStampFields(path: PathBuilderLike): Promise<FSTStampFields | null>;
|
|
90
44
|
/**
|
|
91
45
|
* The source identity an FST build should stamp, or a check should compare against.
|
|
92
|
-
*
|
|
93
|
-
* Uses the `.md5` sidecar convention the weights linkers already established on this exact file: `<path>.md5` in
|
|
94
|
-
* md5sum(1) format (`<hash> <filename>`), trusted only while its mtime is at least the source's. An older sidecar is
|
|
95
|
-
* recomputed. Without it the admin DB costs 7.3 s per call and the guard would be quietly disabled by whoever noticed
|
|
96
|
-
* `yarn test` got slower.
|
|
97
|
-
*
|
|
98
|
-
* `refreshSidecar` writes the recomputed digest back. Best-effort: a sealed data root or a read-only mount fails the
|
|
99
|
-
* write and the caller still gets its answer, because refusing to check freshness on a read-only tree would be the
|
|
100
|
-
* wrong trade.
|
|
101
46
|
*/
|
|
102
47
|
export declare function readWOFSourceIdentity(source: PathBuilderLike, { refreshSidecar }?: {
|
|
103
48
|
refreshSidecar?: boolean | undefined;
|
|
104
49
|
}): Promise<FSTSourceIdentity>;
|
|
105
50
|
/**
|
|
106
|
-
* Why an FST artifact is stale against `expected`, or `
|
|
107
|
-
*
|
|
108
|
-
* The order is deliberate: FORMAT first (a version-obsolete file is stale whatever its source says), then the presence
|
|
109
|
-
* of a stamp, then the source identity, then the build policy. Each returns prose a reader can act on — the reasons are
|
|
110
|
-
* printed verbatim into {@link formatFSTStaleWarning}.
|
|
51
|
+
* Why an FST artifact is stale against `expected`, or `null` when it still matches.
|
|
111
52
|
*/
|
|
112
|
-
export declare function fstStaleReason(fields: FSTStampFields |
|
|
53
|
+
export declare function fstStaleReason(fields: FSTStampFields | null, expected: FSTExpectation): string | null;
|
|
113
54
|
/**
|
|
114
|
-
* The whole check, for a caller
|
|
115
|
-
*
|
|
116
|
-
* Returns `undefined` when the artifact is current OR when it is absent — an absent artifact is a different problem
|
|
117
|
-
* with a different message, and every existing caller already reports it in place.
|
|
55
|
+
* The whole check, for a caller with a path and a source DB that wants a warning string or none.
|
|
118
56
|
*/
|
|
119
57
|
export declare function fstFreshnessWarning({ fstPath, sourceDBPath, formatVersion, exclusionPolicy, rebuildCommand, }: {
|
|
120
|
-
fstPath:
|
|
121
|
-
sourceDBPath:
|
|
122
|
-
formatVersion?: number;
|
|
123
|
-
exclusionPolicy?: string;
|
|
58
|
+
fstPath: PathBuilderLike;
|
|
59
|
+
sourceDBPath: PathBuilderLike;
|
|
60
|
+
formatVersion?: number | null;
|
|
61
|
+
exclusionPolicy?: string | null;
|
|
124
62
|
rebuildCommand: string;
|
|
125
|
-
}): Promise<string |
|
|
63
|
+
}): Promise<string | null>;
|
|
126
64
|
/**
|
|
127
|
-
* The one warning format, so `grep -r "FST
|
|
65
|
+
* The one warning format, so `grep -r "FST stale"` finds every site that emits one.
|
|
128
66
|
*/
|
|
129
67
|
export declare function formatFSTStaleWarning({ fstPath, reason, rebuildCommand, }: {
|
|
130
|
-
fstPath:
|
|
68
|
+
fstPath: PathBuilderLike;
|
|
131
69
|
reason: string;
|
|
132
70
|
rebuildCommand: string;
|
|
133
71
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../../lib/fst/freshness.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../../lib/fst/freshness.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAc/C;;;GAGG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAI3C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,aAAa,GAAG,IAAI,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,iBAAiB,CAAA;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAwB9F;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAC1C,MAAM,EAAE,eAAe,EACvB,EAAE,cAAqB,EAAE;;CAAK,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAsC5B;AAID;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAiCrG;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,EACzC,OAAO,EACP,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,GACd,EAAE;IACF,OAAO,EAAE,eAAe,CAAA;IACxB,YAAY,EAAE,eAAe,CAAA;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;CACtB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUzB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EACrC,OAAO,EACP,MAAM,EACN,cAAc,GACd,EAAE;IACF,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACtB,GAAG,MAAM,CAET"}
|
package/out/fst/freshness.js
CHANGED
|
@@ -3,107 +3,58 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* WHY THIS EXISTS. Every FST artifact is a projection of one WOF admin database, and the admin
|
|
9
|
-
* database is a sealed readonly artifact that a rebuild REPLACES. Nothing mechanically tied the two
|
|
10
|
-
* together: the 2026-08-04 admin swap (4.87M rows, ancestry repaired, macrohood/microhood ingested)
|
|
11
|
-
* left `fst-global-priority.bin` at its 2026-05-28 build and the per-locale set at 2026-07-26, and
|
|
12
|
-
* the only way to notice was to compare mtimes by hand. The artifacts kept loading, kept answering
|
|
13
|
-
* queries, and answered them from a gazetteer that no longer exists.
|
|
14
|
-
*
|
|
15
|
-
* `FSTProvenance` already recorded `sourceDB` — the source's PATH, which is exactly the field that
|
|
16
|
-
* cannot change when the bytes behind it do. So the stamp gains the source's IDENTITY (md5 + byte
|
|
17
|
-
* size) and this module compares it. The shape deliberately mirrors
|
|
18
|
-
* `@mailwoman/resolver-wof-sqlite/weights-overlay-linker`'s `pairIndexStaleReason`: one function returning a reason
|
|
19
|
-
* string or `undefined`, so a fact added to the stamp cannot be checked by some callers and not
|
|
20
|
-
* others — which is how three of the four base linkers ended up unable to notice a PIX1 schema bump.
|
|
21
|
-
*
|
|
22
|
-
* FORMAT IS PART OF FRESHNESS. The check compares the serializer version too, not just the source
|
|
23
|
-
* md5. A guard that checks only the source reads a format-obsolete binary as "current" (the R5
|
|
24
|
-
* freshness-guard lesson, format edition), and a file below {@link MIN_STAMPED_FORMAT_VERSION}
|
|
25
|
-
* cannot carry a stamp at all — reported as its own reason rather than silently passing.
|
|
26
|
-
*
|
|
27
|
-
* STALE IS A WARNING, NOT A FAULT. A dev tree with an old FST must still run; the artifact is a
|
|
28
|
-
* decode-time bias list, not a correctness dependency. Callers print {@link formatFSTStaleWarning}
|
|
29
|
-
* and continue.
|
|
6
|
+
* Does an `fst-*.bin` still match the gazetteer it was built from?
|
|
30
7
|
*/
|
|
31
|
-
import {
|
|
8
|
+
import { readFileRange, readLocalTextFile } from "@mailwoman/core/fs/readers";
|
|
9
|
+
import { pathExists, statPath } from "@mailwoman/core/fs/readers/stat";
|
|
32
10
|
import { writeLocalTextFile } from "@mailwoman/core/fs/writers";
|
|
33
11
|
import { md5File } from "@mailwoman/core/hash";
|
|
34
12
|
import { tryParsingJSON } from "@mailwoman/core/json";
|
|
35
13
|
import { basename, resolvePath } from "path-ts";
|
|
36
|
-
import { FST_FORMAT_VERSION } from "#fst/
|
|
14
|
+
import { FST_FORMAT_VERSION } from "#fst/format";
|
|
37
15
|
/**
|
|
38
|
-
* Fixed header size in bytes
|
|
39
|
-
* because this module reads the header by SEEK (never buffering the file), and the serializer's constant is private to
|
|
40
|
-
* its own read/write pair.
|
|
16
|
+
* Fixed header size in bytes, mirroring `fst-serialize.ts`'s private `HEADER_SIZE`.
|
|
41
17
|
*/
|
|
42
18
|
const HEADER_SIZE = 32;
|
|
43
19
|
/**
|
|
44
|
-
* `"FST\0"` little-endian, the four
|
|
20
|
+
* `"FST\0"` little-endian, the four bytes every artifact opens with.
|
|
45
21
|
*/
|
|
46
22
|
const MAGIC = 0x00_54_53_46;
|
|
47
|
-
/**
|
|
48
|
-
* Byte offset of the u32 trailer offset inside the header (the last of its eight fields).
|
|
49
|
-
*/
|
|
50
23
|
const PROVENANCE_OFFSET_FIELD = 28;
|
|
51
24
|
/**
|
|
52
|
-
* First serializer version carrying the trailing provenance block.
|
|
53
|
-
*
|
|
25
|
+
* First serializer version carrying the trailing provenance block. below it
|
|
26
|
+
* a file has no place to put a stamp.
|
|
54
27
|
*/
|
|
55
28
|
export const MIN_STAMPED_FORMAT_VERSION = 3;
|
|
56
|
-
/**
|
|
57
|
-
* Hex characters in an md5 digest.
|
|
58
|
-
*/
|
|
59
29
|
const MD5_HEX_LENGTH = 32;
|
|
60
30
|
/**
|
|
61
|
-
* Read an artifact's stamp
|
|
62
|
-
* kilobytes. The distinction matters: `fst-global-priority.bin` is 317 MB and this runs on every `yarn test` via the
|
|
63
|
-
* weights linkers, so `readFileSync` + `readFSTProvenance` would trade a freshness guard for a slower test suite and
|
|
64
|
-
* nobody would keep it.
|
|
65
|
-
*
|
|
66
|
-
* Returns `undefined` for a file that is absent, too small, or not an FST at all — none of which is this function's
|
|
67
|
-
* business to diagnose.
|
|
31
|
+
* Read an artifact's stamp without deserializing it.
|
|
68
32
|
*/
|
|
69
33
|
export async function peekFSTStampFields(path) {
|
|
70
34
|
if (!(await pathExists(path)))
|
|
71
|
-
return
|
|
35
|
+
return null;
|
|
72
36
|
const size = (await statPath(path)).size;
|
|
73
37
|
if (size < HEADER_SIZE)
|
|
74
|
-
return
|
|
38
|
+
return null;
|
|
75
39
|
const header = await readFileRange(path, 0, HEADER_SIZE);
|
|
76
40
|
if (header.readUInt32LE(0) !== MAGIC)
|
|
77
|
-
return
|
|
41
|
+
return null;
|
|
78
42
|
const formatVersion = header.readUInt16LE(4);
|
|
79
43
|
if (formatVersion < MIN_STAMPED_FORMAT_VERSION)
|
|
80
|
-
return { formatVersion, provenance:
|
|
44
|
+
return { formatVersion, provenance: null };
|
|
81
45
|
const trailerStart = header.readUInt32LE(PROVENANCE_OFFSET_FIELD);
|
|
82
|
-
// 0
|
|
83
|
-
//
|
|
46
|
+
// 0 means this build wrote no trailer and past-EOF means truncated.
|
|
47
|
+
// Both read as no stamp.
|
|
84
48
|
if (trailerStart === 0 || trailerStart + 4 > size)
|
|
85
|
-
return { formatVersion, provenance:
|
|
49
|
+
return { formatVersion, provenance: null };
|
|
86
50
|
const jsonLength = (await readFileRange(path, trailerStart, 4)).readUInt32LE(0);
|
|
87
51
|
if (jsonLength === 0 || trailerStart + 4 + jsonLength > size)
|
|
88
|
-
return { formatVersion, provenance:
|
|
52
|
+
return { formatVersion, provenance: null };
|
|
89
53
|
const json = await readFileRange(path, trailerStart + 4, jsonLength);
|
|
90
|
-
return { formatVersion, provenance: tryParsingJSON(json.toString("utf8")) ??
|
|
54
|
+
return { formatVersion, provenance: tryParsingJSON(json.toString("utf8")) ?? null };
|
|
91
55
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Re-exported from `@mailwoman/core/hash`. This package's own test imports it from here, and the sidecar convention
|
|
94
|
-
* below is what it is for.
|
|
95
|
-
*/
|
|
96
56
|
/**
|
|
97
57
|
* The source identity an FST build should stamp, or a check should compare against.
|
|
98
|
-
*
|
|
99
|
-
* Uses the `.md5` sidecar convention the weights linkers already established on this exact file: `<path>.md5` in
|
|
100
|
-
* md5sum(1) format (`<hash> <filename>`), trusted only while its mtime is at least the source's. An older sidecar is
|
|
101
|
-
* recomputed. Without it the admin DB costs 7.3 s per call and the guard would be quietly disabled by whoever noticed
|
|
102
|
-
* `yarn test` got slower.
|
|
103
|
-
*
|
|
104
|
-
* `refreshSidecar` writes the recomputed digest back. Best-effort: a sealed data root or a read-only mount fails the
|
|
105
|
-
* write and the caller still gets its answer, because refusing to check freshness on a read-only tree would be the
|
|
106
|
-
* wrong trade.
|
|
107
58
|
*/
|
|
108
59
|
export async function readWOFSourceIdentity(source, { refreshSidecar = true } = {}) {
|
|
109
60
|
const path = resolvePath(source);
|
|
@@ -113,7 +64,7 @@ export async function readWOFSourceIdentity(source, { refreshSidecar = true } =
|
|
|
113
64
|
if (hit)
|
|
114
65
|
return hit;
|
|
115
66
|
const sidecarPath = `${path}.md5`;
|
|
116
|
-
let md5;
|
|
67
|
+
let md5 = null;
|
|
117
68
|
if (await pathExists(sidecarPath)) {
|
|
118
69
|
const sidecarStats = await statPath(sidecarPath);
|
|
119
70
|
if (sidecarStats.mtimeMs >= stats.mtimeMs) {
|
|
@@ -130,7 +81,7 @@ export async function readWOFSourceIdentity(source, { refreshSidecar = true } =
|
|
|
130
81
|
await writeLocalTextFile(`${md5} ${basename(path)}\n`, sidecarPath);
|
|
131
82
|
}
|
|
132
83
|
catch {
|
|
133
|
-
// Read-only data root
|
|
84
|
+
// Read-only data root: the digest is still correct, only the cache write failed.
|
|
134
85
|
}
|
|
135
86
|
}
|
|
136
87
|
}
|
|
@@ -138,18 +89,9 @@ export async function readWOFSourceIdentity(source, { refreshSidecar = true } =
|
|
|
138
89
|
sourceIdentityMemo.set(memoKey, identity);
|
|
139
90
|
return identity;
|
|
140
91
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Memo for {@link readWOFSourceIdentity}, keyed on (path, mtimeMs, size) — NOT on path alone, for the same reason
|
|
143
|
-
* `computeSurfaceCountryCounts` isn't: the admin DB is a sealed artifact that a rebuild REPLACES, so a path-only memo
|
|
144
|
-
* would serve a stale digest against a new file for the life of the process.
|
|
145
|
-
*/
|
|
146
92
|
const sourceIdentityMemo = new Map();
|
|
147
93
|
/**
|
|
148
|
-
* Why an FST artifact is stale against `expected`, or `
|
|
149
|
-
*
|
|
150
|
-
* The order is deliberate: FORMAT first (a version-obsolete file is stale whatever its source says), then the presence
|
|
151
|
-
* of a stamp, then the source identity, then the build policy. Each returns prose a reader can act on — the reasons are
|
|
152
|
-
* printed verbatim into {@link formatFSTStaleWarning}.
|
|
94
|
+
* Why an FST artifact is stale against `expected`, or `null` when it still matches.
|
|
153
95
|
*/
|
|
154
96
|
export function fstStaleReason(fields, expected) {
|
|
155
97
|
if (!fields)
|
|
@@ -170,36 +112,31 @@ export function fstStaleReason(fields, expected) {
|
|
|
170
112
|
if (provenance.sourceDBMD5 !== expected.source.md5) {
|
|
171
113
|
return `source db ${provenance.sourceDBMD5.slice(0, 8)} → ${expected.source.md5.slice(0, 8)} (built ${provenance.builtAt})`;
|
|
172
114
|
}
|
|
173
|
-
|
|
174
|
-
// against a different file than it was hashed from. Cheap to check, and it never fires by accident.
|
|
175
|
-
if (provenance.sourceDBBytes !== undefined && provenance.sourceDBBytes !== expected.source.bytes) {
|
|
115
|
+
if (provenance.sourceDBBytes != null && provenance.sourceDBBytes !== expected.source.bytes) {
|
|
176
116
|
return `source db size ${provenance.sourceDBBytes} → ${expected.source.bytes} at a matching md5 — one of the two is misrecorded`;
|
|
177
117
|
}
|
|
178
|
-
if (expected.exclusionPolicy
|
|
118
|
+
if (expected.exclusionPolicy && provenance.exclusionPolicy !== expected.exclusionPolicy) {
|
|
179
119
|
return `exclusion policy ${provenance.exclusionPolicy ?? "(none)"} → ${expected.exclusionPolicy}`;
|
|
180
120
|
}
|
|
181
|
-
return
|
|
121
|
+
return null;
|
|
182
122
|
}
|
|
183
123
|
/**
|
|
184
|
-
* The whole check, for a caller
|
|
185
|
-
*
|
|
186
|
-
* Returns `undefined` when the artifact is current OR when it is absent — an absent artifact is a different problem
|
|
187
|
-
* with a different message, and every existing caller already reports it in place.
|
|
124
|
+
* The whole check, for a caller with a path and a source DB that wants a warning string or none.
|
|
188
125
|
*/
|
|
189
126
|
export async function fstFreshnessWarning({ fstPath, sourceDBPath, formatVersion, exclusionPolicy, rebuildCommand, }) {
|
|
190
127
|
if (!(await pathExists(fstPath)) || !(await pathExists(sourceDBPath)))
|
|
191
|
-
return
|
|
128
|
+
return null;
|
|
192
129
|
const reason = fstStaleReason(await peekFSTStampFields(fstPath), {
|
|
193
130
|
source: await readWOFSourceIdentity(sourceDBPath),
|
|
194
|
-
|
|
195
|
-
|
|
131
|
+
formatVersion: formatVersion ?? null,
|
|
132
|
+
exclusionPolicy: exclusionPolicy ?? null,
|
|
196
133
|
});
|
|
197
|
-
return reason
|
|
134
|
+
return reason ? formatFSTStaleWarning({ fstPath, reason, rebuildCommand }) : null;
|
|
198
135
|
}
|
|
199
136
|
/**
|
|
200
|
-
* The one warning format, so `grep -r "FST
|
|
137
|
+
* The one warning format, so `grep -r "FST stale"` finds every site that emits one.
|
|
201
138
|
*/
|
|
202
139
|
export function formatFSTStaleWarning({ fstPath, reason, rebuildCommand, }) {
|
|
203
|
-
return `WARNING: FST STALE — ${fstPath}: ${reason}. Rebuild with: ${rebuildCommand}`;
|
|
140
|
+
return `WARNING: FST STALE — ${fstPath.toString()}: ${reason}. Rebuild with: ${rebuildCommand}`;
|
|
204
141
|
}
|
|
205
142
|
//# sourceMappingURL=freshness.js.map
|
package/out/fst/freshness.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freshness.js","sourceRoot":"","sources":["../../lib/fst/freshness.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"freshness.js","sourceRoot":"","sources":["../../lib/fst/freshness.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BA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,aAAa,EACb,eAAe,EACf,cAAc,GAOd;IACA,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,YAAY,CAAC,CAAC;QAAE,OAAO,IAAI,CAAA;IAElF,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,kBAAkB,CAAC,OAAO,CAAC,EAAE;QAChE,MAAM,EAAE,MAAM,qBAAqB,CAAC,YAAY,CAAC;QACjD,aAAa,EAAE,aAAa,IAAI,IAAI;QACpC,eAAe,EAAE,eAAe,IAAI,IAAI;KACxC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAClF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACrC,OAAO,EACP,MAAM,EACN,cAAc,GAKd;IACA,OAAO,wBAAwB,OAAO,CAAC,QAAQ,EAAE,KAAK,MAAM,mBAAmB,cAAc,EAAE,CAAA;AAChG,CAAC"}
|
package/out/fst/matcher.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* introspection. The structure is a deterministic trie over normalized tokens with PlaceEntry
|
|
8
8
|
* arrays at accepting states.
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
10
|
+
import type { AncestrieMatch } from "@mailwoman/ancestrie";
|
|
11
|
+
import type { FSTContinuation, FSTQueryResult, PlaceEntry } from "#fst/types";
|
|
11
12
|
interface FSTNode {
|
|
12
13
|
edges: Map<string, number>;
|
|
13
14
|
places: PlaceEntry[];
|
|
@@ -17,8 +18,8 @@ export declare class FSTMatcher {
|
|
|
17
18
|
constructor(nodes: FSTNode[]);
|
|
18
19
|
get stateCount(): number;
|
|
19
20
|
get placeCount(): number;
|
|
20
|
-
walk(tokens: string[]):
|
|
21
|
-
walkFrom(prev:
|
|
21
|
+
walk(tokens: string[]): AncestrieMatch | null;
|
|
22
|
+
walkFrom(prev: AncestrieMatch, token: string): AncestrieMatch | null;
|
|
22
23
|
accepting(stateID: number): PlaceEntry[];
|
|
23
24
|
continuations(stateID: number): FSTContinuation[];
|
|
24
25
|
query(text: string): FSTQueryResult;
|
|
@@ -30,7 +31,7 @@ export declare class FSTMatcher {
|
|
|
30
31
|
static fromNodes(nodes: FSTNode[]): FSTMatcher;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
|
-
* Normalize text into FST tokens: lowercase,
|
|
34
|
+
* Normalize text into FST tokens: lowercase, nfkc, strip punctuation, split on whitespace.
|
|
34
35
|
*/
|
|
35
36
|
export declare function normalizeTokens(text: string): string[];
|
|
36
37
|
export type { FSTNode };
|
package/out/fst/matcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../../lib/fst/matcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../../lib/fst/matcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE7E,UAAU,OAAO;IAChB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1B,MAAM,EAAE,UAAU,EAAE,CAAA;CACpB;AAED,qBAAa,UAAU;IACtB,OAAO,CAAC,KAAK,CAAW;IAExB,YAAY,KAAK,EAAE,OAAO,EAAE,EAE3B;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,UAAU,IAAI,MAAM,CAQvB;IAED,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,GAAG,IAAI,CAgB5C;IAED,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAUnE;IAED,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE,CAEvC;IAED,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,CAiBhD;IAED,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAmClC;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,OAAO,IAAI,SAAS,OAAO,EAAE,CAE5B;IAED,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,CAE7C;CACD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAOtD;AAED,YAAY,EAAE,OAAO,EAAE,CAAA"}
|
package/out/fst/matcher.js
CHANGED
|
@@ -109,7 +109,7 @@ export class FSTMatcher {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
-
* Normalize text into FST tokens: lowercase,
|
|
112
|
+
* Normalize text into FST tokens: lowercase, nfkc, strip punctuation, split on whitespace.
|
|
113
113
|
*/
|
|
114
114
|
export function normalizeTokens(text) {
|
|
115
115
|
return text
|
|
@@ -117,6 +117,6 @@ export function normalizeTokens(text) {
|
|
|
117
117
|
.toLowerCase()
|
|
118
118
|
.replaceAll(/[\p{P}\p{S}]/gu, "")
|
|
119
119
|
.split(/\s+/)
|
|
120
|
-
.filter((t) => t.length
|
|
120
|
+
.filter((t) => t.length);
|
|
121
121
|
}
|
|
122
122
|
//# sourceMappingURL=matcher.js.map
|
package/out/fst/matcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matcher.js","sourceRoot":"","sources":["../../lib/fst/matcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":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