@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
package/out/types.d.ts CHANGED
@@ -23,7 +23,7 @@ export type WOFPlacetype = "country" | "macroregion" | "region" | "macrocounty"
23
23
  * treat it as ordinal, not absolute.
24
24
  *
25
25
  * `id` is the WOF place id. It's named generically (not `wof_id`) so the shape stays structurally compatible with
26
- * `@mailwoman/resolver`'s `ResolvedPlace` — `WOFSqlitePlaceLookup` satisfies the generic `ResolverBackend` contract
26
+ * `@mailwoman/resolver`'s `ResolvedPlace` — `WOFSQLitePlaceLookup` satisfies the generic `ResolverBackend` contract
27
27
  * without an adapter shim.
28
28
  *
29
29
  * `distanceKm` is populated only when the query carried `near` (and the place has a centroid). Useful for downstream
@@ -75,8 +75,8 @@ export interface PlaceCandidate {
75
75
  /**
76
76
  * STRICT encyclopedia-evidence importance in [0, 1], fan-out-guarded per #1497 — CARRIED, NEVER RANKED ON.
77
77
  *
78
- * RESERVED SLOT awaiting a strict-channel source: present only when a shard's `place_importance` table carries the
79
- * split columns, and no shipped shard does — the FTS lookup's clauses emit NULL for everything today. `undefined`
78
+ * RESERVED SLOT awaiting a strict-channel source: present only when a extract's `place_importance` table carries the
79
+ * split columns, and no shipped extract does — the FTS lookup's clauses emit NULL for everything today. `undefined`
80
80
  * means either "no encyclopedia entry for this place" or "this gazetteer predates the split"; both are absence, and
81
81
  * neither is 0. The BLENDED prior the ranking reads is {@link PlaceCandidate.importance}.
82
82
  *
@@ -106,6 +106,21 @@ export interface PlaceCandidate {
106
106
  * the falsehood-detection differentiator.
107
107
  */
108
108
  mismatch?: boolean;
109
+ /**
110
+ * Admin-containment stamp (#1717 stage 2) — TRI-STATE, mirroring `ResolvedPlace.containedByQualifier` in
111
+ * `@mailwoman/core`: `true` = the ancestors sidecar vouches this candidate sits under the query's
112
+ * {@link FindPlaceQuery.regionQualifier}; `false` = evaluated and not vouched for; absent = never evaluated (no
113
+ * qualifier on the query, or an artifact without the sidecar). Absence is required — the resolver walk reads it as
114
+ * `unavailable`, never as "not contained".
115
+ */
116
+ containedByQualifier?: boolean;
117
+ /**
118
+ * The #1882 exemption's firing mark (#1893), mirroring `ResolvedPlace.variantAliasExempted` in `@mailwoman/core`:
119
+ * present only when this candidate's row would have taken the cross-country alias penalty and the exemption prevented
120
+ * it. Emitted by the candidate-table backend alone — the WASM FTS lookup never runs the ranker, and its candidates
121
+ * omit the field (not evaluated, never "did not fire").
122
+ */
123
+ variantAliasExempted?: true;
109
124
  }
110
125
  /**
111
126
  * A WGS-84 lat/lon point. Used as a proximity hint for `FindPlaceQuery.near`.
@@ -144,6 +159,24 @@ export interface FindPlaceQuery {
144
159
  * ISO 3166-1 alpha-2 — narrows to one country.
145
160
  */
146
161
  country?: string;
162
+ /**
163
+ * ISO 3166-1 alpha-2 — narrows the TYPO-FUZZY tier only (#1585). Exact and qualifier-strip probes stay worldwide (a
164
+ * locale hint is a prior, never a hard filter on exact matches), but a typo CORRECTION into a different country's
165
+ * namespace is nearly always a scrape, so the corrected-key probes honor this scope and a scoped-empty ABSTAINS
166
+ * rather than falling through to a world-fuzzy candidate. Ignored when `country` is set (already narrower).
167
+ */
168
+ fuzzyCountry?: string;
169
+ /**
170
+ * Restrict name matching to PRIMARY-keyed rows (#1632) — set by probes whose surface is a RE-READING (a token taken
171
+ * out of a longer classified span), which never named an alias. See the ResolverBackend contract in
172
+ * `@mailwoman/core/resolver`.
173
+ */
174
+ primaryOnly?: boolean;
175
+ /**
176
+ * Alias-row NAME ROLES the probe refuses to answer through (#1730) — the bare-toponym side races pass `abbr`/`gloss`.
177
+ * Role-NULL alias rows (the exonym tier) stay open; backends/artifacts without a role column ignore it.
178
+ */
179
+ excludeNameRoles?: readonly string[];
147
180
  /**
148
181
  * WOF place id — narrows to descendants of this place.
149
182
  */
