@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.
Files changed (477) hide show
  1. package/README.md +9 -8
  2. package/lib/address/point/interpolation.ts +45 -39
  3. package/lib/address/point/schema.ts +17 -40
  4. package/lib/address/point.ts +316 -0
  5. package/lib/{address/index.ts → address.ts} +1 -1
  6. package/lib/ancestry/backfill.ts +20 -86
  7. package/lib/{ancestry/index.ts → ancestry.ts} +19 -15
  8. package/lib/build/candidate.ts +122 -174
  9. package/lib/build/population-corrections.ts +64 -0
  10. package/lib/build/slim.ts +44 -114
  11. package/lib/candidate/alias-bags.ts +16 -17
  12. package/lib/candidate/ancestors/schema.ts +77 -61
  13. package/lib/candidate/ancestors/sidecar.ts +15 -22
  14. package/lib/candidate/country-display-names.ts +6 -20
  15. package/lib/candidate/extract-fold.ts +10 -55
  16. package/lib/candidate/fts.ts +5 -23
  17. package/lib/candidate/importance.ts +65 -68
  18. package/lib/candidate/lookup.ts +124 -415
  19. package/lib/candidate/name-roles.ts +15 -33
  20. package/lib/candidate/own-name.ts +35 -32
  21. package/lib/candidate/place-attrs.ts +20 -13
  22. package/lib/candidate/schema.ts +29 -65
  23. package/lib/candidate/scoring.ts +54 -93
  24. package/lib/capital-schema.ts +21 -17
  25. package/lib/capitals.ts +29 -27
  26. package/lib/coincident-roles.ts +85 -55
  27. package/lib/convention/schema.ts +15 -16
  28. package/lib/convention.ts +144 -0
  29. package/lib/coverage-manifest-schema.ts +40 -45
  30. package/lib/currency-backfill.ts +34 -79
  31. package/lib/env.ts +1 -1
  32. package/lib/exact-match.ts +32 -21
  33. package/lib/extracts.ts +97 -74
  34. package/lib/fst/autocomplete.ts +54 -37
  35. package/lib/fst/builder.ts +37 -41
  36. package/lib/fst/deserialize-web.ts +16 -17
  37. package/lib/fst/format.ts +41 -23
  38. package/lib/fst/freshness.ts +43 -120
  39. package/lib/fst/matcher.ts +7 -5
  40. package/lib/fst/serialize.ts +54 -74
  41. package/lib/fst/types.ts +78 -75
  42. package/lib/{fst/index.ts → fst.ts} +1 -0
  43. package/lib/fts/query.ts +5 -36
  44. package/lib/fts.ts +280 -0
  45. package/lib/geonames/aliases.ts +73 -144
  46. package/lib/geonames/postal.ts +162 -71
  47. package/lib/index.ts +9 -8
  48. package/lib/interpolation.ts +48 -100
  49. package/lib/lookup.ts +155 -270
  50. package/lib/name-score.ts +9 -7
  51. package/lib/nsul/lookup.ts +37 -54
  52. package/lib/nsul/schema.ts +16 -43
  53. package/lib/paths.ts +159 -0
  54. package/lib/place-importance-schema.ts +62 -169
  55. package/lib/poi/lookup.ts +104 -121
  56. package/lib/poi/schema.ts +42 -26
  57. package/lib/polygon-schema.ts +10 -6
  58. package/lib/postal/city/alias/lookup.ts +22 -40
  59. package/lib/postal/city/alias/schema.ts +14 -10
  60. package/lib/postal/city/candidate-schema.ts +26 -20
  61. package/lib/postcode-point-lookup.ts +8 -27
  62. package/lib/primary-preference.ts +46 -126
  63. package/lib/proximity-rerank.ts +44 -33
  64. package/lib/ranking-weights.ts +105 -78
  65. package/lib/region-keys.ts +70 -42
  66. package/lib/reverse.ts +149 -86
  67. package/lib/schema.ts +73 -50
  68. package/lib/search-fetch.ts +90 -68
  69. package/lib/sqlite/convention-source.ts +15 -23
  70. package/lib/sqlite/utils.ts +19 -22
  71. package/lib/street/centroid/schema.ts +37 -42
  72. package/lib/street/{centroid/index.ts → centroid.ts} +16 -25
  73. package/lib/street/morphology/fst/builder.ts +60 -42
  74. package/lib/street/morphology/fst/loader.ts +40 -32
  75. package/lib/street/name-lookup.ts +45 -41
  76. package/lib/street/normalize.ts +88 -219
  77. package/lib/street/segment-schema.ts +116 -43
  78. package/lib/{street/index.ts → street.ts} +1 -1
  79. package/lib/types.ts +109 -150
  80. package/lib/unified-schema.ts +29 -29
  81. package/lib/uprn/existence.ts +30 -19
  82. package/lib/uprn/lookup.ts +29 -68
  83. package/lib/uprn/schema.ts +18 -40
  84. package/lib/weights-overlay-linker.ts +236 -252
  85. package/out/address/point/interpolation.d.ts +20 -23
  86. package/out/address/point/interpolation.d.ts.map +1 -1
  87. package/out/address/point/interpolation.js +42 -39
  88. package/out/address/point/interpolation.js.map +1 -1
  89. package/out/address/point/schema.d.ts +12 -35
  90. package/out/address/point/schema.d.ts.map +1 -1
  91. package/out/address/point/schema.js +3 -19
  92. package/out/address/point/schema.js.map +1 -1
  93. package/out/address/point.d.ts +57 -0
  94. package/out/address/point.d.ts.map +1 -0
  95. package/out/address/point.js +206 -0
  96. package/out/address/point.js.map +1 -0
  97. package/out/{address/index.js → address.d.ts} +2 -2
  98. package/out/address.d.ts.map +1 -0
  99. package/out/{address/index.d.ts → address.js} +2 -2
  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 +14 -74
  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 +82 -112
  110. package/out/build/candidate.d.ts.map +1 -1
  111. package/out/build/candidate.js +17 -100
  112. package/out/build/candidate.js.map +1 -1
  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 +8 -44
  118. package/out/build/slim.d.ts.map +1 -1
  119. package/out/build/slim.js +33 -94
  120. package/out/build/slim.js.map +1 -1
  121. package/out/candidate/alias-bags.d.ts +6 -6
  122. package/out/candidate/alias-bags.d.ts.map +1 -1
  123. package/out/candidate/alias-bags.js +16 -17
  124. package/out/candidate/alias-bags.js.map +1 -1
  125. package/out/candidate/ancestors/schema.d.ts +73 -57
  126. package/out/candidate/ancestors/schema.d.ts.map +1 -1
  127. package/out/candidate/ancestors/schema.js +56 -48
  128. package/out/candidate/ancestors/schema.js.map +1 -1
  129. package/out/candidate/ancestors/sidecar.d.ts +3 -8
  130. package/out/candidate/ancestors/sidecar.d.ts.map +1 -1
  131. package/out/candidate/ancestors/sidecar.js +15 -22
  132. package/out/candidate/ancestors/sidecar.js.map +1 -1
  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 +7 -15
  138. package/out/candidate/extract-fold.d.ts.map +1 -1
  139. package/out/candidate/extract-fold.js +5 -47
  140. package/out/candidate/extract-fold.js.map +1 -1
  141. package/out/candidate/fts.d.ts +5 -23
  142. package/out/candidate/fts.d.ts.map +1 -1
  143. package/out/candidate/fts.js +5 -23
  144. package/out/candidate/fts.js.map +1 -1
  145. package/out/candidate/importance.d.ts +60 -65
  146. package/out/candidate/importance.d.ts.map +1 -1
  147. package/out/candidate/importance.js +56 -63
  148. package/out/candidate/importance.js.map +1 -1
  149. package/out/candidate/lookup.d.ts +18 -55
  150. package/out/candidate/lookup.d.ts.map +1 -1
  151. package/out/candidate/lookup.js +82 -385
  152. package/out/candidate/lookup.js.map +1 -1
  153. package/out/candidate/name-roles.d.ts +9 -21
  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 +35 -32
  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 +27 -62
  166. package/out/candidate/schema.d.ts.map +1 -1
  167. package/out/candidate/schema.js +10 -22
  168. package/out/candidate/schema.js.map +1 -1
  169. package/out/candidate/scoring.d.ts +7 -8
  170. package/out/candidate/scoring.d.ts.map +1 -1
  171. package/out/candidate/scoring.js +52 -89
  172. package/out/candidate/scoring.js.map +1 -1
  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 +27 -25
  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 +72 -50
  184. package/out/coincident-roles.js.map +1 -1
  185. package/out/convention/schema.d.ts +14 -14
  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 +34 -39
  194. package/out/coverage-manifest-schema.d.ts.map +1 -1
  195. package/out/coverage-manifest-schema.js +25 -34
  196. package/out/coverage-manifest-schema.js.map +1 -1
  197. package/out/currency-backfill.d.ts +16 -38
  198. package/out/currency-backfill.d.ts.map +1 -1
  199. package/out/currency-backfill.js +19 -46
  200. package/out/currency-backfill.js.map +1 -1
  201. package/out/env.d.ts +1 -1
  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 +32 -21
  206. package/out/exact-match.js.map +1 -1
  207. package/out/extracts.d.ts +66 -55
  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 +29 -21
  212. package/out/fst/autocomplete.d.ts.map +1 -1
  213. package/out/fst/autocomplete.js +39 -28
  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 +37 -41
  217. package/out/fst/builder.js.map +1 -1
  218. package/out/fst/deserialize-web.d.ts +4 -4
  219. package/out/fst/deserialize-web.d.ts.map +1 -1
  220. package/out/fst/deserialize-web.js +15 -16
  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 +19 -81
  227. package/out/fst/freshness.d.ts.map +1 -1
  228. package/out/fst/freshness.js +31 -94
  229. package/out/fst/freshness.js.map +1 -1
  230. package/out/fst/matcher.d.ts +5 -4
  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 +28 -28
  235. package/out/fst/serialize.d.ts.map +1 -1
  236. package/out/fst/serialize.js +53 -71
  237. package/out/fst/serialize.js.map +1 -1
  238. package/out/fst/types.d.ts +78 -74
  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} +2 -1
  243. package/out/fst.d.ts.map +1 -0
  244. package/out/{fst/index.d.ts → fst.js} +2 -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 -62
  255. package/out/geonames/aliases.d.ts.map +1 -1
  256. package/out/geonames/aliases.js +45 -117
  257. package/out/geonames/aliases.js.map +1 -1
  258. package/out/geonames/postal.d.ts +84 -44
  259. package/out/geonames/postal.d.ts.map +1 -1
  260. package/out/geonames/postal.js +115 -73
  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 +9 -8
  267. package/out/index.d.ts.map +1 -1
  268. package/out/index.js +6 -5
  269. package/out/index.js.map +1 -1
  270. package/out/interpolation.d.ts +18 -55
  271. package/out/interpolation.d.ts.map +1 -1
  272. package/out/interpolation.js +27 -69
  273. package/out/interpolation.js.map +1 -1
  274. package/out/lookup.d.ts +23 -51
  275. package/out/lookup.d.ts.map +1 -1
  276. package/out/lookup.js +136 -234
  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 +51 -143
  299. package/out/place-importance-schema.d.ts.map +1 -1
  300. package/out/place-importance-schema.js +28 -143
  301. package/out/place-importance-schema.js.map +1 -1
  302. package/out/poi/lookup.d.ts +40 -47
  303. package/out/poi/lookup.d.ts.map +1 -1
  304. package/out/poi/lookup.js +69 -96
  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 +20 -23
  319. package/out/postal/city/alias/lookup.d.ts.map +1 -1
  320. package/out/postal/city/alias/lookup.js +17 -30
  321. package/out/postal/city/alias/lookup.js.map +1 -1
  322. package/out/postal/city/alias/schema.d.ts +14 -10
  323. package/out/postal/city/alias/schema.d.ts.map +1 -1
  324. package/out/postal/city/alias/schema.js +10 -8
  325. package/out/postal/city/alias/schema.js.map +1 -1
  326. package/out/postal/city/candidate-schema.d.ts +25 -19
  327. package/out/postal/city/candidate-schema.d.ts.map +1 -1
  328. package/out/postal/city/candidate-schema.js +21 -17
  329. package/out/postal/city/candidate-schema.js.map +1 -1
  330. package/out/{postal/index.d.ts → postal.d.ts} +1 -1
  331. package/out/postal.d.ts.map +1 -0
  332. package/out/{postal/index.js → postal.js} +1 -1
  333. package/out/postal.js.map +1 -0
  334. package/out/postcode-point-lookup.d.ts +6 -24
  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 +38 -92
  339. package/out/primary-preference.d.ts.map +1 -1
  340. package/out/primary-preference.js +15 -99
  341. package/out/primary-preference.js.map +1 -1
  342. package/out/proximity-rerank.d.ts +41 -30
  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 +98 -64
  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 +50 -31
  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 +78 -50
  355. package/out/reverse.d.ts.map +1 -1
  356. package/out/reverse.js +98 -61
  357. package/out/reverse.js.map +1 -1
  358. package/out/schema.d.ts +72 -49
  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 +12 -16
  367. package/out/sqlite/convention-source.d.ts.map +1 -1
  368. package/out/sqlite/convention-source.js +13 -22
  369. package/out/sqlite/convention-source.js.map +1 -1
  370. package/out/sqlite/utils.d.ts +19 -19
  371. package/out/sqlite/utils.d.ts.map +1 -1
  372. package/out/sqlite/utils.js +14 -15
  373. package/out/sqlite/utils.js.map +1 -1
  374. package/out/street/centroid/schema.d.ts +37 -42
  375. package/out/street/centroid/schema.d.ts.map +1 -1
  376. package/out/street/centroid/schema.js +9 -21
  377. package/out/street/centroid/schema.js.map +1 -1
  378. package/out/street/centroid.d.ts +30 -0
  379. package/out/street/centroid.d.ts.map +1 -0
  380. package/out/street/{centroid/index.js → centroid.js} +13 -24
  381. package/out/street/centroid.js.map +1 -0
  382. package/out/street/morphology/fst/builder.d.ts +20 -10
  383. package/out/street/morphology/fst/builder.d.ts.map +1 -1
  384. package/out/street/morphology/fst/builder.js +44 -34
  385. package/out/street/morphology/fst/builder.js.map +1 -1
  386. package/out/street/morphology/fst/loader.d.ts +33 -26
  387. package/out/street/morphology/fst/loader.d.ts.map +1 -1
  388. package/out/street/morphology/fst/loader.js +23 -22
  389. package/out/street/morphology/fst/loader.js.map +1 -1
  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 +34 -35
  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 +77 -194
  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.js → street.d.ts} +2 -2
  403. package/out/street.d.ts.map +1 -0
  404. package/out/{street/index.d.ts → street.js} +2 -2
  405. package/out/street.js.map +1 -0
  406. package/out/types.d.ts +84 -149
  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 +21 -57
  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 +138 -144
  431. package/out/weights-overlay-linker.d.ts.map +1 -1
  432. package/out/weights-overlay-linker.js +105 -159
  433. package/out/weights-overlay-linker.js.map +1 -1
  434. package/package.json +91 -596
  435. package/lib/address/point/index.ts +0 -328
  436. package/lib/convention/index.ts +0 -154
  437. package/lib/fts/index.ts +0 -361
  438. package/out/address/index.d.ts.map +0 -1
  439. package/out/address/index.js.map +0 -1
  440. package/out/address/point/index.d.ts +0 -53
  441. package/out/address/point/index.d.ts.map +0 -1
  442. package/out/address/point/index.js +0 -222
  443. package/out/address/point/index.js.map +0 -1
  444. package/out/ancestry/index.d.ts +0 -45
  445. package/out/ancestry/index.d.ts.map +0 -1
  446. package/out/ancestry/index.js +0 -55
  447. package/out/ancestry/index.js.map +0 -1
  448. package/out/convention/index.d.ts +0 -106
  449. package/out/convention/index.d.ts.map +0 -1
  450. package/out/convention/index.js +0 -93
  451. package/out/convention/index.js.map +0 -1
  452. package/out/fst/index.d.ts.map +0 -1
  453. package/out/fst/index.js.map +0 -1
  454. package/out/fts/index.d.ts +0 -184
  455. package/out/fts/index.d.ts.map +0 -1
  456. package/out/fts/index.js +0 -277
  457. package/out/fts/index.js.map +0 -1
  458. package/out/geonames/index.d.ts.map +0 -1
  459. package/out/geonames/index.js.map +0 -1
  460. package/out/nsul/index.d.ts.map +0 -1
  461. package/out/nsul/index.js.map +0 -1
  462. package/out/poi/index.d.ts.map +0 -1
  463. package/out/poi/index.js.map +0 -1
  464. package/out/postal/index.d.ts.map +0 -1
  465. package/out/postal/index.js.map +0 -1
  466. package/out/street/centroid/index.d.ts +0 -40
  467. package/out/street/centroid/index.d.ts.map +0 -1
  468. package/out/street/centroid/index.js.map +0 -1
  469. package/out/street/index.d.ts.map +0 -1
  470. package/out/street/index.js.map +0 -1
  471. package/out/uprn/index.d.ts.map +0 -1
  472. package/out/uprn/index.js.map +0 -1
  473. /package/lib/{geonames/index.ts → geonames.ts} +0 -0
  474. /package/lib/{nsul/index.ts → nsul.ts} +0 -0
  475. /package/lib/{poi/index.ts → poi.ts} +0 -0
  476. /package/lib/{postal/index.ts → postal.ts} +0 -0
  477. /package/lib/{uprn/index.ts → uprn.ts} +0 -0
