durable-db 0.13.1 → 0.13.2

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/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as registerDbCommands } from "../cli--9cKeEka.js";
2
+ import { n as registerDbCommands } from "../cli-B_bNgIGE.js";
3
3
  import { Command } from "commander";
4
4
  //#region src/cli/bin.ts
5
5
  const program = new Command();
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { c as getDatabaseEpochs, d as getInstanceKey, f as init_state, g as runningDevServer, l as getDevEpoch, m as loadDevState, o as generateEpoch, p as loadDevMigrations, s as getDatabaseEpoch, u as getDevPaths, v as saveDevState } from "../state-UT6GH0JD.js";
2
2
  import { _ as parseRenameSpec, u as SchemaRenameRequiredError } from "../snapshot-CY4FLqAo.js";
3
3
  import { n as declaresSchema } from "../parser-mUnAtllk.js";
4
- import { C as diffSchema, D as reportCliError, E as loadSchemaTables, O as selectDatabases, S as diffDatabases, T as loadSchema, _ as sift, a as reset, b as pushOne, c as status, d as generate, f as generateOne, g as replayWithRows, h as readAccepted, i as DevServerRunningError, l as MigrationFailsOnRowsError, m as accept, n as registerDbCommands, o as resetAndPush, p as ACCEPTED_FILE, r as validate, s as formatStatus, t as createDbCommand, u as UnsafeMigrationError, v as writeAccepted, w as discoverDatabases, x as UnknownDatabaseError, y as push } from "../cli--9cKeEka.js";
4
+ import { C as diffSchema, D as reportCliError, E as loadSchemaTables, O as selectDatabases, S as diffDatabases, T as loadSchema, _ as sift, a as reset, b as pushOne, c as status, d as generate, f as generateOne, g as replayWithRows, h as readAccepted, i as DevServerRunningError, l as MigrationFailsOnRowsError, m as accept, n as registerDbCommands, o as resetAndPush, p as ACCEPTED_FILE, r as validate, s as formatStatus, t as createDbCommand, u as UnsafeMigrationError, v as writeAccepted, w as discoverDatabases, x as UnknownDatabaseError, y as push } from "../cli-B_bNgIGE.js";
5
5
  init_state();
6
6
  export { ACCEPTED_FILE, DevServerRunningError, MigrationFailsOnRowsError, SchemaRenameRequiredError, UnknownDatabaseError, UnsafeMigrationError, accept, createDbCommand, declaresSchema, diffDatabases, diffSchema, discoverDatabases, formatStatus, generate, generateEpoch, generateOne, getDatabaseEpoch, getDatabaseEpochs, getDevEpoch, getDevPaths, getInstanceKey, loadDevMigrations, loadDevState, loadSchema, loadSchemaTables, parseRenameSpec, push, pushOne, readAccepted, registerDbCommands, replayWithRows, reportCliError, reset, resetAndPush, runningDevServer, saveDevState, selectDatabases, sift, status, validate, writeAccepted };
@@ -486,7 +486,7 @@ function compare(migration, statements, before, after) {
486
486
  /** What to do about a failure, by what SQLite said. */
487
487
  function remedy(error) {
488
488
  if (/NOT NULL constraint failed/i.test(error)) return "a row holds NULL there — give those rows a value in this migration, before the statement: UPDATE … SET … WHERE … IS NULL";
489
- if (/FOREIGN KEY constraint failed|foreign key mismatch|references a row that is not there/i.test(error)) return "a row references a row that is not there — remove or repair those rows in this migration, before the statement: DELETE FROM … WHERE … NOT IN (SELECT …)";
489
+ if (/FOREIGN KEY constraint failed|foreign key mismatch|references a row that is not there/i.test(error)) return "a row references a row that is not there — remove or repair those rows in this migration, before the statement: add the rows they reference (INSERT INTO … SELECT DISTINCT … WHERE … NOT IN (SELECT …)), or remove the ones that reference nothing (DELETE FROM … WHERE … NOT IN (SELECT …))";
490
490
  if (/UNIQUE constraint failed/i.test(error)) return "two rows hold the same value there — make them distinct, or remove one, in this migration before the statement";
491
491
  if (/CHECK constraint failed/i.test(error)) return "a row does not meet the check — repair those rows in this migration, before the statement";
492
492
  return "it passes on an empty database and fails on one with rows";
@@ -172,7 +172,8 @@ async function buildAndLoadSchema(schemaPath, tableNames) {
172
172
  format: "esm",
173
173
  platform: "node",
174
174
  packages: "external",
175
- target: "node18"
175
+ target: "node18",
176
+ logLevel: "silent"
176
177
  });
177
178
  if (result.outputFiles?.length !== 1) throw new Error(`Unexpected esbuild output for ${schemaPath}`);
178
179
  const tempDir = resolveTempDir(schemaPath);
@@ -3,6 +3,8 @@ import { SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
3
3
  import { Kysely } from "kysely";
4
4
  import { DatabaseSync } from "node:sqlite";
5
5
  //#region src/testing/index.d.ts
6
+ /** `node:sqlite`, loaded without Node 22's experimental notice: for a test that opens a database of its own. */
7
+ export declare const loadSqlite: () => typeof import('node:sqlite');
6
8
  type Schema = Record<string, SQLiteTableWithColumns<any>>;
7
9
  export interface CreateTestDatabaseOptions {
8
10
  /**
@@ -6,7 +6,25 @@ import { c as tenantOfInstanceKey, i as createActionOutbox, t as createKyselyFro
6
6
  import { i as generateSnapshotFromSchema, n as createEmptySnapshot, r as generateMigrationStatements } from "../snapshot-CY4FLqAo.js";
7
7
  import { createRequire } from "node:module";
8
8
  //#region src/testing/index.ts
9
- const loadSqlite = () => createRequire(import.meta.url)("node:sqlite");
9
+ let sqlite;
10
+ /** `node:sqlite`, loaded without Node 22's experimental notice: for a test that opens a database of its own. */
11
+ const loadSqlite = () => {
12
+ if (sqlite) return sqlite;
13
+ const emit = process.emitWarning;
14
+ process.emitWarning = function(warning, ...rest) {
15
+ const option = rest[0];
16
+ const type = typeof option === "string" ? option : option?.type ?? (warning instanceof Error ? warning.name : void 0);
17
+ const text = warning instanceof Error ? warning.message : String(warning);
18
+ if (type === "ExperimentalWarning" && text.startsWith("SQLite ")) return;
19
+ return emit.call(process, warning, ...rest);
20
+ };
21
+ try {
22
+ sqlite = createRequire(import.meta.url)("node:sqlite");
23
+ } finally {
24
+ process.emitWarning = emit;
25
+ }
26
+ return sqlite;
27
+ };
10
28
  /**
11
29
  * A `SqlStorage`-shaped shim over a synchronous `node:sqlite` connection — the
12
30
  * minimal surface `createKyselyFromSql` drives (`exec(sql, …params).toArray()`).
@@ -113,4 +131,4 @@ async function createTestDatabase(options) {
113
131
  };
114
132
  }
115
133
  //#endregion
116
- export { createTestDatabase };
134
+ export { createTestDatabase, loadSqlite };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "durable-db",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/eagerpatch/durable-db.git"