@danielhritcu/zenstack-orm 3.5.4

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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/dialects/mysql.cjs +31 -0
  4. package/dist/dialects/mysql.cjs.map +1 -0
  5. package/dist/dialects/mysql.d.cts +1 -0
  6. package/dist/dialects/mysql.d.ts +1 -0
  7. package/dist/dialects/mysql.js +6 -0
  8. package/dist/dialects/mysql.js.map +1 -0
  9. package/dist/dialects/postgres.cjs +31 -0
  10. package/dist/dialects/postgres.cjs.map +1 -0
  11. package/dist/dialects/postgres.d.cts +1 -0
  12. package/dist/dialects/postgres.d.ts +1 -0
  13. package/dist/dialects/postgres.js +6 -0
  14. package/dist/dialects/postgres.js.map +1 -0
  15. package/dist/dialects/sql.js.cjs +108 -0
  16. package/dist/dialects/sql.js.cjs.map +1 -0
  17. package/dist/dialects/sql.js.d.cts +32 -0
  18. package/dist/dialects/sql.js.d.ts +32 -0
  19. package/dist/dialects/sql.js.js +83 -0
  20. package/dist/dialects/sql.js.js.map +1 -0
  21. package/dist/dialects/sqlite.cjs +31 -0
  22. package/dist/dialects/sqlite.cjs.map +1 -0
  23. package/dist/dialects/sqlite.d.cts +1 -0
  24. package/dist/dialects/sqlite.d.ts +1 -0
  25. package/dist/dialects/sqlite.js +6 -0
  26. package/dist/dialects/sqlite.js.map +1 -0
  27. package/dist/helpers.cjs +31 -0
  28. package/dist/helpers.cjs.map +1 -0
  29. package/dist/helpers.d.cts +1 -0
  30. package/dist/helpers.d.ts +1 -0
  31. package/dist/helpers.js +6 -0
  32. package/dist/helpers.js.map +1 -0
  33. package/dist/index.cjs +10630 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.cts +3377 -0
  36. package/dist/index.d.ts +3377 -0
  37. package/dist/index.js +10580 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/schema.cjs +25 -0
  40. package/dist/schema.cjs.map +1 -0
  41. package/dist/schema.d.cts +2 -0
  42. package/dist/schema.d.ts +2 -0
  43. package/dist/schema.js +3 -0
  44. package/dist/schema.js.map +1 -0
  45. package/package.json +156 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ZenStack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @zenstackhq/orm
