@mailwoman/core 8.0.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (409) hide show
  1. package/api/APIClient.ts +3 -4
  2. package/api/responses.ts +6 -3
  3. package/coarse-placer/coarse-placer.ts +26 -11
  4. package/coarse-placer/featurize.ts +25 -16
  5. package/coarse-placer/tools/build-dataset.ts +42 -18
  6. package/coarse-placer/tools/build-outlier-exposure.ts +51 -18
  7. package/coarse-placer/tools/build-outlier-latin.ts +48 -22
  8. package/coarse-placer/tools/build-outlier-oa.ts +52 -20
  9. package/coarse-placer/tools/eval-latin-offmap.ts +37 -12
  10. package/coarse-placer/tools/eval-openset.ts +104 -37
  11. package/coarse-placer/tools/eval-quant-compare.ts +41 -11
  12. package/coarse-placer/tools/eval.ts +51 -13
  13. package/coarse-placer/tools/fnv-hash.ts +5 -3
  14. package/coarse-placer/tools/probe-frontier.ts +63 -32
  15. package/coarse-placer/tools/quantize.ts +30 -8
  16. package/coarse-placer/tools/train.ts +63 -17
  17. package/collections.ts +2 -2
  18. package/decoder/build-tree.ts +16 -3
  19. package/decoder/calibration.ts +23 -7
  20. package/decoder/containment.ts +3 -1
  21. package/decoder/proposals-to-tree.ts +2 -0
  22. package/decoder/resolve-proposal-overlaps.ts +5 -1
  23. package/decoder/serialize-json.ts +8 -2
  24. package/decoder/serialize-tuples.ts +7 -2
  25. package/decoder/serialize-xml.ts +29 -11
  26. package/decoder/types.ts +34 -12
  27. package/decoder/unknown-spans.ts +14 -5
  28. package/decoder/validate-tree.ts +6 -1
  29. package/env/index.ts +1 -1
  30. package/env/load.ts +1 -1
  31. package/env/paths.ts +1 -1
  32. package/env/schema.ts +12 -4
  33. package/errors/schema.ts +1 -1
  34. package/fs/node.ts +9 -10
  35. package/identifiers.ts +3 -3
  36. package/kysley/adapter.ts +1 -1
  37. package/layers/manifest.ts +22 -8
  38. package/layers/schema.ts +59 -19
  39. package/locale/locale.ts +6 -2
  40. package/locale/profiles/en-us.ts +3 -0
  41. package/locale/profiles/fr-fr.ts +3 -0
  42. package/locale/profiles/ja-jp.ts +3 -0
  43. package/locale/registry.ts +3 -1
  44. package/logging/shared.ts +1 -0
  45. package/logging/utils.ts +1 -1
  46. package/objects.ts +7 -2
  47. package/out/api/APIClient.d.ts +1 -1
  48. package/out/api/APIClient.d.ts.map +1 -1
  49. package/out/api/APIClient.js +3 -2
  50. package/out/api/APIClient.js.map +1 -1
  51. package/out/api/responses.d.ts.map +1 -1
  52. package/out/api/responses.js +3 -3
  53. package/out/api/responses.js.map +1 -1
  54. package/out/coarse-placer/coarse-placer.d.ts +19 -9
  55. package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
  56. package/out/coarse-placer/coarse-placer.js +6 -4
  57. package/out/coarse-placer/coarse-placer.js.map +1 -1
  58. package/out/coarse-placer/featurize.d.ts.map +1 -1
  59. package/out/coarse-placer/featurize.js +20 -16
  60. package/out/coarse-placer/featurize.js.map +1 -1
  61. package/out/coarse-placer/tools/build-dataset.d.ts +15 -5
  62. package/out/coarse-placer/tools/build-dataset.d.ts.map +1 -1
  63. package/out/coarse-placer/tools/build-dataset.js +19 -14
  64. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  65. package/out/coarse-placer/tools/build-outlier-exposure.d.ts +21 -7
  66. package/out/coarse-placer/tools/build-outlier-exposure.d.ts.map +1 -1
  67. package/out/coarse-placer/tools/build-outlier-exposure.js +24 -12
  68. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  69. package/out/coarse-placer/tools/build-outlier-latin.d.ts +18 -6
  70. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  71. package/out/coarse-placer/tools/build-outlier-latin.js +27 -17
  72. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  73. package/out/coarse-placer/tools/build-outlier-oa.d.ts +18 -6
  74. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  75. package/out/coarse-placer/tools/build-outlier-oa.js +29 -15
  76. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  77. package/out/coarse-placer/tools/eval-latin-offmap.d.ts +18 -6
  78. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  79. package/out/coarse-placer/tools/eval-latin-offmap.js +13 -7
  80. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  81. package/out/coarse-placer/tools/eval-openset.d.ts +24 -8
  82. package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
  83. package/out/coarse-placer/tools/eval-openset.js +52 -31
  84. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  85. package/out/coarse-placer/tools/eval-quant-compare.d.ts +30 -10
  86. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
  87. package/out/coarse-placer/tools/eval-quant-compare.js +4 -2
  88. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  89. package/out/coarse-placer/tools/eval.d.ts +24 -8
  90. package/out/coarse-placer/tools/eval.d.ts.map +1 -1
  91. package/out/coarse-placer/tools/eval.js +16 -6
  92. package/out/coarse-placer/tools/eval.js.map +1 -1
  93. package/out/coarse-placer/tools/fnv-hash.d.ts +3 -1
  94. package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
  95. package/out/coarse-placer/tools/fnv-hash.js +5 -3
  96. package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
  97. package/out/coarse-placer/tools/probe-frontier.d.ts +18 -6
  98. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  99. package/out/coarse-placer/tools/probe-frontier.js +39 -23
  100. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  101. package/out/coarse-placer/tools/quantize.d.ts +15 -5
  102. package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
  103. package/out/coarse-placer/tools/quantize.js +11 -4
  104. package/out/coarse-placer/tools/quantize.js.map +1 -1
  105. package/out/coarse-placer/tools/train.d.ts +24 -8
  106. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  107. package/out/coarse-placer/tools/train.js +24 -10
  108. package/out/coarse-placer/tools/train.js.map +1 -1
  109. package/out/collections.js +2 -2
  110. package/out/collections.js.map +1 -1
  111. package/out/decoder/build-tree.d.ts.map +1 -1
  112. package/out/decoder/build-tree.js +9 -3
  113. package/out/decoder/build-tree.js.map +1 -1
  114. package/out/decoder/calibration.d.ts +17 -3
  115. package/out/decoder/calibration.d.ts.map +1 -1
  116. package/out/decoder/calibration.js +12 -4
  117. package/out/decoder/calibration.js.map +1 -1
  118. package/out/decoder/containment.d.ts +3 -1
  119. package/out/decoder/containment.d.ts.map +1 -1
  120. package/out/decoder/containment.js +3 -1
  121. package/out/decoder/containment.js.map +1 -1
  122. package/out/decoder/proposals-to-tree.d.ts.map +1 -1
  123. package/out/decoder/proposals-to-tree.js.map +1 -1
  124. package/out/decoder/resolve-proposal-overlaps.d.ts.map +1 -1
  125. package/out/decoder/resolve-proposal-overlaps.js +5 -1
  126. package/out/decoder/resolve-proposal-overlaps.js.map +1 -1
  127. package/out/decoder/serialize-json.d.ts +6 -2
  128. package/out/decoder/serialize-json.d.ts.map +1 -1
  129. package/out/decoder/serialize-json.js.map +1 -1
  130. package/out/decoder/serialize-tuples.d.ts +6 -2
  131. package/out/decoder/serialize-tuples.d.ts.map +1 -1
  132. package/out/decoder/serialize-tuples.js.map +1 -1
  133. package/out/decoder/serialize-xml.d.ts +21 -7
  134. package/out/decoder/serialize-xml.d.ts.map +1 -1
  135. package/out/decoder/serialize-xml.js +7 -5
  136. package/out/decoder/serialize-xml.js.map +1 -1
  137. package/out/decoder/types.d.ts +34 -12
  138. package/out/decoder/types.d.ts.map +1 -1
  139. package/out/decoder/types.js +1 -1
  140. package/out/decoder/types.js.map +1 -1
  141. package/out/decoder/unknown-spans.d.ts +9 -3
  142. package/out/decoder/unknown-spans.d.ts.map +1 -1
  143. package/out/decoder/unknown-spans.js +4 -2
  144. package/out/decoder/unknown-spans.js.map +1 -1
  145. package/out/decoder/validate-tree.d.ts +3 -1
  146. package/out/decoder/validate-tree.d.ts.map +1 -1
  147. package/out/decoder/validate-tree.js +3 -1
  148. package/out/decoder/validate-tree.js.map +1 -1
  149. package/out/env/index.js +0 -1
  150. package/out/env/index.js.map +1 -1
  151. package/out/env/load.js +1 -1
  152. package/out/env/load.js.map +1 -1
  153. package/out/env/paths.js +1 -1
  154. package/out/env/paths.js.map +1 -1
  155. package/out/env/schema.d.ts.map +1 -1
  156. package/out/env/schema.js +12 -4
  157. package/out/env/schema.js.map +1 -1
  158. package/out/errors/schema.js +1 -1
  159. package/out/errors/schema.js.map +1 -1
  160. package/out/fs/node.d.ts +1 -2
  161. package/out/fs/node.d.ts.map +1 -1
  162. package/out/fs/node.js +7 -8
  163. package/out/fs/node.js.map +1 -1
  164. package/out/identifiers.js +3 -3
  165. package/out/identifiers.js.map +1 -1
  166. package/out/kysley/adapter.d.ts +1 -1
  167. package/out/kysley/adapter.d.ts.map +1 -1
  168. package/out/kysley/adapter.js +1 -1
  169. package/out/kysley/adapter.js.map +1 -1
  170. package/out/layers/manifest.d.ts +18 -6
  171. package/out/layers/manifest.d.ts.map +1 -1
  172. package/out/layers/manifest.js +8 -4
  173. package/out/layers/manifest.js.map +1 -1
  174. package/out/layers/schema.d.ts +57 -19
  175. package/out/layers/schema.d.ts.map +1 -1
  176. package/out/layers/schema.js +24 -8
  177. package/out/layers/schema.js.map +1 -1
  178. package/out/locale/locale.d.ts +6 -2
  179. package/out/locale/locale.d.ts.map +1 -1
  180. package/out/locale/profiles/en-us.d.ts +3 -0
  181. package/out/locale/profiles/en-us.d.ts.map +1 -1
  182. package/out/locale/profiles/en-us.js +3 -0
  183. package/out/locale/profiles/en-us.js.map +1 -1
  184. package/out/locale/profiles/fr-fr.d.ts +3 -0
  185. package/out/locale/profiles/fr-fr.d.ts.map +1 -1
  186. package/out/locale/profiles/fr-fr.js +3 -0
  187. package/out/locale/profiles/fr-fr.js.map +1 -1
  188. package/out/locale/profiles/ja-jp.d.ts +3 -0
  189. package/out/locale/profiles/ja-jp.d.ts.map +1 -1
  190. package/out/locale/profiles/ja-jp.js +3 -0
  191. package/out/locale/profiles/ja-jp.js.map +1 -1
  192. package/out/locale/registry.d.ts +3 -1
  193. package/out/locale/registry.d.ts.map +1 -1
  194. package/out/locale/registry.js +3 -1
  195. package/out/locale/registry.js.map +1 -1
  196. package/out/logging/shared.d.ts.map +1 -1
  197. package/out/logging/shared.js +1 -0
  198. package/out/logging/shared.js.map +1 -1
  199. package/out/logging/utils.js +1 -1
  200. package/out/logging/utils.js.map +1 -1
  201. package/out/objects.d.ts.map +1 -1
  202. package/out/objects.js +2 -2
  203. package/out/objects.js.map +1 -1
  204. package/out/pipeline/index.d.ts +2 -2
  205. package/out/pipeline/index.d.ts.map +1 -1
  206. package/out/pipeline/index.js +1 -1
  207. package/out/pipeline/index.js.map +1 -1
  208. package/out/pipeline/reconcile-lookups.d.ts.map +1 -1
  209. package/out/pipeline/reconcile-lookups.js.map +1 -1
  210. package/out/pipeline/reconcile.d.ts +30 -10
  211. package/out/pipeline/reconcile.d.ts.map +1 -1
  212. package/out/pipeline/reconcile.js +12 -9
  213. package/out/pipeline/reconcile.js.map +1 -1
  214. package/out/pipeline/runtime-pipeline.d.ts +22 -0
  215. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  216. package/out/pipeline/runtime-pipeline.js +94 -42
  217. package/out/pipeline/runtime-pipeline.js.map +1 -1
  218. package/out/pipeline/span-logit-aggregation.d.ts.map +1 -1
  219. package/out/pipeline/span-logit-aggregation.js +5 -2
  220. package/out/pipeline/span-logit-aggregation.js.map +1 -1
  221. package/out/pipeline/span-proposer.d.ts +19 -9
  222. package/out/pipeline/span-proposer.d.ts.map +1 -1
  223. package/out/pipeline/span-proposer.js +42 -22
  224. package/out/pipeline/span-proposer.js.map +1 -1
  225. package/out/pipeline/types.d.ts +82 -23
  226. package/out/pipeline/types.d.ts.map +1 -1
  227. package/out/pipeline/types.js +16 -0
  228. package/out/pipeline/types.js.map +1 -1
  229. package/out/policy/proposal-collection.d.ts +1 -1
  230. package/out/policy/proposal-collection.d.ts.map +1 -1
  231. package/out/policy/proposal-collection.js +2 -3
  232. package/out/policy/proposal-collection.js.map +1 -1
  233. package/out/policy/registry.d.ts +9 -3
  234. package/out/policy/registry.d.ts.map +1 -1
  235. package/out/policy/registry.js +9 -3
  236. package/out/policy/registry.js.map +1 -1
  237. package/out/resolver/index.d.ts +2 -2
  238. package/out/resolver/index.d.ts.map +1 -1
  239. package/out/resolver/index.js +1 -1
  240. package/out/resolver/index.js.map +1 -1
  241. package/out/resolver/types.d.ts +172 -25
  242. package/out/resolver/types.d.ts.map +1 -1
  243. package/out/resolver/types.js +16 -0
  244. package/out/resolver/types.js.map +1 -1
  245. package/out/resources/LocaleIndex.d.ts +1 -1
  246. package/out/resources/LocaleIndex.d.ts.map +1 -1
  247. package/out/resources/LocaleIndex.js +1 -2
  248. package/out/resources/LocaleIndex.js.map +1 -1
  249. package/out/resources/ResourceMapCache.d.ts.map +1 -1
  250. package/out/resources/ResourceMapCache.js +1 -1
  251. package/out/resources/ResourceMapCache.js.map +1 -1
  252. package/out/resources/collections.d.ts.map +1 -1
  253. package/out/resources/collections.js +3 -1
  254. package/out/resources/collections.js.map +1 -1
  255. package/out/resources/languages/index.d.ts +1 -1
  256. package/out/resources/languages/index.d.ts.map +1 -1
  257. package/out/resources/languages/index.js +1 -1
  258. package/out/resources/languages/index.js.map +1 -1
  259. package/out/resources/libpostal.d.ts +1 -1
  260. package/out/resources/libpostal.d.ts.map +1 -1
  261. package/out/resources/libpostal.js +7 -5
  262. package/out/resources/libpostal.js.map +1 -1
  263. package/out/resources/set.js +6 -6
  264. package/out/resources/set.js.map +1 -1
  265. package/out/resources/whosonfirst/DataSourceCache.d.ts +1 -4
  266. package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
  267. package/out/resources/whosonfirst/DataSourceCache.js +1 -20
  268. package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
  269. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
  270. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  271. package/out/resources/whosonfirst/PlacetypeDataSource.js +2 -2
  272. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  273. package/out/resources/whosonfirst/backoff.d.ts +19 -0
  274. package/out/resources/whosonfirst/backoff.d.ts.map +1 -0
  275. package/out/resources/whosonfirst/backoff.js +35 -0
  276. package/out/resources/whosonfirst/backoff.js.map +1 -0
  277. package/out/resources/whosonfirst/loader.d.ts +1 -1
  278. package/out/resources/whosonfirst/loader.d.ts.map +1 -1
  279. package/out/resources/whosonfirst/loader.js +0 -1
  280. package/out/resources/whosonfirst/loader.js.map +1 -1
  281. package/out/resources/whosonfirst/placetypes/Placetype.d.ts +4 -1
  282. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  283. package/out/resources/whosonfirst/placetypes/Placetype.js +8 -6
  284. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  285. package/out/resources/whosonfirst/placetypes/admin.d.ts +6 -4
  286. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  287. package/out/resources/whosonfirst/placetypes/admin.js +8 -4
  288. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  289. package/out/resources/whosonfirst/placetypes/definition.d.ts +5 -6
  290. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  291. package/out/resources/whosonfirst/placetypes/definition.js +3 -0
  292. package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
  293. package/out/resources/whosonfirst/placetypes/graph.d.ts +4 -2
  294. package/out/resources/whosonfirst/placetypes/graph.d.ts.map +1 -1
  295. package/out/resources/whosonfirst/placetypes/graph.js +0 -0
  296. package/out/resources/whosonfirst/placetypes/graph.js.map +1 -1
  297. package/out/resources/whosonfirst/placetypes/mermaid.d.ts +4 -2
  298. package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
  299. package/out/resources/whosonfirst/placetypes/mermaid.js +0 -1
  300. package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
  301. package/out/resources/whosonfirst/placetypes/tree.d.ts +1 -1
  302. package/out/resources/whosonfirst/placetypes/tree.d.ts.map +1 -1
  303. package/out/resources/whosonfirst/placetypes/tree.js +0 -1
  304. package/out/resources/whosonfirst/placetypes/tree.js.map +1 -1
  305. package/out/routing/index.d.ts.map +1 -1
  306. package/out/routing/index.js +1 -1
  307. package/out/routing/index.js.map +1 -1
  308. package/out/scripting/utils/index.d.ts +3 -1
  309. package/out/scripting/utils/index.d.ts.map +1 -1
  310. package/out/scripting/utils/index.js +3 -1
  311. package/out/scripting/utils/index.js.map +1 -1
  312. package/out/tokenization/Span.js.map +1 -1
  313. package/out/tokenization/normalizer.js +11 -11
  314. package/out/tokenization/normalizer.js.map +1 -1
  315. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  316. package/out/tools/download-libpostal-resources.js.map +1 -1
  317. package/out/tools/download-ssl-address.d.ts +9 -3
  318. package/out/tools/download-ssl-address.d.ts.map +1 -1
  319. package/out/tools/download-ssl-address.js +8 -4
  320. package/out/tools/download-ssl-address.js.map +1 -1
  321. package/out/tools/generate-language-types.d.ts +12 -4
  322. package/out/tools/generate-language-types.d.ts.map +1 -1
  323. package/out/tools/generate-language-types.js +3 -1
  324. package/out/tools/generate-language-types.js.map +1 -1
  325. package/out/types/Classification.d.ts.map +1 -1
  326. package/out/types/Classification.js.map +1 -1
  327. package/out/types/classifier.d.ts +27 -9
  328. package/out/types/classifier.d.ts.map +1 -1
  329. package/out/types/component.d.ts +6 -2
  330. package/out/types/component.d.ts.map +1 -1
  331. package/out/types/component.js.map +1 -1
  332. package/out/utils/data-root.d.ts +3 -1
  333. package/out/utils/data-root.d.ts.map +1 -1
  334. package/out/utils/data-root.js +3 -1
  335. package/out/utils/data-root.js.map +1 -1
  336. package/out/utils/hash.d.ts +6 -2
  337. package/out/utils/hash.d.ts.map +1 -1
  338. package/out/utils/hash.js +6 -2
  339. package/out/utils/hash.js.map +1 -1
  340. package/out/utils/jsonl.d.ts +9 -3
  341. package/out/utils/jsonl.d.ts.map +1 -1
  342. package/out/utils/jsonl.js +9 -3
  343. package/out/utils/jsonl.js.map +1 -1
  344. package/out/utils/python-json.d.ts +6 -2
  345. package/out/utils/python-json.d.ts.map +1 -1
  346. package/out/utils/python-json.js +9 -3
  347. package/out/utils/python-json.js.map +1 -1
  348. package/out/utils/python-random.d.ts +15 -5
  349. package/out/utils/python-random.d.ts.map +1 -1
  350. package/out/utils/python-random.js +17 -7
  351. package/out/utils/python-random.js.map +1 -1
  352. package/out/utils/repo.d.ts +4 -0
  353. package/out/utils/repo.d.ts.map +1 -1
  354. package/out/utils/repo.js +4 -0
  355. package/out/utils/repo.js.map +1 -1
  356. package/out/utils/sealed-db.d.ts +6 -2
  357. package/out/utils/sealed-db.d.ts.map +1 -1
  358. package/out/utils/sealed-db.js +6 -2
  359. package/out/utils/sealed-db.js.map +1 -1
  360. package/out/utils/stats.d.ts +9 -3
  361. package/out/utils/stats.d.ts.map +1 -1
  362. package/out/utils/stats.js +11 -5
  363. package/out/utils/stats.js.map +1 -1
  364. package/package.json +2 -2
  365. package/pipeline/index.ts +5 -1
  366. package/pipeline/reconcile-lookups.ts +3 -0
  367. package/pipeline/reconcile.ts +65 -24
  368. package/pipeline/runtime-pipeline.ts +118 -42
  369. package/pipeline/span-logit-aggregation.ts +7 -2
  370. package/pipeline/span-proposer.ts +95 -34
  371. package/pipeline/types.ts +93 -23
  372. package/policy/proposal-collection.ts +4 -3
  373. package/policy/registry.ts +13 -3
  374. package/resolver/index.ts +11 -1
  375. package/resolver/types.ts +187 -25
  376. package/resources/LocaleIndex.ts +2 -2
  377. package/resources/ResourceMapCache.ts +3 -2
  378. package/resources/collections.ts +4 -1
  379. package/resources/languages/index.ts +2 -1
  380. package/resources/libpostal.ts +6 -3
  381. package/resources/set.ts +6 -6
  382. package/resources/whosonfirst/DataSourceCache.ts +2 -24
  383. package/resources/whosonfirst/PlacetypeDataSource.ts +2 -2
  384. package/resources/whosonfirst/backoff.ts +39 -0
  385. package/resources/whosonfirst/loader.ts +2 -1
  386. package/resources/whosonfirst/placetypes/Placetype.ts +9 -6
  387. package/resources/whosonfirst/placetypes/admin.ts +12 -7
  388. package/resources/whosonfirst/placetypes/definition.ts +6 -6
  389. package/resources/whosonfirst/placetypes/graph.ts +0 -0
  390. package/resources/whosonfirst/placetypes/mermaid.ts +5 -2
  391. package/resources/whosonfirst/placetypes/tree.ts +1 -1
  392. package/routing/index.ts +5 -1
  393. package/scripting/utils/index.ts +3 -1
  394. package/tokenization/Span.ts +1 -1
  395. package/tokenization/normalizer.ts +11 -11
  396. package/tools/download-libpostal-resources.ts +1 -0
  397. package/tools/download-ssl-address.ts +19 -7
  398. package/tools/generate-language-types.ts +12 -4
  399. package/types/Classification.ts +5 -0
  400. package/types/classifier.ts +27 -9
  401. package/types/component.ts +6 -2
  402. package/utils/data-root.ts +3 -1
  403. package/utils/hash.ts +6 -2
  404. package/utils/jsonl.ts +11 -3
  405. package/utils/python-json.ts +13 -4
  406. package/utils/python-random.ts +17 -7
  407. package/utils/repo.ts +8 -0
  408. package/utils/sealed-db.ts +10 -2
  409. package/utils/stats.ts +11 -5
