@mailwoman/core 10.1.0 → 10.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 (429) hide show
  1. package/lib/api/APIClient.ts +5 -6
  2. package/lib/api/arcgis.ts +5 -5
  3. package/lib/api/ckan.ts +2 -1
  4. package/lib/api/disk-storage.ts +3 -3
  5. package/lib/api/ogc.ts +56 -52
  6. package/lib/api/pacer.ts +1 -1
  7. package/lib/api/retry.ts +6 -4
  8. package/lib/api/test/transport.ts +20 -20
  9. package/lib/api.ts +1 -0
  10. package/lib/coarse-placer/coarse-placer.ts +4 -3
  11. package/lib/crypto/node.ts +1 -2
  12. package/lib/decoder/build-tree.ts +5 -5
  13. package/lib/decoder/parse-diff.ts +47 -31
  14. package/lib/decoder/proposals-to-tree.ts +1 -0
  15. package/lib/decoder/serialize/json.ts +9 -6
  16. package/lib/decoder/serialize/tuples.ts +2 -1
  17. package/lib/decoder/serialize/xml.ts +15 -14
  18. package/lib/decoder/tree/shape.ts +14 -14
  19. package/lib/decoder/tree/walk.ts +2 -2
  20. package/lib/decoder/types.ts +48 -2
  21. package/lib/env/schema.ts +21 -23
  22. package/lib/env/utils.ts +4 -3
  23. package/lib/env.ts +4 -4
  24. package/lib/fs/delimited.ts +35 -1
  25. package/lib/fs/readers.ts +2 -5
  26. package/lib/fs/zip.ts +1 -1
  27. package/lib/geocode/result.ts +337 -0
  28. package/lib/git.ts +1 -1
  29. package/lib/html/document.ts +6 -6
  30. package/lib/html/elements.ts +26 -23
  31. package/lib/identical.ts +20 -0
  32. package/lib/json.ts +5 -7
  33. package/lib/layers/coverage.ts +28 -1
  34. package/lib/layers/feature-count.ts +3 -3
  35. package/lib/layers/manifest.ts +22 -21
  36. package/lib/layers/schema.ts +25 -1
  37. package/lib/license/configured.ts +3 -3
  38. package/lib/license/key/file.ts +2 -1
  39. package/lib/license/key.ts +3 -3
  40. package/lib/license/stamp.ts +4 -4
  41. package/lib/locale/locale.ts +1 -1
  42. package/lib/locale/registry.ts +2 -2
  43. package/lib/module/compiled-freshness.ts +1 -1
  44. package/lib/module/package-command.ts +4 -2
  45. package/lib/module/packaged-data.ts +1 -1
  46. package/lib/module/resolve-from.ts +1 -1
  47. package/lib/numeric.ts +4 -4
  48. package/lib/objects.ts +3 -0
  49. package/lib/paths.ts +16 -1
  50. package/lib/pipeline/client-result.ts +14 -14
  51. package/lib/pipeline/result.ts +5 -4
  52. package/lib/pipeline/runtime-pipeline.ts +65 -42
  53. package/lib/pipeline/span-proposer.ts +1 -1
  54. package/lib/pipeline/types.ts +328 -161
  55. package/lib/pipeline.ts +32 -7
  56. package/lib/policy/proposal-collection.ts +1 -1
  57. package/lib/policy/registry.ts +5 -3
  58. package/lib/resolver/authoritative-provider.ts +17 -17
  59. package/lib/resolver/coverage-facts.ts +3 -3
  60. package/lib/resolver/fixture-authoritative-provider.ts +4 -0
  61. package/lib/resolver/lookup-types.ts +54 -14
  62. package/lib/resolver/postcode-format.ts +9 -9
  63. package/lib/resolver/referential.ts +2 -2
  64. package/lib/resolver/types.ts +155 -51
  65. package/lib/resolver.ts +22 -20
  66. package/lib/resources/git.ts +1 -1
  67. package/lib/resources/languages.ts +0 -2
  68. package/lib/resources/libpostal.ts +1 -1
  69. package/lib/resources/whosonfirst/PlacetypeDataSource.ts +2 -6
  70. package/lib/resources/whosonfirst/extract-repo.ts +2 -1
  71. package/lib/resources/whosonfirst/placetypes/admin.ts +20 -25
  72. package/lib/resources/whosonfirst/placetypes/mermaid.ts +4 -3
  73. package/lib/resources/whosonfirst/placetypes/specificity.ts +7 -7
  74. package/lib/resources.ts +1 -0
  75. package/lib/scripting/arguments.ts +6 -5
  76. package/lib/scripting/command.ts +3 -2
  77. package/lib/scripting/operation.ts +2 -2
  78. package/lib/scripting/utils.ts +3 -5
  79. package/lib/strings/python-json.ts +1 -1
  80. package/lib/tokenization/Span.ts +1 -1
  81. package/lib/trust-policies.ts +0 -2
  82. package/lib/types/Classification.ts +1 -1
  83. package/lib/types/classifier.ts +1 -1
  84. package/lib/utils/geodatabase-archive.ts +13 -5
  85. package/lib/utils/sqlite-rows.ts +3 -3
  86. package/lib/utils/stream-to-disk.ts +1 -3
  87. package/lib/utils/union-find.ts +1 -1
  88. package/lib/vale.ts +1 -1
  89. package/lib/workspaces.ts +2 -2
  90. package/out/api/APIClient.d.ts +3 -3
  91. package/out/api/APIClient.d.ts.map +1 -1
  92. package/out/api/APIClient.js +2 -3
  93. package/out/api/APIClient.js.map +1 -1
  94. package/out/api/arcgis.d.ts +2 -2
  95. package/out/api/arcgis.d.ts.map +1 -1
  96. package/out/api/arcgis.js +6 -6
  97. package/out/api/arcgis.js.map +1 -1
  98. package/out/api/ckan.d.ts +2 -1
  99. package/out/api/ckan.d.ts.map +1 -1
  100. package/out/api/ckan.js.map +1 -1
  101. package/out/api/disk-storage.d.ts +1 -1
  102. package/out/api/disk-storage.js +2 -2
  103. package/out/api/disk-storage.js.map +1 -1
  104. package/out/api/ogc.d.ts +32 -27
  105. package/out/api/ogc.d.ts.map +1 -1
  106. package/out/api/ogc.js +41 -46
  107. package/out/api/ogc.js.map +1 -1
  108. package/out/api/pacer.d.ts +1 -1
  109. package/out/api/pacer.js +1 -1
  110. package/out/api/retry.d.ts +6 -4
  111. package/out/api/retry.d.ts.map +1 -1
  112. package/out/api/retry.js +1 -1
  113. package/out/api/retry.js.map +1 -1
  114. package/out/api/test/transport.d.ts +11 -11
  115. package/out/api/test/transport.d.ts.map +1 -1
  116. package/out/api/test/transport.js +16 -16
  117. package/out/api/test/transport.js.map +1 -1
  118. package/out/api.d.ts +1 -0
  119. package/out/api.d.ts.map +1 -1
  120. package/out/api.js +1 -0
  121. package/out/api.js.map +1 -1
  122. package/out/coarse-placer/coarse-placer.d.ts +3 -2
  123. package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
  124. package/out/coarse-placer/coarse-placer.js +1 -1
  125. package/out/coarse-placer/coarse-placer.js.map +1 -1
  126. package/out/crypto/node.d.ts +1 -2
  127. package/out/crypto/node.d.ts.map +1 -1
  128. package/out/crypto/node.js +1 -2
  129. package/out/crypto/node.js.map +1 -1
  130. package/out/decoder/build-tree.js +5 -5
  131. package/out/decoder/build-tree.js.map +1 -1
  132. package/out/decoder/parse-diff.d.ts +19 -19
  133. package/out/decoder/parse-diff.d.ts.map +1 -1
  134. package/out/decoder/parse-diff.js +28 -12
  135. package/out/decoder/parse-diff.js.map +1 -1
  136. package/out/decoder/proposals-to-tree.d.ts.map +1 -1
  137. package/out/decoder/proposals-to-tree.js +1 -0
  138. package/out/decoder/proposals-to-tree.js.map +1 -1
  139. package/out/decoder/serialize/json.d.ts +35 -17
  140. package/out/decoder/serialize/json.d.ts.map +1 -1
  141. package/out/decoder/serialize/json.js +28 -0
  142. package/out/decoder/serialize/json.js.map +1 -1
  143. package/out/decoder/serialize/tuples.d.ts +2 -1
  144. package/out/decoder/serialize/tuples.d.ts.map +1 -1
  145. package/out/decoder/serialize/tuples.js.map +1 -1
  146. package/out/decoder/serialize/xml.d.ts +12 -11
  147. package/out/decoder/serialize/xml.d.ts.map +1 -1
  148. package/out/decoder/serialize/xml.js +3 -3
  149. package/out/decoder/serialize/xml.js.map +1 -1
  150. package/out/decoder/tree/shape.d.ts +6 -6
  151. package/out/decoder/tree/shape.d.ts.map +1 -1
  152. package/out/decoder/tree/shape.js +8 -8
  153. package/out/decoder/tree/shape.js.map +1 -1
  154. package/out/decoder/tree/walk.d.ts +1 -1
  155. package/out/decoder/tree/walk.d.ts.map +1 -1
  156. package/out/decoder/tree/walk.js +1 -1
  157. package/out/decoder/tree/walk.js.map +1 -1
  158. package/out/decoder/types.d.ts +55 -2
  159. package/out/decoder/types.d.ts.map +1 -1
  160. package/out/decoder/types.js +39 -1
  161. package/out/decoder/types.js.map +1 -1
  162. package/out/env/schema.d.ts +11 -12
  163. package/out/env/schema.d.ts.map +1 -1
  164. package/out/env/schema.js +15 -17
  165. package/out/env/schema.js.map +1 -1
  166. package/out/env/utils.d.ts +2 -2
  167. package/out/env/utils.d.ts.map +1 -1
  168. package/out/env/utils.js +2 -2
  169. package/out/env/utils.js.map +1 -1
  170. package/out/env.js +4 -4
  171. package/out/env.js.map +1 -1
  172. package/out/fs/delimited.d.ts +18 -0
  173. package/out/fs/delimited.d.ts.map +1 -1
  174. package/out/fs/delimited.js +31 -1
  175. package/out/fs/delimited.js.map +1 -1
  176. package/out/fs/readers.d.ts +2 -4
  177. package/out/fs/readers.d.ts.map +1 -1
  178. package/out/fs/readers.js +2 -4
  179. package/out/fs/readers.js.map +1 -1
  180. package/out/fs/zip.js +1 -1
  181. package/out/fs/zip.js.map +1 -1
  182. package/out/geocode/result.d.ts +475 -0
  183. package/out/geocode/result.d.ts.map +1 -0
  184. package/out/geocode/result.js +280 -0
  185. package/out/geocode/result.js.map +1 -0
  186. package/out/git.js +1 -1
  187. package/out/git.js.map +1 -1
  188. package/out/html/document.d.ts +3 -3
  189. package/out/html/document.d.ts.map +1 -1
  190. package/out/html/document.js +4 -4
  191. package/out/html/document.js.map +1 -1
  192. package/out/html/elements.d.ts +18 -15
  193. package/out/html/elements.d.ts.map +1 -1
  194. package/out/html/elements.js +17 -16
  195. package/out/html/elements.js.map +1 -1
  196. package/out/identical.d.ts +16 -0
  197. package/out/identical.d.ts.map +1 -0
  198. package/out/identical.js +19 -0
  199. package/out/identical.js.map +1 -0
  200. package/out/json.d.ts +3 -5
  201. package/out/json.d.ts.map +1 -1
  202. package/out/json.js +3 -5
  203. package/out/json.js.map +1 -1
  204. package/out/layers/coverage.d.ts +26 -1
  205. package/out/layers/coverage.d.ts.map +1 -1
  206. package/out/layers/coverage.js.map +1 -1
  207. package/out/layers/feature-count.d.ts +1 -1
  208. package/out/layers/feature-count.d.ts.map +1 -1
  209. package/out/layers/feature-count.js +2 -2
  210. package/out/layers/feature-count.js.map +1 -1
  211. package/out/layers/manifest.d.ts +11 -10
  212. package/out/layers/manifest.d.ts.map +1 -1
  213. package/out/layers/manifest.js +12 -13
  214. package/out/layers/manifest.js.map +1 -1
  215. package/out/layers/schema.d.ts +23 -0
  216. package/out/layers/schema.d.ts.map +1 -1
  217. package/out/layers/schema.js +1 -1
  218. package/out/layers/schema.js.map +1 -1
  219. package/out/license/configured.d.ts +1 -1
  220. package/out/license/configured.d.ts.map +1 -1
  221. package/out/license/configured.js +2 -2
  222. package/out/license/configured.js.map +1 -1
  223. package/out/license/key/file.d.ts.map +1 -1
  224. package/out/license/key/file.js +2 -1
  225. package/out/license/key/file.js.map +1 -1
  226. package/out/license/key.d.ts +1 -1
  227. package/out/license/key.d.ts.map +1 -1
  228. package/out/license/key.js +2 -2
  229. package/out/license/key.js.map +1 -1
  230. package/out/license/stamp.d.ts +2 -2
  231. package/out/license/stamp.d.ts.map +1 -1
  232. package/out/license/stamp.js +2 -2
  233. package/out/license/stamp.js.map +1 -1
  234. package/out/locale/locale.d.ts +1 -1
  235. package/out/locale/locale.d.ts.map +1 -1
  236. package/out/locale/registry.d.ts +1 -1
  237. package/out/locale/registry.d.ts.map +1 -1
  238. package/out/locale/registry.js +1 -1
  239. package/out/locale/registry.js.map +1 -1
  240. package/out/module/compiled-freshness.js +1 -1
  241. package/out/module/compiled-freshness.js.map +1 -1
  242. package/out/module/package-command.d.ts +3 -2
  243. package/out/module/package-command.d.ts.map +1 -1
  244. package/out/module/package-command.js +3 -2
  245. package/out/module/package-command.js.map +1 -1
  246. package/out/module/packaged-data.js +1 -1
  247. package/out/module/packaged-data.js.map +1 -1
  248. package/out/module/resolve-from.js +1 -1
  249. package/out/module/resolve-from.js.map +1 -1
  250. package/out/numeric.d.ts +1 -1
  251. package/out/numeric.d.ts.map +1 -1
  252. package/out/numeric.js +3 -3
  253. package/out/numeric.js.map +1 -1
  254. package/out/objects.d.ts +3 -0
  255. package/out/objects.d.ts.map +1 -1
  256. package/out/objects.js +3 -0
  257. package/out/objects.js.map +1 -1
  258. package/out/paths.d.ts +20 -1
  259. package/out/paths.d.ts.map +1 -1
  260. package/out/paths.js +1 -1
  261. package/out/paths.js.map +1 -1
  262. package/out/pipeline/client-result.d.ts +15 -15
  263. package/out/pipeline/client-result.d.ts.map +1 -1
  264. package/out/pipeline/client-result.js +1 -1
  265. package/out/pipeline/result.d.ts +4 -3
  266. package/out/pipeline/result.d.ts.map +1 -1
  267. package/out/pipeline/runtime-pipeline.d.ts +16 -9
  268. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  269. package/out/pipeline/runtime-pipeline.js +43 -27
  270. package/out/pipeline/runtime-pipeline.js.map +1 -1
  271. package/out/pipeline/span-proposer.js +1 -1
  272. package/out/pipeline/span-proposer.js.map +1 -1
  273. package/out/pipeline/types.d.ts +394 -175
  274. package/out/pipeline/types.d.ts.map +1 -1
  275. package/out/pipeline/types.js +199 -4
  276. package/out/pipeline/types.js.map +1 -1
  277. package/out/pipeline.d.ts +4 -2
  278. package/out/pipeline.d.ts.map +1 -1
  279. package/out/pipeline.js +1 -1
  280. package/out/pipeline.js.map +1 -1
  281. package/out/policy/proposal-collection.d.ts +1 -1
  282. package/out/policy/proposal-collection.d.ts.map +1 -1
  283. package/out/policy/proposal-collection.js.map +1 -1
  284. package/out/policy/registry.d.ts +3 -1
  285. package/out/policy/registry.d.ts.map +1 -1
  286. package/out/policy/registry.js +4 -2
  287. package/out/policy/registry.js.map +1 -1
  288. package/out/resolver/authoritative-provider.d.ts +17 -17
  289. package/out/resolver/authoritative-provider.d.ts.map +1 -1
  290. package/out/resolver/authoritative-provider.js +2 -2
  291. package/out/resolver/coverage-facts.d.ts +3 -3
  292. package/out/resolver/coverage-facts.d.ts.map +1 -1
  293. package/out/resolver/fixture-authoritative-provider.d.ts.map +1 -1
  294. package/out/resolver/fixture-authoritative-provider.js +4 -0
  295. package/out/resolver/fixture-authoritative-provider.js.map +1 -1
  296. package/out/resolver/lookup-types.d.ts +52 -15
  297. package/out/resolver/lookup-types.d.ts.map +1 -1
  298. package/out/resolver/postcode-format.d.ts +3 -3
  299. package/out/resolver/postcode-format.d.ts.map +1 -1
  300. package/out/resolver/postcode-format.js +7 -7
  301. package/out/resolver/postcode-format.js.map +1 -1
  302. package/out/resolver/referential.d.ts +2 -2
  303. package/out/resolver/referential.d.ts.map +1 -1
  304. package/out/resolver/types.d.ts +126 -40
  305. package/out/resolver/types.d.ts.map +1 -1
  306. package/out/resolver/types.js +43 -1
  307. package/out/resolver/types.js.map +1 -1
  308. package/out/resolver.d.ts +5 -3
  309. package/out/resolver.d.ts.map +1 -1
  310. package/out/resolver.js +2 -2
  311. package/out/resolver.js.map +1 -1
  312. package/out/resources/git.js +1 -1
  313. package/out/resources/git.js.map +1 -1
  314. package/out/resources/languages.d.ts +0 -1
  315. package/out/resources/languages.d.ts.map +1 -1
  316. package/out/resources/languages.js +0 -1
  317. package/out/resources/languages.js.map +1 -1
  318. package/out/resources/libpostal.d.ts +1 -1
  319. package/out/resources/libpostal.d.ts.map +1 -1
  320. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
  321. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  322. package/out/resources/whosonfirst/PlacetypeDataSource.js +2 -1
  323. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  324. package/out/resources/whosonfirst/extract-repo.d.ts.map +1 -1
  325. package/out/resources/whosonfirst/extract-repo.js +2 -1
  326. package/out/resources/whosonfirst/extract-repo.js.map +1 -1
  327. package/out/resources/whosonfirst/placetypes/admin.d.ts +12 -12
  328. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  329. package/out/resources/whosonfirst/placetypes/admin.js +9 -8
  330. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  331. package/out/resources/whosonfirst/placetypes/mermaid.d.ts +2 -1
  332. package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
  333. package/out/resources/whosonfirst/placetypes/mermaid.js +1 -1
  334. package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
  335. package/out/resources/whosonfirst/placetypes/specificity.d.ts +3 -3
  336. package/out/resources/whosonfirst/placetypes/specificity.d.ts.map +1 -1
  337. package/out/resources/whosonfirst/placetypes/specificity.js +6 -6
  338. package/out/resources/whosonfirst/placetypes/specificity.js.map +1 -1
  339. package/out/resources.d.ts +1 -0
  340. package/out/resources.d.ts.map +1 -1
  341. package/out/resources.js +1 -0
  342. package/out/resources.js.map +1 -1
  343. package/out/scripting/arguments.d.ts +5 -4
  344. package/out/scripting/arguments.d.ts.map +1 -1
  345. package/out/scripting/arguments.js +5 -4
  346. package/out/scripting/arguments.js.map +1 -1
  347. package/out/scripting/command.d.ts +2 -2
  348. package/out/scripting/command.d.ts.map +1 -1
  349. package/out/scripting/command.js +1 -0
  350. package/out/scripting/command.js.map +1 -1
  351. package/out/scripting/operation.d.ts +1 -1
  352. package/out/scripting/operation.d.ts.map +1 -1
  353. package/out/scripting/operation.js +1 -1
  354. package/out/scripting/operation.js.map +1 -1
  355. package/out/scripting/utils.d.ts +3 -4
  356. package/out/scripting/utils.d.ts.map +1 -1
  357. package/out/scripting/utils.js +3 -4
  358. package/out/scripting/utils.js.map +1 -1
  359. package/out/strings/python-json.js +1 -1
  360. package/out/strings/python-json.js.map +1 -1
  361. package/out/tokenization/Span.d.ts +1 -1
  362. package/out/tokenization/Span.d.ts.map +1 -1
  363. package/out/tools/coarse-placer/build/dataset.d.ts +4 -2
  364. package/out/tools/coarse-placer/build/dataset.d.ts.map +1 -1
  365. package/out/tools/coarse-placer/build/dataset.js.map +1 -1
  366. package/out/tools/coarse-placer/build/outlier/exposure.d.ts +5 -3
  367. package/out/tools/coarse-placer/build/outlier/exposure.d.ts.map +1 -1
  368. package/out/tools/coarse-placer/build/outlier/exposure.js.map +1 -1
  369. package/out/tools/coarse-placer/build/outlier/latin.d.ts +3 -3
  370. package/out/tools/coarse-placer/build/outlier/oa.d.ts +3 -3
  371. package/out/tools/coarse-placer/eval/latin-offmap.d.ts +3 -3
  372. package/out/tools/coarse-placer/eval/openset.js +2 -2
  373. package/out/tools/coarse-placer/eval/openset.js.map +1 -1
  374. package/out/tools/coarse-placer/eval/quant-compare.d.ts +4 -4
  375. package/out/tools/coarse-placer/eval.d.ts +3 -3
  376. package/out/tools/coarse-placer/paths.js +1 -1
  377. package/out/tools/coarse-placer/paths.js.map +1 -1
  378. package/out/tools/coarse-placer/probe-frontier.d.ts +2 -2
  379. package/out/tools/coarse-placer/quantize.d.ts +2 -2
  380. package/out/tools/coarse-placer/train.d.ts +5 -5
  381. package/out/tools/download/libpostal-resources.d.ts.map +1 -1
  382. package/out/tools/download/libpostal-resources.js +2 -1
  383. package/out/tools/download/libpostal-resources.js.map +1 -1
  384. package/out/tools/download/ssl-address.d.ts +2 -2
  385. package/out/tools/generate-language-types.d.ts +1 -1
  386. package/out/tools/generate-language-types.js +1 -1
  387. package/out/tools/generate-language-types.js.map +1 -1
  388. package/out/trust-policies.d.ts +0 -1
  389. package/out/trust-policies.d.ts.map +1 -1
  390. package/out/trust-policies.js +0 -1
  391. package/out/trust-policies.js.map +1 -1
  392. package/out/types/Classification.d.ts +1 -1
  393. package/out/types/Classification.d.ts.map +1 -1
  394. package/out/types/classifier.d.ts +1 -1
  395. package/out/types/classifier.d.ts.map +1 -1
  396. package/out/utils/geodatabase-archive.d.ts +11 -4
  397. package/out/utils/geodatabase-archive.d.ts.map +1 -1
  398. package/out/utils/geodatabase-archive.js +1 -1
  399. package/out/utils/geodatabase-archive.js.map +1 -1
  400. package/out/utils/sqlite-rows.d.ts +2 -2
  401. package/out/utils/sqlite-rows.d.ts.map +1 -1
  402. package/out/utils/sqlite-rows.js +2 -2
  403. package/out/utils/sqlite-rows.js.map +1 -1
  404. package/out/utils/stream-to-disk.d.ts.map +1 -1
  405. package/out/utils/stream-to-disk.js +1 -1
  406. package/out/utils/stream-to-disk.js.map +1 -1
  407. package/out/utils/union-find.js +1 -1
  408. package/out/utils/union-find.js.map +1 -1
  409. package/out/vale.js +1 -1
  410. package/out/vale.js.map +1 -1
  411. package/out/workspaces.d.ts +1 -1
  412. package/out/workspaces.js +1 -1
  413. package/out/workspaces.js.map +1 -1
  414. package/package.json +46 -14
  415. package/tools/coarse-placer/build/dataset.ts +4 -2
  416. package/tools/coarse-placer/build/outlier/exposure.ts +5 -3
  417. package/tools/coarse-placer/build/outlier/latin.ts +3 -3
  418. package/tools/coarse-placer/build/outlier/oa.ts +3 -3
  419. package/tools/coarse-placer/eval/latin-offmap.ts +3 -3
  420. package/tools/coarse-placer/eval/openset.ts +3 -3
  421. package/tools/coarse-placer/eval/quant-compare.ts +4 -4
  422. package/tools/coarse-placer/eval.ts +3 -3
  423. package/tools/coarse-placer/paths.ts +1 -1
  424. package/tools/coarse-placer/probe-frontier.ts +2 -2
  425. package/tools/coarse-placer/quantize.ts +2 -2
  426. package/tools/coarse-placer/train.ts +5 -5
  427. package/tools/download/libpostal-resources.ts +2 -1
  428. package/tools/download/ssl-address.ts +2 -2
  429. package/tools/generate-language-types.ts +3 -3
