@event-driven-io/dumbo 0.13.0-beta.2 → 0.13.0-beta.20

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 (90) hide show
  1. package/dist/chunk-3B24ORM3.js +34 -0
  2. package/dist/chunk-3B24ORM3.js.map +1 -0
  3. package/dist/chunk-FXETEUW2.cjs +34 -0
  4. package/dist/chunk-FXETEUW2.cjs.map +1 -0
  5. package/dist/chunk-JDP6VMRY.cjs +556 -0
  6. package/dist/chunk-JDP6VMRY.cjs.map +1 -0
  7. package/dist/{chunk-OJ34O3Q2.cjs → chunk-PYTHH6WO.cjs} +2161 -1639
  8. package/dist/chunk-PYTHH6WO.cjs.map +1 -0
  9. package/dist/chunk-SQXAAA3N.cjs +481 -0
  10. package/dist/chunk-SQXAAA3N.cjs.map +1 -0
  11. package/dist/chunk-U445U32Q.js +83 -0
  12. package/dist/chunk-U445U32Q.js.map +1 -0
  13. package/dist/{chunk-XVV3OOQX.js → chunk-USPL7TWB.js} +209 -58
  14. package/dist/chunk-USPL7TWB.js.map +1 -0
  15. package/dist/chunk-V3QUMPUM.js +481 -0
  16. package/dist/chunk-V3QUMPUM.js.map +1 -0
  17. package/dist/chunk-VIQJEUVF.cjs +83 -0
  18. package/dist/chunk-VIQJEUVF.cjs.map +1 -0
  19. package/dist/{chunk-N7RWT46K.js → chunk-ZH6YVE3B.js} +2132 -1610
  20. package/dist/chunk-ZH6YVE3B.js.map +1 -0
  21. package/dist/cloudflare.cjs +451 -0
  22. package/dist/cloudflare.cjs.map +1 -0
  23. package/dist/cloudflare.d.cts +92 -0
  24. package/dist/cloudflare.d.ts +92 -0
  25. package/dist/cloudflare.js +451 -0
  26. package/dist/cloudflare.js.map +1 -0
  27. package/dist/{columnProcessors-DMPpTPqM.d.ts → columnProcessors-BwcyMnUX.d.ts} +1 -1
  28. package/dist/{columnProcessors-BX-sH7ah.d.cts → columnProcessors-CO9z2XBz.d.cts} +1 -1
  29. package/dist/{connectionString-B1wm0TFc.d.cts → connectionString-DHJiGj2D.d.cts} +339 -129
  30. package/dist/{connectionString-B1wm0TFc.d.ts → connectionString-DHJiGj2D.d.ts} +339 -129
  31. package/dist/index.cjs +96 -4
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +23 -18
  34. package/dist/index.d.ts +23 -18
  35. package/dist/index.js +99 -7
  36. package/dist/index.js.map +1 -1
  37. package/dist/pg.cjs +375 -9
  38. package/dist/pg.cjs.map +1 -1
  39. package/dist/pg.d.cts +76 -104
  40. package/dist/pg.d.ts +76 -104
  41. package/dist/pg.js +427 -61
  42. package/dist/pg.js.map +1 -1
  43. package/dist/postgresql.cjs +50 -0
  44. package/dist/postgresql.cjs.map +1 -0
  45. package/dist/postgresql.d.cts +61 -0
  46. package/dist/postgresql.d.ts +61 -0
  47. package/dist/postgresql.js +50 -0
  48. package/dist/sqlite.cjs +56 -0
  49. package/dist/sqlite.cjs.map +1 -0
  50. package/dist/{index-C0h0c380.d.cts → sqlite.d.cts} +24 -7
  51. package/dist/{index-C2z_XBn6.d.ts → sqlite.d.ts} +24 -7
  52. package/dist/sqlite.js +56 -0
  53. package/dist/sqlite3.cjs +240 -11
  54. package/dist/sqlite3.cjs.map +1 -1
  55. package/dist/sqlite3.d.cts +38 -18
  56. package/dist/sqlite3.d.ts +38 -18
  57. package/dist/sqlite3.js +251 -22
  58. package/dist/sqlite3.js.map +1 -1
  59. package/package.json +69 -29
  60. package/dist/chunk-A7TC7IOP.cjs +0 -55
  61. package/dist/chunk-A7TC7IOP.cjs.map +0 -1
  62. package/dist/chunk-F7JQ7BX7.js +0 -240
  63. package/dist/chunk-F7JQ7BX7.js.map +0 -1
  64. package/dist/chunk-I34X53VL.js +0 -688
  65. package/dist/chunk-I34X53VL.js.map +0 -1
  66. package/dist/chunk-ISNF6USX.cjs +0 -688
  67. package/dist/chunk-ISNF6USX.cjs.map +0 -1
  68. package/dist/chunk-IYEHOE4S.cjs +0 -405
  69. package/dist/chunk-IYEHOE4S.cjs.map +0 -1
  70. package/dist/chunk-L2YZQAG3.cjs +0 -240
  71. package/dist/chunk-L2YZQAG3.cjs.map +0 -1
  72. package/dist/chunk-N7RWT46K.js.map +0 -1
  73. package/dist/chunk-OJ34O3Q2.cjs.map +0 -1
  74. package/dist/chunk-TXSETOGH.js +0 -55
  75. package/dist/chunk-TXSETOGH.js.map +0 -1
  76. package/dist/chunk-XVV3OOQX.js.map +0 -1
  77. package/dist/d1.cjs +0 -277
  78. package/dist/d1.cjs.map +0 -1
  79. package/dist/d1.d.cts +0 -72
  80. package/dist/d1.d.ts +0 -72
  81. package/dist/d1.js +0 -277
  82. package/dist/d1.js.map +0 -1
  83. package/dist/pg-3ACXFMU4.cjs +0 -59
  84. package/dist/pg-3ACXFMU4.cjs.map +0 -1
  85. package/dist/pg-GHOW3XSG.js +0 -59
  86. package/dist/sqlite3-EEIKQCJR.js +0 -25
  87. package/dist/sqlite3-SE4DDYZE.cjs +0 -25
  88. package/dist/sqlite3-SE4DDYZE.cjs.map +0 -1
  89. /package/dist/{pg-GHOW3XSG.js.map → postgresql.js.map} +0 -0
  90. /package/dist/{sqlite3-EEIKQCJR.js.map → sqlite.js.map} +0 -0
