@mailwoman/core 9.0.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/README.md +1 -1
  2. package/api/responses.ts +12 -0
  3. package/coarse-placer/featurize.ts +0 -2
  4. package/coarse-placer/tools/build-dataset.ts +2 -2
  5. package/coarse-placer/tools/build-outlier-exposure.ts +2 -2
  6. package/coarse-placer/tools/build-outlier-latin.ts +14 -8
  7. package/coarse-placer/tools/build-outlier-oa.ts +12 -6
  8. package/coarse-placer/tools/eval-latin-offmap.ts +3 -4
  9. package/coarse-placer/tools/eval-openset.ts +3 -3
  10. package/coarse-placer/tools/eval-quant-compare.ts +3 -3
  11. package/coarse-placer/tools/eval.ts +3 -3
  12. package/coarse-placer/tools/fnv-hash.ts +1 -6
  13. package/coarse-placer/tools/index.ts +1 -1
  14. package/coarse-placer/tools/probe-frontier.ts +3 -4
  15. package/coarse-placer/tools/quantize.ts +3 -2
  16. package/coarse-placer/tools/train.ts +2 -2
  17. package/crypto/node.ts +3 -1
  18. package/data/internal/dictionaries/languages.csv +184 -184
  19. package/data/libpostal/README.md +8 -2
  20. package/db/schema.ts +12 -3
  21. package/decoder/build-tree.ts +19 -0
  22. package/decoder/containment.ts +5 -1
  23. package/decoder/index.ts +1 -0
  24. package/decoder/parse-diff.ts +347 -0
  25. package/decoder/proposals-to-tree.ts +1 -1
  26. package/decoder/serialize-json.ts +51 -7
  27. package/decoder/serialize-tuples.ts +7 -1
  28. package/decoder/serialize-xml.ts +1 -1
  29. package/decoder/tree-shape.ts +144 -0
  30. package/decoder/types.ts +8 -0
  31. package/decoder/validate-tree.ts +15 -3
  32. package/env/index.ts +3 -1
  33. package/env/paths.ts +21 -33
  34. package/env/schema.ts +35 -3
  35. package/fs/utils/formatters.ts +107 -0
  36. package/fs/utils/index.ts +7 -0
  37. package/fs/zip.ts +297 -0
  38. package/layers/manifest.ts +56 -15
  39. package/layers/schema.ts +54 -2
  40. package/locale/locale.ts +1 -1
  41. package/locale/registry.ts +1 -1
  42. package/objects.ts +20 -8
  43. package/out/api/responses.d.ts +9 -0
  44. package/out/api/responses.d.ts.map +1 -1
  45. package/out/api/responses.js +11 -0
  46. package/out/api/responses.js.map +1 -1
  47. package/out/coarse-placer/featurize.d.ts +0 -1
  48. package/out/coarse-placer/featurize.d.ts.map +1 -1
  49. package/out/coarse-placer/featurize.js.map +1 -1
  50. package/out/coarse-placer/tools/build-dataset.js +1 -2
  51. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  52. package/out/coarse-placer/tools/build-outlier-exposure.js +1 -2
  53. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  54. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  55. package/out/coarse-placer/tools/build-outlier-latin.js +12 -8
  56. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  57. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  58. package/out/coarse-placer/tools/build-outlier-oa.js +10 -6
  59. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  60. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  61. package/out/coarse-placer/tools/eval-latin-offmap.js +2 -4
  62. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  63. package/out/coarse-placer/tools/eval-openset.js +2 -3
  64. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  65. package/out/coarse-placer/tools/eval-quant-compare.js +2 -3
  66. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  67. package/out/coarse-placer/tools/eval.js +2 -3
  68. package/out/coarse-placer/tools/eval.js.map +1 -1
  69. package/out/coarse-placer/tools/fnv-hash.d.ts +1 -6
  70. package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
  71. package/out/coarse-placer/tools/fnv-hash.js +1 -6
  72. package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
  73. package/out/coarse-placer/tools/index.d.ts +1 -1
  74. package/out/coarse-placer/tools/index.js +1 -1
  75. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  76. package/out/coarse-placer/tools/probe-frontier.js +2 -4
  77. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  78. package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
  79. package/out/coarse-placer/tools/quantize.js +2 -2
  80. package/out/coarse-placer/tools/quantize.js.map +1 -1
  81. package/out/coarse-placer/tools/train.js +1 -2
  82. package/out/coarse-placer/tools/train.js.map +1 -1
  83. package/out/crypto/node.d.ts.map +1 -1
  84. package/out/crypto/node.js +2 -1
  85. package/out/crypto/node.js.map +1 -1
  86. package/out/db/schema.d.ts +12 -3
  87. package/out/db/schema.d.ts.map +1 -1
  88. package/out/db/schema.js +6 -0
  89. package/out/db/schema.js.map +1 -1
  90. package/out/decoder/build-tree.d.ts.map +1 -1
  91. package/out/decoder/build-tree.js +17 -0
  92. package/out/decoder/build-tree.js.map +1 -1
  93. package/out/decoder/containment.d.ts.map +1 -1
  94. package/out/decoder/containment.js +5 -1
  95. package/out/decoder/containment.js.map +1 -1
  96. package/out/decoder/index.d.ts +1 -0
  97. package/out/decoder/index.d.ts.map +1 -1
  98. package/out/decoder/index.js +1 -0
  99. package/out/decoder/index.js.map +1 -1
  100. package/out/decoder/parse-diff.d.ts +125 -0
  101. package/out/decoder/parse-diff.d.ts.map +1 -0
  102. package/out/decoder/parse-diff.js +219 -0
  103. package/out/decoder/parse-diff.js.map +1 -0
  104. package/out/decoder/proposals-to-tree.js.map +1 -1
  105. package/out/decoder/serialize-json.d.ts +29 -0
  106. package/out/decoder/serialize-json.d.ts.map +1 -1
  107. package/out/decoder/serialize-json.js +20 -4
  108. package/out/decoder/serialize-json.js.map +1 -1
  109. package/out/decoder/serialize-tuples.d.ts +8 -1
  110. package/out/decoder/serialize-tuples.d.ts.map +1 -1
  111. package/out/decoder/serialize-tuples.js +7 -1
  112. package/out/decoder/serialize-tuples.js.map +1 -1
  113. package/out/decoder/serialize-xml.js +1 -1
  114. package/out/decoder/serialize-xml.js.map +1 -1
  115. package/out/decoder/tree-shape.d.ts +84 -0
  116. package/out/decoder/tree-shape.d.ts.map +1 -0
  117. package/out/decoder/tree-shape.js +98 -0
  118. package/out/decoder/tree-shape.js.map +1 -0
  119. package/out/decoder/types.d.ts +11 -0
  120. package/out/decoder/types.d.ts.map +1 -1
  121. package/out/decoder/validate-tree.d.ts +8 -0
  122. package/out/decoder/validate-tree.d.ts.map +1 -1
  123. package/out/decoder/validate-tree.js +4 -3
  124. package/out/decoder/validate-tree.js.map +1 -1
  125. package/out/env/index.d.ts +13 -1
  126. package/out/env/index.d.ts.map +1 -1
  127. package/out/env/index.js +2 -1
  128. package/out/env/index.js.map +1 -1
  129. package/out/env/paths.d.ts +15 -8
  130. package/out/env/paths.d.ts.map +1 -1
  131. package/out/env/paths.js +19 -29
  132. package/out/env/paths.js.map +1 -1
  133. package/out/env/schema.d.ts +12 -1
  134. package/out/env/schema.d.ts.map +1 -1
  135. package/out/env/schema.js +33 -3
  136. package/out/env/schema.js.map +1 -1
  137. package/out/fs/utils/formatters.d.ts +57 -0
  138. package/out/fs/utils/formatters.d.ts.map +1 -0
  139. package/out/fs/utils/formatters.js +79 -0
  140. package/out/fs/utils/formatters.js.map +1 -0
  141. package/out/fs/utils/index.d.ts +7 -0
  142. package/out/fs/utils/index.d.ts.map +1 -0
  143. package/out/fs/utils/index.js +7 -0
  144. package/out/fs/utils/index.js.map +1 -0
  145. package/out/fs/zip.d.ts +116 -0
  146. package/out/fs/zip.d.ts.map +1 -0
  147. package/out/fs/zip.js +216 -0
  148. package/out/fs/zip.js.map +1 -0
  149. package/out/layers/manifest.d.ts +32 -7
  150. package/out/layers/manifest.d.ts.map +1 -1
  151. package/out/layers/manifest.js +31 -6
  152. package/out/layers/manifest.js.map +1 -1
  153. package/out/layers/schema.d.ts +48 -2
  154. package/out/layers/schema.d.ts.map +1 -1
  155. package/out/layers/schema.js +32 -0
  156. package/out/layers/schema.js.map +1 -1
  157. package/out/locale/locale.d.ts +1 -1
  158. package/out/locale/locale.d.ts.map +1 -1
  159. package/out/locale/registry.js +1 -1
  160. package/out/locale/registry.js.map +1 -1
  161. package/out/objects.d.ts +12 -6
  162. package/out/objects.d.ts.map +1 -1
  163. package/out/objects.js +4 -1
  164. package/out/objects.js.map +1 -1
  165. package/out/pipeline/index.d.ts +3 -7
  166. package/out/pipeline/index.d.ts.map +1 -1
  167. package/out/pipeline/index.js +2 -4
  168. package/out/pipeline/index.js.map +1 -1
  169. package/out/pipeline/runtime-pipeline.d.ts +51 -9
  170. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  171. package/out/pipeline/runtime-pipeline.js +46 -133
  172. package/out/pipeline/runtime-pipeline.js.map +1 -1
  173. package/out/pipeline/span-proposer.js +1 -1
  174. package/out/pipeline/span-proposer.js.map +1 -1
  175. package/out/pipeline/types.d.ts +137 -16
  176. package/out/pipeline/types.d.ts.map +1 -1
  177. package/out/pipeline/types.js +30 -0
  178. package/out/pipeline/types.js.map +1 -1
  179. package/out/policy/defaults.d.ts +1 -1
  180. package/out/policy/defaults.d.ts.map +1 -1
  181. package/out/policy/defaults.js +1 -1
  182. package/out/policy/defaults.js.map +1 -1
  183. package/out/policy/policy.d.ts +1 -1
  184. package/out/policy/policy.d.ts.map +1 -1
  185. package/out/policy/registry.d.ts +1 -1
  186. package/out/policy/registry.d.ts.map +1 -1
  187. package/out/resolver/coverage-facts.d.ts +89 -0
  188. package/out/resolver/coverage-facts.d.ts.map +1 -0
  189. package/out/resolver/coverage-facts.js +22 -0
  190. package/out/resolver/coverage-facts.js.map +1 -0
  191. package/out/resolver/index.d.ts +4 -1
  192. package/out/resolver/index.d.ts.map +1 -1
  193. package/out/resolver/index.js +2 -0
  194. package/out/resolver/index.js.map +1 -1
  195. package/out/resolver/lookup-types.d.ts +178 -0
  196. package/out/resolver/lookup-types.d.ts.map +1 -0
  197. package/out/resolver/lookup-types.js +11 -0
  198. package/out/resolver/lookup-types.js.map +1 -0
  199. package/out/resolver/placetype-map.d.ts +71 -0
  200. package/out/resolver/placetype-map.d.ts.map +1 -0
  201. package/out/resolver/placetype-map.js +98 -0
  202. package/out/resolver/placetype-map.js.map +1 -0
  203. package/out/resolver/postcode-format.d.ts +38 -0
  204. package/out/resolver/postcode-format.d.ts.map +1 -0
  205. package/out/resolver/postcode-format.js +83 -0
  206. package/out/resolver/postcode-format.js.map +1 -0
  207. package/out/resolver/referential.d.ts +73 -0
  208. package/out/resolver/referential.d.ts.map +1 -0
  209. package/out/resolver/referential.js +71 -0
  210. package/out/resolver/referential.js.map +1 -0
  211. package/out/resolver/types.d.ts +401 -264
  212. package/out/resolver/types.d.ts.map +1 -1
  213. package/out/resolver/types.js +4 -97
  214. package/out/resolver/types.js.map +1 -1
  215. package/out/resources/git.d.ts +8 -1
  216. package/out/resources/git.d.ts.map +1 -1
  217. package/out/resources/git.js +4 -3
  218. package/out/resources/git.js.map +1 -1
  219. package/out/resources/languages/types.gen.d.ts +1 -1
  220. package/out/resources/languages/types.gen.d.ts.map +1 -1
  221. package/out/resources/languages/types.gen.js +40 -0
  222. package/out/resources/languages/types.gen.js.map +1 -1
  223. package/out/resources/libpostal.d.ts +2 -2
  224. package/out/resources/libpostal.d.ts.map +1 -1
  225. package/out/resources/libpostal.js +2 -2
  226. package/out/resources/libpostal.js.map +1 -1
  227. package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
  228. package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
  229. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
  230. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  231. package/out/resources/whosonfirst/PlacetypeDataSource.js +28 -3
  232. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  233. package/out/resources/whosonfirst/loader.d.ts +2 -2
  234. package/out/resources/whosonfirst/loader.d.ts.map +1 -1
  235. package/out/resources/whosonfirst/loader.js.map +1 -1
  236. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  237. package/out/resources/whosonfirst/placetypes/Placetype.js +1 -1
  238. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  239. package/out/resources/whosonfirst/placetypes/admin.d.ts +9 -1
  240. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  241. package/out/resources/whosonfirst/placetypes/admin.js +1 -1
  242. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  243. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  244. package/out/resources/whosonfirst/placetypes/definition.js +1 -1
  245. package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
  246. package/out/resources/whosonfirst/placetypes/index.d.ts +1 -0
  247. package/out/resources/whosonfirst/placetypes/index.d.ts.map +1 -1
  248. package/out/resources/whosonfirst/placetypes/index.js +1 -0
  249. package/out/resources/whosonfirst/placetypes/index.js.map +1 -1
  250. package/out/resources/whosonfirst/placetypes/specificity.d.ts +65 -0
  251. package/out/resources/whosonfirst/placetypes/specificity.d.ts.map +1 -0
  252. package/out/resources/whosonfirst/placetypes/specificity.js +101 -0
  253. package/out/resources/whosonfirst/placetypes/specificity.js.map +1 -0
  254. package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
  255. package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -1
  256. package/out/resources/whosonfirst/sharded-repo.js +46 -2
  257. package/out/resources/whosonfirst/sharded-repo.js.map +1 -1
  258. package/out/scripting/arguments.d.ts +27 -0
  259. package/out/scripting/arguments.d.ts.map +1 -0
  260. package/out/scripting/arguments.js +32 -0
  261. package/out/scripting/arguments.js.map +1 -0
  262. package/out/scripting/command.d.ts +28 -0
  263. package/out/scripting/command.d.ts.map +1 -0
  264. package/out/scripting/command.js +47 -0
  265. package/out/scripting/command.js.map +1 -0
  266. package/out/scripting/index.js +3 -3
  267. package/out/scripting/index.js.map +1 -1
  268. package/out/scripting/utils/index.d.ts +1 -12
  269. package/out/scripting/utils/index.d.ts.map +1 -1
  270. package/out/scripting/utils/index.js +4 -21
  271. package/out/scripting/utils/index.js.map +1 -1
  272. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  273. package/out/tools/download-libpostal-resources.js +4 -7
  274. package/out/tools/download-libpostal-resources.js.map +1 -1
  275. package/out/tools/download-ssl-address.d.ts +3 -3
  276. package/out/tools/download-ssl-address.d.ts.map +1 -1
  277. package/out/tools/download-ssl-address.js +26 -13
  278. package/out/tools/download-ssl-address.js.map +1 -1
  279. package/out/tools/generate-language-types.d.ts +16 -1
  280. package/out/tools/generate-language-types.d.ts.map +1 -1
  281. package/out/tools/generate-language-types.js +38 -5
  282. package/out/tools/generate-language-types.js.map +1 -1
  283. package/out/tools/index.d.ts +1 -2
  284. package/out/tools/index.d.ts.map +1 -1
  285. package/out/tools/index.js +1 -2
  286. package/out/tools/index.js.map +1 -1
  287. package/out/utils/data-root.d.ts +27 -7
  288. package/out/utils/data-root.d.ts.map +1 -1
  289. package/out/utils/data-root.js +36 -13
  290. package/out/utils/data-root.js.map +1 -1
  291. package/out/utils/hash.d.ts +2 -3
  292. package/out/utils/hash.d.ts.map +1 -1
  293. package/out/utils/hash.js +3 -3
  294. package/out/utils/hash.js.map +1 -1
  295. package/out/utils/index.d.ts +1 -0
  296. package/out/utils/index.d.ts.map +1 -1
  297. package/out/utils/index.js +1 -0
  298. package/out/utils/index.js.map +1 -1
  299. package/out/utils/jsonl.js +1 -1
  300. package/out/utils/jsonl.js.map +1 -1
  301. package/out/utils/repo.d.ts +8 -0
  302. package/out/utils/repo.d.ts.map +1 -1
  303. package/out/utils/repo.js +10 -1
  304. package/out/utils/repo.js.map +1 -1
  305. package/out/utils/sealed-db.d.ts +11 -0
  306. package/out/utils/sealed-db.d.ts.map +1 -1
  307. package/out/utils/sealed-db.js +28 -1
  308. package/out/utils/sealed-db.js.map +1 -1
  309. package/out/utils/sqlite-rows.d.ts +34 -0
  310. package/out/utils/sqlite-rows.d.ts.map +1 -0
  311. package/out/utils/sqlite-rows.js +37 -0
  312. package/out/utils/sqlite-rows.js.map +1 -0
  313. package/out/utils/stats.d.ts +1 -6
  314. package/out/utils/stats.d.ts.map +1 -1
  315. package/out/utils/stats.js +1 -6
  316. package/out/utils/stats.js.map +1 -1
  317. package/package.json +488 -8
  318. package/pipeline/index.ts +14 -15
  319. package/pipeline/runtime-pipeline.ts +48 -184
  320. package/pipeline/span-proposer.ts +1 -1
  321. package/pipeline/types.ts +143 -16
  322. package/policy/defaults.ts +1 -1
  323. package/policy/policy.ts +1 -1
  324. package/policy/registry.ts +1 -1
  325. package/resolver/coverage-facts.ts +102 -0
  326. package/resolver/index.ts +18 -0
  327. package/resolver/lookup-types.ts +174 -0
  328. package/resolver/placetype-map.ts +122 -0
  329. package/resolver/postcode-format.ts +89 -0
  330. package/resolver/referential.ts +84 -0
  331. package/resolver/types.ts +423 -315
  332. package/resources/git.ts +18 -4
  333. package/resources/languages/types.gen.ts +60 -0
  334. package/resources/libpostal.ts +4 -3
  335. package/resources/whosonfirst/DataSourceCache.ts +2 -1
  336. package/resources/whosonfirst/PlacetypeDataSource.ts +36 -11
  337. package/resources/whosonfirst/loader.ts +3 -2
  338. package/resources/whosonfirst/placetypes/Placetype.ts +2 -1
  339. package/resources/whosonfirst/placetypes/admin.ts +11 -2
  340. package/resources/whosonfirst/placetypes/definition.ts +4 -3
  341. package/resources/whosonfirst/placetypes/index.ts +1 -0
  342. package/resources/whosonfirst/placetypes/specificity.ts +114 -0
  343. package/resources/whosonfirst/sharded-repo.ts +55 -2
  344. package/scripting/arguments.ts +38 -0
  345. package/scripting/command.ts +55 -0
  346. package/scripting/index.ts +3 -3
  347. package/scripting/utils/index.ts +5 -23
  348. package/tools/download-libpostal-resources.ts +4 -7
  349. package/tools/download-ssl-address.ts +28 -12
  350. package/tools/generate-language-types.ts +39 -5
  351. package/tools/index.ts +1 -2
  352. package/utils/data-root.ts +40 -14
  353. package/utils/hash.ts +5 -4
  354. package/utils/index.ts +1 -0
  355. package/utils/jsonl.ts +1 -1
  356. package/utils/repo.ts +12 -1
  357. package/utils/sealed-db.ts +30 -1
  358. package/utils/sqlite-rows.ts +40 -0
  359. package/utils/stats.ts +1 -6
  360. package/data/libpostal/dictionaries/all/chains.txt +0 -504
  361. package/kysley/adapter.ts +0 -29
  362. package/out/kysley/adapter.d.ts +0 -13
  363. package/out/kysley/adapter.d.ts.map +0 -1
  364. package/out/kysley/adapter.js +0 -25
  365. package/out/kysley/adapter.js.map +0 -1
  366. package/out/pipeline/reconcile-lookups.d.ts +0 -39
  367. package/out/pipeline/reconcile-lookups.d.ts.map +0 -1
  368. package/out/pipeline/reconcile-lookups.js +0 -88
  369. package/out/pipeline/reconcile-lookups.js.map +0 -1
  370. package/out/pipeline/reconcile.d.ts +0 -153
  371. package/out/pipeline/reconcile.d.ts.map +0 -1
  372. package/out/pipeline/reconcile.js +0 -388
  373. package/out/pipeline/reconcile.js.map +0 -1
  374. package/out/pipeline/span-logit-aggregation.d.ts +0 -58
  375. package/out/pipeline/span-logit-aggregation.d.ts.map +0 -1
  376. package/out/pipeline/span-logit-aggregation.js +0 -117
  377. package/out/pipeline/span-logit-aggregation.js.map +0 -1
  378. package/pipeline/reconcile-lookups.ts +0 -111
  379. package/pipeline/reconcile.ts +0 -583
  380. package/pipeline/span-logit-aggregation.ts +0 -156
