@mailwoman/core 8.6.0 → 9.1.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 (238) hide show
  1. package/README.md +2 -2
  2. package/api/clock.ts +1 -1
  3. package/api/disk-storage.ts +7 -4
  4. package/api/test-clocks.ts +57 -9
  5. package/api/test-transport.ts +182 -0
  6. package/coarse-placer/coarse-placer.ts +2 -1
  7. package/coarse-placer/tools/build-dataset.ts +2 -2
  8. package/coarse-placer/tools/build-outlier-exposure.ts +2 -2
  9. package/coarse-placer/tools/build-outlier-latin.ts +3 -2
  10. package/coarse-placer/tools/build-outlier-oa.ts +3 -2
  11. package/coarse-placer/tools/eval-latin-offmap.ts +8 -8
  12. package/coarse-placer/tools/eval-openset.ts +20 -12
  13. package/coarse-placer/tools/eval-quant-compare.ts +8 -9
  14. package/coarse-placer/tools/eval.ts +30 -23
  15. package/coarse-placer/tools/probe-frontier.ts +9 -7
  16. package/coarse-placer/tools/quantize.ts +4 -2
  17. package/coarse-placer/tools/train.ts +10 -10
  18. package/collections.ts +2 -128
  19. package/crypto/node.ts +68 -0
  20. package/decoder/build-tree.ts +19 -0
  21. package/env/schema.ts +58 -2
  22. package/fs/zip.ts +297 -0
  23. package/identifiers.ts +48 -0
  24. package/layers/manifest.ts +2 -1
  25. package/locale/profiles/en-us.ts +2 -3
  26. package/locale/profiles/fr-fr.ts +1 -1
  27. package/locale/profiles/ja-jp.ts +7 -7
  28. package/objects.ts +40 -8
  29. package/out/api/clock.d.ts +1 -1
  30. package/out/api/clock.js +1 -1
  31. package/out/api/disk-storage.d.ts +1 -1
  32. package/out/api/disk-storage.d.ts.map +1 -1
  33. package/out/api/disk-storage.js +5 -5
  34. package/out/api/disk-storage.js.map +1 -1
  35. package/out/api/test-clocks.d.ts +2 -2
  36. package/out/api/test-clocks.d.ts.map +1 -1
  37. package/out/api/test-clocks.js +51 -9
  38. package/out/api/test-clocks.js.map +1 -1
  39. package/out/api/test-transport.d.ts +112 -0
  40. package/out/api/test-transport.d.ts.map +1 -0
  41. package/out/api/test-transport.js +84 -0
  42. package/out/api/test-transport.js.map +1 -0
  43. package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
  44. package/out/coarse-placer/coarse-placer.js +2 -1
  45. package/out/coarse-placer/coarse-placer.js.map +1 -1
  46. package/out/coarse-placer/tools/build-dataset.js +1 -2
  47. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  48. package/out/coarse-placer/tools/build-outlier-exposure.js +1 -2
  49. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  50. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  51. package/out/coarse-placer/tools/build-outlier-latin.js +2 -2
  52. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  53. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  54. package/out/coarse-placer/tools/build-outlier-oa.js +2 -2
  55. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  56. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  57. package/out/coarse-placer/tools/eval-latin-offmap.js +5 -8
  58. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  59. package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
  60. package/out/coarse-placer/tools/eval-openset.js +12 -11
  61. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  62. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
  63. package/out/coarse-placer/tools/eval-quant-compare.js +7 -9
  64. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  65. package/out/coarse-placer/tools/eval.d.ts.map +1 -1
  66. package/out/coarse-placer/tools/eval.js +20 -21
  67. package/out/coarse-placer/tools/eval.js.map +1 -1
  68. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  69. package/out/coarse-placer/tools/probe-frontier.js +8 -8
  70. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  71. package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
  72. package/out/coarse-placer/tools/quantize.js +3 -2
  73. package/out/coarse-placer/tools/quantize.js.map +1 -1
  74. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  75. package/out/coarse-placer/tools/train.js +7 -10
  76. package/out/coarse-placer/tools/train.js.map +1 -1
  77. package/out/collections.d.ts +1 -59
  78. package/out/collections.d.ts.map +1 -1
  79. package/out/collections.js +2 -90
  80. package/out/collections.js.map +1 -1
  81. package/out/crypto/node.d.ts +43 -0
  82. package/out/crypto/node.d.ts.map +1 -0
  83. package/out/crypto/node.js +43 -0
  84. package/out/crypto/node.js.map +1 -0
  85. package/out/decoder/build-tree.d.ts.map +1 -1
  86. package/out/decoder/build-tree.js +17 -0
  87. package/out/decoder/build-tree.js.map +1 -1
  88. package/out/env/index.d.ts +8 -0
  89. package/out/env/index.d.ts.map +1 -1
  90. package/out/env/schema.d.ts +9 -1
  91. package/out/env/schema.d.ts.map +1 -1
  92. package/out/env/schema.js +54 -2
  93. package/out/env/schema.js.map +1 -1
  94. package/out/fs/zip.d.ts +116 -0
  95. package/out/fs/zip.d.ts.map +1 -0
  96. package/out/fs/zip.js +216 -0
  97. package/out/fs/zip.js.map +1 -0
  98. package/out/identifiers.d.ts +23 -0
  99. package/out/identifiers.d.ts.map +1 -1
  100. package/out/identifiers.js +39 -0
  101. package/out/identifiers.js.map +1 -1
  102. package/out/layers/manifest.d.ts.map +1 -1
  103. package/out/layers/manifest.js +2 -1
  104. package/out/layers/manifest.js.map +1 -1
  105. package/out/locale/profiles/en-us.d.ts +2 -3
  106. package/out/locale/profiles/en-us.d.ts.map +1 -1
  107. package/out/locale/profiles/en-us.js +2 -3
  108. package/out/locale/profiles/en-us.js.map +1 -1
  109. package/out/locale/profiles/fr-fr.d.ts +1 -1
  110. package/out/locale/profiles/fr-fr.js +1 -1
  111. package/out/locale/profiles/ja-jp.d.ts +7 -7
  112. package/out/locale/profiles/ja-jp.js +7 -7
  113. package/out/objects.d.ts +18 -2
  114. package/out/objects.d.ts.map +1 -1
  115. package/out/objects.js +29 -3
  116. package/out/objects.js.map +1 -1
  117. package/out/pipeline/index.d.ts +2 -2
  118. package/out/pipeline/index.d.ts.map +1 -1
  119. package/out/pipeline/index.js +1 -1
  120. package/out/pipeline/index.js.map +1 -1
  121. package/out/pipeline/runtime-pipeline.d.ts +1 -1
  122. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  123. package/out/pipeline/runtime-pipeline.js +74 -18
  124. package/out/pipeline/runtime-pipeline.js.map +1 -1
  125. package/out/pipeline/span-proposer.d.ts +24 -0
  126. package/out/pipeline/span-proposer.d.ts.map +1 -1
  127. package/out/pipeline/span-proposer.js +36 -1
  128. package/out/pipeline/span-proposer.js.map +1 -1
  129. package/out/pipeline/types.d.ts +155 -3
  130. package/out/pipeline/types.d.ts.map +1 -1
  131. package/out/pipeline/types.js +41 -1
  132. package/out/pipeline/types.js.map +1 -1
  133. package/out/resolver/index.d.ts +3 -1
  134. package/out/resolver/index.d.ts.map +1 -1
  135. package/out/resolver/index.js +1 -0
  136. package/out/resolver/index.js.map +1 -1
  137. package/out/resolver/referential.d.ts +73 -0
  138. package/out/resolver/referential.d.ts.map +1 -0
  139. package/out/resolver/referential.js +71 -0
  140. package/out/resolver/referential.js.map +1 -0
  141. package/out/resolver/types.d.ts +204 -0
  142. package/out/resolver/types.d.ts.map +1 -1
  143. package/out/resolver/types.js.map +1 -1
  144. package/out/resources/index.d.ts +0 -1
  145. package/out/resources/index.d.ts.map +1 -1
  146. package/out/resources/index.js +0 -1
  147. package/out/resources/index.js.map +1 -1
  148. package/out/resources/libpostal.d.ts.map +1 -1
  149. package/out/resources/libpostal.js +3 -4
  150. package/out/resources/libpostal.js.map +1 -1
  151. package/out/resources/whosonfirst/index.d.ts +1 -0
  152. package/out/resources/whosonfirst/index.d.ts.map +1 -1
  153. package/out/resources/whosonfirst/index.js +1 -0
  154. package/out/resources/whosonfirst/index.js.map +1 -1
  155. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  156. package/out/resources/whosonfirst/placetypes/Placetype.js +6 -5
  157. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  158. package/out/resources/whosonfirst/placetypes/admin.d.ts +12 -3
  159. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  160. package/out/resources/whosonfirst/placetypes/admin.js +1 -1
  161. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  162. package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
  163. package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -0
  164. package/out/resources/whosonfirst/sharded-repo.js +58 -0
  165. package/out/resources/whosonfirst/sharded-repo.js.map +1 -0
  166. package/out/scripting/utils/index.d.ts.map +1 -1
  167. package/out/scripting/utils/index.js +2 -2
  168. package/out/scripting/utils/index.js.map +1 -1
  169. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  170. package/out/tools/download-libpostal-resources.js +1 -0
  171. package/out/tools/download-libpostal-resources.js.map +1 -1
  172. package/out/tools/generate-language-types.d.ts.map +1 -1
  173. package/out/tools/generate-language-types.js +5 -11
  174. package/out/tools/generate-language-types.js.map +1 -1
  175. package/out/utils/data-root.d.ts +20 -6
  176. package/out/utils/data-root.d.ts.map +1 -1
  177. package/out/utils/data-root.js +24 -5
  178. package/out/utils/data-root.js.map +1 -1
  179. package/out/utils/hash.d.ts +6 -0
  180. package/out/utils/hash.d.ts.map +1 -1
  181. package/out/utils/hash.js +8 -0
  182. package/out/utils/hash.js.map +1 -1
  183. package/out/utils/index.d.ts +1 -0
  184. package/out/utils/index.d.ts.map +1 -1
  185. package/out/utils/index.js +1 -0
  186. package/out/utils/index.js.map +1 -1
  187. package/out/utils/jsonl.d.ts +17 -3
  188. package/out/utils/jsonl.d.ts.map +1 -1
  189. package/out/utils/jsonl.js +23 -6
  190. package/out/utils/jsonl.js.map +1 -1
  191. package/out/utils/python-json.d.ts +3 -3
  192. package/out/utils/python-json.js +9 -9
  193. package/out/utils/python-numeric.d.ts +33 -0
  194. package/out/utils/python-numeric.d.ts.map +1 -0
  195. package/out/utils/python-numeric.js +149 -0
  196. package/out/utils/python-numeric.js.map +1 -0
  197. package/out/utils/python-random.d.ts +26 -1
  198. package/out/utils/python-random.d.ts.map +1 -1
  199. package/out/utils/python-random.js +43 -7
  200. package/out/utils/python-random.js.map +1 -1
  201. package/out/utils/repo.d.ts.map +1 -1
  202. package/out/utils/repo.js +18 -0
  203. package/out/utils/repo.js.map +1 -1
  204. package/out/utils/sealed-db.d.ts +12 -0
  205. package/out/utils/sealed-db.d.ts.map +1 -1
  206. package/out/utils/sealed-db.js +32 -1
  207. package/out/utils/sealed-db.js.map +1 -1
  208. package/package.json +34 -7
  209. package/pipeline/index.ts +3 -1
  210. package/pipeline/runtime-pipeline.ts +88 -27
  211. package/pipeline/span-proposer.ts +64 -1
  212. package/pipeline/types.ts +160 -2
  213. package/resolver/index.ts +13 -0
  214. package/resolver/referential.ts +84 -0
  215. package/resolver/types.ts +207 -0
  216. package/resources/index.ts +0 -1
  217. package/resources/libpostal.ts +8 -7
  218. package/resources/whosonfirst/index.ts +1 -0
  219. package/resources/whosonfirst/placetypes/Placetype.ts +13 -8
  220. package/resources/whosonfirst/placetypes/admin.ts +12 -2
  221. package/resources/whosonfirst/sharded-repo.ts +69 -0
  222. package/scripting/utils/index.ts +2 -3
  223. package/tools/download-libpostal-resources.ts +1 -0
  224. package/tools/generate-language-types.ts +5 -14
  225. package/utils/data-root.ts +27 -6
  226. package/utils/hash.ts +9 -0
  227. package/utils/index.ts +1 -0
  228. package/utils/jsonl.ts +26 -7
  229. package/utils/python-json.ts +10 -10
  230. package/utils/python-numeric.ts +168 -0
  231. package/utils/python-random.ts +49 -8
  232. package/utils/repo.ts +18 -0
  233. package/utils/sealed-db.ts +38 -1
  234. package/out/resources/collections.d.ts +0 -22
  235. package/out/resources/collections.d.ts.map +0 -1
  236. package/out/resources/collections.js +0 -69
  237. package/out/resources/collections.js.map +0 -1
  238. package/resources/collections.ts +0 -96