@@ -37,21 +37,21 @@ export type SpanDeltaKind = "added" | "removed" | "retagged" | "moved" | "confid
37
37
  export interface SpanDelta {
38
38
  kind: SpanDeltaKind
39
39
  /**
40
- * The tag on each side: equal unless `kind` is `retagged`, and one side is absent for `added`/`removed`.
40
+ * The tag on each side: equal unless `kind` is `retagged`, and one side is `null` for `added`/`removed`.
41
41
  */
42
- tagBefore?: string
43
- tagAfter?: string
44
- valueBefore?: string
45
- valueAfter?: string
46
- spanBefore?: [number, number]
47
- spanAfter?: [number, number]
48
- confidenceBefore?: number
49
- confidenceAfter?: number
42
+ tagBefore: string | null
43
+ tagAfter: string | null
44
+ valueBefore: string | null
45
+ valueAfter: string | null
46
+ spanBefore: [number, number] | null
47
+ spanAfter: [number, number] | null
48
+ confidenceBefore: number | null
49
+ confidenceAfter: number | null
50
50
  /**
51
- * `after - before`, present only when both sides are.
51
+ * `after - before`, `null` unless both sides are present.
52
52
  * Negative means the arm under test is less sure.
53
53
  */
54
- confidenceDelta?: number
54
+ confidenceDelta: number | null
55
55
  /**
56
56
  * Where the assertion came from — `rule`, `neural`, `resolver`.
57
57
  *
@@ -59,10 +59,10 @@ export interface SpanDelta {
59
59
  * That change removes its gazetteer backing.
60
60
  * A tag-level diff cannot show it.
61
61
  */
62
- sourceBefore?: string
63
- sourceAfter?: string
64
- sourceIDBefore?: string
65
- sourceIDAfter?: string
62
+ sourceBefore: string | null
63
+ sourceAfter: string | null
64
+ sourceIDBefore: string | null
65
+ sourceIDAfter: string | null
66
66
  }
