@mailwoman/resolver-wof-sqlite 9.1.0 → 9.3.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 (501) hide show
  1. package/README.md +36 -20
  2. package/lib/address/index.ts +9 -0
  3. package/{address-point-interpolation.ts → lib/address/point-interpolation.ts} +40 -28
  4. package/{address-point-schema.ts → lib/address/point-schema.ts} +34 -8
  5. package/lib/address/point.ts +280 -0
  6. package/{ancestry-backfill.ts → lib/ancestry/backfill.ts} +14 -19
  7. package/{ancestry.ts → lib/ancestry/index.ts} +13 -8
  8. package/{build-candidate.ts → lib/build-candidate.ts} +243 -199
  9. package/{build-slim.ts → lib/build-slim.ts} +153 -168
  10. package/lib/candidate/alias-bags.ts +56 -0
  11. package/lib/candidate/ancestors-sidecar.ts +204 -0
  12. package/lib/candidate/country-display-names.ts +79 -0
  13. package/lib/candidate/extract-fold.ts +138 -0
  14. package/lib/candidate/name-roles.ts +238 -0
  15. package/lib/candidate/own-name.ts +146 -0
  16. package/lib/candidate/place-attrs.ts +44 -0
  17. package/lib/candidate-ancestors-schema.ts +195 -0
  18. package/{candidate-fts.ts → lib/candidate-fts.ts} +7 -5
  19. package/{candidate-importance.ts → lib/candidate-importance.ts} +54 -57
  20. package/lib/candidate-lookup.ts +976 -0
  21. package/{candidate-schema.ts → lib/candidate-schema.ts} +34 -6
  22. package/lib/candidate-scoring.ts +261 -0
  23. package/lib/capital-schema.ts +89 -0
  24. package/lib/capitals.ts +148 -0
  25. package/{coincident-roles.ts → lib/coincident-roles.ts} +75 -19
  26. package/{convention.ts → lib/convention/index.ts} +5 -5
  27. package/lib/convention/schema.ts +72 -0
  28. package/{coverage-manifest-schema.ts → lib/coverage-manifest-schema.ts} +15 -16
  29. package/lib/currency-backfill.ts +334 -0
  30. package/lib/env.ts +50 -0
  31. package/lib/exact-match.ts +113 -0
  32. package/{sharding.ts → lib/extracts.ts} +63 -60
  33. package/lib/fst/autocomplete.ts +176 -0
  34. package/{fst-builder.ts → lib/fst/builder.ts} +30 -27
  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} +42 -75
  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} +28 -23
  43. package/{fts-query.ts → lib/fts/query.ts} +2 -2
  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} +16 -15
  47. package/{index.ts → lib/index.ts} +52 -48
  48. package/{interpolation.ts → lib/interpolation.ts} +137 -41
  49. package/lib/lookup.ts +861 -0
  50. package/{name-score.ts → lib/name-score.ts} +6 -4
  51. package/lib/nsul/index.ts +8 -0
  52. package/lib/nsul/lookup.ts +144 -0
  53. package/lib/nsul/schema.ts +130 -0
  54. package/{place-importance-schema.ts → lib/place-importance-schema.ts} +70 -22
  55. package/lib/poi/index.ts +8 -0
  56. package/{poi-lookup.ts → lib/poi/lookup.ts} +32 -39
  57. package/{poi-schema.ts → lib/poi/schema.ts} +10 -6
  58. package/lib/polygon-schema.ts +47 -0
  59. package/{postal-city-alias-lookup.ts → lib/postal/city-alias-lookup.ts} +15 -21
  60. package/{postal-city-candidate-schema.ts → lib/postal/city-candidate-schema.ts} +4 -2
  61. package/lib/postal/index.ts +9 -0
  62. package/{postcode-point-lookup.ts → lib/postcode-point-lookup.ts} +17 -15
  63. package/lib/primary-preference.ts +226 -0
  64. package/lib/proximity-rerank.ts +120 -0
  65. package/{ranking-weights.ts → lib/ranking-weights.ts} +30 -4
  66. package/lib/region-keys.ts +144 -0
  67. package/{reverse.ts → lib/reverse.ts} +45 -56
  68. package/{schema.ts → lib/schema.ts} +11 -1
  69. package/lib/search-fetch.ts +257 -0
  70. package/{sqlite-convention-source.ts → lib/sqlite-convention-source.ts} +9 -10
  71. package/lib/sqlite-utils.ts +83 -0
  72. package/{street-centroid-schema.ts → lib/street/centroid-schema.ts} +12 -6
  73. package/{street-centroid.ts → lib/street/centroid.ts} +26 -28
  74. package/lib/street/index.ts +13 -0
  75. package/{street-morphology-fst-builder.ts → lib/street/morphology-fst-builder.ts} +24 -14
  76. package/{street-morphology-fst-loader.ts → lib/street/morphology-fst-loader.ts} +14 -12
  77. package/{street-name-lookup.ts → lib/street/name-lookup.ts} +14 -30
  78. package/lib/street/normalize.ts +572 -0
  79. package/{street-segment-schema.ts → lib/street/segment-schema.ts} +13 -8
  80. package/{types.ts → lib/types.ts} +49 -9
  81. package/{unified-schema.ts → lib/unified-schema.ts} +21 -25
  82. package/lib/uprn/existence.ts +84 -0
  83. package/lib/uprn/index.ts +9 -0
  84. package/lib/uprn/lookup.ts +206 -0
  85. package/lib/uprn/schema.ts +124 -0
  86. package/lib/weights-overlay-linker.ts +878 -0
  87. package/out/address/index.d.ts +9 -0
  88. package/out/address/index.d.ts.map +1 -0
  89. package/out/address/index.js +9 -0
  90. package/out/address/index.js.map +1 -0
  91. package/out/{address-point-interpolation.d.ts → address/point-interpolation.d.ts} +11 -10
  92. package/out/address/point-interpolation.d.ts.map +1 -0
  93. package/out/{address-point-interpolation.js → address/point-interpolation.js} +29 -23
  94. package/out/address/point-interpolation.js.map +1 -0
  95. package/out/{address-point-schema.d.ts → address/point-schema.d.ts} +30 -10
  96. package/out/address/point-schema.d.ts.map +1 -0
  97. package/out/{address-point-schema.js → address/point-schema.js} +7 -3
  98. package/out/address/point-schema.js.map +1 -0
  99. package/out/{address-point.d.ts → address/point.d.ts} +16 -8
  100. package/out/address/point.d.ts.map +1 -0
  101. package/out/address/point.js +191 -0
  102. package/out/address/point.js.map +1 -0
  103. package/out/{ancestry-backfill.d.ts → ancestry/backfill.d.ts} +7 -5
  104. package/out/ancestry/backfill.d.ts.map +1 -0
  105. package/out/{ancestry-backfill.js → ancestry/backfill.js} +12 -16
  106. package/out/ancestry/backfill.js.map +1 -0
  107. package/out/{ancestry.d.ts → ancestry/index.d.ts} +6 -5
  108. package/out/ancestry/index.d.ts.map +1 -0
  109. package/out/{ancestry.js → ancestry/index.js} +7 -7
  110. package/out/ancestry/index.js.map +1 -0
  111. package/out/build-candidate.d.ts +88 -7
  112. package/out/build-candidate.d.ts.map +1 -1
  113. package/out/build-candidate.js +145 -149
  114. package/out/build-candidate.js.map +1 -1
  115. package/out/build-slim.d.ts +5 -5
  116. package/out/build-slim.d.ts.map +1 -1
  117. package/out/build-slim.js +127 -142
  118. package/out/build-slim.js.map +1 -1
  119. package/out/candidate/alias-bags.d.ts +19 -0
  120. package/out/candidate/alias-bags.d.ts.map +1 -0
  121. package/out/candidate/alias-bags.js +39 -0
  122. package/out/candidate/alias-bags.js.map +1 -0
  123. package/out/candidate/ancestors-sidecar.d.ts +32 -0
  124. package/out/candidate/ancestors-sidecar.d.ts.map +1 -0
  125. package/out/candidate/ancestors-sidecar.js +140 -0
  126. package/out/candidate/ancestors-sidecar.js.map +1 -0
  127. package/out/candidate/country-display-names.d.ts +35 -0
  128. package/out/candidate/country-display-names.d.ts.map +1 -0
  129. package/out/candidate/country-display-names.js +59 -0
  130. package/out/candidate/country-display-names.js.map +1 -0
  131. package/out/candidate/extract-fold.d.ts +32 -0
  132. package/out/candidate/extract-fold.d.ts.map +1 -0
  133. package/out/candidate/extract-fold.js +104 -0
  134. package/out/candidate/extract-fold.js.map +1 -0
  135. package/out/candidate/name-roles.d.ts +57 -0
  136. package/out/candidate/name-roles.d.ts.map +1 -0
  137. package/out/candidate/name-roles.js +166 -0
  138. package/out/candidate/name-roles.js.map +1 -0
  139. package/out/candidate/own-name.d.ts +50 -0
  140. package/out/candidate/own-name.d.ts.map +1 -0
  141. package/out/candidate/own-name.js +132 -0
  142. package/out/candidate/own-name.js.map +1 -0
  143. package/out/candidate/place-attrs.d.ts +43 -0
  144. package/out/candidate/place-attrs.d.ts.map +1 -0
  145. package/out/candidate/place-attrs.js +15 -0
  146. package/out/candidate/place-attrs.js.map +1 -0
  147. package/out/candidate-ancestors-schema.d.ts +150 -0
  148. package/out/candidate-ancestors-schema.d.ts.map +1 -0
  149. package/out/candidate-ancestors-schema.js +123 -0
  150. package/out/candidate-ancestors-schema.js.map +1 -0
  151. package/out/candidate-fts.d.ts +7 -5
  152. package/out/candidate-fts.d.ts.map +1 -1
  153. package/out/candidate-fts.js +5 -3
  154. package/out/candidate-fts.js.map +1 -1
  155. package/out/candidate-importance.d.ts +16 -16
  156. package/out/candidate-importance.d.ts.map +1 -1
  157. package/out/candidate-importance.js +47 -52
  158. package/out/candidate-importance.js.map +1 -1
  159. package/out/candidate-lookup.d.ts +31 -52
  160. package/out/candidate-lookup.d.ts.map +1 -1
  161. package/out/candidate-lookup.js +380 -172
  162. package/out/candidate-lookup.js.map +1 -1
  163. package/out/candidate-schema.d.ts +31 -7
  164. package/out/candidate-schema.d.ts.map +1 -1
  165. package/out/candidate-schema.js +3 -0
  166. package/out/candidate-schema.js.map +1 -1
  167. package/out/candidate-scoring.d.ts +34 -0
  168. package/out/candidate-scoring.d.ts.map +1 -0
  169. package/out/candidate-scoring.js +196 -0
  170. package/out/candidate-scoring.js.map +1 -0
  171. package/out/capital-schema.d.ts +51 -0
  172. package/out/capital-schema.d.ts.map +1 -0
  173. package/out/capital-schema.js +63 -0
  174. package/out/capital-schema.js.map +1 -0
  175. package/out/capitals.d.ts +69 -0
  176. package/out/capitals.d.ts.map +1 -0
  177. package/out/capitals.js +98 -0
  178. package/out/capitals.js.map +1 -0
  179. package/out/coincident-roles.d.ts +12 -4
  180. package/out/coincident-roles.d.ts.map +1 -1
  181. package/out/coincident-roles.js +43 -11
  182. package/out/coincident-roles.js.map +1 -1
  183. package/out/{convention.d.ts → convention/index.d.ts} +5 -5
  184. package/out/convention/index.d.ts.map +1 -0
  185. package/out/{convention.js → convention/index.js} +4 -4
  186. package/out/convention/index.js.map +1 -0
  187. package/out/convention/schema.d.ts +51 -0
  188. package/out/convention/schema.d.ts.map +1 -0
  189. package/out/convention/schema.js +34 -0
  190. package/out/convention/schema.js.map +1 -0
  191. package/out/coverage-manifest-schema.d.ts +8 -8
  192. package/out/coverage-manifest-schema.d.ts.map +1 -1
  193. package/out/coverage-manifest-schema.js +6 -10
  194. package/out/coverage-manifest-schema.js.map +1 -1
  195. package/out/currency-backfill.d.ts +90 -0
  196. package/out/currency-backfill.d.ts.map +1 -0
  197. package/out/currency-backfill.js +196 -0
  198. package/out/currency-backfill.js.map +1 -0
  199. package/out/env.d.ts +43 -0
  200. package/out/env.d.ts.map +1 -0
  201. package/out/env.js +48 -0
  202. package/out/env.js.map +1 -0
  203. package/out/exact-match.d.ts +25 -0
  204. package/out/exact-match.d.ts.map +1 -0
  205. package/out/exact-match.js +88 -0
  206. package/out/exact-match.js.map +1 -0
  207. package/out/extracts.d.ts +114 -0
  208. package/out/extracts.d.ts.map +1 -0
  209. package/out/{sharding.js → extracts.js} +38 -38
  210. package/out/extracts.js.map +1 -0
  211. package/out/{fst-autocomplete.d.ts → fst/autocomplete.d.ts} +13 -13
  212. package/out/fst/autocomplete.d.ts.map +1 -0
  213. package/out/fst/autocomplete.js +113 -0
  214. package/out/fst/autocomplete.js.map +1 -0
  215. package/out/{fst-builder.d.ts → fst/builder.d.ts} +5 -5
  216. package/out/fst/builder.d.ts.map +1 -0
  217. package/out/{fst-builder.js → fst/builder.js} +24 -24
  218. package/out/fst/builder.js.map +1 -0
  219. package/out/{fst-deserialize-web.d.ts → fst/deserialize-web.d.ts} +3 -3
  220. package/out/fst/deserialize-web.d.ts.map +1 -0
  221. package/out/{fst-deserialize-web.js → fst/deserialize-web.js} +10 -74
  222. package/out/fst/deserialize-web.js.map +1 -0
  223. package/out/fst/format.d.ts +80 -0
  224. package/out/fst/format.d.ts.map +1 -0
  225. package/out/fst/format.js +91 -0
  226. package/out/fst/format.js.map +1 -0
  227. package/out/{fst-freshness.d.ts → fst/freshness.d.ts} +11 -14
  228. package/out/fst/freshness.d.ts.map +1 -0
  229. package/out/{fst-freshness.js → fst/freshness.js} +42 -74
  230. package/out/fst/freshness.js.map +1 -0
  231. package/out/fst/index.d.ts +14 -0
  232. package/out/fst/index.d.ts.map +1 -0
  233. package/out/fst/index.js +14 -0
  234. package/out/fst/index.js.map +1 -0
  235. package/out/{fst-matcher.d.ts → fst/matcher.d.ts} +2 -2
  236. package/out/fst/matcher.d.ts.map +1 -0
  237. package/out/{fst-matcher.js → fst/matcher.js} +1 -1
  238. package/out/fst/matcher.js.map +1 -0
  239. package/out/{fst-serialize.d.ts → fst/serialize.d.ts} +5 -10
  240. package/out/fst/serialize.d.ts.map +1 -0
  241. package/out/{fst-serialize.js → fst/serialize.js} +18 -98
  242. package/out/fst/serialize.js.map +1 -0
  243. package/out/{fst-types.d.ts → fst/types.d.ts} +4 -3
  244. package/out/fst/types.d.ts.map +1 -0
  245. package/out/{fst-types.js → fst/types.js} +1 -1
  246. package/out/fst/types.js.map +1 -0
  247. package/out/{fts.d.ts → fts/index.d.ts} +20 -13
  248. package/out/fts/index.d.ts.map +1 -0
  249. package/out/{fts.js → fts/index.js} +20 -15
  250. package/out/fts/index.js.map +1 -0
  251. package/out/{fts-query.d.ts → fts/query.d.ts} +2 -2
  252. package/out/fts/query.d.ts.map +1 -0
  253. package/out/{fts-query.js → fts/query.js} +2 -2
  254. package/out/fts/query.js.map +1 -0
  255. package/out/{geonames-aliases.d.ts → geonames/aliases.d.ts} +8 -6
  256. package/out/geonames/aliases.d.ts.map +1 -0
  257. package/out/{geonames-aliases.js → geonames/aliases.js} +7 -7
  258. package/out/geonames/aliases.js.map +1 -0
  259. package/out/geonames/index.d.ts +8 -0
  260. package/out/geonames/index.d.ts.map +1 -0
  261. package/out/geonames/index.js +8 -0
  262. package/out/geonames/index.js.map +1 -0
  263. package/out/{geonames-postal.d.ts → geonames/postal.d.ts} +12 -10
  264. package/out/geonames/postal.d.ts.map +1 -0
  265. package/out/{geonames-postal.js → geonames/postal.js} +11 -11
  266. package/out/geonames/postal.js.map +1 -0
  267. package/out/index.d.ts +32 -31
  268. package/out/index.d.ts.map +1 -1
  269. package/out/index.js +24 -24
  270. package/out/index.js.map +1 -1
  271. package/out/interpolation.d.ts +18 -9
  272. package/out/interpolation.d.ts.map +1 -1
  273. package/out/interpolation.js +108 -36
  274. package/out/interpolation.js.map +1 -1
  275. package/out/lookup.d.ts +25 -25
  276. package/out/lookup.d.ts.map +1 -1
  277. package/out/lookup.js +174 -558
  278. package/out/lookup.js.map +1 -1
  279. package/out/name-score.d.ts +0 -10
  280. package/out/name-score.d.ts.map +1 -1
  281. package/out/name-score.js +6 -4
  282. package/out/name-score.js.map +1 -1
  283. package/out/nsul/index.d.ts +8 -0
  284. package/out/nsul/index.d.ts.map +1 -0
  285. package/out/nsul/index.js +8 -0
  286. package/out/nsul/index.js.map +1 -0
  287. package/out/nsul/lookup.d.ts +83 -0
  288. package/out/nsul/lookup.d.ts.map +1 -0
  289. package/out/nsul/lookup.js +80 -0
  290. package/out/nsul/lookup.js.map +1 -0
  291. package/out/nsul/schema.d.ts +100 -0
  292. package/out/nsul/schema.d.ts.map +1 -0
  293. package/out/nsul/schema.js +78 -0
  294. package/out/nsul/schema.js.map +1 -0
  295. package/out/place-importance-schema.d.ts +47 -10
  296. package/out/place-importance-schema.d.ts.map +1 -1
  297. package/out/place-importance-schema.js +56 -10
  298. package/out/place-importance-schema.js.map +1 -1
  299. package/out/poi/index.d.ts +8 -0
  300. package/out/poi/index.d.ts.map +1 -0
  301. package/out/poi/index.js +8 -0
  302. package/out/poi/index.js.map +1 -0
  303. package/out/{poi-lookup.d.ts → poi/lookup.d.ts} +8 -10
  304. package/out/poi/lookup.d.ts.map +1 -0
  305. package/out/{poi-lookup.js → poi/lookup.js} +24 -29
  306. package/out/poi/lookup.js.map +1 -0
  307. package/out/{poi-schema.d.ts → poi/schema.d.ts} +10 -6
  308. package/out/poi/schema.d.ts.map +1 -0
  309. package/out/{poi-schema.js → poi/schema.js} +1 -1
  310. package/out/poi/schema.js.map +1 -0
  311. package/out/polygon-schema.d.ts +37 -0
  312. package/out/polygon-schema.d.ts.map +1 -0
  313. package/out/polygon-schema.js +23 -0
  314. package/out/polygon-schema.js.map +1 -0
  315. package/out/{postal-city-alias-lookup.d.ts → postal/city-alias-lookup.d.ts} +7 -6
  316. package/out/postal/city-alias-lookup.d.ts.map +1 -0
  317. package/out/{postal-city-alias-lookup.js → postal/city-alias-lookup.js} +12 -16
  318. package/out/postal/city-alias-lookup.js.map +1 -0
  319. package/out/{postal-city-alias-schema.d.ts → postal/city-alias-schema.d.ts} +1 -1
  320. package/out/{postal-city-alias-schema.d.ts.map → postal/city-alias-schema.d.ts.map} +1 -1
  321. package/out/{postal-city-alias-schema.js → postal/city-alias-schema.js} +1 -1
  322. package/out/{postal-city-alias-schema.js.map → postal/city-alias-schema.js.map} +1 -1
  323. package/out/{postal-city-candidate-schema.d.ts → postal/city-candidate-schema.d.ts} +4 -3
  324. package/out/postal/city-candidate-schema.d.ts.map +1 -0
  325. package/out/{postal-city-candidate-schema.js → postal/city-candidate-schema.js} +2 -2
  326. package/out/{postal-city-candidate-schema.js.map → postal/city-candidate-schema.js.map} +1 -1
  327. package/out/postal/index.d.ts +9 -0
  328. package/out/postal/index.d.ts.map +1 -0
  329. package/out/postal/index.js +9 -0
  330. package/out/postal/index.js.map +1 -0
  331. package/out/postcode-point-lookup.d.ts +10 -10
  332. package/out/postcode-point-lookup.d.ts.map +1 -1
  333. package/out/postcode-point-lookup.js +13 -13
  334. package/out/postcode-point-lookup.js.map +1 -1
  335. package/out/primary-preference.d.ts +133 -0
  336. package/out/primary-preference.d.ts.map +1 -0
  337. package/out/primary-preference.js +146 -0
  338. package/out/primary-preference.js.map +1 -0
  339. package/out/proximity-rerank.d.ts +77 -0
  340. package/out/proximity-rerank.d.ts.map +1 -0
  341. package/out/proximity-rerank.js +86 -0
  342. package/out/proximity-rerank.js.map +1 -0
  343. package/out/ranking-weights.d.ts +15 -3
  344. package/out/ranking-weights.d.ts.map +1 -1
  345. package/out/ranking-weights.js +21 -3
  346. package/out/ranking-weights.js.map +1 -1
  347. package/out/region-keys.d.ts +47 -0
  348. package/out/region-keys.d.ts.map +1 -0
  349. package/out/region-keys.js +121 -0
  350. package/out/region-keys.js.map +1 -0
  351. package/out/reverse.d.ts +6 -6
  352. package/out/reverse.d.ts.map +1 -1
  353. package/out/reverse.js +23 -35
  354. package/out/reverse.js.map +1 -1
  355. package/out/schema.d.ts +10 -1
  356. package/out/schema.d.ts.map +1 -1
  357. package/out/schema.js.map +1 -1
  358. package/out/search-fetch.d.ts +59 -0
  359. package/out/search-fetch.d.ts.map +1 -0
  360. package/out/search-fetch.js +184 -0
  361. package/out/search-fetch.js.map +1 -0
  362. package/out/sqlite-convention-source.d.ts +7 -7
  363. package/out/sqlite-convention-source.d.ts.map +1 -1
  364. package/out/sqlite-convention-source.js +5 -5
  365. package/out/sqlite-convention-source.js.map +1 -1
  366. package/out/sqlite-utils.d.ts +24 -6
  367. package/out/sqlite-utils.d.ts.map +1 -1
  368. package/out/sqlite-utils.js +24 -7
  369. package/out/sqlite-utils.js.map +1 -1
  370. package/out/{street-centroid-schema.d.ts → street/centroid-schema.d.ts} +12 -7
  371. package/out/street/centroid-schema.d.ts.map +1 -0
  372. package/out/{street-centroid-schema.js → street/centroid-schema.js} +5 -5
  373. package/out/{street-centroid-schema.js.map → street/centroid-schema.js.map} +1 -1
  374. package/out/{street-centroid.d.ts → street/centroid.d.ts} +6 -6
  375. package/out/street/centroid.d.ts.map +1 -0
  376. package/out/{street-centroid.js → street/centroid.js} +18 -24
  377. package/out/street/centroid.js.map +1 -0
  378. package/out/street/index.d.ts +13 -0
  379. package/out/street/index.d.ts.map +1 -0
  380. package/out/street/index.js +13 -0
  381. package/out/street/index.js.map +1 -0
  382. package/out/{street-morphology-fst-builder.d.ts → street/morphology-fst-builder.d.ts} +4 -4
  383. package/out/street/morphology-fst-builder.d.ts.map +1 -0
  384. package/out/{street-morphology-fst-builder.js → street/morphology-fst-builder.js} +18 -13
  385. package/out/street/morphology-fst-builder.js.map +1 -0
  386. package/out/{street-morphology-fst-loader.d.ts → street/morphology-fst-loader.d.ts} +5 -5
  387. package/out/street/morphology-fst-loader.d.ts.map +1 -0
  388. package/out/{street-morphology-fst-loader.js → street/morphology-fst-loader.js} +11 -10
  389. package/out/street/morphology-fst-loader.js.map +1 -0
  390. package/out/{street-name-lookup.d.ts → street/name-lookup.d.ts} +4 -7
  391. package/out/street/name-lookup.d.ts.map +1 -0
  392. package/out/{street-name-lookup.js → street/name-lookup.js} +9 -23
  393. package/out/street/name-lookup.js.map +1 -0
  394. package/out/street/normalize.d.ts +179 -0
  395. package/out/street/normalize.d.ts.map +1 -0
  396. package/out/street/normalize.js +457 -0
  397. package/out/street/normalize.js.map +1 -0
  398. package/out/{street-segment-schema.d.ts → street/segment-schema.d.ts} +13 -9
  399. package/out/street/segment-schema.d.ts.map +1 -0
  400. package/out/{street-segment-schema.js → street/segment-schema.js} +4 -4
  401. package/out/{street-segment-schema.js.map → street/segment-schema.js.map} +1 -1
  402. package/out/types.d.ts +49 -9
  403. package/out/types.d.ts.map +1 -1
  404. package/out/types.js.map +1 -1
  405. package/out/unified-schema.d.ts +6 -5
  406. package/out/unified-schema.d.ts.map +1 -1
  407. package/out/unified-schema.js +16 -19
  408. package/out/unified-schema.js.map +1 -1
  409. package/out/uprn/existence.d.ts +53 -0
  410. package/out/uprn/existence.d.ts.map +1 -0
  411. package/out/uprn/existence.js +61 -0
  412. package/out/uprn/existence.js.map +1 -0
  413. package/out/uprn/index.d.ts +9 -0
  414. package/out/uprn/index.d.ts.map +1 -0
  415. package/out/uprn/index.js +9 -0
  416. package/out/uprn/index.js.map +1 -0
  417. package/out/uprn/lookup.d.ts +85 -0
  418. package/out/uprn/lookup.d.ts.map +1 -0
  419. package/out/uprn/lookup.js +149 -0
  420. package/out/uprn/lookup.js.map +1 -0
  421. package/out/uprn/schema.d.ts +93 -0
  422. package/out/uprn/schema.d.ts.map +1 -0
  423. package/out/uprn/schema.js +78 -0
  424. package/out/uprn/schema.js.map +1 -0
  425. package/out/weights-overlay-linker.d.ts +299 -0
  426. package/out/weights-overlay-linker.d.ts.map +1 -0
  427. package/out/weights-overlay-linker.js +511 -0
  428. package/out/weights-overlay-linker.js.map +1 -0
  429. package/package.json +622 -154
  430. package/address-point.ts +0 -125
  431. package/candidate-lookup.ts +0 -720
  432. package/fst-autocomplete.ts +0 -204
  433. package/geo.ts +0 -121
  434. package/lookup.ts +0 -1354
  435. package/out/address-point-interpolation.d.ts.map +0 -1
  436. package/out/address-point-interpolation.js.map +0 -1
  437. package/out/address-point-schema.d.ts.map +0 -1
  438. package/out/address-point-schema.js.map +0 -1
  439. package/out/address-point.d.ts.map +0 -1
  440. package/out/address-point.js +0 -84
  441. package/out/address-point.js.map +0 -1
  442. package/out/ancestry-backfill.d.ts.map +0 -1
  443. package/out/ancestry-backfill.js.map +0 -1
  444. package/out/ancestry.d.ts.map +0 -1
  445. package/out/ancestry.js.map +0 -1
  446. package/out/convention.d.ts.map +0 -1
  447. package/out/convention.js.map +0 -1
  448. package/out/fst-autocomplete.d.ts.map +0 -1
  449. package/out/fst-autocomplete.js +0 -130
  450. package/out/fst-autocomplete.js.map +0 -1
  451. package/out/fst-builder.d.ts.map +0 -1
  452. package/out/fst-builder.js.map +0 -1
  453. package/out/fst-deserialize-web.d.ts.map +0 -1
  454. package/out/fst-deserialize-web.js.map +0 -1
  455. package/out/fst-freshness.d.ts.map +0 -1
  456. package/out/fst-freshness.js.map +0 -1
  457. package/out/fst-matcher.d.ts.map +0 -1
  458. package/out/fst-matcher.js.map +0 -1
  459. package/out/fst-serialize.d.ts.map +0 -1
  460. package/out/fst-serialize.js.map +0 -1
  461. package/out/fst-types.d.ts.map +0 -1
  462. package/out/fst-types.js.map +0 -1
  463. package/out/fts-query.d.ts.map +0 -1
  464. package/out/fts-query.js.map +0 -1
  465. package/out/fts.d.ts.map +0 -1
  466. package/out/fts.js.map +0 -1
  467. package/out/geo.d.ts +0 -74
  468. package/out/geo.d.ts.map +0 -1
  469. package/out/geo.js +0 -71
  470. package/out/geo.js.map +0 -1
  471. package/out/geonames-aliases.d.ts.map +0 -1
  472. package/out/geonames-aliases.js.map +0 -1
  473. package/out/geonames-postal.d.ts.map +0 -1
  474. package/out/geonames-postal.js.map +0 -1
  475. package/out/poi-lookup.d.ts.map +0 -1
  476. package/out/poi-lookup.js.map +0 -1
  477. package/out/poi-schema.d.ts.map +0 -1
  478. package/out/poi-schema.js.map +0 -1
  479. package/out/postal-city-alias-lookup.d.ts.map +0 -1
  480. package/out/postal-city-alias-lookup.js.map +0 -1
  481. package/out/postal-city-candidate-schema.d.ts.map +0 -1
  482. package/out/sharding.d.ts +0 -114
  483. package/out/sharding.d.ts.map +0 -1
  484. package/out/sharding.js.map +0 -1
  485. package/out/street-centroid-schema.d.ts.map +0 -1
  486. package/out/street-centroid.d.ts.map +0 -1
  487. package/out/street-centroid.js.map +0 -1
  488. package/out/street-morphology-fst-builder.d.ts.map +0 -1
  489. package/out/street-morphology-fst-builder.js.map +0 -1
  490. package/out/street-morphology-fst-loader.d.ts.map +0 -1
  491. package/out/street-morphology-fst-loader.js.map +0 -1
  492. package/out/street-name-lookup.d.ts.map +0 -1
  493. package/out/street-name-lookup.js.map +0 -1
  494. package/out/street-normalize.d.ts +0 -95
  495. package/out/street-normalize.d.ts.map +0 -1
  496. package/out/street-normalize.js +0 -272
  497. package/out/street-normalize.js.map +0 -1
  498. package/out/street-segment-schema.d.ts.map +0 -1
  499. package/sqlite-utils.ts +0 -46
  500. package/street-normalize.ts +0 -318
  501. /package/{postal-city-alias-schema.ts → lib/postal/city-alias-schema.ts} +0 -0
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The CAPITAL-STATUS reference index (#1880) — answers, for one resolved candidate, "is this
7
+ * place the national capital or an admin-1 seat of its country?". The consumer is the resolver's
8
+ * bounded capital promotion (`@mailwoman/resolver`'s `promoteCapitals`, applied after the fame
9
+ * key on the bare-toponym class); this module only matches, it never ranks. PURE and
10
+ * platform-free (the #861 parity discipline).
11
+ *
12
+ * Matching is an IDENTITY test with three conjuncts: same country, within
13
+ * {@link CAPITAL_MATCH_RADIUS_KM} of the reference point, and the candidate's own folded name a
14
+ * member of the reference entry's folded name set (name + romanization + the source's alternate
15
+ * names, so exonym rows — "Vienna" for Wien — still match). All three are required. The
16
+ * iteration-1 board run matched on country + coordinate alone, and the 25 km radius promoted
17
+ * capital-ADJACENT namesakes instead of capitals: North Salt Lake beside the Utah seat, a Gujarat
18
+ * Indiranagar beside Gandhinagar, Via delle Parti beside Perugia. The name set is what makes the
19
+ * radius a centroid-drift allowance rather than a catchment.
20
+ */
21
+ /**
22
+ * Capital status of one candidate: national capital, admin-1 seat, or neither. Numeric so the resolver's promotion can
23
+ * compare levels.
24
+ */
25
+ export declare const CAPITAL_LEVEL: {
26
+ readonly none: 0;
27
+ readonly admin1: 1;
28
+ readonly national: 2;
29
+ };
30
+ export type CapitalLevel = (typeof CAPITAL_LEVEL)[keyof typeof CAPITAL_LEVEL];
31
+ /**
32
+ * How far a candidate row may sit from the reference point and still read as the same place — a centroid-convention
33
+ * allowance (GeoNames point vs WOF centroid on a metro-scale city), not a catchment: the name-membership conjunct is
34
+ * what excludes neighbours inside the radius.
35
+ */
36
+ export declare const CAPITAL_MATCH_RADIUS_KM = 25;
37
+ /**
38
+ * One reference entry, as `data/gazetteer/capitals-v1.json` carries it (`entries[]`).
39
+ */
40
+ export interface CapitalPoint {
41
+ /**
42
+ * ISO alpha-2, uppercase.
43
+ */
44
+ country: string;
45
+ latitude: number;
46
+ longitude: number;
47
+ level: "national" | "admin1";
48
+ /**
49
+ * Folded name keys (name + romanization + alternate names, `normalizeLocalityForKey` fold) — the membership set for
50
+ * the name conjunct.
51
+ */
52
+ k: string[];
53
+ }
54
+ /**
55
+ * Country-bucketed capital points with the three-conjunct identity probe. Construct from the parsed reference file's
56
+ * `entries` — the loader that reads the file off disk lives with the path owners (`mailwoman`'s resolver backend),
57
+ * keeping this module platform-free.
58
+ */
59
+ export declare class CapitalIndex {
60
+ #private;
61
+ constructor(entries: Iterable<CapitalPoint>);
62
+ /**
63
+ * The highest capital level whose entry passes all three conjuncts for this place. `none` — never a throw — for a
64
+ * missing name, country, or coordinate, an unknown country, or no matching entry.
65
+ */
66
+ levelOfPlace(name: string | null | undefined, country: string | null | undefined, latitude: number | null | undefined, longitude: number | null | undefined): CapitalLevel;
67
+ get size(): number;
68
+ }
69
+ //# sourceMappingURL=capitals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitals.d.ts","sourceRoot":"","sources":["../lib/capitals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;CAIhB,CAAA;AAEV,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAA;AAE7E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAA;AAEzC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAA;IAC5B;;;OAGG;IACH,CAAC,EAAE,MAAM,EAAE,CAAA;CACX;AAcD;;;;GAIG;AACH,qBAAa,YAAY;;gBAGZ,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC;IAqB3C;;;OAGG;IACH,YAAY,CACX,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,YAAY;IA0Bf,IAAI,IAAI,IAAI,MAAM,CAQjB;CACD"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The CAPITAL-STATUS reference index (#1880) — answers, for one resolved candidate, "is this
7
+ * place the national capital or an admin-1 seat of its country?". The consumer is the resolver's
8
+ * bounded capital promotion (`@mailwoman/resolver`'s `promoteCapitals`, applied after the fame
9
+ * key on the bare-toponym class); this module only matches, it never ranks. PURE and
10
+ * platform-free (the #861 parity discipline).
11
+ *
12
+ * Matching is an IDENTITY test with three conjuncts: same country, within
13
+ * {@link CAPITAL_MATCH_RADIUS_KM} of the reference point, and the candidate's own folded name a
14
+ * member of the reference entry's folded name set (name + romanization + the source's alternate
15
+ * names, so exonym rows — "Vienna" for Wien — still match). All three are required. The
16
+ * iteration-1 board run matched on country + coordinate alone, and the 25 km radius promoted
17
+ * capital-ADJACENT namesakes instead of capitals: North Salt Lake beside the Utah seat, a Gujarat
18
+ * Indiranagar beside Gandhinagar, Via delle Parti beside Perugia. The name set is what makes the
19
+ * radius a centroid-drift allowance rather than a catchment.
20
+ */
21
+ import { haversineKm } from "@mailwoman/spatial";
22
+ import { normalizeLocalityForKey } from "#street/normalize";
23
+ /**
24
+ * Capital status of one candidate: national capital, admin-1 seat, or neither. Numeric so the resolver's promotion can
25
+ * compare levels.
26
+ */
27
+ export const CAPITAL_LEVEL = {
28
+ none: 0,
29
+ admin1: 1,
30
+ national: 2,
31
+ };
32
+ /**
33
+ * How far a candidate row may sit from the reference point and still read as the same place — a centroid-convention
34
+ * allowance (GeoNames point vs WOF centroid on a metro-scale city), not a catchment: the name-membership conjunct is
35
+ * what excludes neighbours inside the radius.
36
+ */
37
+ export const CAPITAL_MATCH_RADIUS_KM = 25;
38
+ const LEVEL_OF = {
39
+ national: CAPITAL_LEVEL.national,
40
+ admin1: CAPITAL_LEVEL.admin1,
41
+ };
42
+ /**
43
+ * Country-bucketed capital points with the three-conjunct identity probe. Construct from the parsed reference file's
44
+ * `entries` — the loader that reads the file off disk lives with the path owners (`mailwoman`'s resolver backend),
45
+ * keeping this module platform-free.
46
+ */
47
+ export class CapitalIndex {
48
+ #byCountry = new Map();
49
+ constructor(entries) {
50
+ for (const entry of entries) {
51
+ const country = entry.country.toUpperCase();
52
+ const point = {
53
+ latitude: entry.latitude,
54
+ longitude: entry.longitude,
55
+ level: LEVEL_OF[entry.level],
56
+ keys: new Set(entry.k),
57
+ };
58
+ const bucket = this.#byCountry.get(country);
59
+ if (bucket) {
60
+ bucket.push(point);
61
+ }
62
+ else {
63
+ this.#byCountry.set(country, [point]);
64
+ }
65
+ }
66
+ }
67
+ /**
68
+ * The highest capital level whose entry passes all three conjuncts for this place. `none` — never a throw — for a
69
+ * missing name, country, or coordinate, an unknown country, or no matching entry.
70
+ */
71
+ levelOfPlace(name, country, latitude, longitude) {
72
+ if (!name || !country || typeof latitude !== "number" || typeof longitude !== "number")
73
+ return CAPITAL_LEVEL.none;
74
+ const bucket = this.#byCountry.get(country.toUpperCase());
75
+ if (!bucket)
76
+ return CAPITAL_LEVEL.none;
77
+ const key = String(normalizeLocalityForKey(name));
78
+ if (!key)
79
+ return CAPITAL_LEVEL.none;
80
+ let best = CAPITAL_LEVEL.none;
81
+ for (const point of bucket) {
82
+ if (point.level > best &&
83
+ point.keys.has(key) &&
84
+ haversineKm(latitude, longitude, point.latitude, point.longitude) <= CAPITAL_MATCH_RADIUS_KM) {
85
+ best = point.level;
86
+ }
87
+ }
88
+ return best;
89
+ }
90
+ get size() {
91
+ let n = 0;
92
+ for (const bucket of this.#byCountry.values()) {
93
+ n += bucket.length;
94
+ }
95
+ return n;
96
+ }
97
+ }
98
+ //# sourceMappingURL=capitals.js.map
@@ -0,0 +1 @@
1
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existing `admin-global-priority.db` via `build-coincident-roles-cli.ts`; should also
38
38
  * be wired as a post-step of the main `scripts/build-unified-wof.ts`.
39
39
  */
40
- import type { DatabaseSync } from "node:sqlite";
40
+ import type { CoincidentLocality } from "@mailwoman/resolver";
41
+ import type { DatabaseClient } from "@mailwoman/sqlite/client";
42
+ import type { WOFDatabase } from "#schema";
41
43
  /**
42
44
  * Table of places that hold more than one admin role — a locality that is also its county seat. Written by the
43
45
  * gazetteer build, read by the resolver when a coincident locality has to be chosen.
@@ -82,15 +84,21 @@ export interface BuildCoincidentRolesResult {
82
84
  * Derive the coincident-roles relation into `db`. Additive — only creates/replaces the `coincident_roles` table; never
83
85
  * touches `spr`/`names`/`ancestors`. Idempotent.
84
86
  */
85
- export declare function buildCoincidentRoles(db: DatabaseSync, opts?: BuildCoincidentRolesOpts): BuildCoincidentRolesResult;
87
+ export declare function buildCoincidentRoles(db: DatabaseClient<WOFDatabase>, opts?: BuildCoincidentRolesOpts): BuildCoincidentRolesResult;
86
88
  /**
87
89
  * True iff the relation table exists. Used by the resolver to decide whether completion can run.
88
90
  */
89
- export declare function coincidentRolesExists(db: DatabaseSync): boolean;
91
+ export declare function coincidentRolesExists<DB>(db: DatabaseClient<DB>): boolean;
90
92
  /**
91
93
  * Load the relation into an in-memory map keyed by `admin_id` for O(1) runtime lookup (#405). Each admin may map to
92
94
  * MULTIPLE same-name descendants; the consumer disambiguates (min distance → population → abstain). Returns an empty
93
95
  * map when the table is absent.
94
96
  */
95
- export declare function loadCoincidentRoles(db: DatabaseSync): Map<number, CoincidentRole[]>;
97
+ export declare function loadCoincidentRoles<DB>(db: DatabaseClient<DB>): Map<number, CoincidentRole[]>;
98
+ /**
99
+ * The relation joined with `spr`, as an in-memory map keyed by `admin_id` — the resolver-facing view of
100
+ * {@link loadCoincidentRoles}, carrying the canonical name and coordinates each coincident locality resolves to.
101
+ * Returns an empty map when the relation table is absent.
102
+ */
103
+ export declare function loadCoincidentLocalities<DB>(db: DatabaseClient<DB>): Map<number, CoincidentLocality[]>;
96
104
  //# sourceMappingURL=coincident-roles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coincident-roles.d.ts","sourceRoot":"","sources":["../coincident-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,qBAAqB,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,YAAY,GAAG,cAAc,GAAG,qBAAqB,CAAA;IACvE,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CACrD;AAED,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,UAAU,EAAE,MAAM,CAAA;CAClB;AAsBD;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,YAAY,EAChB,IAAI,GAAE,wBAA6B,GACjC,0BAA0B,CA8F5B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAE/D;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wBAAgB,oBAAoB,CACnC,EAAE,EAAE,cAAc,CAAC,WAAW,CAAC,EAC/B,IAAI,GAAE,wBAA6B,GACjC,0BAA0B,CA8F5B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,OAAO,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAsC7F;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAiDtG"}
@@ -38,14 +38,13 @@
38
38
  * be wired as a post-step of the main `scripts/build-unified-wof.ts`.
39
39
  */
40
40
  import { haversineKm } from "@mailwoman/spatial";
41
+ import { tableExists } from "@mailwoman/sqlite/introspection";
42
+ import { allRows } from "#sqlite-utils";
41
43
  /**
42
44
  * Table of places that hold more than one admin role — a locality that is also its county seat. Written by the
43
45
  * gazetteer build, read by the resolver when a coincident locality has to be chosen.
44
46
  */
45
47
  export const COINCIDENT_ROLES_TABLE = "coincident_roles";
46
- function tableExists(db, name) {
47
- return !!db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name = ?").get(name);
48
- }
49
48
  /**
50
49
  * Derive the coincident-roles relation into `db`. Additive — only creates/replaces the `coincident_roles` table; never
51
50
  * touches `spr`/`names`/`ancestors`. Idempotent.
@@ -81,8 +80,7 @@ export function buildCoincidentRoles(db, opts = {}) {
81
80
  // Admin (region/county tier) ⋈ same-name DESCENDANT locality. `place_population` is optional (LEFT
82
81
  // JOIN → 0 when absent). The relative-tolerance filter + relationship classification happen in JS so
83
82
  // the SQL stays a plain join. `spr` exposes the bbox columns we need for the diagonal.
84
- const candidates = db
85
- .prepare(`SELECT r.id AS admin_id, r.placetype AS admin_placetype, r.country AS country, l.id AS locality_id,
83
+ const candidates = allRows(db.prepare(`SELECT r.id AS admin_id, r.placetype AS admin_placetype, r.country AS country, l.id AS locality_id,
86
84
  r.latitude AS rlat, r.longitude AS rlon, l.latitude AS llat, l.longitude AS llon,
87
85
  r.min_latitude, r.min_longitude, r.max_latitude, r.max_longitude,
88
86
  COALESCE(p.population, 0) AS pop
@@ -92,8 +90,7 @@ export function buildCoincidentRoles(db, opts = {}) {
92
90
  JOIN ${"ancestors"} a ON a.id = l.id AND a.ancestor_id = r.id
93
91
  LEFT JOIN place_population p ON p.id = l.id
94
92
  WHERE r.placetype = 'region'
95
- AND r.is_current != 0 AND r.is_deprecated = 0`)
96
- .all();
93
+ AND r.is_current != 0 AND r.is_deprecated = 0`));
97
94
  onProgress("filtering", `${candidates.length} candidates`);
98
95
  const insert = db.prepare(`INSERT OR REPLACE INTO ${COINCIDENT_ROLES_TABLE}
99
96
  (admin_id, locality_id, relationship_type, admin_placetype, distance_km, locality_population)
@@ -143,10 +140,8 @@ export function loadCoincidentRoles(db) {
143
140
  const map = new Map();
144
141
  if (!coincidentRolesExists(db))
145
142
  return map;
146
- const rows = db
147
- .prepare(`SELECT admin_id, locality_id, relationship_type, admin_placetype, distance_km, locality_population
148
- FROM ${COINCIDENT_ROLES_TABLE}`)
149
- .all();
143
+ const rows = allRows(db.prepare(`SELECT admin_id, locality_id, relationship_type, admin_placetype, distance_km, locality_population
144
+ FROM ${COINCIDENT_ROLES_TABLE}`));
150
145
  for (const r of rows) {
151
146
  const entry = {
152
147
  localityID: r.locality_id,
@@ -165,4 +160,41 @@ export function loadCoincidentRoles(db) {
165
160
  }
166
161
  return map;
167
162
  }
163
+ /**
164
+ * The relation joined with `spr`, as an in-memory map keyed by `admin_id` — the resolver-facing view of
165
+ * {@link loadCoincidentRoles}, carrying the canonical name and coordinates each coincident locality resolves to.
166
+ * Returns an empty map when the relation table is absent.
167
+ */
168
+ export function loadCoincidentLocalities(db) {
169
+ const map = new Map();
170
+ if (coincidentRolesExists(db)) {
171
+ const rows = allRows(db.prepare(`SELECT cr.admin_id AS adminID, s.id AS id, s.name AS name, s.country AS country,
172
+ s.latitude AS lat, s.longitude AS lon,
173
+ cr.relationship_type AS relationshipType, cr.locality_population AS population,
174
+ cr.distance_km AS distanceKm
175
+ FROM ${COINCIDENT_ROLES_TABLE} cr JOIN spr s ON s.id = cr.locality_id`));
176
+ for (const r of rows) {
177
+ const candidate = {
178
+ id: r.id,
179
+ name: r.name,
180
+ placetype: "locality",
181
+ country: r.country,
182
+ lat: r.lat,
183
+ lon: r.lon,
184
+ score: 0,
185
+ relationshipType: r.relationshipType,
186
+ population: r.population,
187
+ distanceKm: r.distanceKm,
188
+ };
189
+ const list = map.get(r.adminID);
190
+ if (list) {
191
+ list.push(candidate);
192
+ }
193
+ else {
194
+ map.set(r.adminID, [candidate]);
195
+ }
196
+ }
197
+ }
198
+ return map;
199
+ }
168
200
  //# sourceMappingURL=coincident-roles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coincident-roles.js","sourceRoot":"","sources":["../coincident-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAA;AAwDxD,SAAS,WAAW,CAAC,EAAgB,EAAE,IAAY;IAClD,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,6DAA6D,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC7F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,EAAgB,EAChB,OAAiC,EAAE;IAEnC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACxB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,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F,CAAC;IACF,CAAC;IAED,OAAO,GAAG,CAAA;AACX,CAAC"}
@@ -20,7 +20,7 @@
20
20
  * / KR / TW add rows here (and #290 swaps the seed map for a build-from-source sqlite-backed
21
21
  * source).
22
22
  */
23
- import type { FindPlaceQuery, PlaceCandidate } from "./types.ts";
23
+ import type { FindPlaceQuery, PlaceCandidate } from "#types";
24
24
  /**
25
25
  * Soft-scoring weights for the `postcode_area_resolution` strategy: `pc·S_pc + name·S_name + pop·S_pop`.
26
26
  */
@@ -66,12 +66,12 @@ export declare const WORLD_DEFAULT: ResolvedConvention;
66
66
  */
67
67
  export declare const BUILTIN_STRATEGY_NAMES: readonly ["postcode_area_resolution", "fallback_fuzzy_name_match"];
68
68
  /**
69
- * Table name for the convention asset (#290). Carried here so the build script, the runtime source, and the shard
69
+ * Table name for the convention asset (#290). Carried here so the build script, the runtime source, and the extract
70
70
  * auto-detect all agree.
71
71
  */
72
72
  export declare const ADDRESS_CONVENTION_TABLE = "address_convention";
73
73
  /**
74
- * A named resolution primitive. Returns `null` to abstain (gate unmet / no data) → the dispatcher tries the next
74
+ * A named resolution primitive. Returns `null` to abstain (condition unmet / no data) → the dispatcher tries the next
75
75
  * strategy; returns an array (possibly empty) to claim the result.
76
76
  */
77
77
  export type Strategy = (query: FindPlaceQuery, convention: ResolvedConvention) => Promise<PlaceCandidate[] | null>;
@@ -102,5 +102,5 @@ export declare function mergeConventions(base: Convention, ...overrides: Array<C
102
102
  * region, …, locality). Starts from `WORLD_DEFAULT` so every field is defined regardless of which (if any) ancestors
103
103
  * carry an override.
104
104
  */
105
- export declare function resolveConvention(source: ConventionSource, ancestorIds: readonly number[]): ResolvedConvention;
106
- //# sourceMappingURL=convention.d.ts.map
105
+ export declare function resolveConvention(source: ConventionSource, ancestorIDs: readonly number[]): ResolvedConvention;
106
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/convention/index.ts"],"names":[],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AU,GAAG,SAAS,CAAC,GAAG,UAAU,CAmB1G;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,kBAAkB,CAS9G"}
@@ -36,7 +36,7 @@ export const WORLD_DEFAULT = {
36
36
  */
37
37
  export const BUILTIN_STRATEGY_NAMES = ["postcode_area_resolution", "fallback_fuzzy_name_match"];
38
38
  /**
39
- * Table name for the convention asset (#290). Carried here so the build script, the runtime source, and the shard
39
+ * Table name for the convention asset (#290). Carried here so the build script, the runtime source, and the extract
40
40
  * auto-detect all agree.
41
41
  */
42
42
  export const ADDRESS_CONVENTION_TABLE = "address_convention";
@@ -81,8 +81,8 @@ export function mergeConventions(base, ...overrides) {
81
81
  * region, …, locality). Starts from `WORLD_DEFAULT` so every field is defined regardless of which (if any) ancestors
82
82
  * carry an override.
83
83
  */
84
- export function resolveConvention(source, ancestorIds) {
85
- const layers = ancestorIds.map((id) => source.get(id));
84
+ export function resolveConvention(source, ancestorIDs) {
85
+ const layers = ancestorIDs.map((id) => source.get(id));
86
86
  const merged = mergeConventions(WORLD_DEFAULT, ...layers);
87
87
  return {
88
88
  candidateStrategies: merged.candidateStrategies ?? WORLD_DEFAULT.candidateStrategies,
@@ -90,4 +90,4 @@ export function resolveConvention(source, ancestorIds) {
90
90
  scoringWeights: { ...WORLD_DEFAULT.scoringWeights, ...merged.scoringWeights },
91
91
  };
92
92
  }
93
- //# sourceMappingURL=convention.js.map
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/convention/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAuCH;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAuB;IAChD,mBAAmB,EAAE,CAAC,0BAA0B,EAAE,2BAA2B,CAAC;IAC9E,cAAc,EAAE,EAAE,EAAE,EAA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ACrD,CAAC;QAED,IAAI,CAAC,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACpC,GAAG,CAAC,cAAc,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,CAAC,cAAc,EAAE,CAAA;QACtG,CAAC;IACF,CAAC;IAED,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAwB,EAAE,WAA8B;IACzF,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IACtD,MAAM,MAAM,GAAG,gBAAgB,CAAC,aAAa,EAAE,GAAG,MAAM,CAAC,CAAA;IAEzD,OAAO;QACN,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,IAAI,aAAa,CAAC,mBAAmB;QACpF,8EAA8E;QAC9E,cAAc,EAAE,EAAE,GAAG,aAAa,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,cAAc,EAAE;KAC7E,CAAA;AACF,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Typed schema for the convention asset — the `address_convention` table `SqliteConventionSource` probes, plus the
7
+ * `meta` provenance row every sealed artifact here carries. The interface is the read/write contract and
8
+ * {@link createAddressConventionTable} creates the table, so a column added to one is a compile error against the
9
+ * other.
10
+ */
11
+ import type { Kysely } from "kysely";
12
+ /**
13
+ * One convention profile, keyed by the WOF admin polygon it attaches to.
14
+ */
15
+ export interface AddressConventionTable {
16
+ wof_id: number;
17
+ /**
18
+ * The `Convention` record, JSON-encoded. Parsed at read time by `SqliteConventionSource`.
19
+ */
20
+ convention: string;
21
+ /**
22
+ * Provenance: why this row exists and where it came from.
23
+ */
24
+ source: string;
25
+ }
26
+ /**
27
+ * Key/value provenance for the sealed artifact.
28
+ */
29
+ export interface ConventionMetaTable {
30
+ key: string;
31
+ value: string | null;
32
+ }
33
+ export interface ConventionDatabase {
34
+ address_convention: AddressConventionTable;
35
+ meta: ConventionMetaTable;
36
+ }
37
+ /**
38
+ * The slice of a Kysely handle the convention DDL touches. Kysely is invariant in its schema parameter, so naming only
39
+ * `schema` lets a builder holding a wider handle pass it without a cast.
40
+ */
41
+ export type ConventionSchemaHandle = Pick<Kysely<ConventionDatabase>, "schema">;
42
+ /**
43
+ * Create `address_convention`. The table name comes from {@link ADDRESS_CONVENTION_TABLE} so the build script, the
44
+ * runtime source, and the extract auto-detect cannot drift apart.
45
+ */
46
+ export declare function createAddressConventionTable(db: ConventionSchemaHandle): Promise<void>;
47
+ /**
48
+ * Create the artifact's `meta` table.
49
+ */
50
+ export declare function createConventionMetaTable(db: ConventionSchemaHandle): Promise<void>;
51
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../lib/convention/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AAED,MAAM,WAAW,kBAAkB;IAClC,kBAAkB,EAAE,sBAAsB,CAAA;IAC1C,IAAI,EAAE,mBAAmB,CAAA;CACzB;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAA;AAE/E;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,EAAE,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAO5F;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,EAAE,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Typed schema for the convention asset — the `address_convention` table `SqliteConventionSource` probes, plus the
7
+ * `meta` provenance row every sealed artifact here carries. The interface is the read/write contract and
8
+ * {@link createAddressConventionTable} creates the table, so a column added to one is a compile error against the
9
+ * other.
10
+ */
11
+ import { ADDRESS_CONVENTION_TABLE } from "#convention/index";
12
+ /**
13
+ * Create `address_convention`. The table name comes from {@link ADDRESS_CONVENTION_TABLE} so the build script, the
14
+ * runtime source, and the extract auto-detect cannot drift apart.
15
+ */
16
+ export async function createAddressConventionTable(db) {
17
+ await db.schema
18
+ .createTable(ADDRESS_CONVENTION_TABLE)
19
+ .addColumn("wof_id", "integer", (column) => column.primaryKey())
20
+ .addColumn("convention", "text", (column) => column.notNull())
21
+ .addColumn("source", "text", (column) => column.notNull())
22
+ .execute();
23
+ }
24
+ /**
25
+ * Create the artifact's `meta` table.
26
+ */
27
+ export async function createConventionMetaTable(db) {
28
+ await db.schema
29
+ .createTable("meta")
30
+ .addColumn("key", "text", (column) => column.primaryKey())
31
+ .addColumn("value", "text")
32
+ .execute();
33
+ }
34
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../lib/convention/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAoC5D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EAA0B;IAC5E,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,wBAAwB,CAAC;SACrC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SAC/D,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SAC7D,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SACzD,OAAO,EAAE,CAAA;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAA0B;IACzE,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,MAAM,CAAC;SACnB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SACzD,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;SAC1B,OAAO,EAAE,CAAA;AACZ,CAAC"}
@@ -8,9 +8,9 @@
8
8
  * updated at gazetteer REBUILD, not by a hand-edited code PR after someone remembers:
9
9
  *
10
10
  * - `country_coverage`: the hard-country-filter coverage record (#743/#194) — per-country
11
- * promote-gate verdicts + the measured hard-resolve rates that used to live in a code comment on
11
+ * promotion-eval verdicts + the measured hard-resolve rates that used to live in a code comment on
12
12
  * `HARD_PLACE_COUNTRY_SAFELIST`. Presence = measured; `hard_filter_safe = 0` = measured and
13
- * FAILED the gate (FI 69.5%, PL 77.8%) — distinguishable from a country never measured at all
13
+ * FAILED the check (FI 69.5%, PL 77.8%) — distinguishable from a country never measured at all
14
14
  * (the meaning-of-zero rule, `docs/engineering/reference/layer-contract.mdx`).
15
15
  * - `country_bbox`: the coarse guard-B plausibility boxes that used to live in
16
16
  * `resolver/plausibility.ts`'s `COUNTRY_BBOX`. An absent row fails open (never trips the guard),
@@ -22,8 +22,8 @@
22
22
  * calls {@link readGazetteerCoverageManifest} in its constructor); an artifact that predates the
23
23
  * manifest returns `undefined` and every consumer falls back to the code constants byte-identically.
24
24
  */
25
- import type { DatabaseSync } from "node:sqlite";
26
25
  import { type CountryBBoxFact, type CountryCoverageFact, type GazetteerArtifactCoverage } from "@mailwoman/core/resolver";
26
+ import type { DatabaseClient } from "@mailwoman/sqlite/client";
27
27
  import { type Kysely } from "kysely";
28
28
  /**
29
29
  * One country's hard-filter coverage measurement — the storage form of {@link CountryCoverageFact}.
@@ -34,7 +34,7 @@ export interface CountryCoverageTable {
34
34
  */
35
35
  country: string;
36
36
  /**
37
- * 0/1 — the promote-gate verdict (a verdict column, NOT re-derived from the rate; see the fact type's docstring).
37
+ * 0/1 — the promotion-eval verdict (a verdict column, NOT re-derived from the rate; see the fact type's docstring).
38
38
  */
39
39
  hard_filter_safe: number;
40
40
  /**
@@ -46,11 +46,11 @@ export interface CountryCoverageTable {
46
46
  */
47
47
  sample_size: number | null;
48
48
  /**
49
- * ISO-8601 date of the measurement / promote gate.
49
+ * ISO-8601 date of the measurement / promote eval.
50
50
  */
51
51
  measured_at: string;
52
52
  /**
53
- * The receipt: which panel/gate produced this row.
53
+ * The receipt: which panel/check produced this row.
54
54
  */
55
55
  source: string;
56
56
  }
@@ -79,7 +79,7 @@ export interface GazetteerCoverageDatabase {
79
79
  country_bbox: CountryBBoxTable;
80
80
  }
81
81
  /**
82
- * Table names the lookup probes (existence-gated, so a candidate.db built before the manifest is byte-stable).
82
+ * Table names the lookup probes (existence-restricted, so a candidate.db built before the manifest is byte-stable).
83
83
  */
84
84
  export declare const COUNTRY_COVERAGE_TABLE = "country_coverage";
85
85
  /**
@@ -108,5 +108,5 @@ export declare function writeGazetteerCoverageManifest(db: Kysely<GazetteerCover
108
108
  * purpose: this runs inside {@link WOFCandidateTableLookup}'s synchronous constructor (the sync-reader carve-out in
109
109
  * `AGENTS.md`), and the tables are a few dozen rows read once per open.
110
110
  */
111
- export declare function readGazetteerCoverageManifest(db: DatabaseSync): GazetteerArtifactCoverage | undefined;
111
+ export declare function readGazetteerCoverageManifest<DB>(db: DatabaseClient<DB>): GazetteerArtifactCoverage | undefined;
112
112
  //# sourceMappingURL=coverage-manifest-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coverage-manifest-schema.d.ts","sourceRoot":"","sources":["../coverage-manifest-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIzC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,gBAAgB,EAAE,oBAAoB,CAAA;IACtC,YAAY,EAAE,gBAAgB,CAAA;CAC9B;AAED;;GAEG;AACH,eAA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;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,gBAAgB,EAAE,oBAAoB,CAAA;IACtC,YAAY,EAAE,gBAAgB,CAAA;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,qBAAqB,CAAA;AACxD;;GAEG;AACH,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAEhD;;GAEG;AACH,wBAAsB,0BAA0B,CAAC,EAAE,EAAE,MAAM,CAAC,yBAAyB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAarG;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM,CAAC,yBAAyB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjG;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CACnD,EAAE,EAAE,MAAM,CAAC,yBAAyB,CAAC,EACrC,KAAK,EAAE;IAAE,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,GACrF,OAAO,CAAC,IAAI,CAAC,CAmCf;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,yBAAyB,GAAG,SAAS,CAuD/G"}
@@ -8,9 +8,9 @@
8
8
  * updated at gazetteer REBUILD, not by a hand-edited code PR after someone remembers:
9
9
  *
10
10
  * - `country_coverage`: the hard-country-filter coverage record (#743/#194) — per-country
11
- * promote-gate verdicts + the measured hard-resolve rates that used to live in a code comment on
11
+ * promotion-eval verdicts + the measured hard-resolve rates that used to live in a code comment on
12
12
  * `HARD_PLACE_COUNTRY_SAFELIST`. Presence = measured; `hard_filter_safe = 0` = measured and
13
- * FAILED the gate (FI 69.5%, PL 77.8%) — distinguishable from a country never measured at all
13
+ * FAILED the check (FI 69.5%, PL 77.8%) — distinguishable from a country never measured at all
14
14
  * (the meaning-of-zero rule, `docs/engineering/reference/layer-contract.mdx`).
15
15
  * - `country_bbox`: the coarse guard-B plausibility boxes that used to live in
16
16
  * `resolver/plausibility.ts`'s `COUNTRY_BBOX`. An absent row fails open (never trips the guard),
@@ -24,9 +24,9 @@
24
24
  */
25
25
  import { hardCountrySafelistFromCoverage, } from "@mailwoman/core/resolver";
26
26
  import { sql } from "kysely";
27
- import { hasTable } from "./sqlite-utils.js";
27
+ import { allRows, hasTable } from "#sqlite-utils";
28
28
  /**
29
- * Table names the lookup probes (existence-gated, so a candidate.db built before the manifest is byte-stable).
29
+ * Table names the lookup probes (existence-restricted, so a candidate.db built before the manifest is byte-stable).
30
30
  */
31
31
  export const COUNTRY_COVERAGE_TABLE = "country_coverage";
32
32
  /**
@@ -113,9 +113,7 @@ export function readGazetteerCoverageManifest(db) {
113
113
  return undefined;
114
114
  const countryCoverage = new Map();
115
115
  if (hasCoverage) {
116
- const rows = db
117
- .prepare(`SELECT country, hard_filter_safe, hard_resolve_rate, sample_size, measured_at, source FROM ${COUNTRY_COVERAGE_TABLE}`)
118
- .all();
116
+ const rows = allRows(db.prepare(`SELECT country, hard_filter_safe, hard_resolve_rate, sample_size, measured_at, source FROM ${COUNTRY_COVERAGE_TABLE}`));
119
117
  for (const row of rows) {
120
118
  const country = String(row.country).toUpperCase();
121
119
  countryCoverage.set(country, {
@@ -130,9 +128,7 @@ export function readGazetteerCoverageManifest(db) {
130
128
  }
131
129
  const countryBBoxes = new Map();
132
130
  if (hasBBox) {
133
- const rows = db
134
- .prepare(`SELECT country, lat_min, lat_max, lon_min, lon_max, source FROM ${COUNTRY_BBOX_TABLE}`)
135
- .all();
131
+ const rows = allRows(db.prepare(`SELECT country, lat_min, lat_max, lon_min, lon_max, source FROM ${COUNTRY_BBOX_TABLE}`));
136
132
  for (const row of rows) {
137
133
  const country = String(row.country).toUpperCase();
138
134
  countryBBoxes.set(country, {