package/utils/repo.ts CHANGED
@@ -19,12 +19,15 @@ import { createPathBuilderResolver, createPathResolver, type Join, type PathBuil
19
19
  * Compiled directory name for TS output files.
20
20
  */
21
21
  export const OutDirectoryName = "out"
22
+
22
23
  export type OutDirectoryName = typeof OutDirectoryName
23
24
 
24
25
  const RepoRootAlias = "mailwoman" as const
26
+
25
27
  type RepoRootAlias = typeof RepoRootAlias
26
28
 
27
29
  const PathReflection = ["core", "out", "utils"] as const
30
+
28
31
  type PathReflection = typeof PathReflection
29
32
 
30
33
  /**
@@ -47,6 +50,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url)) as Join<[RepoRootAlias
47
50
  const __isCompiledTree = basename(resolve(__dirname, "..")) === OutDirectoryName
48
51
  const __upCount = __isCompiledTree ? PathReflection.length : PathReflection.length - 1
49
52
  const RepoRootAbsolutePath = resolve(__dirname, ...Array.from({ length: __upCount }, () => ".."))
53
+
50
54
  type RepoRootAbsolutePath = RepoRootAlias
51
55
 
52
56
  /**
@@ -70,6 +74,10 @@ export const repoRootPath = createPathResolver<RepoRootAlias>(RepoRootAbsolutePa
70
74
  * the JS without any post-install copy step.
71
75
  */
72
76
  const CorePackageAbsolutePath = resolve(__dirname, "..", __isCompiledTree ? ".." : "")
77
+ /**
78
+ * Path builder rooted at `@mailwoman/core`, so data under `core/data/` resolves the same in source and compiled trees.
79
+ * See the `__isCompiledTree` note in this file before reaching across that boundary.
80
+ */
73
81
  export const corePackagePathBuilder = createPathBuilderResolver<RepoRootAlias>(CorePackageAbsolutePath)
74
82
 
75
83
  /**
@@ -23,18 +23,23 @@ function sqlite(): typeof import("node:sqlite") {
23
23
  return process.getBuiltinModule("node:sqlite")
24
24
  }
25
25
 
26
- /** A write-mode open was attempted on a sealed (0444) data artifact. */
26
+ /**
27
+ * A write-mode open was attempted on a sealed (0444) data artifact.
28
+ */
27
29
  export class SealedArtifactError extends Error {
28
30
  constructor(path: string) {
29
31
  super(
30
32
  `${basename(path)} is a sealed read-only artifact — rebuild it via \`mailwoman gazetteer build …\`, ` +
31
33
  `don't mutate it. (Deliberate unseal: chmod u+w — but prefer a rebuild.)`
32
34
  )
35
+
33
36
  this.name = "SealedArtifactError"
34
37
  }
35
38
  }
36
39
 
37
- /** True when the artifact exists and carries no write bits (the sealed state {@link sealDatabase} leaves). */
40
+ /**
41
+ * True when the artifact exists and carries no write bits (the sealed state {@link sealDatabase} leaves).
42
+ */
38
43
  export function isSealed(path: string): boolean {
39
44
  return existsSync(path) && (statSync(path).mode & 0o222) === 0
40
45
  }
@@ -48,6 +53,7 @@ export function sealDatabase(path: string): void {
48
53
  if (isSealed(path)) {
49
54
  chmodSync(path, 0o644)
50
55
  }
56
+
51
57
  const db = new (sqlite().DatabaseSync)(path)
52
58
  const checkpoint = db.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get() as { busy: number }
53
59
 
@@ -55,6 +61,7 @@ export function sealDatabase(path: string): void {
55
61
  db.close()
56
62
  throw new Error(`sealDatabase: WAL checkpoint busy on ${path} — close all writers first`)
57
63
  }
64
+
58
65
  const mode = db.prepare("PRAGMA journal_mode = DELETE").get() as { journal_mode: string }
59
66
  db.close()
60
67
 
@@ -67,6 +74,7 @@ export function sealDatabase(path: string): void {
67
74
  unlinkSync(sidecar)
68
75
  }
69
76
  }
77
+
70
78
  chmodSync(path, 0o444)
71
79
  }