67
67
 
68
68
  /**
@@ -84,8 +84,8 @@ export interface ParseDiff {
84
84
  * A parse that changed no other component but moved its country confidence across
85
85
  * the scope threshold will geocode somewhere else entirely.
86
86
  */
87
- localeCountryBefore?: { country: string; confidence: number }
88
- localeCountryAfter?: { country: string; confidence: number }
87
+ localeCountryBefore: { country: string; confidence: number } | null
88
+ localeCountryAfter: { country: string; confidence: number } | null
89
89
  /**
90
90
  * True when no span changed and the locale call is identical — the arms agree on this input.
91
91
  */
@@ -98,8 +98,8 @@ interface Flat {
98
98
  start: number
99
99
  end: number
100
100
  confidence: number
101
- source?: string
102
- sourceID?: string
101
+ source: string | null
102
+ sourceID: string | null
103
103
  }
104
104
 
105
105
  function toFlat(tree: AddressTree | null | undefined): Flat[] {
@@ -109,8 +109,8 @@ function toFlat(tree: AddressTree | null | undefined): Flat[] {
109
109
  start: node.start,
110
110
  end: node.end,
111
111
  confidence: node.confidence,
112
- ...(node.source === undefined ? {} : { source: node.source }),
113
- ...(node.sourceID === undefined ? {} : { sourceID: node.sourceID }),
112
+ source: node.source ?? null,
113
+ sourceID: node.sourceID ?? null,
114
114
  }))
