@bsv/wallet-toolbox-client 2.1.25 → 2.1.26
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/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
- package/out/src/mockchain/MockChainStorage.js +3 -3
- package/out/src/mockchain/MockChainStorage.js.map +1 -1
- package/out/src/mockchain/MockMiner.js +1 -1
- package/out/src/mockchain/MockMiner.js.map +1 -1
- package/out/src/mockchain/MockServices.js +14 -13
- package/out/src/mockchain/MockServices.js.map +1 -1
- package/out/src/monitor/Monitor.js +8 -6
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js +6 -3
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +19 -18
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.js +1 -1
- package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.js +3 -4
- package/out/src/services/ServiceCollection.js.map +1 -1
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +27 -25
- package/out/src/services/Services.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +99 -94
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +35 -31
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.js +7 -7
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts +0 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js +0 -3
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.js +1 -1
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +22 -21
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/index.client.d.ts +3 -0
- package/out/src/storage/index.client.d.ts.map +1 -1
- package/out/src/storage/index.client.js +3 -0
- package/out/src/storage/index.client.js.map +1 -1
- package/out/src/storage/portable/index.d.ts +55 -0
- package/out/src/storage/portable/index.d.ts.map +1 -0
- package/out/src/storage/portable/index.js +830 -0
- package/out/src/storage/portable/index.js.map +1 -0
- package/out/src/storage/storageProviderHelpers.js +2 -2
- package/out/src/storage/storageProviderHelpers.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +3 -2
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/brc114ActionTimeLabels.js +1 -1
- package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
- package/out/src/utility/identityUtils.d.ts.map +1 -1
- package/out/src/utility/identityUtils.js +5 -5
- package/out/src/utility/identityUtils.js.map +1 -1
- package/out/src/utility/index.client.d.ts +1 -0
- package/out/src/utility/index.client.d.ts.map +1 -1
- package/out/src/utility/index.client.js +1 -0
- package/out/src/utility/index.client.js.map +1 -1
- package/out/src/utility/stampLog.js +3 -3
- package/out/src/utility/stampLog.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +2 -2
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/src/wab-client/WABClient.d.ts +2 -2
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ cursor, since, offset, limit, matches, accept) {
|
|
|
38
38
|
}
|
|
39
39
|
accept(r);
|
|
40
40
|
count++;
|
|
41
|
-
if (limit && count >= limit)
|
|
41
|
+
if ((limit !== null && limit !== void 0 ? limit : 0) > 0 && count >= limit)
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
44
|
return count;
|
|
@@ -115,7 +115,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
115
115
|
if (this.db == null)
|
|
116
116
|
throw new Error('not initialized');
|
|
117
117
|
const db = this.db;
|
|
118
|
-
const trx = db.transaction(stores
|
|
118
|
+
const trx = db.transaction(stores.length > 0 ? stores : this.allStores, mode);
|
|
119
119
|
this.whenLastAccess = new Date();
|
|
120
120
|
return trx;
|
|
121
121
|
}
|
|
@@ -140,7 +140,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
140
140
|
upgrade(db) {
|
|
141
141
|
(0, idbHelpers_1.upgradeAllStoresV1)(db);
|
|
142
142
|
if (!db.objectStoreNames.contains('settings')) {
|
|
143
|
-
if (
|
|
143
|
+
if (storageName == null || storageName === '' || storageIdentityKey == null || storageIdentityKey === '') {
|
|
144
144
|
throw new WERR_errors_1.WERR_INVALID_OPERATION('migrate must be called before first access');
|
|
145
145
|
}
|
|
146
146
|
const settings = db.createObjectStore('settings', { keyPath: 'storageIdentityKey' });
|
|
@@ -153,7 +153,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
153
153
|
dbtype: 'IndexedDB',
|
|
154
154
|
maxOutputScript
|
|
155
155
|
};
|
|
156
|
-
settings.put(s);
|
|
156
|
+
void settings.put(s);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
});
|
|
@@ -205,7 +205,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
205
205
|
let output;
|
|
206
206
|
let scores = [];
|
|
207
207
|
for (const o of outputs) {
|
|
208
|
-
if (exactSatoshis && o.satoshis === exactSatoshis) {
|
|
208
|
+
if (exactSatoshis != null && exactSatoshis !== 0 && o.satoshis === exactSatoshis) {
|
|
209
209
|
output = o;
|
|
210
210
|
break;
|
|
211
211
|
}
|
|
@@ -261,7 +261,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
261
261
|
return r;
|
|
262
262
|
}
|
|
263
263
|
async getRawTxOfKnownValidTransaction(txid, offset, length, trx) {
|
|
264
|
-
if (
|
|
264
|
+
if (txid == null || txid === '')
|
|
265
265
|
return undefined;
|
|
266
266
|
if (!this.isAvailable())
|
|
267
267
|
await this.makeAvailable();
|
|
@@ -300,10 +300,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
300
300
|
// Knex/Bun drop it via JOIN; we must do the same silently or we'd break the whole
|
|
301
301
|
// listActions response. Skip + log so persistent orphans still produce a signal.
|
|
302
302
|
const label = (0, utilityHelpers_1.verifyOneOrNone)(await this.findTxLabels({ partial: { txLabelId, isDeleted: false }, trx }));
|
|
303
|
-
if (label != null)
|
|
303
|
+
if (label != null) {
|
|
304
304
|
labels.push(label);
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
console.debug(`[StorageIdb] orphan tx_labels_map row skipped: transactionId=${String(transactionId)} txLabelId=${txLabelId}`);
|
|
308
|
+
}
|
|
307
309
|
}
|
|
308
310
|
return labels;
|
|
309
311
|
}
|
|
@@ -313,20 +315,22 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
313
315
|
const tags = [];
|
|
314
316
|
for (const outputTagId of tagIds) {
|
|
315
317
|
const tag = (0, utilityHelpers_1.verifyOneOrNone)(await this.findOutputTags({ partial: { outputTagId, isDeleted: false }, trx }));
|
|
316
|
-
if (tag != null)
|
|
318
|
+
if (tag != null) {
|
|
317
319
|
tags.push(tag);
|
|
318
|
-
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
319
322
|
console.debug(`[StorageIdb] orphan output_tags_map row skipped: outputId=${outputId} outputTagId=${outputTagId}`);
|
|
323
|
+
}
|
|
320
324
|
}
|
|
321
325
|
return tags;
|
|
322
326
|
}
|
|
323
327
|
async listActions(auth, vargs) {
|
|
324
|
-
if (
|
|
328
|
+
if (auth.userId == null)
|
|
325
329
|
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
326
330
|
return await (0, listActionsIdb_1.listActionsIdb)(this, auth, vargs);
|
|
327
331
|
}
|
|
328
332
|
async listOutputs(auth, vargs) {
|
|
329
|
-
if (
|
|
333
|
+
if (auth.userId == null)
|
|
330
334
|
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
331
335
|
return await (0, listOutputsIdb_1.listOutputsIdb)(this, auth, vargs);
|
|
332
336
|
}
|
|
@@ -342,25 +346,25 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
342
346
|
return count;
|
|
343
347
|
}
|
|
344
348
|
async findCertificatesAuth(auth, args) {
|
|
345
|
-
if (
|
|
349
|
+
if (auth.userId == null || (args.partial.userId != null && args.partial.userId !== 0 && args.partial.userId !== auth.userId))
|
|
346
350
|
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
347
351
|
args.partial.userId = auth.userId;
|
|
348
352
|
return await this.findCertificates(args);
|
|
349
353
|
}
|
|
350
354
|
async findOutputBasketsAuth(auth, args) {
|
|
351
|
-
if (
|
|
355
|
+
if (auth.userId == null || (args.partial.userId != null && args.partial.userId !== 0 && args.partial.userId !== auth.userId))
|
|
352
356
|
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
353
357
|
args.partial.userId = auth.userId;
|
|
354
358
|
return await this.findOutputBaskets(args);
|
|
355
359
|
}
|
|
356
360
|
async findOutputsAuth(auth, args) {
|
|
357
|
-
if (
|
|
361
|
+
if (auth.userId == null || (args.partial.userId != null && args.partial.userId !== 0 && args.partial.userId !== auth.userId))
|
|
358
362
|
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
359
363
|
args.partial.userId = auth.userId;
|
|
360
364
|
return await this.findOutputs(args);
|
|
361
365
|
}
|
|
362
366
|
async insertCertificateAuth(auth, certificate) {
|
|
363
|
-
if (
|
|
367
|
+
if (auth.userId == null || (certificate.userId != null && certificate.userId !== 0 && certificate.userId !== auth.userId))
|
|
364
368
|
throw new WERR_errors_1.WERR_UNAUTHORIZED();
|
|
365
369
|
certificate.userId = auth.userId;
|
|
366
370
|
return await this.insertCertificate(certificate);
|
|
@@ -383,12 +387,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
383
387
|
return;
|
|
384
388
|
for (const k of Object.keys(partial)) {
|
|
385
389
|
if (partial[k] === undefined) {
|
|
386
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`args.partial.${k}`,
|
|
390
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`args.partial.${k}`, 'not undefined. Passing undefined as a filter value is not supported — omit the key to skip filtering. Matches Knex semantics.');
|
|
387
391
|
}
|
|
388
392
|
}
|
|
389
393
|
}
|
|
390
394
|
async filterOutputTagMaps(args, filtered, userId) {
|
|
391
|
-
var _a, _b, _c, _d;
|
|
395
|
+
var _a, _b, _c, _d, _e;
|
|
392
396
|
this.assertNoUndefinedInPartial(args.partial);
|
|
393
397
|
const dbTrx = this.toDbTrx(['output_tags_map', 'output_tags'], 'readonly', args.trx);
|
|
394
398
|
const store = dbTrx.objectStore('output_tags_map');
|
|
@@ -403,7 +407,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
403
407
|
else {
|
|
404
408
|
cursor = await store.openCursor();
|
|
405
409
|
}
|
|
406
|
-
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset)
|
|
410
|
+
await scanCursor(cursor, args.since, (_d = (_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0, (_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit, async (r) => {
|
|
407
411
|
if (args.tagIds != null && !args.tagIds.includes(r.outputTagId))
|
|
408
412
|
return false;
|
|
409
413
|
if (!(0, idbHelpers_1.matchesOutputTagMapPartial)(r, args.partial))
|
|
@@ -433,7 +437,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
433
437
|
partial, direction
|
|
434
438
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
435
439
|
) {
|
|
436
|
-
if (partial === null || partial === void 0 ? void 0 : partial.provenTxReqId)
|
|
440
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.provenTxReqId) != null && partial.provenTxReqId !== 0)
|
|
437
441
|
return store.openCursor(partial.provenTxReqId, direction);
|
|
438
442
|
if ((partial === null || partial === void 0 ? void 0 : partial.provenTxId) !== undefined)
|
|
439
443
|
return store.index('provenTxId').openCursor(partial.provenTxId, direction);
|
|
@@ -446,7 +450,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
446
450
|
return store.openCursor(null, direction);
|
|
447
451
|
}
|
|
448
452
|
async filterProvenTxReqs(args, filtered, userId) {
|
|
449
|
-
var _a, _b;
|
|
453
|
+
var _a, _b, _c;
|
|
450
454
|
this.assertNoUndefinedInPartial(args.partial);
|
|
451
455
|
if (args.partial.rawTx != null) {
|
|
452
456
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. ProvenTxReqs may not be found by rawTx value.');
|
|
@@ -455,10 +459,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
455
459
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', 'undefined. ProvenTxReqs may not be found by inputBEEF value.');
|
|
456
460
|
}
|
|
457
461
|
const dbTrx = this.toDbTrx(['proven_tx_reqs', 'transactions'], 'readonly', args.trx);
|
|
458
|
-
const direction = args.orderDescending ? 'prev' : 'next';
|
|
462
|
+
const direction = args.orderDescending === true ? 'prev' : 'next';
|
|
459
463
|
const store = dbTrx.objectStore('proven_tx_reqs');
|
|
460
464
|
const cursor = await this.openProvenTxReqsCursor(store, args.partial, direction);
|
|
461
|
-
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset)
|
|
465
|
+
await scanCursor(cursor, args.since, (_b = (_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0, (_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit, async (r) => {
|
|
462
466
|
if (!(0, idbHelpers_1.matchesProvenTxReqPartial)(r, args.partial))
|
|
463
467
|
return false;
|
|
464
468
|
if (args.status != null && args.status.length > 0 && !args.status.includes(r.status))
|
|
@@ -483,7 +487,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
483
487
|
return results;
|
|
484
488
|
}
|
|
485
489
|
async filterProvenTxs(args, filtered, userId) {
|
|
486
|
-
var _a, _b, _c, _d;
|
|
490
|
+
var _a, _b, _c, _d, _e;
|
|
487
491
|
this.assertNoUndefinedInPartial(args.partial);
|
|
488
492
|
if (args.partial.rawTx != null) {
|
|
489
493
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. ProvenTxs may not be found by rawTx value.');
|
|
@@ -492,11 +496,11 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
492
496
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.merklePath', 'undefined. ProvenTxs may not be found by merklePath value.');
|
|
493
497
|
}
|
|
494
498
|
const dbTrx = this.toDbTrx(['proven_txs', 'transactions'], 'readonly', args.trx);
|
|
495
|
-
const direction = args.orderDescending ? 'prev' : 'next';
|
|
499
|
+
const direction = args.orderDescending === true ? 'prev' : 'next';
|
|
496
500
|
const store = dbTrx.objectStore('proven_txs');
|
|
497
501
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
498
502
|
let cursor;
|
|
499
|
-
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.provenTxId) {
|
|
503
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.provenTxId) != null && args.partial.provenTxId > 0) {
|
|
500
504
|
cursor = await store.openCursor(args.partial.provenTxId, direction);
|
|
501
505
|
}
|
|
502
506
|
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.txid) !== undefined) {
|
|
@@ -505,7 +509,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
505
509
|
else {
|
|
506
510
|
cursor = await store.openCursor(null, direction);
|
|
507
511
|
}
|
|
508
|
-
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset)
|
|
512
|
+
await scanCursor(cursor, args.since, (_d = (_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0, (_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit, async (r) => {
|
|
509
513
|
if (!(0, idbHelpers_1.matchesProvenTxPartial)(r, args.partial))
|
|
510
514
|
return false;
|
|
511
515
|
if (userId !== undefined) {
|
|
@@ -526,7 +530,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
526
530
|
return results;
|
|
527
531
|
}
|
|
528
532
|
async filterTxLabelMaps(args, filtered, userId) {
|
|
529
|
-
var _a, _b, _c, _d;
|
|
533
|
+
var _a, _b, _c, _d, _e;
|
|
530
534
|
this.assertNoUndefinedInPartial(args.partial);
|
|
531
535
|
const dbTrx = this.toDbTrx(['tx_labels_map', 'tx_labels'], 'readonly', args.trx);
|
|
532
536
|
const store = dbTrx.objectStore('tx_labels_map');
|
|
@@ -541,7 +545,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
541
545
|
else {
|
|
542
546
|
cursor = await store.openCursor();
|
|
543
547
|
}
|
|
544
|
-
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset)
|
|
548
|
+
await scanCursor(cursor, args.since, (_d = (_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0, (_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit, async (r) => {
|
|
545
549
|
if (!(0, idbHelpers_1.matchesTxLabelMapPartial)(r, args.partial))
|
|
546
550
|
return false;
|
|
547
551
|
if (userId !== undefined) {
|
|
@@ -592,10 +596,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
592
596
|
async insertCertificate(certificate, trx) {
|
|
593
597
|
const e = await this.validateEntityForInsert(certificate, trx, undefined, ['isDeleted']);
|
|
594
598
|
// Strip non-schema runtime fields before insert. Matches Knex canon.
|
|
595
|
-
if (e.logger)
|
|
599
|
+
if (e.logger != null)
|
|
596
600
|
delete e.logger;
|
|
597
601
|
const fields = e.fields;
|
|
598
|
-
if (e.fields)
|
|
602
|
+
if (e.fields != null)
|
|
599
603
|
delete e.fields;
|
|
600
604
|
if (e.certificateId === 0)
|
|
601
605
|
delete e.certificateId;
|
|
@@ -604,7 +608,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
604
608
|
try {
|
|
605
609
|
const id = Number(await store.add(e));
|
|
606
610
|
certificate.certificateId = id;
|
|
607
|
-
if (fields) {
|
|
611
|
+
if (fields != null) {
|
|
608
612
|
for (const field of fields) {
|
|
609
613
|
field.certificateId = certificate.certificateId;
|
|
610
614
|
field.userId = certificate.userId;
|
|
@@ -844,7 +848,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
844
848
|
const e = await store.get(i);
|
|
845
849
|
// Match Knex/Bun semantics: missing rows produce a 0-row result, not an error.
|
|
846
850
|
// Caller receives the true updated count and can decide how to react.
|
|
847
|
-
if (
|
|
851
|
+
if (e == null)
|
|
848
852
|
continue;
|
|
849
853
|
const v = {
|
|
850
854
|
...e,
|
|
@@ -876,7 +880,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
876
880
|
const store = dbTrx.objectStore(storeName);
|
|
877
881
|
try {
|
|
878
882
|
const e = await store.get(key);
|
|
879
|
-
if (
|
|
883
|
+
if (e == null) {
|
|
880
884
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('key', `an existing record to update ${keyProps.join(',')} ${key.join(',')} not found`);
|
|
881
885
|
}
|
|
882
886
|
const v = {
|
|
@@ -886,7 +890,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
886
890
|
const uid = await store.put(v);
|
|
887
891
|
for (let i = 0; i < key.length; i++) {
|
|
888
892
|
if (uid[i] !== key[i])
|
|
889
|
-
throw new WERR_errors_1.WERR_INTERNAL(`updated key ${uid[i]} does not match original ${key[i]}`);
|
|
893
|
+
throw new WERR_errors_1.WERR_INTERNAL(`updated key ${String(uid[i])} does not match original ${String(key[i])}`);
|
|
890
894
|
}
|
|
891
895
|
}
|
|
892
896
|
finally {
|
|
@@ -973,7 +977,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
973
977
|
}
|
|
974
978
|
}
|
|
975
979
|
async filterCertificateFields(args, filtered) {
|
|
976
|
-
var _a, _b, _c, _d;
|
|
980
|
+
var _a, _b, _c, _d, _e;
|
|
977
981
|
this.assertNoUndefinedInPartial(args.partial);
|
|
978
982
|
const dbTrx = this.toDbTrx(['certificate_fields'], 'readonly', args.trx);
|
|
979
983
|
const store = dbTrx.objectStore('certificate_fields');
|
|
@@ -988,7 +992,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
988
992
|
else {
|
|
989
993
|
cursor = await store.openCursor();
|
|
990
994
|
}
|
|
991
|
-
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset)
|
|
995
|
+
await scanCursor(cursor, args.since, (_d = (_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) !== null && _d !== void 0 ? _d : 0, (_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit, r => (0, idbHelpers_1.matchesCertificateFieldPartial)(r, args.partial), filtered);
|
|
992
996
|
if (args.trx == null)
|
|
993
997
|
await dbTrx.done;
|
|
994
998
|
}
|
|
@@ -1007,10 +1011,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1007
1011
|
partial
|
|
1008
1012
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1009
1013
|
) {
|
|
1010
|
-
if (partial === null || partial === void 0 ? void 0 : partial.certificateId)
|
|
1014
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.certificateId) != null && partial.certificateId !== 0)
|
|
1011
1015
|
return store.openCursor(partial.certificateId);
|
|
1012
1016
|
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1013
|
-
if ((partial === null || partial === void 0 ? void 0 : partial.type) && (partial === null || partial === void 0 ? void 0 : partial.certifier) && (partial === null || partial === void 0 ? void 0 : partial.serialNumber)) {
|
|
1017
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.type) != null && (partial === null || partial === void 0 ? void 0 : partial.certifier) != null && (partial === null || partial === void 0 ? void 0 : partial.serialNumber) != null) {
|
|
1014
1018
|
return store
|
|
1015
1019
|
.index('userId_type_certifier_serialNumber')
|
|
1016
1020
|
.openCursor([partial.userId, partial.type, partial.certifier, partial.serialNumber]);
|
|
@@ -1020,12 +1024,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1020
1024
|
return store.openCursor();
|
|
1021
1025
|
}
|
|
1022
1026
|
async filterCertificates(args, filtered) {
|
|
1023
|
-
var _a, _b;
|
|
1027
|
+
var _a, _b, _c;
|
|
1024
1028
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1025
1029
|
const dbTrx = this.toDbTrx(['certificates'], 'readonly', args.trx);
|
|
1026
1030
|
const store = dbTrx.objectStore('certificates');
|
|
1027
1031
|
const cursor = await this.openCertificatesCursor(store, args.partial);
|
|
1028
|
-
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset)
|
|
1032
|
+
await scanCursor(cursor, args.since, (_b = (_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0, (_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit, r => {
|
|
1029
1033
|
if (args.certifiers != null && !args.certifiers.includes(r.certifier))
|
|
1030
1034
|
return false;
|
|
1031
1035
|
if (args.types != null && !args.types.includes(r.type))
|
|
@@ -1040,7 +1044,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1040
1044
|
await this.filterCertificates(args, r => {
|
|
1041
1045
|
result.push(this.validateEntity(r));
|
|
1042
1046
|
});
|
|
1043
|
-
if (args.includeFields) {
|
|
1047
|
+
if (args.includeFields === true) {
|
|
1044
1048
|
for (const c of result) {
|
|
1045
1049
|
const fields = await this.findCertificateFields({ partial: { certificateId: c.certificateId }, trx: args.trx });
|
|
1046
1050
|
c.fields = fields;
|
|
@@ -1049,7 +1053,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1049
1053
|
return result;
|
|
1050
1054
|
}
|
|
1051
1055
|
async filterCommissions(args, filtered) {
|
|
1052
|
-
var _a, _b, _c, _d, _e;
|
|
1056
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1053
1057
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1054
1058
|
if (args.partial.lockingScript != null) {
|
|
1055
1059
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('partial.lockingScript', 'undefined. Commissions may not be found by lockingScript value.');
|
|
@@ -1058,7 +1062,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1058
1062
|
const store = dbTrx.objectStore('commissions');
|
|
1059
1063
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1060
1064
|
let cursor;
|
|
1061
|
-
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.commissionId) {
|
|
1065
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.commissionId) != null && args.partial.commissionId !== 0) {
|
|
1062
1066
|
cursor = await store.openCursor(args.partial.commissionId);
|
|
1063
1067
|
}
|
|
1064
1068
|
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
@@ -1070,7 +1074,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1070
1074
|
else {
|
|
1071
1075
|
cursor = await store.openCursor();
|
|
1072
1076
|
}
|
|
1073
|
-
await scanCursor(cursor, args.since, ((_d = args.paged) === null || _d === void 0 ? void 0 : _d.offset)
|
|
1077
|
+
await scanCursor(cursor, args.since, (_e = (_d = args.paged) === null || _d === void 0 ? void 0 : _d.offset) !== null && _e !== void 0 ? _e : 0, (_f = args.paged) === null || _f === void 0 ? void 0 : _f.limit, r => (0, idbHelpers_1.matchesCommissionPartial)(r, args.partial), filtered);
|
|
1074
1078
|
if (args.trx == null)
|
|
1075
1079
|
await dbTrx.done;
|
|
1076
1080
|
}
|
|
@@ -1082,12 +1086,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1082
1086
|
return result;
|
|
1083
1087
|
}
|
|
1084
1088
|
async filterMonitorEvents(args, filtered) {
|
|
1085
|
-
var _a, _b, _c;
|
|
1089
|
+
var _a, _b, _c, _d;
|
|
1086
1090
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1087
1091
|
const dbTrx = this.toDbTrx(['monitor_events'], 'readonly', args.trx);
|
|
1088
1092
|
const store = dbTrx.objectStore('monitor_events');
|
|
1089
|
-
const cursor = ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.id) ? await store.openCursor(args.partial.id) : await store.openCursor();
|
|
1090
|
-
await scanCursor(cursor, args.since, ((_b = args.paged) === null || _b === void 0 ? void 0 : _b.offset)
|
|
1093
|
+
const cursor = (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.id) != null && args.partial.id !== 0) ? await store.openCursor(args.partial.id) : await store.openCursor();
|
|
1094
|
+
await scanCursor(cursor, args.since, (_c = (_b = args.paged) === null || _b === void 0 ? void 0 : _b.offset) !== null && _c !== void 0 ? _c : 0, (_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit, r => (0, idbHelpers_1.matchesMonitorEventPartial)(r, args.partial), filtered);
|
|
1091
1095
|
if (args.trx == null)
|
|
1092
1096
|
await dbTrx.done;
|
|
1093
1097
|
}
|
|
@@ -1099,13 +1103,13 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1099
1103
|
return result;
|
|
1100
1104
|
}
|
|
1101
1105
|
async filterOutputBaskets(args, filtered) {
|
|
1102
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1106
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1103
1107
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1104
1108
|
const dbTrx = this.toDbTrx(['output_baskets'], 'readonly', args.trx);
|
|
1105
1109
|
const store = dbTrx.objectStore('output_baskets');
|
|
1106
1110
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1107
1111
|
let cursor;
|
|
1108
|
-
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.basketId) {
|
|
1112
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.basketId) != null && args.partial.basketId !== 0) {
|
|
1109
1113
|
cursor = await store.openCursor(args.partial.basketId);
|
|
1110
1114
|
}
|
|
1111
1115
|
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined && ((_c = args.partial) === null || _c === void 0 ? void 0 : _c.name) !== undefined) {
|
|
@@ -1117,7 +1121,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1117
1121
|
else {
|
|
1118
1122
|
cursor = await store.openCursor();
|
|
1119
1123
|
}
|
|
1120
|
-
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset)
|
|
1124
|
+
await scanCursor(cursor, args.since, (_f = (_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) !== null && _f !== void 0 ? _f : 0, (_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit, r => (0, idbHelpers_1.matchesOutputBasketPartial)(r, args.partial), filtered);
|
|
1121
1125
|
if (args.trx == null)
|
|
1122
1126
|
await dbTrx.done;
|
|
1123
1127
|
}
|
|
@@ -1136,10 +1140,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1136
1140
|
partial, direction
|
|
1137
1141
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1138
1142
|
) {
|
|
1139
|
-
if (partial === null || partial === void 0 ? void 0 : partial.outputId)
|
|
1143
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.outputId) != null && partial.outputId !== 0)
|
|
1140
1144
|
return store.openCursor(partial.outputId, direction);
|
|
1141
1145
|
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1142
|
-
if ((partial === null || partial === void 0 ? void 0 : partial.transactionId) && (partial === null || partial === void 0 ? void 0 : partial.vout) !== undefined) {
|
|
1146
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.transactionId) != null && partial.transactionId !== 0 && (partial === null || partial === void 0 ? void 0 : partial.vout) !== undefined) {
|
|
1143
1147
|
return store.index('transactionId_vout_userId').openCursor([partial.transactionId, partial.vout, partial.userId], direction);
|
|
1144
1148
|
}
|
|
1145
1149
|
return store.index('userId').openCursor(partial.userId, direction);
|
|
@@ -1153,7 +1157,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1153
1157
|
return store.openCursor(null, direction);
|
|
1154
1158
|
}
|
|
1155
1159
|
async filterOutputs(args, filtered, tagIds, isQueryModeAll) {
|
|
1156
|
-
var _a, _b;
|
|
1160
|
+
var _a, _b, _c;
|
|
1157
1161
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1158
1162
|
if (args.partial.lockingScript != null) {
|
|
1159
1163
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.lockingScript', 'undefined. Outputs may not be found by lockingScript value.');
|
|
@@ -1164,10 +1168,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1164
1168
|
if (args.txStatus != null)
|
|
1165
1169
|
stores.push('transactions');
|
|
1166
1170
|
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1167
|
-
const direction = args.orderDescending ? 'prev' : 'next';
|
|
1171
|
+
const direction = args.orderDescending === true ? 'prev' : 'next';
|
|
1168
1172
|
const store = dbTrx.objectStore('outputs');
|
|
1169
1173
|
const cursor = await this.openOutputsCursor(store, args.partial, direction);
|
|
1170
|
-
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset)
|
|
1174
|
+
await scanCursor(cursor, args.since, (_b = (_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0, (_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit, async (r) => {
|
|
1171
1175
|
if (!(0, idbHelpers_1.matchesOutputPartial)(r, args.partial))
|
|
1172
1176
|
return false;
|
|
1173
1177
|
if (args.txStatus !== undefined) {
|
|
@@ -1197,7 +1201,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1197
1201
|
if (ids.length > 0) {
|
|
1198
1202
|
const i = ids.indexOf(tm.outputTagId);
|
|
1199
1203
|
if (i >= 0) {
|
|
1200
|
-
if (isQueryModeAll) {
|
|
1204
|
+
if (isQueryModeAll === true) {
|
|
1201
1205
|
ids.splice(i, 1);
|
|
1202
1206
|
}
|
|
1203
1207
|
else {
|
|
@@ -1214,7 +1218,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1214
1218
|
results.push(this.validateEntity(r));
|
|
1215
1219
|
}, tagIds, isQueryModeAll);
|
|
1216
1220
|
for (const o of results) {
|
|
1217
|
-
if (args.noScript) {
|
|
1221
|
+
if (args.noScript === true) {
|
|
1218
1222
|
o.lockingScript = undefined;
|
|
1219
1223
|
}
|
|
1220
1224
|
else {
|
|
@@ -1224,12 +1228,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1224
1228
|
return results;
|
|
1225
1229
|
}
|
|
1226
1230
|
async filterOutputTags(args, filtered) {
|
|
1227
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1231
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1228
1232
|
const dbTrx = this.toDbTrx(['output_tags'], 'readonly', args.trx);
|
|
1229
1233
|
const store = dbTrx.objectStore('output_tags');
|
|
1230
1234
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1231
1235
|
let cursor;
|
|
1232
|
-
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.outputTagId) {
|
|
1236
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.outputTagId) != null && args.partial.outputTagId !== 0) {
|
|
1233
1237
|
cursor = await store.openCursor(args.partial.outputTagId);
|
|
1234
1238
|
}
|
|
1235
1239
|
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined && ((_c = args.partial) === null || _c === void 0 ? void 0 : _c.tag) !== undefined) {
|
|
@@ -1241,7 +1245,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1241
1245
|
else {
|
|
1242
1246
|
cursor = await store.openCursor();
|
|
1243
1247
|
}
|
|
1244
|
-
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset)
|
|
1248
|
+
await scanCursor(cursor, args.since, (_f = (_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) !== null && _f !== void 0 ? _f : 0, (_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit, r => (0, idbHelpers_1.matchesOutputTagPartial)(r, args.partial), filtered);
|
|
1245
1249
|
if (args.trx == null)
|
|
1246
1250
|
await dbTrx.done;
|
|
1247
1251
|
}
|
|
@@ -1253,15 +1257,15 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1253
1257
|
return result;
|
|
1254
1258
|
}
|
|
1255
1259
|
async filterSyncStates(args, filtered) {
|
|
1256
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1257
|
-
if (args.partial.syncMap) {
|
|
1260
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1261
|
+
if (args.partial.syncMap != null && args.partial.syncMap !== '') {
|
|
1258
1262
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.syncMap', 'undefined. SyncStates may not be found by syncMap value.');
|
|
1259
1263
|
}
|
|
1260
1264
|
const dbTrx = this.toDbTrx(['sync_states'], 'readonly', args.trx);
|
|
1261
1265
|
const store = dbTrx.objectStore('sync_states');
|
|
1262
1266
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1263
1267
|
let cursor;
|
|
1264
|
-
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.syncStateId) {
|
|
1268
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.syncStateId) != null && args.partial.syncStateId !== 0) {
|
|
1265
1269
|
cursor = await store.openCursor(args.partial.syncStateId);
|
|
1266
1270
|
}
|
|
1267
1271
|
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
@@ -1276,7 +1280,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1276
1280
|
else {
|
|
1277
1281
|
cursor = await store.openCursor();
|
|
1278
1282
|
}
|
|
1279
|
-
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset)
|
|
1283
|
+
await scanCursor(cursor, args.since, (_f = (_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) !== null && _f !== void 0 ? _f : 0, (_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit, r => (0, idbHelpers_1.matchesSyncStatePartial)(r, args.partial), filtered);
|
|
1280
1284
|
if (args.trx == null)
|
|
1281
1285
|
await dbTrx.done;
|
|
1282
1286
|
}
|
|
@@ -1295,7 +1299,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1295
1299
|
partial, direction
|
|
1296
1300
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1297
1301
|
) {
|
|
1298
|
-
if (partial === null || partial === void 0 ? void 0 : partial.transactionId)
|
|
1302
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.transactionId) != null && partial.transactionId !== 0)
|
|
1299
1303
|
return store.openCursor(partial.transactionId, direction);
|
|
1300
1304
|
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1301
1305
|
if ((partial === null || partial === void 0 ? void 0 : partial.status) !== undefined) {
|
|
@@ -1312,7 +1316,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1312
1316
|
return store.openCursor(null, direction);
|
|
1313
1317
|
}
|
|
1314
1318
|
async filterTransactions(args, filtered, labelIds, isQueryModeAll) {
|
|
1315
|
-
var _a, _b;
|
|
1319
|
+
var _a, _b, _c;
|
|
1316
1320
|
if (args.partial.rawTx != null) {
|
|
1317
1321
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. Transactions may not be found by rawTx value.');
|
|
1318
1322
|
}
|
|
@@ -1323,10 +1327,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1323
1327
|
if (labelIds != null && labelIds.length > 0)
|
|
1324
1328
|
stores.push('tx_labels_map');
|
|
1325
1329
|
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1326
|
-
const direction = args.orderDescending ? 'prev' : 'next';
|
|
1330
|
+
const direction = args.orderDescending === true ? 'prev' : 'next';
|
|
1327
1331
|
const store = dbTrx.objectStore('transactions');
|
|
1328
1332
|
const cursor = await this.openTransactionsCursor(store, args.partial, direction);
|
|
1329
|
-
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset)
|
|
1333
|
+
await scanCursor(cursor, args.since, (_b = (_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0, (_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit, async (r) => {
|
|
1330
1334
|
if (args.from != null && r.created_at.getTime() < args.from.getTime())
|
|
1331
1335
|
return false;
|
|
1332
1336
|
if (args.to != null && r.created_at.getTime() >= args.to.getTime())
|
|
@@ -1348,7 +1352,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1348
1352
|
if (ids.length > 0) {
|
|
1349
1353
|
const i = ids.indexOf(lm.txLabelId);
|
|
1350
1354
|
if (i >= 0) {
|
|
1351
|
-
if (isQueryModeAll) {
|
|
1355
|
+
if (isQueryModeAll === true) {
|
|
1352
1356
|
ids.splice(i, 1);
|
|
1353
1357
|
}
|
|
1354
1358
|
else {
|
|
@@ -1365,7 +1369,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1365
1369
|
results.push(this.validateEntity(r));
|
|
1366
1370
|
}, labelIds, isQueryModeAll);
|
|
1367
1371
|
for (const t of results) {
|
|
1368
|
-
if (args.noRawTx) {
|
|
1372
|
+
if (args.noRawTx === true) {
|
|
1369
1373
|
t.rawTx = undefined;
|
|
1370
1374
|
t.inputBEEF = undefined;
|
|
1371
1375
|
}
|
|
@@ -1376,12 +1380,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1376
1380
|
return results;
|
|
1377
1381
|
}
|
|
1378
1382
|
async filterTxLabels(args, filtered) {
|
|
1379
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1383
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1380
1384
|
const dbTrx = this.toDbTrx(['tx_labels'], 'readonly', args.trx);
|
|
1381
1385
|
const store = dbTrx.objectStore('tx_labels');
|
|
1382
1386
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1383
1387
|
let cursor;
|
|
1384
|
-
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.txLabelId) {
|
|
1388
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.txLabelId) != null && args.partial.txLabelId !== 0) {
|
|
1385
1389
|
cursor = await store.openCursor(args.partial.txLabelId);
|
|
1386
1390
|
}
|
|
1387
1391
|
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined && ((_c = args.partial) === null || _c === void 0 ? void 0 : _c.label) !== undefined) {
|
|
@@ -1393,7 +1397,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1393
1397
|
else {
|
|
1394
1398
|
cursor = await store.openCursor();
|
|
1395
1399
|
}
|
|
1396
|
-
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset)
|
|
1400
|
+
await scanCursor(cursor, args.since, (_f = (_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) !== null && _f !== void 0 ? _f : 0, (_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit, r => (0, idbHelpers_1.matchesTxLabelPartial)(r, args.partial), filtered);
|
|
1397
1401
|
if (args.trx == null)
|
|
1398
1402
|
await dbTrx.done;
|
|
1399
1403
|
}
|
|
@@ -1405,25 +1409,25 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1405
1409
|
return result;
|
|
1406
1410
|
}
|
|
1407
1411
|
matchesUserPartial(r, partial) {
|
|
1408
|
-
if (
|
|
1412
|
+
if (partial == null)
|
|
1409
1413
|
return true;
|
|
1410
|
-
if (partial.userId && r.userId !== partial.userId)
|
|
1414
|
+
if (partial.userId != null && partial.userId !== 0 && r.userId !== partial.userId)
|
|
1411
1415
|
return false;
|
|
1412
1416
|
if ((partial.created_at != null) && r.created_at.getTime() !== partial.created_at.getTime())
|
|
1413
1417
|
return false;
|
|
1414
1418
|
if ((partial.updated_at != null) && r.updated_at.getTime() !== partial.updated_at.getTime())
|
|
1415
1419
|
return false;
|
|
1416
|
-
if (partial.identityKey && r.identityKey !== partial.identityKey)
|
|
1420
|
+
if (partial.identityKey != null && partial.identityKey !== '' && r.identityKey !== partial.identityKey)
|
|
1417
1421
|
return false;
|
|
1418
|
-
if (partial.activeStorage && r.activeStorage !== partial.activeStorage)
|
|
1422
|
+
if (partial.activeStorage != null && partial.activeStorage !== '' && r.activeStorage !== partial.activeStorage)
|
|
1419
1423
|
return false;
|
|
1420
1424
|
return true;
|
|
1421
1425
|
}
|
|
1422
1426
|
async filterUsers(args, filtered) {
|
|
1423
|
-
var _a, _b;
|
|
1427
|
+
var _a, _b, _c;
|
|
1424
1428
|
const dbTrx = this.toDbTrx(['users'], 'readonly', args.trx);
|
|
1425
1429
|
const cursor = await dbTrx.objectStore('users').openCursor();
|
|
1426
|
-
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset)
|
|
1430
|
+
await scanCursor(cursor, args.since, (_b = (_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : 0, (_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit, r => this.matchesUserPartial(r, args.partial), filtered);
|
|
1427
1431
|
if (args.trx == null)
|
|
1428
1432
|
await dbTrx.done;
|
|
1429
1433
|
}
|
|
@@ -1586,7 +1590,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1586
1590
|
if (dateFields == null)
|
|
1587
1591
|
return;
|
|
1588
1592
|
for (const df of dateFields) {
|
|
1589
|
-
if (entity[df])
|
|
1593
|
+
if (entity[df] != null)
|
|
1590
1594
|
entity[df] = this.validateDate(entity[df]);
|
|
1591
1595
|
}
|
|
1592
1596
|
}
|
|
@@ -1595,7 +1599,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1595
1599
|
return;
|
|
1596
1600
|
for (const df of booleanFields) {
|
|
1597
1601
|
if (entity[df] !== undefined)
|
|
1598
|
-
entity[df] =
|
|
1602
|
+
entity[df] = entity[df] !== 0 && entity[df] != null && entity[df] !== false;
|
|
1599
1603
|
}
|
|
1600
1604
|
}
|
|
1601
1605
|
normalizeEntityValues(entity) {
|
|
@@ -1625,13 +1629,13 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1625
1629
|
* Use to process the update template for entities being updated.
|
|
1626
1630
|
*/
|
|
1627
1631
|
validatePartialForUpdate(update, dateFields, booleanFields) {
|
|
1628
|
-
if (
|
|
1632
|
+
if (this.dbtype == null)
|
|
1629
1633
|
throw new WERR_errors_1.WERR_INTERNAL('must call verifyReadyForDatabaseAccess first');
|
|
1630
1634
|
const v = { ...update };
|
|
1631
|
-
v.created_at = v.created_at ? this.validateEntityDate(v.created_at) : undefined;
|
|
1632
|
-
if (
|
|
1635
|
+
v.created_at = v.created_at != null ? this.validateEntityDate(v.created_at) : undefined;
|
|
1636
|
+
if (v.created_at == null)
|
|
1633
1637
|
delete v.created_at;
|
|
1634
|
-
v.updated_at = v.updated_at ? this.validateEntityDate(v.updated_at) : this.validateEntityDate(new Date());
|
|
1638
|
+
v.updated_at = v.updated_at != null ? this.validateEntityDate(v.updated_at) : this.validateEntityDate(new Date());
|
|
1635
1639
|
this.applyOptionalDateFields(v, dateFields);
|
|
1636
1640
|
this.applyIntegerBooleanFields(update, booleanFields);
|
|
1637
1641
|
this.normalizeForStorage(v);
|
|
@@ -1642,7 +1646,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1642
1646
|
if (dateFields == null)
|
|
1643
1647
|
return;
|
|
1644
1648
|
for (const df of dateFields) {
|
|
1645
|
-
if (v[df])
|
|
1649
|
+
if (v[df] != null)
|
|
1646
1650
|
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
1647
1651
|
}
|
|
1648
1652
|
}
|
|
@@ -1653,7 +1657,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1653
1657
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1654
1658
|
const u = update;
|
|
1655
1659
|
if (u[df] !== undefined)
|
|
1656
|
-
u[df] = u[df] ? 1 : 0;
|
|
1660
|
+
u[df] = u[df] != null && u[df] !== false ? 1 : 0;
|
|
1657
1661
|
}
|
|
1658
1662
|
}
|
|
1659
1663
|
normalizeForStorage(v) {
|
|
@@ -1672,13 +1676,14 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1672
1676
|
* Use to process new entities being inserted into the database.
|
|
1673
1677
|
*/
|
|
1674
1678
|
async validateEntityForInsert(entity, trx, dateFields, booleanFields) {
|
|
1679
|
+
var _a, _b;
|
|
1675
1680
|
await this.verifyReadyForDatabaseAccess(trx);
|
|
1676
1681
|
const v = { ...entity };
|
|
1677
|
-
v.created_at = this.validateOptionalEntityDate(v.created_at, true);
|
|
1678
|
-
v.updated_at = this.validateOptionalEntityDate(v.updated_at, true);
|
|
1679
|
-
if (
|
|
1682
|
+
v.created_at = (_a = this.validateOptionalEntityDate(v.created_at, true)) !== null && _a !== void 0 ? _a : new Date();
|
|
1683
|
+
v.updated_at = (_b = this.validateOptionalEntityDate(v.updated_at, true)) !== null && _b !== void 0 ? _b : new Date();
|
|
1684
|
+
if (v.created_at == null)
|
|
1680
1685
|
delete v.created_at;
|
|
1681
|
-
if (
|
|
1686
|
+
if (v.updated_at == null)
|
|
1682
1687
|
delete v.updated_at;
|
|
1683
1688
|
this.applyOptionalDateFields(v, dateFields);
|
|
1684
1689
|
this.applyIntegerBooleanFields(entity, booleanFields);
|
|
@@ -1688,7 +1693,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1688
1693
|
}
|
|
1689
1694
|
async validateRawTransaction(t, trx) {
|
|
1690
1695
|
// if there is no txid or there is a rawTransaction return what we have.
|
|
1691
|
-
if (t.rawTx ||
|
|
1696
|
+
if (t.rawTx != null || t.txid == null || t.txid === '')
|
|
1692
1697
|
return;
|
|
1693
1698
|
// rawTransaction is missing, see if we moved it ...
|
|
1694
1699
|
const rawTx = await this.getRawTxOfKnownValidTransaction(t.txid, undefined, undefined, trx);
|