@xyo-network/bridge-pub-sub 2.104.0 → 2.104.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 +21 -21
- package/src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts +1 -0
package/dist/node/index.cjs
CHANGED
|
@@ -20,10 +20,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
return to;
|
|
21
21
|
};
|
|
22
22
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var __publicField = (obj, key, value) =>
|
|
24
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
25
|
-
return value;
|
|
26
|
-
};
|
|
23
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
27
24
|
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
28
25
|
|
|
29
26
|
// src/index.ts
|
|
@@ -148,8 +145,7 @@ var _AsyncQueryBusBase = class _AsyncQueryBusBase extends import_object2.Base {
|
|
|
148
145
|
async commitState(address, nextState) {
|
|
149
146
|
await Promise.resolve();
|
|
150
147
|
const lastState = this.lastState.get(address);
|
|
151
|
-
if (lastState && lastState >= nextState)
|
|
152
|
-
return;
|
|
148
|
+
if (lastState && lastState >= nextState) return;
|
|
153
149
|
this.lastState.set(address, nextState);
|
|
154
150
|
}
|
|
155
151
|
/**
|
|
@@ -265,8 +261,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
265
261
|
const insertResult = await ((_c = queryArchivist.insert) == null ? void 0 : _c.call(queryArchivist, data));
|
|
266
262
|
(_d = this.logger) == null ? void 0 : _d.debug(`Issued query: ${routedQueryHash} to: ${address}`);
|
|
267
263
|
this.queryCache.set(routedQueryHash, Pending);
|
|
268
|
-
if (!insertResult)
|
|
269
|
-
throw new Error("Unable to issue query to queryArchivist");
|
|
264
|
+
if (!insertResult) throw new Error("Unable to issue query to queryArchivist");
|
|
270
265
|
const context = new Promise((resolve, reject) => {
|
|
271
266
|
var _a2;
|
|
272
267
|
(_a2 = this.logger) == null ? void 0 : _a2.debug(`Polling for response to query: ${routedQueryHash}`);
|
|
@@ -285,8 +280,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
285
280
|
return;
|
|
286
281
|
}
|
|
287
282
|
nextDelay = Math.floor(nextDelay * 1.2);
|
|
288
|
-
if (nextDelay > 1e3)
|
|
289
|
-
nextDelay = 1e3;
|
|
283
|
+
if (nextDelay > 1e3) nextDelay = 1e3;
|
|
290
284
|
}
|
|
291
285
|
(_b2 = this.logger) == null ? void 0 : _b2.error("Timeout waiting for query response");
|
|
292
286
|
const error = {
|
|
@@ -319,8 +313,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
319
313
|
} catch (e) {
|
|
320
314
|
(_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `Error in main loop: ${e}`);
|
|
321
315
|
} finally {
|
|
322
|
-
if (this._pollId)
|
|
323
|
-
(0, import_timer.clearTimeoutEx)(this._pollId);
|
|
316
|
+
if (this._pollId) (0, import_timer.clearTimeoutEx)(this._pollId);
|
|
324
317
|
this._pollId = void 0;
|
|
325
318
|
this.poll();
|
|
326
319
|
}
|
|
@@ -329,7 +322,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
329
322
|
/**
|
|
330
323
|
* Background process for processing incoming responses to previously issued queries
|
|
331
324
|
*/
|
|
332
|
-
processIncomingResponses = async () => {
|
|
325
|
+
processIncomingResponses = /* @__PURE__ */ __name(async () => {
|
|
333
326
|
const responseArchivist = await this.responsesArchivist();
|
|
334
327
|
if (responseArchivist) {
|
|
335
328
|
const responseBoundWitnessDiviner = await this.responsesDiviner();
|
|
@@ -365,7 +358,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
365
358
|
}));
|
|
366
359
|
}
|
|
367
360
|
}
|
|
368
|
-
};
|
|
361
|
+
}, "processIncomingResponses");
|
|
369
362
|
start() {
|
|
370
363
|
if (this._pollCount === 0) {
|
|
371
364
|
this.poll();
|
|
@@ -375,8 +368,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
375
368
|
stop() {
|
|
376
369
|
this._pollCount--;
|
|
377
370
|
if (this._pollCount <= 0) {
|
|
378
|
-
if (this._pollId)
|
|
379
|
-
(0, import_timer.clearTimeoutEx)(this._pollId);
|
|
371
|
+
if (this._pollId) (0, import_timer.clearTimeoutEx)(this._pollId);
|
|
380
372
|
this._pollId = void 0;
|
|
381
373
|
this._pollCount = 0;
|
|
382
374
|
}
|
|
@@ -475,8 +467,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
475
467
|
if (!this.started) {
|
|
476
468
|
console.warn("AsyncQueryBus stopping when already stopped");
|
|
477
469
|
}
|
|
478
|
-
if (this._pollId)
|
|
479
|
-
(0, import_timer2.clearTimeoutEx)(this._pollId);
|
|
470
|
+
if (this._pollId) (0, import_timer2.clearTimeoutEx)(this._pollId);
|
|
480
471
|
this._pollId = void 0;
|
|
481
472
|
}
|
|
482
473
|
async unexpose(id, validate = true) {
|
|
@@ -493,7 +484,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
493
484
|
return module2;
|
|
494
485
|
}
|
|
495
486
|
// eslint-disable-next-line max-statements
|
|
496
|
-
callLocalModule = async (localModule, query) => {
|
|
487
|
+
callLocalModule = /* @__PURE__ */ __name(async (localModule, query) => {
|
|
497
488
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
498
489
|
this._idle = false;
|
|
499
490
|
this._lastQueryTime = Date.now();
|
|
@@ -560,12 +551,12 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
560
551
|
}
|
|
561
552
|
}
|
|
562
553
|
}
|
|
563
|
-
};
|
|
554
|
+
}, "callLocalModule");
|
|
564
555
|
/**
|
|
565
556
|
* Finds unprocessed commands addressed to the supplied address
|
|
566
557
|
* @param address The address to find commands for
|
|
567
558
|
*/
|
|
568
|
-
findQueriesToAddress = async (address) => {
|
|
559
|
+
findQueriesToAddress = /* @__PURE__ */ __name(async (address) => {
|
|
569
560
|
var _a, _b, _c, _d, _e;
|
|
570
561
|
const queriesDivinerId = (0, import_assert3.assertEx)((_c = (_b = (_a = this.config) == null ? void 0 : _a.intersect) == null ? void 0 : _b.queries) == null ? void 0 : _c.boundWitnessDiviner, () => "No queries Diviner defined");
|
|
571
562
|
const queriesBoundWitnessDiviner = await this.queriesDiviner();
|
|
@@ -593,7 +584,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
593
584
|
} else {
|
|
594
585
|
(_e = this.logger) == null ? void 0 : _e.warn(`Unable to resolve queriesBoundWitnessDiviner [${queriesDivinerId}] [${await import_module_model2.ResolveHelper.traceModuleIdentifier(this.rootModule, queriesDivinerId)}]`);
|
|
595
586
|
}
|
|
596
|
-
};
|
|
587
|
+
}, "findQueriesToAddress");
|
|
597
588
|
/**
|
|
598
589
|
* Runs the background divine process on a loop with a delay
|
|
599
590
|
* specified by the `config.pollFrequency`
|
|
@@ -606,8 +597,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
606
597
|
} catch (e) {
|
|
607
598
|
(_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `Error in main loop: ${e}`);
|
|
608
599
|
} finally {
|
|
609
|
-
if (this._pollId)
|
|
610
|
-
(0, import_timer2.clearTimeoutEx)(this._pollId);
|
|
600
|
+
if (this._pollId) (0, import_timer2.clearTimeoutEx)(this._pollId);
|
|
611
601
|
this._pollId = void 0;
|
|
612
602
|
this.poll();
|
|
613
603
|
}
|
|
@@ -620,7 +610,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
620
610
|
/**
|
|
621
611
|
* Background process for checking for inbound queries
|
|
622
612
|
*/
|
|
623
|
-
processIncomingQueries = async () => {
|
|
613
|
+
processIncomingQueries = /* @__PURE__ */ __name(async () => {
|
|
624
614
|
var _a;
|
|
625
615
|
(_a = this.logger) == null ? void 0 : _a.debug("Checking for inbound queries");
|
|
626
616
|
const localModules = await this.listeningModules();
|
|
@@ -630,8 +620,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
630
620
|
const localModuleName = localModule.id;
|
|
631
621
|
(_a2 = this.logger) == null ? void 0 : _a2.debug(`Checking for inbound queries to ${localModuleName} [${localModule.address}]`);
|
|
632
622
|
const queries = await this.findQueriesToAddress(localModule.address) ?? [];
|
|
633
|
-
if (queries.length === 0)
|
|
634
|
-
return;
|
|
623
|
+
if (queries.length === 0) return;
|
|
635
624
|
(_b = this.logger) == null ? void 0 : _b.debug(`Found queries addressed to local module: ${localModuleName}`);
|
|
636
625
|
for (const query of queries) {
|
|
637
626
|
await this.callLocalModule(localModule, query);
|
|
@@ -640,7 +629,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
640
629
|
(_c = this.logger) == null ? void 0 : _c.error(`Error processing queries for address ${localModule.address}: ${error}`);
|
|
641
630
|
}
|
|
642
631
|
}));
|
|
643
|
-
};
|
|
632
|
+
}, "processIncomingQueries");
|
|
644
633
|
};
|
|
645
634
|
__name(_AsyncQueryBusHost, "AsyncQueryBusHost");
|
|
646
635
|
var AsyncQueryBusHost = _AsyncQueryBusHost;
|
|
@@ -730,6 +719,7 @@ var _AsyncQueryBusModuleProxy = class _AsyncQueryBusModuleProxy extends import_b
|
|
|
730
719
|
const first = (0, import_assert4.assertEx)(parts.shift(), () => "Missing first");
|
|
731
720
|
const remainingPath = parts.join(":");
|
|
732
721
|
const address = (0, import_hex.isAddress)(first) ? first : this.childAddressByName(first);
|
|
722
|
+
if (!address) return void 0;
|
|
733
723
|
const firstInstance = await this.params.host.resolve(address);
|
|
734
724
|
return remainingPath ? await (firstInstance == null ? void 0 : firstInstance.resolve(remainingPath)) : firstInstance;
|
|
735
725
|
}
|
|
@@ -839,12 +829,8 @@ var PubSubBridgeModuleResolver = _PubSubBridgeModuleResolver;
|
|
|
839
829
|
// src/PubSubBridge.ts
|
|
840
830
|
function _ts_decorate(decorators, target, key, desc) {
|
|
841
831
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
842
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
843
|
-
|
|
844
|
-
else
|
|
845
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
846
|
-
if (d = decorators[i])
|
|
847
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
832
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
833
|
+
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;
|
|
848
834
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
849
835
|
}
|
|
850
836
|
__name(_ts_decorate, "_ts_decorate");
|
|
@@ -868,18 +854,18 @@ var _PubSubBridge = class _PubSubBridge extends import_bridge_abstract3.Abstract
|
|
|
868
854
|
},
|
|
869
855
|
bridge: this,
|
|
870
856
|
busClient: (0, import_assert6.assertEx)(this.busClient(), () => "busClient not configured"),
|
|
871
|
-
onQuerySendFinished: (args) => {
|
|
857
|
+
onQuerySendFinished: /* @__PURE__ */ __name((args) => {
|
|
872
858
|
(0, import_forget3.forget)(this.emit("querySendFinished", {
|
|
873
859
|
module: this,
|
|
874
860
|
...args
|
|
875
861
|
}));
|
|
876
|
-
},
|
|
877
|
-
onQuerySendStarted: (args) => {
|
|
862
|
+
}, "onQuerySendFinished"),
|
|
863
|
+
onQuerySendStarted: /* @__PURE__ */ __name((args) => {
|
|
878
864
|
(0, import_forget3.forget)(this.emit("querySendStarted", {
|
|
879
865
|
module: this,
|
|
880
866
|
...args
|
|
881
867
|
}));
|
|
882
|
-
},
|
|
868
|
+
}, "onQuerySendStarted"),
|
|
883
869
|
root: this,
|
|
884
870
|
wrapperAccount: this.account
|
|
885
871
|
});
|
|
@@ -921,8 +907,7 @@ var _PubSubBridge = class _PubSubBridge extends import_bridge_abstract3.Abstract
|
|
|
921
907
|
mod,
|
|
922
908
|
...exposedChildren
|
|
923
909
|
];
|
|
924
|
-
for (const exposedMod of allExposed)
|
|
925
|
-
(_b = this.logger) == null ? void 0 : _b.log(`exposed: ${exposedMod.address} [${mod.id}]`);
|
|
910
|
+
for (const exposedMod of allExposed) (_b = this.logger) == null ? void 0 : _b.log(`exposed: ${exposedMod.address} [${mod.id}]`);
|
|
926
911
|
return allExposed;
|
|
927
912
|
}
|
|
928
913
|
async exposeHandler(address, options) {
|
|
@@ -1004,8 +989,7 @@ var _PubSubBridge = class _PubSubBridge extends import_bridge_abstract3.Abstract
|
|
|
1004
989
|
const results = [];
|
|
1005
990
|
if ((0, import_module_model5.isAddressModuleFilter)(idOrFilter)) {
|
|
1006
991
|
for (const mod of workingSet) {
|
|
1007
|
-
if (mod.modName && idOrFilter.address.includes(mod.address))
|
|
1008
|
-
results.push(mod);
|
|
992
|
+
if (mod.modName && idOrFilter.address.includes(mod.address)) results.push(mod);
|
|
1009
993
|
}
|
|
1010
994
|
}
|
|
1011
995
|
return results;
|
|
@@ -1053,7 +1037,7 @@ var _PubSubBridge = class _PubSubBridge extends import_bridge_abstract3.Abstract
|
|
|
1053
1037
|
this._busHost = new AsyncQueryBusHost({
|
|
1054
1038
|
config: this.config.host,
|
|
1055
1039
|
logger: this.logger,
|
|
1056
|
-
onQueryFulfillFinished: (args) => {
|
|
1040
|
+
onQueryFulfillFinished: /* @__PURE__ */ __name((args) => {
|
|
1057
1041
|
var _a;
|
|
1058
1042
|
if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
|
|
1059
1043
|
(0, import_forget3.forget)(this.storeToArchivists(((_a = args.result) == null ? void 0 : _a.flat()) ?? []));
|
|
@@ -1062,8 +1046,8 @@ var _PubSubBridge = class _PubSubBridge extends import_bridge_abstract3.Abstract
|
|
|
1062
1046
|
module: this,
|
|
1063
1047
|
...args
|
|
1064
1048
|
}));
|
|
1065
|
-
},
|
|
1066
|
-
onQueryFulfillStarted: (args) => {
|
|
1049
|
+
}, "onQueryFulfillFinished"),
|
|
1050
|
+
onQueryFulfillStarted: /* @__PURE__ */ __name((args) => {
|
|
1067
1051
|
if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
|
|
1068
1052
|
(0, import_forget3.forget)(this.storeToArchivists([
|
|
1069
1053
|
args.query,
|
|
@@ -1074,7 +1058,7 @@ var _PubSubBridge = class _PubSubBridge extends import_bridge_abstract3.Abstract
|
|
|
1074
1058
|
module: this,
|
|
1075
1059
|
...args
|
|
1076
1060
|
}));
|
|
1077
|
-
},
|
|
1061
|
+
}, "onQueryFulfillStarted"),
|
|
1078
1062
|
rootModule: this
|
|
1079
1063
|
});
|
|
1080
1064
|
}
|