@mailwoman/core 8.1.0 → 8.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 (407) 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 +6 -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 +6 -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 +18 -0
  215. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  216. package/out/pipeline/runtime-pipeline.js +73 -46
  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 +77 -19
  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.map +1 -1
  238. package/out/resolver/types.d.ts +94 -30
  239. package/out/resolver/types.d.ts.map +1 -1
  240. package/out/resolver/types.js +7 -1
  241. package/out/resolver/types.js.map +1 -1
  242. package/out/resources/LocaleIndex.d.ts +1 -1
  243. package/out/resources/LocaleIndex.d.ts.map +1 -1
  244. package/out/resources/LocaleIndex.js +1 -2
  245. package/out/resources/LocaleIndex.js.map +1 -1
  246. package/out/resources/ResourceMapCache.d.ts.map +1 -1
  247. package/out/resources/ResourceMapCache.js +1 -1
  248. package/out/resources/ResourceMapCache.js.map +1 -1
  249. package/out/resources/collections.d.ts.map +1 -1
  250. package/out/resources/collections.js +3 -1
  251. package/out/resources/collections.js.map +1 -1
  252. package/out/resources/languages/index.d.ts +1 -1
  253. package/out/resources/languages/index.d.ts.map +1 -1
  254. package/out/resources/languages/index.js +1 -1
  255. package/out/resources/languages/index.js.map +1 -1
  256. package/out/resources/libpostal.d.ts +1 -1
  257. package/out/resources/libpostal.d.ts.map +1 -1
  258. package/out/resources/libpostal.js +7 -5
  259. package/out/resources/libpostal.js.map +1 -1
  260. package/out/resources/set.js +6 -6
  261. package/out/resources/set.js.map +1 -1
  262. package/out/resources/whosonfirst/DataSourceCache.d.ts +1 -4
  263. package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
  264. package/out/resources/whosonfirst/DataSourceCache.js +1 -20
  265. package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
  266. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
  267. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  268. package/out/resources/whosonfirst/PlacetypeDataSource.js +2 -2
  269. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  270. package/out/resources/whosonfirst/backoff.d.ts +19 -0
  271. package/out/resources/whosonfirst/backoff.d.ts.map +1 -0
  272. package/out/resources/whosonfirst/backoff.js +35 -0
  273. package/out/resources/whosonfirst/backoff.js.map +1 -0
  274. package/out/resources/whosonfirst/loader.d.ts +1 -1
  275. package/out/resources/whosonfirst/loader.d.ts.map +1 -1
  276. package/out/resources/whosonfirst/loader.js +0 -1
  277. package/out/resources/whosonfirst/loader.js.map +1 -1
  278. package/out/resources/whosonfirst/placetypes/Placetype.d.ts +4 -1
  279. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  280. package/out/resources/whosonfirst/placetypes/Placetype.js +8 -6
  281. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  282. package/out/resources/whosonfirst/placetypes/admin.d.ts +6 -4
  283. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  284. package/out/resources/whosonfirst/placetypes/admin.js +8 -4
  285. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  286. package/out/resources/whosonfirst/placetypes/definition.d.ts +5 -6
  287. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  288. package/out/resources/whosonfirst/placetypes/definition.js +3 -0
  289. package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
  290. package/out/resources/whosonfirst/placetypes/graph.d.ts +4 -2
  291. package/out/resources/whosonfirst/placetypes/graph.d.ts.map +1 -1
  292. package/out/resources/whosonfirst/placetypes/graph.js +0 -0
  293. package/out/resources/whosonfirst/placetypes/graph.js.map +1 -1
  294. package/out/resources/whosonfirst/placetypes/mermaid.d.ts +4 -2
  295. package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
  296. package/out/resources/whosonfirst/placetypes/mermaid.js +0 -1
  297. package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
  298. package/out/resources/whosonfirst/placetypes/tree.d.ts +1 -1
  299. package/out/resources/whosonfirst/placetypes/tree.d.ts.map +1 -1
  300. package/out/resources/whosonfirst/placetypes/tree.js +0 -1
  301. package/out/resources/whosonfirst/placetypes/tree.js.map +1 -1
  302. package/out/routing/index.d.ts.map +1 -1
  303. package/out/routing/index.js +1 -1
  304. package/out/routing/index.js.map +1 -1
  305. package/out/scripting/utils/index.d.ts +3 -1
  306. package/out/scripting/utils/index.d.ts.map +1 -1
  307. package/out/scripting/utils/index.js +3 -1
  308. package/out/scripting/utils/index.js.map +1 -1
  309. package/out/tokenization/Span.js.map +1 -1
  310. package/out/tokenization/normalizer.js +11 -11
  311. package/out/tokenization/normalizer.js.map +1 -1
  312. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  313. package/out/tools/download-libpostal-resources.js.map +1 -1
  314. package/out/tools/download-ssl-address.d.ts +9 -3
  315. package/out/tools/download-ssl-address.d.ts.map +1 -1
  316. package/out/tools/download-ssl-address.js +8 -4
  317. package/out/tools/download-ssl-address.js.map +1 -1
  318. package/out/tools/generate-language-types.d.ts +12 -4
  319. package/out/tools/generate-language-types.d.ts.map +1 -1
  320. package/out/tools/generate-language-types.js +3 -1
  321. package/out/tools/generate-language-types.js.map +1 -1
  322. package/out/types/Classification.d.ts.map +1 -1
  323. package/out/types/Classification.js.map +1 -1
  324. package/out/types/classifier.d.ts +27 -9
  325. package/out/types/classifier.d.ts.map +1 -1
  326. package/out/types/component.d.ts +8 -4
  327. package/out/types/component.d.ts.map +1 -1
  328. package/out/types/component.js +3 -3
  329. package/out/types/component.js.map +1 -1
  330. package/out/utils/data-root.d.ts +3 -1
  331. package/out/utils/data-root.d.ts.map +1 -1
  332. package/out/utils/data-root.js +3 -1
  333. package/out/utils/data-root.js.map +1 -1
  334. package/out/utils/hash.d.ts +6 -2
  335. package/out/utils/hash.d.ts.map +1 -1
  336. package/out/utils/hash.js +6 -2
  337. package/out/utils/hash.js.map +1 -1
  338. package/out/utils/jsonl.d.ts +9 -3
  339. package/out/utils/jsonl.d.ts.map +1 -1
  340. package/out/utils/jsonl.js +9 -3
  341. package/out/utils/jsonl.js.map +1 -1
  342. package/out/utils/python-json.d.ts +6 -2
  343. package/out/utils/python-json.d.ts.map +1 -1
  344. package/out/utils/python-json.js +9 -3
  345. package/out/utils/python-json.js.map +1 -1
  346. package/out/utils/python-random.d.ts +15 -5
  347. package/out/utils/python-random.d.ts.map +1 -1
  348. package/out/utils/python-random.js +17 -7
  349. package/out/utils/python-random.js.map +1 -1
  350. package/out/utils/repo.d.ts +4 -0
  351. package/out/utils/repo.d.ts.map +1 -1
  352. package/out/utils/repo.js +4 -0
  353. package/out/utils/repo.js.map +1 -1
  354. package/out/utils/sealed-db.d.ts +6 -2
  355. package/out/utils/sealed-db.d.ts.map +1 -1
  356. package/out/utils/sealed-db.js +6 -2
  357. package/out/utils/sealed-db.js.map +1 -1
  358. package/out/utils/stats.d.ts +9 -3
  359. package/out/utils/stats.d.ts.map +1 -1
  360. package/out/utils/stats.js +11 -5
  361. package/out/utils/stats.js.map +1 -1
  362. package/package.json +2 -2
  363. package/pipeline/index.ts +5 -1
  364. package/pipeline/reconcile-lookups.ts +3 -0
  365. package/pipeline/reconcile.ts +65 -24
  366. package/pipeline/runtime-pipeline.ts +95 -46
  367. package/pipeline/span-logit-aggregation.ts +7 -2
  368. package/pipeline/span-proposer.ts +95 -34
  369. package/pipeline/types.ts +88 -19
  370. package/policy/proposal-collection.ts +4 -3
  371. package/policy/registry.ts +13 -3
  372. package/resolver/index.ts +1 -0
  373. package/resolver/types.ts +95 -30
  374. package/resources/LocaleIndex.ts +2 -2
  375. package/resources/ResourceMapCache.ts +3 -2
  376. package/resources/collections.ts +4 -1
  377. package/resources/languages/index.ts +2 -1
  378. package/resources/libpostal.ts +6 -3
  379. package/resources/set.ts +6 -6
  380. package/resources/whosonfirst/DataSourceCache.ts +2 -24
  381. package/resources/whosonfirst/PlacetypeDataSource.ts +2 -2
  382. package/resources/whosonfirst/backoff.ts +39 -0
  383. package/resources/whosonfirst/loader.ts +2 -1
  384. package/resources/whosonfirst/placetypes/Placetype.ts +9 -6
  385. package/resources/whosonfirst/placetypes/admin.ts +12 -7
  386. package/resources/whosonfirst/placetypes/definition.ts +6 -6
  387. package/resources/whosonfirst/placetypes/graph.ts +0 -0
  388. package/resources/whosonfirst/placetypes/mermaid.ts +5 -2
  389. package/resources/whosonfirst/placetypes/tree.ts +1 -1
  390. package/routing/index.ts +5 -1
  391. package/scripting/utils/index.ts +3 -1
  392. package/tokenization/Span.ts +1 -1
  393. package/tokenization/normalizer.ts +11 -11
  394. package/tools/download-libpostal-resources.ts +1 -0
  395. package/tools/download-ssl-address.ts +19 -7
  396. package/tools/generate-language-types.ts +12 -4
  397. package/types/Classification.ts +5 -0
  398. package/types/classifier.ts +27 -9
  399. package/types/component.ts +9 -5
  400. package/utils/data-root.ts +3 -1
  401. package/utils/hash.ts +6 -2
  402. package/utils/jsonl.ts +11 -3
  403. package/utils/python-json.ts +13 -4
  404. package/utils/python-random.ts +17 -7
  405. package/utils/repo.ts +8 -0
  406. package/utils/sealed-db.ts +10 -2
  407. package/utils/stats.ts +11 -5