@@ -152,16 +185,24 @@ export interface FindPlaceQuery {
152
185
  * Sibling postcode. When set on a `locality` query AND a `postcode_locality` table is present, triggers the
153
186
  * coordinate-first soft-score path: postcode→candidate localities are injected and scored `0.6·S_pc + 0.3·S_name +
154
187
  * 0.1·S_pop` against the FTS name-match set, recovering small localities the name-match alone misses. Ignored when no
155
- * postcode_locality shard is present.
188
+ * postcode_locality extract is present.
156
189
  */
157
190
  postcode?: string;
158
191
  /**
159
192
  * Postcode-containment coherence (#31, Mechanism 2) — when true on a locality query that also carries `postcode`,
160
- * candidate rows within `POSTCODE_CONTAINMENT_GATE_KM` of the postcode's own centroid sort by distance first, the
161
- * rest appended in their original order. Set by the resolver from `ResolveOpts.postcodeContainmentCoherence`; absent
162
- * → the population-first order is untouched (byte-identical).
193
+ * candidate rows within `POSTCODE_CONTAINMENT_THRESHOLD_KM` of the postcode's own centroid sort by distance first,
194
+ * the rest appended in their original order. Set by the resolver from `ResolveOpts.postcodeContainmentCoherence`;
195
+ * absent → the population-first order is untouched (byte-identical).
163
196
  */
164
197
  postcodeContainmentCoherence?: boolean;
198
+ /**
199
+ * The tree's parsed REGION qualifier (#1717 stage 2) — set by the resolver on locality lookups when
200
+ * `ResolveOpts.adminContainmentRerank` is on. See the `ResolverBackend` contract in `@mailwoman/core/resolver`: a
201
+ * capable backend stamps `containedByQualifier`, ranks contained candidates first, and may ADD contained same-key
202
+ * candidates a country scope hid — additive only, never a filter. Ignored on an artifact without the ancestors
203
+ * sidecar (candidates then carry no stamp).
204
+ */
205
+ regionQualifier?: string;
165
206
  /**
166
207
  * Proximity hint — candidates close to this point get a ranking boost.
167
208
  */
@@ -193,8 +234,7 @@ export interface FindPlaceQuery {
193
234
  * interface is async even though `node:sqlite` is sync — leaves room for `Worker`-backed implementations later without
194
235
  * a public API break.
195
236
  */
196
- export interface PlaceLookup {
237
+ export interface PlaceLookup extends Disposable {
197
238
  findPlace(query: FindPlaceQuery): Promise<PlaceCandidate[]>;
198
- close(): void;
199
239
  }
200
240
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACrB,SAAS,GACT,aAAa,GACb,QAAQ,GACR,aAAa,GACb,QAAQ,GACR,YAAY,GACZ,UAAU,GACV,SAAS,GACT,eAAe,GACf,WAAW,G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AC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAA;IACtC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC5C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC9C,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;CAC3D"}
package/out/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -7,12 +7,13 @@
7
7
  * (`scripts/build-unified-wof.ts`). This is the CANONICAL gazetteer — we never use the
8
8
  * off-the-shelf geocode.earth prebuilt dumps (they assign different WOF ids to the same place;
9
9
  * see the `feedback-custom-wof-db-only` memory). The table/column names match the resolver's
10
- * expectations (`lookup.ts`) so `WOFSqlitePlaceLookup` works unchanged, INCLUDING the `ancestors`
10
+ * expectations (`lookup.ts`) so `WOFSQLitePlaceLookup` works unchanged, INCLUDING the `ancestors`
11
11
  * table (which lookup.ts's parent-constraint subquery needs) — see `populateAncestors`. The
12
12
  * `place_search` FTS5 + `place_bbox` R*Tree are built separately by `build-fts` (fts.ts).
13
13
  */
14
- import type { DatabaseSync } from "node:sqlite";
15
- export declare function createUnifiedSchema(db: DatabaseSync): Promise<void>;
14
+ import type { DatabaseClient } from "@mailwoman/sqlite/client";
15
+ import type { WOFDatabase } from "#schema";
16
+ export declare function createUnifiedSchema(db: DatabaseClient<WOFDatabase>): Promise<void>;
16
17
  /**
17
18
  * Populate the `ancestors` table by walking each place's `parent_id` chain in `spr` (transitive closure, including the
18
19
  * place itself). Idempotent: drops + rebuilds the table contents. Returns the row count. Run after `spr` is fully
@@ -20,6 +21,6 @@ export declare function createUnifiedSchema(db: DatabaseSync): Promise<void>;
20
21
  * Sentinel/negative parent_ids and cycles terminate the walk. ~4 rows/place average; a transaction keeps the ~5M
21
22
  * inserts fast.
22
23
  */
23
- export declare function populateAncestors(db: DatabaseSync): number;
24
- export declare function createUnifiedIndexes(db: DatabaseSync): Promise<void>;
24
+ export declare function populateAncestors<DB>(db: DatabaseClient<DB>): number;
25
+ export declare function createUnifiedIndexes(db: DatabaseClient<WOFDatabase>): Promise<void>;
25
26
  //# sourceMappingURL=unified-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unified-schema.d.ts","sourceRoot":"","sources":["../unified-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM/C,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgFzE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,GAAG,MAAM,CA0C1D;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B1E"}
1
+ {"version":3,"file":"unified-schema.d.ts","sourceRoot":"","sources":["../lib/unified-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA+ExF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,MAAM,CA0CpE;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBzF"}
@@ -7,20 +7,18 @@
7
7
  * (`scripts/build-unified-wof.ts`). This is the CANONICAL gazetteer — we never use the
8
8
  * off-the-shelf geocode.earth prebuilt dumps (they assign different WOF ids to the same place;
9
9
  * see the `feedback-custom-wof-db-only` memory). The table/column names match the resolver's
10
- * expectations (`lookup.ts`) so `WOFSqlitePlaceLookup` works unchanged, INCLUDING the `ancestors`
10
+ * expectations (`lookup.ts`) so `WOFSQLitePlaceLookup` works unchanged, INCLUDING the `ancestors`
11
11
  * table (which lookup.ts's parent-constraint subquery needs) — see `populateAncestors`. The
12
12
  * `place_search` FTS5 + `place_bbox` R*Tree are built separately by `build-fts` (fts.ts).
13
13
  */
14
- import { DatabaseClient } from "@mailwoman/core/kysley/client";
15
14
  export async function createUnifiedSchema(db) {
16
15
  // PRAGMAs stay raw — not Kysely-modelled, and these tune the bulk build.
17
16
  db.exec("PRAGMA journal_mode = WAL");
18
17
  db.exec("PRAGMA busy_timeout = 10000");
19
18
  db.exec("PRAGMA synchronous = OFF");
20
- // `kdb` wraps `db` for the DDL (the house idiom); the caller owns `db`'s lifecycle, so we don't
19
+ // `db` wraps `db` for the DDL (the house idiom); the caller owns `db`'s lifecycle, so we don't
21
20
  // destroy it here. The bulk INSERTs (populateAncestors + build-unified-wof) stay on the raw handle.
22
- const kdb = new DatabaseClient({ database: db });
23
- await kdb.schema
21
+ await db.schema
24
22
  .createTable("spr")
25
23
  .ifNotExists()
26
24
  .addColumn("id", "integer", (c) => c.primaryKey())
@@ -47,7 +45,7 @@ export async function createUnifiedSchema(db) {
47
45
  // x_variant rows tagged with an official language ("MSP", "Frisco") stay 0. Primary-name mirror
48
46
  // rows stay 0 too: the name-exact tier already consults spr.name; `official` only marks the
49
47
  // ALIASES eligible to join it. Both are ingest-time facts, never computed at query time.
50
- await kdb.schema
48
+ await db.schema
51
49
  .createTable("names")
52
50
  .ifNotExists()
53
51
  .addColumn("id", "integer", (c) => c.notNull())
@@ -59,7 +57,7 @@ export async function createUnifiedSchema(db) {
59
57
  .addColumn("official", "integer", (c) => c.notNull().defaultTo(0))
60
58
  .addColumn("lastmodified", "integer", (c) => c.notNull().defaultTo(0))
61
59
  .execute();
62
- await kdb.schema
60
+ await db.schema
63
61
  .createTable("concordances")
64
62
  .ifNotExists()
65
63
  .addColumn("id", "integer", (c) => c.notNull())
@@ -67,7 +65,7 @@ export async function createUnifiedSchema(db) {
67
65
  .addColumn("other_source", "text", (c) => c.notNull())
68
66
  .addColumn("lastmodified", "integer", (c) => c.notNull().defaultTo(0))
69
67
  .execute();
70
- await kdb.schema
68
+ await db.schema
71
69
  .createTable("place_population")
72
70
  .ifNotExists()
73
71
  .addColumn("id", "integer", (c) => c.primaryKey())
@@ -78,7 +76,7 @@ export async function createUnifiedSchema(db) {
78
76
  // `spr.id IN (SELECT id FROM ancestors WHERE ancestor_id = ?)`. The off-the-shelf WOF dumps
79
77
  // ship this table; our build derives it from the parent_id chain (see populateAncestors) since
80
78
  // we don't capture `wof:hierarchy`.
81
- await kdb.schema
79
+ await db.schema
82
80
  .createTable("ancestors")
83
81
  .ifNotExists()
84
82
  .addColumn("id", "integer", (c) => c.notNull())
@@ -124,19 +122,18 @@ export function populateAncestors(db) {
124
122
  return count;
125
123
  }
126
124
  export async function createUnifiedIndexes(db) {
127
- const kdb = new DatabaseClient({ database: db });
128
- await kdb.schema.createIndex("spr_by_placetype").ifNotExists().on("spr").column("placetype").execute();
129
- await kdb.schema.createIndex("spr_by_country").ifNotExists().on("spr").column("country").execute();
130
- await kdb.schema.createIndex("spr_by_parent").ifNotExists().on("spr").column("parent_id").execute();
131
- await kdb.schema.createIndex("names_by_id").ifNotExists().on("names").column("id").execute();
132
- await kdb.schema.createIndex("names_by_name").ifNotExists().on("names").column("name").execute();
133
- await kdb.schema
125
+ await db.schema.createIndex("spr_by_placetype").ifNotExists().on("spr").column("placetype").execute();
126
+ await db.schema.createIndex("spr_by_country").ifNotExists().on("spr").column("country").execute();
127
+ await db.schema.createIndex("spr_by_parent").ifNotExists().on("spr").column("parent_id").execute();
128
+ await db.schema.createIndex("names_by_id").ifNotExists().on("names").column("id").execute();
129
+ await db.schema.createIndex("names_by_name").ifNotExists().on("names").column("name").execute();
130
+ await db.schema
134
131
  .createIndex("concordances_by_id")
135
132
  .ifNotExists()
136
133
  .on("concordances")
137
134
  .columns(["id", "lastmodified"])
138
135
  .execute();
139
- await kdb.schema
136
+ await db.schema
140
137
  .createIndex("concordances_by_other_id")
141
138
  .ifNotExists()
142
139
  .on("concordances")
@@ -144,7 +141,7 @@ export async function createUnifiedIndexes(db) {
144
141
  .execute();
145
142
  // ancestor_id is the hot column (parent-constraint queries `WHERE ancestor_id = ?`); id supports
146
143
  // the reverse lookup.
147
- await kdb.schema.createIndex("ancestors_by_ancestor").ifNotExists().on("ancestors").column("ancestor_id").execute();
148
- await kdb.schema.createIndex("ancestors_by_id").ifNotExists().on("ancestors").column("id").execute();
144
+ await db.schema.createIndex("ancestors_by_ancestor").ifNotExists().on("ancestors").column("ancestor_id").execute();
145
+ await db.schema.createIndex("ancestors_by_id").ifNotExists().on("ancestors").column("id").execute();
149
146
  }
150
147
  //# sourceMappingURL=unified-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unified-schema.js","sourceRoot":"","sources":["../unified-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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M,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;IAC3F,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;IAE/F,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,oBAAoB,CAAC;SACjC,WAAW,EAAE;SACb,EAAE,CAAC,cAAc,CAAC;SAClB,OAAO,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;SAC/B,OAAO,EAAE,CAAA;IAEX,MAAM,EAAE,CAAC,MAAM;SACb,WAAW,CAAC,0BAA0B,CAAC;SACvC,WAAW,EAAE;SACb,EAAE,CAAC,cAAc,CAAC;SAClB,OAAO,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;SACrC,OAAO,EAAE,CAAA;IAEX,iGAAiG;IACjG,sBAAsB;IACtB,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAA;IAClH,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;AACpG,CAAC"}
@@ -0,0 +1,53 @@
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
+ import { type LayerContractHandle } from "@mailwoman/core/layers";
15
+ import { type Exclusion } from "@mailwoman/evidence";
16
+ import type { UPRNLookup } from "#uprn/lookup";
17
+ /**
18
+ * The identity fold, on purpose: this probe keys on a COORDINATE, not a name, so there is no string folding for the
19
+ * builder and the probe to disagree about. Passing the same identity as both `probeFold` and `layerFold` records that
20
+ * the fold axis is not in play here, rather than silently omitting the check. It is not a stub.
21
+ */
22
+ export declare const UPRN_EXISTENCE_FOLD: string;
23
+ /**
24
+ * The countries OS Open UPRN covers. Northern Ireland is outside the product, so a `null` there is unknown and must
25
+ * never become evidence of absence; the country check is what keeps it out.
26
+ */
27
+ export declare const UPRN_COVERED_COUNTRIES: ReadonlySet<string>;
28
+ export interface UPRNAbsenceInput {
29
+ lookup: UPRNLookup;
30
+ /**
31
+ * The same file the lookup reads; the layer contract tables live beside the points.
32
+ */
33
+ contractDB: LayerContractHandle;
34
+ latitude: number;
35
+ longitude: number;
36
+ radiusM: number;
37
+ /**
38
+ * ISO-2 country of the thing whose absence is being asserted, when known.
39
+ */
40
+ country?: string;
41
+ }
42
+ /**
43
+ * The coverage cell a coordinate falls in, derived from its stored res-9 cell exactly as the builder derives it — never
44
+ * from the centroid, which lands in a different parent for a fraction of cells.
45
+ */
46
+ export declare function uprnCoverageCell(latitude: number, longitude: number): number;
47
+ /**
48
+ * An {@link Exclusion} when no UPRN lies within `radiusM` AND the layer's coverage licenses saying so; `null` on a hit
49
+ * (presence is not this probe's business) and on every refusal (unsurveyed cell, `source_present` basis, a country the
50
+ * product does not cover). Never throws on a refusal: the caller falls open to the ranking it already had.
51
+ */
52
+ export declare function uprnAbsenceAt(input: UPRNAbsenceInput): Promise<Exclusion | null>;
53
+ //# sourceMappingURL=existence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"existence.d.ts","sourceRoot":"","sources":["../../lib/uprn/existence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAwC,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACvG,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAG9C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAyB,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAAmB,CAAA;AAE1E,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,UAAU,CAAA;IAClB;;OAEG;IACH,UAAU,EAAE,mBAAmB,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAqBtF"}
@@ -0,0 +1,61 @@
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
+ import { readLayerCoverage, readLayerManifest } from "@mailwoman/core/layers";
15
+ import { foldIdentity, requireExclusionBasis } from "@mailwoman/evidence";
16
+ import { shortCellToParentInt } from "@mailwoman/spatial";
17
+ import { UPRN_COVERAGE_H3_RESOLUTION, UPRN_H3_RESOLUTION, uprnH3Cell } from "#uprn/schema";
18
+ /**
19
+ * The identity fold, on purpose: this probe keys on a COORDINATE, not a name, so there is no string folding for the
20
+ * builder and the probe to disagree about. Passing the same identity as both `probeFold` and `layerFold` records that
21
+ * the fold axis is not in play here, rather than silently omitting the check. It is not a stub.
22
+ */
23
+ export const UPRN_EXISTENCE_FOLD = foldIdentity((s) => s);
24
+ /**
25
+ * The countries OS Open UPRN covers. Northern Ireland is outside the product, so a `null` there is unknown and must
26
+ * never become evidence of absence; the country check is what keeps it out.
27
+ */
28
+ export const UPRN_COVERED_COUNTRIES = new Set(["GB"]);
29
+ /**
30
+ * The coverage cell a coordinate falls in, derived from its stored res-9 cell exactly as the builder derives it — never
31
+ * from the centroid, which lands in a different parent for a fraction of cells.
32
+ */
33
+ export function uprnCoverageCell(latitude, longitude) {
34
+ return shortCellToParentInt(uprnH3Cell(latitude, longitude), UPRN_H3_RESOLUTION, UPRN_COVERAGE_H3_RESOLUTION);
35
+ }
36
+ /**
37
+ * An {@link Exclusion} when no UPRN lies within `radiusM` AND the layer's coverage licenses saying so; `null` on a hit
38
+ * (presence is not this probe's business) and on every refusal (unsurveyed cell, `source_present` basis, a country the
39
+ * product does not cover). Never throws on a refusal: the caller falls open to the ranking it already had.
40
+ */
41
+ export async function uprnAbsenceAt(input) {
42
+ const coverageCell = uprnCoverageCell(input.latitude, input.longitude);
43
+ const coverage = await readLayerCoverage(input.contractDB, coverageCell);
44
+ if (!coverage)
45
+ return null;
46
+ if (input.lookup.nearestUPRN(input.latitude, input.longitude, input.radiusM))
47
+ return null;
48
+ const manifest = await readLayerManifest(input.contractDB);
49
+ return requireExclusionBasis({
50
+ layer: manifest.name,
51
+ source: manifest.source,
52
+ vintage: manifest.sourceVintage,
53
+ h3Cell: coverageCell,
54
+ cell: coverage,
55
+ probeFold: UPRN_EXISTENCE_FOLD,
56
+ layerFold: UPRN_EXISTENCE_FOLD,
57
+ country: input.country,
58
+ countries: UPRN_COVERED_COUNTRIES,
59
+ });
60
+ }
61
+ //# sourceMappingURL=existence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"existence.js","sourceRoot":"","sources":["../../lib/uprn/existence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAA4B,MAAM,wBAAwB,CAAA;AACvG,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAkB,MAAM,qBAAqB,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE1F;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAiB1E;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,SAAiB;IACnE,OAAO,oBAAoB,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,kBAAkB,EAAE,2BAA2B,CAAC,CAAA;AAC9G,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAuB;IAC1D,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;IACtE,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;IAExE,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,IAAI,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAEzF,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAE1D,OAAO,qBAAqB,CAAC;QAC5B,KAAK,EAAE,QAAQ,CAAC,IAAI;QACpB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO,EAAE,QAAQ,CAAC,aAAa;QAC/B,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,mBAAmB;QAC9B,SAAS,EAAE,mBAAmB;QAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,SAAS,EAAE,sBAAsB;KACjC,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#uprn/existence";
7
+ export * from "#uprn/lookup";
8
+ export * from "#uprn/schema";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/uprn/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#uprn/existence";
7
+ export * from "#uprn/lookup";
8
+ export * from "#uprn/schema";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/uprn/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Node reader for `uprn.db` — the OS Open UPRN layer (`uprn-schema.ts`). Two probes:
7
+ *
8
+ * - **`coordinateOf(uprn)`**: rowid B-tree hit on the `uprn` integer PK.
9
+ * - **`nearestUPRN(lat, lon, radiusM)`**: bounded nearest-point search over the res-9 `h3_cell`
10
+ * index — ring-by-ring `gridDisk` expansion with chunked `IN` probes and haversine ranking.
11
+ * Rings stop as soon as geometry proves no unprobed cell could beat the best hit — a distance
12
+ * bound, not POILookup's row-count accumulation, so the early exit can never strand a nearer
13
+ * point in an unprobed ring.
14
+ *
15
+ * ## `null` is a claim, scoped by coverage
16
+ *
17
+ * OS designates Open UPRN complete for GB (every UPRN in AddressBase Premium with geometry), and
18
+ * the builder writes `layer_coverage` with basis `designated` for every cell the product touches.
19
+ * So a `null` from either probe inside a covered cell is evidence of absence — "no such published
20
+ * GB UPRN" / "no UPRN within the radius". Outside coverage (Northern Ireland, the Isle of Man, the
21
+ * Channel Islands, open water) it is UNKNOWN, per the meaning-of-zero rule — callers building
22
+ * negative evidence must consult `readLayerCoverage`, not this reader alone.
23
+ *
24
+ * `latLngToCell`/`gridDisk` come from `h3-js`; the 48-bit short-cell packing is
25
+ * `@mailwoman/spatial`'s `shortCellToInt` via `uprnFullCell` — never reimplemented here.
26
+ */
27
+ import { DatabaseClient } from "@mailwoman/sqlite/client";
28
+ import type { UPRNDatabase } from "#uprn/schema";
29
+ /**
30
+ * Hard ceiling on `radiusM`. Keeps the probe bounded (10 km → ~72 rings ≈ 15.8k cells ≈ 18 `IN` chunks); a caller who
31
+ * wants a wider search than "which property is this coordinate" has outgrown this reader and should say so loudly.
32
+ */
33
+ export declare const UPRN_MAX_NEAREST_RADIUS_M = 10000;
34
+ export interface UPRNCoordinate {
35
+ latitude: number;
36
+ longitude: number;
37
+ }
38
+ export interface UPRNNearestHit {
39
+ uprn: number;
40
+ latitude: number;
41
+ longitude: number;
42
+ /**
43
+ * Haversine distance from the query point, metres.
44
+ */
45
+ distanceM: number;
46
+ }
47
+ export interface UPRNLookupOpts {
48
+ /**
49
+ * Path to a `uprn.db` built by `mailwoman`'s gazetteer pipeline. Opened read-only.
50
+ */
51
+ databasePath?: string;
52
+ /**
53
+ * Pre-opened handle (tests / shared connections). Mutually exclusive with `databasePath`.
54
+ */
55
+ database?: DatabaseClient<UPRNDatabase>;
56
+ }
57
+ /**
58
+ * Node reader over `uprn.db`. `implements Disposable` so callers can `using lookup = new UPRNLookup(...)` — the same
59
+ * precedent as {@link POILookup}.
60
+ */
61
+ export declare class UPRNLookup implements Disposable {
62
+ #private;
63
+ constructor(opts: UPRNLookupOpts);
64
+ /**
65
+ * The WGS84 point OS publishes for `uprn`, or `null` when the layer holds no such UPRN (see the module docstring for
66
+ * what that `null` claims).
67
+ */
68
+ coordinateOf(uprn: number): UPRNCoordinate | null;
69
+ /**
70
+ * The single nearest UPRN within `radiusM` metres of the query point, or `null` when no UPRN lies inside the radius.
71
+ *
72
+ * Bounded two ways: `radiusM` is capped at {@link UPRN_MAX_NEAREST_RADIUS_M}, and rings expand outward only until no
73
+ * unprobed cell could beat the best hit found so far (or the radius, when nothing has been found). The stop rule is
74
+ * geometric — a cell at grid distance `g` holds no point nearer than `g` × spacing floor − cell radius, using the
75
+ * same conservative constants the reach math uses — so unlike POILookup's row-count accumulation there is no
76
+ * early-exit ambiguity: a break can never strand a nearer point in an unprobed ring. This is what keeps a
77
+ * capped-radius call over dense ground at milliseconds instead of a full-disk fetch (measured 6.4 s → 13 ms for a 10
78
+ * km radius over central London, 41.6M-row layer; an empty-sea miss at the cap runs the full expansion, 74 ms).
79
+ *
80
+ * @throws {RangeError} When `radiusM` is not a positive finite number, or exceeds the cap.
81
+ */
82
+ nearestUPRN(latitude: number, longitude: number, radiusM: number): UPRNNearestHit | null;
83
+ [Symbol.dispose](): void;
84
+ }
85
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../lib/uprn/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAIzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAkBhD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,QAAS,CAAA;AAO/C,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;CACvC;AAQD;;;GAGG;AACH,qBAAa,UAAW,YAAW,UAAU;;gBAahC,IAAI,EAAE,cAAc;IAYhC;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAMjD;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAyDxF,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGxB"}