@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
@@ -3,8 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Typed schema for the TIGER STREET-SEGMENT interpolation shards (`street-segments-<cc>-<st>.db`,
7
- * built by `scripts/build-interpolation-shard.ts` from TIGER EDGES) — the #483 Method-3 fallback
6
+ * Typed schema for the TIGER STREET-SEGMENT interpolation extracts (`street-segments-<cc>-<st>.db`,
7
+ * built by `scripts/build-interpolation-extract.ts` from TIGER EDGES) — the #483 Method-3 fallback
8
8
  * the resolver drops to when the address-point tier (Method 2) can't bracket. Single source of
9
9
  * truth for the columns the BUILDER writes and the READER ({@link StreetInterpolator}) probes, so
10
10
  * a column rename in one is a compile error in the other.
@@ -17,7 +17,7 @@
17
17
 
18
18
  import type { Kysely } from "kysely"
19
19
 
20
- import type { RouteKey } from "./street-normalize.ts"
20
+ import type { RouteKey } from "#street/normalize"
21
21
 
22
22
  /**
23
23
  * One TIGER street-segment edge: a `(from_hn, to_hn)` house-number range on one `side` of a named street, with the
@@ -74,11 +74,11 @@ export interface StreetSegmentTable {
74
74
  }
75
75
 
76
76
  /**
77
- * The shard's single-row calibration metadata (#374 doctrine, 2026-07-26): the conformal radius multiplier is a
77
+ * The extract's single-row calibration metadata (#374 doctrine, 2026-07-26): the conformal radius multiplier is a
78
78
  * property of the CALIBRATION SET the artifact was built against — so it ships IN the artifact (the pair-index δ
79
79
  * precedent, `neural/pair-index-resolver.ts`), not in caller code. Written once by the builder; read at open time by
80
- * {@link StreetInterpolator}. Shards built before this table exists simply lack it — the reader degrades to `undefined`
81
- * and callers fall back to the in-code per-region table (never patch shipped DBs — rebuild).
80
+ * {@link StreetInterpolator}. Extracts built before this table exists simply lack it — the reader degrades to
81
+ * `undefined` and callers fall back to the in-code per-region table (never patch shipped DBs — rebuild).
82
82
  */
