@zenstackhq/orm 3.5.5 → 3.6.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/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/dialects/mysql.cjs +8 -30
- package/dist/dialects/mysql.d.cts +2 -1
- package/dist/dialects/mysql.d.mts +2 -0
- package/dist/dialects/mysql.mjs +2 -0
- package/dist/dialects/postgres.cjs +8 -30
- package/dist/dialects/postgres.d.cts +2 -1
- package/dist/dialects/postgres.d.mts +2 -0
- package/dist/dialects/postgres.mjs +2 -0
- package/dist/dialects/sql.js.cjs +61 -101
- package/dist/dialects/sql.js.cjs.map +1 -1
- package/dist/dialects/sql.js.d.cts +25 -21
- package/dist/dialects/sql.js.d.mts +36 -0
- package/dist/dialects/sql.js.mjs +66 -0
- package/dist/dialects/sql.js.mjs.map +1 -0
- package/dist/dialects/sqlite.cjs +8 -30
- package/dist/dialects/sqlite.d.cts +2 -1
- package/dist/dialects/sqlite.d.mts +2 -0
- package/dist/dialects/sqlite.mjs +2 -0
- package/dist/helpers.cjs +8 -30
- package/dist/helpers.d.cts +2 -1
- package/dist/helpers.d.mts +2 -0
- package/dist/helpers.mjs +2 -0
- package/dist/index.cjs +7583 -10108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2488 -2628
- package/dist/index.d.mts +3219 -0
- package/dist/index.mjs +7746 -0
- package/dist/index.mjs.map +1 -0
- package/dist/schema.cjs +8 -24
- package/dist/schema.d.cts +3 -2
- package/dist/schema.d.mts +3 -0
- package/dist/schema.mjs +2 -0
- package/package.json +25 -24
- package/dist/dialects/mysql.cjs.map +0 -1
- package/dist/dialects/mysql.d.ts +0 -1
- package/dist/dialects/mysql.js +0 -6
- package/dist/dialects/mysql.js.map +0 -1
- package/dist/dialects/postgres.cjs.map +0 -1
- package/dist/dialects/postgres.d.ts +0 -1
- package/dist/dialects/postgres.js +0 -6
- package/dist/dialects/postgres.js.map +0 -1
- package/dist/dialects/sql.js.d.ts +0 -32
- package/dist/dialects/sql.js.js +0 -83
- package/dist/dialects/sql.js.js.map +0 -1
- package/dist/dialects/sqlite.cjs.map +0 -1
- package/dist/dialects/sqlite.d.ts +0 -1
- package/dist/dialects/sqlite.js +0 -6
- package/dist/dialects/sqlite.js.map +0 -1
- package/dist/helpers.cjs.map +0 -1
- package/dist/helpers.d.ts +0 -1
- package/dist/helpers.js +0 -6
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -3359
- package/dist/index.js +0 -10306
- package/dist/index.js.map +0 -1
- package/dist/schema.cjs.map +0 -1
- package/dist/schema.d.ts +0 -2
- package/dist/schema.js +0 -3
- package/dist/schema.js.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
package/dist/dialects/mysql.cjs
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/dialects/mysql.ts
|
|
21
|
-
var mysql_exports = {};
|
|
22
|
-
__export(mysql_exports, {
|
|
23
|
-
MysqlDialect: () => import_kysely.MysqlDialect
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../index.cjs");
|
|
3
|
+
let kysely = require("kysely");
|
|
4
|
+
Object.defineProperty(exports, "MysqlDialect", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return kysely.MysqlDialect;
|
|
8
|
+
}
|
|
24
9
|
});
|
|
25
|
-
module.exports = __toCommonJS(mysql_exports);
|
|
26
|
-
var import_kysely = require("kysely");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
MysqlDialect
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=mysql.cjs.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { MysqlDialect, MysqlDialectConfig } from "kysely";
|
|
2
|
+
export { MysqlDialect, type MysqlDialectConfig };
|
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/dialects/postgres.ts
|
|
21
|
-
var postgres_exports = {};
|
|
22
|
-
__export(postgres_exports, {
|
|
23
|
-
PostgresDialect: () => import_kysely.PostgresDialect
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../index.cjs");
|
|
3
|
+
let kysely = require("kysely");
|
|
4
|
+
Object.defineProperty(exports, "PostgresDialect", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return kysely.PostgresDialect;
|
|
8
|
+
}
|
|
24
9
|
});
|
|
25
|
-
module.exports = __toCommonJS(postgres_exports);
|
|
26
|
-
var import_kysely = require("kysely");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
PostgresDialect
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=postgres.cjs.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { PostgresDialect, PostgresDialectConfig } from "kysely";
|
|
2
|
+
export { PostgresDialect, type PostgresDialectConfig };
|
package/dist/dialects/sql.js.cjs
CHANGED
|
@@ -1,108 +1,68 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/dialects/sql.js/index.ts
|
|
22
|
-
var sql_exports = {};
|
|
23
|
-
__export(sql_exports, {
|
|
24
|
-
SqlJsDialect: () => SqlJsDialect
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(sql_exports);
|
|
27
|
-
|
|
28
|
-
// src/dialects/sql.js/dialect.ts
|
|
29
|
-
var import_kysely2 = require("kysely");
|
|
30
|
-
|
|
31
|
-
// src/dialects/sql.js/driver.ts
|
|
32
|
-
var import_kysely = require("kysely");
|
|
33
|
-
|
|
34
|
-
// src/dialects/sql.js/connection.ts
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../index.cjs");
|
|
3
|
+
let kysely = require("kysely");
|
|
4
|
+
//#region src/dialects/sql.js/connection.ts
|
|
35
5
|
var SqlJsConnection = class {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// eslint-disable-next-line require-yield
|
|
55
|
-
async *streamQuery() {
|
|
56
|
-
throw new Error("Not supported with SQLite");
|
|
57
|
-
}
|
|
6
|
+
database;
|
|
7
|
+
constructor(database) {
|
|
8
|
+
this.database = database;
|
|
9
|
+
}
|
|
10
|
+
async executeQuery(compiledQuery) {
|
|
11
|
+
const executeResult = this.database.exec(compiledQuery.sql, compiledQuery.parameters);
|
|
12
|
+
const rowsModified = this.database.getRowsModified();
|
|
13
|
+
return {
|
|
14
|
+
numAffectedRows: BigInt(rowsModified),
|
|
15
|
+
rows: executeResult.map(({ columns, values }) => values.map((row) => columns.reduce((acc, column, i) => ({
|
|
16
|
+
...acc,
|
|
17
|
+
[column]: row[i]
|
|
18
|
+
}), {}))).flat()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async *streamQuery() {
|
|
22
|
+
throw new Error("Not supported with SQLite");
|
|
23
|
+
}
|
|
58
24
|
};
|
|
59
|
-
|
|
60
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/dialects/sql.js/driver.ts
|
|
61
27
|
var SqlJsDriver = class {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
async init() {
|
|
85
|
-
}
|
|
86
|
-
async releaseConnection(_connection) {
|
|
87
|
-
}
|
|
28
|
+
config;
|
|
29
|
+
constructor(config) {
|
|
30
|
+
this.config = config;
|
|
31
|
+
}
|
|
32
|
+
async acquireConnection() {
|
|
33
|
+
return new SqlJsConnection(this.config.sqlJs);
|
|
34
|
+
}
|
|
35
|
+
async beginTransaction(connection) {
|
|
36
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("BEGIN"));
|
|
37
|
+
}
|
|
38
|
+
async commitTransaction(connection) {
|
|
39
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("COMMIT"));
|
|
40
|
+
}
|
|
41
|
+
async rollbackTransaction(connection) {
|
|
42
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("ROLLBACK"));
|
|
43
|
+
}
|
|
44
|
+
async destroy() {
|
|
45
|
+
this.config.sqlJs.close();
|
|
46
|
+
}
|
|
47
|
+
async init() {}
|
|
48
|
+
async releaseConnection(_connection) {}
|
|
88
49
|
};
|
|
89
|
-
|
|
90
|
-
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/dialects/sql.js/dialect.ts
|
|
52
|
+
/**
|
|
53
|
+
* The SqlJsDialect is for testing purposes only and should not be used in production.
|
|
54
|
+
*/
|
|
91
55
|
var SqlJsDialect = class {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
createDriver = /* @__PURE__ */ __name(() => new SqlJsDriver(this.config), "createDriver");
|
|
101
|
-
createIntrospector = /* @__PURE__ */ __name((db) => new import_kysely2.SqliteIntrospector(db), "createIntrospector");
|
|
102
|
-
createQueryCompiler = /* @__PURE__ */ __name(() => new import_kysely2.SqliteQueryCompiler(), "createQueryCompiler");
|
|
56
|
+
config;
|
|
57
|
+
constructor(config) {
|
|
58
|
+
this.config = config;
|
|
59
|
+
}
|
|
60
|
+
createAdapter = () => new kysely.SqliteAdapter();
|
|
61
|
+
createDriver = () => new SqlJsDriver(this.config);
|
|
62
|
+
createIntrospector = (db) => new kysely.SqliteIntrospector(db);
|
|
63
|
+
createQueryCompiler = () => new kysely.SqliteQueryCompiler();
|
|
103
64
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.SqlJsDialect = SqlJsDialect;
|
|
67
|
+
|
|
108
68
|
//# sourceMappingURL=sql.js.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sql.js.cjs","names":["CompiledQuery","SqliteAdapter","SqliteIntrospector","SqliteQueryCompiler"],"sources":["../../src/dialects/sql.js/connection.ts","../../src/dialects/sql.js/driver.ts","../../src/dialects/sql.js/dialect.ts"],"sourcesContent":["import type { DatabaseConnection, QueryResult } from 'kysely';\nimport type { BindParams, Database } from 'sql.js';\n\nimport { CompiledQuery } from 'kysely';\n\nexport class SqlJsConnection implements DatabaseConnection {\n private database: Database;\n\n constructor(database: Database) {\n this.database = database;\n }\n\n async executeQuery<R>(compiledQuery: CompiledQuery<unknown>): Promise<QueryResult<R>> {\n const executeResult = this.database.exec(compiledQuery.sql, compiledQuery.parameters as BindParams);\n const rowsModified = this.database.getRowsModified();\n return {\n numAffectedRows: BigInt(rowsModified),\n rows: executeResult\n .map(({ columns, values }) =>\n values.map((row) => columns.reduce((acc, column, i) => ({ ...acc, [column]: row[i] }), {}) as R),\n )\n .flat(),\n };\n }\n\n // eslint-disable-next-line require-yield\n async *streamQuery() {\n throw new Error('Not supported with SQLite');\n }\n}\n","import type { DatabaseConnection, Driver } from 'kysely';\n\nimport { CompiledQuery } from 'kysely';\n\nimport { SqlJsConnection } from './connection';\nimport type { SqlJsDialectConfig } from './types';\n\nexport class SqlJsDriver implements Driver {\n private config: SqlJsDialectConfig;\n\n constructor(config: SqlJsDialectConfig) {\n this.config = config;\n }\n\n async acquireConnection(): Promise<DatabaseConnection> {\n return new SqlJsConnection(this.config.sqlJs);\n }\n\n async beginTransaction(connection: DatabaseConnection): Promise<void> {\n await connection.executeQuery(CompiledQuery.raw('BEGIN'));\n }\n\n async commitTransaction(connection: DatabaseConnection): Promise<void> {\n await connection.executeQuery(CompiledQuery.raw('COMMIT'));\n }\n\n async rollbackTransaction(connection: DatabaseConnection): Promise<void> {\n await connection.executeQuery(CompiledQuery.raw('ROLLBACK'));\n }\n\n async destroy(): Promise<void> {\n this.config.sqlJs.close();\n }\n\n async init() {}\n\n async releaseConnection(_connection: DatabaseConnection): Promise<void> {}\n}\n","import type { Dialect } from 'kysely';\n\nimport type { SqlJsDialectConfig } from './types';\n\nimport { Kysely, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from 'kysely';\n\nimport { SqlJsDriver } from './driver';\n\n/**\n * The SqlJsDialect is for testing purposes only and should not be used in production.\n */\nexport class SqlJsDialect implements Dialect {\n private config: SqlJsDialectConfig;\n\n constructor(config: SqlJsDialectConfig) {\n this.config = config;\n }\n\n createAdapter = () => new SqliteAdapter();\n\n createDriver = () => new SqlJsDriver(this.config);\n\n createIntrospector = (db: Kysely<any>) => new SqliteIntrospector(db);\n\n createQueryCompiler = () => new SqliteQueryCompiler();\n}\n"],"mappings":";;;;AAKA,IAAa,kBAAb,MAA2D;CACvD;CAEA,YAAY,UAAoB;AAC5B,OAAK,WAAW;;CAGpB,MAAM,aAAgB,eAAgE;EAClF,MAAM,gBAAgB,KAAK,SAAS,KAAK,cAAc,KAAK,cAAc,WAAyB;EACnG,MAAM,eAAe,KAAK,SAAS,iBAAiB;AACpD,SAAO;GACH,iBAAiB,OAAO,aAAa;GACrC,MAAM,cACD,KAAK,EAAE,SAAS,aACb,OAAO,KAAK,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,OAAO;IAAE,GAAG;KAAM,SAAS,IAAI;IAAI,GAAG,EAAE,CAAC,CAAM,CACnG,CACA,MAAM;GACd;;CAIL,OAAO,cAAc;AACjB,QAAM,IAAI,MAAM,4BAA4B;;;;;ACpBpD,IAAa,cAAb,MAA2C;CACvC;CAEA,YAAY,QAA4B;AACpC,OAAK,SAAS;;CAGlB,MAAM,oBAAiD;AACnD,SAAO,IAAI,gBAAgB,KAAK,OAAO,MAAM;;CAGjD,MAAM,iBAAiB,YAA+C;AAClE,QAAM,WAAW,aAAaA,OAAAA,cAAc,IAAI,QAAQ,CAAC;;CAG7D,MAAM,kBAAkB,YAA+C;AACnE,QAAM,WAAW,aAAaA,OAAAA,cAAc,IAAI,SAAS,CAAC;;CAG9D,MAAM,oBAAoB,YAA+C;AACrE,QAAM,WAAW,aAAaA,OAAAA,cAAc,IAAI,WAAW,CAAC;;CAGhE,MAAM,UAAyB;AAC3B,OAAK,OAAO,MAAM,OAAO;;CAG7B,MAAM,OAAO;CAEb,MAAM,kBAAkB,aAAgD;;;;;;;ACzB5E,IAAa,eAAb,MAA6C;CACzC;CAEA,YAAY,QAA4B;AACpC,OAAK,SAAS;;CAGlB,sBAAsB,IAAIC,OAAAA,eAAe;CAEzC,qBAAqB,IAAI,YAAY,KAAK,OAAO;CAEjD,sBAAsB,OAAoB,IAAIC,OAAAA,mBAAmB,GAAG;CAEpE,4BAA4B,IAAIC,OAAAA,qBAAqB"}
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Database } from
|
|
1
|
+
import { DatabaseConnection, Dialect, Driver, Kysely, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
|
|
2
|
+
import { Database } from "sql.js";
|
|
3
3
|
|
|
4
|
+
//#region src/dialects/sql.js/types.d.ts
|
|
4
5
|
interface SqlJsDialectConfig {
|
|
5
|
-
|
|
6
|
+
sqlJs: Database;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/dialects/sql.js/driver.d.ts
|
|
8
10
|
declare class SqlJsDriver implements Driver {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config: SqlJsDialectConfig);
|
|
13
|
+
acquireConnection(): Promise<DatabaseConnection>;
|
|
14
|
+
beginTransaction(connection: DatabaseConnection): Promise<void>;
|
|
15
|
+
commitTransaction(connection: DatabaseConnection): Promise<void>;
|
|
16
|
+
rollbackTransaction(connection: DatabaseConnection): Promise<void>;
|
|
17
|
+
destroy(): Promise<void>;
|
|
18
|
+
init(): Promise<void>;
|
|
19
|
+
releaseConnection(_connection: DatabaseConnection): Promise<void>;
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/dialects/sql.js/dialect.d.ts
|
|
20
23
|
/**
|
|
21
24
|
* The SqlJsDialect is for testing purposes only and should not be used in production.
|
|
22
25
|
*/
|
|
23
26
|
declare class SqlJsDialect implements Dialect {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
private config;
|
|
28
|
+
constructor(config: SqlJsDialectConfig);
|
|
29
|
+
createAdapter: () => SqliteAdapter;
|
|
30
|
+
createDriver: () => SqlJsDriver;
|
|
31
|
+
createIntrospector: (db: Kysely<any>) => SqliteIntrospector;
|
|
32
|
+
createQueryCompiler: () => SqliteQueryCompiler;
|
|
30
33
|
}
|
|
31
|
-
|
|
34
|
+
//#endregion
|
|
32
35
|
export { SqlJsDialect, type SqlJsDialectConfig };
|
|
36
|
+
//# sourceMappingURL=sql.js.d.cts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DatabaseConnection, Dialect, Driver, Kysely, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
|
|
2
|
+
import { Database } from "sql.js";
|
|
3
|
+
|
|
4
|
+
//#region src/dialects/sql.js/types.d.ts
|
|
5
|
+
interface SqlJsDialectConfig {
|
|
6
|
+
sqlJs: Database;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/dialects/sql.js/driver.d.ts
|
|
10
|
+
declare class SqlJsDriver implements Driver {
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config: SqlJsDialectConfig);
|
|
13
|
+
acquireConnection(): Promise<DatabaseConnection>;
|
|
14
|
+
beginTransaction(connection: DatabaseConnection): Promise<void>;
|
|
15
|
+
commitTransaction(connection: DatabaseConnection): Promise<void>;
|
|
16
|
+
rollbackTransaction(connection: DatabaseConnection): Promise<void>;
|
|
17
|
+
destroy(): Promise<void>;
|
|
18
|
+
init(): Promise<void>;
|
|
19
|
+
releaseConnection(_connection: DatabaseConnection): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/dialects/sql.js/dialect.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* The SqlJsDialect is for testing purposes only and should not be used in production.
|
|
25
|
+
*/
|
|
26
|
+
declare class SqlJsDialect implements Dialect {
|
|
27
|
+
private config;
|
|
28
|
+
constructor(config: SqlJsDialectConfig);
|
|
29
|
+
createAdapter: () => SqliteAdapter;
|
|
30
|
+
createDriver: () => SqlJsDriver;
|
|
31
|
+
createIntrospector: (db: Kysely<any>) => SqliteIntrospector;
|
|
32
|
+
createQueryCompiler: () => SqliteQueryCompiler;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { SqlJsDialect, type SqlJsDialectConfig };
|
|
36
|
+
//# sourceMappingURL=sql.js.d.mts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CompiledQuery, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
|
|
2
|
+
//#region src/dialects/sql.js/connection.ts
|
|
3
|
+
var SqlJsConnection = class {
|
|
4
|
+
database;
|
|
5
|
+
constructor(database) {
|
|
6
|
+
this.database = database;
|
|
7
|
+
}
|
|
8
|
+
async executeQuery(compiledQuery) {
|
|
9
|
+
const executeResult = this.database.exec(compiledQuery.sql, compiledQuery.parameters);
|
|
10
|
+
const rowsModified = this.database.getRowsModified();
|
|
11
|
+
return {
|
|
12
|
+
numAffectedRows: BigInt(rowsModified),
|
|
13
|
+
rows: executeResult.map(({ columns, values }) => values.map((row) => columns.reduce((acc, column, i) => ({
|
|
14
|
+
...acc,
|
|
15
|
+
[column]: row[i]
|
|
16
|
+
}), {}))).flat()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async *streamQuery() {
|
|
20
|
+
throw new Error("Not supported with SQLite");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/dialects/sql.js/driver.ts
|
|
25
|
+
var SqlJsDriver = class {
|
|
26
|
+
config;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
}
|
|
30
|
+
async acquireConnection() {
|
|
31
|
+
return new SqlJsConnection(this.config.sqlJs);
|
|
32
|
+
}
|
|
33
|
+
async beginTransaction(connection) {
|
|
34
|
+
await connection.executeQuery(CompiledQuery.raw("BEGIN"));
|
|
35
|
+
}
|
|
36
|
+
async commitTransaction(connection) {
|
|
37
|
+
await connection.executeQuery(CompiledQuery.raw("COMMIT"));
|
|
38
|
+
}
|
|
39
|
+
async rollbackTransaction(connection) {
|
|
40
|
+
await connection.executeQuery(CompiledQuery.raw("ROLLBACK"));
|
|
41
|
+
}
|
|
42
|
+
async destroy() {
|
|
43
|
+
this.config.sqlJs.close();
|
|
44
|
+
}
|
|
45
|
+
async init() {}
|
|
46
|
+
async releaseConnection(_connection) {}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/dialects/sql.js/dialect.ts
|
|
50
|
+
/**
|
|
51
|
+
* The SqlJsDialect is for testing purposes only and should not be used in production.
|
|
52
|
+
*/
|
|
53
|
+
var SqlJsDialect = class {
|
|
54
|
+
config;
|
|
55
|
+
constructor(config) {
|
|
56
|
+
this.config = config;
|
|
57
|
+
}
|
|
58
|
+
createAdapter = () => new SqliteAdapter();
|
|
59
|
+
createDriver = () => new SqlJsDriver(this.config);
|
|
60
|
+
createIntrospector = (db) => new SqliteIntrospector(db);
|
|
61
|
+
createQueryCompiler = () => new SqliteQueryCompiler();
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { SqlJsDialect };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=sql.js.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql.js.mjs","names":[],"sources":["../../src/dialects/sql.js/connection.ts","../../src/dialects/sql.js/driver.ts","../../src/dialects/sql.js/dialect.ts"],"sourcesContent":["import type { DatabaseConnection, QueryResult } from 'kysely';\nimport type { BindParams, Database } from 'sql.js';\n\nimport { CompiledQuery } from 'kysely';\n\nexport class SqlJsConnection implements DatabaseConnection {\n private database: Database;\n\n constructor(database: Database) {\n this.database = database;\n }\n\n async executeQuery<R>(compiledQuery: CompiledQuery<unknown>): Promise<QueryResult<R>> {\n const executeResult = this.database.exec(compiledQuery.sql, compiledQuery.parameters as BindParams);\n const rowsModified = this.database.getRowsModified();\n return {\n numAffectedRows: BigInt(rowsModified),\n rows: executeResult\n .map(({ columns, values }) =>\n values.map((row) => columns.reduce((acc, column, i) => ({ ...acc, [column]: row[i] }), {}) as R),\n )\n .flat(),\n };\n }\n\n // eslint-disable-next-line require-yield\n async *streamQuery() {\n throw new Error('Not supported with SQLite');\n }\n}\n","import type { DatabaseConnection, Driver } from 'kysely';\n\nimport { CompiledQuery } from 'kysely';\n\nimport { SqlJsConnection } from './connection';\nimport type { SqlJsDialectConfig } from './types';\n\nexport class SqlJsDriver implements Driver {\n private config: SqlJsDialectConfig;\n\n constructor(config: SqlJsDialectConfig) {\n this.config = config;\n }\n\n async acquireConnection(): Promise<DatabaseConnection> {\n return new SqlJsConnection(this.config.sqlJs);\n }\n\n async beginTransaction(connection: DatabaseConnection): Promise<void> {\n await connection.executeQuery(CompiledQuery.raw('BEGIN'));\n }\n\n async commitTransaction(connection: DatabaseConnection): Promise<void> {\n await connection.executeQuery(CompiledQuery.raw('COMMIT'));\n }\n\n async rollbackTransaction(connection: DatabaseConnection): Promise<void> {\n await connection.executeQuery(CompiledQuery.raw('ROLLBACK'));\n }\n\n async destroy(): Promise<void> {\n this.config.sqlJs.close();\n }\n\n async init() {}\n\n async releaseConnection(_connection: DatabaseConnection): Promise<void> {}\n}\n","import type { Dialect } from 'kysely';\n\nimport type { SqlJsDialectConfig } from './types';\n\nimport { Kysely, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from 'kysely';\n\nimport { SqlJsDriver } from './driver';\n\n/**\n * The SqlJsDialect is for testing purposes only and should not be used in production.\n */\nexport class SqlJsDialect implements Dialect {\n private config: SqlJsDialectConfig;\n\n constructor(config: SqlJsDialectConfig) {\n this.config = config;\n }\n\n createAdapter = () => new SqliteAdapter();\n\n createDriver = () => new SqlJsDriver(this.config);\n\n createIntrospector = (db: Kysely<any>) => new SqliteIntrospector(db);\n\n createQueryCompiler = () => new SqliteQueryCompiler();\n}\n"],"mappings":";;AAKA,IAAa,kBAAb,MAA2D;CACvD;CAEA,YAAY,UAAoB;AAC5B,OAAK,WAAW;;CAGpB,MAAM,aAAgB,eAAgE;EAClF,MAAM,gBAAgB,KAAK,SAAS,KAAK,cAAc,KAAK,cAAc,WAAyB;EACnG,MAAM,eAAe,KAAK,SAAS,iBAAiB;AACpD,SAAO;GACH,iBAAiB,OAAO,aAAa;GACrC,MAAM,cACD,KAAK,EAAE,SAAS,aACb,OAAO,KAAK,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,OAAO;IAAE,GAAG;KAAM,SAAS,IAAI;IAAI,GAAG,EAAE,CAAC,CAAM,CACnG,CACA,MAAM;GACd;;CAIL,OAAO,cAAc;AACjB,QAAM,IAAI,MAAM,4BAA4B;;;;;ACpBpD,IAAa,cAAb,MAA2C;CACvC;CAEA,YAAY,QAA4B;AACpC,OAAK,SAAS;;CAGlB,MAAM,oBAAiD;AACnD,SAAO,IAAI,gBAAgB,KAAK,OAAO,MAAM;;CAGjD,MAAM,iBAAiB,YAA+C;AAClE,QAAM,WAAW,aAAa,cAAc,IAAI,QAAQ,CAAC;;CAG7D,MAAM,kBAAkB,YAA+C;AACnE,QAAM,WAAW,aAAa,cAAc,IAAI,SAAS,CAAC;;CAG9D,MAAM,oBAAoB,YAA+C;AACrE,QAAM,WAAW,aAAa,cAAc,IAAI,WAAW,CAAC;;CAGhE,MAAM,UAAyB;AAC3B,OAAK,OAAO,MAAM,OAAO;;CAG7B,MAAM,OAAO;CAEb,MAAM,kBAAkB,aAAgD;;;;;;;ACzB5E,IAAa,eAAb,MAA6C;CACzC;CAEA,YAAY,QAA4B;AACpC,OAAK,SAAS;;CAGlB,sBAAsB,IAAI,eAAe;CAEzC,qBAAqB,IAAI,YAAY,KAAK,OAAO;CAEjD,sBAAsB,OAAoB,IAAI,mBAAmB,GAAG;CAEpE,4BAA4B,IAAI,qBAAqB"}
|
package/dist/dialects/sqlite.cjs
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/dialects/sqlite.ts
|
|
21
|
-
var sqlite_exports = {};
|
|
22
|
-
__export(sqlite_exports, {
|
|
23
|
-
SqliteDialect: () => import_kysely.SqliteDialect
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../index.cjs");
|
|
3
|
+
let kysely = require("kysely");
|
|
4
|
+
Object.defineProperty(exports, "SqliteDialect", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return kysely.SqliteDialect;
|
|
8
|
+
}
|
|
24
9
|
});
|
|
25
|
-
module.exports = __toCommonJS(sqlite_exports);
|
|
26
|
-
var import_kysely = require("kysely");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
SqliteDialect
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=sqlite.cjs.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { SqliteDialect, SqliteDialectConfig } from "kysely";
|
|
2
|
+
export { SqliteDialect, type SqliteDialectConfig };
|
package/dist/helpers.cjs
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/helpers.ts
|
|
21
|
-
var helpers_exports = {};
|
|
22
|
-
__export(helpers_exports, {
|
|
23
|
-
sql: () => import_kysely.sql
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./index.cjs");
|
|
3
|
+
let kysely = require("kysely");
|
|
4
|
+
Object.defineProperty(exports, "sql", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function() {
|
|
7
|
+
return kysely.sql;
|
|
8
|
+
}
|
|
24
9
|
});
|
|
25
|
-
module.exports = __toCommonJS(helpers_exports);
|
|
26
|
-
var import_kysely = require("kysely");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
sql
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=helpers.cjs.map
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
export { sql };
|
package/dist/helpers.mjs
ADDED