package/env/index.ts CHANGED
@@ -4,6 +4,8 @@ import { loadEnvFile } from "./load.ts"
4
4
  import { cwdPathBuilder } from "./paths.ts"
5
5
  import { PrivateEnvSchema, PublicEnvSchema } from "./schema.ts"
6
6
 
7
+ export { defaultMailwomanPaths } from "./paths.ts"
8
+
7
9
  // The optional `.env` is read once (it can't change mid-process); the real environment is layered on top
8
10
  // LIVE. `process.env` can change during a process — a test stubbing a var, a late setter — and `$public` /
9
11
  // `$private` must reflect it, exactly like `process.env` itself. So each key is a getter that re-parses the
@@ -17,7 +19,7 @@ function liveEnv<Shape extends z.ZodRawShape>(schema: z.ZodObject<Shape>): z.inf
17
19
  for (const key of Object.keys(schema.shape)) {
18
20
  Object.defineProperty(view, key, {
19
21
  enumerable: true,
20
- // oxlint-disable-next-line sister-software/no-process-globals
22
+ // oxlint-disable-next-line sister-software/no-process-globals -- this module is the typed process.env boundary
21
23
  get: () => schema.parse({ ...dotEnv, ...process.env })[key as keyof z.infer<z.ZodObject<Shape>>],
22
24
  })
23
25
  }