115
115
  }
116
116
 
@@ -201,10 +201,10 @@ export function diffParse(
201
201
  confidenceBefore: left.confidence,
202
202
  confidenceAfter: right.confidence,
203
203
  confidenceDelta: right.confidence - left.confidence,
204
- ...(left.source === undefined ? {} : { sourceBefore: left.source }),
205
- ...(right.source === undefined ? {} : { sourceAfter: right.source }),
206
- ...(left.sourceID === undefined ? {} : { sourceIDBefore: left.sourceID }),
207
- ...(right.sourceID === undefined ? {} : { sourceIDAfter: right.sourceID }),
204
+ sourceBefore: left.source,
205
+ sourceAfter: right.source,
206
+ sourceIDBefore: left.sourceID,
207
+ sourceIDAfter: right.sourceID,
208
208
  })
209
209
  }
210
210
 
@@ -214,10 +214,18 @@ export function diffParse(
214
214
  spans.push({
215
215
  kind: "removed",
216
216
  tagBefore: left.tag,
217
+ tagAfter: null,
217
218
  valueBefore: left.value,
219
+ valueAfter: null,
218
220
  spanBefore: [left.start, left.end],
221
+ spanAfter: null,
219
222
  confidenceBefore: left.confidence,
220
- ...(left.source === undefined ? {} : { sourceBefore: left.source }),
223
+ confidenceAfter: null,
224
+ confidenceDelta: null,
225
+ sourceBefore: left.source,
226
+ sourceAfter: null,
227
+ sourceIDBefore: left.sourceID,
228
+ sourceIDAfter: null,
221
229
  })
222
230
  }
