@mailwoman/core 9.3.0 → 10.0.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 (441) hide show
  1. package/lib/coarse-placer/tools/{build-dataset.ts → build/dataset.ts} +2 -1
  2. package/lib/coarse-placer/tools/{build-outlier-latin.ts → build/outlier/latin.ts} +4 -3
  3. package/lib/coarse-placer/tools/{eval-openset.ts → eval/openset.ts} +11 -7
  4. package/lib/coarse-placer/tools/{eval-quant-compare.ts → eval/quant-compare.ts} +2 -1
  5. package/lib/coarse-placer/tools/eval.ts +2 -2
  6. package/lib/coarse-placer/tools/index.ts +7 -7
  7. package/lib/coarse-placer/tools/train.ts +4 -6
  8. package/lib/decoder/build-tree.ts +2 -1
  9. package/lib/decoder/containment.ts +2 -1
  10. package/lib/decoder/index.ts +5 -5
  11. package/lib/decoder/parse-diff.ts +1 -1
  12. package/lib/decoder/proposals-to-tree.ts +3 -1
  13. package/lib/decoder/{serialize-json.ts → serialize/json.ts} +3 -2
  14. package/lib/decoder/{serialize-tuples.ts → serialize/tuples.ts} +2 -1
  15. package/lib/decoder/{tree-shape.ts → tree/shape.ts} +7 -10
  16. package/lib/decoder/types.ts +1 -3
  17. package/lib/decoder/unknown-spans.ts +1 -1
  18. package/lib/decoder/validate-tree.ts +2 -1
  19. package/lib/fs/readers/stat.ts +244 -0
  20. package/lib/fs/readers.ts +38 -270
  21. package/lib/fs/streams.ts +58 -0
  22. package/lib/fs/writers.ts +5 -5
  23. package/lib/fs/zip.ts +64 -8
  24. package/lib/git.ts +26 -0
  25. package/lib/layers/coverage.ts +3 -2
  26. package/lib/layers/manifest.ts +2 -4
  27. package/lib/layers/schema.ts +0 -1
  28. package/lib/license/configured.ts +2 -2
  29. package/lib/license/docs-site.ts +1 -15
  30. package/lib/license/index.ts +2 -2
  31. package/lib/license/obligations.ts +4 -1
  32. package/lib/license/stamp.ts +1 -1
  33. package/lib/license/status.ts +1 -1
  34. package/lib/locale/locale.ts +2 -1
  35. package/lib/locale/registry.ts +2 -1
  36. package/lib/module/resolve-from.ts +16 -4
  37. package/lib/objects.ts +9 -1
  38. package/lib/overture-pins.ts +24 -0
  39. package/lib/pipeline/client-result.ts +82 -0
  40. package/lib/pipeline/index.ts +1 -1
  41. package/lib/pipeline/preferences.ts +13 -0
  42. package/lib/pipeline/result.ts +84 -0
  43. package/lib/pipeline/runtime-pipeline.ts +10 -17
  44. package/lib/pipeline/types.ts +28 -88
  45. package/lib/policy/defaults.ts +2 -1
  46. package/lib/policy/policy.ts +3 -1
  47. package/lib/policy/registry.ts +3 -1
  48. package/lib/process.ts +3 -1
  49. package/lib/resolver/authoritative-provider.ts +1 -1
  50. package/lib/resolver/index.ts +1 -8
  51. package/lib/resolver/lookup-types.ts +8 -0
  52. package/lib/resolver/synthetic-id-ranges.ts +83 -0
  53. package/lib/resolver/types.ts +2 -9
  54. package/lib/resources/whosonfirst/placetypes/Placetype.ts +7 -6
  55. package/lib/scripting/arguments.ts +34 -0
  56. package/lib/scripting/utils/index.ts +1 -1
  57. package/lib/strings/case.ts +13 -2
  58. package/lib/strings/format.ts +15 -0
  59. package/lib/tokenization/Graph.ts +3 -4
  60. package/lib/tools/{download-libpostal-resources.ts → download/libpostal-resources.ts} +3 -2
  61. package/lib/tools/generate-language-types.ts +3 -4
  62. package/lib/tools/index.ts +2 -2
  63. package/lib/types/classifier.ts +2 -1
  64. package/lib/types/index.ts +0 -1
  65. package/lib/types/mapping.ts +2 -1
  66. package/lib/workspaces.ts +104 -0
  67. package/out/api/APIClient.d.ts.map +1 -1
  68. package/out/api/arcgis.d.ts.map +1 -1
  69. package/out/api/defaults.d.ts.map +1 -1
  70. package/out/api/headless.d.ts.map +1 -1
  71. package/out/api/ogc.d.ts.map +1 -1
  72. package/out/api/paced-client.js.map +1 -1
  73. package/out/api/pacer.d.ts.map +1 -1
  74. package/out/api/pacer.js.map +1 -1
  75. package/out/api/responses.d.ts.map +1 -1
  76. package/out/api/{test-clocks.d.ts → test/clocks.d.ts} +1 -1
  77. package/out/api/test/clocks.d.ts.map +1 -0
  78. package/out/api/{test-clocks.js → test/clocks.js} +1 -1
  79. package/out/api/test/clocks.js.map +1 -0
  80. package/out/api/{test-transport.d.ts → test/transport.d.ts} +1 -1
  81. package/out/api/test/transport.d.ts.map +1 -0
  82. package/out/api/{test-transport.js → test/transport.js} +1 -1
  83. package/out/api/test/transport.js.map +1 -0
  84. package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
  85. package/out/coarse-placer/coarse-placer.js.map +1 -1
  86. package/out/coarse-placer/featurize.d.ts.map +1 -1
  87. package/out/coarse-placer/tools/{build-dataset.d.ts → build/dataset.d.ts} +1 -1
  88. package/out/coarse-placer/tools/build/dataset.d.ts.map +1 -0
  89. package/out/coarse-placer/tools/{build-dataset.js → build/dataset.js} +3 -2
  90. package/out/coarse-placer/tools/build/dataset.js.map +1 -0
  91. package/out/coarse-placer/tools/{build-outlier-exposure.d.ts → build/outlier/exposure.d.ts} +1 -1
  92. package/out/coarse-placer/tools/build/outlier/exposure.d.ts.map +1 -0
  93. package/out/coarse-placer/tools/{build-outlier-exposure.js → build/outlier/exposure.js} +1 -1
  94. package/out/coarse-placer/tools/build/outlier/exposure.js.map +1 -0
  95. package/out/coarse-placer/tools/{build-outlier-latin.d.ts → build/outlier/latin.d.ts} +3 -3
  96. package/out/coarse-placer/tools/build/outlier/latin.d.ts.map +1 -0
  97. package/out/coarse-placer/tools/{build-outlier-latin.js → build/outlier/latin.js} +4 -3
  98. package/out/coarse-placer/tools/build/outlier/latin.js.map +1 -0
  99. package/out/coarse-placer/tools/{build-outlier-oa.d.ts → build/outlier/oa.d.ts} +1 -1
  100. package/out/coarse-placer/tools/build/outlier/oa.d.ts.map +1 -0
  101. package/out/coarse-placer/tools/{build-outlier-oa.js → build/outlier/oa.js} +1 -1
  102. package/out/coarse-placer/tools/build/outlier/oa.js.map +1 -0
  103. package/out/coarse-placer/tools/country-sets.d.ts.map +1 -1
  104. package/out/coarse-placer/tools/{eval-latin-offmap.d.ts → eval/latin-offmap.d.ts} +1 -1
  105. package/out/coarse-placer/tools/eval/latin-offmap.d.ts.map +1 -0
  106. package/out/coarse-placer/tools/{eval-latin-offmap.js → eval/latin-offmap.js} +1 -1
  107. package/out/coarse-placer/tools/eval/latin-offmap.js.map +1 -0
  108. package/out/coarse-placer/tools/{eval-openset.d.ts → eval/openset.d.ts} +1 -1
  109. package/out/coarse-placer/tools/eval/openset.d.ts.map +1 -0
  110. package/out/coarse-placer/tools/{eval-openset.js → eval/openset.js} +10 -7
  111. package/out/coarse-placer/tools/eval/openset.js.map +1 -0
  112. package/out/coarse-placer/tools/{eval-quant-compare.d.ts → eval/quant-compare.d.ts} +1 -1
  113. package/out/coarse-placer/tools/eval/quant-compare.d.ts.map +1 -0
  114. package/out/coarse-placer/tools/{eval-quant-compare.js → eval/quant-compare.js} +2 -2
  115. package/out/coarse-placer/tools/eval/quant-compare.js.map +1 -0
  116. package/out/coarse-placer/tools/eval.js +2 -2
  117. package/out/coarse-placer/tools/eval.js.map +1 -1
  118. package/out/coarse-placer/tools/index.d.ts +7 -7
  119. package/out/coarse-placer/tools/index.js +7 -7
  120. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  121. package/out/coarse-placer/tools/quantize.js.map +1 -1
  122. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  123. package/out/coarse-placer/tools/train.js +2 -3
  124. package/out/coarse-placer/tools/train.js.map +1 -1
  125. package/out/data-root.js.map +1 -1
  126. package/out/decoder/build-tree.d.ts.map +1 -1
  127. package/out/decoder/build-tree.js.map +1 -1
  128. package/out/decoder/containment.d.ts +2 -2
  129. package/out/decoder/containment.d.ts.map +1 -1
  130. package/out/decoder/containment.js.map +1 -1
  131. package/out/decoder/index.d.ts +5 -5
  132. package/out/decoder/index.js +5 -5
  133. package/out/decoder/parse-diff.js +1 -1
  134. package/out/decoder/parse-diff.js.map +1 -1
  135. package/out/decoder/proposals-to-tree.d.ts +2 -1
  136. package/out/decoder/proposals-to-tree.d.ts.map +1 -1
  137. package/out/decoder/proposals-to-tree.js.map +1 -1
  138. package/out/decoder/{serialize-json.d.ts → serialize/json.d.ts} +2 -2
  139. package/out/decoder/serialize/json.d.ts.map +1 -0
  140. package/out/decoder/{serialize-json.js → serialize/json.js} +2 -2
  141. package/out/decoder/serialize/json.js.map +1 -0
  142. package/out/decoder/{serialize-tuples.d.ts → serialize/tuples.d.ts} +2 -2
  143. package/out/decoder/serialize/tuples.d.ts.map +1 -0
  144. package/out/decoder/{serialize-tuples.js → serialize/tuples.js} +1 -1
  145. package/out/decoder/serialize/tuples.js.map +1 -0
  146. package/out/decoder/{serialize-xml.d.ts → serialize/xml.d.ts} +1 -1
  147. package/out/decoder/serialize/xml.d.ts.map +1 -0
  148. package/out/decoder/{serialize-xml.js → serialize/xml.js} +1 -1
  149. package/out/decoder/serialize/xml.js.map +1 -0
  150. package/out/decoder/{tree-shape.d.ts → tree/shape.d.ts} +5 -9
  151. package/out/decoder/tree/shape.d.ts.map +1 -0
  152. package/out/decoder/{tree-shape.js → tree/shape.js} +6 -10
  153. package/out/decoder/tree/shape.js.map +1 -0
  154. package/out/decoder/{tree-walk.d.ts → tree/walk.d.ts} +1 -1
  155. package/out/decoder/tree/walk.d.ts.map +1 -0
  156. package/out/decoder/{tree-walk.js → tree/walk.js} +1 -1
  157. package/out/decoder/tree/walk.js.map +1 -0
  158. package/out/decoder/types.d.ts +1 -2
  159. package/out/decoder/types.d.ts.map +1 -1
  160. package/out/decoder/types.js +1 -1
  161. package/out/decoder/types.js.map +1 -1
  162. package/out/decoder/unknown-spans.js +1 -1
  163. package/out/decoder/validate-tree.d.ts +1 -1
  164. package/out/decoder/validate-tree.d.ts.map +1 -1
  165. package/out/decoder/validate-tree.js.map +1 -1
  166. package/out/env/index.d.ts +1 -1
  167. package/out/env/schema.d.ts +4 -4
  168. package/out/errors/schema.d.ts.map +1 -1
  169. package/out/errors/schema.js.map +1 -1
  170. package/out/fs/formatters.d.ts.map +1 -1
  171. package/out/fs/formatters.js.map +1 -1
  172. package/out/fs/readers/stat.d.ts +126 -0
  173. package/out/fs/readers/stat.d.ts.map +1 -0
  174. package/out/fs/readers/stat.js +202 -0
  175. package/out/fs/readers/stat.js.map +1 -0
  176. package/out/fs/readers.d.ts +16 -149
  177. package/out/fs/readers.d.ts.map +1 -1
  178. package/out/fs/readers.js +19 -230
  179. package/out/fs/readers.js.map +1 -1
  180. package/out/fs/streams.d.ts +33 -0
  181. package/out/fs/streams.d.ts.map +1 -1
  182. package/out/fs/streams.js +49 -0
  183. package/out/fs/streams.js.map +1 -1
  184. package/out/fs/writers.d.ts +5 -5
  185. package/out/fs/writers.js +5 -5
  186. package/out/fs/zip.d.ts +21 -2
  187. package/out/fs/zip.d.ts.map +1 -1
  188. package/out/fs/zip.js +36 -8
  189. package/out/fs/zip.js.map +1 -1
  190. package/out/git.d.ts +15 -0
  191. package/out/git.d.ts.map +1 -1
  192. package/out/git.js +22 -0
  193. package/out/git.js.map +1 -1
  194. package/out/html/document.js.map +1 -1
  195. package/out/json.d.ts.map +1 -1
  196. package/out/layers/coverage.d.ts +1 -1
  197. package/out/layers/coverage.d.ts.map +1 -1
  198. package/out/layers/coverage.js +1 -2
  199. package/out/layers/coverage.js.map +1 -1
  200. package/out/layers/manifest.d.ts +2 -2
  201. package/out/layers/manifest.d.ts.map +1 -1
  202. package/out/layers/manifest.js +2 -3
  203. package/out/layers/manifest.js.map +1 -1
  204. package/out/layers/schema.d.ts +0 -1
  205. package/out/layers/schema.d.ts.map +1 -1
  206. package/out/layers/schema.js +0 -3
  207. package/out/layers/schema.js.map +1 -1
  208. package/out/license/configured.d.ts +1 -1
  209. package/out/license/configured.d.ts.map +1 -1
  210. package/out/license/configured.js +2 -2
  211. package/out/license/configured.js.map +1 -1
  212. package/out/license/docs-site.d.ts +0 -6
  213. package/out/license/docs-site.d.ts.map +1 -1
  214. package/out/license/docs-site.js +1 -12
  215. package/out/license/docs-site.js.map +1 -1
  216. package/out/license/index.d.ts +2 -2
  217. package/out/license/index.d.ts.map +1 -1
  218. package/out/license/index.js +2 -2
  219. package/out/license/index.js.map +1 -1
  220. package/out/license/{key-file.d.ts → key/file.d.ts} +1 -1
  221. package/out/license/key/file.d.ts.map +1 -0
  222. package/out/license/{key-file.js → key/file.js} +1 -1
  223. package/out/license/key/file.js.map +1 -0
  224. package/out/license/{key.d.ts → key/index.d.ts} +1 -1
  225. package/out/license/key/index.d.ts.map +1 -0
  226. package/out/license/{key.js → key/index.js} +1 -1
  227. package/out/license/key/index.js.map +1 -0
  228. package/out/license/obligations.d.ts +1 -1
  229. package/out/license/obligations.d.ts.map +1 -1
  230. package/out/license/obligations.js +3 -0
  231. package/out/license/obligations.js.map +1 -1
  232. package/out/license/publication.js.map +1 -1
  233. package/out/license/register.d.ts.map +1 -1
  234. package/out/license/stamp.d.ts +1 -1
  235. package/out/license/stamp.d.ts.map +1 -1
  236. package/out/license/status.js +1 -1
  237. package/out/license/status.js.map +1 -1
  238. package/out/locale/locale.d.ts +1 -1
  239. package/out/locale/locale.d.ts.map +1 -1
  240. package/out/locale/registry.d.ts.map +1 -1
  241. package/out/locale/registry.js +1 -1
  242. package/out/locale/registry.js.map +1 -1
  243. package/out/locale/zh-cn-units.d.ts.map +1 -1
  244. package/out/logging/shared.d.ts.map +1 -1
  245. package/out/module/resolve-from.d.ts +12 -3
  246. package/out/module/resolve-from.d.ts.map +1 -1
  247. package/out/module/resolve-from.js.map +1 -1
  248. package/out/module/resolvers.js.map +1 -1
  249. package/out/objects.d.ts +6 -0
  250. package/out/objects.d.ts.map +1 -1
  251. package/out/objects.js +8 -1
  252. package/out/objects.js.map +1 -1
  253. package/out/overture-pins.d.ts +24 -0
  254. package/out/overture-pins.d.ts.map +1 -0
  255. package/out/overture-pins.js +24 -0
  256. package/out/overture-pins.js.map +1 -0
  257. package/out/paths.js.map +1 -1
  258. package/out/pipeline/client-result.d.ts +84 -0
  259. package/out/pipeline/client-result.d.ts.map +1 -0
  260. package/out/pipeline/client-result.js +12 -0
  261. package/out/pipeline/client-result.js.map +1 -0
  262. package/out/pipeline/index.d.ts +1 -1
  263. package/out/pipeline/index.d.ts.map +1 -1
  264. package/out/pipeline/preferences.d.ts +13 -0
  265. package/out/pipeline/preferences.d.ts.map +1 -0
  266. package/out/pipeline/preferences.js +7 -0
  267. package/out/pipeline/preferences.js.map +1 -0
  268. package/out/pipeline/result.d.ts +72 -0
  269. package/out/pipeline/result.d.ts.map +1 -0
  270. package/out/pipeline/result.js +7 -0
  271. package/out/pipeline/result.js.map +1 -0
  272. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  273. package/out/pipeline/runtime-pipeline.js +7 -13
  274. package/out/pipeline/runtime-pipeline.js.map +1 -1
  275. package/out/pipeline/span-proposer.js.map +1 -1
  276. package/out/pipeline/types.d.ts +23 -85
  277. package/out/pipeline/types.d.ts.map +1 -1
  278. package/out/pipeline/types.js +2 -0
  279. package/out/pipeline/types.js.map +1 -1
  280. package/out/policy/defaults.d.ts +1 -1
  281. package/out/policy/defaults.d.ts.map +1 -1
  282. package/out/policy/defaults.js +1 -1
  283. package/out/policy/defaults.js.map +1 -1
  284. package/out/policy/policy.d.ts +2 -1
  285. package/out/policy/policy.d.ts.map +1 -1
  286. package/out/policy/proposal-collection.js.map +1 -1
  287. package/out/policy/registry.d.ts +2 -1
  288. package/out/policy/registry.d.ts.map +1 -1
  289. package/out/policy/registry.js.map +1 -1
  290. package/out/process.d.ts +2 -2
  291. package/out/process.d.ts.map +1 -1
  292. package/out/process.js.map +1 -1
  293. package/out/random.d.ts.map +1 -1
  294. package/out/release-config.js.map +1 -1
  295. package/out/resolver/authoritative-provider.d.ts +1 -1
  296. package/out/resolver/authoritative-provider.d.ts.map +1 -1
  297. package/out/resolver/fixture-authoritative-provider.js.map +1 -1
  298. package/out/resolver/index.d.ts +2 -2
  299. package/out/resolver/index.d.ts.map +1 -1
  300. package/out/resolver/index.js +1 -1
  301. package/out/resolver/index.js.map +1 -1
  302. package/out/resolver/lookup-types.d.ts +8 -0
  303. package/out/resolver/lookup-types.d.ts.map +1 -1
  304. package/out/resolver/synthetic-id-ranges.d.ts +66 -0
  305. package/out/resolver/synthetic-id-ranges.d.ts.map +1 -0
  306. package/out/resolver/synthetic-id-ranges.js +73 -0
  307. package/out/resolver/synthetic-id-ranges.js.map +1 -0
  308. package/out/resolver/types.d.ts +1 -2
  309. package/out/resolver/types.d.ts.map +1 -1
  310. package/out/resolver/types.js +0 -1
  311. package/out/resolver/types.js.map +1 -1
  312. package/out/resources/languages/index.js.map +1 -1
  313. package/out/resources/languages/types.gen.d.ts.map +1 -1
  314. package/out/resources/locale.d.ts.map +1 -1
  315. package/out/resources/set.d.ts.map +1 -1
  316. package/out/resources/set.js.map +1 -1
  317. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
  318. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  319. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  320. package/out/resources/whosonfirst/placetypes/Placetype.js +7 -6
  321. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  322. package/out/resources/whosonfirst/placetypes/admin.d.ts +1 -1
  323. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  324. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  325. package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
  326. package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
  327. package/out/routing/index.d.ts.map +1 -1
  328. package/out/routing/index.js.map +1 -1
  329. package/out/scripting/arguments.d.ts +7 -0
  330. package/out/scripting/arguments.d.ts.map +1 -1
  331. package/out/scripting/arguments.js +29 -0
  332. package/out/scripting/arguments.js.map +1 -1
  333. package/out/scripting/command.d.ts.map +1 -1
  334. package/out/scripting/ingest-chunk-script.d.ts.map +1 -1
  335. package/out/scripting/utils/index.d.ts +1 -1
  336. package/out/scripting/utils/index.d.ts.map +1 -1
  337. package/out/scripting/utils/index.js +1 -1
  338. package/out/scripting/utils/index.js.map +1 -1
  339. package/out/strings/case.d.ts +3 -0
  340. package/out/strings/case.d.ts.map +1 -1
  341. package/out/strings/case.js +12 -2
  342. package/out/strings/case.js.map +1 -1
  343. package/out/strings/format.d.ts +6 -0
  344. package/out/strings/format.d.ts.map +1 -1
  345. package/out/strings/format.js +12 -0
  346. package/out/strings/format.js.map +1 -1
  347. package/out/strings/python-json.js.map +1 -1
  348. package/out/tokenization/Graph.d.ts +3 -0
  349. package/out/tokenization/Graph.d.ts.map +1 -1
  350. package/out/tokenization/Graph.js +0 -4
  351. package/out/tokenization/Graph.js.map +1 -1
  352. package/out/tokenization/Span.d.ts.map +1 -1
  353. package/out/tokenization/Span.js.map +1 -1
  354. package/out/tokenization/normalizer.d.ts.map +1 -1
  355. package/out/tokenization/normalizer.js.map +1 -1
  356. package/out/tools/{download-libpostal-resources.d.ts → download/libpostal-resources.d.ts} +1 -1
  357. package/out/tools/download/libpostal-resources.d.ts.map +1 -0
  358. package/out/tools/{download-libpostal-resources.js → download/libpostal-resources.js} +4 -3
  359. package/out/tools/download/libpostal-resources.js.map +1 -0
  360. package/out/tools/{download-ssl-address.d.ts → download/ssl-address.d.ts} +1 -1
  361. package/out/tools/download/ssl-address.d.ts.map +1 -0
  362. package/out/tools/{download-ssl-address.js → download/ssl-address.js} +1 -1
  363. package/out/tools/download/ssl-address.js.map +1 -0
  364. package/out/tools/generate-language-types.d.ts.map +1 -1
  365. package/out/tools/generate-language-types.js +3 -4
  366. package/out/tools/generate-language-types.js.map +1 -1
  367. package/out/tools/index.d.ts +2 -2
  368. package/out/tools/index.js +2 -2
  369. package/out/types/Classification.d.ts +2 -2
  370. package/out/types/Classification.d.ts.map +1 -1
  371. package/out/types/classifier.d.ts +1 -1
  372. package/out/types/classifier.d.ts.map +1 -1
  373. package/out/types/index.d.ts +0 -1
  374. package/out/types/index.d.ts.map +1 -1
  375. package/out/types/index.js +0 -1
  376. package/out/types/index.js.map +1 -1
  377. package/out/types/mapping.d.ts +1 -1
  378. package/out/types/mapping.d.ts.map +1 -1
  379. package/out/types/mapping.js.map +1 -1
  380. package/out/utils/time.js.map +1 -1
  381. package/out/workspaces.d.ts +31 -0
  382. package/out/workspaces.d.ts.map +1 -0
  383. package/out/workspaces.js +72 -0
  384. package/out/workspaces.js.map +1 -0
  385. package/package.json +84 -55
  386. package/lib/resolver/placetype-map.ts +0 -130
  387. package/lib/types/component.ts +0 -96
  388. package/out/api/test-clocks.d.ts.map +0 -1
  389. package/out/api/test-clocks.js.map +0 -1
  390. package/out/api/test-transport.d.ts.map +0 -1
  391. package/out/api/test-transport.js.map +0 -1
  392. package/out/coarse-placer/tools/build-dataset.d.ts.map +0 -1
  393. package/out/coarse-placer/tools/build-dataset.js.map +0 -1
  394. package/out/coarse-placer/tools/build-outlier-exposure.d.ts.map +0 -1
  395. package/out/coarse-placer/tools/build-outlier-exposure.js.map +0 -1
  396. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +0 -1
  397. package/out/coarse-placer/tools/build-outlier-latin.js.map +0 -1
  398. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +0 -1
  399. package/out/coarse-placer/tools/build-outlier-oa.js.map +0 -1
  400. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +0 -1
  401. package/out/coarse-placer/tools/eval-latin-offmap.js.map +0 -1
  402. package/out/coarse-placer/tools/eval-openset.d.ts.map +0 -1
  403. package/out/coarse-placer/tools/eval-openset.js.map +0 -1
  404. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +0 -1
  405. package/out/coarse-placer/tools/eval-quant-compare.js.map +0 -1
  406. package/out/decoder/serialize-json.d.ts.map +0 -1
  407. package/out/decoder/serialize-json.js.map +0 -1
  408. package/out/decoder/serialize-tuples.d.ts.map +0 -1
  409. package/out/decoder/serialize-tuples.js.map +0 -1
  410. package/out/decoder/serialize-xml.d.ts.map +0 -1
  411. package/out/decoder/serialize-xml.js.map +0 -1
  412. package/out/decoder/tree-shape.d.ts.map +0 -1
  413. package/out/decoder/tree-shape.js.map +0 -1
  414. package/out/decoder/tree-walk.d.ts.map +0 -1
  415. package/out/decoder/tree-walk.js.map +0 -1
  416. package/out/license/key-file.d.ts.map +0 -1
  417. package/out/license/key-file.js.map +0 -1
  418. package/out/license/key.d.ts.map +0 -1
  419. package/out/license/key.js.map +0 -1
  420. package/out/resolver/placetype-map.d.ts +0 -76
  421. package/out/resolver/placetype-map.d.ts.map +0 -1
  422. package/out/resolver/placetype-map.js +0 -106
  423. package/out/resolver/placetype-map.js.map +0 -1
  424. package/out/tools/download-libpostal-resources.d.ts.map +0 -1
  425. package/out/tools/download-libpostal-resources.js.map +0 -1
  426. package/out/tools/download-ssl-address.d.ts.map +0 -1
  427. package/out/tools/download-ssl-address.js.map +0 -1
  428. package/out/types/component.d.ts +0 -50
  429. package/out/types/component.d.ts.map +0 -1
  430. package/out/types/component.js +0 -84
  431. package/out/types/component.js.map +0 -1
  432. /package/lib/api/{test-clocks.ts → test/clocks.ts} +0 -0
  433. /package/lib/api/{test-transport.ts → test/transport.ts} +0 -0
  434. /package/lib/coarse-placer/tools/{build-outlier-exposure.ts → build/outlier/exposure.ts} +0 -0
  435. /package/lib/coarse-placer/tools/{build-outlier-oa.ts → build/outlier/oa.ts} +0 -0
  436. /package/lib/coarse-placer/tools/{eval-latin-offmap.ts → eval/latin-offmap.ts} +0 -0
  437. /package/lib/decoder/{serialize-xml.ts → serialize/xml.ts} +0 -0
  438. /package/lib/decoder/{tree-walk.ts → tree/walk.ts} +0 -0
  439. /package/lib/license/{key-file.ts → key/file.ts} +0 -0
  440. /package/lib/license/{key.ts → key/index.ts} +0 -0
  441. /package/lib/tools/{download-ssl-address.ts → download/ssl-address.ts} +0 -0
