@xyo-network/bridge-pub-sub 2.90.23 → 2.91.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/AbstractModuleHost/AbstractModuleHost.d.cts +11 -0
- package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.cts.map +1 -0
- package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.mts +11 -0
- package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.mts.map +1 -0
- package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.ts +11 -0
- package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.ts.map +1 -0
- package/dist/browser/AbstractModuleHost/index.d.cts +2 -0
- package/dist/browser/AbstractModuleHost/index.d.cts.map +1 -0
- package/dist/browser/AbstractModuleHost/index.d.mts +2 -0
- package/dist/browser/AbstractModuleHost/index.d.mts.map +1 -0
- package/dist/browser/AbstractModuleHost/index.d.ts +2 -0
- package/dist/browser/AbstractModuleHost/index.d.ts.map +1 -0
- package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.cts +90 -0
- package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.cts.map +1 -0
- package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.mts +90 -0
- package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.mts.map +1 -0
- package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.ts +90 -0
- package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.ts.map +1 -0
- package/dist/browser/AbstractModuleProxy/index.d.cts +2 -0
- package/dist/browser/AbstractModuleProxy/index.d.cts.map +1 -0
- package/dist/browser/AbstractModuleProxy/index.d.mts +2 -0
- package/dist/browser/AbstractModuleProxy/index.d.mts.map +1 -0
- package/dist/browser/AbstractModuleProxy/index.d.ts +2 -0
- package/dist/browser/AbstractModuleProxy/index.d.ts.map +1 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts +75 -38
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +75 -38
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +75 -38
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts +16 -46
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts +16 -46
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts +16 -46
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts +37 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts +37 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts +37 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -0
- package/dist/browser/AsyncQueryBus/Config.d.cts +21 -31
- package/dist/browser/AsyncQueryBus/Config.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/Config.d.mts +21 -31
- package/dist/browser/AsyncQueryBus/Config.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/Config.d.ts +21 -31
- package/dist/browser/AsyncQueryBus/Config.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.cts +12 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.cts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.mts +12 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.mts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.ts +12 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.ts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/index.d.cts +2 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/index.d.cts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/index.d.mts +2 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/index.d.mts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/index.d.ts +2 -0
- package/dist/browser/AsyncQueryBus/ModuleHost/index.d.ts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts +12 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts +12 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts +12 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.cts +2 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.cts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.mts +2 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.mts.map +1 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.ts +2 -0
- package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.ts.map +1 -0
- package/dist/browser/AsyncQueryBus/Params.d.cts +5 -3
- package/dist/browser/AsyncQueryBus/Params.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/Params.d.mts +5 -3
- package/dist/browser/AsyncQueryBus/Params.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/Params.d.ts +5 -3
- package/dist/browser/AsyncQueryBus/Params.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/index.d.cts +3 -1
- package/dist/browser/AsyncQueryBus/index.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/index.d.mts +3 -1
- package/dist/browser/AsyncQueryBus/index.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/index.d.ts +3 -1
- package/dist/browser/AsyncQueryBus/index.d.ts.map +1 -1
- package/dist/browser/Config.d.cts +5 -2
- package/dist/browser/Config.d.cts.map +1 -1
- package/dist/browser/Config.d.mts +5 -2
- package/dist/browser/Config.d.mts.map +1 -1
- package/dist/browser/Config.d.ts +5 -2
- package/dist/browser/Config.d.ts.map +1 -1
- package/dist/browser/PubSubBridge.d.cts +14 -19
- package/dist/browser/PubSubBridge.d.cts.map +1 -1
- package/dist/browser/PubSubBridge.d.mts +14 -19
- package/dist/browser/PubSubBridge.d.mts.map +1 -1
- package/dist/browser/PubSubBridge.d.ts +14 -19
- package/dist/browser/PubSubBridge.d.ts.map +1 -1
- package/dist/browser/index.cjs +341 -135
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +2 -0
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +2 -0
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +343 -137
- package/dist/browser/index.js.map +1 -1
- package/dist/node/AbstractModuleHost/AbstractModuleHost.d.cts +11 -0
- package/dist/node/AbstractModuleHost/AbstractModuleHost.d.cts.map +1 -0
- package/dist/node/AbstractModuleHost/AbstractModuleHost.d.mts +11 -0
- package/dist/node/AbstractModuleHost/AbstractModuleHost.d.mts.map +1 -0
- package/dist/node/AbstractModuleHost/AbstractModuleHost.d.ts +11 -0
- package/dist/node/AbstractModuleHost/AbstractModuleHost.d.ts.map +1 -0
- package/dist/node/AbstractModuleHost/index.d.cts +2 -0
- package/dist/node/AbstractModuleHost/index.d.cts.map +1 -0
- package/dist/node/AbstractModuleHost/index.d.mts +2 -0
- package/dist/node/AbstractModuleHost/index.d.mts.map +1 -0
- package/dist/node/AbstractModuleHost/index.d.ts +2 -0
- package/dist/node/AbstractModuleHost/index.d.ts.map +1 -0
- package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.cts +90 -0
- package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.cts.map +1 -0
- package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.mts +90 -0
- package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.mts.map +1 -0
- package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.ts +90 -0
- package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.ts.map +1 -0
- package/dist/node/AbstractModuleProxy/index.d.cts +2 -0
- package/dist/node/AbstractModuleProxy/index.d.cts.map +1 -0
- package/dist/node/AbstractModuleProxy/index.d.mts +2 -0
- package/dist/node/AbstractModuleProxy/index.d.mts.map +1 -0
- package/dist/node/AbstractModuleProxy/index.d.ts +2 -0
- package/dist/node/AbstractModuleProxy/index.d.ts.map +1 -0
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +75 -38
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +75 -38
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +75 -38
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts +16 -46
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts +16 -46
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts +16 -46
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts +37 -0
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -0
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts +37 -0
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -0
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts +37 -0
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -0
- package/dist/node/AsyncQueryBus/Config.d.cts +21 -31
- package/dist/node/AsyncQueryBus/Config.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/Config.d.mts +21 -31
- package/dist/node/AsyncQueryBus/Config.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/Config.d.ts +21 -31
- package/dist/node/AsyncQueryBus/Config.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.cts +12 -0
- package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.cts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.mts +12 -0
- package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.mts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.ts +12 -0
- package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.ts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleHost/index.d.cts +2 -0
- package/dist/node/AsyncQueryBus/ModuleHost/index.d.cts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleHost/index.d.mts +2 -0
- package/dist/node/AsyncQueryBus/ModuleHost/index.d.mts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleHost/index.d.ts +2 -0
- package/dist/node/AsyncQueryBus/ModuleHost/index.d.ts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts +12 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts +12 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts +12 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/index.d.cts +2 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/index.d.cts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/index.d.mts +2 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/index.d.mts.map +1 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/index.d.ts +2 -0
- package/dist/node/AsyncQueryBus/ModuleProxy/index.d.ts.map +1 -0
- package/dist/node/AsyncQueryBus/Params.d.cts +5 -3
- package/dist/node/AsyncQueryBus/Params.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/Params.d.mts +5 -3
- package/dist/node/AsyncQueryBus/Params.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/Params.d.ts +5 -3
- package/dist/node/AsyncQueryBus/Params.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/index.d.cts +3 -1
- package/dist/node/AsyncQueryBus/index.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/index.d.mts +3 -1
- package/dist/node/AsyncQueryBus/index.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/index.d.ts +3 -1
- package/dist/node/AsyncQueryBus/index.d.ts.map +1 -1
- package/dist/node/Config.d.cts +5 -2
- package/dist/node/Config.d.cts.map +1 -1
- package/dist/node/Config.d.mts +5 -2
- package/dist/node/Config.d.mts.map +1 -1
- package/dist/node/Config.d.ts +5 -2
- package/dist/node/Config.d.ts.map +1 -1
- package/dist/node/PubSubBridge.d.cts +14 -19
- package/dist/node/PubSubBridge.d.cts.map +1 -1
- package/dist/node/PubSubBridge.d.mts +14 -19
- package/dist/node/PubSubBridge.d.mts.map +1 -1
- package/dist/node/PubSubBridge.d.ts +14 -19
- package/dist/node/PubSubBridge.d.ts.map +1 -1
- package/dist/node/index.cjs +367 -152
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -0
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +2 -0
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +363 -154
- package/dist/node/index.js.map +1 -1
- package/package.json +32 -25
- package/src/AbstractModuleHost/AbstractModuleHost.ts +12 -0
- package/src/AbstractModuleHost/index.ts +1 -0
- package/src/AbstractModuleProxy/AbstractModuleProxy.ts +239 -0
- package/src/AbstractModuleProxy/index.ts +1 -0
- package/src/AsyncQueryBus/AsyncQueryBusBase.ts +19 -40
- package/src/AsyncQueryBus/AsyncQueryBusClient.ts +73 -63
- package/src/AsyncQueryBus/{AsyncQueryBusServer.ts → AsyncQueryBusHost.ts} +35 -27
- package/src/AsyncQueryBus/Config.ts +23 -33
- package/src/AsyncQueryBus/ModuleHost/ModuleHost.ts +29 -0
- package/src/AsyncQueryBus/ModuleHost/index.ts +1 -0
- package/src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts +19 -0
- package/src/AsyncQueryBus/ModuleProxy/index.ts +1 -0
- package/src/AsyncQueryBus/Params.ts +6 -3
- package/src/AsyncQueryBus/index.ts +3 -1
- package/src/Config.ts +5 -2
- package/src/PubSubBridge.ts +19 -20
- package/src/index.ts +2 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -74
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -74
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -74
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -74
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -74
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -74
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -21,48 +21,197 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
|
+
AbstractModuleProxy: () => AbstractModuleProxy,
|
|
25
|
+
AsyncQueryBusClient: () => AsyncQueryBusClient,
|
|
26
|
+
AsyncQueryBusHost: () => AsyncQueryBusHost,
|
|
27
|
+
AsyncQueryBusModuleHost: () => AsyncQueryBusModuleHost,
|
|
28
|
+
AsyncQueryBusModuleProxy: () => AsyncQueryBusModuleProxy,
|
|
29
|
+
Pending: () => Pending,
|
|
24
30
|
PubSubBridge: () => PubSubBridge,
|
|
25
31
|
PubSubBridgeConfigSchema: () => PubSubBridgeConfigSchema,
|
|
26
32
|
PubSubBridgeSchema: () => PubSubBridgeSchema
|
|
27
33
|
});
|
|
28
34
|
module.exports = __toCommonJS(src_exports);
|
|
29
35
|
|
|
30
|
-
// src/
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
var import_abstract_bridge = require("@xyo-network/abstract-bridge");
|
|
39
|
-
var import_manifest_model = require("@xyo-network/manifest-model");
|
|
40
|
-
var import_module_model3 = require("@xyo-network/module-model");
|
|
36
|
+
// src/AbstractModuleProxy/AbstractModuleProxy.ts
|
|
37
|
+
var import_assert = require("@xylabs/assert");
|
|
38
|
+
var import_lodash = require("@xylabs/lodash");
|
|
39
|
+
var import_object = require("@xylabs/object");
|
|
40
|
+
var import_promise = require("@xylabs/promise");
|
|
41
|
+
var import_boundwitness_builder = require("@xyo-network/boundwitness-builder");
|
|
42
|
+
var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
|
|
43
|
+
var import_module_model = require("@xyo-network/module-model");
|
|
41
44
|
var import_payload_model = require("@xyo-network/payload-model");
|
|
42
|
-
var
|
|
45
|
+
var AbstractModuleProxy = class extends import_object.Base {
|
|
46
|
+
static {
|
|
47
|
+
__name(this, "AbstractModuleProxy");
|
|
48
|
+
}
|
|
49
|
+
static requiredQueries = [
|
|
50
|
+
import_module_model.ModuleDiscoverQuerySchema
|
|
51
|
+
];
|
|
52
|
+
eventData = {};
|
|
53
|
+
proxyParams;
|
|
54
|
+
constructor(params) {
|
|
55
|
+
super({
|
|
56
|
+
config: {
|
|
57
|
+
schema: import_module_model.ModuleConfigSchema
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
this.proxyParams = params;
|
|
61
|
+
}
|
|
62
|
+
get account() {
|
|
63
|
+
return this.proxyParams.account;
|
|
64
|
+
}
|
|
65
|
+
get address() {
|
|
66
|
+
return this.proxyParams.moduleAddress;
|
|
67
|
+
}
|
|
68
|
+
get config() {
|
|
69
|
+
return this.params.config;
|
|
70
|
+
}
|
|
71
|
+
get downResolver() {
|
|
72
|
+
throw new Error("Unsupported");
|
|
73
|
+
}
|
|
74
|
+
get id() {
|
|
75
|
+
return this.proxyParams.moduleAddress;
|
|
76
|
+
}
|
|
77
|
+
get queries() {
|
|
78
|
+
return this.proxyParams.queries;
|
|
79
|
+
}
|
|
80
|
+
get upResolver() {
|
|
81
|
+
throw new Error("Unsupported");
|
|
82
|
+
}
|
|
83
|
+
static hasRequiredQueries(module2) {
|
|
84
|
+
return this.missingRequiredQueries(module2).length === 0;
|
|
85
|
+
}
|
|
86
|
+
static missingRequiredQueries(module2) {
|
|
87
|
+
const moduleQueries = module2.queries;
|
|
88
|
+
return (0, import_lodash.compact)(this.requiredQueries.map((query) => {
|
|
89
|
+
return moduleQueries.includes(query) ? null : query;
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
async addressPreviousHash() {
|
|
93
|
+
const queryPayload = {
|
|
94
|
+
schema: import_module_model.ModuleAddressQuerySchema
|
|
95
|
+
};
|
|
96
|
+
return (0, import_assert.assertEx)((await this.sendQuery(queryPayload)).find((payload) => payload.schema === import_module_model.AddressPreviousHashSchema), "Result did not include correct payload");
|
|
97
|
+
}
|
|
98
|
+
clearListeners(_eventNames) {
|
|
99
|
+
throw new Error("Unsupported");
|
|
100
|
+
}
|
|
101
|
+
//TODO: Make ModuleDescription into real payload
|
|
102
|
+
async describe() {
|
|
103
|
+
const queryPayload = {
|
|
104
|
+
schema: import_module_model.ModuleDescribeQuerySchema
|
|
105
|
+
};
|
|
106
|
+
return (await this.sendQuery(queryPayload))[0];
|
|
107
|
+
}
|
|
108
|
+
async discover() {
|
|
109
|
+
const queryPayload = {
|
|
110
|
+
schema: import_module_model.ModuleDiscoverQuerySchema
|
|
111
|
+
};
|
|
112
|
+
return await this.sendQuery(queryPayload);
|
|
113
|
+
}
|
|
114
|
+
emit(_eventName, _eventArgs) {
|
|
115
|
+
throw new Error("Unsupported");
|
|
116
|
+
}
|
|
117
|
+
emitSerial(_eventName, _eventArgs) {
|
|
118
|
+
throw new Error("Unsupported");
|
|
119
|
+
}
|
|
120
|
+
listenerCount(_eventNames) {
|
|
121
|
+
throw new Error("Unsupported");
|
|
122
|
+
}
|
|
123
|
+
async manifest(maxDepth) {
|
|
124
|
+
const queryPayload = {
|
|
125
|
+
schema: import_module_model.ModuleManifestQuerySchema,
|
|
126
|
+
...maxDepth === void 0 ? {} : {
|
|
127
|
+
maxDepth
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return (await this.sendQuery(queryPayload))[0];
|
|
131
|
+
}
|
|
132
|
+
async moduleAddress() {
|
|
133
|
+
const queryPayload = {
|
|
134
|
+
schema: import_module_model.ModuleAddressQuerySchema
|
|
135
|
+
};
|
|
136
|
+
return await this.sendQuery(queryPayload);
|
|
137
|
+
}
|
|
138
|
+
off(_eventNames, _listener) {
|
|
139
|
+
throw new Error("Unsupported");
|
|
140
|
+
}
|
|
141
|
+
offAny(_listener) {
|
|
142
|
+
throw new Error("Unsupported");
|
|
143
|
+
}
|
|
144
|
+
on(_eventNames, _listener) {
|
|
145
|
+
throw new Error("Unsupported");
|
|
146
|
+
}
|
|
147
|
+
onAny(_listener) {
|
|
148
|
+
throw new Error("Unsupported");
|
|
149
|
+
}
|
|
150
|
+
once(_eventName, _listener) {
|
|
151
|
+
throw new Error("Unsupported");
|
|
152
|
+
}
|
|
153
|
+
async previousHash() {
|
|
154
|
+
const queryPayload = {
|
|
155
|
+
schema: import_module_model.ModuleAddressQuerySchema
|
|
156
|
+
};
|
|
157
|
+
return (await this.sendQuery(queryPayload)).pop().previousHash;
|
|
158
|
+
}
|
|
159
|
+
queryable(_query, _payloads) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
resolve(nameOrAddressOrFilter, _options) {
|
|
163
|
+
return typeof nameOrAddressOrFilter === "string" ? void 0 : [];
|
|
164
|
+
}
|
|
165
|
+
state() {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
bindQuery(query, payloads, account = this.account) {
|
|
169
|
+
const promise = new import_promise.PromiseEx(async (resolve) => {
|
|
170
|
+
const result = await this.bindQueryInternal(query, payloads, account);
|
|
171
|
+
resolve?.(result);
|
|
172
|
+
return result;
|
|
173
|
+
}, account);
|
|
174
|
+
return promise;
|
|
175
|
+
}
|
|
176
|
+
async bindQueryInternal(query, payloads, account = this.account) {
|
|
177
|
+
const builder = await new import_boundwitness_builder.QueryBoundWitnessBuilder().payloads(payloads).query(query);
|
|
178
|
+
const result = await (account ? builder.witness(account) : builder).build();
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
async filterErrors(result) {
|
|
182
|
+
const wrapper = await import_boundwitness_wrapper.BoundWitnessWrapper.wrap(result[0], result[1]);
|
|
183
|
+
return wrapper.payloadsBySchema(import_payload_model.ModuleErrorSchema);
|
|
184
|
+
}
|
|
185
|
+
async sendQuery(queryPayload, payloads) {
|
|
186
|
+
const query = await this.bindQuery(queryPayload, payloads);
|
|
187
|
+
const [, resultPayloads, errors] = await this.query(query[0], query[1]);
|
|
188
|
+
if (errors && errors.length > 0) {
|
|
189
|
+
throw errors[0];
|
|
190
|
+
}
|
|
191
|
+
return resultPayloads;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
43
194
|
|
|
44
195
|
// src/AsyncQueryBus/AsyncQueryBusClient.ts
|
|
45
|
-
var import_assert2 = require("@xylabs/assert");
|
|
46
196
|
var import_delay = require("@xylabs/delay");
|
|
47
197
|
var import_forget = require("@xylabs/forget");
|
|
48
198
|
var import_timer = require("@xylabs/timer");
|
|
49
199
|
var import_boundwitness_model = require("@xyo-network/boundwitness-model");
|
|
50
200
|
var import_diviner_boundwitness_model = require("@xyo-network/diviner-boundwitness-model");
|
|
51
|
-
var import_module_model = require("@xyo-network/module-model");
|
|
52
201
|
var import_payload_builder = require("@xyo-network/payload-builder");
|
|
202
|
+
var import_lru_cache2 = require("lru-cache");
|
|
53
203
|
|
|
54
204
|
// src/AsyncQueryBus/AsyncQueryBusBase.ts
|
|
55
|
-
var
|
|
56
|
-
var
|
|
205
|
+
var import_assert2 = require("@xylabs/assert");
|
|
206
|
+
var import_object2 = require("@xylabs/object");
|
|
57
207
|
var import_archivist_model = require("@xyo-network/archivist-model");
|
|
58
208
|
var import_diviner_model = require("@xyo-network/diviner-model");
|
|
59
209
|
var import_lru_cache = require("lru-cache");
|
|
60
|
-
var AsyncQueryBusBase = class extends
|
|
210
|
+
var AsyncQueryBusBase = class extends import_object2.Base {
|
|
61
211
|
static {
|
|
62
212
|
__name(this, "AsyncQueryBusBase");
|
|
63
213
|
}
|
|
64
214
|
_lastState;
|
|
65
|
-
_queryCache;
|
|
66
215
|
_targetConfigs = {};
|
|
67
216
|
_targetQueries = {};
|
|
68
217
|
constructor(params) {
|
|
@@ -71,19 +220,8 @@ var AsyncQueryBusBase = class extends import_object.Base {
|
|
|
71
220
|
get config() {
|
|
72
221
|
return this.params.config;
|
|
73
222
|
}
|
|
74
|
-
get individualAddressBatchQueryLimitConfig() {
|
|
75
|
-
return this.config.individualAddressBatchQueryLimit ?? 10;
|
|
76
|
-
}
|
|
77
223
|
get pollFrequencyConfig() {
|
|
78
|
-
return this.config
|
|
79
|
-
}
|
|
80
|
-
get queryCacheConfig() {
|
|
81
|
-
const queryCacheConfig = this.config.queryCache === true ? {} : this.config.queryCache;
|
|
82
|
-
return {
|
|
83
|
-
max: 100,
|
|
84
|
-
ttl: 1e3 * 60,
|
|
85
|
-
...queryCacheConfig
|
|
86
|
-
};
|
|
224
|
+
return this.config?.pollFrequency ?? 1e3;
|
|
87
225
|
}
|
|
88
226
|
get resolver() {
|
|
89
227
|
return this.params.resolver;
|
|
@@ -99,32 +237,17 @@ var AsyncQueryBusBase = class extends import_object.Base {
|
|
|
99
237
|
this._lastState = this._lastState ?? new import_lru_cache.LRUCache(requiredConfig);
|
|
100
238
|
return this._lastState;
|
|
101
239
|
}
|
|
102
|
-
/**
|
|
103
|
-
* A cache of queries that have been issued
|
|
104
|
-
*/
|
|
105
|
-
get queryCache() {
|
|
106
|
-
const config = this.queryCacheConfig;
|
|
107
|
-
const requiredConfig = {
|
|
108
|
-
noUpdateTTL: false,
|
|
109
|
-
ttlAutopurge: true
|
|
110
|
-
};
|
|
111
|
-
this._queryCache = this._queryCache ?? new import_lru_cache.LRUCache({
|
|
112
|
-
...config,
|
|
113
|
-
...requiredConfig
|
|
114
|
-
});
|
|
115
|
-
return this._queryCache;
|
|
116
|
-
}
|
|
117
240
|
async queriesArchivist() {
|
|
118
|
-
return (0,
|
|
241
|
+
return (0, import_assert2.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve(this.config?.clearingHouse?.queries?.archivist)), () => `Unable to resolve queriesArchivist [${this.config?.clearingHouse?.queries?.archivist}]`);
|
|
119
242
|
}
|
|
120
243
|
async queriesDiviner() {
|
|
121
|
-
return (0,
|
|
244
|
+
return (0, import_assert2.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve(this.config?.clearingHouse?.queries?.boundWitnessDiviner)), () => `Unable to resolve queriesDiviner [${this.config?.clearingHouse?.queries?.boundWitnessDiviner}]`);
|
|
122
245
|
}
|
|
123
246
|
async responsesArchivist() {
|
|
124
|
-
return (0,
|
|
247
|
+
return (0, import_assert2.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve(this.config?.clearingHouse?.responses?.archivist)), () => `Unable to resolve responsesArchivist [${this.config?.clearingHouse?.responses?.archivist}]`);
|
|
125
248
|
}
|
|
126
249
|
async responsesDiviner() {
|
|
127
|
-
return (0,
|
|
250
|
+
return (0, import_assert2.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve(this.config?.clearingHouse?.responses?.boundWitnessDiviner)), () => `Unable to resolve responsesDiviner [${this.config?.clearingHouse?.responses?.boundWitnessDiviner}]`);
|
|
128
251
|
}
|
|
129
252
|
/**
|
|
130
253
|
* Commit the internal state of the process. This is similar
|
|
@@ -166,18 +289,40 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
166
289
|
static {
|
|
167
290
|
__name(this, "AsyncQueryBusClient");
|
|
168
291
|
}
|
|
292
|
+
_queryCache;
|
|
293
|
+
_pollCount = 0;
|
|
169
294
|
_pollId;
|
|
170
295
|
constructor(params) {
|
|
171
296
|
super(params);
|
|
172
297
|
}
|
|
298
|
+
get queryCacheConfig() {
|
|
299
|
+
const queryCacheConfig = this.config?.queryCache === true ? {} : this.config?.queryCache;
|
|
300
|
+
return {
|
|
301
|
+
max: 100,
|
|
302
|
+
ttl: 1e3 * 60,
|
|
303
|
+
...queryCacheConfig
|
|
304
|
+
};
|
|
305
|
+
}
|
|
173
306
|
get started() {
|
|
174
307
|
return !!this._pollId;
|
|
175
308
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
309
|
+
/**
|
|
310
|
+
* A cache of queries that have been issued
|
|
311
|
+
*/
|
|
312
|
+
get queryCache() {
|
|
313
|
+
const config = this.queryCacheConfig;
|
|
314
|
+
const requiredConfig = {
|
|
315
|
+
noUpdateTTL: false,
|
|
316
|
+
ttlAutopurge: true
|
|
317
|
+
};
|
|
318
|
+
this._queryCache = this._queryCache ?? new import_lru_cache2.LRUCache({
|
|
319
|
+
...config,
|
|
320
|
+
...requiredConfig
|
|
179
321
|
});
|
|
180
|
-
return
|
|
322
|
+
return this._queryCache;
|
|
323
|
+
}
|
|
324
|
+
listeningAddresses() {
|
|
325
|
+
return this._queryCache?.keys();
|
|
181
326
|
}
|
|
182
327
|
async send(address, query, payloads) {
|
|
183
328
|
this.logger?.debug(`Begin issuing query to: ${address}`);
|
|
@@ -192,10 +337,6 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
192
337
|
$meta
|
|
193
338
|
});
|
|
194
339
|
const queryArchivist = await this.queriesArchivist();
|
|
195
|
-
const sourceAddress = query.addresses.at(0);
|
|
196
|
-
if (sourceAddress && !this.config.listeningModules?.includes(sourceAddress)) {
|
|
197
|
-
this.config.listeningModules?.push(sourceAddress);
|
|
198
|
-
}
|
|
199
340
|
const routedQueryHash = (
|
|
200
341
|
// Trust the signed hash if it's there
|
|
201
342
|
routedQuery?.$hash ?? // TODO: What is the right way to find the dataHash
|
|
@@ -218,52 +359,43 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
218
359
|
const context = new Promise((resolve) => {
|
|
219
360
|
this.logger?.debug(`Polling for response to query: ${routedQueryHash}`);
|
|
220
361
|
const pollForResponse = /* @__PURE__ */ __name(async () => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
response
|
|
225
|
-
|
|
226
|
-
this.
|
|
227
|
-
|
|
228
|
-
|
|
362
|
+
try {
|
|
363
|
+
this.start();
|
|
364
|
+
let response = this.queryCache.get(routedQueryHash);
|
|
365
|
+
while (response !== void 0) {
|
|
366
|
+
await (0, import_delay.delay)(100);
|
|
367
|
+
response = this.queryCache.get(routedQueryHash);
|
|
368
|
+
if (response && response !== Pending) {
|
|
369
|
+
this.logger?.debug(`Returning response to query: ${routedQueryHash}`);
|
|
370
|
+
resolve(response);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
229
373
|
}
|
|
374
|
+
this.logger?.error("Timeout waiting for query response");
|
|
375
|
+
const error = {
|
|
376
|
+
message: "Timeout waiting for query response",
|
|
377
|
+
query: "network.xyo.boundwitness",
|
|
378
|
+
schema: "network.xyo.error.module",
|
|
379
|
+
sources: [
|
|
380
|
+
routedQueryHash
|
|
381
|
+
]
|
|
382
|
+
};
|
|
383
|
+
resolve([
|
|
384
|
+
routedQuery,
|
|
385
|
+
[],
|
|
386
|
+
[
|
|
387
|
+
await import_payload_builder.PayloadBuilder.build(error)
|
|
388
|
+
]
|
|
389
|
+
]);
|
|
390
|
+
return;
|
|
391
|
+
} finally {
|
|
392
|
+
this.stop();
|
|
230
393
|
}
|
|
231
|
-
this.logger?.error("Timeout waiting for query response");
|
|
232
|
-
const error = {
|
|
233
|
-
message: "Timeout waiting for query response",
|
|
234
|
-
query: "network.xyo.boundwitness",
|
|
235
|
-
schema: "network.xyo.error.module",
|
|
236
|
-
sources: [
|
|
237
|
-
routedQueryHash
|
|
238
|
-
]
|
|
239
|
-
};
|
|
240
|
-
resolve([
|
|
241
|
-
routedQuery,
|
|
242
|
-
[],
|
|
243
|
-
[
|
|
244
|
-
await import_payload_builder.PayloadBuilder.build(error)
|
|
245
|
-
]
|
|
246
|
-
]);
|
|
247
|
-
return;
|
|
248
394
|
}, "pollForResponse");
|
|
249
395
|
(0, import_forget.forget)(pollForResponse());
|
|
250
396
|
});
|
|
251
397
|
return context;
|
|
252
398
|
}
|
|
253
|
-
start() {
|
|
254
|
-
if (this.started) {
|
|
255
|
-
console.warn("AsyncQueryBus starting when already started");
|
|
256
|
-
}
|
|
257
|
-
this.poll();
|
|
258
|
-
}
|
|
259
|
-
stop() {
|
|
260
|
-
if (!this.started) {
|
|
261
|
-
console.warn("AsyncQueryBus stopping when already stopped");
|
|
262
|
-
}
|
|
263
|
-
if (this._pollId)
|
|
264
|
-
(0, import_timer.clearTimeoutEx)(this._pollId);
|
|
265
|
-
this._pollId = void 0;
|
|
266
|
-
}
|
|
267
399
|
/**
|
|
268
400
|
* Runs the background divine process on a loop with a delay
|
|
269
401
|
* specified by the `config.pollFrequency`
|
|
@@ -315,9 +447,24 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
315
447
|
}
|
|
316
448
|
}));
|
|
317
449
|
};
|
|
450
|
+
start() {
|
|
451
|
+
if (this._pollCount === 0) {
|
|
452
|
+
this.poll();
|
|
453
|
+
}
|
|
454
|
+
this._pollCount++;
|
|
455
|
+
}
|
|
456
|
+
stop() {
|
|
457
|
+
this._pollCount--;
|
|
458
|
+
if (this._pollCount <= 0) {
|
|
459
|
+
if (this._pollId)
|
|
460
|
+
(0, import_timer.clearTimeoutEx)(this._pollId);
|
|
461
|
+
this._pollId = void 0;
|
|
462
|
+
this._pollCount = 0;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
318
465
|
};
|
|
319
466
|
|
|
320
|
-
// src/AsyncQueryBus/
|
|
467
|
+
// src/AsyncQueryBus/AsyncQueryBusHost.ts
|
|
321
468
|
var import_array = require("@xylabs/array");
|
|
322
469
|
var import_assert3 = require("@xylabs/assert");
|
|
323
470
|
var import_timer2 = require("@xylabs/timer");
|
|
@@ -325,20 +472,23 @@ var import_boundwitness_model2 = require("@xyo-network/boundwitness-model");
|
|
|
325
472
|
var import_diviner_boundwitness_model2 = require("@xyo-network/diviner-boundwitness-model");
|
|
326
473
|
var import_module_model2 = require("@xyo-network/module-model");
|
|
327
474
|
var import_payload_builder2 = require("@xyo-network/payload-builder");
|
|
328
|
-
var
|
|
475
|
+
var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
329
476
|
static {
|
|
330
|
-
__name(this, "
|
|
477
|
+
__name(this, "AsyncQueryBusHost");
|
|
331
478
|
}
|
|
332
479
|
_pollId;
|
|
333
480
|
constructor(params) {
|
|
334
481
|
super(params);
|
|
335
482
|
}
|
|
483
|
+
get perAddressBatchQueryLimit() {
|
|
484
|
+
return this.config?.perAddressBatchQueryLimit ?? 10;
|
|
485
|
+
}
|
|
336
486
|
get started() {
|
|
337
487
|
return !!this._pollId;
|
|
338
488
|
}
|
|
339
489
|
async listeningModules() {
|
|
340
|
-
const mods = this.config
|
|
341
|
-
direction: "
|
|
490
|
+
const mods = this.config?.listeningModules ? await Promise.all(this.config.listeningModules.map(async (listeningModule) => (0, import_assert3.assertEx)((0, import_module_model2.asModuleInstance)(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`))) : await this.resolver.resolve(void 0, {
|
|
491
|
+
direction: "down"
|
|
342
492
|
});
|
|
343
493
|
return mods;
|
|
344
494
|
}
|
|
@@ -356,27 +506,27 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
356
506
|
(0, import_timer2.clearTimeoutEx)(this._pollId);
|
|
357
507
|
this._pollId = void 0;
|
|
358
508
|
}
|
|
359
|
-
callLocalModule = async (localModule,
|
|
509
|
+
callLocalModule = async (localModule, query) => {
|
|
360
510
|
const localModuleName = localModule.config.name ?? localModule.address;
|
|
361
511
|
const queryArchivist = await this.queriesArchivist();
|
|
362
512
|
const responseArchivist = await this.responsesArchivist();
|
|
363
|
-
const commandDestination =
|
|
513
|
+
const commandDestination = query.$meta?.destination;
|
|
364
514
|
if (commandDestination && commandDestination?.includes(localModule.address)) {
|
|
365
|
-
const queryIndex =
|
|
515
|
+
const queryIndex = query.payload_hashes.indexOf(query.query);
|
|
366
516
|
if (queryIndex !== -1) {
|
|
367
|
-
const querySchema =
|
|
517
|
+
const querySchema = query.payload_schemas[queryIndex];
|
|
368
518
|
if (localModule.queries.includes(querySchema)) {
|
|
369
|
-
const commandPayloads = await queryArchivist.get(
|
|
519
|
+
const commandPayloads = await queryArchivist.get(query.payload_hashes);
|
|
370
520
|
const commandPayloadsDict = await import_payload_builder2.PayloadBuilder.toAllHashMap(commandPayloads);
|
|
371
|
-
const commandHash = (await import_payload_builder2.PayloadBuilder.build(
|
|
372
|
-
if (!(0, import_array.containsAll)(Object.keys(commandPayloadsDict),
|
|
521
|
+
const commandHash = (await import_payload_builder2.PayloadBuilder.build(query)).$hash;
|
|
522
|
+
if (!(0, import_array.containsAll)(Object.keys(commandPayloadsDict), query.payload_hashes)) {
|
|
373
523
|
this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}, missing payloads`);
|
|
374
524
|
return;
|
|
375
525
|
}
|
|
376
526
|
try {
|
|
377
|
-
const commandSchema = commandPayloadsDict[
|
|
527
|
+
const commandSchema = commandPayloadsDict[query.query].schema;
|
|
378
528
|
this.logger?.debug(`Issuing command ${commandSchema} (${commandHash}) addressed to module: ${localModuleName}`);
|
|
379
|
-
const response = await localModule.query(
|
|
529
|
+
const response = await localModule.query(query, commandPayloads);
|
|
380
530
|
const [bw, payloads, errors] = response;
|
|
381
531
|
this.logger?.debug(`Replying to command ${commandHash} addressed to module: ${localModuleName}`);
|
|
382
532
|
const insertResult = await responseArchivist.insert([
|
|
@@ -384,11 +534,11 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
384
534
|
...payloads,
|
|
385
535
|
...errors
|
|
386
536
|
]);
|
|
387
|
-
if (insertResult.length
|
|
537
|
+
if (insertResult.length === 0) {
|
|
388
538
|
this.logger?.error(`Error replying to command ${commandHash} addressed to module: ${localModuleName}`);
|
|
389
539
|
}
|
|
390
|
-
if (
|
|
391
|
-
await this.commitState(localModule.address,
|
|
540
|
+
if (query?.timestamp) {
|
|
541
|
+
await this.commitState(localModule.address, query.timestamp);
|
|
392
542
|
}
|
|
393
543
|
} catch (error) {
|
|
394
544
|
this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}: ${error}`);
|
|
@@ -401,13 +551,13 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
401
551
|
* Finds unprocessed commands addressed to the supplied address
|
|
402
552
|
* @param address The address to find commands for
|
|
403
553
|
*/
|
|
404
|
-
|
|
554
|
+
findQueriesToAddress = async (address) => {
|
|
405
555
|
const queryBoundWitnessDiviner = await this.queriesDiviner();
|
|
406
556
|
const timestamp = await this.retrieveState(address);
|
|
407
557
|
const destination = [
|
|
408
558
|
address
|
|
409
559
|
];
|
|
410
|
-
const limit = this.
|
|
560
|
+
const limit = this.perAddressBatchQueryLimit;
|
|
411
561
|
const divinerQuery = {
|
|
412
562
|
destination,
|
|
413
563
|
limit,
|
|
@@ -418,10 +568,10 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
418
568
|
const result = await queryBoundWitnessDiviner.divine([
|
|
419
569
|
divinerQuery
|
|
420
570
|
]);
|
|
421
|
-
const
|
|
422
|
-
const nextState = Math.max(...
|
|
571
|
+
const queries = result.filter(import_boundwitness_model2.isQueryBoundWitnessWithMeta);
|
|
572
|
+
const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp;
|
|
423
573
|
await this.commitState(address, nextState);
|
|
424
|
-
return
|
|
574
|
+
return queries;
|
|
425
575
|
};
|
|
426
576
|
/**
|
|
427
577
|
* Runs the background divine process on a loop with a delay
|
|
@@ -451,12 +601,12 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
451
601
|
try {
|
|
452
602
|
const localModuleName = localModule.config.name ?? localModule.address;
|
|
453
603
|
this.logger?.debug(`Checking for inbound commands to ${localModuleName}`);
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
604
|
+
const queries = await this.findQueriesToAddress(localModule.address);
|
|
605
|
+
if (queries.length === 0)
|
|
456
606
|
return;
|
|
457
607
|
this.logger?.debug(`Found commands addressed to local module: ${localModuleName}`);
|
|
458
|
-
for (const
|
|
459
|
-
await this.callLocalModule(localModule,
|
|
608
|
+
for (const query of queries) {
|
|
609
|
+
await this.callLocalModule(localModule, query);
|
|
460
610
|
}
|
|
461
611
|
} catch (error) {
|
|
462
612
|
this.logger?.error(`Error processing commands for address ${localModule.address}: ${error}`);
|
|
@@ -465,7 +615,65 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
465
615
|
};
|
|
466
616
|
};
|
|
467
617
|
|
|
618
|
+
// src/AbstractModuleHost/AbstractModuleHost.ts
|
|
619
|
+
var import_object3 = require("@xylabs/object");
|
|
620
|
+
var AbstractModuleHost = class extends import_object3.Base {
|
|
621
|
+
static {
|
|
622
|
+
__name(this, "AbstractModuleHost");
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
// src/AsyncQueryBus/ModuleHost/ModuleHost.ts
|
|
627
|
+
var AsyncQueryBusModuleHost = class extends AbstractModuleHost {
|
|
628
|
+
static {
|
|
629
|
+
__name(this, "AsyncQueryBusModuleHost");
|
|
630
|
+
}
|
|
631
|
+
_busHost;
|
|
632
|
+
constructor(params) {
|
|
633
|
+
super(params);
|
|
634
|
+
}
|
|
635
|
+
async start() {
|
|
636
|
+
const listeningModules = this.params.config.listeningModules ?? (await this.params.module.resolve(void 0, {
|
|
637
|
+
direction: "down"
|
|
638
|
+
})).map((m) => m.address);
|
|
639
|
+
this._busHost = new AsyncQueryBusHost({
|
|
640
|
+
config: {
|
|
641
|
+
...this.params.config,
|
|
642
|
+
listeningModules
|
|
643
|
+
},
|
|
644
|
+
logger: this.params.logger,
|
|
645
|
+
resolver: this.params.module
|
|
646
|
+
});
|
|
647
|
+
this._busHost?.start();
|
|
648
|
+
}
|
|
649
|
+
stop() {
|
|
650
|
+
this._busHost?.stop();
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
// src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts
|
|
655
|
+
var AsyncQueryBusModuleProxy = class extends AbstractModuleProxy {
|
|
656
|
+
static {
|
|
657
|
+
__name(this, "AsyncQueryBusModuleProxy");
|
|
658
|
+
}
|
|
659
|
+
async query(query, payloads) {
|
|
660
|
+
return await this.proxyParams.bridgeClient.send(this.address, query, payloads);
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
// src/Schema.ts
|
|
665
|
+
var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
|
|
666
|
+
|
|
667
|
+
// src/Config.ts
|
|
668
|
+
var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
|
|
669
|
+
|
|
468
670
|
// src/PubSubBridge.ts
|
|
671
|
+
var import_assert4 = require("@xylabs/assert");
|
|
672
|
+
var import_abstract_bridge = require("@xyo-network/abstract-bridge");
|
|
673
|
+
var import_manifest_model = require("@xyo-network/manifest-model");
|
|
674
|
+
var import_module_model3 = require("@xyo-network/module-model");
|
|
675
|
+
var import_payload_model2 = require("@xyo-network/payload-model");
|
|
676
|
+
var import_lru_cache3 = require("lru-cache");
|
|
469
677
|
function _ts_decorate(decorators, target, key, desc) {
|
|
470
678
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
471
679
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -493,10 +701,10 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
|
|
|
493
701
|
_targetConfigs = {};
|
|
494
702
|
_targetQueries = {};
|
|
495
703
|
_busClient;
|
|
496
|
-
|
|
704
|
+
_busHost;
|
|
497
705
|
get discoverCache() {
|
|
498
706
|
const config = this.discoverCacheConfig;
|
|
499
|
-
this._discoverCache = this._discoverCache ?? new
|
|
707
|
+
this._discoverCache = this._discoverCache ?? new import_lru_cache3.LRUCache({
|
|
500
708
|
ttlAutopurge: true,
|
|
501
709
|
...config
|
|
502
710
|
});
|
|
@@ -557,7 +765,7 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
|
|
|
557
765
|
};
|
|
558
766
|
const boundQuery = await this.bindQuery(queryPayload);
|
|
559
767
|
const manifest = (0, import_assert4.assertEx)(await this.targetQuery(addressToCall, boundQuery[0], boundQuery[1]), () => `Unable to resolve [${address}]`)[1];
|
|
560
|
-
return (0, import_assert4.assertEx)(manifest.find((0,
|
|
768
|
+
return (0, import_assert4.assertEx)(manifest.find((0, import_payload_model2.isPayloadOfSchemaType)(import_manifest_model.ModuleManifestPayloadSchema)), "Did not receive manifest");
|
|
561
769
|
}
|
|
562
770
|
targetQueries(address) {
|
|
563
771
|
if (!this.connected)
|
|
@@ -577,32 +785,30 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
|
|
|
577
785
|
busClient() {
|
|
578
786
|
if (!this._busClient) {
|
|
579
787
|
this._busClient = new AsyncQueryBusClient({
|
|
580
|
-
config: this.config,
|
|
788
|
+
config: this.config.client,
|
|
581
789
|
logger: this.logger,
|
|
582
790
|
resolver: this
|
|
583
791
|
});
|
|
584
792
|
}
|
|
585
793
|
return this._busClient;
|
|
586
794
|
}
|
|
587
|
-
|
|
588
|
-
if (!this.
|
|
589
|
-
this.
|
|
590
|
-
config: this.config,
|
|
795
|
+
busHost() {
|
|
796
|
+
if (!this._busHost) {
|
|
797
|
+
this._busHost = new AsyncQueryBusHost({
|
|
798
|
+
config: this.config.host,
|
|
591
799
|
logger: this.logger,
|
|
592
800
|
resolver: this
|
|
593
801
|
});
|
|
594
802
|
}
|
|
595
|
-
return this.
|
|
803
|
+
return this._busHost;
|
|
596
804
|
}
|
|
597
805
|
async startHandler() {
|
|
598
806
|
await Promise.resolve(this.connect());
|
|
599
|
-
this.
|
|
600
|
-
this.busClient().start();
|
|
807
|
+
this.busHost().start();
|
|
601
808
|
return true;
|
|
602
809
|
}
|
|
603
810
|
stopHandler(_timeout) {
|
|
604
|
-
this.
|
|
605
|
-
this.busServer().stop();
|
|
811
|
+
this.busHost().stop();
|
|
606
812
|
return true;
|
|
607
813
|
}
|
|
608
814
|
};
|