@procedures/sqlite 0.3.0 → 0.5.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 (52) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +93 -32
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/engines.d.ts +68 -0
  5. package/dist/engines.d.ts.map +1 -0
  6. package/dist/engines.js +268 -0
  7. package/dist/engines.js.map +1 -0
  8. package/dist/index.d.ts +3 -3
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +4 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/module.d.ts +13 -3
  13. package/dist/module.d.ts.map +1 -1
  14. package/dist/module.js +60 -27
  15. package/dist/module.js.map +1 -1
  16. package/dist/procedures/db/backup.d.ts +1 -1
  17. package/dist/procedures/db/backup.js +6 -6
  18. package/dist/procedures/db/backup.js.map +1 -1
  19. package/dist/procedures/db/migrate.d.ts +1 -1
  20. package/dist/procedures/db/migrate.js +8 -8
  21. package/dist/procedures/db/migrate.js.map +1 -1
  22. package/dist/procedures/db/schema.d.ts +1 -1
  23. package/dist/procedures/db/schema.js +3 -3
  24. package/dist/procedures/db/schema.js.map +1 -1
  25. package/dist/procedures/db/shared.d.ts +1 -1
  26. package/dist/procedures/db/shared.js +1 -1
  27. package/dist/procedures/db/tables.d.ts +1 -1
  28. package/dist/procedures/db/tables.js +2 -2
  29. package/dist/procedures/db/tables.js.map +1 -1
  30. package/dist/procedures/db/transaction.d.ts +1 -1
  31. package/dist/procedures/db/transaction.js +2 -2
  32. package/dist/procedures/db/transaction.js.map +1 -1
  33. package/dist/storage.d.ts +57 -16
  34. package/dist/storage.d.ts.map +1 -1
  35. package/dist/storage.js +255 -148
  36. package/dist/storage.js.map +1 -1
  37. package/dist/types.d.ts +1 -1
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js +2 -2
  40. package/dist/types.js.map +1 -1
  41. package/package.json +6 -5
  42. package/src/engines.ts +360 -0
  43. package/src/index.ts +12 -4
  44. package/src/module.ts +65 -28
  45. package/src/procedures/db/backup.ts +6 -6
  46. package/src/procedures/db/migrate.ts +8 -8
  47. package/src/procedures/db/schema.ts +3 -3
  48. package/src/procedures/db/shared.ts +1 -1
  49. package/src/procedures/db/tables.ts +2 -2
  50. package/src/procedures/db/transaction.ts +2 -2
  51. package/src/storage.ts +335 -176
  52. package/src/types.ts +4 -4
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The two SQLite engines of `SqliteStorage`: `node:sqlite` and sql.js.
3
+ *
4
+ * - The engine `node` is the module `node:sqlite` of Node.js. It writes only the changed pages of
5
+ * the file, and SQLite locks the file for each write.
6
+ * - The engine `sqljs` is sql.js (SQLite in WebAssembly), through `@mark1russell7/docker-sqlite`.
7
+ * It keeps the database in memory and writes the whole file after a write.
8
+ * - The two engines read and write the same file format.
9
+ *
10
+ * This module imports `node:sqlite` only when a storage opens: an import of the package does not
11
+ * load it.
12
+ */
13
+ /** The path of a database that is only in memory. */
14
+ export declare const MEMORY_PATH = ":memory:";
15
+ /** The engine of a database: `node:sqlite` (`node`) or sql.js (`sqljs`). */
16
+ export type SqliteEngineName = "node" | "sqljs";
17
+ /**
18
+ * The engine choice of a `SqliteStorage`. With `auto`, the storage uses `node` when Node.js has
19
+ * `node:sqlite`, and `sqljs` when it does not.
20
+ */
21
+ export type SqliteEngine = "auto" | SqliteEngineName;
22
+ /** This function gives the engine choice when it is known. Else it throws a `TypeError`. */
23
+ export declare function checkEngine(engine: unknown): SqliteEngine;
24
+ /** A value that a statement takes or gives. */
25
+ export type SqlValue = string | number | null;
26
+ /** The calls of an open database that a storage uses. Each call is synchronous. */
27
+ export interface EngineDatabase {
28
+ /** The rows of a query, as objects. */
29
+ all<R>(sql: string, params?: SqlValue[]): R[];
30
+ /** The first row of a statement for each list of parameters, or undefined for no row. */
31
+ firstOfEach<R>(sql: string, params: SqlValue[][]): Array<R | undefined>;
32
+ /** This method runs one statement, and gives the number of rows that it changed. */
33
+ run(sql: string, params?: SqlValue[]): number;
34
+ /** This method runs SQL text that can have several statements. */
35
+ exec(sql: string): void;
36
+ close(): void;
37
+ }
38
+ /**
39
+ * This function gives true when this Node.js has `node:sqlite` without a flag (Node.js 22.13 or
40
+ * later). Then the engine `auto` uses it.
41
+ */
42
+ export declare function isNodeSqliteAvailable(): Promise<boolean>;
43
+ /**
44
+ * This function copies the schema of the storages from one database to another. The node engine
45
+ * calls it when it makes the file at the first write.
46
+ */
47
+ export type CopySchema = (from: EngineDatabase, to: EngineDatabase) => void;
48
+ /** An open database of a path, with the file work of its engine. */
49
+ export interface OpenDatabase {
50
+ readonly engine: SqliteEngineName;
51
+ /** The current database. The node engine changes it when it opens the file. */
52
+ readonly db: EngineDatabase;
53
+ /**
54
+ * True when the node engine waits for the first write to make the file. Until then, the
55
+ * database is in memory, and it has the tables and no item.
56
+ */
57
+ readonly waiting: boolean;
58
+ /** This method opens the file and copies the schema to it. The node engine uses it before the first write. */
59
+ makeFile(copy: CopySchema): void;
60
+ /** This method opens a file that another process made after the open, before a read. */
61
+ refresh(copy: CopySchema): void;
62
+ /** This method writes the database to the file. Only sql.js has a write to do. */
63
+ saveFile(): Promise<void>;
64
+ close(): void;
65
+ }
66
+ /** This function opens the database of a path with an engine. `auto` uses `node` when it can. */
67
+ export declare function openEngine(path: string, engine: SqliteEngine, busyTimeoutMs: number): Promise<OpenDatabase>;
68
+ //# sourceMappingURL=engines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,qDAAqD;AACrD,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,gBAAgB,CAAC;AAIrD,4FAA4F;AAC5F,w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CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf;AAyGD,iGAAiG;AACjG,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CASjH"}
@@ -0,0 +1,268 @@
1
+ /**
2
+ * The two SQLite engines of `SqliteStorage`: `node:sqlite` and sql.js.
3
+ *
4
+ * - The engine `node` is the module `node:sqlite` of Node.js. It writes only the changed pages of
5
+ * the file, and SQLite locks the file for each write.
6
+ * - The engine `sqljs` is sql.js (SQLite in WebAssembly), through `@mark1russell7/docker-sqlite`.
7
+ * It keeps the database in memory and writes the whole file after a write.
8
+ * - The two engines read and write the same file format.
9
+ *
10
+ * This module imports `node:sqlite` only when a storage opens: an import of the package does not
11
+ * load it.
12
+ */
13
+ import { existsSync, mkdirSync, statSync } from "node:fs";
14
+ import { dirname } from "node:path";
15
+ import { createConnection } from "@mark1russell7/docker-sqlite";
16
+ /** The path of a database that is only in memory. */
17
+ export const MEMORY_PATH = ":memory:";
18
+ const ENGINES = new Set(["auto", "node", "sqljs"]);
19
+ /** This function gives the engine choice when it is known. Else it throws a `TypeError`. */
20
+ export function checkEngine(engine) {
21
+ if (typeof engine !== "string" || !ENGINES.has(engine)) {
22
+ throw new TypeError(`Unknown SQLite engine ${JSON.stringify(engine)}: use auto, node or sqljs`);
23
+ }
24
+ return engine;
25
+ }
26
+ let nodeModule;
27
+ /**
28
+ * This function loads `node:sqlite` one time. The promise gives undefined when the import fails,
29
+ * or when the module has no database class. Node.js before 22.13 has the module only with the
30
+ * flag `--experimental-sqlite`.
31
+ */
32
+ function loadNodeSqlite() {
33
+ nodeModule ??= import("node:sqlite")
34
+ .then((module) => {
35
+ const exports = module;
36
+ const found = "Database" in exports ? exports.Database : exports.DatabaseSync;
37
+ return typeof found === "function" ? found : undefined;
38
+ })
39
+ .catch(() => undefined);
40
+ return nodeModule;
41
+ }
42
+ /**
43
+ * This function gives true when this Node.js has `node:sqlite` without a flag (Node.js 22.13 or
44
+ * later). Then the engine `auto` uses it.
45
+ */
46
+ export async function isNodeSqliteAvailable() {
47
+ return (await loadNodeSqlite()) !== undefined;
48
+ }
49
+ /** A database of `node:sqlite`. It keeps the prepared statements of the storage. */
50
+ class NodeDatabase {
51
+ handle;
52
+ statements = new Map();
53
+ constructor(handle) {
54
+ this.handle = handle;
55
+ }
56
+ all(sql, params = []) {
57
+ return this.statement(sql).all(...params);
58
+ }
59
+ firstOfEach(sql, params) {
60
+ const statement = this.statement(sql);
61
+ return params.map((list) => statement.get(...list));
62
+ }
63
+ run(sql, params = []) {
64
+ return Number(this.statement(sql).run(...params).changes);
65
+ }
66
+ exec(sql) {
67
+ this.handle.exec(sql);
68
+ }
69
+ close() {
70
+ this.statements.clear();
71
+ this.handle.close();
72
+ }
73
+ statement(sql) {
74
+ let statement = this.statements.get(sql);
75
+ if (!statement) {
76
+ statement = this.handle.prepare(sql);
77
+ this.statements.set(sql, statement);
78
+ }
79
+ return statement;
80
+ }
81
+ }
82
+ /** The error code of SQLite for a write to a read-only database. */
83
+ const SQLITE_READONLY = 8;
84
+ /**
85
+ * This function opens a database file with `node:sqlite`, and makes the file when it is missing.
86
+ * The file gets WAL mode, so a read in another process does not wait for a write. The busy
87
+ * timeout makes a write wait for the lock of another process.
88
+ */
89
+ function openNodeFile(Database, path, busyTimeoutMs) {
90
+ const handle = new Database(path);
91
+ try {
92
+ handle.exec(`PRAGMA busy_timeout = ${Math.max(0, Math.floor(busyTimeoutMs))}`);
93
+ try {
94
+ handle.prepare("PRAGMA journal_mode = WAL").get();
95
+ }
96
+ catch (error) {
97
+ // A read-only file keeps its journal mode: the reads work, and a write gives the error. An
98
+ // error of an older Node.js can have no `errcode`: then its message tells it.
99
+ const { errcode, message } = error;
100
+ if (errcode !== SQLITE_READONLY && !/readonly database/i.test(String(message)))
101
+ throw error;
102
+ }
103
+ // In WAL mode, NORMAL keeps the file consistent after a crash, with fewer disk syncs
104
+ handle.exec("PRAGMA synchronous = NORMAL");
105
+ }
106
+ catch (error) {
107
+ handle.close();
108
+ throw error;
109
+ }
110
+ return new NodeDatabase(handle);
111
+ }
112
+ // ---------------------------------------------------------------------------
113
+ // sql.js
114
+ // ---------------------------------------------------------------------------
115
+ /** A database of sql.js. */
116
+ class SqlJsDatabase {
117
+ raw;
118
+ constructor(raw) {
119
+ this.raw = raw;
120
+ }
121
+ all(sql, params = []) {
122
+ const statement = this.raw.prepare(sql);
123
+ try {
124
+ statement.bind(params);
125
+ const out = [];
126
+ while (statement.step())
127
+ out.push(statement.getAsObject());
128
+ return out;
129
+ }
130
+ finally {
131
+ statement.free();
132
+ }
133
+ }
134
+ firstOfEach(sql, params) {
135
+ const statement = this.raw.prepare(sql);
136
+ try {
137
+ return params.map((list) => {
138
+ statement.bind(list);
139
+ const row = statement.step() ? statement.getAsObject() : undefined;
140
+ statement.reset();
141
+ return row;
142
+ });
143
+ }
144
+ finally {
145
+ statement.free();
146
+ }
147
+ }
148
+ run(sql, params = []) {
149
+ this.raw.run(sql, params);
150
+ return this.raw.getRowsModified();
151
+ }
152
+ exec(sql) {
153
+ this.raw.exec(sql);
154
+ }
155
+ close() {
156
+ this.raw.close();
157
+ }
158
+ }
159
+ /**
160
+ * A database of `node:sqlite`. A missing file stays missing until the first write that changes
161
+ * an item: until then, the database is in memory.
162
+ */
163
+ class NodeOpenDatabase {
164
+ Database;
165
+ path;
166
+ busyTimeoutMs;
167
+ engine = "node";
168
+ db;
169
+ waiting;
170
+ constructor(Database, path, busyTimeoutMs) {
171
+ this.Database = Database;
172
+ this.path = path;
173
+ this.busyTimeoutMs = busyTimeoutMs;
174
+ if (path === MEMORY_PATH) {
175
+ this.db = new NodeDatabase(new Database(MEMORY_PATH));
176
+ this.waiting = false;
177
+ }
178
+ else if (existsSync(path)) {
179
+ this.db = openNodeFile(Database, path, busyTimeoutMs);
180
+ this.waiting = false;
181
+ }
182
+ else {
183
+ this.db = new NodeDatabase(new Database(MEMORY_PATH));
184
+ this.waiting = true;
185
+ }
186
+ }
187
+ makeFile(copy) {
188
+ if (!this.waiting)
189
+ return;
190
+ mkdirSync(dirname(this.path), { recursive: true });
191
+ const file = openNodeFile(this.Database, this.path, this.busyTimeoutMs);
192
+ try {
193
+ copy(this.db, file);
194
+ }
195
+ catch (error) {
196
+ file.close();
197
+ throw error;
198
+ }
199
+ this.db.close();
200
+ this.db = file;
201
+ this.waiting = false;
202
+ }
203
+ refresh(copy) {
204
+ if (this.waiting && existsSync(this.path))
205
+ this.makeFile(copy);
206
+ }
207
+ saveFile() {
208
+ return Promise.resolve();
209
+ }
210
+ close() {
211
+ this.db.close();
212
+ }
213
+ }
214
+ /** A database of sql.js: the database is in memory, and `saveFile()` writes the whole file. */
215
+ class SqlJsOpenDatabase {
216
+ db;
217
+ save;
218
+ engine = "sqljs";
219
+ waiting = false;
220
+ constructor(db, save) {
221
+ this.db = db;
222
+ this.save = save;
223
+ }
224
+ makeFile() { }
225
+ refresh() { }
226
+ saveFile() {
227
+ return this.save();
228
+ }
229
+ close() {
230
+ this.db.close();
231
+ }
232
+ }
233
+ /**
234
+ * sql.js reads only the main file. A write-ahead log of the node engine (`<file>-wal`) can hold
235
+ * changes that are not in the main file yet. A whole-file write of sql.js does not agree with the
236
+ * log. Thus sql.js refuses such a file.
237
+ */
238
+ function checkNoWriteAheadLog(path) {
239
+ let size = 0;
240
+ try {
241
+ size = statSync(`${path}-wal`).size;
242
+ }
243
+ catch {
244
+ return;
245
+ }
246
+ if (size > 0) {
247
+ throw new Error(`The file ${path} has a write-ahead log (${path}-wal) of the engine node: open it with the engine node, or close the process that uses it`);
248
+ }
249
+ }
250
+ /** The error of the engine `node` when this Node.js has no `node:sqlite`. */
251
+ function noNodeSqlite() {
252
+ return new Error(`The SQLite engine node needs node:sqlite, and this Node.js (${process.version}) does not have it without a flag: use Node.js 22.13 or later, or the engine sqljs or auto`);
253
+ }
254
+ /** This function opens the database of a path with an engine. `auto` uses `node` when it can. */
255
+ export async function openEngine(path, engine, busyTimeoutMs) {
256
+ if (engine !== "sqljs") {
257
+ const Database = await loadNodeSqlite();
258
+ if (Database)
259
+ return new NodeOpenDatabase(Database, path, busyTimeoutMs);
260
+ if (engine === "node")
261
+ throw noNodeSqlite();
262
+ }
263
+ if (path !== MEMORY_PATH)
264
+ checkNoWriteAheadLog(path);
265
+ const { db, save } = await createConnection({ dbPath: path });
266
+ return new SqlJsOpenDatabase(new SqlJsDatabase(db), save);
267
+ }
268
+ //# sourceMappingURL=engines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.js","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAiB,MAAM,8BAA8B,CAAC;AAE/E,qDAAqD;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AAWtC,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEtF,4FAA4F;AAC5F,MAAM,UAAU,WAAW,CAAC,MAAe;IACzC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,SAAS,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,MAAsB,CAAC;AAChC,CAAC;AAuCD,IAAI,UAA8D,CAAC;AAEnE;;;;GAIG;AACH,SAAS,cAAc;IACrB,UAAU,KAAK,MAAM,CAAC,aAAa,CAAC;SACjC,IAAI,CAAC,CAAC,MAAe,EAAE,EAA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a query
14
- * const result = await client.call(["db", "query"], {
13
+ * // Execute a query (sqlite.query: the old name db.query is a deprecated alias)
14
+ * const result = await client.call(["sqlite", "query"], {
15
15
  * sql: "SELECT * FROM logs WHERE level = ?",
16
16
  * params: ["error"]
17
17
  * });
@@ -37,7 +37,7 @@ export type { DbQueryInput, DbQueryOutput, DbExecuteInput, DbExecuteOutput, Logs
37
37
  export { DEFAULT_DB_PATH, LOG_LEVELS } from "./types.js";
38
38
  export { dbTables, dbSchema, dbTransaction, dbMigrate, dbBackup } from "./procedures/db/index.js";
39
39
  export { registerSqliteProcedures } from "./module.js";
40
- export { SqliteStorage, checkTableName, MEMORY_PATH, type SqliteStorageOptions } from "./storage.js";
40
+ export { SqliteStorage, checkTableName, isNodeSqliteAvailable, MEMORY_PATH, type SqliteEngine, type SqliteEngineName, type SqliteStorageOptions, } from "./storage.js";
41
41
  export { withConnection, createConnection, query, execute, execMultiple, lastInsertRowId, tableExists, getMigrationStatus, runMigrations, rollbackMigration, createMigration, } from "@mark1russell7/docker-sqlite";
42
42
  export type { ConnectionConfig, ConnectionCallback, QueryResult, ExecuteResult, Migration, MigrationStatus, Database, } from "@mark1russell7/docker-sqlite";
43
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAMH,YAAY,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,Y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0BAA0B,CAAC;AAMlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAMvD,OAAO,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,cAAc,CAAC;AAMtB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,SAAS,EACT,eAAe,EACf,QAAQ,GACT,MAAM,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -10,8 +10,8 @@
10
10
  *
11
11
  * const client = new Client(...);
12
12
  *
13
- * // Execute a query
14
- * const result = await client.call(["db", "query"], {
13
+ * // Execute a query (sqlite.query: the old name db.query is a deprecated alias)
14
+ * const result = await client.call(["sqlite", "query"], {
15
15
  * sql: "SELECT * FROM logs WHERE level = ?",
16
16
  * params: ["error"]
17
17
  * });
@@ -34,7 +34,7 @@
34
34
  * ```
35
35
  */
36
36
  export { DEFAULT_DB_PATH, LOG_LEVELS } from "./types.js";
37
- // The db.* procedures of roadmap R44, for direct use
37
+ // The sqlite.* procedures of roadmap R44, for direct use
38
38
  export { dbTables, dbSchema, dbTransaction, dbMigrate, dbBackup } from "./procedures/db/index.js";
39
39
  // =============================================================================
40
40
  // Registration
@@ -43,7 +43,7 @@ export { registerSqliteProcedures } from "./module.js";
43
43
  // =============================================================================
44
44
  // The collection storage (roadmap R45). The entry @procedures/sqlite/storage has it alone.
45
45
  // =============================================================================
46
- export { SqliteStorage, checkTableName, MEMORY_PATH } from "./storage.js";
46
+ export { SqliteStorage, checkTableName, isNodeSqliteAvailable, MEMORY_PATH, } from "./storage.js";
47
47
  // =============================================================================
48
48
  // Re-export docker-sqlite utilities for direct use
49
49
  // =============================================================================
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAoCH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD,qDAAqD;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAElG,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,gFAAgF;AAChF,2FAA2F;AAC3F,gFAAgF;AAEhF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAA6B,MAAM,cAAc,CAAC;AAErG,gFAAgF;AAChF,mDAAmD;AACnD,gFAAgF;AAEhF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAoCH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD,yDAAyD;AACzD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAElG,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,gFAAgF;AAChF,2FAA2F;AAC3F,gFAAgF;AAEhF,OAAO,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,WAAW,GAIZ,MAAM,cAAc,CAAC;AAEtB,gFAAgF;AAChF,mDAAmD;AACnD,gFAAgF;AAEhF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,8BAA8B,CAAC"}
package/dist/module.d.ts CHANGED
@@ -3,11 +3,21 @@
3
3
  *
4
4
  * Procedure Registration for SQLite
5
5
  *
6
- * Registers database and logging procedures with the client system: db.query, db.execute,
7
- * db.tables, db.schema, db.transaction, db.migrate, db.backup, logs.store and logs.query.
6
+ * The module has the database and logging procedures: sqlite.query, sqlite.execute,
7
+ * sqlite.tables, sqlite.schema, sqlite.transaction, sqlite.migrate, sqlite.backup, logs.store
8
+ * and logs.query. The old names db.* stay for one release as deprecated aliases (refer to
9
+ * `deprecatedDbAlias`).
8
10
  * This file is referenced by package.json's client.procedures field.
9
11
  */
10
- import { type ProcedureModule, type ProcedureRegistry } from "@procedures/client";
12
+ import { type AnyProcedure, type ProcedureModule, type ProcedureRegistry } from "@procedures/client";
13
+ /**
14
+ * This function gives the deprecated alias `db.<name>` of the procedure `sqlite.<name>`. The alias
15
+ * has the same schemas, handler and effects. Its description names the new procedure. The aliases
16
+ * go away in the next release. The MCP server does not expose them (`bundle-mcp`).
17
+ */
18
+ export declare function deprecatedDbAlias(procedure: AnyProcedure): AnyProcedure;
19
+ /** The deprecated aliases `db.query`, `db.execute`, `db.tables`, `db.schema`, `db.transaction`, `db.migrate` and `db.backup`. */
20
+ export declare const dbAliasProcedures: readonly AnyProcedure[];
11
21
  /**
12
22
  * The module of this package, for `createRegistry()`: its procedures as data. Importing this
13
23
  * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA6C,KAAK,eAAe,EAAuC,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAoelK;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,eAUvB,CAAC;eAEU,YAAY;AAE3B;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,GAAE,iBAAsC,GAAG,IAAI,CAE/F"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAA6C,KAAK,YAAY,EAAE,KAAK,eAAe,EAAuC,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAgfrL;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,YAAY,GAAG,YAAY,CAavE;AAED,iIAAiI;AACjI,eAAO,MAAM,iBAAiB,EAAE,SAAS,YAAY,EAA4C,CAAC;AAMlG;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,eAMvB,CAAC;eAEU,YAAY;AAE3B;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,GAAE,iBAAsC,GAAG,IAAI,CAE/F"}
package/dist/module.js CHANGED
@@ -3,8 +3,10 @@
3
3
  *
4
4
  * Procedure Registration for SQLite
5
5
  *
6
- * Registers database and logging procedures with the client system: db.query, db.execute,
7
- * db.tables, db.schema, db.transaction, db.migrate, db.backup, logs.store and logs.query.
6
+ * The module has the database and logging procedures: sqlite.query, sqlite.execute,
7
+ * sqlite.tables, sqlite.schema, sqlite.transaction, sqlite.migrate, sqlite.backup, logs.store
8
+ * and logs.query. The old names db.* stay for one release as deprecated aliases (refer to
9
+ * `deprecatedDbAlias`).
8
10
  * This file is referenced by package.json's client.procedures field.
9
11
  */
10
12
  import { createProcedure, zodAdapter, defineModule, PROCEDURE_REGISTRY, registerModules } from "@procedures/client";
@@ -18,10 +20,11 @@ import { DbTablesInputSchema, DbTablesOutputSchema, DbSchemaInputSchema, DbSchem
18
20
  // =============================================================================
19
21
  // Real schemas (roadmap 2.1): the input is validated before the handler, and the MCP tool list
20
22
  // and the help of mark describe each field. zodAdapter<T> checks each schema against its type.
23
+ // The description is the same on each computer: it does not show the home folder of this one
21
24
  const dbPathField = z
22
25
  .string()
23
26
  .optional()
24
- .describe(`The SQLite database file (default: ${DEFAULT_DB_PATH}). A query does not make a missing file.`);
27
+ .describe("The SQLite database file (default: the CLI log database, ~/logs/cli/cli.db). A query does not make a missing file.");
25
28
  const paramsField = z
26
29
  .array(z.unknown())
27
30
  .optional()
@@ -120,10 +123,10 @@ async function ensureLogsTable(dbPath) {
120
123
  });
121
124
  }
122
125
  // =============================================================================
123
- // db.query Procedure
126
+ // sqlite.query Procedure
124
127
  // =============================================================================
125
- const dbQueryProcedure = createProcedure()
126
- .path(["db", "query"])
128
+ const sqliteQueryProcedure = createProcedure()
129
+ .path(["sqlite", "query"])
127
130
  .input(dbQueryInputSchema)
128
131
  .output(dbQueryOutputSchema)
129
132
  .meta({
@@ -146,10 +149,10 @@ const dbQueryProcedure = createProcedure()
146
149
  })
147
150
  .build();
148
151
  // =============================================================================
149
- // db.execute Procedure
152
+ // sqlite.execute Procedure
150
153
  // =============================================================================
151
- const dbExecuteProcedure = createProcedure()
152
- .path(["db", "execute"])
154
+ const sqliteExecuteProcedure = createProcedure()
155
+ .path(["sqlite", "execute"])
153
156
  .input(dbExecuteInputSchema)
154
157
  .output(dbExecuteOutputSchema)
155
158
  .meta({
@@ -294,10 +297,10 @@ const logsQueryProcedure = createProcedure()
294
297
  })
295
298
  .build();
296
299
  // =============================================================================
297
- // db.tables, db.schema, db.transaction, db.migrate and db.backup (roadmap R44)
300
+ // sqlite.tables, sqlite.schema, sqlite.transaction, sqlite.migrate and sqlite.backup (roadmap R44)
298
301
  // =============================================================================
299
- const dbTablesProcedure = createProcedure()
300
- .path(["db", "tables"])
302
+ const sqliteTablesProcedure = createProcedure()
303
+ .path(["sqlite", "tables"])
301
304
  .input(zodAdapter(DbTablesInputSchema))
302
305
  .output(zodAdapter(DbTablesOutputSchema))
303
306
  .meta({
@@ -309,8 +312,8 @@ const dbTablesProcedure = createProcedure()
309
312
  })
310
313
  .handler(async (input) => dbTables(input))
311
314
  .build();
312
- const dbSchemaProcedure = createProcedure()
313
- .path(["db", "schema"])
315
+ const sqliteSchemaProcedure = createProcedure()
316
+ .path(["sqlite", "schema"])
314
317
  .input(zodAdapter(DbSchemaInputSchema))
315
318
  .output(zodAdapter(DbSchemaOutputSchema))
316
319
  .meta({
@@ -322,8 +325,8 @@ const dbSchemaProcedure = createProcedure()
322
325
  })
323
326
  .handler(async (input) => dbSchema(input))
324
327
  .build();
325
- const dbTransactionProcedure = createProcedure()
326
- .path(["db", "transaction"])
328
+ const sqliteTransactionProcedure = createProcedure()
329
+ .path(["sqlite", "transaction"])
327
330
  .input(zodAdapter(DbTransactionInputSchema))
328
331
  .output(zodAdapter(DbTransactionOutputSchema))
329
332
  .meta({
@@ -336,8 +339,8 @@ const dbTransactionProcedure = createProcedure()
336
339
  })
337
340
  .handler(async (input) => dbTransaction(input))
338
341
  .build();
339
- const dbMigrateProcedure = createProcedure()
340
- .path(["db", "migrate"])
342
+ const sqliteMigrateProcedure = createProcedure()
343
+ .path(["sqlite", "migrate"])
341
344
  .input(zodAdapter(DbMigrateInputSchema))
342
345
  .output(zodAdapter(DbMigrateOutputSchema))
343
346
  .meta({
@@ -350,8 +353,8 @@ const dbMigrateProcedure = createProcedure()
350
353
  })
351
354
  .handler(async (input) => dbMigrate(input))
352
355
  .build();
353
- const dbBackupProcedure = createProcedure()
354
- .path(["db", "backup"])
356
+ const sqliteBackupProcedure = createProcedure()
357
+ .path(["sqlite", "backup"])
355
358
  .input(zodAdapter(DbBackupInputSchema))
356
359
  .output(zodAdapter(DbBackupOutputSchema))
357
360
  .meta({
@@ -365,6 +368,40 @@ const dbBackupProcedure = createProcedure()
365
368
  .handler(async (input) => dbBackup(input))
366
369
  .build();
367
370
  // =============================================================================
371
+ // The deprecated db.* aliases (one release)
372
+ // =============================================================================
373
+ /** The procedures of the `sqlite` namespace. Each one has a deprecated alias in `db`. */
374
+ const sqliteProcedures = [
375
+ sqliteQueryProcedure,
376
+ sqliteExecuteProcedure,
377
+ sqliteTablesProcedure,
378
+ sqliteSchemaProcedure,
379
+ sqliteTransactionProcedure,
380
+ sqliteMigrateProcedure,
381
+ sqliteBackupProcedure,
382
+ ];
383
+ /**
384
+ * This function gives the deprecated alias `db.<name>` of the procedure `sqlite.<name>`. The alias
385
+ * has the same schemas, handler and effects. Its description names the new procedure. The aliases
386
+ * go away in the next release. The MCP server does not expose them (`bundle-mcp`).
387
+ */
388
+ export function deprecatedDbAlias(procedure) {
389
+ const name = procedure.path.slice(1).join(".");
390
+ const description = typeof procedure.metadata.description === "string" ? ` ${procedure.metadata.description}` : "";
391
+ return {
392
+ ...procedure,
393
+ path: ["db", ...procedure.path.slice(1)],
394
+ metadata: {
395
+ ...procedure.metadata,
396
+ description: `Deprecated: use sqlite.${name}.${description}`,
397
+ deprecated: true,
398
+ deprecationMessage: `Use sqlite.${name}. The alias db.${name} goes away in the next release.`,
399
+ },
400
+ };
401
+ }
402
+ /** The deprecated aliases `db.query`, `db.execute`, `db.tables`, `db.schema`, `db.transaction`, `db.migrate` and `db.backup`. */
403
+ export const dbAliasProcedures = sqliteProcedures.map(deprecatedDbAlias);
404
+ // =============================================================================
368
405
  // Registration
369
406
  // =============================================================================
370
407
  /**
@@ -372,15 +409,11 @@ const dbBackupProcedure = createProcedure()
372
409
  * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
373
410
  */
374
411
  export const sqliteModule = defineModule("@procedures/sqlite", [
375
- dbQueryProcedure,
376
- dbExecuteProcedure,
412
+ ...sqliteProcedures,
377
413
  logsStoreProcedure,
378
414
  logsQueryProcedure,
379
- dbTablesProcedure,
380
- dbSchemaProcedure,
381
- dbTransactionProcedure,
382
- dbMigrateProcedure,
383
- dbBackupProcedure,
415
+ // The old names, for one release
416
+ ...dbAliasProcedures,
384
417
  ]);
385
418
  export default sqliteModule;
386
419
  /**