223
231
 
@@ -226,11 +234,19 @@ export function diffParse(
226
234
 
227
235
  spans.push({
228
236
  kind: "added",
237
+ tagBefore: null,
229
238
  tagAfter: right.tag,
239
+ valueBefore: null,
230
240
  valueAfter: right.value,
241
+ spanBefore: null,
231
242
  spanAfter: [right.start, right.end],
243
+ confidenceBefore: null,
232
244
  confidenceAfter: right.confidence,
233
- ...(right.source === undefined ? {} : { sourceAfter: right.source }),
245
+ confidenceDelta: null,
246
+ sourceBefore: null,
247
+ sourceAfter: right.source,
248
+ sourceIDBefore: null,
249
+ sourceIDAfter: right.sourceID,
234
250
  })
235
251
  }
236
252
 
@@ -243,8 +259,8 @@ export function diffParse(
243
259
  return {
244
260
  input,
245
261
  spans,
246
- ...(locale?.before ? { localeCountryBefore: locale.before } : {}),
247
- ...(locale?.after ? { localeCountryAfter: locale.after } : {}),
262
+ localeCountryBefore: locale?.before ?? null,
263
+ localeCountryAfter: locale?.after ?? null,
248
264
  identical: !spans.some(isChange) && !localeMoved,
249
265
  }
250
266
  }
@@ -269,7 +285,7 @@ export function renderParseDiff(diff: ParseDiff, options: { context?: boolean }
269
285
  return lines.join("\n")
270
286
  }
271
287
 
272
- const conf = (value?: number): string => (value === undefined ? "—" : value.toFixed(2))
288
+ const conf = (value: number | null): string => (value === null ? "—" : value.toFixed(2))
273
289
 
274
290
  for (const span of diff.spans) {
275
291
  if (span.kind === "unchanged" && !options.context) continue
@@ -331,7 +347,7 @@ export function renderParseDiff(diff: ParseDiff, options: { context?: boolean }
331
347
 
332
348
  if (moved) {
333
349
  lines.push(
334
- ` ! locale country ${lb?.country ?? "—"} (${conf(lb?.confidence)}) → ${la?.country ?? "—"} (${conf(la?.confidence)})`
350
+ ` ! locale country ${lb?.country ?? "—"} (${conf(lb?.confidence ?? null)}) → ${la?.country ?? "—"} (${conf(la?.confidence ?? null)})`
335
351
  )
336
352
  }
337
353
  }
@@ -64,6 +64,7 @@ export function treeToProposals(
64
64
  source,
65
65
  source_id: sourceID ?? node.sourceID ?? source,
66
66
  penalty: 0,
67
+ metadata: null,
67
68
  })
68
69
  }
69
70
 
@@ -16,9 +16,10 @@
16
16
  */
17
17
 
18
18
  import type { ComponentTag } from "@mailwoman/codex/component"
19
+ import { z } from "zod"
19
20
 
20
21
  import { slotNodes } from "#decoder/tree/walk"
21
- import type { AddressNode, AddressTree } from "#decoder/types"
22
+ import { type AddressNode, type AddressTree, ComponentTagSchema } from "#decoder/types"
22
23
  import { type UnknownSpan, unknownSpans } from "#decoder/unknown-spans"
23
24
 
24
25
  /**
@@ -31,22 +32,24 @@ import { type UnknownSpan, unknownSpans } from "#decoder/unknown-spans"
31
32
  * `region: null` can mean the input had no region.
32
33
  * It can also mean the projection dropped an input region.
33
34
  */
34
- export interface DroppedSpan {
35
+ export const DroppedSpanSchema = z.object({
35
36
  /**
36
37
  * The tag stored on the span.
37
38
  *
38
39
  * It is always one already present in the output, because a drop happens only when the slot was taken.
39
40
  */
40
- tag: ComponentTag
41
+ tag: ComponentTagSchema,
41
42
  /**
42
43
  * The value that was discarded.
43
44
  */
44
- value: string
45
+ value: z.string(),
45
46
  /**
46
47
  * The value that held the slot, so a reader can see which of the two survived without re-walking the tree.
47
48
  */
48
- kept: string
49
- }
49
+ kept: z.string(),
50
+ })
51
+
52
+ export type DroppedSpan = z.infer<typeof DroppedSpanSchema>
50
53
 
