@tursodatabase/database-common 0.5.0-pre.6 → 0.5.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.
- package/dist/compat.d.ts +1 -1
- package/dist/compat.d.ts.map +1 -1
- package/dist/compat.js +7 -1
- package/dist/promise.d.ts +2 -1
- package/dist/promise.d.ts.map +1 -1
- package/dist/promise.js +17 -5
- package/package.json +1 -1
package/dist/compat.d.ts
CHANGED
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;
|
|
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,cA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AAI,CAAC,GAAG,cAAc,OAAA;IAStB,KAAK;CAGN;AAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/compat.js
CHANGED
|
@@ -54,6 +54,9 @@ class Database {
|
|
|
54
54
|
* @param {string} sql - The SQL statement string to prepare.
|
|
55
55
|
*/
|
|
56
56
|
prepare(sql) {
|
|
57
|
+
if (!this.open) {
|
|
58
|
+
throw new TypeError("The database connection is not open");
|
|
59
|
+
}
|
|
57
60
|
if (!sql) {
|
|
58
61
|
throw new RangeError("The supplied SQL string contains no statements");
|
|
59
62
|
}
|
|
@@ -148,6 +151,9 @@ class Database {
|
|
|
148
151
|
* @param {string} sql - The string containing SQL statements to execute
|
|
149
152
|
*/
|
|
150
153
|
exec(sql) {
|
|
154
|
+
if (!this.open) {
|
|
155
|
+
throw new TypeError("The database connection is not open");
|
|
156
|
+
}
|
|
151
157
|
const exec = this.db.executor(sql);
|
|
152
158
|
try {
|
|
153
159
|
while (true) {
|
|
@@ -239,7 +245,7 @@ class Statement {
|
|
|
239
245
|
throw new Error("not implemented");
|
|
240
246
|
}
|
|
241
247
|
get reader() {
|
|
242
|
-
|
|
248
|
+
return this.stmt.columns().length > 0;
|
|
243
249
|
}
|
|
244
250
|
get database() {
|
|
245
251
|
return this.db;
|
package/dist/promise.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ declare class Database {
|
|
|
60
60
|
* Closes the database connection.
|
|
61
61
|
*/
|
|
62
62
|
close(): Promise<void>;
|
|
63
|
+
io(): Promise<void>;
|
|
63
64
|
}
|
|
64
65
|
interface MaybeLazy<T> {
|
|
65
66
|
apply(fn: (value: T) => void): any;
|
|
@@ -102,7 +103,7 @@ declare class Statement {
|
|
|
102
103
|
*/
|
|
103
104
|
columns(): import("./types.js").TableColumn[];
|
|
104
105
|
get source(): void;
|
|
105
|
-
get reader():
|
|
106
|
+
get reader(): boolean;
|
|
106
107
|
get database(): NativeDatabase;
|
|
107
108
|
/**
|
|
108
109
|
* Executes the SQL statement and returns an info object.
|
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,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;IACG,OAAO;IAMb;;;;OAIG;IACH,OAAO,CAAC,GAAG,KAAA;
|
|
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,O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ACH,cAAM,SAAS;IACb,OAAO,CAAC,IAAI,CAA6B;IACzC,OAAO,CAAC,EAAE,CAAiB;IAC3B,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,MAAM,CAAsB;gBAExB,IAAI,EAAE,SAAS,CAAC,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,IAAI,OAAO,CAEpB;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;IAIR;;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
|
@@ -59,6 +59,11 @@ class Database {
|
|
|
59
59
|
* @param {string} sql - The SQL statement string to prepare.
|
|
60
60
|
*/
|
|
61
61
|
prepare(sql) {
|
|
62
|
+
// Only throw if we connected before but now the database is closed
|
|
63
|
+
// Allow implicit connection if not connected yet
|
|
64
|
+
if (this.connected && !this.open) {
|
|
65
|
+
throw new TypeError("The database connection is not open");
|
|
66
|
+
}
|
|
62
67
|
if (!sql) {
|
|
63
68
|
throw new RangeError("The supplied SQL string contains no statements");
|
|
64
69
|
}
|
|
@@ -158,14 +163,16 @@ class Database {
|
|
|
158
163
|
* @param {string} sql - The string containing SQL statements to execute
|
|
159
164
|
*/
|
|
160
165
|
async exec(sql) {
|
|
166
|
+
if (!this.open) {
|
|
167
|
+
throw new TypeError("The database connection is not open");
|
|
168
|
+
}
|
|
161
169
|
await this.execLock.acquire();
|
|
162
170
|
const exec = this.db.executor(sql);
|
|
163
171
|
try {
|
|
164
172
|
while (true) {
|
|
165
173
|
const stepResult = exec.stepSync();
|
|
166
174
|
if (stepResult === STEP_IO) {
|
|
167
|
-
await this.
|
|
168
|
-
await this.ioStep();
|
|
175
|
+
await this.io();
|
|
169
176
|
continue;
|
|
170
177
|
}
|
|
171
178
|
if (stepResult === STEP_DONE) {
|
|
@@ -202,6 +209,12 @@ class Database {
|
|
|
202
209
|
async close() {
|
|
203
210
|
this.db.close();
|
|
204
211
|
}
|
|
212
|
+
async io() {
|
|
213
|
+
// For WASM browser builds, ioStep awaits a promise that resolves when
|
|
214
|
+
// the OPFS Worker completes the I/O (via IONotifier in wasm-common).
|
|
215
|
+
// For in-memory / Node.js builds, ioStep is a no-op since I/O is synchronous.
|
|
216
|
+
await this.ioStep();
|
|
217
|
+
}
|
|
205
218
|
}
|
|
206
219
|
function maybePromise(arg) {
|
|
207
220
|
let lazy = arg;
|
|
@@ -296,7 +309,7 @@ class Statement {
|
|
|
296
309
|
throw new Error("not implemented");
|
|
297
310
|
}
|
|
298
311
|
get reader() {
|
|
299
|
-
|
|
312
|
+
return this.stmt.must().columns().length > 0;
|
|
300
313
|
}
|
|
301
314
|
get database() {
|
|
302
315
|
return this.db;
|
|
@@ -378,7 +391,7 @@ class Statement {
|
|
|
378
391
|
while (true) {
|
|
379
392
|
const stepResult = await stmt.stepSync();
|
|
380
393
|
if (stepResult === STEP_IO) {
|
|
381
|
-
await this.
|
|
394
|
+
await this.io();
|
|
382
395
|
continue;
|
|
383
396
|
}
|
|
384
397
|
if (stepResult === STEP_DONE) {
|
|
@@ -426,7 +439,6 @@ class Statement {
|
|
|
426
439
|
}
|
|
427
440
|
}
|
|
428
441
|
async io() {
|
|
429
|
-
await this.db.ioLoopAsync();
|
|
430
442
|
await this.ioStep();
|
|
431
443
|
}
|
|
432
444
|
/**
|