@rivetkit/db 0.9.2 → 0.9.5
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/config-D99afWH0.d.cts +25 -0
- package/dist/config-D99afWH0.d.ts +25 -0
- package/dist/drizzle/mod.cjs +35 -30
- package/dist/drizzle/mod.cjs.map +1 -1
- package/dist/drizzle/mod.d.cts +2 -2
- package/dist/drizzle/mod.d.ts +2 -2
- package/dist/drizzle/mod.js +35 -30
- package/dist/drizzle/mod.js.map +1 -1
- package/dist/mod.cjs +37 -22
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +3 -10
- package/dist/mod.d.ts +3 -10
- package/dist/mod.js +36 -21
- package/dist/mod.js.map +1 -1
- package/package.json +2 -2
- package/dist/config-BIvph9_B.d.cts +0 -10
- package/dist/config-BIvph9_B.d.ts +0 -10
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type DatabaseProvider<DB extends RawAccess> = {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new database client for the actor.
|
|
4
|
+
* The result is passed to the actor context as `c.db`.
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
createClient: (ctx: {
|
|
8
|
+
getDatabase: () => Promise<string | unknown>;
|
|
9
|
+
}) => Promise<DB>;
|
|
10
|
+
/**
|
|
11
|
+
* Runs before the actor has started.
|
|
12
|
+
* Use this to run migrations or other setup tasks.
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
onMigrate: (client: DB) => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
type ExecuteFunction = (query: string, ...args: unknown[]) => Promise<unknown[]>;
|
|
18
|
+
type RawAccess = {
|
|
19
|
+
/**
|
|
20
|
+
* Executes a raw SQL query.
|
|
21
|
+
*/
|
|
22
|
+
execute: ExecuteFunction;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { DatabaseProvider as D, RawAccess as R };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type DatabaseProvider<DB extends RawAccess> = {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new database client for the actor.
|
|
4
|
+
* The result is passed to the actor context as `c.db`.
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
createClient: (ctx: {
|
|
8
|
+
getDatabase: () => Promise<string | unknown>;
|
|
9
|
+
}) => Promise<DB>;
|
|
10
|
+
/**
|
|
11
|
+
* Runs before the actor has started.
|
|
12
|
+
* Use this to run migrations or other setup tasks.
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
onMigrate: (client: DB) => void | Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
type ExecuteFunction = (query: string, ...args: unknown[]) => Promise<unknown[]>;
|
|
18
|
+
type RawAccess = {
|
|
19
|
+
/**
|
|
20
|
+
* Executes a raw SQL query.
|
|
21
|
+
*/
|
|
22
|
+
execute: ExecuteFunction;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { DatabaseProvider as D, RawAccess as R };
|
package/dist/drizzle/mod.cjs
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
2
|
-
var _bettersqlite3 = require('better-sqlite3'); var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }// src/drizzle/mod.ts
|
|
2
|
+
var _bettersqlite3 = require('better-sqlite3'); var _bettersqlite32 = _interopRequireDefault(_bettersqlite3);
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _bettersqlite33 = require('drizzle-orm/better-sqlite3');
|
|
6
6
|
var _durablesqlite = require('drizzle-orm/durable-sqlite');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
7
|
var _migrator = require('drizzle-orm/durable-sqlite/migrator');
|
|
11
8
|
var _sqlitecore = require('drizzle-orm/sqlite-core'); _createStarExport(_sqlitecore);
|
|
12
9
|
var _drizzlekit = require('drizzle-kit');
|
|
@@ -18,34 +15,42 @@ function defineConfig(config) {
|
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
function db(config) {
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
18
|
+
return {
|
|
19
|
+
createClient: async (ctx) => {
|
|
20
|
+
if (!ctx.getDatabase) {
|
|
21
|
+
throw new Error("createDatabase method is not available in context.");
|
|
22
|
+
}
|
|
23
|
+
const conn = await ctx.getDatabase();
|
|
24
|
+
if (!conn) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"Cannot create database connection, or database feature is not enabled."
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (isSQLiteShim(conn)) {
|
|
30
|
+
const client2 = _durablesqlite.drizzle.call(void 0, conn, config);
|
|
31
|
+
return Object.assign(client2, {
|
|
32
|
+
// client.$client.exec is the underlying SQLite client
|
|
33
|
+
execute: async (query, ...args) => client2.$client.exec(query, ...args)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const client = _bettersqlite33.drizzle.call(void 0, {
|
|
37
|
+
client: new (0, _bettersqlite32.default)(conn),
|
|
38
|
+
...config
|
|
39
|
+
});
|
|
40
|
+
return Object.assign(client, {
|
|
41
|
+
execute: async (query, ...args) => client.$client.prepare(query).all(...args)
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
onMigrate: async (client) => {
|
|
45
|
+
if (config == null ? void 0 : config.migrations) {
|
|
44
46
|
await _migrator.migrate.call(void 0, client, config == null ? void 0 : config.migrations);
|
|
45
47
|
}
|
|
46
|
-
}
|
|
48
|
+
}
|
|
47
49
|
};
|
|
48
50
|
}
|
|
51
|
+
function isSQLiteShim(conn) {
|
|
52
|
+
return typeof conn === "object" && conn !== null && "exec" in conn && typeof conn.exec === "function";
|
|
53
|
+
}
|
|
49
54
|
|
|
50
55
|
|
|
51
56
|
|
package/dist/drizzle/mod.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/nathan/rivetkit/packages/db/dist/drizzle/mod.cjs","../../src/drizzle/mod.ts"],"names":["client"],"mappings":"AAAA;ACAA,
|
|
1
|
+
{"version":3,"sources":["/home/nathan/rivetkit/packages/db/dist/drizzle/mod.cjs","../../src/drizzle/mod.ts"],"names":["client"],"mappings":"AAAA;ACAA,6GAAqB;AACrB;AAEC;AAAW,4DACL;AACP,2DAA0C;AAC1C,+DAA0C;AAG1C,qFAAc;AAEd,yCAAkE;AAG3D,SAAS,YAAA,CACf,MAAA,EACS;AAGT,EAAA,OAAO,sCAAA;AAAqB,IAC3B,OAAA,EAAS,QAAA;AAAA,IACT,MAAA,EAAQ,gBAAA;AAAA,IACR,GAAG;AAAA,EACJ,CAAC,CAAA;AACF;AAYO,SAAS,EAAA,CAGf,MAAA,EAC+D;AAC/D,EAAA,OAAO;AAAA,IACN,YAAA,EAAc,MAAA,CAAO,GAAA,EAAA,GAAQ;AAE5B,MAAA,GAAA,CAAI,CAAC,GAAA,CAAI,WAAA,EAAa;AACrB,QAAA,MAAM,IAAI,KAAA,CAAM,oDAAoD,CAAA;AAAA,MACrE;AAEA,MAAA,MAAM,KAAA,EAAO,MAAM,GAAA,CAAI,WAAA,CAAY,CAAA;AAEnC,MAAA,GAAA,CAAI,CAAC,IAAA,EAAM;AACV,QAAA,MAAM,IAAI,KAAA;AAAA,UACT;AAAA,QACD,CAAA;AAAA,MACD;AAEA,MAAA,GAAA,CAAI,YAAA,CAAa,IAAI,CAAA,EAAG;AAGvB,QAAA,MAAMA,QAAAA,EAAS,oCAAA,IAAoC,EAAM,MAAM,CAAA;AAC/D,QAAA,OAAO,MAAA,CAAO,MAAA,CAAOA,OAAAA,EAAQ;AAAA;AAAA,UAE5B,OAAA,EAAS,MAAA,CAAO,KAAA,EAAA,GAAU,IAAA,EAAA,GACzBA,OAAAA,CAAO,OAAA,CAAQ,IAAA,CAAK,KAAA,EAAO,GAAG,IAAI;AAAA,QACpC,CAAqB,CAAA;AAAA,MACtB;AAGA,MAAA,MAAM,OAAA,EAAS,qCAAA;AAAc,QAC5B,MAAA,EAAQ,IAAI,4BAAA,CAAS,IAAc,CAAA;AAAA,QACnC,GAAG;AAAA,MACJ,CAAC,CAAA;AAED,MAAA,OAAO,MAAA,CAAO,MAAA,CAAO,MAAA,EAAQ;AAAA,QAC5B,OAAA,EAAS,MAAA,CAAO,KAAA,EAAA,GAAU,IAAA,EAAA,GACzB,MAAA,CAAO,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA,CAAE,GAAA,CAAI,GAAG,IAAI;AAAA,MAC3C,CAAqB,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,SAAA,EAAW,MAAA,CAAO,MAAA,EAAA,GAAW;AAE5B,MAAA,GAAA,CAAI,OAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,MAAA,CAAQ,UAAA,EAAY;AACvB,QAAA,MAAM,+BAAA,MAAe,EAAQ,OAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,MAAA,CAAQ,UAAU,CAAA;AAAA,MAChD;AAAA,IACD;AAAA,EACD,CAAA;AACD;AAEA,SAAS,YAAA,CAAa,IAAA,EAAmC;AACxD,EAAA,OACC,OAAO,KAAA,IAAS,SAAA,GAChB,KAAA,IAAS,KAAA,GACT,OAAA,GAAU,KAAA,GACV,OAAQ,IAAA,CAAa,KAAA,IAAS,UAAA;AAEhC;ADzCA;AACE;AACA;AACF,qDAAC","file":"/home/nathan/rivetkit/packages/db/dist/drizzle/mod.cjs","sourcesContent":[null,"import Database from \"better-sqlite3\";\nimport {\n\ttype BetterSQLite3Database,\n\tdrizzle as sqliteDrizzle,\n} from \"drizzle-orm/better-sqlite3\";\nimport { drizzle as durableDrizzle } from \"drizzle-orm/durable-sqlite\";\nimport { migrate as durableMigrate } from \"drizzle-orm/durable-sqlite/migrator\";\nimport type { DatabaseProvider, RawAccess } from \"@/config\";\n\nexport * from \"drizzle-orm/sqlite-core\";\n\nimport { type Config, defineConfig as originalDefineConfig } from \"drizzle-kit\";\nimport type { SQLiteShim } from \"@/utils\";\n\nexport function defineConfig(\n\tconfig: Partial<Config & { driver: \"durable-sqlite\" }>,\n): Config {\n\t// This is a workaround to avoid the \"drizzle-kit\" import issue in the examples.\n\t// It allows us to use the same defineConfig function in both the main package and the examples.\n\treturn originalDefineConfig({\n\t\tdialect: \"sqlite\",\n\t\tdriver: \"durable-sqlite\",\n\t\t...config,\n\t});\n}\n\ninterface DatabaseFactoryConfig<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> {\n\t/**\n\t * The database schema.\n\t */\n\tschema?: TSchema;\n\tmigrations?: any;\n}\n\nexport function db<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n>(\n\tconfig?: DatabaseFactoryConfig<TSchema>,\n): DatabaseProvider<BetterSQLite3Database<TSchema> & RawAccess> {\n\treturn {\n\t\tcreateClient: async (ctx) => {\n\t\t\t// Create a database connection using the provided context\n\t\t\tif (!ctx.getDatabase) {\n\t\t\t\tthrow new Error(\"createDatabase method is not available in context.\");\n\t\t\t}\n\n\t\t\tconst conn = await ctx.getDatabase();\n\n\t\t\tif (!conn) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Cannot create database connection, or database feature is not enabled.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (isSQLiteShim(conn)) {\n\t\t\t\t// If the connection is already an object with exec method, return it\n\t\t\t\t// i.e. in serverless environments (Cloudflare Workers)\n\t\t\t\tconst client = durableDrizzle<TSchema, SQLiteShim>(conn, config);\n\t\t\t\treturn Object.assign(client, {\n\t\t\t\t\t// client.$client.exec is the underlying SQLite client\n\t\t\t\t\texecute: async (query, ...args) =>\n\t\t\t\t\t\tclient.$client.exec(query, ...args),\n\t\t\t\t} satisfies RawAccess);\n\t\t\t}\n\n\t\t\t// Create a database client using the connection\n\t\t\tconst client = sqliteDrizzle({\n\t\t\t\tclient: new Database(conn as string),\n\t\t\t\t...config,\n\t\t\t});\n\n\t\t\treturn Object.assign(client, {\n\t\t\t\texecute: async (query, ...args) =>\n\t\t\t\t\tclient.$client.prepare(query).all(...args),\n\t\t\t} satisfies RawAccess);\n\t\t},\n\t\tonMigrate: async (client) => {\n\t\t\t// Run migrations if provided in the config\n\t\t\tif (config?.migrations) {\n\t\t\t\tawait durableMigrate(client, config?.migrations);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction isSQLiteShim(conn: unknown): conn is SQLiteShim {\n\treturn (\n\t\ttypeof conn === \"object\" &&\n\t\tconn !== null &&\n\t\t\"exec\" in conn &&\n\t\ttypeof (conn as any).exec === \"function\"\n\t);\n}\n"]}
|
package/dist/drizzle/mod.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
-
import { D as
|
|
2
|
+
import { D as DatabaseProvider, R as RawAccess } from '../config-D99afWH0.cjs';
|
|
3
3
|
export * from 'drizzle-orm/sqlite-core';
|
|
4
4
|
import { Config } from 'drizzle-kit';
|
|
5
5
|
|
|
@@ -13,6 +13,6 @@ interface DatabaseFactoryConfig<TSchema extends Record<string, unknown> = Record
|
|
|
13
13
|
schema?: TSchema;
|
|
14
14
|
migrations?: any;
|
|
15
15
|
}
|
|
16
|
-
declare function db<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DatabaseFactoryConfig<TSchema>):
|
|
16
|
+
declare function db<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DatabaseFactoryConfig<TSchema>): DatabaseProvider<BetterSQLite3Database<TSchema> & RawAccess>;
|
|
17
17
|
|
|
18
18
|
export { db, defineConfig };
|
package/dist/drizzle/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
-
import { D as
|
|
2
|
+
import { D as DatabaseProvider, R as RawAccess } from '../config-D99afWH0.js';
|
|
3
3
|
export * from 'drizzle-orm/sqlite-core';
|
|
4
4
|
import { Config } from 'drizzle-kit';
|
|
5
5
|
|
|
@@ -13,6 +13,6 @@ interface DatabaseFactoryConfig<TSchema extends Record<string, unknown> = Record
|
|
|
13
13
|
schema?: TSchema;
|
|
14
14
|
migrations?: any;
|
|
15
15
|
}
|
|
16
|
-
declare function db<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DatabaseFactoryConfig<TSchema>):
|
|
16
|
+
declare function db<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DatabaseFactoryConfig<TSchema>): DatabaseProvider<BetterSQLite3Database<TSchema> & RawAccess>;
|
|
17
17
|
|
|
18
18
|
export { db, defineConfig };
|
package/dist/drizzle/mod.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
// src/drizzle/mod.ts
|
|
2
|
-
import
|
|
2
|
+
import Database from "better-sqlite3";
|
|
3
3
|
import {
|
|
4
4
|
drizzle as sqliteDrizzle
|
|
5
5
|
} from "drizzle-orm/better-sqlite3";
|
|
6
6
|
import { drizzle as durableDrizzle } from "drizzle-orm/durable-sqlite";
|
|
7
|
-
import {
|
|
8
|
-
migrate as durableMigrate,
|
|
9
|
-
migrate as sqliteMigrate
|
|
10
|
-
} from "drizzle-orm/durable-sqlite/migrator";
|
|
7
|
+
import { migrate as durableMigrate } from "drizzle-orm/durable-sqlite/migrator";
|
|
11
8
|
export * from "drizzle-orm/sqlite-core";
|
|
12
9
|
import { defineConfig as originalDefineConfig } from "drizzle-kit";
|
|
13
10
|
function defineConfig(config) {
|
|
@@ -18,34 +15,42 @@ function defineConfig(config) {
|
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
function db(config) {
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
client: client2,
|
|
32
|
-
onMigrate: async () => {
|
|
33
|
-
await durableMigrate(client2, config == null ? void 0 : config.migrations);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const client = sqliteDrizzle({
|
|
38
|
-
client: new Database(conn),
|
|
39
|
-
...config
|
|
40
|
-
});
|
|
41
|
-
return {
|
|
42
|
-
client,
|
|
43
|
-
onMigrate: async () => {
|
|
44
|
-
await sqliteMigrate(client, config == null ? void 0 : config.migrations);
|
|
18
|
+
return {
|
|
19
|
+
createClient: async (ctx) => {
|
|
20
|
+
if (!ctx.getDatabase) {
|
|
21
|
+
throw new Error("createDatabase method is not available in context.");
|
|
22
|
+
}
|
|
23
|
+
const conn = await ctx.getDatabase();
|
|
24
|
+
if (!conn) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"Cannot create database connection, or database feature is not enabled."
|
|
27
|
+
);
|
|
45
28
|
}
|
|
46
|
-
|
|
29
|
+
if (isSQLiteShim(conn)) {
|
|
30
|
+
const client2 = durableDrizzle(conn, config);
|
|
31
|
+
return Object.assign(client2, {
|
|
32
|
+
// client.$client.exec is the underlying SQLite client
|
|
33
|
+
execute: async (query, ...args) => client2.$client.exec(query, ...args)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const client = sqliteDrizzle({
|
|
37
|
+
client: new Database(conn),
|
|
38
|
+
...config
|
|
39
|
+
});
|
|
40
|
+
return Object.assign(client, {
|
|
41
|
+
execute: async (query, ...args) => client.$client.prepare(query).all(...args)
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
onMigrate: async (client) => {
|
|
45
|
+
if (config == null ? void 0 : config.migrations) {
|
|
46
|
+
await durableMigrate(client, config == null ? void 0 : config.migrations);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
47
49
|
};
|
|
48
50
|
}
|
|
51
|
+
function isSQLiteShim(conn) {
|
|
52
|
+
return typeof conn === "object" && conn !== null && "exec" in conn && typeof conn.exec === "function";
|
|
53
|
+
}
|
|
49
54
|
export {
|
|
50
55
|
db,
|
|
51
56
|
defineConfig
|
package/dist/drizzle/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/drizzle/mod.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/drizzle/mod.ts"],"sourcesContent":["import Database from \"better-sqlite3\";\nimport {\n\ttype BetterSQLite3Database,\n\tdrizzle as sqliteDrizzle,\n} from \"drizzle-orm/better-sqlite3\";\nimport { drizzle as durableDrizzle } from \"drizzle-orm/durable-sqlite\";\nimport { migrate as durableMigrate } from \"drizzle-orm/durable-sqlite/migrator\";\nimport type { DatabaseProvider, RawAccess } from \"@/config\";\n\nexport * from \"drizzle-orm/sqlite-core\";\n\nimport { type Config, defineConfig as originalDefineConfig } from \"drizzle-kit\";\nimport type { SQLiteShim } from \"@/utils\";\n\nexport function defineConfig(\n\tconfig: Partial<Config & { driver: \"durable-sqlite\" }>,\n): Config {\n\t// This is a workaround to avoid the \"drizzle-kit\" import issue in the examples.\n\t// It allows us to use the same defineConfig function in both the main package and the examples.\n\treturn originalDefineConfig({\n\t\tdialect: \"sqlite\",\n\t\tdriver: \"durable-sqlite\",\n\t\t...config,\n\t});\n}\n\ninterface DatabaseFactoryConfig<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> {\n\t/**\n\t * The database schema.\n\t */\n\tschema?: TSchema;\n\tmigrations?: any;\n}\n\nexport function db<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n>(\n\tconfig?: DatabaseFactoryConfig<TSchema>,\n): DatabaseProvider<BetterSQLite3Database<TSchema> & RawAccess> {\n\treturn {\n\t\tcreateClient: async (ctx) => {\n\t\t\t// Create a database connection using the provided context\n\t\t\tif (!ctx.getDatabase) {\n\t\t\t\tthrow new Error(\"createDatabase method is not available in context.\");\n\t\t\t}\n\n\t\t\tconst conn = await ctx.getDatabase();\n\n\t\t\tif (!conn) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Cannot create database connection, or database feature is not enabled.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (isSQLiteShim(conn)) {\n\t\t\t\t// If the connection is already an object with exec method, return it\n\t\t\t\t// i.e. in serverless environments (Cloudflare Workers)\n\t\t\t\tconst client = durableDrizzle<TSchema, SQLiteShim>(conn, config);\n\t\t\t\treturn Object.assign(client, {\n\t\t\t\t\t// client.$client.exec is the underlying SQLite client\n\t\t\t\t\texecute: async (query, ...args) =>\n\t\t\t\t\t\tclient.$client.exec(query, ...args),\n\t\t\t\t} satisfies RawAccess);\n\t\t\t}\n\n\t\t\t// Create a database client using the connection\n\t\t\tconst client = sqliteDrizzle({\n\t\t\t\tclient: new Database(conn as string),\n\t\t\t\t...config,\n\t\t\t});\n\n\t\t\treturn Object.assign(client, {\n\t\t\t\texecute: async (query, ...args) =>\n\t\t\t\t\tclient.$client.prepare(query).all(...args),\n\t\t\t} satisfies RawAccess);\n\t\t},\n\t\tonMigrate: async (client) => {\n\t\t\t// Run migrations if provided in the config\n\t\t\tif (config?.migrations) {\n\t\t\t\tawait durableMigrate(client, config?.migrations);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction isSQLiteShim(conn: unknown): conn is SQLiteShim {\n\treturn (\n\t\ttypeof conn === \"object\" &&\n\t\tconn !== null &&\n\t\t\"exec\" in conn &&\n\t\ttypeof (conn as any).exec === \"function\"\n\t);\n}\n"],"mappings":";AAAA,OAAO,cAAc;AACrB;AAAA,EAEC,WAAW;AAAA,OACL;AACP,SAAS,WAAW,sBAAsB;AAC1C,SAAS,WAAW,sBAAsB;AAG1C,cAAc;AAEd,SAAsB,gBAAgB,4BAA4B;AAG3D,SAAS,aACf,QACS;AAGT,SAAO,qBAAqB;AAAA,IAC3B,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,GAAG;AAAA,EACJ,CAAC;AACF;AAYO,SAAS,GAGf,QAC+D;AAC/D,SAAO;AAAA,IACN,cAAc,OAAO,QAAQ;AAE5B,UAAI,CAAC,IAAI,aAAa;AACrB,cAAM,IAAI,MAAM,oDAAoD;AAAA,MACrE;AAEA,YAAM,OAAO,MAAM,IAAI,YAAY;AAEnC,UAAI,CAAC,MAAM;AACV,cAAM,IAAI;AAAA,UACT;AAAA,QACD;AAAA,MACD;AAEA,UAAI,aAAa,IAAI,GAAG;AAGvB,cAAMA,UAAS,eAAoC,MAAM,MAAM;AAC/D,eAAO,OAAO,OAAOA,SAAQ;AAAA;AAAA,UAE5B,SAAS,OAAO,UAAU,SACzBA,QAAO,QAAQ,KAAK,OAAO,GAAG,IAAI;AAAA,QACpC,CAAqB;AAAA,MACtB;AAGA,YAAM,SAAS,cAAc;AAAA,QAC5B,QAAQ,IAAI,SAAS,IAAc;AAAA,QACnC,GAAG;AAAA,MACJ,CAAC;AAED,aAAO,OAAO,OAAO,QAAQ;AAAA,QAC5B,SAAS,OAAO,UAAU,SACzB,OAAO,QAAQ,QAAQ,KAAK,EAAE,IAAI,GAAG,IAAI;AAAA,MAC3C,CAAqB;AAAA,IACtB;AAAA,IACA,WAAW,OAAO,WAAW;AAE5B,UAAI,iCAAQ,YAAY;AACvB,cAAM,eAAe,QAAQ,iCAAQ,UAAU;AAAA,MAChD;AAAA,IACD;AAAA,EACD;AACD;AAEA,SAAS,aAAa,MAAmC;AACxD,SACC,OAAO,SAAS,YAChB,SAAS,QACT,UAAU,QACV,OAAQ,KAAa,SAAS;AAEhC;","names":["client"]}
|
package/dist/mod.cjs
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
2
|
-
var _bettersqlite3 = require('better-sqlite3'); var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/mod.ts
|
|
2
|
+
var _bettersqlite3 = require('better-sqlite3'); var _bettersqlite32 = _interopRequireDefault(_bettersqlite3);
|
|
3
|
+
|
|
4
|
+
// src/utils.ts
|
|
5
|
+
function isSQLiteShim(conn) {
|
|
6
|
+
return typeof conn === "object" && conn !== null && "exec" in conn && typeof conn.exec === "function";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/mod.ts
|
|
3
10
|
function db({
|
|
4
11
|
onMigrate
|
|
5
12
|
} = {}) {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return {
|
|
14
|
+
createClient: async (ctx) => {
|
|
15
|
+
if (!ctx.getDatabase) {
|
|
16
|
+
throw new Error("createDatabase method is not available in context.");
|
|
17
|
+
}
|
|
18
|
+
const conn = await ctx.getDatabase();
|
|
19
|
+
if (!conn) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"Cannot create database connection, or database feature is not enabled."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (isSQLiteShim(conn)) {
|
|
25
|
+
return Object.assign({}, conn, {
|
|
26
|
+
execute: async (query, ...args) => {
|
|
27
|
+
return conn.exec(query, ...args);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const client = new (0, _bettersqlite32.default)(conn);
|
|
32
|
+
return Object.assign({}, client, {
|
|
33
|
+
execute: async (query, ...args) => {
|
|
34
|
+
return client.prepare(query).all(...args);
|
|
18
35
|
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onMigrate: () => {
|
|
25
|
-
onMigrate == null ? void 0 : onMigrate(client);
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
onMigrate: async (client) => {
|
|
39
|
+
if (onMigrate) {
|
|
40
|
+
await onMigrate(client);
|
|
26
41
|
}
|
|
27
|
-
}
|
|
42
|
+
}
|
|
28
43
|
};
|
|
29
44
|
}
|
|
30
45
|
|
package/dist/mod.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/nathan/rivetkit/packages/db/dist/mod.cjs","../src/mod.ts"],"names":[],"mappings":"AAAA;ACAA,
|
|
1
|
+
{"version":3,"sources":["/home/nathan/rivetkit/packages/db/dist/mod.cjs","../src/mod.ts","../src/utils.ts"],"names":[],"mappings":"AAAA;ACAA,6GAAmB;ADEnB;AACA;AEMO,SAAS,YAAA,CAAgB,IAAA,EAAuC;AACtE,EAAA,OACC,OAAO,KAAA,IAAS,SAAA,GAChB,KAAA,IAAS,KAAA,GACT,OAAA,GAAU,KAAA,GACV,OAAQ,IAAA,CAAoB,KAAA,IAAS,UAAA;AAEvC;AFTA;AACA;ACAO,SAAS,EAAA,CAAG;AAAA,EAClB;AACD,EAAA,EAA2B,CAAC,CAAA,EAAgC;AAC3D,EAAA,OAAO;AAAA,IACN,YAAA,EAAc,MAAA,CAAO,GAAA,EAAA,GAAQ;AAE5B,MAAA,GAAA,CAAI,CAAC,GAAA,CAAI,WAAA,EAAa;AACrB,QAAA,MAAM,IAAI,KAAA,CAAM,oDAAoD,CAAA;AAAA,MACrE;AAEA,MAAA,MAAM,KAAA,EAAO,MAAM,GAAA,CAAI,WAAA,CAAY,CAAA;AAEnC,MAAA,GAAA,CAAI,CAAC,IAAA,EAAM;AACV,QAAA,MAAM,IAAI,KAAA;AAAA,UACT;AAAA,QACD,CAAA;AAAA,MACD;AAEA,MAAA,GAAA,CAAI,YAAA,CAAa,IAAI,CAAA,EAAG;AAGvB,QAAA,OAAO,MAAA,CAAO,MAAA,CAAO,CAAC,CAAA,EAAG,IAAA,EAAM;AAAA,UAC9B,OAAA,EAAS,MAAA,CAAO,KAAA,EAAA,GAAU,IAAA,EAAA,GAAS;AAClC,YAAA,OAAO,IAAA,CAAK,IAAA,CAAK,KAAA,EAAO,GAAG,IAAI,CAAA;AAAA,UAChC;AAAA,QACD,CAAqB,CAAA;AAAA,MACtB;AAEA,MAAA,MAAM,OAAA,EAAS,IAAI,4BAAA,CAAO,IAAc,CAAA;AACxC,MAAA,OAAO,MAAA,CAAO,MAAA,CAAO,CAAC,CAAA,EAAG,MAAA,EAAQ;AAAA,QAChC,OAAA,EAAS,MAAA,CAAO,KAAA,EAAA,GAAU,IAAA,EAAA,GAAS;AAClC,UAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,CAAE,GAAA,CAAI,GAAG,IAAI,CAAA;AAAA,QACzC;AAAA,MACD,CAAqB,CAAA;AAAA,IACtB,CAAA;AAAA,IACA,SAAA,EAAW,MAAA,CAAO,MAAA,EAAA,GAAW;AAE5B,MAAA,GAAA,CAAI,SAAA,EAAW;AACd,QAAA,MAAM,SAAA,CAAU,MAAM,CAAA;AAAA,MACvB;AAAA,IACD;AAAA,EACD,CAAA;AACD;ADNA;AACE;AACF,gBAAC","file":"/home/nathan/rivetkit/packages/db/dist/mod.cjs","sourcesContent":[null,"import SQLite from \"better-sqlite3\";\nimport type { DatabaseProvider, RawAccess } from \"./config\";\nimport { isSQLiteShim, type SQLiteShim } from \"./utils\";\n\ninterface DatabaseFactoryConfig {\n\tonMigrate?: (db: RawAccess) => Promise<void> | void;\n}\n\nexport function db({\n\tonMigrate,\n}: DatabaseFactoryConfig = {}): DatabaseProvider<RawAccess> {\n\treturn {\n\t\tcreateClient: async (ctx) => {\n\t\t\t// Create a database connection using the provided context\n\t\t\tif (!ctx.getDatabase) {\n\t\t\t\tthrow new Error(\"createDatabase method is not available in context.\");\n\t\t\t}\n\n\t\t\tconst conn = await ctx.getDatabase();\n\n\t\t\tif (!conn) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Cannot create database connection, or database feature is not enabled.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (isSQLiteShim(conn)) {\n\t\t\t\t// If the connection is already an object with exec method, return it\n\t\t\t\t// i.e. in serverless environments (Cloudflare Workers)\n\t\t\t\treturn Object.assign({}, conn, {\n\t\t\t\t\texecute: async (query, ...args) => {\n\t\t\t\t\t\treturn conn.exec(query, ...args);\n\t\t\t\t\t},\n\t\t\t\t} satisfies RawAccess) as SQLiteShim & RawAccess;\n\t\t\t}\n\n\t\t\tconst client = new SQLite(conn as string);\n\t\t\treturn Object.assign({}, client, {\n\t\t\t\texecute: async (query, ...args) => {\n\t\t\t\t\treturn client.prepare(query).all(...args);\n\t\t\t\t},\n\t\t\t} satisfies RawAccess) as RawAccess;\n\t\t},\n\t\tonMigrate: async (client) => {\n\t\t\t// Run migrations if provided in the config\n\t\t\tif (onMigrate) {\n\t\t\t\tawait onMigrate(client);\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * On serverless environments, we use a shim, as not all methods are available.\n * This is a minimal shim that only includes the `exec` method, which is used for\n * running raw SQL commands.\n */\nexport type SQLiteShim = {\n\texec: (query: string, ...args: unknown[]) => unknown[];\n};\n\nexport function isSQLiteShim<T>(conn: unknown): conn is SQLiteShim & T {\n\treturn (\n\t\ttypeof conn === \"object\" &&\n\t\tconn !== null &&\n\t\t\"exec\" in conn &&\n\t\ttypeof (conn as SQLiteShim).exec === \"function\"\n\t);\n}\n"]}
|
package/dist/mod.d.cts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { D as DatabaseFactory } from './config-BIvph9_B.cjs';
|
|
1
|
+
import { R as RawAccess, D as DatabaseProvider } from './config-D99afWH0.cjs';
|
|
3
2
|
|
|
4
|
-
/**
|
|
5
|
-
* On serverless environments, we use a shim, as not all methods are available.
|
|
6
|
-
* This is a minimal shim that only includes the `exec` method, which is used for
|
|
7
|
-
* running raw SQL commands.
|
|
8
|
-
*/
|
|
9
|
-
type SQLiteShim = Pick<SQLite.Database, "exec">;
|
|
10
3
|
interface DatabaseFactoryConfig {
|
|
11
|
-
onMigrate?: (db:
|
|
4
|
+
onMigrate?: (db: RawAccess) => Promise<void> | void;
|
|
12
5
|
}
|
|
13
|
-
declare function db({ onMigrate, }?: DatabaseFactoryConfig):
|
|
6
|
+
declare function db({ onMigrate, }?: DatabaseFactoryConfig): DatabaseProvider<RawAccess>;
|
|
14
7
|
|
|
15
8
|
export { db };
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { D as DatabaseFactory } from './config-BIvph9_B.js';
|
|
1
|
+
import { R as RawAccess, D as DatabaseProvider } from './config-D99afWH0.js';
|
|
3
2
|
|
|
4
|
-
/**
|
|
5
|
-
* On serverless environments, we use a shim, as not all methods are available.
|
|
6
|
-
* This is a minimal shim that only includes the `exec` method, which is used for
|
|
7
|
-
* running raw SQL commands.
|
|
8
|
-
*/
|
|
9
|
-
type SQLiteShim = Pick<SQLite.Database, "exec">;
|
|
10
3
|
interface DatabaseFactoryConfig {
|
|
11
|
-
onMigrate?: (db:
|
|
4
|
+
onMigrate?: (db: RawAccess) => Promise<void> | void;
|
|
12
5
|
}
|
|
13
|
-
declare function db({ onMigrate, }?: DatabaseFactoryConfig):
|
|
6
|
+
declare function db({ onMigrate, }?: DatabaseFactoryConfig): DatabaseProvider<RawAccess>;
|
|
14
7
|
|
|
15
8
|
export { db };
|
package/dist/mod.js
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
// src/mod.ts
|
|
2
|
-
import
|
|
2
|
+
import SQLite from "better-sqlite3";
|
|
3
|
+
|
|
4
|
+
// src/utils.ts
|
|
5
|
+
function isSQLiteShim(conn) {
|
|
6
|
+
return typeof conn === "object" && conn !== null && "exec" in conn && typeof conn.exec === "function";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/mod.ts
|
|
3
10
|
function db({
|
|
4
11
|
onMigrate
|
|
5
12
|
} = {}) {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return {
|
|
14
|
+
createClient: async (ctx) => {
|
|
15
|
+
if (!ctx.getDatabase) {
|
|
16
|
+
throw new Error("createDatabase method is not available in context.");
|
|
17
|
+
}
|
|
18
|
+
const conn = await ctx.getDatabase();
|
|
19
|
+
if (!conn) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"Cannot create database connection, or database feature is not enabled."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (isSQLiteShim(conn)) {
|
|
25
|
+
return Object.assign({}, conn, {
|
|
26
|
+
execute: async (query, ...args) => {
|
|
27
|
+
return conn.exec(query, ...args);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const client = new SQLite(conn);
|
|
32
|
+
return Object.assign({}, client, {
|
|
33
|
+
execute: async (query, ...args) => {
|
|
34
|
+
return client.prepare(query).all(...args);
|
|
18
35
|
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onMigrate: () => {
|
|
25
|
-
onMigrate == null ? void 0 : onMigrate(client);
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
onMigrate: async (client) => {
|
|
39
|
+
if (onMigrate) {
|
|
40
|
+
await onMigrate(client);
|
|
26
41
|
}
|
|
27
|
-
}
|
|
42
|
+
}
|
|
28
43
|
};
|
|
29
44
|
}
|
|
30
45
|
export {
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mod.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/mod.ts","../src/utils.ts"],"sourcesContent":["import SQLite from \"better-sqlite3\";\nimport type { DatabaseProvider, RawAccess } from \"./config\";\nimport { isSQLiteShim, type SQLiteShim } from \"./utils\";\n\ninterface DatabaseFactoryConfig {\n\tonMigrate?: (db: RawAccess) => Promise<void> | void;\n}\n\nexport function db({\n\tonMigrate,\n}: DatabaseFactoryConfig = {}): DatabaseProvider<RawAccess> {\n\treturn {\n\t\tcreateClient: async (ctx) => {\n\t\t\t// Create a database connection using the provided context\n\t\t\tif (!ctx.getDatabase) {\n\t\t\t\tthrow new Error(\"createDatabase method is not available in context.\");\n\t\t\t}\n\n\t\t\tconst conn = await ctx.getDatabase();\n\n\t\t\tif (!conn) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Cannot create database connection, or database feature is not enabled.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (isSQLiteShim(conn)) {\n\t\t\t\t// If the connection is already an object with exec method, return it\n\t\t\t\t// i.e. in serverless environments (Cloudflare Workers)\n\t\t\t\treturn Object.assign({}, conn, {\n\t\t\t\t\texecute: async (query, ...args) => {\n\t\t\t\t\t\treturn conn.exec(query, ...args);\n\t\t\t\t\t},\n\t\t\t\t} satisfies RawAccess) as SQLiteShim & RawAccess;\n\t\t\t}\n\n\t\t\tconst client = new SQLite(conn as string);\n\t\t\treturn Object.assign({}, client, {\n\t\t\t\texecute: async (query, ...args) => {\n\t\t\t\t\treturn client.prepare(query).all(...args);\n\t\t\t\t},\n\t\t\t} satisfies RawAccess) as RawAccess;\n\t\t},\n\t\tonMigrate: async (client) => {\n\t\t\t// Run migrations if provided in the config\n\t\t\tif (onMigrate) {\n\t\t\t\tawait onMigrate(client);\n\t\t\t}\n\t\t},\n\t};\n}\n","/**\n * On serverless environments, we use a shim, as not all methods are available.\n * This is a minimal shim that only includes the `exec` method, which is used for\n * running raw SQL commands.\n */\nexport type SQLiteShim = {\n\texec: (query: string, ...args: unknown[]) => unknown[];\n};\n\nexport function isSQLiteShim<T>(conn: unknown): conn is SQLiteShim & T {\n\treturn (\n\t\ttypeof conn === \"object\" &&\n\t\tconn !== null &&\n\t\t\"exec\" in conn &&\n\t\ttypeof (conn as SQLiteShim).exec === \"function\"\n\t);\n}\n"],"mappings":";AAAA,OAAO,YAAY;;;ACSZ,SAAS,aAAgB,MAAuC;AACtE,SACC,OAAO,SAAS,YAChB,SAAS,QACT,UAAU,QACV,OAAQ,KAAoB,SAAS;AAEvC;;;ADRO,SAAS,GAAG;AAAA,EAClB;AACD,IAA2B,CAAC,GAAgC;AAC3D,SAAO;AAAA,IACN,cAAc,OAAO,QAAQ;AAE5B,UAAI,CAAC,IAAI,aAAa;AACrB,cAAM,IAAI,MAAM,oDAAoD;AAAA,MACrE;AAEA,YAAM,OAAO,MAAM,IAAI,YAAY;AAEnC,UAAI,CAAC,MAAM;AACV,cAAM,IAAI;AAAA,UACT;AAAA,QACD;AAAA,MACD;AAEA,UAAI,aAAa,IAAI,GAAG;AAGvB,eAAO,OAAO,OAAO,CAAC,GAAG,MAAM;AAAA,UAC9B,SAAS,OAAO,UAAU,SAAS;AAClC,mBAAO,KAAK,KAAK,OAAO,GAAG,IAAI;AAAA,UAChC;AAAA,QACD,CAAqB;AAAA,MACtB;AAEA,YAAM,SAAS,IAAI,OAAO,IAAc;AACxC,aAAO,OAAO,OAAO,CAAC,GAAG,QAAQ;AAAA,QAChC,SAAS,OAAO,UAAU,SAAS;AAClC,iBAAO,OAAO,QAAQ,KAAK,EAAE,IAAI,GAAG,IAAI;AAAA,QACzC;AAAA,MACD,CAAqB;AAAA,IACtB;AAAA,IACA,WAAW,OAAO,WAAW;AAE5B,UAAI,WAAW;AACd,cAAM,UAAU,MAAM;AAAA,MACvB;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivetkit/db",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"stableVersion": "0.8.0",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"better-sqlite3": "^11.10.0",
|
|
56
|
-
"@rivetkit/core": "0.9.
|
|
56
|
+
"@rivetkit/core": "0.9.5"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup src/mod.ts src/drizzle/mod.ts",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface DatabaseConfig<DB> {
|
|
2
|
-
client: DB;
|
|
3
|
-
onMigrate: () => void;
|
|
4
|
-
}
|
|
5
|
-
interface DatabaseFactoryContext<DB> {
|
|
6
|
-
createDatabase: () => Promise<unknown>;
|
|
7
|
-
}
|
|
8
|
-
type DatabaseFactory<DB> = (ctx: DatabaseFactoryContext<DB>) => Promise<DatabaseConfig<DB>>;
|
|
9
|
-
|
|
10
|
-
export type { DatabaseFactory as D };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface DatabaseConfig<DB> {
|
|
2
|
-
client: DB;
|
|
3
|
-
onMigrate: () => void;
|
|
4
|
-
}
|
|
5
|
-
interface DatabaseFactoryContext<DB> {
|
|
6
|
-
createDatabase: () => Promise<unknown>;
|
|
7
|
-
}
|
|
8
|
-
type DatabaseFactory<DB> = (ctx: DatabaseFactoryContext<DB>) => Promise<DatabaseConfig<DB>>;
|
|
9
|
-
|
|
10
|
-
export type { DatabaseFactory as D };
|