@xyo-network/bridge-pub-sub 2.104.0 → 2.105.0-rc.1
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/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +1 -1
- package/dist/browser/index.cjs +29 -42
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +29 -42
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +1 -1
- package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +1 -1
- package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +1 -1
- package/dist/neutral/index.cjs +29 -42
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +29 -42
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +1 -1
- package/dist/node/index.cjs +30 -46
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +30 -46
- package/dist/node/index.js.map +1 -1
- package/package.json +23 -22
- package/src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts +1 -0
package/dist/neutral/index.js
CHANGED
|
@@ -106,8 +106,7 @@ var AsyncQueryBusBase = class extends Base2 {
|
|
|
106
106
|
async commitState(address, nextState) {
|
|
107
107
|
await Promise.resolve();
|
|
108
108
|
const lastState = this.lastState.get(address);
|
|
109
|
-
if (lastState && lastState >= nextState)
|
|
110
|
-
return;
|
|
109
|
+
if (lastState && lastState >= nextState) return;
|
|
111
110
|
this.lastState.set(address, nextState);
|
|
112
111
|
}
|
|
113
112
|
/**
|
|
@@ -217,8 +216,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
217
216
|
const insertResult = await queryArchivist.insert?.(data);
|
|
218
217
|
this.logger?.debug(`Issued query: ${routedQueryHash} to: ${address}`);
|
|
219
218
|
this.queryCache.set(routedQueryHash, Pending);
|
|
220
|
-
if (!insertResult)
|
|
221
|
-
throw new Error("Unable to issue query to queryArchivist");
|
|
219
|
+
if (!insertResult) throw new Error("Unable to issue query to queryArchivist");
|
|
222
220
|
const context = new Promise((resolve, reject) => {
|
|
223
221
|
this.logger?.debug(`Polling for response to query: ${routedQueryHash}`);
|
|
224
222
|
let nextDelay = 100;
|
|
@@ -235,8 +233,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
235
233
|
return;
|
|
236
234
|
}
|
|
237
235
|
nextDelay = Math.floor(nextDelay * 1.2);
|
|
238
|
-
if (nextDelay > 1e3)
|
|
239
|
-
nextDelay = 1e3;
|
|
236
|
+
if (nextDelay > 1e3) nextDelay = 1e3;
|
|
240
237
|
}
|
|
241
238
|
this.logger?.error("Timeout waiting for query response");
|
|
242
239
|
const error = {
|
|
@@ -268,8 +265,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
268
265
|
} catch (e) {
|
|
269
266
|
this.logger?.error?.(`Error in main loop: ${e}`);
|
|
270
267
|
} finally {
|
|
271
|
-
if (this._pollId)
|
|
272
|
-
clearTimeoutEx(this._pollId);
|
|
268
|
+
if (this._pollId) clearTimeoutEx(this._pollId);
|
|
273
269
|
this._pollId = void 0;
|
|
274
270
|
this.poll();
|
|
275
271
|
}
|
|
@@ -278,7 +274,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
278
274
|
/**
|
|
279
275
|
* Background process for processing incoming responses to previously issued queries
|
|
280
276
|
*/
|
|
281
|
-
processIncomingResponses = async () => {
|
|
277
|
+
processIncomingResponses = /* @__PURE__ */ __name(async () => {
|
|
282
278
|
const responseArchivist = await this.responsesArchivist();
|
|
283
279
|
if (responseArchivist) {
|
|
284
280
|
const responseBoundWitnessDiviner = await this.responsesDiviner();
|
|
@@ -313,7 +309,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
313
309
|
}));
|
|
314
310
|
}
|
|
315
311
|
}
|
|
316
|
-
};
|
|
312
|
+
}, "processIncomingResponses");
|
|
317
313
|
start() {
|
|
318
314
|
if (this._pollCount === 0) {
|
|
319
315
|
this.poll();
|
|
@@ -323,8 +319,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
323
319
|
stop() {
|
|
324
320
|
this._pollCount--;
|
|
325
321
|
if (this._pollCount <= 0) {
|
|
326
|
-
if (this._pollId)
|
|
327
|
-
clearTimeoutEx(this._pollId);
|
|
322
|
+
if (this._pollId) clearTimeoutEx(this._pollId);
|
|
328
323
|
this._pollId = void 0;
|
|
329
324
|
this._pollCount = 0;
|
|
330
325
|
}
|
|
@@ -419,8 +414,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
419
414
|
if (!this.started) {
|
|
420
415
|
console.warn("AsyncQueryBus stopping when already stopped");
|
|
421
416
|
}
|
|
422
|
-
if (this._pollId)
|
|
423
|
-
clearTimeoutEx2(this._pollId);
|
|
417
|
+
if (this._pollId) clearTimeoutEx2(this._pollId);
|
|
424
418
|
this._pollId = void 0;
|
|
425
419
|
}
|
|
426
420
|
async unexpose(id, validate = true) {
|
|
@@ -436,7 +430,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
436
430
|
return module;
|
|
437
431
|
}
|
|
438
432
|
// eslint-disable-next-line max-statements
|
|
439
|
-
callLocalModule = async (localModule, query) => {
|
|
433
|
+
callLocalModule = /* @__PURE__ */ __name(async (localModule, query) => {
|
|
440
434
|
this._idle = false;
|
|
441
435
|
this._lastQueryTime = Date.now();
|
|
442
436
|
const localModuleName = localModule.id;
|
|
@@ -496,12 +490,12 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
496
490
|
}
|
|
497
491
|
}
|
|
498
492
|
}
|
|
499
|
-
};
|
|
493
|
+
}, "callLocalModule");
|
|
500
494
|
/**
|
|
501
495
|
* Finds unprocessed commands addressed to the supplied address
|
|
502
496
|
* @param address The address to find commands for
|
|
503
497
|
*/
|
|
504
|
-
findQueriesToAddress = async (address) => {
|
|
498
|
+
findQueriesToAddress = /* @__PURE__ */ __name(async (address) => {
|
|
505
499
|
const queriesDivinerId = assertEx3(this.config?.intersect?.queries?.boundWitnessDiviner, () => "No queries Diviner defined");
|
|
506
500
|
const queriesBoundWitnessDiviner = await this.queriesDiviner();
|
|
507
501
|
if (queriesBoundWitnessDiviner) {
|
|
@@ -528,7 +522,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
528
522
|
} else {
|
|
529
523
|
this.logger?.warn(`Unable to resolve queriesBoundWitnessDiviner [${queriesDivinerId}] [${await ResolveHelper2.traceModuleIdentifier(this.rootModule, queriesDivinerId)}]`);
|
|
530
524
|
}
|
|
531
|
-
};
|
|
525
|
+
}, "findQueriesToAddress");
|
|
532
526
|
/**
|
|
533
527
|
* Runs the background divine process on a loop with a delay
|
|
534
528
|
* specified by the `config.pollFrequency`
|
|
@@ -540,8 +534,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
540
534
|
} catch (e) {
|
|
541
535
|
this.logger?.error?.(`Error in main loop: ${e}`);
|
|
542
536
|
} finally {
|
|
543
|
-
if (this._pollId)
|
|
544
|
-
clearTimeoutEx2(this._pollId);
|
|
537
|
+
if (this._pollId) clearTimeoutEx2(this._pollId);
|
|
545
538
|
this._pollId = void 0;
|
|
546
539
|
this.poll();
|
|
547
540
|
}
|
|
@@ -554,7 +547,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
554
547
|
/**
|
|
555
548
|
* Background process for checking for inbound queries
|
|
556
549
|
*/
|
|
557
|
-
processIncomingQueries = async () => {
|
|
550
|
+
processIncomingQueries = /* @__PURE__ */ __name(async () => {
|
|
558
551
|
this.logger?.debug("Checking for inbound queries");
|
|
559
552
|
const localModules = await this.listeningModules();
|
|
560
553
|
await Promise.allSettled(localModules.map(async (localModule) => {
|
|
@@ -562,8 +555,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
562
555
|
const localModuleName = localModule.id;
|
|
563
556
|
this.logger?.debug(`Checking for inbound queries to ${localModuleName} [${localModule.address}]`);
|
|
564
557
|
const queries = await this.findQueriesToAddress(localModule.address) ?? [];
|
|
565
|
-
if (queries.length === 0)
|
|
566
|
-
return;
|
|
558
|
+
if (queries.length === 0) return;
|
|
567
559
|
this.logger?.debug(`Found queries addressed to local module: ${localModuleName}`);
|
|
568
560
|
for (const query of queries) {
|
|
569
561
|
await this.callLocalModule(localModule, query);
|
|
@@ -572,7 +564,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
572
564
|
this.logger?.error(`Error processing queries for address ${localModule.address}: ${error}`);
|
|
573
565
|
}
|
|
574
566
|
}));
|
|
575
|
-
};
|
|
567
|
+
}, "processIncomingQueries");
|
|
576
568
|
};
|
|
577
569
|
|
|
578
570
|
// src/AsyncQueryBus/ModuleHost/ModuleHost.ts
|
|
@@ -663,6 +655,7 @@ var AsyncQueryBusModuleProxy = class _AsyncQueryBusModuleProxy extends AbstractM
|
|
|
663
655
|
const first = assertEx4(parts.shift(), () => "Missing first");
|
|
664
656
|
const remainingPath = parts.join(":");
|
|
665
657
|
const address = isAddress(first) ? first : this.childAddressByName(first);
|
|
658
|
+
if (!address) return void 0;
|
|
666
659
|
const firstInstance = await this.params.host.resolve(address);
|
|
667
660
|
return remainingPath ? await firstInstance?.resolve(remainingPath) : firstInstance;
|
|
668
661
|
}
|
|
@@ -769,12 +762,8 @@ var PubSubBridgeModuleResolver = class extends AbstractBridgeModuleResolver {
|
|
|
769
762
|
// src/PubSubBridge.ts
|
|
770
763
|
function _ts_decorate(decorators, target, key, desc) {
|
|
771
764
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
772
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
773
|
-
|
|
774
|
-
else
|
|
775
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
776
|
-
if (d = decorators[i])
|
|
777
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
765
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
766
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
778
767
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
779
768
|
}
|
|
780
769
|
__name(_ts_decorate, "_ts_decorate");
|
|
@@ -806,18 +795,18 @@ var PubSubBridge = class extends AbstractBridge {
|
|
|
806
795
|
},
|
|
807
796
|
bridge: this,
|
|
808
797
|
busClient: assertEx6(this.busClient(), () => "busClient not configured"),
|
|
809
|
-
onQuerySendFinished: (args) => {
|
|
798
|
+
onQuerySendFinished: /* @__PURE__ */ __name((args) => {
|
|
810
799
|
forget3(this.emit("querySendFinished", {
|
|
811
800
|
module: this,
|
|
812
801
|
...args
|
|
813
802
|
}));
|
|
814
|
-
},
|
|
815
|
-
onQuerySendStarted: (args) => {
|
|
803
|
+
}, "onQuerySendFinished"),
|
|
804
|
+
onQuerySendStarted: /* @__PURE__ */ __name((args) => {
|
|
816
805
|
forget3(this.emit("querySendStarted", {
|
|
817
806
|
module: this,
|
|
818
807
|
...args
|
|
819
808
|
}));
|
|
820
|
-
},
|
|
809
|
+
}, "onQuerySendStarted"),
|
|
821
810
|
root: this,
|
|
822
811
|
wrapperAccount: this.account
|
|
823
812
|
});
|
|
@@ -858,8 +847,7 @@ var PubSubBridge = class extends AbstractBridge {
|
|
|
858
847
|
mod,
|
|
859
848
|
...exposedChildren
|
|
860
849
|
];
|
|
861
|
-
for (const exposedMod of allExposed)
|
|
862
|
-
this.logger?.log(`exposed: ${exposedMod.address} [${mod.id}]`);
|
|
850
|
+
for (const exposedMod of allExposed) this.logger?.log(`exposed: ${exposedMod.address} [${mod.id}]`);
|
|
863
851
|
return allExposed;
|
|
864
852
|
}
|
|
865
853
|
async exposeHandler(address, options) {
|
|
@@ -937,8 +925,7 @@ var PubSubBridge = class extends AbstractBridge {
|
|
|
937
925
|
const results = [];
|
|
938
926
|
if (isAddressModuleFilter(idOrFilter)) {
|
|
939
927
|
for (const mod of workingSet) {
|
|
940
|
-
if (mod.modName && idOrFilter.address.includes(mod.address))
|
|
941
|
-
results.push(mod);
|
|
928
|
+
if (mod.modName && idOrFilter.address.includes(mod.address)) results.push(mod);
|
|
942
929
|
}
|
|
943
930
|
}
|
|
944
931
|
return results;
|
|
@@ -984,7 +971,7 @@ var PubSubBridge = class extends AbstractBridge {
|
|
|
984
971
|
this._busHost = new AsyncQueryBusHost({
|
|
985
972
|
config: this.config.host,
|
|
986
973
|
logger: this.logger,
|
|
987
|
-
onQueryFulfillFinished: (args) => {
|
|
974
|
+
onQueryFulfillFinished: /* @__PURE__ */ __name((args) => {
|
|
988
975
|
if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
|
|
989
976
|
forget3(this.storeToArchivists(args.result?.flat() ?? []));
|
|
990
977
|
}
|
|
@@ -992,8 +979,8 @@ var PubSubBridge = class extends AbstractBridge {
|
|
|
992
979
|
module: this,
|
|
993
980
|
...args
|
|
994
981
|
}));
|
|
995
|
-
},
|
|
996
|
-
onQueryFulfillStarted: (args) => {
|
|
982
|
+
}, "onQueryFulfillFinished"),
|
|
983
|
+
onQueryFulfillStarted: /* @__PURE__ */ __name((args) => {
|
|
997
984
|
if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
|
|
998
985
|
forget3(this.storeToArchivists([
|
|
999
986
|
args.query,
|
|
@@ -1004,7 +991,7 @@ var PubSubBridge = class extends AbstractBridge {
|
|
|
1004
991
|
module: this,
|
|
1005
992
|
...args
|
|
1006
993
|
}));
|
|
1007
|
-
},
|
|
994
|
+
}, "onQueryFulfillStarted"),
|
|
1008
995
|
rootModule: this
|
|
1009
996
|
});
|
|
1010
997
|
}
|