@peerbit/indexer-sqlite3 1.2.26 → 1.2.27-0fddff8
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/peerbit/sqlite3.min.js +254 -189
- package/dist/peerbit/sqlite3.worker.min.js +91 -79
- package/dist/src/engine.d.ts +4 -0
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/engine.js +69 -17
- package/dist/src/engine.js.map +1 -1
- package/dist/src/schema.d.ts +2 -2
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +2 -2
- package/dist/src/schema.js.map +1 -1
- package/dist/src/sqlite3.browser.js +1 -1
- package/dist/src/sqlite3.browser.js.map +1 -1
- package/dist/src/sqlite3.wasm.d.ts.map +1 -1
- package/dist/src/sqlite3.wasm.js +20 -1
- package/dist/src/sqlite3.wasm.js.map +1 -1
- package/dist/src/utils.d.ts +2 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +8 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +78 -78
- package/src/engine.ts +81 -23
- package/src/schema.ts +6 -4
- package/src/sqlite3.browser.ts +1 -1
- package/src/sqlite3.wasm.ts +23 -1
- package/src/utils.ts +9 -0
|
@@ -30,83 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
-
// ../../../../node_modules/@protobufjs/utf8/index.js
|
|
34
|
-
var require_utf8 = __commonJS({
|
|
35
|
-
"../../../../node_modules/@protobufjs/utf8/index.js"(exports) {
|
|
36
|
-
"use strict";
|
|
37
|
-
var utf82 = exports;
|
|
38
|
-
utf82.length = function utf8_length(string) {
|
|
39
|
-
var len = 0, c = 0;
|
|
40
|
-
for (var i = 0; i < string.length; ++i) {
|
|
41
|
-
c = string.charCodeAt(i);
|
|
42
|
-
if (c < 128)
|
|
43
|
-
len += 1;
|
|
44
|
-
else if (c < 2048)
|
|
45
|
-
len += 2;
|
|
46
|
-
else if ((c & 64512) === 55296 && (string.charCodeAt(i + 1) & 64512) === 56320) {
|
|
47
|
-
++i;
|
|
48
|
-
len += 4;
|
|
49
|
-
} else
|
|
50
|
-
len += 3;
|
|
51
|
-
}
|
|
52
|
-
return len;
|
|
53
|
-
};
|
|
54
|
-
utf82.read = function utf8_read(buffer, start, end) {
|
|
55
|
-
var len = end - start;
|
|
56
|
-
if (len < 1)
|
|
57
|
-
return "";
|
|
58
|
-
var parts = null, chunk = [], i = 0, t;
|
|
59
|
-
while (start < end) {
|
|
60
|
-
t = buffer[start++];
|
|
61
|
-
if (t < 128)
|
|
62
|
-
chunk[i++] = t;
|
|
63
|
-
else if (t > 191 && t < 224)
|
|
64
|
-
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
65
|
-
else if (t > 239 && t < 365) {
|
|
66
|
-
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 65536;
|
|
67
|
-
chunk[i++] = 55296 + (t >> 10);
|
|
68
|
-
chunk[i++] = 56320 + (t & 1023);
|
|
69
|
-
} else
|
|
70
|
-
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
71
|
-
if (i > 8191) {
|
|
72
|
-
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
73
|
-
i = 0;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (parts) {
|
|
77
|
-
if (i)
|
|
78
|
-
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
79
|
-
return parts.join("");
|
|
80
|
-
}
|
|
81
|
-
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
82
|
-
};
|
|
83
|
-
utf82.write = function utf8_write(string, buffer, offset) {
|
|
84
|
-
var start = offset, c1, c2;
|
|
85
|
-
for (var i = 0; i < string.length; ++i) {
|
|
86
|
-
c1 = string.charCodeAt(i);
|
|
87
|
-
if (c1 < 128) {
|
|
88
|
-
buffer[offset++] = c1;
|
|
89
|
-
} else if (c1 < 2048) {
|
|
90
|
-
buffer[offset++] = c1 >> 6 | 192;
|
|
91
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
92
|
-
} else if ((c1 & 64512) === 55296 && ((c2 = string.charCodeAt(i + 1)) & 64512) === 56320) {
|
|
93
|
-
c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
|
|
94
|
-
++i;
|
|
95
|
-
buffer[offset++] = c1 >> 18 | 240;
|
|
96
|
-
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
97
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
98
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
99
|
-
} else {
|
|
100
|
-
buffer[offset++] = c1 >> 12 | 224;
|
|
101
|
-
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
102
|
-
buffer[offset++] = c1 & 63 | 128;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return offset - start;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
33
|
// ../../../../node_modules/@protobufjs/float/index.js
|
|
111
34
|
var require_float = __commonJS({
|
|
112
35
|
"../../../../node_modules/@protobufjs/float/index.js"(exports, module) {
|
|
@@ -301,6 +224,83 @@ var require_float = __commonJS({
|
|
|
301
224
|
}
|
|
302
225
|
});
|
|
303
226
|
|
|
227
|
+
// ../../../../node_modules/@protobufjs/utf8/index.js
|
|
228
|
+
var require_utf8 = __commonJS({
|
|
229
|
+
"../../../../node_modules/@protobufjs/utf8/index.js"(exports) {
|
|
230
|
+
"use strict";
|
|
231
|
+
var utf82 = exports;
|
|
232
|
+
utf82.length = function utf8_length(string) {
|
|
233
|
+
var len = 0, c = 0;
|
|
234
|
+
for (var i = 0; i < string.length; ++i) {
|
|
235
|
+
c = string.charCodeAt(i);
|
|
236
|
+
if (c < 128)
|
|
237
|
+
len += 1;
|
|
238
|
+
else if (c < 2048)
|
|
239
|
+
len += 2;
|
|
240
|
+
else if ((c & 64512) === 55296 && (string.charCodeAt(i + 1) & 64512) === 56320) {
|
|
241
|
+
++i;
|
|
242
|
+
len += 4;
|
|
243
|
+
} else
|
|
244
|
+
len += 3;
|
|
245
|
+
}
|
|
246
|
+
return len;
|
|
247
|
+
};
|
|
248
|
+
utf82.read = function utf8_read(buffer, start, end) {
|
|
249
|
+
var len = end - start;
|
|
250
|
+
if (len < 1)
|
|
251
|
+
return "";
|
|
252
|
+
var parts = null, chunk = [], i = 0, t;
|
|
253
|
+
while (start < end) {
|
|
254
|
+
t = buffer[start++];
|
|
255
|
+
if (t < 128)
|
|
256
|
+
chunk[i++] = t;
|
|
257
|
+
else if (t > 191 && t < 224)
|
|
258
|
+
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
|
|
259
|
+
else if (t > 239 && t < 365) {
|
|
260
|
+
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 65536;
|
|
261
|
+
chunk[i++] = 55296 + (t >> 10);
|
|
262
|
+
chunk[i++] = 56320 + (t & 1023);
|
|
263
|
+
} else
|
|
264
|
+
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
|
|
265
|
+
if (i > 8191) {
|
|
266
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
|
|
267
|
+
i = 0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (parts) {
|
|
271
|
+
if (i)
|
|
272
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
273
|
+
return parts.join("");
|
|
274
|
+
}
|
|
275
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
276
|
+
};
|
|
277
|
+
utf82.write = function utf8_write(string, buffer, offset) {
|
|
278
|
+
var start = offset, c1, c2;
|
|
279
|
+
for (var i = 0; i < string.length; ++i) {
|
|
280
|
+
c1 = string.charCodeAt(i);
|
|
281
|
+
if (c1 < 128) {
|
|
282
|
+
buffer[offset++] = c1;
|
|
283
|
+
} else if (c1 < 2048) {
|
|
284
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
285
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
286
|
+
} else if ((c1 & 64512) === 55296 && ((c2 = string.charCodeAt(i + 1)) & 64512) === 56320) {
|
|
287
|
+
c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
|
|
288
|
+
++i;
|
|
289
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
290
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
291
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
292
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
293
|
+
} else {
|
|
294
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
295
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
296
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return offset - start;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
304
|
// (disabled):fs
|
|
305
305
|
var require_fs = __commonJS({
|
|
306
306
|
"(disabled):fs"() {
|
|
@@ -5522,97 +5522,9 @@ var require_libsodium_wrappers = __commonJS({
|
|
|
5522
5522
|
}
|
|
5523
5523
|
});
|
|
5524
5524
|
|
|
5525
|
-
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/
|
|
5526
|
-
var
|
|
5527
|
-
|
|
5528
|
-
super(message);
|
|
5529
|
-
this.fieldPath = [];
|
|
5530
|
-
this.originalMessage = message;
|
|
5531
|
-
}
|
|
5532
|
-
addToFieldPath(fieldName) {
|
|
5533
|
-
this.fieldPath.splice(0, 0, fieldName);
|
|
5534
|
-
this.message = this.originalMessage + ". Error originated at field path: " + this.fieldPath.join(".");
|
|
5535
|
-
}
|
|
5536
|
-
};
|
|
5537
|
-
|
|
5538
|
-
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/types.js
|
|
5539
|
-
var extendingClasses = (clazz) => {
|
|
5540
|
-
let ret = [];
|
|
5541
|
-
if (clazz instanceof Function) {
|
|
5542
|
-
let baseClass = clazz;
|
|
5543
|
-
while (baseClass) {
|
|
5544
|
-
const newBaseClass = Object.getPrototypeOf(baseClass);
|
|
5545
|
-
if (newBaseClass && newBaseClass !== Object && newBaseClass.name) {
|
|
5546
|
-
ret.push(newBaseClass);
|
|
5547
|
-
baseClass = newBaseClass;
|
|
5548
|
-
} else {
|
|
5549
|
-
return ret;
|
|
5550
|
-
}
|
|
5551
|
-
}
|
|
5552
|
-
}
|
|
5553
|
-
return ret;
|
|
5554
|
-
};
|
|
5555
|
-
var getOffset = (clazz) => extendingClasses(clazz).length;
|
|
5556
|
-
var WrappedType = class _WrappedType {
|
|
5557
|
-
constructor(elementType) {
|
|
5558
|
-
this.elementType = elementType;
|
|
5559
|
-
}
|
|
5560
|
-
getDependency() {
|
|
5561
|
-
if (typeof this.elementType === "function")
|
|
5562
|
-
return this.elementType;
|
|
5563
|
-
if (this.elementType instanceof _WrappedType)
|
|
5564
|
-
return this.elementType.getDependency();
|
|
5565
|
-
return void 0;
|
|
5566
|
-
}
|
|
5567
|
-
};
|
|
5568
|
-
var StringType = class {
|
|
5569
|
-
constructor(sizeEncoding) {
|
|
5570
|
-
this.sizeEncoding = sizeEncoding;
|
|
5571
|
-
}
|
|
5572
|
-
};
|
|
5573
|
-
var OptionKind = class extends WrappedType {
|
|
5574
|
-
};
|
|
5575
|
-
var VecKind = class extends WrappedType {
|
|
5576
|
-
constructor(elementType, sizeEncoding) {
|
|
5577
|
-
super(elementType);
|
|
5578
|
-
this.sizeEncoding = sizeEncoding;
|
|
5579
|
-
}
|
|
5580
|
-
};
|
|
5581
|
-
var vec = (type, sizeEncoding = "u32") => {
|
|
5582
|
-
return new VecKind(type, sizeEncoding);
|
|
5583
|
-
};
|
|
5584
|
-
var FixedArrayKind = class extends WrappedType {
|
|
5585
|
-
constructor(type, length) {
|
|
5586
|
-
super(type);
|
|
5587
|
-
this.length = length;
|
|
5588
|
-
}
|
|
5589
|
-
};
|
|
5590
|
-
var StructKind = class {
|
|
5591
|
-
constructor(properties) {
|
|
5592
|
-
if (properties) {
|
|
5593
|
-
this.fields = properties.fields;
|
|
5594
|
-
this.variant = properties.variant;
|
|
5595
|
-
} else {
|
|
5596
|
-
this.fields = [];
|
|
5597
|
-
}
|
|
5598
|
-
}
|
|
5599
|
-
getDependencies() {
|
|
5600
|
-
let ret = [];
|
|
5601
|
-
this.fields.forEach((field2, ix) => {
|
|
5602
|
-
if (!field2) {
|
|
5603
|
-
throw new BorshError("Field: " + ix + " is missing specification");
|
|
5604
|
-
}
|
|
5605
|
-
if (field2.type instanceof WrappedType) {
|
|
5606
|
-
let dependency = field2.type.getDependency();
|
|
5607
|
-
if (dependency)
|
|
5608
|
-
ret.push(dependency);
|
|
5609
|
-
} else if (typeof field2.type === "function") {
|
|
5610
|
-
ret.push(field2.type);
|
|
5611
|
-
}
|
|
5612
|
-
});
|
|
5613
|
-
return ret;
|
|
5614
|
-
}
|
|
5615
|
-
};
|
|
5525
|
+
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/binary.js
|
|
5526
|
+
var import_float = __toESM(require_float(), 1);
|
|
5527
|
+
var import_utf8 = __toESM(require_utf8(), 1);
|
|
5616
5528
|
|
|
5617
5529
|
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/bigint.js
|
|
5618
5530
|
function arrayToHex(arr, reverse = false) {
|
|
@@ -5727,9 +5639,20 @@ var checkInt = (value, min, max, byteLength) => {
|
|
|
5727
5639
|
}
|
|
5728
5640
|
};
|
|
5729
5641
|
|
|
5642
|
+
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/error.js
|
|
5643
|
+
var BorshError = class extends Error {
|
|
5644
|
+
constructor(message) {
|
|
5645
|
+
super(message);
|
|
5646
|
+
this.fieldPath = [];
|
|
5647
|
+
this.originalMessage = message;
|
|
5648
|
+
}
|
|
5649
|
+
addToFieldPath(fieldName) {
|
|
5650
|
+
this.fieldPath.splice(0, 0, fieldName);
|
|
5651
|
+
this.message = this.originalMessage + ". Error originated at field path: " + this.fieldPath.join(".");
|
|
5652
|
+
}
|
|
5653
|
+
};
|
|
5654
|
+
|
|
5730
5655
|
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/binary.js
|
|
5731
|
-
var import_utf8 = __toESM(require_utf8(), 1);
|
|
5732
|
-
var import_float = __toESM(require_float(), 1);
|
|
5733
5656
|
var allocUnsafeFn = () => {
|
|
5734
5657
|
if (globalThis.Buffer) {
|
|
5735
5658
|
return globalThis.Buffer.allocUnsafe;
|
|
@@ -5903,7 +5826,10 @@ var BinaryWriter = class _BinaryWriter {
|
|
|
5903
5826
|
}
|
|
5904
5827
|
static smallNumberEncoding(encoding) {
|
|
5905
5828
|
if (encoding === "u8") {
|
|
5906
|
-
return [
|
|
5829
|
+
return [
|
|
5830
|
+
(value, buf, offset) => buf[offset] = value,
|
|
5831
|
+
1
|
|
5832
|
+
];
|
|
5907
5833
|
} else if (encoding === "u16") {
|
|
5908
5834
|
return [writeUInt16LE, 2];
|
|
5909
5835
|
} else if (encoding === "u32") {
|
|
@@ -6148,6 +6074,85 @@ var BinaryReader = class _BinaryReader {
|
|
|
6148
6074
|
}
|
|
6149
6075
|
};
|
|
6150
6076
|
|
|
6077
|
+
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/types.js
|
|
6078
|
+
var extendingClasses = (clazz) => {
|
|
6079
|
+
let ret = [];
|
|
6080
|
+
if (clazz instanceof Function) {
|
|
6081
|
+
let baseClass = clazz;
|
|
6082
|
+
while (baseClass) {
|
|
6083
|
+
const newBaseClass = Object.getPrototypeOf(baseClass);
|
|
6084
|
+
if (newBaseClass && newBaseClass !== Object && newBaseClass.name) {
|
|
6085
|
+
ret.push(newBaseClass);
|
|
6086
|
+
baseClass = newBaseClass;
|
|
6087
|
+
} else {
|
|
6088
|
+
return ret;
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
6092
|
+
return ret;
|
|
6093
|
+
};
|
|
6094
|
+
var getOffset = (clazz) => extendingClasses(clazz).length;
|
|
6095
|
+
var WrappedType = class _WrappedType {
|
|
6096
|
+
constructor(elementType) {
|
|
6097
|
+
this.elementType = elementType;
|
|
6098
|
+
}
|
|
6099
|
+
getDependency() {
|
|
6100
|
+
if (typeof this.elementType === "function")
|
|
6101
|
+
return this.elementType;
|
|
6102
|
+
if (this.elementType instanceof _WrappedType)
|
|
6103
|
+
return this.elementType.getDependency();
|
|
6104
|
+
return void 0;
|
|
6105
|
+
}
|
|
6106
|
+
};
|
|
6107
|
+
var StringType = class {
|
|
6108
|
+
constructor(sizeEncoding) {
|
|
6109
|
+
this.sizeEncoding = sizeEncoding;
|
|
6110
|
+
}
|
|
6111
|
+
};
|
|
6112
|
+
var OptionKind = class extends WrappedType {
|
|
6113
|
+
};
|
|
6114
|
+
var VecKind = class extends WrappedType {
|
|
6115
|
+
constructor(elementType, sizeEncoding) {
|
|
6116
|
+
super(elementType);
|
|
6117
|
+
this.sizeEncoding = sizeEncoding;
|
|
6118
|
+
}
|
|
6119
|
+
};
|
|
6120
|
+
var vec = (type, sizeEncoding = "u32") => {
|
|
6121
|
+
return new VecKind(type, sizeEncoding);
|
|
6122
|
+
};
|
|
6123
|
+
var FixedArrayKind = class extends WrappedType {
|
|
6124
|
+
constructor(type, length) {
|
|
6125
|
+
super(type);
|
|
6126
|
+
this.length = length;
|
|
6127
|
+
}
|
|
6128
|
+
};
|
|
6129
|
+
var StructKind = class {
|
|
6130
|
+
constructor(properties) {
|
|
6131
|
+
if (properties) {
|
|
6132
|
+
this.fields = properties.fields;
|
|
6133
|
+
this.variant = properties.variant;
|
|
6134
|
+
} else {
|
|
6135
|
+
this.fields = [];
|
|
6136
|
+
}
|
|
6137
|
+
}
|
|
6138
|
+
getDependencies() {
|
|
6139
|
+
let ret = [];
|
|
6140
|
+
this.fields.forEach((field2, ix) => {
|
|
6141
|
+
if (!field2) {
|
|
6142
|
+
throw new BorshError("Field: " + ix + " is missing specification");
|
|
6143
|
+
}
|
|
6144
|
+
if (field2.type instanceof WrappedType) {
|
|
6145
|
+
let dependency = field2.type.getDependency();
|
|
6146
|
+
if (dependency)
|
|
6147
|
+
ret.push(dependency);
|
|
6148
|
+
} else if (typeof field2.type === "function") {
|
|
6149
|
+
ret.push(field2.type);
|
|
6150
|
+
}
|
|
6151
|
+
});
|
|
6152
|
+
return ret;
|
|
6153
|
+
}
|
|
6154
|
+
};
|
|
6155
|
+
|
|
6151
6156
|
// ../../../../node_modules/@dao-xyz/borsh/lib/esm/index.js
|
|
6152
6157
|
var MAX_PROTOTYPE_SEARCH = 250;
|
|
6153
6158
|
var PROTOTYPE_POLLUTION_CONTEXT_RANGE = 500;
|
|
@@ -6211,7 +6216,6 @@ function serializeField(fieldName, fieldType, options) {
|
|
|
6211
6216
|
} else {
|
|
6212
6217
|
const sizeHandle = fieldType instanceof FixedArrayKind ? void 0 : BinaryWriter.write(fieldType.sizeEncoding);
|
|
6213
6218
|
const fieldHandle = serializeField(null, fieldType.elementType);
|
|
6214
|
-
;
|
|
6215
6219
|
return (obj, writer) => {
|
|
6216
6220
|
let len = obj.length;
|
|
6217
6221
|
if (!sizeHandle) {
|
|
@@ -8170,7 +8174,7 @@ var getSQLFields = (tableName, path, ctor, primary, addJoinFieldFromParent, tabl
|
|
|
8170
8174
|
let foundPrimary = false;
|
|
8171
8175
|
const addJoinFields = primary === false ? addJoinFieldFromParent : (fields2, contstraints) => {
|
|
8172
8176
|
const parentPrimaryField = primary != null ? sqlFields.find((field2) => field2.name === primary) : void 0;
|
|
8173
|
-
const parentPrimaryFieldName = parentPrimaryField?.
|
|
8177
|
+
const parentPrimaryFieldName = parentPrimaryField?.name || CHILD_TABLE_ID;
|
|
8174
8178
|
const parentPrimaryFieldType = parentPrimaryField ? parentPrimaryField.type : "INTEGER";
|
|
8175
8179
|
fields2.unshift(
|
|
8176
8180
|
{
|
|
@@ -8531,7 +8535,7 @@ var insert = async (insertFn, obj, tables, table, fields, handleNestedCallback,
|
|
|
8531
8535
|
}
|
|
8532
8536
|
for (const nested of nestedFields) {
|
|
8533
8537
|
const isOptional = nested.type instanceof OptionKind;
|
|
8534
|
-
handleNestedCallback((id) => handleNested(nested, isOptional, id));
|
|
8538
|
+
await handleNestedCallback((id) => handleNested(nested, isOptional, id));
|
|
8535
8539
|
}
|
|
8536
8540
|
const thisId = await insertFn(bindableValues, table);
|
|
8537
8541
|
if (table.primary === false && nestedCallbacks.length > 0) {
|
|
@@ -9498,6 +9502,11 @@ var generatePermutations = (list) => {
|
|
|
9498
9502
|
return [list, [...list].reverse()];
|
|
9499
9503
|
};
|
|
9500
9504
|
|
|
9505
|
+
// dist/src/utils.js
|
|
9506
|
+
var isFKError = (e) => {
|
|
9507
|
+
return e?.code === "SQLITE_CONSTRAINT_FOREIGNKEY" || e?.rc === 787 || e?.message && (e.message.includes("SQLITE_CONSTRAINT_FOREIGNKEY") || e.message.includes("FOREIGN KEY constraint failed"));
|
|
9508
|
+
};
|
|
9509
|
+
|
|
9501
9510
|
// dist/src/engine.js
|
|
9502
9511
|
var escapePathToSQLName = (path) => {
|
|
9503
9512
|
return path.map((x) => x.replace(/[^a-zA-Z0-9]/g, "_"));
|
|
@@ -9505,6 +9514,45 @@ var escapePathToSQLName = (path) => {
|
|
|
9505
9514
|
var putStatementKey = (table) => table.name + "_put";
|
|
9506
9515
|
var replaceStatementKey = (table) => table.name + "_replicate";
|
|
9507
9516
|
var resolveChildrenStatement = (table) => table.name + "_resolve_children";
|
|
9517
|
+
async function safeReset(stmt) {
|
|
9518
|
+
if (!stmt?.reset)
|
|
9519
|
+
return;
|
|
9520
|
+
try {
|
|
9521
|
+
await stmt.reset();
|
|
9522
|
+
} catch (e) {
|
|
9523
|
+
if (isFKError(e))
|
|
9524
|
+
return;
|
|
9525
|
+
throw e;
|
|
9526
|
+
}
|
|
9527
|
+
}
|
|
9528
|
+
async function runIgnoreFK(stmt, values) {
|
|
9529
|
+
try {
|
|
9530
|
+
await stmt.run(values);
|
|
9531
|
+
await safeReset(stmt);
|
|
9532
|
+
return;
|
|
9533
|
+
} catch (e) {
|
|
9534
|
+
if (isFKError(e)) {
|
|
9535
|
+
await safeReset(stmt);
|
|
9536
|
+
return;
|
|
9537
|
+
}
|
|
9538
|
+
await safeReset(stmt);
|
|
9539
|
+
throw e;
|
|
9540
|
+
}
|
|
9541
|
+
}
|
|
9542
|
+
async function getIgnoreFK(stmt, values) {
|
|
9543
|
+
try {
|
|
9544
|
+
const out = await stmt.get(values);
|
|
9545
|
+
await safeReset(stmt);
|
|
9546
|
+
return out;
|
|
9547
|
+
} catch (e) {
|
|
9548
|
+
if (isFKError(e)) {
|
|
9549
|
+
await safeReset(stmt);
|
|
9550
|
+
return void 0;
|
|
9551
|
+
}
|
|
9552
|
+
await safeReset(stmt);
|
|
9553
|
+
throw e;
|
|
9554
|
+
}
|
|
9555
|
+
}
|
|
9508
9556
|
var SQLLiteIndex = class {
|
|
9509
9557
|
properties;
|
|
9510
9558
|
primaryKeyArr;
|
|
@@ -9518,9 +9566,11 @@ var SQLLiteIndex = class {
|
|
|
9518
9566
|
cursorPruner;
|
|
9519
9567
|
iteratorTimeout;
|
|
9520
9568
|
closed = true;
|
|
9569
|
+
fkMode;
|
|
9521
9570
|
id;
|
|
9522
9571
|
constructor(properties, options) {
|
|
9523
9572
|
this.properties = properties;
|
|
9573
|
+
this.fkMode = options?.fkMode || "race-tolerant";
|
|
9524
9574
|
this.closed = true;
|
|
9525
9575
|
this.id = v4_default();
|
|
9526
9576
|
this.scopeString = properties.scope.length > 0 ? "_" + escapePathToSQLName(properties.scope).join("_") : void 0;
|
|
@@ -9681,19 +9731,22 @@ var SQLLiteIndex = class {
|
|
|
9681
9731
|
const classOfValue = value.constructor;
|
|
9682
9732
|
return insert(async (values, table) => {
|
|
9683
9733
|
let preId = values[table.primaryIndex];
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9734
|
+
let statement = void 0;
|
|
9735
|
+
try {
|
|
9736
|
+
if (preId != null) {
|
|
9737
|
+
statement = this.properties.db.statements.get(replaceStatementKey(table));
|
|
9738
|
+
this.fkMode === "race-tolerant" ? await runIgnoreFK(statement, values) : await statement.run(values);
|
|
9739
|
+
return preId;
|
|
9740
|
+
} else {
|
|
9741
|
+
statement = this.properties.db.statements.get(putStatementKey(table));
|
|
9742
|
+
const out = this.fkMode === "race-tolerant" ? await getIgnoreFK(statement, values) : await statement.get(values);
|
|
9743
|
+
if (out == null) {
|
|
9744
|
+
return void 0;
|
|
9745
|
+
}
|
|
9746
|
+
return out[table.primary];
|
|
9695
9747
|
}
|
|
9696
|
-
|
|
9748
|
+
} finally {
|
|
9749
|
+
await statement?.reset?.();
|
|
9697
9750
|
}
|
|
9698
9751
|
}, value, this.tables, resolveTable(this.scopeString ? [this.scopeString] : [], this.tables, classOfValue, true), getSchema(classOfValue).fields, (_fn) => {
|
|
9699
9752
|
throw new Error("Unexpected");
|
|
@@ -9815,7 +9868,7 @@ var SQLLiteIndex = class {
|
|
|
9815
9868
|
const stmt = await this.properties.db.prepare(sql, sql);
|
|
9816
9869
|
const results = await stmt.all(bindable);
|
|
9817
9870
|
for (const result of results) {
|
|
9818
|
-
ret.push(toId(result[table.primary]));
|
|
9871
|
+
ret.push(toId(convertFromSQLType(result[table.primary], table.primaryField.from.type)));
|
|
9819
9872
|
}
|
|
9820
9873
|
once = true;
|
|
9821
9874
|
} catch (error2) {
|
|
@@ -21486,7 +21539,19 @@ var Statement = class {
|
|
|
21486
21539
|
this.statement.stepReset();
|
|
21487
21540
|
}
|
|
21488
21541
|
async reset() {
|
|
21489
|
-
|
|
21542
|
+
try {
|
|
21543
|
+
await this.statement.reset();
|
|
21544
|
+
} catch (e) {
|
|
21545
|
+
const msg = e?.message || "";
|
|
21546
|
+
const rc = e?.rc;
|
|
21547
|
+
const code = e?.code;
|
|
21548
|
+
const isFk = code === "SQLITE_CONSTRAINT_FOREIGNKEY" || rc === 787 || msg.includes("SQLITE_CONSTRAINT_FOREIGNKEY") || msg.includes("FOREIGN KEY constraint failed");
|
|
21549
|
+
const isBusy = code === "SQLITE_BUSY" || rc === 5;
|
|
21550
|
+
if (isFk || isBusy) {
|
|
21551
|
+
return this;
|
|
21552
|
+
}
|
|
21553
|
+
throw e;
|
|
21554
|
+
}
|
|
21490
21555
|
return this;
|
|
21491
21556
|
}
|
|
21492
21557
|
all(values) {
|
|
@@ -21740,7 +21805,7 @@ var init = async () => {
|
|
|
21740
21805
|
}
|
|
21741
21806
|
const resolver = resolvers[message.id];
|
|
21742
21807
|
if (message.type === "error") {
|
|
21743
|
-
resolver.reject(message.message);
|
|
21808
|
+
resolver.reject(new Error(message.message));
|
|
21744
21809
|
} else if (message.type === "response") {
|
|
21745
21810
|
resolver.resolve(message.result);
|
|
21746
21811
|
}
|