@@ -0,0 +1,34 @@
1
+ import {
2
+ SQL,
3
+ exists
4
+ } from "./chunk-ZH6YVE3B.js";
5
+
6
+ // src/storage/sqlite/core/schema/schema.ts
7
+ var defaultSQLiteDatabase = ":memory:";
8
+ var tableExistsSQL = (tableName) => SQL`
9
+ SELECT EXISTS (
10
+ SELECT 1
11
+ FROM sqlite_master
12
+ WHERE type = 'table' AND name = ${tableName}
13
+ ) AS "exists"
14
+ `;
15
+ var tableExists = async (execute, tableName) => exists(execute.query(tableExistsSQL(tableName)));
16
+
17
+ // src/storage/sqlite/core/schema/sqliteMetadata.ts
18
+ var sqliteMetadata = {
19
+ databaseType: "SQLite",
20
+ capabilities: {
21
+ supportsSchemas: false,
22
+ supportsFunctions: false,
23
+ supportsMultipleDatabases: false
24
+ },
25
+ tableExists
26
+ };
27
+ dumboDatabaseMetadataRegistry.register("SQLite", sqliteMetadata);
28
+
29
+ export {
30
+ defaultSQLiteDatabase,
31
+ tableExists,
32
+ sqliteMetadata
33
+ };
34
+ //# sourceMappingURL=chunk-3B24ORM3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/storage/sqlite/core/schema/schema.ts","../src/storage/sqlite/core/schema/sqliteMetadata.ts"],"sourcesContent":["import { exists, SQL, type SQLExecutor } from '../../../../core';\nexport * from './schema';\n\nexport const defaultSQLiteDatabase = ':memory:';\n\nconst tableExistsSQL = (tableName: string): SQL =>\n SQL`\n SELECT EXISTS (\n SELECT 1\n FROM sqlite_master\n WHERE type = 'table' AND name = ${tableName}\n ) AS \"exists\"\n `;\n\nexport const tableExists = async (\n execute: SQLExecutor,\n tableName: string,\n): Promise<boolean> => exists(execute.query(tableExistsSQL(tableName)));\n","import type { DatabaseMetadata } from '../../../../core';\nimport { tableExists } from './schema';\n\nexport const sqliteMetadata: DatabaseMetadata<false, false, false> = {\n databaseType: 'SQLite',\n capabilities: {\n supportsSchemas: false,\n supportsFunctions: false,\n supportsMultipleDatabases: false,\n },\n tableExists,\n};\n\ndumboDatabaseMetadataRegistry.register('SQLite', sqliteMetadata);\n"],"mappings":";;;;;;AAGO,IAAM,wBAAwB;AAErC,IAAM,iBAAiB,CAAC,cACtB;AAAA;AAAA;AAAA;AAAA,sCAIoC,SAAS;AAAA;AAAA;AAIxC,IAAM,cAAc,OACzB,SACA,cACqB,OAAO,QAAQ,MAAM,eAAe,SAAS,CAAC,CAAC;;;ACd/D,IAAM,iBAAwD;AAAA,EACnE,cAAc;AAAA,EACd,cAAc;AAAA,IACZ,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,2BAA2B;AAAA,EAC7B;AAAA,EACA;AACF;AAEA,8BAA8B,SAAS,UAAU,cAAc;","names":[]}
@@ -0,0 +1,34 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkPYTHH6WOcjs = require('./chunk-PYTHH6WO.cjs');
5
+
6
+ // src/storage/sqlite/core/schema/schema.ts
7
+ var defaultSQLiteDatabase = ":memory:";
8
+ var tableExistsSQL = (tableName) => _chunkPYTHH6WOcjs.SQL`
9
+ SELECT EXISTS (
10
+ SELECT 1
11
+ FROM sqlite_master
12
+ WHERE type = 'table' AND name = ${tableName}
13
+ ) AS "exists"
14
+ `;
15
+ var tableExists = async (execute, tableName) => _chunkPYTHH6WOcjs.exists.call(void 0, execute.query(tableExistsSQL(tableName)));
16
+
17
+ // src/storage/sqlite/core/schema/sqliteMetadata.ts
18
+ var sqliteMetadata = {
19
+ databaseType: "SQLite",
20
+ capabilities: {
21
+ supportsSchemas: false,
22
+ supportsFunctions: false,
23
+ supportsMultipleDatabases: false
24
+ },
25
+ tableExists
26
+ };
27
+ dumboDatabaseMetadataRegistry.register("SQLite", sqliteMetadata);
28
+
29
+
30
+
31
+
32
+
33
+ exports.defaultSQLiteDatabase = defaultSQLiteDatabase; exports.tableExists = tableExists; exports.sqliteMetadata = sqliteMetadata;
34
+ //# sourceMappingURL=chunk-FXETEUW2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-FXETEUW2.cjs","../src/storage/sqlite/core/schema/schema.ts","../src/storage/sqlite/core/schema/sqliteMetadata.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACFO,IAAM,sBAAA,EAAwB,UAAA;AAErC,IAAM,eAAA,EAAiB,CAAC,SAAA,EAAA,GACtB,qBAAA,CAAA;AAAA;AAAA;AAAA;AAAA,oCAAA,EAIoC,SAAS,CAAA;AAAA;AAAA,GAAA,CAAA;AAIxC,IAAM,YAAA,EAAc,MAAA,CACzB,OAAA,EACA,SAAA,EAAA,GACqB,sCAAA,OAAO,CAAQ,KAAA,CAAM,cAAA,CAAe,SAAS,CAAC,CAAC,CAAA;ADFtE;AACA;AEbO,IAAM,eAAA,EAAwD;AAAA,EACnE,YAAA,EAAc,QAAA;AAAA,EACd,YAAA,EAAc;AAAA,IACZ,eAAA,EAAiB,KAAA;AAAA,IACjB,iBAAA,EAAmB,KAAA;AAAA,IACnB,yBAAA,EAA2B;AAAA,EAC7B,CAAA;AAAA,EACA;AACF,CAAA;AAEA,6BAAA,CAA8B,QAAA,CAAS,QAAA,EAAU,cAAc,CAAA;AFc/D;AACA;AACE;AACA;AACA;AACF,kIAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/dumbo/dist/chunk-FXETEUW2.cjs","sourcesContent":[null,"import { exists, SQL, type SQLExecutor } from '../../../../core';\nexport * from './schema';\n\nexport const defaultSQLiteDatabase = ':memory:';\n\nconst tableExistsSQL = (tableName: string): SQL =>\n SQL`\n SELECT EXISTS (\n SELECT 1\n FROM sqlite_master\n WHERE type = 'table' AND name = ${tableName}\n ) AS \"exists\"\n `;\n\nexport const tableExists = async (\n execute: SQLExecutor,\n tableName: string,\n): Promise<boolean> => exists(execute.query(tableExistsSQL(tableName)));\n","import type { DatabaseMetadata } from '../../../../core';\nimport { tableExists } from './schema';\n\nexport const sqliteMetadata: DatabaseMetadata<false, false, false> = {\n databaseType: 'SQLite',\n capabilities: {\n supportsSchemas: false,\n supportsFunctions: false,\n supportsMultipleDatabases: false,\n },\n tableExists,\n};\n\ndumboDatabaseMetadataRegistry.register('SQLite', sqliteMetadata);\n"]}
@@ -0,0 +1,556 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ var _chunkPYTHH6WOcjs = require('./chunk-PYTHH6WO.cjs');
32
+
33
+ // src/storage/sqlite/core/errors/errorMapper.ts
34
+ var getSqliteErrorCode = (error) => {
35
+ if (error instanceof Error && "code" in error && typeof error.code === "string") {
36
+ return error.code;
37
+ }
38
+ return void 0;
39
+ };
40
+ var getErrorMessage = (error) => error instanceof Error ? error.message : void 0;
41
+ var asError = (error) => error instanceof Error ? error : void 0;
42
+ var mapConstraintError = (message, innerError) => {
43
+ const upperMessage = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _ => _.toUpperCase, 'call', _2 => _2()]), () => ( ""));
44
+ if (upperMessage.includes("UNIQUE") || upperMessage.includes("PRIMARY KEY"))
45
+ return new (0, _chunkPYTHH6WOcjs.UniqueConstraintError)(message, innerError);
46
+ if (upperMessage.includes("FOREIGN KEY"))
47
+ return new (0, _chunkPYTHH6WOcjs.ForeignKeyViolationError)(message, innerError);
48
+ if (upperMessage.includes("NOT NULL"))
49
+ return new (0, _chunkPYTHH6WOcjs.NotNullViolationError)(message, innerError);
50
+ if (upperMessage.includes("CHECK"))
51
+ return new (0, _chunkPYTHH6WOcjs.CheckViolationError)(message, innerError);
52
+ return new (0, _chunkPYTHH6WOcjs.IntegrityConstraintViolationError)(message, innerError);
53
+ };
54
+ var mapSqliteError = (error) => {
55
+ if (_chunkPYTHH6WOcjs.DumboError.isInstanceOf(error)) return error;
56
+ const code = getSqliteErrorCode(error);
57
+ if (!code)
58
+ return new (0, _chunkPYTHH6WOcjs.DumboError)({
59
+ errorCode: 500,
60
+ message: getErrorMessage(error),
61
+ innerError: asError(error)
62
+ });
63
+ const message = getErrorMessage(error);
64
+ const innerError = asError(error);
65
+ switch (code) {
66
+ // ── Constraint violations (19) ──
67
+ // node-sqlite3 only exposes the primary code; subtype is in the message.
68
+ case "SQLITE_CONSTRAINT":
69
+ return mapConstraintError(message, innerError);
70
+ // ── Busy / lock contention ──
71
+ // SQLITE_BUSY (5): conflict with a separate database connection
72
+ case "SQLITE_BUSY":
73
+ return new (0, _chunkPYTHH6WOcjs.LockNotAvailableError)(message, innerError);
74
+ // SQLITE_LOCKED (6): conflict within the same connection or shared cache
75
+ case "SQLITE_LOCKED":
76
+ return new (0, _chunkPYTHH6WOcjs.DeadlockError)(message, innerError);
77
+ // SQLITE_PROTOCOL (15): WAL locking race condition
78
+ case "SQLITE_PROTOCOL":
79
+ return new (0, _chunkPYTHH6WOcjs.LockNotAvailableError)(message, innerError);
80
+ // ── Connection / open errors ──
81
+ // SQLITE_CANTOPEN (14): unable to open database file
82
+ case "SQLITE_CANTOPEN":
83
+ return new (0, _chunkPYTHH6WOcjs.ConnectionError)(message, innerError);
84
+ // SQLITE_NOTADB (26): file is not a database
85
+ case "SQLITE_NOTADB":
86
+ return new (0, _chunkPYTHH6WOcjs.ConnectionError)(message, innerError);
87
+ // ── Resource exhaustion ──
88
+ // SQLITE_NOMEM (7): out of memory
89
+ case "SQLITE_NOMEM":
90
+ return new (0, _chunkPYTHH6WOcjs.InsufficientResourcesError)(message, innerError);
91
+ // SQLITE_FULL (13): disk full
92
+ case "SQLITE_FULL":
93
+ return new (0, _chunkPYTHH6WOcjs.InsufficientResourcesError)(message, innerError);
94
+ // ── System / I/O errors ──
95
+ // SQLITE_IOERR (10): operating system I/O error
96
+ case "SQLITE_IOERR":
97
+ return new (0, _chunkPYTHH6WOcjs.SystemError)(message, innerError);
98
+ // SQLITE_CORRUPT (11): database file is corrupted
99
+ case "SQLITE_CORRUPT":
100
+ return new (0, _chunkPYTHH6WOcjs.SystemError)(message, innerError);
101
+ // SQLITE_INTERNAL (2): internal SQLite malfunction
102
+ case "SQLITE_INTERNAL":
103
+ return new (0, _chunkPYTHH6WOcjs.SystemError)(message, innerError);
104
+ // SQLITE_NOLFS (22): large file support unavailable
105
+ case "SQLITE_NOLFS":
106
+ return new (0, _chunkPYTHH6WOcjs.SystemError)(message, innerError);
107
+ // ── Data errors ──
108
+ // SQLITE_TOOBIG (18): string or BLOB too large
109
+ case "SQLITE_TOOBIG":
110
+ return new (0, _chunkPYTHH6WOcjs.DataError)(message, innerError);
111
+ // SQLITE_MISMATCH (20): datatype mismatch
112
+ case "SQLITE_MISMATCH":
113
+ return new (0, _chunkPYTHH6WOcjs.DataError)(message, innerError);
114
+ // SQLITE_RANGE (25): bind parameter index out of range
115
+ case "SQLITE_RANGE":
116
+ return new (0, _chunkPYTHH6WOcjs.DataError)(message, innerError);
117
+ // ── Invalid operations ──
118
+ // SQLITE_ERROR (1): generic SQL error (syntax errors, missing tables, etc.)
119
+ case "SQLITE_ERROR":
120
+ return new (0, _chunkPYTHH6WOcjs.InvalidOperationError)(message, innerError);
121
+ // SQLITE_READONLY (8): attempt to write to a read-only database
122
+ case "SQLITE_READONLY":
123
+ return new (0, _chunkPYTHH6WOcjs.InvalidOperationError)(message, innerError);
124
+ // SQLITE_MISUSE (21): API misuse
125
+ case "SQLITE_MISUSE":
126
+ return new (0, _chunkPYTHH6WOcjs.InvalidOperationError)(message, innerError);
127
+ // SQLITE_AUTH (23): authorization denied
128
+ case "SQLITE_AUTH":
129
+ return new (0, _chunkPYTHH6WOcjs.InvalidOperationError)(message, innerError);
130
+ // SQLITE_PERM (3): access permission denied
131
+ case "SQLITE_PERM":
132
+ return new (0, _chunkPYTHH6WOcjs.InvalidOperationError)(message, innerError);
133
+ // SQLITE_SCHEMA (17): schema changed, statement needs re-preparation
134
+ case "SQLITE_SCHEMA":
135
+ return new (0, _chunkPYTHH6WOcjs.InvalidOperationError)(message, innerError);
136
+ // ── Transaction / abort ──
137
+ // SQLITE_ABORT (4): operation aborted (e.g. by rollback)
138
+ case "SQLITE_ABORT":
139
+ return new (0, _chunkPYTHH6WOcjs.SerializationError)(message, innerError);
140
+ // SQLITE_INTERRUPT (9): operation interrupted
141
+ case "SQLITE_INTERRUPT":
142
+ return new (0, _chunkPYTHH6WOcjs.SerializationError)(message, innerError);
143
+ }
144
+ return new (0, _chunkPYTHH6WOcjs.DumboError)({
145
+ errorCode: 500,
146
+ message,
147
+ innerError
148
+ });
149
+ };
150
+
151
+ // src/storage/sqlite/core/sql/processors/columProcessors.ts
152
+ var mapColumnType = (token, { builder }) => {
153
+ let columnSQL;
154
+ const { sqlTokenType } = token;
155
+ switch (sqlTokenType) {
156
+ case "SQL_COLUMN_AUTO_INCREMENT":
157
+ columnSQL = `INTEGER ${token.primaryKey ? "PRIMARY KEY" : ""} AUTOINCREMENT`;
158
+ break;
159
+ case "SQL_COLUMN_BIGINT":
160
+ columnSQL = "INTEGER";
161
+ break;
162
+ case "SQL_COLUMN_SERIAL":
163
+ columnSQL = "INTEGER";
164
+ break;
165
+ case "SQL_COLUMN_INTEGER":
166
+ columnSQL = "INTEGER";
167
+ break;
168
+ case "SQL_COLUMN_JSONB":
169
+ columnSQL = "BLOB";
170
+ break;
171
+ case "SQL_COLUMN_BIGSERIAL":
172
+ columnSQL = "INTEGER";
173
+ break;
174
+ case "SQL_COLUMN_TIMESTAMP":
175
+ columnSQL = "DATETIME";
176
+ break;
177
+ case "SQL_COLUMN_TIMESTAMPTZ":
178
+ columnSQL = "DATETIME";
179
+ break;
180
+ case "SQL_COLUMN_VARCHAR":
181
+ columnSQL = `VARCHAR ${Number.isNaN(token.length) ? "" : `(${token.length})`}`;
182
+ break;
183
+ default: {
184
+ const exhaustiveCheck = sqlTokenType;
185
+ throw new Error(`Unknown column type: ${exhaustiveCheck}`);
186
+ }
187
+ }
188
+ builder.addSQL(columnSQL);
189
+ };
190
+ var sqliteColumnProcessors = _chunkPYTHH6WOcjs.mapDefaultSQLColumnProcessors.call(void 0, mapColumnType);
191
+
192
+ // src/storage/sqlite/core/sql/formatter/index.ts
193
+ var sqliteSQLProcessorsRegistry = _chunkPYTHH6WOcjs.SQLProcessorsRegistry.call(void 0, {
194
+ from: _chunkPYTHH6WOcjs.defaultProcessorsRegistry
195
+ }).register(sqliteColumnProcessors);
196
+ var sqliteFormatter = _chunkPYTHH6WOcjs.SQLFormatter.call(void 0, {
197
+ processorsRegistry: sqliteSQLProcessorsRegistry
198
+ });
199
+ _chunkPYTHH6WOcjs.registerFormatter.call(void 0, "SQLite", sqliteFormatter);
200
+
201
+ // src/storage/sqlite/core/execute/execute.ts
202
+ var sqliteExecute = async (database, handle) => {
203
+ try {
204
+ return await handle(database);
205
+ } finally {
206
+ await database.close();
207
+ }
208
+ };
209
+ var sqliteSQLExecutor = (driverType, serializer, formatter, errorMapper) => ({
210
+ driverType,
211
+ query: async (client, sql, options) => {
212
+ if (_optionalChain([options, 'optionalAccess', _3 => _3.timeoutMs])) {
213
+ await client.query(_chunkPYTHH6WOcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
214
+ }
215
+ _chunkPYTHH6WOcjs.tracer.info("db:sql:query", {
216
+ query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
217
+ params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
218
+ debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
219
+ });
220
+ try {
221
+ let result = await client.query(sql, options);
222
+ if (_optionalChain([options, 'optionalAccess', _4 => _4.mapping])) {
223
+ result = {
224
+ ...result,
225
+ rows: result.rows.map(
226
+ (row) => _chunkPYTHH6WOcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
227
+ )
228
+ };
229
+ }
230
+ return result;
231
+ } catch (error) {
232
+ _chunkPYTHH6WOcjs.tracer.error("db:sql:query:execute:error", { error });
233
+ throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
234
+ }
235
+ },
236
+ batchQuery: async (client, sqls, options) => {
237
+ if (_optionalChain([options, 'optionalAccess', _5 => _5.timeoutMs])) {
238
+ await client.query(_chunkPYTHH6WOcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
239
+ }
240
+ try {
241
+ const results = await client.batchQuery(sqls, options);
242
+ if (_optionalChain([options, 'optionalAccess', _6 => _6.mapping])) {
243
+ return results.map((result) => ({
244
+ ...result,
245
+ rows: result.rows.map(
246
+ (row) => _chunkPYTHH6WOcjs.mapSQLQueryResult.call(void 0, row, options.mapping)
247
+ )
248
+ }));
249
+ }
250
+ return results;
251
+ } catch (error) {
252
+ _chunkPYTHH6WOcjs.tracer.error("db:sql:batch_query:execute:error", { error });
253
+ throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
254
+ }
255
+ },
256
+ command: async (client, sql, options) => {
257
+ if (_optionalChain([options, 'optionalAccess', _7 => _7.timeoutMs])) {
258
+ await client.query(_chunkPYTHH6WOcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
259
+ }
260
+ _chunkPYTHH6WOcjs.tracer.info("db:sql:command", {
261
+ query: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).query,
262
+ params: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).format(sql, { serializer }).params,
263
+ debugSQL: (_nullishCoalesce(formatter, () => ( sqliteFormatter))).describe(sql, { serializer })
264
+ });
265
+ try {
266
+ return await client.command(sql, options);
267
+ } catch (error) {
268
+ _chunkPYTHH6WOcjs.tracer.error("db:sql:command:execute:error", { error });
269
+ throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
270
+ }
271
+ },
272
+ batchCommand: async (client, sqls, options) => {
273
+ if (_optionalChain([options, 'optionalAccess', _8 => _8.timeoutMs])) {
274
+ await client.query(_chunkPYTHH6WOcjs.SQL`PRAGMA busy_timeout = ${options.timeoutMs}`);
275
+ }
276
+ try {
277
+ return await client.batchCommand(sqls, options);
278
+ } catch (error) {
279
+ _chunkPYTHH6WOcjs.tracer.error("db:sql:batch_command:execute:error", { error });
280
+ throw (_nullishCoalesce(errorMapper, () => ( mapSqliteError)))(error);
281
+ }
282
+ },
283
+ formatter: _nullishCoalesce(formatter, () => ( sqliteFormatter))
284
+ });
285
+
286
+ // src/storage/sqlite/core/pool/pool.ts
287
+ var isInMemoryDatabase = (options) => {
288
+ if ("fileName" in options) {
289
+ return options.fileName === InMemorySQLiteDatabase;
290
+ }
291
+ if ("connectionString" in options) {
292
+ return options.connectionString === InMemorySQLiteDatabase;
293
+ }
294
+ return false;
295
+ };
296
+ var sqliteAmbientConnectionPool = (options) => {
297
+ const { connection, driverType } = options;
298
+ return _chunkPYTHH6WOcjs.createAmbientConnectionPool.call(void 0, {
299
+ driverType,
300
+ connection
301
+ });
302
+ };
303
+ var sqliteSingletonConnectionPool = (options) => {
304
+ const { driverType, sqliteConnectionFactory, connectionOptions } = options;
305
+ return _chunkPYTHH6WOcjs.createSingletonConnectionPool.call(void 0, {
306
+ driverType,
307
+ getConnection: () => sqliteConnectionFactory(connectionOptions)
308
+ });
309
+ };
310
+ var sqliteAlwaysNewConnectionPool = (options) => {
311
+ const { driverType, sqliteConnectionFactory, connectionOptions } = options;
312
+ return _chunkPYTHH6WOcjs.createAlwaysNewConnectionPool.call(void 0, {
313
+ driverType,
314
+ getConnection: () => sqliteConnectionFactory(connectionOptions)
315
+ });
316
+ };
317
+ var toSqlitePoolOptions = (options) => {
318
+ const { singleton, ...rest } = options;
319
+ const useSingleton = _nullishCoalesce(singleton, () => ( isInMemoryDatabase(options)));
320
+ if (useSingleton) {
321
+ return { ...rest, singleton: true };
322
+ }
323
+ return { ...rest, singleton: false };
324
+ };
325
+ function sqlitePool(options) {
326
+ const { driverType } = options;
327
+ if (options.connection)
328
+ return _chunkPYTHH6WOcjs.createAmbientConnectionPool.call(void 0, {
329
+ driverType,
330
+ connection: options.connection
331
+ });
332
+ if (options.singleton === true && options.sqliteConnectionFactory) {
333
+ return _chunkPYTHH6WOcjs.createSingletonConnectionPool.call(void 0, {
334
+ driverType,
335
+ getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
336
+ });
337
+ }
338
+ return _chunkPYTHH6WOcjs.createAlwaysNewConnectionPool.call(void 0, {
339
+ driverType,
340
+ getConnection: () => options.sqliteConnectionFactory(options.connectionOptions)
341
+ });
342
+ }
343
+
344
+ // src/storage/sqlite/core/schema/migrations.ts
345
+ var DefaultSQLiteMigratorOptions = {};
346
+ _chunkPYTHH6WOcjs.registerDefaultMigratorOptions.call(void 0, "SQLite", DefaultSQLiteMigratorOptions);
347
+
348
+ // src/storage/sqlite/core/index.ts
349
+ var SQLiteDatabaseName = "SQLite";
350
+
351
+ // src/storage/sqlite/core/connections/connectionString.ts
352
+ var SQLiteConnectionString = (connectionString) => {
353
+ if (!connectionString.startsWith("file:") && connectionString !== ":memory:" && !connectionString.startsWith("/") && !connectionString.startsWith("./")) {
354
+ throw new Error(
355
+ `Invalid SQLite connection string: ${connectionString}. It should start with "file:", ":memory:", "/", or "./".`
356
+ );
357
+ }
358
+ return connectionString;
359
+ };
360
+
361
+ // src/storage/sqlite/core/connections/index.ts
362
+ var isSQLiteError = (error) => {
363
+ if (error instanceof Error && "code" in error) {
364
+ return true;
365
+ }
366
+ return false;
367
+ };
368
+ var transactionNestingCounter = () => {
369
+ let transactionLevel = 0;
370
+ return {
371
+ reset: () => {
372
+ transactionLevel = 0;
373
+ },
374
+ increment: () => {
375
+ transactionLevel++;
376
+ },
377
+ decrement: () => {
378
+ transactionLevel--;
379
+ if (transactionLevel < 0) {
380
+ throw new Error("Transaction level is out of bounds");
381
+ }
382
+ },
383
+ get level() {
384
+ return transactionLevel;
385
+ }
386
+ };
387
+ };
388
+ var sqliteAmbientClientConnection = (options) => {
389
+ const {
390
+ client,
391
+ driverType,
392
+ initTransaction,
393
+ allowNestedTransactions,
394
+ serializer,
395
+ errorMapper
396
+ } = options;
397
+ return _chunkPYTHH6WOcjs.createAmbientConnection.call(void 0, {
398
+ driverType,
399
+ client,
400
+ initTransaction: _nullishCoalesce(initTransaction, () => ( ((connection) => sqliteTransaction(
401
+ driverType,
402
+ connection,
403
+ _nullishCoalesce(allowNestedTransactions, () => ( false)),
404
+ serializer
405
+ )))),
406
+ executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(driverType, serializer2, void 0, errorMapper),
407
+ serializer
408
+ });
409
+ };
410
+ var sqliteClientConnection = (options) => {
411
+ const { connectionOptions, sqliteClientFactory, serializer } = options;
412
+ let client = null;
413
+ const connect = async () => {
414
+ if (client) return Promise.resolve(client);
415
+ client = sqliteClientFactory(connectionOptions);
416
+ if (client && "connect" in client && typeof client.connect === "function")
417
+ await client.connect();
418
+ return client;
419
+ };
420
+ return _chunkPYTHH6WOcjs.createConnection.call(void 0, {
421
+ driverType: options.driverType,
422
+ connect,
423
+ close: async () => {
424
+ if (client && "close" in client && typeof client.close === "function")
425
+ await client.close();
426
+ else if (client && "release" in client && typeof client.release === "function")
427
+ client.release();
428
+ },
429
+ initTransaction: (connection) => sqliteTransaction(
430
+ options.driverType,
431
+ connection,
432
+ _nullishCoalesce(_optionalChain([connectionOptions, 'access', _9 => _9.transactionOptions, 'optionalAccess', _10 => _10.allowNestedTransactions]), () => ( false)),
433
+ serializer
434
+ ),
435
+ executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(options.driverType, serializer2),
436
+ serializer
437
+ });
438
+ };
439
+ var sqlitePoolClientConnection = (options) => {
440
+ const { connectionOptions, sqliteClientFactory, serializer } = options;
441
+ let client = null;
442
+ const connect = async () => {
443
+ if (client) return Promise.resolve(client);
444
+ client = sqliteClientFactory(connectionOptions);
445
+ await client.connect();
446
+ return client;
447
+ };
448
+ return _chunkPYTHH6WOcjs.createConnection.call(void 0, {
449
+ driverType: options.driverType,
450
+ connect,
451
+ close: () => client !== null ? Promise.resolve(client.release()) : Promise.resolve(),
452
+ initTransaction: (connection) => sqliteTransaction(
453
+ options.driverType,
454
+ connection,
455
+ _nullishCoalesce(_optionalChain([connectionOptions, 'access', _11 => _11.transactionOptions, 'optionalAccess', _12 => _12.allowNestedTransactions]), () => ( false)),
456
+ serializer
457
+ ),
458
+ executor: ({ serializer: serializer2 }) => sqliteSQLExecutor(options.driverType, serializer2),
459
+ serializer
460
+ });
461
+ };
462
+ function sqliteConnection(options) {
463
+ return options.type === "Client" ? sqliteClientConnection(options) : sqlitePoolClientConnection(options);
464
+ }
465
+ var InMemorySQLiteDatabase = SQLiteConnectionString(":memory:");
466
+
467
+ // src/storage/sqlite/core/transactions/index.ts
468
+ var sqliteTransaction = (driverType, connection, allowNestedTransactions, serializer) => (getClient, options) => {
469
+ const transactionCounter = transactionNestingCounter();
470
+ allowNestedTransactions = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.allowNestedTransactions]), () => ( allowNestedTransactions));
471
+ return {
472
+ connection: connection(),
473
+ driverType,
474
+ begin: async function() {
475
+ const client = await getClient;
476
+ if (allowNestedTransactions) {
477
+ if (transactionCounter.level >= 1) {
478
+ transactionCounter.increment();
479
+ await client.query(
480
+ _chunkPYTHH6WOcjs.SQL`SAVEPOINT transaction${_chunkPYTHH6WOcjs.SQL.plain(transactionCounter.level.toString())}`
481
+ );
482
+ return;
483
+ }
484
+ transactionCounter.increment();
485
+ }
486
+ await client.query(_chunkPYTHH6WOcjs.SQL`BEGIN TRANSACTION`);
487
+ },
488
+ commit: async function() {
489
+ const client = await getClient;
490
+ try {
491
+ if (allowNestedTransactions) {
492
+ if (transactionCounter.level > 1) {
493
+ await client.query(
494
+ _chunkPYTHH6WOcjs.SQL`RELEASE transaction${_chunkPYTHH6WOcjs.SQL.plain(transactionCounter.level.toString())}`
495
+ );
496
+ transactionCounter.decrement();
497
+ return;
498
+ }
499
+ transactionCounter.reset();
500
+ }
501
+ await client.query(_chunkPYTHH6WOcjs.SQL`COMMIT`);
502
+ } finally {
503
+ if (_optionalChain([options, 'optionalAccess', _14 => _14.close]))
504
+ await _optionalChain([options, 'optionalAccess', _15 => _15.close, 'call', _16 => _16(
505
+ client
506
+ )]);
507
+ }
508
+ },
509
+ rollback: async function(error) {
510
+ const client = await getClient;
511
+ try {
512
+ if (allowNestedTransactions) {
513
+ if (transactionCounter.level > 1) {
514
+ transactionCounter.decrement();
515
+ return;
516
+ }
517
+ }
518
+ await client.query(_chunkPYTHH6WOcjs.SQL`ROLLBACK`);
519
+ } finally {
520
+ if (_optionalChain([options, 'optionalAccess', _17 => _17.close]))
521
+ await _optionalChain([options, 'optionalAccess', _18 => _18.close, 'call', _19 => _19(
522
+ client,
523
+ error
524
+ )]);
525
+ }
526
+ },
527
+ execute: _chunkPYTHH6WOcjs.sqlExecutor.call(void 0, sqliteSQLExecutor(driverType, serializer), {
528
+ connect: () => getClient
529
+ })
530
+ };
531
+ };
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+
553
+
554
+
555
+ exports.mapSqliteError = mapSqliteError; exports.sqliteFormatter = sqliteFormatter; exports.sqliteExecute = sqliteExecute; exports.sqliteSQLExecutor = sqliteSQLExecutor; exports.sqliteTransaction = sqliteTransaction; exports.SQLiteConnectionString = SQLiteConnectionString; exports.isSQLiteError = isSQLiteError; exports.transactionNestingCounter = transactionNestingCounter; exports.sqliteAmbientClientConnection = sqliteAmbientClientConnection; exports.sqliteClientConnection = sqliteClientConnection; exports.sqlitePoolClientConnection = sqlitePoolClientConnection; exports.sqliteConnection = sqliteConnection; exports.InMemorySQLiteDatabase = InMemorySQLiteDatabase; exports.isInMemoryDatabase = isInMemoryDatabase; exports.sqliteAmbientConnectionPool = sqliteAmbientConnectionPool; exports.sqliteSingletonConnectionPool = sqliteSingletonConnectionPool; exports.sqliteAlwaysNewConnectionPool = sqliteAlwaysNewConnectionPool; exports.toSqlitePoolOptions = toSqlitePoolOptions; exports.sqlitePool = sqlitePool; exports.DefaultSQLiteMigratorOptions = DefaultSQLiteMigratorOptions; exports.SQLiteDatabaseName = SQLiteDatabaseName;
556
+ //# sourceMappingURL=chunk-JDP6VMRY.cjs.map