@prisma/adapter-libsql 6.16.0-integration-feat-orm-1074-package-dev-export.3 → 6.16.0-integration-feat-orm-1074-package-dev-export.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.
- package/dist/index-node.d.mts +6 -2
- package/dist/index-node.d.ts +6 -2
- package/dist/index-node.js +32 -17
- package/dist/index-node.mjs +32 -17
- package/dist/index-web.d.mts +6 -2
- package/dist/index-web.d.ts +6 -2
- package/dist/index-web.js +32 -17
- package/dist/index-web.mjs +32 -17
- package/package.json +3 -7
package/dist/index-node.d.mts
CHANGED
|
@@ -8,15 +8,19 @@ export declare class PrismaLibSQL extends PrismaLibSQLAdapterFactoryBase {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
declare abstract class PrismaLibSQLAdapterFactoryBase implements SqlMigrationAwareDriverAdapterFactory {
|
|
11
|
-
private
|
|
11
|
+
#private;
|
|
12
12
|
readonly provider = "sqlite";
|
|
13
13
|
readonly adapterName: string;
|
|
14
|
-
constructor(config: Config);
|
|
14
|
+
constructor(config: Config, options?: PrismaLibSQLOptions);
|
|
15
15
|
connect(): Promise<SqlDriverAdapter>;
|
|
16
16
|
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
17
17
|
abstract createClient(config: Config): StdClient;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
declare type PrismaLibSQLOptions = {
|
|
21
|
+
timestampFormat?: 'iso8601' | 'unixepoch-ms';
|
|
22
|
+
};
|
|
23
|
+
|
|
20
24
|
declare type StdClient = Client;
|
|
21
25
|
|
|
22
26
|
export { }
|
package/dist/index-node.d.ts
CHANGED
|
@@ -8,15 +8,19 @@ export declare class PrismaLibSQL extends PrismaLibSQLAdapterFactoryBase {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
declare abstract class PrismaLibSQLAdapterFactoryBase implements SqlMigrationAwareDriverAdapterFactory {
|
|
11
|
-
private
|
|
11
|
+
#private;
|
|
12
12
|
readonly provider = "sqlite";
|
|
13
13
|
readonly adapterName: string;
|
|
14
|
-
constructor(config: Config);
|
|
14
|
+
constructor(config: Config, options?: PrismaLibSQLOptions);
|
|
15
15
|
connect(): Promise<SqlDriverAdapter>;
|
|
16
16
|
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
17
17
|
abstract createClient(config: Config): StdClient;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
declare type PrismaLibSQLOptions = {
|
|
21
|
+
timestampFormat?: 'iso8601' | 'unixepoch-ms';
|
|
22
|
+
};
|
|
23
|
+
|
|
20
24
|
declare type StdClient = Client;
|
|
21
25
|
|
|
22
26
|
export { }
|
package/dist/index-node.js
CHANGED
|
@@ -171,7 +171,7 @@ function mapRow(row, columnTypes) {
|
|
|
171
171
|
}
|
|
172
172
|
return result;
|
|
173
173
|
}
|
|
174
|
-
function mapArg(arg, argType) {
|
|
174
|
+
function mapArg(arg, argType, options) {
|
|
175
175
|
if (arg === null) {
|
|
176
176
|
return null;
|
|
177
177
|
}
|
|
@@ -185,7 +185,15 @@ function mapArg(arg, argType) {
|
|
|
185
185
|
arg = new Date(arg);
|
|
186
186
|
}
|
|
187
187
|
if (arg instanceof Date) {
|
|
188
|
-
|
|
188
|
+
const format = options?.timestampFormat ?? "iso8601";
|
|
189
|
+
switch (format) {
|
|
190
|
+
case "unixepoch-ms":
|
|
191
|
+
return arg.getTime();
|
|
192
|
+
case "iso8601":
|
|
193
|
+
return arg.toISOString().replace("Z", "+00:00");
|
|
194
|
+
default:
|
|
195
|
+
throw new Error(`Unknown timestamp format: ${format}`);
|
|
196
|
+
}
|
|
189
197
|
}
|
|
190
198
|
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
191
199
|
return Buffer.from(arg, "base64");
|
|
@@ -269,8 +277,9 @@ function isDriverError(error) {
|
|
|
269
277
|
var debug2 = (0, import_driver_adapter_utils2.Debug)("prisma:driver-adapter:libsql");
|
|
270
278
|
var LOCK_TAG = Symbol();
|
|
271
279
|
var LibSqlQueryable = class {
|
|
272
|
-
constructor(client) {
|
|
280
|
+
constructor(client, adapterOptions) {
|
|
273
281
|
this.client = client;
|
|
282
|
+
this.adapterOptions = adapterOptions;
|
|
274
283
|
}
|
|
275
284
|
provider = "sqlite";
|
|
276
285
|
adapterName = name;
|
|
@@ -309,7 +318,7 @@ var LibSqlQueryable = class {
|
|
|
309
318
|
try {
|
|
310
319
|
const result = await this.client.execute({
|
|
311
320
|
sql: query.sql,
|
|
312
|
-
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
321
|
+
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions))
|
|
313
322
|
});
|
|
314
323
|
return result;
|
|
315
324
|
} catch (e) {
|
|
@@ -324,17 +333,18 @@ var LibSqlQueryable = class {
|
|
|
324
333
|
}
|
|
325
334
|
};
|
|
326
335
|
var LibSqlTransaction = class extends LibSqlQueryable {
|
|
327
|
-
constructor(client, options, unlockParent) {
|
|
328
|
-
super(client);
|
|
336
|
+
constructor(client, options, adapterOptions, unlockParent) {
|
|
337
|
+
super(client, adapterOptions);
|
|
329
338
|
this.options = options;
|
|
330
|
-
this
|
|
339
|
+
this.#unlockParent = unlockParent;
|
|
331
340
|
}
|
|
341
|
+
#unlockParent;
|
|
332
342
|
async commit() {
|
|
333
343
|
debug2(`[js::commit]`);
|
|
334
344
|
try {
|
|
335
345
|
await this.client.commit();
|
|
336
346
|
} finally {
|
|
337
|
-
this
|
|
347
|
+
this.#unlockParent();
|
|
338
348
|
}
|
|
339
349
|
}
|
|
340
350
|
async rollback() {
|
|
@@ -344,13 +354,13 @@ var LibSqlTransaction = class extends LibSqlQueryable {
|
|
|
344
354
|
} catch (error) {
|
|
345
355
|
debug2("error in rollback:", error);
|
|
346
356
|
} finally {
|
|
347
|
-
this
|
|
357
|
+
this.#unlockParent();
|
|
348
358
|
}
|
|
349
359
|
}
|
|
350
360
|
};
|
|
351
361
|
var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
352
|
-
constructor(client) {
|
|
353
|
-
super(client);
|
|
362
|
+
constructor(client, adapterOptions) {
|
|
363
|
+
super(client, adapterOptions);
|
|
354
364
|
}
|
|
355
365
|
async executeScript(script) {
|
|
356
366
|
const release = await this[LOCK_TAG].acquire();
|
|
@@ -377,7 +387,7 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
377
387
|
const release = await this[LOCK_TAG].acquire();
|
|
378
388
|
try {
|
|
379
389
|
const tx = await this.client.transaction("deferred");
|
|
380
|
-
return new LibSqlTransaction(tx, options, release);
|
|
390
|
+
return new LibSqlTransaction(tx, options, this.adapterOptions, release);
|
|
381
391
|
} catch (e) {
|
|
382
392
|
release();
|
|
383
393
|
this.onError(e);
|
|
@@ -389,16 +399,21 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
389
399
|
}
|
|
390
400
|
};
|
|
391
401
|
var PrismaLibSQLAdapterFactoryBase = class {
|
|
392
|
-
constructor(config) {
|
|
393
|
-
this.config = config;
|
|
394
|
-
}
|
|
395
402
|
provider = "sqlite";
|
|
396
403
|
adapterName = name;
|
|
404
|
+
#config;
|
|
405
|
+
#options;
|
|
406
|
+
constructor(config, options) {
|
|
407
|
+
this.#config = config;
|
|
408
|
+
this.#options = options;
|
|
409
|
+
}
|
|
397
410
|
connect() {
|
|
398
|
-
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this
|
|
411
|
+
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this.#config), this.#options));
|
|
399
412
|
}
|
|
400
413
|
connectToShadowDb() {
|
|
401
|
-
return Promise.resolve(
|
|
414
|
+
return Promise.resolve(
|
|
415
|
+
new PrismaLibSQLAdapter(this.createClient({ ...this.#config, url: ":memory:" }), this.#options)
|
|
416
|
+
);
|
|
402
417
|
}
|
|
403
418
|
};
|
|
404
419
|
|
package/dist/index-node.mjs
CHANGED
|
@@ -145,7 +145,7 @@ function mapRow(row, columnTypes) {
|
|
|
145
145
|
}
|
|
146
146
|
return result;
|
|
147
147
|
}
|
|
148
|
-
function mapArg(arg, argType) {
|
|
148
|
+
function mapArg(arg, argType, options) {
|
|
149
149
|
if (arg === null) {
|
|
150
150
|
return null;
|
|
151
151
|
}
|
|
@@ -159,7 +159,15 @@ function mapArg(arg, argType) {
|
|
|
159
159
|
arg = new Date(arg);
|
|
160
160
|
}
|
|
161
161
|
if (arg instanceof Date) {
|
|
162
|
-
|
|
162
|
+
const format = options?.timestampFormat ?? "iso8601";
|
|
163
|
+
switch (format) {
|
|
164
|
+
case "unixepoch-ms":
|
|
165
|
+
return arg.getTime();
|
|
166
|
+
case "iso8601":
|
|
167
|
+
return arg.toISOString().replace("Z", "+00:00");
|
|
168
|
+
default:
|
|
169
|
+
throw new Error(`Unknown timestamp format: ${format}`);
|
|
170
|
+
}
|
|
163
171
|
}
|
|
164
172
|
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
165
173
|
return Buffer.from(arg, "base64");
|
|
@@ -243,8 +251,9 @@ function isDriverError(error) {
|
|
|
243
251
|
var debug2 = Debug2("prisma:driver-adapter:libsql");
|
|
244
252
|
var LOCK_TAG = Symbol();
|
|
245
253
|
var LibSqlQueryable = class {
|
|
246
|
-
constructor(client) {
|
|
254
|
+
constructor(client, adapterOptions) {
|
|
247
255
|
this.client = client;
|
|
256
|
+
this.adapterOptions = adapterOptions;
|
|
248
257
|
}
|
|
249
258
|
provider = "sqlite";
|
|
250
259
|
adapterName = name;
|
|
@@ -283,7 +292,7 @@ var LibSqlQueryable = class {
|
|
|
283
292
|
try {
|
|
284
293
|
const result = await this.client.execute({
|
|
285
294
|
sql: query.sql,
|
|
286
|
-
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
295
|
+
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions))
|
|
287
296
|
});
|
|
288
297
|
return result;
|
|
289
298
|
} catch (e) {
|
|
@@ -298,17 +307,18 @@ var LibSqlQueryable = class {
|
|
|
298
307
|
}
|
|
299
308
|
};
|
|
300
309
|
var LibSqlTransaction = class extends LibSqlQueryable {
|
|
301
|
-
constructor(client, options, unlockParent) {
|
|
302
|
-
super(client);
|
|
310
|
+
constructor(client, options, adapterOptions, unlockParent) {
|
|
311
|
+
super(client, adapterOptions);
|
|
303
312
|
this.options = options;
|
|
304
|
-
this
|
|
313
|
+
this.#unlockParent = unlockParent;
|
|
305
314
|
}
|
|
315
|
+
#unlockParent;
|
|
306
316
|
async commit() {
|
|
307
317
|
debug2(`[js::commit]`);
|
|
308
318
|
try {
|
|
309
319
|
await this.client.commit();
|
|
310
320
|
} finally {
|
|
311
|
-
this
|
|
321
|
+
this.#unlockParent();
|
|
312
322
|
}
|
|
313
323
|
}
|
|
314
324
|
async rollback() {
|
|
@@ -318,13 +328,13 @@ var LibSqlTransaction = class extends LibSqlQueryable {
|
|
|
318
328
|
} catch (error) {
|
|
319
329
|
debug2("error in rollback:", error);
|
|
320
330
|
} finally {
|
|
321
|
-
this
|
|
331
|
+
this.#unlockParent();
|
|
322
332
|
}
|
|
323
333
|
}
|
|
324
334
|
};
|
|
325
335
|
var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
326
|
-
constructor(client) {
|
|
327
|
-
super(client);
|
|
336
|
+
constructor(client, adapterOptions) {
|
|
337
|
+
super(client, adapterOptions);
|
|
328
338
|
}
|
|
329
339
|
async executeScript(script) {
|
|
330
340
|
const release = await this[LOCK_TAG].acquire();
|
|
@@ -351,7 +361,7 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
351
361
|
const release = await this[LOCK_TAG].acquire();
|
|
352
362
|
try {
|
|
353
363
|
const tx = await this.client.transaction("deferred");
|
|
354
|
-
return new LibSqlTransaction(tx, options, release);
|
|
364
|
+
return new LibSqlTransaction(tx, options, this.adapterOptions, release);
|
|
355
365
|
} catch (e) {
|
|
356
366
|
release();
|
|
357
367
|
this.onError(e);
|
|
@@ -363,16 +373,21 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
363
373
|
}
|
|
364
374
|
};
|
|
365
375
|
var PrismaLibSQLAdapterFactoryBase = class {
|
|
366
|
-
constructor(config) {
|
|
367
|
-
this.config = config;
|
|
368
|
-
}
|
|
369
376
|
provider = "sqlite";
|
|
370
377
|
adapterName = name;
|
|
378
|
+
#config;
|
|
379
|
+
#options;
|
|
380
|
+
constructor(config, options) {
|
|
381
|
+
this.#config = config;
|
|
382
|
+
this.#options = options;
|
|
383
|
+
}
|
|
371
384
|
connect() {
|
|
372
|
-
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this
|
|
385
|
+
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this.#config), this.#options));
|
|
373
386
|
}
|
|
374
387
|
connectToShadowDb() {
|
|
375
|
-
return Promise.resolve(
|
|
388
|
+
return Promise.resolve(
|
|
389
|
+
new PrismaLibSQLAdapter(this.createClient({ ...this.#config, url: ":memory:" }), this.#options)
|
|
390
|
+
);
|
|
376
391
|
}
|
|
377
392
|
};
|
|
378
393
|
|
package/dist/index-web.d.mts
CHANGED
|
@@ -10,15 +10,19 @@ export declare class PrismaLibSQL extends PrismaLibSQLAdapterFactoryBase {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
declare abstract class PrismaLibSQLAdapterFactoryBase implements SqlMigrationAwareDriverAdapterFactory {
|
|
13
|
-
private
|
|
13
|
+
#private;
|
|
14
14
|
readonly provider = "sqlite";
|
|
15
15
|
readonly adapterName: string;
|
|
16
|
-
constructor(config: Config);
|
|
16
|
+
constructor(config: Config, options?: PrismaLibSQLOptions);
|
|
17
17
|
connect(): Promise<SqlDriverAdapter>;
|
|
18
18
|
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
19
19
|
abstract createClient(config: Config): StdClient;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
declare type PrismaLibSQLOptions = {
|
|
23
|
+
timestampFormat?: 'iso8601' | 'unixepoch-ms';
|
|
24
|
+
};
|
|
25
|
+
|
|
22
26
|
declare type StdClient = Client;
|
|
23
27
|
|
|
24
28
|
export { }
|
package/dist/index-web.d.ts
CHANGED
|
@@ -10,15 +10,19 @@ export declare class PrismaLibSQL extends PrismaLibSQLAdapterFactoryBase {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
declare abstract class PrismaLibSQLAdapterFactoryBase implements SqlMigrationAwareDriverAdapterFactory {
|
|
13
|
-
private
|
|
13
|
+
#private;
|
|
14
14
|
readonly provider = "sqlite";
|
|
15
15
|
readonly adapterName: string;
|
|
16
|
-
constructor(config: Config);
|
|
16
|
+
constructor(config: Config, options?: PrismaLibSQLOptions);
|
|
17
17
|
connect(): Promise<SqlDriverAdapter>;
|
|
18
18
|
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
19
19
|
abstract createClient(config: Config): StdClient;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
declare type PrismaLibSQLOptions = {
|
|
23
|
+
timestampFormat?: 'iso8601' | 'unixepoch-ms';
|
|
24
|
+
};
|
|
25
|
+
|
|
22
26
|
declare type StdClient = Client;
|
|
23
27
|
|
|
24
28
|
export { }
|
package/dist/index-web.js
CHANGED
|
@@ -171,7 +171,7 @@ function mapRow(row, columnTypes) {
|
|
|
171
171
|
}
|
|
172
172
|
return result;
|
|
173
173
|
}
|
|
174
|
-
function mapArg(arg, argType) {
|
|
174
|
+
function mapArg(arg, argType, options) {
|
|
175
175
|
if (arg === null) {
|
|
176
176
|
return null;
|
|
177
177
|
}
|
|
@@ -185,7 +185,15 @@ function mapArg(arg, argType) {
|
|
|
185
185
|
arg = new Date(arg);
|
|
186
186
|
}
|
|
187
187
|
if (arg instanceof Date) {
|
|
188
|
-
|
|
188
|
+
const format = options?.timestampFormat ?? "iso8601";
|
|
189
|
+
switch (format) {
|
|
190
|
+
case "unixepoch-ms":
|
|
191
|
+
return arg.getTime();
|
|
192
|
+
case "iso8601":
|
|
193
|
+
return arg.toISOString().replace("Z", "+00:00");
|
|
194
|
+
default:
|
|
195
|
+
throw new Error(`Unknown timestamp format: ${format}`);
|
|
196
|
+
}
|
|
189
197
|
}
|
|
190
198
|
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
191
199
|
return Buffer.from(arg, "base64");
|
|
@@ -269,8 +277,9 @@ function isDriverError(error) {
|
|
|
269
277
|
var debug2 = (0, import_driver_adapter_utils2.Debug)("prisma:driver-adapter:libsql");
|
|
270
278
|
var LOCK_TAG = Symbol();
|
|
271
279
|
var LibSqlQueryable = class {
|
|
272
|
-
constructor(client) {
|
|
280
|
+
constructor(client, adapterOptions) {
|
|
273
281
|
this.client = client;
|
|
282
|
+
this.adapterOptions = adapterOptions;
|
|
274
283
|
}
|
|
275
284
|
provider = "sqlite";
|
|
276
285
|
adapterName = name;
|
|
@@ -309,7 +318,7 @@ var LibSqlQueryable = class {
|
|
|
309
318
|
try {
|
|
310
319
|
const result = await this.client.execute({
|
|
311
320
|
sql: query.sql,
|
|
312
|
-
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
321
|
+
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions))
|
|
313
322
|
});
|
|
314
323
|
return result;
|
|
315
324
|
} catch (e) {
|
|
@@ -324,17 +333,18 @@ var LibSqlQueryable = class {
|
|
|
324
333
|
}
|
|
325
334
|
};
|
|
326
335
|
var LibSqlTransaction = class extends LibSqlQueryable {
|
|
327
|
-
constructor(client, options, unlockParent) {
|
|
328
|
-
super(client);
|
|
336
|
+
constructor(client, options, adapterOptions, unlockParent) {
|
|
337
|
+
super(client, adapterOptions);
|
|
329
338
|
this.options = options;
|
|
330
|
-
this
|
|
339
|
+
this.#unlockParent = unlockParent;
|
|
331
340
|
}
|
|
341
|
+
#unlockParent;
|
|
332
342
|
async commit() {
|
|
333
343
|
debug2(`[js::commit]`);
|
|
334
344
|
try {
|
|
335
345
|
await this.client.commit();
|
|
336
346
|
} finally {
|
|
337
|
-
this
|
|
347
|
+
this.#unlockParent();
|
|
338
348
|
}
|
|
339
349
|
}
|
|
340
350
|
async rollback() {
|
|
@@ -344,13 +354,13 @@ var LibSqlTransaction = class extends LibSqlQueryable {
|
|
|
344
354
|
} catch (error) {
|
|
345
355
|
debug2("error in rollback:", error);
|
|
346
356
|
} finally {
|
|
347
|
-
this
|
|
357
|
+
this.#unlockParent();
|
|
348
358
|
}
|
|
349
359
|
}
|
|
350
360
|
};
|
|
351
361
|
var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
352
|
-
constructor(client) {
|
|
353
|
-
super(client);
|
|
362
|
+
constructor(client, adapterOptions) {
|
|
363
|
+
super(client, adapterOptions);
|
|
354
364
|
}
|
|
355
365
|
async executeScript(script) {
|
|
356
366
|
const release = await this[LOCK_TAG].acquire();
|
|
@@ -377,7 +387,7 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
377
387
|
const release = await this[LOCK_TAG].acquire();
|
|
378
388
|
try {
|
|
379
389
|
const tx = await this.client.transaction("deferred");
|
|
380
|
-
return new LibSqlTransaction(tx, options, release);
|
|
390
|
+
return new LibSqlTransaction(tx, options, this.adapterOptions, release);
|
|
381
391
|
} catch (e) {
|
|
382
392
|
release();
|
|
383
393
|
this.onError(e);
|
|
@@ -389,16 +399,21 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
389
399
|
}
|
|
390
400
|
};
|
|
391
401
|
var PrismaLibSQLAdapterFactoryBase = class {
|
|
392
|
-
constructor(config) {
|
|
393
|
-
this.config = config;
|
|
394
|
-
}
|
|
395
402
|
provider = "sqlite";
|
|
396
403
|
adapterName = name;
|
|
404
|
+
#config;
|
|
405
|
+
#options;
|
|
406
|
+
constructor(config, options) {
|
|
407
|
+
this.#config = config;
|
|
408
|
+
this.#options = options;
|
|
409
|
+
}
|
|
397
410
|
connect() {
|
|
398
|
-
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this
|
|
411
|
+
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this.#config), this.#options));
|
|
399
412
|
}
|
|
400
413
|
connectToShadowDb() {
|
|
401
|
-
return Promise.resolve(
|
|
414
|
+
return Promise.resolve(
|
|
415
|
+
new PrismaLibSQLAdapter(this.createClient({ ...this.#config, url: ":memory:" }), this.#options)
|
|
416
|
+
);
|
|
402
417
|
}
|
|
403
418
|
};
|
|
404
419
|
|
package/dist/index-web.mjs
CHANGED
|
@@ -145,7 +145,7 @@ function mapRow(row, columnTypes) {
|
|
|
145
145
|
}
|
|
146
146
|
return result;
|
|
147
147
|
}
|
|
148
|
-
function mapArg(arg, argType) {
|
|
148
|
+
function mapArg(arg, argType, options) {
|
|
149
149
|
if (arg === null) {
|
|
150
150
|
return null;
|
|
151
151
|
}
|
|
@@ -159,7 +159,15 @@ function mapArg(arg, argType) {
|
|
|
159
159
|
arg = new Date(arg);
|
|
160
160
|
}
|
|
161
161
|
if (arg instanceof Date) {
|
|
162
|
-
|
|
162
|
+
const format = options?.timestampFormat ?? "iso8601";
|
|
163
|
+
switch (format) {
|
|
164
|
+
case "unixepoch-ms":
|
|
165
|
+
return arg.getTime();
|
|
166
|
+
case "iso8601":
|
|
167
|
+
return arg.toISOString().replace("Z", "+00:00");
|
|
168
|
+
default:
|
|
169
|
+
throw new Error(`Unknown timestamp format: ${format}`);
|
|
170
|
+
}
|
|
163
171
|
}
|
|
164
172
|
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
165
173
|
return Buffer.from(arg, "base64");
|
|
@@ -243,8 +251,9 @@ function isDriverError(error) {
|
|
|
243
251
|
var debug2 = Debug2("prisma:driver-adapter:libsql");
|
|
244
252
|
var LOCK_TAG = Symbol();
|
|
245
253
|
var LibSqlQueryable = class {
|
|
246
|
-
constructor(client) {
|
|
254
|
+
constructor(client, adapterOptions) {
|
|
247
255
|
this.client = client;
|
|
256
|
+
this.adapterOptions = adapterOptions;
|
|
248
257
|
}
|
|
249
258
|
provider = "sqlite";
|
|
250
259
|
adapterName = name;
|
|
@@ -283,7 +292,7 @@ var LibSqlQueryable = class {
|
|
|
283
292
|
try {
|
|
284
293
|
const result = await this.client.execute({
|
|
285
294
|
sql: query.sql,
|
|
286
|
-
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
295
|
+
args: query.args.map((arg, i) => mapArg(arg, query.argTypes[i], this.adapterOptions))
|
|
287
296
|
});
|
|
288
297
|
return result;
|
|
289
298
|
} catch (e) {
|
|
@@ -298,17 +307,18 @@ var LibSqlQueryable = class {
|
|
|
298
307
|
}
|
|
299
308
|
};
|
|
300
309
|
var LibSqlTransaction = class extends LibSqlQueryable {
|
|
301
|
-
constructor(client, options, unlockParent) {
|
|
302
|
-
super(client);
|
|
310
|
+
constructor(client, options, adapterOptions, unlockParent) {
|
|
311
|
+
super(client, adapterOptions);
|
|
303
312
|
this.options = options;
|
|
304
|
-
this
|
|
313
|
+
this.#unlockParent = unlockParent;
|
|
305
314
|
}
|
|
315
|
+
#unlockParent;
|
|
306
316
|
async commit() {
|
|
307
317
|
debug2(`[js::commit]`);
|
|
308
318
|
try {
|
|
309
319
|
await this.client.commit();
|
|
310
320
|
} finally {
|
|
311
|
-
this
|
|
321
|
+
this.#unlockParent();
|
|
312
322
|
}
|
|
313
323
|
}
|
|
314
324
|
async rollback() {
|
|
@@ -318,13 +328,13 @@ var LibSqlTransaction = class extends LibSqlQueryable {
|
|
|
318
328
|
} catch (error) {
|
|
319
329
|
debug2("error in rollback:", error);
|
|
320
330
|
} finally {
|
|
321
|
-
this
|
|
331
|
+
this.#unlockParent();
|
|
322
332
|
}
|
|
323
333
|
}
|
|
324
334
|
};
|
|
325
335
|
var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
326
|
-
constructor(client) {
|
|
327
|
-
super(client);
|
|
336
|
+
constructor(client, adapterOptions) {
|
|
337
|
+
super(client, adapterOptions);
|
|
328
338
|
}
|
|
329
339
|
async executeScript(script) {
|
|
330
340
|
const release = await this[LOCK_TAG].acquire();
|
|
@@ -351,7 +361,7 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
351
361
|
const release = await this[LOCK_TAG].acquire();
|
|
352
362
|
try {
|
|
353
363
|
const tx = await this.client.transaction("deferred");
|
|
354
|
-
return new LibSqlTransaction(tx, options, release);
|
|
364
|
+
return new LibSqlTransaction(tx, options, this.adapterOptions, release);
|
|
355
365
|
} catch (e) {
|
|
356
366
|
release();
|
|
357
367
|
this.onError(e);
|
|
@@ -363,16 +373,21 @@ var PrismaLibSQLAdapter = class extends LibSqlQueryable {
|
|
|
363
373
|
}
|
|
364
374
|
};
|
|
365
375
|
var PrismaLibSQLAdapterFactoryBase = class {
|
|
366
|
-
constructor(config) {
|
|
367
|
-
this.config = config;
|
|
368
|
-
}
|
|
369
376
|
provider = "sqlite";
|
|
370
377
|
adapterName = name;
|
|
378
|
+
#config;
|
|
379
|
+
#options;
|
|
380
|
+
constructor(config, options) {
|
|
381
|
+
this.#config = config;
|
|
382
|
+
this.#options = options;
|
|
383
|
+
}
|
|
371
384
|
connect() {
|
|
372
|
-
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this
|
|
385
|
+
return Promise.resolve(new PrismaLibSQLAdapter(this.createClient(this.#config), this.#options));
|
|
373
386
|
}
|
|
374
387
|
connectToShadowDb() {
|
|
375
|
-
return Promise.resolve(
|
|
388
|
+
return Promise.resolve(
|
|
389
|
+
new PrismaLibSQLAdapter(this.createClient({ ...this.#config, url: ":memory:" }), this.#options)
|
|
390
|
+
);
|
|
376
391
|
}
|
|
377
392
|
};
|
|
378
393
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-libsql",
|
|
3
|
-
"version": "6.16.0-integration-feat-orm-1074-package-dev-export.
|
|
3
|
+
"version": "6.16.0-integration-feat-orm-1074-package-dev-export.4",
|
|
4
4
|
"description": "Prisma's driver adapter for libSQL and Turso",
|
|
5
5
|
"main": "dist/index-node.js",
|
|
6
6
|
"module": "dist/index-node.mjs",
|
|
@@ -43,15 +43,11 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@libsql/client": "^0.3.5 || ^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0",
|
|
45
45
|
"async-mutex": "0.5.0",
|
|
46
|
-
"@prisma/driver-adapter-utils": "6.16.0-integration-feat-orm-1074-package-dev-export.
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"jest": "29.7.0",
|
|
50
|
-
"jest-junit": "16.0.0"
|
|
46
|
+
"@prisma/driver-adapter-utils": "6.16.0-integration-feat-orm-1074-package-dev-export.4"
|
|
51
47
|
},
|
|
52
48
|
"scripts": {
|
|
53
49
|
"dev": "DEV=true tsx helpers/build.ts",
|
|
54
50
|
"build": "tsx helpers/build.ts",
|
|
55
|
-
"test": "
|
|
51
|
+
"test": "vitest run"
|
|
56
52
|
}
|
|
57
53
|
}
|