@@ -0,0 +1,116 @@
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
+ import ADMZip from "adm-zip";
18
+ import type { PathBuilderLike } from "path-ts";
19
+ export type ZipEntryContentPair = [entry: ADMZip.IZipEntry, content: Buffer];
20
+ /**
21
+ * Extract the contents of a zip file.
22
+ *
23
+ * @category Files
24
+ * @internal
25
+ */
26
+ export declare function extractZip(data: ArrayBuffer | Buffer): Map<ADMZip.IZipEntry, Buffer>;
27
+ /**
28
+ * Extract the contents of a zip file and return the first entry.
29
+ */
30
+ export declare function extractSingleFileZip(data: ArrayBuffer | Buffer): Promise<Buffer>;
31
+ /**
32
+ * Names a member of an archive, either exactly or by pattern.
33
+ *
34
+ * A pattern matches the FIRST entry whose full archive-internal path tests true, in central-directory order.
35
+ */
36
+ export type ZipEntrySelector = string | RegExp;
37
+ /**
38
+ * One archive member, as reported by the central directory.
39
+ *
40
+ * @category Files
41
+ */
42
+ export interface ZipEntryInfo {
43
+ /**
44
+ * The archive-internal path, e.g. `it/countrywide.csv`. Directory entries keep their trailing slash.
45
+ */
46
+ name: string;
47
+ compressedSize: number;
48
+ uncompressedSize: number;
49
+ }
50
+ /**
51
+ * List an archive's members without decompressing any of them.
52
+ *
53
+ * @category Files
54
+ */
55
+ export declare function listZipEntries(archivePath: PathBuilderLike): Promise<ZipEntryInfo[]>;
56
+ /**
57
+ * Stream one member's decompressed bytes out of an archive on disk.
58
+ *
59
+ * Nothing beyond the central directory and the inflate window is held in memory, so this is bounded by the consumer
60
+ * rather than by the member's size. A consumer that stops early — a `take`, a `break` — destroys the member stream and
61
+ * closes the archive on the way out.
62
+ *
63
+ * @category Files
64
+ * @throws If no member matches `selector`.
65
+ */
66
+ export declare function readZipEntry(archivePath: PathBuilderLike, selector: ZipEntrySelector): AsyncGenerator<Uint8Array>;
67
+ /**
68
+ * Write one member's decompressed bytes to `destinationPath`.
69
+ *
70
+ * @category Files
71
+ *
72
+ * @returns The number of bytes written, as the central directory reports them.
73
+ * @throws If no member matches `selector`.
74
+ */
75
+ export declare function extractZipEntry(archivePath: PathBuilderLike, selector: ZipEntrySelector, destinationPath: PathBuilderLike): Promise<number>;
76
+ export interface ExtractZipEntriesOptions {
77
+ /**
78
+ * Which members to write. Omit for every member.
79
+ */
80
+ selector?: ZipEntrySelector;
81
+ /**
82
+ * Write each member under its basename rather than its archive-internal path, flattening the tree — `unzip -j`.
83
+ *
84
+ * The shapefile archives this exists for carry their siblings in one directory, and the readers downstream expect
85
+ * them flat.
86
+ */
87
+ flatten?: boolean;
88
+ }
89
+ /**
90
+ * Extract members of an archive into `destinationDirectory`.
91
+ *
92
+ * Directory entries are skipped; a nested path is created as needed unless `flatten` is set. Members stream one at a
93
+ * time, so this is bounded by the largest member rather than by the archive.
94
+ *
95
+ * @category Files
96
+ *
97
+ * @returns The archive-internal names of everything written, in central-directory order.
98
+ */
99
+ export declare function extractZipEntries(archivePath: PathBuilderLike, destinationDirectory: PathBuilderLike, { selector, flatten }?: ExtractZipEntriesOptions): Promise<string[]>;
100
+ /**
101
+ * Verify every member's CRC-32 against the value its central-directory header claims — what `unzip -t` is for.
102
+ *
103
+ * This is a corruption check on a download, so it decompresses everything and keeps nothing; the archive is read one
104
+ * member at a time and the checksum is folded chunk by chunk, so memory is bounded by the inflate window.
105
+ *
106
+ * The CRC is computed here rather than delegated to yauzl's `validateCrc32`, which asserts `Cannot validate CRC32 for
107
+ * uncompressed data` on a STORED member — and a corrupt stored member is precisely what this is meant to catch. Folding
108
+ * it locally covers both storage methods with one path.
109
+ *
110
+ * @category Files
111
+ *
112
+ * @returns The number of members checked. @throws If the archive is unreadable, or any member's checksum or length
113
+ * disagrees with its header.
114
+ */
115
+ export declare function verifyZipIntegrity(archivePath: PathBuilderLike): Promise<number>;
116
+ //# sourceMappingURL=zip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../fs/zip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAE5E;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAcpF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBhF;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAA;AAE9C;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,CAAA;CACxB;AAMD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAiB1F;AAED;;;;;;;;;GASG;AACH,wBAAuB,YAAY,CAClC,WAAW,EAAE,eAAe,EAC5B,QAAQ,EAAE,gBAAgB,GACxB,cAAc,CAAC,UAAU,CAAC,CAsB5B;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACpC,WAAW,EAAE,eAAe,EAC5B,QAAQ,EAAE,gBAAgB,EAC1B,eAAe,EAAE,eAAe,GAC9B,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAA;IAC3B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACtC,WAAW,EAAE,eAAe,EAC5B,oBAAoB,EAAE,eAAe,EACrC,EAAE,QAAQ,EAAE,OAAe,EAAE,GAAE,wBAA6B,GAC1D,OAAO,CAAC,MAAM,EAAE,CAAC,CA0BnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCtF"}
package/out/fs/zip.js ADDED
@@ -0,0 +1,216 @@
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
+ import { createWriteStream } from "node:fs";
18
+ import { mkdir } from "node:fs/promises";
19
+ import { basename, dirname, join } from "node:path";
20
+ import { pipeline } from "node:stream/promises";
21
+ import { crc32 } from "node:zlib";
22
+ import ADMZip from "adm-zip";
23
+ import { open as openArchive } from "yauzl-promise";
24
+ /**
25
+ * Extract the contents of a zip file.
26
+ *
27
+ * @category Files
28
+ * @internal
29
+ */
30
+ export function extractZip(data) {
31
+ const normalizedData = data instanceof ArrayBuffer ? Buffer.from(data) : data;
32
+ const zip = new ADMZip(normalizedData);
33
+ const pairs = zip
34
+ .getEntries()
35
+ .map((entry) => [entry, zip.readFile(entry)])
36
+ .filter((pair) => pair[1] !== null);
37
+ if (!pairs.length) {
38
+ throw new Error("No entry pairs found in zip file.");
39
+ }
40
+ return new Map(pairs);
41
+ }
42
+ /**
43
+ * Extract the contents of a zip file and return the first entry.
44
+ */
45
+ export function extractSingleFileZip(data) {
46
+ const normalizedData = data instanceof ArrayBuffer ? Buffer.from(data) : data;
47
+ const zip = new ADMZip(normalizedData);
48
+ const [entry] = zip.getEntries();
49
+ // We use the async version of getData to avoid blocking the event loop.
50
+ return new Promise((resolve, reject) =>
51
+ // oxlint-disable-next-line no-promise-executor-return
52
+ entry.getDataAsync((extractedData, error) => {
53
+ if (error) {
54
+ reject(error);
55
+ }
56
+ else {
57
+ resolve(extractedData);
58
+ }
59
+ }));
60
+ }
61
+ function selectorMatches(selector, name) {
62
+ return typeof selector === "string" ? name === selector : selector.test(name);
63
+ }
64
+ /**
65
+ * List an archive's members without decompressing any of them.
66
+ *
67
+ * @category Files
68
+ */
69
+ export async function listZipEntries(archivePath) {
70
+ const archive = await openArchive(String(archivePath));
71
+ const entries = [];
72
+ try {
73
+ for await (const entry of archive) {
74
+ entries.push({
75
+ name: entry.filename,
76
+ compressedSize: entry.compressedSize,
77
+ uncompressedSize: entry.uncompressedSize,
78
+ });
79
+ }
80
+ }
81
+ finally {
82
+ await archive.close();
83
+ }
84
+ return entries;
85
+ }
86
+ /**
87
+ * Stream one member's decompressed bytes out of an archive on disk.
88
+ *
89
+ * Nothing beyond the central directory and the inflate window is held in memory, so this is bounded by the consumer
90
+ * rather than by the member's size. A consumer that stops early — a `take`, a `break` — destroys the member stream and
91
+ * closes the archive on the way out.
92
+ *
93
+ * @category Files
94
+ * @throws If no member matches `selector`.
95
+ */
96
+ export async function* readZipEntry(archivePath, selector) {
97
+ const archive = await openArchive(String(archivePath));
98
+ try {
99
+ for await (const entry of archive) {
100
+ if (!selectorMatches(selector, entry.filename))
101
+ continue;
102
+ const contents = await entry.openReadStream();
103
+ try {
104
+ yield* contents;
105
+ }
106
+ finally {
107
+ contents.destroy();
108
+ }
109
+ return;
110
+ }
111
+ throw new Error(`No entry matching ${selector} in ${archivePath}`);
112
+ }
113
+ finally {
114
+ await archive.close();
115
+ }
116
+ }
117
+ /**
118
+ * Write one member's decompressed bytes to `destinationPath`.
119
+ *
120
+ * @category Files
121
+ *
122
+ * @returns The number of bytes written, as the central directory reports them.
123
+ * @throws If no member matches `selector`.
124
+ */
125
+ export async function extractZipEntry(archivePath, selector, destinationPath) {
126
+ const archive = await openArchive(String(archivePath));
127
+ try {
128
+ for await (const entry of archive) {
129
+ if (!selectorMatches(selector, entry.filename))
130
+ continue;
131
+ await pipeline(await entry.openReadStream(), createWriteStream(String(destinationPath)));
132
+ return entry.uncompressedSize;
133
+ }
134
+ }
135
+ finally {
136
+ await archive.close();
137
+ }
138
+ throw new Error(`No entry matching ${selector} in ${archivePath}`);
139
+ }
140
+ /**
141
+ * Extract members of an archive into `destinationDirectory`.
142
+ *
143
+ * Directory entries are skipped; a nested path is created as needed unless `flatten` is set. Members stream one at a
144
+ * time, so this is bounded by the largest member rather than by the archive.
145
+ *
146
+ * @category Files
147
+ *
148
+ * @returns The archive-internal names of everything written, in central-directory order.
149
+ */
150
+ export async function extractZipEntries(archivePath, destinationDirectory, { selector, flatten = false } = {}) {
151
+ const archive = await openArchive(String(archivePath));
152
+ const written = [];
153
+ try {
154
+ for await (const entry of archive) {
155
+ if (entry.filename.endsWith("/"))
156
+ continue;
157
+ if (selector && !selectorMatches(selector, entry.filename))
158
+ continue;
159
+ const relative = flatten ? basename(entry.filename) : entry.filename;
160
+ const destination = join(String(destinationDirectory), relative);
161
+ if (!flatten) {
162
+ await mkdir(dirname(destination), { recursive: true });
163
+ }
164
+ await pipeline(await entry.openReadStream(), createWriteStream(destination));
165
+ written.push(entry.filename);
166
+ }
167
+ }
168
+ finally {
169
+ await archive.close();
170
+ }
171
+ return written;
172
+ }
173
+ /**
174
+ * Verify every member's CRC-32 against the value its central-directory header claims — what `unzip -t` is for.
175
+ *
176
+ * This is a corruption check on a download, so it decompresses everything and keeps nothing; the archive is read one
177
+ * member at a time and the checksum is folded chunk by chunk, so memory is bounded by the inflate window.
178
+ *
179
+ * The CRC is computed here rather than delegated to yauzl's `validateCrc32`, which asserts `Cannot validate CRC32 for
180
+ * uncompressed data` on a STORED member — and a corrupt stored member is precisely what this is meant to catch. Folding
181
+ * it locally covers both storage methods with one path.
182
+ *
183
+ * @category Files
184
+ *
185
+ * @returns The number of members checked. @throws If the archive is unreadable, or any member's checksum or length
186
+ * disagrees with its header.
187
+ */
188
+ export async function verifyZipIntegrity(archivePath) {
189
+ const archive = await openArchive(String(archivePath));
190
+ let checked = 0;
191
+ try {
192
+ for await (const entry of archive) {
193
+ if (entry.filename.endsWith("/"))
194
+ continue;
195
+ const contents = await entry.openReadStream({ validateCrc32: false });
196
+ let checksum = 0;
197
+ let length = 0;
198
+ for await (const chunk of contents) {
199
+ checksum = crc32(chunk, checksum);
200
+ length += chunk.length;
201
+ }
202
+ if (checksum !== entry.crc32) {
203
+ throw new Error(`CRC mismatch in ${archivePath}: ${entry.filename} is 0x${checksum.toString(16)}, header claims 0x${entry.crc32.toString(16)}`);
204
+ }
205
+ if (length !== entry.uncompressedSize) {
206
+ throw new Error(`Length mismatch in ${archivePath}: ${entry.filename} is ${length} bytes, header claims ${entry.uncompressedSize}`);
207
+ }
208
+ checked++;
209
+ }
210
+ }
211
+ finally {
212
+ await archive.close();
213
+ }
214
+ return checked;
215
+ }
216
+ //# sourceMappingURL=zip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip.js","sourceRoot":"","sources":["../../fs/zip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,OAAO,MAAM,MAAM,SAAS,CAAA;AAE5B,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AAInD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAA0B;IACpD,MAAM,cAAc,GAAG,IAAI,YAAY,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC7E,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,CAAA;IAEtC,MAAM,KAAK,GAAG,GAAG;SACf,UAAU,EAAE;SACZ,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SAC5C,MAAM,CAAC,CAAC,IAAI,EAA+B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;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SAAS,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,qBAAqB,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAC9H,CAAA;YACF,CAAC;YAED,IAAI,MAAM,KAAK,KAAK,CAAC,gBAAgB,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CACd,sBAAsB,WAAW,KAAK,KAAK,CAAC,QAAQ,OAAO,MAAM,yBAAyB,KAAK,CAAC,gBAAgB,EAAE,CAClH,CAAA;YACF,CAAC;YAED,OAAO,EAAE,CAAA;QACV,CAAC;IACF,CAAC;YAAS,CAAC;QACV,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACtB,CAAC;IAED,OAAO,OAAO,CAAA;AACf,CAAC"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @copyright Sister Software.
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
1
6
  import type { CamelCase, SnakeCase } from "type-fest";
