@mailwoman/resolver-wof-sqlite 9.4.0 → 10.1.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.
Files changed (548) hide show
  1. package/README.md +8 -8
  2. package/lib/address/{point-interpolation.ts → point/interpolation.ts} +40 -38
  3. package/lib/address/point/schema.ts +132 -0
  4. package/lib/address/point.ts +68 -81
  5. package/lib/{address/index.ts → address.ts} +2 -2
  6. package/lib/ancestry/backfill.ts +24 -88
  7. package/lib/{ancestry/index.ts → ancestry.ts} +19 -15
  8. package/lib/build/candidate.ts +608 -0
  9. package/lib/build/population-corrections.ts +64 -0
  10. package/lib/build/slim.ts +338 -0
  11. package/lib/candidate/alias-bags.ts +74 -14
  12. package/lib/candidate/ancestors/schema.ts +211 -0
  13. package/lib/candidate/{ancestors-sidecar.ts → ancestors/sidecar.ts} +17 -24
  14. package/lib/candidate/country-display-names.ts +6 -20
  15. package/lib/candidate/extract-fold.ts +12 -57
  16. package/lib/candidate/fts.ts +28 -0
  17. package/lib/candidate/importance.ts +221 -0
  18. package/lib/candidate/lookup.ts +669 -0
  19. package/lib/candidate/name-roles.ts +16 -34
  20. package/lib/candidate/own-name.ts +34 -31
  21. package/lib/candidate/place-attrs.ts +20 -13
  22. package/lib/candidate/schema.ts +211 -0
  23. package/lib/candidate/scoring.ts +222 -0
  24. package/lib/capital-schema.ts +21 -17
  25. package/lib/capitals.ts +26 -24
  26. package/lib/coincident-roles.ts +74 -55
  27. package/lib/convention/schema.ts +13 -7
  28. package/lib/convention.ts +144 -0
  29. package/lib/coverage-manifest-schema.ts +34 -39
  30. package/lib/currency-backfill.ts +24 -69
  31. package/lib/env.ts +1 -1
  32. package/lib/exact-match.ts +31 -20
  33. package/lib/extracts.ts +96 -73
  34. package/lib/fst/autocomplete.ts +52 -35
  35. package/lib/fst/builder.ts +30 -36
  36. package/lib/fst/deserialize-web.ts +8 -9
  37. package/lib/fst/format.ts +41 -23
  38. package/lib/fst/freshness.ts +17 -95
  39. package/lib/fst/matcher.ts +2 -2
  40. package/lib/fst/serialize.ts +45 -60
  41. package/lib/fst/types.ts +71 -59
  42. package/lib/fts/query.ts +5 -36
  43. package/lib/fts.ts +280 -0
  44. package/lib/geonames/aliases.ts +72 -149
  45. package/lib/geonames/postal.ts +162 -77
  46. package/lib/index.ts +20 -27
  47. package/lib/interpolation.ts +43 -96
  48. package/lib/lookup.ts +137 -257
  49. package/lib/name-score.ts +9 -7
  50. package/lib/nsul/lookup.ts +36 -53
  51. package/lib/nsul/schema.ts +16 -43
  52. package/lib/paths.ts +159 -0
  53. package/lib/place-importance-schema.ts +57 -164
  54. package/lib/poi/lookup.ts +100 -109
  55. package/lib/poi/schema.ts +42 -26
  56. package/lib/polygon-schema.ts +10 -6
  57. package/lib/postal/city/alias/lookup.ts +79 -0
  58. package/lib/postal/{city-alias-schema.ts → city/alias/schema.ts} +14 -10
  59. package/lib/postal/{city-candidate-schema.ts → city/candidate-schema.ts} +26 -20
  60. package/lib/postal.ts +9 -0
  61. package/lib/postcode-point-lookup.ts +9 -19
  62. package/lib/primary-preference.ts +45 -125
  63. package/lib/proximity-rerank.ts +43 -32
  64. package/lib/ranking-weights.ts +98 -76
  65. package/lib/region-keys.ts +68 -40
  66. package/lib/reverse.ts +108 -72
  67. package/lib/schema.ts +74 -42
  68. package/lib/search-fetch.ts +90 -68
  69. package/lib/sqlite/convention-source.ts +57 -0
  70. package/lib/sqlite/utils.ts +79 -0
  71. package/lib/street/centroid/schema.ts +149 -0
  72. package/lib/street/centroid.ts +16 -25
  73. package/lib/street/{morphology-fst-builder.ts → morphology/fst/builder.ts} +56 -41
  74. package/lib/street/{morphology-fst-loader.ts → morphology/fst/loader.ts} +36 -29
  75. package/lib/street/name-lookup.ts +43 -35
  76. package/lib/street/normalize.ts +85 -216
  77. package/lib/street/segment-schema.ts +116 -43
  78. package/lib/{street/index.ts → street.ts} +3 -3
  79. package/lib/types.ts +94 -140
  80. package/lib/unified-schema.ts +29 -29
  81. package/lib/uprn/existence.ts +30 -19
  82. package/lib/uprn/lookup.ts +28 -67
  83. package/lib/uprn/schema.ts +18 -40
  84. package/lib/weights-overlay-linker.ts +204 -232
  85. package/out/address/point/interpolation.d.ts +45 -0
  86. package/out/address/point/interpolation.d.ts.map +1 -0
  87. package/out/address/{point-interpolation.js → point/interpolation.js} +38 -38
  88. package/out/address/point/interpolation.js.map +1 -0
  89. package/out/address/point/schema.d.ts +74 -0
  90. package/out/address/point/schema.d.ts.map +1 -0
  91. package/out/address/{point-schema.js → point/schema.js} +4 -20
  92. package/out/address/point/schema.js.map +1 -0
  93. package/out/address/point.d.ts +24 -21
  94. package/out/address/point.d.ts.map +1 -1
  95. package/out/address/point.js +60 -77
  96. package/out/address/point.js.map +1 -1
  97. package/out/{address/index.js → address.d.ts} +3 -3
  98. package/out/address.d.ts.map +1 -0
  99. package/out/{address/index.d.ts → address.js} +3 -3
  100. package/out/address.js.map +1 -0
  101. package/out/ancestry/backfill.d.ts +11 -64
  102. package/out/ancestry/backfill.d.ts.map +1 -1
  103. package/out/ancestry/backfill.js +18 -76
  104. package/out/ancestry/backfill.js.map +1 -1
  105. package/out/ancestry.d.ts +49 -0
  106. package/out/ancestry.d.ts.map +1 -0
  107. package/out/ancestry.js +59 -0
  108. package/out/ancestry.js.map +1 -0
  109. package/out/build/candidate.d.ts +170 -0
  110. package/out/build/candidate.d.ts.map +1 -0
  111. package/out/{build-candidate.js → build/candidate.js} +33 -102
  112. package/out/build/candidate.js.map +1 -0
  113. package/out/build/population-corrections.d.ts +52 -0
  114. package/out/build/population-corrections.d.ts.map +1 -0
  115. package/out/build/population-corrections.js +40 -0
  116. package/out/build/population-corrections.js.map +1 -0
  117. package/out/build/slim.d.ts +44 -0
  118. package/out/build/slim.d.ts.map +1 -0
  119. package/out/{build-slim.js → build/slim.js} +33 -94
  120. package/out/build/slim.js.map +1 -0
  121. package/out/candidate/alias-bags.d.ts +13 -5
  122. package/out/candidate/alias-bags.d.ts.map +1 -1
  123. package/out/candidate/alias-bags.js +55 -12
  124. package/out/candidate/alias-bags.js.map +1 -1
  125. package/out/candidate/ancestors/schema.d.ts +166 -0
  126. package/out/candidate/ancestors/schema.d.ts.map +1 -0
  127. package/out/candidate/ancestors/schema.js +131 -0
  128. package/out/candidate/ancestors/schema.js.map +1 -0
  129. package/out/candidate/ancestors/sidecar.d.ts +27 -0
  130. package/out/candidate/ancestors/sidecar.d.ts.map +1 -0
  131. package/out/candidate/{ancestors-sidecar.js → ancestors/sidecar.js} +17 -24
  132. package/out/candidate/ancestors/sidecar.js.map +1 -0
  133. package/out/candidate/country-display-names.d.ts +5 -15
  134. package/out/candidate/country-display-names.d.ts.map +1 -1
  135. package/out/candidate/country-display-names.js +6 -20
  136. package/out/candidate/country-display-names.js.map +1 -1
  137. package/out/candidate/extract-fold.d.ts +8 -16
  138. package/out/candidate/extract-fold.d.ts.map +1 -1
  139. package/out/candidate/extract-fold.js +6 -48
  140. package/out/candidate/extract-fold.js.map +1 -1
  141. package/out/candidate/fts.d.ts +19 -0
  142. package/out/candidate/fts.d.ts.map +1 -0
  143. package/out/candidate/fts.js +22 -0
  144. package/out/candidate/fts.js.map +1 -0
  145. package/out/candidate/importance.d.ts +127 -0
  146. package/out/candidate/importance.d.ts.map +1 -0
  147. package/out/candidate/importance.js +162 -0
  148. package/out/candidate/importance.js.map +1 -0
  149. package/out/candidate/lookup.d.ts +36 -0
  150. package/out/candidate/lookup.d.ts.map +1 -0
  151. package/out/candidate/lookup.js +456 -0
  152. package/out/candidate/lookup.js.map +1 -0
  153. package/out/candidate/name-roles.d.ts +10 -22
  154. package/out/candidate/name-roles.d.ts.map +1 -1
  155. package/out/candidate/name-roles.js +15 -33
  156. package/out/candidate/name-roles.js.map +1 -1
  157. package/out/candidate/own-name.d.ts +23 -25
  158. package/out/candidate/own-name.d.ts.map +1 -1
  159. package/out/candidate/own-name.js +34 -31
  160. package/out/candidate/own-name.js.map +1 -1
  161. package/out/candidate/place-attrs.d.ts +20 -13
  162. package/out/candidate/place-attrs.d.ts.map +1 -1
  163. package/out/candidate/place-attrs.js +4 -5
  164. package/out/candidate/place-attrs.js.map +1 -1
  165. package/out/candidate/schema.d.ts +120 -0
  166. package/out/candidate/schema.d.ts.map +1 -0
  167. package/out/{candidate-schema.js → candidate/schema.js} +11 -23
  168. package/out/candidate/schema.js.map +1 -0
  169. package/out/{candidate-scoring.d.ts → candidate/scoring.d.ts} +8 -9
  170. package/out/candidate/scoring.d.ts.map +1 -0
  171. package/out/candidate/scoring.js +157 -0
  172. package/out/candidate/scoring.js.map +1 -0
  173. package/out/capital-schema.d.ts +21 -17
  174. package/out/capital-schema.d.ts.map +1 -1
  175. package/out/capital-schema.js +17 -15
  176. package/out/capital-schema.js.map +1 -1
  177. package/out/capitals.d.ts +26 -24
  178. package/out/capitals.d.ts.map +1 -1
  179. package/out/capitals.js +23 -21
  180. package/out/capitals.js.map +1 -1
  181. package/out/coincident-roles.d.ts +60 -43
  182. package/out/coincident-roles.d.ts.map +1 -1
  183. package/out/coincident-roles.js +61 -50
  184. package/out/coincident-roles.js.map +1 -1
  185. package/out/convention/schema.d.ts +12 -6
  186. package/out/convention/schema.d.ts.map +1 -1
  187. package/out/convention/schema.js +6 -4
  188. package/out/convention/schema.js.map +1 -1
  189. package/out/convention.d.ts +97 -0
  190. package/out/convention.d.ts.map +1 -0
  191. package/out/convention.js +81 -0
  192. package/out/convention.js.map +1 -0
  193. package/out/coverage-manifest-schema.d.ts +33 -38
  194. package/out/coverage-manifest-schema.d.ts.map +1 -1
  195. package/out/coverage-manifest-schema.js +20 -29
  196. package/out/coverage-manifest-schema.js.map +1 -1
  197. package/out/currency-backfill.d.ts +13 -35
  198. package/out/currency-backfill.d.ts.map +1 -1
  199. package/out/currency-backfill.js +12 -39
  200. package/out/currency-backfill.js.map +1 -1
  201. package/out/env.d.ts +2 -2
  202. package/out/env.js +1 -1
  203. package/out/exact-match.d.ts +19 -10
  204. package/out/exact-match.d.ts.map +1 -1
  205. package/out/exact-match.js +31 -20
  206. package/out/exact-match.js.map +1 -1
  207. package/out/extracts.d.ts +65 -54
  208. package/out/extracts.d.ts.map +1 -1
  209. package/out/extracts.js +63 -55
  210. package/out/extracts.js.map +1 -1
  211. package/out/fst/autocomplete.d.ts +28 -20
  212. package/out/fst/autocomplete.d.ts.map +1 -1
  213. package/out/fst/autocomplete.js +38 -27
  214. package/out/fst/autocomplete.js.map +1 -1
  215. package/out/fst/builder.d.ts.map +1 -1
  216. package/out/fst/builder.js +30 -36
  217. package/out/fst/builder.js.map +1 -1
  218. package/out/fst/deserialize-web.d.ts +3 -3
  219. package/out/fst/deserialize-web.d.ts.map +1 -1
  220. package/out/fst/deserialize-web.js +8 -9
  221. package/out/fst/deserialize-web.js.map +1 -1
  222. package/out/fst/format.d.ts +41 -23
  223. package/out/fst/format.d.ts.map +1 -1
  224. package/out/fst/format.js +41 -23
  225. package/out/fst/format.js.map +1 -1
  226. package/out/fst/freshness.d.ts +11 -73
  227. package/out/fst/freshness.d.ts.map +1 -1
  228. package/out/fst/freshness.js +12 -76
  229. package/out/fst/freshness.js.map +1 -1
  230. package/out/fst/matcher.d.ts +1 -1
  231. package/out/fst/matcher.d.ts.map +1 -1
  232. package/out/fst/matcher.js +2 -2
  233. package/out/fst/matcher.js.map +1 -1
  234. package/out/fst/serialize.d.ts +30 -26
  235. package/out/fst/serialize.d.ts.map +1 -1
  236. package/out/fst/serialize.js +44 -58
  237. package/out/fst/serialize.js.map +1 -1
  238. package/out/fst/types.d.ts +71 -59
  239. package/out/fst/types.d.ts.map +1 -1
  240. package/out/fst/types.js +1 -4
  241. package/out/fst/types.js.map +1 -1
  242. package/out/{fst/index.js → fst.d.ts} +1 -1
  243. package/out/fst.d.ts.map +1 -0
  244. package/out/{fst/index.d.ts → fst.js} +1 -1
  245. package/out/fst.js.map +1 -0
  246. package/out/fts/query.d.ts +2 -27
  247. package/out/fts/query.d.ts.map +1 -1
  248. package/out/fts/query.js +5 -36
  249. package/out/fts/query.js.map +1 -1
  250. package/out/fts.d.ts +126 -0
  251. package/out/fts.d.ts.map +1 -0
  252. package/out/fts.js +188 -0
  253. package/out/fts.js.map +1 -0
  254. package/out/geonames/aliases.d.ts +26 -67
  255. package/out/geonames/aliases.d.ts.map +1 -1
  256. package/out/geonames/aliases.js +44 -121
  257. package/out/geonames/aliases.js.map +1 -1
  258. package/out/geonames/postal.d.ts +84 -50
  259. package/out/geonames/postal.d.ts.map +1 -1
  260. package/out/geonames/postal.js +115 -78
  261. package/out/geonames/postal.js.map +1 -1
  262. package/out/{geonames/index.js → geonames.d.ts} +1 -1
  263. package/out/geonames.d.ts.map +1 -0
  264. package/out/{geonames/index.d.ts → geonames.js} +1 -1
  265. package/out/geonames.js.map +1 -0
  266. package/out/index.d.ts +20 -21
  267. package/out/index.d.ts.map +1 -1
  268. package/out/index.js +14 -15
  269. package/out/index.js.map +1 -1
  270. package/out/interpolation.d.ts +15 -52
  271. package/out/interpolation.d.ts.map +1 -1
  272. package/out/interpolation.js +25 -68
  273. package/out/interpolation.js.map +1 -1
  274. package/out/lookup.d.ts +24 -53
  275. package/out/lookup.d.ts.map +1 -1
  276. package/out/lookup.js +117 -223
  277. package/out/lookup.js.map +1 -1
  278. package/out/name-score.d.ts +2 -2
  279. package/out/name-score.d.ts.map +1 -1
  280. package/out/name-score.js +9 -7
  281. package/out/name-score.js.map +1 -1
  282. package/out/nsul/lookup.d.ts +33 -34
  283. package/out/nsul/lookup.d.ts.map +1 -1
  284. package/out/nsul/lookup.js +26 -40
  285. package/out/nsul/lookup.js.map +1 -1
  286. package/out/nsul/schema.d.ts +16 -43
  287. package/out/nsul/schema.d.ts.map +1 -1
  288. package/out/nsul/schema.js +9 -35
  289. package/out/nsul/schema.js.map +1 -1
  290. package/out/{nsul/index.d.ts → nsul.d.ts} +1 -1
  291. package/out/nsul.d.ts.map +1 -0
  292. package/out/{nsul/index.js → nsul.js} +1 -1
  293. package/out/nsul.js.map +1 -0
  294. package/out/paths.d.ts +124 -0
  295. package/out/paths.d.ts.map +1 -0
  296. package/out/paths.js +104 -0
  297. package/out/paths.js.map +1 -0
  298. package/out/place-importance-schema.d.ts +49 -141
  299. package/out/place-importance-schema.d.ts.map +1 -1
  300. package/out/place-importance-schema.js +25 -140
  301. package/out/place-importance-schema.js.map +1 -1
  302. package/out/poi/lookup.d.ts +38 -42
  303. package/out/poi/lookup.d.ts.map +1 -1
  304. package/out/poi/lookup.js +67 -90
  305. package/out/poi/lookup.js.map +1 -1
  306. package/out/poi/schema.d.ts +41 -25
  307. package/out/poi/schema.d.ts.map +1 -1
  308. package/out/poi/schema.js +25 -17
  309. package/out/poi/schema.js.map +1 -1
  310. package/out/{poi/index.js → poi.d.ts} +1 -1
  311. package/out/poi.d.ts.map +1 -0
  312. package/out/{poi/index.d.ts → poi.js} +1 -1
  313. package/out/poi.js.map +1 -0
  314. package/out/polygon-schema.d.ts +10 -6
  315. package/out/polygon-schema.d.ts.map +1 -1
  316. package/out/polygon-schema.js +2 -2
  317. package/out/polygon-schema.js.map +1 -1
  318. package/out/postal/{city-alias-lookup.d.ts → city/alias/lookup.d.ts} +22 -25
  319. package/out/postal/city/alias/lookup.d.ts.map +1 -0
  320. package/out/postal/city/alias/lookup.js +49 -0
  321. package/out/postal/city/alias/lookup.js.map +1 -0
  322. package/out/postal/{city-alias-schema.d.ts → city/alias/schema.d.ts} +15 -11
  323. package/out/postal/city/alias/schema.d.ts.map +1 -0
  324. package/out/postal/{city-alias-schema.js → city/alias/schema.js} +11 -9
  325. package/out/postal/city/alias/schema.js.map +1 -0
  326. package/out/postal/city/candidate-schema.d.ts +72 -0
  327. package/out/postal/city/candidate-schema.d.ts.map +1 -0
  328. package/out/postal/city/candidate-schema.js +60 -0
  329. package/out/postal/city/candidate-schema.js.map +1 -0
  330. package/out/postal.d.ts +9 -0
  331. package/out/postal.d.ts.map +1 -0
  332. package/out/postal.js +9 -0
  333. package/out/postal.js.map +1 -0
  334. package/out/postcode-point-lookup.d.ts +9 -19
  335. package/out/postcode-point-lookup.d.ts.map +1 -1
  336. package/out/postcode-point-lookup.js +5 -17
  337. package/out/postcode-point-lookup.js.map +1 -1
  338. package/out/primary-preference.d.ts +39 -93
  339. package/out/primary-preference.d.ts.map +1 -1
  340. package/out/primary-preference.js +13 -97
  341. package/out/primary-preference.js.map +1 -1
  342. package/out/proximity-rerank.d.ts +40 -29
  343. package/out/proximity-rerank.d.ts.map +1 -1
  344. package/out/proximity-rerank.js +38 -29
  345. package/out/proximity-rerank.js.map +1 -1
  346. package/out/ranking-weights.d.ts +91 -62
  347. package/out/ranking-weights.d.ts.map +1 -1
  348. package/out/ranking-weights.js +26 -25
  349. package/out/ranking-weights.js.map +1 -1
  350. package/out/region-keys.d.ts +48 -29
  351. package/out/region-keys.d.ts.map +1 -1
  352. package/out/region-keys.js +68 -40
  353. package/out/region-keys.js.map +1 -1
  354. package/out/reverse.d.ts +75 -50
  355. package/out/reverse.d.ts.map +1 -1
  356. package/out/reverse.js +61 -49
  357. package/out/reverse.js.map +1 -1
  358. package/out/schema.d.ts +74 -42
  359. package/out/schema.d.ts.map +1 -1
  360. package/out/schema.js +4 -5
  361. package/out/schema.js.map +1 -1
  362. package/out/search-fetch.d.ts +16 -12
  363. package/out/search-fetch.d.ts.map +1 -1
  364. package/out/search-fetch.js +83 -63
  365. package/out/search-fetch.js.map +1 -1
  366. package/out/sqlite/convention-source.d.ts +25 -0
  367. package/out/sqlite/convention-source.d.ts.map +1 -0
  368. package/out/sqlite/convention-source.js +48 -0
  369. package/out/sqlite/convention-source.js.map +1 -0
  370. package/out/sqlite/utils.d.ts +45 -0
  371. package/out/sqlite/utils.d.ts.map +1 -0
  372. package/out/sqlite/utils.js +56 -0
  373. package/out/sqlite/utils.js.map +1 -0
  374. package/out/street/centroid/schema.d.ts +100 -0
  375. package/out/street/centroid/schema.d.ts.map +1 -0
  376. package/out/street/centroid/schema.js +66 -0
  377. package/out/street/centroid/schema.js.map +1 -0
  378. package/out/street/centroid.d.ts +9 -19
  379. package/out/street/centroid.d.ts.map +1 -1
  380. package/out/street/centroid.js +11 -22
  381. package/out/street/centroid.js.map +1 -1
  382. package/out/street/{morphology-fst-builder.d.ts → morphology/fst/builder.d.ts} +21 -11
  383. package/out/street/morphology/fst/builder.d.ts.map +1 -0
  384. package/out/street/{morphology-fst-builder.js → morphology/fst/builder.js} +40 -34
  385. package/out/street/morphology/fst/builder.js.map +1 -0
  386. package/out/street/morphology/fst/loader.d.ts +74 -0
  387. package/out/street/morphology/fst/loader.d.ts.map +1 -0
  388. package/out/street/{morphology-fst-loader.js → morphology/fst/loader.js} +21 -21
  389. package/out/street/morphology/fst/loader.js.map +1 -0
  390. package/out/street/name-lookup.d.ts +24 -18
  391. package/out/street/name-lookup.d.ts.map +1 -1
  392. package/out/street/name-lookup.js +32 -31
  393. package/out/street/name-lookup.js.map +1 -1
  394. package/out/street/normalize.d.ts +35 -136
  395. package/out/street/normalize.d.ts.map +1 -1
  396. package/out/street/normalize.js +74 -191
  397. package/out/street/normalize.js.map +1 -1
  398. package/out/street/segment-schema.d.ts +79 -39
  399. package/out/street/segment-schema.d.ts.map +1 -1
  400. package/out/street/segment-schema.js +71 -21
  401. package/out/street/segment-schema.js.map +1 -1
  402. package/out/{street/index.d.ts → street.d.ts} +4 -4
  403. package/out/street.d.ts.map +1 -0
  404. package/out/{street/index.js → street.js} +4 -4
  405. package/out/street.js.map +1 -0
  406. package/out/types.d.ts +69 -138
  407. package/out/types.d.ts.map +1 -1
  408. package/out/types.js +0 -6
  409. package/out/types.js.map +1 -1
  410. package/out/unified-schema.d.ts +8 -12
  411. package/out/unified-schema.d.ts.map +1 -1
  412. package/out/unified-schema.js +29 -29
  413. package/out/unified-schema.js.map +1 -1
  414. package/out/uprn/existence.d.ts +28 -17
  415. package/out/uprn/existence.d.ts.map +1 -1
  416. package/out/uprn/existence.js +26 -16
  417. package/out/uprn/existence.js.map +1 -1
  418. package/out/uprn/lookup.d.ts +14 -44
  419. package/out/uprn/lookup.d.ts.map +1 -1
  420. package/out/uprn/lookup.js +20 -56
  421. package/out/uprn/lookup.js.map +1 -1
  422. package/out/uprn/schema.d.ts +18 -40
  423. package/out/uprn/schema.d.ts.map +1 -1
  424. package/out/uprn/schema.js +10 -32
  425. package/out/uprn/schema.js.map +1 -1
  426. package/out/{uprn/index.d.ts → uprn.d.ts} +1 -1
  427. package/out/uprn.d.ts.map +1 -0
  428. package/out/{uprn/index.js → uprn.js} +1 -1
  429. package/out/uprn.js.map +1 -0
  430. package/out/weights-overlay-linker.d.ts +132 -141
  431. package/out/weights-overlay-linker.d.ts.map +1 -1
  432. package/out/weights-overlay-linker.js +86 -154
  433. package/out/weights-overlay-linker.js.map +1 -1
  434. package/package.json +94 -599
  435. package/lib/address/point-schema.ts +0 -155
  436. package/lib/build-candidate.ts +0 -632
  437. package/lib/build-slim.ts +0 -408
  438. package/lib/candidate-ancestors-schema.ts +0 -195
  439. package/lib/candidate-fts.ts +0 -46
  440. package/lib/candidate-importance.ts +0 -224
  441. package/lib/candidate-lookup.ts +0 -977
  442. package/lib/candidate-schema.ts +0 -247
  443. package/lib/candidate-scoring.ts +0 -261
  444. package/lib/convention/index.ts +0 -154
  445. package/lib/fts/index.ts +0 -361
  446. package/lib/postal/city-alias-lookup.ts +0 -97
  447. package/lib/postal/index.ts +0 -9
  448. package/lib/sqlite-convention-source.ts +0 -65
  449. package/lib/sqlite-utils.ts +0 -82
  450. package/lib/street/centroid-schema.ts +0 -154
  451. package/out/address/index.d.ts.map +0 -1
  452. package/out/address/index.js.map +0 -1
  453. package/out/address/point-interpolation.d.ts +0 -49
  454. package/out/address/point-interpolation.d.ts.map +0 -1
  455. package/out/address/point-interpolation.js.map +0 -1
  456. package/out/address/point-schema.d.ts +0 -97
  457. package/out/address/point-schema.d.ts.map +0 -1
  458. package/out/address/point-schema.js.map +0 -1
  459. package/out/ancestry/index.d.ts +0 -45
  460. package/out/ancestry/index.d.ts.map +0 -1
  461. package/out/ancestry/index.js +0 -55
  462. package/out/ancestry/index.js.map +0 -1
  463. package/out/build-candidate.d.ts +0 -184
  464. package/out/build-candidate.d.ts.map +0 -1
  465. package/out/build-candidate.js.map +0 -1
  466. package/out/build-slim.d.ts +0 -80
  467. package/out/build-slim.d.ts.map +0 -1
  468. package/out/build-slim.js.map +0 -1
  469. package/out/candidate/ancestors-sidecar.d.ts +0 -32
  470. package/out/candidate/ancestors-sidecar.d.ts.map +0 -1
  471. package/out/candidate/ancestors-sidecar.js.map +0 -1
  472. package/out/candidate-ancestors-schema.d.ts +0 -150
  473. package/out/candidate-ancestors-schema.d.ts.map +0 -1
  474. package/out/candidate-ancestors-schema.js +0 -123
  475. package/out/candidate-ancestors-schema.js.map +0 -1
  476. package/out/candidate-fts.d.ts +0 -37
  477. package/out/candidate-fts.d.ts.map +0 -1
  478. package/out/candidate-fts.js +0 -40
  479. package/out/candidate-fts.js.map +0 -1
  480. package/out/candidate-importance.d.ts +0 -132
  481. package/out/candidate-importance.d.ts.map +0 -1
  482. package/out/candidate-importance.js +0 -169
  483. package/out/candidate-importance.js.map +0 -1
  484. package/out/candidate-lookup.d.ts +0 -76
  485. package/out/candidate-lookup.d.ts.map +0 -1
  486. package/out/candidate-lookup.js +0 -768
  487. package/out/candidate-lookup.js.map +0 -1
  488. package/out/candidate-schema.d.ts +0 -155
  489. package/out/candidate-schema.d.ts.map +0 -1
  490. package/out/candidate-schema.js.map +0 -1
  491. package/out/candidate-scoring.d.ts.map +0 -1
  492. package/out/candidate-scoring.js +0 -196
  493. package/out/candidate-scoring.js.map +0 -1
  494. package/out/convention/index.d.ts +0 -106
  495. package/out/convention/index.d.ts.map +0 -1
  496. package/out/convention/index.js +0 -93
  497. package/out/convention/index.js.map +0 -1
  498. package/out/fst/index.d.ts.map +0 -1
  499. package/out/fst/index.js.map +0 -1
  500. package/out/fts/index.d.ts +0 -184
  501. package/out/fts/index.d.ts.map +0 -1
  502. package/out/fts/index.js +0 -277
  503. package/out/fts/index.js.map +0 -1
  504. package/out/geonames/index.d.ts.map +0 -1
  505. package/out/geonames/index.js.map +0 -1
  506. package/out/nsul/index.d.ts.map +0 -1
  507. package/out/nsul/index.js.map +0 -1
  508. package/out/poi/index.d.ts.map +0 -1
  509. package/out/poi/index.js.map +0 -1
  510. package/out/postal/city-alias-lookup.d.ts.map +0 -1
  511. package/out/postal/city-alias-lookup.js +0 -62
  512. package/out/postal/city-alias-lookup.js.map +0 -1
  513. package/out/postal/city-alias-schema.d.ts.map +0 -1
  514. package/out/postal/city-alias-schema.js.map +0 -1
  515. package/out/postal/city-candidate-schema.d.ts +0 -66
  516. package/out/postal/city-candidate-schema.d.ts.map +0 -1
  517. package/out/postal/city-candidate-schema.js +0 -56
  518. package/out/postal/city-candidate-schema.js.map +0 -1
  519. package/out/postal/index.d.ts +0 -9
  520. package/out/postal/index.d.ts.map +0 -1
  521. package/out/postal/index.js +0 -9
  522. package/out/postal/index.js.map +0 -1
  523. package/out/sqlite-convention-source.d.ts +0 -29
  524. package/out/sqlite-convention-source.d.ts.map +0 -1
  525. package/out/sqlite-convention-source.js +0 -57
  526. package/out/sqlite-convention-source.js.map +0 -1
  527. package/out/sqlite-utils.d.ts +0 -45
  528. package/out/sqlite-utils.d.ts.map +0 -1
  529. package/out/sqlite-utils.js +0 -57
  530. package/out/sqlite-utils.js.map +0 -1
  531. package/out/street/centroid-schema.d.ts +0 -105
  532. package/out/street/centroid-schema.d.ts.map +0 -1
  533. package/out/street/centroid-schema.js +0 -78
  534. package/out/street/centroid-schema.js.map +0 -1
  535. package/out/street/index.d.ts.map +0 -1
  536. package/out/street/index.js.map +0 -1
  537. package/out/street/morphology-fst-builder.d.ts.map +0 -1
  538. package/out/street/morphology-fst-builder.js.map +0 -1
  539. package/out/street/morphology-fst-loader.d.ts +0 -67
  540. package/out/street/morphology-fst-loader.d.ts.map +0 -1
  541. package/out/street/morphology-fst-loader.js.map +0 -1
  542. package/out/uprn/index.d.ts.map +0 -1
  543. package/out/uprn/index.js.map +0 -1
  544. /package/lib/{fst/index.ts → fst.ts} +0 -0
  545. /package/lib/{geonames/index.ts → geonames.ts} +0 -0
  546. /package/lib/{nsul/index.ts → nsul.ts} +0 -0
  547. /package/lib/{poi/index.ts → poi.ts} +0 -0
  548. /package/lib/{uprn/index.ts → uprn.ts} +0 -0
