@tursodatabase/database-common 0.4.0-pre.1 → 0.4.0-pre.15
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/compat.d.ts.map +1 -1
- package/dist/compat.js +5 -3
- package/dist/promise.d.ts +5 -2
- package/dist/promise.d.ts.map +1 -1
- package/dist/promise.js +22 -11
- package/package.json +1 -1
package/dist/compat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../compat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAgC,MAAM,YAAY,CAAC;AAyB3F;;GAEG;AACH,cAAM,QAAQ;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IAEvB,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,cAAc,CAAkB;IAExC;;;;;;;;;OASG;gBACS,EAAE,EAAE,cAAc;IAa9B;;;;OAIG;IACH,OAAO,CAAC,GAAG,KAAA;IAYX;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAA;IAmCd,MAAM,CAAC,MAAM,KAAA,EAAE,OAAO,KAAA;IAoBtB,MAAM,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA;IAIxB,SAAS,CAAC,OAAO,KAAA;IAIjB,QAAQ,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,EAAE,EAAE,KAAA;IAI1B,SAAS,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA;IAIvB,KAAK,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA;IAInB,aAAa,CAAC,IAAI,KAAA;IAIlB,wBAAwB;IAIxB;;;;;OAKG;IACH,IAAI,CAAC,GAAG,KAAA;IAsBR;;OAEG;IACH,SAAS;I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EAAE,OAAO,KAAA,EAAE,EAAE,KAAA;IAI1B,SAAS,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA;IAIvB,KAAK,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA;IAInB,aAAa,CAAC,IAAI,KAAA;IAIlB,wBAAwB;IAIxB;;;;;OAKG;IACH,IAAI,CAAC,GAAG,KAAA;IAsBR;;OAEG;IACH,SAAS;IAIT;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,KAAA;IAI1B;;OAEG;IACH,KAAK;CAGN;AAED;;GAEG;AACH,cAAM,SAAS;IACb,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,EAAE,cAAc,CAAC;gBAEP,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,cAAc;IAKrD;;;;OAIG;IACH,GAAG,CAAC,GAAG,KAAA;IAKP;;;;OAIG;IACH,KAAK,CAAC,SAAS,KAAA;IAKf;;;;OAIG;IACH,YAAY,CAAC,MAAM,KAAA;IAKnB;;;;OAIG;IACH,OAAO;IAIP,IAAI,MAAM,SAET;IAED,IAAI,MAAM,SAET;IAED,IAAI,QAAQ,mBAEX;IAED;;OAEG;IACH,GAAG,CAAC,GAAG,cAAc,OAAA;;;;IA0BrB;;;;OAIG;IACH,GAAG,CAAC,GAAG,cAAc,OAAA;IAoBrB;;;;OAIG;IACF,OAAO,CAAC,GAAG,cAAc,OAAA;IAmB1B;;;;OAIG;IACH,GAAG,CAAC,GAAG,cAAc,OAAA;IAoBrB;;OAEG;IACH,SAAS;IAKT;;;;;OAKG;IACH,IAAI,CAAC,GAAG,cAAc,OAAA;IAStB,KAAK;CAGN;AAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/compat.js
CHANGED
|
@@ -277,6 +277,7 @@ class Statement {
|
|
|
277
277
|
get(...bindParameters) {
|
|
278
278
|
this.stmt.reset();
|
|
279
279
|
bindParams(this.stmt, bindParameters);
|
|
280
|
+
let row = undefined;
|
|
280
281
|
for (;;) {
|
|
281
282
|
const stepResult = this.stmt.stepSync();
|
|
282
283
|
if (stepResult === STEP_IO) {
|
|
@@ -284,12 +285,13 @@ class Statement {
|
|
|
284
285
|
continue;
|
|
285
286
|
}
|
|
286
287
|
if (stepResult === STEP_DONE) {
|
|
287
|
-
|
|
288
|
+
break;
|
|
288
289
|
}
|
|
289
|
-
if (stepResult === STEP_ROW) {
|
|
290
|
-
|
|
290
|
+
if (stepResult === STEP_ROW && row === undefined) {
|
|
291
|
+
row = this.stmt.row();
|
|
291
292
|
}
|
|
292
293
|
}
|
|
294
|
+
return row;
|
|
293
295
|
}
|
|
294
296
|
/**
|
|
295
297
|
* Executes the SQL statement and returns an iterator to the resulting rows.
|
package/dist/promise.d.ts
CHANGED
|
@@ -10,10 +10,11 @@ declare class Database {
|
|
|
10
10
|
memory: boolean;
|
|
11
11
|
inTransaction: boolean;
|
|
12
12
|
private db;
|
|
13
|
+
private ioStep;
|
|
13
14
|
private execLock;
|
|
14
15
|
private _inTransaction;
|
|
15
16
|
protected connected: boolean;
|
|
16
|
-
constructor(db: NativeDatabase);
|
|
17
|
+
constructor(db: NativeDatabase, ioStep?: () => Promise<void>);
|
|
17
18
|
/**
|
|
18
19
|
* connect database
|
|
19
20
|
*/
|
|
@@ -74,7 +75,8 @@ declare class Statement {
|
|
|
74
75
|
private stmt;
|
|
75
76
|
private db;
|
|
76
77
|
private execLock;
|
|
77
|
-
|
|
78
|
+
private ioStep;
|
|
79
|
+
constructor(stmt: MaybeLazy<NativeStatement>, db: NativeDatabase, execLock: AsyncLock, ioStep: () => Promise<void>);
|
|
78
80
|
/**
|
|
79
81
|
* Toggle raw mode.
|
|
80
82
|
*
|
|
@@ -127,6 +129,7 @@ declare class Statement {
|
|
|
127
129
|
* @param bindParameters - The bind parameters for executing the statement.
|
|
128
130
|
*/
|
|
129
131
|
all(...bindParameters: any[]): Promise<any[]>;
|
|
132
|
+
io(): Promise<void>;
|
|
130
133
|
/**
|
|
131
134
|
* Interrupts the statement.
|
|
132
135
|
*/
|
package/dist/promise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAA8C,MAAM,YAAY,CAAC;AAyBzG;;GAEG;AACH,cAAM,QAAQ;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IAEvB,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,cAAc,CAAkB;IACxC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAS;gBAEzB,EAAE,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../promise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAA8C,MAAM,YAAY,CAAC;AAyBzG;;GAEG;AACH,cAAM,QAAQ;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IAEvB,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,cAAc,CAAkB;IACxC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAS;gBAEzB,EAAE,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAa5D;;OAEG;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eAAe,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAOlH;;;;OAIG;IACH,GAAG,CAAC,GAAG,KAAA;IAKP;;;;OAIG;IACH,KAAK,CAAC,SAAS,KAAA;IAKf;;;;OAIG;IACH,YAAY,CAAC,MAAM,KAAA;IAKnB;;;;OAIG;IACH,OAAO;IAIP,IAAI,MAAM,SAET;IAED,IAAI,MAAM,SAET;IAED,IAAI,QAAQ,mBAEX;IAED;;OAEG;IACG,GAAG,CAAC,GAAG,cAAc,OAAA;;;;IAiC3B;;;;OAIG;IACG,GAAG,CAAC,GAAG,cAAc,OAAA;IA6B3B;;;;OAIG;IACI,OAAO,CAAC,GAAG,cAAc,OAAA;IA0BhC;;;;OAIG;IACG,GAAG,CAAC,GAAG,cAAc,OAAA;IA6BrB,EAAE;IAKR;;OAEG;IACH,SAAS;IAKT;;;;;OAKG;IACH,IAAI,CAAC,GAAG,cAAc,OAAA;IAStB,KAAK;CAUN;AAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,CAAA"}
|
package/dist/promise.js
CHANGED
|
@@ -27,12 +27,14 @@ class Database {
|
|
|
27
27
|
memory;
|
|
28
28
|
inTransaction;
|
|
29
29
|
db;
|
|
30
|
+
ioStep;
|
|
30
31
|
execLock;
|
|
31
32
|
_inTransaction = false;
|
|
32
33
|
connected = false;
|
|
33
|
-
constructor(db) {
|
|
34
|
+
constructor(db, ioStep) {
|
|
34
35
|
this.db = db;
|
|
35
36
|
this.execLock = new AsyncLock();
|
|
37
|
+
this.ioStep = ioStep ?? (async () => { });
|
|
36
38
|
Object.defineProperties(this, {
|
|
37
39
|
name: { get: () => this.db.path },
|
|
38
40
|
readonly: { get: () => this.db.readonly },
|
|
@@ -62,10 +64,10 @@ class Database {
|
|
|
62
64
|
}
|
|
63
65
|
try {
|
|
64
66
|
if (this.connected) {
|
|
65
|
-
return new Statement(maybeValue(this.db.prepare(sql)), this.db, this.execLock);
|
|
67
|
+
return new Statement(maybeValue(this.db.prepare(sql)), this.db, this.execLock, this.ioStep);
|
|
66
68
|
}
|
|
67
69
|
else {
|
|
68
|
-
return new Statement(maybePromise(() => this.connect().then(() => this.db.prepare(sql))), this.db, this.execLock);
|
|
70
|
+
return new Statement(maybePromise(() => this.connect().then(() => this.db.prepare(sql))), this.db, this.execLock, this.ioStep);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
catch (err) {
|
|
@@ -163,6 +165,7 @@ class Database {
|
|
|
163
165
|
const stepResult = exec.stepSync();
|
|
164
166
|
if (stepResult === STEP_IO) {
|
|
165
167
|
await this.db.ioLoopAsync();
|
|
168
|
+
await this.ioStep();
|
|
166
169
|
continue;
|
|
167
170
|
}
|
|
168
171
|
if (stepResult === STEP_DONE) {
|
|
@@ -247,10 +250,12 @@ class Statement {
|
|
|
247
250
|
stmt;
|
|
248
251
|
db;
|
|
249
252
|
execLock;
|
|
250
|
-
|
|
253
|
+
ioStep;
|
|
254
|
+
constructor(stmt, db, execLock, ioStep) {
|
|
251
255
|
this.stmt = stmt;
|
|
252
256
|
this.db = db;
|
|
253
257
|
this.execLock = execLock;
|
|
258
|
+
this.ioStep = ioStep;
|
|
254
259
|
}
|
|
255
260
|
/**
|
|
256
261
|
* Toggle raw mode.
|
|
@@ -308,7 +313,7 @@ class Statement {
|
|
|
308
313
|
while (true) {
|
|
309
314
|
const stepResult = await stmt.stepSync();
|
|
310
315
|
if (stepResult === STEP_IO) {
|
|
311
|
-
await this.
|
|
316
|
+
await this.io();
|
|
312
317
|
continue;
|
|
313
318
|
}
|
|
314
319
|
if (stepResult === STEP_DONE) {
|
|
@@ -337,21 +342,23 @@ class Statement {
|
|
|
337
342
|
let stmt = await this.stmt.resolve();
|
|
338
343
|
bindParams(stmt, bindParameters);
|
|
339
344
|
await this.execLock.acquire();
|
|
345
|
+
let row = undefined;
|
|
340
346
|
try {
|
|
341
347
|
while (true) {
|
|
342
348
|
const stepResult = await stmt.stepSync();
|
|
343
349
|
if (stepResult === STEP_IO) {
|
|
344
|
-
await this.
|
|
350
|
+
await this.io();
|
|
345
351
|
continue;
|
|
346
352
|
}
|
|
347
353
|
if (stepResult === STEP_DONE) {
|
|
348
|
-
|
|
354
|
+
break;
|
|
349
355
|
}
|
|
350
|
-
if (stepResult === STEP_ROW) {
|
|
351
|
-
|
|
352
|
-
|
|
356
|
+
if (stepResult === STEP_ROW && row === undefined) {
|
|
357
|
+
row = stmt.row();
|
|
358
|
+
continue;
|
|
353
359
|
}
|
|
354
360
|
}
|
|
361
|
+
return row;
|
|
355
362
|
}
|
|
356
363
|
finally {
|
|
357
364
|
stmt.reset();
|
|
@@ -401,7 +408,7 @@ class Statement {
|
|
|
401
408
|
while (true) {
|
|
402
409
|
const stepResult = await stmt.stepSync();
|
|
403
410
|
if (stepResult === STEP_IO) {
|
|
404
|
-
await this.
|
|
411
|
+
await this.io();
|
|
405
412
|
continue;
|
|
406
413
|
}
|
|
407
414
|
if (stepResult === STEP_DONE) {
|
|
@@ -418,6 +425,10 @@ class Statement {
|
|
|
418
425
|
this.execLock.release();
|
|
419
426
|
}
|
|
420
427
|
}
|
|
428
|
+
async io() {
|
|
429
|
+
await this.db.ioLoopAsync();
|
|
430
|
+
await this.ioStep();
|
|
431
|
+
}
|
|
421
432
|
/**
|
|
422
433
|
* Interrupts the statement.
|
|
423
434
|
*/
|