2
7
  /**
3
8
  * Converts a name to snake_case, unless the name is already in all caps.
@@ -15,4 +20,22 @@ export declare function isUniformlyCased(input: string | null): boolean;
15
20
  * Capitalizes a string, unless the string is uniformly cased, or an email address.
16
21
  */
17
22
  export declare function smartCapitalCase(input: string): string;
23
+ /**
24
+ * Python `str.isupper()`: at least one cased character, and every cased character uppercase.
25
+ *
26
+ * Distinct from {@link isUniformlyCased}, which reports `true` for a string with no cased characters at all — `"123"` is
27
+ * uniformly cased and is NOT `isupper()`. Ports that gate a titlecase on the Python predicate need this one.
28
+ */
29
+ export declare function pyIsUpper(input: string): boolean;
30
+ /**
31
+ * Python `str.title()`: titlecase the first cased character of each run, lowercase the rest.
32
+ *
33
+ * Not `capitalCase` from change-case, which splits on word boundaries and drops punctuation — Python titlecases
34
+ * `"o'brien"` to `"O'Brien"` because the apostrophe ends a cased run.
35
+ */
36
+ export declare function pyTitle(input: string): string;
37
+ /**
38
+ * Titlecase a SHOUTED string, leave anything else alone — the shape source dumps use when a field arrives ALL CAPS.
39
+ */
40
+ export declare function titlecaseIfUpper(input: string): string;
18
41
  //# sourceMappingURL=identifiers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../identifiers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAiBnG;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAMnG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtD"}
