@mailwoman/resolver-wof-sqlite 5.9.0 → 5.10.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 (43) hide show
  1. package/README.md +12 -9
  2. package/out/address-point-interpolation.d.ts +1 -1
  3. package/out/address-point.d.ts +1 -1
  4. package/out/address-point.d.ts.map +1 -1
  5. package/out/address-point.js +8 -2
  6. package/out/address-point.js.map +1 -1
  7. package/out/candidate-lookup.d.ts +1 -1
  8. package/out/convention.d.ts +1 -1
  9. package/out/fst-autocomplete.d.ts +1 -1
  10. package/out/fst-builder.d.ts +2 -2
  11. package/out/fst-deserialize-web.d.ts +2 -2
  12. package/out/fst-matcher.d.ts +1 -1
  13. package/out/fst-serialize.d.ts +2 -2
  14. package/out/fts.d.ts +1 -1
  15. package/out/fts.js +1 -1
  16. package/out/geo.js +1 -1
  17. package/out/index.d.ts +26 -26
  18. package/out/lookup.d.ts +5 -5
  19. package/out/lookup.js +2 -4
  20. package/out/lookup.js.map +1 -1
  21. package/out/reverse.d.ts +2 -2
  22. package/out/reverse.js +1 -1
  23. package/out/reverse.js.map +1 -1
  24. package/out/sqlite-convention-source.d.ts +1 -1
  25. package/out/street-centroid.d.ts +1 -1
  26. package/out/street-morphology-fst-builder.d.ts +2 -2
  27. package/package.json +192 -34
  28. package/out/build-candidate-cli.d.ts +0 -16
  29. package/out/build-candidate-cli.d.ts.map +0 -1
  30. package/out/build-candidate-cli.js +0 -86
  31. package/out/build-candidate-cli.js.map +0 -1
  32. package/out/build-coincident-roles-cli.d.ts +0 -16
  33. package/out/build-coincident-roles-cli.d.ts.map +0 -1
  34. package/out/build-coincident-roles-cli.js +0 -99
  35. package/out/build-coincident-roles-cli.js.map +0 -1
  36. package/out/build-fts-cli.d.ts +0 -23
  37. package/out/build-fts-cli.d.ts.map +0 -1
  38. package/out/build-fts-cli.js +0 -120
  39. package/out/build-fts-cli.js.map +0 -1
  40. package/out/build-slim-cli.d.ts +0 -14
  41. package/out/build-slim-cli.d.ts.map +0 -1
  42. package/out/build-slim-cli.js +0 -135
  43. package/out/build-slim-cli.js.map +0 -1
@@ -22,8 +22,8 @@
22
22
  * Output: an `FSTMatcher` ready to serialize via `serializeFST` to e.g.
23
23
  * `fst-street-morphology.bin`.
24
24
  */
