dirsql 0.3.55 → 0.3.57
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/dist/cli/resolve-config-extensions.d.ts.map +1 -1
- package/dist/cli/resolve-config-extensions.js +11 -35
- package/dist/cli/resolve-config-extensions.js.map +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js.map +1 -1
- package/dist/dirsql.d.ts +3 -1
- package/dist/dirsql.d.ts.map +1 -1
- package/dist/dirsql.js +14 -1
- package/dist/dirsql.js.map +1 -1
- package/dist/resolve-config-extensions.d.ts +14 -0
- package/dist/resolve-config-extensions.d.ts.map +1 -0
- package/dist/resolve-config-extensions.js +59 -0
- package/dist/resolve-config-extensions.js.map +1 -0
- package/docs/api/index.md +1 -1
- package/docs/guide/querying.md +9 -9
- package/docs/guide/tables.md +12 -12
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config-extensions.d.ts","sourceRoot":"","sources":["../../src/cli/resolve-config-extensions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve-config-extensions.d.ts","sourceRoot":"","sources":["../../src/cli/resolve-config-extensions.ts"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAiB/D"}
|
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
// The compiled `dirsql` binary reads a `.dirsql.toml` itself and loads its
|
|
4
4
|
// extensions literally — it has no `require.resolve`, so it cannot resolve a
|
|
5
5
|
// bare **package name** (#227). This launcher can. When a TOML config names an
|
|
6
|
-
// extension by package name,
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
6
|
+
// extension by package name, the shared SDK resolver
|
|
7
|
+
// (`../resolve-config-extensions.ts`, #313) resolves every one of its
|
|
8
|
+
// extensions and this launcher passes the resolved literal paths to the binary
|
|
9
|
+
// via repeatable `--extension` flags; the binary then loads those and ignores
|
|
10
|
+
// the config's own extension entries (see the Rust `--extension` flag /
|
|
11
|
+
// `suppress_config_extensions`).
|
|
10
12
|
//
|
|
11
13
|
// Native-language configs (`.py`/`.js`/`.mjs`/`.cjs`) are untouched: the binary
|
|
12
14
|
// dispatches those to `dirsql interpret`, whose handshake already carries
|
|
13
|
-
// resolved paths
|
|
14
|
-
import {
|
|
15
|
-
import { dirname, resolve as resolvePath } from "node:path";
|
|
16
|
-
import { parse as parseToml } from "smol-toml";
|
|
17
|
-
import { isBareName, resolveExtensionPath } from "../resolve-extension.js";
|
|
15
|
+
// resolved paths.
|
|
16
|
+
import { resolveConfigExtensionSpecs } from "../resolve-config-extensions.js";
|
|
18
17
|
// Config extensions the binary dispatches to `dirsql interpret`; never
|
|
19
18
|
// pre-resolved here (that path resolves via the handshake).
|
|
20
19
|
const NATIVE_CONFIG_SUFFIXES = [".py", ".js", ".mjs", ".cjs"];
|
|
@@ -45,35 +44,12 @@ export function withResolvedExtensions(argv) {
|
|
|
45
44
|
if (NATIVE_CONFIG_SUFFIXES.some((s) => configPath.endsWith(s))) {
|
|
46
45
|
return argv;
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
const specs = resolveConfigExtensionSpecs(configPath);
|
|
48
|
+
if (specs === null) {
|
|
49
49
|
return argv;
|
|
50
50
|
}
|
|
51
|
-
let doc;
|
|
52
|
-
try {
|
|
53
|
-
doc = parseToml(readFileSync(configPath, "utf8"));
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
// Leave a malformed config for the binary to report.
|
|
57
|
-
return argv;
|
|
58
|
-
}
|
|
59
|
-
const dirsql = (doc.dirsql ?? {});
|
|
60
|
-
const entries = Array.isArray(dirsql.extension)
|
|
61
|
-
? dirsql.extension
|
|
62
|
-
: [];
|
|
63
|
-
if (entries.length === 0) {
|
|
64
|
-
return argv;
|
|
65
|
-
}
|
|
66
|
-
// Only intervene when at least one path is a bare package name; a config with
|
|
67
|
-
// only literal paths keeps the binary's existing behavior untouched.
|
|
68
|
-
const hasPackageName = entries.some((e) => typeof e.path === "string" && isBareName(e.path));
|
|
69
|
-
if (!hasPackageName) {
|
|
70
|
-
return argv;
|
|
71
|
-
}
|
|
72
|
-
const base = dirname(resolvePath(configPath));
|
|
73
51
|
const flags = [];
|
|
74
|
-
for (const
|
|
75
|
-
const path = resolveExtensionPath(e.path, base, true);
|
|
76
|
-
const entrypoint = typeof e.entrypoint === "string" ? e.entrypoint : null;
|
|
52
|
+
for (const { path, entrypoint } of specs) {
|
|
77
53
|
flags.push("--extension", entrypoint ? `${path}::${entrypoint}` : path);
|
|
78
54
|
}
|
|
79
55
|
return [...argv, ...flags];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config-extensions.js","sourceRoot":"","sources":["../../src/cli/resolve-config-extensions.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"resolve-config-extensions.js","sourceRoot":"","sources":["../../src/cli/resolve-config-extensions.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,EAAE;AACF,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,qDAAqD;AACrD,sEAAsE;AACtE,+EAA+E;AAC/E,8EAA8E;AAC9E,wEAAwE;AACxE,iCAAiC;AACjC,EAAE;AACF,gFAAgF;AAChF,0EAA0E;AAC1E,kBAAkB;AAElB,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAE9E,uEAAuE;AACvE,4DAA4D;AAC5D,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9D,qFAAqF;AACrF,SAAS,kBAAkB,CAAC,IAAc;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,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B,CAAC"}
|
package/dist/core.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface NativeDirSQL {
|
|
|
6
6
|
pollEvents(timeoutMs: number): Promise<RowEvent[]>;
|
|
7
7
|
}
|
|
8
8
|
export interface NativeDirSQLConstructor {
|
|
9
|
-
openAsync(root: string | null, tables: TableDef[] | null, ignore: string[] | null, config: string | null, persist: boolean | null, persistPath: string | null, extensions: ExtensionSpec[] | null): Promise<NativeDirSQL>;
|
|
9
|
+
openAsync(root: string | null, tables: TableDef[] | null, ignore: string[] | null, config: string | null, persist: boolean | null, persistPath: string | null, extensions: ExtensionSpec[] | null, suppressConfigExtensions: boolean | null): Promise<NativeDirSQL>;
|
|
10
10
|
}
|
|
11
11
|
export interface CoreModule {
|
|
12
12
|
DirSQL: NativeDirSQLConstructor;
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACvD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,CACP,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EACzB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,UAAU,EAAE,aAAa,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACvD,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,CACP,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EACzB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,UAAU,EAAE,aAAa,EAAE,GAAG,IAAI,EAGlC,wBAAwB,EAAE,OAAO,GAAG,IAAI,GACvC,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1B;AAID,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,uBAAuB,CAAC;IAChC,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5C;AAQD,wBAAgB,OAAO,IAAI,UAAU,CAKpC"}
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iEAAiE;AACjE,EAAE;AACF,wEAAwE;AACxE,4CAA4C;AAG5C,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iEAAiE;AACjE,EAAE;AACF,wEAAwE;AACxE,4CAA4C;AAG5C,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAgChF,yEAAyE;AACzE,qEAAqE;AACrE,2EAA2E;AAC3E,+BAA+B;AAC/B,IAAI,IAAI,GAAsB,IAAI,CAAC;AAEnC,MAAM,UAAU,OAAO;IACrB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,IAAI,GAAG,qBAAqB,EAAgB,CAAC;IAC/C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/dirsql.d.ts
CHANGED
|
@@ -56,7 +56,9 @@ export interface DirSQLOptions {
|
|
|
56
56
|
* SQLite extensions to load onto the connection at startup, before any
|
|
57
57
|
* table DDL (enable → load → disable, so the SQL `load_extension()`
|
|
58
58
|
* function is never left exposed). Programmatic entries load first, then
|
|
59
|
-
* any `[[dirsql.extension]]` declared in `config`.
|
|
59
|
+
* any `[[dirsql.extension]]` declared in `config`. A `path` (programmatic
|
|
60
|
+
* or config-file) may be a bare **package name**, resolved from the
|
|
61
|
+
* installed package under `node_modules` (#299 / #313).
|
|
60
62
|
*/
|
|
61
63
|
extensions?: ExtensionSpec[];
|
|
62
64
|
}
|
package/dist/dirsql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dirsql.d.ts","sourceRoot":"","sources":["../src/dirsql.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dirsql.d.ts","sourceRoot":"","sources":["../src/dirsql.ts"],"names":[],"mappings":"AAUA,OAAO,K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AAQ,EAAE,aAAa,CAAC;IAEjC,wDAAwD;gBAC5C,UAAU,EAAE,MAAM;IAC9B,yCAAyC;gBAC7B,OAAO,EAAE,aAAa;IA+ClC;;;;;;OAMG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAK5D;;;;;;;OAOG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnC;;;;;;;OAOG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAKxD;;;;;;;;;;OAUG;IACI,KAAK,IAAI,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC;CAaxD"}
|
package/dist/dirsql.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// unit test instead of an exemption (#239). The native binding is reached
|
|
5
5
|
// through `getCore()` (see `core.ts`), which tests fake.
|
|
6
6
|
import { getCore } from "./core.js";
|
|
7
|
+
import { resolveConfigExtensionSpecs } from "./resolve-config-extensions.js";
|
|
7
8
|
import { resolveExtensionPath } from "./resolve-extension.js";
|
|
8
9
|
/**
|
|
9
10
|
* Ephemeral SQL index over a local directory.
|
|
@@ -62,7 +63,19 @@ export class DirSQL {
|
|
|
62
63
|
path: resolveExtensionPath(e.path, process.cwd(), false),
|
|
63
64
|
entrypoint: e.entrypoint,
|
|
64
65
|
})) ?? null;
|
|
65
|
-
|
|
66
|
+
// When the config file names an extension by bare package name, the
|
|
67
|
+
// SDK resolves every one of the config's [[dirsql.extension]] entries
|
|
68
|
+
// itself (#313) -- appended after the programmatic ones, matching the
|
|
69
|
+
// core's ordering -- and suppresses the core's own config-extension
|
|
70
|
+
// loading so the entries are not loaded a second time (and the core
|
|
71
|
+
// never sees the unresolvable bare name).
|
|
72
|
+
const configExtensions = options.config != null
|
|
73
|
+
? resolveConfigExtensionSpecs(options.config)
|
|
74
|
+
: null;
|
|
75
|
+
const merged = configExtensions !== null
|
|
76
|
+
? [...(extensions ?? []), ...configExtensions]
|
|
77
|
+
: extensions;
|
|
78
|
+
return Ctor.openAsync(options.root ?? null, options.tables ?? null, options.ignore ?? null, options.config ?? null, options.persist ?? null, options.persistPath ?? null, merged, configExtensions !== null);
|
|
66
79
|
})
|
|
67
80
|
.then((inner) => {
|
|
68
81
|
this._inner = inner;
|
package/dist/dirsql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dirsql.js","sourceRoot":"","sources":["../src/dirsql.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,yDAAyD;AAGzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"dirsql.js","sourceRoot":"","sources":["../src/dirsql.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,yDAAyD;AAGzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmF9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,MAAM;IACjB;;;;;;OAMG;IACM,KAAK,CAAgB;IAE9B,gEAAgE;IACxD,MAAM,CAAgB;IAC9B,2EAA2E;IAC3E,6BAA6B;IACpB,QAAQ,CAAgB;IAMjC,YAAY,GAA2B;QACrC,MAAM,OAAO,GACX,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC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AI,CAAC,MAAM,GAAG,KAAK,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,GAAW;QACrB,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,UAAU,CAAC,SAAiB;QAChC,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,CAAC,KAAK;QACV,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACjC,OAAO,IAAI,EAAE,CAAC;YACZ,qEAAqE;YACrE,gEAAgE;YAChE,sEAAsE;YACtE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACjD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ExtensionSpec } from "./dirsql.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a TOML config's `[[dirsql.extension]]` entries to literal paths.
|
|
4
|
+
*
|
|
5
|
+
* Returns the resolved specs — every entry resolved via
|
|
6
|
+
* `resolveExtensionPath` against the config file's parent directory — when at
|
|
7
|
+
* least one entry's `path` is a bare package name. Returns `null` when the
|
|
8
|
+
* caller should not intervene: the config is missing, malformed, declares no
|
|
9
|
+
* extensions, or uses only literal paths — leaving the core's own loading
|
|
10
|
+
* (and error reporting) untouched. Throws if a package name cannot be
|
|
11
|
+
* resolved.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveConfigExtensionSpecs(configPath: string): ExtensionSpec[] | null;
|
|
14
|
+
//# sourceMappingURL=resolve-config-extensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-config-extensions.d.ts","sourceRoot":"","sources":["../src/resolve-config-extensions.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,GACjB,aAAa,EAAE,GAAG,IAAI,CA+BxB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SDK-side resolution of a TOML config's `[[dirsql.extension]]` entries.
|
|
2
|
+
//
|
|
3
|
+
// The Rust core parses a `.dirsql.toml` itself and loads its extensions
|
|
4
|
+
// literally — it has no `require.resolve`, so it cannot resolve a bare
|
|
5
|
+
// **package name** (#227). The SDK can (#313). When a TOML config names an
|
|
6
|
+
// extension by package name, the SDK resolves every one of its extensions
|
|
7
|
+
// here, hands the core the resolved literal paths, and suppresses the core's
|
|
8
|
+
// own config-extension loading (the Rust `suppress_config_extensions` builder
|
|
9
|
+
// toggle) so the config's entries are not loaded a second time.
|
|
10
|
+
//
|
|
11
|
+
// Shared by the `DirSQL` constructor (`config` option) and the CLI launcher
|
|
12
|
+
// (`cli/resolve-config-extensions.ts`, which converts the resolved specs into
|
|
13
|
+
// `--extension` flags for the binary).
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
+
import { dirname, resolve as resolvePath } from "node:path";
|
|
16
|
+
import { parse as parseToml } from "smol-toml";
|
|
17
|
+
import { isBareName, resolveExtensionPath } from "./resolve-extension.js";
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a TOML config's `[[dirsql.extension]]` entries to literal paths.
|
|
20
|
+
*
|
|
21
|
+
* Returns the resolved specs — every entry resolved via
|
|
22
|
+
* `resolveExtensionPath` against the config file's parent directory — when at
|
|
23
|
+
* least one entry's `path` is a bare package name. Returns `null` when the
|
|
24
|
+
* caller should not intervene: the config is missing, malformed, declares no
|
|
25
|
+
* extensions, or uses only literal paths — leaving the core's own loading
|
|
26
|
+
* (and error reporting) untouched. Throws if a package name cannot be
|
|
27
|
+
* resolved.
|
|
28
|
+
*/
|
|
29
|
+
export function resolveConfigExtensionSpecs(configPath) {
|
|
30
|
+
if (!existsSync(configPath)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
let doc;
|
|
34
|
+
try {
|
|
35
|
+
doc = parseToml(readFileSync(configPath, "utf8"));
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Leave a malformed config for the core to report.
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const dirsql = (doc.dirsql ?? {});
|
|
42
|
+
if (!Array.isArray(dirsql.extension)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const entries = dirsql.extension;
|
|
46
|
+
// Only intervene when at least one path is a bare package name; a config
|
|
47
|
+
// with only literal paths (or no entries at all) keeps the core's existing
|
|
48
|
+
// behavior untouched.
|
|
49
|
+
const hasPackageName = entries.some((e) => typeof e.path === "string" && isBareName(e.path));
|
|
50
|
+
if (!hasPackageName) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const base = dirname(resolvePath(configPath));
|
|
54
|
+
return entries.map((e) => ({
|
|
55
|
+
path: resolveExtensionPath(e.path, base, true),
|
|
56
|
+
entrypoint: typeof e.entrypoint === "string" ? e.entrypoint : undefined,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=resolve-config-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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AO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CACxD,CAAC;IACF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzB,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAc,EAAE,IAAI,EAAE,IAAI,CAAC;QACxD,UAAU,EAAE,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;KACxE,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/docs/api/index.md
CHANGED
|
@@ -77,7 +77,7 @@ In Python, the constructor starts scanning in a background thread and returns im
|
|
|
77
77
|
- `tables` -- List of `Table` definitions. Each defines a SQLite table, a glob pattern, and an extract function.
|
|
78
78
|
- `ignore` -- Optional list of glob patterns. Files matching any ignore pattern are skipped regardless of table globs.
|
|
79
79
|
- `config` -- Optional path to a `.dirsql.toml` config file. Its `[[table]]` entries are appended to any programmatic `tables`; its `[dirsql].ignore` patterns are appended to any explicit `ignore`; its optional `[dirsql].root` supplies the root directory when `root` is not passed explicitly; its `[[dirsql.extension]]` entries are appended to any programmatic `extensions`.
|
|
80
|
-
- `extensions` -- Optional SQLite extensions to load onto the connection at startup, before any table DDL (enable → load → disable, so the SQL `load_extension()` function is never left exposed). Each entry pairs a shared-library `path` with an optional `entrypoint` init-symbol override (Python: `{ "path", "entrypoint"? }` dicts; Rust: `Extension { path, entrypoint }`; TypeScript: `{ path, entrypoint? }` objects). A `path` is either a file path or a bare **package name**; a package name is resolved from the installed package (Python `importlib` / TypeScript `node_modules`, file-first, erroring on zero or multiple matches). This works on the Python/TypeScript constructor and CLI; the Rust binary and SDK are file-path-only. Programmatic entries load first, then any `[[dirsql.extension]]` from `config`. See [Loading extensions](../cli/config.md#loading-extensions).
|
|
80
|
+
- `extensions` -- Optional SQLite extensions to load onto the connection at startup, before any table DDL (enable → load → disable, so the SQL `load_extension()` function is never left exposed). Each entry pairs a shared-library `path` with an optional `entrypoint` init-symbol override (Python: `{ "path", "entrypoint"? }` dicts; Rust: `Extension { path, entrypoint }`; TypeScript: `{ path, entrypoint? }` objects). A `path` is either a file path or a bare **package name**; a package name is resolved from the installed package (Python `importlib` / TypeScript `node_modules`, file-first, erroring on zero or multiple matches). This works on the Python/TypeScript constructor — for both the programmatic `extensions` list and a `config` file's `[[dirsql.extension]]` entries — and on the CLI; the Rust binary and SDK are file-path-only. Programmatic entries load first, then any `[[dirsql.extension]]` from `config`. See [Loading extensions](../cli/config.md#loading-extensions).
|
|
81
81
|
|
|
82
82
|
### Methods
|
|
83
83
|
|
package/docs/guide/querying.md
CHANGED
|
@@ -103,15 +103,15 @@ const results = await db.query('SELECT title, author FROM posts');
|
|
|
103
103
|
|
|
104
104
|
:::
|
|
105
105
|
|
|
106
|
-
SQLite types map back to
|
|
107
|
-
|
|
108
|
-
| SQLite type | Python
|
|
109
|
-
|
|
110
|
-
| TEXT | `str`
|
|
111
|
-
| INTEGER | `int`
|
|
112
|
-
| REAL | `float`
|
|
113
|
-
| BLOB | `bytes`
|
|
114
|
-
| NULL | `None`
|
|
106
|
+
SQLite types map back to language types:
|
|
107
|
+
|
|
108
|
+
| SQLite type | Python | TypeScript | Rust |
|
|
109
|
+
|-------------|---------|------------|------------------|
|
|
110
|
+
| TEXT | `str` | `string` | `Value::Text` |
|
|
111
|
+
| INTEGER | `int` | `number` | `Value::Integer` |
|
|
112
|
+
| REAL | `float` | `number` | `Value::Real` |
|
|
113
|
+
| BLOB | `bytes` | `Buffer` | `Value::Blob` |
|
|
114
|
+
| NULL | `None` | `null` | `Value::Null` |
|
|
115
115
|
|
|
116
116
|
## Internal columns
|
|
117
117
|
|
package/docs/guide/tables.md
CHANGED
|
@@ -255,15 +255,15 @@ Ignore patterns are applied before glob matching. Any file matching an ignore pa
|
|
|
255
255
|
|
|
256
256
|
## Supported value types
|
|
257
257
|
|
|
258
|
-
The extract function can return these
|
|
259
|
-
|
|
260
|
-
|
|
|
261
|
-
|
|
262
|
-
| `str`
|
|
263
|
-
| `int` |
|
|
264
|
-
| `float` |
|
|
265
|
-
|
|
|
266
|
-
| `bytes`
|
|
267
|
-
| `None`
|
|
268
|
-
|
|
269
|
-
Any other type is converted to its string representation
|
|
258
|
+
The extract function can return these types, which map to SQLite types:
|
|
259
|
+
|
|
260
|
+
| SQLite type | Python | TypeScript | Rust |
|
|
261
|
+
|---------------|---------|-------------------------|------------------|
|
|
262
|
+
| TEXT | `str` | `string` | `Value::Text` |
|
|
263
|
+
| INTEGER | `int` | integral `number` | `Value::Integer` |
|
|
264
|
+
| REAL | `float` | fractional `number` | `Value::Real` |
|
|
265
|
+
| INTEGER (0/1) | `bool` | `boolean` | `Value::Integer` |
|
|
266
|
+
| BLOB | `bytes` | `Buffer` / `Uint8Array` | `Value::Blob` |
|
|
267
|
+
| NULL | `None` | `null` / `undefined` | `Value::Null` |
|
|
268
|
+
|
|
269
|
+
Any other type is converted to its string representation (`str()` in Python, string coercion in TypeScript).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirsql",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.57",
|
|
4
4
|
"description": "Ephemeral SQL index over a local directory",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/thekevinscott/dirsql",
|
|
@@ -219,15 +219,15 @@
|
|
|
219
219
|
]
|
|
220
220
|
},
|
|
221
221
|
"optionalDependencies": {
|
|
222
|
-
"@dirsql/lib-linux-x64-gnu": "0.3.
|
|
223
|
-
"@dirsql/lib-linux-arm64-gnu": "0.3.
|
|
224
|
-
"@dirsql/lib-darwin-x64": "0.3.
|
|
225
|
-
"@dirsql/lib-darwin-arm64": "0.3.
|
|
226
|
-
"@dirsql/lib-win32-x64-msvc": "0.3.
|
|
227
|
-
"@dirsql/cli-linux-x64-gnu": "0.3.
|
|
228
|
-
"@dirsql/cli-linux-arm64-gnu": "0.3.
|
|
229
|
-
"@dirsql/cli-darwin-x64": "0.3.
|
|
230
|
-
"@dirsql/cli-darwin-arm64": "0.3.
|
|
231
|
-
"@dirsql/cli-win32-x64-msvc": "0.3.
|
|
222
|
+
"@dirsql/lib-linux-x64-gnu": "0.3.57",
|
|
223
|
+
"@dirsql/lib-linux-arm64-gnu": "0.3.57",
|
|
224
|
+
"@dirsql/lib-darwin-x64": "0.3.57",
|
|
225
|
+
"@dirsql/lib-darwin-arm64": "0.3.57",
|
|
226
|
+
"@dirsql/lib-win32-x64-msvc": "0.3.57",
|
|
227
|
+
"@dirsql/cli-linux-x64-gnu": "0.3.57",
|
|
228
|
+
"@dirsql/cli-linux-arm64-gnu": "0.3.57",
|
|
229
|
+
"@dirsql/cli-darwin-x64": "0.3.57",
|
|
230
|
+
"@dirsql/cli-darwin-arm64": "0.3.57",
|
|
231
|
+
"@dirsql/cli-win32-x64-msvc": "0.3.57"
|
|
232
232
|
}
|
|
233
233
|
}
|