@xyo-network/bridge-http 2.105.1 → 2.106.0-rc.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/HttpBridgeBase.d.cts +4 -1
- package/dist/browser/HttpBridgeBase.d.cts.map +1 -1
- package/dist/browser/HttpBridgeBase.d.mts +4 -1
- package/dist/browser/HttpBridgeBase.d.mts.map +1 -1
- package/dist/browser/HttpBridgeBase.d.ts +4 -1
- package/dist/browser/HttpBridgeBase.d.ts.map +1 -1
- package/dist/browser/HttpBridgeModuleResolver.d.cts +18 -2
- package/dist/browser/HttpBridgeModuleResolver.d.cts.map +1 -1
- package/dist/browser/HttpBridgeModuleResolver.d.mts +18 -2
- package/dist/browser/HttpBridgeModuleResolver.d.mts.map +1 -1
- package/dist/browser/HttpBridgeModuleResolver.d.ts +18 -2
- package/dist/browser/HttpBridgeModuleResolver.d.ts.map +1 -1
- package/dist/browser/ModuleProxy/ModuleProxy.d.cts +9 -1
- package/dist/browser/ModuleProxy/ModuleProxy.d.cts.map +1 -1
- package/dist/browser/ModuleProxy/ModuleProxy.d.mts +9 -1
- package/dist/browser/ModuleProxy/ModuleProxy.d.mts.map +1 -1
- package/dist/browser/ModuleProxy/ModuleProxy.d.ts +9 -1
- package/dist/browser/ModuleProxy/ModuleProxy.d.ts.map +1 -1
- package/dist/browser/index-browser.cjs +132 -60
- package/dist/browser/index-browser.cjs.map +1 -1
- package/dist/browser/index-browser.js +127 -55
- package/dist/browser/index-browser.js.map +1 -1
- package/dist/neutral/HttpBridgeBase.d.cts +4 -1
- package/dist/neutral/HttpBridgeBase.d.cts.map +1 -1
- package/dist/neutral/HttpBridgeBase.d.mts +4 -1
- package/dist/neutral/HttpBridgeBase.d.mts.map +1 -1
- package/dist/neutral/HttpBridgeBase.d.ts +4 -1
- package/dist/neutral/HttpBridgeBase.d.ts.map +1 -1
- package/dist/neutral/HttpBridgeModuleResolver.d.cts +18 -2
- package/dist/neutral/HttpBridgeModuleResolver.d.cts.map +1 -1
- package/dist/neutral/HttpBridgeModuleResolver.d.mts +18 -2
- package/dist/neutral/HttpBridgeModuleResolver.d.mts.map +1 -1
- package/dist/neutral/HttpBridgeModuleResolver.d.ts +18 -2
- package/dist/neutral/HttpBridgeModuleResolver.d.ts.map +1 -1
- package/dist/neutral/ModuleProxy/ModuleProxy.d.cts +9 -1
- package/dist/neutral/ModuleProxy/ModuleProxy.d.cts.map +1 -1
- package/dist/neutral/ModuleProxy/ModuleProxy.d.mts +9 -1
- package/dist/neutral/ModuleProxy/ModuleProxy.d.mts.map +1 -1
- package/dist/neutral/ModuleProxy/ModuleProxy.d.ts +9 -1
- package/dist/neutral/ModuleProxy/ModuleProxy.d.ts.map +1 -1
- package/dist/neutral/index-browser.cjs +132 -60
- package/dist/neutral/index-browser.cjs.map +1 -1
- package/dist/neutral/index-browser.js +127 -55
- package/dist/neutral/index-browser.js.map +1 -1
- package/dist/node/HttpBridgeBase.d.cts +4 -1
- package/dist/node/HttpBridgeBase.d.cts.map +1 -1
- package/dist/node/HttpBridgeBase.d.mts +4 -1
- package/dist/node/HttpBridgeBase.d.mts.map +1 -1
- package/dist/node/HttpBridgeBase.d.ts +4 -1
- package/dist/node/HttpBridgeBase.d.ts.map +1 -1
- package/dist/node/HttpBridgeModuleResolver.d.cts +18 -2
- package/dist/node/HttpBridgeModuleResolver.d.cts.map +1 -1
- package/dist/node/HttpBridgeModuleResolver.d.mts +18 -2
- package/dist/node/HttpBridgeModuleResolver.d.mts.map +1 -1
- package/dist/node/HttpBridgeModuleResolver.d.ts +18 -2
- package/dist/node/HttpBridgeModuleResolver.d.ts.map +1 -1
- package/dist/node/ModuleProxy/ModuleProxy.d.cts +9 -1
- package/dist/node/ModuleProxy/ModuleProxy.d.cts.map +1 -1
- package/dist/node/ModuleProxy/ModuleProxy.d.mts +9 -1
- package/dist/node/ModuleProxy/ModuleProxy.d.mts.map +1 -1
- package/dist/node/ModuleProxy/ModuleProxy.d.ts +9 -1
- package/dist/node/ModuleProxy/ModuleProxy.d.ts.map +1 -1
- package/dist/node/index.cjs +145 -72
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +139 -66
- package/dist/node/index.js.map +1 -1
- package/package.json +24 -20
- package/src/HttpBridgeBase.ts +52 -5
- package/src/HttpBridgeModuleResolver.ts +42 -35
- package/src/ModuleProxy/ModuleProxy.ts +68 -2
|
@@ -5,33 +5,39 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
5
5
|
import { creatableModule as creatableModule2 } from "@xyo-network/module-model";
|
|
6
6
|
|
|
7
7
|
// src/HttpBridgeBase.ts
|
|
8
|
-
import { assertEx as
|
|
8
|
+
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
9
9
|
import { AxiosJson } from "@xylabs/axios";
|
|
10
|
-
import { exists } from "@xylabs/exists";
|
|
10
|
+
import { exists as exists2 } from "@xylabs/exists";
|
|
11
11
|
import { forget as forget2 } from "@xylabs/forget";
|
|
12
12
|
import { toJsonString } from "@xylabs/object";
|
|
13
13
|
import { AbstractBridge } from "@xyo-network/bridge-abstract";
|
|
14
14
|
import { NodeManifestPayloadSchema } from "@xyo-network/manifest-model";
|
|
15
|
-
import { creatableModule, ModuleStateQuerySchema } from "@xyo-network/module-model";
|
|
15
|
+
import { creatableModule, ModuleStateQuerySchema, ResolveHelper as ResolveHelper3 } from "@xyo-network/module-model";
|
|
16
16
|
import { asAttachableNodeInstance } from "@xyo-network/node-model";
|
|
17
17
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
18
|
-
import { Mutex, Semaphore } from "async-mutex";
|
|
19
|
-
import { LRUCache } from "lru-cache";
|
|
18
|
+
import { Mutex as Mutex2, Semaphore } from "async-mutex";
|
|
19
|
+
import { LRUCache as LRUCache2 } from "lru-cache";
|
|
20
20
|
|
|
21
21
|
// src/HttpBridgeConfig.ts
|
|
22
22
|
var HttpBridgeConfigSchema = "network.xyo.bridge.http.config";
|
|
23
23
|
|
|
24
24
|
// src/HttpBridgeModuleResolver.ts
|
|
25
|
-
import { assertEx } from "@xylabs/assert";
|
|
26
|
-
import { isAddress } from "@xylabs/hex";
|
|
25
|
+
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
26
|
+
import { isAddress as isAddress2 } from "@xylabs/hex";
|
|
27
27
|
import { Account } from "@xyo-network/account";
|
|
28
28
|
import { AbstractBridgeModuleResolver, wrapModuleWithType } from "@xyo-network/bridge-abstract";
|
|
29
29
|
import { ConfigSchema } from "@xyo-network/config-payload-plugin";
|
|
30
|
-
import { asModuleInstance, ModuleConfigSchema, ResolveHelper } from "@xyo-network/module-model";
|
|
30
|
+
import { asModuleInstance, ModuleConfigSchema, ResolveHelper as ResolveHelper2 } from "@xyo-network/module-model";
|
|
31
|
+
import { Mutex } from "async-mutex";
|
|
32
|
+
import { LRUCache } from "lru-cache";
|
|
31
33
|
|
|
32
34
|
// src/ModuleProxy/ModuleProxy.ts
|
|
35
|
+
import { assertEx } from "@xylabs/assert";
|
|
36
|
+
import { exists } from "@xylabs/exists";
|
|
33
37
|
import { forget } from "@xylabs/forget";
|
|
38
|
+
import { isAddress } from "@xylabs/hex";
|
|
34
39
|
import { AbstractModuleProxy } from "@xyo-network/bridge-abstract";
|
|
40
|
+
import { ResolveHelper } from "@xyo-network/module-model";
|
|
35
41
|
var HttpModuleProxy = class _HttpModuleProxy extends AbstractModuleProxy {
|
|
36
42
|
static {
|
|
37
43
|
__name(this, "HttpModuleProxy");
|
|
@@ -57,6 +63,40 @@ var HttpModuleProxy = class _HttpModuleProxy extends AbstractModuleProxy {
|
|
|
57
63
|
}
|
|
58
64
|
return result;
|
|
59
65
|
}
|
|
66
|
+
async publicChildren() {
|
|
67
|
+
return (await Promise.all(Object.values(await this.childAddressMap()).filter(exists).map((address) => this.resolve(address)))).filter(exists);
|
|
68
|
+
}
|
|
69
|
+
async resolve(idOrFilter = "*", options = {}) {
|
|
70
|
+
const config = {
|
|
71
|
+
address: this.address,
|
|
72
|
+
dead: this.dead,
|
|
73
|
+
downResolver: this.downResolver,
|
|
74
|
+
logger: this.logger,
|
|
75
|
+
module: this,
|
|
76
|
+
transformers: this.moduleIdentifierTransformers,
|
|
77
|
+
upResolver: this.upResolver
|
|
78
|
+
};
|
|
79
|
+
if (idOrFilter === "*") {
|
|
80
|
+
return await this.publicChildren();
|
|
81
|
+
}
|
|
82
|
+
switch (typeof idOrFilter) {
|
|
83
|
+
case "string": {
|
|
84
|
+
const parts = idOrFilter.split(":");
|
|
85
|
+
const first = assertEx(parts.shift(), () => "Missing first");
|
|
86
|
+
const remainingPath = parts.join(":");
|
|
87
|
+
const address = isAddress(first) ? first : this.id === first ? this.address : this.childAddressByName(first);
|
|
88
|
+
if (!address) return void 0;
|
|
89
|
+
const firstInstance = await this.params.host.resolve(address);
|
|
90
|
+
return remainingPath ? await firstInstance?.resolve(remainingPath) : firstInstance;
|
|
91
|
+
}
|
|
92
|
+
case "object": {
|
|
93
|
+
return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address);
|
|
94
|
+
}
|
|
95
|
+
default: {
|
|
96
|
+
return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
60
100
|
};
|
|
61
101
|
|
|
62
102
|
// src/HttpBridgeModuleResolver.ts
|
|
@@ -64,63 +104,69 @@ var HttpBridgeModuleResolver = class extends AbstractBridgeModuleResolver {
|
|
|
64
104
|
static {
|
|
65
105
|
__name(this, "HttpBridgeModuleResolver");
|
|
66
106
|
}
|
|
107
|
+
_resolvedCache = new LRUCache({
|
|
108
|
+
max: 1e3
|
|
109
|
+
});
|
|
110
|
+
_resolvedCacheMutex = new Mutex();
|
|
67
111
|
get querySender() {
|
|
68
112
|
return this.params.querySender;
|
|
69
113
|
}
|
|
70
114
|
moduleUrl(address) {
|
|
71
115
|
return new URL(address, this.params.rootUrl);
|
|
72
116
|
}
|
|
73
|
-
async resolveHandler(id, options) {
|
|
117
|
+
async resolveHandler(id, options, params) {
|
|
74
118
|
const parentResult = await super.resolveHandler(id, options);
|
|
75
119
|
if (parentResult.length > 0) {
|
|
76
120
|
return parentResult;
|
|
77
121
|
}
|
|
78
|
-
if (id === "*") {
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
122
|
const idParts = id.split(":");
|
|
82
|
-
const untransformedFirstPart =
|
|
83
|
-
const firstPart = await
|
|
84
|
-
|
|
85
|
-
assertEx(isAddress(firstPart), () => `Invalid module address: ${firstPart}`);
|
|
123
|
+
const untransformedFirstPart = assertEx2(idParts.shift(), () => "Missing module identifier");
|
|
124
|
+
const firstPart = await ResolveHelper2.transformModuleIdentifier(untransformedFirstPart);
|
|
125
|
+
assertEx2(isAddress2(firstPart), () => `Invalid module address: ${firstPart}`);
|
|
86
126
|
const remainderParts = idParts.join(":");
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
127
|
+
const instance = await this._resolvedCacheMutex.runExclusive(async () => {
|
|
128
|
+
const cachedMod = this._resolvedCache.get(firstPart);
|
|
129
|
+
if (cachedMod) {
|
|
130
|
+
const result2 = idParts.length <= 0 ? cachedMod : cachedMod.resolve(remainderParts, {
|
|
131
|
+
...options,
|
|
132
|
+
maxDepth: (options?.maxDepth ?? 5) - 1
|
|
133
|
+
});
|
|
134
|
+
return result2;
|
|
135
|
+
}
|
|
136
|
+
const account = Account.randomSync();
|
|
137
|
+
const finalParams = {
|
|
138
|
+
account,
|
|
139
|
+
archiving: this.params.archiving,
|
|
140
|
+
config: {
|
|
141
|
+
schema: ModuleConfigSchema
|
|
142
|
+
},
|
|
143
|
+
host: this,
|
|
144
|
+
moduleAddress: firstPart,
|
|
145
|
+
onQuerySendFinished: this.params.onQuerySendFinished,
|
|
146
|
+
onQuerySendStarted: this.params.onQuerySendStarted,
|
|
147
|
+
querySender: this.params.querySender,
|
|
148
|
+
...params
|
|
149
|
+
};
|
|
150
|
+
this.logger?.debug(`creating HttpProxy [${firstPart}] ${id}`);
|
|
151
|
+
console.log(`creating HttpProxy [${firstPart}] ${id}`);
|
|
152
|
+
const proxy = new HttpModuleProxy(finalParams);
|
|
103
153
|
const state = await proxy.state();
|
|
104
154
|
if (state) {
|
|
105
155
|
const configSchema = state.find((payload) => payload.schema === ConfigSchema)?.config;
|
|
106
|
-
const config =
|
|
156
|
+
const config = assertEx2(state.find((payload) => payload.schema === configSchema), () => "Unable to locate config");
|
|
107
157
|
proxy.setConfig(config);
|
|
108
158
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
return [
|
|
122
|
-
instance
|
|
123
|
-
];
|
|
159
|
+
console.log(`created HttpProxy [${firstPart}] ${proxy.id}`);
|
|
160
|
+
await proxy.start?.();
|
|
161
|
+
const wrapped = wrapModuleWithType(proxy, account);
|
|
162
|
+
assertEx2(asModuleInstance(wrapped, {}), () => `Failed to asModuleInstance [${id}]`);
|
|
163
|
+
this._resolvedCache.set(wrapped.address, wrapped);
|
|
164
|
+
return wrapped;
|
|
165
|
+
});
|
|
166
|
+
const result = remainderParts.length > 0 ? await instance.resolve(remainderParts, options) : instance;
|
|
167
|
+
return result ? [
|
|
168
|
+
result
|
|
169
|
+
] : [];
|
|
124
170
|
}
|
|
125
171
|
};
|
|
126
172
|
|
|
@@ -147,8 +193,8 @@ var HttpBridgeBase = class _HttpBridgeBase extends AbstractBridge {
|
|
|
147
193
|
static defaultMaxPayloadSizeWarning = 256 * 256;
|
|
148
194
|
static maxFailureCacheSize = 1e3;
|
|
149
195
|
_axios;
|
|
150
|
-
_discoverRootsMutex = new
|
|
151
|
-
_failureTimeCache = new
|
|
196
|
+
_discoverRootsMutex = new Mutex2();
|
|
197
|
+
_failureTimeCache = new LRUCache2({
|
|
152
198
|
max: _HttpBridgeBase.maxFailureCacheSize
|
|
153
199
|
});
|
|
154
200
|
_querySemaphore;
|
|
@@ -158,7 +204,7 @@ var HttpBridgeBase = class _HttpBridgeBase extends AbstractBridge {
|
|
|
158
204
|
return this._axios;
|
|
159
205
|
}
|
|
160
206
|
get clientUrl() {
|
|
161
|
-
return
|
|
207
|
+
return assertEx3(this.config.client?.url ?? this.config.nodeUrl, () => "No Url Set");
|
|
162
208
|
}
|
|
163
209
|
get failureRetryTime() {
|
|
164
210
|
return this.config.failureRetryTime ?? _HttpBridgeBase.defaultFailureRetryTime;
|
|
@@ -200,6 +246,23 @@ var HttpBridgeBase = class _HttpBridgeBase extends AbstractBridge {
|
|
|
200
246
|
});
|
|
201
247
|
return this._resolver;
|
|
202
248
|
}
|
|
249
|
+
async connect(id) {
|
|
250
|
+
const transformedId = assertEx3(await ResolveHelper3.transformModuleIdentifier(id), () => `Unable to transform module identifier: ${id}`);
|
|
251
|
+
const existingInstance = await this.resolve(transformedId);
|
|
252
|
+
if (existingInstance) {
|
|
253
|
+
return existingInstance.address;
|
|
254
|
+
}
|
|
255
|
+
const [instance] = await this.resolver.resolveHandler(id);
|
|
256
|
+
return this.connectInstance(instance);
|
|
257
|
+
}
|
|
258
|
+
async disconnect(id) {
|
|
259
|
+
const transformedId = assertEx3(await ResolveHelper3.transformModuleIdentifier(id), () => `Unable to transform module identifier: ${id}`);
|
|
260
|
+
const instance = await this.resolve(transformedId);
|
|
261
|
+
if (instance) {
|
|
262
|
+
this.downResolver.remove(instance.address);
|
|
263
|
+
return instance.address;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
203
266
|
exposeHandler(_id, _options) {
|
|
204
267
|
throw new Error("Unsupported");
|
|
205
268
|
}
|
|
@@ -213,7 +276,7 @@ var HttpBridgeBase = class _HttpBridgeBase extends AbstractBridge {
|
|
|
213
276
|
this.logger?.debug(`HttpBridge:discoverRoots.state [${state?.length}]`);
|
|
214
277
|
const nodeManifest = state?.find(isPayloadOfSchemaType(NodeManifestPayloadSchema));
|
|
215
278
|
if (nodeManifest) {
|
|
216
|
-
const mods = (await this.resolveRootNode(nodeManifest)).filter(
|
|
279
|
+
const mods = (await this.resolveRootNode(nodeManifest)).filter(exists2);
|
|
217
280
|
this.logger?.debug(`HttpBridge:discoverRoots [${mods.length}]`);
|
|
218
281
|
this._roots = mods;
|
|
219
282
|
} else {
|
|
@@ -269,6 +332,13 @@ var HttpBridgeBase = class _HttpBridgeBase extends AbstractBridge {
|
|
|
269
332
|
unexposeHandler(_id, _options) {
|
|
270
333
|
throw new Error("Unsupported");
|
|
271
334
|
}
|
|
335
|
+
connectInstance(instance) {
|
|
336
|
+
if (instance) {
|
|
337
|
+
this.downResolver.add(instance);
|
|
338
|
+
this.logger?.log(`Connect: ${instance.id}`);
|
|
339
|
+
return instance.address;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
272
342
|
async getRootState() {
|
|
273
343
|
const queryPayload = {
|
|
274
344
|
schema: ModuleStateQuerySchema
|
|
@@ -290,12 +360,14 @@ var HttpBridgeBase = class _HttpBridgeBase extends AbstractBridge {
|
|
|
290
360
|
}
|
|
291
361
|
}
|
|
292
362
|
async resolveRootNode(nodeManifest) {
|
|
293
|
-
const rootModule =
|
|
294
|
-
|
|
363
|
+
const rootModule = assertEx3((await this.resolver.resolveHandler(assertEx3(nodeManifest.status?.address, () => "Root has no address"), void 0, {
|
|
364
|
+
manifest: nodeManifest
|
|
365
|
+
})).at(0), () => `Root not found [${nodeManifest.status?.address}]`);
|
|
366
|
+
assertEx3(rootModule.constructor.name !== "HttpModuleProxy", () => "rootModule is not a Wrapper");
|
|
295
367
|
const rootNode = asAttachableNodeInstance(rootModule, "Root modules is not a node");
|
|
296
368
|
if (rootNode) {
|
|
297
369
|
this.logger.debug(`rootNode: ${rootNode.id}`);
|
|
298
|
-
this.
|
|
370
|
+
this.connectInstance(rootNode);
|
|
299
371
|
return [
|
|
300
372
|
rootNode
|
|
301
373
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/HttpBridgeClientOnly.ts","../../src/HttpBridgeBase.ts","../../src/HttpBridgeConfig.ts","../../src/HttpBridgeModuleResolver.ts","../../src/ModuleProxy/ModuleProxy.ts"],"sourcesContent":["import { BridgeParams } from '@xyo-network/bridge-model'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\n\nimport { HttpBridgeBase } from './HttpBridgeBase'\nimport { HttpBridgeConfig } from './HttpBridgeConfig'\n\nexport interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}\n\n@creatableModule()\nexport class HttpBridge<TParams extends HttpBridgeParams> extends HttpBridgeBase<TParams> {}\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosError, AxiosJson } from '@xylabs/axios'\nimport { exists } from '@xylabs/exists'\nimport { forget } from '@xylabs/forget'\nimport { Address } from '@xylabs/hex'\nimport { toJsonString } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\nimport { ApiEnvelope } from '@xyo-network/api-models'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractBridge } from '@xyo-network/bridge-abstract'\nimport {\n BridgeExposeOptions,\n BridgeModule,\n BridgeParams,\n BridgeUnexposeOptions,\n QuerySendFinishedEventArgs,\n QuerySendStartedEventArgs,\n} from '@xyo-network/bridge-model'\nimport { NodeManifestPayload, NodeManifestPayloadSchema } from '@xyo-network/manifest-model'\nimport {\n AnyConfigSchema,\n creatableModule,\n ModuleInstance,\n ModuleQueryResult,\n ModuleResolverInstance,\n ModuleStateQuery,\n ModuleStateQuerySchema,\n} from '@xyo-network/module-model'\nimport { asAttachableNodeInstance } from '@xyo-network/node-model'\nimport { isPayloadOfSchemaType, Payload, Schema, WithMeta } from '@xyo-network/payload-model'\nimport { Mutex, Semaphore } from 'async-mutex'\nimport { LRUCache } from 'lru-cache'\n\nimport { HttpBridgeConfig, HttpBridgeConfigSchema } from './HttpBridgeConfig'\nimport { HttpBridgeModuleResolver } from './HttpBridgeModuleResolver'\nimport { BridgeQuerySender } from './ModuleProxy'\n\nexport interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {\n axios?: AxiosJson\n}\n\n@creatableModule()\nexport class HttpBridgeBase<TParams extends HttpBridgeParams> extends AbstractBridge<TParams> implements BridgeModule<TParams>, BridgeQuerySender {\n static axios = new AxiosJson()\n static override readonly configSchemas: Schema[] = [...super.configSchemas, HttpBridgeConfigSchema]\n static override readonly defaultConfigSchema: Schema = HttpBridgeConfigSchema\n static defaultFailureRetryTime = 1000 * 60\n static defaultMaxConnections = 4\n static defaultMaxPayloadSizeWarning = 256 * 256\n static maxFailureCacheSize = 1000\n\n private _axios?: AxiosJson\n private _discoverRootsMutex = new Mutex()\n private _failureTimeCache = new LRUCache<Address, number>({ max: HttpBridgeBase.maxFailureCacheSize })\n private _querySemaphore?: Semaphore\n private _resolver?: HttpBridgeModuleResolver\n\n get axios() {\n this._axios = this._axios ?? this.params.axios ?? HttpBridgeBase.axios\n return this._axios\n }\n\n get clientUrl() {\n // eslint-disable-next-line deprecation/deprecation\n return assertEx(this.config.client?.url ?? this.config.nodeUrl, () => 'No Url Set')\n }\n\n get failureRetryTime() {\n return this.config.failureRetryTime ?? HttpBridgeBase.defaultFailureRetryTime\n }\n\n get maxConnections() {\n return this.config.maxConnections ?? HttpBridgeBase.defaultMaxConnections\n }\n\n get maxPayloadSizeWarning() {\n return this.config.maxPayloadSizeWarning ?? HttpBridgeBase.defaultMaxPayloadSizeWarning\n }\n\n get querySemaphore() {\n this._querySemaphore = this._querySemaphore ?? new Semaphore(this.maxConnections)\n return this._querySemaphore\n }\n\n override get resolver() {\n this._resolver =\n this._resolver ??\n new HttpBridgeModuleResolver({\n additionalSigners: this.additionalSigners,\n archiving: { ...this.archiving, resolveArchivists: this.resolveArchivingArchivists.bind(this) },\n bridge: this,\n onQuerySendFinished: (args: Omit<QuerySendFinishedEventArgs, 'module'>) => {\n forget(this.emit('querySendFinished', { module: this, ...args }))\n },\n onQuerySendStarted: (args: Omit<QuerySendStartedEventArgs, 'module'>) => {\n forget(this.emit('querySendStarted', { module: this, ...args }))\n },\n querySender: this,\n root: this,\n rootUrl: this.clientUrl,\n wrapperAccount: this.account,\n })\n return this._resolver\n }\n\n override exposeHandler(_id: string, _options?: BridgeExposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n override exposedHandler(): Promisable<Address[]> {\n throw new Error('Unsupported')\n }\n\n async getRoots(force?: boolean): Promise<ModuleInstance[]> {\n return await this._discoverRootsMutex.runExclusive(async () => {\n if (this._roots === undefined || force) {\n const state = await this.getRootState()\n this.logger?.debug(`HttpBridge:discoverRoots.state [${state?.length}]`)\n const nodeManifest = state?.find(isPayloadOfSchemaType<WithMeta<NodeManifestPayload>>(NodeManifestPayloadSchema))\n if (nodeManifest) {\n const mods = (await this.resolveRootNode(nodeManifest)).filter(exists)\n this.logger?.debug(`HttpBridge:discoverRoots [${mods.length}]`)\n this._roots = mods\n } else {\n this._roots = []\n }\n }\n return this._roots\n })\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.clientUrl)\n }\n\n async sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ): Promise<ModuleQueryResult<TOut>> {\n const lastFailureTime = this._failureTimeCache.get(targetAddress)\n if (lastFailureTime !== undefined) {\n const now = Date.now()\n const timeSincePreviousFailure = now - lastFailureTime\n if (timeSincePreviousFailure > this.failureRetryTime) {\n throw new Error(`target module failed recently [${targetAddress}] [${timeSincePreviousFailure}ms ago]`)\n }\n this._failureTimeCache.delete(targetAddress)\n }\n try {\n await this.querySemaphore.acquire()\n const payloadSize = JSON.stringify([query, payloads]).length\n if (payloadSize > this.maxPayloadSizeWarning) {\n this.logger?.warn(\n `Large targetQuery being sent: ${payloadSize} bytes [${this.address}][${this.moduleAddress}] [${query.schema}] [${payloads?.length}]`,\n )\n }\n const moduleUrl = this.moduleUrl(targetAddress).href\n const result = await this.axios.post<ApiEnvelope<ModuleQueryResult<TOut>>>(moduleUrl, [query, payloads])\n if (result.status === 404) {\n throw `target module not found [${moduleUrl}] [${result.status}]`\n }\n if (result.status >= 400) {\n this.logger?.error(`targetQuery failed [${moduleUrl}]`)\n throw `targetQuery failed [${moduleUrl}] [${result.status}]`\n }\n return result.data?.data\n } catch (ex) {\n const error = ex as AxiosError\n this.logger?.error(`Error: ${toJsonString(error)}`)\n throw error\n } finally {\n this.querySemaphore.release()\n }\n }\n\n override unexposeHandler(_id: string, _options?: BridgeUnexposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n private async getRootState() {\n const queryPayload: ModuleStateQuery = { schema: ModuleStateQuerySchema }\n const boundQuery = await this.bindQuery(queryPayload)\n try {\n const response = await this.axios.post<ApiEnvelope<ModuleQueryResult>>(this.clientUrl.toString(), boundQuery)\n if (response.status === 404) {\n return []\n }\n const [, payloads, errors] = response.data.data\n if (errors.length > 0) {\n throw new Error(`getRootState failed: ${JSON.stringify(errors, null, 2)}`)\n }\n return payloads\n } catch (ex) {\n const error = ex as Error\n this.logger?.warn(`Unable to connect to remote node: ${error.message} [${this.clientUrl}]`)\n }\n }\n\n private async resolveRootNode(nodeManifest: NodeManifestPayload): Promise<ModuleInstance[]> {\n const rootModule = assertEx(\n (await this.resolver.resolveHandler(assertEx(nodeManifest.status?.address, () => 'Root has no address'))).at(0),\n () => `Root not found [${nodeManifest.status?.address}]`,\n )\n assertEx(rootModule.constructor.name !== 'HttpModuleProxy', () => 'rootModule is not a Wrapper')\n const rootNode = asAttachableNodeInstance(rootModule, 'Root modules is not a node')\n if (rootNode) {\n this.logger.debug(`rootNode: ${rootNode.id}`)\n this.downResolver.addResolver(rootNode as unknown as ModuleResolverInstance)\n return [rootNode]\n }\n return []\n }\n}\n","import { EmptyObject } from '@xylabs/object'\nimport { BridgeConfig } from '@xyo-network/bridge-model'\n\nexport type HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\nexport const HttpBridgeConfigSchema: HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\n\nexport type HttpBridgeConfig<TConfig extends EmptyObject = EmptyObject, TSchema extends string | void = void> = BridgeConfig<\n {\n client?: BridgeConfig['client'] & {\n url: string\n }\n failureRetryTime?: number\n failureTimeCacheMax?: number\n host?: {\n port: number\n }\n maxConnections?: number\n maxPayloadSizeWarning?: number\n /** @deprecated use client.url instead */\n nodeUrl?: string\n schema: HttpBridgeConfigSchema\n } & TConfig,\n TSchema extends string ? TSchema : HttpBridgeConfigSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport { Address, isAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport { AbstractBridgeModuleResolver, BridgeModuleResolverParams, wrapModuleWithType } from '@xyo-network/bridge-abstract'\nimport { ConfigPayload, ConfigSchema } from '@xyo-network/config-payload-plugin'\nimport {\n asModuleInstance,\n ModuleConfig,\n ModuleConfigSchema,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ResolveHelper,\n} from '@xyo-network/module-model'\n\nimport { BridgeQuerySender, HttpModuleProxy, HttpModuleProxyParams } from './ModuleProxy'\n\nexport interface HttpBridgeModuleResolverParams extends BridgeModuleResolverParams {\n querySender: BridgeQuerySender\n rootUrl: string\n}\n\nexport class HttpBridgeModuleResolver<\n T extends HttpBridgeModuleResolverParams = HttpBridgeModuleResolverParams,\n> extends AbstractBridgeModuleResolver<T> {\n get querySender() {\n return this.params.querySender\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.params.rootUrl)\n }\n\n override async resolveHandler<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T[]> {\n const parentResult = await super.resolveHandler(id, options)\n if (parentResult.length > 0) {\n return parentResult\n }\n if (id === '*') {\n return []\n }\n const idParts = id.split(':')\n const untransformedFirstPart = assertEx(idParts.shift(), () => `Invalid module identifier: ${id}`)\n const firstPart = await ResolveHelper.transformModuleIdentifier(untransformedFirstPart)\n const moduleAddress = firstPart as Address\n assertEx(isAddress(firstPart), () => `Invalid module address: ${firstPart}`)\n const remainderParts = idParts.join(':')\n const params: HttpModuleProxyParams = {\n account: Account.randomSync(),\n additionalSigners: this.params.additionalSigners,\n archiving: this.params.archiving,\n config: { schema: ModuleConfigSchema },\n host: this,\n moduleAddress,\n onQuerySendFinished: this.params.onQuerySendFinished,\n onQuerySendStarted: this.params.onQuerySendStarted,\n querySender: this.querySender,\n }\n\n this.logger?.debug(`creating HttpProxy [${moduleAddress}] ${id}`)\n\n const proxy = new HttpModuleProxy<T, HttpModuleProxyParams>(params)\n //calling state here to get the config\n if (proxy) {\n const state = await proxy.state()\n if (state) {\n const configSchema = (state.find((payload) => payload.schema === ConfigSchema) as ConfigPayload | undefined)?.config\n const config = assertEx(\n state.find((payload) => payload.schema === configSchema),\n () => 'Unable to locate config',\n ) as ModuleConfig\n proxy.setConfig(config)\n }\n }\n\n await proxy.start()\n\n const wrapped = assertEx(wrapModuleWithType(proxy, Account.randomSync()) as unknown as T, () => `Failed to wrapModuleWithType [${id}]`)\n const instance = assertEx(asModuleInstance<T>(wrapped, {}), () => `Failed to asModuleInstance [${id}]`)\n proxy.upResolver.add(instance)\n proxy.downResolver.add(instance)\n\n if (remainderParts.length > 0) {\n const result = await wrapped.resolve<T>(remainderParts, options)\n return result ? [result] : []\n }\n\n //console.log(`resolved: ${proxy.address} [${wrapped.constructor.name}] [${as.constructor.name}]`)\n return [instance]\n }\n}\n","import { forget } from '@xylabs/forget'\nimport { Address } from '@xylabs/hex'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractModuleProxy, ModuleProxyParams } from '@xyo-network/bridge-abstract'\nimport { AttachableModuleInstance, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport interface BridgeQuerySender {\n sendBridgeQuery: <TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ) => Promise<ModuleQueryResult<TOut>>\n}\n\nexport type HttpModuleProxyParams = ModuleProxyParams & {\n querySender: BridgeQuerySender\n}\n\nexport class HttpModuleProxy<\n TWrappedModule extends ModuleInstance = ModuleInstance,\n TParams extends Omit<HttpModuleProxyParams, 'config'> & { config: TWrappedModule['config'] } = Omit<HttpModuleProxyParams, 'config'> & {\n config: TWrappedModule['config']\n },\n >\n extends AbstractModuleProxy<TWrappedModule, TParams>\n implements AttachableModuleInstance<TParams, TWrappedModule['eventData']>\n{\n static createCount = 0\n\n constructor(params: TParams) {\n HttpModuleProxy.createCount = HttpModuleProxy.createCount + 1\n if (Math.floor(HttpModuleProxy.createCount / 10) === HttpModuleProxy.createCount / 10) {\n console.log(`HttpModuleProxy.createCount: ${HttpModuleProxy.createCount}`)\n }\n super(params)\n }\n\n async proxyQueryHandler<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads: Payload[] = []): Promise<ModuleQueryResult> {\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists([query, ...(payloads ?? [])]))\n }\n const result = await this.params.querySender.sendBridgeQuery(this.params.moduleAddress, query, payloads)\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists(result.flat()))\n }\n return result\n }\n}\n"],"mappings":";;;;AACA,SAA0BA,mBAAAA,wBAAuB;;;ACDjD,SAASC,YAAAA,iBAAgB;AACzB,SAAqBC,iBAAiB;AACtC,SAASC,cAAc;AACvB,SAASC,UAAAA,eAAc;AAEvB,SAASC,oBAAoB;AAI7B,SAASC,s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C,aAAaC,YAAYJ,QAAAA;AAC9B,aAAO;QAACA;;IACV;AACA,WAAO,CAAA;EACT;AACF;AA3KapH,iBAAAA,aAAAA;EADZyH,gBAAAA;GACYzH,cAAAA;;;;;;;;;;ADjCN,IAAM0H,aAAN,cAA2DC,eAAAA;SAAAA;;;AAAyB;AAA9ED,aAAAA,cAAAA;EADZE,iBAAAA;GACYF,UAAAA;","names":["creatableModule","assertEx","AxiosJson","exists","forget","toJsonString","AbstractBridge","NodeManifestPayloadSchema","creatableModule","ModuleStateQuerySchema","asAttachableNodeInstance","isPayloadOfSchemaType","Mutex","Semaphore","LRUCache","HttpBridgeConfigSchema","assertEx","isAddress","Account","AbstractBridgeModuleResolver","wrapModuleWithType","ConfigSchema","asModuleInstance","ModuleConfigSchema","ResolveHelper","forget","AbstractModuleProxy","HttpModuleProxy","AbstractModuleProxy","createCount","constructor","params","Math","floor","console","log","proxyQueryHandler","query","payloads","archiving","isAllowedArchivingQuery","schema","forget","storeToArchivists","result","querySender","sendBridgeQuery","moduleAddress","flat","HttpBridgeModuleResolver","AbstractBridgeModuleResolver","querySender","params","moduleUrl","address","URL","rootUrl","resolveHandler","id","options","parentResult","length","idParts","split","untransformedFirstPart","assertEx","shift","firstPart","ResolveHelper","transformModuleIdentifier","moduleAddress","isAddress","remainderParts","join","account","Account","randomSync","additionalSigners","archiving","config","schema","ModuleConfigSchema","host","onQuerySendFinished","onQuerySendStarted","logger","debug","proxy","HttpModuleProxy","state","configSchema","find","payload","ConfigSchema","setConfig","start","wrapped","wrapModuleWithType","instance","asModuleInstance","upResolver","add","downResolver","result","resolve","HttpBridgeBase","AbstractBridge","axios","AxiosJson","configSchemas","HttpBridgeConfigSchema","defaultConfigSchema","defaultFailureRetryTime","defaultMaxConnections","defaultMaxPayloadSizeWarning","maxFailureCacheSize","_axios","_discoverRootsMutex","Mutex","_failureTimeCache","LRUCache","max","_querySemaphore","_resolver","params","clientUrl","assertEx","config","client","url","nodeUrl","failureRetryTime","maxConnections","maxPayloadSizeWarning","querySemaphore","Semaphore","resolver","HttpBridgeModuleResolver","additionalSigners","archiving","resolveArchivists","resolveArchivingArchivists","bind","bridge","onQuerySendFinished","args","forget","emit","module","onQuerySendStarted","querySender","root","rootUrl","wrapperAccount","account","exposeHandler","_id","_options","Error","exposedHandler","getRoots","force","runExclusive","_roots","undefined","state","getRootState","logger","debug","length","nodeManifest","find","isPayloadOfSchemaType","NodeManifestPayloadSchema","mods","resolveRootNode","filter","exists","moduleUrl","address","URL","sendBridgeQuery","targetAddress","query","payloads","lastFailureTime","get","now","Date","timeSincePreviousFailure","delete","acquire","payloadSize","JSON","stringify","warn","moduleAddress","schema","href","result","post","status","error","data","ex","toJsonString","release","unexposeHandler","queryPayload","ModuleStateQuerySchema","boundQuery","bindQuery","response","toString","errors","message","rootModule","resolveHandler","at","constructor","name","rootNode","asAttachableNodeInstance","id","downResolver","addResolver","creatableModule","HttpBridge","HttpBridgeBase","creatableModule"]}
|
|
1
|
+
{"version":3,"sources":["../../src/HttpBridgeClientOnly.ts","../../src/HttpBridgeBase.ts","../../src/HttpBridgeConfig.ts","../../src/HttpBridgeModuleResolver.ts","../../src/ModuleProxy/ModuleProxy.ts"],"sourcesContent":["import { BridgeParams } from '@xyo-network/bridge-model'\nimport { AnyConfigSchema, creatableModule } from '@xyo-network/module-model'\n\nimport { HttpBridgeBase } from './HttpBridgeBase'\nimport { HttpBridgeConfig } from './HttpBridgeConfig'\n\nexport interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {}\n\n@creatableModule()\nexport class HttpBridge<TParams extends HttpBridgeParams> extends HttpBridgeBase<TParams> {}\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosError, AxiosJson } from '@xylabs/axios'\nimport { exists } from '@xylabs/exists'\nimport { forget } from '@xylabs/forget'\nimport { Address } from '@xylabs/hex'\nimport { toJsonString } from '@xylabs/object'\nimport { Promisable } from '@xylabs/promise'\nimport { ApiEnvelope } from '@xyo-network/api-models'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractBridge } from '@xyo-network/bridge-abstract'\nimport {\n BridgeExposeOptions,\n BridgeModule,\n BridgeParams,\n BridgeUnexposeOptions,\n QuerySendFinishedEventArgs,\n QuerySendStartedEventArgs,\n} from '@xyo-network/bridge-model'\nimport { ModuleManifestPayload, NodeManifestPayload, NodeManifestPayloadSchema } from '@xyo-network/manifest-model'\nimport {\n AnyConfigSchema,\n creatableModule,\n ModuleIdentifier,\n ModuleInstance,\n ModuleQueryResult,\n ModuleStateQuery,\n ModuleStateQuerySchema,\n ResolveHelper,\n} from '@xyo-network/module-model'\nimport { asAttachableNodeInstance } from '@xyo-network/node-model'\nimport { isPayloadOfSchemaType, Payload, Schema, WithMeta } from '@xyo-network/payload-model'\nimport { Mutex, Semaphore } from 'async-mutex'\nimport { LRUCache } from 'lru-cache'\n\nimport { HttpBridgeConfig, HttpBridgeConfigSchema } from './HttpBridgeConfig'\nimport { HttpBridgeModuleResolver } from './HttpBridgeModuleResolver'\nimport { BridgeQuerySender } from './ModuleProxy'\n\nexport interface HttpBridgeParams extends BridgeParams<AnyConfigSchema<HttpBridgeConfig>> {\n axios?: AxiosJson\n}\n\n@creatableModule()\nexport class HttpBridgeBase<TParams extends HttpBridgeParams> extends AbstractBridge<TParams> implements BridgeModule<TParams>, BridgeQuerySender {\n static axios = new AxiosJson()\n static override readonly configSchemas: Schema[] = [...super.configSchemas, HttpBridgeConfigSchema]\n static override readonly defaultConfigSchema: Schema = HttpBridgeConfigSchema\n static defaultFailureRetryTime = 1000 * 60\n static defaultMaxConnections = 4\n static defaultMaxPayloadSizeWarning = 256 * 256\n static maxFailureCacheSize = 1000\n\n private _axios?: AxiosJson\n private _discoverRootsMutex = new Mutex()\n private _failureTimeCache = new LRUCache<Address, number>({ max: HttpBridgeBase.maxFailureCacheSize })\n private _querySemaphore?: Semaphore\n private _resolver?: HttpBridgeModuleResolver\n\n get axios() {\n this._axios = this._axios ?? this.params.axios ?? HttpBridgeBase.axios\n return this._axios\n }\n\n get clientUrl() {\n // eslint-disable-next-line deprecation/deprecation\n return assertEx(this.config.client?.url ?? this.config.nodeUrl, () => 'No Url Set')\n }\n\n get failureRetryTime() {\n return this.config.failureRetryTime ?? HttpBridgeBase.defaultFailureRetryTime\n }\n\n get maxConnections() {\n return this.config.maxConnections ?? HttpBridgeBase.defaultMaxConnections\n }\n\n get maxPayloadSizeWarning() {\n return this.config.maxPayloadSizeWarning ?? HttpBridgeBase.defaultMaxPayloadSizeWarning\n }\n\n get querySemaphore() {\n this._querySemaphore = this._querySemaphore ?? new Semaphore(this.maxConnections)\n return this._querySemaphore\n }\n\n override get resolver() {\n this._resolver =\n this._resolver ??\n new HttpBridgeModuleResolver({\n additionalSigners: this.additionalSigners,\n archiving: { ...this.archiving, resolveArchivists: this.resolveArchivingArchivists.bind(this) },\n bridge: this,\n onQuerySendFinished: (args: Omit<QuerySendFinishedEventArgs, 'module'>) => {\n forget(this.emit('querySendFinished', { module: this, ...args }))\n },\n onQuerySendStarted: (args: Omit<QuerySendStartedEventArgs, 'module'>) => {\n forget(this.emit('querySendStarted', { module: this, ...args }))\n },\n querySender: this,\n root: this,\n rootUrl: this.clientUrl,\n wrapperAccount: this.account,\n })\n return this._resolver\n }\n\n async connect(id: ModuleIdentifier): Promise<Address | undefined> {\n const transformedId = assertEx(await ResolveHelper.transformModuleIdentifier(id), () => `Unable to transform module identifier: ${id}`)\n //check if already connected\n const existingInstance = await this.resolve<ModuleInstance>(transformedId)\n if (existingInstance) {\n return existingInstance.address\n }\n\n //use the resolver to create the proxy instance\n const [instance] = await this.resolver.resolveHandler<ModuleInstance>(id)\n return this.connectInstance(instance)\n }\n\n async disconnect(id: ModuleIdentifier): Promise<Address | undefined> {\n const transformedId = assertEx(await ResolveHelper.transformModuleIdentifier(id), () => `Unable to transform module identifier: ${id}`)\n const instance = await this.resolve<ModuleInstance>(transformedId)\n if (instance) {\n this.downResolver.remove(instance.address)\n return instance.address\n }\n }\n\n override exposeHandler(_id: string, _options?: BridgeExposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n override exposedHandler(): Promisable<Address[]> {\n throw new Error('Unsupported')\n }\n\n async getRoots(force?: boolean): Promise<ModuleInstance[]> {\n return await this._discoverRootsMutex.runExclusive(async () => {\n if (this._roots === undefined || force) {\n const state = await this.getRootState()\n this.logger?.debug(`HttpBridge:discoverRoots.state [${state?.length}]`)\n const nodeManifest = state?.find(isPayloadOfSchemaType<WithMeta<NodeManifestPayload>>(NodeManifestPayloadSchema))\n if (nodeManifest) {\n const mods = (await this.resolveRootNode(nodeManifest)).filter(exists)\n this.logger?.debug(`HttpBridge:discoverRoots [${mods.length}]`)\n this._roots = mods\n } else {\n this._roots = []\n }\n }\n return this._roots\n })\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.clientUrl)\n }\n\n async sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ): Promise<ModuleQueryResult<TOut>> {\n const lastFailureTime = this._failureTimeCache.get(targetAddress)\n if (lastFailureTime !== undefined) {\n const now = Date.now()\n const timeSincePreviousFailure = now - lastFailureTime\n if (timeSincePreviousFailure > this.failureRetryTime) {\n throw new Error(`target module failed recently [${targetAddress}] [${timeSincePreviousFailure}ms ago]`)\n }\n this._failureTimeCache.delete(targetAddress)\n }\n try {\n await this.querySemaphore.acquire()\n const payloadSize = JSON.stringify([query, payloads]).length\n if (payloadSize > this.maxPayloadSizeWarning) {\n this.logger?.warn(\n `Large targetQuery being sent: ${payloadSize} bytes [${this.address}][${this.moduleAddress}] [${query.schema}] [${payloads?.length}]`,\n )\n }\n const moduleUrl = this.moduleUrl(targetAddress).href\n const result = await this.axios.post<ApiEnvelope<ModuleQueryResult<TOut>>>(moduleUrl, [query, payloads])\n if (result.status === 404) {\n throw `target module not found [${moduleUrl}] [${result.status}]`\n }\n if (result.status >= 400) {\n this.logger?.error(`targetQuery failed [${moduleUrl}]`)\n throw `targetQuery failed [${moduleUrl}] [${result.status}]`\n }\n return result.data?.data\n } catch (ex) {\n const error = ex as AxiosError\n this.logger?.error(`Error: ${toJsonString(error)}`)\n throw error\n } finally {\n this.querySemaphore.release()\n }\n }\n\n override unexposeHandler(_id: string, _options?: BridgeUnexposeOptions | undefined): Promisable<ModuleInstance[]> {\n throw new Error('Unsupported')\n }\n\n protected connectInstance(instance?: ModuleInstance): Address | undefined {\n if (instance) {\n this.downResolver.add(instance)\n /*if (maxDepth > 0) {\n const node = asNodeInstance(instance)\n if (node) {\n const state = await node.state()\n const children = (state?.filter(isPayloadOfSchemaType<AddressPayload>(AddressSchema)).map((s) => s.address) ?? []).filter(\n (a) => a !== instance.address,\n )\n await Promise.all(children.map((child) => this.connect(child, maxDepth - 1)))\n }\n }*/\n this.logger?.log(`Connect: ${instance.id}`)\n return instance.address\n }\n }\n\n private async getRootState() {\n const queryPayload: ModuleStateQuery = { schema: ModuleStateQuerySchema }\n const boundQuery = await this.bindQuery(queryPayload)\n try {\n const response = await this.axios.post<ApiEnvelope<ModuleQueryResult>>(this.clientUrl.toString(), boundQuery)\n if (response.status === 404) {\n return []\n }\n const [, payloads, errors] = response.data.data\n if (errors.length > 0) {\n throw new Error(`getRootState failed: ${JSON.stringify(errors, null, 2)}`)\n }\n return payloads\n } catch (ex) {\n const error = ex as Error\n this.logger?.warn(`Unable to connect to remote node: ${error.message} [${this.clientUrl}]`)\n }\n }\n\n private async resolveRootNode(nodeManifest: ModuleManifestPayload): Promise<ModuleInstance[]> {\n const rootModule = assertEx(\n (\n await this.resolver.resolveHandler(\n assertEx(nodeManifest.status?.address, () => 'Root has no address'),\n undefined,\n { manifest: nodeManifest },\n )\n ).at(0),\n () => `Root not found [${nodeManifest.status?.address}]`,\n )\n assertEx(rootModule.constructor.name !== 'HttpModuleProxy', () => 'rootModule is not a Wrapper')\n const rootNode = asAttachableNodeInstance(rootModule, 'Root modules is not a node')\n if (rootNode) {\n this.logger.debug(`rootNode: ${rootNode.id}`)\n this.connectInstance(rootNode)\n return [rootNode]\n }\n return []\n }\n}\n","import { EmptyObject } from '@xylabs/object'\nimport { BridgeConfig } from '@xyo-network/bridge-model'\n\nexport type HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\nexport const HttpBridgeConfigSchema: HttpBridgeConfigSchema = 'network.xyo.bridge.http.config'\n\nexport type HttpBridgeConfig<TConfig extends EmptyObject = EmptyObject, TSchema extends string | void = void> = BridgeConfig<\n {\n client?: BridgeConfig['client'] & {\n url: string\n }\n failureRetryTime?: number\n failureTimeCacheMax?: number\n host?: {\n port: number\n }\n maxConnections?: number\n maxPayloadSizeWarning?: number\n /** @deprecated use client.url instead */\n nodeUrl?: string\n schema: HttpBridgeConfigSchema\n } & TConfig,\n TSchema extends string ? TSchema : HttpBridgeConfigSchema\n>\n","import { assertEx } from '@xylabs/assert'\nimport { Address, isAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport { AbstractBridgeModuleResolver, BridgeModuleResolverParams, wrapModuleWithType } from '@xyo-network/bridge-abstract'\nimport { ConfigPayload, ConfigSchema } from '@xyo-network/config-payload-plugin'\nimport {\n asModuleInstance,\n ModuleConfig,\n ModuleConfigSchema,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ResolveHelper,\n} from '@xyo-network/module-model'\nimport { Mutex } from 'async-mutex'\nimport { LRUCache } from 'lru-cache'\n\nimport { BridgeQuerySender, HttpModuleProxy, HttpModuleProxyParams } from './ModuleProxy'\n\nexport interface HttpBridgeModuleResolverParams extends BridgeModuleResolverParams {\n querySender: BridgeQuerySender\n rootUrl: string\n}\n\nexport class HttpBridgeModuleResolver<\n T extends HttpBridgeModuleResolverParams = HttpBridgeModuleResolverParams,\n> extends AbstractBridgeModuleResolver<T> {\n protected _resolvedCache = new LRUCache<Address, ModuleInstance>({ max: 1000 })\n protected _resolvedCacheMutex = new Mutex()\n\n get querySender() {\n return this.params.querySender\n }\n\n moduleUrl(address: Address) {\n return new URL(address, this.params.rootUrl)\n }\n\n override async resolveHandler<T extends ModuleInstance = ModuleInstance>(\n id: ModuleIdentifier,\n options?: ModuleFilterOptions<T>,\n params?: Partial<HttpModuleProxyParams>,\n ): Promise<T[]> {\n const parentResult = await super.resolveHandler(id, options)\n if (parentResult.length > 0) {\n return parentResult\n }\n const idParts = id.split(':')\n const untransformedFirstPart = assertEx(idParts.shift(), () => 'Missing module identifier')\n const firstPart = await ResolveHelper.transformModuleIdentifier(untransformedFirstPart)\n assertEx(isAddress(firstPart), () => `Invalid module address: ${firstPart}`)\n const remainderParts = idParts.join(':')\n const instance: T = await this._resolvedCacheMutex.runExclusive(async () => {\n const cachedMod = this._resolvedCache.get(firstPart as Address)\n if (cachedMod) {\n const result = idParts.length <= 0 ? cachedMod : cachedMod.resolve(remainderParts, { ...options, maxDepth: (options?.maxDepth ?? 5) - 1 })\n return result as T\n }\n const account = Account.randomSync()\n const finalParams: HttpModuleProxyParams = {\n account,\n archiving: this.params.archiving,\n config: { schema: ModuleConfigSchema },\n host: this,\n moduleAddress: firstPart as Address,\n onQuerySendFinished: this.params.onQuerySendFinished,\n onQuerySendStarted: this.params.onQuerySendStarted,\n querySender: this.params.querySender,\n ...params,\n }\n\n this.logger?.debug(`creating HttpProxy [${firstPart}] ${id}`)\n console.log(`creating HttpProxy [${firstPart}] ${id}`)\n\n const proxy = new HttpModuleProxy<T, HttpModuleProxyParams>(finalParams)\n\n const state = await proxy.state()\n if (state) {\n const configSchema = (state.find((payload) => payload.schema === ConfigSchema) as ConfigPayload | undefined)?.config\n const config = assertEx(\n state.find((payload) => payload.schema === configSchema),\n () => 'Unable to locate config',\n ) as ModuleConfig\n proxy.setConfig(config)\n }\n\n console.log(`created HttpProxy [${firstPart}] ${proxy.id}`)\n\n await proxy.start?.()\n const wrapped = wrapModuleWithType(proxy, account) as unknown as T\n assertEx(asModuleInstance<T>(wrapped, {}), () => `Failed to asModuleInstance [${id}]`)\n this._resolvedCache.set(wrapped.address, wrapped)\n return wrapped as ModuleInstance as T\n })\n const result = remainderParts.length > 0 ? await instance.resolve(remainderParts, options) : instance\n return result ? [result] : []\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { forget } from '@xylabs/forget'\nimport { Address, isAddress } from '@xylabs/hex'\nimport { QueryBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractModuleProxy, ModuleProxyParams } from '@xyo-network/bridge-abstract'\nimport {\n AttachableModuleInstance,\n ModuleFilter,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n ModuleQueryResult,\n ResolveHelper,\n ResolveHelperConfig,\n} from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport interface BridgeQuerySender {\n sendBridgeQuery: <TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(\n targetAddress: Address,\n query: TQuery,\n payloads?: TIn[],\n ) => Promise<ModuleQueryResult<TOut>>\n}\n\nexport type HttpModuleProxyParams = ModuleProxyParams & {\n querySender: BridgeQuerySender\n}\n\nexport class HttpModuleProxy<\n TWrappedModule extends ModuleInstance = ModuleInstance,\n TParams extends Omit<HttpModuleProxyParams, 'config'> & { config: TWrappedModule['config'] } = Omit<HttpModuleProxyParams, 'config'> & {\n config: TWrappedModule['config']\n },\n >\n extends AbstractModuleProxy<TWrappedModule, TParams>\n implements AttachableModuleInstance<TParams, TWrappedModule['eventData']>\n{\n static createCount = 0\n\n constructor(params: TParams) {\n HttpModuleProxy.createCount = HttpModuleProxy.createCount + 1\n if (Math.floor(HttpModuleProxy.createCount / 10) === HttpModuleProxy.createCount / 10) {\n console.log(`HttpModuleProxy.createCount: ${HttpModuleProxy.createCount}`)\n }\n super(params)\n }\n\n async proxyQueryHandler<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads: Payload[] = []): Promise<ModuleQueryResult> {\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists([query, ...(payloads ?? [])]))\n }\n const result = await this.params.querySender.sendBridgeQuery(this.params.moduleAddress, query, payloads)\n if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {\n forget(this.storeToArchivists(result.flat()))\n }\n return result\n }\n\n override async publicChildren(): Promise<ModuleInstance[]> {\n return (\n await Promise.all(\n Object.values(await this.childAddressMap())\n .filter(exists)\n .map((address) => this.resolve(address)),\n )\n ).filter(exists)\n }\n\n /** @deprecated do not pass undefined. If trying to get all, pass '*' */\n override async resolve(): Promise<ModuleInstance[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ModuleFilterOptions<T>): Promise<T[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(filter: ModuleFilter, options?: ModuleFilterOptions<T>): Promise<T[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T | undefined>\n /** @deprecated use '*' if trying to resolve all */\n override async resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter, options?: ModuleFilterOptions<T>): Promise<T[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(\n idOrFilter: ModuleFilter<T> | ModuleIdentifier = '*',\n options: ModuleFilterOptions<T> = {},\n ): Promise<T | T[] | undefined> {\n const config: ResolveHelperConfig = {\n address: this.address,\n dead: this.dead,\n downResolver: this.downResolver,\n logger: this.logger,\n module: this,\n transformers: this.moduleIdentifierTransformers,\n upResolver: this.upResolver,\n }\n if (idOrFilter === '*') {\n return (await this.publicChildren()) as T[]\n }\n switch (typeof idOrFilter) {\n case 'string': {\n const parts = idOrFilter.split(':')\n const first = assertEx(parts.shift(), () => 'Missing first')\n const remainingPath = parts.join(':')\n const address =\n isAddress(first) ? first\n : this.id === first ? this.address\n : this.childAddressByName(first)\n if (!address) return undefined\n const firstInstance = (await this.params.host.resolve(address)) as ModuleInstance | undefined\n return (remainingPath ? await firstInstance?.resolve(remainingPath) : firstInstance) as T | undefined\n }\n case 'object': {\n return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address)\n }\n default: {\n return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address)\n }\n }\n }\n}\n"],"mappings":";;;;AACA,SAA0BA,mBAAAA,wBAAuB;;;ACDjD,SAASC,YAAAA,iBAAgB;AACzB,SAAqBC,iBAAiB;AACtC,SAASC,UAAAA,eAAc;AACvB,SAASC,UAAAA,eAAc;AAEvB,SAASC,oBAAoB;AAI7B,SAASC,sBAAsB;AAS/B,SAAqDC,iCAAiC;AACtF,SAEEC,iBAKAC,wBACAC,iBAAAA,sBACK;AACP,SAASC,gCAAgC;AACzC,SAASC,6BAAwD;AACjE,SAASC,SAAAA,QAAOC,iBAAiB;AACjC,SAASC,YAAAA,iBAAgB;;;AC5BlB,IAAMC,yBAAiD;;;ACJ9D,SAASC,YAAAA,iBAAgB;AACzB,SAAkBC,aAAAA,kBAAiB;AACnC,SAASC,eAAe;AACxB,SAASC,8BAA0DC,0BAA0B;AAC7F,SAAwBC,oBAAoB;AAC5C,SACEC,kBAEAC,oBAIAC,iBAAAA,sBACK;AACP,SAASC,aAAa;AACtB,SAASC,gBAAgB;;;ACfzB,SAASC,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,cAAc;AACvB,SAAkBC,iBAAiB;AAEnC,SAASC,2BAA8C;AACvD,SAOEC,qBAEK;AAeA,IAAMC,kBAAN,MAAMA,yBAMHC,oBAAAA;EApCV,OAoCUA;;;EAGR,OAAOC,cAAc;EAErBC,YAAYC,QAAiB;AAC3BJ,qBAAgBE,cAAcF,iBAAgBE,cAAc;AAC5D,QAAIG,KAAKC,MAAMN,iBAAgBE,cAAc,EAAA,MAAQF,iBAAgBE,cAAc,IAAI;AACrFK,cAAQC,IAAI,gCAAgCR,iBAAgBE,WAAW,EAAE;IAC3E;AACA,UAAME,MAAAA;EACR;EAEA,MAAMK,k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azG,WAEf,MAAM,KAAKU,SAAS4B,eAClBtC,UAAS0D,aAAa8B,QAAQpD,SAAS,MAAM,qBAAA,GAC7CgB,QACA;MAAEsD,UAAUhD;IAAa,CAAA,GAE3BiD,GAAG,CAAA,GACL,MAAM,mBAAmBjD,aAAa8B,QAAQpD,OAAAA,GAAU;AAE1DpC,IAAAA,UAASyG,WAAWG,YAAYC,SAAS,mBAAmB,MAAM,6BAAA;AAClE,UAAMC,WAAWC,yBAAyBN,YAAY,4BAAA;AACtD,QAAIK,UAAU;AACZ,WAAKvD,OAAOC,MAAM,aAAasD,SAAShF,EAAE,EAAE;AAC5C,WAAKS,gBAAgBuE,QAAAA;AACrB,aAAO;QAACA;;IACV;AACA,WAAO,CAAA;EACT;AACF;AAzNanI,iBAAAA,aAAAA;EADZqI,gBAAAA;GACYrI,cAAAA;;;;;;;;;;ADlCN,IAAMsI,aAAN,cAA2DC,eAAAA;SAAAA;;;AAAyB;AAA9ED,aAAAA,cAAAA;EADZE,iBAAAA;GACYF,UAAAA;","names":["creatableModule","assertEx","AxiosJson","exists","forget","toJsonString","AbstractBridge","NodeManifestPayloadSchema","creatableModule","ModuleStateQuerySchema","ResolveHelper","asAttachableNodeInstance","isPayloadOfSchemaType","Mutex","Semaphore","LRUCache","HttpBridgeConfigSchema","assertEx","isAddress","Account","AbstractBridgeModuleResolver","wrapModuleWithType","ConfigSchema","asModuleInstance","ModuleConfigSchema","ResolveHelper","Mutex","LRUCache","assertEx","exists","forget","isAddress","AbstractModuleProxy","ResolveHelper","HttpModuleProxy","AbstractModuleProxy","createCount","constructor","params","Math","floor","console","log","proxyQueryHandler","query","payloads","archiving","isAllowedArchivingQuery","schema","forget","storeToArchivists","result","querySender","sendBridgeQuery","moduleAddress","flat","publicChildren","Promise","all","Object","values","childAddressMap","filter","exists","map","address","resolve","idOrFilter","options","config","dead","downResolver","logger","module","transformers","moduleIdentifierTransformers","upResolver","parts","split","first","assertEx","shift","remainingPath","join","isAddress","id","childAddressByName","undefined","firstInstance","host","ResolveHelper","mod","HttpBridgeModuleResolver","AbstractBridgeModuleResolver","_resolvedCache","LRUCache","max","_resolvedCacheMutex","Mutex","querySender","params","moduleUrl","address","URL","rootUrl","resolveHandler","id","options","parentResult","length","idParts","split","untransformedFirstPart","assertEx","shift","firstPart","ResolveHelper","transformModuleIdentifier","isAddress","remainderParts","join","instance","runExclusive","cachedMod","get","result","resolve","maxDepth","account","Account","randomSync","finalParams","archiving","config","schema","ModuleConfigSchema","host","moduleAddress","onQuerySendFinished","onQuerySendStarted","logger","debug","console","log","proxy","HttpModuleProxy","state","configSchema","find","payload","ConfigSchema","setConfig","start","wrapped","wrapModuleWithType","asModuleInstance","set","HttpBridgeBase","AbstractBridge","axios","AxiosJson","configSchemas","HttpBridgeConfigSchema","defaultConfigSchema","defaultFailureRetryTime","defaultMaxConnections","defaultMaxPayloadSizeWarning","maxFailureCacheSize","_axios","_discoverRootsMutex","Mutex","_failureTimeCache","LRUCache","max","_querySemaphore","_resolver","params","clientUrl","assertEx","config","client","url","nodeUrl","failureRetryTime","maxConnections","maxPayloadSizeWarning","querySemaphore","Semaphore","resolver","HttpBridgeModuleResolver","additionalSigners","archiving","resolveArchivists","resolveArchivingArchivists","bind","bridge","onQuerySendFinished","args","forget","emit","module","onQuerySendStarted","querySender","root","rootUrl","wrapperAccount","account","connect","id","transformedId","ResolveHelper","transformModuleIdentifier","existingInstance","resolve","address","instance","resolveHandler","connectInstance","disconnect","downResolver","remove","exposeHandler","_id","_options","Error","exposedHandler","getRoots","force","runExclusive","_roots","undefined","state","getRootState","logger","debug","length","nodeManifest","find","isPayloadOfSchemaType","NodeManifestPayloadSchema","mods","resolveRootNode","filter","exists","moduleUrl","URL","sendBridgeQuery","targetAddress","query","payloads","lastFailureTime","get","now","Date","timeSincePreviousFailure","delete","acquire","payloadSize","JSON","stringify","warn","moduleAddress","schema","href","result","post","status","error","data","ex","toJsonString","release","unexposeHandler","add","log","queryPayload","ModuleStateQuerySchema","boundQuery","bindQuery","response","toString","errors","message","rootModule","manifest","at","constructor","name","rootNode","asAttachableNodeInstance","creatableModule","HttpBridge","HttpBridgeBase","creatableModule"]}
|
|
@@ -4,7 +4,7 @@ import { Promisable } from '@xylabs/promise';
|
|
|
4
4
|
import { QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
5
5
|
import { AbstractBridge } from '@xyo-network/bridge-abstract';
|
|
6
6
|
import { BridgeExposeOptions, BridgeModule, BridgeParams, BridgeUnexposeOptions } from '@xyo-network/bridge-model';
|
|
7
|
-
import { AnyConfigSchema, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model';
|
|
7
|
+
import { AnyConfigSchema, ModuleIdentifier, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model';
|
|
8
8
|
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
9
9
|
import { Semaphore } from 'async-mutex';
|
|
10
10
|
import { HttpBridgeConfig } from './HttpBridgeConfig';
|
|
@@ -33,12 +33,15 @@ export declare class HttpBridgeBase<TParams extends HttpBridgeParams> extends Ab
|
|
|
33
33
|
get maxPayloadSizeWarning(): number;
|
|
34
34
|
get querySemaphore(): Semaphore;
|
|
35
35
|
get resolver(): HttpBridgeModuleResolver<import("./HttpBridgeModuleResolver").HttpBridgeModuleResolverParams>;
|
|
36
|
+
connect(id: ModuleIdentifier): Promise<Address | undefined>;
|
|
37
|
+
disconnect(id: ModuleIdentifier): Promise<Address | undefined>;
|
|
36
38
|
exposeHandler(_id: string, _options?: BridgeExposeOptions | undefined): Promisable<ModuleInstance[]>;
|
|
37
39
|
exposedHandler(): Promisable<Address[]>;
|
|
38
40
|
getRoots(force?: boolean): Promise<ModuleInstance[]>;
|
|
39
41
|
moduleUrl(address: Address): URL;
|
|
40
42
|
sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(targetAddress: Address, query: TQuery, payloads?: TIn[]): Promise<ModuleQueryResult<TOut>>;
|
|
41
43
|
unexposeHandler(_id: string, _options?: BridgeUnexposeOptions | undefined): Promisable<ModuleInstance[]>;
|
|
44
|
+
protected connectInstance(instance?: ModuleInstance): Address | undefined;
|
|
42
45
|
private getRootState;
|
|
43
46
|
private resolveRootNode;
|
|
44
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBridgeBase.d.ts","sourceRoot":"","sources":["../../src/HttpBridgeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,qBAAqB,EAGtB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,eAAe,EAEf,cAAc,EACd,iBAAiB,EAIlB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAyB,OAAO,EAAE,MAAM,EAAY,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EAAS,SAAS,EAAE,MAAM,aAAa,CAAA;AAG9C,OAAO,EAAE,gBAAgB,EAA0B,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEjD,MAAM,WAAW,gBAAiB,SAAQ,YAAY,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;IACvF,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,qBACa,cAAc,CAAC,OAAO,SAAS,gBAAgB,CAAE,SAAQ,cAAc,CAAC,OAAO,CAAE,YAAW,YAAY,CAAC,OAAO,CAAC,EAAE,iBAAiB;IAC/I,MAAM,CAA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CAAC,EAAE,mBAAmB,GAAG,SAAS,GAAG,UAAU,CAAC,cAAc,EAAE,CAAC;IAIpG,cAAc,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;IAI1C,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAkB1D,SAAS,CAAC,OAAO,EAAE,OAAO;IAIpB,eAAe,CAAC,IAAI,SAAS,OAAO,GAAG,OAAO,EAAE,MAAM,SAAS,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,SAAS,OAAO,GAAG,OAAO,EACvI,aAAa,EAAE,OAAO,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,GAAG,EAAE,GACf,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAqC1B,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,qBAAqB,GAAG,SAAS,GAAG,UAAU,CAAC,cAAc,EAAE,CAAC;IAIjH,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,GAAG,SAAS;YAkB3D,YAAY;YAmBZ,eAAe;CAoB9B"}
|
|
@@ -4,7 +4,7 @@ import { Promisable } from '@xylabs/promise';
|
|
|
4
4
|
import { QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
5
5
|
import { AbstractBridge } from '@xyo-network/bridge-abstract';
|
|
6
6
|
import { BridgeExposeOptions, BridgeModule, BridgeParams, BridgeUnexposeOptions } from '@xyo-network/bridge-model';
|
|
7
|
-
import { AnyConfigSchema, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model';
|
|
7
|
+
import { AnyConfigSchema, ModuleIdentifier, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model';
|
|
8
8
|
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
9
9
|
import { Semaphore } from 'async-mutex';
|
|
10
10
|
import { HttpBridgeConfig } from './HttpBridgeConfig';
|
|
@@ -33,12 +33,15 @@ export declare class HttpBridgeBase<TParams extends HttpBridgeParams> extends Ab
|
|
|
33
33
|
get maxPayloadSizeWarning(): number;
|
|
34
34
|
get querySemaphore(): Semaphore;
|
|
35
35
|
get resolver(): HttpBridgeModuleResolver<import("./HttpBridgeModuleResolver").HttpBridgeModuleResolverParams>;
|
|
36
|
+
connect(id: ModuleIdentifier): Promise<Address | undefined>;
|
|
37
|
+
disconnect(id: ModuleIdentifier): Promise<Address | undefined>;
|
|
36
38
|
exposeHandler(_id: string, _options?: BridgeExposeOptions | undefined): Promisable<ModuleInstance[]>;
|
|
37
39
|
exposedHandler(): Promisable<Address[]>;
|
|
38
40
|
getRoots(force?: boolean): Promise<ModuleInstance[]>;
|
|
39
41
|
moduleUrl(address: Address): URL;
|
|
40
42
|
sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(targetAddress: Address, query: TQuery, payloads?: TIn[]): Promise<ModuleQueryResult<TOut>>;
|
|
41
43
|
unexposeHandler(_id: string, _options?: BridgeUnexposeOptions | undefined): Promisable<ModuleInstance[]>;
|
|
44
|
+
protected connectInstance(instance?: ModuleInstance): Address | undefined;
|
|
42
45
|
private getRootState;
|
|
43
46
|
private resolveRootNode;
|
|
44
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBridgeBase.d.ts","sourceRoot":"","sources":["../../src/HttpBridgeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,qBAAqB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U,CAAC,cAAc,EAAE,CAAC;IAIjH,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,GAAG,SAAS;YAkB3D,YAAY;YAmBZ,eAAe;CAoB9B"}
|
|
@@ -4,7 +4,7 @@ import { Promisable } from '@xylabs/promise';
|
|
|
4
4
|
import { QueryBoundWitness } from '@xyo-network/boundwitness-model';
|
|
5
5
|
import { AbstractBridge } from '@xyo-network/bridge-abstract';
|
|
6
6
|
import { BridgeExposeOptions, BridgeModule, BridgeParams, BridgeUnexposeOptions } from '@xyo-network/bridge-model';
|
|
7
|
-
import { AnyConfigSchema, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model';
|
|
7
|
+
import { AnyConfigSchema, ModuleIdentifier, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model';
|
|
8
8
|
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
9
9
|
import { Semaphore } from 'async-mutex';
|
|
10
10
|
import { HttpBridgeConfig } from './HttpBridgeConfig';
|
|
@@ -33,12 +33,15 @@ export declare class HttpBridgeBase<TParams extends HttpBridgeParams> extends Ab
|
|
|
33
33
|
get maxPayloadSizeWarning(): number;
|
|
34
34
|
get querySemaphore(): Semaphore;
|
|
35
35
|
get resolver(): HttpBridgeModuleResolver<import("./HttpBridgeModuleResolver").HttpBridgeModuleResolverParams>;
|
|
36
|
+
connect(id: ModuleIdentifier): Promise<Address | undefined>;
|
|
37
|
+
disconnect(id: ModuleIdentifier): Promise<Address | undefined>;
|
|
36
38
|
exposeHandler(_id: string, _options?: BridgeExposeOptions | undefined): Promisable<ModuleInstance[]>;
|
|
37
39
|
exposedHandler(): Promisable<Address[]>;
|
|
38
40
|
getRoots(force?: boolean): Promise<ModuleInstance[]>;
|
|
39
41
|
moduleUrl(address: Address): URL;
|
|
40
42
|
sendBridgeQuery<TOut extends Payload = Payload, TQuery extends QueryBoundWitness = QueryBoundWitness, TIn extends Payload = Payload>(targetAddress: Address, query: TQuery, payloads?: TIn[]): Promise<ModuleQueryResult<TOut>>;
|
|
41
43
|
unexposeHandler(_id: string, _options?: BridgeUnexposeOptions | undefined): Promisable<ModuleInstance[]>;
|
|
44
|
+
protected connectInstance(instance?: ModuleInstance): Address | undefined;
|
|
42
45
|
private getRootState;
|
|
43
46
|
private resolveRootNode;
|
|
44
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBridgeBase.d.ts","sourceRoot":"","sources":["../../src/HttpBridgeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAE,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,qBAAqB,EAGtB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,eAAe,EAEf,cAAc,EACd,iBAAiB,EAIlB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAyB,OAAO,EAAE,MAAM,EAAY,MAAM,4BAA4B,CAAA;AAC7F,OAAO,EAAS,SAAS,EAAE,MAAM,aAAa,CAAA;AAG9C,OAAO,EAAE,gBAAgB,EAA0B,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEjD,MAAM,WAAW,gBAAiB,SAAQ,YAAY,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;IACvF,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED,qBACa,cAAc,CAAC,OAAO,SAAS,gBAAgB,CAAE,SAAQ,cAAc,CAAC,OAAO,CAAE,YAAW,YAAY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IAS3D,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,SAAS,GAAG,UAAU,CAAC,cAAc,EAAE,CAAC;IAIpG,cAAc,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;IAI1C,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAkB1D,SAAS,CAAC,OAAO,EAAE,OAAO;IAIpB,eAAe,CAAC,IAAI,SAAS,OAAO,GAAG,OAAO,EAAE,MAAM,SAAS,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,SAAS,OAAO,GAAG,OAAO,EACvI,aAAa,EAAE,OAAO,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,GAAG,EAAE,GACf,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAqC1B,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,qBAAqB,GAAG,SAAS,GAAG,UAAU,CAAC,cAAc,EAAE,CAAC;IAIjH,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,GAAG,SAAS;YAkB3D,YAAY;YAmBZ,eAAe;CAoB9B"}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { Address } from '@xylabs/hex';
|
|
2
2
|
import { AbstractBridgeModuleResolver, BridgeModuleResolverParams } from '@xyo-network/bridge-abstract';
|
|
3
3
|
import { ModuleFilterOptions, ModuleIdentifier, ModuleInstance } from '@xyo-network/module-model';
|
|
4
|
-
import {
|
|
4
|
+
import { Mutex } from 'async-mutex';
|
|
5
|
+
import { LRUCache } from 'lru-cache';
|
|
6
|
+
import { BridgeQuerySender, HttpModuleProxyParams } from './ModuleProxy';
|
|
5
7
|
export interface HttpBridgeModuleResolverParams extends BridgeModuleResolverParams {
|
|
6
8
|
querySender: BridgeQuerySender;
|
|
7
9
|
rootUrl: string;
|
|
8
10
|
}
|
|
9
11
|
export declare class HttpBridgeModuleResolver<T extends HttpBridgeModuleResolverParams = HttpBridgeModuleResolverParams> extends AbstractBridgeModuleResolver<T> {
|
|
12
|
+
protected _resolvedCache: LRUCache<Lowercase<string>, ModuleInstance<import("@xylabs/object").BaseParamsFields & {
|
|
13
|
+
account?: import("@xyo-network/account").AccountInstance | "random" | undefined;
|
|
14
|
+
addToResolvers?: boolean | undefined;
|
|
15
|
+
additionalSigners?: import("@xyo-network/account").AccountInstance[] | undefined;
|
|
16
|
+
allowNameResolution?: boolean | undefined;
|
|
17
|
+
config: import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & Omit<import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/module-model").ModuleConfigFields & import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
18
|
+
schema: "network.xyo.module.config";
|
|
19
|
+
}, "schema"> & {
|
|
20
|
+
schema: string;
|
|
21
|
+
};
|
|
22
|
+
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
23
|
+
moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[] | undefined;
|
|
24
|
+
}, import("@xyo-network/module-model").ModuleEventData<object>>, unknown>;
|
|
25
|
+
protected _resolvedCacheMutex: Mutex;
|
|
10
26
|
get querySender(): BridgeQuerySender;
|
|
11
27
|
moduleUrl(address: Address): URL;
|
|
12
|
-
resolveHandler<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T[]>;
|
|
28
|
+
resolveHandler<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>, params?: Partial<HttpModuleProxyParams>): Promise<T[]>;
|
|
13
29
|
}
|
|
14
30
|
//# sourceMappingURL=HttpBridgeModuleResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBridgeModuleResolver.d.ts","sourceRoot":"","sources":["../../src/HttpBridgeModuleResolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAa,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAsB,MAAM,8BAA8B,CAAA;AAE3H,OAAO,EAIL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EAEf,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"HttpBridgeModuleResolver.d.ts","sourceRoot":"","sources":["../../src/HttpBridgeModuleResolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAa,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAsB,MAAM,8BAA8B,CAAA;AAE3H,OAAO,EAIL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EAEf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,iBAAiB,EAAmB,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAEzF,MAAM,WAAW,8BAA+B,SAAQ,0BAA0B;IAChF,WAAW,EAAE,iBAAiB,CAAA;IAC9B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,wBAAwB,CACnC,CAAC,SAAS,8BAA8B,GAAG,8BAA8B,CACzE,SAAQ,4BAA4B,CAAC,CAAC,CAAC;IACvC,SAAS,CAAC,cAAc;;;;;;;;;;;;8EAAuD;IAC/E,SAAS,CAAC,mBAAmB,QAAc;IAE3C,IAAI,WAAW,sBAEd;IAED,SAAS,CAAC,OAAO,EAAE,OAAO;IAIX,cAAc,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EACrE,EAAE,EAAE,gBAAgB,EACpB,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,qBAA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