@@ -1,154 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Typed schema for the DERIVED STREET-CENTROID extract (`street-centroids-<cc>.db`, built by
7
- * `ban/scripts/build-street-centroid-extract.ts` — the #1042 street-level tier behind "street-only
8
- * FR queries deserve a street-level answer"). The extract is a `GROUP BY street` roll-up of the
9
- * sealed rooftop address-point extract: one row per (street, postcode, commune) carrying the street's
10
- * CENTROID + bounding-box EXTENT + member-point count. No new data source — a derived artifact.
11
- *
12
- * Single source of truth for the columns shared by the BUILDER (a positional prepared INSERT for
13
- * throughput) and the READER ({@link StreetCentroidSqliteLookup}), so a column rename in one is a
14
- * compile error in the other — the same discipline as `address-point-schema.ts`.
15
- *
16
- * Probe scopes (most-selective first): by `postcode`, else by `locality_base` (the
17
- * arrondissement-stripped commune — see `stripArrondissement`; BAN names Paris/Lyon/Marseille rows
18
- * per arrondissement, but a query names the base commune). The reader WEIGHTED-aggregates across the
19
- * matched rows (by `point_count`) so a locality-scope probe returns the street's grand centroid over
20
- * every postcode/arrondissement it spans.
21
- */
22
-
23
- import type { Kysely } from "kysely"
24
-
25
- import type { NameKey, StreetKey } from "#street/normalize"
26
-
27
- /**
28
- * One street roll-up. `(street_norm, postcode, locality_base)` is unique. `lat`/`lon` are the UNWEIGHTED mean of the
29
- * group's member address points (each source row = one point), so a cross-group weighted mean (`SUM(lat*point_count) /
30
- * SUM(point_count)`) reconstructs the grand centroid. `min_/max_lat/lon` are the group's extent (the reader turns the
31
- * bbox diagonal into an honest `uncertainty_m`).
32
- */
33
- export interface StreetCentroidTable {
34
- /**
35
- * Shared `normalizeStreetForKeyLocale` of the street — the build/query-consistent probe key.
36
- */
37
- street_norm: StreetKey
38
- /**
39
- * The 5-digit postcode of this group, or null when the source row carried none.
40
- */
41
- postcode: string | null
42
- /**
43
- * Arrondissement-stripped commune (`stripArrondissement(normalizeLocalityForKey(commune))`) — the fallback scope.
44
- */
45
- locality_base: NameKey
46
- /**
47
- * Weighted-mean centroid latitude of the street's member points.
48
- */
49
- lat: number
50
- /**
51
- * Weighted-mean centroid longitude of the street's member points.
52
- */
53
- lon: number
54
- min_lat: number
55
- max_lat: number
56
- min_lon: number
57
- max_lon: number
58
- /**
59
- * Member address-point count — the weight for a cross-group centroid aggregate.
60
- */
61
- point_count: number
62
- /**
63
- * A representative street name as it appeared in the source (display / debugging).
64
- */
65
- street_raw: string
66
- /**
67
- * Provenance: the register this street was derived from (e.g. `ban:fr`).
68
- */
69
- source: string
70
- /**
71
- * The pinned data release the underlying points came from.
72
- */
73
- release: string
74
- /**
75
- * #727 phase-4c: `foldStreetSurface(street_raw)` — the contract-fold street-NAME existence key for
76
- * {@link StreetLocalityEvidence}. Distinct from `street_norm` (the `street-normalize` geocoding key): the
77
- * name-evidence rerank folds the model's street surface with the SAME `foldStreetSurface` used to build this column
78
- * (the fold-parity contract), so it must not drift from `street_norm`'s richer normalizer. Indexed (`idx_sc_name`)
79
- * for a direct seek.
80
- *
81
- * Deliberately UNBRANDED despite the `name_key` column name: `foldStreetSurface` is a different fold from the
82
- * {@link NameKey} one every other `name_key` column carries, and giving it that brand would invite exactly the
83
- * cross-fold probe the brands exist to stop.
84
- */
85
- name_key: string
86
- }
87
-
88
- /**
89
- * The street-centroid database schema for `new DatabaseClient<StreetCentroidDatabase>(...)`.
90
- */
91
- export interface StreetCentroidDatabase {
92
- street_centroid: StreetCentroidTable
93
- }
94
-
95
- /**
96
- * The `street_centroid` columns in INSERT order. The builder's positional prepared statement derives its placeholder
97
- * list from this, so the positional order can't drift from the DDL / the reader.
98
- */
99
- export const STREET_CENTROID_COLUMNS = [
100
- "street_norm",
101
- "postcode",
102
- "locality_base",
103
- "lat",
104
- "lon",
105
- "min_lat",
106
- "max_lat",
107
- "min_lon",
108
- "max_lon",
109
- "point_count",
110
- "street_raw",
111
- "source",
112
- "release",
113
- "name_key",
114
- ] as const
115
-
116
- /**
117
- * Create the `street_centroid` table — called before the streaming bulk load.
118
- */
119
- export async function createStreetCentroidTable(db: Kysely<StreetCentroidDatabase>): Promise<void> {
120
- await db.schema
121
- .createTable("street_centroid")
122
- .addColumn("street_norm", "text", (c) => c.notNull())
123
- .addColumn("postcode", "text")
124
- .addColumn("locality_base", "text", (c) => c.notNull())
125
- .addColumn("lat", "real", (c) => c.notNull())
126
- .addColumn("lon", "real", (c) => c.notNull())
127
- .addColumn("min_lat", "real", (c) => c.notNull())
128
- .addColumn("max_lat", "real", (c) => c.notNull())
129
- .addColumn("min_lon", "real", (c) => c.notNull())
130
- .addColumn("max_lon", "real", (c) => c.notNull())
131
- .addColumn("point_count", "integer", (c) => c.notNull())
132
- .addColumn("street_raw", "text", (c) => c.notNull())
133
- .addColumn("source", "text", (c) => c.notNull())
134
- .addColumn("release", "text", (c) => c.notNull())
135
- .addColumn("name_key", "text", (c) => c.notNull())
136
- .execute()
137
- }
138
-
139
- /**
140
- * Create the probe indexes: the two geocoding-scope indexes (postcode, locality-base) the resolver reader relies on,
141
- * plus `idx_sc_name` — the #727 phase-4c name-existence key for a direct `name_key = ?` seek (the unscoped fragment
142
- * lookup; without it that query skip-scans `idx_sc_postcode` at ~5 ms/probe).
143
- */
144
- export async function createStreetCentroidIndexes(db: Kysely<StreetCentroidDatabase>): Promise<void> {
145
- await db.schema.createIndex("idx_sc_postcode").on("street_centroid").columns(["postcode", "street_norm"]).execute()
146
-
147
- await db.schema
148
- .createIndex("idx_sc_locality")
149
- .on("street_centroid")
150
- .columns(["locality_base", "street_norm"])
151
- .execute()
152
-
153
- await db.schema.createIndex("idx_sc_name").on("street_centroid").columns(["name_key"]).execute()
154
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/address/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/address/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA"}
@@ -1,49 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Address-point interpolation — "Method 2" of the resolution ladder (#483, Phase 1 of
7
- * `docs/articles/plan/2026-06-11-resolution-ladder.md`): when the exact address-point tier (#476)
8
- * misses a house number, bracket the number with REAL neighbor points on the same street from the
9
- * same #476 extract and interpolate linearly in house-number space between them. Real occupancy
10
- * replaces TIGER's uniform-spacing assumption — the dominant error term of the TIGER pilot's check
11
- * miss; TIGER range interpolation (`StreetInterpolator`) demotes to the fallback for streets too
12
- * sparse to bracket.
13
- *
14
- * Matching key is `street_key` — THE shared normalizer plus the route fold
15
- * (`canonicalizeRouteKey`), identical at build time (`scripts/build-address-point-extract.ts`) and
16
- * query time, by construction. Scope is postcode-first like the segment tier; a query without a
17
- * postcode goes straight to the fallback (which carries its own statewide-ambiguity abstention).
18
- *
19
- * Bracketing contract:
20
- *
21
- * - Neighbor candidates NEVER include the queried number itself (any unit/duplicate row of it) — in
22
- * production the exact tier would already have answered an on-file number, and in the eval
23
- * this is what makes grading against the same extract non-circular by construction.
24
- * - Both-sided bracket (`bracket: "both"`): linear interpolation between the nearest known number
25
- * below and above; `uncertaintyM` = half the distance between them.
26
- * - Single-sided (`bracket: "single"`): linear extrapolation along the two nearest known numbers on
27
- * that side, capped at one pair-span beyond the nearest point (`t ≤ 2` — beyond that the line
28
- * carries no evidence and the query falls through); `uncertaintyM` = the pair distance plus
29
- * the extrapolated overshoot, explicitly larger than the both-sided radius.
30
- * - No bracket (no neighbors, a single known number, or past the extrapolation cap): fall through to
31
- * the TIGER fallback when configured, else null.
32
- *
33
- * Standalone like the segment tier — core wiring rides the Phase 2 ordered `spatialTiers` list.
34
- */
35
- import type { InterpolationLookup } from "@mailwoman/core/resolver";
36
- import { DatabaseClient } from "@mailwoman/sqlite/client";
37
- import type { AddressPointDatabase } from "#address/point-schema";
38
- import type { InterpolatedHit, InterpolationQuery, StreetInterpolator } from "#interpolation";
39
- export declare class AddressPointInterpolator<DB extends AddressPointDatabase = AddressPointDatabase> implements InterpolationLookup {
40
- #private;
41
- constructor(opts: {
42
- dbPath?: string;
43
- database?: DatabaseClient<DB>;
44
- fallback?: StreetInterpolator;
45
- });
46
- find(query: InterpolationQuery): InterpolatedHit | null;
47
- [Symbol.dispose](): void;
48
- }
49
- //# sourceMappingURL=point-interpolation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"point-interpolation.d.ts","sourceRoot":"","sources":["../../lib/address/point-interpolation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AA4B7F,qBAAa,wBAAwB,CACpC,EAAE,SAAS,oBAAoB,GAAG,oBAAoB,CACrD,YAAW,mBAAmB;;gBAUnB,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;KAAE;IA2BnG,I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AAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;QAC5C,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;KACrB,CAAA;AACF,CAAC"}
@@ -1,97 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Typed schema for the SITUS / rooftop ADDRESS-POINT extracts (`address-points-<cc>-<slug>.db`, built
7
- * by `scripts/build-address-point-extract.ts` — the #476/#567 national rooftop tier behind the
8
- * demo's "type any US address, get the building"). Single source of truth for the columns shared
9
- * by the BUILDER and the READER ({@link AddressPointSqliteLookup}), so a column rename in one is a
10
- * compile error in the other.
11
- *
12
- * The builder's hot INSERT (tens of millions of rows per state) stays a POSITIONAL prepared
13
- * statement for throughput — but its column list is derived from {@link ADDRESS_POINT_COLUMNS}
14
- * here, and its table comes from {@link createAddressPointTable}, so the positional order can't
15
- * silently drift from what the reader expects. (Same convention as the candidate build: typed
16
- * schema guards the contract; positional inserts keep the speed.)
17
- */
18
- import type { Kysely } from "kysely";
19
- import type { NameKey, RouteKey, StreetKey } from "#street/normalize";
20
- /**
21
- * One rooftop address point. `(street_norm, number)` within a `postcode` (preferred) or `locality_norm` scope is the
22
- * lookup; `street_key` is the #483 route-fold key for interpolation. Coordinates are non-null (the builder drops
23
- * non-finite coords). `unit`/`postcode`/`locality_norm` are nullable (not every source carries all three).
24
- */
25
- export interface AddressPointTable {
26
- /**
27
- * Shared {@link normalizeStreetForKey} of the street — the build/query-consistent probe key.
28
- */
29
- street_norm: StreetKey;
30
- /**
31
- * `canonicalizeRouteKey(street_norm)` — the route-fold key (#483 Method 2). Its own brand, so it cannot be
32
- * interchanged with the plain `street_norm` above.
33
- */
34
- street_key: RouteKey;
35
- /**
36
- * House number, normalized lower-case (kept TEXT — "123-A", "12 1/2" must survive).
37
- */
38
- number: string;
39
- unit: string | null;
40
- postcode: string | null;
41
- /**
42
- * Shared {@link normalizeLocalityForKey} of the locality — the fallback scope.
43
- */
44
- locality_norm: NameKey | null;
45
- /**
46
- * The street as it appeared in the source (kept for display / debugging).
47
- */
48
- street_raw: string;
49
- lat: number;
50
- lon: number;
51
- /**
52
- * Provenance: the dataset this point came from (e.g. `overture:us`, `openaddresses`).
53
- */
54
- source: string;
55
- /**
56
- * The pinned data release the point was ingested from.
57
- */
58
- release: string;
59
- /**
60
- * The source register's stable administrative key for the point's commune or municipality — BAN's `code_insee`. A
61
- * display name (`locality_norm`) is not a key; the coverage basis is computed per THIS.
62
- */
63
- admin_code: string | null;
64
- /**
65
- * The register's own certification flag for the point (BAN `certification_commune`: 1 certified by the commune, 0
66
- * not), or null for a source that states none. A basis is never inferred from a share of these.
67
- */
68
- certified: number | null;
69
- }
70
- /**
71
- * The address-point database schema for `new DatabaseClient<AddressPointDatabase>(...)`.
72
- */
73
- export interface AddressPointDatabase {
74
- address_point: AddressPointTable;
75
- }
76
- /**
77
- * The slice of a Kysely handle the `address_point` DDL touches — the parameter type its builders take.
78
- *
79
- * Kysely is invariant in its schema parameter (the incompatibility is in `transaction()`), so a extract that EXTENDS
80
- * `AddressPointTable` — OSM adds `h3_cell` — cannot pass its own handle to a `Kysely<AddressPointDatabase>` parameter.
81
- * Naming only `schema` lets it, and the DDL below needs nothing else.
82
- */
83
- export type AddressPointSchemaHandle = Pick<Kysely<AddressPointDatabase>, "schema">;
84
- /**
85
- * The `address_point` columns in INSERT order. The builder's positional prepared statement derives its placeholder list
86
- * from this, so the positional order can't drift from the DDL / the reader.
87
- */
88
- export declare const ADDRESS_POINT_COLUMNS: readonly ["street_norm", "street_key", "number", "unit", "postcode", "locality_norm", "street_raw", "lat", "lon", "source", "release", "admin_code", "certified"];
89
- /**
90
- * Create the `address_point` table — called before the streaming bulk load.
91
- */
92
- export declare function createAddressPointTable(db: AddressPointSchemaHandle): Promise<void>;
93
- /**
94
- * Create the three probe indexes the reader relies on (postcode-scope, locality-scope, route-key).
95
- */
96
- export declare function createAddressPointIndexes(db: AddressPointSchemaHandle): Promise<void>;
97
- //# sourceMappingURL=point-schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"point-schema.d.ts","sourceRoot":"","sources":["../../lib/address/point-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAErE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,WAAW,EAAE,SAAS,CAAA;IACtB;;;OAGG;IACH,UAAU,EAAE,QAAQ,CAAA;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB;;OAEG;IACH,aAAa,EAAE,OAAO,GAAG,IAAI,CAAA;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,aAAa,EAAE,iBAAiB,CAAA;CAChC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,QAAQ,CAAC,CAAA;AAEnF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,mKAcxB,CAAA;AAEV;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,EA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O,CAAC,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;AAC9G,CAAC"}
@@ -1,45 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * The shared ancestor-lineage walk over the WOF `ancestors` table — one place's containment chain
7
- * joined with `spr` for canonical names + centroids, ordered NEAREST-FIRST (deepest placetype
8
- * first, country last).
9
- *
10
- * Factored out of `WOFSQLitePlaceLookup.ancestors()` (#404) so the reverse geocoder (`reverse.ts`,
11
- * #484) reuses the SAME walk instead of growing a second one. The placetype-specificity ordering
12
- * lives here as `PLACETYPE_DEPTH` — a single TS map instead of the previous SQL CASE, and
13
- * extended below `localadmin` (locality/borough/neighbourhood/microhood now rank correctly
14
- * instead of sorting last; forward resolution rarely saw those as ANCESTOR placetypes, reverse
15
- * geocoding always does).
16
- */
17
- import type { DatabaseClient } from "@mailwoman/sqlite/client";
18
- /**
19
- * WOF placetype → containment depth, coarsest = 1. Higher = finer. Placetypes we never resolve (continent, empire, …)
20
- * map to 0 and sort last. NOT the same table as the FST's `PLACETYPE_ORDER` (fst-serialize.ts) — that one is a
21
- * serialization order, this one is containment depth.
22
- */
23
- export declare const PLACETYPE_DEPTH: Readonly<Record<string, number>>;
24
- /**
25
- * Containment depth for a placetype — 0 (sorts coarsest) when unknown.
26
- */
27
- export declare function placetypeDepth(placetype: string): number;
28
- /**
29
- * One ancestor row, enriched with the `spr` columns both consumers need.
30
- */
31
- export interface AncestorPlaceRow {
32
- id: number;
33
- placetype: string;
34
- name: string;
35
- country: string;
36
- lat: number;
37
- lon: number;
38
- }
39
- /**
40
- * The ancestor lineage of `id` — self excluded, nearest-first. Returns `[]` when the place has no recorded ancestry.
41
- * NOT memoized here; `WOFSQLitePlaceLookup` keeps its own per-id cache.
42
- */
43
- export declare function ancestorLineage<DB>(db: DatabaseClient<DB>, id: number, schemaName?: string): AncestorPlaceRow[];
44
- export * from "#ancestry/backfill";
45
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/ancestry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAY5D,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACX;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,SAAS,GAAG,gBAAgB,EAAE,CAc/G;AAED,cAAc,oBAAoB,CAAA"}
@@ -1,55 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * The shared ancestor-lineage walk over the WOF `ancestors` table — one place's containment chain
7
- * joined with `spr` for canonical names + centroids, ordered NEAREST-FIRST (deepest placetype
8
- * first, country last).
9
- *
10
- * Factored out of `WOFSQLitePlaceLookup.ancestors()` (#404) so the reverse geocoder (`reverse.ts`,
11
- * #484) reuses the SAME walk instead of growing a second one. The placetype-specificity ordering
12
- * lives here as `PLACETYPE_DEPTH` — a single TS map instead of the previous SQL CASE, and
13
- * extended below `localadmin` (locality/borough/neighbourhood/microhood now rank correctly
14
- * instead of sorting last; forward resolution rarely saw those as ANCESTOR placetypes, reverse
15
- * geocoding always does).
16
- */
17
- import { allRows } from "@mailwoman/core/utils";
18
- /**
19
- * WOF placetype → containment depth, coarsest = 1. Higher = finer. Placetypes we never resolve (continent, empire, …)
20
- * map to 0 and sort last. NOT the same table as the FST's `PLACETYPE_ORDER` (fst-serialize.ts) — that one is a
21
- * serialization order, this one is containment depth.
22
- */
23
- export const PLACETYPE_DEPTH = {
24
- country: 1,
25
- macroregion: 2,
26
- region: 3,
27
- macrocounty: 4,
28
- county: 5,
29
- localadmin: 6,
30
- locality: 7,
31
- borough: 8,
32
- macrohood: 9,
33
- neighbourhood: 10,
34
- microhood: 11,
35
- };
36
- /**
37
- * Containment depth for a placetype — 0 (sorts coarsest) when unknown.
38
- */
39
- export function placetypeDepth(placetype) {
40
- return PLACETYPE_DEPTH[placetype] ?? 0;
41
- }
42
- /**
43
- * The ancestor lineage of `id` — self excluded, nearest-first. Returns `[]` when the place has no recorded ancestry.
44
- * NOT memoized here; `WOFSQLitePlaceLookup` keeps its own per-id cache.
45
- */
46
- export function ancestorLineage(db, id, schemaName = "main") {
47
- const rows = allRows(db.prepare(`SELECT a.ancestor_id AS id, a.ancestor_placetype AS placetype, s.name AS name,
48
- s.country AS country, s.latitude AS lat, s.longitude AS lon
49
- FROM ${schemaName}.ancestors a JOIN ${schemaName}.spr s ON s.id = a.ancestor_id
50
- WHERE a.id = ? AND a.ancestor_id != a.id`), id);
51
- rows.sort((a, b) => placetypeDepth(b.placetype) - placetypeDepth(a.placetype));
52
- return rows;
53
- }
54
- export * from "#ancestry/backfill";
55
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/ancestry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAG/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAqC;IAChE,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC;IACd,MAAM,EAAE,CAAC;IACT,WAAW,EAAE,CAAC;IACd,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,EAAE;IACjB,SAAS,EAAE,EAAE;CACb,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC/C,OAAO,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AACvC,CAAC;AAcD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAK,EAAsB,EAAE,EAAU,EAAE,UAAU,GAAG,MAAM;IAC1F,MAAM,IAAI,GAAG,OAAO,CACnB,EAAE,CAAC,OAAO,CACT;;UAEO,UAAU,qBAAqB,UAAU;4CACP,CACzC,EACD,EAAE,CACF,CAAA;IAED,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IAE9E,OAAO,IAAI,CAAA;AACZ,CAAC;AAED,cAAc,oBAAoB,CAAA"}
@@ -1,184 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Build the global "candidate" lookup DB from a unified admin WOF DB — the byte-range-optimal
7
- * gazetteer the browser demo resolves against. Instead of FTS5 (whose postings for a common name
8
- * scatter across a multi-GB file → hundreds of serial range fetches), this materializes one
9
- * `WITHOUT ROWID` B-tree keyed `(name_key, country_id, region_id, placetype_id, neg_rank,
10
- * spr_id)`: every place's normalized name + distinct aliases + region abbreviations become rows,
11
- * population rank is precomputed into `neg_rank`, and the rows are bulk-loaded PRE-SORTED so a
12
- * resolve is one contiguous B-tree probe (a handful of pages → 1-2 chunk fetches, regardless of
13
- * global volume).
14
- *
15
- * Each row is DENORMALIZED — it carries the place's display `name`, centroid (`latitude`/
16
- * `longitude`), and `min/max` bbox — so a resolve is one statement, no FTS, no join to spr:
17
- * SELECT spr_id, name, latitude, longitude, min_lat, ... FROM candidate WHERE name_key = ? AND
18
- * country_id = ? AND placetype_id IN (...) [AND latitude BETWEEN ...] ORDER BY neg_rank ASC LIMIT
19
- * K; The demo cascade resolves a parsed region first (its bbox), then constrains the locality to
20
- * that bbox; `region_id` (the place's region-tier ancestor) is also carried for a future region
21
- * 2-step.
22
- *
23
- * The name_key normalizer is the SHARED {@link normalizeLocalityForKey} — the query side (the demo
24
- * resolver {@link WOFCandidateTableLookup}) MUST use the same function, the one-normalizer
25
- * discipline the address-point extract uses, so build/query stay consistent by construction.
26
- *
27
- * Measured (2026-06-20, vs the 2.6 GB full-DB FTS): ~5 M rows; ~12 range fetches per 8-query
28
- * session (the full DB needs 243); US locality 96.8% (region bbox), EU coord parity 88.6%.
29
- *
30
- * #28 adds one more denormalized field, `importance` — the toponym-fame prior that decides a BARE
31
- * city name, joined in from a separate score source by name rather than by id (see
32
- * `candidate-importance.ts`, which owns that join and explains why the id would be wrong). It is
33
- * optional: without {@link BuildCandidateOptions.importance} the column is NULL on every row, which
34
- * the consumer reads as unmeasured and ignores.
35
- *
36
- * The build also materializes the ANCESTORS SIDECAR (`candidate_ancestor` closure rows +
37
- * `candidate_interval` pre/post labels) from the source `ancestors` table — the containment
38
- * lineage behind {@link WOFCandidateTableLookup.ancestors} and the admin-coherence check.
39
- * `candidate-ancestors-schema.ts` owns the encoding decision and the DAG/absence semantics.
40
- */
41
- import type { CapitalPoint } from "#capitals";
42
- export { stageCountryDisplayNames } from "#candidate/country-display-names";
43
- export { GLOSS_EXCLUDED_PLACETYPES, GLOSS_KEY_THRESHOLD } from "#candidate/name-roles";
44
- export type { PlaceAttrs } from "#candidate/place-attrs";
45
- export interface BuildCandidateOptions {
46
- /**
47
- * Source unified admin DB — needs spr, place_population, place_search, place_abbr, ancestors.
48
- */
49
- input: string;
50
- /**
51
- * Output candidate DB path (overwritten if present).
52
- */
53
- output: string;
54
- /**
55
- * The capital-status reference entries (#1880) to carry in-artifact — the parsed `data/gazetteer/capitals-v1.json`
56
- * entries, passed by the CALLER because this module publishes to npm and must not read repo-root paths. Absent → the
57
- * `capital` table is not created, and the session loader falls back to the repo file where one exists.
58
- */
59
- capitals?: readonly CapitalPoint[];
60
- /**
61
- * Optional postcode extracts (`spr` rows with `placetype='postalcode'` + real coords, e.g. postalcode-us.db) — folded
62
- * in as `postalcode` candidate rows so `findPlace(postalcode)` resolves a ZIP directly (the demo's primary postcode
63
- * path; the postcode-*.bin anchor stays the fallback). Matches the slim wof-hot.db, which took one such postcode DB.
64
- *
65
- * Each extract's `names` table is folded in too (#1495) — that's where the GeoNames delivery-city names live
66
- * ("Brooklyn" for 11201), and they were previously reachable only through FTS.
67
- */
68
- postcodes?: string[];
69
- /**
70
- * Optional LOCALITY extracts (`spr` rows with `placetype='locality'` + real coords, e.g. localities-nz-linz.db — the
71
- * #1564 NZ suburb tier) — folded through the same extract loop as the postcode extracts, staged as `locality`
72
- * candidate rows with UNMEASURED population (`neg_rank 0`: a extract row ranks behind any populated namesake and wins
73
- * only where its key is the answer). Each extract's `names` table folds as aliases, `is_primary = 0`, same as the
74
- * delivery-city pass. An extract whose `ancestors` table names an admin region for a row gives that row the region's
75
- * scope (`region_id`) plus closure rows for the region and the region's own chain above it; an extract without one
76
- * stays unscoped, as before.
77
- */
78
- localities?: string[];
79
- /**
80
- * Optional WOF admin database carrying a `place_importance` table — the source of the `importance` column (#28), the
81
- * toponym-fame prior that decides the bare-city-name class. Joined by `(name_key, country, placetype)` + nearest
82
- * centroid, NOT by id; see `candidate-importance.ts` for why the id join silently drops the foreign homonyms the
83
- * prior exists to demote.
84
- *
85
- * Omit it and every row's `importance` is NULL — unmeasured, which is what the consumer's positive-evidence-only rule
86
- * already treats as "do not participate", so the artifact is byte-identical to a pre-#28 build except for the empty
87
- * column. That is the honest degradation and it is the DEFAULT: a caller with no score source must not get a
88
- * population-derived stand-in written into a column that means fame.
89
- */
90
- importance?: string;
91
- /**
92
- * Cross-source currency backfill (#1737). WOF carries deprecated-with-no-successor records for real, populated
93
- * settlements (Rochester Kent, Aldershot, Telford — 120 GB localities alone), and the currency filter correctly drops
94
- * them, leaving holes no ranking can fill. When this option is set, pass 1c resurrects a dead locality ONLY under
95
- * three conditions, positive evidence throughout: no live same-name row of any placetype near the dead record (a
96
- * distant same-name row is a NAMESAKE and does not block — Rochester, Northumberland pop 318 must not veto Rochester,
97
- * Kent); an independent GeoNames P-class attestation of the same folded name within
98
- * {@link CURRENCY_BACKFILL_RADIUS_KM}; and the attestor at or above {@link CURRENCY_BACKFILL_POP_FLOOR}. The staged
99
- * row keeps the real WOF id, name, centroid and bbox — GeoNames only ATTESTS the place and supplies the population
100
- * that lets it stand in prominence races. `countries` are judged only where `<cc>.txt` exists under `geonamesDir`;
101
- * absent dumps are skipped loudly.
102
- */
103
- currencyBackfill?: {
104
- geonamesDir: string;
105
- countries: readonly string[];
106
- /**
107
- * The dead placetypes the resurrection judges; `resurrectCurrencyHoles`'s default (`locality`) when absent. The
108
- * `localadmin` widening #1746 named is admitted here once its census is read.
109
- */
110
- deadPlacetypes?: readonly string[];
111
- };
112
- /**
113
- * Optional progress callback for CLI / test introspection.
114
- */
115
- onProgress?: (phase: string, message: string) => void;
116
- /**
117
- * Key-count threshold for the gloss anomaly detector — {@link GLOSS_KEY_THRESHOLD} unless a test passes a
118
- * fixture-scale value. The production number is the #1730 sweep's own threshold (4,000 places at >= 50 keys).
119
- */
120
- glossKeyThreshold?: number;
121
- }
122
- export interface BuildCandidateResult {
123
- rows: number;
124
- places: number;
125
- primaries: number;
126
- aliases: number;
127
- abbrevs: number;
128
- postcodes: number;
129
- /**
130
- * Delivery-city (and other `names`-table) aliases folded onto postcode rows — #1495. Zero here means the extracts
131
- * carried no alias names, NOT that the pass was skipped: a extract with no `names` table reports that separately
132
- * through `onProgress`.
133
- */
134
- postcodeAliases: number;
135
- /**
136
- * Closure rows in the `candidate_ancestor` sidecar (see candidate-ancestors-schema.ts). Zero means the source
137
- * `ancestors` table contributed nothing within the resolvable placetypes — a finding, reported rather than implied.
138
- */
139
- ancestorRows: number;
140
- /**
141
- * Places carrying at least one closure row.
142
- */
143
- ancestorPlaces: number;
144
- /**
145
- * Places that received a pre/post interval label — the canonical-parent forest's node count. Places outside it (no
146
- * recorded ancestry, extract rows, cycle-skipped) have NO label: containment against them is unverifiable, never
147
- * false.
148
- */
149
- intervalPlaces: number;
150
- /**
151
- * Places that took an `importance` score from the join (#28).
152
- *
153
- * `undefined` and `0` mean different things. `undefined` is "the pass did not run" — no score source was given. A `0`
154
- * would be the source matching NOTHING, which is a finding. Never collapse the two.
155
- */
156
- importanceScored?: number;
157
- /**
158
- * Places whose `(name_key, country, placetype)` matched a scored group but whose nearest scored centroid was outside
159
- * {@link IMPORTANCE_JOIN_RADIUS_KM} — a different town wearing the same name, refused rather than scored.
160
- *
161
- * Worth watching across rebuilds: a jump here means the score source and the admin source have drifted apart, and the
162
- * join is being asked to guess.
163
- */
164
- importanceFiltered?: number;
165
- /**
166
- * Alias rows stamped `name_role = 'gloss'` — the anomaly detector's certain core (#1730).
167
- */
168
- roleGloss: number;
169
- /**
170
- * Alias rows stamped `name_role = 'abbr'` — the variant-in-official-language provenance signal (#1730/#936).
171
- */
172
- roleAbbr: number;
173
- /**
174
- * Admin places whose staged key count reached {@link GLOSS_KEY_THRESHOLD} — the sweep's tail, reported so the stamped
175
- * fraction has its denominator.
176
- */
177
- keyTailPlaces: number;
178
- /**
179
- * Of {@link BuildCandidateResult.keyTailPlaces}, how many carry at least one stamped role row.
180
- */
181
- keyTailWithRole: number;
182
- }
183
- export declare function buildCandidateTable(opts: BuildCandidateOptions): Promise<BuildCandidateResult>;
184
- //# sourceMappingURL=build-candidate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-candidate.d.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