@@ -25,6 +25,7 @@ import { COUNTRIES, IN_MAP_EU, NEW_EU } from "#coarse-placer/tools/country-sets"
25
25
  import { defaultDataDir } from "#coarse-placer/tools/paths"
26
26
  import { errorMessage } from "#errors/schema"
27
27
  import { writeLocalTextFile, makeDirectories } from "#fs/writers"
28
+ import { OVERTURE_ADDRESSES_RELEASE } from "#overture-pins"
28
29
  import { dataRootPath } from "#utils"
29
30
 
30
31
  interface DatasetRow {
@@ -108,7 +109,7 @@ export async function buildDataset(
108
109
  "*.parquet"
109
110
  )
110
111
 
111
- const OVERTURE_DIR = dataRootPath("overture", "2026-06-17.0")
112
+ const OVERTURE_DIR = dataRootPath("overture", OVERTURE_ADDRESSES_RELEASE)
112
113
  await makeDirectories(OUT_DIR)
113
114
 
114
115
  // Heavy dep (devDependency — operator tooling), lazy-imported so loading the tools barrel stays cheap.
@@ -20,7 +20,7 @@
20
20
  * without rebuilding train/val).
21
21
  *
22
22
  * Run: `mailwoman placer build-dataset --outliers latin [--per-country 6000] [--overture
23
- * $MAILWOMAN_DATA_ROOT/overture/2026-05-20.0]`
23
+ * $MAILWOMAN_DATA_ROOT/overture/<release>]` (default: the addresses-theme pin, `OVERTURE_ADDRESSES_RELEASE`)
24
24
  */
25
25
 
26
26
  import { type PathBuilderLike, resolvePath } from "path-ts"
@@ -30,6 +30,7 @@ import { assembleOutlierRow, collectOutlierRows, otherRowsJSONL } from "#coarse-
30
30
  import { defaultDataDir } from "#coarse-placer/tools/paths"
31
31
  import { errorMessage } from "#errors/schema"
32
32
  import { writeLocalTextFile, appendLocalTextFile } from "#fs/writers"
33
+ import { OVERTURE_ADDRESSES_RELEASE } from "#overture-pins"
33
34
  import { dataRootPath } from "#utils"
34
35
 
35
36
  interface LatinTestRow {
@@ -48,7 +49,7 @@ export interface BuildOutlierLatinOptions {
48
49
  */
49
50
  perCountry?: number
50
51
  /**
51
- * Overture release dir. Default `$MAILWOMAN_DATA_ROOT/overture/2026-05-20.0`.
52
+ * Overture release dir. Default `$MAILWOMAN_DATA_ROOT/overture/<OVERTURE_ADDRESSES_RELEASE>`.
52
53
  */
53
54
  overture?: PathBuilderLike
54
55
  /**
@@ -116,7 +117,7 @@ export async function buildOutlierLatin(
116
117
  report?: (line: string) => void
117
118
  ): Promise<BuildOutlierLatinResult> {
118
119
  const PER = options.perCountry ?? 6000
119
- const overtureDir = options.overture || dataRootPath("overture", "2026-05-20.0")
120
+ const overtureDir = options.overture || dataRootPath("overture", OVERTURE_ADDRESSES_RELEASE)
120
121
  const dataDir = options.data || defaultDataDir()
121
122
 
122
123
  // Heavy dep (devDependency — operator tooling), lazy-imported so loading the tools barrel stays cheap.
@@ -204,17 +204,17 @@ export async function evalOpenSet(
204
204
  */
205
205
  const inVec = (z: Float64Array): number[] => IN.map((c) => z[c]!)
206
206
 
207
- function load(file: string): Promise<DataRow[]> {
208
- return Array.fromAsync(JSONSpliterator.fromAsync<DataRow>(resolvePath(dataDir, file)))
207
+ function load(file: string) {
208
+ return JSONSpliterator.fromAsync<DataRow>(resolvePath(dataDir, file))
209
209
  }
210
210
 
211
211
  // Fit the Mahalanobis params on IN-MAP TRAIN logits (no test leak): per-class
212
212
  // mean in the nIn-dim in-map-logit space + a tied (shared) covariance.
213
213
  report?.("fitting Mahalanobis on in-map train logits…")
214
- const trainRows = await load("train.jsonl")
214
+ const trainRows = load("train.jsonl")
215
215
  const byClass = new Map<string, string[]>(COARSE_CLASSES.map((c): [string, string[]] => [c, []]))
216
216
 
217
- for (const r of trainRows) {
217
+ for await (const r of trainRows) {
218
218
  if (r.country === "OTHER") continue
219
219
  const arr = byClass.get(r.country)
220
220
 
@@ -361,10 +361,14 @@ export async function evalOpenSet(
361
361
  }
362
362
  }
363
363
 
364
- const inmapTest = (await load("test.jsonl")).filter((r) => r.country !== "OTHER") // the 11 countries only
364
+ // the 11 countries only
365
+ const inmapScored = await load("test.jsonl")
366
+ .filter((r) => r.country !== "OTHER")
367
+ .map((r) => scoreRow(r.raw, r.country))
368
+ .toArray()
369
+
365
370
  const heldout = (await readLatinOffmapRows<DataRow>(dataDir)).filter((r) => r.group === "heldout")
366
371
 
367
- const inmapScored = inmapTest.map((r) => scoreRow(r.raw, r.country))
368
372
  const heldoutScored = heldout.map((r) => scoreRow(r.raw, undefined))
369
373
 
370
374
  // Honest threshold protocol: split each probe 50/50 (deterministic by index parity) into DEV + TEST.
@@ -459,7 +463,7 @@ export async function evalOpenSet(
459
463
  const lines: string[] = [
460
464
  `# Coarse-placer M2 Phase 1 — post-hoc open-set score comparison (#244)`,
