@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.
- package/README.md +2 -2
- package/api/clock.ts +1 -1
- package/api/disk-storage.ts +7 -4
- package/api/test-clocks.ts +57 -9
- package/api/test-transport.ts +182 -0
- package/coarse-placer/coarse-placer.ts +2 -1
- package/coarse-placer/tools/build-dataset.ts +2 -2
- package/coarse-placer/tools/build-outlier-exposure.ts +2 -2
- package/coarse-placer/tools/build-outlier-latin.ts +3 -2
- package/coarse-placer/tools/build-outlier-oa.ts +3 -2
- package/coarse-placer/tools/eval-latin-offmap.ts +8 -8
- package/coarse-placer/tools/eval-openset.ts +20 -12
- package/coarse-placer/tools/eval-quant-compare.ts +8 -9
- package/coarse-placer/tools/eval.ts +30 -23
- package/coarse-placer/tools/probe-frontier.ts +9 -7
- package/coarse-placer/tools/quantize.ts +4 -2
- package/coarse-placer/tools/train.ts +10 -10
- package/collections.ts +2 -128
- package/crypto/node.ts +68 -0
- package/decoder/build-tree.ts +19 -0
- package/env/schema.ts +58 -2
- package/fs/zip.ts +297 -0
- package/identifiers.ts +48 -0
- package/layers/manifest.ts +2 -1
- package/locale/profiles/en-us.ts +2 -3
- package/locale/profiles/fr-fr.ts +1 -1
- package/locale/profiles/ja-jp.ts +7 -7
- package/objects.ts +40 -8
- package/out/api/clock.d.ts +1 -1
- package/out/api/clock.js +1 -1
- package/out/api/disk-storage.d.ts +1 -1
- package/out/api/disk-storage.d.ts.map +1 -1
- package/out/api/disk-storage.js +5 -5
- package/out/api/disk-storage.js.map +1 -1
- package/out/api/test-clocks.d.ts +2 -2
- package/out/api/test-clocks.d.ts.map +1 -1
- package/out/api/test-clocks.js +51 -9
- package/out/api/test-clocks.js.map +1 -1
- package/out/api/test-transport.d.ts +112 -0
- package/out/api/test-transport.d.ts.map +1 -0
- package/out/api/test-transport.js +84 -0
- package/out/api/test-transport.js.map +1 -0
- package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
- package/out/coarse-placer/coarse-placer.js +2 -1
- package/out/coarse-placer/coarse-placer.js.map +1 -1
- package/out/coarse-placer/tools/build-dataset.js +1 -2
- package/out/coarse-placer/tools/build-dataset.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-exposure.js +1 -2
- package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-outlier-latin.js +2 -2
- package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-outlier-oa.js +2 -2
- package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
- package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-latin-offmap.js +5 -8
- package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
- package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-openset.js +12 -11
- package/out/coarse-placer/tools/eval-openset.js.map +1 -1
- package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-quant-compare.js +7 -9
- package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
- package/out/coarse-placer/tools/eval.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval.js +20 -21
- package/out/coarse-placer/tools/eval.js.map +1 -1
- package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
- package/out/coarse-placer/tools/probe-frontier.js +8 -8
- package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
- package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
- package/out/coarse-placer/tools/quantize.js +3 -2
- package/out/coarse-placer/tools/quantize.js.map +1 -1
- package/out/coarse-placer/tools/train.d.ts.map +1 -1
- package/out/coarse-placer/tools/train.js +7 -10
- package/out/coarse-placer/tools/train.js.map +1 -1
- package/out/collections.d.ts +1 -59
- package/out/collections.d.ts.map +1 -1
- package/out/collections.js +2 -90
- package/out/collections.js.map +1 -1
- package/out/crypto/node.d.ts +43 -0
- package/out/crypto/node.d.ts.map +1 -0
- package/out/crypto/node.js +43 -0
- package/out/crypto/node.js.map +1 -0
- package/out/decoder/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js +17 -0
- package/out/decoder/build-tree.js.map +1 -1
- package/out/env/index.d.ts +8 -0
- package/out/env/index.d.ts.map +1 -1
- package/out/env/schema.d.ts +9 -1
- package/out/env/schema.d.ts.map +1 -1
- package/out/env/schema.js +54 -2
- package/out/env/schema.js.map +1 -1
- package/out/fs/zip.d.ts +116 -0
- package/out/fs/zip.d.ts.map +1 -0
- package/out/fs/zip.js +216 -0
- package/out/fs/zip.js.map +1 -0
- package/out/identifiers.d.ts +23 -0
- package/out/identifiers.d.ts.map +1 -1
- package/out/identifiers.js +39 -0
- package/out/identifiers.js.map +1 -1
- package/out/layers/manifest.d.ts.map +1 -1
- package/out/layers/manifest.js +2 -1
- package/out/layers/manifest.js.map +1 -1
- package/out/locale/profiles/en-us.d.ts +2 -3
- package/out/locale/profiles/en-us.d.ts.map +1 -1
- package/out/locale/profiles/en-us.js +2 -3
- package/out/locale/profiles/en-us.js.map +1 -1
- package/out/locale/profiles/fr-fr.d.ts +1 -1
- package/out/locale/profiles/fr-fr.js +1 -1
- package/out/locale/profiles/ja-jp.d.ts +7 -7
- package/out/locale/profiles/ja-jp.js +7 -7
- package/out/objects.d.ts +18 -2
- package/out/objects.d.ts.map +1 -1
- package/out/objects.js +29 -3
- package/out/objects.js.map +1 -1
- package/out/pipeline/index.d.ts +2 -2
- package/out/pipeline/index.d.ts.map +1 -1
- package/out/pipeline/index.js +1 -1
- package/out/pipeline/index.js.map +1 -1
- package/out/pipeline/runtime-pipeline.d.ts +1 -1
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +74 -18
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/span-proposer.d.ts +24 -0
- package/out/pipeline/span-proposer.d.ts.map +1 -1
- package/out/pipeline/span-proposer.js +36 -1
- package/out/pipeline/span-proposer.js.map +1 -1
- package/out/pipeline/types.d.ts +155 -3
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +41 -1
- package/out/pipeline/types.js.map +1 -1
- package/out/resolver/index.d.ts +3 -1
- package/out/resolver/index.d.ts.map +1 -1
- package/out/resolver/index.js +1 -0
- package/out/resolver/index.js.map +1 -1
- package/out/resolver/referential.d.ts +73 -0
- package/out/resolver/referential.d.ts.map +1 -0
- package/out/resolver/referential.js +71 -0
- package/out/resolver/referential.js.map +1 -0
- package/out/resolver/types.d.ts +204 -0
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js.map +1 -1
- package/out/resources/index.d.ts +0 -1
- package/out/resources/index.d.ts.map +1 -1
- package/out/resources/index.js +0 -1
- package/out/resources/index.js.map +1 -1
- package/out/resources/libpostal.d.ts.map +1 -1
- package/out/resources/libpostal.js +3 -4
- package/out/resources/libpostal.js.map +1 -1
- package/out/resources/whosonfirst/index.d.ts +1 -0
- package/out/resources/whosonfirst/index.d.ts.map +1 -1
- package/out/resources/whosonfirst/index.js +1 -0
- package/out/resources/whosonfirst/index.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.js +6 -5
- package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts +12 -3
- package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.js +1 -1
- package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
- package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
- package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -0
- package/out/resources/whosonfirst/sharded-repo.js +58 -0
- package/out/resources/whosonfirst/sharded-repo.js.map +1 -0
- package/out/scripting/utils/index.d.ts.map +1 -1
- package/out/scripting/utils/index.js +2 -2
- package/out/scripting/utils/index.js.map +1 -1
- package/out/tools/download-libpostal-resources.d.ts.map +1 -1
- package/out/tools/download-libpostal-resources.js +1 -0
- package/out/tools/download-libpostal-resources.js.map +1 -1
- package/out/tools/generate-language-types.d.ts.map +1 -1
- package/out/tools/generate-language-types.js +5 -11
- package/out/tools/generate-language-types.js.map +1 -1
- package/out/utils/data-root.d.ts +20 -6
- package/out/utils/data-root.d.ts.map +1 -1
- package/out/utils/data-root.js +24 -5
- package/out/utils/data-root.js.map +1 -1
- package/out/utils/hash.d.ts +6 -0
- package/out/utils/hash.d.ts.map +1 -1
- package/out/utils/hash.js +8 -0
- package/out/utils/hash.js.map +1 -1
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +1 -0
- package/out/utils/index.js.map +1 -1
- package/out/utils/jsonl.d.ts +17 -3
- package/out/utils/jsonl.d.ts.map +1 -1
- package/out/utils/jsonl.js +23 -6
- package/out/utils/jsonl.js.map +1 -1
- package/out/utils/python-json.d.ts +3 -3
- package/out/utils/python-json.js +9 -9
- package/out/utils/python-numeric.d.ts +33 -0
- package/out/utils/python-numeric.d.ts.map +1 -0
- package/out/utils/python-numeric.js +149 -0
- package/out/utils/python-numeric.js.map +1 -0
- package/out/utils/python-random.d.ts +26 -1
- package/out/utils/python-random.d.ts.map +1 -1
- package/out/utils/python-random.js +43 -7
- package/out/utils/python-random.js.map +1 -1
- package/out/utils/repo.d.ts.map +1 -1
- package/out/utils/repo.js +18 -0
- package/out/utils/repo.js.map +1 -1
- package/out/utils/sealed-db.d.ts +12 -0
- package/out/utils/sealed-db.d.ts.map +1 -1
- package/out/utils/sealed-db.js +32 -1
- package/out/utils/sealed-db.js.map +1 -1
- package/package.json +34 -7
- package/pipeline/index.ts +3 -1
- package/pipeline/runtime-pipeline.ts +88 -27
- package/pipeline/span-proposer.ts +64 -1
- package/pipeline/types.ts +160 -2
- package/resolver/index.ts +13 -0
- package/resolver/referential.ts +84 -0
- package/resolver/types.ts +207 -0
- package/resources/index.ts +0 -1
- package/resources/libpostal.ts +8 -7
- package/resources/whosonfirst/index.ts +1 -0
- package/resources/whosonfirst/placetypes/Placetype.ts +13 -8
- package/resources/whosonfirst/placetypes/admin.ts +12 -2
- package/resources/whosonfirst/sharded-repo.ts +69 -0
- package/scripting/utils/index.ts +2 -3
- package/tools/download-libpostal-resources.ts +1 -0
- package/tools/generate-language-types.ts +5 -14
- package/utils/data-root.ts +27 -6
- package/utils/hash.ts +9 -0
- package/utils/index.ts +1 -0
- package/utils/jsonl.ts +26 -7
- package/utils/python-json.ts +10 -10
- package/utils/python-numeric.ts +168 -0
- package/utils/python-random.ts +49 -8
- package/utils/repo.ts +18 -0
- package/utils/sealed-db.ts +38 -1
- package/out/resources/collections.d.ts +0 -22
- package/out/resources/collections.d.ts.map +0 -1
- package/out/resources/collections.js +0 -69
- package/out/resources/collections.js.map +0 -1
- package/resources/collections.ts +0 -96
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Reading a place out of a cloned Who's On First data repo.
|
|
7
|
+
*
|
|
8
|
+
* WOF stores each record at a path derived from its own id: the decimal id split into three-character directories,
|
|
9
|
+
* then `<id>.geojson`. `85977539` lives at `859/775/39/85977539.geojson`. The rule is not written down in the data —
|
|
10
|
+
* it is layout knowledge every reader has to carry — so it lives here once, next to the {@link WOFFeature} type the
|
|
11
|
+
* parsed record has.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
14
|
+
import { tryParsingJSON } from "@mailwoman/core/objects";
|
|
15
|
+
import { resolvePath } from "path-ts";
|
|
16
|
+
/**
|
|
17
|
+
* Characters per directory level. A trailing group shorter than this is its own directory — `85977539` ends in `39`,
|
|
18
|
+
* not `390`.
|
|
19
|
+
*/
|
|
20
|
+
const ID_CHUNK = 3;
|
|
21
|
+
/**
|
|
22
|
+
* A WOF id → its repo-relative path segments, ending in `<id>.geojson`.
|
|
23
|
+
*
|
|
24
|
+
* Segments rather than a joined string so a caller can append them to whatever root it already holds — the repos layout
|
|
25
|
+
* puts a `data` directory under each `whosonfirst-data-*` clone, and callers reach it differently.
|
|
26
|
+
*/
|
|
27
|
+
export function wofIDPathSegments(id) {
|
|
28
|
+
const digits = String(id);
|
|
29
|
+
const segments = [];
|
|
30
|
+
for (let i = 0; i < digits.length; i += ID_CHUNK) {
|
|
31
|
+
segments.push(digits.slice(i, i + ID_CHUNK));
|
|
32
|
+
}
|
|
33
|
+
segments.push(`${digits}.geojson`);
|
|
34
|
+
return segments;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read a place's GeoJSON from the first `root` that holds it, or `null` when no root does or the file will not parse.
|
|
38
|
+
*
|
|
39
|
+
* `null` conflates "absent" with "unparseable" on purpose: every caller so far treats both as "no evidence for this
|
|
40
|
+
* place" and continues. A caller that needs to tell them apart should read the file itself.
|
|
41
|
+
*/
|
|
42
|
+
export function readWOFFeature(id, roots) {
|
|
43
|
+
const segments = wofIDPathSegments(id);
|
|
44
|
+
for (const root of roots) {
|
|
45
|
+
const path = resolvePath(root, ...segments);
|
|
46
|
+
if (!existsSync(path))
|
|
47
|
+
continue;
|
|
48
|
+
try {
|
|
49
|
+
return tryParsingJSON(readFileSync(path, "utf8"));
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// The file vanished or turned unreadable between existsSync and the read — same "no evidence" verdict.
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=sharded-repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shar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AA;QACZ,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../scripting/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../scripting/utils/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAYnD;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAE/E;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,MAAM,CAAC,OAAmB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBtG;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAevE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAGvC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAM,GAAG,MAAM,CAAC,UAAU,CAG9F;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAGxC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ResourceError } from "@mailwoman/core/errors";
|
|
2
|
+
import { ConsoleLogger } from "@mailwoman/core/logging";
|
|
1
3
|
import { defaultRegistry } from "async-init";
|
|
2
|
-
import { ResourceError } from "../../errors/index.js";
|
|
3
|
-
import { ConsoleLogger } from "../../logging/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Logs an error that occurred while running a script.
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../scripting/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../scripting/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC5C,aAAa,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAElE,MAAM,eAAe,GAAG,KAAK,YAAY,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAE1F,aAAa,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;IAEpC,IAAI,eAAe,CAAC,KAAK,YAAY,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC3E,aAAa,CAAC,KAAK,CAAC,oBAAoB,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACxE,CAAC;SAAM,IAAI,eAAe,CAAC,KAAK,EAAE,CAAC;QAClC,aAAa,CAAC,KAAK,CAAC,oBAAoB,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC;AACF,CAAC;AASD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAyB,SAAS,EAAE,QAAiB;IACtF,aAAa,CAAC,KAAK,CAAC,MAAM,MAAM,oBAAoB,CAAC,CAAA;IAErD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;QAC/B,aAAa,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;QAE9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,C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,CAAA;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-libpostal-resources.d.ts","sourceRoot":"","sources":["../../tools/download-libpostal-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;
|
|
1
|
+
{"version":3,"file":"download-libpostal-resources.d.ts","sourceRoot":"","sources":["../../tools/download-libpostal-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA+BH;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC/C,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,EACjC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,IAAI,CAAC,CAoCf"}
|
|
@@ -37,6 +37,7 @@ const DICTIONARIES_DIR = resourceDictionaryPath("libpostal");
|
|
|
37
37
|
async function sortFileInPlace(path) {
|
|
38
38
|
const text = await readFile(path, "utf8");
|
|
39
39
|
const hadTrailingNewline = text.endsWith("\n");
|
|
40
|
+
// oxlint-disable-next-line mailwoman/prefer-spliterator -- Sorting needs every line resident; the largest libpostal dictionary is 409 KB.
|
|
40
41
|
const lines = text.split("\n");
|
|
41
42
|
// Drop the empty element produced by a trailing newline so it isn't re-sorted as a blank line.
|
|
42
43
|
if (hadTrailingNewline) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download-libpostal-resources.js","sourceRoot":"","sources":["../../tools/download-libpostal-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AA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@@
|
|
|
1
|
-
{"version":3,"file":"generate-language-types.d.ts","sourceRoot":"","sources":["../../tools/generate-language-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,GAAE,4BAAiC,EAC1C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,4BAA4B,CAAC,
|
|
1
|
+
{"version":3,"file":"generate-language-types.d.ts","sourceRoot":"","sources":["../../tools/generate-language-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,GAAE,4BAAiC,EAC1C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC,4BAA4B,CAAC,CAsJvC"}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Usage: mailwoman dev generate language-types
|
|
10
10
|
*/
|
|
11
|
-
import { createReadStream } from "node:fs";
|
|
12
11
|
import * as fs from "node:fs/promises";
|
|
13
12
|
import { pascalCase } from "change-case";
|
|
13
|
+
import { CSVSpliterator } from "spliterator";
|
|
14
14
|
import { repoRootPath, resourceDictionaryPath } from "../utils/index.js";
|
|
15
15
|
/**
|
|
16
16
|
* Regenerate the committed language-code types from `internal/languages.csv`.
|
|
@@ -22,16 +22,10 @@ export async function generateLanguageTypes(options = {}, report) {
|
|
|
22
22
|
const alpha3bEntries = new Map();
|
|
23
23
|
const entryLines = [];
|
|
24
24
|
report?.(`Reading ${dataSourcePath}`);
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
columns: false,
|
|
30
|
-
skip_empty_lines: true,
|
|
31
|
-
from_line: 2,
|
|
32
|
-
});
|
|
33
|
-
const stream = createReadStream(dataSourcePath).pipe(parser);
|
|
34
|
-
for await (const columns of stream) {
|
|
25
|
+
// Quote handling is on and load-bearing: six labels wrap an embedded comma
|
|
26
|
+
// (`gre,el,"Greek, Modern (1453-)"`), and the spliterator leaves quoting off by default.
|
|
27
|
+
// `header` defaults true, which is what skips the `alpha3-b,alpha2,English` line.
|
|
28
|
+
for await (const columns of CSVSpliterator.fromAsync(dataSourcePath, { enableQuoteHandling: true })) {
|
|
35
29
|
const alpha3b = columns[0];
|
|
36
30
|
const alpha2 = columns[1];
|
|
37
31
|
const labelsConcatenated = columns[2];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-language-types.js","sourceRoot":"","sources":["../../tools/generate-language-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"generate-language-types.js","sourceRoot":"","sources":["../../tools/generate-language-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAoBxE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,UAAwC,EAAE,EAC1C,MAA+B;IAE/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IAAI,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,SAAS,CAAC,IAAI,CAAC,CAAA;IAErB,aAAa;IAEb,MAAM,SAAS,CAAC;;;;;CAKhB,CAAC,CAAA;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,EAAE,CAAC;QAC5C,MAAM,SAAS,CAAC,KAAK,MAAM,OAAO,OAAO,KAAK,CAAC,CAAA;IAChD,CAAC;IAED,MAAM,SAAS,CAAC,IAAI,CAAC,CAAA;IAErB,MAAM,SAAS,CAAC;;;;;CAKhB,CAAC,CAAA;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,EAAE,CAAC;QAC5C,MAAM,SAAS,CAAC,KAAK,OAAO,OAAO,MAAM,KAAK,CAAC,CAAA;IAChD,CAAC;IAED,MAAM,SAAS,CAAC,IAAI,CAAC,CAAA;IAErB,WAAW;IAEX,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IAEpB,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,CAAA;IAE5B,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;AAC1D,CAAC"}
|
package/out/utils/data-root.d.ts
CHANGED
|
@@ -21,11 +21,25 @@ export declare function mailwomanDataRoot(): string;
|
|
|
21
21
|
export declare function dataRootPath(...segments: string[]): string;
|
|
22
22
|
/**
|
|
23
23
|
* The default WOF shard list the FTS backend probes when no single `--wof-db` is given: the global admin-priority shard
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* plus the postcode shards, with country-aware routing in `pickShardForPlacetype` sending each postcode query to the
|
|
25
|
+
* shard that claims its country (#920). All under `dataRoot` (defaults to the configured {@link mailwomanDataRoot};
|
|
26
|
+
* callers thread a `--data-root` option through). A fresh array each call; callers filter with `existsSync`, so a
|
|
27
|
+
* deployment missing any of them degrades to whatever is present.
|
|
28
|
+
*
|
|
29
|
+
* This list is DELIBERATELY SMALLER than `DEFAULT_POSTCODE_SHARDS` (`mailwoman/gazetteer-pipeline/index.ts`), which is
|
|
30
|
+
* the set the candidate gazetteer is BUILT from — twenty-odd shards including the 876 MB Code-Point Open GB one. These
|
|
31
|
+
* are attached live per query, so the cost of a member is paid at every boot rather than once at build time; membership
|
|
32
|
+
* here is earned by a shard the runtime cannot resolve its locales without.
|
|
33
|
+
*
|
|
34
|
+
* Two notes on specific members, because both look like mistakes and are not:
|
|
35
|
+
*
|
|
36
|
+
* - The tail shard's own contents moved on 2026-08-05. It carried GB (1,839,678 of 1,895,753 rows, ~946 MB) until
|
|
37
|
+
* Code-Point Open replaced those rows under a clean licence; it is now the nine-country namesake set
|
|
38
|
+
* FI/CZ/SK/SI/DK/NO/HR/PL/SE at 26 MB. Rebuild: `mailwoman gazetteer build postcode-geonames`.
|
|
39
|
+
* - `postalcode-ni-osm.db` is **build-local**: OSM `addr:postcode` under ODbL, never published, so on any machine that
|
|
40
|
+
* did not build it the `existsSync` filter simply drops it and GB postcode queries behave as they did before. It is
|
|
41
|
+
* listed rather than special-cased because that filter IS the tier's enforcement. It is also the only GB-claiming
|
|
42
|
+
* shard in this list — the Code-Point Open shard is not here — so nothing competes with it for `BT` routing.
|
|
29
43
|
*/
|
|
30
|
-
export declare function wofShardPaths(dataRoot?: string): [string, string, string, string, string];
|
|
44
|
+
export declare function wofShardPaths(dataRoot?: string): [string, string, string, string, string, string];
|
|
31
45
|
//# sourceMappingURL=data-root.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-root.d.ts","sourceRoot":"","sources":["../../utils/data-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D;AAED
|
|
1
|
+
{"version":3,"file":"data-root.d.ts","sourceRoot":"","sources":["../../utils/data-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAE1D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAC5B,QAAQ,GAAE,MAA4B,GACpC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAgBlD"}
|
package/out/utils/data-root.js
CHANGED
|
@@ -32,11 +32,25 @@ export function dataRootPath(...segments) {
|
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* The default WOF shard list the FTS backend probes when no single `--wof-db` is given: the global admin-priority shard
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
35
|
+
* plus the postcode shards, with country-aware routing in `pickShardForPlacetype` sending each postcode query to the
|
|
36
|
+
* shard that claims its country (#920). All under `dataRoot` (defaults to the configured {@link mailwomanDataRoot};
|
|
37
|
+
* callers thread a `--data-root` option through). A fresh array each call; callers filter with `existsSync`, so a
|
|
38
|
+
* deployment missing any of them degrades to whatever is present.
|
|
39
|
+
*
|
|
40
|
+
* This list is DELIBERATELY SMALLER than `DEFAULT_POSTCODE_SHARDS` (`mailwoman/gazetteer-pipeline/index.ts`), which is
|
|
41
|
+
* the set the candidate gazetteer is BUILT from — twenty-odd shards including the 876 MB Code-Point Open GB one. These
|
|
42
|
+
* are attached live per query, so the cost of a member is paid at every boot rather than once at build time; membership
|
|
43
|
+
* here is earned by a shard the runtime cannot resolve its locales without.
|
|
44
|
+
*
|
|
45
|
+
* Two notes on specific members, because both look like mistakes and are not:
|
|
46
|
+
*
|
|
47
|
+
* - The tail shard's own contents moved on 2026-08-05. It carried GB (1,839,678 of 1,895,753 rows, ~946 MB) until
|
|
48
|
+
* Code-Point Open replaced those rows under a clean licence; it is now the nine-country namesake set
|
|
49
|
+
* FI/CZ/SK/SI/DK/NO/HR/PL/SE at 26 MB. Rebuild: `mailwoman gazetteer build postcode-geonames`.
|
|
50
|
+
* - `postalcode-ni-osm.db` is **build-local**: OSM `addr:postcode` under ODbL, never published, so on any machine that
|
|
51
|
+
* did not build it the `existsSync` filter simply drops it and GB postcode queries behave as they did before. It is
|
|
52
|
+
* listed rather than special-cased because that filter IS the tier's enforcement. It is also the only GB-claiming
|
|
53
|
+
* shard in this list — the Code-Point Open shard is not here — so nothing competes with it for `BT` routing.
|
|
40
54
|
*/
|
|
41
55
|
export function wofShardPaths(dataRoot = mailwomanDataRoot()) {
|
|
42
56
|
// TODO: Redo this as an object.
|
|
@@ -48,6 +62,11 @@ export function wofShardPaths(dataRoot = mailwomanDataRoot()) {
|
|
|
48
62
|
// #977: the NL PC6 full-postcode shard (CBS via PDOK; scripts/build-postalcode-nl-pc6.ts) — the
|
|
49
63
|
// data the lookup's NL PC6 ladder ("1012 LG" → joined "1012LG" → 4-digit stem) resolves against.
|
|
50
64
|
resolvePath(dataRoot, "wof", "postalcode-nl-pc6.db"),
|
|
65
|
+
// Northern Ireland (BT) from OpenStreetMap — 4,757 of 50,032 live NI postcodes (9.5 %), the only
|
|
66
|
+
// coverage that exists for the hole Code-Point Open leaves. ODbL, build-local, 2.5 MB. A miss on a
|
|
67
|
+
// BT code means NOT ATTESTED IN OSM; since #1480 an unknown postcode abstains, so the shard is
|
|
68
|
+
// strictly additive. Rebuild: `mailwoman gazetteer build postcode-ni-osm`.
|
|
69
|
+
resolvePath(dataRoot, "wof", "postalcode-ni-osm.db"),
|
|
51
70
|
];
|
|
52
71
|
}
|
|
53
72
|
//# sourceMappingURL=data-root.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-root.js","sourceRoot":"","sources":["../../utils/data-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC;;;GAGG;AACH,MAAM,2BAA2B,GAAG,6BAA6B,CAAA;AAEjE;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAChC,OAAO,OAAO,CAAC,mBAAmB,IAAI,2BAA2B,CAAA;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAG,QAAkB;IACjD,OAAO,WAAW,CAAC,iBAAiB,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAA;AACrD,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"data-root.js","sourceRoot":"","sources":["../../utils/data-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC;;;GAGG;AACH,MAAM,2BAA2B,GAAG,6BAA6B,CAAA;AAEjE;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAChC,OAAO,OAAO,CAAC,mBAAmB,IAAI,2BAA2B,CAAA;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAG,QAAkB;IACjD,OAAO,WAAW,CAAC,iBAAiB,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAA;AACrD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,aAAa,CAC5B,WAAmB,iBAAiB,EAAE;IAEtC,gCAAgC;IAChC,OAAO;QACN,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,0BAA0B,CAAC;QACxD,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,kBAAkB,CAAC;QAChD,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,6BAA6B,CAAC;QAC3D,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,oBAAoB,CAAC;QAClD,gGAAgG;QAChG,iGAAiG;QACjG,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,CAAC;QACpD,iGAAiG;QACjG,mGAAmG;QACnG,+FAA+F;QAC/F,2EAA2E;QAC3E,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,CAAC;KACpD,CAAA;AACF,CAAC"}
|
package/out/utils/hash.d.ts
CHANGED
|
@@ -22,4 +22,10 @@ export declare function sha256Hex(data: string | NodeJS.ArrayBufferView): string
|
|
|
22
22
|
* used for accidental-corruption / drift detection.
|
|
23
23
|
*/
|
|
24
24
|
export declare function md5File(path: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* MD5 of in-memory content, hex-encoded — the {@link md5File} counterpart for a string that never becomes a file. Same
|
|
27
|
+
* provenance-only rationale, and the same non-security caveat: it exists so a query text, a manifest line or a config
|
|
28
|
+
* blob can be fingerprinted with the SAME algorithm as the files recorded beside it in one `meta` table.
|
|
29
|
+
*/
|
|
30
|
+
export declare function md5Hex(data: string | NodeJS.ArrayBufferView): string;
|
|
25
31
|
//# sourceMappingURL=hash.d.ts.map
|
package/out/utils/hash.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../utils/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ9D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,GAAG,MAAM,CAEvE;AAED;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ3D"}
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../utils/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ9D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,GAAG,MAAM,CAEvE;AAED;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ3D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,GAAG,MAAM,CAEpE"}
|
package/out/utils/hash.js
CHANGED
|
@@ -38,4 +38,12 @@ export async function md5File(path) {
|
|
|
38
38
|
}
|
|
39
39
|
return hash.digest("hex");
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* MD5 of in-memory content, hex-encoded — the {@link md5File} counterpart for a string that never becomes a file. Same
|
|
43
|
+
* provenance-only rationale, and the same non-security caveat: it exists so a query text, a manifest line or a config
|
|
44
|
+
* blob can be fingerprinted with the SAME algorithm as the files recorded beside it in one `meta` table.
|
|
45
|
+
*/
|
|
46
|
+
export function md5Hex(data) {
|
|
47
|
+
return createHash("md5").update(data).digest("hex");
|
|
48
|
+
}
|
|
41
49
|
//# sourceMappingURL=hash.js.map
|
package/out/utils/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../utils/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC5C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AM,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAqC;IAC9D,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAY;IACzC,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAE9B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,KAAe,CAAC,CAAA;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,IAAqC;IAC3D,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACpD,CAAC"}
|
package/out/utils/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./data-root.ts";
|
|
|
7
7
|
export * from "./hash.ts";
|
|
8
8
|
export * from "./jsonl.ts";
|
|
9
9
|
export * from "./python-json.ts";
|
|
10
|
+
export * from "./python-numeric.ts";
|
|
10
11
|
export * from "./python-random.ts";
|
|
11
12
|
export * from "./repo.ts";
|
|
12
13
|
export * from "./sealed-db.ts";
|
package/out/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
package/out/utils/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./data-root.js";
|
|
|
7
7
|
export * from "./hash.js";
|
|
8
8
|
export * from "./jsonl.js";
|
|
9
9
|
export * from "./python-json.js";
|
|
10
|
+
export * from "./python-numeric.js";
|
|
10
11
|
export * from "./python-random.js";
|
|
11
12
|
export * from "./repo.js";
|
|
12
13
|
export * from "./sealed-db.js";
|
package/out/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
package/out/utils/jsonl.d.ts
CHANGED
|
@@ -3,20 +3,34 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* JSON Lines helpers
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* JSON Lines helpers, all three DEPRECATED — `spliterator` covers the whole surface, and a thin
|
|
7
|
+
* wrapper in front of it only hides which half you are getting.
|
|
8
|
+
*
|
|
9
|
+
* - `readJSONL` → `Array.fromAsync(JSONSpliterator.fromAsync<T>(path))`
|
|
10
|
+
* - `iterateJSONL` → `JSONSpliterator.fromAsync<T>(path)`
|
|
11
|
+
* - `writeJSONL` → `createNewlineWriter(path)`
|
|
12
|
+
*
|
|
13
|
+
* Kept exported because `@mailwoman/core` is published; they go in the next major.
|
|
9
14
|
*/
|
|
10
15
|
/**
|
|
11
16
|
* Read an entire JSONL file into memory. Blank and whitespace-only lines are skipped.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use `Array.fromAsync(JSONSpliterator.fromAsync<T>(path))` from `spliterator`. This buffers the whole file
|
|
19
|
+
* as one string, which throws `ERR_STRING_TOO_LONG` past V8's 512 MiB cap.
|
|
12
20
|
*/
|
|
13
21
|
export declare function readJSONL<T>(path: string): T[];
|
|
14
22
|
/**
|
|
15
23
|
* Write rows as JSONL (one `JSON.stringify` per line, trailing newline). Returns the row count.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Use `createNewlineWriter(path)` from `spliterator`. This concatenates every row into one string before it
|
|
26
|
+
* writes anything, so the output is capped the same way the input is.
|
|
16
27
|
*/
|
|
17
28
|
export declare function writeJSONL(path: string, rows: Iterable<unknown>): number;
|
|
18
29
|
/**
|
|
19
30
|
* Stream a JSONL file row-by-row without loading it whole. Blank lines are skipped.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Use `JSONSpliterator.fromAsync<T>(path)` from `spliterator` — this is a decode-then-parse wrapper around
|
|
33
|
+
* exactly that.
|
|
20
34
|
*/
|
|
21
35
|
export declare function iterateJSONL<T>(path: string): AsyncIterable<T>;
|
|
22
36
|
//# sourceMappingURL=jsonl.d.ts.map
|
package/out/utils/jsonl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../utils/jsonl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../utils/jsonl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,CAS9C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,MAAM,CAaxE;AAED;;;;;GAKG;AACH,wBAAuB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAMrE"}
|
package/out/utils/jsonl.js
CHANGED
|
@@ -3,23 +3,36 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* JSON Lines helpers
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* JSON Lines helpers, all three DEPRECATED — `spliterator` covers the whole surface, and a thin
|
|
7
|
+
* wrapper in front of it only hides which half you are getting.
|
|
8
|
+
*
|
|
9
|
+
* - `readJSONL` → `Array.fromAsync(JSONSpliterator.fromAsync<T>(path))`
|
|
10
|
+
* - `iterateJSONL` → `JSONSpliterator.fromAsync<T>(path)`
|
|
11
|
+
* - `writeJSONL` → `createNewlineWriter(path)`
|
|
12
|
+
*
|
|
13
|
+
* Kept exported because `@mailwoman/core` is published; they go in the next major.
|
|
9
14
|
*/
|
|
10
15
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
11
16
|
import { TextSpliterator } from "spliterator";
|
|
12
17
|
/**
|
|
13
18
|
* Read an entire JSONL file into memory. Blank and whitespace-only lines are skipped.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Use `Array.fromAsync(JSONSpliterator.fromAsync<T>(path))` from `spliterator`. This buffers the whole file
|
|
21
|
+
* as one string, which throws `ERR_STRING_TOO_LONG` past V8's 512 MiB cap.
|
|
14
22
|
*/
|
|
15
23
|
export function readJSONL(path) {
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
// The whole-buffer read and the throw-on-corrupt parse are both part of the shipped contract this
|
|
25
|
+
// function is deprecated FOR; rewriting either would change what remaining callers get.
|
|
26
|
+
return ([...TextSpliterator.from(readFileSync(path, "utf8"))]
|
|
18
27
|
.filter((line) => line.trim().length > 0)
|
|
19
|
-
|
|
28
|
+
// oxlint-disable-next-line no-restricted-properties
|
|
29
|
+
.map((line) => JSON.parse(line)));
|
|
20
30
|
}
|
|
21
31
|
/**
|
|
22
32
|
* Write rows as JSONL (one `JSON.stringify` per line, trailing newline). Returns the row count.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated Use `createNewlineWriter(path)` from `spliterator`. This concatenates every row into one string before it
|
|
35
|
+
* writes anything, so the output is capped the same way the input is.
|
|
23
36
|
*/
|
|
24
37
|
export function writeJSONL(path, rows) {
|
|
25
38
|
let count = 0;
|
|
@@ -33,11 +46,15 @@ export function writeJSONL(path, rows) {
|
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
48
|
* Stream a JSONL file row-by-row without loading it whole. Blank lines are skipped.
|
|
49
|
+
*
|
|
50
|
+
* @deprecated Use `JSONSpliterator.fromAsync<T>(path)` from `spliterator` — this is a decode-then-parse wrapper around
|
|
51
|
+
* exactly that.
|
|
36
52
|
*/
|
|
37
53
|
export async function* iterateJSONL(path) {
|
|
38
54
|
for await (const line of TextSpliterator.fromAsync(path)) {
|
|
39
55
|
if (!line.trim())
|
|
40
56
|
continue;
|
|
57
|
+
// oxlint-disable-next-line no-restricted-properties -- Throw-on-corrupt is this function's shipped contract.
|
|
41
58
|
yield JSON.parse(line);
|
|
42
59
|
}
|
|
43
60
|
}
|
package/out/utils/jsonl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../utils/jsonl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../utils/jsonl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAI,IAAY;IACxC,kGAAkG;IAClG,wFAAwF;IACxF,OAAO,CACN,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;SACnD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;QACzC,oDAAoD;SACnD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC,CACtC,CAAA;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,IAAuB;IAC/D,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,GAAG,GAAG,EAAE,CAAA;IAEZ,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;QAEjC,KAAK,EAAE,CAAA;IACR,CAAC;IAED,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;IAEhC,OAAO,KAAK,CAAA;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,YAAY,CAAI,IAAY;IAClD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAQ;QAC1B,6GAA6G;QAC7G,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAA;IAC5B,CAAC;AACF,CAAC"}
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* `JSON.stringify` is compact (`","` / `":"`). The committed files are spaced, so we match.
|
|
14
14
|
* 2. **`ensure_ascii`.** Python defaults to escaping every non-ASCII codepoint as `\uXXXX` (surrogate
|
|
15
15
|
* pairs for astral chars). `JSON.stringify` emits raw UTF-8. We replicate Python's default
|
|
16
|
-
* (`
|
|
16
|
+
* (`ensureASCII: true`) and allow `ensure_ascii=False` (`ensureASCII: false`).
|
|
17
17
|
*
|
|
18
18
|
* String escaping of ASCII (quote, backslash, `\n`/`\t`/`\r`/`\b`/`\f`, other control -> `\u00xx`)
|
|
19
19
|
* is identical between `JSON.stringify` and Python's json, so we delegate per-string base
|
|
20
|
-
* escaping to `JSON.stringify` and only post-escape the non-ASCII range when `
|
|
20
|
+
* escaping to `JSON.stringify` and only post-escape the non-ASCII range when `ensureASCII` is
|
|
21
21
|
* on.
|
|
22
22
|
*
|
|
23
23
|
* Caveat: JS has a single number type, so a whole-valued float (e.g. an exact `5.0` coordinate)
|
|
@@ -28,7 +28,7 @@ export interface PyJSONOptions {
|
|
|
28
28
|
/**
|
|
29
29
|
* Escape non-ASCII as `\uXXXX` (Python `ensure_ascii`). Defaults to `true`, matching Python.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
ensureASCII?: boolean;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* `json.dumps(value)` — single line, `(", ", ": ")` separators, `ensure_ascii` per options.
|
package/out/utils/python-json.js
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* `JSON.stringify` is compact (`","` / `":"`). The committed files are spaced, so we match.
|
|
14
14
|
* 2. **`ensure_ascii`.** Python defaults to escaping every non-ASCII codepoint as `\uXXXX` (surrogate
|
|
15
15
|
* pairs for astral chars). `JSON.stringify` emits raw UTF-8. We replicate Python's default
|
|
16
|
-
* (`
|
|
16
|
+
* (`ensureASCII: true`) and allow `ensure_ascii=False` (`ensureASCII: false`).
|
|
17
17
|
*
|
|
18
18
|
* String escaping of ASCII (quote, backslash, `\n`/`\t`/`\r`/`\b`/`\f`, other control -> `\u00xx`)
|
|
19
19
|
* is identical between `JSON.stringify` and Python's json, so we delegate per-string base
|
|
20
|
-
* escaping to `JSON.stringify` and only post-escape the non-ASCII range when `
|
|
20
|
+
* escaping to `JSON.stringify` and only post-escape the non-ASCII range when `ensureASCII` is
|
|
21
21
|
* on.
|
|
22
22
|
*
|
|
23
23
|
* Caveat: JS has a single number type, so a whole-valued float (e.g. an exact `5.0` coordinate)
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* Serialize one string the way Python's json does (then optionally `ensure_ascii`-escape it).
|
|
29
29
|
*/
|
|
30
|
-
function serializeString(value,
|
|
30
|
+
function serializeString(value, ensureASCII) {
|
|
31
31
|
// JSON.stringify handles the quote/backslash/control escaping identically to Python's json.
|
|
32
32
|
const out = JSON.stringify(value);
|
|
33
|
-
if (!
|
|
33
|
+
if (!ensureASCII)
|
|
34
34
|
return out;
|
|
35
35
|
// ensure_ascii: escape every code unit >= 0x80 as \uXXXX (surrogate halves handled per-unit,
|
|
36
36
|
// exactly as CPython emits astral codepoints as a \u-pair).
|
|
@@ -52,7 +52,7 @@ function serializeNumber(value) {
|
|
|
52
52
|
return "NaN";
|
|
53
53
|
return value > 0 ? "Infinity" : "-Infinity";
|
|
54
54
|
}
|
|
55
|
-
function serialize(value,
|
|
55
|
+
function serialize(value, ensureASCII) {
|
|
56
56
|
if (value === null || value === undefined)
|
|
57
57
|
return "null";
|
|
58
58
|
const t = typeof value;
|
|
@@ -61,16 +61,16 @@ function serialize(value, ensureAscii) {
|
|
|
61
61
|
if (t === "number")
|
|
62
62
|
return serializeNumber(value);
|
|
63
63
|
if (t === "string")
|
|
64
|
-
return serializeString(value,
|
|
64
|
+
return serializeString(value, ensureASCII);
|
|
65
65
|
if (Array.isArray(value)) {
|
|
66
|
-
return "[" + value.map((v) => serialize(v,
|
|
66
|
+
return "[" + value.map((v) => serialize(v, ensureASCII)).join(", ") + "]";
|
|
67
67
|
}
|
|
68
68
|
if (t === "object") {
|
|
69
69
|
const parts = [];
|
|
70
70
|
for (const [k, v] of Object.entries(value)) {
|
|
71
71
|
if (v === undefined)
|
|
72
72
|
continue; // a key Python would never have produced
|
|
73
|
-
parts.push(serializeString(k,
|
|
73
|
+
parts.push(serializeString(k, ensureASCII) + ": " + serialize(v, ensureASCII));
|
|
74
74
|
}
|
|
75
75
|
return "{" + parts.join(", ") + "}";
|
|
76
76
|
}
|
|
@@ -80,7 +80,7 @@ function serialize(value, ensureAscii) {
|
|
|
80
80
|
* `json.dumps(value)` — single line, `(", ", ": ")` separators, `ensure_ascii` per options.
|
|
81
81
|
*/
|
|
82
82
|
export function pyJSONDumps(value, options = {}) {
|
|
83
|
-
return serialize(value, options.
|
|
83
|
+
return serialize(value, options.ensureASCII ?? true);
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Render a string->number map the way Python prints `dict(...)` / `dict(Counter(...))` — single-quoted keys, `, ` / `:
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Python-parity numeric helpers — the third member of the `python-*` family in this directory,
|
|
7
|
+
* beside `python-json.ts` (CPython `json.dumps` spacing) and `python-random.ts` (`random.Random`).
|
|
8
|
+
*
|
|
9
|
+
* These exist because the gazetteer pipeline was ported from Python and its outputs have to match
|
|
10
|
+
* the originals bit for bit: a postcode centroid that rounds differently is a different centroid,
|
|
11
|
+
* and the shard it lands in is a different shard. Divergence here never throws — it surfaces as a
|
|
12
|
+
* shard that quietly disagrees with the reference.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Increment a non-negative decimal-digit string, propagating the carry (e.g. "999" → "1000").
|
|
16
|
+
*/
|
|
17
|
+
export declare function incDecimalString(s: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Python `round()` — correctly-rounded, round-half-to-EVEN. Works off the double's EXACT (terminating) decimal
|
|
20
|
+
* expansion via `toFixed(80)`, so it matches Python both on ordinary values (where a naïve `x * 10**nd` would diverge
|
|
21
|
+
* by a ULP) and on exact half-way ties like `40.890625` → `40.89062` (where `toFixed(nd)` rounds half-UP and would
|
|
22
|
+
* diverge). `nd === 0` keeps a fast half-even path on the double.
|
|
23
|
+
*/
|
|
24
|
+
export declare function pyRound(x: number, nd?: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* Python `float()`: trimmed-empty / non-numeric → null (the build's try/except skip).
|
|
27
|
+
*/
|
|
28
|
+
export declare function pyFloat(s: string | undefined): number | null;
|
|
29
|
+
/**
|
|
30
|
+
* Python `format(x, ".{d}f")` — round-half-to-even (banker's), unlike JS `toFixed` (half-away).
|
|
31
|
+
*/
|
|
32
|
+
export declare function pyFixed(x: number, d: number): string;
|
|
33
|
+
//# sourceMappingURL=python-numeric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python-numeric.d.ts","sourceRoot":"","sources":["../../utils/python-numeric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBlD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,SAAI,GAAG,MAAM,CA6CjD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAQ5D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAsDpD"}
|