@@ -2,31 +2,24 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * `SqliteConventionSource` — a `ConventionSource` backed by the build-from-source convention asset
7
- * (#290, Direction E). Conventions live in a read-only, provenance-stamped `address_convention`
8
- * table keyed by WOF polygon id; this source queries them ON DEMAND by id (one indexed lookup,
9
- * memoized) rather than paging the whole table into memory as a code constant — the deliberate
10
- * counter to the Pelias "giant dictionary in RAM, no provenance" pattern (see the operator design
11
- * value in memory `feedback-no-irrelevant-trivia`).
12
- *
13
- * The asset is the queryable, distributable artifact; the strategy IMPLEMENTATIONS stay in code. An
14
- * unknown strategy NAME is surfaced loudly at dispatch (see `lookup.ts`), not silently
15
- * swallowed.
16
5
  */
17
6
  import { tryParsingJSON } from "@mailwoman/core/json";
18
- import { ADDRESS_CONVENTION_TABLE } from "#convention/index";
7
+ import { ADDRESS_CONVENTION_TABLE } from "#convention";
8
+ /**
9
+ * Reads per-place address conventions from the convention table in an attached
10
+ * SQLite schema, caching each lookup, including misses.
11
+ *
12
+ * A missing table or unparseable row reads as no convention rather than throwing.
13
+ */
19
14
  export class SqliteConventionSource {
20
15
  #db;
21
16
  #schema;
22
- /**
23
- * Memoize per-id lookups (including misses, as `null`) so a hot ancestor chain is queried once.
24
- */
25
17
  #cache = new Map();
26
18
  /**
27
- * @param db An open handle to a DB that has the convention asset attached (or is it).
28
- * @param schema The schema name the `address_convention` table lives under (`main` or an ATTACHed extract name —
29
- * `WOFSQLitePlaceLookup` auto-detects which extract carries the table).
19
+ * Creates a source over an open database that is, or has attached, the convention asset.
20
+ *
21
+ * @param db The open database handle.
22
+ * @param schema The schema that holds the convention table, either `main` or an attached extract's name.
30
23
  */
31
24
  constructor(db, schema) {
32
25
  this.#db = db;
@@ -35,7 +28,7 @@ export class SqliteConventionSource {
35
28
  get(wofID) {
36
29
  const cached = this.#cache.get(wofID);
37
30
  if (cached !== undefined)
38
- return cached ?? undefined;
31
+ return cached;
39
32
  let value = null;
40
33
  try {
41
34
  const row = this.#db
@@ -46,12 +39,10 @@ export class SqliteConventionSource {
46
39
  }
47
40
  }
48
41
  catch {
49
- // A missing table → treat as no override (the chain falls back to WORLD_DEFAULT); malformed
50
- // JSON already nulls out above. The build script validates structure, so this is purely defensive.
51
42
  value = null;
52
43
  }
53
44
  this.#cache.set(wofID, value);
54
- return value ?? undefined;
45
+ return value;
55
46
  }
56
47
  }
57
48
  //# sourceMappingURL=convention-source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convention-source.js","sourceRoot":"","sources":["../../lib/sqlite/convention-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAAE,wBAAwB,EAA0C,MAAM,mBAAmB,CAAA;AAEpG,MAAM,OAAO,sBAAsB;IACzB,GAAG,CAAoB;IACvB,OAAO,CAAQ;IACxB;;OAEG;IACM,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAA;IAEtD;;;;OAIG;IACH,YAAY,EAAsB,EAAE,MAAc;QACjD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,GAAG,CAAC,KAAa;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAErC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,IAAI,SAAS,CAAA;QACpD,IAAI,KAAK,GAAsB,IAAI,CAAA;QAEnC,IAAI,CAAC;YACJ,MAAM,GAAG,GAAG,I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OAAO,IAAI,wBAAwB,mBAAmB,CAAC;iBAC9F,GAAG,CAAC,KAAK,CAAuC,CAAA;YAElD,IAAI,GAAG,EAAE,UAAU,EAAE,CAAC;gBACrB,KAAK,GAAG,cAAc,CAAa,GAAG,CAAC,UAAU,CAAC,CAAA;YACnD,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,KAAK,GAAG,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAE7B,OAAO,KAAK,CAAA;IACb,CAAC;CACD"}
@@ -2,44 +2,44 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * Small shared helpers for the SQLite-backed lookups.
5
+ * @file Shared helpers for the SQLite-backed lookups.
7
6
  */
8
7
  import type { DatabaseClient, SQLInputValue } from "@mailwoman/sqlite/client";
9
8
  /**
10
- * A prepared single-row query whose parameter tuple remains visible to TypeScript. `StatementSync` accepts only the
11
- * broad `SQLInputValue[]`, which otherwise erases tagged key types before they reach SQLite.
9
+ * A prepared single-row query whose parameter tuple stays visible to TypeScript.
10
+ *
11
+ * `StatementSync` accepts any `SQLInputValue[]`, which would erase tagged key types at the call site.
12
12
  */
13
- export type PreparedGet<Parameters extends SQLInputValue[], Row> = (...parameters: Parameters) => Row | undefined;
13
+ export type PreparedGet<Parameters extends SQLInputValue[], Row> = (...parameters: Parameters) => Row | null;
14
14
  /**
15
- * Prepare a single-row query while preserving its exact parameter tuple at every call site.
15
+ * Prepares a single-row query with a typed parameter tuple.
16
16
  */
17
17
  export declare function prepareGet<Parameters extends SQLInputValue[], Row, DB>(db: DatabaseClient<DB>, sql: string): PreparedGet<Parameters, Row>;
18
18
  /**
19
- * Multi-row counterpart to {@link PreparedGet}.
19
+ * The multi-row counterpart to {@link PreparedGet}.
20
20
  */
21
21
  export type PreparedAll<Parameters extends SQLInputValue[], Row> = (...parameters: Parameters) => Row[];
22
22
  /**
23
- * Prepare a multi-row query while preserving its exact parameter tuple at every call site.
23
+ * Prepares a multi-row query with a typed parameter tuple.
24
24
  */
25
25
  export declare function prepareAll<Parameters extends SQLInputValue[], Row, DB>(db: DatabaseClient<DB>, sql: string): PreparedAll<Parameters, Row>;
26
26
  /**
27
- * True when `name` is a table in the open database. The street-level lookups use this to degrade gracefully on an
28
- * empty/tableless extract — an interrupted `build-*-extract.ts`, or a stray 0-byte file (e.g. `sqlite3 <missing>.db
29
- * "…"` CREATES one) — rather than throwing `no such table` at construction and taking down a whole state's geocode
30
- * (#568). A missing table makes the lookup a no-op miss.
27
+ * Returns true when `name` is a table in the open database.
28
+ * Returns false when the check itself fails.
29
+ *
30
+ * The street-level lookups call it so that an empty extract, such as an interrupted build
31
+ * or a zero-byte file, makes every lookup miss instead of throwing `no such table`.
31
32
  */
32
33
  export declare function hasTable<DB>(db: DatabaseClient<DB>, name: string): boolean;
33
34
  /**
34
- * True when `table` exists in the open database AND carries `column`.
35
+ * Returns true when `table` exists in the open database and has `column`.
35
36
  *
36
- * The column-level sibling of {@link hasTable}, and it exists for the same reason one layer down: an artifact built
37
- * before a column was added is still a VALID artifact, and a reader that unconditionally names the new column in its
38
- * `SELECT` turns "this gazetteer is a build behind" into `no such column` at the first keystroke. Probe once at
39
- * construction and shape the query — `table_info` is a PRAGMA, so it must not sit on a per-query path.
37
+ * An artifact built before a column was added is still valid, so readers call this once
38
+ * at construction and leave the column out of their queries when it is missing.
39
+ * Avoid calling it per query, because it runs a pragma.
40
40
  *
41
- * Note the interpolation: PRAGMA does not take bound parameters, so `table` is spliced. Every caller passes a
42
- * module-level constant; never pass user input.
41
+ * The pragma does not accept bound parameters, so `table` is interpolated into the SQL.
42
+ * Pass only constants.
43
43
  */
44
44
  export declare function hasColumn<DB>(db: DatabaseClient<DB>, table: string, column: string): boolean;
45
45
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRo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,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAG7E;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,UAAU,EAAE,UAAU,KAAK,GAAG,GAAG,IAAI,CAAA;AAE5G;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,EAAE,EAAE,EACrE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EACtB,GAAG,EAAE,MAAM,GACT,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAI9B;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,UAAU,EAAE,UAAU,KAAK,GAAG,EAAE,CAAA;AAEvG;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,SAAS,aAAa,EAAE,EAAE,GAAG,EAAE,EAAE,EACrE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EACtB,GAAG,EAAE,MAAM,GACT,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAI9B;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAM5F"}
@@ -2,30 +2,30 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * Small shared helpers for the SQLite-backed lookups.
5
+ * @file Shared helpers for the SQLite-backed lookups.
7
6
  */
8
7
  import { allRows, getRow } from "@mailwoman/core/utils";
9
8
  import { hasColumn as columnExists, tableExists } from "@mailwoman/sqlite/introspection";
10
9
  /**
11
- * Prepare a single-row query while preserving its exact parameter tuple at every call site.
10
+ * Prepares a single-row query with a typed parameter tuple.
12
11
  */
13
12
  export function prepareGet(db, sql) {
14
13
  const statement = db.prepare(sql);
15
14
  return (...parameters) => getRow(statement, ...parameters);
16
15
  }
17
16
  /**
18
- * Prepare a multi-row query while preserving its exact parameter tuple at every call site.
17
+ * Prepares a multi-row query with a typed parameter tuple.
19
18
  */
20
19
  export function prepareAll(db, sql) {
21
20
  const statement = db.prepare(sql);
22
21
  return (...parameters) => allRows(statement, ...parameters);
23
22
  }
24
23
  /**
25
- * True when `name` is a table in the open database. The street-level lookups use this to degrade gracefully on an
26
- * empty/tableless extract — an interrupted `build-*-extract.ts`, or a stray 0-byte file (e.g. `sqlite3 <missing>.db
27
- * "…"` CREATES one) — rather than throwing `no such table` at construction and taking down a whole state's geocode
28
- * (#568). A missing table makes the lookup a no-op miss.
24
+ * Returns true when `name` is a table in the open database.
25
+ * Returns false when the check itself fails.
26
+ *
27
+ * The street-level lookups call it so that an empty extract, such as an interrupted build
28
+ * or a zero-byte file, makes every lookup miss instead of throwing `no such table`.
29
29
  */
30
30
  export function hasTable(db, name) {
31
31
  try {
@@ -36,15 +36,14 @@ export function hasTable(db, name) {
36
36
  }
37
37
  }
38
38
  /**
39
- * True when `table` exists in the open database AND carries `column`.
39
+ * Returns true when `table` exists in the open database and has `column`.
40
40
  *
41
- * The column-level sibling of {@link hasTable}, and it exists for the same reason one layer down: an artifact built
42
- * before a column was added is still a VALID artifact, and a reader that unconditionally names the new column in its
43
- * `SELECT` turns "this gazetteer is a build behind" into `no such column` at the first keystroke. Probe once at
44
- * construction and shape the query — `table_info` is a PRAGMA, so it must not sit on a per-query path.
41
+ * An artifact built before a column was added is still valid, so readers call this once
42
+ * at construction and leave the column out of their queries when it is missing.
43
+ * Avoid calling it per query, because it runs a pragma.
45
44
  *
46
- * Note the interpolation: PRAGMA does not take bound parameters, so `table` is spliced. Every caller passes a
47
- * module-level constant; never pass user input.
45
+ * The pragma does not accept bound parameters, so `table` is interpolated into the SQL.
46
+ * Pass only constants.
48
47
  */
49
48
  export function hasColumn(db, table, column) {
50
49
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/sqlite/utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAWxF;;GAEG;AACH,MAAM,UAAU,UAAU,CACzB,EAAsB,EACtB,GAAW;IAEX,MAAM,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAEjC,OAAO,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,MAAM,CAAM,SAAS,EAAE,GAAG,UAAU,CAAC,CAAA;AAChE,CAAC;AAOD;;GAEG;AACH,MAAM,UAAU,UAAU,CACzB,EAAsB,EACtB,GAAW;IAEX,MAAM,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAEjC,OAAO,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,OAAO,CAAM,SAAS,EAAE,GAAG,UAAU,CAAC,CAAA;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAK,EAAsB,EAAE,IAAY;IAChE,IAAI,CAAC;QACJ,OAAO,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IAC7B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAA;IACb,CAAC;AACF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAK,EAAsB,EAAE,KAAa,EAAE,MAAc;IAClF,IAAI,CAAC;QACJ,OAAO,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,MA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AC;AACF,CAAC"}
@@ -3,49 +3,41 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
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.
6
+ * Schema for the street-centroid extract. It groups address-point rows by street.
21
7
  */
22
8
  import type { Kysely } from "kysely";
23
9
  import type { NameKey, StreetKey } from "#street/normalize";
24
10
  /**
25
- * One street roll-up. `(street_norm, postcode, locality_base)` is unique. `lat`/`lon` are the UNWEIGHTED mean of the
26
- * group's member address points (each source row = one point), so a cross-group weighted mean (`SUM(lat*point_count) /
27
- * SUM(point_count)`) reconstructs the grand centroid. `min_/max_lat/lon` are the group's extent (the reader turns the
28
- * bbox diagonal into an honest `uncertainty_m`).
11
+ * One row per street, postcode and commune.
12
+ *
13
+ * The tuple `(street_norm, postcode, locality_base)` is unique.
14
+ * The reader combines rows by `SUM(lat * point_count) / SUM(point_count)` to get a
15
+ * street's centroid across every postcode and arrondissement it spans.
16
+ *
17
+ * It converts the bounding-box diagonal from the `min_*` and `max_*` columns into `uncertainty_m`.
29
18
  */
30
19
  export interface StreetCentroidTable {
31
20
  /**
32
- * Shared `normalizeStreetForKeyLocale` of the street — the build/query-consistent probe key.
21
+ * The street key from `normalizeStreetForKeyLocale`, which both the builder and the reader use.
33
22
  */
34
23
  street_norm: StreetKey;
35
24
  /**
36
- * The 5-digit postcode of this group, or null when the source row carried none.
25
+ * The postcode of this group, or null when the source row has none.
37
26
  */
38
27
  postcode: string | null;
39
28
  /**
40
- * Arrondissement-stripped commune (`stripArrondissement(normalizeLocalityForKey(commune))`) — the fallback scope.
29
+ * The commune key with any arrondissement removed.
30
+ *
31
+ * BAN stores Paris, Lyon and Marseille per arrondissement, but a query usually gives the base commune.
32
+ * The reader uses this column when the query has no postcode.
41
33
  */
42
34
  locality_base: NameKey;
43
35
  /**
44
- * Weighted-mean centroid latitude of the street's member points.
36
+ * The mean latitude of the group's member address points.
45
37
  */
46
38
  lat: number;
47
39
  /**
48
- * Weighted-mean centroid longitude of the street's member points.
40
+ * The mean longitude of the group's member address points.
49
41
  */
50
42
  lon: number;
51
43
  min_lat: number;
@@ -53,31 +45,32 @@ export interface StreetCentroidTable {
53
45
  min_lon: number;
54
46
  max_lon: number;
55
47
  /**
56
- * Member address-point count — the weight for a cross-group centroid aggregate.
48
+ * The number of member address points.
49
+ * This value weights the cross-row centroid.
57
50
  */
58
51
  point_count: number;
59
52
  /**
60
- * A representative street name as it appeared in the source (display / debugging).
53
+ * One street name as it appeared in the source, kept for display and debugging.
61
54
  */
62
55
  street_raw: string;
63
56
  /**
64
- * Provenance: the register this street was derived from (e.g. `ban:fr`).
57
+ * The source register, such as `ban:fr`.
65
58
  */
66
59
  source: string;
67
60
  /**
68
- * The pinned data release the underlying points came from.
61
+ * The data release that the member points came from.
69
62
  */
70
63
  release: string;
71
64
  /**
72
- * #727 phase-4c: `foldStreetSurface(street_raw)` — the contract-fold street-NAME existence key for
73
- * {@link StreetLocalityEvidence}. Distinct from `street_norm` (the `street-normalize` geocoding key): the
74
- * name-evidence rerank folds the model's street surface with the SAME `foldStreetSurface` used to build this column
75
- * (the fold-parity contract), so it must not drift from `street_norm`'s richer normalizer. Indexed (`idx_sc_name`)
76
- * for a direct seek.
65
+ * The value of `foldStreetSurface(street_raw)`, used by {@link StreetLocalityEvidence}
66
+ * to check that a street name exists.
67
+ *
68
+ * The name-evidence rerank folds the model's street text with the same function, so this
69
+ * column must use `foldStreetSurface` and must not follow the `street_norm` normalizer.
70
+ * The type is a plain string because `foldStreetSurface` differs from the
71
+ * {@link NameKey} fold that other `name_key` columns use.
77
72
  *
78
- * Deliberately UNBRANDED despite the `name_key` column name: `foldStreetSurface` is a different fold from the
79
- * {@link NameKey} one every other `name_key` column carries, and giving it that brand would invite exactly the
80
- * cross-fold probe the brands exist to stop.
73
+ * A `NameKey` type would allow a probe with the wrong fold.
81
74
  */
82
75
  name_key: string;
83
76
  }
@@ -88,18 +81,20 @@ export interface StreetCentroidDatabase {
88
81
  street_centroid: StreetCentroidTable;
89
82
  }
90
83
  /**
91
- * The `street_centroid` columns in INSERT order. The builder's positional prepared statement derives its placeholder
92
- * list from this, so the positional order can't drift from the DDL / the reader.
84
+ * The `street_centroid` columns in insert order.
85
+ *
86
+ * The builder derives the placeholders of its positional insert from this list.
93
87
  */
94
88
  export declare const STREET_CENTROID_COLUMNS: readonly ["street_norm", "postcode", "locality_base", "lat", "lon", "min_lat", "max_lat", "min_lon", "max_lon", "point_count", "street_raw", "source", "release", "name_key"];
95
89
  /**
96
- * Create the `street_centroid` table — called before the streaming bulk load.
90
+ * Creates the `street_centroid` table before the bulk load.
97
91
  */
98
92
  export declare function createStreetCentroidTable(db: Kysely<StreetCentroidDatabase>): Promise<void>;
99
93
  /**
100
- * Create the probe indexes: the two geocoding-scope indexes (postcode, locality-base) the resolver reader relies on,
101
- * plus `idx_sc_name` — the #727 phase-4c name-existence key for a direct `name_key = ?` seek (the unscoped fragment
102
- * lookup; without it that query skip-scans `idx_sc_postcode` at ~5 ms/probe).
94
+ * Creates the postcode and locality indexes that the reader probes, plus `idx_sc_name`.
95
+ *
96
+ * The `idx_sc_name` index serves the unscoped `name_key = ?` lookup.
97
+ * Without it, SQLite would skip-scan `idx_sc_postcode`.
103
98
  */
104
99
  export declare function createStreetCentroidIndexes(db: Kysely<StreetCentroidDatabase>): Promise<void>;
105
100
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../lib/street/centroid/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,WAAW,EAAE,SAAS,CAAA;IACtB;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,eAAe,EAAE,mBAAmB,CAAA;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,YACnC,aAAa,EACb,UAAU,EACV,eAAe,EACf,KAAK,EACL,KAAK,EACL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AE,mBAAmB,CAAA;CACpC;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,YACnC,aAAa,EACb,UAAU,EACV,eAAe,EACf,KAAK,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,UAAU,CACD,CAAA;AAEV;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,MAAM,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBjG;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,EAAE,EAAE,MAAM,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUnG"}
@@ -3,25 +3,12 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
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.
6
+ * Schema for the street-centroid extract. It groups address-point rows by street.
21
7
  */
22
8
  /**
23
- * The `street_centroid` columns in INSERT order. The builder's positional prepared statement derives its placeholder
24
- * list from this, so the positional order can't drift from the DDL / the reader.
9
+ * The `street_centroid` columns in insert order.
10
+ *
11
+ * The builder derives the placeholders of its positional insert from this list.
25
12
  */
26
13
  export const STREET_CENTROID_COLUMNS = [
27
14
  "street_norm",
@@ -40,7 +27,7 @@ export const STREET_CENTROID_COLUMNS = [
40
27
  "name_key",
41
28
  ];
42
29
  /**
43
- * Create the `street_centroid` table — called before the streaming bulk load.
30
+ * Creates the `street_centroid` table before the bulk load.
44
31
  */
45
32
  export async function createStreetCentroidTable(db) {
46
33
  await db.schema
@@ -62,9 +49,10 @@ export async function createStreetCentroidTable(db) {
62
49
  .execute();
63
50
  }
64
51
  /**
65
- * Create the probe indexes: the two geocoding-scope indexes (postcode, locality-base) the resolver reader relies on,
66
- * plus `idx_sc_name` — the #727 phase-4c name-existence key for a direct `name_key = ?` seek (the unscoped fragment
67
- * lookup; without it that query skip-scans `idx_sc_postcode` at ~5 ms/probe).
52
+ * Creates the postcode and locality indexes that the reader probes, plus `idx_sc_name`.
53
+ *
54
+ * The `idx_sc_name` index serves the unscoped `name_key = ?` lookup.
55
+ * Without it, SQLite would skip-scan `idx_sc_postcode`.
68
56
  */
69
57
  export async function createStreetCentroidIndexes(db) {
70
58
  await db.schema.createIndex("idx_sc_postcode").on("street_centroid").columns(["postcode", "street_norm"]).execute();
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../lib/street/centroid/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA0EH;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,aAAa;IACb,UAAU;IACV,eAAe;IACf,KAAK;IACL,KAAK;IACL,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,UAAU;CACD,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC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AAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACjD,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAAkC;IACnF,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;IAEnH,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,iBAAiB,CAAC;SAC9B,EAAE,CAAC,iBAAiB,CAAC;SACrB,OAAO,CAAC,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;SACzC,OAAO,EAAE,CAAA;IAEX,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;AACjG,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file SQLite implementation of core's `StreetCentroidLookup`.
6
+ */
7
+ import type { StreetCentroidHit, StreetCentroidLookup } from "@mailwoman/core/resolver";
8
+ import type { PathBuilderLike } from "path-ts";
9
+ import { type StreetLocale } from "#street/normalize";
10
+ /**
11
+ * Finds a street's centroid and extent-based uncertainty by street name,
12
+ * scoped by postcode and then by base commune.
13
+ */
14
+ export declare class StreetCentroidSqliteLookup implements StreetCentroidLookup {
15
+ #private;
16
+ /**
17
+ * The extract defaults to the `fr` street-normalization locale.
18
+ * A mismatch with the extract's locale makes every key miss.
19
+ */
20
+ constructor(dbPath: PathBuilderLike, opts?: {
21
+ streetLocale?: StreetLocale;
22
+ });
23
+ find(query: {
24
+ street: string;
25
+ postcode?: string;
26
+ locality?: string;
27
+ }): StreetCentroidHit | null;
28
+ [Symbol.dispose](): void;
29
+ }
30
+ //# sourceMappingURL=centroid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centroid.d.ts","sourceRoot":"","sources":["../../lib/street/centroid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAGvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,EAMN,KAAK,YAAY,EAEjB,MAAM,mBAAmB,CAAA;AAkC1B;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,oBAAoB;;IAMtE;;;OAGG;IACH,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,GAAE;QAAE,YAAY,CAAC,EAAE,YAAY,CAAA;KAAO,EAgB9E;IAED,IAAI,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,iBAAiB,GAAG,IAAI,CA0B9F;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAEvB;CACD"}
@@ -2,54 +2,43 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * SQLite implementation of core's `StreetCentroidLookup` (#1042): the street-level tier BELOW the
7
- * exact address-point tier and ABOVE admin-centroid resolution. Given a street name (no house
8
- * number) plus a postcode/commune scope, it returns the street's CENTROID + an honest extent-derived
9
- * uncertainty from the derived `street-centroids-<cc>.db` roll-up.
10
- *
11
- * Query-side normalization is THE shared normalizer (`street-normalize.ts`), selected per the extract's
12
- * `streetLocale`, so build-side and probe-side keys agree by construction. The commune scope folds
13
- * through `normalizeLocalityForKey` + `stripArrondissement` (BAN names Paris/Lyon/Marseille per
14
- * arrondissement; a query names the base commune).
15
- *
16
- * Scope order is most-selective first: `postcode`, then the base commune. Each scope WEIGHTED-
17
- * aggregates (by `point_count`) across the matched rows in SQL, so a commune-scope probe returns the
18
- * street's grand centroid over every postcode/arrondissement it spans — one row, one hit. Matching is
19
- * exact-after-normalization only (no fuzzy street matching in this tier).
5
+ * @file SQLite implementation of core's `StreetCentroidLookup`.
20
6
  */
21
7
  import { haversineKm } from "@mailwoman/spatial";
22
8
  import { DatabaseClient } from "@mailwoman/sqlite/client";
23
9
  import { hasTable, prepareGet } from "#sqlite-utils";
24
10
  import { normalizeLocalityForKey, normalizeStreetForKeyLocale, streetLocaleForSurface, stripArrondissement, } from "#street/normalize";
25
11
  /**
26
- * Weighted-centroid aggregate over a WHERE-filtered set. `SUM(coord*n)/SUM(n)` reconstructs the grand centroid.
12
+ * The aggregate columns that weight each row's centroid by `point_count` to
13
+ * reconstruct the combined centroid.
27
14
  */
28
15
  const AGG_SELECT = "SUM(lat * point_count) / SUM(point_count) AS lat, " +
29
16
  "SUM(lon * point_count) / SUM(point_count) AS lon, " +
30
17
  "MIN(min_lat) AS min_lat, MAX(max_lat) AS max_lat, MIN(min_lon) AS min_lon, MAX(max_lon) AS max_lon, " +
31
18
  "MAX(source) AS source, MAX(release) AS release";
32
19
  /**
33
- * Half the bbox diagonal, in METERS — an honest coarse radius for a street centroid.
20
+ * Half the bounding-box diagonal in meters, used as a coarse uncertainty radius for a street centroid.
34
21
  */
35
22
  function extentRadiusM(minLat, maxLat, minLon, maxLon) {
36
23
  return Math.round(haversineKm(minLat, minLon, maxLat, maxLon) * 500);
37
24
  }
25
+ /**
26
+ * Finds a street's centroid and extent-based uncertainty by street name,
27
+ * scoped by postcode and then by base commune.
28
+ */
38
29
  export class StreetCentroidSqliteLookup {
39
30
  #db;
40
31
  #locale;
41
32
  #byPostcode;
42
33
  #byLocality;
43
34
  /**
44
- * @param dbPath Extract path.
45
- * @param opts.streetLocale The street-normalization locale this extract was BUILT with — must match, or every key
46
- * misses. Defaults to `"fr"` (BAN is the French national register; the tier is FR-only today).
35
+ * The extract defaults to the `fr` street-normalization locale.
36
+ * A mismatch with the extract's locale makes every key miss.
47
37
  */
48
38
  constructor(dbPath, opts = {}) {
49
39
  this.#db = new DatabaseClient(dbPath, { readOnly: true });
50
40
  this.#locale = opts.streetLocale ?? "fr";
51
- // Degrade gracefully on an empty/tableless extract (interrupted build, stray 0-byte file): with no
52
- // `street_centroid` table this lookup is a no-op miss, not a crash (mirrors the address-point reader).
41
+ // An extract without a `street_centroid` table makes every lookup miss.
53
42
  if (hasTable(this.#db, "street_centroid")) {
54
43
  this.#byPostcode = prepareGet(this.#db, `SELECT ${AGG_SELECT} FROM street_centroid WHERE postcode = ? AND street_norm = ?`);
55
44
  this.#byLocality = prepareGet(this.#db, `SELECT ${AGG_SELECT} FROM street_centroid WHERE locality_base = ? AND street_norm = ?`);
@@ -61,7 +50,7 @@ export class StreetCentroidSqliteLookup {
61
50
  const streetNorm = normalizeStreetForKeyLocale(query.street, streetLocaleForSurface(query.street, this.#locale));
62
51
  if (!streetNorm)
63
52
  return null;
64
- let row;
53
+ let row = null;
65
54
  if (query.postcode?.trim()) {
66
55
  row = this.#byPostcode(query.postcode.trim(), streetNorm);
67
56
  }
@@ -83,4 +72,4 @@ export class StreetCentroidSqliteLookup {
83
72
  this.#db[Symbol.dispose]();
84
73
  }
85
74
  }
86
- //# sourceMappingURL=index.js.map
75
+ //# sourceMappingURL=centroid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centroid.js","sourceRoot":"","sources":["../../lib/street/centroid.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,0B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C,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAA;IAC3B,CAAC;CACD"}
@@ -5,13 +5,14 @@
5
5
  *
6
6
  * Build a street-morphology FST from libpostal's street_types dictionaries. The morphology FST maps
7
7
  * street-typing affixes (Street/Avenue/rue/Calle/Straße/...) to a single synthetic placetype
8
- * `"street_affix"` — distinct from the admin FST in source data, intent, and binary artifact.
8
+ * `"street_affix"`. Its source data and purpose differ from the admin FST.
9
+ * It also produces a separate binary artifact.
9
10
  *
10
11
  * The morphology FST closes the inference-time vacuum identified by the v0.6.1 postmortem: street
11
12
  * tokens have no admin-FST anchor, so synth-street training pushed the model toward over-emitting
12
13
  * `dependent_locality` on subcomponents. With the morphology FST, the neural decoder gets
13
14
  * positive evidence for street-typing affixes and the adjacent name tokens, plus negative
14
- * evidence away from `dependent_locality` on the same neighbours.
15
+ * evidence away from `dependent_locality` on the same neighbors.
15
16
  *
16
17
  * Design rationale + the four-layer street-supplement architecture lives in
17
18
  * `docs/articles/concepts/street-supplement-architecture.md`.
@@ -22,25 +23,34 @@
22
23
  * Output: an `FSTMatcher` ready to serialize via `serializeFST` to e.g.
23
24
  * `fst-street-morphology.bin`.
24
25
  */
26
+ import { type PathBuilderLike } from "path-ts";
25
27
  import { FSTMatcher } from "#fst/matcher";
26
28
  import type { FSTProvenance } from "#fst/types";
27
29
  export interface BuildStreetMorphologyFSTOpts {
28
30
  /**
29
31
  * Path to the `core/data/libpostal/dictionaries` directory containing per-locale subfolders.
30
32
  */
31
- dictionariesDir: string;
33
+ dictionariesDir: PathBuilderLike;
32
34
  /**
33
- * Optional locale filter — only ingest these locale subfolders. Defaults to all that have a `street_types.txt`.
35
+ * Optional locale filter — only ingest these locale subfolders.
36
+ *
37
+ * @defaultValue all that have a `street_types.txt`.
34
38
  */
35
39
  locales?: string[];
36
40
  /**
37
- * Minimum length (in characters, post-normalization) of variant surface forms to insert into the trie. Defaults to 3.
41
+ * Minimum length (in characters, post-normalization) of variant surface forms to insert into the trie.
42
+ *
43
+ * Rationale: libpostal's street_types dictionaries contain 1-2 character abbreviations
44
+ * (`a`, `b`, `av`, `bd`, `br`, ...) that collide with non-affix tokens at parse time,
45
+ * including US state abbreviations (`or`, `CA`, `ND`, `NY`).
46
+ * Single-letter unit designators and other short tokens also collide.
47
+ *
48
+ * Empirically these collisions push the morphology prior to mis-tag state
49
+ * abbreviations as `street_suffix`.
50
+ *
51
+ * A minimum length of 3 retains useful forms (`ave`, `blvd`, `rue`, `str`) while filtering out the noise.
38
52
  *
39
- * Rationale: libpostal's street_types dictionaries contain 1-2 character abbreviations (`a`, `b`, `av`, `bd`, `br`,
40
- * ...) that collide with non-affix tokens at parse time — notably US state abbreviations (`OR`, `CA`, `ND`, `NY`),
41
- * single-letter unit designators, and arbitrary short tokens. Empirically these collisions push the morphology prior
42
- * to mis-tag state abbreviations as `street_suffix`. A minimum length of 3 retains useful forms (`ave`, `blvd`,
43
- * `rue`, `str`) while filtering out the noise.
53
+ * @defaultValue `3`
44
54
  */
45
55
  minVariantLength?: number;
46
56
  /**