2
+
3
+ The core ZenStack ORM engine, built on top of [Kysely](https://kysely.dev/). Provides a type-safe database client (`ZenStackClient`) with a high-level, [Prisma](https://prisma.io/)-compatible CRUD API and direct access to the underlying Kysely query builder for advanced queries.
4
+
5
+ ## Key Features
6
+
7
+ - **Type-safe CRUD operations** generated from your ZModel schema
8
+ - **Plugin system** for query interception and entity mutation hooks
9
+ - **Multi-dialect support** — SQLite (better-sqlite3), PostgreSQL (pg), and MySQL (mysql2)
10
+ - **Computed fields** evaluated at the database level
11
+ - **Custom procedures** for encapsulating complex queries and mutations
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @zenstackhq/orm
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { ZenStackClient } from '@zenstackhq/orm';
23
+ import schema from './schema';
24
+
25
+ const client = new ZenStackClient(schema, {
26
+ /* dialect config */
27
+ });
28
+
29
+ const user = await client.user.findFirst({ where: { email: 'alice@example.com' } });
30
+ ```
31
+
32
+ ## Learn More
33
+
34
+ - [ZenStack Documentation](https://zenstack.dev/docs)
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
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
24
+ });
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/mysql.ts"],"sourcesContent":["export { MysqlDialect, type MysqlDialectConfig } from 'kysely';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;oBAAsD;","names":[]}
@@ -0,0 +1 @@
1
+ export { MysqlDialect, MysqlDialectConfig } from 'kysely';
@@ -0,0 +1 @@
1
+ export { MysqlDialect, MysqlDialectConfig } from 'kysely';
@@ -0,0 +1,6 @@
1
+ // src/dialects/mysql.ts
2
+ import { MysqlDialect } from "kysely";
3
+ export {
4
+ MysqlDialect
5
+ };
6
+ //# sourceMappingURL=mysql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/mysql.ts"],"sourcesContent":["export { MysqlDialect, type MysqlDialectConfig } from 'kysely';\n"],"mappings":";AAAA,SAASA,oBAA6C;","names":["MysqlDialect"]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
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
24
+ });
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/postgres.ts"],"sourcesContent":["export { PostgresDialect, type PostgresDialectConfig } from 'kysely';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;oBAA4D;","names":[]}
@@ -0,0 +1 @@
1
+ export { PostgresDialect, PostgresDialectConfig } from 'kysely';
@@ -0,0 +1 @@
1
+ export { PostgresDialect, PostgresDialectConfig } from 'kysely';
@@ -0,0 +1,6 @@
1
+ // src/dialects/postgres.ts
2
+ import { PostgresDialect } from "kysely";
3
+ export {
4
+ PostgresDialect
5
+ };
6
+ //# sourceMappingURL=postgres.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/postgres.ts"],"sourcesContent":["export { PostgresDialect, type PostgresDialectConfig } from 'kysely';\n"],"mappings":";AAAA,SAASA,uBAAmD;","names":["PostgresDialect"]}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
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
35
+ var SqlJsConnection = class {
36
+ static {
37
+ __name(this, "SqlJsConnection");
38
+ }
39
+ database;
40
+ constructor(database) {
41
+ this.database = database;
42
+ }
43
+ async executeQuery(compiledQuery) {
44
+ const executeResult = this.database.exec(compiledQuery.sql, compiledQuery.parameters);
45
+ const rowsModified = this.database.getRowsModified();
46
+ return {
47
+ numAffectedRows: BigInt(rowsModified),
48
+ rows: executeResult.map(({ columns, values }) => values.map((row) => columns.reduce((acc, column, i) => ({
49
+ ...acc,
50
+ [column]: row[i]
51
+ }), {}))).flat()
52
+ };
53
+ }
54
+ // eslint-disable-next-line require-yield
55
+ async *streamQuery() {
56
+ throw new Error("Not supported with SQLite");
57
+ }
58
+ };
59
+
60
+ // src/dialects/sql.js/driver.ts
61
+ var SqlJsDriver = class {
62
+ static {
63
+ __name(this, "SqlJsDriver");
64
+ }
65
+ config;
66
+ constructor(config) {
67
+ this.config = config;
68
+ }
69
+ async acquireConnection() {
70
+ return new SqlJsConnection(this.config.sqlJs);
71
+ }
72
+ async beginTransaction(connection) {
73
+ await connection.executeQuery(import_kysely.CompiledQuery.raw("BEGIN"));
74
+ }
75
+ async commitTransaction(connection) {
76
+ await connection.executeQuery(import_kysely.CompiledQuery.raw("COMMIT"));
77
+ }
78
+ async rollbackTransaction(connection) {
79
+ await connection.executeQuery(import_kysely.CompiledQuery.raw("ROLLBACK"));
80
+ }
81
+ async destroy() {
82
+ this.config.sqlJs.close();
83
+ }
84
+ async init() {
85
+ }
86
+ async releaseConnection(_connection) {
87
+ }
88
+ };
89
+
90
+ // src/dialects/sql.js/dialect.ts
91
+ var SqlJsDialect = class {
92
+ static {
93
+ __name(this, "SqlJsDialect");
94
+ }
95
+ config;
96
+ constructor(config) {
97
+ this.config = config;
98
+ }
99
+ createAdapter = /* @__PURE__ */ __name(() => new import_kysely2.SqliteAdapter(), "createAdapter");
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");
103
+ };
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ SqlJsDialect
107
+ });
108
+ //# sourceMappingURL=sql.js.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/sql.js/index.ts","../../src/dialects/sql.js/dialect.ts","../../src/dialects/sql.js/driver.ts","../../src/dialects/sql.js/connection.ts"],"sourcesContent":["// This module is ported from https://github.com/betarixm/kysely-sql-js by @betarixm\n\nexport { SqlJsDialect } from './dialect';\nexport type { SqlJsDialectConfig } from './types';\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","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 { 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACIA,IAAAA,iBAA+E;;;ACF/E,oBAA8B;;;ACGvB,IAAMC,kBAAN,MAAMA;EAAb,OAAaA;;;EACDC;EAER,YAAYA,UAAoB;AAC5B,SAAKA,WAAWA;EACpB;EAEA,MAAMC,aAAgBC,eAAgE;AAClF,UAAMC,gBAAgB,KAAKH,SAASI,KAAKF,cAAcG,KAAKH,cAAcI,UAAU;AACpF,UAAMC,eAAe,KAAKP,SAASQ,gBAAe;AAClD,WAAO;MACHC,iBAAiBC,OAAOH,YAAAA;MACxBI,MAAMR,cACDS,IAAI,CAAC,EAAEC,SAASC,OAAM,MACnBA,OAAOF,IAAI,CAACG,QAAQF,QAAQG,OAAO,CAACC,KAAKC,QAAQC,OAAO;QAAE,GAAGF;QAAK,CAACC,MAAAA,GAASH,IAAII,CAAAA;MAAG,IAAI,CAAC,CAAA,CAAA,CAAA,EAE3FC,KAAI;IACb;EACJ;;EAGA,OAAOC,cAAc;AACjB,UAAM,IAAIC,MAAM,2BAAA;EACpB;AACJ;;;ADtBO,IAAMC,cAAN,MAAMA;EALb,OAKaA;;;EACDC;EAER,YAAYA,QAA4B;AACpC,SAAKA,SAASA;EAClB;EAEA,MAAMC,oBAAiD;AACnD,WAAO,IAAIC,gBAAgB,KAAKF,OAAOG,KAAK;EAChD;EAEA,MAAMC,iBAAiBC,YAA+C;AAClE,UAAMA,WAAWC,aAAaC,4BAAcC,IAAI,OAAA,CAAA;EACpD;EAEA,MAAMC,kBAAkBJ,YAA+C;AACnE,UAAMA,WAAWC,aAAaC,4BAAcC,IAAI,QAAA,CAAA;EACpD;EAEA,MAAME,oBAAoBL,YAA+C;AACrE,UAAMA,WAAWC,aAAaC,4BAAcC,IAAI,UAAA,CAAA;EACpD;EAEA,MAAMG,UAAyB;AAC3B,SAAKX,OAAOG,MAAMS,MAAK;EAC3B;EAEA,MAAMC,OAAO;EAAC;EAEd,MAAMC,kBAAkBC,aAAgD;EAAC;AAC7E;;;AD1BO,IAAMC,eAAN,MAAMA;EAPb,OAOaA;;;EACDC;EAER,YAAYA,QAA4B;AACpC,SAAKA,SAASA;EAClB;EAEAC,gBAAgB,6BAAM,IAAIC,6BAAAA,GAAV;EAEhBC,eAAe,6BAAM,IAAIC,YAAY,KAAKJ,MAAM,GAAjC;EAEfK,qBAAqB,wBAACC,OAAoB,IAAIC,kCAAmBD,EAAAA,GAA5C;EAErBE,sBAAsB,6BAAM,IAAIC,mCAAAA,GAAV;AAC1B;","names":["import_kysely","SqlJsConnection","database","executeQuery","compiledQuery","executeResult","exec","sql","parameters","rowsModified","getRowsModified","numAffectedRows","BigInt","rows","map","columns","values","row","reduce","acc","column","i","flat","streamQuery","Error","SqlJsDriver","config","acquireConnection","SqlJsConnection","sqlJs","beginTransaction","connection","executeQuery","CompiledQuery","raw","commitTransaction","rollbackTransaction","destroy","close","init","releaseConnection","_connection","SqlJsDialect","config","createAdapter","SqliteAdapter","createDriver","SqlJsDriver","createIntrospector","db","SqliteIntrospector","createQueryCompiler","SqliteQueryCompiler"]}
@@ -0,0 +1,32 @@
1
+ import { Driver, DatabaseConnection, Dialect, SqliteAdapter, Kysely, SqliteIntrospector, SqliteQueryCompiler } from 'kysely';
2
+ import { Database } from 'sql.js';
3
+
4
+ interface SqlJsDialectConfig {
5
+ sqlJs: Database;
6
+ }
7
+
8
+ declare class SqlJsDriver implements Driver {
9
+ private config;
10
+ constructor(config: SqlJsDialectConfig);
11
+ acquireConnection(): Promise<DatabaseConnection>;
12
+ beginTransaction(connection: DatabaseConnection): Promise<void>;
13
+ commitTransaction(connection: DatabaseConnection): Promise<void>;
14
+ rollbackTransaction(connection: DatabaseConnection): Promise<void>;
15
+ destroy(): Promise<void>;
16
+ init(): Promise<void>;
17
+ releaseConnection(_connection: DatabaseConnection): Promise<void>;
18
+ }
19
+
20
+ /**
21
+ * The SqlJsDialect is for testing purposes only and should not be used in production.
22
+ */
23
+ declare class SqlJsDialect implements Dialect {
24
+ private config;
25
+ constructor(config: SqlJsDialectConfig);
26
+ createAdapter: () => SqliteAdapter;
27
+ createDriver: () => SqlJsDriver;
28
+ createIntrospector: (db: Kysely<any>) => SqliteIntrospector;
29
+ createQueryCompiler: () => SqliteQueryCompiler;
30
+ }
31
+
32
+ export { SqlJsDialect, type SqlJsDialectConfig };
@@ -0,0 +1,32 @@
1
+ import { Driver, DatabaseConnection, Dialect, SqliteAdapter, Kysely, SqliteIntrospector, SqliteQueryCompiler } from 'kysely';
2
+ import { Database } from 'sql.js';
3
+
4
+ interface SqlJsDialectConfig {
5
+ sqlJs: Database;
6
+ }
7
+
8
+ declare class SqlJsDriver implements Driver {
9
+ private config;
10
+ constructor(config: SqlJsDialectConfig);
11
+ acquireConnection(): Promise<DatabaseConnection>;
12
+ beginTransaction(connection: DatabaseConnection): Promise<void>;
13
+ commitTransaction(connection: DatabaseConnection): Promise<void>;
14
+ rollbackTransaction(connection: DatabaseConnection): Promise<void>;
15
+ destroy(): Promise<void>;
16
+ init(): Promise<void>;
17
+ releaseConnection(_connection: DatabaseConnection): Promise<void>;
18
+ }
19
+
20
+ /**
21
+ * The SqlJsDialect is for testing purposes only and should not be used in production.
22
+ */
23
+ declare class SqlJsDialect implements Dialect {
24
+ private config;
25
+ constructor(config: SqlJsDialectConfig);
26
+ createAdapter: () => SqliteAdapter;
27
+ createDriver: () => SqlJsDriver;
28
+ createIntrospector: (db: Kysely<any>) => SqliteIntrospector;
29
+ createQueryCompiler: () => SqliteQueryCompiler;
30
+ }
31
+
32
+ export { SqlJsDialect, type SqlJsDialectConfig };
@@ -0,0 +1,83 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/dialects/sql.js/dialect.ts
5
+ import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
6
+
7
+ // src/dialects/sql.js/driver.ts
8
+ import { CompiledQuery } from "kysely";
9
+
10
+ // src/dialects/sql.js/connection.ts
11
+ var SqlJsConnection = class {
12
+ static {
13
+ __name(this, "SqlJsConnection");
14
+ }
15
+ database;
16
+ constructor(database) {
17
+ this.database = database;
18
+ }
19
+ async executeQuery(compiledQuery) {
20
+ const executeResult = this.database.exec(compiledQuery.sql, compiledQuery.parameters);
21
+ const rowsModified = this.database.getRowsModified();
22
+ return {
23
+ numAffectedRows: BigInt(rowsModified),
24
+ rows: executeResult.map(({ columns, values }) => values.map((row) => columns.reduce((acc, column, i) => ({
25
+ ...acc,
26
+ [column]: row[i]
27
+ }), {}))).flat()
28
+ };
29
+ }
30
+ // eslint-disable-next-line require-yield
31
+ async *streamQuery() {
32
+ throw new Error("Not supported with SQLite");
33
+ }
34
+ };
35
+
36
+ // src/dialects/sql.js/driver.ts
37
+ var SqlJsDriver = class {
38
+ static {
39
+ __name(this, "SqlJsDriver");
40
+ }
41
+ config;
42
+ constructor(config) {
43
+ this.config = config;
44
+ }
45
+ async acquireConnection() {
46
+ return new SqlJsConnection(this.config.sqlJs);
47
+ }
48
+ async beginTransaction(connection) {
49
+ await connection.executeQuery(CompiledQuery.raw("BEGIN"));
50
+ }
51
+ async commitTransaction(connection) {
52
+ await connection.executeQuery(CompiledQuery.raw("COMMIT"));
53
+ }
54
+ async rollbackTransaction(connection) {
55
+ await connection.executeQuery(CompiledQuery.raw("ROLLBACK"));
56
+ }
57
+ async destroy() {
58
+ this.config.sqlJs.close();
59
+ }
60
+ async init() {
61
+ }
62
+ async releaseConnection(_connection) {
63
+ }
64
+ };
65
+
66
+ // src/dialects/sql.js/dialect.ts
67
+ var SqlJsDialect = class {
68
+ static {
69
+ __name(this, "SqlJsDialect");
70
+ }
71
+ config;
72
+ constructor(config) {
73
+ this.config = config;
74
+ }
75
+ createAdapter = /* @__PURE__ */ __name(() => new SqliteAdapter(), "createAdapter");
76
+ createDriver = /* @__PURE__ */ __name(() => new SqlJsDriver(this.config), "createDriver");
77
+ createIntrospector = /* @__PURE__ */ __name((db) => new SqliteIntrospector(db), "createIntrospector");
78
+ createQueryCompiler = /* @__PURE__ */ __name(() => new SqliteQueryCompiler(), "createQueryCompiler");
79
+ };
80
+ export {
81
+ SqlJsDialect
82
+ };
83
+ //# sourceMappingURL=sql.js.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/sql.js/dialect.ts","../../src/dialects/sql.js/driver.ts","../../src/dialects/sql.js/connection.ts"],"sourcesContent":["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","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 { 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"],"mappings":";;;;AAIA,SAAiBA,eAAeC,oBAAoBC,2BAA2B;;;ACF/E,SAASC,qBAAqB;;;ACGvB,IAAMC,kBAAN,MAAMA;EAAb,OAAaA;;;EACDC;EAER,YAAYA,UAAoB;AAC5B,SAAKA,WAAWA;EACpB;EAEA,MAAMC,aAAgBC,eAAgE;AAClF,UAAMC,gBAAgB,KAAKH,SAASI,KAAKF,cAAcG,KAAKH,cAAcI,UAAU;AACpF,UAAMC,eAAe,KAAKP,SAASQ,gBAAe;AAClD,WAAO;MACHC,iBAAiBC,OAAOH,YAAAA;MACxBI,MAAMR,cACDS,IAAI,CAAC,EAAEC,SAASC,OAAM,MACnBA,OAAOF,IAAI,CAACG,QAAQF,QAAQG,OAAO,CAACC,KAAKC,QAAQC,OAAO;QAAE,GAAGF;QAAK,CAACC,MAAAA,GAASH,IAAII,CAAAA;MAAG,IAAI,CAAC,CAAA,CAAA,CAAA,EAE3FC,KAAI;IACb;EACJ;;EAGA,OAAOC,cAAc;AACjB,UAAM,IAAIC,MAAM,2BAAA;EACpB;AACJ;;;ADtBO,IAAMC,cAAN,MAAMA;EALb,OAKaA;;;EACDC;EAER,YAAYA,QAA4B;AACpC,SAAKA,SAASA;EAClB;EAEA,MAAMC,oBAAiD;AACnD,WAAO,IAAIC,gBAAgB,KAAKF,OAAOG,KAAK;EAChD;EAEA,MAAMC,iBAAiBC,YAA+C;AAClE,UAAMA,WAAWC,aAAaC,cAAcC,IAAI,OAAA,CAAA;EACpD;EAEA,MAAMC,kBAAkBJ,YAA+C;AACnE,UAAMA,WAAWC,aAAaC,cAAcC,IAAI,QAAA,CAAA;EACpD;EAEA,MAAME,oBAAoBL,YAA+C;AACrE,UAAMA,WAAWC,aAAaC,cAAcC,IAAI,UAAA,CAAA;EACpD;EAEA,MAAMG,UAAyB;AAC3B,SAAKX,OAAOG,MAAMS,MAAK;EAC3B;EAEA,MAAMC,OAAO;EAAC;EAEd,MAAMC,kBAAkBC,aAAgD;EAAC;AAC7E;;;AD1BO,IAAMC,eAAN,MAAMA;EAPb,OAOaA;;;EACDC;EAER,YAAYA,QAA4B;AACpC,SAAKA,SAASA;EAClB;EAEAC,gBAAgB,6BAAM,IAAIC,cAAAA,GAAV;EAEhBC,eAAe,6BAAM,IAAIC,YAAY,KAAKJ,MAAM,GAAjC;EAEfK,qBAAqB,wBAACC,OAAoB,IAAIC,mBAAmBD,EAAAA,GAA5C;EAErBE,sBAAsB,6BAAM,IAAIC,oBAAAA,GAAV;AAC1B;","names":["SqliteAdapter","SqliteIntrospector","SqliteQueryCompiler","CompiledQuery","SqlJsConnection","database","executeQuery","compiledQuery","executeResult","exec","sql","parameters","rowsModified","getRowsModified","numAffectedRows","BigInt","rows","map","columns","values","row","reduce","acc","column","i","flat","streamQuery","Error","SqlJsDriver","config","acquireConnection","SqlJsConnection","sqlJs","beginTransaction","connection","executeQuery","CompiledQuery","raw","commitTransaction","rollbackTransaction","destroy","close","init","releaseConnection","_connection","SqlJsDialect","config","createAdapter","SqliteAdapter","createDriver","SqlJsDriver","createIntrospector","db","SqliteIntrospector","createQueryCompiler","SqliteQueryCompiler"]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
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
24
+ });
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/sqlite.ts"],"sourcesContent":["export { SqliteDialect, type SqliteDialectConfig } from 'kysely';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;oBAAwD;","names":[]}
@@ -0,0 +1 @@
1
+ export { SqliteDialect, SqliteDialectConfig } from 'kysely';
@@ -0,0 +1 @@
1
+ export { SqliteDialect, SqliteDialectConfig } from 'kysely';
@@ -0,0 +1,6 @@
1
+ // src/dialects/sqlite.ts
2
+ import { SqliteDialect } from "kysely";
3
+ export {
4
+ SqliteDialect
5
+ };
6
+ //# sourceMappingURL=sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/dialects/sqlite.ts"],"sourcesContent":["export { SqliteDialect, type SqliteDialectConfig } from 'kysely';\n"],"mappings":";AAAA,SAASA,qBAA+C;","names":["SqliteDialect"]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
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
24
+ });
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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers.ts"],"sourcesContent":["export { sql } from 'kysely';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;oBAAoB;","names":[]}
@@ -0,0 +1 @@
1
+ export { sql } from 'kysely';
@@ -0,0 +1 @@
1
+ export { sql } from 'kysely';
@@ -0,0 +1,6 @@
1
+ // src/helpers.ts
2
+ import { sql } from "kysely";
3
+ export {
4
+ sql
5
+ };
6
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers.ts"],"sourcesContent":["export { sql } from 'kysely';\n"],"mappings":";AAAA,SAASA,WAAW;","names":["sql"]}