sqlite-executor 4.0.3 → 4.0.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/cjs/index.cjs +205 -117
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +205 -117
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ function normalizeSQL(sql) {
|
|
|
135
135
|
if (void 0 !== cached) return cached;
|
|
136
136
|
var len = sql.length;
|
|
137
137
|
var needed = len + 1;
|
|
138
|
-
if (_normBuf.length < needed) _normBuf = new Uint16Array(
|
|
138
|
+
if (_normBuf.length < needed) _normBuf = new Uint16Array(needed);
|
|
139
139
|
var outCodes = _normBuf;
|
|
140
140
|
var writePos = 0;
|
|
141
141
|
var pendingSpace = false;
|
|
@@ -241,6 +241,7 @@ function createJsonValueParser(onValue) {
|
|
|
241
241
|
nesting: 0,
|
|
242
242
|
inString: false,
|
|
243
243
|
escaped: false,
|
|
244
|
+
_consumed: 0,
|
|
244
245
|
feed: function(chunk) {
|
|
245
246
|
this.buffer += chunk;
|
|
246
247
|
var consumeUntil = 0;
|
|
@@ -272,6 +273,11 @@ function createJsonValueParser(onValue) {
|
|
|
272
273
|
if (code === CHAR_CLOSE_BRACKET || code === CHAR_CLOSE_BRACE) {
|
|
273
274
|
this.nesting--;
|
|
274
275
|
if (0 === this.nesting) {
|
|
276
|
+
if (index === this.start + 1) {
|
|
277
|
+
this.start = -1;
|
|
278
|
+
consumeUntil = index + 1;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
275
281
|
var raw = this.buffer.slice(this.start, index + 1);
|
|
276
282
|
this.start = -1;
|
|
277
283
|
onValue(raw);
|
|
@@ -280,12 +286,18 @@ function createJsonValueParser(onValue) {
|
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
if (consumeUntil > 0) {
|
|
283
|
-
this.
|
|
284
|
-
this.readPos =
|
|
289
|
+
this._consumed = consumeUntil;
|
|
290
|
+
this.readPos = this._consumed;
|
|
291
|
+
if (this._consumed > 65536) {
|
|
292
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
293
|
+
this.readPos = 0;
|
|
294
|
+
this._consumed = 0;
|
|
295
|
+
}
|
|
285
296
|
} else this.readPos = this.buffer.length;
|
|
286
297
|
},
|
|
287
298
|
reset: function() {
|
|
288
299
|
this.buffer = "";
|
|
300
|
+
this._consumed = 0;
|
|
289
301
|
this.start = -1;
|
|
290
302
|
this.readPos = 0;
|
|
291
303
|
this.nesting = 0;
|
|
@@ -305,6 +317,7 @@ function createRowStreamParser(onRow) {
|
|
|
305
317
|
elementEnd: -1,
|
|
306
318
|
nesting: 0,
|
|
307
319
|
readPos: 0,
|
|
320
|
+
_consumed: 0,
|
|
308
321
|
feed: function(chunk) {
|
|
309
322
|
if (this.finished) return chunk;
|
|
310
323
|
this.buffer += chunk;
|
|
@@ -371,24 +384,38 @@ function createRowStreamParser(onRow) {
|
|
|
371
384
|
var delimiter = this.buffer.charCodeAt(lookAhead);
|
|
372
385
|
if (delimiter === CHAR_COMMA || delimiter === CHAR_CLOSE_BRACKET) {
|
|
373
386
|
onRow(this.buffer.slice(this.elementStart, this.elementEnd));
|
|
374
|
-
this.
|
|
387
|
+
this._consumed = lookAhead + 1;
|
|
375
388
|
this.elementStart = -1;
|
|
376
389
|
this.elementEnd = -1;
|
|
377
390
|
this.nesting = 0;
|
|
378
391
|
if (delimiter === CHAR_CLOSE_BRACKET) {
|
|
379
392
|
this.finished = true;
|
|
380
|
-
var tail = this.buffer;
|
|
393
|
+
var tail = this.buffer.slice(this._consumed);
|
|
381
394
|
this.buffer = "";
|
|
395
|
+
this._consumed = 0;
|
|
382
396
|
this.readPos = 0;
|
|
383
397
|
return tail;
|
|
384
398
|
}
|
|
385
|
-
index =
|
|
399
|
+
index = this._consumed;
|
|
400
|
+
if (this._consumed > 65536) {
|
|
401
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
402
|
+
index = 0;
|
|
403
|
+
this._consumed = 0;
|
|
404
|
+
}
|
|
386
405
|
continue;
|
|
387
406
|
}
|
|
388
407
|
}
|
|
389
408
|
}
|
|
390
409
|
index++;
|
|
391
410
|
}
|
|
411
|
+
if (this._consumed > 0) {
|
|
412
|
+
if (-1 !== this.elementStart) {
|
|
413
|
+
this.elementStart -= this._consumed;
|
|
414
|
+
if (-1 !== this.elementEnd) this.elementEnd -= this._consumed;
|
|
415
|
+
}
|
|
416
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
417
|
+
this._consumed = 0;
|
|
418
|
+
}
|
|
392
419
|
if (this.elementStart > 0) {
|
|
393
420
|
this.buffer = this.buffer.slice(this.elementStart);
|
|
394
421
|
if (-1 !== this.elementEnd) this.elementEnd -= this.elementStart;
|
|
@@ -399,6 +426,7 @@ function createRowStreamParser(onRow) {
|
|
|
399
426
|
},
|
|
400
427
|
reset: function() {
|
|
401
428
|
this.buffer = "";
|
|
429
|
+
this._consumed = 0;
|
|
402
430
|
this.started = false;
|
|
403
431
|
this.finished = false;
|
|
404
432
|
this.inString = false;
|
|
@@ -427,6 +455,22 @@ function stream_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
427
455
|
descriptor.value = value;
|
|
428
456
|
}
|
|
429
457
|
}
|
|
458
|
+
function _class_apply_descriptor_update(receiver, descriptor) {
|
|
459
|
+
if (descriptor.set) {
|
|
460
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
461
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
462
|
+
set value (v){
|
|
463
|
+
descriptor.set.call(receiver, v);
|
|
464
|
+
},
|
|
465
|
+
get value () {
|
|
466
|
+
return descriptor.get.call(receiver);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
return descriptor.__destrWrapper;
|
|
470
|
+
}
|
|
471
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
472
|
+
return descriptor;
|
|
473
|
+
}
|
|
430
474
|
function stream_class_call_check(instance, Constructor) {
|
|
431
475
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
432
476
|
}
|
|
@@ -447,6 +491,10 @@ function stream_class_private_field_set(receiver, privateMap, value) {
|
|
|
447
491
|
stream_class_apply_descriptor_set(receiver, descriptor, value);
|
|
448
492
|
return value;
|
|
449
493
|
}
|
|
494
|
+
function _class_private_field_update(receiver, privateMap) {
|
|
495
|
+
var descriptor = stream_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
496
|
+
return _class_apply_descriptor_update(receiver, descriptor);
|
|
497
|
+
}
|
|
450
498
|
function stream_defineProperties(target, props) {
|
|
451
499
|
for(var i = 0; i < props.length; i++){
|
|
452
500
|
var descriptor = props[i];
|
|
@@ -483,7 +531,7 @@ function setupStreamParser(task) {
|
|
|
483
531
|
return parser;
|
|
484
532
|
}
|
|
485
533
|
_computedKey = Symbol.asyncIterator;
|
|
486
|
-
var _buffer = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
534
|
+
var _buffer = /*#__PURE__*/ new WeakMap(), _index = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
487
535
|
var _computedKey1 = _computedKey;
|
|
488
536
|
var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
489
537
|
"use strict";
|
|
@@ -493,6 +541,10 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
493
541
|
writable: true,
|
|
494
542
|
value: []
|
|
495
543
|
});
|
|
544
|
+
stream_class_private_field_init(this, _index, {
|
|
545
|
+
writable: true,
|
|
546
|
+
value: 0
|
|
547
|
+
});
|
|
496
548
|
stream_class_private_field_init(this, _done, {
|
|
497
549
|
writable: true,
|
|
498
550
|
value: false
|
|
@@ -510,6 +562,7 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
510
562
|
{
|
|
511
563
|
key: "push",
|
|
512
564
|
value: function(row) {
|
|
565
|
+
if (stream_class_private_field_get(this, _done) || stream_class_private_field_get(this, _error)) return;
|
|
513
566
|
if (stream_class_private_field_get(this, _pending)) {
|
|
514
567
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
515
568
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -549,8 +602,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
549
602
|
key: "next",
|
|
550
603
|
value: function() {
|
|
551
604
|
var _this = this;
|
|
552
|
-
if (stream_class_private_field_get(this, _buffer).length
|
|
553
|
-
value: stream_class_private_field_get(this, _buffer)
|
|
605
|
+
if (stream_class_private_field_get(this, _index) < stream_class_private_field_get(this, _buffer).length) return Promise.resolve({
|
|
606
|
+
value: stream_class_private_field_get(this, _buffer)[_class_private_field_update(this, _index).value++],
|
|
554
607
|
done: false
|
|
555
608
|
});
|
|
556
609
|
if (stream_class_private_field_get(this, _done)) return Promise.resolve({
|
|
@@ -570,6 +623,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
570
623
|
key: "return",
|
|
571
624
|
value: function() {
|
|
572
625
|
stream_class_private_field_set(this, _done, true);
|
|
626
|
+
stream_class_private_field_set(this, _buffer, []);
|
|
627
|
+
stream_class_private_field_set(this, _index, 0);
|
|
573
628
|
if (stream_class_private_field_get(this, _pending)) {
|
|
574
629
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
575
630
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -1102,13 +1157,14 @@ var _counter = 0;
|
|
|
1102
1157
|
var _PREFIX = "__executor_end__";
|
|
1103
1158
|
var _PID36 = process.pid.toString(36);
|
|
1104
1159
|
function generateToken() {
|
|
1105
|
-
|
|
1160
|
+
_counter = _counter + 1 >>> 0;
|
|
1161
|
+
return "".concat(_PREFIX).concat(_counter.toString(36), "_").concat(_PID36);
|
|
1106
1162
|
}
|
|
1107
1163
|
function escape_type_of(obj) {
|
|
1108
1164
|
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1109
1165
|
}
|
|
1110
1166
|
function escapeValue(value) {
|
|
1111
|
-
if ("string" == typeof value) return "'".concat(value.replace(/'/g, "''"), "'");
|
|
1167
|
+
if ("string" == typeof value) return value.includes("'") ? "'".concat(value.replace(/'/g, "''"), "'") : "'".concat(value, "'");
|
|
1112
1168
|
if (null == value) return "NULL";
|
|
1113
1169
|
if ("number" == typeof value || (void 0 === value ? "undefined" : escape_type_of(value)) === "bigint") return String(value);
|
|
1114
1170
|
if ("boolean" == typeof value) return value ? "TRUE" : "FALSE";
|
|
@@ -1282,7 +1338,7 @@ function queue_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
1282
1338
|
descriptor.value = value;
|
|
1283
1339
|
}
|
|
1284
1340
|
}
|
|
1285
|
-
function
|
|
1341
|
+
function queue_class_apply_descriptor_update(receiver, descriptor) {
|
|
1286
1342
|
if (descriptor.set) {
|
|
1287
1343
|
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
1288
1344
|
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
@@ -1318,9 +1374,9 @@ function queue_class_private_field_set(receiver, privateMap, value) {
|
|
|
1318
1374
|
queue_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1319
1375
|
return value;
|
|
1320
1376
|
}
|
|
1321
|
-
function
|
|
1377
|
+
function queue_class_private_field_update(receiver, privateMap) {
|
|
1322
1378
|
var descriptor = queue_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
1323
|
-
return
|
|
1379
|
+
return queue_class_apply_descriptor_update(receiver, descriptor);
|
|
1324
1380
|
}
|
|
1325
1381
|
function _class_private_method_get(receiver, privateSet, fn) {
|
|
1326
1382
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
@@ -1475,7 +1531,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1475
1531
|
if (queue_class_private_field_get(this, _size) === queue_class_private_field_get(this, _items).length) _class_private_method_get(this, _grow, grow).call(this);
|
|
1476
1532
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = value;
|
|
1477
1533
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) + 1 & queue_class_private_field_get(this, _mask));
|
|
1478
|
-
|
|
1534
|
+
queue_class_private_field_update(this, _size).value++;
|
|
1479
1535
|
}
|
|
1480
1536
|
},
|
|
1481
1537
|
{
|
|
@@ -1485,7 +1541,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1485
1541
|
var value = queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)];
|
|
1486
1542
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)] = void 0;
|
|
1487
1543
|
queue_class_private_field_set(this, _head, queue_class_private_field_get(this, _head) + 1 & queue_class_private_field_get(this, _mask));
|
|
1488
|
-
|
|
1544
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1489
1545
|
return value;
|
|
1490
1546
|
}
|
|
1491
1547
|
},
|
|
@@ -1512,7 +1568,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1512
1568
|
}
|
|
1513
1569
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) - 1 & queue_class_private_field_get(this, _mask));
|
|
1514
1570
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = void 0;
|
|
1515
|
-
|
|
1571
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1516
1572
|
return true;
|
|
1517
1573
|
}
|
|
1518
1574
|
}
|
|
@@ -1731,6 +1787,9 @@ function buildBatchPayload(batch) {
|
|
|
1731
1787
|
}
|
|
1732
1788
|
return parts1.join("");
|
|
1733
1789
|
}
|
|
1790
|
+
function isSentinelRaw(raw, token) {
|
|
1791
|
+
return raw === '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
1792
|
+
}
|
|
1734
1793
|
function isSentinelRow(value, token) {
|
|
1735
1794
|
var _value_;
|
|
1736
1795
|
return Array.isArray(value) && 1 === value.length && (null == (_value_ = value[0]) ? void 0 : _value_[TOKEN_COLUMN]) === token;
|
|
@@ -1809,6 +1868,46 @@ function settleTask(task, error, value, metrics) {
|
|
|
1809
1868
|
null == metrics || metrics.incrementTasksSuccess(duration);
|
|
1810
1869
|
task.resolve(value);
|
|
1811
1870
|
}
|
|
1871
|
+
function finalizePendingTasks(tasks, settle, pumpQueue) {
|
|
1872
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1873
|
+
try {
|
|
1874
|
+
for(var _iterator = tasks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1875
|
+
var task = _step.value;
|
|
1876
|
+
if (task.stderrText) {
|
|
1877
|
+
settle(task, new Error(task.stderrText.trim()), void 0);
|
|
1878
|
+
continue;
|
|
1879
|
+
}
|
|
1880
|
+
if (task.consumerError) {
|
|
1881
|
+
settle(task, task.consumerError, void 0);
|
|
1882
|
+
continue;
|
|
1883
|
+
}
|
|
1884
|
+
if ("query" === task.kind) {
|
|
1885
|
+
settle(task, null, task.rows);
|
|
1886
|
+
continue;
|
|
1887
|
+
}
|
|
1888
|
+
settle(task, null, void 0);
|
|
1889
|
+
}
|
|
1890
|
+
} catch (err) {
|
|
1891
|
+
_didIteratorError = true;
|
|
1892
|
+
_iteratorError = err;
|
|
1893
|
+
} finally{
|
|
1894
|
+
try {
|
|
1895
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1896
|
+
} finally{
|
|
1897
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
tasks.clear();
|
|
1901
|
+
pumpQueue();
|
|
1902
|
+
}
|
|
1903
|
+
function prepareTaskTimeout(task, metrics) {
|
|
1904
|
+
if (task.settled) return null;
|
|
1905
|
+
task.timedout = true;
|
|
1906
|
+
clearTimeout(task.timer);
|
|
1907
|
+
task.timer = null;
|
|
1908
|
+
null == metrics || metrics.incrementTasksTimeout();
|
|
1909
|
+
return createTimeoutError(task.timeout, task.sql);
|
|
1910
|
+
}
|
|
1812
1911
|
function taskWorker_array_like_to_array(arr, len) {
|
|
1813
1912
|
if (null == len || len > arr.length) len = arr.length;
|
|
1814
1913
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -1964,7 +2063,7 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
1964
2063
|
database: database,
|
|
1965
2064
|
initMode: initMode,
|
|
1966
2065
|
onDrain: function() {
|
|
1967
|
-
return taskWorker_class_private_method_get(_this, _pumpQueue,
|
|
2066
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
1968
2067
|
}
|
|
1969
2068
|
}));
|
|
1970
2069
|
taskWorker_class_private_field_set(this, _valueParser, createJsonValueParser(function(raw) {
|
|
@@ -2014,7 +2113,13 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2014
2113
|
};
|
|
2015
2114
|
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTotal(config.kind);
|
|
2016
2115
|
taskWorker_class_private_field_get(this, _pendingQueue).enqueue(task);
|
|
2017
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2116
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2117
|
+
}
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
key: "_process",
|
|
2121
|
+
get: function() {
|
|
2122
|
+
return taskWorker_class_private_field_get(this, _processManager).process;
|
|
2018
2123
|
}
|
|
2019
2124
|
},
|
|
2020
2125
|
{
|
|
@@ -2048,7 +2153,7 @@ function startProcess() {
|
|
|
2048
2153
|
taskWorker_class_private_method_get(_this, _rejectAll, taskWorker_rejectAll).call(_this, err);
|
|
2049
2154
|
});
|
|
2050
2155
|
}
|
|
2051
|
-
function
|
|
2156
|
+
function taskWorker_pumpQueue() {
|
|
2052
2157
|
var _this = this;
|
|
2053
2158
|
var _$_class_private_field_get;
|
|
2054
2159
|
if (taskWorker_class_private_field_get(this, _processManager).draining) return;
|
|
@@ -2090,6 +2195,26 @@ function pumpQueue() {
|
|
|
2090
2195
|
function handleParsedValue(raw) {
|
|
2091
2196
|
var task = taskWorker_class_private_field_get(this, _inflightTasks)[0];
|
|
2092
2197
|
if (!task) return;
|
|
2198
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
2199
|
+
clearTimeout(task.timer);
|
|
2200
|
+
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2201
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2202
|
+
if (task.stderrText) {
|
|
2203
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2204
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
if (task.consumerError) {
|
|
2208
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2209
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2213
|
+
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2214
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
if ("[]" === raw) return;
|
|
2093
2218
|
var parsed;
|
|
2094
2219
|
try {
|
|
2095
2220
|
parsed = JSON.parse(raw);
|
|
@@ -2100,20 +2225,20 @@ function handleParsedValue(raw) {
|
|
|
2100
2225
|
if (isSentinelRow(parsed, task.token)) {
|
|
2101
2226
|
clearTimeout(task.timer);
|
|
2102
2227
|
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2103
|
-
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2228
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2104
2229
|
if (task.stderrText) {
|
|
2105
2230
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2106
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2231
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2107
2232
|
return;
|
|
2108
2233
|
}
|
|
2109
2234
|
if (task.consumerError) {
|
|
2110
2235
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2111
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2236
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2112
2237
|
return;
|
|
2113
2238
|
}
|
|
2114
2239
|
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2115
2240
|
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2116
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2241
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2117
2242
|
return;
|
|
2118
2243
|
}
|
|
2119
2244
|
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
@@ -2125,36 +2250,11 @@ function scheduleFinalizeCheck() {
|
|
|
2125
2250
|
taskWorker_class_private_field_set(this, _scheduledFinalize, true);
|
|
2126
2251
|
setImmediate(function() {
|
|
2127
2252
|
taskWorker_class_private_field_set(_this, _scheduledFinalize, false);
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
2134
|
-
continue;
|
|
2135
|
-
}
|
|
2136
|
-
if (task.consumerError) {
|
|
2137
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, task.consumerError, void 0);
|
|
2138
|
-
continue;
|
|
2139
|
-
}
|
|
2140
|
-
if ("query" === task.kind) {
|
|
2141
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, task.rows);
|
|
2142
|
-
continue;
|
|
2143
|
-
}
|
|
2144
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, void 0);
|
|
2145
|
-
}
|
|
2146
|
-
} catch (err) {
|
|
2147
|
-
_didIteratorError = true;
|
|
2148
|
-
_iteratorError = err;
|
|
2149
|
-
} finally{
|
|
2150
|
-
try {
|
|
2151
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2152
|
-
} finally{
|
|
2153
|
-
if (_didIteratorError) throw _iteratorError;
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
taskWorker_class_private_field_get(_this, _pendingFinalizeTasks).clear();
|
|
2157
|
-
taskWorker_class_private_method_get(_this, _pumpQueue, pumpQueue).call(_this);
|
|
2253
|
+
finalizePendingTasks(taskWorker_class_private_field_get(_this, _pendingFinalizeTasks), function(t, e, v1) {
|
|
2254
|
+
return taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, t, e, v1);
|
|
2255
|
+
}, function() {
|
|
2256
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2257
|
+
});
|
|
2158
2258
|
});
|
|
2159
2259
|
}
|
|
2160
2260
|
function taskWorker_handleStderrChunk(chunk) {
|
|
@@ -2168,13 +2268,8 @@ function taskWorker_handleStderrChunk(chunk) {
|
|
|
2168
2268
|
task.stderrText += String(chunk);
|
|
2169
2269
|
}
|
|
2170
2270
|
function handleTaskTimeout(task) {
|
|
2171
|
-
var
|
|
2172
|
-
if (task
|
|
2173
|
-
task.timedout = true;
|
|
2174
|
-
clearTimeout(task.timer);
|
|
2175
|
-
task.timer = null;
|
|
2176
|
-
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTimeout();
|
|
2177
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, createTimeoutError(task.timeout, task.sql), void 0);
|
|
2271
|
+
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(this, _metrics));
|
|
2272
|
+
if (error) taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, error, void 0);
|
|
2178
2273
|
}
|
|
2179
2274
|
function settleTask1(task, error, value) {
|
|
2180
2275
|
settleTask(task, error, value, taskWorker_class_private_field_get(this, _metrics));
|
|
@@ -2228,21 +2323,12 @@ function readerPool_class_apply_descriptor_get(receiver, descriptor) {
|
|
|
2228
2323
|
if (descriptor.get) return descriptor.get.call(receiver);
|
|
2229
2324
|
return descriptor.value;
|
|
2230
2325
|
}
|
|
2231
|
-
function
|
|
2232
|
-
if (descriptor.set)
|
|
2233
|
-
|
|
2234
|
-
if (!("
|
|
2235
|
-
|
|
2236
|
-
descriptor.set.call(receiver, v);
|
|
2237
|
-
},
|
|
2238
|
-
get value () {
|
|
2239
|
-
return descriptor.get.call(receiver);
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
return descriptor.__destrWrapper;
|
|
2326
|
+
function readerPool_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
2327
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
2328
|
+
else {
|
|
2329
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2330
|
+
descriptor.value = value;
|
|
2243
2331
|
}
|
|
2244
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2245
|
-
return descriptor;
|
|
2246
2332
|
}
|
|
2247
2333
|
function readerPool_class_call_check(instance, Constructor) {
|
|
2248
2334
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
@@ -2259,9 +2345,10 @@ function readerPool_class_private_field_init(obj, privateMap, value) {
|
|
|
2259
2345
|
readerPool_check_private_redeclaration(obj, privateMap);
|
|
2260
2346
|
privateMap.set(obj, value);
|
|
2261
2347
|
}
|
|
2262
|
-
function
|
|
2263
|
-
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "
|
|
2264
|
-
|
|
2348
|
+
function readerPool_class_private_field_set(receiver, privateMap, value) {
|
|
2349
|
+
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
2350
|
+
readerPool_class_apply_descriptor_set(receiver, descriptor, value);
|
|
2351
|
+
return value;
|
|
2265
2352
|
}
|
|
2266
2353
|
function readerPool_defineProperties(target, props) {
|
|
2267
2354
|
for(var i = 0; i < props.length; i++){
|
|
@@ -2291,6 +2378,7 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2291
2378
|
writable: true,
|
|
2292
2379
|
value: 0
|
|
2293
2380
|
});
|
|
2381
|
+
if (poolSize < 1) throw new RangeError("poolSize must be >= 1");
|
|
2294
2382
|
for(var i = 0; i < poolSize; i++){
|
|
2295
2383
|
var worker = new taskWorker_TaskWorker({
|
|
2296
2384
|
binary: binary,
|
|
@@ -2323,10 +2411,16 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2323
2411
|
key: "enqueue",
|
|
2324
2412
|
value: function(task) {
|
|
2325
2413
|
var worker = readerPool_class_private_field_get(this, _workers)[readerPool_class_private_field_get(this, _rrIndex) % readerPool_class_private_field_get(this, _workers).length];
|
|
2326
|
-
|
|
2414
|
+
readerPool_class_private_field_set(this, _rrIndex, readerPool_class_private_field_get(this, _rrIndex) + 1 >>> 0);
|
|
2327
2415
|
worker.enqueue(task);
|
|
2328
2416
|
}
|
|
2329
2417
|
},
|
|
2418
|
+
{
|
|
2419
|
+
key: "_workers",
|
|
2420
|
+
get: function() {
|
|
2421
|
+
return readerPool_class_private_field_get(this, _workers);
|
|
2422
|
+
}
|
|
2423
|
+
},
|
|
2330
2424
|
{
|
|
2331
2425
|
key: "kill",
|
|
2332
2426
|
value: function() {
|
|
@@ -3186,6 +3280,21 @@ function pipelineEngine_pumpQueue() {
|
|
|
3186
3280
|
function core_pipelineEngine_handleParsedValue(raw) {
|
|
3187
3281
|
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[0];
|
|
3188
3282
|
if (!task) return;
|
|
3283
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
3284
|
+
clearTimeout(task.timer);
|
|
3285
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3286
|
+
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3287
|
+
if (task.consumerError) {
|
|
3288
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
3289
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3290
|
+
return;
|
|
3291
|
+
}
|
|
3292
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).add(task);
|
|
3293
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_scheduleFinalizeCheck, pipelineEngine_scheduleFinalizeCheck).call(this);
|
|
3294
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3295
|
+
return;
|
|
3296
|
+
}
|
|
3297
|
+
if ("[]" === raw) return;
|
|
3189
3298
|
var parsed;
|
|
3190
3299
|
try {
|
|
3191
3300
|
parsed = JSON.parse(raw);
|
|
@@ -3217,44 +3326,20 @@ function pipelineEngine_scheduleFinalizeCheck() {
|
|
|
3217
3326
|
pipelineEngine_class_private_field_set(this, pipelineEngine_scheduledFinalize, true);
|
|
3218
3327
|
setImmediate(function() {
|
|
3219
3328
|
pipelineEngine_class_private_field_set(_this, pipelineEngine_scheduledFinalize, false);
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
3226
|
-
continue;
|
|
3227
|
-
}
|
|
3228
|
-
if (task.consumerError) {
|
|
3229
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, task.consumerError, void 0);
|
|
3230
|
-
continue;
|
|
3231
|
-
}
|
|
3232
|
-
if ("query" === task.kind) {
|
|
3233
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, task.rows);
|
|
3234
|
-
continue;
|
|
3235
|
-
}
|
|
3236
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, void 0);
|
|
3237
|
-
}
|
|
3238
|
-
} catch (err) {
|
|
3239
|
-
_didIteratorError = true;
|
|
3240
|
-
_iteratorError = err;
|
|
3241
|
-
} finally{
|
|
3242
|
-
try {
|
|
3243
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
3244
|
-
} finally{
|
|
3245
|
-
if (_didIteratorError) throw _iteratorError;
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks).clear();
|
|
3329
|
+
finalizePendingTasks(pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks), function(t, e, v1) {
|
|
3330
|
+
return pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, t, e, v1);
|
|
3331
|
+
}, function() {
|
|
3332
|
+
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3333
|
+
});
|
|
3249
3334
|
});
|
|
3250
3335
|
}
|
|
3251
3336
|
function pipelineEngine_handleTaskTimeout(task) {
|
|
3252
3337
|
var _this, _this1;
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3338
|
+
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics));
|
|
3339
|
+
if (error) {
|
|
3340
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, error, void 0);
|
|
3341
|
+
null == (_this = pipelineEngine_class_private_field_get(_this1 = this, _onTaskTimeout)) || _this.call(_this1, task);
|
|
3342
|
+
}
|
|
3258
3343
|
}
|
|
3259
3344
|
function pipelineEngine_settleTask1(task, error, value) {
|
|
3260
3345
|
settleTask(task, error, value, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics), {
|
|
@@ -3483,7 +3568,6 @@ var _computedKey2 = executor_computedKey;
|
|
|
3483
3568
|
var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
3484
3569
|
"use strict";
|
|
3485
3570
|
function SQLiteExecutor() {
|
|
3486
|
-
var _this = this;
|
|
3487
3571
|
var _ref = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, _ref_binary = _ref.binary, binary = void 0 === _ref_binary ? "sqlite3" : _ref_binary, _ref_database = _ref.database, database = void 0 === _ref_database ? ":memory:" : _ref_database, logger = _ref.logger, _ref_statementTimeout = _ref.statementTimeout, statementTimeout = void 0 === _ref_statementTimeout ? DEFAULT_STATEMENT_TIMEOUT : _ref_statementTimeout, _ref_autoRestart = _ref.autoRestart, autoRestart = void 0 === _ref_autoRestart ? true : _ref_autoRestart, _ref_poolSize = _ref.poolSize, poolSize = void 0 === _ref_poolSize ? 0 : _ref_poolSize, metrics = _ref.metrics;
|
|
3488
3572
|
executor_class_call_check(this, SQLiteExecutor);
|
|
3489
3573
|
executor_class_private_method_init(this, _normalizeTimeout);
|
|
@@ -3563,9 +3647,7 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3563
3647
|
metrics: executor_class_private_field_get(this, executor_metrics),
|
|
3564
3648
|
statementTimeout: executor_class_private_field_get(this, executor_statementTimeout),
|
|
3565
3649
|
logger: executor_class_private_field_get(this, executor_logger),
|
|
3566
|
-
onTaskTimeout: function(
|
|
3567
|
-
executor_class_private_field_get(_this, executor_metrics).incrementTasksTimeout();
|
|
3568
|
-
}
|
|
3650
|
+
onTaskTimeout: function() {}
|
|
3569
3651
|
}));
|
|
3570
3652
|
executor_class_private_method_get(this, executor_startProcess, core_executor_startProcess).call(this);
|
|
3571
3653
|
if (poolSize > 0 && ":memory:" !== database) executor_class_private_field_set(this, _readerPool, new readerPool_ReaderPool({
|
|
@@ -3592,6 +3674,12 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3592
3674
|
return executor_class_private_field_get(this, _readerPool);
|
|
3593
3675
|
}
|
|
3594
3676
|
},
|
|
3677
|
+
{
|
|
3678
|
+
key: "_process",
|
|
3679
|
+
get: function() {
|
|
3680
|
+
return executor_class_private_field_get(this, executor_proc);
|
|
3681
|
+
}
|
|
3682
|
+
},
|
|
3595
3683
|
{
|
|
3596
3684
|
key: "metrics",
|
|
3597
3685
|
get: function() {
|