durable-db 0.1.1 → 0.1.3
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 +6 -6
- package/dist/cli/index.js +6 -6
- package/dist/{cli-BtEsZzHF.js → cli-EPI9dH9A.js} +6 -6
- package/dist/context/index.js +3 -3
- package/dist/{context-NjS9iv2J.js → context-Cwe1IsnH.js} +2 -2
- package/dist/db/index.js +1 -1
- package/dist/debug-DmBrUmwe.js +98 -0
- package/dist/{generator-BVwDQvKA.js → generator-DyrLOnPS.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/migrations/generator.js +2 -2
- package/dist/{parser-B05psK1k.js → parser-DCZuDQSQ.js} +1 -1
- package/dist/push-BqFhNoP2.js +8 -0
- package/dist/{push-gXPr9k-l.js → push-DbdlGawo.js} +4 -4
- package/dist/{state-CMRjqCDw.js → state-B4v8ICj8.js} +1 -1
- package/dist/{state-DCXcGtiu.js → state-BfYEMzuB.js} +2 -2
- package/dist/testing/index.js +3 -3
- package/dist/vite/durableDb.js +26 -10
- package/package.json +1 -3
- package/dist/debug-DzvNVBs5.js +0 -49
- package/dist/push-BW7sodiO.js +0 -8
package/dist/cli/bin.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "../debug-
|
|
3
|
-
import "../state-
|
|
2
|
+
import "../debug-DmBrUmwe.js";
|
|
3
|
+
import "../state-B4v8ICj8.js";
|
|
4
4
|
import "../snapshot-DMW6j2Ix.js";
|
|
5
|
-
import "../generator-
|
|
6
|
-
import "../parser-
|
|
7
|
-
import "../push-
|
|
8
|
-
import { n as registerDbCommands } from "../cli-
|
|
5
|
+
import "../generator-DyrLOnPS.js";
|
|
6
|
+
import "../parser-DCZuDQSQ.js";
|
|
7
|
+
import "../push-DbdlGawo.js";
|
|
8
|
+
import { n as registerDbCommands } from "../cli-EPI9dH9A.js";
|
|
9
9
|
import { Command } from "commander";
|
|
10
10
|
|
|
11
11
|
//#region src/cli/bin.ts
|
package/dist/cli/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "../debug-
|
|
2
|
-
import { _ as saveDevState, a as generateEpoch, c as getDevPaths, f as loadDevMigrations, l as getInstanceKey, m as loadDevState, s as getDevEpoch } from "../state-
|
|
1
|
+
import "../debug-DmBrUmwe.js";
|
|
2
|
+
import { _ as saveDevState, a as generateEpoch, c as getDevPaths, f as loadDevMigrations, l as getInstanceKey, m as loadDevState, s as getDevEpoch } from "../state-B4v8ICj8.js";
|
|
3
3
|
import "../snapshot-DMW6j2Ix.js";
|
|
4
|
-
import "../generator-
|
|
5
|
-
import "../parser-
|
|
6
|
-
import { a as loadSchema, i as discoverDatabases, n as pushOne, o as reportCliError, r as diffSchema, t as push } from "../push-
|
|
7
|
-
import { a as resetAndPush, c as generate, i as reset, l as generateOne, n as registerDbCommands, o as formatStatus, r as validate, s as status, t as createDbCommand } from "../cli-
|
|
4
|
+
import "../generator-DyrLOnPS.js";
|
|
5
|
+
import "../parser-DCZuDQSQ.js";
|
|
6
|
+
import { a as loadSchema, i as discoverDatabases, n as pushOne, o as reportCliError, r as diffSchema, t as push } from "../push-DbdlGawo.js";
|
|
7
|
+
import { a as resetAndPush, c as generate, i as reset, l as generateOne, n as registerDbCommands, o as formatStatus, r as validate, s as status, t as createDbCommand } from "../cli-EPI9dH9A.js";
|
|
8
8
|
|
|
9
9
|
export { createDbCommand, diffSchema, discoverDatabases, formatStatus, generate, generateEpoch, generateOne, getDevEpoch, getDevPaths, getInstanceKey, loadDevMigrations, loadDevState, loadSchema, push, pushOne, registerDbCommands, reportCliError, reset, resetAndPush, saveDevState, status, validate };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as init_debug, t as debugCli } from "./debug-
|
|
2
|
-
import { _ as saveDevState, a as generateEpoch, c as getDevPaths, d as init_state, f as loadDevMigrations, m as loadDevState, t as clearDatabaseDevState } from "./state-
|
|
1
|
+
import { i as init_debug, t as debugCli } from "./debug-DmBrUmwe.js";
|
|
2
|
+
import { _ as saveDevState, a as generateEpoch, c as getDevPaths, d as init_state, f as loadDevMigrations, m as loadDevState, t as clearDatabaseDevState } from "./state-B4v8ICj8.js";
|
|
3
3
|
import { a as hashSnapshot } from "./snapshot-DMW6j2Ix.js";
|
|
4
|
-
import { a as loadMigrationFiles, i as generateMigrationName, l as saveSnapshot, n as generateCreateTableSQL, s as loadSnapshot, t as buildAndLoadSchema } from "./generator-
|
|
5
|
-
import { a as resolveImportPath, o as loadViteAliases } from "./parser-
|
|
6
|
-
import { a as loadSchema, i as discoverDatabases, o as reportCliError, r as diffSchema, t as push } from "./push-
|
|
4
|
+
import { a as loadMigrationFiles, i as generateMigrationName, l as saveSnapshot, n as generateCreateTableSQL, s as loadSnapshot, t as buildAndLoadSchema } from "./generator-DyrLOnPS.js";
|
|
5
|
+
import { a as resolveImportPath, o as loadViteAliases } from "./parser-DCZuDQSQ.js";
|
|
6
|
+
import { a as loadSchema, i as discoverDatabases, o as reportCliError, r as diffSchema, t as push } from "./push-DbdlGawo.js";
|
|
7
7
|
import * as fs from "node:fs";
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
import { Command } from "commander";
|
|
@@ -322,7 +322,7 @@ async function reset(ctx = {}, options = {}) {
|
|
|
322
322
|
* Convenience function that combines reset + push
|
|
323
323
|
*/
|
|
324
324
|
async function resetAndPush(ctx = {}, options = {}) {
|
|
325
|
-
const { push: push$1 } = await import("./push-
|
|
325
|
+
const { push: push$1 } = await import("./push-BqFhNoP2.js");
|
|
326
326
|
return {
|
|
327
327
|
reset: await reset(ctx, options),
|
|
328
328
|
push: await push$1(ctx)
|
package/dist/context/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../debug-
|
|
2
|
-
import "../state-
|
|
3
|
-
import { a as setTenantIdResolver, i as hasTenantId, n as getInstanceKey, r as getTenantId, t as getDevInstanceKeySuffix } from "../context-
|
|
1
|
+
import "../debug-DmBrUmwe.js";
|
|
2
|
+
import "../state-B4v8ICj8.js";
|
|
3
|
+
import { a as setTenantIdResolver, i as hasTenantId, n as getInstanceKey, r as getTenantId, t as getDevInstanceKeySuffix } from "../context-Cwe1IsnH.js";
|
|
4
4
|
|
|
5
5
|
export { getDevInstanceKeySuffix, getInstanceKey, getTenantId, hasTenantId, setTenantIdResolver };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as __toCommonJS } from "./debug-
|
|
2
|
-
import { d as init_state, v as state_exports } from "./state-
|
|
1
|
+
import { s as __toCommonJS } from "./debug-DmBrUmwe.js";
|
|
2
|
+
import { d as init_state, v as state_exports } from "./state-B4v8ICj8.js";
|
|
3
3
|
|
|
4
4
|
//#region src/context/index.ts
|
|
5
5
|
/**
|
package/dist/db/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as init_debug, n as debugMigrations } from "../debug-
|
|
1
|
+
import { i as init_debug, n as debugMigrations } from "../debug-DmBrUmwe.js";
|
|
2
2
|
import { t as type } from "../out-on886o85.js";
|
|
3
3
|
import { n as defineDatabase } from "../defineDatabase-DXA53pG3.js";
|
|
4
4
|
import { a as createDrizzlePlugins, i as SchemaPlugin, n as DateSerializePlugin, o as dateSerializers, r as DrizzleDefaultsPlugin, t as createKyselyFromSql } from "../kysely-yPsCWEvR.js";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
9
|
+
var __export = (all, symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) {
|
|
12
|
+
__defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (symbols) {
|
|
18
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
19
|
+
}
|
|
20
|
+
return target;
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
+
key = keys[i];
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
27
|
+
__defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/utils/debug.ts
|
|
40
|
+
function readDebugEnv() {
|
|
41
|
+
if (typeof process !== "undefined" && process.env && process.env.DEBUG) return process.env.DEBUG;
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
function namespaceEnabled(namespace) {
|
|
45
|
+
const spec = readDebugEnv();
|
|
46
|
+
if (!spec) return false;
|
|
47
|
+
let enabled = false;
|
|
48
|
+
for (const raw of spec.split(/[\s,]+/)) {
|
|
49
|
+
if (!raw) continue;
|
|
50
|
+
const negated = raw[0] === "-";
|
|
51
|
+
const pattern = negated ? raw.slice(1) : raw;
|
|
52
|
+
if (!(pattern.endsWith("*") ? namespace.startsWith(pattern.slice(0, -1)) : pattern === namespace)) continue;
|
|
53
|
+
if (negated) return false;
|
|
54
|
+
enabled = true;
|
|
55
|
+
}
|
|
56
|
+
return enabled;
|
|
57
|
+
}
|
|
58
|
+
function stringify(value) {
|
|
59
|
+
if (typeof value === "string") return value;
|
|
60
|
+
try {
|
|
61
|
+
return JSON.stringify(value);
|
|
62
|
+
} catch {
|
|
63
|
+
return String(value);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function format(formatter, args) {
|
|
67
|
+
if (typeof formatter !== "string") return [formatter, ...args].map(stringify).join(" ");
|
|
68
|
+
let index = 0;
|
|
69
|
+
const formatted = formatter.replace(/%([%sdjoO])/g, (match, spec) => {
|
|
70
|
+
if (spec === "%") return "%";
|
|
71
|
+
if (index >= args.length) return match;
|
|
72
|
+
const arg = args[index++];
|
|
73
|
+
if (spec === "s") return String(arg);
|
|
74
|
+
if (spec === "d") return String(Number(arg));
|
|
75
|
+
return stringify(arg);
|
|
76
|
+
});
|
|
77
|
+
const extra = args.slice(index);
|
|
78
|
+
return extra.length ? `${formatted} ${extra.map(stringify).join(" ")}` : formatted;
|
|
79
|
+
}
|
|
80
|
+
function createDebug(namespace) {
|
|
81
|
+
const debug = ((formatter, ...args) => {
|
|
82
|
+
if (!debug.enabled) return;
|
|
83
|
+
console.error(`${namespace} ${format(formatter, args)}`);
|
|
84
|
+
});
|
|
85
|
+
debug.namespace = namespace;
|
|
86
|
+
debug.enabled = namespaceEnabled(namespace);
|
|
87
|
+
debug.extend = (subNamespace, delimiter = ":") => createDebug(`${namespace}${delimiter}${subNamespace}`);
|
|
88
|
+
return debug;
|
|
89
|
+
}
|
|
90
|
+
var debugVite, debugCli, debugMigrations;
|
|
91
|
+
var init_debug = __esmMin((() => {
|
|
92
|
+
debugVite = createDebug("database:vite");
|
|
93
|
+
debugCli = createDebug("database:cli");
|
|
94
|
+
debugMigrations = createDebug("database:migrations");
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
export { __esmMin as a, init_debug as i, debugMigrations as n, __export as o, debugVite as r, __toCommonJS as s, debugCli as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as init_debug, n as debugMigrations } from "./debug-
|
|
1
|
+
import { i as init_debug, n as debugMigrations } from "./debug-DmBrUmwe.js";
|
|
2
2
|
import { i as generateSnapshotId, n as generateMigrationStatements, o as snapshotsEqual, r as generateSnapshotFromSchema, t as createEmptySnapshot } from "./snapshot-DMW6j2Ix.js";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as path from "node:path";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./debug-
|
|
1
|
+
import "./debug-DmBrUmwe.js";
|
|
2
2
|
import { t as type } from "./out-on886o85.js";
|
|
3
3
|
import { n as defineDatabase } from "./defineDatabase-DXA53pG3.js";
|
|
4
4
|
import { a as numeric, c as table, i as integer, l as text, n as foreignKey, o as primaryKey, r as index, s as real, t as blob, u as uniqueIndex } from "./schema-IFq7ovQq.js";
|
|
5
|
-
import "./state-
|
|
6
|
-
import { a as setTenantIdResolver, i as hasTenantId, r as getTenantId } from "./context-
|
|
5
|
+
import "./state-B4v8ICj8.js";
|
|
6
|
+
import { a as setTenantIdResolver, i as hasTenantId, r as getTenantId } from "./context-Cwe1IsnH.js";
|
|
7
7
|
|
|
8
8
|
export { blob, defineDatabase, foreignKey, getTenantId, hasTenantId, index, integer, numeric, primaryKey, real, setTenantIdResolver, table, text, type, uniqueIndex };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../debug-
|
|
1
|
+
import "../debug-DmBrUmwe.js";
|
|
2
2
|
import "../snapshot-DMW6j2Ix.js";
|
|
3
|
-
import { a as loadMigrationFiles, c as parseSqlMigration, i as generateMigrationName, l as saveSnapshot, n as generateCreateTableSQL, o as loadSchemaModule, r as generateMigration, s as loadSnapshot, t as buildAndLoadSchema } from "../generator-
|
|
3
|
+
import { a as loadMigrationFiles, c as parseSqlMigration, i as generateMigrationName, l as saveSnapshot, n as generateCreateTableSQL, o as loadSchemaModule, r as generateMigration, s as loadSnapshot, t as buildAndLoadSchema } from "../generator-DyrLOnPS.js";
|
|
4
4
|
|
|
5
5
|
export { buildAndLoadSchema, generateCreateTableSQL, generateMigration, generateMigrationName, loadMigrationFiles, loadSchemaModule, loadSnapshot, parseSqlMigration, saveSnapshot };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as init_debug, t as debugCli } from "./debug-
|
|
2
|
-
import { d as init_state, f as loadDevMigrations, h as saveDevMigration, n as clearDevMigrations } from "./state-
|
|
1
|
+
import { i as init_debug, t as debugCli } from "./debug-DmBrUmwe.js";
|
|
2
|
+
import { d as init_state, f as loadDevMigrations, h as saveDevMigration, n as clearDevMigrations } from "./state-B4v8ICj8.js";
|
|
3
3
|
import { n as generateMigrationStatements, o as snapshotsEqual, r as generateSnapshotFromSchema } from "./snapshot-DMW6j2Ix.js";
|
|
4
|
-
import { s as loadSnapshot, t as buildAndLoadSchema } from "./generator-
|
|
5
|
-
import { a as resolveImportPath, i as readFile, n as parseDatabaseFile, o as loadViteAliases, r as discoverDatabaseFiles } from "./parser-
|
|
4
|
+
import { s as loadSnapshot, t as buildAndLoadSchema } from "./generator-DyrLOnPS.js";
|
|
5
|
+
import { a as resolveImportPath, i as readFile, n as parseDatabaseFile, o as loadViteAliases, r as discoverDatabaseFiles } from "./parser-DCZuDQSQ.js";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import * as crypto from "node:crypto";
|
|
8
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __esmMin, i as init_debug, o as __export, t as debugCli } from "./debug-
|
|
1
|
+
import { a as __esmMin, i as init_debug, o as __export, t as debugCli } from "./debug-DmBrUmwe.js";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./debug-
|
|
2
|
-
import { _ as saveDevState, a as generateEpoch, c as getDevPaths, d as init_state, f as loadDevMigrations, g as saveDevSnapshot, h as saveDevMigration, i as findNodeModules, l as getInstanceKey, m as loadDevState, n as clearDevMigrations, o as getDatabaseDevState, p as loadDevSnapshot, r as createEmptyDevState, s as getDevEpoch, t as clearDatabaseDevState, u as hasProdSnapshotChanged } from "./state-
|
|
1
|
+
import "./debug-DmBrUmwe.js";
|
|
2
|
+
import { _ as saveDevState, a as generateEpoch, c as getDevPaths, d as init_state, f as loadDevMigrations, g as saveDevSnapshot, h as saveDevMigration, i as findNodeModules, l as getInstanceKey, m as loadDevState, n as clearDevMigrations, o as getDatabaseDevState, p as loadDevSnapshot, r as createEmptyDevState, s as getDevEpoch, t as clearDatabaseDevState, u as hasProdSnapshotChanged } from "./state-B4v8ICj8.js";
|
|
3
3
|
|
|
4
4
|
init_state();
|
|
5
5
|
export { loadDevMigrations };
|
package/dist/testing/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../debug-
|
|
1
|
+
import "../debug-DmBrUmwe.js";
|
|
2
2
|
import { t as type } from "../out-on886o85.js";
|
|
3
3
|
import { t as ACTION_TEST_META } from "../defineDatabase-DXA53pG3.js";
|
|
4
|
-
import "../state-
|
|
5
|
-
import { a as setTenantIdResolver } from "../context-
|
|
4
|
+
import "../state-B4v8ICj8.js";
|
|
5
|
+
import { a as setTenantIdResolver } from "../context-Cwe1IsnH.js";
|
|
6
6
|
import { t as createKyselyFromSql } from "../kysely-yPsCWEvR.js";
|
|
7
7
|
import { n as generateMigrationStatements, r as generateSnapshotFromSchema, t as createEmptySnapshot } from "../snapshot-DMW6j2Ix.js";
|
|
8
8
|
import { createRequire } from "node:module";
|
package/dist/vite/durableDb.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as init_debug, r as debugVite } from "../debug-
|
|
2
|
-
import { _ as saveDevState, c as getDevPaths, d as init_state, m as loadDevState } from "../state-
|
|
1
|
+
import { i as init_debug, r as debugVite } from "../debug-DmBrUmwe.js";
|
|
2
|
+
import { _ as saveDevState, c as getDevPaths, d as init_state, m as loadDevState } from "../state-B4v8ICj8.js";
|
|
3
3
|
import "../snapshot-DMW6j2Ix.js";
|
|
4
|
-
import { a as loadMigrationFiles } from "../generator-
|
|
5
|
-
import { i as readFile, n as parseDatabaseFile, r as discoverDatabaseFiles, t as BABEL_PARSER_PLUGINS } from "../parser-
|
|
4
|
+
import { a as loadMigrationFiles } from "../generator-DyrLOnPS.js";
|
|
5
|
+
import { i as readFile, n as parseDatabaseFile, r as discoverDatabaseFiles, t as BABEL_PARSER_PLUGINS } from "../parser-DCZuDQSQ.js";
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { parse } from "@babel/parser";
|
|
@@ -272,6 +272,7 @@ const generate = typeof _generate === "function" ? _generate : _generate.default
|
|
|
272
272
|
* is the identity function.
|
|
273
273
|
*/
|
|
274
274
|
const DEV_EPOCH_IMPORT = "virtual:durable-db/__devEpoch";
|
|
275
|
+
const ARKTYPE_LOCAL = "__ddType";
|
|
275
276
|
function parseProgram(code) {
|
|
276
277
|
return parse(code, {
|
|
277
278
|
sourceType: "module",
|
|
@@ -286,8 +287,17 @@ function parseExpression(code) {
|
|
|
286
287
|
if (t.isExpressionStatement(stmt)) return stmt.expression;
|
|
287
288
|
throw new Error(`Expected expression, got ${stmt?.type ?? "unknown"}`);
|
|
288
289
|
}
|
|
290
|
+
function asImportName(n) {
|
|
291
|
+
return typeof n === "string" ? {
|
|
292
|
+
imported: n,
|
|
293
|
+
local: n
|
|
294
|
+
} : n;
|
|
295
|
+
}
|
|
289
296
|
function createNamedImport(names, source) {
|
|
290
|
-
const specifiers = names.map((
|
|
297
|
+
const specifiers = names.map((n) => {
|
|
298
|
+
const { imported, local } = asImportName(n);
|
|
299
|
+
return t.importSpecifier(t.identifier(local), t.identifier(imported));
|
|
300
|
+
});
|
|
291
301
|
return t.importDeclaration(specifiers, t.stringLiteral(source));
|
|
292
302
|
}
|
|
293
303
|
function ensureNamedImports(body, source, names) {
|
|
@@ -299,7 +309,10 @@ function ensureNamedImports(body, source, names) {
|
|
|
299
309
|
return;
|
|
300
310
|
}
|
|
301
311
|
const have = new Set(existing.specifiers.filter((sp) => t.isImportSpecifier(sp)).map((sp) => sp.imported.name));
|
|
302
|
-
for (const n of names)
|
|
312
|
+
for (const n of names) {
|
|
313
|
+
const { imported, local } = asImportName(n);
|
|
314
|
+
if (!have.has(imported)) existing.specifiers.push(t.importSpecifier(t.identifier(local), t.identifier(imported)));
|
|
315
|
+
}
|
|
303
316
|
}
|
|
304
317
|
function buildMigrationsObject(migrations) {
|
|
305
318
|
if (!migrations || migrations.size === 0) return t.objectExpression([]);
|
|
@@ -571,7 +584,7 @@ function buildStubBodyStatements(config) {
|
|
|
571
584
|
const bindingExpr = t.memberExpression(t.identifier("env"), t.identifier(database.bindingName));
|
|
572
585
|
const instanceKeyExpr = buildInstanceKeyExpr(database);
|
|
573
586
|
const commonStatements = [
|
|
574
|
-
t.variableDeclaration("const", [t.variableDeclarator(t.identifier("argsSchema"), t.callExpression(t.identifier(
|
|
587
|
+
t.variableDeclaration("const", [t.variableDeclarator(t.identifier("argsSchema"), t.callExpression(t.identifier(ARKTYPE_LOCAL), [parseExpression(action.argsSchemaSource)]))]),
|
|
575
588
|
t.variableDeclaration("const", [t.variableDeclarator(t.identifier("validatedArgs"), t.callExpression(t.memberExpression(t.identifier("argsSchema"), t.identifier("assert")), [t.identifier("args")]))]),
|
|
576
589
|
...buildDoShortPath(config),
|
|
577
590
|
t.variableDeclaration("const", [t.variableDeclarator(t.identifier("instanceKey"), instanceKeyExpr)]),
|
|
@@ -603,7 +616,10 @@ function applyActionTransforms(body, ctx) {
|
|
|
603
616
|
"registerAction",
|
|
604
617
|
"getDoContext",
|
|
605
618
|
"callAction",
|
|
606
|
-
|
|
619
|
+
{
|
|
620
|
+
imported: "type",
|
|
621
|
+
local: ARKTYPE_LOCAL
|
|
622
|
+
}
|
|
607
623
|
]);
|
|
608
624
|
ensureNamedImports(body, DEV_EPOCH_IMPORT, ["applyDevEpoch"]);
|
|
609
625
|
if (database.transport === "websocket") ensureNamedImports(body, "durable-db/transport/websocket", ["WebSocketTransport"]);
|
|
@@ -626,7 +642,7 @@ function applyActionTransforms(body, ctx) {
|
|
|
626
642
|
const action = actionsInFile.find((a) => a.exportName === exportName);
|
|
627
643
|
const validatorId = t.identifier(`__validator_${exportName}`);
|
|
628
644
|
const handlerId = t.identifier(`__handler_${exportName}`);
|
|
629
|
-
replaced.push(t.variableDeclaration("const", [t.variableDeclarator(validatorId, t.callExpression(t.identifier(
|
|
645
|
+
replaced.push(t.variableDeclaration("const", [t.variableDeclarator(validatorId, t.callExpression(t.identifier(ARKTYPE_LOCAL), [parseExpression(action.argsSchemaSource)]))]));
|
|
630
646
|
replaced.push(t.variableDeclaration("const", [t.variableDeclarator(handlerId, parseExpression(action.handlerSource))]));
|
|
631
647
|
replaced.push(t.expressionStatement(t.callExpression(t.identifier("registerAction"), [
|
|
632
648
|
t.stringLiteral(dbName),
|
|
@@ -845,7 +861,7 @@ var PluginState = class {
|
|
|
845
861
|
const isDev = this.config.command === "serve";
|
|
846
862
|
db.migrations = loadMigrationFiles(migrationsDir);
|
|
847
863
|
if (isDev) try {
|
|
848
|
-
const { loadDevMigrations } = await import("../state-
|
|
864
|
+
const { loadDevMigrations } = await import("../state-BfYEMzuB.js");
|
|
849
865
|
const devMigrations = loadDevMigrations(this.projectRoot, db.name);
|
|
850
866
|
for (const [name, chunks] of devMigrations) db.migrations.set(`_dev_${name}`, chunks);
|
|
851
867
|
if (devMigrations.size > 0) debugVite("Loaded %d dev migration(s) for %s", devMigrations.size, db.name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "durable-db",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/eagerpatch/durable-db.git"
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"@outerbase/browsable-durable-object": "^0.1.0",
|
|
78
78
|
"arktype": "^2.1.28",
|
|
79
79
|
"commander": "^13.1.0",
|
|
80
|
-
"debug": "^4.4.3",
|
|
81
80
|
"drizzle-kit": "^0.30.0",
|
|
82
81
|
"drizzle-orm": "^0.38.0",
|
|
83
82
|
"esbuild": "^0.27.1",
|
|
@@ -98,7 +97,6 @@
|
|
|
98
97
|
"@cloudflare/workers-types": "^4.20241127.0",
|
|
99
98
|
"@types/babel__generator": "^7.6.8",
|
|
100
99
|
"@types/babel__traverse": "^7.20.6",
|
|
101
|
-
"@types/debug": "^4.1.12",
|
|
102
100
|
"@types/node": "^24.0.0",
|
|
103
101
|
"drizzle-kit": "^0.30.0",
|
|
104
102
|
"esbuild": "^0.27.1",
|
package/dist/debug-DzvNVBs5.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import createDebug from "debug";
|
|
3
|
-
|
|
4
|
-
//#region rolldown:runtime
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
10
|
-
var __export = (all, symbols) => {
|
|
11
|
-
let target = {};
|
|
12
|
-
for (var name in all) {
|
|
13
|
-
__defProp(target, name, {
|
|
14
|
-
get: all[name],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
if (symbols) {
|
|
19
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
20
|
-
}
|
|
21
|
-
return target;
|
|
22
|
-
};
|
|
23
|
-
var __copyProps = (to, from, except, desc) => {
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
26
|
-
key = keys[i];
|
|
27
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
28
|
-
__defProp(to, key, {
|
|
29
|
-
get: ((k) => from[k]).bind(null, key),
|
|
30
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return to;
|
|
36
|
-
};
|
|
37
|
-
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/utils/debug.ts
|
|
41
|
-
var debugVite, debugCli, debugMigrations;
|
|
42
|
-
var init_debug = __esmMin((() => {
|
|
43
|
-
debugVite = createDebug("database:vite");
|
|
44
|
-
debugCli = createDebug("database:cli");
|
|
45
|
-
debugMigrations = createDebug("database:migrations");
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { __esmMin as a, init_debug as i, debugMigrations as n, __export as o, debugVite as r, __toCommonJS as s, debugCli as t };
|
package/dist/push-BW7sodiO.js
DELETED