72
80
 
package/utils/stats.ts CHANGED
@@ -11,20 +11,26 @@
11
11
  * "upgrade" it to linear interpolation.
12
12
  */
13
13
 
14
- /** Nearest-rank percentile over an unsorted sample; `null` on an empty sample. `p` in [0, 100]. */
14
+ /**
15
+ * Nearest-rank percentile over an unsorted sample; `null` on an empty sample. `p` in [0, 100].
16
+ */
15
17
  export function percentile(xs: readonly number[], p: number): number | null {
16
- if (xs.length === 0) return null
17
- const s = [...xs].sort((a, b) => a - b)
18
+ if (!xs.length) return null
19
+ const s = [...xs].toSorted((a, b) => a - b)
18
20
 
19
21
  return s[Math.min(s.length - 1, Math.floor((p / 100) * s.length))]!
20
22
  }
21
23
 
22
- /** `percentile(xs, 50)`. */
24
+ /**
25
+ * `percentile(xs, 50)`.
26
+ */
23
27
  export function median(xs: readonly number[]): number | null {
24
28
  return percentile(xs, 50)
25
29
  }
26
30
 
27
- /** Format `numerator / denominator` as a fixed-digit percentage (`"12.5%"`); `"—"` when `denominator` is 0. */
31
+ /**
32
+ * Format `numerator / denominator` as a fixed-digit percentage (`"12.5%"`); `"—"` when `denominator` is 0.
33
+ */
28
34
  export function formatPercent(numerator: number, denominator: number, digits = 1): string {
29
35
  if (denominator === 0) return "—"
30
36