durable-db 0.7.0 → 0.9.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.
@@ -1,572 +0,0 @@
1
- import { SQLiteSyncDialect, getTableConfig } from "drizzle-orm/sqlite-core";
2
- import { toCamelCase, toSnakeCase } from "drizzle-orm/casing";
3
- import { CamelCasePlugin, ColumnNode, ColumnUpdateNode, InsertQueryNode, Kysely, PrimitiveValueListNode, SqliteDialect, SqliteQueryCompiler, TableNode, ValueListNode, ValueNode, ValuesNode, sql } from "kysely";
4
- import { Table, getTableColumns, getTableName, is, isSQLWrapper } from "drizzle-orm";
5
- //#region src/db/plugins.ts
6
- /**
7
- * Schema-aware CamelCasePlugin that uses Drizzle schema for column name mapping.
8
- *
9
- * Extends CamelCasePlugin to handle non-standard column names that don't follow
10
- * simple camelCase ↔ snake_case conversion. For example, a JS property `userId`
11
- * mapped to SQL column `user_identifier` would be handled correctly.
12
- *
13
- * Falls back to standard CamelCasePlugin behavior for columns not in the schema.
14
- */
15
- var SchemaPlugin = class extends CamelCasePlugin {
16
- jsToSql;
17
- sqlToJs;
18
- constructor(schema) {
19
- super();
20
- this.jsToSql = /* @__PURE__ */ new Map();
21
- this.sqlToJs = /* @__PURE__ */ new Map();
22
- for (const [schemaKey, table] of Object.entries(schema)) {
23
- const tableConfig = getTableConfig(table);
24
- const sqlTableName = tableConfig.name;
25
- if (schemaKey !== sqlTableName) {
26
- this.jsToSql.set(schemaKey, sqlTableName);
27
- this.sqlToJs.set(sqlTableName, schemaKey);
28
- }
29
- const sqlColumnNames = new Set(tableConfig.columns.map((c) => c.name));
30
- for (const [propertyName, value] of Object.entries(table)) if (value && typeof value === "object" && "name" in value && typeof value.name === "string" && sqlColumnNames.has(value.name) && propertyName !== value.name) {
31
- this.jsToSql.set(propertyName, value.name);
32
- this.sqlToJs.set(value.name, propertyName);
33
- }
34
- }
35
- }
36
- snakeCase(str) {
37
- return this.jsToSql.get(str) ?? super.snakeCase(str);
38
- }
39
- camelCase(str) {
40
- return this.sqlToJs.get(str) ?? super.camelCase(str);
41
- }
42
- };
43
- function getKyselyTableName(node) {
44
- if (node && TableNode.is(node)) return node.table.identifier.name;
45
- return null;
46
- }
47
- function getKyselyColumnName(node) {
48
- if (!node) return null;
49
- if (ColumnNode.is(node)) return node.column.name;
50
- if (ColumnUpdateNode.is(node) && node.column) return getKyselyColumnName(node.column);
51
- return null;
52
- }
53
- function convertDrizzleSql(drizzleSql) {
54
- return drizzleSql.sql.split("?").reduce((acc, part, index) => {
55
- const param = index < drizzleSql.params.length ? drizzleSql.params[index] : "";
56
- return acc + part + param;
57
- }, "");
58
- }
59
- function createValueNode(val) {
60
- if (isSQLWrapper(val)) {
61
- const drizzleSql = new SQLiteSyncDialect().sqlToQuery(val);
62
- return sql.raw(convertDrizzleSql(drizzleSql)).toOperationNode();
63
- }
64
- return ValueNode.create(val);
65
- }
66
- function extractDefaults(schemas) {
67
- const defaults = /* @__PURE__ */ new Map();
68
- for (const schema of Object.values(schemas)) {
69
- const tableName = toCamelCase(getTableName(schema));
70
- const columns = getTableColumns(schema);
71
- const tableDefaults = {};
72
- for (const column of Object.values(columns)) {
73
- const { defaultFn, onUpdateFn, name } = column;
74
- if (defaultFn || onUpdateFn) tableDefaults[name] = {
75
- defaultFn,
76
- onUpdateFn
77
- };
78
- }
79
- if (Object.keys(tableDefaults).length > 0) defaults.set(tableName, tableDefaults);
80
- }
81
- return defaults;
82
- }
83
- /**
84
- * Plugin that handles Drizzle's defaultFn and onUpdateFn during Kysely queries.
85
- *
86
- * On INSERT: auto-populates columns that have a defaultFn but weren't provided,
87
- * and resolves DefaultInsertValueNode markers to actual values.
88
- *
89
- * On UPDATE: auto-adds column updates for columns with onUpdateFn that weren't
90
- * already included in the SET clause.
91
- */
92
- var DrizzleDefaultsPlugin = class {
93
- defaults;
94
- constructor(drizzleSchemas) {
95
- this.defaults = extractDefaults(drizzleSchemas);
96
- }
97
- transformInsertQuery(node) {
98
- const tableName = getKyselyTableName(node.into);
99
- if (!tableName) return node;
100
- const tableDefaults = this.defaults.get(tableName);
101
- if (!tableDefaults) return node;
102
- if (!node.values || !ValuesNode.is(node.values)) return node;
103
- const providedColumns = node.columns ?? [];
104
- const providedColumnNames = providedColumns.map((col) => col.column.name);
105
- const missingDefaults = Object.entries(tableDefaults).filter(([colName, { defaultFn }]) => defaultFn && !providedColumnNames.includes(colName)).map(([colName, { defaultFn }]) => ({
106
- name: colName,
107
- defaultFn
108
- }));
109
- const newColumns = [...providedColumns, ...missingDefaults.map(({ name }) => ColumnNode.create(name))];
110
- const newRows = node.values.values.map((rowNode) => {
111
- if (missingDefaults.length === 0 && PrimitiveValueListNode.is(rowNode)) return rowNode;
112
- let originalValues;
113
- if (PrimitiveValueListNode.is(rowNode)) originalValues = rowNode.values.map((val) => ValueNode.create(val));
114
- else if (ValueListNode.is(rowNode)) originalValues = [...rowNode.values];
115
- else throw new Error("Unsupported row node type in insert query");
116
- const processedValues = originalValues.map((val, idx) => {
117
- if (val.kind === "DefaultInsertValueNode") {
118
- const colName = providedColumns[idx].column.name;
119
- const colDef = tableDefaults[colName];
120
- if (colDef?.defaultFn) return createValueNode(colDef.defaultFn());
121
- }
122
- return val;
123
- });
124
- const missingValues = missingDefaults.map(({ defaultFn }) => createValueNode(defaultFn()));
125
- return ValueListNode.create([...processedValues, ...missingValues]);
126
- });
127
- return InsertQueryNode.cloneWith(node, {
128
- columns: newColumns,
129
- values: ValuesNode.create(newRows)
130
- });
131
- }
132
- transformUpdateQuery(node) {
133
- const tableName = getKyselyTableName(node.table);
134
- if (!tableName) return node;
135
- const tableDefaults = this.defaults.get(tableName);
136
- if (!tableDefaults) return node;
137
- const existingUpdates = new Set(node.updates?.map(getKyselyColumnName) || []);
138
- const newUpdates = node.updates ? [...node.updates] : [];
139
- for (const [colName, { onUpdateFn }] of Object.entries(tableDefaults)) {
140
- if (!onUpdateFn || existingUpdates.has(colName)) continue;
141
- newUpdates.push(ColumnUpdateNode.create(ColumnNode.create(colName), createValueNode(onUpdateFn())));
142
- }
143
- if (newUpdates.length === (node.updates?.length || 0)) return node;
144
- return {
145
- ...node,
146
- updates: newUpdates
147
- };
148
- }
149
- transformQuery(args) {
150
- const { node } = args;
151
- switch (node.kind) {
152
- case "InsertQueryNode": return this.transformInsertQuery(node);
153
- case "UpdateQueryNode": return this.transformUpdateQuery(node);
154
- default: return node;
155
- }
156
- }
157
- async transformResult(args) {
158
- return args.result;
159
- }
160
- };
161
- /**
162
- * Date serialization helpers for SQLite
163
- * SQLite stores dates as TEXT in ISO format (without timezone)
164
- */
165
- const dateSerializers = {
166
- /**
167
- * Serialize a Date to SQLite format
168
- * Converts to ISO string, removes timezone info
169
- */
170
- serialize(value) {
171
- return value.toISOString().replace("T", " ").slice(0, 19);
172
- },
173
- /**
174
- * Deserialize a SQLite date string to Date
175
- * Parses assuming UTC timezone
176
- */
177
- deserialize(value) {
178
- const normalized = value.replace(" ", "T");
179
- if (/(?:Z|[+-]\d{2}:?\d{2})$/.test(normalized)) return new Date(normalized);
180
- return /* @__PURE__ */ new Date(normalized + "Z");
181
- },
182
- /**
183
- * Check if a string looks like an ISO date
184
- */
185
- isDateString(value) {
186
- return /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}/.test(value);
187
- },
188
- /**
189
- * Check if a string matches exactly the format produced by serialize()
190
- * (and SQLite's CURRENT_TIMESTAMP): `YYYY-MM-DD HH:MM:SS`.
191
- *
192
- * The read path only deserializes strings in this exact format. Anything
193
- * else — full ISO strings with a 'T' separator, timezone, or milliseconds —
194
- * was stored by the user as a plain string and must round-trip verbatim.
195
- */
196
- isSerializedDateString(value) {
197
- return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(value);
198
- }
199
- };
200
- /**
201
- * Collect the names of columns that Drizzle declares as date-typed
202
- * (e.g. `integer({ mode: 'timestamp' })`). Includes both the SQL column
203
- * name and the JS property name, since result rows may be seen in either
204
- * form depending on where this plugin sits relative to CamelCasePlugin.
205
- */
206
- function collectDateColumnNames(schema) {
207
- const dateColumns = /* @__PURE__ */ new Set();
208
- for (const table of Object.values(schema)) {
209
- const columns = getTableColumns(table);
210
- for (const [propertyName, column] of Object.entries(columns)) if (column.dataType === "date") {
211
- dateColumns.add(column.name);
212
- dateColumns.add(propertyName);
213
- dateColumns.add(toSnakeCase(propertyName));
214
- }
215
- }
216
- return dateColumns;
217
- }
218
- /**
219
- * Plugin that serializes/deserializes Date objects for SQLite
220
- *
221
- * On query: Converts Date objects to ISO strings
222
- * On result: Converts stored date strings back to Date objects — but only
223
- * for values in the exact format the write path produces, and (when a schema
224
- * is provided) only for columns Drizzle declares as date-typed. Plain text
225
- * columns holding date-looking strings round-trip verbatim.
226
- */
227
- var DateSerializePlugin = class {
228
- /**
229
- * Names of date-typed columns (SQL and JS forms) when constructed with a
230
- * schema; null means "no schema available", which falls back to matching
231
- * on value format alone.
232
- */
233
- dateColumns;
234
- constructor(schema) {
235
- this.dateColumns = schema ? collectDateColumnNames(schema) : null;
236
- }
237
- transformQuery(args) {
238
- return this.transformNode(args.node);
239
- }
240
- transformNode(node) {
241
- if (node === null || node === void 0) return node;
242
- if (node instanceof Date) return dateSerializers.serialize(node);
243
- if (Array.isArray(node)) return node.map((item) => this.transformNode(item));
244
- if (typeof node === "object") {
245
- const result = {};
246
- for (const [key, value] of Object.entries(node)) result[key] = this.transformNode(value);
247
- return result;
248
- }
249
- return node;
250
- }
251
- async transformResult(args) {
252
- return {
253
- ...args.result,
254
- rows: args.result.rows.map((row) => this.transformRow(row))
255
- };
256
- }
257
- transformRow(row) {
258
- const result = {};
259
- for (const [key, value] of Object.entries(row)) if (typeof value === "string" && this.shouldDeserialize(key, value)) result[key] = dateSerializers.deserialize(value);
260
- else result[key] = value;
261
- return result;
262
- }
263
- shouldDeserialize(key, value) {
264
- if (this.dateColumns && !this.dateColumns.has(key)) return false;
265
- return dateSerializers.isSerializedDateString(value);
266
- }
267
- };
268
- /**
269
- * Collect the names of columns Drizzle declares as boolean-typed
270
- * (`integer({ mode: 'boolean' })`). Mirrors collectDateColumnNames: covers
271
- * the SQL column name, the JS property name, and the snake_cased property
272
- * name, so it works on either side of the CamelCasePlugin.
273
- */
274
- function collectBooleanColumnNames(schema) {
275
- const booleanColumns = /* @__PURE__ */ new Set();
276
- for (const table of Object.values(schema)) {
277
- const columns = getTableColumns(table);
278
- for (const [propertyName, column] of Object.entries(columns)) if (column.dataType === "boolean") {
279
- booleanColumns.add(column.name);
280
- booleanColumns.add(propertyName);
281
- booleanColumns.add(toSnakeCase(propertyName));
282
- }
283
- }
284
- return booleanColumns;
285
- }
286
- /**
287
- * Plugin that deserializes boolean-mode columns on read.
288
- *
289
- * SQLite stores booleans as INTEGER 1/0 (the write side is normalized in the
290
- * driver — see normalizeParameter in kysely.ts), so schema-declared boolean
291
- * columns come back as numbers and must be mapped to real booleans. Legacy
292
- * rows written before the driver normalization existed carry TEXT
293
- * 'true'/'false' — those are mapped too, so old data keeps reading correctly.
294
- * Anything unrecognized round-trips verbatim rather than being guessed at.
295
- */
296
- var BooleanDeserializePlugin = class {
297
- booleanColumns;
298
- constructor(schema) {
299
- this.booleanColumns = collectBooleanColumnNames(schema);
300
- }
301
- transformQuery(args) {
302
- return args.node;
303
- }
304
- async transformResult(args) {
305
- if (this.booleanColumns.size === 0) return args.result;
306
- return {
307
- ...args.result,
308
- rows: args.result.rows.map((row) => this.transformRow(row))
309
- };
310
- }
311
- transformRow(row) {
312
- const result = {};
313
- for (const [key, value] of Object.entries(row)) result[key] = this.booleanColumns.has(key) ? this.toBoolean(value) : value;
314
- return result;
315
- }
316
- toBoolean(value) {
317
- if (value === null || value === void 0 || typeof value === "boolean") return value;
318
- if (typeof value === "number") return value !== 0;
319
- if (typeof value === "bigint") return value !== 0n;
320
- if (value === "true" || value === "1") return true;
321
- if (value === "false" || value === "0") return false;
322
- return value;
323
- }
324
- };
325
- /**
326
- * Validate that a schema object is shaped like a record of Drizzle tables.
327
- *
328
- * Throws a descriptive error pointing at the offending key when the schema
329
- * is not a plain object or when any value isn't a Drizzle `Table`. This
330
- * catches the common foot-guns (passing a Drizzle relations helper, a plain
331
- * column builder, or `undefined` because of a missing import) before Kysely
332
- * plugins crash with an unhelpful stack deep inside their constructors.
333
- */
334
- function assertValidSchema(schema) {
335
- if (schema === null || typeof schema !== "object" || Array.isArray(schema)) throw new Error(`[db] Invalid schema: expected a record of Drizzle tables (e.g. { users, posts }), got ${Array.isArray(schema) ? "array" : schema === null ? "null" : typeof schema}.`);
336
- for (const [key, value] of Object.entries(schema)) if (!is(value, Table)) throw new Error(`[db] Invalid schema: '${key}' is not a Drizzle table (got ${value === null ? "null" : value === void 0 ? "undefined" : typeof value}). Make sure every value is defined with table() from 'durable-db/schema'.`);
337
- }
338
- /**
339
- * Create all recommended plugins for use with Drizzle schemas.
340
- *
341
- * Includes:
342
- * - DrizzleDefaultsPlugin: auto-populates defaultFn/onUpdateFn values
343
- * - SchemaPlugin (extends CamelCasePlugin): schema-aware camelCase ↔ snake_case
344
- * - DateSerializePlugin: Date ↔ SQLite text serialization
345
- * - BooleanDeserializePlugin: boolean-mode columns read back as booleans
346
- *
347
- * When camelCase is false, SchemaPlugin is omitted.
348
- */
349
- function createDrizzlePlugins(schema, camelCase = true) {
350
- assertValidSchema(schema);
351
- const plugins = [];
352
- plugins.push(new DrizzleDefaultsPlugin(schema));
353
- if (camelCase) plugins.push(new SchemaPlugin(schema));
354
- plugins.push(new DateSerializePlugin(schema));
355
- plugins.push(new BooleanDeserializePlugin(schema));
356
- return plugins;
357
- }
358
- //#endregion
359
- //#region src/db/kysely.ts
360
- const MAX_BOUND_PARAMETERS = 100;
361
- /**
362
- * Kysely's SQLite compiler with identifiers quoted in backticks instead of
363
- * double quotes. SQLite (workerd's build included) reads a double-quoted
364
- * identifier that names no column as a string literal, so a column missing
365
- * from the database — a schema change not yet migrated — silently selects its
366
- * own name (`"weight_grams"` → 'weight_grams') and a WHERE on it compares two
367
- * constants. A backtick-quoted identifier is never a literal: the query fails
368
- * with "no such column". The migrations already quote with backticks.
369
- */
370
- var BacktickSqliteQueryCompiler = class extends SqliteQueryCompiler {
371
- getLeftIdentifierWrapper() {
372
- return "`";
373
- }
374
- getRightIdentifierWrapper() {
375
- return "`";
376
- }
377
- sanitizeIdentifier(identifier) {
378
- return identifier.replaceAll("`", "``");
379
- }
380
- };
381
- /**
382
- * workerd has no boolean binding type and silently stringifies JS booleans
383
- * (storing TEXT 'true' in an INTEGER column); node:sqlite rejects them
384
- * outright. Normalize to SQLite's 1/0 convention before the value reaches
385
- * either. `undefined` → NULL for the same reason.
386
- */
387
- function normalizeParameter(value) {
388
- if (typeof value === "boolean") return value ? 1 : 0;
389
- if (value === void 0) return null;
390
- return value;
391
- }
392
- function escapeLiteral(value) {
393
- if (value === null || value === void 0) return "NULL";
394
- if (typeof value === "boolean") return value ? "1" : "0";
395
- if (typeof value === "number") {
396
- if (!Number.isFinite(value)) throw new Error(`[db] Cannot inline non-finite number parameter (${value})`);
397
- return String(value);
398
- }
399
- if (typeof value === "bigint") return value.toString();
400
- if (typeof value === "string") {
401
- if (value.includes("\0")) throw new Error("[db] Cannot inline a string parameter containing a NUL byte");
402
- return `'${value.replaceAll("'", "''")}'`;
403
- }
404
- if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) {
405
- const bytes = value instanceof ArrayBuffer ? new Uint8Array(value) : new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
406
- let hex = "";
407
- for (const b of bytes) hex += b.toString(16).padStart(2, "0");
408
- return `X'${hex}'`;
409
- }
410
- throw new Error(`[db] Cannot inline SQL parameter of type ${typeof value}`);
411
- }
412
- /**
413
- * Replace each `?` placeholder in `sql` with the escaped literal of its
414
- * parameter. A real scanner, not a regex: '…' string literals ('' escapes),
415
- * "…" and `…` quoted identifiers, `--` line comments and C-style block
416
- * comments are skipped, so a `?` inside any of them is never touched.
417
- *
418
- * Exported for tests.
419
- */
420
- function inlineParameters(sql, parameters) {
421
- let out = "";
422
- let p = 0;
423
- for (let i = 0; i < sql.length; i++) {
424
- const ch = sql[i];
425
- if (ch === "'" || ch === "\"" || ch === "`") {
426
- let j = i + 1;
427
- while (j < sql.length) {
428
- if (sql[j] === ch) {
429
- if (sql[j + 1] === ch) {
430
- j += 2;
431
- continue;
432
- }
433
- break;
434
- }
435
- j++;
436
- }
437
- out += sql.slice(i, j + 1);
438
- i = j;
439
- continue;
440
- }
441
- if (ch === "-" && sql[i + 1] === "-") {
442
- let j = sql.indexOf("\n", i);
443
- if (j === -1) j = sql.length;
444
- out += sql.slice(i, j);
445
- i = j - 1;
446
- continue;
447
- }
448
- if (ch === "/" && sql[i + 1] === "*") {
449
- let j = sql.indexOf("*/", i + 2);
450
- j = j === -1 ? sql.length : j + 2;
451
- out += sql.slice(i, j);
452
- i = j - 1;
453
- continue;
454
- }
455
- if (ch === "?") {
456
- if (p >= parameters.length) throw new Error("[db] Query has more `?` placeholders than parameters while inlining");
457
- out += escapeLiteral(parameters[p++]);
458
- continue;
459
- }
460
- out += ch;
461
- }
462
- if (p !== parameters.length) throw new Error(`[db] Inlined ${p} parameter(s) but the query provided ${parameters.length} — placeholder/parameter mismatch`);
463
- return out;
464
- }
465
- /**
466
- * A Kysely driver that uses Cloudflare DO SQLite storage
467
- */
468
- var CloudflareSqliteDriver = class {
469
- sql;
470
- constructor(sql) {
471
- this.sql = sql;
472
- }
473
- async init() {}
474
- async acquireConnection() {
475
- return new CloudflareSqliteConnection(this.sql);
476
- }
477
- async beginTransaction(connection, settings) {
478
- if (settings.isolationLevel) throw new Error("SQLite does not support isolation levels");
479
- await connection.executeQuery(createCompiledQuery("BEGIN"));
480
- }
481
- async commitTransaction(connection) {
482
- await connection.executeQuery(createCompiledQuery("COMMIT"));
483
- }
484
- async rollbackTransaction(connection) {
485
- await connection.executeQuery(createCompiledQuery("ROLLBACK"));
486
- }
487
- async releaseConnection() {}
488
- async destroy() {}
489
- };
490
- /**
491
- * Helper to create a CompiledQuery object
492
- */
493
- function createCompiledQuery(sql, parameters = []) {
494
- return {
495
- sql,
496
- parameters,
497
- query: {
498
- kind: "RawNode",
499
- sqlFragments: [sql],
500
- parameters: []
501
- }
502
- };
503
- }
504
- /**
505
- * A Kysely connection that wraps Cloudflare's SqlStorage
506
- */
507
- var CloudflareSqliteConnection = class {
508
- sql;
509
- constructor(sql) {
510
- this.sql = sql;
511
- }
512
- async executeQuery(compiledQuery) {
513
- let queryStr = compiledQuery.sql;
514
- let parameters = compiledQuery.parameters.map(normalizeParameter);
515
- if (parameters.length > MAX_BOUND_PARAMETERS) {
516
- queryStr = inlineParameters(queryStr, parameters);
517
- parameters = [];
518
- }
519
- const isSelect = /^\s*(SELECT|RETURNING)/i.test(queryStr) || /\s+RETURNING\s+/i.test(queryStr);
520
- try {
521
- if (isSelect) return {
522
- rows: this.sql.exec(queryStr, ...parameters).toArray(),
523
- numAffectedRows: void 0,
524
- insertId: void 0
525
- };
526
- else {
527
- this.sql.exec(queryStr, ...parameters);
528
- const [result] = this.sql.exec("SELECT changes() AS changes, last_insert_rowid() AS id").toArray();
529
- const changes = result?.changes ?? 0;
530
- const lastId = result?.id;
531
- return {
532
- rows: [],
533
- numAffectedRows: BigInt(changes),
534
- insertId: typeof lastId === "number" || typeof lastId === "bigint" ? BigInt(lastId) : void 0
535
- };
536
- }
537
- } catch (error) {
538
- throw error;
539
- }
540
- }
541
- streamQuery() {
542
- throw new Error("Streaming is not supported in Cloudflare SQLite");
543
- }
544
- };
545
- /**
546
- * Create a Kysely instance from Cloudflare SqlStorage
547
- *
548
- * @param sqlStorage - The Cloudflare SqlStorage instance
549
- * @param options - Configuration options including schema for plugins
550
- */
551
- function createKyselyFromSql(sqlStorage, options = {}) {
552
- const { schema, plugins = [], camelCase = true } = options;
553
- const sqliteDialect = new SqliteDialect({ database: null });
554
- const allPlugins = [];
555
- if (schema) allPlugins.push(...createDrizzlePlugins(schema, camelCase));
556
- else if (camelCase) {
557
- allPlugins.push(new CamelCasePlugin());
558
- allPlugins.push(new DateSerializePlugin());
559
- } else allPlugins.push(new DateSerializePlugin());
560
- allPlugins.push(...plugins);
561
- return new Kysely({
562
- dialect: {
563
- createAdapter: () => sqliteDialect.createAdapter(),
564
- createDriver: () => new CloudflareSqliteDriver(sqlStorage),
565
- createIntrospector: (db) => sqliteDialect.createIntrospector(db),
566
- createQueryCompiler: () => new BacktickSqliteQueryCompiler()
567
- },
568
- plugins: allPlugins
569
- });
570
- }
571
- //#endregion
572
- export { createDrizzlePlugins as a, SchemaPlugin as i, DateSerializePlugin as n, dateSerializers as o, DrizzleDefaultsPlugin as r, createKyselyFromSql as t };