83
83
  export interface InterpCalibrationRow {
84
84
  /**
@@ -147,7 +147,7 @@ export async function createStreetSegmentTable(db: Kysely<StreetSegmentDatabase>
147
147
 
148
148
  /**
149
149
  * Create + populate the single-row `interp_calibration` metadata table (see {@link InterpCalibrationRow}) — called once
150
- * by the shard builder, after the value is selected from the calibration source of record. Build-time only (async
150
+ * by the extract builder, after the value is selected from the calibration source of record. Build-time only (async
151
151
  * Kysely is fine here); the READ side is the raw sync probe in {@link StreetInterpolator}'s constructor, per the
152
152
  * sync-by-interface doctrine.
153
153
  */
@@ -91,8 +91,8 @@ export interface PlaceCandidate {
91
91
  /**
92
92
  * STRICT encyclopedia-evidence importance in [0, 1], fan-out-guarded per #1497 — CARRIED, NEVER RANKED ON.
93
93
  *
94
- * RESERVED SLOT awaiting a strict-channel source: present only when a shard's `place_importance` table carries the
95
- * split columns, and no shipped shard does — the FTS lookup's clauses emit NULL for everything today. `undefined`
94
+ * RESERVED SLOT awaiting a strict-channel source: present only when a extract's `place_importance` table carries the
95
+ * split columns, and no shipped extract does — the FTS lookup's clauses emit NULL for everything today. `undefined`
96
96
  * means either "no encyclopedia entry for this place" or "this gazetteer predates the split"; both are absence, and
97
97
  * neither is 0. The BLENDED prior the ranking reads is {@link PlaceCandidate.importance}.
98
98
  *
@@ -126,10 +126,17 @@ export interface PlaceCandidate {
126
126
  * Admin-containment stamp (#1717 stage 2) — TRI-STATE, mirroring `ResolvedPlace.containedByQualifier` in
127
127
  * `@mailwoman/core`: `true` = the ancestors sidecar vouches this candidate sits under the query's
128
128
  * {@link FindPlaceQuery.regionQualifier}; `false` = evaluated and not vouched for; absent = never evaluated (no
129
- * qualifier on the query, or an artifact without the sidecar). Absence is load-bearing — the resolver walk reads it
130
- * as `unavailable`, never as "not contained".
129
+ * qualifier on the query, or an artifact without the sidecar). Absence is required — the resolver walk reads it as
130
+ * `unavailable`, never as "not contained".
131
131
  */
132
132
  containedByQualifier?: boolean
133
+ /**
134
+ * The #1882 exemption's firing mark (#1893), mirroring `ResolvedPlace.variantAliasExempted` in `@mailwoman/core`:
135
+ * present only when this candidate's row would have taken the cross-country alias penalty and the exemption prevented
136
+ * it. Emitted by the candidate-table backend alone — the WASM FTS lookup never runs the ranker, and its candidates
137
+ * omit the field (not evaluated, never "did not fire").
138
+ */
139
+ variantAliasExempted?: true
133
140
  }
134
141
 
135
142
  /**
@@ -179,8 +186,8 @@ export interface FindPlaceQuery {
179
186
  */
180
187
  fuzzyCountry?: string
181
188
  /**
182
- * Restrict name matching to PRIMARY-keyed rows (#1632) — set by probes whose surface is a RE-READING (a token cut out
183
- * of a longer classified span), which never named an alias. See the ResolverBackend contract in
189
+ * Restrict name matching to PRIMARY-keyed rows (#1632) — set by probes whose surface is a RE-READING (a token taken
190
+ * out of a longer classified span), which never named an alias. See the ResolverBackend contract in
184
191
  * `@mailwoman/core/resolver`.
185
192
  */
186
193
  primaryOnly?: boolean
@@ -197,14 +204,14 @@ export interface FindPlaceQuery {
197
204
  * Sibling postcode. When set on a `locality` query AND a `postcode_locality` table is present, triggers the
198
205
  * coordinate-first soft-score path: postcode→candidate localities are injected and scored `0.6·S_pc + 0.3·S_name +
199
206
  * 0.1·S_pop` against the FTS name-match set, recovering small localities the name-match alone misses. Ignored when no
200
- * postcode_locality shard is present.
207
+ * postcode_locality extract is present.
201
208
  */
202
209
  postcode?: string
203
210
  /**
204
211
  * Postcode-containment coherence (#31, Mechanism 2) — when true on a locality query that also carries `postcode`,
205
- * candidate rows within `POSTCODE_CONTAINMENT_GATE_KM` of the postcode's own centroid sort by distance first, the
206
- * rest appended in their original order. Set by the resolver from `ResolveOpts.postcodeContainmentCoherence`; absent
207
- * → the population-first order is untouched (byte-identical).
212
+ * candidate rows within `POSTCODE_CONTAINMENT_THRESHOLD_KM` of the postcode's own centroid sort by distance first,
213
+ * the rest appended in their original order. Set by the resolver from `ResolveOpts.postcodeContainmentCoherence`;
214
+ * absent → the population-first order is untouched (byte-identical).
208
215
  */
209
216
  postcodeContainmentCoherence?: boolean
210
217
  /**
@@ -243,7 +250,6 @@ export interface FindPlaceQuery {
243
250
  * interface is async even though `node:sqlite` is sync — leaves room for `Worker`-backed implementations later without
244
251
  * a public API break.
245
252
  */
246
- export interface PlaceLookup {
253
+ export interface PlaceLookup extends Disposable {
247
254
  findPlace(query: FindPlaceQuery): Promise<PlaceCandidate[]>
248
- close(): void
249
255
  }
@@ -12,23 +12,20 @@
12
12
  * `place_search` FTS5 + `place_bbox` R*Tree are built separately by `build-fts` (fts.ts).
13
13
  */
14
14
 
15
- import type { DatabaseSync } from "node:sqlite"
15
+ import type { DatabaseClient } from "@mailwoman/sqlite/client"
16
16
 
17
- import { DatabaseClient } from "@mailwoman/core/kysley/client"
17
+ import type { WOFDatabase } from "#schema"
18
18
 
19
- import type { WOFDatabase } from "./schema.ts"
20
-
21
- export async function createUnifiedSchema(db: DatabaseSync): Promise<void> {
19
+ export async function createUnifiedSchema(db: DatabaseClient<WOFDatabase>): Promise<void> {
22
20
  // PRAGMAs stay raw — not Kysely-modelled, and these tune the bulk build.
23
21
  db.exec("PRAGMA journal_mode = WAL")
24
22
  db.exec("PRAGMA busy_timeout = 10000")
25
23
  db.exec("PRAGMA synchronous = OFF")
26
24
 
27
- // `kdb` wraps `db` for the DDL (the house idiom); the caller owns `db`'s lifecycle, so we don't
25
+ // `db` wraps `db` for the DDL (the house idiom); the caller owns `db`'s lifecycle, so we don't
28
26
  // destroy it here. The bulk INSERTs (populateAncestors + build-unified-wof) stay on the raw handle.
29
- const kdb = new DatabaseClient<WOFDatabase>({ database: db })
30
27
 
31
- await kdb.schema
28
+ await db.schema
32
29
  .createTable("spr")
33
30
  .ifNotExists()
34
31
  .addColumn("id", "integer", (c) => c.primaryKey())
@@ -56,7 +53,7 @@ export async function createUnifiedSchema(db: DatabaseSync): Promise<void> {
56
53
  // x_variant rows tagged with an official language ("MSP", "Frisco") stay 0. Primary-name mirror
57
54
  // rows stay 0 too: the name-exact tier already consults spr.name; `official` only marks the
58
55
  // ALIASES eligible to join it. Both are ingest-time facts, never computed at query time.
59
- await kdb.schema
56
+ await db.schema
60
57
  .createTable("names")
61
58
  .ifNotExists()
62
59
  .addColumn("id", "integer", (c) => c.notNull())
@@ -69,7 +66,7 @@ export async function createUnifiedSchema(db: DatabaseSync): Promise<void> {
69
66
  .addColumn("lastmodified", "integer", (c) => c.notNull().defaultTo(0))
70
67
  .execute()
71
68
 
72
- await kdb.schema
69
+ await db.schema
73
70
  .createTable("concordances")
74
71
  .ifNotExists()
75
72
  .addColumn("id", "integer", (c) => c.notNull())
@@ -78,7 +75,7 @@ export async function createUnifiedSchema(db: DatabaseSync): Promise<void> {
78
75
  .addColumn("lastmodified", "integer", (c) => c.notNull().defaultTo(0))
79
76
  .execute()
80
77
 
81
- await kdb.schema
78
+ await db.schema
82
79
  .createTable("place_population")
83
80
  .ifNotExists()
84
81
  .addColumn("id", "integer", (c) => c.primaryKey())
@@ -90,7 +87,7 @@ export async function createUnifiedSchema(db: DatabaseSync): Promise<void> {
90
87
  // `spr.id IN (SELECT id FROM ancestors WHERE ancestor_id = ?)`. The off-the-shelf WOF dumps
91
88
  // ship this table; our build derives it from the parent_id chain (see populateAncestors) since
92
89
  // we don't capture `wof:hierarchy`.
93
- await kdb.schema
90
+ await db.schema
94
91
  .createTable("ancestors")
95
92
  .ifNotExists()
96
93
  .addColumn("id", "integer", (c) => c.notNull())
@@ -107,7 +104,7 @@ export async function createUnifiedSchema(db: DatabaseSync): Promise<void> {
107
104
  * Sentinel/negative parent_ids and cycles terminate the walk. ~4 rows/place average; a transaction keeps the ~5M
108
105
  * inserts fast.
109
106
  */
110
- export function populateAncestors(db: DatabaseSync): number {
107
+ export function populateAncestors<DB>(db: DatabaseClient<DB>): number {
111
108
  db.exec("DELETE FROM ancestors")
112
109
 
113
110
  const rows = db.prepare("SELECT id, parent_id, placetype FROM spr").all() as Array<{
@@ -151,22 +148,21 @@ export function populateAncestors(db: DatabaseSync): number {
151
148
  return count
152
149
  }
153
150
 
154
- export async function createUnifiedIndexes(db: DatabaseSync): Promise<void> {
155
- const kdb = new DatabaseClient<WOFDatabase>({ database: db })
156
- await kdb.schema.createIndex("spr_by_placetype").ifNotExists().on("spr").column("placetype").execute()
157
- await kdb.schema.createIndex("spr_by_country").ifNotExists().on("spr").column("country").execute()
158
- await kdb.schema.createIndex("spr_by_parent").ifNotExists().on("spr").column("parent_id").execute()
159
- await kdb.schema.createIndex("names_by_id").ifNotExists().on("names").column("id").execute()
160
- await kdb.schema.createIndex("names_by_name").ifNotExists().on("names").column("name").execute()
151
+ export async function createUnifiedIndexes(db: DatabaseClient<WOFDatabase>): Promise<void> {
152
+ await db.schema.createIndex("spr_by_placetype").ifNotExists().on("spr").column("placetype").execute()
153
+ await db.schema.createIndex("spr_by_country").ifNotExists().on("spr").column("country").execute()
154
+ await db.schema.createIndex("spr_by_parent").ifNotExists().on("spr").column("parent_id").execute()
155
+ await db.schema.createIndex("names_by_id").ifNotExists().on("names").column("id").execute()
156
+ await db.schema.createIndex("names_by_name").ifNotExists().on("names").column("name").execute()
161
157
 
162
- await kdb.schema
158
+ await db.schema
163
159
  .createIndex("concordances_by_id")
164
160
  .ifNotExists()
165
161
  .on("concordances")
166
162
  .columns(["id", "lastmodified"])
167
163
  .execute()
168
164
 
169
- await kdb.schema
165
+ await db.schema
170
166
  .createIndex("concordances_by_other_id")
171
167
  .ifNotExists()
172
168
  .on("concordances")
@@ -175,6 +171,6 @@ export async function createUnifiedIndexes(db: DatabaseSync): Promise<void> {
175
171
 
176
172
  // ancestor_id is the hot column (parent-constraint queries `WHERE ancestor_id = ?`); id supports
177
173
  // the reverse lookup.
178
- await kdb.schema.createIndex("ancestors_by_ancestor").ifNotExists().on("ancestors").column("ancestor_id").execute()
179
- await kdb.schema.createIndex("ancestors_by_id").ifNotExists().on("ancestors").column("id").execute()
174
+ await db.schema.createIndex("ancestors_by_ancestor").ifNotExists().on("ancestors").column("ancestor_id").execute()
175
+ await db.schema.createIndex("ancestors_by_id").ifNotExists().on("ancestors").column("id").execute()
180
176
  }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file The consult `./lookup.ts`'s docstring instructs: "callers building negative evidence must consult
6
+ * `readLayerCoverage`, not this reader alone." A bare `null` from `nearestUPRN` is two different facts — no UPRN here,
7
+ * or nobody surveyed here — and this is the only place that separates them. It answers an {@link Exclusion} or `null`,
8
+ * so a caller cannot read an unsurveyed cell as an empty one by accident.
9
+ *
10
+ * `radiusM` is a CALLER'S parameter with no default. There is no radius that is correct for both "which property is
11
+ * this coordinate" and "is this street built at all", and picking one here would bury that choice where nobody
12
+ * reviewing an exclusion can see it.
13
+ */
14
+
15
+ import { readLayerCoverage, readLayerManifest, type LayerContractHandle } from "@mailwoman/core/layers"
16
+ import { foldIdentity, requireExclusionBasis, type Exclusion } from "@mailwoman/evidence"
17
+ import { shortCellToParentInt } from "@mailwoman/spatial"
18
+
19
+ import type { UPRNLookup } from "#uprn/lookup"
20
+ import { UPRN_COVERAGE_H3_RESOLUTION, UPRN_H3_RESOLUTION, uprnH3Cell } from "#uprn/schema"
21
+
22
+ /**
23
+ * The identity fold, on purpose: this probe keys on a COORDINATE, not a name, so there is no string folding for the
24
+ * builder and the probe to disagree about. Passing the same identity as both `probeFold` and `layerFold` records that
25
+ * the fold axis is not in play here, rather than silently omitting the check. It is not a stub.
26
+ */
27
+ export const UPRN_EXISTENCE_FOLD = foldIdentity((s) => s)
28
+
29
+ /**
30
+ * The countries OS Open UPRN covers. Northern Ireland is outside the product, so a `null` there is unknown and must
31
+ * never become evidence of absence; the country check is what keeps it out.
32
+ */
33
+ export const UPRN_COVERED_COUNTRIES: ReadonlySet<string> = new Set(["GB"])
34
+
35
+ export interface UPRNAbsenceInput {
36
+ lookup: UPRNLookup
37
+ /**
38
+ * The same file the lookup reads; the layer contract tables live beside the points.
39
+ */
40
+ contractDB: LayerContractHandle
41
+ latitude: number
42
+ longitude: number
43
+ radiusM: number
44
+ /**
45
+ * ISO-2 country of the thing whose absence is being asserted, when known.
46
+ */
47
+ country?: string
48
+ }
49
+
50
+ /**
51
+ * The coverage cell a coordinate falls in, derived from its stored res-9 cell exactly as the builder derives it — never
52
+ * from the centroid, which lands in a different parent for a fraction of cells.
53
+ */
54
+ export function uprnCoverageCell(latitude: number, longitude: number): number {
55
+ return shortCellToParentInt(uprnH3Cell(latitude, longitude), UPRN_H3_RESOLUTION, UPRN_COVERAGE_H3_RESOLUTION)
56
+ }
57
+
58
+ /**
59
+ * An {@link Exclusion} when no UPRN lies within `radiusM` AND the layer's coverage licenses saying so; `null` on a hit
60
+ * (presence is not this probe's business) and on every refusal (unsurveyed cell, `source_present` basis, a country the
61
+ * product does not cover). Never throws on a refusal: the caller falls open to the ranking it already had.
62
+ */
63
+ export async function uprnAbsenceAt(input: UPRNAbsenceInput): Promise<Exclusion | null> {
64
+ const coverageCell = uprnCoverageCell(input.latitude, input.longitude)
65
+ const coverage = await readLayerCoverage(input.contractDB, coverageCell)
66
+
67
+ if (!coverage) return null
68
+
69
+ if (input.lookup.nearestUPRN(input.latitude, input.longitude, input.radiusM)) return null
70
+
71
+ const manifest = await readLayerManifest(input.contractDB)
72
+
73
+ return requireExclusionBasis({
74
+ layer: manifest.name,
75
+ source: manifest.source,
76
+ vintage: manifest.sourceVintage,
77
+ h3Cell: coverageCell,
78
+ cell: coverage,
79
+ probeFold: UPRN_EXISTENCE_FOLD,
80
+ layerFold: UPRN_EXISTENCE_FOLD,
81
+ country: input.country,
82
+ countries: UPRN_COVERED_COUNTRIES,
83
+ })
84
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+
7
+ export * from "#uprn/existence"
8
+ export * from "#uprn/lookup"
9
+ export * from "#uprn/schema"
@@ -25,14 +25,13 @@
25
25
  * `@mailwoman/spatial`'s `shortCellToInt` via `uprnFullCell` — never reimplemented here.
26
26
  */
27
27
 
28
- import { DatabaseSync } from "node:sqlite"
29
-
28
+ import { allRows } from "@mailwoman/core/utils"
30
29
  import { haversineKm, shortCellToInt, type H3Cell } from "@mailwoman/spatial"
30
+ import { DatabaseClient } from "@mailwoman/sqlite/client"
31
31
  import { gridDisk } from "h3-js"
32
32
 
33
- import { allRows } from "./sqlite-utils.ts"
34
- import { uprnFullCell } from "./uprn-schema.ts"
35
-
33
+ import type { UPRNDatabase } from "#uprn/schema"
34
+ import { uprnFullCell } from "#uprn/schema"
36
35
  /**
37
36
  * Conservative FLOOR on how much CENTRE distance one unit of res-9 GRID distance buys, metres. Adjacent centres sit √3
38
37
  * × edge apart (avg edge 174.4 m → ≈302 m); the worst bearing across a ring costs a further ×0.866, and H3's projection
@@ -82,7 +81,7 @@ export interface UPRNLookupOpts {
82
81
  /**
83
82
  * Pre-opened handle (tests / shared connections). Mutually exclusive with `databasePath`.
84
83
  */
85
- database?: DatabaseSync
84
+ database?: DatabaseClient<UPRNDatabase>
86
85
  }
87
86
 
88
87
  interface UPRNRow {
@@ -96,21 +95,23 @@ interface UPRNRow {
96
95
  * precedent as {@link POILookup}.
97
96
  */
98
97
  export class UPRNLookup implements Disposable {
99
- #db: DatabaseSync
100
- #ownsDB: boolean
98
+ #db: DatabaseClient<UPRNDatabase>
99
+ /**
100
+ * Resources this instance opened. A connection handed in by a caller is NOT in here, so disposal cannot reach it —
101
+ * ownership is membership rather than a flag a later branch has to check.
102
+ */
103
+ readonly #resources = new DisposableStack()
101
104
 
102
105
  /**
103
106
  * `uprn` → its point (rowid-alias PK hit).
104
107
  */
105
- readonly #coordinateProbe: ReturnType<DatabaseSync["prepare"]>
108
+ readonly #coordinateProbe: ReturnType<DatabaseClient["prepare"]>
106
109
 
107
110
  constructor(opts: UPRNLookupOpts) {
108
111
  if (opts.database) {
109
112
  this.#db = opts.database
110
- this.#ownsDB = false
111
113
  } else if (opts.databasePath) {
112
- this.#db = new DatabaseSync(opts.databasePath, { readOnly: true })
113
- this.#ownsDB = true
114
+ this.#db = this.#resources.use(new DatabaseClient<UPRNDatabase>(opts.databasePath, { readOnly: true }))
114
115
  } else {
115
116
  throw new Error("UPRNLookup needs `databasePath` or `database`")
116
117
  }
@@ -198,13 +199,7 @@ export class UPRNLookup implements Disposable {
198
199
  return best
199
200
  }
200
201
 
201
- close(): void {
202
- if (this.#ownsDB) {
203
- this.#db.close()
204
- }
205
- }
206
-
207
202
  [Symbol.dispose](): void {
208
- this.close()
203
+ this.#resources[Symbol.dispose]()
209
204
  }
210
205
  }
@@ -22,11 +22,11 @@
22
22
  * The layer contract requires every domain row to be addressable by at least one spine key —
23
23
  * `writeLayerManifest` throws on a manifest that declares none — and UPRN is its own id space, not
24
24
  * H3/WOF/address-id/street. The res-9 short cell (`shortCellToInt`, the same packing as poi.db and
25
- * the OSM situs shards) is the spine that fits a point table, and its index doubles as the
25
+ * the OSM situs extracts) is the spine that fits a point table, and its index doubles as the
26
26
  * `nearestUPRN` ring probe.
27
27
  *
28
28
  * The DB also embeds the layer-contract tables from `@mailwoman/core/layers`; the builder
29
- * (`packages/mailwoman/gazetteer-pipeline/uprn-layer.ts`) writes the manifest and per-res-6-cell
29
+ * (`packages/mailwoman/lib/gazetteer-pipeline/uprn-layer.ts`) writes the manifest and per-res-6-cell
30
30
  * coverage.
31
31
  */
32
32
 
@@ -37,7 +37,7 @@ import type { Kysely } from "kysely"
37
37
 
38
38
  /**
39
39
  * Resolution the `uprn` table's `h3_cell` column is keyed at — the shared layer-spine resolution (poi.db, the OSM situs
40
- * shards).
40
+ * extracts).
41
41
  */
42
42
  export const UPRN_H3_RESOLUTION = 9
43
43