1
+ {"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../identifiers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAiBnG;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAMnG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAYhD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -46,4 +46,43 @@ export function smartCapitalCase(input) {
46
46
  return input;
47
47
  return capitalCase(input);
48
48
  }
49
+ /**
50
+ * Python `str.isupper()`: at least one cased character, and every cased character uppercase.
51
+ *
52
+ * Distinct from {@link isUniformlyCased}, which reports `true` for a string with no cased characters at all — `"123"` is
53
+ * uniformly cased and is NOT `isupper()`. Ports that gate a titlecase on the Python predicate need this one.
54
+ */
55
+ export function pyIsUpper(input) {
56
+ let hasCased = false;
57
+ for (const ch of input) {
58
+ if (ch.toLowerCase() === ch.toUpperCase())
59
+ continue;
60
+ hasCased = true;
61
+ if (ch !== ch.toUpperCase())
62
+ return false;
63
+ }
64
+ return hasCased;
65
+ }
66
+ /**
67
+ * Python `str.title()`: titlecase the first cased character of each run, lowercase the rest.
68
+ *
69
+ * Not `capitalCase` from change-case, which splits on word boundaries and drops punctuation — Python titlecases
70
+ * `"o'brien"` to `"O'Brien"` because the apostrophe ends a cased run.
71
+ */
72
+ export function pyTitle(input) {
73
+ let out = "";
74
+ let prevCased = false;
75
+ for (const ch of input) {
76
+ const cased = ch.toLowerCase() !== ch.toUpperCase();
77
+ out += prevCased ? ch.toLowerCase() : ch.toUpperCase();
78
+ prevCased = cased;
79
+ }
80
+ return out;
81
+ }
82
+ /**
83
+ * Titlecase a SHOUTED string, leave anything else alone — the shape source dumps use when a field arrives ALL CAPS.
84
+ */
85
+ export function titlecaseIfUpper(input) {
86
+ return pyIsUpper(input) ? pyTitle(input) : input;
87
+ }
49
88
  //# sourceMappingURL=identifiers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../identifiers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG/D;;GAEG;AACH,MAAM,UAAU,cAAc,CAAmB,IAAO;IACvD,MAAM,cAAc,GAAG,IAAI;QAC1B,+DAA+D;SAC9D,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC;SACjC,IAAI,EAAE,CAAA;IAER,IAAI,cAAc,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC;QACrD,OACC,cAAc;YACb,sDAAsD;aACrD,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC;YAC3B,6EAA6E;aAC5E,UAAU,CAAC,QAAQ,EAAE,GAAG,CAC1B,CAAA;IACF,CAAC;IAED,OAAO,SAAS,CAAC,cAAc,CAA8C,CAAA;AAC9E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAmB,IAAO;IACvD,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,IAAiD,CAAA;IACzD,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAA8C,CAAA;AACpE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAoB;IACpD,OAAO,OAAO,CAAC,KAAK,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAA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YAAY;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;CACpB;AAmBD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,MAAM,CAAC,qBAAqB,CAAC,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBlH;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CA4BjG;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,OAAO,CAAA;AAEzC;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,MAAM,CAAC,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhH;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,EAAE,EAAE,MAAM,CAAC,qBAAqB,CAAC,EACjC,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAMnC"}