51
54
  /**
52
55
  * Options for {@link decodeAsJSON}.
@@ -22,8 +22,9 @@ export interface SerializeTuplesOpts {
22
22
  /**
23
23
  * Interleave `["unknown", value]` tuples for the all-O spans the model left unclassified, in source order.
24
24
  *
25
- * Default false keeps the tag-only shape.
26
25
  * The caller can request the gaps.
26
+ *
27
+ * @defaultValue `false`, which keeps the tag-only shape.
27
28
  */
28
29
  includeUnknown?: boolean
29
30
  }
@@ -33,37 +33,37 @@ export interface SerializeXMLOpts {
33
33
  /**
34
34
  * Pretty-print with line breaks and indentation.
35
35
  *
36
- * Default true.
36
+ * @defaultValue `true`
37
37
  */
38
38
  pretty?: boolean
39
39
  /**
40
40
  * Include `conf` attribute on every component.
41
41
  *
42
- * Default true.
42
+ * @defaultValue `true`
43
43
  */
44
44
  includeConf?: boolean
45
45
  /**
46
46
  * Include `start` + `end` char-offset attributes.
47
47
  *
48
- * Default true.
48
+ * @defaultValue `true`
49
49
  */
50
50
  includeOffsets?: boolean
51
51
  /**
52
52
  * Include `src` provenance attribute when the node has source info.
53
53
  *
54
- * Default true.
54
+ * @defaultValue `true`
55
55
  */
56
56
  includeSrc?: boolean
57
57
  /**
58
58
  * Include `lat` + `lon` resolver-supplied centroid attrs when set on the node.
59
59
  *
60
- * Default true.
60
+ * @defaultValue `true`
61
61
  */
62
62
  includeGeo?: boolean
63
63
  /**
64
64
  * Include `place` resolver-supplied normalized place URI when set.
65
65
  *
66
- * Default true.
66
+ * @defaultValue `true`
67
67
  */
68
68
  includePlace?: boolean
69
69
  /**
@@ -71,17 +71,18 @@ export interface SerializeXMLOpts {
71
71
  *
72
72
  * When set and `node.alternatives` is populated, each runner-up is emitted as a
73
73
  * self-closing element with `place`, `name`, `lat`, `lon`, `score` attributes.
74
- * Default false keeps the output libpostal-compatible unless the caller asks.
74
+ *
75
+ * @defaultValue `false`, which keeps the output libpostal-compatible unless the caller asks.
75
76
  */
76
77
  includeAlternatives?: boolean
77
78
  /**
78
79
  * Emit `<unknown start end>…</unknown>` elements for all-O runs that no node covers.
79
80
  * Those runs contain input the model left unclassified.
80
81
  *
81
- * Interleaved with the root components in source order, so the `<address>`
82
- * children tile the raw input exactly.
83
- * Default false keeps the output libpostal-compatible unless the caller asks.
84
- * {@link includeAlternatives} uses the same default.
82
+ * Interleaved with the root components in source order, so the `<address>` children
83
+ * tile the raw input exactly. {@link includeAlternatives} uses the same default.
84
+ *
85
+ * @defaultValue `false`, which keeps the output libpostal-compatible unless the caller asks.
85
86
  */
86
87
  includeUnknown?: boolean
87
88
  }
@@ -129,7 +130,7 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
129
130
  if (opts.includeSrc) {
130
131
  const src = srcAttrValue(node)
131
132
 
132
- if (src !== null) {
133
+ if (src) {
133
134
  parts.push(`src="${escapeXml(src)}"`)
134
135
  }
135
136
  }
@@ -141,7 +142,7 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
141
142
  parts.push(`lat="${node.lat.toFixed(GEO_PRECISION)}"`, `lon="${node.lon.toFixed(GEO_PRECISION)}"`)
142
143
  }
143
144
 
144
- if (opts.includePlace && node.placeID !== undefined) {
145
+ if (opts.includePlace && node.placeID) {
145
146
  parts.push(`place="${escapeXml(node.placeID)}"`)
146
147
  }
147
148
 
@@ -153,7 +154,7 @@ function attrs(node: AddressNode, opts: Required<SerializeXMLOpts>): string {
153
154
  parts.push(`roles="${escapeXml(roles.join(" "))}"`)
154
155
  }
155
156
 
156
- return !parts.length ? "" : " " + parts.join(" ")
157
+ return parts.length ? " " + parts.join(" ") : ""
157
158
  }
158
159
 
