@mailwoman/core 5.6.0 → 5.8.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/data/chromium-i18n/ssl-address-download.ts +7 -11
- package/data/libpostal/resources-download.ts +9 -12
- package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
- package/out/coarse-placer/coarse-placer.js +12 -7
- package/out/coarse-placer/coarse-placer.js.map +1 -1
- package/out/coarse-placer/tools/build-dataset.d.ts +21 -0
- package/out/coarse-placer/tools/build-dataset.d.ts.map +1 -0
- package/out/coarse-placer/tools/build-dataset.js +171 -0
- package/out/coarse-placer/tools/build-dataset.js.map +1 -0
- package/out/coarse-placer/tools/build-outlier-exposure.d.ts +19 -0
- package/out/coarse-placer/tools/build-outlier-exposure.d.ts.map +1 -0
- package/out/coarse-placer/tools/build-outlier-exposure.js +144 -0
- package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -0
- package/out/coarse-placer/tools/build-outlier-latin.d.ts +2 -0
- package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -0
- package/out/coarse-placer/tools/build-outlier-latin.js +155 -0
- package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -0
- package/out/coarse-placer/tools/build-outlier-oa.d.ts +2 -0
- package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -0
- package/out/coarse-placer/tools/build-outlier-oa.js +182 -0
- package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -0
- package/out/coarse-placer/tools/eval-latin-offmap.d.ts +2 -0
- package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -0
- package/out/coarse-placer/tools/eval-latin-offmap.js +103 -0
- package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -0
- package/out/coarse-placer/tools/eval-openset.d.ts +34 -0
- package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -0
- package/out/coarse-placer/tools/eval-openset.js +394 -0
- package/out/coarse-placer/tools/eval-openset.js.map +1 -0
- package/out/coarse-placer/tools/eval-quant-compare.d.ts +2 -0
- package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -0
- package/out/coarse-placer/tools/eval-quant-compare.js +107 -0
- package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -0
- package/out/coarse-placer/tools/eval.d.ts +14 -0
- package/out/coarse-placer/tools/eval.d.ts.map +1 -0
- package/out/coarse-placer/tools/eval.js +131 -0
- package/out/coarse-placer/tools/eval.js.map +1 -0
- package/out/coarse-placer/tools/probe-frontier.d.ts +23 -0
- package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -0
- package/out/coarse-placer/tools/probe-frontier.js +159 -0
- package/out/coarse-placer/tools/probe-frontier.js.map +1 -0
- package/out/coarse-placer/tools/quantize.d.ts +2 -0
- package/out/coarse-placer/tools/quantize.d.ts.map +1 -0
- package/out/coarse-placer/tools/quantize.js +80 -0
- package/out/coarse-placer/tools/quantize.js.map +1 -0
- package/out/coarse-placer/tools/train.d.ts +16 -0
- package/out/coarse-placer/tools/train.d.ts.map +1 -0
- package/out/coarse-placer/tools/train.js +173 -0
- package/out/coarse-placer/tools/train.js.map +1 -0
- package/out/data/chromium-i18n/ssl-address-download.js +5 -11
- package/out/data/chromium-i18n/ssl-address-download.js.map +1 -1
- package/out/data/libpostal/resources-download.js +7 -12
- package/out/data/libpostal/resources-download.js.map +1 -1
- package/out/decoder/arbitrate-tree.d.ts.map +1 -1
- package/out/decoder/arbitrate-tree.js +8 -4
- package/out/decoder/arbitrate-tree.js.map +1 -1
- package/out/decoder/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js +17 -9
- package/out/decoder/build-tree.js.map +1 -1
- package/out/decoder/calibration.d.ts.map +1 -1
- package/out/decoder/calibration.js +4 -2
- package/out/decoder/calibration.js.map +1 -1
- package/out/decoder/proposals-to-tree.d.ts.map +1 -1
- package/out/decoder/proposals-to-tree.js +4 -2
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/serialize-json.d.ts.map +1 -1
- package/out/decoder/serialize-json.js +10 -5
- package/out/decoder/serialize-json.js.map +1 -1
- package/out/decoder/serialize-tuples.d.ts.map +1 -1
- package/out/decoder/serialize-tuples.js +6 -3
- package/out/decoder/serialize-tuples.js.map +1 -1
- package/out/decoder/serialize-xml.d.ts.map +1 -1
- package/out/decoder/serialize-xml.js +6 -3
- package/out/decoder/serialize-xml.js.map +1 -1
- package/out/decoder/unknown-spans.d.ts.map +1 -1
- package/out/decoder/unknown-spans.js +6 -3
- package/out/decoder/unknown-spans.js.map +1 -1
- package/out/env/index.d.ts +7 -0
- package/out/env/index.d.ts.map +1 -1
- package/out/env/index.js +1 -0
- package/out/env/index.js.map +1 -1
- package/out/env/paths.d.ts.map +1 -1
- package/out/env/paths.js +2 -1
- package/out/env/paths.js.map +1 -1
- package/out/env/schema.d.ts +7 -0
- package/out/env/schema.d.ts.map +1 -1
- package/out/env/schema.js +11 -0
- package/out/env/schema.js.map +1 -1
- package/out/parser/proposal-pipeline.d.ts.map +1 -1
- package/out/parser/proposal-pipeline.js +8 -4
- package/out/parser/proposal-pipeline.js.map +1 -1
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +12 -6
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/span-logit-aggregation.js +2 -1
- package/out/pipeline/span-logit-aggregation.js.map +1 -1
- package/out/pipeline/span-proposer.d.ts.map +1 -1
- package/out/pipeline/span-proposer.js +14 -7
- package/out/pipeline/span-proposer.js.map +1 -1
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js +2 -1
- package/out/resolver/types.js.map +1 -1
- package/out/resources/fs.js +1 -1
- package/out/resources/fs.js.map +1 -1
- package/out/resources/git.js +1 -1
- package/out/resources/git.js.map +1 -1
- package/out/resources/libpostal.js +1 -1
- package/out/resources/libpostal.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/mermaid.js +2 -1
- package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
- package/out/types/mapping.d.ts.map +1 -1
- package/out/types/mapping.js +2 -1
- package/out/types/mapping.js.map +1 -1
- package/out/utils/data-root.d.ts +1 -1
- package/out/utils/data-root.d.ts.map +1 -1
- package/out/utils/data-root.js +11 -9
- package/out/utils/data-root.js.map +1 -1
- package/out/utils/index.d.ts +4 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +4 -0
- package/out/utils/index.js.map +1 -1
- package/out/utils/python-json.d.ts +38 -0
- package/out/utils/python-json.d.ts.map +1 -0
- package/out/utils/python-json.js +90 -0
- package/out/utils/python-json.js.map +1 -0
- package/out/utils/python-random.d.ts +41 -0
- package/out/utils/python-random.d.ts.map +1 -0
- package/out/utils/python-random.js +78 -0
- package/out/utils/python-random.js.map +1 -0
- package/out/utils/repo.d.ts +16 -1
- package/out/utils/repo.d.ts.map +1 -1
- package/out/utils/repo.js +18 -1
- package/out/utils/repo.js.map +1 -1
- package/out/utils/scripting.d.ts +50 -0
- package/out/utils/scripting.d.ts.map +1 -0
- package/out/utils/scripting.js +99 -0
- package/out/utils/scripting.js.map +1 -0
- package/out/utils/sealed-db.d.ts +20 -0
- package/out/utils/sealed-db.d.ts.map +1 -0
- package/out/utils/sealed-db.js +74 -0
- package/out/utils/sealed-db.js.map +1 -0
- package/out/vitest.config.d.ts.map +1 -1
- package/out/vitest.config.js +1 -2
- package/out/vitest.config.js.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import esMain from "es-main";
|
|
2
|
+
import { ResourceError } from "../errors/index.js";
|
|
3
|
+
import { ServiceRepository } from "../lifecycle/index.js";
|
|
4
|
+
import { ConsoleLogger, stringifyLoggedObject } from "../logging/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Logs an error that occurred while running a script.
|
|
7
|
+
*/
|
|
8
|
+
export function logScriptError(error) {
|
|
9
|
+
ConsoleLogger.error("An error occurred while running the script.");
|
|
10
|
+
const normalizedError = error instanceof ResourceError ? error : ResourceError.wrap(error);
|
|
11
|
+
ConsoleLogger.error(normalizedError);
|
|
12
|
+
if (normalizedError.cause instanceof Error && normalizedError.cause.stack) {
|
|
13
|
+
ConsoleLogger.error("Stack via cause:\n" + normalizedError.cause.stack);
|
|
14
|
+
}
|
|
15
|
+
else if (normalizedError.stack) {
|
|
16
|
+
ConsoleLogger.error("Stack via cause:\n" + normalizedError.stack);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Cleans up services and exits the script cleanly.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export function postScriptCleanup(signal = "SIGTERM", exitCode = 0) {
|
|
25
|
+
ConsoleLogger.debug(`\n[${signal}] Shutting down...`);
|
|
26
|
+
const timeout = setTimeout(() => {
|
|
27
|
+
ConsoleLogger.error("Script did not exit in a timely manner.");
|
|
28
|
+
ServiceRepository.abortController.abort(signal);
|
|
29
|
+
const services = ServiceRepository.inspect();
|
|
30
|
+
ConsoleLogger.warn(services, `${services.length} did not dispose.`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}, 15_000);
|
|
33
|
+
return ServiceRepository.dispose()
|
|
34
|
+
.catch(logScriptError)
|
|
35
|
+
.finally(() => {
|
|
36
|
+
clearTimeout(timeout);
|
|
37
|
+
process.exit(exitCode);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Runs a script callback and handles cleanup.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export function runScript(scriptCallback) {
|
|
46
|
+
process.on("SIGINT", postScriptCleanup);
|
|
47
|
+
process.on("SIGTERM", postScriptCleanup);
|
|
48
|
+
return Promise.resolve()
|
|
49
|
+
.then(() => scriptCallback())
|
|
50
|
+
.catch(logScriptError)
|
|
51
|
+
.then(() => postScriptCleanup())
|
|
52
|
+
.catch(() => postScriptCleanup("SIGTERM", 1));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Given a module's import.meta object, resolves if the module was run as a NPM script.
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* runIfScript(import.meta, async () => {...})
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* This is useful for conditionally running scripts without too much boilerplate.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
export async function runIfScript(meta, scriptCallback) {
|
|
66
|
+
if (!esMain(meta))
|
|
67
|
+
return;
|
|
68
|
+
const { $public } = await import("@mailwoman/core/env");
|
|
69
|
+
ConsoleLogger.info(stringifyLoggedObject($public, {
|
|
70
|
+
description: "Public Environment",
|
|
71
|
+
showValues: true,
|
|
72
|
+
}));
|
|
73
|
+
return runScript(scriptCallback);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The ONE blessed accessor for CLI arguments. Everything outside `core/env` + this module is forbidden from touching
|
|
77
|
+
* `process.argv` directly (enforced by the `sister-software/no-process-globals` oxlint rule) — prefer `node:util`
|
|
78
|
+
* `parseArgs` (which reads this same slice by default) and reach for this only where `parseArgs` cannot express the
|
|
79
|
+
* grammar (e.g. negative-coordinate positionals).
|
|
80
|
+
*/
|
|
81
|
+
export function cliArguments() {
|
|
82
|
+
// oxlint-disable-next-line sister-software/no-process-globals
|
|
83
|
+
return process.argv.slice(2);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The ONE blessed way to build a child-process environment: the current environment with explicit overrides. Everything
|
|
87
|
+
* outside `core/env` + this module is forbidden from touching `process.env` directly (enforced by
|
|
88
|
+
* `scripts/lint-raw-env-argv.ts`) — read config through `$public`/`$private`.
|
|
89
|
+
*/
|
|
90
|
+
export function childEnv(overrides = {}) {
|
|
91
|
+
// oxlint-disable-next-line sister-software/no-process-globals
|
|
92
|
+
return { ...process.env, ...overrides };
|
|
93
|
+
}
|
|
94
|
+
/** The path of the executing script (`argv[1]`) — for commands that re-spawn or reference their own CLI entry. */
|
|
95
|
+
export function scriptEntryPath() {
|
|
96
|
+
// oxlint-disable-next-line sister-software/no-process-globals
|
|
97
|
+
return process.argv[1];
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=scripting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripting.js","sourceRoot":"","sources":["../../utils/scripting.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAE1E;;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;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAyB,SAAS,EAAE,QAAQ,GAAG,CAAC;IACjF,aAAa,CAAC,KAAK,CAAC,MAAM,MAAM,oBAAoB,CAAC,C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E,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAEvD,aAAa,CAAC,IAAI,CACjB,qBAAqB,CAAC,OAAO,EAAE;QAC9B,WAAW,EAAE,oBAAoB;QACjC,UAAU,EAAE,IAAI;KAChB,CAAC,CACF,CAAA;IAED,OAAO,SAAS,CAAC,cAAc,CAAC,CAAA;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY;IAC3B,8DAA8D;IAC9D,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,YAAgD,EAAE;IAC1E,8DAA8D;IAC9D,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,SAAS,EAAE,CAAA;AACxC,CAAC;AAED,kHAAkH;AAClH,MAAM,UAAU,eAAe;IAC9B,8DAA8D;IAC9D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAE,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DatabaseSync } from "node:sqlite";
|
|
2
|
+
/** A write-mode open was attempted on a sealed (0444) data artifact. */
|
|
3
|
+
export declare class SealedArtifactError extends Error {
|
|
4
|
+
constructor(path: string);
|
|
5
|
+
}
|
|
6
|
+
/** True when the artifact exists and carries no write bits (the sealed state {@link sealDatabase} leaves). */
|
|
7
|
+
export declare function isSealed(path: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Finalize a built DB: WAL-checkpoint → `journal_mode = DELETE` → remove `-wal`/`-shm` sidecars → `chmod 0o444`.
|
|
10
|
+
* Idempotent. Throws if the checkpoint cannot complete (another writer holds the DB).
|
|
11
|
+
*/
|
|
12
|
+
export declare function sealDatabase(path: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Open a data artifact. Read-only by default. `write: true` is for builders working on UNsealed staging — against a
|
|
15
|
+
* sealed artifact it throws {@link SealedArtifactError}.
|
|
16
|
+
*/
|
|
17
|
+
export declare function openBuiltDatabase(path: string, opts?: {
|
|
18
|
+
write?: boolean;
|
|
19
|
+
}): DatabaseSync;
|
|
20
|
+
//# sourceMappingURL=sealed-db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sealed-db.d.ts","sourceRoot":"","sources":["../../utils/sealed-db.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAY/C,wEAAwE;AACxE,qBAAa,mBAAoB,SAAQ,KAAK;gBACjC,IAAI,EAAE,MAAM;CAOxB;AAED,8GAA8G;AAC9G,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAyB/C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,YAAY,CAQ5F"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The sealed-artifact invariant: every SQLite DB a build produces is a READ-ONLY asset. `sealDatabase`
|
|
7
|
+
* is the last step of every builder — checkpoint, freeze the journal, chmod 0444. `openBuiltDatabase`
|
|
8
|
+
* is how anything opens a data artifact; a write-mode open of a sealed file throws a NAMED error
|
|
9
|
+
* pointing at the rebuild command instead of a cryptic SQLITE_READONLY. Unsealing is deliberate and
|
|
10
|
+
* manual (`chmod u+w`), never programmatic — rebuild, don't mutate.
|
|
11
|
+
*/
|
|
12
|
+
import { chmodSync, existsSync, statSync, unlinkSync } from "node:fs";
|
|
13
|
+
import { basename } from "node:path";
|
|
14
|
+
/**
|
|
15
|
+
* `node:sqlite` via {@link process.getBuiltinModule} — invisible to bundlers. A static import here would ride the
|
|
16
|
+
* `@mailwoman/core/utils` barrel into every consumer, and the docs' plugin loader (which transpiles `docusaurus.config`
|
|
17
|
+
* imports) can't resolve `node:sqlite` (CI: "Cannot find module 'sqlite'"). The builtin accessor keeps the functions
|
|
18
|
+
* synchronous with zero resolve surface.
|
|
19
|
+
*/
|
|
20
|
+
function sqlite() {
|
|
21
|
+
return process.getBuiltinModule("node:sqlite");
|
|
22
|
+
}
|
|
23
|
+
/** A write-mode open was attempted on a sealed (0444) data artifact. */
|
|
24
|
+
export class SealedArtifactError extends Error {
|
|
25
|
+
constructor(path) {
|
|
26
|
+
super(`${basename(path)} is a sealed read-only artifact — rebuild it via \`mailwoman gazetteer build …\`, ` +
|
|
27
|
+
`don't mutate it. (Deliberate unseal: chmod u+w — but prefer a rebuild.)`);
|
|
28
|
+
this.name = "SealedArtifactError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** True when the artifact exists and carries no write bits (the sealed state {@link sealDatabase} leaves). */
|
|
32
|
+
export function isSealed(path) {
|
|
33
|
+
return existsSync(path) && (statSync(path).mode & 0o222) === 0;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Finalize a built DB: WAL-checkpoint → `journal_mode = DELETE` → remove `-wal`/`-shm` sidecars → `chmod 0o444`.
|
|
37
|
+
* Idempotent. Throws if the checkpoint cannot complete (another writer holds the DB).
|
|
38
|
+
*/
|
|
39
|
+
export function sealDatabase(path) {
|
|
40
|
+
// A previously sealed artifact needs the write bit back for the journal-mode switch.
|
|
41
|
+
if (isSealed(path)) {
|
|
42
|
+
chmodSync(path, 0o644);
|
|
43
|
+
}
|
|
44
|
+
const db = new (sqlite().DatabaseSync)(path);
|
|
45
|
+
const checkpoint = db.prepare("PRAGMA wal_checkpoint(TRUNCATE)").get();
|
|
46
|
+
if (checkpoint.busy !== 0) {
|
|
47
|
+
db.close();
|
|
48
|
+
throw new Error(`sealDatabase: WAL checkpoint busy on ${path} — close all writers first`);
|
|
49
|
+
}
|
|
50
|
+
const mode = db.prepare("PRAGMA journal_mode = DELETE").get();
|
|
51
|
+
db.close();
|
|
52
|
+
if (mode.journal_mode !== "delete") {
|
|
53
|
+
throw new Error(`sealDatabase: journal_mode switch failed on ${path} (still ${mode.journal_mode})`);
|
|
54
|
+
}
|
|
55
|
+
for (const sidecar of [`${path}-wal`, `${path}-shm`]) {
|
|
56
|
+
if (existsSync(sidecar)) {
|
|
57
|
+
unlinkSync(sidecar);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
chmodSync(path, 0o444);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Open a data artifact. Read-only by default. `write: true` is for builders working on UNsealed staging — against a
|
|
64
|
+
* sealed artifact it throws {@link SealedArtifactError}.
|
|
65
|
+
*/
|
|
66
|
+
export function openBuiltDatabase(path, opts = {}) {
|
|
67
|
+
if (opts.write) {
|
|
68
|
+
if (isSealed(path))
|
|
69
|
+
throw new SealedArtifactError(path);
|
|
70
|
+
return new (sqlite().DatabaseSync)(path);
|
|
71
|
+
}
|
|
72
|
+
return new (sqlite().DatabaseSync)(path, { readOnly: true });
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=sealed-db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sealed-db.js","sourceRoot":"","sources":["../../utils/sealed-db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC;;;;;GAKG;AACH,SAAS,MAAM;IACd,OAAO,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAA;AAC/C,CAAC;AAED,wEAAwE;AACxE,MAAM,OAAO,mBAAoB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,MAAM,CAAC,EAAE,CAAC;QACtD,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,UAAU,CAAC,OAAO,CAAC,CAAA;QACpB,CAAC;IACF,CAAC;IACD,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAA4B,EAAE;IAC7E,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,QAAQ,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAA;QAEvD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;AAWH,wBA0BE"}
|
package/out/vitest.config.js
CHANGED
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
* preserves the trailing path segment.
|
|
12
12
|
*/
|
|
13
13
|
import { resolve } from "node:path";
|
|
14
|
-
import { fileURLToPath } from "node:url";
|
|
15
14
|
// `defineConfig` from "vitest/config" (not "vite"): vitest's overload carries the `test` field.
|
|
16
15
|
// vite 8 (pulled in by docs/ Storybook) no longer applies the `vitest/config` type augmentation to
|
|
17
16
|
// vite's own `defineConfig`, so importing from "vite" makes `test` a type error under vite 8.
|
|
18
17
|
import { defineConfig } from "vitest/config";
|
|
19
|
-
const here =
|
|
18
|
+
const here = import.meta.dirname;
|
|
20
19
|
export default defineConfig({
|
|
21
20
|
resolve: {
|
|
22
21
|
alias: [
|
package/out/vitest.config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,gGAAgG;AAChG,mGAAmG;AACnG,8FAA8F;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAA;AAEhC,eAAe,YAAY,CAAC;IAC3B,OAAO,EAAE;QACR,KAAK,EAAE;YACN,+CAA+C;YAC/C,EAAE,IAAI,EAAE,mCAAmC,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE;YACvF,EAAE,IAAI,EAAE,mCAAmC,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE;YACvF,mFAAmF;YACnF,EAAE,IAAI,EAAE,0BAA0B,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE;YAC/E,EAAE,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE;YACtE,sBAAsB;YACtB,EAAE,IAAI,EAAE,2BAA2B,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC,EAAE;YAC5F,EAAE,IAAI,EAAE,4BAA4B,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC,EAAE;YACzF,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAE;YACtF,qFAAqF;YACrF,mFAAmF;YACnF,EAAE,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,gCAAgC,CAAC,EAAE;YAC5F,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,uBAAuB,CAAC,EAAE;SAC5E;KACD;IACD,IAAI,EAAE;QACL,uFAAuF;QACvF,mFAAmF;QACnF,uDAAuD;QACvD,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,oBAAoB,EAAE,WAAW,EAAE,YAAY,CAAC;KAC1D;CACD,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Mailwoman core: tokenization, classification primitives, solver, formatter, resources, filters, solvers, utils.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
@@ -69,21 +69,24 @@
|
|
|
69
69
|
"change-case": "^5.4.4",
|
|
70
70
|
"d3-color": "^3.1.0",
|
|
71
71
|
"d3-scale-chromatic": "^3.1.0",
|
|
72
|
+
"es-main": "^1.4.0",
|
|
72
73
|
"fast-glob": "^3.3.3",
|
|
73
74
|
"http-status-codes": "^2.3.0",
|
|
74
75
|
"json-colorizer": "^3.0.1",
|
|
75
76
|
"kysely": "^0.29.2",
|
|
76
77
|
"lru-cache": "^10.4.3",
|
|
77
|
-
"path-ts": "^1.0
|
|
78
|
+
"path-ts": "^2.1.0",
|
|
78
79
|
"pino": "^10.3.1",
|
|
79
80
|
"pino-pretty": "^13.1.3",
|
|
80
81
|
"pluralize": "^8.0.0",
|
|
81
82
|
"regenerate": "^1.4.2",
|
|
82
|
-
"spliterator": "^3.
|
|
83
|
+
"spliterator": "^3.2.0",
|
|
83
84
|
"table": "^6.9.0",
|
|
84
85
|
"zod": "^4.4.3"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
88
|
+
"@duckdb/node-api": "1.5.3-r.3",
|
|
89
|
+
"@mailwoman/codex": "5.8.0",
|
|
87
90
|
"@types/d3-color": "^3.1.3",
|
|
88
91
|
"@types/d3-scale-chromatic": "^3.1.0"
|
|
89
92
|
}
|