@xyo-network/bridge-pub-sub 2.91.0 → 2.91.2
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 +51 -15
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +51 -15
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +51 -15
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts +14 -45
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts +14 -45
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts +14 -45
- 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 +4 -10
- package/dist/browser/PubSubBridge.d.cts.map +1 -1
- package/dist/browser/PubSubBridge.d.mts +4 -10
- package/dist/browser/PubSubBridge.d.mts.map +1 -1
- package/dist/browser/PubSubBridge.d.ts +4 -10
- package/dist/browser/PubSubBridge.d.ts.map +1 -1
- package/dist/browser/index.cjs +331 -126
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -0
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -0
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +332 -127
- 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 +51 -15
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +51 -15
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +51 -15
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts +14 -45
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts +14 -45
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts +14 -45
- 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 +4 -10
- package/dist/node/PubSubBridge.d.cts.map +1 -1
- package/dist/node/PubSubBridge.d.mts +4 -10
- package/dist/node/PubSubBridge.d.mts.map +1 -1
- package/dist/node/PubSubBridge.d.ts +4 -10
- package/dist/node/PubSubBridge.d.ts.map +1 -1
- package/dist/node/index.cjs +355 -144
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -0
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -0
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +352 -144
- package/dist/node/index.js.map +1 -1
- package/package.json +30 -24
- 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 +11 -33
- package/src/AsyncQueryBus/AsyncQueryBusClient.ts +69 -61
- package/src/AsyncQueryBus/{AsyncQueryBusServer.ts → AsyncQueryBusHost.ts} +32 -26
- 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 +10 -12
- package/src/index.ts +1 -0
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -75
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -75
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -75
- package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -75
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -75
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -75
- package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -21,8 +21,11 @@ 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,
|
|
24
25
|
AsyncQueryBusClient: () => AsyncQueryBusClient,
|
|
25
|
-
|
|
26
|
+
AsyncQueryBusHost: () => AsyncQueryBusHost,
|
|
27
|
+
AsyncQueryBusModuleHost: () => AsyncQueryBusModuleHost,
|
|
28
|
+
AsyncQueryBusModuleProxy: () => AsyncQueryBusModuleProxy,
|
|
26
29
|
Pending: () => Pending,
|
|
27
30
|
PubSubBridge: () => PubSubBridge,
|
|
28
31
|
PubSubBridgeConfigSchema: () => PubSubBridgeConfigSchema,
|
|
@@ -30,28 +33,185 @@ __export(src_exports, {
|
|
|
30
33
|
});
|
|
31
34
|
module.exports = __toCommonJS(src_exports);
|
|
32
35
|
|
|
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");
|
|
44
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
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
|
+
};
|
|
194
|
+
|
|
33
195
|
// src/AsyncQueryBus/AsyncQueryBusClient.ts
|
|
34
|
-
var import_assert2 = require("@xylabs/assert");
|
|
35
196
|
var import_delay = require("@xylabs/delay");
|
|
36
197
|
var import_forget = require("@xylabs/forget");
|
|
37
198
|
var import_timer = require("@xylabs/timer");
|
|
38
199
|
var import_boundwitness_model = require("@xyo-network/boundwitness-model");
|
|
39
200
|
var import_diviner_boundwitness_model = require("@xyo-network/diviner-boundwitness-model");
|
|
40
|
-
var import_module_model = require("@xyo-network/module-model");
|
|
41
201
|
var import_payload_builder = require("@xyo-network/payload-builder");
|
|
202
|
+
var import_lru_cache2 = require("lru-cache");
|
|
42
203
|
|
|
43
204
|
// src/AsyncQueryBus/AsyncQueryBusBase.ts
|
|
44
|
-
var
|
|
45
|
-
var
|
|
205
|
+
var import_assert2 = require("@xylabs/assert");
|
|
206
|
+
var import_object2 = require("@xylabs/object");
|
|
46
207
|
var import_archivist_model = require("@xyo-network/archivist-model");
|
|
47
208
|
var import_diviner_model = require("@xyo-network/diviner-model");
|
|
48
209
|
var import_lru_cache = require("lru-cache");
|
|
49
|
-
var AsyncQueryBusBase = class extends
|
|
210
|
+
var AsyncQueryBusBase = class extends import_object2.Base {
|
|
50
211
|
static {
|
|
51
212
|
__name(this, "AsyncQueryBusBase");
|
|
52
213
|
}
|
|
53
214
|
_lastState;
|
|
54
|
-
_queryCache;
|
|
55
215
|
_targetConfigs = {};
|
|
56
216
|
_targetQueries = {};
|
|
57
217
|
constructor(params) {
|
|
@@ -60,19 +220,8 @@ var AsyncQueryBusBase = class extends import_object.Base {
|
|
|
60
220
|
get config() {
|
|
61
221
|
return this.params.config;
|
|
62
222
|
}
|
|
63
|
-
get individualAddressBatchQueryLimitConfig() {
|
|
64
|
-
return this.config.individualAddressBatchQueryLimit ?? 10;
|
|
65
|
-
}
|
|
66
223
|
get pollFrequencyConfig() {
|
|
67
|
-
return this.config
|
|
68
|
-
}
|
|
69
|
-
get queryCacheConfig() {
|
|
70
|
-
const queryCacheConfig = this.config.queryCache === true ? {} : this.config.queryCache;
|
|
71
|
-
return {
|
|
72
|
-
max: 100,
|
|
73
|
-
ttl: 1e3 * 60,
|
|
74
|
-
...queryCacheConfig
|
|
75
|
-
};
|
|
224
|
+
return this.config?.pollFrequency ?? 1e3;
|
|
76
225
|
}
|
|
77
226
|
get resolver() {
|
|
78
227
|
return this.params.resolver;
|
|
@@ -88,32 +237,17 @@ var AsyncQueryBusBase = class extends import_object.Base {
|
|
|
88
237
|
this._lastState = this._lastState ?? new import_lru_cache.LRUCache(requiredConfig);
|
|
89
238
|
return this._lastState;
|
|
90
239
|
}
|
|
91
|
-
/**
|
|
92
|
-
* A cache of queries that have been issued
|
|
93
|
-
*/
|
|
94
|
-
get queryCache() {
|
|
95
|
-
const config = this.queryCacheConfig;
|
|
96
|
-
const requiredConfig = {
|
|
97
|
-
noUpdateTTL: false,
|
|
98
|
-
ttlAutopurge: true
|
|
99
|
-
};
|
|
100
|
-
this._queryCache = this._queryCache ?? new import_lru_cache.LRUCache({
|
|
101
|
-
...config,
|
|
102
|
-
...requiredConfig
|
|
103
|
-
});
|
|
104
|
-
return this._queryCache;
|
|
105
|
-
}
|
|
106
240
|
async queriesArchivist() {
|
|
107
|
-
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}]`);
|
|
108
242
|
}
|
|
109
243
|
async queriesDiviner() {
|
|
110
|
-
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}]`);
|
|
111
245
|
}
|
|
112
246
|
async responsesArchivist() {
|
|
113
|
-
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}]`);
|
|
114
248
|
}
|
|
115
249
|
async responsesDiviner() {
|
|
116
|
-
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}]`);
|
|
117
251
|
}
|
|
118
252
|
/**
|
|
119
253
|
* Commit the internal state of the process. This is similar
|
|
@@ -155,18 +289,40 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
155
289
|
static {
|
|
156
290
|
__name(this, "AsyncQueryBusClient");
|
|
157
291
|
}
|
|
292
|
+
_queryCache;
|
|
293
|
+
_pollCount = 0;
|
|
158
294
|
_pollId;
|
|
159
295
|
constructor(params) {
|
|
160
296
|
super(params);
|
|
161
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
|
+
}
|
|
162
306
|
get started() {
|
|
163
307
|
return !!this._pollId;
|
|
164
308
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
168
321
|
});
|
|
169
|
-
return
|
|
322
|
+
return this._queryCache;
|
|
323
|
+
}
|
|
324
|
+
listeningAddresses() {
|
|
325
|
+
return this._queryCache?.keys();
|
|
170
326
|
}
|
|
171
327
|
async send(address, query, payloads) {
|
|
172
328
|
this.logger?.debug(`Begin issuing query to: ${address}`);
|
|
@@ -181,10 +337,6 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
181
337
|
$meta
|
|
182
338
|
});
|
|
183
339
|
const queryArchivist = await this.queriesArchivist();
|
|
184
|
-
const sourceAddress = query.addresses.at(0);
|
|
185
|
-
if (sourceAddress && !this.config.listeningModules?.includes(sourceAddress)) {
|
|
186
|
-
this.config.listeningModules?.push(sourceAddress);
|
|
187
|
-
}
|
|
188
340
|
const routedQueryHash = (
|
|
189
341
|
// Trust the signed hash if it's there
|
|
190
342
|
routedQuery?.$hash ?? // TODO: What is the right way to find the dataHash
|
|
@@ -207,52 +359,43 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
207
359
|
const context = new Promise((resolve) => {
|
|
208
360
|
this.logger?.debug(`Polling for response to query: ${routedQueryHash}`);
|
|
209
361
|
const pollForResponse = /* @__PURE__ */ __name(async () => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
response
|
|
214
|
-
|
|
215
|
-
this.
|
|
216
|
-
|
|
217
|
-
|
|
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
|
+
}
|
|
218
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();
|
|
219
393
|
}
|
|
220
|
-
this.logger?.error("Timeout waiting for query response");
|
|
221
|
-
const error = {
|
|
222
|
-
message: "Timeout waiting for query response",
|
|
223
|
-
query: "network.xyo.boundwitness",
|
|
224
|
-
schema: "network.xyo.error.module",
|
|
225
|
-
sources: [
|
|
226
|
-
routedQueryHash
|
|
227
|
-
]
|
|
228
|
-
};
|
|
229
|
-
resolve([
|
|
230
|
-
routedQuery,
|
|
231
|
-
[],
|
|
232
|
-
[
|
|
233
|
-
await import_payload_builder.PayloadBuilder.build(error)
|
|
234
|
-
]
|
|
235
|
-
]);
|
|
236
|
-
return;
|
|
237
394
|
}, "pollForResponse");
|
|
238
395
|
(0, import_forget.forget)(pollForResponse());
|
|
239
396
|
});
|
|
240
397
|
return context;
|
|
241
398
|
}
|
|
242
|
-
start() {
|
|
243
|
-
if (this.started) {
|
|
244
|
-
console.warn("AsyncQueryBus starting when already started");
|
|
245
|
-
}
|
|
246
|
-
this.poll();
|
|
247
|
-
}
|
|
248
|
-
stop() {
|
|
249
|
-
if (!this.started) {
|
|
250
|
-
console.warn("AsyncQueryBus stopping when already stopped");
|
|
251
|
-
}
|
|
252
|
-
if (this._pollId)
|
|
253
|
-
(0, import_timer.clearTimeoutEx)(this._pollId);
|
|
254
|
-
this._pollId = void 0;
|
|
255
|
-
}
|
|
256
399
|
/**
|
|
257
400
|
* Runs the background divine process on a loop with a delay
|
|
258
401
|
* specified by the `config.pollFrequency`
|
|
@@ -304,9 +447,24 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
304
447
|
}
|
|
305
448
|
}));
|
|
306
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
|
+
}
|
|
307
465
|
};
|
|
308
466
|
|
|
309
|
-
// src/AsyncQueryBus/
|
|
467
|
+
// src/AsyncQueryBus/AsyncQueryBusHost.ts
|
|
310
468
|
var import_array = require("@xylabs/array");
|
|
311
469
|
var import_assert3 = require("@xylabs/assert");
|
|
312
470
|
var import_timer2 = require("@xylabs/timer");
|
|
@@ -314,20 +472,23 @@ var import_boundwitness_model2 = require("@xyo-network/boundwitness-model");
|
|
|
314
472
|
var import_diviner_boundwitness_model2 = require("@xyo-network/diviner-boundwitness-model");
|
|
315
473
|
var import_module_model2 = require("@xyo-network/module-model");
|
|
316
474
|
var import_payload_builder2 = require("@xyo-network/payload-builder");
|
|
317
|
-
var
|
|
475
|
+
var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
318
476
|
static {
|
|
319
|
-
__name(this, "
|
|
477
|
+
__name(this, "AsyncQueryBusHost");
|
|
320
478
|
}
|
|
321
479
|
_pollId;
|
|
322
480
|
constructor(params) {
|
|
323
481
|
super(params);
|
|
324
482
|
}
|
|
483
|
+
get perAddressBatchQueryLimit() {
|
|
484
|
+
return this.config?.perAddressBatchQueryLimit ?? 10;
|
|
485
|
+
}
|
|
325
486
|
get started() {
|
|
326
487
|
return !!this._pollId;
|
|
327
488
|
}
|
|
328
489
|
async listeningModules() {
|
|
329
|
-
const mods = this.config
|
|
330
|
-
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"
|
|
331
492
|
});
|
|
332
493
|
return mods;
|
|
333
494
|
}
|
|
@@ -345,27 +506,27 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
345
506
|
(0, import_timer2.clearTimeoutEx)(this._pollId);
|
|
346
507
|
this._pollId = void 0;
|
|
347
508
|
}
|
|
348
|
-
callLocalModule = async (localModule,
|
|
509
|
+
callLocalModule = async (localModule, query) => {
|
|
349
510
|
const localModuleName = localModule.config.name ?? localModule.address;
|
|
350
511
|
const queryArchivist = await this.queriesArchivist();
|
|
351
512
|
const responseArchivist = await this.responsesArchivist();
|
|
352
|
-
const commandDestination =
|
|
513
|
+
const commandDestination = query.$meta?.destination;
|
|
353
514
|
if (commandDestination && commandDestination?.includes(localModule.address)) {
|
|
354
|
-
const queryIndex =
|
|
515
|
+
const queryIndex = query.payload_hashes.indexOf(query.query);
|
|
355
516
|
if (queryIndex !== -1) {
|
|
356
|
-
const querySchema =
|
|
517
|
+
const querySchema = query.payload_schemas[queryIndex];
|
|
357
518
|
if (localModule.queries.includes(querySchema)) {
|
|
358
|
-
const commandPayloads = await queryArchivist.get(
|
|
519
|
+
const commandPayloads = await queryArchivist.get(query.payload_hashes);
|
|
359
520
|
const commandPayloadsDict = await import_payload_builder2.PayloadBuilder.toAllHashMap(commandPayloads);
|
|
360
|
-
const commandHash = (await import_payload_builder2.PayloadBuilder.build(
|
|
361
|
-
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)) {
|
|
362
523
|
this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}, missing payloads`);
|
|
363
524
|
return;
|
|
364
525
|
}
|
|
365
526
|
try {
|
|
366
|
-
const commandSchema = commandPayloadsDict[
|
|
527
|
+
const commandSchema = commandPayloadsDict[query.query].schema;
|
|
367
528
|
this.logger?.debug(`Issuing command ${commandSchema} (${commandHash}) addressed to module: ${localModuleName}`);
|
|
368
|
-
const response = await localModule.query(
|
|
529
|
+
const response = await localModule.query(query, commandPayloads);
|
|
369
530
|
const [bw, payloads, errors] = response;
|
|
370
531
|
this.logger?.debug(`Replying to command ${commandHash} addressed to module: ${localModuleName}`);
|
|
371
532
|
const insertResult = await responseArchivist.insert([
|
|
@@ -373,11 +534,11 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
373
534
|
...payloads,
|
|
374
535
|
...errors
|
|
375
536
|
]);
|
|
376
|
-
if (insertResult.length
|
|
537
|
+
if (insertResult.length === 0) {
|
|
377
538
|
this.logger?.error(`Error replying to command ${commandHash} addressed to module: ${localModuleName}`);
|
|
378
539
|
}
|
|
379
|
-
if (
|
|
380
|
-
await this.commitState(localModule.address,
|
|
540
|
+
if (query?.timestamp) {
|
|
541
|
+
await this.commitState(localModule.address, query.timestamp);
|
|
381
542
|
}
|
|
382
543
|
} catch (error) {
|
|
383
544
|
this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}: ${error}`);
|
|
@@ -390,13 +551,13 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
390
551
|
* Finds unprocessed commands addressed to the supplied address
|
|
391
552
|
* @param address The address to find commands for
|
|
392
553
|
*/
|
|
393
|
-
|
|
554
|
+
findQueriesToAddress = async (address) => {
|
|
394
555
|
const queryBoundWitnessDiviner = await this.queriesDiviner();
|
|
395
556
|
const timestamp = await this.retrieveState(address);
|
|
396
557
|
const destination = [
|
|
397
558
|
address
|
|
398
559
|
];
|
|
399
|
-
const limit = this.
|
|
560
|
+
const limit = this.perAddressBatchQueryLimit;
|
|
400
561
|
const divinerQuery = {
|
|
401
562
|
destination,
|
|
402
563
|
limit,
|
|
@@ -407,10 +568,10 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
407
568
|
const result = await queryBoundWitnessDiviner.divine([
|
|
408
569
|
divinerQuery
|
|
409
570
|
]);
|
|
410
|
-
const
|
|
411
|
-
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;
|
|
412
573
|
await this.commitState(address, nextState);
|
|
413
|
-
return
|
|
574
|
+
return queries;
|
|
414
575
|
};
|
|
415
576
|
/**
|
|
416
577
|
* Runs the background divine process on a loop with a delay
|
|
@@ -440,12 +601,12 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
440
601
|
try {
|
|
441
602
|
const localModuleName = localModule.config.name ?? localModule.address;
|
|
442
603
|
this.logger?.debug(`Checking for inbound commands to ${localModuleName}`);
|
|
443
|
-
const
|
|
444
|
-
if (
|
|
604
|
+
const queries = await this.findQueriesToAddress(localModule.address);
|
|
605
|
+
if (queries.length === 0)
|
|
445
606
|
return;
|
|
446
607
|
this.logger?.debug(`Found commands addressed to local module: ${localModuleName}`);
|
|
447
|
-
for (const
|
|
448
|
-
await this.callLocalModule(localModule,
|
|
608
|
+
for (const query of queries) {
|
|
609
|
+
await this.callLocalModule(localModule, query);
|
|
449
610
|
}
|
|
450
611
|
} catch (error) {
|
|
451
612
|
this.logger?.error(`Error processing commands for address ${localModule.address}: ${error}`);
|
|
@@ -454,6 +615,52 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
|
|
|
454
615
|
};
|
|
455
616
|
};
|
|
456
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
|
+
|
|
457
664
|
// src/Schema.ts
|
|
458
665
|
var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
|
|
459
666
|
|
|
@@ -465,8 +672,8 @@ var import_assert4 = require("@xylabs/assert");
|
|
|
465
672
|
var import_abstract_bridge = require("@xyo-network/abstract-bridge");
|
|
466
673
|
var import_manifest_model = require("@xyo-network/manifest-model");
|
|
467
674
|
var import_module_model3 = require("@xyo-network/module-model");
|
|
468
|
-
var
|
|
469
|
-
var
|
|
675
|
+
var import_payload_model2 = require("@xyo-network/payload-model");
|
|
676
|
+
var import_lru_cache3 = require("lru-cache");
|
|
470
677
|
function _ts_decorate(decorators, target, key, desc) {
|
|
471
678
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
472
679
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -494,10 +701,10 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
|
|
|
494
701
|
_targetConfigs = {};
|
|
495
702
|
_targetQueries = {};
|
|
496
703
|
_busClient;
|
|
497
|
-
|
|
704
|
+
_busHost;
|
|
498
705
|
get discoverCache() {
|
|
499
706
|
const config = this.discoverCacheConfig;
|
|
500
|
-
this._discoverCache = this._discoverCache ?? new
|
|
707
|
+
this._discoverCache = this._discoverCache ?? new import_lru_cache3.LRUCache({
|
|
501
708
|
ttlAutopurge: true,
|
|
502
709
|
...config
|
|
503
710
|
});
|
|
@@ -558,7 +765,7 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
|
|
|
558
765
|
};
|
|
559
766
|
const boundQuery = await this.bindQuery(queryPayload);
|
|
560
767
|
const manifest = (0, import_assert4.assertEx)(await this.targetQuery(addressToCall, boundQuery[0], boundQuery[1]), () => `Unable to resolve [${address}]`)[1];
|
|
561
|
-
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");
|
|
562
769
|
}
|
|
563
770
|
targetQueries(address) {
|
|
564
771
|
if (!this.connected)
|
|
@@ -578,32 +785,30 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
|
|
|
578
785
|
busClient() {
|
|
579
786
|
if (!this._busClient) {
|
|
580
787
|
this._busClient = new AsyncQueryBusClient({
|
|
581
|
-
config: this.config,
|
|
788
|
+
config: this.config.client,
|
|
582
789
|
logger: this.logger,
|
|
583
790
|
resolver: this
|
|
584
791
|
});
|
|
585
792
|
}
|
|
586
793
|
return this._busClient;
|
|
587
794
|
}
|
|
588
|
-
|
|
589
|
-
if (!this.
|
|
590
|
-
this.
|
|
591
|
-
config: this.config,
|
|
795
|
+
busHost() {
|
|
796
|
+
if (!this._busHost) {
|
|
797
|
+
this._busHost = new AsyncQueryBusHost({
|
|
798
|
+
config: this.config.host,
|
|
592
799
|
logger: this.logger,
|
|
593
800
|
resolver: this
|
|
594
801
|
});
|
|
595
802
|
}
|
|
596
|
-
return this.
|
|
803
|
+
return this._busHost;
|
|
597
804
|
}
|
|
598
805
|
async startHandler() {
|
|
599
806
|
await Promise.resolve(this.connect());
|
|
600
|
-
this.
|
|
601
|
-
this.busClient().start();
|
|
807
|
+
this.busHost().start();
|
|
602
808
|
return true;
|
|
603
809
|
}
|
|
604
810
|
stopHandler(_timeout) {
|
|
605
|
-
this.
|
|
606
|
-
this.busServer().stop();
|
|
811
|
+
this.busHost().stop();
|
|
607
812
|
return true;
|
|
608
813
|
}
|
|
609
814
|
};
|