461
465
  "",
462
- `_Frozen shipped model (\`${basename(modelDir)}\`), NO retrain. In-map test ${inmapTest.length} rows ` +
466
+ `_Frozen shipped model (\`${basename(modelDir)}\`), NO retrain. In-map test ${inmapScored.length} rows ` +
463
467
  `(11 countries); off-map HELDOUT ${heldout.length} rows (never-trained families: baltic/oceania/middle-east). ` +
464
468
  `Mahalanobis fit on ≤${fitPerClass}/class in-map train logits. The 11-way routing is fixed; each score only ` +
465
469
  `changes the reject decision._`,
@@ -76,9 +76,10 @@ export async function evalQuantCompare(options: EvalQuantCompareOptions = {}): P
76
76
  const fp32 = await CoarsePlacer.fromArtifactDir(resolvePath(fp32Dir), { abstainBelow })
77
77
  const int8 = await CoarsePlacer.fromArtifactDir(resolvePath(int8Dir), { abstainBelow })
78
78
 
79
- const test = await Array.fromAsync(JSONSpliterator.fromAsync<TestRow>(resolvePath(dataDir, "test.jsonl")))
79
+ const test = await JSONSpliterator.fromAsync<TestRow>(resolvePath(dataDir, "test.jsonl")).toArray()
80
80
 
