@xyo-network/bridge-pub-sub 2.94.16 → 2.94.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts +7 -72
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +7 -72
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +7 -72
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
- package/dist/browser/index.cjs +64 -118
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +60 -114
- package/dist/browser/index.js.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +7 -72
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +7 -72
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +7 -72
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
- package/dist/node/index.cjs +69 -122
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +65 -118
- package/dist/node/index.js.map +1 -1
- package/package.json +18 -18
- package/src/AsyncQueryBus/AsyncQueryBusBase.ts +58 -101
- package/src/AsyncQueryBus/AsyncQueryBusHost.ts +8 -5
package/dist/browser/index.cjs
CHANGED
|
@@ -43,7 +43,7 @@ var AbstractModuleHost = class extends import_object.Base {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
// src/AsyncQueryBus/AsyncQueryBusClient.ts
|
|
46
|
-
var
|
|
46
|
+
var import_assert2 = require("@xylabs/assert");
|
|
47
47
|
var import_delay = require("@xylabs/delay");
|
|
48
48
|
var import_forget = require("@xylabs/forget");
|
|
49
49
|
var import_timer = require("@xylabs/timer");
|
|
@@ -53,9 +53,11 @@ var import_payload_builder = require("@xyo-network/payload-builder");
|
|
|
53
53
|
var import_lru_cache2 = require("lru-cache");
|
|
54
54
|
|
|
55
55
|
// src/AsyncQueryBus/AsyncQueryBusBase.ts
|
|
56
|
+
var import_assert = require("@xylabs/assert");
|
|
56
57
|
var import_object2 = require("@xylabs/object");
|
|
57
58
|
var import_archivist_model = require("@xyo-network/archivist-model");
|
|
58
59
|
var import_diviner_model = require("@xyo-network/diviner-model");
|
|
60
|
+
var import_module_model = require("@xyo-network/module-model");
|
|
59
61
|
var import_async_mutex = require("async-mutex");
|
|
60
62
|
var import_lru_cache = require("lru-cache");
|
|
61
63
|
var AsyncQueryBusBase = class extends import_object2.Base {
|
|
@@ -65,19 +67,13 @@ var AsyncQueryBusBase = class extends import_object2.Base {
|
|
|
65
67
|
_lastState;
|
|
66
68
|
_targetConfigs = {};
|
|
67
69
|
_targetQueries = {};
|
|
68
|
-
|
|
69
|
-
_lastQueriesDivinerAttempt;
|
|
70
|
-
_lastResponsesArchivistAttempt;
|
|
71
|
-
_lastResponsesDivinerAttempt;
|
|
70
|
+
_lastResolveAttempt = {};
|
|
72
71
|
_queriesArchivist;
|
|
73
|
-
_queriesArchivistMutex = new import_async_mutex.Mutex();
|
|
74
72
|
_queriesDiviner;
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
_reResolveDelay = 1e3 * 5;
|
|
74
|
+
_resolveMutex = new import_async_mutex.Mutex();
|
|
77
75
|
_responsesArchivist;
|
|
78
|
-
_responsesArchivistMutex = new import_async_mutex.Mutex();
|
|
79
76
|
_responsesDiviner;
|
|
80
|
-
_responsesDivinerMutex = new import_async_mutex.Mutex();
|
|
81
77
|
constructor(params) {
|
|
82
78
|
super(params);
|
|
83
79
|
}
|
|
@@ -102,92 +98,20 @@ var AsyncQueryBusBase = class extends import_object2.Base {
|
|
|
102
98
|
return this._lastState;
|
|
103
99
|
}
|
|
104
100
|
async queriesArchivist() {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return this._queriesArchivist;
|
|
108
|
-
}
|
|
109
|
-
if (Date.now() - (this._lastQueriesArchivistAttempt ?? 0) < this._reResolveDelay) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this._lastQueriesArchivistAttempt = Date.now();
|
|
113
|
-
const resolved = await this.resolver.resolve(this.config?.intersect?.queries?.archivist);
|
|
114
|
-
if (resolved) {
|
|
115
|
-
const typedResolve = (0, import_archivist_model.asArchivistInstance)(resolved);
|
|
116
|
-
if (typedResolve) {
|
|
117
|
-
return typedResolve;
|
|
118
|
-
} else {
|
|
119
|
-
this.logger?.warn(`Unable to resolve queriesArchivist as correct type [${this.config?.intersect?.queries?.archivist}][${resolved?.constructor?.name}]: ${(0, import_object2.toJsonString)(resolved)}`);
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
this.logger?.log(`Unable to resolve queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
101
|
+
this._queriesArchivist = this._queriesArchivist ?? await this.resolve((0, import_assert.assertEx)(this.config?.intersect?.queries?.archivist, () => "No queries Archivist defined"), import_archivist_model.isArchivistInstance);
|
|
102
|
+
return this._queriesArchivist;
|
|
125
103
|
}
|
|
126
104
|
async queriesDiviner() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return this._queriesDiviner;
|
|
130
|
-
}
|
|
131
|
-
if (Date.now() - (this._lastQueriesDivinerAttempt ?? 0) < this._reResolveDelay) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
this._lastQueriesDivinerAttempt = Date.now();
|
|
135
|
-
const resolved = await this.resolver.resolve(this.config?.intersect?.queries?.boundWitnessDiviner);
|
|
136
|
-
if (resolved) {
|
|
137
|
-
const typedResolve = (0, import_diviner_model.asDivinerInstance)(resolved);
|
|
138
|
-
if (typedResolve) {
|
|
139
|
-
return typedResolve;
|
|
140
|
-
} else {
|
|
141
|
-
this.logger?.warn(`Unable to resolve queriesDiviner as correct type [${this.config?.intersect?.queries?.boundWitnessDiviner}][${resolved?.constructor?.name}]: ${(0, import_object2.toJsonString)(resolved)}`);
|
|
142
|
-
}
|
|
143
|
-
} else {
|
|
144
|
-
this.logger?.log(`Unable to resolve queriesDiviner [${this.config?.intersect?.queries?.boundWitnessDiviner}]`);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
105
|
+
this._queriesDiviner = this._queriesDiviner ?? await this.resolve((0, import_assert.assertEx)(this.config?.intersect?.queries?.boundWitnessDiviner, () => "No queries Diviner defined"), import_diviner_model.isDivinerInstance);
|
|
106
|
+
return this._queriesDiviner;
|
|
147
107
|
}
|
|
148
108
|
async responsesArchivist() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this._responsesArchivist;
|
|
152
|
-
}
|
|
153
|
-
if (Date.now() - (this._lastResponsesArchivistAttempt ?? 0) < this._reResolveDelay) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
this._lastResponsesArchivistAttempt = Date.now();
|
|
157
|
-
const resolved = await this.resolver.resolve(this.config?.intersect?.responses?.archivist);
|
|
158
|
-
if (resolved) {
|
|
159
|
-
const typedResolve = (0, import_archivist_model.asArchivistInstance)(resolved);
|
|
160
|
-
if (typedResolve) {
|
|
161
|
-
return typedResolve;
|
|
162
|
-
} else {
|
|
163
|
-
this.logger?.warn(`Unable to resolve responseArchivist as correct type [${this.config?.intersect?.responses?.archivist}][${resolved?.constructor?.name}]: ${(0, import_object2.toJsonString)(resolved)}`);
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
this.logger?.log(`Unable to resolve responseArchivist [${this.config?.intersect?.responses?.archivist}]`);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
109
|
+
this._responsesArchivist = this._responsesArchivist ?? await this.resolve((0, import_assert.assertEx)(this.config?.intersect?.responses?.archivist, () => "No responses Archivist defined"), import_archivist_model.isArchivistInstance);
|
|
110
|
+
return this._responsesArchivist;
|
|
169
111
|
}
|
|
170
112
|
async responsesDiviner() {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return this._responsesDiviner;
|
|
174
|
-
}
|
|
175
|
-
if (Date.now() - (this._lastResponsesDivinerAttempt ?? 0) < this._reResolveDelay) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
this._lastResponsesDivinerAttempt = Date.now();
|
|
179
|
-
const resolved = await this.resolver.resolve(this.config?.intersect?.responses?.boundWitnessDiviner);
|
|
180
|
-
if (resolved) {
|
|
181
|
-
const typedResolve = (0, import_diviner_model.asDivinerInstance)(resolved);
|
|
182
|
-
if (typedResolve) {
|
|
183
|
-
return typedResolve;
|
|
184
|
-
} else {
|
|
185
|
-
this.logger?.warn(`Unable to resolve responsesDiviner as correct type [${this.config?.intersect?.responses?.boundWitnessDiviner}][${resolved?.constructor?.name}]: ${(0, import_object2.toJsonString)(resolved)}`);
|
|
186
|
-
}
|
|
187
|
-
} else {
|
|
188
|
-
this.logger?.log(`Unable to resolve responsesDiviner [${this.config?.intersect?.responses?.boundWitnessDiviner}]`);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
113
|
+
this._responsesDiviner = this._responsesDiviner ?? await this.resolve((0, import_assert.assertEx)(this.config?.intersect?.responses?.boundWitnessDiviner, () => "No responses Diviner defined"), import_diviner_model.isDivinerInstance);
|
|
114
|
+
return this._responsesDiviner;
|
|
191
115
|
}
|
|
192
116
|
/**
|
|
193
117
|
* Commit the internal state of the process. This is similar
|
|
@@ -219,6 +143,27 @@ var AsyncQueryBusBase = class extends import_object2.Base {
|
|
|
219
143
|
return state;
|
|
220
144
|
}
|
|
221
145
|
}
|
|
146
|
+
async resolve(id, typeCheck) {
|
|
147
|
+
return await this._resolveMutex.runExclusive(async () => {
|
|
148
|
+
if (this._queriesArchivist) {
|
|
149
|
+
return this._queriesArchivist;
|
|
150
|
+
}
|
|
151
|
+
if (Date.now() - (this._lastResolveAttempt[id] ?? 0) < this._reResolveDelay) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this._lastResolveAttempt[id] = Date.now();
|
|
155
|
+
const resolved = await (0, import_module_model.resolveModuleIdentifier)(this.resolver, id);
|
|
156
|
+
if (resolved) {
|
|
157
|
+
if (typeCheck(resolved)) {
|
|
158
|
+
return resolved;
|
|
159
|
+
} else {
|
|
160
|
+
this.logger?.warn(`Unable to resolve responsesDiviner as correct type [${id}][${resolved?.constructor?.name}]: ${resolved.id}`);
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
this.logger?.debug(`Unable to resolve queriesArchivist [${id}] [${await (0, import_module_model.traceModuleIdentifier)(this.resolver, id)}]`);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
222
167
|
};
|
|
223
168
|
|
|
224
169
|
// src/AsyncQueryBus/model/QueryStatus.ts
|
|
@@ -276,7 +221,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
276
221
|
...query,
|
|
277
222
|
$meta
|
|
278
223
|
});
|
|
279
|
-
const queryArchivist = (0,
|
|
224
|
+
const queryArchivist = (0, import_assert2.assertEx)(await this.queriesArchivist(), () => `Unable to contact queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
|
|
280
225
|
const routedQueryHash = (
|
|
281
226
|
// Trust the signed hash if it's there
|
|
282
227
|
routedQuery?.$hash ?? // TODO: What is the right way to find the dataHash
|
|
@@ -404,11 +349,11 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
|
|
|
404
349
|
|
|
405
350
|
// src/AsyncQueryBus/AsyncQueryBusHost.ts
|
|
406
351
|
var import_array = require("@xylabs/array");
|
|
407
|
-
var
|
|
352
|
+
var import_assert3 = require("@xylabs/assert");
|
|
408
353
|
var import_timer2 = require("@xylabs/timer");
|
|
409
354
|
var import_boundwitness_model2 = require("@xyo-network/boundwitness-model");
|
|
410
355
|
var import_diviner_boundwitness_model2 = require("@xyo-network/diviner-boundwitness-model");
|
|
411
|
-
var
|
|
356
|
+
var import_module_model2 = require("@xyo-network/module-model");
|
|
412
357
|
var import_payload_builder2 = require("@xyo-network/payload-builder");
|
|
413
358
|
var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
414
359
|
static {
|
|
@@ -431,14 +376,14 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
431
376
|
}
|
|
432
377
|
async expose(id, options) {
|
|
433
378
|
const { failOnAlreadyExposed, required = true } = options ?? {};
|
|
434
|
-
const module2 = (0,
|
|
379
|
+
const module2 = (0, import_module_model2.asModuleInstance)(await this.resolver.resolve(id, {
|
|
435
380
|
maxDepth: 10
|
|
436
381
|
}));
|
|
437
382
|
if (!module2 && required) {
|
|
438
383
|
throw new Error(`Unable to resolve module to expose [${id}]`);
|
|
439
384
|
}
|
|
440
385
|
if (module2) {
|
|
441
|
-
(0,
|
|
386
|
+
(0, import_assert3.assertEx)(!failOnAlreadyExposed || !this._exposedAddresses.has(module2.address), () => `Address already exposed: ${id} [${module2.address}]`);
|
|
442
387
|
this._exposedAddresses.add(module2.address);
|
|
443
388
|
this._exposeOptions[module2.address] = {
|
|
444
389
|
...options
|
|
@@ -452,7 +397,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
452
397
|
...this.config?.listeningModules ?? [],
|
|
453
398
|
...this.exposedAddresses.values()
|
|
454
399
|
];
|
|
455
|
-
const mods = await Promise.all(exposedModules.map(async (exposedModule) => (0,
|
|
400
|
+
const mods = await Promise.all(exposedModules.map(async (exposedModule) => (0, import_assert3.assertEx)((0, import_module_model2.asModuleInstance)(await this.resolver.resolve(exposedModule, {
|
|
456
401
|
maxDepth: 10
|
|
457
402
|
})), () => `Unable to resolve listeningModule [${exposedModule}]`)));
|
|
458
403
|
return mods;
|
|
@@ -472,11 +417,11 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
472
417
|
this._pollId = void 0;
|
|
473
418
|
}
|
|
474
419
|
async unexpose(id, validate = true) {
|
|
475
|
-
const module2 = (0,
|
|
420
|
+
const module2 = (0, import_module_model2.asModuleInstance)(await this.resolver.resolve(id, {
|
|
476
421
|
maxDepth: 10
|
|
477
422
|
}));
|
|
478
423
|
if (module2) {
|
|
479
|
-
(0,
|
|
424
|
+
(0, import_assert3.assertEx)(!validate || this._exposedAddresses.has(module2.address), () => `Address not exposed [${module2.address}][${module2.id}]`);
|
|
480
425
|
this._exposedAddresses.delete(module2.address);
|
|
481
426
|
delete this._exposeOptions[module2.address];
|
|
482
427
|
this.logger?.debug(`${module2.address} [${module2.id}] unexposed`);
|
|
@@ -485,8 +430,8 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
485
430
|
}
|
|
486
431
|
callLocalModule = async (localModule, query) => {
|
|
487
432
|
const localModuleName = localModule.config.name ?? localModule.address;
|
|
488
|
-
const queryArchivist = (0,
|
|
489
|
-
const responsesArchivist = (0,
|
|
433
|
+
const queryArchivist = (0, import_assert3.assertEx)(await this.queriesArchivist(), () => `Unable to contact queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
|
|
434
|
+
const responsesArchivist = (0, import_assert3.assertEx)(await this.responsesArchivist(), () => `Unable to contact responsesArchivist [${this.config?.intersect?.queries?.archivist}]`);
|
|
490
435
|
const queryDestination = query.$meta?.destination;
|
|
491
436
|
if (queryDestination && queryDestination?.includes(localModule.address)) {
|
|
492
437
|
const queryIndex = query.payload_hashes.indexOf(query.query);
|
|
@@ -505,7 +450,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
505
450
|
this.logger?.debug(`Issuing query ${querySchema2} (${queryHash}) addressed to module: ${localModuleName}`);
|
|
506
451
|
const response = await localModule.query(query, queryPayloads, {
|
|
507
452
|
allowedQueries: this._exposeOptions[localModule.address]?.allowedQueries,
|
|
508
|
-
schema:
|
|
453
|
+
schema: import_module_model2.ModuleConfigSchema
|
|
509
454
|
});
|
|
510
455
|
const [bw, payloads, errors] = response;
|
|
511
456
|
this.logger?.debug(`Replying to query ${queryHash} addressed to module: ${localModuleName}`);
|
|
@@ -533,8 +478,9 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
533
478
|
* @param address The address to find commands for
|
|
534
479
|
*/
|
|
535
480
|
findQueriesToAddress = async (address) => {
|
|
536
|
-
const
|
|
537
|
-
|
|
481
|
+
const queriesDivinerId = (0, import_assert3.assertEx)(this.config?.intersect?.queries?.boundWitnessDiviner, () => "No queries Diviner defined");
|
|
482
|
+
const queriesBoundWitnessDiviner = await this.queriesDiviner();
|
|
483
|
+
if (queriesBoundWitnessDiviner) {
|
|
538
484
|
const timestamp = await this.retrieveState(address);
|
|
539
485
|
const destination = [
|
|
540
486
|
address
|
|
@@ -547,7 +493,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
547
493
|
sort: "asc",
|
|
548
494
|
timestamp
|
|
549
495
|
};
|
|
550
|
-
const result = await
|
|
496
|
+
const result = await queriesBoundWitnessDiviner.divine([
|
|
551
497
|
divinerQuery
|
|
552
498
|
]);
|
|
553
499
|
const queries = result.filter(import_boundwitness_model2.isQueryBoundWitnessWithMeta);
|
|
@@ -555,7 +501,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
|
|
|
555
501
|
await this.commitState(address, nextState);
|
|
556
502
|
return queries;
|
|
557
503
|
} else {
|
|
558
|
-
this.logger?.warn(`Unable to resolve
|
|
504
|
+
this.logger?.warn(`Unable to resolve queriesBoundWitnessDiviner [${queriesDivinerId}] [${await (0, import_module_model2.traceModuleIdentifier)(this.resolver, queriesDivinerId)}]`);
|
|
559
505
|
}
|
|
560
506
|
};
|
|
561
507
|
/**
|
|
@@ -649,18 +595,18 @@ var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
|
|
|
649
595
|
var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
|
|
650
596
|
|
|
651
597
|
// src/PubSubBridge.ts
|
|
652
|
-
var
|
|
598
|
+
var import_assert5 = require("@xylabs/assert");
|
|
653
599
|
var import_exists = require("@xylabs/exists");
|
|
654
600
|
var import_abstract_bridge3 = require("@xyo-network/abstract-bridge");
|
|
655
|
-
var
|
|
601
|
+
var import_module_model4 = require("@xyo-network/module-model");
|
|
656
602
|
|
|
657
603
|
// src/PubSubBridgeModuleResolver.ts
|
|
658
|
-
var
|
|
604
|
+
var import_assert4 = require("@xylabs/assert");
|
|
659
605
|
var import_hex = require("@xylabs/hex");
|
|
660
606
|
var import_abstract_bridge2 = require("@xyo-network/abstract-bridge");
|
|
661
607
|
var import_account = require("@xyo-network/account");
|
|
662
608
|
var import_config_payload_plugin = require("@xyo-network/config-payload-plugin");
|
|
663
|
-
var
|
|
609
|
+
var import_module_model3 = require("@xyo-network/module-model");
|
|
664
610
|
var PubSubBridgeModuleResolver = class extends import_abstract_bridge2.AbstractBridgeModuleResolver {
|
|
665
611
|
static {
|
|
666
612
|
__name(this, "PubSubBridgeModuleResolver");
|
|
@@ -672,14 +618,14 @@ var PubSubBridgeModuleResolver = class extends import_abstract_bridge2.AbstractB
|
|
|
672
618
|
}
|
|
673
619
|
const idParts = id.split(":");
|
|
674
620
|
const firstPart = idParts.shift();
|
|
675
|
-
(0,
|
|
621
|
+
(0, import_assert4.assertEx)((0, import_hex.isAddress)(firstPart), () => `Invalid module address: ${firstPart}`);
|
|
676
622
|
const remainderParts = idParts.join(":");
|
|
677
623
|
const account = import_account.Account.randomSync();
|
|
678
624
|
const params = {
|
|
679
625
|
account,
|
|
680
626
|
busClient: this.params.busClient,
|
|
681
627
|
config: {
|
|
682
|
-
schema:
|
|
628
|
+
schema: import_module_model3.ModuleConfigSchema
|
|
683
629
|
},
|
|
684
630
|
host: this.params.bridge,
|
|
685
631
|
moduleAddress: firstPart
|
|
@@ -689,13 +635,13 @@ var PubSubBridgeModuleResolver = class extends import_abstract_bridge2.AbstractB
|
|
|
689
635
|
const state = await proxy.state();
|
|
690
636
|
if (state) {
|
|
691
637
|
const configSchema = state.find((payload) => payload.schema === import_config_payload_plugin.ConfigSchema)?.config;
|
|
692
|
-
const config = (0,
|
|
638
|
+
const config = (0, import_assert4.assertEx)(state.find((payload) => payload.schema === configSchema), () => "Unable to locate config");
|
|
693
639
|
proxy.setConfig(config);
|
|
694
640
|
}
|
|
695
641
|
}
|
|
696
642
|
await proxy.start?.();
|
|
697
643
|
const wrapped = (0, import_abstract_bridge2.wrapModuleWithType)(proxy, account);
|
|
698
|
-
const as = (0,
|
|
644
|
+
const as = (0, import_assert4.assertEx)((0, import_module_model3.asModuleInstance)(wrapped, {}), () => `Failed to asModuleInstance [${id}]`);
|
|
699
645
|
proxy.upResolver.add(as);
|
|
700
646
|
proxy.downResolver.add(as);
|
|
701
647
|
this.add(as);
|
|
@@ -734,7 +680,7 @@ var PubSubBridge = class extends import_abstract_bridge3.AbstractBridge {
|
|
|
734
680
|
get resolver() {
|
|
735
681
|
this._resolver = this._resolver ?? new PubSubBridgeModuleResolver({
|
|
736
682
|
bridge: this,
|
|
737
|
-
busClient: (0,
|
|
683
|
+
busClient: (0, import_assert5.assertEx)(this.busClient(), () => "busClient not configured"),
|
|
738
684
|
wrapperAccount: this.account
|
|
739
685
|
});
|
|
740
686
|
return this._resolver;
|
|
@@ -743,7 +689,7 @@ var PubSubBridge = class extends import_abstract_bridge3.AbstractBridge {
|
|
|
743
689
|
return `${this.config.name ?? moduleName}`;
|
|
744
690
|
}
|
|
745
691
|
get roots() {
|
|
746
|
-
return (0,
|
|
692
|
+
return (0, import_assert5.assertEx)(this.config.roots, () => "roots not configured");
|
|
747
693
|
}
|
|
748
694
|
async discoverRoots() {
|
|
749
695
|
const rootInstances = (await Promise.all(this.roots.map(async (root) => await this.resolver.resolve(root)))).filter(import_exists.exists);
|
|
@@ -754,7 +700,7 @@ var PubSubBridge = class extends import_abstract_bridge3.AbstractBridge {
|
|
|
754
700
|
}
|
|
755
701
|
async exposeHandler(id, options) {
|
|
756
702
|
const { maxDepth = 2, direction = "all", required = true } = options ?? {};
|
|
757
|
-
const host = (0,
|
|
703
|
+
const host = (0, import_assert5.assertEx)(this.busHost(), () => "Not configured as a host");
|
|
758
704
|
const module2 = await host.expose(id, {
|
|
759
705
|
required
|
|
760
706
|
});
|
|
@@ -787,7 +733,7 @@ var PubSubBridge = class extends import_abstract_bridge3.AbstractBridge {
|
|
|
787
733
|
}
|
|
788
734
|
async unexposeHandler(id, options) {
|
|
789
735
|
const { maxDepth = 2, direction = "all", required = true } = options ?? {};
|
|
790
|
-
const host = (0,
|
|
736
|
+
const host = (0, import_assert5.assertEx)(this.busHost(), () => "Not configured as a host");
|
|
791
737
|
const module2 = await host.unexpose(id, required);
|
|
792
738
|
if (module2) {
|
|
793
739
|
const children = maxDepth > 0 ? await module2.resolve("*", {
|
|
@@ -832,6 +778,6 @@ var PubSubBridge = class extends import_abstract_bridge3.AbstractBridge {
|
|
|
832
778
|
}
|
|
833
779
|
};
|
|
834
780
|
PubSubBridge = _ts_decorate([
|
|
835
|
-
(0,
|
|
781
|
+
(0, import_module_model4.creatableModule)()
|
|
836
782
|
], PubSubBridge);
|
|
837
783
|
//# sourceMappingURL=index.cjs.map
|