@mailwoman/resolver-wof-sqlite 9.2.0 → 9.4.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 (493) hide show
  1. package/README.md +16 -19
  2. package/lib/address/index.ts +9 -0
  3. package/{address-point-interpolation.ts → lib/address/point-interpolation.ts} +25 -24
  4. package/{address-point-schema.ts → lib/address/point-schema.ts} +18 -4
  5. package/lib/address/point.ts +328 -0
  6. package/{ancestry-backfill.ts → lib/ancestry/backfill.ts} +14 -19
  7. package/{ancestry.ts → lib/ancestry/index.ts} +5 -4
  8. package/{build-candidate.ts → lib/build-candidate.ts} +99 -79
  9. package/{build-slim.ts → lib/build-slim.ts} +150 -165
  10. package/{candidate → lib/candidate}/alias-bags.ts +8 -6
  11. package/{candidate → lib/candidate}/ancestors-sidecar.ts +13 -15
  12. package/{candidate → lib/candidate}/country-display-names.ts +2 -2
  13. package/lib/candidate/extract-fold.ts +219 -0
  14. package/{candidate → lib/candidate}/name-roles.ts +17 -16
  15. package/{candidate → lib/candidate}/own-name.ts +2 -1
  16. package/{candidate → lib/candidate}/place-attrs.ts +3 -3
  17. package/{candidate-ancestors-schema.ts → lib/candidate-ancestors-schema.ts} +4 -4
  18. package/{candidate-fts.ts → lib/candidate-fts.ts} +3 -3
  19. package/{candidate-importance.ts → lib/candidate-importance.ts} +53 -57
  20. package/{candidate-lookup.ts → lib/candidate-lookup.ts} +84 -80
  21. package/{candidate-schema.ts → lib/candidate-schema.ts} +6 -6
  22. package/{candidate-scoring.ts → lib/candidate-scoring.ts} +15 -22
  23. package/{capital-schema.ts → lib/capital-schema.ts} +5 -6
  24. package/{capitals.ts → lib/capitals.ts} +2 -2
  25. package/{coincident-roles.ts → lib/coincident-roles.ts} +9 -13
  26. package/{convention.ts → lib/convention/index.ts} +3 -3
  27. package/{convention-schema.ts → lib/convention/schema.ts} +2 -2
  28. package/{coverage-manifest-schema.ts → lib/coverage-manifest-schema.ts} +10 -10
  29. package/{currency-backfill.ts → lib/currency-backfill.ts} +126 -41
  30. package/lib/env.ts +50 -0
  31. package/{exact-match.ts → lib/exact-match.ts} +23 -14
  32. package/{sharding.ts → lib/extracts.ts} +61 -58
  33. package/{fst-autocomplete.ts → lib/fst/autocomplete.ts} +4 -4
  34. package/{fst-builder.ts → lib/fst/builder.ts} +17 -16
  35. package/{fst-deserialize-web.ts → lib/fst/deserialize-web.ts} +27 -87
  36. package/lib/fst/format.ts +106 -0
  37. package/{fst-freshness.ts → lib/fst/freshness.ts} +40 -74
  38. package/lib/fst/index.ts +14 -0
  39. package/{fst-matcher.ts → lib/fst/matcher.ts} +1 -1
  40. package/{fst-serialize.ts → lib/fst/serialize.ts} +37 -115
  41. package/{fst-types.ts → lib/fst/types.ts} +4 -2
  42. package/{fts.ts → lib/fts/index.ts} +24 -19
  43. package/{fts-query.ts → lib/fts/query.ts} +1 -1
  44. package/{geonames-aliases.ts → lib/geonames/aliases.ts} +13 -13
  45. package/lib/geonames/index.ts +8 -0
  46. package/{geonames-postal.ts → lib/geonames/postal.ts} +14 -13
  47. package/{index.ts → lib/index.ts} +37 -37
  48. package/{interpolation.ts → lib/interpolation.ts} +28 -26
  49. package/{lookup.ts → lib/lookup.ts} +130 -142
  50. package/lib/nsul/index.ts +8 -0
  51. package/lib/nsul/lookup.ts +144 -0
  52. package/lib/nsul/schema.ts +130 -0
  53. package/{place-importance-schema.ts → lib/place-importance-schema.ts} +7 -16
  54. package/lib/poi/index.ts +8 -0
  55. package/{poi-lookup.ts → lib/poi/lookup.ts} +22 -29
  56. package/{poi-schema.ts → lib/poi/schema.ts} +3 -4
  57. package/{postal-city-alias-lookup.ts → lib/postal/city-alias-lookup.ts} +14 -20
  58. package/{postal-city-candidate-schema.ts → lib/postal/city-candidate-schema.ts} +2 -2
  59. package/lib/postal/index.ts +9 -0
  60. package/{postcode-point-lookup.ts → lib/postcode-point-lookup.ts} +17 -15
  61. package/{primary-preference.ts → lib/primary-preference.ts} +43 -14
  62. package/{proximity-rerank.ts → lib/proximity-rerank.ts} +2 -2
  63. package/{ranking-weights.ts → lib/ranking-weights.ts} +30 -4
  64. package/{region-keys.ts → lib/region-keys.ts} +9 -9
  65. package/{reverse.ts → lib/reverse.ts} +34 -47
  66. package/{schema.ts → lib/schema.ts} +10 -0
  67. package/{search-fetch.ts → lib/search-fetch.ts} +29 -29
  68. package/{sqlite-convention-source.ts → lib/sqlite-convention-source.ts} +9 -10
  69. package/{sqlite-utils.ts → lib/sqlite-utils.ts} +14 -19
  70. package/{street-centroid-schema.ts → lib/street/centroid-schema.ts} +5 -5
  71. package/{street-centroid.ts → lib/street/centroid.ts} +15 -22
  72. package/lib/street/index.ts +13 -0
  73. package/{street-morphology-fst-builder.ts → lib/street/morphology-fst-builder.ts} +24 -14
  74. package/{street-morphology-fst-loader.ts → lib/street/morphology-fst-loader.ts} +14 -12
  75. package/{street-name-lookup.ts → lib/street/name-lookup.ts} +14 -30
  76. package/{street-normalize.ts → lib/street/normalize.ts} +86 -20
  77. package/{street-segment-schema.ts → lib/street/segment-schema.ts} +7 -7
  78. package/{types.ts → lib/types.ts} +18 -12
  79. package/{unified-schema.ts → lib/unified-schema.ts} +20 -24
  80. package/lib/uprn/existence.ts +84 -0
  81. package/lib/uprn/index.ts +9 -0
  82. package/{uprn-lookup.ts → lib/uprn/lookup.ts} +14 -19
  83. package/{uprn-schema.ts → lib/uprn/schema.ts} +3 -3
  84. package/lib/weights-overlay-linker.ts +879 -0
  85. package/out/address/index.d.ts +9 -0
  86. package/out/address/index.d.ts.map +1 -0
  87. package/out/address/index.js +9 -0
  88. package/out/address/index.js.map +1 -0
  89. package/out/{address-point-interpolation.d.ts → address/point-interpolation.d.ts} +12 -11
  90. package/out/address/point-interpolation.d.ts.map +1 -0
  91. package/out/{address-point-interpolation.js → address/point-interpolation.js} +18 -18
  92. package/out/address/point-interpolation.js.map +1 -0
  93. package/out/{address-point-schema.d.ts → address/point-schema.d.ts} +16 -6
  94. package/out/address/point-schema.d.ts.map +1 -0
  95. package/out/{address-point-schema.js → address/point-schema.js} +7 -3
  96. package/out/address/point-schema.js.map +1 -0
  97. package/out/{address-point.d.ts → address/point.d.ts} +19 -9
  98. package/out/address/point.d.ts.map +1 -0
  99. package/out/address/point.js +222 -0
  100. package/out/address/point.js.map +1 -0
  101. package/out/{ancestry-backfill.d.ts → ancestry/backfill.d.ts} +7 -5
  102. package/out/ancestry/backfill.d.ts.map +1 -0
  103. package/out/{ancestry-backfill.js → ancestry/backfill.js} +12 -16
  104. package/out/ancestry/backfill.js.map +1 -0
  105. package/out/{ancestry.d.ts → ancestry/index.d.ts} +4 -3
  106. package/out/ancestry/index.d.ts.map +1 -0
  107. package/out/{ancestry.js → ancestry/index.js} +3 -2
  108. package/out/ancestry/index.js.map +1 -0
  109. package/out/build-candidate.d.ts +32 -24
  110. package/out/build-candidate.d.ts.map +1 -1
  111. package/out/build-candidate.js +60 -54
  112. package/out/build-candidate.js.map +1 -1
  113. package/out/build-slim.d.ts +4 -4
  114. package/out/build-slim.d.ts.map +1 -1
  115. package/out/build-slim.js +124 -139
  116. package/out/build-slim.js.map +1 -1
  117. package/out/candidate/alias-bags.d.ts +5 -3
  118. package/out/candidate/alias-bags.d.ts.map +1 -1
  119. package/out/candidate/alias-bags.js +2 -2
  120. package/out/candidate/alias-bags.js.map +1 -1
  121. package/out/candidate/ancestors-sidecar.d.ts +9 -10
  122. package/out/candidate/ancestors-sidecar.d.ts.map +1 -1
  123. package/out/candidate/ancestors-sidecar.js +7 -7
  124. package/out/candidate/ancestors-sidecar.js.map +1 -1
  125. package/out/candidate/country-display-names.d.ts +1 -1
  126. package/out/candidate/country-display-names.d.ts.map +1 -1
  127. package/out/candidate/country-display-names.js +1 -1
  128. package/out/candidate/country-display-names.js.map +1 -1
  129. package/out/candidate/extract-fold.d.ts +41 -0
  130. package/out/candidate/extract-fold.d.ts.map +1 -0
  131. package/out/candidate/extract-fold.js +153 -0
  132. package/out/candidate/extract-fold.js.map +1 -0
  133. package/out/candidate/name-roles.d.ts +13 -11
  134. package/out/candidate/name-roles.d.ts.map +1 -1
  135. package/out/candidate/name-roles.js +11 -10
  136. package/out/candidate/name-roles.js.map +1 -1
  137. package/out/candidate/own-name.d.ts +1 -1
  138. package/out/candidate/own-name.d.ts.map +1 -1
  139. package/out/candidate/own-name.js +2 -1
  140. package/out/candidate/own-name.js.map +1 -1
  141. package/out/candidate/place-attrs.d.ts +3 -3
  142. package/out/candidate/place-attrs.d.ts.map +1 -1
  143. package/out/candidate/place-attrs.js +1 -1
  144. package/out/candidate/place-attrs.js.map +1 -1
  145. package/out/candidate-ancestors-schema.d.ts +4 -4
  146. package/out/candidate-ancestors-schema.d.ts.map +1 -1
  147. package/out/candidate-ancestors-schema.js +2 -2
  148. package/out/candidate-ancestors-schema.js.map +1 -1
  149. package/out/candidate-fts.d.ts +3 -3
  150. package/out/candidate-fts.d.ts.map +1 -1
  151. package/out/candidate-fts.js +1 -1
  152. package/out/candidate-fts.js.map +1 -1
  153. package/out/candidate-importance.d.ts +16 -16
  154. package/out/candidate-importance.d.ts.map +1 -1
  155. package/out/candidate-importance.js +46 -51
  156. package/out/candidate-importance.js.map +1 -1
  157. package/out/candidate-lookup.d.ts +16 -14
  158. package/out/candidate-lookup.d.ts.map +1 -1
  159. package/out/candidate-lookup.js +67 -63
  160. package/out/candidate-lookup.js.map +1 -1
  161. package/out/candidate-schema.d.ts +6 -6
  162. package/out/candidate-schema.d.ts.map +1 -1
  163. package/out/candidate-schema.js +1 -1
  164. package/out/candidate-schema.js.map +1 -1
  165. package/out/candidate-scoring.d.ts +7 -7
  166. package/out/candidate-scoring.d.ts.map +1 -1
  167. package/out/candidate-scoring.js +10 -14
  168. package/out/candidate-scoring.js.map +1 -1
  169. package/out/capital-schema.d.ts +3 -3
  170. package/out/capital-schema.d.ts.map +1 -1
  171. package/out/capital-schema.js +2 -2
  172. package/out/capital-schema.js.map +1 -1
  173. package/out/capitals.d.ts +1 -1
  174. package/out/capitals.d.ts.map +1 -1
  175. package/out/capitals.js +2 -2
  176. package/out/capitals.js.map +1 -1
  177. package/out/coincident-roles.d.ts +7 -6
  178. package/out/coincident-roles.d.ts.map +1 -1
  179. package/out/coincident-roles.js +2 -4
  180. package/out/coincident-roles.js.map +1 -1
  181. package/out/{convention.d.ts → convention/index.d.ts} +4 -4
  182. package/out/convention/index.d.ts.map +1 -0
  183. package/out/{convention.js → convention/index.js} +2 -2
  184. package/out/convention/index.js.map +1 -0
  185. package/out/{convention-schema.d.ts → convention/schema.d.ts} +2 -2
  186. package/out/convention/schema.d.ts.map +1 -0
  187. package/out/{convention-schema.js → convention/schema.js} +3 -3
  188. package/out/convention/schema.js.map +1 -0
  189. package/out/coverage-manifest-schema.d.ts +8 -8
  190. package/out/coverage-manifest-schema.d.ts.map +1 -1
  191. package/out/coverage-manifest-schema.js +5 -4
  192. package/out/coverage-manifest-schema.js.map +1 -1
  193. package/out/currency-backfill.d.ts +51 -7
  194. package/out/currency-backfill.d.ts.map +1 -1
  195. package/out/currency-backfill.js +65 -49
  196. package/out/currency-backfill.js.map +1 -1
  197. package/out/env.d.ts +43 -0
  198. package/out/env.d.ts.map +1 -0
  199. package/out/env.js +48 -0
  200. package/out/env.js.map +1 -0
  201. package/out/exact-match.d.ts +5 -5
  202. package/out/exact-match.d.ts.map +1 -1
  203. package/out/exact-match.js +10 -11
  204. package/out/exact-match.js.map +1 -1
  205. package/out/extracts.d.ts +114 -0
  206. package/out/extracts.d.ts.map +1 -0
  207. package/out/{sharding.js → extracts.js} +38 -38
  208. package/out/extracts.js.map +1 -0
  209. package/out/{fst-autocomplete.d.ts → fst/autocomplete.d.ts} +2 -2
  210. package/out/fst/autocomplete.d.ts.map +1 -0
  211. package/out/{fst-autocomplete.js → fst/autocomplete.js} +3 -3
  212. package/out/fst/autocomplete.js.map +1 -0
  213. package/out/{fst-builder.d.ts → fst/builder.d.ts} +5 -5
  214. package/out/fst/builder.d.ts.map +1 -0
  215. package/out/{fst-builder.js → fst/builder.js} +14 -13
  216. package/out/fst/builder.js.map +1 -0
  217. package/out/{fst-deserialize-web.d.ts → fst/deserialize-web.d.ts} +3 -3
  218. package/out/fst/deserialize-web.d.ts.map +1 -0
  219. package/out/{fst-deserialize-web.js → fst/deserialize-web.js} +10 -74
  220. package/out/fst/deserialize-web.js.map +1 -0
  221. package/out/fst/format.d.ts +80 -0
  222. package/out/fst/format.d.ts.map +1 -0
  223. package/out/fst/format.js +91 -0
  224. package/out/fst/format.js.map +1 -0
  225. package/out/{fst-freshness.d.ts → fst/freshness.d.ts} +9 -13
  226. package/out/fst/freshness.d.ts.map +1 -0
  227. package/out/{fst-freshness.js → fst/freshness.js} +40 -73
  228. package/out/fst/freshness.js.map +1 -0
  229. package/out/fst/index.d.ts +14 -0
  230. package/out/fst/index.d.ts.map +1 -0
  231. package/out/fst/index.js +14 -0
  232. package/out/fst/index.js.map +1 -0
  233. package/out/{fst-matcher.d.ts → fst/matcher.d.ts} +2 -2
  234. package/out/fst/matcher.d.ts.map +1 -0
  235. package/out/{fst-matcher.js → fst/matcher.js} +1 -1
  236. package/out/fst/matcher.js.map +1 -0
  237. package/out/{fst-serialize.d.ts → fst/serialize.d.ts} +5 -10
  238. package/out/fst/serialize.d.ts.map +1 -0
  239. package/out/{fst-serialize.js → fst/serialize.js} +18 -98
  240. package/out/fst/serialize.js.map +1 -0
  241. package/out/{fst-types.d.ts → fst/types.d.ts} +4 -3
  242. package/out/fst/types.d.ts.map +1 -0
  243. package/out/{fst-types.js → fst/types.js} +1 -1
  244. package/out/fst/types.js.map +1 -0
  245. package/out/{fts.d.ts → fts/index.d.ts} +16 -9
  246. package/out/fts/index.d.ts.map +1 -0
  247. package/out/{fts.js → fts/index.js} +16 -11
  248. package/out/fts/index.js.map +1 -0
  249. package/out/{fts-query.d.ts → fts/query.d.ts} +2 -2
  250. package/out/fts/query.d.ts.map +1 -0
  251. package/out/{fts-query.js → fts/query.js} +1 -1
  252. package/out/fts/query.js.map +1 -0
  253. package/out/{geonames-aliases.d.ts → geonames/aliases.d.ts} +8 -6
  254. package/out/geonames/aliases.d.ts.map +1 -0
  255. package/out/{geonames-aliases.js → geonames/aliases.js} +7 -7
  256. package/out/geonames/aliases.js.map +1 -0
  257. package/out/geonames/index.d.ts +8 -0
  258. package/out/geonames/index.d.ts.map +1 -0
  259. package/out/geonames/index.js +8 -0
  260. package/out/geonames/index.js.map +1 -0
  261. package/out/{geonames-postal.d.ts → geonames/postal.d.ts} +10 -8
  262. package/out/geonames/postal.d.ts.map +1 -0
  263. package/out/{geonames-postal.js → geonames/postal.js} +9 -9
  264. package/out/geonames/postal.js.map +1 -0
  265. package/out/index.d.ts +32 -32
  266. package/out/index.d.ts.map +1 -1
  267. package/out/index.js +24 -24
  268. package/out/index.js.map +1 -1
  269. package/out/interpolation.d.ts +11 -10
  270. package/out/interpolation.d.ts.map +1 -1
  271. package/out/interpolation.js +20 -20
  272. package/out/interpolation.js.map +1 -1
  273. package/out/lookup.d.ts +22 -21
  274. package/out/lookup.d.ts.map +1 -1
  275. package/out/lookup.js +103 -113
  276. package/out/lookup.js.map +1 -1
  277. package/out/name-score.d.ts.map +1 -1
  278. package/out/name-score.js.map +1 -1
  279. package/out/nsul/index.d.ts +8 -0
  280. package/out/nsul/index.d.ts.map +1 -0
  281. package/out/nsul/index.js +8 -0
  282. package/out/nsul/index.js.map +1 -0
  283. package/out/nsul/lookup.d.ts +83 -0
  284. package/out/nsul/lookup.d.ts.map +1 -0
  285. package/out/nsul/lookup.js +80 -0
  286. package/out/nsul/lookup.js.map +1 -0
  287. package/out/nsul/schema.d.ts +100 -0
  288. package/out/nsul/schema.d.ts.map +1 -0
  289. package/out/nsul/schema.js +78 -0
  290. package/out/nsul/schema.js.map +1 -0
  291. package/out/place-importance-schema.d.ts +5 -6
  292. package/out/place-importance-schema.d.ts.map +1 -1
  293. package/out/place-importance-schema.js +3 -4
  294. package/out/place-importance-schema.js.map +1 -1
  295. package/out/poi/index.d.ts +8 -0
  296. package/out/poi/index.d.ts.map +1 -0
  297. package/out/poi/index.js +8 -0
  298. package/out/poi/index.js.map +1 -0
  299. package/out/{poi-lookup.d.ts → poi/lookup.d.ts} +8 -10
  300. package/out/poi/lookup.d.ts.map +1 -0
  301. package/out/{poi-lookup.js → poi/lookup.js} +14 -18
  302. package/out/poi/lookup.js.map +1 -0
  303. package/out/{poi-schema.d.ts → poi/schema.d.ts} +4 -4
  304. package/out/poi/schema.d.ts.map +1 -0
  305. package/out/{poi-schema.js → poi/schema.js} +1 -1
  306. package/out/poi/schema.js.map +1 -0
  307. package/out/polygon-schema.d.ts.map +1 -1
  308. package/out/polygon-schema.js.map +1 -1
  309. package/out/{postal-city-alias-lookup.d.ts → postal/city-alias-lookup.d.ts} +6 -5
  310. package/out/postal/city-alias-lookup.d.ts.map +1 -0
  311. package/out/{postal-city-alias-lookup.js → postal/city-alias-lookup.js} +11 -15
  312. package/out/postal/city-alias-lookup.js.map +1 -0
  313. package/out/{postal-city-alias-schema.d.ts → postal/city-alias-schema.d.ts} +1 -1
  314. package/out/{postal-city-alias-schema.d.ts.map → postal/city-alias-schema.d.ts.map} +1 -1
  315. package/out/{postal-city-alias-schema.js → postal/city-alias-schema.js} +1 -1
  316. package/out/{postal-city-alias-schema.js.map → postal/city-alias-schema.js.map} +1 -1
  317. package/out/{postal-city-candidate-schema.d.ts → postal/city-candidate-schema.d.ts} +3 -3
  318. package/out/{postal-city-candidate-schema.d.ts.map → postal/city-candidate-schema.d.ts.map} +1 -1
  319. package/out/{postal-city-candidate-schema.js → postal/city-candidate-schema.js} +2 -2
  320. package/out/{postal-city-candidate-schema.js.map → postal/city-candidate-schema.js.map} +1 -1
  321. package/out/postal/index.d.ts +9 -0
  322. package/out/postal/index.d.ts.map +1 -0
  323. package/out/postal/index.js +9 -0
  324. package/out/postal/index.js.map +1 -0
  325. package/out/postcode-point-lookup.d.ts +10 -10
  326. package/out/postcode-point-lookup.d.ts.map +1 -1
  327. package/out/postcode-point-lookup.js +13 -13
  328. package/out/postcode-point-lookup.js.map +1 -1
  329. package/out/primary-preference.d.ts +15 -7
  330. package/out/primary-preference.d.ts.map +1 -1
  331. package/out/primary-preference.js +28 -12
  332. package/out/primary-preference.js.map +1 -1
  333. package/out/proximity-rerank.d.ts +2 -2
  334. package/out/proximity-rerank.d.ts.map +1 -1
  335. package/out/proximity-rerank.js +2 -2
  336. package/out/proximity-rerank.js.map +1 -1
  337. package/out/ranking-weights.d.ts +15 -3
  338. package/out/ranking-weights.d.ts.map +1 -1
  339. package/out/ranking-weights.js +21 -3
  340. package/out/ranking-weights.js.map +1 -1
  341. package/out/region-keys.d.ts +8 -8
  342. package/out/region-keys.d.ts.map +1 -1
  343. package/out/region-keys.js +9 -9
  344. package/out/region-keys.js.map +1 -1
  345. package/out/reverse.d.ts +6 -6
  346. package/out/reverse.d.ts.map +1 -1
  347. package/out/reverse.js +20 -29
  348. package/out/reverse.js.map +1 -1
  349. package/out/schema.d.ts +9 -0
  350. package/out/schema.d.ts.map +1 -1
  351. package/out/schema.js.map +1 -1
  352. package/out/search-fetch.d.ts +12 -10
  353. package/out/search-fetch.d.ts.map +1 -1
  354. package/out/search-fetch.js +21 -20
  355. package/out/search-fetch.js.map +1 -1
  356. package/out/sqlite-convention-source.d.ts +7 -7
  357. package/out/sqlite-convention-source.d.ts.map +1 -1
  358. package/out/sqlite-convention-source.js +5 -5
  359. package/out/sqlite-convention-source.js.map +1 -1
  360. package/out/sqlite-utils.d.ts +8 -9
  361. package/out/sqlite-utils.d.ts.map +1 -1
  362. package/out/sqlite-utils.js +6 -10
  363. package/out/sqlite-utils.js.map +1 -1
  364. package/out/{street-centroid-schema.d.ts → street/centroid-schema.d.ts} +6 -6
  365. package/out/{street-centroid-schema.d.ts.map → street/centroid-schema.d.ts.map} +1 -1
  366. package/out/{street-centroid-schema.js → street/centroid-schema.js} +5 -5
  367. package/out/{street-centroid-schema.js.map → street/centroid-schema.js.map} +1 -1
  368. package/out/{street-centroid.d.ts → street/centroid.d.ts} +7 -7
  369. package/out/street/centroid.d.ts.map +1 -0
  370. package/out/{street-centroid.js → street/centroid.js} +13 -19
  371. package/out/street/centroid.js.map +1 -0
  372. package/out/street/index.d.ts +13 -0
  373. package/out/street/index.d.ts.map +1 -0
  374. package/out/street/index.js +13 -0
  375. package/out/street/index.js.map +1 -0
  376. package/out/{street-morphology-fst-builder.d.ts → street/morphology-fst-builder.d.ts} +4 -4
  377. package/out/street/morphology-fst-builder.d.ts.map +1 -0
  378. package/out/{street-morphology-fst-builder.js → street/morphology-fst-builder.js} +18 -13
  379. package/out/street/morphology-fst-builder.js.map +1 -0
  380. package/out/{street-morphology-fst-loader.d.ts → street/morphology-fst-loader.d.ts} +5 -5
  381. package/out/street/morphology-fst-loader.d.ts.map +1 -0
  382. package/out/{street-morphology-fst-loader.js → street/morphology-fst-loader.js} +11 -10
  383. package/out/street/morphology-fst-loader.js.map +1 -0
  384. package/out/{street-name-lookup.d.ts → street/name-lookup.d.ts} +4 -7
  385. package/out/street/name-lookup.d.ts.map +1 -0
  386. package/out/{street-name-lookup.js → street/name-lookup.js} +9 -23
  387. package/out/street/name-lookup.js.map +1 -0
  388. package/out/{street-normalize.d.ts → street/normalize.d.ts} +38 -15
  389. package/out/street/normalize.d.ts.map +1 -0
  390. package/out/{street-normalize.js → street/normalize.js} +73 -17
  391. package/out/street/normalize.js.map +1 -0
  392. package/out/{street-segment-schema.d.ts → street/segment-schema.d.ts} +8 -8
  393. package/out/{street-segment-schema.d.ts.map → street/segment-schema.d.ts.map} +1 -1
  394. package/out/{street-segment-schema.js → street/segment-schema.js} +4 -4
  395. package/out/{street-segment-schema.js.map → street/segment-schema.js.map} +1 -1
  396. package/out/types.d.ts +18 -12
  397. package/out/types.d.ts.map +1 -1
  398. package/out/types.js.map +1 -1
  399. package/out/unified-schema.d.ts +5 -4
  400. package/out/unified-schema.d.ts.map +1 -1
  401. package/out/unified-schema.js +15 -18
  402. package/out/unified-schema.js.map +1 -1
  403. package/out/uprn/existence.d.ts +53 -0
  404. package/out/uprn/existence.d.ts.map +1 -0
  405. package/out/uprn/existence.js +61 -0
  406. package/out/uprn/existence.js.map +1 -0
  407. package/out/uprn/index.d.ts +9 -0
  408. package/out/uprn/index.d.ts.map +1 -0
  409. package/out/uprn/index.js +9 -0
  410. package/out/uprn/index.js.map +1 -0
  411. package/out/{uprn-lookup.d.ts → uprn/lookup.d.ts} +4 -4
  412. package/out/uprn/lookup.d.ts.map +1 -0
  413. package/out/{uprn-lookup.js → uprn/lookup.js} +11 -14
  414. package/out/uprn/lookup.js.map +1 -0
  415. package/out/{uprn-schema.d.ts → uprn/schema.d.ts} +4 -4
  416. package/out/uprn/schema.d.ts.map +1 -0
  417. package/out/{uprn-schema.js → uprn/schema.js} +4 -4
  418. package/out/uprn/schema.js.map +1 -0
  419. package/out/weights-overlay-linker.d.ts +184 -26
  420. package/out/weights-overlay-linker.d.ts.map +1 -1
  421. package/out/weights-overlay-linker.js +339 -86
  422. package/out/weights-overlay-linker.js.map +1 -1
  423. package/package.json +465 -269
  424. package/address-point.ts +0 -218
  425. package/candidate/shard-fold.ts +0 -137
  426. package/out/address-point-interpolation.d.ts.map +0 -1
  427. package/out/address-point-interpolation.js.map +0 -1
  428. package/out/address-point-schema.d.ts.map +0 -1
  429. package/out/address-point-schema.js.map +0 -1
  430. package/out/address-point.d.ts.map +0 -1
  431. package/out/address-point.js +0 -140
  432. package/out/address-point.js.map +0 -1
  433. package/out/ancestry-backfill.d.ts.map +0 -1
  434. package/out/ancestry-backfill.js.map +0 -1
  435. package/out/ancestry.d.ts.map +0 -1
  436. package/out/ancestry.js.map +0 -1
  437. package/out/candidate/shard-fold.d.ts +0 -31
  438. package/out/candidate/shard-fold.d.ts.map +0 -1
  439. package/out/candidate/shard-fold.js +0 -104
  440. package/out/candidate/shard-fold.js.map +0 -1
  441. package/out/convention-schema.d.ts.map +0 -1
  442. package/out/convention-schema.js.map +0 -1
  443. package/out/convention.d.ts.map +0 -1
  444. package/out/convention.js.map +0 -1
  445. package/out/fst-autocomplete.d.ts.map +0 -1
  446. package/out/fst-autocomplete.js.map +0 -1
  447. package/out/fst-builder.d.ts.map +0 -1
  448. package/out/fst-builder.js.map +0 -1
  449. package/out/fst-deserialize-web.d.ts.map +0 -1
  450. package/out/fst-deserialize-web.js.map +0 -1
  451. package/out/fst-freshness.d.ts.map +0 -1
  452. package/out/fst-freshness.js.map +0 -1
  453. package/out/fst-matcher.d.ts.map +0 -1
  454. package/out/fst-matcher.js.map +0 -1
  455. package/out/fst-serialize.d.ts.map +0 -1
  456. package/out/fst-serialize.js.map +0 -1
  457. package/out/fst-types.d.ts.map +0 -1
  458. package/out/fst-types.js.map +0 -1
  459. package/out/fts-query.d.ts.map +0 -1
  460. package/out/fts-query.js.map +0 -1
  461. package/out/fts.d.ts.map +0 -1
  462. package/out/fts.js.map +0 -1
  463. package/out/geonames-aliases.d.ts.map +0 -1
  464. package/out/geonames-aliases.js.map +0 -1
  465. package/out/geonames-postal.d.ts.map +0 -1
  466. package/out/geonames-postal.js.map +0 -1
  467. package/out/poi-lookup.d.ts.map +0 -1
  468. package/out/poi-lookup.js.map +0 -1
  469. package/out/poi-schema.d.ts.map +0 -1
  470. package/out/poi-schema.js.map +0 -1
  471. package/out/postal-city-alias-lookup.d.ts.map +0 -1
  472. package/out/postal-city-alias-lookup.js.map +0 -1
  473. package/out/sharding.d.ts +0 -114
  474. package/out/sharding.d.ts.map +0 -1
  475. package/out/sharding.js.map +0 -1
  476. package/out/street-centroid.d.ts.map +0 -1
  477. package/out/street-centroid.js.map +0 -1
  478. package/out/street-morphology-fst-builder.d.ts.map +0 -1
  479. package/out/street-morphology-fst-builder.js.map +0 -1
  480. package/out/street-morphology-fst-loader.d.ts.map +0 -1
  481. package/out/street-morphology-fst-loader.js.map +0 -1
  482. package/out/street-name-lookup.d.ts.map +0 -1
  483. package/out/street-name-lookup.js.map +0 -1
  484. package/out/street-normalize.d.ts.map +0 -1
  485. package/out/street-normalize.js.map +0 -1
  486. package/out/uprn-lookup.d.ts.map +0 -1
  487. package/out/uprn-lookup.js.map +0 -1
  488. package/out/uprn-schema.d.ts.map +0 -1
  489. package/out/uprn-schema.js.map +0 -1
  490. package/weights-overlay-linker.ts +0 -377
  491. /package/{name-score.ts → lib/name-score.ts} +0 -0
  492. /package/{polygon-schema.ts → lib/polygon-schema.ts} +0 -0
  493. /package/{postal-city-alias-schema.ts → lib/postal/city-alias-schema.ts} +0 -0
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Node reader for `nsul.db` — the GB UPRN → unit-postcode register (`nsul/schema.ts`). Two probes,
7
+ * both synchronous `.prepare()` hits in the `uprn/lookup.ts` style:
8
+ *
9
+ * - **`postcodeForUPRN(uprn)`**: primary-key hit on the `WITHOUT ROWID` table.
10
+ * - **`uprnsForPostcode(postcode)`**: the `pcds_compact` index, answering every UPRN the register
11
+ * assigns to one unit postcode with the point OS publishes for each — the "assigned points and
12
+ * their bound" the physical-constraint design record names as the prior's soft structure.
13
+ *
14
+ * ## `null` and `[]` are claims, scoped by coverage
15
+ *
16
+ * The register designates GB complete (every UPRN in AddressBase with a Code-Point Open postcode),
17
+ * and the builder writes `layer_coverage` with basis `designated` for every cell the register
18
+ * touches. Inside a covered cell an empty answer is evidence of absence: no GB UPRN by that number
19
+ * carries a Code-Point postcode, or no UPRN carries that postcode. Two absences the reader cannot
20
+ * tell from those are recorded in `nsul_meta` as counts rather than as rows — a UPRN whose `PCDS` is
21
+ * null (its postcode is not in Code-Point Open) and one Open UPRN publishes no coordinate for — so a
22
+ * caller building negative evidence reads the coverage table and those counts, not this reader
23
+ * alone. Outside coverage (Northern Ireland, the Isle of Man, the Channel Islands) the answer is
24
+ * UNKNOWN, per the meaning-of-zero rule.
25
+ */
26
+ import { DatabaseClient } from "@mailwoman/sqlite/client";
27
+ import { type NSULDatabase } from "#nsul/schema";
28
+ /**
29
+ * The unit postcode the register assigns to a UPRN, in both stored forms.
30
+ */
31
+ export interface NSULPostcode {
32
+ /**
33
+ * As NSUL writes it — `RG40 4HR`.
34
+ */
35
+ pcds: string;
36
+ /**
37
+ * Space removed — `RG404HR`, Code-Point Open's `spr.name` form.
38
+ */
39
+ pcdsCompact: string;
40
+ }
41
+ /**
42
+ * One UPRN assigned to a unit postcode, with the point `uprn.db` holds for it.
43
+ */
44
+ export interface NSULAssignedPoint {
45
+ uprn: number;
46
+ latitude: number;
47
+ longitude: number;
48
+ /**
49
+ * 48-bit short res-9 H3 cell, as `uprn.db` stores it.
50
+ */
51
+ h3Cell: number;
52
+ }
53
+ export interface NSULLookupOpts {
54
+ /**
55
+ * Path to a `nsul.db` built by `mailwoman`'s gazetteer pipeline. Opened read-only.
56
+ */
57
+ databasePath?: string;
58
+ /**
59
+ * Pre-opened handle (tests / shared connections). Mutually exclusive with `databasePath`.
60
+ */
61
+ database?: DatabaseClient<NSULDatabase>;
62
+ }
63
+ /**
64
+ * Node reader over `nsul.db`. `implements Disposable` so callers can `using lookup = new NSULLookup(...)` — the same
65
+ * precedent as `UPRNLookup`.
66
+ */
67
+ export declare class NSULLookup implements Disposable {
68
+ #private;
69
+ constructor(opts: NSULLookupOpts);
70
+ /**
71
+ * The unit postcode the register assigns to `uprn`, or `null` when the register holds no row for it (see the module
72
+ * docstring for what that `null` claims).
73
+ */
74
+ postcodeForUPRN(uprn: number): NSULPostcode | null;
75
+ /**
76
+ * Every UPRN the register assigns to one unit postcode, with its published point, in ascending UPRN order. The key is
77
+ * compacted through {@link compactPostcode} first, so `PO21 1HR` and `PO211HR` answer identically. An empty array is
78
+ * the register's answer, scoped as the module docstring says.
79
+ */
80
+ uprnsForPostcode(postcode: string): NSULAssignedPoint[];
81
+ [Symbol.dispose](): void;
82
+ }
83
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../lib/nsul/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAA;AAGjE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;CACvC;AAcD;;;GAGG;AACH,qBAAa,UAAW,YAAW,UAAU;;gBAWhC,IAAI,EAAE,cAAc;IAoBhC;;;OAGG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAMlD;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,EAAE;IASvD,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGxB"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Node reader for `nsul.db` — the GB UPRN → unit-postcode register (`nsul/schema.ts`). Two probes,
7
+ * both synchronous `.prepare()` hits in the `uprn/lookup.ts` style:
8
+ *
9
+ * - **`postcodeForUPRN(uprn)`**: primary-key hit on the `WITHOUT ROWID` table.
10
+ * - **`uprnsForPostcode(postcode)`**: the `pcds_compact` index, answering every UPRN the register
11
+ * assigns to one unit postcode with the point OS publishes for each — the "assigned points and
12
+ * their bound" the physical-constraint design record names as the prior's soft structure.
13
+ *
14
+ * ## `null` and `[]` are claims, scoped by coverage
15
+ *
16
+ * The register designates GB complete (every UPRN in AddressBase with a Code-Point Open postcode),
17
+ * and the builder writes `layer_coverage` with basis `designated` for every cell the register
18
+ * touches. Inside a covered cell an empty answer is evidence of absence: no GB UPRN by that number
19
+ * carries a Code-Point postcode, or no UPRN carries that postcode. Two absences the reader cannot
20
+ * tell from those are recorded in `nsul_meta` as counts rather than as rows — a UPRN whose `PCDS` is
21
+ * null (its postcode is not in Code-Point Open) and one Open UPRN publishes no coordinate for — so a
22
+ * caller building negative evidence reads the coverage table and those counts, not this reader
23
+ * alone. Outside coverage (Northern Ireland, the Isle of Man, the Channel Islands) the answer is
24
+ * UNKNOWN, per the meaning-of-zero rule.
25
+ */
26
+ import { DatabaseClient } from "@mailwoman/sqlite/client";
27
+ import { compactPostcode } from "#nsul/schema";
28
+ import { prepareAll, prepareGet } from "#sqlite-utils";
29
+ /**
30
+ * Node reader over `nsul.db`. `implements Disposable` so callers can `using lookup = new NSULLookup(...)` — the same
31
+ * precedent as `UPRNLookup`.
32
+ */
33
+ export class NSULLookup {
34
+ #db;
35
+ /**
36
+ * Resources this instance opened. A connection handed in by a caller is NOT in here, so disposal cannot reach it —
37
+ * ownership is membership rather than a flag a later branch has to check.
38
+ */
39
+ #resources = new DisposableStack();
40
+ #postcodeProbe;
41
+ #pointsProbe;
42
+ constructor(opts) {
43
+ if (opts.database) {
44
+ this.#db = opts.database;
45
+ }
46
+ else if (opts.databasePath) {
47
+ this.#db = this.#resources.use(new DatabaseClient(opts.databasePath, { readOnly: true }));
48
+ }
49
+ else {
50
+ throw new Error("NSULLookup needs `databasePath` or `database`");
51
+ }
52
+ this.#postcodeProbe = prepareGet(this.#db, "SELECT pcds, pcds_compact FROM uprn_postcode WHERE uprn = ?");
53
+ this.#pointsProbe = prepareAll(this.#db, "SELECT uprn, lat, lon, h3_cell FROM uprn_postcode WHERE pcds_compact = ? ORDER BY uprn");
54
+ }
55
+ /**
56
+ * The unit postcode the register assigns to `uprn`, or `null` when the register holds no row for it (see the module
57
+ * docstring for what that `null` claims).
58
+ */
59
+ postcodeForUPRN(uprn) {
60
+ const row = this.#postcodeProbe(uprn);
61
+ return row ? { pcds: row.pcds, pcdsCompact: row.pcds_compact } : null;
62
+ }
63
+ /**
64
+ * Every UPRN the register assigns to one unit postcode, with its published point, in ascending UPRN order. The key is
65
+ * compacted through {@link compactPostcode} first, so `PO21 1HR` and `PO211HR` answer identically. An empty array is
66
+ * the register's answer, scoped as the module docstring says.
67
+ */
68
+ uprnsForPostcode(postcode) {
69
+ return this.#pointsProbe(compactPostcode(postcode)).map((row) => ({
70
+ uprn: row.uprn,
71
+ latitude: row.lat,
72
+ longitude: row.lon,
73
+ h3Cell: row.h3_cell,
74
+ }));
75
+ }
76
+ [Symbol.dispose]() {
77
+ this.#resources[Symbol.dispose]();
78
+ }
79
+ }
80
+ //# sourceMappingURL=lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../lib/nsul/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,OAAO,EAAE,eAAe,EAAqB,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAoDtD;;;GAGG;AACH,MAAM,OAAO,UAAU;IACtB,GAAG,CAA8B;IACjC;;;OAGG;IACM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IAElC,cAAc,CAA2C;IACzD,YAAY,CAAqC;IAE1D,YAAY,IAAoB;QAC/B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAA;QACzB,CAAC;aAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YA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al.
5
+ *
6
+ * Typed schema for `nsul.db` — the GB UPRN → unit-postcode register: the ONS **National Statistics
7
+ * UPRN Lookup** (NSUL) joined to the WGS84 point OS Open UPRN publishes for the same UPRN. One row per
8
+ * GB UPRN that carries a unit postcode AND has a published coordinate; the postcode is Code-Point
9
+ * Open's, so this table and `postcode-gb.bin` agree by construction on the universe of unit postcodes.
10
+ *
11
+ * ## Why this table exists
12
+ *
13
+ * Code-Point Open gives one coordinate per unit postcode; Open UPRN gives one coordinate per
14
+ * addressable object; neither says which object carries which postcode. NSUL does, as field `PCDS`,
15
+ * under OGL-UK-3.0. The `PO`-area measurement that produced this design (recorded on #1975) showed a
16
+ * nearest-centroid reconstruction of the register is exact on 69.6% of 531,266 UPRNs and a building
17
+ * footprint adds nothing, so the register is stored rather than inferred.
18
+ *
19
+ * ## Shape
20
+ *
21
+ * `uprn_postcode` is `WITHOUT ROWID` keyed on the UPRN: small fixed rows, probed by primary key, with
22
+ * one secondary index on `pcds_compact`. The postcode is stored twice on purpose — `pcds` exactly as
23
+ * NSUL writes it (`RG40 4HR`, one space) and `pcds_compact` with the space removed (`RG404HR`), which
24
+ * is the form Code-Point Open's `spr.name` uses, so the two artifacts join on a column rather than an
25
+ * expression. `lat`/`lon`/`h3_cell` are COPIED from `uprn.db` at build time by UPRN join — OS's own
26
+ * WGS84 columns, never a reprojection of NSUL's `GRIDGB1E`/`GRIDGB1N` — so a coordinate here is
27
+ * byte-identical to the one `uprn.db` holds for the same UPRN.
28
+ *
29
+ * The DB also embeds the layer-contract tables from `@mailwoman/core/layers`; the builder
30
+ * (`packages/mailwoman/lib/gazetteer-pipeline/nsul-layer.ts`) writes the manifest and coverage.
31
+ */
32
+ import type { LayerContractDatabase } from "@mailwoman/core/layers";
33
+ import { type Kysely } from "kysely";
34
+ /**
35
+ * Resolution of the `h3_cell` column — the same res-9 spine `uprn.db` keys on, because the value is copied from it.
36
+ */
37
+ export declare const NSUL_H3_RESOLUTION = 9;
38
+ /**
39
+ * Resolution of the layer's `layer_coverage` cells — coarse, per the contract, and the same as `uprn.db`'s so the two
40
+ * layers' coverage tables describe the same cells.
41
+ */
42
+ export declare const NSUL_COVERAGE_H3_RESOLUTION = 6;
43
+ /**
44
+ * One UPRN with its unit postcode and the point OS publishes for it.
45
+ */
46
+ export interface UPRNPostcodeTable {
47
+ /**
48
+ * The Unique Property Reference Number — up to 12 digits, so always within `Number.MAX_SAFE_INTEGER`.
49
+ */
50
+ uprn: number;
51
+ /**
52
+ * The unit postcode as NSUL writes it — outward code, one space, inward code (`RG40 4HR`).
53
+ */
54
+ pcds: string;
55
+ /**
56
+ * {@link pcds} with the space removed (`RG404HR`) — the form Code-Point Open's `spr.name` carries, and the column
57
+ * `uprnsForPostcode` probes.
58
+ */
59
+ pcds_compact: string;
60
+ /**
61
+ * WGS84 latitude, copied from `uprn.db` for the same UPRN.
62
+ */
63
+ lat: number;
64
+ /**
65
+ * WGS84 longitude, copied from `uprn.db` for the same UPRN.
66
+ */
67
+ lon: number;
68
+ /**
69
+ * 48-bit short H3 cell at {@link NSUL_H3_RESOLUTION}, copied from `uprn.db` for the same UPRN.
70
+ */
71
+ h3_cell: number;
72
+ }
73
+ /**
74
+ * Build-provenance key/value pairs the fixed `layer_manifest` columns have no room for: the accounting counts, the
75
+ * header as found, the per-region row counts, the four attribution lines.
76
+ */
77
+ export interface NSULMetaTable {
78
+ key: string;
79
+ value: string;
80
+ }
81
+ export interface NSULDatabase extends LayerContractDatabase {
82
+ uprn_postcode: UPRNPostcodeTable;
83
+ nsul_meta: NSULMetaTable;
84
+ }
85
+ /**
86
+ * The compact form of a unit postcode: every space removed, upper-cased. `RG40 4HR` → `RG404HR`. The ONE derivation
87
+ * both the builder and every consumer share, so a caller holding NSUL's spaced form and one holding Code-Point's
88
+ * compact form reach the same key.
89
+ */
90
+ export declare function compactPostcode(pcds: string): string;
91
+ export declare function createUPRNPostcodeTable(db: Kysely<NSULDatabase>): Promise<void>;
92
+ export declare function createNSULMetaTable(db: Kysely<NSULDatabase>): Promise<void>;
93
+ /**
94
+ * The `pcds_compact` index the `uprnsForPostcode` probe reads. Builders call this AFTER the bulk load
95
+ * (index-after-load). There is no index on the spaced `pcds`: it is derivable from `pcds_compact` through
96
+ * {@link compactPostcode}, and a second index over 40 million rows would buy nothing a caller cannot get by compacting
97
+ * its key first.
98
+ */
99
+ export declare function createNSULIndexes(db: Kysely<NSULDatabase>): Promise<void>;
100
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../lib/nsul/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAE5C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,YAAa,SAAQ,qBAAqB;IAC1D,aAAa,EAAE,iBAAiB,CAAA;IAChC,SAAS,EAAE,aAAa,CAAA;CACxB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAWrF;AAED,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjF;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/E"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Typed schema for `nsul.db` — the GB UPRN → unit-postcode register: the ONS **National Statistics
7
+ * UPRN Lookup** (NSUL) joined to the WGS84 point OS Open UPRN publishes for the same UPRN. One row per
8
+ * GB UPRN that carries a unit postcode AND has a published coordinate; the postcode is Code-Point
9
+ * Open's, so this table and `postcode-gb.bin` agree by construction on the universe of unit postcodes.
10
+ *
11
+ * ## Why this table exists
12
+ *
13
+ * Code-Point Open gives one coordinate per unit postcode; Open UPRN gives one coordinate per
14
+ * addressable object; neither says which object carries which postcode. NSUL does, as field `PCDS`,
15
+ * under OGL-UK-3.0. The `PO`-area measurement that produced this design (recorded on #1975) showed a
16
+ * nearest-centroid reconstruction of the register is exact on 69.6% of 531,266 UPRNs and a building
17
+ * footprint adds nothing, so the register is stored rather than inferred.
18
+ *
19
+ * ## Shape
20
+ *
21
+ * `uprn_postcode` is `WITHOUT ROWID` keyed on the UPRN: small fixed rows, probed by primary key, with
22
+ * one secondary index on `pcds_compact`. The postcode is stored twice on purpose — `pcds` exactly as
23
+ * NSUL writes it (`RG40 4HR`, one space) and `pcds_compact` with the space removed (`RG404HR`), which
24
+ * is the form Code-Point Open's `spr.name` uses, so the two artifacts join on a column rather than an
25
+ * expression. `lat`/`lon`/`h3_cell` are COPIED from `uprn.db` at build time by UPRN join — OS's own
26
+ * WGS84 columns, never a reprojection of NSUL's `GRIDGB1E`/`GRIDGB1N` — so a coordinate here is
27
+ * byte-identical to the one `uprn.db` holds for the same UPRN.
28
+ *
29
+ * The DB also embeds the layer-contract tables from `@mailwoman/core/layers`; the builder
30
+ * (`packages/mailwoman/lib/gazetteer-pipeline/nsul-layer.ts`) writes the manifest and coverage.
31
+ */
32
+ import { sql } from "kysely";
33
+ /**
34
+ * Resolution of the `h3_cell` column — the same res-9 spine `uprn.db` keys on, because the value is copied from it.
35
+ */
36
+ export const NSUL_H3_RESOLUTION = 9;
37
+ /**
38
+ * Resolution of the layer's `layer_coverage` cells — coarse, per the contract, and the same as `uprn.db`'s so the two
39
+ * layers' coverage tables describe the same cells.
40
+ */
41
+ export const NSUL_COVERAGE_H3_RESOLUTION = 6;
42
+ /**
43
+ * The compact form of a unit postcode: every space removed, upper-cased. `RG40 4HR` → `RG404HR`. The ONE derivation
44
+ * both the builder and every consumer share, so a caller holding NSUL's spaced form and one holding Code-Point's
45
+ * compact form reach the same key.
46
+ */
47
+ export function compactPostcode(pcds) {
48
+ return pcds.replaceAll(/\s+/g, "").toUpperCase();
49
+ }
50
+ export async function createUPRNPostcodeTable(db) {
51
+ await db.schema
52
+ .createTable("uprn_postcode")
53
+ .addColumn("uprn", "integer", (c) => c.primaryKey())
54
+ .addColumn("pcds", "text", (c) => c.notNull())
55
+ .addColumn("pcds_compact", "text", (c) => c.notNull())
56
+ .addColumn("lat", "real", (c) => c.notNull())
57
+ .addColumn("lon", "real", (c) => c.notNull())
58
+ .addColumn("h3_cell", "integer", (c) => c.notNull())
59
+ .modifyEnd(sql `without rowid`)
60
+ .execute();
61
+ }
62
+ export async function createNSULMetaTable(db) {
63
+ await db.schema
64
+ .createTable("nsul_meta")
65
+ .addColumn("key", "text", (c) => c.primaryKey())
66
+ .addColumn("value", "text", (c) => c.notNull())
67
+ .execute();
68
+ }
69
+ /**
70
+ * The `pcds_compact` index the `uprnsForPostcode` probe reads. Builders call this AFTER the bulk load
71
+ * (index-after-load). There is no index on the spaced `pcds`: it is derivable from `pcds_compact` through
72
+ * {@link compactPostcode}, and a second index over 40 million rows would buy nothing a caller cannot get by compacting
73
+ * its key first.
74
+ */
75
+ export async function createNSULIndexes(db) {
76
+ await db.schema.createIndex("uprn_postcode_pcds_compact").on("uprn_postcode").column("pcds_compact").execute();
77
+ }
78
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../lib/nsul/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,GAAG,EAAe,MAAM,QAAQ,CAAA;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AA+C5C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;AACjD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,EAAwB;IACrE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,eAAe,CAAC;SAC5B,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;SACnD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC7C,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACrD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC5C,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC5C,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACnD,SAAS,CAAC,GAAG,CAAA,eAAe,CAAC;SAC7B,OAAO,EAAE,CAAA;AACZ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EAAwB;IACjE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,WAAW,CAAC;SACxB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;SAC/C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC9C,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EAAwB;IAC/D,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,CAAA;AAC/G,CAAC"}
@@ -30,7 +30,7 @@
30
30
  * bounded blend the bare-toponym fame consumer (#28) ranks on. It is the CONFLATION, and nothing new
31
31
  * should read it; new code reads the split columns.
32
32
  */
33
- import type { DatabaseSync } from "node:sqlite";
33
+ import type { DatabaseClient } from "@mailwoman/sqlite/client";
34
34
  import type { Kysely } from "kysely";
35
35
  /**
36
36
  * One row of `place_importance`. Keyed by WOF place id.
@@ -76,7 +76,6 @@ export declare function createPlaceImportanceTable(db: Kysely<PlaceImportanceDat
76
76
  * (backend-agnostic — it cannot import this package) reads the same number. Re-exported HERE so the schema module stays
77
77
  * the one-stop read for the table: the column and the function that fills it are one hop apart.
78
78
  */
79
- export { compareReferential, REFERENTIAL_LOG2_SCALE, REFERENTIAL_POPULATION_DIVISOR, REFERENTIAL_SATURATION_POPULATION, referentialFromPopulation, } from "@mailwoman/core/resolver";
80
79
  /**
81
80
  * The most the encyclopedic channel may raise a place's blended importance above its population-anchored referential
82
81
  * score.
@@ -149,12 +148,12 @@ export type ImportanceSplitSource = (typeof IMPORTANCE_SPLIT_SOURCES)[keyof type
149
148
  *
150
149
  * There is deliberately no ORDER BY counterpart, and there should never be one: §2's policy is that this score is
151
150
  * carried and never ranked on. Without the column the select degrades to a literal `NULL` and the join is the empty
152
- * string, so a pre-split shard's query plan is byte-identical to what it was before the split. No shipped gazetteer
151
+ * string, so a pre-split extract's query plan is byte-identical to what it was before the split. No shipped gazetteer
153
152
  * carries the column yet, so today that degraded form is the only one anything builds.
154
153
  *
155
- * Call it ONCE per shard and cache the result — it runs a `PRAGMA`, and the callers are per-keystroke hot.
154
+ * Call it ONCE per extract and cache the result — it runs a `PRAGMA`, and the callers are per-keystroke hot.
156
155
  */
157
- export declare function encyclopedicClauses(db: DatabaseSync, schemaName: string): {
156
+ export declare function encyclopedicClauses<DB>(db: DatabaseClient<DB>, schemaName: string): {
158
157
  select: string;
159
158
  join: string;
160
159
  };
@@ -222,5 +221,5 @@ export interface ImportanceSplit {
222
221
  * builder in particular must read the shipped population-only databases, the read-only 2026-08-05 staging database
223
222
  * (legacy conflated column), and post-split builds with one code path.
224
223
  */
225
- export declare function loadImportanceSplit(db: DatabaseSync): ImportanceSplit;
224
+ export declare function loadImportanceSplit<DB>(db: DatabaseClient<DB>): ImportanceSplit;
226
225
  //# sourceMappingURL=place-importance-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"place-importance-schema.d.ts","sourceRoot":"","sources":["../place-importance-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,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AEG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,MAAM,EAAE,qBAAqB,CAAA;IAC7B;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC1B;AAeD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,eAAe,CAgF/E"}
@@ -31,7 +31,7 @@
31
31
  * should read it; new code reads the split columns.
32
32
  */
33
33
  import { referentialFromPopulation } from "@mailwoman/core/resolver";
34
- import { allRows } from "./sqlite-utils.js";
34
+ import { allRows } from "@mailwoman/core/utils";
35
35
  /**
36
36
  * The columns in declaration order. The builder's INSERT derives its column list from this, so a field added to
37
37
  * {@link PlaceImportanceTable} without a matching DDL column is a compile error at the insert site.
@@ -63,7 +63,6 @@ export async function createPlaceImportanceTable(db) {
63
63
  * (backend-agnostic — it cannot import this package) reads the same number. Re-exported HERE so the schema module stays
64
64
  * the one-stop read for the table: the column and the function that fills it are one hop apart.
65
65
  */
66
- export { compareReferential, REFERENTIAL_LOG2_SCALE, REFERENTIAL_POPULATION_DIVISOR, REFERENTIAL_SATURATION_POPULATION, referentialFromPopulation, } from "@mailwoman/core/resolver";
67
66
  //#endregion
68
67
  //#region The legacy blend
69
68
  /**
@@ -145,10 +144,10 @@ export const IMPORTANCE_SPLIT_SOURCES = {
145
144
  *
146
145
  * There is deliberately no ORDER BY counterpart, and there should never be one: §2's policy is that this score is
147
146
  * carried and never ranked on. Without the column the select degrades to a literal `NULL` and the join is the empty
148
- * string, so a pre-split shard's query plan is byte-identical to what it was before the split. No shipped gazetteer
147
+ * string, so a pre-split extract's query plan is byte-identical to what it was before the split. No shipped gazetteer
149
148
  * carries the column yet, so today that degraded form is the only one anything builds.
150
149
  *
151
- * Call it ONCE per shard and cache the result — it runs a `PRAGMA`, and the callers are per-keystroke hot.
150
+ * Call it ONCE per extract and cache the result — it runs a `PRAGMA`, and the callers are per-keystroke hot.
152
151
  */
153
152
  export function encyclopedicClauses(db, schemaName) {
154
153
  let present;
@@ -1 +1 @@
1
- {"version":3,"file":"place-importance-schema.js","sourceRoot":"","sources":["../place-importance-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAGpE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAmC3C;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,IAAI;IACJ,aAAa;IACb,cAAc;IACd,YAAY;CAC+C,CAAA;AAE5D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,EAAmC;IACnF,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAA;IAElE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,kBAAkB,CAAC;SAC/B,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;SACjD,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACpD,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;SACjC,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACnD,OAAO,EAAE,CAAA;AACZ,CAAC;AAED,YAAY;AAEZ,oCAAoC;AAEpC;;;;GAIG;AACH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,8BAA8B,EAC9B,iCAAiC,EACjC,yBAAyB,GACzB,MAAM,0BAA0B,CAAA;AAEjC,YAAY;AAEZ,0BAA0B;AAE1B;;;;;;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E,CAAC;gBACtC,kBAAkB,EAAE,CAAA;YACrB,CAAC;iBAAM,CAAC;gBACP,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,YAAY,CAAC,CAAA;YAC7C,CAAC;QACF,CAAC;QAED,OAAO;YACN,WAAW;YACX,YAAY;YACZ,MAAM,EAAE,wBAAwB,CAAC,mBAAmB;YACpD,kBAAkB;SAClB,CAAA;IACF,CAAC;IAED,OAAO;QACN,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI;QAClG,kBAAkB,EAAE,CAAC;KACrB,CAAA;AACF,CAAC;AAED,YAAY"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#poi/lookup";
7
+ export * from "#poi/schema";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/poi/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#poi/lookup";
7
+ export * from "#poi/schema";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/poi/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
@@ -24,7 +24,8 @@
24
24
  * is NEVER reimplemented here (see AGENTS.md on `@mailwoman/spatial` being the one true home for
25
25
  * it).
26
26
  */
27
- import { DatabaseSync } from "node:sqlite";
27
+ import { DatabaseClient } from "@mailwoman/sqlite/client";
28
+ import type { POIDatabase } from "#poi/schema";
28
29
  /**
29
30
  * Resolution the `poi` table's `h3_cell` column is keyed at — matches the builder (spec §3.4).
30
31
  */
@@ -77,7 +78,7 @@ export interface POISearchHit {
77
78
  gersID: string | null;
78
79
  distanceM?: number;
79
80
  }
80
- export interface POILookupOpts {
81
+ export interface POILookupOpts<DB extends POIDatabase = POIDatabase> {
81
82
  /**
82
83
  * Path to a `poi.db` built by the (future) POI builder. Opened read-only.
83
84
  */
@@ -85,18 +86,15 @@ export interface POILookupOpts {
85
86
  /**
86
87
  * Pre-opened handle (tests / shared connections). Mutually exclusive with `databasePath`.
87
88
  */
88
- database?: DatabaseSync;
89
+ database?: DatabaseClient<DB>;
89
90
  }
90
91
  /**
91
- * Node reader over `poi.db`. `implements Disposable` so callers can `using lookup = new POILookup(...)` (or call
92
- * `[Symbol.dispose]()` explicitly), the same precedent as {@link WOFCandidateTableLookup} /
93
- * {@link WOFSQLitePlaceLookup}.
92
+ * Node reader over `poi.db`.
94
93
  */
95
- export declare class POILookup implements Disposable {
94
+ export declare class POILookup<DB extends POIDatabase = POIDatabase> implements Disposable {
96
95
  #private;
97
- constructor(opts: POILookupOpts);
96
+ constructor(opts: POILookupOpts<DB>);
98
97
  search(query: POISearchQuery): POISearchHit[];
99
- close(): void;
100
98
  [Symbol.dispose](): void;
101
99
  }
102
- //# sourceMappingURL=poi-lookup.d.ts.map
100
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../lib/poi/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,OAAO,KAAK,EAAwB,WAAW,EAAY,MAAM,aAAa,CAAA;AAC9E;;GAEG;AACH,eAAO,MAAM,iBAAiB,IAAI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B"}
@@ -24,10 +24,10 @@
24
24
  * is NEVER reimplemented here (see AGENTS.md on `@mailwoman/spatial` being the one true home for
25
25
  * it).
26
26
  */
27
- import { DatabaseSync } from "node:sqlite";
27
+ import { allRows } from "@mailwoman/core/utils";
28
28
  import { haversineKm, shortCellToInt } from "@mailwoman/spatial";
29
+ import { DatabaseClient } from "@mailwoman/sqlite/client";
29
30
  import { gridDisk, latLngToCell } from "h3-js";
30
- import { allRows } from "./sqlite-utils.js";
31
31
  /**
32
32
  * Resolution the `poi` table's `h3_cell` column is keyed at — matches the builder (spec §3.4).
33
33
  */
@@ -42,8 +42,9 @@ export const POI_H3_RESOLUTION = 9;
42
42
  * unaffected: the loop breaks the ring it accumulates `limit` rows (cafe@Paris fills 20 by ring 2), so this ceiling
43
43
  * never enters their probe budget. Only sparse-but-present categories that never reach `limit` scan the fuller budget —
44
44
  * a cold, one-shot `mailwoman poi` path, not per-keystroke. 16 (not the bare threshold 14) leaves ~2 rings of margin so
45
- * the gate is stable against small db rebuilds, while staying ~4x tighter than the board's 25 km "roughly right place"
46
- * window (no wrong-city false positives). The browser reader passes its own smaller `maxRings` and is untouched.
45
+ * the radius is stable against small db rebuilds, while staying ~4x tighter than the board's 25 km "roughly right
46
+ * place" window (no wrong-city false positives). The browser reader passes its own smaller `maxRings` and is
47
+ * untouched.
47
48
  */
48
49
  const DEFAULT_MAX_RINGS = 16;
49
50
  /**
@@ -57,13 +58,15 @@ const BRAND_MAX_DISTANCE_KM = 500;
57
58
  */
58
59
  const DEFAULT_LIMIT = 20;
59
60
  /**
60
- * Node reader over `poi.db`. `implements Disposable` so callers can `using lookup = new POILookup(...)` (or call
61
- * `[Symbol.dispose]()` explicitly), the same precedent as {@link WOFCandidateTableLookup} /
62
- * {@link WOFSQLitePlaceLookup}.
61
+ * Node reader over `poi.db`.
63
62
  */
64
63
  export class POILookup {
65
64
  #db;
66
- #ownsDB;
65
+ /**
66
+ * Resources this instance opened. A connection handed in by a caller is NOT in here, so disposal cannot reach it —
67
+ * ownership is membership rather than a flag a later branch has to check.
68
+ */
69
+ #resources = new DisposableStack();
67
70
  #categoryToID = new Map();
68
71
  #idToCategory = new Map();
69
72
  /**
@@ -81,11 +84,9 @@ export class POILookup {
81
84
  constructor(opts) {
82
85
  if (opts.database) {
83
86
  this.#db = opts.database;
84
- this.#ownsDB = false;
85
87
  }
86
88
  else if (opts.databasePath) {
87
- this.#db = new DatabaseSync(opts.databasePath, { readOnly: true });
88
- this.#ownsDB = true;
89
+ this.#db = this.#resources.use(new DatabaseClient(opts.databasePath, { readOnly: true }));
89
90
  }
90
91
  else {
91
92
  throw new Error("POILookup needs `databasePath` or `database`");
@@ -230,13 +231,8 @@ export class POILookup {
230
231
  const stmt = this.#db.prepare(`SELECT ${columns} FROM poi WHERE name_key IN (${placeholders})`);
231
232
  return allRows(stmt, ...nameKeys);
232
233
  }
233
- close() {
234
- if (this.#ownsDB) {
235
- this.#db.close();
236
- }
237
- }
238
234
  [Symbol.dispose]() {
239
- this.close();
235
+ this.#resources[Symbol.dispose]();
240
236
  }
241
237
  }
242
238
  function sortByDistance(rows, center) {
@@ -276,4 +272,4 @@ function sanitizePOINameQuery(text) {
276
272
  .map((token) => `"${token.replaceAll('"', '""')}"`)
277
273
  .join(" ");
278
274
  }
279
- //# sourceMappingURL=poi-lookup.js.map
275
+ //# sourceMappingURL=lookup.js.map