81
81
  const classes = (await readLocalJSONFile<CoarsePlacerMeta>(resolvePath(fp32Dir, "meta.json"))).classes
82
+
82
83
  let okF = 0
83
84
  let okI = 0
84
85
  let agree = 0
@@ -85,7 +85,7 @@ export async function evalCoarsePlacer(options: EvalCoarsePlacerOptions = {}): P
85
85
  const meta = await readLocalJSONFile<CoarsePlacerMeta>(resolvePath(modelDir, "meta.json"))
86
86
  const placer = await CoarsePlacer.fromArtifactDir(resolvePath(modelDir), { abstainBelow: abstain })
87
87
 
88
- // --- In-distribution test: accuracy + per-class + ECE ---
88
+ // Measure in-distribution accuracy, per-class results, and ECE.
89
89
  let testN = 0
90
90
  let correct = 0
91
91
  const perClass: Record<string, { n: number; ok: number }> = {} // country → {n, ok}
@@ -160,7 +160,7 @@ export async function evalCoarsePlacer(options: EvalCoarsePlacerOptions = {}): P
160
160
  console.log(confLines.toSorted().join("\n"))
161
161
  }
162
162
 
163
- // --- Abstention on the multi-script set (off-map scripts should abstain) ---
163
+ // Measure abstention for multi-script inputs outside the map.
164
164
  const msPath = repoRootPath("data", "eval", "multi-script", "v0.5.0-a0.jsonl")
