@procedures/sqlite 0.3.0 → 0.4.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/CHANGELOG.md +25 -0
- package/README.md +36 -28
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +13 -3
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +60 -27
- package/dist/module.js.map +1 -1
- package/dist/procedures/db/backup.d.ts +1 -1
- package/dist/procedures/db/backup.js +6 -6
- package/dist/procedures/db/backup.js.map +1 -1
- package/dist/procedures/db/migrate.d.ts +1 -1
- package/dist/procedures/db/migrate.js +8 -8
- package/dist/procedures/db/migrate.js.map +1 -1
- package/dist/procedures/db/schema.d.ts +1 -1
- package/dist/procedures/db/schema.js +3 -3
- package/dist/procedures/db/schema.js.map +1 -1
- package/dist/procedures/db/shared.d.ts +1 -1
- package/dist/procedures/db/shared.js +1 -1
- package/dist/procedures/db/tables.d.ts +1 -1
- package/dist/procedures/db/tables.js +2 -2
- package/dist/procedures/db/tables.js.map +1 -1
- package/dist/procedures/db/transaction.d.ts +1 -1
- package/dist/procedures/db/transaction.js +2 -2
- package/dist/procedures/db/transaction.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +3 -3
- package/src/module.ts +65 -28
- package/src/procedures/db/backup.ts +6 -6
- package/src/procedures/db/migrate.ts +8 -8
- package/src/procedures/db/schema.ts +3 -3
- package/src/procedures/db/shared.ts +1 -1
- package/src/procedures/db/tables.ts +2 -2
- package/src/procedures/db/transaction.ts +2 -2
- package/src/types.ts +4 -4
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"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LOG_LEVELS = [
|
|
|
19
19
|
"error",
|
|
20
20
|
];
|
|
21
21
|
// =============================================================================
|
|
22
|
-
//
|
|
22
|
+
// sqlite.tables, sqlite.schema, sqlite.transaction, sqlite.migrate and sqlite.backup (roadmap R44)
|
|
23
23
|
// =============================================================================
|
|
24
24
|
/** The `dbPath` field of the R44 procedures. Its description does not show the home folder. */
|
|
25
25
|
const dbPath = z.string().min(1).optional().describe("The SQLite database file (default: the CLI log database, ~/logs/cli/cli.db)");
|
|
@@ -91,7 +91,7 @@ export const DbTransactionOutputSchema = z.looseObject({
|
|
|
91
91
|
.describe("One result for each statement of the input"),
|
|
92
92
|
changes: z.number().describe("The rows that the transaction changed"),
|
|
93
93
|
});
|
|
94
|
-
/** The name of a table that the SQL of
|
|
94
|
+
/** The name of a table that the SQL of sqlite.migrate names: letters, digits and underscores. */
|
|
95
95
|
export const MIGRATION_TABLE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
96
96
|
export const DbMigrateInputSchema = z.object({
|
|
97
97
|
folder: z.string().min(1).optional().describe("A folder of files named <number>_<name>.sql, for example 001_create_users.sql (not with migrations)"),
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAW,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAQhF,MAAM,CAAC,MAAM,UAAU,GAAwB;IAC7C,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM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C,QAAQ,CAAC,8DAA8D,CAAC;IACvG,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAA8B,CAAC,CAAC,WAAW,CAAC;IAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IACjD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;CAC7D,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/sqlite",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "SQLite procedures with sql.js and no native build: queries, tables and schemas, transactions, migrations, backups and structured logs, safe for concurrent writes, and SqliteStorage, a durable collection storage with a change log.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"sqlite",
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"procedures": "./dist/register.js"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@procedures/client": "0.
|
|
67
|
+
"@procedures/client": "0.4.0",
|
|
68
68
|
"@mark1russell7/docker-sqlite": "^0.1.0",
|
|
69
69
|
"zod": "^4.6.5"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@mark1russell7/cue": "^1.0.0",
|
|
73
|
-
"@procedures/collections": "0.
|
|
74
|
-
"@procedures/store": "0.
|
|
73
|
+
"@procedures/collections": "0.4.0",
|
|
74
|
+
"@procedures/store": "0.4.0",
|
|
75
75
|
"@types/node": "^22.0.0",
|
|
76
76
|
"typescript": "^7.0.2",
|
|
77
77
|
"vitest": "^5.0.3"
|
package/src/index.ts
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(["
|
|
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
|
* });
|
|
@@ -70,7 +70,7 @@ export type {
|
|
|
70
70
|
|
|
71
71
|
export { DEFAULT_DB_PATH, LOG_LEVELS } from "./types.js";
|
|
72
72
|
|
|
73
|
-
// The
|
|
73
|
+
// The sqlite.* procedures of roadmap R44, for direct use
|
|
74
74
|
export { dbTables, dbSchema, dbTransaction, dbMigrate, dbBackup } from "./procedures/db/index.js";
|
|
75
75
|
|
|
76
76
|
// =============================================================================
|
package/src/module.ts
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Procedure Registration for SQLite
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
|
11
|
-
import { createProcedure, zodAdapter, defineModule, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
|
|
13
|
+
import { createProcedure, zodAdapter, defineModule, type AnyProcedure, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
|
|
12
14
|
import { z } from "zod";
|
|
13
15
|
import {
|
|
14
16
|
withConnection,
|
|
@@ -64,10 +66,11 @@ import {
|
|
|
64
66
|
// Real schemas (roadmap 2.1): the input is validated before the handler, and the MCP tool list
|
|
65
67
|
// and the help of mark describe each field. zodAdapter<T> checks each schema against its type.
|
|
66
68
|
|
|
69
|
+
// The description is the same on each computer: it does not show the home folder of this one
|
|
67
70
|
const dbPathField = z
|
|
68
71
|
.string()
|
|
69
72
|
.optional()
|
|
70
|
-
.describe(
|
|
73
|
+
.describe("The SQLite database file (default: the CLI log database, ~/logs/cli/cli.db). A query does not make a missing file.");
|
|
71
74
|
const paramsField = z
|
|
72
75
|
.array(z.unknown())
|
|
73
76
|
.optional()
|
|
@@ -190,11 +193,11 @@ async function ensureLogsTable(dbPath: string): Promise<void> {
|
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
// =============================================================================
|
|
193
|
-
//
|
|
196
|
+
// sqlite.query Procedure
|
|
194
197
|
// =============================================================================
|
|
195
198
|
|
|
196
|
-
const
|
|
197
|
-
.path(["
|
|
199
|
+
const sqliteQueryProcedure = createProcedure()
|
|
200
|
+
.path(["sqlite", "query"])
|
|
198
201
|
.input(dbQueryInputSchema)
|
|
199
202
|
.output(dbQueryOutputSchema)
|
|
200
203
|
.meta({
|
|
@@ -219,11 +222,11 @@ const dbQueryProcedure = createProcedure()
|
|
|
219
222
|
.build();
|
|
220
223
|
|
|
221
224
|
// =============================================================================
|
|
222
|
-
//
|
|
225
|
+
// sqlite.execute Procedure
|
|
223
226
|
// =============================================================================
|
|
224
227
|
|
|
225
|
-
const
|
|
226
|
-
.path(["
|
|
228
|
+
const sqliteExecuteProcedure = createProcedure()
|
|
229
|
+
.path(["sqlite", "execute"])
|
|
227
230
|
.input(dbExecuteInputSchema)
|
|
228
231
|
.output(dbExecuteOutputSchema)
|
|
229
232
|
.meta({
|
|
@@ -412,11 +415,11 @@ const logsQueryProcedure = createProcedure()
|
|
|
412
415
|
.build();
|
|
413
416
|
|
|
414
417
|
// =============================================================================
|
|
415
|
-
//
|
|
418
|
+
// sqlite.tables, sqlite.schema, sqlite.transaction, sqlite.migrate and sqlite.backup (roadmap R44)
|
|
416
419
|
// =============================================================================
|
|
417
420
|
|
|
418
|
-
const
|
|
419
|
-
.path(["
|
|
421
|
+
const sqliteTablesProcedure = createProcedure()
|
|
422
|
+
.path(["sqlite", "tables"])
|
|
420
423
|
.input(zodAdapter<DbTablesInput>(DbTablesInputSchema))
|
|
421
424
|
.output(zodAdapter<DbTablesOutput>(DbTablesOutputSchema))
|
|
422
425
|
.meta({
|
|
@@ -429,8 +432,8 @@ const dbTablesProcedure = createProcedure()
|
|
|
429
432
|
.handler(async (input: DbTablesInput): Promise<DbTablesOutput> => dbTables(input))
|
|
430
433
|
.build();
|
|
431
434
|
|
|
432
|
-
const
|
|
433
|
-
.path(["
|
|
435
|
+
const sqliteSchemaProcedure = createProcedure()
|
|
436
|
+
.path(["sqlite", "schema"])
|
|
434
437
|
.input(zodAdapter<DbSchemaInput>(DbSchemaInputSchema))
|
|
435
438
|
.output(zodAdapter<DbSchemaOutput>(DbSchemaOutputSchema))
|
|
436
439
|
.meta({
|
|
@@ -443,8 +446,8 @@ const dbSchemaProcedure = createProcedure()
|
|
|
443
446
|
.handler(async (input: DbSchemaInput): Promise<DbSchemaOutput> => dbSchema(input))
|
|
444
447
|
.build();
|
|
445
448
|
|
|
446
|
-
const
|
|
447
|
-
.path(["
|
|
449
|
+
const sqliteTransactionProcedure = createProcedure()
|
|
450
|
+
.path(["sqlite", "transaction"])
|
|
448
451
|
.input(zodAdapter<DbTransactionInput>(DbTransactionInputSchema))
|
|
449
452
|
.output(zodAdapter<DbTransactionOutput>(DbTransactionOutputSchema))
|
|
450
453
|
.meta({
|
|
@@ -458,8 +461,8 @@ const dbTransactionProcedure = createProcedure()
|
|
|
458
461
|
.handler(async (input: DbTransactionInput): Promise<DbTransactionOutput> => dbTransaction(input))
|
|
459
462
|
.build();
|
|
460
463
|
|
|
461
|
-
const
|
|
462
|
-
.path(["
|
|
464
|
+
const sqliteMigrateProcedure = createProcedure()
|
|
465
|
+
.path(["sqlite", "migrate"])
|
|
463
466
|
.input(zodAdapter<DbMigrateInput>(DbMigrateInputSchema))
|
|
464
467
|
.output(zodAdapter<DbMigrateOutput>(DbMigrateOutputSchema))
|
|
465
468
|
.meta({
|
|
@@ -473,8 +476,8 @@ const dbMigrateProcedure = createProcedure()
|
|
|
473
476
|
.handler(async (input: DbMigrateInput): Promise<DbMigrateOutput> => dbMigrate(input))
|
|
474
477
|
.build();
|
|
475
478
|
|
|
476
|
-
const
|
|
477
|
-
.path(["
|
|
479
|
+
const sqliteBackupProcedure = createProcedure()
|
|
480
|
+
.path(["sqlite", "backup"])
|
|
478
481
|
.input(zodAdapter<DbBackupInput>(DbBackupInputSchema))
|
|
479
482
|
.output(zodAdapter<DbBackupOutput>(DbBackupOutputSchema))
|
|
480
483
|
.meta({
|
|
@@ -488,6 +491,44 @@ const dbBackupProcedure = createProcedure()
|
|
|
488
491
|
.handler(async (input: DbBackupInput): Promise<DbBackupOutput> => dbBackup(input))
|
|
489
492
|
.build();
|
|
490
493
|
|
|
494
|
+
// =============================================================================
|
|
495
|
+
// The deprecated db.* aliases (one release)
|
|
496
|
+
// =============================================================================
|
|
497
|
+
|
|
498
|
+
/** The procedures of the `sqlite` namespace. Each one has a deprecated alias in `db`. */
|
|
499
|
+
const sqliteProcedures: readonly AnyProcedure[] = [
|
|
500
|
+
sqliteQueryProcedure,
|
|
501
|
+
sqliteExecuteProcedure,
|
|
502
|
+
sqliteTablesProcedure,
|
|
503
|
+
sqliteSchemaProcedure,
|
|
504
|
+
sqliteTransactionProcedure,
|
|
505
|
+
sqliteMigrateProcedure,
|
|
506
|
+
sqliteBackupProcedure,
|
|
507
|
+
];
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* This function gives the deprecated alias `db.<name>` of the procedure `sqlite.<name>`. The alias
|
|
511
|
+
* has the same schemas, handler and effects. Its description names the new procedure. The aliases
|
|
512
|
+
* go away in the next release. The MCP server does not expose them (`bundle-mcp`).
|
|
513
|
+
*/
|
|
514
|
+
export function deprecatedDbAlias(procedure: AnyProcedure): AnyProcedure {
|
|
515
|
+
const name = procedure.path.slice(1).join(".");
|
|
516
|
+
const description = typeof procedure.metadata.description === "string" ? ` ${procedure.metadata.description}` : "";
|
|
517
|
+
return {
|
|
518
|
+
...procedure,
|
|
519
|
+
path: ["db", ...procedure.path.slice(1)],
|
|
520
|
+
metadata: {
|
|
521
|
+
...procedure.metadata,
|
|
522
|
+
description: `Deprecated: use sqlite.${name}.${description}`,
|
|
523
|
+
deprecated: true,
|
|
524
|
+
deprecationMessage: `Use sqlite.${name}. The alias db.${name} goes away in the next release.`,
|
|
525
|
+
},
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/** The deprecated aliases `db.query`, `db.execute`, `db.tables`, `db.schema`, `db.transaction`, `db.migrate` and `db.backup`. */
|
|
530
|
+
export const dbAliasProcedures: readonly AnyProcedure[] = sqliteProcedures.map(deprecatedDbAlias);
|
|
531
|
+
|
|
491
532
|
// =============================================================================
|
|
492
533
|
// Registration
|
|
493
534
|
// =============================================================================
|
|
@@ -497,15 +538,11 @@ const dbBackupProcedure = createProcedure()
|
|
|
497
538
|
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
498
539
|
*/
|
|
499
540
|
export const sqliteModule: ProcedureModule = defineModule("@procedures/sqlite", [
|
|
500
|
-
|
|
501
|
-
dbExecuteProcedure,
|
|
541
|
+
...sqliteProcedures,
|
|
502
542
|
logsStoreProcedure,
|
|
503
543
|
logsQueryProcedure,
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
dbTransactionProcedure,
|
|
507
|
-
dbMigrateProcedure,
|
|
508
|
-
dbBackupProcedure,
|
|
544
|
+
// The old names, for one release
|
|
545
|
+
...dbAliasProcedures,
|
|
509
546
|
]);
|
|
510
547
|
|
|
511
548
|
export default sqliteModule;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* sqlite.backup procedure (roadmap R44)
|
|
3
3
|
*
|
|
4
4
|
* A copy of a database in a new file. The package runs SQLite in WebAssembly (sql.js): the
|
|
5
5
|
* database is in the memory of the module, and `VACUUM INTO` and the backup API write into the
|
|
@@ -30,13 +30,13 @@ function fileKey(path: string): string {
|
|
|
30
30
|
*/
|
|
31
31
|
export async function dbBackup(input: DbBackupInput): Promise<DbBackupOutput> {
|
|
32
32
|
const source = databasePath(input.dbPath);
|
|
33
|
-
requireDatabaseFile("
|
|
33
|
+
requireDatabaseFile("sqlite.backup", source);
|
|
34
34
|
const target = resolve(input.to);
|
|
35
35
|
if (source !== ":memory:" && fileKey(source) === fileKey(target)) {
|
|
36
|
-
throw new Error("
|
|
36
|
+
throw new Error("sqlite.backup: the copy cannot be the database file itself");
|
|
37
37
|
}
|
|
38
38
|
if (existsSync(target)) {
|
|
39
|
-
const error = new Error(`
|
|
39
|
+
const error = new Error(`sqlite.backup: the file exists already: ${target}. The procedure does not replace a file.`) as NodeJS.ErrnoException;
|
|
40
40
|
error.code = "EEXIST";
|
|
41
41
|
throw error;
|
|
42
42
|
}
|
|
@@ -51,8 +51,8 @@ export async function dbBackup(input: DbBackupInput): Promise<DbBackupOutput> {
|
|
|
51
51
|
}
|
|
52
52
|
const check = await withConnection({ dbPath: temporary }, (db) => query<{ integrity_check: string }>(db, "PRAGMA integrity_check").rows);
|
|
53
53
|
const verdict = check.map((row) => row.integrity_check).join("; ");
|
|
54
|
-
if (verdict !== "ok") throw new Error(`
|
|
55
|
-
if (existsSync(target)) throw new Error(`
|
|
54
|
+
if (verdict !== "ok") throw new Error(`sqlite.backup: the copy is not valid: ${verdict}`);
|
|
55
|
+
if (existsSync(target)) throw new Error(`sqlite.backup: the file exists already: ${target}. The procedure does not replace a file.`);
|
|
56
56
|
await rename(temporary, target);
|
|
57
57
|
} catch (error) {
|
|
58
58
|
await unlink(temporary).catch(() => undefined);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* sqlite.migrate procedure (roadmap R44)
|
|
3
3
|
*
|
|
4
4
|
* The procedure applies the numbered migrations that the database does not have, in the order
|
|
5
5
|
* of their numbers. The migrations come from a folder (files named `<number>_<name>.sql`) or
|
|
@@ -44,7 +44,7 @@ export async function migrationsOfFolder(folder: string): Promise<DbMigration[]>
|
|
|
44
44
|
for (const entry of entries) {
|
|
45
45
|
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".sql")) continue;
|
|
46
46
|
const match = MIGRATION_FILE.exec(entry.name);
|
|
47
|
-
if (!match) throw new Error(`
|
|
47
|
+
if (!match) throw new Error(`sqlite.migrate: the file ${entry.name} has no number: name it <number>_<name>.sql`);
|
|
48
48
|
migrations.push({ version: Number(match[1]), name: match[2]!, sql: await readFile(join(folder, entry.name), "utf8") });
|
|
49
49
|
}
|
|
50
50
|
return migrations;
|
|
@@ -55,9 +55,9 @@ function ordered(migrations: DbMigration[]): Migration[] {
|
|
|
55
55
|
const byVersion = new Map<number, Migration>();
|
|
56
56
|
for (const migration of migrations) {
|
|
57
57
|
if (!Number.isSafeInteger(migration.version) || migration.version < 1) {
|
|
58
|
-
throw new Error(`
|
|
58
|
+
throw new Error(`sqlite.migrate: the version ${migration.version} is not a whole number of 1 or more`);
|
|
59
59
|
}
|
|
60
|
-
if (byVersion.has(migration.version)) throw new Error(`
|
|
60
|
+
if (byVersion.has(migration.version)) throw new Error(`sqlite.migrate: two migrations have the version ${migration.version}`);
|
|
61
61
|
const name = migration.name ?? `migration ${migration.version}`;
|
|
62
62
|
byVersion.set(migration.version, { version: migration.version, name, sql: migration.sql, checksum: checksum(migration.sql) });
|
|
63
63
|
}
|
|
@@ -69,10 +69,10 @@ function ordered(migrations: DbMigration[]): Migration[] {
|
|
|
69
69
|
*/
|
|
70
70
|
export async function dbMigrate(input: DbMigrateInput): Promise<DbMigrateOutput> {
|
|
71
71
|
if ((input.folder === undefined) === (input.migrations === undefined)) {
|
|
72
|
-
throw new Error("
|
|
72
|
+
throw new Error("sqlite.migrate: give exactly one of folder or migrations");
|
|
73
73
|
}
|
|
74
74
|
const table = input.table ?? DEFAULT_MIGRATION_TABLE;
|
|
75
|
-
if (!MIGRATION_TABLE_PATTERN.test(table)) throw new Error(`
|
|
75
|
+
if (!MIGRATION_TABLE_PATTERN.test(table)) throw new Error(`sqlite.migrate: the table name ${JSON.stringify(table)} is not valid`);
|
|
76
76
|
const migrations = ordered(input.folder !== undefined ? await migrationsOfFolder(input.folder) : input.migrations!);
|
|
77
77
|
|
|
78
78
|
return withConnection({ dbPath: databasePath(input.dbPath) }, (db) => {
|
|
@@ -87,7 +87,7 @@ export async function dbMigrate(input: DbMigrateInput): Promise<DbMigrateOutput>
|
|
|
87
87
|
for (const migration of migrations) {
|
|
88
88
|
const known = applied.get(migration.version);
|
|
89
89
|
if (known !== undefined && known !== migration.checksum) {
|
|
90
|
-
throw new Error(`
|
|
90
|
+
throw new Error(`sqlite.migrate: the migration ${migration.version} (${migration.name}) changed after it was applied: its sha256 is different`);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
const pending = migrations.filter((migration) => !applied.has(migration.version));
|
|
@@ -97,7 +97,7 @@ export async function dbMigrate(input: DbMigrateInput): Promise<DbMigrateOutput>
|
|
|
97
97
|
runStatements(db, migration.sql, [], label);
|
|
98
98
|
} catch (error) {
|
|
99
99
|
const message = error instanceof Error ? error.message : String(error);
|
|
100
|
-
throw new Error(message.startsWith(label) ? `
|
|
100
|
+
throw new Error(message.startsWith(label) ? `sqlite.migrate: ${message}` : `sqlite.migrate: ${label} failed: ${message}`);
|
|
101
101
|
}
|
|
102
102
|
db.run(`INSERT INTO "${table}" (version, name, checksum) VALUES (?, ?, ?)`, [migration.version, migration.name, migration.checksum]);
|
|
103
103
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* sqlite.schema procedure (roadmap R44)
|
|
3
3
|
*
|
|
4
4
|
* The columns, the indexes and the foreign keys of a table (or the columns of a view). The
|
|
5
5
|
* procedure reads them with the table-valued PRAGMA functions, so the name of the table is a
|
|
@@ -38,7 +38,7 @@ interface ForeignKeyRow {
|
|
|
38
38
|
*/
|
|
39
39
|
export async function dbSchema(input: DbSchemaInput): Promise<DbSchemaOutput> {
|
|
40
40
|
const path = databasePath(input.dbPath);
|
|
41
|
-
requireDatabaseFile("
|
|
41
|
+
requireDatabaseFile("sqlite.schema", path);
|
|
42
42
|
return withConnection({ dbPath: path }, (db) => {
|
|
43
43
|
db.run("PRAGMA query_only = 1");
|
|
44
44
|
const found = query<{ type: "table" | "view"; sql: string | null }>(
|
|
@@ -46,7 +46,7 @@ export async function dbSchema(input: DbSchemaInput): Promise<DbSchemaOutput> {
|
|
|
46
46
|
"SELECT type, sql FROM sqlite_master WHERE name = ? AND type IN ('table', 'view')",
|
|
47
47
|
[input.table],
|
|
48
48
|
).rows[0];
|
|
49
|
-
if (!found) throw new Error(`
|
|
49
|
+
if (!found) throw new Error(`sqlite.schema: no table or view named ${JSON.stringify(input.table)}`);
|
|
50
50
|
|
|
51
51
|
const columns: DbColumnInfo[] = query<ColumnRow>(db, "SELECT name, type, \"notnull\", dflt_value, pk FROM pragma_table_info(?) ORDER BY cid", [input.table]).rows.map(
|
|
52
52
|
(row) => ({ name: row.name, type: row.type, notNull: row.notnull === 1, defaultValue: row.dflt_value, primaryKey: row.pk }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* sqlite.tables procedure (roadmap R44)
|
|
3
3
|
*
|
|
4
4
|
* The tables and the views of a database, without the internal `sqlite_` tables. The connection
|
|
5
5
|
* is read only (PRAGMA query_only), and a missing file is an error: it does not make one.
|
|
@@ -14,7 +14,7 @@ import { databasePath, requireDatabaseFile } from "./shared.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export async function dbTables(input: DbTablesInput): Promise<DbTablesOutput> {
|
|
16
16
|
const path = databasePath(input.dbPath);
|
|
17
|
-
requireDatabaseFile("
|
|
17
|
+
requireDatabaseFile("sqlite.tables", path);
|
|
18
18
|
const types = input.views === false ? "('table')" : "('table', 'view')";
|
|
19
19
|
return withConnection({ dbPath: path }, (db) => {
|
|
20
20
|
db.run("PRAGMA query_only = 1");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* sqlite.transaction procedure (roadmap R44)
|
|
3
3
|
*
|
|
4
4
|
* The statements of the input run in order in one transaction. When one fails, the procedure
|
|
5
5
|
* rolls back the transaction and does not save the file: the database stays as it was. A
|
|
@@ -20,7 +20,7 @@ export async function dbTransaction(input: DbTransactionInput): Promise<DbTransa
|
|
|
20
20
|
const results: DbStatementResult[] = [];
|
|
21
21
|
try {
|
|
22
22
|
input.statements.forEach((statement, index) => {
|
|
23
|
-
const label = `
|
|
23
|
+
const label = `sqlite.transaction: statements[${index}]`;
|
|
24
24
|
try {
|
|
25
25
|
results.push(runStatements(db, statement.sql, statement.params ?? [], label));
|
|
26
26
|
} catch (error) {
|
package/src/types.ts
CHANGED
|
@@ -30,7 +30,7 @@ export const LOG_LEVELS: readonly LogLevel[] = [
|
|
|
30
30
|
] as const;
|
|
31
31
|
|
|
32
32
|
// =============================================================================
|
|
33
|
-
//
|
|
33
|
+
// sqlite.query types
|
|
34
34
|
// =============================================================================
|
|
35
35
|
|
|
36
36
|
export interface DbQueryInput {
|
|
@@ -50,7 +50,7 @@ export interface DbQueryOutput<T = Record<string, unknown>> {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// =============================================================================
|
|
53
|
-
//
|
|
53
|
+
// sqlite.execute types
|
|
54
54
|
// =============================================================================
|
|
55
55
|
|
|
56
56
|
export interface DbExecuteInput {
|
|
@@ -136,7 +136,7 @@ export interface LogsQueryOutput {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// =============================================================================
|
|
139
|
-
//
|
|
139
|
+
// sqlite.tables, sqlite.schema, sqlite.transaction, sqlite.migrate and sqlite.backup (roadmap R44)
|
|
140
140
|
// =============================================================================
|
|
141
141
|
|
|
142
142
|
/** The `dbPath` field of the R44 procedures. Its description does not show the home folder. */
|
|
@@ -345,7 +345,7 @@ export interface DbMigrateOutput {
|
|
|
345
345
|
version: number;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
/** The name of a table that the SQL of
|
|
348
|
+
/** The name of a table that the SQL of sqlite.migrate names: letters, digits and underscores. */
|
|
349
349
|
export const MIGRATION_TABLE_PATTERN: RegExp = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
350
350
|
|
|
351
351
|
export const DbMigrateInputSchema: z.ZodType<DbMigrateInput> = z.object({
|