package/env/paths.ts CHANGED
@@ -1,40 +1,28 @@
1
- import { existsSync } from "node:fs"
2
- import { homedir } from "node:os"
3
- import { dirname, resolve } from "node:path"
4
-
5
- /**
6
- * Resolve a path relative to the directory Claude Code is running in (cwd).
7
- *
8
- * @param paths Path segments to join onto cwd.
9
- */
10
- export function cwdPathBuilder(...paths: string[]): string {
11
- return resolve(process.cwd(), ...paths)
12
- }
13
-
14
1
  /**
15
- * Find all `.env` files from the current working directory up to the home directory or repo root.
16
- *
17
- * @returns An array of `.env` file paths, ordered from shallowest to deepest (cwd last).
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
18
5
  */
19
- export function cwdEnvPaths(): string[] {
20
- const found: string[] = []
21
- let dir = process.cwd()
22
- const home = homedir()
23
6
 
24
- while (true) {
25
- const candidate = resolve(dir, ".env")
7
+ import envPaths from "env-paths"
8
+ import { resolvePath } from "path-ts"
26
9
 
27
- if (existsSync(candidate)) {
28
- found.push(candidate)
29
- }
10
+ const platformPaths = envPaths("mailwoman", { suffix: "" })
30
11
 
31
- const parent = dirname(dir)
32
- const atRepoRoot = existsSync(resolve(dir, ".git"))
33
-
34
- if (atRepoRoot || dir === home || parent === dir) break
35
- dir = parent
36
- }
12
+ /**
13
+ * Platform-native filesystem defaults used by the typed environment schema.
14
+ */
15
+ export const defaultMailwomanPaths = {
16
+ data: resolvePath(platformPaths.data),
17
+ config: resolvePath(platformPaths.config),
18
+ cache: resolvePath(platformPaths.cache),
19
+ log: resolvePath(platformPaths.log),
20
+ temp: resolvePath(platformPaths.temp),
21
+ } as const
37
22
 
38
- // `found` is deepest-first (cwd first); reverse so cwd is applied last and wins.
39
- return found.toReversed()
23
+ /**
24
+ * Resolve a path relative to the current working directory.
25
+ */
26
+ export function cwdPathBuilder(...paths: string[]): string {
27
+ return resolvePath(process.cwd(), ...paths)
40
28
  }
package/env/schema.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod"
2
2
 
3
+ import { defaultMailwomanPaths } from "./paths.ts"
4
+
3
5
  /**
4
6
  * Wrap a coerced schema so a BLANK value means the same as an absent one.
5
7
  *
@@ -23,6 +25,10 @@ export const PublicEnvSchema = z.object({
23
25
  // `.catch` (not `.default`) so an unknown value never throws — vitest sets NODE_ENV=test, CI may set others.
24
26
  NODE_ENV: z.enum(["development", "production", "test"]).catch("development"),
25
27
  CI: z.coerce.boolean().default(false),
28
+ /**
29
+ * Operator locale override used when a request supplies no locale. Safe to expose in diagnostics.
30
+ */
31
+ MW_LOCALE: z.string().min(1).optional(),
26
32
 
27
33
  // Gazetteer / resolver database paths. CLI flags (`--resolve-db`, …) override these at the call site.
28
34
  MAILWOMAN_WOF_DB: z.string().optional(),
@@ -33,6 +39,8 @@ export const PublicEnvSchema = z.object({
33
39
  MAILWOMAN_FST_BIN: z.string().optional(),
34
40
  MAILWOMAN_MODEL_CARD: z.string().optional(),
35
41
  MAILWOMAN_COARSE_PLACER_DIR: z.string().optional(),
42
+ // PMTiles archive for the geocode --debug map pane; --tiles outranks it at the call site.
43
+ MAILWOMAN_TILES: z.string().optional(),
36
44
 
37
45
  // ONNX intra-op thread cap. Deployment-shaped rather than code-shaped: the right value depends on how many
38
46
  // mailwoman processes share the host, which the library cannot know. See DEFAULT_INTRA_OP_THREADS.
@@ -50,8 +58,12 @@ export const PublicEnvSchema = z.object({
50
58
  // Receipts: `docs/engineering/reference/performance.mdx`.
51
59
  MAILWOMAN_BATCH_MAX: blankAsAbsent(z.coerce.number().int().positive().default(1000)),
52
60
 
53
- // The gazetteer/model data root (`core/utils/data-root.ts`, `scripts/copy-weights.ts`).
54
- MAILWOMAN_DATA_ROOT: z.string().optional(),
61
+ // Platform-native application directories. Environment values override these defaults.
62
+ MAILWOMAN_DATA_ROOT: z.string().default(defaultMailwomanPaths.data),
63
+ MAILWOMAN_CONFIG_ROOT: z.string().default(defaultMailwomanPaths.config),
64
+ MAILWOMAN_CACHE_ROOT: z.string().default(defaultMailwomanPaths.cache),
65
+ MAILWOMAN_LOG_ROOT: z.string().default(defaultMailwomanPaths.log),
66
+ MAILWOMAN_TEMP_ROOT: z.string().default(defaultMailwomanPaths.temp),
55
67
 
56
68
  // Corpus source-fetch tools (`corpus/src/tools/fetch/*` — env knobs are now command flags; these remain for compat). Callers do their own numeric/boolean parsing on these,
57
69
  // so they stay raw strings — the schema only gates which keys surface, not how they're coerced.
@@ -84,13 +96,22 @@ export const PublicEnvSchema = z.object({
84
96
 
85
97
  // Release-it publish flow (`scripts/publish-workspace.ts`). The OTP is a secret — see `$private`.
86
98
  MAILWOMAN_SKIP_WEIGHTS: z.string().optional(),
99
+ /**
100
+ * Set to `0` to publish WITHOUT a sigstore provenance attestation. Provenance is otherwise on by default under GitHub
101
+ * Actions — this exists so a release blocked by a sigstore or registry outage can still ship.
102
+ */
87
103
  MAILWOMAN_NPM_PROVENANCE: z.string().optional(),
104
+ /**
105
+ * Set by GitHub Actions itself. npm can only mint a provenance attestation from a CI provider it supports, so this is
106
+ * the predicate for `--provenance` rather than the generic {@link CI} flag.
107
+ */
108
+ GITHUB_ACTIONS: z.coerce.boolean().default(false),
88
109
  RELEASE_IT_WORKSPACES_PATH_TO_WORKSPACE: z.string().optional(),
89
110
  RELEASE_IT_WORKSPACES_TAG: z.string().optional(),
90
111
  RELEASE_IT_WORKSPACES_ACCESS: z.string().optional(),
91
112
  RELEASE_IT_WORKSPACES_DRY_RUN: z.string().optional(),
92
113
 
93
- // Demo resolver (`docs/plugins/demo-assets/resolve.ts`) + docs driver.
114
+ // Demo artifact staging (`docs/plugins/demo-assets/artifacts.ts`) + docs driver.
94
115
  PLAYPEN_WOF_ADMIN_DB: z.string().optional(),
95
116
  PLAYPEN_WOF_POSTCODE_DB: z.string().optional(),
96
117
  SLIM_COUNTRIES: z.string().optional(),
@@ -141,6 +162,8 @@ export const PublicEnvSchema = z.object({
141
162
  MW_DUMP_REGRESSIONS: z.string().optional(),
142
163
  PROBE_N: z.string().optional(),
143
164
  DEBUG: z.string().optional(),
165
+ // The informal-standard color kill switch (no-color.org). chalk/Ink honor it on their own; declared here because the debug view's map pane emits raw SGR and must consult it itself — the schema strips unlisted vars.
166
+ NO_COLOR: z.string().optional(),
144
167
  })
145
168
 
146
169
  /**
@@ -181,6 +204,15 @@ export const PrivateEnvSchema = z.object({
181
204
 
182
205
  // SEC EDGAR fair-access User-Agent (`filer/sdk/sec-client.ts`) — "Company Name AdminContact@domain.com".
183
206
  SEC_EDGAR_USER_AGENT: z.string().optional(),
207
+ /**
208
+ * Descriptive User-Agent for the FCC CORES lookup (`filer/sdk/cores-client.ts`). Optional in a way
209
+ * `SEC_EDGAR_USER_AGENT` is not: SEC 403s a request that fails to identify itself, FCC does not. Falls back to
210
+ * `SEC_EDGAR_USER_AGENT` — the same contact address — when unset.
211
+ */
212
+ FCC_CORES_USER_AGENT: z.string().optional(),
213
+
214
+ USAC_API_KEY_ID: z.string().optional(),
215
+ USAC_API_SECRET_KEY: z.string().optional(),
184
216
 
185
217
  // Google Maps Platform key for the reference-geocoder ORACLE (`geocode-oracle/sdk/google-client.ts`).
186
218
  // Verification tooling only — nothing on the parse path reads this, and `@mailwoman/geocode-oracle` is
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @copyright Sister Software.
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+
7
+ /**
8
+ * A kibibyte. Named so a `< 1024` guard reads as a threshold rather than a magic number — several fetchers use it to
9
+ * reject a response too small to be the archive they asked for.
10
+ */
11
+ export const BYTES_PER_KIB = 1024
12
+
13
+ export interface ByteFormatterOptions {
14
+ /**
15
+ * Prefix an explicit `+` on a positive value. For a DELTA, where the sign is the information. A negative always
16
+ * carries its own sign.
17
+ */
18
+ signed?: boolean
19
+ /**
20
+ * Override the formatter's locale for this call.
21
+ */
22
+ locales?: Intl.LocalesArgument
23
+ }
24
+
25
+ /**
26
+ * Byte counts as a human reads them, in whichever of the two bases the number was actually measured in.
27
+ *
28
+ * Both bases, spelled correctly. A formatter that divides by 1024 and prints `KB` is off by 2.4% at KB and 10% by TB,
29
+ * and the label is the only thing telling a reader which it did — so the choice is named at the call site:
30
+ *
31
+ * - {@linkcode ByteFormatter.formatIEC} for anything a MACHINE measured — heap, file size on disk, buffer length.
32
+ * - {@linkcode ByteFormatter.formatSI} for a size a VENDOR reports. Disk capacity, download sizes and GitHub's own API
33
+ * are quoted in powers of ten; rendering GitHub's `41.3 GB` as `38.5 GiB` is correct arithmetic and the wrong
34
+ * answer.
35
+ *
36
+ * Rendering goes through `Intl.NumberFormat`, so the unit and the decimal separator follow the locale. Pass an explicit
37
+ * locale when a caller needs a stable string — a test asserting an exact rendering, not a line printed for a human.
38
+ */
39
+ export class ByteFormatter {
40
+ public static SI_UNITS = ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte"] as const
41
+ public static IEC_UNITS = ["B", "KiB", "MiB", "GiB", "TiB"] as const
42
+
43
+ public static shared = new ByteFormatter()
44
+
45
+ public static formatSI(bytes: number, options?: ByteFormatterOptions): string {
46
+ return ByteFormatter.shared.formatSI(bytes, options)
47
+ }
48
+
49
+ public static formatIEC(bytes: number, options?: ByteFormatterOptions): string {
50
+ return ByteFormatter.shared.formatIEC(bytes, options)
51
+ }
52
+
53
+ protected locales?: Intl.LocalesArgument
54
+
55
+ constructor(locales?: Intl.LocalesArgument) {
56
+ this.locales = locales
57
+ }
58
+
59
+ /**
60
+ * Formats a file size in bytes into a human-readable string with appropriate SI units (B, kB, MB, GB, TB).
61
+ *
62
+ * @param bytes The file size in bytes.
63
+ */
64
+ public formatSI(bytes: number, options?: ByteFormatterOptions): string {
65
+ const units = ByteFormatter.SI_UNITS
66
+
67
+ let value = bytes
68
+ let unit = 0
69
+
70
+ while (Math.abs(value) >= 1000 && unit < units.length - 1) {
71
+ value /= 1000
72
+
73
+ unit++
74
+ }
75
+
76
+ return new Intl.NumberFormat(options?.locales ?? this.locales, {
77
+ style: "unit",
78
+ unit: units[unit],
79
+ maximumFractionDigits: 1,
80
+ signDisplay: options?.signed ? "exceptZero" : "auto",
81
+ }).format(value)
82
+ }
83
+
84
+ /**
85
+ * Formats a file size in bytes into a human-readable string with appropriate IEC units (B, KiB, MiB, GiB, TiB).
86
+ *
87
+ * @param bytes The file size in bytes.
88
+ */
89
+ public formatIEC(bytes: number, options?: ByteFormatterOptions): string {
90
+ let value = bytes
91
+ let unit = 0
92
+
93
+ // oxlint-disable-next-line sister-software/no-unnamed-threshold -- Well known.
94
+ while (Math.abs(value) >= 1024 && unit < ByteFormatter.IEC_UNITS.length - 1) {
95
+ value /= 1024
96
+
97
+ unit++
98
+ }
99
+
100
+ const formatted = new Intl.NumberFormat(options?.locales ?? this.locales, {
101
+ maximumFractionDigits: 1,
102
+ signDisplay: options?.signed ? "exceptZero" : "auto",
103
+ }).format(value)
104
+
105
+ return `${formatted} ${ByteFormatter.IEC_UNITS[unit]}`
106
+ }
107
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @copyright Sister Software.
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+
7
+ export * from "./formatters.ts"
package/fs/zip.ts ADDED
@@ -0,0 +1,297 @@
1
+ /**
2
+ * @copyright Sister Software.
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Zip readers, in two flavours — buffer-in for archives already in memory, path-in for archives on disk.
6
+ *
7
+ * {@link extractZip} and {@link extractSingleFileZip} take the whole archive as a `Buffer`, which is the right shape
8
+ * when a client has just downloaded one (`bdc/sdk/download.ts`) and the wrong shape for anything sizable: adm-zip
9
+ * holds the archive AND the decompressed member resident at once. The national address dumps under
10
+ * `$MAILWOMAN_DATA_ROOT` are 0.5–2.9 GB compressed and up to 9 GB unpacked, so the path-in readers below stream —
11
+ * yauzl seeks the central directory over a file handle and inflates one member on demand, at constant memory
12
+ * regardless of archive size.
13
+ *
14
+ * The path-in readers also handle ZIP64, which the dumps need: a member above 4 GB parks `0xFFFFFFFF` in the 32-bit
15
+ * size and offset slots and carries the real values in the entry's extra field.
16
+ */
17
+
18
+ import { createWriteStream } from "node:fs"
19
+ import { mkdir } from "node:fs/promises"
20
+ import { basename, dirname, join } from "node:path"
21
+ import { pipeline } from "node:stream/promises"
22
+ import { crc32 } from "node:zlib"
23
+
24
+ import ADMZip from "adm-zip"
25
+ import type { PathBuilderLike } from "path-ts"
26
+ import { open as openArchive } from "yauzl-promise"
27
+
28
+ export type ZipEntryContentPair = [entry: ADMZip.IZipEntry, content: Buffer]
29
+
30
+ /**
31
+ * Extract the contents of a zip file.
32
+ *
33
+ * @category Files
34
+ * @internal
35
+ */
36
+ export function extractZip(data: ArrayBuffer | Buffer): Map<ADMZip.IZipEntry, Buffer> {
37
+ const normalizedData = data instanceof ArrayBuffer ? Buffer.from(data) : data
38
+ const zip = new ADMZip(normalizedData)
39
+
40
+ const pairs = zip
41
+ .getEntries()
42
+ .map((entry) => [entry, zip.readFile(entry)])
43
+ .filter((pair): pair is ZipEntryContentPair => pair[1] !== null)
44
+
45
+ if (!pairs.length) {
46
+ throw new Error("No entry pairs found in zip file.")
47
+ }
48
+
49
+ return new Map<ADMZip.IZipEntry, Buffer>(pairs)
50
+ }
51
+
52
+ /**
53
+ * Extract the contents of a zip file and return the first entry.
54
+ */
55
+ export function extractSingleFileZip(data: ArrayBuffer | Buffer): Promise<Buffer> {
56
+ const normalizedData = data instanceof ArrayBuffer ? Buffer.from(data) : data
57
+ const zip = new ADMZip(normalizedData)
58
+
59
+ const [entry] = zip.getEntries()
60
+
61
+ // We use the async version of getData to avoid blocking the event loop.
62
+ return new Promise<Buffer>((resolve, reject) =>
63
+ // oxlint-disable-next-line no-promise-executor-return -- return the callback registration from this expression-bodied executor
64
+ entry!.getDataAsync((extractedData, error) => {
65
+ if (error) {
66
+ reject(error)
67
+ } else {
68
+ resolve(extractedData)
69
+ }
70
+ })
71
+ )
72
+ }
73
+
74
+ /**
75
+ * Names a member of an archive, either exactly or by pattern.
76
+ *
77
+ * A pattern matches the FIRST entry whose full archive-internal path tests true, in central-directory order.
78
+ */
79
+ export type ZipEntrySelector = string | RegExp
80
+
81
+ /**
82
+ * One archive member, as reported by the central directory.
83
+ *
84
+ * @category Files
85
+ */
86
+ export interface ZipEntryInfo {
87
+ /**
88
+ * The archive-internal path, e.g. `it/countrywide.csv`. Directory entries keep their trailing slash.
89
+ */
90
+ name: string
91
+ compressedSize: number
92
+ uncompressedSize: number
93
+ }
94
+
95
+ function selectorMatches(selector: ZipEntrySelector, name: string): boolean {
96
+ return typeof selector === "string" ? name === selector : selector.test(name)
97
+ }
98
+
99
+ /**
100
+ * List an archive's members without decompressing any of them.
101
+ *
102
+ * @category Files
103
+ */
104
+ export async function listZipEntries(archivePath: PathBuilderLike): Promise<ZipEntryInfo[]> {
105
+ const archive = await openArchive(String(archivePath))
106
+ const entries: ZipEntryInfo[] = []
107
+
108
+ try {
109
+ for await (const entry of archive) {
110
+ entries.push({
111
+ name: entry.filename,
112
+ compressedSize: entry.compressedSize,
113
+ uncompressedSize: entry.uncompressedSize,
114
+ })
115
+ }
116
+ } finally {
117
+ await archive.close()
118
+ }
119
+
120
+ return entries
121
+ }
122
+
123
+ /**
124
+ * Stream one member's decompressed bytes out of an archive on disk.
125
+ *
126
+ * Nothing beyond the central directory and the inflate window is held in memory, so this is bounded by the consumer
127
+ * rather than by the member's size. A consumer that stops early — a `take`, a `break` — destroys the member stream and
128
+ * closes the archive on the way out.
129
+ *
130
+ * @category Files
131
+ * @throws If no member matches `selector`.
132
+ */
133
+ export async function* readZipEntry(
134
+ archivePath: PathBuilderLike,
135
+ selector: ZipEntrySelector
136
+ ): AsyncGenerator<Uint8Array> {
137
+ const archive = await openArchive(String(archivePath))
138
+
139
+ try {
140
+ for await (const entry of archive) {
141
+ if (!selectorMatches(selector, entry.filename)) continue
142
+
143
+ const contents = await entry.openReadStream()
144
+
145
+ try {
146
+ yield* contents
147
+ } finally {
148
+ contents.destroy()
149
+ }
150
+
151
+ return
152
+ }
153
+
154
+ throw new Error(`No entry matching ${selector} in ${archivePath}`)
155
+ } finally {
156
+ await archive.close()
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Write one member's decompressed bytes to `destinationPath`.
162
+ *
163
+ * @category Files
164
+ *
165
+ * @returns The number of bytes written, as the central directory reports them.
166
+ * @throws If no member matches `selector`.
167
+ */
168
+ export async function extractZipEntry(
169
+ archivePath: PathBuilderLike,
170
+ selector: ZipEntrySelector,
171
+ destinationPath: PathBuilderLike
172
+ ): Promise<number> {
173
+ const archive = await openArchive(String(archivePath))
174
+
175
+ try {
176
+ for await (const entry of archive) {
177
+ if (!selectorMatches(selector, entry.filename)) continue
178
+
179
+ await pipeline(await entry.openReadStream(), createWriteStream(String(destinationPath)))
180
+
181
+ return entry.uncompressedSize
182
+ }
183
+ } finally {
184
+ await archive.close()
185
+ }
186
+
187
+ throw new Error(`No entry matching ${selector} in ${archivePath}`)
188
+ }
189
+
190
+ export interface ExtractZipEntriesOptions {
191
+ /**
192
+ * Which members to write. Omit for every member.
193
+ */
194
+ selector?: ZipEntrySelector
195
+ /**
196
+ * Write each member under its basename rather than its archive-internal path, flattening the tree — `unzip -j`.
197
+ *
198
+ * The shapefile archives this exists for carry their siblings in one directory, and the readers downstream expect
199
+ * them flat.
200
+ */
201
+ flatten?: boolean
202
+ }
203
+
204
+ /**
205
+ * Extract members of an archive into `destinationDirectory`.
206
+ *
207
+ * Directory entries are skipped; a nested path is created as needed unless `flatten` is set. Members stream one at a
208
+ * time, so this is bounded by the largest member rather than by the archive.
209
+ *
210
+ * @category Files
211
+ *
212
+ * @returns The archive-internal names of everything written, in central-directory order.
213
+ */
214
+ export async function extractZipEntries(
215
+ archivePath: PathBuilderLike,
216
+ destinationDirectory: PathBuilderLike,
217
+ { selector, flatten = false }: ExtractZipEntriesOptions = {}
218
+ ): Promise<string[]> {
219
+ const archive = await openArchive(String(archivePath))
220
+ const written: string[] = []
221
+
222
+ try {
223
+ for await (const entry of archive) {
224
+ if (entry.filename.endsWith("/")) continue
225
+
226
+ if (selector && !selectorMatches(selector, entry.filename)) continue
227
+
228
+ const relative = flatten ? basename(entry.filename) : entry.filename
229
+ const destination = join(String(destinationDirectory), relative)
230
+
231
+ if (!flatten) {
232
+ await mkdir(dirname(destination), { recursive: true })
233
+ }
234
+
235
+ await pipeline(await entry.openReadStream(), createWriteStream(destination))
236
+
237
+ written.push(entry.filename)
238
+ }
239
+ } finally {
240
+ await archive.close()
241
+ }
242
+
243
+ return written
244
+ }
245
+
246
+ /**
247
+ * Verify every member's CRC-32 against the value its central-directory header claims — what `unzip -t` is for.
248
+ *
249
+ * This is a corruption check on a download, so it decompresses everything and keeps nothing; the archive is read one
250
+ * member at a time and the checksum is folded chunk by chunk, so memory is bounded by the inflate window.
251
+ *
252
+ * The CRC is computed here rather than delegated to yauzl's `validateCrc32`, which asserts `Cannot validate CRC32 for
253
+ * uncompressed data` on a STORED member — and a corrupt stored member is precisely what this is meant to catch. Folding
254
+ * it locally covers both storage methods with one path.
255
+ *
256
+ * @category Files
257
+ *
258
+ * @returns The number of members checked. @throws If the archive is unreadable, or any member's checksum or length
259
+ * disagrees with its header.
260
+ */
261
+ export async function verifyZipIntegrity(archivePath: PathBuilderLike): Promise<number> {
262
+ const archive = await openArchive(String(archivePath))
263
+ let checked = 0
264
+
265
+ try {
266
+ for await (const entry of archive) {
267
+ if (entry.filename.endsWith("/")) continue
268
+
269
+ const contents = await entry.openReadStream({ validateCrc32: false })
270
+ let checksum = 0
271
+ let length = 0
272
+
273
+ for await (const chunk of contents) {
274
+ checksum = crc32(chunk as Uint8Array, checksum)
275
+ length += (chunk as Uint8Array).length
276
+ }
277
+
278
+ if (checksum !== entry.crc32) {
279
+ throw new Error(
280
+ `CRC mismatch in ${archivePath}: ${entry.filename} is 0x${checksum.toString(16)}, header claims 0x${entry.crc32.toString(16)}`
281
+ )
282
+ }
283
+
284
+ if (length !== entry.uncompressedSize) {
285
+ throw new Error(
286
+ `Length mismatch in ${archivePath}: ${entry.filename} is ${length} bytes, header claims ${entry.uncompressedSize}`
287
+ )
288
+ }
289
+
290
+ checked++
291
+ }
292
+ } finally {
293
+ await archive.close()
294
+ }
295
+
296
+ return checked
297
+ }