@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.js
CHANGED
|
@@ -3,10 +3,7 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
3
3
|
var __reflectGet = Reflect.get;
|
|
4
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
-
var __publicField = (obj, key, value) =>
|
|
7
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
-
return value;
|
|
9
|
-
};
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
7
|
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
11
8
|
|
|
12
9
|
// src/AbstractModuleHost/AbstractModuleHost.ts
|
|
@@ -115,8 +112,7 @@ var _AsyncQueryBusBase = class _AsyncQueryBusBase extends Base2 {
|
|
|
115
112
|
async commitState(address, nextState) {
|
|
116
113
|
await Promise.resolve();
|
|
117
114
|
const lastState = this.lastState.get(address);
|
|
118
|
-
if (lastState && lastState >= nextState)
|
|
119
|
-
return;
|
|
115
|
+
if (lastState && lastState >= nextState) return;
|
|
120
116
|
this.lastState.set(address, nextState);
|
|
121
117
|
}
|
|
122
118
|
/**
|
|
@@ -232,8 +228,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
232
228
|
const insertResult = await ((_c = queryArchivist.insert) == null ? void 0 : _c.call(queryArchivist, data));
|
|
233
229
|
(_d = this.logger) == null ? void 0 : _d.debug(`Issued query: ${routedQueryHash} to: ${address}`);
|
|
234
230
|
this.queryCache.set(routedQueryHash, Pending);
|
|
235
|
-
if (!insertResult)
|
|
236
|
-
throw new Error("Unable to issue query to queryArchivist");
|
|
231
|
+
if (!insertResult) throw new Error("Unable to issue query to queryArchivist");
|
|
237
232
|
const context = new Promise((resolve, reject) => {
|
|
238
233
|
var _a2;
|
|
239
234
|
(_a2 = this.logger) == null ? void 0 : _a2.debug(`Polling for response to query: ${routedQueryHash}`);
|
|
@@ -252,8 +247,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
252
247
|
return;
|
|
253
248
|
}
|
|
254
249
|
nextDelay = Math.floor(nextDelay * 1.2);
|
|
255
|
-
if (nextDelay > 1e3)
|
|
256
|
-
nextDelay = 1e3;
|
|
250
|
+
if (nextDelay > 1e3) nextDelay = 1e3;
|
|
257
251
|
}
|
|
258
252
|
(_b2 = this.logger) == null ? void 0 : _b2.error("Timeout waiting for query response");
|
|
259
253
|
const error = {
|
|
@@ -286,8 +280,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
286
280
|
} catch (e) {
|
|
287
281
|
(_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `Error in main loop: ${e}`);
|
|
288
282
|
} finally {
|
|
289
|
-
if (this._pollId)
|
|
290
|
-
clearTimeoutEx(this._pollId);
|
|
283
|
+
if (this._pollId) clearTimeoutEx(this._pollId);
|
|
291
284
|
this._pollId = void 0;
|
|
292
285
|
this.poll();
|
|
293
286
|
}
|
|
@@ -296,7 +289,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
296
289
|
/**
|
|
297
290
|
* Background process for processing incoming responses to previously issued queries
|
|
298
291
|
*/
|
|
299
|
-
processIncomingResponses = async () => {
|
|
292
|
+
processIncomingResponses = /* @__PURE__ */ __name(async () => {
|
|
300
293
|
const responseArchivist = await this.responsesArchivist();
|
|
301
294
|
if (responseArchivist) {
|
|
302
295
|
const responseBoundWitnessDiviner = await this.responsesDiviner();
|
|
@@ -332,7 +325,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
332
325
|
}));
|
|
333
326
|
}
|
|
334
327
|
}
|
|
335
|
-
};
|
|
328
|
+
}, "processIncomingResponses");
|
|
336
329
|
start() {
|
|
337
330
|
if (this._pollCount === 0) {
|
|
338
331
|
this.poll();
|
|
@@ -342,8 +335,7 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
|
|
|
342
335
|
stop() {
|
|
343
336
|
this._pollCount--;
|
|
344
337
|
if (this._pollCount <= 0) {
|
|
345
|
-
if (this._pollId)
|
|
346
|
-
clearTimeoutEx(this._pollId);
|
|
338
|
+
if (this._pollId) clearTimeoutEx(this._pollId);
|
|
347
339
|
this._pollId = void 0;
|
|
348
340
|
this._pollCount = 0;
|
|
349
341
|
}
|
|
@@ -442,8 +434,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
442
434
|
if (!this.started) {
|
|
443
435
|
console.warn("AsyncQueryBus stopping when already stopped");
|
|
444
436
|
}
|
|
445
|
-
if (this._pollId)
|
|
446
|
-
clearTimeoutEx2(this._pollId);
|
|
437
|
+
if (this._pollId) clearTimeoutEx2(this._pollId);
|
|
447
438
|
this._pollId = void 0;
|
|
448
439
|
}
|
|
449
440
|
async unexpose(id, validate = true) {
|
|
@@ -460,7 +451,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
460
451
|
return module;
|
|
461
452
|
}
|
|
462
453
|
// eslint-disable-next-line max-statements
|
|
463
|
-
callLocalModule = async (localModule, query) => {
|
|
454
|
+
callLocalModule = /* @__PURE__ */ __name(async (localModule, query) => {
|
|
464
455
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
465
456
|
this._idle = false;
|
|
466
457
|
this._lastQueryTime = Date.now();
|
|
@@ -527,12 +518,12 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
527
518
|
}
|
|
528
519
|
}
|
|
529
520
|
}
|
|
530
|
-
};
|
|
521
|
+
}, "callLocalModule");
|
|
531
522
|
/**
|
|
532
523
|
* Finds unprocessed commands addressed to the supplied address
|
|
533
524
|
* @param address The address to find commands for
|
|
534
525
|
*/
|
|
535
|
-
findQueriesToAddress = async (address) => {
|
|
526
|
+
findQueriesToAddress = /* @__PURE__ */ __name(async (address) => {
|
|
536
527
|
var _a, _b, _c, _d, _e;
|
|
537
528
|
const queriesDivinerId = assertEx3((_c = (_b = (_a = this.config) == null ? void 0 : _a.intersect) == null ? void 0 : _b.queries) == null ? void 0 : _c.boundWitnessDiviner, () => "No queries Diviner defined");
|
|
538
529
|
const queriesBoundWitnessDiviner = await this.queriesDiviner();
|
|
@@ -560,7 +551,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
560
551
|
} else {
|
|
561
552
|
(_e = this.logger) == null ? void 0 : _e.warn(`Unable to resolve queriesBoundWitnessDiviner [${queriesDivinerId}] [${await ResolveHelper2.traceModuleIdentifier(this.rootModule, queriesDivinerId)}]`);
|
|
562
553
|
}
|
|
563
|
-
};
|
|
554
|
+
}, "findQueriesToAddress");
|
|
564
555
|
/**
|
|
565
556
|
* Runs the background divine process on a loop with a delay
|
|
566
557
|
* specified by the `config.pollFrequency`
|
|
@@ -573,8 +564,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
573
564
|
} catch (e) {
|
|
574
565
|
(_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `Error in main loop: ${e}`);
|
|
575
566
|
} finally {
|
|
576
|
-
if (this._pollId)
|
|
577
|
-
clearTimeoutEx2(this._pollId);
|
|
567
|
+
if (this._pollId) clearTimeoutEx2(this._pollId);
|
|
578
568
|
this._pollId = void 0;
|
|
579
569
|
this.poll();
|
|
580
570
|
}
|
|
@@ -587,7 +577,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
587
577
|
/**
|
|
588
578
|
* Background process for checking for inbound queries
|
|
589
579
|
*/
|
|
590
|
-
processIncomingQueries = async () => {
|
|
580
|
+
processIncomingQueries = /* @__PURE__ */ __name(async () => {
|
|
591
581
|
var _a;
|
|
592
582
|
(_a = this.logger) == null ? void 0 : _a.debug("Checking for inbound queries");
|
|
593
583
|
const localModules = await this.listeningModules();
|
|
@@ -597,8 +587,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
597
587
|
const localModuleName = localModule.id;
|
|
598
588
|
(_a2 = this.logger) == null ? void 0 : _a2.debug(`Checking for inbound queries to ${localModuleName} [${localModule.address}]`);
|
|
599
589
|
const queries = await this.findQueriesToAddress(localModule.address) ?? [];
|
|
600
|
-
if (queries.length === 0)
|
|
601
|
-
return;
|
|
590
|
+
if (queries.length === 0) return;
|
|
602
591
|
(_b = this.logger) == null ? void 0 : _b.debug(`Found queries addressed to local module: ${localModuleName}`);
|
|
603
592
|
for (const query of queries) {
|
|
604
593
|
await this.callLocalModule(localModule, query);
|
|
@@ -607,7 +596,7 @@ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
|
|
|
607
596
|
(_c = this.logger) == null ? void 0 : _c.error(`Error processing queries for address ${localModule.address}: ${error}`);
|
|
608
597
|
}
|
|
609
598
|
}));
|
|
610
|
-
};
|
|
599
|
+
}, "processIncomingQueries");
|
|
611
600
|
};
|
|
612
601
|
__name(_AsyncQueryBusHost, "AsyncQueryBusHost");
|
|
613
602
|
var AsyncQueryBusHost = _AsyncQueryBusHost;
|
|
@@ -697,6 +686,7 @@ var _AsyncQueryBusModuleProxy = class _AsyncQueryBusModuleProxy extends Abstract
|
|
|
697
686
|
const first = assertEx4(parts.shift(), () => "Missing first");
|
|
698
687
|
const remainingPath = parts.join(":");
|
|
699
688
|
const address = isAddress(first) ? first : this.childAddressByName(first);
|
|
689
|
+
if (!address) return void 0;
|
|
700
690
|
const firstInstance = await this.params.host.resolve(address);
|
|
701
691
|
return remainingPath ? await (firstInstance == null ? void 0 : firstInstance.resolve(remainingPath)) : firstInstance;
|
|
702
692
|
}
|
|
@@ -806,12 +796,8 @@ var PubSubBridgeModuleResolver = _PubSubBridgeModuleResolver;
|
|
|
806
796
|
// src/PubSubBridge.ts
|
|
807
797
|
function _ts_decorate(decorators, target, key, desc) {
|
|
808
798
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
809
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
810
|
-
|
|
811
|
-
else
|
|
812
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
813
|
-
if (d = decorators[i])
|
|
814
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
799
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
800
|
+
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;
|
|
815
801
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
816
802
|
}
|
|
817
803
|
__name(_ts_decorate, "_ts_decorate");
|
|
@@ -835,18 +821,18 @@ var _PubSubBridge = class _PubSubBridge extends AbstractBridge {
|
|
|
835
821
|
},
|
|
836
822
|
bridge: this,
|
|
837
823
|
busClient: assertEx6(this.busClient(), () => "busClient not configured"),
|
|
838
|
-
onQuerySendFinished: (args) => {
|
|
824
|
+
onQuerySendFinished: /* @__PURE__ */ __name((args) => {
|
|
839
825
|
forget3(this.emit("querySendFinished", {
|
|
840
826
|
module: this,
|
|
841
827
|
...args
|
|
842
828
|
}));
|
|
843
|
-
},
|
|
844
|
-
onQuerySendStarted: (args) => {
|
|
829
|
+
}, "onQuerySendFinished"),
|
|
830
|
+
onQuerySendStarted: /* @__PURE__ */ __name((args) => {
|
|
845
831
|
forget3(this.emit("querySendStarted", {
|
|
846
832
|
module: this,
|
|
847
833
|
...args
|
|
848
834
|
}));
|
|
849
|
-
},
|
|
835
|
+
}, "onQuerySendStarted"),
|
|
850
836
|
root: this,
|
|
851
837
|
wrapperAccount: this.account
|
|
852
838
|
});
|
|
@@ -888,8 +874,7 @@ var _PubSubBridge = class _PubSubBridge extends AbstractBridge {
|
|
|
888
874
|
mod,
|
|
889
875
|
...exposedChildren
|
|
890
876
|
];
|
|
891
|
-
for (const exposedMod of allExposed)
|
|
892
|
-
(_b = this.logger) == null ? void 0 : _b.log(`exposed: ${exposedMod.address} [${mod.id}]`);
|
|
877
|
+
for (const exposedMod of allExposed) (_b = this.logger) == null ? void 0 : _b.log(`exposed: ${exposedMod.address} [${mod.id}]`);
|
|
893
878
|
return allExposed;
|
|
894
879
|
}
|
|
895
880
|
async exposeHandler(address, options) {
|
|
@@ -971,8 +956,7 @@ var _PubSubBridge = class _PubSubBridge extends AbstractBridge {
|
|
|
971
956
|
const results = [];
|
|
972
957
|
if (isAddressModuleFilter(idOrFilter)) {
|
|
973
958
|
for (const mod of workingSet) {
|
|
974
|
-
if (mod.modName && idOrFilter.address.includes(mod.address))
|
|
975
|
-
results.push(mod);
|
|
959
|
+
if (mod.modName && idOrFilter.address.includes(mod.address)) results.push(mod);
|
|
976
960
|
}
|
|
977
961
|
}
|
|
978
962
|
return results;
|
|
@@ -1020,7 +1004,7 @@ var _PubSubBridge = class _PubSubBridge extends AbstractBridge {
|
|
|
1020
1004
|
this._busHost = new AsyncQueryBusHost({
|
|
1021
1005
|
config: this.config.host,
|
|
1022
1006
|
logger: this.logger,
|
|
1023
|
-
onQueryFulfillFinished: (args) => {
|
|
1007
|
+
onQueryFulfillFinished: /* @__PURE__ */ __name((args) => {
|
|
1024
1008
|
var _a;
|
|
1025
1009
|
if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
|
|
1026
1010
|
forget3(this.storeToArchivists(((_a = args.result) == null ? void 0 : _a.flat()) ?? []));
|
|
@@ -1029,8 +1013,8 @@ var _PubSubBridge = class _PubSubBridge extends AbstractBridge {
|
|
|
1029
1013
|
module: this,
|
|
1030
1014
|
...args
|
|
1031
1015
|
}));
|
|
1032
|
-
},
|
|
1033
|
-
onQueryFulfillStarted: (args) => {
|
|
1016
|
+
}, "onQueryFulfillFinished"),
|
|
1017
|
+
onQueryFulfillStarted: /* @__PURE__ */ __name((args) => {
|
|
1034
1018
|
if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
|
|
1035
1019
|
forget3(this.storeToArchivists([
|
|
1036
1020
|
args.query,
|
|
@@ -1041,7 +1025,7 @@ var _PubSubBridge = class _PubSubBridge extends AbstractBridge {
|
|
|
1041
1025
|
module: this,
|
|
1042
1026
|
...args
|
|
1043
1027
|
}));
|
|
1044
|
-
},
|
|
1028
|
+
}, "onQueryFulfillStarted"),
|
|
1045
1029
|
rootModule: this
|
|
1046
1030
|
});
|
|
1047
1031
|
}
|