165
165
 
166
166
  try {
@@ -11,14 +11,14 @@
11
11
  * `fnv-hash.ts` lives at the coarse-placer root because `featurize` hashes through it.
12
12
  */
13
13
 
14
- export * from "#coarse-placer/tools/build-dataset"
15
- export * from "#coarse-placer/tools/build-outlier-exposure"
16
- export * from "#coarse-placer/tools/build-outlier-latin"
17
- export * from "#coarse-placer/tools/build-outlier-oa"
14
+ export * from "#coarse-placer/tools/build/dataset"
15
+ export * from "#coarse-placer/tools/build/outlier/exposure"
16
+ export * from "#coarse-placer/tools/build/outlier/latin"
17
+ export * from "#coarse-placer/tools/build/outlier/oa"
18
18
  export * from "#coarse-placer/tools/eval"
19
- export * from "#coarse-placer/tools/eval-latin-offmap"
20
- export * from "#coarse-placer/tools/eval-openset"
21
- export * from "#coarse-placer/tools/eval-quant-compare"
19
+ export * from "#coarse-placer/tools/eval/latin-offmap"
20
+ export * from "#coarse-placer/tools/eval/openset"
21
+ export * from "#coarse-placer/tools/eval/quant-compare"
22
22
  export * from "#coarse-placer/tools/probe-frontier"
23
23
  export * from "#coarse-placer/tools/quantize"
24
24
  export * from "#coarse-placer/tools/train"
@@ -95,14 +95,12 @@ export async function trainCoarsePlacer(
95
95
  const classIdx = new Map<string, number>(COARSE_CLASSES.map((c, i): [string, number] => [c, i]))
96
96
 
97
97
  async function load(split: string): Promise<Sample[]> {
98
- const rows = await Array.fromAsync(
99
- JSONSpliterator.fromAsync<{ raw: string; country: string }>(resolvePath(dataDir, `${split}.jsonl`))
100
- )
101
-
102
98
  // Precompute features once: Int32Array of active indices + label id per row.
103
99
  const out: Sample[] = []
104
100
 
105
- for (const r of rows) {
101
+ for await (const r of JSONSpliterator.fromAsync<{ raw: string; country: string }>(
102
+ resolvePath(dataDir, `${split}.jsonl`)
103
+ )) {
106
104
  const y = classIdx.get(r.country)
107
105
 
108
106
  if (y === undefined) continue
@@ -199,7 +197,7 @@ export async function trainCoarsePlacer(
199
197
  )
200
198
  }
201
199
 
202
- // --- Temperature calibration: minimize val NLL over T by coarse-then-fine 1-D search. ---
200
+ // Calibrate temperature by minimizing validation NLL through coarse and fine one-dimensional search.
203
201
  function valNLL(T: number): number {
204
202
  let nll = 0
205
203
 
@@ -23,10 +23,11 @@
23
23
  * exposes as attributes.
24
24
  */
25
25
 
26
+ import type { BIOLabel, ComponentTag } from "@mailwoman/codex/component"
27
+
26
28
  import type { Calibrator } from "#decoder/calibration"
27
29
  import { containmentFor } from "#decoder/containment"
28
30
  import type { AddressNode, AddressSystem, AddressTree, DecoderToken } from "#decoder/types"
29
- import type { BIOLabel, ComponentTag } from "#types/component"
30
31
 
31
32
  /**
32
33
  * Optional caller-supplied attribution stamped on every emitted node. The BIO stream comes from a single model, so
@@ -28,8 +28,9 @@
28
28
  * call-site churn. See `AddressSystem` in `./types.ts`.
29
29
  */
30
30
 
31
+ import type { ComponentTag } from "@mailwoman/codex/component"
32
+
31
33
  import type { AddressSystem } from "#decoder/types"
32
- import type { ComponentTag } from "#types/component"
33
34
 
34
35
  /**
35
36
  * Preferred-parent ordering for each tag. Empty / missing = always root.
@@ -9,11 +9,11 @@ export * from "#decoder/calibration"
9
9
  export * from "#decoder/containment"
10
10
  export * from "#decoder/proposals-to-tree"
11
11
  export * from "#decoder/resolve-proposal-overlaps"
12
- export * from "#decoder/serialize-json"
13
- export * from "#decoder/tree-shape"
14
- export * from "#decoder/tree-walk"
15
- export * from "#decoder/serialize-tuples"
16
- export * from "#decoder/serialize-xml"
12
+ export * from "#decoder/serialize/json"
13
+ export * from "#decoder/tree/shape"
14
+ export * from "#decoder/tree/walk"
15
+ export * from "#decoder/serialize/tuples"
16
+ export * from "#decoder/serialize/xml"
17
17
  export * from "#decoder/types"
18
18
  export * from "#decoder/unknown-spans"
19
19
  export * from "#decoder/validate-tree"
@@ -27,7 +27,7 @@
27
27
  * its answer but lost 0.3 of confidence on the deciding span is a row about to flip, and an aggregate cannot say so.
28
28
  */
29
29
 
30
- import { flattenTreeNodes } from "#decoder/tree-shape"
30
+ import { flattenTreeNodes } from "#decoder/tree/shape"
31
31
  import type { AddressTree } from "#decoder/types"
32
32
 
33
33
  /**
@@ -14,9 +14,11 @@
14
14
  * pipeline.
15
15
  */
16
16
 
17
+ import type { ComponentTag } from "@mailwoman/codex/component"
18
+
17
19
  import type { AddressNode, AddressTree } from "#decoder/types"
18
20
  import type { Span } from "#tokenization/index"
19
- import type { ClassificationProposal, ClassificationProposalSource, ComponentTag } from "#types/index"
21
+ import type { ClassificationProposal, ClassificationProposalSource } from "#types/index"
20
22
 
21
23
  export function proposalsToTree(raw: string, proposals: readonly ClassificationProposal[]): AddressTree {
22
24
  const roots: AddressNode[] = proposals.map((p) => ({
@@ -13,10 +13,11 @@
13
13
  * city-state. The shared span means every role gets the same `value`.
14
14
  */
15
15
 
16
- import { slotNodes } from "#decoder/tree-walk"
16
+ import type { ComponentTag } from "@mailwoman/codex/component"
17
+
18
+ import { slotNodes } from "#decoder/tree/walk"
17
19
  import type { AddressNode, AddressTree } from "#decoder/types"
18
20
  import { type UnknownSpan, unknownSpans } from "#decoder/unknown-spans"
19
- import type { ComponentTag } from "#types/component"
20
21
 
21
22
  /**
22
23
  * A span the flat projection could not represent, and why.
@@ -10,9 +10,10 @@
10
10
  * use `decodeAsXML` when containment matters.
11
11
  */
12
12
 
13
+ import type { ComponentTag } from "@mailwoman/codex/component"
14
+
13
15
  import type { AddressNode, AddressTree } from "#decoder/types"
14
16
  import { unknownSpans } from "#decoder/unknown-spans"
15
- import type { ComponentTag } from "#types/component"
16
17
 
17
18
  /**
18
19
  * Options for {@link decodeAsTuples}.
@@ -16,10 +16,11 @@
16
16
  * and both behaviors are pinned by their consumers' boards.
17
17
  */
18
18
 
19
- import { flatten } from "#decoder/serialize-tuples"
20
- import { walkNodes } from "#decoder/tree-walk"
19
+ import type { ComponentTag } from "@mailwoman/codex/component"
20
+
21
+ import { flatten } from "#decoder/serialize/tuples"
22
+ import { walkNodes } from "#decoder/tree/walk"
21
23
  import type { AddressNode, AddressTree } from "#decoder/types"
22
- import type { ComponentTag } from "#types/component"
23
24
 
24
25
  /**
25
26
  * True when every node in the tree either carries `tag` or bears no value — i.e. the only EVIDENCE in the parse is
@@ -93,10 +94,9 @@ export interface FlatTreeNode {
93
94
  /**
94
95
  * Flatten a tree to its nodes in SOURCE order — sorted by `start`, the same order `decodeAsTuples` means by it.
95
96
  *
96
- * The two copies this replaces (the demo's `demo-helpers.ts` and the `demo-cascade-smoke` mirror of it) relied on
97
- * TRAVERSAL order instead: depth-first onto a stack, then reversed. That coincides with source order only while every
98
- * parent's span precedes its children's, and the decoder does not promise it — measured, the two orders disagree on **7
99
- * of 10** ordinary addresses, always with a child ahead of its parent:
97
+ * A traversal-order walk (depth-first onto a stack, then reversed) is the obvious implementation and is wrong here: it
98
+ * coincides with source order only while every parent's span precedes its children's, and the decoder does not promise
99
+ * it — measured, the two orders disagree on **7 of 10** ordinary addresses, always with a child ahead of its parent:
100
100
  *
101
101
  * Queen Street, Bristol street_suffix@6 before street@0
102
102
  * Via Roma, 5, 50123 Firenze, … house_number@10 before street@0
@@ -104,9 +104,6 @@ export interface FlatTreeNode {
104
104
  *
105
105
  * Sorting is what the tuple projection already does, so this makes a rendered span list and `decodeAsTuples` agree by
106
106
  * construction rather than by luck.
107
- *
108
- * The smoke test could not import the demo's copy (that would be a `mailwoman` → `docs` project reference, and `docs`
109
- * already depends on `mailwoman`), which is why a third home was the only way to collapse them.
110
107
  */
111
108
  export function flattenTreeNodes(tree?: AddressTree | null): FlatTreeNode[] {
112
109
  if (!tree) return []
@@ -26,9 +26,7 @@
26
26
  * essential.
27
27
  */
28
28
 
29
- import type { BIOLabel, ComponentTag } from "#types/component"
30
-
31
- export { type BIOLabel, type ComponentTag } from "#types/component"
29
+ import type { BIOLabel, ComponentTag } from "@mailwoman/codex/component"
32
30
 
33
31
  /**
34
32
  * A single token emitted by the model, paired with its predicted label and confidence.
@@ -12,7 +12,7 @@
12
12
  * It mutates nothing and changes no serializer — wiring `unknown` into the JSON/XML/tuple contracts + the
13
13
  * demo is the focused follow-up (#493). Byte-stable by construction, so it ships ahead of that work.
14
14
  */
15
- import { walkNodes } from "#decoder/tree-walk"
15
+ import { walkNodes } from "#decoder/tree/walk"
16
16
  import type { AddressTree } from "#decoder/types"
17
17
 
18
18
  export interface UnknownSpan {
@@ -23,9 +23,10 @@
23
23
  * postcode-only or city-only input is a degenerate-but-valid parse, not a violation.
24
24
  */
25
25
 
26
+ import type { ComponentTag } from "@mailwoman/codex/component"
27
+
26
28
  import { containmentFor } from "#decoder/containment"
27
29
  import type { AddressNode, AddressTree } from "#decoder/types"
28
- import type { ComponentTag } from "#types/component"
29
30
 
30
31
  /**
31
32
  * Tags that cannot stand alone: each is a sub-component of a specific structural anchor (street / locality / venue /
@@ -0,0 +1,244 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @file Filesystem metadata readers.
5
+ */
6
+
7
+ import { AssertionError } from "node:assert"
8
+ import type { Dirent, Mode, Stats } from "node:fs"
9
+ import {
10
+ open as openNative,
11
+ access,
12
+ constants,
13
+ lstat,
14
+ readlink,
15
+ realpath,
16
+ stat,
17
+ type FileHandle,
18
+ } from "node:fs/promises"
19
+
20
+ import { type PathBuilderLike, resolvePath } from "path-ts"
21
+
22
+ import { ByteFormatter, type ByteFormatterOptions } from "#fs/formatters"
23
+
24
+ // #region Stat utils
25
+
26
+ /**
27
+ * Attempts to stat a file or directory.
28
+ *
29
+ * A `URL` is passed through rather than stringified: `node:fs` accepts a `file:` URL object, and rejects the string it
30
+ * prints — `stat("file:///etc/hostname")` is ENOENT, which this function reports as absence. Every caller that looks a
31
+ * file up by URL therefore read "not there" for everything, and `cli-native/command-router.ts` answered `Unknown
32
+ * command` for every command it has.
33
+ *
34
+ * @throws If the path exists but cannot be statted for some reason other than non-existence.
35
+ */
36
+ export function tryStat(pathBuilderLike: PathBuilderLike | URL): Promise<Stats | null> {
37
+ const target = pathBuilderLike instanceof URL ? pathBuilderLike : pathBuilderLike.toString()
38
+
39
+ return stat(target).catch((error) => {
40
+ if (error.code === "ENOENT") return null
41
+
42
+ throw error
43
+ })
44
+ }
45
+
46
+ /**
47
+ * Stat a file or directory, raising ENOENT when nothing is there.
48
+ *
49
+ * The throwing counterpart to {@linkcode tryStat}. Reach for this one where absence is a defect the caller wants
50
+ * reported, and for {@linkcode tryStat} where absence is an answer.
51
+ */
52
+ export function statPath(path: PathBuilderLike | URL): Promise<Stats> {
53
+ return stat(path instanceof URL ? path : path.toString())
54
+ }
55
+
56
+ /**
57
+ * Stat a path without following a symbolic link, so the answer describes the link itself.
58
+ */
59
+ export function statLink(path: PathBuilderLike | URL): Promise<Stats> {
60
+ return lstat(path instanceof URL ? path : path.toString())
61
+ }
62
+
63
+ /**
64
+ * Stat a path without following a symbolic link, answering `null` when nothing is there.
65
+ *
66
+ * The link-level counterpart to {@linkcode tryStat}.
67
+ */
68
+ export function tryStatLink(path: PathBuilderLike | URL): Promise<Stats | null> {
69
+ return lstat(path instanceof URL ? path : path.toString()).catch((error) => {
70
+ if (error.code === "ENOENT") return null
71
+
72
+ throw error
73
+ })
74
+ }
75
+
76
+ /**
77
+ * Whether a path exists, whatever it is.
78
+ *
79
+ * The asynchronous answer to `existsSync`, which is the single most-called synchronous builtin in the repository.
80
+ * Prefer {@linkcode isFile} or {@linkcode isDirectory} where the caller goes on to assume one or the other: a directory
81
+ * where a file was expected passes this check and fails the next line.
82
+ */
83
+ export function pathExists(path: PathBuilderLike | URL): Promise<boolean> {
84
+ return tryStat(path).then((stats) => stats !== null)
85
+ }
86
+
87
+ /**
88
+ * Assert that a path exists, throwing an error if it does not.
89
+ */
90
+ export function assertPathExists(path: PathBuilderLike | URL, message?: string): Promise<void> {
91
+ return pathExists(path).then((exists) => {
92
+ if (exists) return void 0
93
+
94
+ throw new AssertionError({
95
+ message: message ?? `Expected path to exist`,
96
+ expected: path.toString(),
97
+ actual: "not found",
98
+ })
99
+ })
100
+ }
101
+
102
+ /**
103
+ * Whether a path exists and is a directory.
104
+ */
105
+ export function isDirectory(path: PathBuilderLike | URL): Promise<boolean> {
106
+ return tryStat(path).then((stats) => stats?.isDirectory() ?? false)
107
+ }
108
+
109
+ /**
110
+ * Assert that a path exists and is a directory, throwing an error if it does not.
111
+ *
112
+ * @category Files
113
+ * @throws AssertionError if the path does not exist or is not a directory.
114
+ * @runtime node
115
+ */
116
+ export function assertIsDirectory(path: PathBuilderLike | URL, message?: string): Promise<void> {
117
+ return statPath(path).then((stats) => {
118
+ if (stats.isDirectory()) {
119
+ return void 0
120
+ }
121
+
122
+ throw new AssertionError({
123
+ message: message ?? `Expected path to be a directory`,
124
+ expected: path.toString(),
125
+ actual: "not a directory",
126
+ })
127
+ })
128
+ }
129
+
130
+ /**
131
+ * Whether a path exists and is a file.
132
+ */
133
+ export function isFile(path: PathBuilderLike | URL): Promise<boolean> {
134
+ return tryStat(path).then((stats) => stats?.isFile() ?? false)
135
+ }
136
+
137
+ /**
138
+ * Whether a path exists and is a symbolic link.
139
+ */
140
+ export function isSymbolicLink(path: PathBuilderLike | URL): Promise<boolean> {
141
+ return tryStatLink(path).then((stats) => stats?.isSymbolicLink() ?? false)
142
+ }
143
+
144
+ /**
145
+ * Whether a directory entry leads to a directory, symbolic links included.
146
+ *
147
+ * `Dirent.isDirectory()` is FALSE for a symbolic link to a directory, so a walk keyed on it alone skips every linked
148
+ * tree. A glob only descends into them when its `followSymlinks` option is `true`; a caller that walks links must use
149
+ * this helper so both traversals describe the same tree. A link is resolved through `stat`, which also answers `false`
150
+ * for a dangling one.
151
+ */
152
+ export function entryLeadsToDirectory(entry: Dirent): Promise<boolean> {
153
+ if (entry.isDirectory()) return Promise.resolve(true)
154
+
155
+ if (!entry.isSymbolicLink()) return Promise.resolve(false)
156
+
157
+ return isDirectory(resolvePath(entry.parentPath, entry.name))
158
+ }
159
+
160
+ /**
161
+ * The size of a file in bytes.
162
+ *
163
+ * @throws ENOENT when the file does not exist.
164
+ */
165
+ export function readFileSize(path: PathBuilderLike | URL): Promise<number> {
166
+ return statPath(path).then((stats) => stats.size)
167
+ }
168
+
169
+ /**
170
+ * The size of a file, rendered in IEC units (`12.3 MiB`) — the unit for anything a machine measured.
171
+ *
172
+ * @throws ENOENT when the file does not exist.
173
+ */
174
+ export async function formatFileSize(path: PathBuilderLike | URL, options?: ByteFormatterOptions): Promise<string> {
175
+ return ByteFormatter.formatIEC(await readFileSize(path), options)
176
+ }
177
+
178
+ /**
179
+ * Resolve a path to its canonical location, following every symbolic link.
180
+ *
181
+ * @throws ENOENT when nothing is there. {@linkcode tryRealPath} answers `null` instead.
182
+ */
183
+ export function realPath(path: PathBuilderLike): Promise<string> {
184
+ return realpath(path.toString())
185
+ }
186
+
187
+ /**
188
+ * Resolve a path to its canonical location, following every symbolic link.
189
+ *
190
+ * @returns The canonical path, or `null` when nothing is there.
191
+ */
192
+ export function tryRealPath(path: PathBuilderLike): Promise<string | null> {
193
+ return realpath(path.toString()).catch((error) => {
194
+ if (error.code === "ENOENT") return null
195
+
196
+ throw error
197
+ })
198
+ }
199
+
200
+ export function open(path: PathBuilderLike | URL, flags?: string | number, mode?: Mode): Promise<FileHandle> {
201
+ return openNative(path instanceof URL ? path : path.toString(), flags, mode)
202
+ }
203
+
204
+ /**
205
+ * The target a symbolic link points at, verbatim — relative if it was written relative.
206
+ *
207
+ * @throws EINVAL when the path is not a link, ENOENT when nothing is there.
208
+ */
209
+ export function readLink(path: PathBuilderLike): Promise<string> {
210
+ return readlink(path.toString())
211
+ }
212
+
213
+ /**
214
+ * Whether the process may WRITE to a path.
215
+ *
216
+ * A permission question, not an existence one: `access` answers about the caller's credentials against the file as it
217
+ * stands, where a stat answers about the file. Absence reads as `false` here, which is what a caller checking "can I
218
+ * write here" means by it.
219
+ */
220
+ export function isWritable(path: PathBuilderLike): Promise<boolean> {
221
+ return access(path.toString(), constants.W_OK).then(
222
+ () => true,
223
+ () => false
224
+ )
225
+ }
226
+
227
+ /**
228
+ * Whether the process may EXECUTE a path.
229
+ */
230
+ export function isExecutable(path: PathBuilderLike): Promise<boolean> {
231
+ return access(path.toString(), constants.X_OK).then(
232
+ () => true,
233
+ () => false
234
+ )
235
+ }
236
+
237
+ /**
238
+ * A `file:` URL is passed through whole: `node:fs` accepts the object and rejects the string it prints.
239
+ */
240
+ export function asTarget(path: PathBuilderLike | URL): URL | string {
241
+ return path instanceof URL ? path : path.toString()
242
+ }
243
+
244
+ // #endregion