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/cjs/index.cjs
CHANGED
|
@@ -188,7 +188,7 @@ function normalizeSQL(sql) {
|
|
|
188
188
|
if (void 0 !== cached) return cached;
|
|
189
189
|
var len = sql.length;
|
|
190
190
|
var needed = len + 1;
|
|
191
|
-
if (_normBuf.length < needed) _normBuf = new Uint16Array(
|
|
191
|
+
if (_normBuf.length < needed) _normBuf = new Uint16Array(needed);
|
|
192
192
|
var outCodes = _normBuf;
|
|
193
193
|
var writePos = 0;
|
|
194
194
|
var pendingSpace = false;
|
|
@@ -294,6 +294,7 @@ function createJsonValueParser(onValue) {
|
|
|
294
294
|
nesting: 0,
|
|
295
295
|
inString: false,
|
|
296
296
|
escaped: false,
|
|
297
|
+
_consumed: 0,
|
|
297
298
|
feed: function(chunk) {
|
|
298
299
|
this.buffer += chunk;
|
|
299
300
|
var consumeUntil = 0;
|
|
@@ -325,6 +326,11 @@ function createJsonValueParser(onValue) {
|
|
|
325
326
|
if (code === CHAR_CLOSE_BRACKET || code === CHAR_CLOSE_BRACE) {
|
|
326
327
|
this.nesting--;
|
|
327
328
|
if (0 === this.nesting) {
|
|
329
|
+
if (index === this.start + 1) {
|
|
330
|
+
this.start = -1;
|
|
331
|
+
consumeUntil = index + 1;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
328
334
|
var raw = this.buffer.slice(this.start, index + 1);
|
|
329
335
|
this.start = -1;
|
|
330
336
|
onValue(raw);
|
|
@@ -333,12 +339,18 @@ function createJsonValueParser(onValue) {
|
|
|
333
339
|
}
|
|
334
340
|
}
|
|
335
341
|
if (consumeUntil > 0) {
|
|
336
|
-
this.
|
|
337
|
-
this.readPos =
|
|
342
|
+
this._consumed = consumeUntil;
|
|
343
|
+
this.readPos = this._consumed;
|
|
344
|
+
if (this._consumed > 65536) {
|
|
345
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
346
|
+
this.readPos = 0;
|
|
347
|
+
this._consumed = 0;
|
|
348
|
+
}
|
|
338
349
|
} else this.readPos = this.buffer.length;
|
|
339
350
|
},
|
|
340
351
|
reset: function() {
|
|
341
352
|
this.buffer = "";
|
|
353
|
+
this._consumed = 0;
|
|
342
354
|
this.start = -1;
|
|
343
355
|
this.readPos = 0;
|
|
344
356
|
this.nesting = 0;
|
|
@@ -358,6 +370,7 @@ function createRowStreamParser(onRow) {
|
|
|
358
370
|
elementEnd: -1,
|
|
359
371
|
nesting: 0,
|
|
360
372
|
readPos: 0,
|
|
373
|
+
_consumed: 0,
|
|
361
374
|
feed: function(chunk) {
|
|
362
375
|
if (this.finished) return chunk;
|
|
363
376
|
this.buffer += chunk;
|
|
@@ -424,24 +437,38 @@ function createRowStreamParser(onRow) {
|
|
|
424
437
|
var delimiter = this.buffer.charCodeAt(lookAhead);
|
|
425
438
|
if (delimiter === CHAR_COMMA || delimiter === CHAR_CLOSE_BRACKET) {
|
|
426
439
|
onRow(this.buffer.slice(this.elementStart, this.elementEnd));
|
|
427
|
-
this.
|
|
440
|
+
this._consumed = lookAhead + 1;
|
|
428
441
|
this.elementStart = -1;
|
|
429
442
|
this.elementEnd = -1;
|
|
430
443
|
this.nesting = 0;
|
|
431
444
|
if (delimiter === CHAR_CLOSE_BRACKET) {
|
|
432
445
|
this.finished = true;
|
|
433
|
-
var tail = this.buffer;
|
|
446
|
+
var tail = this.buffer.slice(this._consumed);
|
|
434
447
|
this.buffer = "";
|
|
448
|
+
this._consumed = 0;
|
|
435
449
|
this.readPos = 0;
|
|
436
450
|
return tail;
|
|
437
451
|
}
|
|
438
|
-
index =
|
|
452
|
+
index = this._consumed;
|
|
453
|
+
if (this._consumed > 65536) {
|
|
454
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
455
|
+
index = 0;
|
|
456
|
+
this._consumed = 0;
|
|
457
|
+
}
|
|
439
458
|
continue;
|
|
440
459
|
}
|
|
441
460
|
}
|
|
442
461
|
}
|
|
443
462
|
index++;
|
|
444
463
|
}
|
|
464
|
+
if (this._consumed > 0) {
|
|
465
|
+
if (-1 !== this.elementStart) {
|
|
466
|
+
this.elementStart -= this._consumed;
|
|
467
|
+
if (-1 !== this.elementEnd) this.elementEnd -= this._consumed;
|
|
468
|
+
}
|
|
469
|
+
this.buffer = this.buffer.slice(this._consumed);
|
|
470
|
+
this._consumed = 0;
|
|
471
|
+
}
|
|
445
472
|
if (this.elementStart > 0) {
|
|
446
473
|
this.buffer = this.buffer.slice(this.elementStart);
|
|
447
474
|
if (-1 !== this.elementEnd) this.elementEnd -= this.elementStart;
|
|
@@ -452,6 +479,7 @@ function createRowStreamParser(onRow) {
|
|
|
452
479
|
},
|
|
453
480
|
reset: function() {
|
|
454
481
|
this.buffer = "";
|
|
482
|
+
this._consumed = 0;
|
|
455
483
|
this.started = false;
|
|
456
484
|
this.finished = false;
|
|
457
485
|
this.inString = false;
|
|
@@ -480,6 +508,22 @@ function stream_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
480
508
|
descriptor.value = value;
|
|
481
509
|
}
|
|
482
510
|
}
|
|
511
|
+
function _class_apply_descriptor_update(receiver, descriptor) {
|
|
512
|
+
if (descriptor.set) {
|
|
513
|
+
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
514
|
+
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
515
|
+
set value (v){
|
|
516
|
+
descriptor.set.call(receiver, v);
|
|
517
|
+
},
|
|
518
|
+
get value () {
|
|
519
|
+
return descriptor.get.call(receiver);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
return descriptor.__destrWrapper;
|
|
523
|
+
}
|
|
524
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
525
|
+
return descriptor;
|
|
526
|
+
}
|
|
483
527
|
function stream_class_call_check(instance, Constructor) {
|
|
484
528
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
485
529
|
}
|
|
@@ -500,6 +544,10 @@ function stream_class_private_field_set(receiver, privateMap, value) {
|
|
|
500
544
|
stream_class_apply_descriptor_set(receiver, descriptor, value);
|
|
501
545
|
return value;
|
|
502
546
|
}
|
|
547
|
+
function _class_private_field_update(receiver, privateMap) {
|
|
548
|
+
var descriptor = stream_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
549
|
+
return _class_apply_descriptor_update(receiver, descriptor);
|
|
550
|
+
}
|
|
503
551
|
function stream_defineProperties(target, props) {
|
|
504
552
|
for(var i = 0; i < props.length; i++){
|
|
505
553
|
var descriptor = props[i];
|
|
@@ -536,7 +584,7 @@ function setupStreamParser(task) {
|
|
|
536
584
|
return parser;
|
|
537
585
|
}
|
|
538
586
|
_computedKey = Symbol.asyncIterator;
|
|
539
|
-
var _buffer = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
587
|
+
var _buffer = /*#__PURE__*/ new WeakMap(), _index = /*#__PURE__*/ new WeakMap(), _done = /*#__PURE__*/ new WeakMap(), _error = /*#__PURE__*/ new WeakMap(), _pending = /*#__PURE__*/ new WeakMap();
|
|
540
588
|
var _computedKey1 = _computedKey;
|
|
541
589
|
var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
542
590
|
"use strict";
|
|
@@ -546,6 +594,10 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
546
594
|
writable: true,
|
|
547
595
|
value: []
|
|
548
596
|
});
|
|
597
|
+
stream_class_private_field_init(this, _index, {
|
|
598
|
+
writable: true,
|
|
599
|
+
value: 0
|
|
600
|
+
});
|
|
549
601
|
stream_class_private_field_init(this, _done, {
|
|
550
602
|
writable: true,
|
|
551
603
|
value: false
|
|
@@ -563,6 +615,7 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
563
615
|
{
|
|
564
616
|
key: "push",
|
|
565
617
|
value: function(row) {
|
|
618
|
+
if (stream_class_private_field_get(this, _done) || stream_class_private_field_get(this, _error)) return;
|
|
566
619
|
if (stream_class_private_field_get(this, _pending)) {
|
|
567
620
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
568
621
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -602,8 +655,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
602
655
|
key: "next",
|
|
603
656
|
value: function() {
|
|
604
657
|
var _this = this;
|
|
605
|
-
if (stream_class_private_field_get(this, _buffer).length
|
|
606
|
-
value: stream_class_private_field_get(this, _buffer)
|
|
658
|
+
if (stream_class_private_field_get(this, _index) < stream_class_private_field_get(this, _buffer).length) return Promise.resolve({
|
|
659
|
+
value: stream_class_private_field_get(this, _buffer)[_class_private_field_update(this, _index).value++],
|
|
607
660
|
done: false
|
|
608
661
|
});
|
|
609
662
|
if (stream_class_private_field_get(this, _done)) return Promise.resolve({
|
|
@@ -623,6 +676,8 @@ var stream_AsyncRowBuffer = /*#__PURE__*/ function() {
|
|
|
623
676
|
key: "return",
|
|
624
677
|
value: function() {
|
|
625
678
|
stream_class_private_field_set(this, _done, true);
|
|
679
|
+
stream_class_private_field_set(this, _buffer, []);
|
|
680
|
+
stream_class_private_field_set(this, _index, 0);
|
|
626
681
|
if (stream_class_private_field_get(this, _pending)) {
|
|
627
682
|
var resolve = stream_class_private_field_get(this, _pending).resolve;
|
|
628
683
|
stream_class_private_field_set(this, _pending, null);
|
|
@@ -1162,13 +1217,14 @@ var _counter = 0;
|
|
|
1162
1217
|
var _PREFIX = "__executor_end__";
|
|
1163
1218
|
var _PID36 = process.pid.toString(36);
|
|
1164
1219
|
function generateToken() {
|
|
1165
|
-
|
|
1220
|
+
_counter = _counter + 1 >>> 0;
|
|
1221
|
+
return "".concat(_PREFIX).concat(_counter.toString(36), "_").concat(_PID36);
|
|
1166
1222
|
}
|
|
1167
1223
|
function escape_type_of(obj) {
|
|
1168
1224
|
return obj && "undefined" != typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1169
1225
|
}
|
|
1170
1226
|
function escapeValue(value) {
|
|
1171
|
-
if ("string" == typeof value) return "'".concat(value.replace(/'/g, "''"), "'");
|
|
1227
|
+
if ("string" == typeof value) return value.includes("'") ? "'".concat(value.replace(/'/g, "''"), "'") : "'".concat(value, "'");
|
|
1172
1228
|
if (null == value) return "NULL";
|
|
1173
1229
|
if ("number" == typeof value || (void 0 === value ? "undefined" : escape_type_of(value)) === "bigint") return String(value);
|
|
1174
1230
|
if ("boolean" == typeof value) return value ? "TRUE" : "FALSE";
|
|
@@ -1342,7 +1398,7 @@ function queue_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
|
1342
1398
|
descriptor.value = value;
|
|
1343
1399
|
}
|
|
1344
1400
|
}
|
|
1345
|
-
function
|
|
1401
|
+
function queue_class_apply_descriptor_update(receiver, descriptor) {
|
|
1346
1402
|
if (descriptor.set) {
|
|
1347
1403
|
if (!descriptor.get) throw new TypeError("attempted to read set only private field");
|
|
1348
1404
|
if (!("__destrWrapper" in descriptor)) descriptor.__destrWrapper = {
|
|
@@ -1378,9 +1434,9 @@ function queue_class_private_field_set(receiver, privateMap, value) {
|
|
|
1378
1434
|
queue_class_apply_descriptor_set(receiver, descriptor, value);
|
|
1379
1435
|
return value;
|
|
1380
1436
|
}
|
|
1381
|
-
function
|
|
1437
|
+
function queue_class_private_field_update(receiver, privateMap) {
|
|
1382
1438
|
var descriptor = queue_class_extract_field_descriptor(receiver, privateMap, "update");
|
|
1383
|
-
return
|
|
1439
|
+
return queue_class_apply_descriptor_update(receiver, descriptor);
|
|
1384
1440
|
}
|
|
1385
1441
|
function _class_private_method_get(receiver, privateSet, fn) {
|
|
1386
1442
|
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
@@ -1535,7 +1591,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1535
1591
|
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);
|
|
1536
1592
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = value;
|
|
1537
1593
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) + 1 & queue_class_private_field_get(this, _mask));
|
|
1538
|
-
|
|
1594
|
+
queue_class_private_field_update(this, _size).value++;
|
|
1539
1595
|
}
|
|
1540
1596
|
},
|
|
1541
1597
|
{
|
|
@@ -1545,7 +1601,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1545
1601
|
var value = queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)];
|
|
1546
1602
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _head)] = void 0;
|
|
1547
1603
|
queue_class_private_field_set(this, _head, queue_class_private_field_get(this, _head) + 1 & queue_class_private_field_get(this, _mask));
|
|
1548
|
-
|
|
1604
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1549
1605
|
return value;
|
|
1550
1606
|
}
|
|
1551
1607
|
},
|
|
@@ -1572,7 +1628,7 @@ var queue_Queue = /*#__PURE__*/ function() {
|
|
|
1572
1628
|
}
|
|
1573
1629
|
queue_class_private_field_set(this, _tail, queue_class_private_field_get(this, _tail) - 1 & queue_class_private_field_get(this, _mask));
|
|
1574
1630
|
queue_class_private_field_get(this, _items)[queue_class_private_field_get(this, _tail)] = void 0;
|
|
1575
|
-
|
|
1631
|
+
queue_class_private_field_update(this, _size).value--;
|
|
1576
1632
|
return true;
|
|
1577
1633
|
}
|
|
1578
1634
|
}
|
|
@@ -1791,6 +1847,9 @@ function buildBatchPayload(batch) {
|
|
|
1791
1847
|
}
|
|
1792
1848
|
return parts1.join("");
|
|
1793
1849
|
}
|
|
1850
|
+
function isSentinelRaw(raw, token) {
|
|
1851
|
+
return raw === '[{"'.concat(TOKEN_COLUMN, '":"').concat(token, '"}]');
|
|
1852
|
+
}
|
|
1794
1853
|
function isSentinelRow(value, token) {
|
|
1795
1854
|
var _value_;
|
|
1796
1855
|
return Array.isArray(value) && 1 === value.length && (null == (_value_ = value[0]) ? void 0 : _value_[TOKEN_COLUMN]) === token;
|
|
@@ -1869,6 +1928,46 @@ function settleTask(task, error, value, metrics) {
|
|
|
1869
1928
|
null == metrics || metrics.incrementTasksSuccess(duration);
|
|
1870
1929
|
task.resolve(value);
|
|
1871
1930
|
}
|
|
1931
|
+
function finalizePendingTasks(tasks, settle, pumpQueue) {
|
|
1932
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1933
|
+
try {
|
|
1934
|
+
for(var _iterator = tasks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1935
|
+
var task = _step.value;
|
|
1936
|
+
if (task.stderrText) {
|
|
1937
|
+
settle(task, new Error(task.stderrText.trim()), void 0);
|
|
1938
|
+
continue;
|
|
1939
|
+
}
|
|
1940
|
+
if (task.consumerError) {
|
|
1941
|
+
settle(task, task.consumerError, void 0);
|
|
1942
|
+
continue;
|
|
1943
|
+
}
|
|
1944
|
+
if ("query" === task.kind) {
|
|
1945
|
+
settle(task, null, task.rows);
|
|
1946
|
+
continue;
|
|
1947
|
+
}
|
|
1948
|
+
settle(task, null, void 0);
|
|
1949
|
+
}
|
|
1950
|
+
} catch (err) {
|
|
1951
|
+
_didIteratorError = true;
|
|
1952
|
+
_iteratorError = err;
|
|
1953
|
+
} finally{
|
|
1954
|
+
try {
|
|
1955
|
+
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
1956
|
+
} finally{
|
|
1957
|
+
if (_didIteratorError) throw _iteratorError;
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
tasks.clear();
|
|
1961
|
+
pumpQueue();
|
|
1962
|
+
}
|
|
1963
|
+
function prepareTaskTimeout(task, metrics) {
|
|
1964
|
+
if (task.settled) return null;
|
|
1965
|
+
task.timedout = true;
|
|
1966
|
+
clearTimeout(task.timer);
|
|
1967
|
+
task.timer = null;
|
|
1968
|
+
null == metrics || metrics.incrementTasksTimeout();
|
|
1969
|
+
return createTimeoutError(task.timeout, task.sql);
|
|
1970
|
+
}
|
|
1872
1971
|
function taskWorker_array_like_to_array(arr, len) {
|
|
1873
1972
|
if (null == len || len > arr.length) len = arr.length;
|
|
1874
1973
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -2024,7 +2123,7 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2024
2123
|
database: database,
|
|
2025
2124
|
initMode: initMode,
|
|
2026
2125
|
onDrain: function() {
|
|
2027
|
-
return taskWorker_class_private_method_get(_this, _pumpQueue,
|
|
2126
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2028
2127
|
}
|
|
2029
2128
|
}));
|
|
2030
2129
|
taskWorker_class_private_field_set(this, _valueParser, createJsonValueParser(function(raw) {
|
|
@@ -2074,7 +2173,13 @@ var taskWorker_TaskWorker = /*#__PURE__*/ function() {
|
|
|
2074
2173
|
};
|
|
2075
2174
|
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTotal(config.kind);
|
|
2076
2175
|
taskWorker_class_private_field_get(this, _pendingQueue).enqueue(task);
|
|
2077
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2176
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2177
|
+
}
|
|
2178
|
+
},
|
|
2179
|
+
{
|
|
2180
|
+
key: "_process",
|
|
2181
|
+
get: function() {
|
|
2182
|
+
return taskWorker_class_private_field_get(this, _processManager).process;
|
|
2078
2183
|
}
|
|
2079
2184
|
},
|
|
2080
2185
|
{
|
|
@@ -2108,7 +2213,7 @@ function startProcess() {
|
|
|
2108
2213
|
taskWorker_class_private_method_get(_this, _rejectAll, taskWorker_rejectAll).call(_this, err);
|
|
2109
2214
|
});
|
|
2110
2215
|
}
|
|
2111
|
-
function
|
|
2216
|
+
function taskWorker_pumpQueue() {
|
|
2112
2217
|
var _this = this;
|
|
2113
2218
|
var _$_class_private_field_get;
|
|
2114
2219
|
if (taskWorker_class_private_field_get(this, _processManager).draining) return;
|
|
@@ -2150,6 +2255,26 @@ function pumpQueue() {
|
|
|
2150
2255
|
function handleParsedValue(raw) {
|
|
2151
2256
|
var task = taskWorker_class_private_field_get(this, _inflightTasks)[0];
|
|
2152
2257
|
if (!task) return;
|
|
2258
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
2259
|
+
clearTimeout(task.timer);
|
|
2260
|
+
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2261
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2262
|
+
if (task.stderrText) {
|
|
2263
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2264
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
if (task.consumerError) {
|
|
2268
|
+
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2269
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2273
|
+
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2274
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
if ("[]" === raw) return;
|
|
2153
2278
|
var parsed;
|
|
2154
2279
|
try {
|
|
2155
2280
|
parsed = JSON.parse(raw);
|
|
@@ -2160,20 +2285,20 @@ function handleParsedValue(raw) {
|
|
|
2160
2285
|
if (isSentinelRow(parsed, task.token)) {
|
|
2161
2286
|
clearTimeout(task.timer);
|
|
2162
2287
|
taskWorker_class_private_field_get(this, _inflightTasks).shift();
|
|
2163
|
-
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2288
|
+
if (task.timedout) return void taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2164
2289
|
if (task.stderrText) {
|
|
2165
2290
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, new Error(task.stderrText.trim()), void 0);
|
|
2166
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2291
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2167
2292
|
return;
|
|
2168
2293
|
}
|
|
2169
2294
|
if (task.consumerError) {
|
|
2170
2295
|
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, task.consumerError, void 0);
|
|
2171
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2296
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2172
2297
|
return;
|
|
2173
2298
|
}
|
|
2174
2299
|
taskWorker_class_private_field_get(this, _pendingFinalizeTasks).add(task);
|
|
2175
2300
|
taskWorker_class_private_method_get(this, _scheduleFinalizeCheck, scheduleFinalizeCheck).call(this);
|
|
2176
|
-
taskWorker_class_private_method_get(this, _pumpQueue,
|
|
2301
|
+
taskWorker_class_private_method_get(this, _pumpQueue, taskWorker_pumpQueue).call(this);
|
|
2177
2302
|
return;
|
|
2178
2303
|
}
|
|
2179
2304
|
if ("query" === task.kind) return void collectQueryRows(task, parsed);
|
|
@@ -2185,36 +2310,11 @@ function scheduleFinalizeCheck() {
|
|
|
2185
2310
|
taskWorker_class_private_field_set(this, _scheduledFinalize, true);
|
|
2186
2311
|
setImmediate(function() {
|
|
2187
2312
|
taskWorker_class_private_field_set(_this, _scheduledFinalize, false);
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
2194
|
-
continue;
|
|
2195
|
-
}
|
|
2196
|
-
if (task.consumerError) {
|
|
2197
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, task.consumerError, void 0);
|
|
2198
|
-
continue;
|
|
2199
|
-
}
|
|
2200
|
-
if ("query" === task.kind) {
|
|
2201
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, task.rows);
|
|
2202
|
-
continue;
|
|
2203
|
-
}
|
|
2204
|
-
taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, task, null, void 0);
|
|
2205
|
-
}
|
|
2206
|
-
} catch (err) {
|
|
2207
|
-
_didIteratorError = true;
|
|
2208
|
-
_iteratorError = err;
|
|
2209
|
-
} finally{
|
|
2210
|
-
try {
|
|
2211
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
2212
|
-
} finally{
|
|
2213
|
-
if (_didIteratorError) throw _iteratorError;
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
taskWorker_class_private_field_get(_this, _pendingFinalizeTasks).clear();
|
|
2217
|
-
taskWorker_class_private_method_get(_this, _pumpQueue, pumpQueue).call(_this);
|
|
2313
|
+
finalizePendingTasks(taskWorker_class_private_field_get(_this, _pendingFinalizeTasks), function(t, e, v1) {
|
|
2314
|
+
return taskWorker_class_private_method_get(_this, _settleTask, settleTask1).call(_this, t, e, v1);
|
|
2315
|
+
}, function() {
|
|
2316
|
+
return taskWorker_class_private_method_get(_this, _pumpQueue, taskWorker_pumpQueue).call(_this);
|
|
2317
|
+
});
|
|
2218
2318
|
});
|
|
2219
2319
|
}
|
|
2220
2320
|
function taskWorker_handleStderrChunk(chunk) {
|
|
@@ -2228,13 +2328,8 @@ function taskWorker_handleStderrChunk(chunk) {
|
|
|
2228
2328
|
task.stderrText += String(chunk);
|
|
2229
2329
|
}
|
|
2230
2330
|
function handleTaskTimeout(task) {
|
|
2231
|
-
var
|
|
2232
|
-
if (task
|
|
2233
|
-
task.timedout = true;
|
|
2234
|
-
clearTimeout(task.timer);
|
|
2235
|
-
task.timer = null;
|
|
2236
|
-
null == (_$_class_private_field_get = taskWorker_class_private_field_get(this, _metrics)) || _$_class_private_field_get.incrementTasksTimeout();
|
|
2237
|
-
taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, createTimeoutError(task.timeout, task.sql), void 0);
|
|
2331
|
+
var error = prepareTaskTimeout(task, taskWorker_class_private_field_get(this, _metrics));
|
|
2332
|
+
if (error) taskWorker_class_private_method_get(this, _settleTask, settleTask1).call(this, task, error, void 0);
|
|
2238
2333
|
}
|
|
2239
2334
|
function settleTask1(task, error, value) {
|
|
2240
2335
|
settleTask(task, error, value, taskWorker_class_private_field_get(this, _metrics));
|
|
@@ -2288,21 +2383,12 @@ function readerPool_class_apply_descriptor_get(receiver, descriptor) {
|
|
|
2288
2383
|
if (descriptor.get) return descriptor.get.call(receiver);
|
|
2289
2384
|
return descriptor.value;
|
|
2290
2385
|
}
|
|
2291
|
-
function
|
|
2292
|
-
if (descriptor.set)
|
|
2293
|
-
|
|
2294
|
-
if (!("
|
|
2295
|
-
|
|
2296
|
-
descriptor.set.call(receiver, v);
|
|
2297
|
-
},
|
|
2298
|
-
get value () {
|
|
2299
|
-
return descriptor.get.call(receiver);
|
|
2300
|
-
}
|
|
2301
|
-
};
|
|
2302
|
-
return descriptor.__destrWrapper;
|
|
2386
|
+
function readerPool_class_apply_descriptor_set(receiver, descriptor, value) {
|
|
2387
|
+
if (descriptor.set) descriptor.set.call(receiver, value);
|
|
2388
|
+
else {
|
|
2389
|
+
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2390
|
+
descriptor.value = value;
|
|
2303
2391
|
}
|
|
2304
|
-
if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
|
|
2305
|
-
return descriptor;
|
|
2306
2392
|
}
|
|
2307
2393
|
function readerPool_class_call_check(instance, Constructor) {
|
|
2308
2394
|
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
@@ -2319,9 +2405,10 @@ function readerPool_class_private_field_init(obj, privateMap, value) {
|
|
|
2319
2405
|
readerPool_check_private_redeclaration(obj, privateMap);
|
|
2320
2406
|
privateMap.set(obj, value);
|
|
2321
2407
|
}
|
|
2322
|
-
function
|
|
2323
|
-
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "
|
|
2324
|
-
|
|
2408
|
+
function readerPool_class_private_field_set(receiver, privateMap, value) {
|
|
2409
|
+
var descriptor = readerPool_class_extract_field_descriptor(receiver, privateMap, "set");
|
|
2410
|
+
readerPool_class_apply_descriptor_set(receiver, descriptor, value);
|
|
2411
|
+
return value;
|
|
2325
2412
|
}
|
|
2326
2413
|
function readerPool_defineProperties(target, props) {
|
|
2327
2414
|
for(var i = 0; i < props.length; i++){
|
|
@@ -2351,6 +2438,7 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2351
2438
|
writable: true,
|
|
2352
2439
|
value: 0
|
|
2353
2440
|
});
|
|
2441
|
+
if (poolSize < 1) throw new RangeError("poolSize must be >= 1");
|
|
2354
2442
|
for(var i = 0; i < poolSize; i++){
|
|
2355
2443
|
var worker = new taskWorker_TaskWorker({
|
|
2356
2444
|
binary: binary,
|
|
@@ -2383,10 +2471,16 @@ var readerPool_ReaderPool = /*#__PURE__*/ function() {
|
|
|
2383
2471
|
key: "enqueue",
|
|
2384
2472
|
value: function(task) {
|
|
2385
2473
|
var worker = readerPool_class_private_field_get(this, _workers)[readerPool_class_private_field_get(this, _rrIndex) % readerPool_class_private_field_get(this, _workers).length];
|
|
2386
|
-
|
|
2474
|
+
readerPool_class_private_field_set(this, _rrIndex, readerPool_class_private_field_get(this, _rrIndex) + 1 >>> 0);
|
|
2387
2475
|
worker.enqueue(task);
|
|
2388
2476
|
}
|
|
2389
2477
|
},
|
|
2478
|
+
{
|
|
2479
|
+
key: "_workers",
|
|
2480
|
+
get: function() {
|
|
2481
|
+
return readerPool_class_private_field_get(this, _workers);
|
|
2482
|
+
}
|
|
2483
|
+
},
|
|
2390
2484
|
{
|
|
2391
2485
|
key: "kill",
|
|
2392
2486
|
value: function() {
|
|
@@ -3246,6 +3340,21 @@ function pipelineEngine_pumpQueue() {
|
|
|
3246
3340
|
function core_pipelineEngine_handleParsedValue(raw) {
|
|
3247
3341
|
var task = pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks)[0];
|
|
3248
3342
|
if (!task) return;
|
|
3343
|
+
if (isSentinelRaw(raw, task.token)) {
|
|
3344
|
+
clearTimeout(task.timer);
|
|
3345
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_inflightTasks).shift();
|
|
3346
|
+
if (task.timedout) return void pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3347
|
+
if (task.consumerError) {
|
|
3348
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, task.consumerError, void 0);
|
|
3349
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3350
|
+
return;
|
|
3351
|
+
}
|
|
3352
|
+
pipelineEngine_class_private_field_get(this, pipelineEngine_pendingFinalizeTasks).add(task);
|
|
3353
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_scheduleFinalizeCheck, pipelineEngine_scheduleFinalizeCheck).call(this);
|
|
3354
|
+
pipelineEngine_class_private_method_get(this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(this);
|
|
3355
|
+
return;
|
|
3356
|
+
}
|
|
3357
|
+
if ("[]" === raw) return;
|
|
3249
3358
|
var parsed;
|
|
3250
3359
|
try {
|
|
3251
3360
|
parsed = JSON.parse(raw);
|
|
@@ -3277,44 +3386,20 @@ function pipelineEngine_scheduleFinalizeCheck() {
|
|
|
3277
3386
|
pipelineEngine_class_private_field_set(this, pipelineEngine_scheduledFinalize, true);
|
|
3278
3387
|
setImmediate(function() {
|
|
3279
3388
|
pipelineEngine_class_private_field_set(_this, pipelineEngine_scheduledFinalize, false);
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, new Error(task.stderrText.trim()), void 0);
|
|
3286
|
-
continue;
|
|
3287
|
-
}
|
|
3288
|
-
if (task.consumerError) {
|
|
3289
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, task.consumerError, void 0);
|
|
3290
|
-
continue;
|
|
3291
|
-
}
|
|
3292
|
-
if ("query" === task.kind) {
|
|
3293
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, task.rows);
|
|
3294
|
-
continue;
|
|
3295
|
-
}
|
|
3296
|
-
pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, task, null, void 0);
|
|
3297
|
-
}
|
|
3298
|
-
} catch (err) {
|
|
3299
|
-
_didIteratorError = true;
|
|
3300
|
-
_iteratorError = err;
|
|
3301
|
-
} finally{
|
|
3302
|
-
try {
|
|
3303
|
-
if (!_iteratorNormalCompletion && null != _iterator["return"]) _iterator["return"]();
|
|
3304
|
-
} finally{
|
|
3305
|
-
if (_didIteratorError) throw _iteratorError;
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks).clear();
|
|
3389
|
+
finalizePendingTasks(pipelineEngine_class_private_field_get(_this, pipelineEngine_pendingFinalizeTasks), function(t, e, v1) {
|
|
3390
|
+
return pipelineEngine_class_private_method_get(_this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(_this, t, e, v1);
|
|
3391
|
+
}, function() {
|
|
3392
|
+
return pipelineEngine_class_private_method_get(_this, core_pipelineEngine_pumpQueue, pipelineEngine_pumpQueue).call(_this);
|
|
3393
|
+
});
|
|
3309
3394
|
});
|
|
3310
3395
|
}
|
|
3311
3396
|
function pipelineEngine_handleTaskTimeout(task) {
|
|
3312
3397
|
var _this, _this1;
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3398
|
+
var error = prepareTaskTimeout(task, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics));
|
|
3399
|
+
if (error) {
|
|
3400
|
+
pipelineEngine_class_private_method_get(this, pipelineEngine_settleTask, pipelineEngine_settleTask1).call(this, task, error, void 0);
|
|
3401
|
+
null == (_this = pipelineEngine_class_private_field_get(_this1 = this, _onTaskTimeout)) || _this.call(_this1, task);
|
|
3402
|
+
}
|
|
3318
3403
|
}
|
|
3319
3404
|
function pipelineEngine_settleTask1(task, error, value) {
|
|
3320
3405
|
settleTask(task, error, value, pipelineEngine_class_private_field_get(this, pipelineEngine_metrics), {
|
|
@@ -3543,7 +3628,6 @@ var _computedKey2 = executor_computedKey;
|
|
|
3543
3628
|
var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
3544
3629
|
"use strict";
|
|
3545
3630
|
function SQLiteExecutor() {
|
|
3546
|
-
var _this = this;
|
|
3547
3631
|
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;
|
|
3548
3632
|
executor_class_call_check(this, SQLiteExecutor);
|
|
3549
3633
|
executor_class_private_method_init(this, _normalizeTimeout);
|
|
@@ -3623,9 +3707,7 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3623
3707
|
metrics: executor_class_private_field_get(this, executor_metrics),
|
|
3624
3708
|
statementTimeout: executor_class_private_field_get(this, executor_statementTimeout),
|
|
3625
3709
|
logger: executor_class_private_field_get(this, executor_logger),
|
|
3626
|
-
onTaskTimeout: function(
|
|
3627
|
-
executor_class_private_field_get(_this, executor_metrics).incrementTasksTimeout();
|
|
3628
|
-
}
|
|
3710
|
+
onTaskTimeout: function() {}
|
|
3629
3711
|
}));
|
|
3630
3712
|
executor_class_private_method_get(this, executor_startProcess, core_executor_startProcess).call(this);
|
|
3631
3713
|
if (poolSize > 0 && ":memory:" !== database) executor_class_private_field_set(this, _readerPool, new readerPool_ReaderPool({
|
|
@@ -3652,6 +3734,12 @@ var executor_SQLiteExecutor = /*#__PURE__*/ function() {
|
|
|
3652
3734
|
return executor_class_private_field_get(this, _readerPool);
|
|
3653
3735
|
}
|
|
3654
3736
|
},
|
|
3737
|
+
{
|
|
3738
|
+
key: "_process",
|
|
3739
|
+
get: function() {
|
|
3740
|
+
return executor_class_private_field_get(this, executor_proc);
|
|
3741
|
+
}
|
|
3742
|
+
},
|
|
3655
3743
|
{
|
|
3656
3744
|
key: "metrics",
|
|
3657
3745
|
get: function() {
|