@@ -7,6 +7,7 @@
7
7
  * camelCase face of `layer_manifest`; validation happens at BOTH ends so a hand-built or
8
8
  * corrupted layer fails loudly at open time rather than misbehaving downstream.
9
9
  */
10
+ import { parseJSONStrict } from "../objects.js";
10
11
  import { LayerFreshnessPolicy, LayerTier } from "./schema.js";
11
12
  const TIERS = new Set(Object.values(LayerTier));
12
13
  const POLICIES = new Set(Object.values(LayerFreshnessPolicy));
@@ -66,7 +67,7 @@ export async function readLayerManifest(db) {
66
67
  buildCmd: row.build_cmd,
67
68
  buildSHA: row.build_sha,
68
69
  freshnessPolicy: row.freshness_policy,
69
- spineKeys: JSON.parse(row.spine_keys),
70
+ spineKeys: parseJSONStrict(row.spine_keys),
70
71
  createdAt: row.created_at,
71
72
  };
72
73
  assertManifestInvariants(manifest);
@@ -1 +1 @@
1
- {"version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AAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;aAC9G,OAAO,EAAE,CAAA;IACZ,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,EAAiC,EACjC,MAAc;IAEd,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,gBAAgB,EAAE,CAAA;IAE9G,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAA;IAE1B,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,aAAa,EAAE,CAAA;AAChG,CAAC"}
@@ -3,9 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * En-US locale profile (per Phase 0 task 5). Lists the rule classifier IDs the legacy registry will
7
- * assign and the `ComponentTag`s the US locale actually uses. No `weightsPackage` is set in Phase
8
- * 0 — neural weights ship in Phase 3.
6
+ * En-US locale profile. Lists the rule classifier IDs active in this locale and the
7
+ * `ComponentTag`s the US locale actually uses.
9
8
  */