@@ -106,6 +106,7 @@ function flush(open: OpenSpan | null, raw: string, out: AddressNode[], attributi
106
106
  if (attribution.sourceID !== undefined) {
107
107
  node.sourceID = attribution.sourceID
108
108
  }
109
+
109
110
  out.push(node)
110
111
 
111
112
  return null
@@ -127,6 +128,7 @@ function emitSpans(raw: string, tokens: DecoderToken[], attribution: BuildTreeOp
127
128
  // non-whitespace `O` (comma, slash, …) is a genuine separator and still flushes.
128
129
  if (open !== null && /^\s*$/.test(raw.slice(tok.start, tok.end))) continue
129
130
  open = flush(open, raw, out, attribution)
131
+
130
132
  continue
131
133
  }
132
134
 
@@ -143,10 +145,13 @@ function emitSpans(raw: string, tokens: DecoderToken[], attribution: BuildTreeOp
143
145
  if (prefix === "B" && open !== null && open.tag === tag && /^\s*$/.test(raw.slice(open.end, tok.start))) {
144
146
  open.end = tok.end
145
147
  open.confidences.push(tok.confidence)
148
+
146
149
  continue
147
150
  }
148
- open = flush(open, raw, out, attribution)
151
+
152
+ flush(open, raw, out, attribution)
149
153
  open = { tag: tag!, start: tok.start, end: tok.end, confidences: [tok.confidence] }
154
+
150
155
  continue
151
156
  }
152
157
 
@@ -178,9 +183,17 @@ function findParent(
178
183
  for (const parentTag of candidates) {
179
184
  const matches = all.filter((s) => s !== span && s.tag === parentTag)
180
185
 
181
- if (matches.length === 0) continue
186
+ if (!matches.length) continue
187
+
188
+ let closest = matches[0]!
189
+
190
+ for (const candidate of matches) {
191
+ if (distance(candidate, span) < distance(closest, span)) {
192
+ closest = candidate
193
+ }
194
+ }
182
195
 
183
- return matches.reduce((best, cur) => (distance(cur, span) < distance(best, span) ? cur : best))
196
+ return closest
184
197
  }
185
198
 
186
199
  return null
@@ -23,7 +23,9 @@
23
23
  * applies in `flush()`.
24
24
  */
25
25
 
26
- /** One row of the lookup table: a confidence bin and the calibrated value at its center. */
26
+ /**
27
+ * One row of the lookup table: a confidence bin and the calibrated value at its center.
28
+ */
27
29
  export interface CalibrationBin {
28
30
  lo: number
29
31
  hi: number
@@ -31,7 +33,9 @@ export interface CalibrationBin {
31
33
  calibrated: number
32
34
  }
33
35
 
34
- /** The full calibration artifact emitted by `fit-isotonic-calibration.py`. */
36
+ /**
37
+ * The full calibration artifact emitted by `fit-isotonic-calibration.py`.
38
+ */
35
39
  export interface CalibrationTable {
36
40
  model: string
37
41
  model_version: string
@@ -41,7 +45,9 @@ export interface CalibrationTable {
41
45
  [key: string]: unknown
42
46
  }
43
47
 
44
- /** Maps a raw span confidence in [0, 1] to its calibrated probability of correctness. */
48
+ /**
49
+ * Maps a raw span confidence in [0, 1] to its calibrated probability of correctness.
50
+ */
45
51
  export type Calibrator = (rawConfidence: number) => number
46
52
 
47
53
  /**
@@ -52,17 +58,19 @@ export type Calibrator = (rawConfidence: number) => number
52
58
  export function createCalibrator(table: CalibrationTable | CalibrationBin[]): Calibrator {
53
59
  const bins = Array.isArray(table) ? table : table.table
54
60
 
55
- if (!bins || bins.length === 0) {
61
+ if (!bins || !bins.length) {
56
62
  throw new Error("createCalibrator: empty calibration table")
57
63
  }
64
+
58
65
  // Sort by center and extract parallel arrays for interpolation.
66
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
59
67
  const sorted = [...bins].sort((a, b) => a.center - b.center)
60
68
  const centers = sorted.map((b) => b.center)
61
- const cals = sorted.map((b) => clamp01(b.calibrated))
69
+ const cals = sorted.map((b) => clampConfidence(b.calibrated))
62
70
  const n = centers.length
63
71
 
64
72
  return (raw: number): number => {
65
- const x = clamp01(raw)
73
+ const x = clampConfidence(raw)
66
74
 
67
75
  if (x <= centers[0]!) return cals[0]!
68
76
 
@@ -80,6 +88,7 @@ export function createCalibrator(table: CalibrationTable | CalibrationBin[]): Ca
80
88
  hi = mid
81
89
  }
82
90
  }
91
+
83
92
  const x0 = centers[lo]!
84
93
  const x1 = centers[hi]!
85
94
  const y0 = cals[lo]!
@@ -90,7 +99,14 @@ export function createCalibrator(table: CalibrationTable | CalibrationBin[]): Ca
90
99
  }
91
100
  }
92
101
 
93
- function clamp01(v: number): number {
102
+ /**
103
+ * Clamp a confidence into `[0, 1]`, mapping NaN to 0.
104
+ *
105
+ * Distinct from `clampFraction` (`@mailwoman/spatial`), which lets NaN through on purpose: a confidence that cannot be
106
+ * computed is no confidence, while an interpolation fraction that cannot be computed must stay detectable rather than
107
+ * silently snapping to a segment's start.
108
+ */
109
+ export function clampConfidence(v: number): number {
94
110
  if (Number.isNaN(v)) return 0
95
111
 
96
112
  if (v < 0) return 0
@@ -31,7 +31,9 @@
31
31
  import type { ComponentTag } from "../types/component.ts"
32
32
  import type { AddressSystem } from "./types.ts"
33
33
 
34
- /** Preferred-parent ordering for each tag. Empty / missing = always root. */
34
+ /**
35
+ * Preferred-parent ordering for each tag. Empty / missing = always root.
36
+ */
35
37
  export const WESTERN_PARENT_OF: Partial<Record<ComponentTag, ComponentTag[]>> = {
36
38
  // Universal coarse — containment follows geographic granularity.
37
39
  region: ["country"],
@@ -29,6 +29,7 @@ export function proposalsToTree(raw: string, proposals: readonly ClassificationP
29
29
  source: p.source,
30
30
  sourceID: p.source_id,
31
31
  }))
32
+
32
33
  roots.sort((a, b) => a.start - b.start)
33
34
 
34
35
  return { raw, roots }
@@ -60,6 +61,7 @@ export function treeToProposals(
60
61
  const visit = (node: AddressNode): void => {
61
62
  if (!emits || emits.has(node.tag)) {
62
63
  const span = { start: node.start, end: node.end, body: node.value } as unknown as Span
64
+
63
65
  proposals.push({
64
66
  span,
65
67
  component: node.tag,
@@ -40,7 +40,9 @@
40
40
 
41
41
  import type { ClassificationProposal } from "../types/index.ts"
42
42
 
43
- /** Half-open interval overlap: `[aStart,aEnd)` and `[bStart,bEnd)` share at least one position. */
43
+ /**
44
+ * Half-open interval overlap: `[aStart,aEnd)` and `[bStart,bEnd)` share at least one position.
45
+ */
44
46
  function spansOverlap(a: ClassificationProposal["span"], b: ClassificationProposal["span"]): boolean {
45
47
  return a.start < b.end && b.start < a.end
46
48
  }
@@ -56,6 +58,7 @@ function spansOverlap(a: ClassificationProposal["span"], b: ClassificationPropos
56
58
  export function resolveProposalOverlaps(proposals: readonly ClassificationProposal[]): ClassificationProposal[] {
57
59
  if (proposals.length <= 1) return [...proposals]
58
60
 
61
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
59
62
  const ranked = [...proposals].sort((a, b) => {
60
63
  if (b.confidence !== a.confidence) return b.confidence - a.confidence // higher confidence first
61
64
  const lenA = a.span.end - a.span.start
@@ -75,5 +78,6 @@ export function resolveProposalOverlaps(proposals: readonly ClassificationPropos
75
78
  }
76
79
  }
77
80
 
81
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
78
82
  return kept.sort((a, b) => a.span.start - b.span.start)
79
83
  }
@@ -17,7 +17,9 @@ import type { ComponentTag } from "../types/component.ts"
17
17
  import type { AddressNode, AddressTree } from "./types.ts"
18
18
  import { type UnknownSpan, unknownSpans } from "./unknown-spans.ts"
19
19
 
20
- /** Options for {@link decodeAsJSON}. */
20
+ /**
21
+ * Options for {@link decodeAsJSON}.
22
+ */
21
23
  export interface SerializeJSONOpts {
22
24
  /**
23
25
  * Add an `unknown` array of the all-O spans the model left unclassified (#493). Default false — keeps the output
@@ -44,12 +46,16 @@ function visit(node: AddressNode, out: Partial<Record<ComponentTag, string>>): v
44
46
  }
45
47
  }
46
48
 
47
- /** Project an `AddressTree` to a flat libpostal-style component map. */
49
+ /**
50
+ * Project an `AddressTree` to a flat libpostal-style component map.
51
+ */
48
52
  export function decodeAsJSON(tree: AddressTree): Partial<Record<ComponentTag, string>>
53
+
49
54
  export function decodeAsJSON(
50
55
  tree: AddressTree,
51
56
  opts: SerializeJSONOpts
52
57
  ): Partial<Record<ComponentTag, string>> & { unknown?: UnknownSpan[] }
58
+
53
59
  export function decodeAsJSON(
54
60
  tree: AddressTree,
55
61
  opts: SerializeJSONOpts = {}
@@ -14,7 +14,9 @@ import type { ComponentTag } from "../types/component.ts"
14
14
  import type { AddressNode, AddressTree } from "./types.ts"
15
15
  import { unknownSpans } from "./unknown-spans.ts"
16
16
 
17
- /** Options for {@link decodeAsTuples}. */
17
+ /**
18
+ * Options for {@link decodeAsTuples}.
19
+ */
18
20
  export interface SerializeTuplesOpts {
19
21
  /**
20
22
  * Interleave `["unknown", value]` tuples for the all-O spans the model left unclassified (#493), in source order.
@@ -31,9 +33,12 @@ function flatten(node: AddressNode, out: AddressNode[]): void {
31
33
  }
32
34
  }
33
35
 
34
- /** Project an `AddressTree` to a source-ordered list of (tag, value) pairs. */
36
+ /**
37
+ * Project an `AddressTree` to a source-ordered list of (tag, value) pairs.
38
+ */
35
39
  export function decodeAsTuples(tree: AddressTree): Array<[ComponentTag, string]>
36
40
  export function decodeAsTuples(tree: AddressTree, opts: SerializeTuplesOpts): Array<[ComponentTag | "unknown", string]>
41
+
37
42
  export function decodeAsTuples(
38
43
  tree: AddressTree,
39
44
  opts: SerializeTuplesOpts = {}
@@ -34,17 +34,29 @@ import type { AddressNode, AddressTree } from "./types.ts"
34
34
  import { unknownSpans } from "./unknown-spans.ts"
35
35
 
36
36
  export interface SerializeXMLOpts {
37
- /** Pretty-print with line breaks and indentation. Default true. */
37
+ /**
38
+ * Pretty-print with line breaks and indentation. Default true.
39
+ */
38
40
  pretty?: boolean
39
- /** Include `conf` attribute on every component. Default true. */
41
+ /**
42
+ * Include `conf` attribute on every component. Default true.
43
+ */
40
44
  includeConf?: boolean
41
- /** Include `start` + `end` char-offset attributes. Default true. */
45
+ /**
46
+ * Include `start` + `end` char-offset attributes. Default true.
47
+ */
42
48
  includeOffsets?: boolean
43
- /** Include `src` provenance attribute when the node carries source info. Default true. */
49
+ /**
50
+ * Include `src` provenance attribute when the node carries source info. Default true.
51
+ */
44
52
  includeSrc?: boolean
45
- /** Include `lat` + `lon` resolver-supplied centroid attrs when set on the node. Default true. */
53
+ /**
54
+ * Include `lat` + `lon` resolver-supplied centroid attrs when set on the node. Default true.
55
+ */
46
56
  includeGeo?: boolean
47
- /** Include `place` resolver-supplied normalized place URI when set. Default true. */
57
+ /**
58
+ * Include `place` resolver-supplied normalized place URI when set. Default true.
59
+ */
48
60
  includePlace?: boolean
49
61
  /**
50
62
  * Include `<alternative>` child elements for each runner-up resolver candidate on the node. When set +
@@ -63,7 +75,7 @@ export interface SerializeXMLOpts {
63
75
  }
64
76
 
65
77
  function escapeXml(s: string): string {
66
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")
78
+ return s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;")
67
79
  }
68
80
 
69
81
  function srcAttrValue(node: AddressNode): string | null {
@@ -113,12 +125,12 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
113
125
 
114
126
  // Multi-role node (#413): a city-state span tagged `region` that also plays `locality` lists every
115
127
  // role it holds, primary first — `roles="region locality"`. Emitted only when extra roles exist.
116
- if (node.interpretations && node.interpretations.length > 0) {
128
+ if (node.interpretations && node.interpretations.length) {
117
129
  const roles = [node.tag, ...node.interpretations.map((i) => i.tag)]
118
130
  parts.push(`roles="${escapeXml(roles.join(" "))}"`)
119
131
  }
120
132
 
121
- return parts.length === 0 ? "" : " " + parts.join(" ")
133
+ return !parts.length ? "" : " " + parts.join(" ")
122
134
  }
123
135
 
124
136
  interface AlternativeLike {
@@ -131,10 +143,12 @@ interface AlternativeLike {
131
143
  }
132
144
 
133
145
  function serializeAlternatives(node: AddressNode, indent: string): string {
134
- if (!node.alternatives || node.alternatives.length === 0) return ""
146
+ if (!node.alternatives || !node.alternatives.length) return ""
147
+
135
148
  const lines = node.alternatives.map((raw) => {
136
149
  const alt = raw as AlternativeLike
137
150
  const place = `wof:${alt.id}`
151
+
138
152
  const parts = [
139
153
  `place="${escapeXml(place)}"`,
140
154
  `name="${escapeXml(alt.name)}"`,
@@ -170,7 +184,9 @@ function serializeNode(node: AddressNode, indent: string, opts: Required<Seriali
170
184
  return `${indent}<${node.tag}${a}>${text}${nl}${inner}${nl}${indent}</${node.tag}>`
171
185
  }
172
186
 
173
- /** Project an `AddressTree` to nested XML with optional confidence/offset attributes. */
187
+ /**
188
+ * Project an `AddressTree` to nested XML with optional confidence/offset attributes.
189
+ */
174
190
  export function decodeAsXML(tree: AddressTree, opts: SerializeXMLOpts = {}): string {
175
191
  const full: Required<SerializeXMLOpts> = {
176
192
  pretty: opts.pretty ?? true,
@@ -182,6 +198,7 @@ export function decodeAsXML(tree: AddressTree, opts: SerializeXMLOpts = {}): str
182
198
  includeAlternatives: opts.includeAlternatives ?? false,
183
199
  includeUnknown: opts.includeUnknown ?? false,
184
200
  }
201
+
185
202
  const rawAttr = escapeXml(tree.raw)
186
203
  const nl = full.pretty ? "\n" : ""
187
204
  const indent = full.pretty ? "\t" : ""
@@ -200,6 +217,7 @@ export function decodeAsXML(tree: AddressTree, opts: SerializeXMLOpts = {}): str
200
217
  xml: `${indent}<unknown start="${u.start}" end="${u.end}">${escapeXml(u.value)}</unknown>`,
201
218
  })
202
219
  }
220
+
203
221
  entries.sort((a, b) => a.start - b.start)
204
222
  }
205
223
 
package/decoder/types.ts CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
  import type { BIOLabel, ComponentTag } from "../types/component.ts"
30
30
 
31
- export type { BIOLabel, ComponentTag }
31
+ export { type BIOLabel, type ComponentTag } from "../types/component.ts"
32
32
 
33
33
  /**
34
34
  * A single token emitted by the model, paired with its predicted label and confidence.
@@ -37,15 +37,25 @@ export type { BIOLabel, ComponentTag }
37
37
  * (SentencePiece's `encode` returns offsets); they are NOT recomputed by the decoder.
38
38
  */
39
39
  export interface DecoderToken {
40
- /** The token piece as the tokenizer emitted it (with any leading-space sentinel preserved). */
40
+ /**
41
+ * The token piece as the tokenizer emitted it (with any leading-space sentinel preserved).
42
+ */
41
43
  piece: string
42
- /** Inclusive start char offset in the original raw text. */
44
+ /**
45
+ * Inclusive start char offset in the original raw text.
46
+ */
43
47
  start: number
44
- /** Exclusive end char offset in the original raw text. */
48
+ /**
49
+ * Exclusive end char offset in the original raw text.
50
+ */
45
51
  end: number
46
- /** The argmax BIO label for this token. */
52
+ /**
53
+ * The argmax BIO label for this token.
54
+ */
47
55
  label: BIOLabel
48
- /** Softmax confidence for the chosen label, in [0, 1]. */
56
+ /**
57
+ * Softmax confidence for the chosen label, in [0, 1].
58
+ */
49
59
  confidence: number
50
60
  }
51
61
 
@@ -74,9 +84,13 @@ export interface AddressNode {
74
84
  * `"neural-v0.3.1-en-us"`, or a resolver-supplied place id like `"wof-admin:101751119"`.
75
85
  */
76
86
  sourceID?: string
77
- /** Resolver-supplied centroid latitude (Phase 4.3). Optional — only set when a resolver wins. */
87
+ /**
88
+ * Resolver-supplied centroid latitude (Phase 4.3). Optional — only set when a resolver wins.
89
+ */
78
90
  lat?: number
79
- /** Resolver-supplied centroid longitude (Phase 4.3). Optional — only set when a resolver wins. */
91
+ /**
92
+ * Resolver-supplied centroid longitude (Phase 4.3). Optional — only set when a resolver wins.
93
+ */
80
94
  lon?: number
81
95
  /**
82
96
  * Resolver-supplied normalized place URI (Phase 4.3) — `"wof:101751119"` for a WOF place. Distinct from `sourceID`
@@ -112,13 +126,19 @@ export interface AddressNode {
112
126
  interpretations?: ReadonlyArray<Interpretation>
113
127
  }
114
128
 
115
- /** One additional role a span plays (#413) — see {@link AddressNode.interpretations}. */
129
+ /**
130
+ * One additional role a span plays (#413) — see {@link AddressNode.interpretations}.
131
+ */
116
132
  export interface Interpretation {
117
133
  tag: ComponentTag
118
- /** Resolver-supplied normalized place URI for this role (e.g. `wof:101909779`). */
134
+ /**
135
+ * Resolver-supplied normalized place URI for this role (e.g. `wof:101909779`).
136
+ */
119
137
  placeID?: string
120
138
  sourceID?: string
121
- /** Centroid for this role's place (a capital-seat comune differs from its province). */
139
+ /**
140
+ * Centroid for this role's place (a capital-seat comune differs from its province).
141
+ */
122
142
  lat?: number
123
143
  lon?: number
124
144
  confidence?: number
@@ -132,7 +152,9 @@ export interface Interpretation {
132
152
  * labeled output become roots themselves (e.g. a bare "house_number" with no labeled street parent).
133
153
  */
134
154
  export interface AddressTree {
135
- /** The original raw input text — preserved for round-trip and XML root @raw attribute. */
155
+ /**
156
+ * The original raw input text — preserved for round-trip and XML root @raw attribute.
157
+ */
136
158
  raw: string
137
159
  roots: AddressNode[]
138
160
  /**
@@ -17,13 +17,19 @@ import type { AddressNode, AddressTree } from "./types.ts"
17
17
  export interface UnknownSpan {
18
18
  kind: "unknown"
19
19
  value: string
20
- /** Inclusive start char offset into `tree.raw`. */
20
+ /**
21
+ * Inclusive start char offset into `tree.raw`.
22
+ */
21
23
  start: number
22
- /** Exclusive end char offset into `tree.raw`. */
24
+ /**
25
+ * Exclusive end char offset into `tree.raw`.
26
+ */
23
27
  end: number
24
28
  }
25
29
 
26
- /** One tile of the lossless decomposition: a run that some node covers, or an `unknown` gap. */
30
+ /**
31
+ * One tile of the lossless decomposition: a run that some node covers, or an `unknown` gap.
32
+ */
27
33
  export interface LosslessSegment {
28
34
  kind: "covered" | "unknown"
29
35
  value: string
@@ -31,13 +37,15 @@ export interface LosslessSegment {
31
37
  end: number
32
38
  }
33
39
 
34
- /** Mark every char index `tree.raw` that any node's `[start,end)` covers (nesting overlaps merge naturally). */
40
+ /**
41
+ * Mark every char index `tree.raw` that any node's `[start,end)` covers (nesting overlaps merge naturally).
42
+ */
35
43
  function coveredMask(tree: AddressTree): Uint8Array {
36
44
  const len = tree.raw.length
37
45
  const covered = new Uint8Array(len)
38
46
  const stack: AddressNode[] = [...tree.roots]
39
47
 
40
- while (stack.length > 0) {
48
+ while (stack.length) {
41
49
  const n = stack.pop()!
42
50
  const lo = Math.max(0, n.start)
43
51
  const hi = Math.min(len, n.end)
@@ -73,6 +81,7 @@ export function losslessSegments(tree: AddressTree): LosslessSegment[] {
73
81
  while (j < len && !!covered[j] === !!covered[i]) {
74
82
  j++
75
83
  }
84
+
76
85
  out.push({ kind, value: tree.raw.slice(i, j), start: i, end: j })
77
86
  i = j
78
87
  }
@@ -56,17 +56,21 @@ export interface TreeValidity {
56
56
  violations: TreeViolation[]
57
57
  }
58
58
 
59
- /** Validate an `AddressTree`'s structural coherence. See module docstring. */
59
+ /**
60
+ * Validate an `AddressTree`'s structural coherence. See module docstring.
61
+ */
60
62
  export function validateTree(tree: AddressTree): TreeValidity {
61
63
  const violations: TreeViolation[] = []
62
64
  // Validate against the tree's own addressing system's hierarchy (defaults to Western).
63
65
  const parentOf = containmentFor(tree.system)
64
66
 
65
67
  const present = new Set<ComponentTag>()
68
+
66
69
  const collect = (n: AddressNode): void => {
67
70
  present.add(n.tag)
68
71
  n.children.forEach(collect)
69
72
  }
73
+
70
74
  tree.roots.forEach(collect)
71
75
 
72
76
  const walk = (node: AddressNode, parent: AddressNode | null): void => {
@@ -94,6 +98,7 @@ export function validateTree(tree: AddressTree): TreeValidity {
94
98
 
95
99
  node.children.forEach((c) => walk(c, node))
96
100
  }
101
+
97
102
  tree.roots.forEach((r) => walk(r, null))
98
103
 
99
104
  return { valid: violations.length === 0, violations }
package/env/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from "zod"
1
+ import type { z } from "zod"
2
2
 
3
3
  import { loadEnvFile } from "./load.ts"
4
4
  import { cwdPathBuilder } from "./paths.ts"
package/env/load.ts CHANGED
@@ -8,7 +8,7 @@ import { parseEnv } from "node:util"
8
8
  export function loadEnvFile<T extends object = object>(envFilePath: PathLike): T {
9
9
  if (!existsSync(envFilePath)) return {} as T
10
10
 
11
- const envFileContent = readFileSync(envFilePath, "utf-8")
11
+ const envFileContent = readFileSync(envFilePath, "utf8")
12
12
 
13
13
  return parseEnv(envFileContent) as T
14
14
  }
package/env/paths.ts CHANGED
@@ -36,5 +36,5 @@ export function cwdEnvPaths(): string[] {
36
36
  }
37
37
 
38
38
  // `found` is deepest-first (cwd first); reverse so cwd is applied last and wins.
39
- return found.reverse()
39
+ return found.toReversed()
40
40
  }
package/env/schema.ts CHANGED
@@ -78,13 +78,21 @@ export const PublicEnvSchema = z.object({
78
78
 
79
79
  // Eval scripts (`scripts/eval/*`) — diagnostic toggles + DB/probe overrides.
80
80
  MAILWOMAN_WOF_HOT_DB: z.string().optional(),
81
- /** Override the admin gazetteer used by the default-country test panel. */
81
+ /**
82
+ * Override the admin gazetteer used by the default-country test panel.
83
+ */
82
84
  MAILWOMAN_WOF_GLOBAL_DB: z.string().optional(),
83
- /** Deployed demo URL for the docs e2e suite (skips the local build+serve machinery). */
85
+ /**
86
+ * Deployed demo URL for the docs e2e suite (skips the local build+serve machinery).
87
+ */
84
88
  MAILWOMAN_DEMO_URL: z.string().optional(),
85
- /** Override the ONNX model exercised by the neural test suites. */
89
+ /**
90
+ * Override the ONNX model exercised by the neural test suites.
91
+ */
86
92
  MAILWOMAN_TEST_ONNX_MODEL: z.string().optional(),
87
- /** Override the ONNX model exercised by the capability gate. */
93
+ /**
94
+ * Override the ONNX model exercised by the capability gate.
95
+ */
88
96
  MAILWOMAN_CAPABILITY_ONNX_MODEL: z.string().optional(),
89
97
  MAILWOMAN_DIAG_INTERP: z.string().optional(),
90
98
  MAILWOMAN_DUMP_MISS_TAG: z.string().optional(),
package/errors/schema.ts CHANGED
@@ -79,7 +79,7 @@ export class ResourceError<S extends StatusCodes = StatusCodes> extends Error {
79
79
  status = error.status
80
80
  break
81
81
  case "string":
82
- status = parseInt(error.status, 10) || this.DefaultStatus
82
+ status = Number.parseInt(error.status, 10) || this.DefaultStatus
83
83
  break
84
84
  }
85
85
  }
package/fs/node.ts CHANGED
@@ -4,22 +4,23 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
6
 
7
- import type { PathLike, Stats } from "node:fs"
8
- import { existsSync } from "node:fs"
7
+ import type { Stats } from "node:fs"
9
8
  import { stat } from "node:fs/promises"
10
9
 
11
10
  import type { PathBuilderLike } from "path-ts"
12
11
 
12
+ export { existsSync } from "node:fs"
13
+
13
14
  /**
14
15
  * Attempts to stat a file or directory.
15
16
  *
16
17
  * @throws If the path exists but cannot be statted for some reason other than non-existence.
17
18
  */
18
19
  export function tryStat(pathBuilderLike: PathBuilderLike): Promise<Stats | null> {
19
- return stat(pathBuilderLike.toString()).catch((err) => {
20
- if (err.code === "ENOENT") return null
20
+ return stat(pathBuilderLike.toString()).catch((error) => {
21
+ if (error.code === "ENOENT") return null
21
22
 
22
- throw err
23
+ throw error
23
24
  })
24
25
  }
25
26
 
@@ -29,10 +30,8 @@ export function tryStat(pathBuilderLike: PathBuilderLike): Promise<Stats | null>
29
30
  export async function isDirectory(path: PathBuilderLike): Promise<boolean> {
30
31
  return tryStat(path)
31
32
  .then((stats) => stats?.isDirectory() ?? false)
32
- .catch((err) => {
33
- if (err.code === "ENOENT") return false
34
- throw err
33
+ .catch((error) => {
34
+ if (error.code === "ENOENT") return false
35
+ throw error
35
36
  })
36
37
  }
37
-
38
- export { existsSync }
package/identifiers.ts CHANGED
@@ -12,16 +12,16 @@ import type { CamelCase, SnakeCase } from "type-fest"
12
12
  export function smartSnakeCase<T extends string>(name: T): T extends Uppercase<T> ? T : SnakeCase<T> {
13
13
  const normalizedName = name
14
14
  // Remove periods after capital letters, e.g. "U.S.A." -> "USA"
15
- .replace(/([A-Z])(\.+)/g, "$1")
15
+ .replaceAll(/([A-Z])(\.+)/g, "$1")
16
16
  .trim()
17
17
 
18
18
  if (normalizedName.toUpperCase() === normalizedName) {
19
19
  return (
20
20
  normalizedName
21
21
  // Replace all non-word characters with underscores...
22
- .replace(/\W{1,}/g, "_")
22
+ .replaceAll(/\W{1,}/g, "_")
23
23
  // ...and then replace all sequences of underscores with a single underscore.
24
- .replace(/_{2,}/g, "_") as T extends Uppercase<T> ? T : SnakeCase<T>
24
+ .replaceAll(/_{2,}/g, "_") as T extends Uppercase<T> ? T : SnakeCase<T>
25
25
  )
26
26
  }
27
27
 
package/kysley/adapter.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
6
 
7
- import { DialectAdapterBase, Kysely, type MigrationLockOptions } from "kysely"
7
+ import { type Kysely, DialectAdapterBase, type MigrationLockOptions } from "kysely"
8
8
 
9
9
  export class SqliteAdapter extends DialectAdapterBase {
10
10
  override get supportsTransactionalDdl(): boolean {