159
160
  interface AlternativeLike {
@@ -48,8 +48,8 @@ export function loneValueNode(tree: AddressTree): AddressNode | null {
48
48
  let lone: AddressNode | null = null
49
49
 
50
50
  for (const node of walkNodes(tree.roots)) {
51
- if (node.value.trim().length) {
52
- if (lone !== null) return null
51
+ if (node.value.trim()) {
52
+ if (lone) return null
53
53
  lone = node
54
54
  }
55
55
  }
@@ -77,8 +77,8 @@ export interface FlatTreeNode {
77
77
  * source moves from `resolver` to `neural` has lost its gazetteer backing.
78
78
  * A projection that drops this reports that span as unchanged.
79
79
  */
80
- source?: string
81
- sourceID?: string
80
+ source: string | null
81
+ sourceID: string | null
82
82
  /**
83
83
  * The resolver's answer for this span, when one won.
84
84
  *
@@ -91,10 +91,10 @@ export interface FlatTreeNode {
91
91
  *
92
92
  * Candidate objects would invite a walk that this projection already performed.
93
93
  */
94
- placeID?: string
95
- lat?: number
96
- lon?: number
97
- alternatives?: number
94
+ placeID: string | null
95
+ lat: number | null
96
+ lon: number | null
97
+ alternatives: number | null
98
98
  }
99
99
 
100
100
  /**
@@ -123,12 +123,12 @@ export function flattenTreeNodes(tree?: AddressTree | null): FlatTreeNode[] {
123
123
  confidence: node.confidence,
124
124
  start: node.start,
125
125
  end: node.end,
126
- ...(node.source === undefined ? {} : { source: node.source }),
127
- ...(node.sourceID === undefined ? {} : { sourceID: node.sourceID }),
128
- ...(node.placeID === undefined ? {} : { placeID: node.placeID }),
129
- ...(node.lat === undefined ? {} : { lat: node.lat }),
130
- ...(node.lon === undefined ? {} : { lon: node.lon }),
131
- ...(node.alternatives === undefined ? {} : { alternatives: node.alternatives.length }),
126
+ source: node.source ?? null,
127
+ sourceID: node.sourceID ?? null,
128
+ placeID: node.placeID ?? null,
129
+ lat: node.lat ?? null,
130
+ lon: node.lon ?? null,
131
+ alternatives: node.alternatives?.length ?? null,
132
132
  }))
133
133
  .toSorted((a, b) => a.start - b.start)
134
134
  }
@@ -119,6 +119,6 @@ export function slotNodes(roots: readonly AddressNode[]): AddressNode[] {
119
119
  export function firstNodeWhere(
120
120
  roots: readonly AddressNode[],
121
121
  predicate: (node: AddressNode) => unknown
122
- ): AddressNode | undefined {
123
- return walkNodes(roots).find(predicate)
122
+ ): AddressNode | null {
123
+ return walkNodes(roots).find(predicate) ?? null
124
124
  }
@@ -6,7 +6,10 @@
6
6
  * Types for decoded address trees and the labeled tokens they are built from.
7
7
  */
8
8
 
9
- import type { BIOLabel, ComponentTag } from "@mailwoman/codex/component"
9
+ import { type BIOLabel, COMPONENT_TAGS, type ComponentTag } from "@mailwoman/codex/component"
10
+ import { z } from "zod"
11
+
12
+ import { isRecordLike } from "#objects"
10
13
 
11
14
  /**
12
15
  * One token with its predicted label, confidence and offsets into the original input.
@@ -108,6 +111,48 @@ export interface Interpretation {
108
111
  metadata?: Record<string, unknown>
109
112
  }
110
113
 
114
+ /**
115
+ * Every recognized address component tag, as a schema.
116
+ */
117
+ export const ComponentTagSchema = z
118
+ .enum(COMPONENT_TAGS)
119
+ .meta({ id: "ComponentTag", description: "A recognized address component tag." })
120
+
121
+ /**
122
+ * The wire schema of an {@link AddressNode}.
123
+ *
124
+ * The node is recursive, so the schema checks only that the value is an object and documents the rest.
125
+ */
126
+ export const AddressNodeSchema = z.custom<AddressNode>(isRecordLike).meta({
127
+ id: "AddressNode",
128
+ type: "object",
129
+ additionalProperties: true,
130
+ description: "A decoded address-tree node: a tag, its span, and its children.",
131
+ })
132
+
133
+ /**
134
+ * The wire schema of an {@link AddressTree}.
135
+ */
136
+ export const AddressTreeSchema = z.custom<AddressTree>(isRecordLike).meta({
137
+ id: "AddressTree",
138
+ type: "object",
139
+ properties: { raw: { type: "string" }, roots: { type: "array", items: { type: "object" } } },
140
+ required: ["raw", "roots"],
141
+ additionalProperties: true,
142
+ description: "A decoded address: the raw input and its top-level component nodes.",
143
+ })
144
+
145
+ /**
146
+ * One parsed component in reading order: a `ComponentTag` and the text it covers.
147
+ *
148
+ * HTTP surfaces put a list of these beside the full {@link AddressTree}.
149
+ */
150
+ export const ParseComponentSchema = z
151
+ .object({ tag: z.string(), value: z.string() })
152
+ .meta({ id: "ParseComponent", description: "One parsed component in reading order." })
153
+
154
+ export type ParseComponent = z.infer<typeof ParseComponentSchema>
155
+
111
156
  /**
112
157
  * A decoded address with its top-level components in source order.
113
158
  */
@@ -119,7 +164,8 @@ export interface AddressTree {
119
164
  roots: AddressNode[]
120
165
  /**
121
166
  * The addressing system that selects the containment hierarchy.
122
- * The default is the Western hierarchy.
167
+ *
168
+ * @defaultValue the Western hierarchy.
123
169
  */
124
170
  system?: AddressSystem
125
171
  /**
package/lib/env/schema.ts CHANGED
@@ -7,45 +7,45 @@
7
7
  * that reads its own variables declares them beside its readers and extends these views with `liveEnv`.
8
8
  */
9
9
 
10
- import { z } from "zod"
10
+ import { object, string } from "zod"
11
11
 
12
12
  import { DefaultMailwomanPaths } from "#env/paths"
13
13
  import { blankAsAbsent } from "#env/utils"
14
14
 
15
15
  // #region Public
16
16
 
17
- const StorageEnvSchema = z.object({
17
+ const StorageEnvSchema = object({
18
18
  // Platform-native application directories.
19
19
  // Environment values override these defaults.
20
20
  //
21
21
  // A bare `.default()` fires only on `undefined`, so a present-but-empty variable passes validation intact.
22
- MAILWOMAN_DATA_ROOT: blankAsAbsent(z.string().default(DefaultMailwomanPaths.data)).meta({
22
+ MAILWOMAN_DATA_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.data)).meta({
23
23
  title: "Data root",
24
24
  description: "Root directory for downloaded Mailwoman data and runtime artifacts.",
25
25
  }),
26
- MAILWOMAN_CONFIG_ROOT: blankAsAbsent(z.string().default(DefaultMailwomanPaths.config)).meta({
26
+ MAILWOMAN_CONFIG_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.config)).meta({
27
27
  title: "Config root",
28
28
  description: "Directory for Mailwoman configuration files.",
29
29
  }),
30
- MAILWOMAN_CACHE_ROOT: blankAsAbsent(z.string().default(DefaultMailwomanPaths.cache)).meta({
30
+ MAILWOMAN_CACHE_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.cache)).meta({
31
31
  title: "Cache root",
32
32
  description: "Directory for reusable downloaded and generated caches.",
33
33
  }),
34
- MAILWOMAN_TEMP_ROOT: blankAsAbsent(z.string().default(DefaultMailwomanPaths.temp)).meta({
34
+ MAILWOMAN_TEMP_ROOT: blankAsAbsent(string().default(DefaultMailwomanPaths.temp)).meta({
35
35
  title: "Temporary root",
36
36
  description: "Directory for named temporary outputs and evaluation staging.",
37
37
  }),
38
38
  })
39
39
 
40
- const RuntimeEnvSchema = z.object({
41
- MAILWOMAN_COARSE_PLACER_DIR: z.string().optional().meta({
40
+ const RuntimeEnvSchema = object({
41
+ MAILWOMAN_COARSE_PLACER_DIR: string().optional().meta({
42
42
  title: "Coarse placer directory",
43
43
  description: "Directory containing the coarse country-placement model artifacts.",
44
44
  }),
45
45
  })
46
46
 
47
- const LicenseEnvSchema = z.object({
48
- MAILWOMAN_DOCS_URL: z.string().optional().meta({
47
+ const LicenseEnvSchema = object({
48
+ MAILWOMAN_DOCS_URL: string().optional().meta({
49
49
  title: "Documentation URL",
50
50
  description: "Base URL used by documentation and demo tooling.",
51
51
  }),
@@ -61,7 +61,7 @@ const LicenseEnvSchema = z.object({
61
61
  * Public in the sense that it is a signed assertion rather than a secret,
62
62
  * but the doctor prints the licensee and expiry rather than the token.
63
63
  */
64
- MAILWOMAN_LICENSE_KEY: blankAsAbsent(z.string().min(1).optional()).meta({
64
+ MAILWOMAN_LICENSE_KEY: blankAsAbsent(string().min(1).optional()).meta({
65
65
  title: "Commercial license key",
66
66
  description: "Signed commercial license assertion used by `mailwoman doctor`; it does not change runtime behavior.",
67
67
  }),
@@ -71,7 +71,7 @@ const LicenseEnvSchema = z.object({
71
71
  *
72
72
  * Pointed at a sandbox deploy or a test stub.
73
73
  */
74
- MAILWOMAN_LICENSE_URL: blankAsAbsent(z.string().min(1).optional()).meta({
74
+ MAILWOMAN_LICENSE_URL: blankAsAbsent(string().min(1).optional()).meta({
75
75
  title: "License service URL",
76
76
  description: "License-service origin used by license refresh and online status checks.",
77
77
  }),
@@ -82,16 +82,14 @@ const LicenseEnvSchema = z.object({
82
82
  *
83
83
  * The schema strips any other key from `process.env` during parsing.
84
84
  */
85
- export const PublicEnvSchema = z
86
- .object({
87
- ...StorageEnvSchema.shape,
88
- ...RuntimeEnvSchema.shape,
89
- ...LicenseEnvSchema.shape,
90
- })
91
- .meta({
92
- title: "Public environment configuration",
93
- description: "Non-secret operational configuration exposed through `$public`.",
94
- })
85
+ export const PublicEnvSchema = object({
86
+ ...StorageEnvSchema.shape,
87
+ ...RuntimeEnvSchema.shape,
88
+ ...LicenseEnvSchema.shape,
89
+ }).meta({
90
+ title: "Public environment configuration",
91
+ description: "Non-secret operational configuration exposed through `$public`.",
92
+ })
95
93
 
96
94
  // #endregion
97
95
 
@@ -103,7 +101,7 @@ export const PublicEnvSchema = z
103
101
  * Core reads none: this is the base every package's private view extends,
104
102
  * so a credential is declared once, beside the code that sends it.
105
103
  */
106
- export const PrivateEnvSchema = z.object({}).meta({
104
+ export const PrivateEnvSchema = object({}).meta({
107
105
  title: "Private environment configuration",
108
106
  description: "Secrets and credentials exposed through `$private`; never log their values.",
109
107
  })
package/lib/env/utils.ts CHANGED
@@ -6,7 +6,8 @@
6
6
  * Utility functions for working with the runtime environment.
7
7
  */
8
8
 
9
- import { z } from "zod"
9
+ import { preprocess } from "zod"
10
+ import type { ZodType } from "zod"
10
11
 
11
12
  /**
12
13
  * Wrap a coerced schema so a blank value means the same as an absent one: a shell `export FOO=`,
@@ -17,6 +18,6 @@ import { z } from "zod"
17
18
  * The `.optional()`/`.default()` must be applied to `inner` before it reaches here,
18
19
  * because the outer value is present and an outer `.optional()` never fires.
19
20
  */
20
- export function blankAsAbsent<T extends z.ZodType>(inner: T) {
21
- return z.preprocess((v) => (v === "" ? undefined : v), inner)
21
+ export function blankAsAbsent<T extends ZodType>(inner: T) {
22
+ return preprocess((v) => (v === "" ? undefined : v), inner)
22
23
  }
package/lib/env.ts CHANGED
@@ -56,8 +56,8 @@ export function liveEnv<Shape extends z.ZodRawShape, Base extends object = Recor
56
56
  // Keep the object wrapper so validation issues still identify the environment variable by name.
57
57
  const fieldSchema = schema.pick({ [key]: true } as Parameters<typeof schema.pick>[0])
58
58
 
59
- let previous: string | undefined
60
- let cached: ReturnType<typeof fieldSchema.safeParse> | undefined
59
+ let previous: string | null = null
60
+ let cached: ReturnType<typeof fieldSchema.safeParse> | null = null
61
61
 
62
62
  Object.defineProperty(view, key, {
63
63
  enumerable: true,
@@ -65,9 +65,9 @@ export function liveEnv<Shape extends z.ZodRawShape, Base extends object = Recor
65
65
  // oxlint-disable-next-line sister-software/no-process-globals -- this module is the typed process.env boundary
66
66
  const raw = process.env[key]
67
67
 
68
- if (!cached || raw !== previous) {
68
+ if (!cached || (raw ?? null) !== previous) {
69
69
  cached = fieldSchema.safeParse({ [key]: raw })
70
- previous = raw
70
+ previous = raw ?? null
71
71
  }
72
72
 
73
73
  if (!cached.success) throw cached.error
@@ -11,6 +11,9 @@
11
11
  * Downstream counts cannot distinguish this result from a small source file.
12
12
  *
13
13
  * The GeoNames country dumps are unquoted TSV and contain `"` in place names (`Ovrag Kyzylak"on`).
14
+ *
15
+ * A quote-aware reader of CSV text indexes its header with {@linkcode headerColumnIndex} and passes its
16
+ * record count to {@linkcode checkRecordCount}. A quote that never closes shortens that read in the same way.
14
17
  */
15
18
 
16
19
  import { createReadStream } from "node:fs"
@@ -61,7 +64,7 @@ export async function readUnquotedTSVChecked(path: PathBuilderLike): Promise<str
61
64
 
62
65
  // Streamed rather than split, so the check stays cheap enough that a build step always runs it.
63
66
  for await (const line of TextSpliterator.fromAsync(path)) {
64
- if (line.length) {
67
+ if (line) {
65
68
  expected++
66
69
  }
67
70
  }
@@ -83,6 +86,37 @@ export async function readUnquotedTSVChecked(path: PathBuilderLike): Promise<str
83
86
  return rows
84
87
  }
85
88
 
89
+ /**
90
+ * Maps each label of a header row to its column index, and throws when a label repeats.
91
+ *
92
+ * `file` identifies the file in the error message.
93
+ */
94
+ export function headerColumnIndex(file: string, header: readonly string[]): Map<string, number> {
95
+ const columns = new Map<string, number>()
96
+
97
+ for (const [index, label] of header.entries()) {
98
+ if (columns.has(label)) throw new Error(`${file} repeats the header column "${label}".`)
99
+
100
+ columns.set(label, index)
101
+ }
102
+
103
+ return columns
104
+ }
105
+
106
+ /**
107
+ * Throws when the count of records parsed from a delimited text differs from the text's count of data lines.
108
+ *
109
+ * The first non-empty line of `text` is its header, and each later non-empty line is a data line.
110
+ *
111
+ * A quote-aware reader joins every line after a quote that never closes into one record.
112
+ * The read then answers short with no other sign, so a reader of quoted text compares the two counts.
113
+ */
114
+ export function checkRecordCount(file: string, text: string, records: number): void {
115
+ const dataLines = TextSpliterator.from(text).toArray().length - 1
116
+
117
+ if (records !== dataLines) throw new Error(`${file}: read ${records} records from ${dataLines} data lines.`)
118
+ }
119
+
86
120
  /**
87
121
  * The extension that marks a delimited file as zstd-compressed at rest.
88
122
  */