25
- import { FSTMatcher } from "./fst-matcher.js";
26
- import type { FSTProvenance } from "./fst-types.js";
25
+ import { FSTMatcher } from "./fst-matcher.ts";
26
+ import type { FSTProvenance } from "./fst-types.ts";
27
27
  export interface BuildStreetMorphologyFSTOpts {
28
28
  /** Path to the `core/data/libpostal/dictionaries` directory containing per-locale subfolders. */
29
29
  dictionariesDir: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/resolver-wof-sqlite",
3
- "version": "5.9.0",
3
+ "version": "5.10.0",
4
4
  "description": "Who's On First SQLite resolver — FTS5-backed PlaceLookup that resolves text queries to WOF place IDs + coordinates. Optional dependency for callers who want geocoding.",
5
5
  "license": "AGPL-3.0-only OR LicenseRef-Commercial",
6
6
  "repository": {
@@ -8,12 +8,6 @@
8
8
  "url": "https://github.com/sister-software/mailwoman.git",
9
9
  "directory": "resolver-wof-sqlite"
10
10
  },
11
- "bin": {
12
- "mailwoman-wof-build-candidate": "./out/build-candidate-cli.js",
13
- "mailwoman-wof-build-coincident-roles": "./out/build-coincident-roles-cli.js",
14
- "mailwoman-wof-build-fts": "./out/build-fts-cli.js",
15
- "mailwoman-wof-build-slim": "./out/build-slim-cli.js"
16
- },
17
11
  "files": [
18
12
  "out/**/*.js",
19
13
  "out/**/*.js.map",
@@ -24,38 +18,202 @@
24
18
  "type": "module",
25
19
  "exports": {
26
20
  "./package.json": "./package.json",
27
- ".": "./out/index.js",
28
- "./fts": "./out/fts.js",
29
- "./build-slim": "./out/build-slim.js",
30
- "./fst-builder": "./out/fst-builder.js",
31
- "./street-morphology-fst-builder": "./out/street-morphology-fst-builder.js",
32
- "./fst-matcher": "./out/fst-matcher.js",
33
- "./fst-serialize": "./out/fst-serialize.js",
34
- "./fst-autocomplete": "./out/fst-autocomplete.js",
35
- "./fst-types": "./out/fst-types.js",
36
- "./fst-deserialize-web": "./out/fst-deserialize-web.js",
37
- "./unified-schema": "./out/unified-schema.js",
38
- "./ancestry-backfill": "./out/ancestry-backfill.js",
39
- "./coincident-roles": "./out/coincident-roles.js",
40
- "./geonames-aliases": "./out/geonames-aliases.js",
41
- "./geonames-postal": "./out/geonames-postal.js",
42
- "./geo": "./out/geo.js",
43
- "./street-normalize": "./out/street-normalize.js",
44
- "./build-candidate": "./out/build-candidate.js",
45
- "./candidate-schema": "./out/candidate-schema.js",
46
- "./postal-city-alias-schema": "./out/postal-city-alias-schema.js",
47
- "./address-point-schema": "./out/address-point-schema.js",
48
- "./street-centroid-schema": "./out/street-centroid-schema.js",
49
- "./street-segment-schema": "./out/street-segment-schema.js"
21
+ ".": {
22
+ "types": "./out/index.d.ts",
23
+ "default": "./out/index.js"
24
+ },
25
+ "./fts": {
26
+ "types": "./out/fts.d.ts",
27
+ "default": "./out/fts.js"
28
+ },
29
+ "./build-slim": {
30
+ "types": "./out/build-slim.d.ts",
31
+ "default": "./out/build-slim.js"
32
+ },
33
+ "./fst-builder": {
34
+ "types": "./out/fst-builder.d.ts",
35
+ "default": "./out/fst-builder.js"
36
+ },
37
+ "./street-morphology-fst-builder": {
38
+ "types": "./out/street-morphology-fst-builder.d.ts",
39
+ "default": "./out/street-morphology-fst-builder.js"
40
+ },
41
+ "./fst-matcher": {
42
+ "types": "./out/fst-matcher.d.ts",
43
+ "default": "./out/fst-matcher.js"
44
+ },
45
+ "./fst-serialize": {
46
+ "types": "./out/fst-serialize.d.ts",
47
+ "default": "./out/fst-serialize.js"
48
+ },
49
+ "./fst-autocomplete": {
50
+ "types": "./out/fst-autocomplete.d.ts",
51
+ "default": "./out/fst-autocomplete.js"
52
+ },
53
+ "./fst-types": {
54
+ "types": "./out/fst-types.d.ts",
55
+ "default": "./out/fst-types.js"
56
+ },
57
+ "./fst-deserialize-web": {
58
+ "types": "./out/fst-deserialize-web.d.ts",
59
+ "default": "./out/fst-deserialize-web.js"
60
+ },
61
+ "./unified-schema": {
62
+ "types": "./out/unified-schema.d.ts",
63
+ "default": "./out/unified-schema.js"
64
+ },
65
+ "./ancestry-backfill": {
66
+ "types": "./out/ancestry-backfill.d.ts",
67
+ "default": "./out/ancestry-backfill.js"
68
+ },
69
+ "./coincident-roles": {
70
+ "types": "./out/coincident-roles.d.ts",
71
+ "default": "./out/coincident-roles.js"
72
+ },
73
+ "./geonames-aliases": {
74
+ "types": "./out/geonames-aliases.d.ts",
75
+ "default": "./out/geonames-aliases.js"
76
+ },
77
+ "./geonames-postal": {
78
+ "types": "./out/geonames-postal.d.ts",
79
+ "default": "./out/geonames-postal.js"
80
+ },
81
+ "./geo": {
82
+ "types": "./out/geo.d.ts",
83
+ "default": "./out/geo.js"
84
+ },
85
+ "./street-normalize": {
86
+ "types": "./out/street-normalize.d.ts",
87
+ "default": "./out/street-normalize.js"
88
+ },
89
+ "./build-candidate": {
90
+ "types": "./out/build-candidate.d.ts",
91
+ "default": "./out/build-candidate.js"
92
+ },
93
+ "./candidate-schema": {
94
+ "types": "./out/candidate-schema.d.ts",
95
+ "default": "./out/candidate-schema.js"
96
+ },
97
+ "./postal-city-alias-schema": {
98
+ "types": "./out/postal-city-alias-schema.d.ts",
99
+ "default": "./out/postal-city-alias-schema.js"
100
+ },
101
+ "./address-point-schema": {
102
+ "types": "./out/address-point-schema.d.ts",
103
+ "default": "./out/address-point-schema.js"
104
+ },
105
+ "./street-centroid-schema": {
106
+ "types": "./out/street-centroid-schema.d.ts",
107
+ "default": "./out/street-centroid-schema.js"
108
+ },
109
+ "./street-segment-schema": {
110
+ "types": "./out/street-segment-schema.d.ts",
111
+ "default": "./out/street-segment-schema.js"
112
+ }
50
113
  },
51
114
  "publishConfig": {
115
+ "exports": {
116
+ "./package.json": "./package.json",
117
+ ".": {
118
+ "types": "./out/index.d.ts",
119
+ "default": "./out/index.js"
120
+ },
121
+ "./fts": {
122
+ "types": "./out/fts.d.ts",
123
+ "default": "./out/fts.js"
124
+ },
125
+ "./build-slim": {
126
+ "types": "./out/build-slim.d.ts",
127
+ "default": "./out/build-slim.js"
128
+ },
129
+ "./fst-builder": {
130
+ "types": "./out/fst-builder.d.ts",
131
+ "default": "./out/fst-builder.js"
132
+ },
133
+ "./street-morphology-fst-builder": {
134
+ "types": "./out/street-morphology-fst-builder.d.ts",
135
+ "default": "./out/street-morphology-fst-builder.js"
136
+ },
137
+ "./fst-matcher": {
138
+ "types": "./out/fst-matcher.d.ts",
139
+ "default": "./out/fst-matcher.js"
140
+ },
141
+ "./fst-serialize": {
142
+ "types": "./out/fst-serialize.d.ts",
143
+ "default": "./out/fst-serialize.js"
144
+ },
145
+ "./fst-autocomplete": {
146
+ "types": "./out/fst-autocomplete.d.ts",
147
+ "default": "./out/fst-autocomplete.js"
148
+ },
149
+ "./fst-types": {
150
+ "types": "./out/fst-types.d.ts",
151
+ "default": "./out/fst-types.js"
152
+ },
153
+ "./fst-deserialize-web": {
154
+ "types": "./out/fst-deserialize-web.d.ts",
155
+ "default": "./out/fst-deserialize-web.js"
156
+ },
157
+ "./unified-schema": {
158
+ "types": "./out/unified-schema.d.ts",
159
+ "default": "./out/unified-schema.js"
160
+ },
161
+ "./ancestry-backfill": {
162
+ "types": "./out/ancestry-backfill.d.ts",
163
+ "default": "./out/ancestry-backfill.js"
164
+ },
165
+ "./coincident-roles": {
166
+ "types": "./out/coincident-roles.d.ts",
167
+ "default": "./out/coincident-roles.js"
168
+ },
169
+ "./geonames-aliases": {
170
+ "types": "./out/geonames-aliases.d.ts",
171
+ "default": "./out/geonames-aliases.js"
172
+ },
173
+ "./geonames-postal": {
174
+ "types": "./out/geonames-postal.d.ts",
175
+ "default": "./out/geonames-postal.js"
176
+ },
177
+ "./geo": {
178
+ "types": "./out/geo.d.ts",
179
+ "default": "./out/geo.js"
180
+ },
181
+ "./street-normalize": {
182
+ "types": "./out/street-normalize.d.ts",
183
+ "default": "./out/street-normalize.js"
184
+ },
185
+ "./build-candidate": {
186
+ "types": "./out/build-candidate.d.ts",
187
+ "default": "./out/build-candidate.js"
188
+ },
189
+ "./candidate-schema": {
190
+ "types": "./out/candidate-schema.d.ts",
191
+ "default": "./out/candidate-schema.js"
192
+ },
193
+ "./postal-city-alias-schema": {
194
+ "types": "./out/postal-city-alias-schema.d.ts",
195
+ "default": "./out/postal-city-alias-schema.js"
196
+ },
197
+ "./address-point-schema": {
198
+ "types": "./out/address-point-schema.d.ts",
199
+ "default": "./out/address-point-schema.js"
200
+ },
201
+ "./street-centroid-schema": {
202
+ "types": "./out/street-centroid-schema.d.ts",
203
+ "default": "./out/street-centroid-schema.js"
204
+ },
205
+ "./street-segment-schema": {
206
+ "types": "./out/street-segment-schema.d.ts",
207
+ "default": "./out/street-segment-schema.js"
208
+ }
209
+ },
52
210
  "access": "public"
53
211
  },
54
212
  "dependencies": {
55
- "@mailwoman/codex": "5.9.0",
56
- "@mailwoman/core": "5.9.0",
57
- "@mailwoman/resolver": "5.9.0",
58
- "@mailwoman/spatial": "5.9.0",
213
+ "@mailwoman/codex": "5.10.0",
214
+ "@mailwoman/core": "5.10.0",
215
+ "@mailwoman/resolver": "5.10.0",
216
+ "@mailwoman/spatial": "5.10.0",
59
217
  "kysely": "^0.29.2"
60
218
  }
61
219
  }
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @copyright Sister Software
4
- * @license AGPL-3.0
5
- * @author Teffen Ellis, et al.
6
- *
7
- * `mailwoman-wof-build-candidate --in <admin.db> --out <candidate.db>`
8
- *
9
- * Operator-side one-shot CLI that builds the global byte-range "candidate" lookup DB for the
10
- * browser demo (the FTS-free, single-probe gazetteer). Delegates to
11
- * {@linkcode buildCandidateTable}; the CLI is just argument parsing + stderr progress. The
12
- * TypeScript port of the 2026-06-20 prototype — it lives in the package (not /scripts) so the
13
- * name_key normalizer is the SAME shared `normalizeLocalityForKey` the query-side resolver uses.
14
- */
15
- export declare function main(rawArgv: string[]): Promise<number>;
16
- //# sourceMappingURL=build-candidate-cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-candidate-cli.d.ts","sourceRoot":"","sources":["../build-candidate-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AA+DH,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB7D"}
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @copyright Sister Software
4
- * @license AGPL-3.0
5
- * @author Teffen Ellis, et al.
6
- *
7
- * `mailwoman-wof-build-candidate --in <admin.db> --out <candidate.db>`
8
- *
9
- * Operator-side one-shot CLI that builds the global byte-range "candidate" lookup DB for the
10
- * browser demo (the FTS-free, single-probe gazetteer). Delegates to
11
- * {@linkcode buildCandidateTable}; the CLI is just argument parsing + stderr progress. The
12
- * TypeScript port of the 2026-06-20 prototype — it lives in the package (not /scripts) so the
13
- * name_key normalizer is the SAME shared `normalizeLocalityForKey` the query-side resolver uses.
14
- */
15
- import { exit, stderr } from "node:process";
16
- import { cliArguments, runIfScript } from "@mailwoman/core/utils";
17
- import { buildCandidateTable } from "./build-candidate.js";
18
- function printUsageAndExit(code) {
19
- stderr.write([
20
- "usage: mailwoman-wof-build-candidate --in <admin.db> --out <candidate.db> [--postcodes <pc.db>]...",
21
- "",
22
- "Builds the global candidate lookup DB (FTS-free, single B-tree probe per resolve) from a",
23
- "unified admin WOF DB (needs spr, place_population, place_search, place_abbr, ancestors).",
24
- "--postcodes folds a postcode shard (spr placetype='postalcode' + coords, e.g. postalcode-us.db)",
25
- "in as postalcode rows so findPlace(postalcode) resolves a ZIP. Name keys use the shared",
26
- "normalizeLocalityForKey — the query side MUST match.",
27
- "",
28
- ].join("\n"));
29
- exit(code);
30
- }
31
- function parseArgs(argv) {
32
- let input;
33
- let output;
34
- const postcodes = [];
35
- for (let i = 0; i < argv.length; i++) {
36
- const a = argv[i];
37
- if (a === "--in" || a === "--input") {
38
- input = argv[++i];
39
- }
40
- else if (a === "--out" || a === "--output") {
41
- output = argv[++i];
42
- }
43
- else if (a === "--postcodes") {
44
- const v = argv[++i];
45
- if (v) {
46
- postcodes.push(v);
47
- }
48
- }
49
- else if (a === "-h" || a === "--help") {
50
- printUsageAndExit(0);
51
- }
52
- else {
53
- stderr.write(`unknown argument: ${a}\n`);
54
- printUsageAndExit(1);
55
- }
56
- }
57
- if (!input || !output) {
58
- printUsageAndExit(1);
59
- }
60
- return { input, output, postcodes };
61
- }
62
- export async function main(rawArgv) {
63
- const args = parseArgs(rawArgv);
64
- const t0 = Date.now();
65
- const result = await buildCandidateTable({
66
- input: args.input,
67
- output: args.output,
68
- postcodes: args.postcodes,
69
- onProgress: (phase, message) => stderr.write(` [${phase}] ${message}\n`),
70
- });
71
- const secs = ((Date.now() - t0) / 1000).toFixed(1);
72
- stderr.write(`done in ${secs}s: ${result.rows.toLocaleString()} rows ` +
73
- `(${result.primaries.toLocaleString()} primary, ${result.aliases.toLocaleString()} alias, ` +
74
- `${result.abbrevs} abbr, ${result.postcodes.toLocaleString()} postcode) ` +
75
- `from ${result.places.toLocaleString()} places → ${args.output}\n`);
76
- return 0;
77
- }
78
- void runIfScript(import.meta, async () => {
79
- main(cliArguments())
80
- .then((code) => exit(code))
81
- .catch((err) => {
82
- stderr.write(`${err instanceof Error ? err.stack : String(err)}\n`);
83
- exit(1);
84
- });
85
- });
86
- //# sourceMappingURL=build-candidate-cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-candidate-cli.js","sourceRoot":"","sources":["../build-candidate-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEjE,OAAO,EAAE,m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CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;IACxC,IAAI,CAAC,YAAY,EAAE,CAAC;SAClB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1B,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACd,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACnE,IAAI,CAAC,CAAC,CAAC,CAAA;IACR,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @copyright Sister Software
4
- * @license AGPL-3.0
5
- * @author Teffen Ellis, et al.
6
- *
7
- * `mailwoman-wof-build-coincident-roles <path-to-admin.db>... [--drop]`
8
- *
9
- * Operator-side one-shot CLI (#403, epic #402): derives the `coincident_roles` relation into an
10
- * existing admin gazetteer — the dual-role places (city-states, capital-seat provinces,
11
- * consolidated city-counties) the hierarchy-completion step (#405) consults. Additive +
12
- * idempotent; re-run after refreshing `spr`/`ancestors`. Mirrors `build-fts-cli.ts`. Should also
13
- * be invoked as a post-step of the main `scripts/build-unified-wof.ts`.
14
- */
15
- export declare function main(argv: readonly string[]): number;
16
- //# sourceMappingURL=build-coincident-roles-cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-coincident-roles-cli.d.ts","sourceRoot":"","sources":["../build-coincident-roles-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AA6DH,wBAAgB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAmCpD"}
@@ -1,99 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @copyright Sister Software
4
- * @license AGPL-3.0
5
- * @author Teffen Ellis, et al.
6
- *
7
- * `mailwoman-wof-build-coincident-roles <path-to-admin.db>... [--drop]`
8
- *
9
- * Operator-side one-shot CLI (#403, epic #402): derives the `coincident_roles` relation into an
10
- * existing admin gazetteer — the dual-role places (city-states, capital-seat provinces,
11
- * consolidated city-counties) the hierarchy-completion step (#405) consults. Additive +
12
- * idempotent; re-run after refreshing `spr`/`ancestors`. Mirrors `build-fts-cli.ts`. Should also
13
- * be invoked as a post-step of the main `scripts/build-unified-wof.ts`.
14
- */
15
- import { existsSync } from "node:fs";
16
- import { exit, stderr } from "node:process";
17
- import { DatabaseSync } from "node:sqlite";
18
- import { cliArguments, runIfScript } from "@mailwoman/core/utils";
19
- import { buildCoincidentRoles } from "./coincident-roles.js";
20
- function printUsageAndExit(code) {
21
- stderr.write([
22
- "usage: mailwoman-wof-build-coincident-roles <path-to-admin.db>... [--drop]",
23
- "",
24
- "Derives the coincident_roles relation (dual-role places — city-states, capital-seat",
25
- "provinces, consolidated city-counties) into one or more admin gazetteers. The",
26
- "hierarchy-completion resolver step (#405) consults it. Additive + idempotent.",
27
- "",
28
- " --drop Drop and rebuild coincident_roles if it already exists (default: rebuild).",
29
- "",
30
- "Example:",
31
- " mailwoman-wof-build-coincident-roles /data/wof/admin-global-priority.db",
32
- "",
33
- ].join("\n"));
34
- exit(code);
35
- }
36
- function buildOne(path, drop) {
37
- if (!existsSync(path)) {
38
- stderr.write(`mailwoman-wof-build-coincident-roles: file not found: ${path}\n`);
39
- return 1;
40
- }
41
- stderr.write(`Opening ${path}…\n`);
42
- const db = new DatabaseSync(path);
43
- try {
44
- const result = buildCoincidentRoles(db, {
45
- drop,
46
- onProgress: (phase, detail) => stderr.write(` [${phase}]${detail ? ` — ${detail}` : ""}\n`),
47
- });
48
- const top = Object.entries(result.byCountry)
49
- .sort((a, b) => b[1] - a[1])
50
- .map(([cc, n]) => `${cc} ${n}`)
51
- .join(", ");
52
- stderr.write(`Built: ${result.rowCount} coincident-role rows (${(result.durationMs / 1000).toFixed(2)}s)\n by country: ${top}\n`);
53
- return 0;
54
- }
55
- catch (err) {
56
- stderr.write(`mailwoman-wof-build-coincident-roles: ${err instanceof Error ? err.message : String(err)}\n`);
57
- return 1;
58
- }
59
- finally {
60
- db.close();
61
- }
62
- }
63
- export function main(argv) {
64
- const paths = [];
65
- // The relation is a cheap (~2 s) derived table that must reflect the current spr/ancestors, so it
66
- // rebuilds by default (idempotent). `--no-drop` appends instead — only useful for incremental tests.
67
- let drop = true;
68
- for (const a of argv) {
69
- if (a === "--drop") {
70
- drop = true;
71
- }
72
- else if (a === "--no-drop") {
73
- drop = false;
74
- }
75
- else if (a === "--help" || a === "-h") {
76
- printUsageAndExit(0);
77
- }
78
- else if (a.startsWith("-")) {
79
- stderr.write(`mailwoman-wof-build-coincident-roles: unknown flag ${JSON.stringify(a)}\n`);
80
- printUsageAndExit(2);
81
- }
82
- else {
83
- paths.push(a);
84
- }
85
- }
86
- if (paths.length === 0) {
87
- printUsageAndExit(2);
88
- }
89
- let worst = 0;
90
- for (const path of paths) {
91
- const rc = buildOne(path, drop);
92
- if (rc > worst) {
93
- worst = rc;
94
- }
95
- }
96
- return worst;
97
- }
98
- void runIfScript(import.meta, () => exit(main(cliArguments())));
99
- //# sourceMappingURL=build-coincident-roles-cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-coincident-roles-cli.js","sourceRoot":"","sources":["../build-coincident-roles-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAE5D,SAAS,iBAAiB,CAAC,IAAY;IACtC,MAAM,CAAC,KAAK,CACX;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AAE,CAAC;QACxB,iBAAiB,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;IACD,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAE/B,IAAI,EAAE,GAAG,KAAK,EAAE,CAAC;YAChB,KAAK,GAAG,EAAE,CAAA;QACX,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC;AAED,KAAK,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAA"}
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @copyright Sister Software
4
- * @license AGPL-3.0
5
- * @author Teffen Ellis, et al.
6
- *
7
- * `mailwoman-wof-build-fts <path-to-wof.db>... [--drop]`
8
- *
9
- * Operator-side one-shot CLI: takes one or more Who's On First SQLite distributions and adds the
10
- * `place_search` FTS5 + `place_bbox` R*Tree virtual tables needed by `WOFSqlitePlaceLookup`. Run
11
- * this once per downloaded WOF shard so production callers can skip the (~minutes-long) lazy
12
- * build.
13
- *
14
- * Multiple positional args process each DB in sequence — useful when you've just pulled the admin +
15
- * postcode shards in one go.
16
- *
17
- * Why a plain-args CLI rather than Ink / Pastel: this is a one-shot operator script, not an
18
- * interactive TUI. The dep weight of inkjs / pastel would dominate the script's footprint and
19
- * doesn't match how operators expect to drive a build step (`script /path/to/db` + stderr
20
- * progress). Matches the spirit of `corpus/scripts/*.ts`.
21
- */
22
- export declare function main(argv: readonly string[]): number;
23
- //# sourceMappingURL=build-fts-cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-fts-cli.d.ts","sourceRoot":"","sources":["../build-fts-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;GAmBG;AAuGH,wBAAgB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAcpD"}
@@ -1,120 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @copyright Sister Software
4
- * @license AGPL-3.0
5
- * @author Teffen Ellis, et al.
6
- *
7
- * `mailwoman-wof-build-fts <path-to-wof.db>... [--drop]`
8
- *
9
- * Operator-side one-shot CLI: takes one or more Who's On First SQLite distributions and adds the
10
- * `place_search` FTS5 + `place_bbox` R*Tree virtual tables needed by `WOFSqlitePlaceLookup`. Run
11
- * this once per downloaded WOF shard so production callers can skip the (~minutes-long) lazy
12
- * build.
13
- *
14
- * Multiple positional args process each DB in sequence — useful when you've just pulled the admin +
15
- * postcode shards in one go.
16
- *
17
- * Why a plain-args CLI rather than Ink / Pastel: this is a one-shot operator script, not an
18
- * interactive TUI. The dep weight of inkjs / pastel would dominate the script's footprint and
19
- * doesn't match how operators expect to drive a build step (`script /path/to/db` + stderr
20
- * progress). Matches the spirit of `corpus/scripts/*.ts`.
21
- */
22
- import { existsSync } from "node:fs";
23
- import { exit, stderr } from "node:process";
24
- import { DatabaseSync } from "node:sqlite";
25
- import { cliArguments, runIfScript } from "@mailwoman/core/utils";
26
- import { buildPlaceSearchFTS } from "./fts.js";
27
- function printUsageAndExit(code) {
28
- stderr.write([
29
- "usage: mailwoman-wof-build-fts <path-to-wof.db>... [--drop]",
30
- "",
31
- "Builds the place_search FTS5 + place_bbox R*Tree virtual tables in one or more",
32
- "Who's On First SQLite distributions. Run this once per downloaded WOF shard so",
33
- "production WOFSqlitePlaceLookup instances skip the lazy-build cost at first open.",
34
- "",
35
- " --drop Drop and rebuild place_search + place_bbox if they already exist.",
36
- " Apply after refreshing the spr / names tables from a newer dump.",
37
- "",
38
- "Examples:",
39
- " mailwoman-wof-build-fts /data/wof/admin-us.db",
40
- " mailwoman-wof-build-fts /data/wof/admin-us.db /data/wof/postalcode-us.db",
41
- " mailwoman-wof-build-fts /data/wof/admin-us.db --drop",
42
- "",
43
- "See https://github.com/sister-software/mailwoman/tree/main/resolver-wof-sqlite for",
44
- "the recommended WOF distribution sources + attribution requirements.",
45
- "",
46
- ].join("\n"));
47
- exit(code);
48
- }
49
- function parseArgs(argv) {
50
- const args = [];
51
- let drop = false;
52
- for (const a of argv) {
53
- if (a === "--drop") {
54
- drop = true;
55
- }
56
- else if (a === "--help" || a === "-h") {
57
- printUsageAndExit(0);
58
- }
59
- else if (a.startsWith("-")) {
60
- stderr.write(`mailwoman-wof-build-fts: unknown flag ${JSON.stringify(a)}\n`);
61
- printUsageAndExit(2);
62
- }
63
- else {
64
- args.push(a);
65
- }
66
- }
67
- if (args.length === 0) {
68
- stderr.write(`mailwoman-wof-build-fts: expected at least one positional arg\n`);
69
- printUsageAndExit(2);
70
- }
71
- return { databasePaths: args, drop };
72
- }
73
- /**
74
- * Build indexes on a single DB. Returns 0 on success, 1 on failure. Errors are written to stderr but the call doesn't
75
- * throw — `main()` aggregates the exit code across multi-DB invocations.
76
- */
77
- function buildOne(path, drop) {
78
- if (!existsSync(path)) {
79
- stderr.write(`mailwoman-wof-build-fts: file not found: ${path}\n`);
80
- return 1;
81
- }
82
- stderr.write(`Opening ${path}…\n`);
83
- const db = new DatabaseSync(path);
84
- try {
85
- const result = buildPlaceSearchFTS(db, {
86
- drop,
87
- onProgress: (phase, detail) => {
88
- const suffix = detail ? ` — ${detail}` : "";
89
- stderr.write(` [${phase}]${suffix}\n`);
90
- },
91
- });
92
- const verb = result.created ? "Built" : "Already present";
93
- stderr.write(`${verb}: place_search has ${result.indexedRows.toLocaleString()} rows ` +
94
- `(${(result.durationMs / 1000).toFixed(2)}s)\n`);
95
- return 0;
96
- }
97
- catch (err) {
98
- const message = err instanceof Error ? err.message : String(err);
99
- stderr.write(`mailwoman-wof-build-fts: ${message}\n`);
100
- return 1;
101
- }
102
- finally {
103
- db.close();
104
- }
105
- }
106
- export function main(argv) {
107
- const args = parseArgs(argv);
108
- // Process every DB; if any fail, the worst exit code wins (so CI / scripts see failure).
109
- let worst = 0;
110
- for (const path of args.databasePaths) {
111
- const rc = buildOne(path, args.drop);
112
- if (rc > worst) {
113
- worst = rc;
114
- }
115
- }
116
- return worst;
117
- }
118
- // Entry point — only run when invoked directly, not when imported by tests.
119
- void runIfScript(import.meta, () => exit(main(cliArguments())));
120
- //# sourceMappingURL=build-fts-cli.js.map