10
9
  import type { LocaleProfile } from "../locale.ts";
11
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"en-us.d.ts","sourceRoot":"","sources":["../../../locale/profiles/en-us.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,aAwDlB,CAAA"}
1
+ {"version":3,"file":"en-us.d.ts","sourceRoot":"","sources":["../../../locale/profiles/en-us.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,aAwDlB,CAAA"}
@@ -3,9 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * En-US locale profile (per Phase 0 task 5). Lists the rule classifier IDs the legacy registry will
7
- * assign and the `ComponentTag`s the US locale actually uses. No `weightsPackage` is set in Phase
8
- * 0 — neural weights ship in Phase 3.
6
+ * En-US locale profile. Lists the rule classifier IDs active in this locale and the
7
+ * `ComponentTag`s the US locale actually uses.
9
8
  */
10
9
  /**
11
10
  * US English locale profile — the component ordering, casing and separators the formatter renders with.
@@ -1 +1 @@
1
- {"version":3,"file":"en-us.js","sourceRoot":"","sources":["../../../locale/profiles/en-us.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAkB;IAClC,MAAM,EAAE,OAAO;IACf,eAAe,EAAE;QAChB,eAAe;QACf,OAAO;QACP,gBAAgB;QAChB,iBAAiB;QACjB,0BAA0B;QAC1B,aAAa;QACb,YAAY;QACZ,cAAc;QACd,cAAc;QACd,OAAO;QACP,kBAAkB;QAClB,gBAAgB;QAChB,SAAS;QACT,QAAQ;QACR,iBAAiB;QACjB,gBAAgB;QAChB,OAAO;QACP,UAAU;QACV,WAAW;QACX,WAAW;QACX,eAAe;QACf,oBAAoB;QACpB,eAAe;QACf,SAAS;QACT,gBAAgB;QAChB,SAAS;QACT,MAAM;QACN,iBAAiB;QACjB,eAAe;QACf,wBAAwB;QACxB,kBAAkB;QAClB,kBAAkB;QAClB,uBAAuB;QACvB,iBAAiB;QACjB,aAAa;KACb;IACD,mBAAmB,EAAE;QACpB,SAAS;QACT,QAAQ;QACR,UAAU;QACV,UAAU;QACV,cAAc;QACd,QAAQ;QACR,eAAe;QACf,eAAe;QACf,MAAM;QACN,OAAO;QACP,WAAW;QACX,QAAQ;QACR,gBAAgB;QAChB,gBAAgB;KAChB;IACD,MAAM,EAAE,EAAE;CACV,CAAA"}
1
+ {"version":3,"file":"en-us.js","sourceRoot":"","sources":["../../../locale/profiles/en-us.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAkB;IAClC,MAAM,EAAE,OAAO;IACf,eAAe,EAAE;QAChB,eAAe;QACf,OAAO;QACP,gBAAgB;QAChB,iBAAiB;QACjB,0BAA0B;QAC1B,aAAa;QACb,YAAY;QACZ,cAAc;QACd,cAAc;QACd,OAAO;QACP,kBAAkB;QAClB,gBAAgB;QAChB,SAAS;QACT,QAAQ;QACR,iBAAiB;QACjB,gBAAgB;QAChB,OAAO;QACP,UAAU;QACV,WAAW;QACX,WAAW;QACX,eAAe;QACf,oBAAoB;QACpB,eAAe;QACf,SAAS;QACT,gBAAgB;QAChB,SAAS;QACT,MAAM;QACN,iBAAiB;QACjB,eAAe;QACf,wBAAwB;QACxB,kBAAkB;QAClB,kBAAkB;QAClB,uBAAuB;QACvB,iBAAiB;QACjB,aAAa;KACb;IACD,mBAAmB,EAAE;QACpB,SAAS;QACT,QAAQ;QACR,UAAU;QACV,UAAU;QACV,cAAc;QACd,QAAQ;QACR,eAAe;QACf,eAAe;QACf,MAAM;QACN,OAAO;QACP,WAAW;QACX,QAAQ;QACR,gBAAgB;QAChB,gBAAgB;KAChB;IACD,MAAM,EAAE,EAAE;CACV,CAAA"}
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Fr-FR locale profile (per Phase 0 task 5). Uses the same rule classifier set as en-US for
6
+ * Fr-FR locale profile. Uses the same rule classifier set as en-US for
7
7
  * locale-agnostic primitives, with the French-specific component set: cedex (postal routing),
8
8
  * street_prefix_particle (de la / du / des), and dependent_locality (arrondissement). The
9
9
  * `central_european_street_name` classifier lives in the registry for FR / DE / etc. and is
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Fr-FR locale profile (per Phase 0 task 5). Uses the same rule classifier set as en-US for
6
+ * Fr-FR locale profile. Uses the same rule classifier set as en-US for
7
7
  * locale-agnostic primitives, with the French-specific component set: cedex (postal routing),
8
8
  * street_prefix_particle (de la / du / des), and dependent_locality (arrondissement). The
9
9
  * `central_european_street_name` classifier lives in the registry for FR / DE / etc. and is
@@ -3,14 +3,14 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Ja-JP locale profile, used in Phase 0 §8 for the forward-compat sanity check (#8 task 8): does
7
- * the core abstraction accept a locale that omits `street` and `house_number` entirely without
8
- * throwing or tripping a type assertion? If this profile registers cleanly today, Phase 6 (Japan)
9
- * does not need a core refactor.
6
+ * Ja-JP locale profile, and the core abstraction's forward-compat sanity check (#8): does the
7
+ * registry accept a locale that omits `street` entirely, and whose hierarchy runs
8
+ * largest-to-smallest, without throwing or tripping a type assertion? While this profile registers
9
+ * cleanly, Japan support needs no core refactor.
10
10
  *
11
- * Note: no rule classifiers are listed because the JP profile is neural-only in Phase 6. The rule
12
- * pipeline does not produce Japanese-specific tags; declaring an empty list here verifies the
13
- * system does not assume there are rule classifiers for every locale.
11
+ * No rule classifiers are listed because the JP profile is neural-only — the rule pipeline produces
12
+ * no Japanese-specific tags. The empty list is itself the assertion that nothing in the system
13
+ * assumes every locale has rule classifiers.
14
14
  */
15
15
  import type { LocaleProfile } from "../locale.ts";
16
16
  /**
@@ -3,14 +3,14 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Ja-JP locale profile, used in Phase 0 §8 for the forward-compat sanity check (#8 task 8): does
7
- * the core abstraction accept a locale that omits `street` and `house_number` entirely without
8
- * throwing or tripping a type assertion? If this profile registers cleanly today, Phase 6 (Japan)
9
- * does not need a core refactor.
6
+ * Ja-JP locale profile, and the core abstraction's forward-compat sanity check (#8): does the
7
+ * registry accept a locale that omits `street` entirely, and whose hierarchy runs
8
+ * largest-to-smallest, without throwing or tripping a type assertion? While this profile registers
9
+ * cleanly, Japan support needs no core refactor.
10
10
  *
11
- * Note: no rule classifiers are listed because the JP profile is neural-only in Phase 6. The rule
12
- * pipeline does not produce Japanese-specific tags; declaring an empty list here verifies the
13
- * system does not assume there are rule classifiers for every locale.
11
+ * No rule classifiers are listed because the JP profile is neural-only — the rule pipeline produces
12
+ * no Japanese-specific tags. The empty list is itself the assertion that nothing in the system
13
+ * assumes every locale has rule classifiers.
14
14
  */
15
15
  /**
16
16
  * Japanese locale profile. Note the reversed hierarchy: Japan addresses run largest-to-smallest.
package/out/objects.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  *
6
6
  * Utility functions for working with objects.
7
7
  */
8
+ import type { PathBuilderLike } from "path-ts";
8
9
  import type { JsonObject } from "type-fest";
9
10
  type SetLike<T> = {
10
11
  has(value: T): boolean;
@@ -83,9 +84,24 @@ export type NonNullableObject<T> = {
83
84
  export declare function omitNullable<T extends object>(input: T): NonNullableObject<T>;
84
85
  /**
85
86
  * Given serialized JSON, attempt to parse it.
87
+ *
88
+ * Non-throwing: invalid JSON — and any non-string input, `Buffer` included — returns the fallback (`null` unless one is
89
+ * given). Callers that need a throw on corrupt input, or `JSON.parse`'s reviver parameter, use `JSON.parse` directly
90
+ * behind a scoped lint disable.
91
+ */
92
+ export declare function tryParsingJSON<T = unknown>(input: unknown): T | null;
93
+ export declare function tryParsingJSON<T = unknown, F = T>(input: unknown, fallback: F): T | F;
94
+ export declare class JSONParseError extends Error {
95
+ constructor(message: string, options?: ErrorOptions);
96
+ }
97
+ /**
98
+ * Parses JSON input or throws a `JSONParseError` if parsing fails.
99
+ *
100
+ * @param input - The JSON input to parse.
101
+ *
102
+ * @returns The parsed object.
86
103
  */
87
- export declare function tryParsingJSON<T = unknown>(input: unknown, fallback?: undefined): T | undefined;
88
- export declare function tryParsingJSON<T = unknown>(input: unknown, fallback: null): T | null;
104
+ export declare function parseJSONStrict<T = unknown>(input: PathBuilderLike): T;
89
105
  export type FlattenObjectKeys<T extends JsonObject, Key = keyof T> = Key extends string ? T[Key] extends JsonObject ? `${Key}.${FlattenObjectKeys<T[Key]>}` : `${Key}` : never;
90
106
  /**
91
107
  * Flattens an object into a single-level object with dot-separated keys.