@xyo-network/bridge-pub-sub 2.94.11 → 2.94.13

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.
Files changed (55) hide show
  1. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts +66 -6
  2. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  3. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +66 -6
  4. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  5. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +66 -6
  6. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  7. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
  8. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
  9. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
  10. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts +1 -1
  11. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
  12. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts +1 -1
  13. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
  14. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts +1 -1
  15. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
  16. package/dist/browser/PubSubBridgeModuleResolver.d.cts +3 -3
  17. package/dist/browser/PubSubBridgeModuleResolver.d.cts.map +1 -1
  18. package/dist/browser/PubSubBridgeModuleResolver.d.mts +3 -3
  19. package/dist/browser/PubSubBridgeModuleResolver.d.mts.map +1 -1
  20. package/dist/browser/PubSubBridgeModuleResolver.d.ts +3 -3
  21. package/dist/browser/PubSubBridgeModuleResolver.d.ts.map +1 -1
  22. package/dist/browser/index.cjs +135 -93
  23. package/dist/browser/index.cjs.map +1 -1
  24. package/dist/browser/index.js +135 -93
  25. package/dist/browser/index.js.map +1 -1
  26. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +66 -6
  27. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  28. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +66 -6
  29. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  30. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +66 -6
  31. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  32. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
  33. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
  34. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
  35. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts +1 -1
  36. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
  37. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts +1 -1
  38. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
  39. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts +1 -1
  40. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
  41. package/dist/node/PubSubBridgeModuleResolver.d.cts +3 -3
  42. package/dist/node/PubSubBridgeModuleResolver.d.cts.map +1 -1
  43. package/dist/node/PubSubBridgeModuleResolver.d.mts +3 -3
  44. package/dist/node/PubSubBridgeModuleResolver.d.mts.map +1 -1
  45. package/dist/node/PubSubBridgeModuleResolver.d.ts +3 -3
  46. package/dist/node/PubSubBridgeModuleResolver.d.ts.map +1 -1
  47. package/dist/node/index.cjs +141 -122
  48. package/dist/node/index.cjs.map +1 -1
  49. package/dist/node/index.js +141 -122
  50. package/dist/node/index.js.map +1 -1
  51. package/package.json +18 -17
  52. package/src/AsyncQueryBus/AsyncQueryBusBase.ts +69 -40
  53. package/src/AsyncQueryBus/AsyncQueryBusClient.ts +24 -26
  54. package/src/AsyncQueryBus/AsyncQueryBusHost.ts +20 -19
  55. package/src/PubSubBridgeModuleResolver.ts +5 -5
@@ -10,7 +10,7 @@ var AbstractModuleHost = class extends Base {
10
10
  };
11
11
 
12
12
  // src/AsyncQueryBus/AsyncQueryBusClient.ts
13
- import { assertEx as assertEx2 } from "@xylabs/assert";
13
+ import { assertEx } from "@xylabs/assert";
14
14
  import { delay } from "@xylabs/delay";
15
15
  import { forget } from "@xylabs/forget";
16
16
  import { clearTimeoutEx, setTimeoutEx } from "@xylabs/timer";
@@ -20,7 +20,6 @@ import { PayloadBuilder } from "@xyo-network/payload-builder";
20
20
  import { LRUCache as LRUCache2 } from "lru-cache";
21
21
 
22
22
  // src/AsyncQueryBus/AsyncQueryBusBase.ts
23
- import { assertEx } from "@xylabs/assert";
24
23
  import { Base as Base2, toJsonString } from "@xylabs/object";
25
24
  import { asArchivistInstance } from "@xyo-network/archivist-model";
26
25
  import { asDivinerInstance } from "@xyo-network/diviner-model";
@@ -34,13 +33,13 @@ var AsyncQueryBusBase = class extends Base2 {
34
33
  _targetQueries = {};
35
34
  _lastQueriesArchivistAttempt;
36
35
  _lastQueriesDivinerAttempt;
37
- _lastResponseArchivistAttempt;
38
- _lastResponseDivinerAttempt;
36
+ _lastResponsesArchivistAttempt;
37
+ _lastResponsesDivinerAttempt;
39
38
  _queriesArchivist;
40
39
  _queriesDiviner;
41
- _reResolveDelay = 5e3;
42
- _responseArchivist;
43
- _responseDiviner;
40
+ _reResolveDelay = 5e4;
41
+ _responsesArchivist;
42
+ _responsesDiviner;
44
43
  constructor(params) {
45
44
  super(params);
46
45
  }
@@ -68,46 +67,81 @@ var AsyncQueryBusBase = class extends Base2 {
68
67
  if (this._queriesArchivist) {
69
68
  return this._queriesArchivist;
70
69
  }
71
- if (this._lastQueriesArchivistAttempt && Date.now() - this._lastQueriesArchivistAttempt < this._reResolveDelay) {
70
+ if (Date.now() - (this._lastQueriesArchivistAttempt ?? 0) < this._reResolveDelay) {
72
71
  return;
73
72
  }
74
- const resolved = await this.resolver.resolve(this.config?.intersect?.queries?.archivist, {
75
- direction: "up"
76
- });
77
- const existingResolved = assertEx(resolved, () => `Unable to resolve queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
78
- const result = asArchivistInstance(existingResolved, () => `Unable to resolve queriesArchivist as correct type [${this.config?.intersect?.queries?.archivist}][${existingResolved?.constructor?.name}]: ${toJsonString(existingResolved)}`);
79
- this._queriesArchivist = result;
80
- return result;
73
+ this._lastQueriesArchivistAttempt = Date.now();
74
+ const resolved = await this.resolver.resolve(this.config?.intersect?.queries?.archivist);
75
+ if (resolved) {
76
+ const typedResolve = asArchivistInstance(resolved);
77
+ if (typedResolve) {
78
+ return typedResolve;
79
+ } else {
80
+ this.logger?.warn(`Unable to resolve queriesArchivist as correct type [${this.config?.intersect?.queries?.archivist}][${resolved?.constructor?.name}]: ${toJsonString(resolved)}`);
81
+ }
82
+ } else {
83
+ this.logger?.log(`Unable to resolve queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
84
+ }
81
85
  }
82
86
  async queriesDiviner() {
83
87
  if (this._queriesDiviner) {
84
88
  return this._queriesDiviner;
85
89
  }
86
- if (this._lastQueriesDivinerAttempt && Date.now() - this._lastQueriesDivinerAttempt < this._reResolveDelay) {
90
+ if (Date.now() - (this._lastQueriesDivinerAttempt ?? 0) < this._reResolveDelay) {
87
91
  return;
88
92
  }
89
- this._queriesDiviner = assertEx(asDivinerInstance(await this.resolver.resolve(this.config?.intersect?.queries?.boundWitnessDiviner)), () => `Unable to resolve queriesDiviner [${this.config?.intersect?.queries?.boundWitnessDiviner}]`);
90
- return this._queriesDiviner;
93
+ this._lastQueriesDivinerAttempt = Date.now();
94
+ const resolved = await this.resolver.resolve(this.config?.intersect?.queries?.boundWitnessDiviner);
95
+ if (resolved) {
96
+ const typedResolve = asDivinerInstance(resolved);
97
+ if (typedResolve) {
98
+ return typedResolve;
99
+ } else {
100
+ this.logger?.warn(`Unable to resolve queriesDiviner as correct type [${this.config?.intersect?.queries?.boundWitnessDiviner}][${resolved?.constructor?.name}]: ${toJsonString(resolved)}`);
101
+ }
102
+ } else {
103
+ this.logger?.log(`Unable to resolve queriesDiviner [${this.config?.intersect?.queries?.boundWitnessDiviner}]`);
104
+ }
91
105
  }
92
106
  async responsesArchivist() {
93
- if (this._responseArchivist) {
94
- return this._responseArchivist;
107
+ if (this._responsesArchivist) {
108
+ return this._responsesArchivist;
95
109
  }
96
- if (this._lastResponseArchivistAttempt && Date.now() - this._lastResponseArchivistAttempt < this._reResolveDelay) {
110
+ if (Date.now() - (this._lastResponsesArchivistAttempt ?? 0) < this._reResolveDelay) {
97
111
  return;
98
112
  }
99
- this._responseArchivist = assertEx(asArchivistInstance(await this.resolver.resolve(this.config?.intersect?.responses?.archivist)), () => `Unable to resolve responsesArchivist [${this.config?.intersect?.responses?.archivist}]`);
100
- return this._responseArchivist;
113
+ this._lastResponsesArchivistAttempt = Date.now();
114
+ const resolved = await this.resolver.resolve(this.config?.intersect?.responses?.archivist);
115
+ if (resolved) {
116
+ const typedResolve = asArchivistInstance(resolved);
117
+ if (typedResolve) {
118
+ return typedResolve;
119
+ } else {
120
+ this.logger?.warn(`Unable to resolve responseArchivist as correct type [${this.config?.intersect?.responses?.archivist}][${resolved?.constructor?.name}]: ${toJsonString(resolved)}`);
121
+ }
122
+ } else {
123
+ this.logger?.log(`Unable to resolve responseArchivist [${this.config?.intersect?.responses?.archivist}]`);
124
+ }
101
125
  }
102
126
  async responsesDiviner() {
103
- if (this._responseDiviner) {
104
- return this._responseDiviner;
127
+ if (this._responsesDiviner) {
128
+ return this._responsesDiviner;
105
129
  }
106
- if (this._lastResponseDivinerAttempt && Date.now() - this._lastResponseDivinerAttempt < this._reResolveDelay) {
130
+ if (Date.now() - (this._lastResponsesDivinerAttempt ?? 0) < this._reResolveDelay) {
107
131
  return;
108
132
  }
109
- this._responseDiviner = assertEx(asDivinerInstance(await this.resolver.resolve(this.config?.intersect?.responses?.boundWitnessDiviner)), () => `Unable to resolve responsesDiviner [${this.config?.intersect?.responses?.boundWitnessDiviner}]`);
110
- return this._responseDiviner;
133
+ this._lastResponsesDivinerAttempt = Date.now();
134
+ const resolved = await this.resolver.resolve(this.config?.intersect?.responses?.boundWitnessDiviner);
135
+ if (resolved) {
136
+ const typedResolve = asDivinerInstance(resolved);
137
+ if (typedResolve) {
138
+ return typedResolve;
139
+ } else {
140
+ this.logger?.warn(`Unable to resolve responsesDiviner as correct type [${this.config?.intersect?.responses?.boundWitnessDiviner}][${resolved?.constructor?.name}]: ${toJsonString(resolved)}`);
141
+ }
142
+ } else {
143
+ this.logger?.log(`Unable to resolve responsesDiviner [${this.config?.intersect?.responses?.boundWitnessDiviner}]`);
144
+ }
111
145
  }
112
146
  /**
113
147
  * Commit the internal state of the process. This is similar
@@ -196,7 +230,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
196
230
  ...query,
197
231
  $meta
198
232
  });
199
- const queryArchivist = assertEx2(await this.queriesArchivist(), () => `Unable to contact queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
233
+ const queryArchivist = assertEx(await this.queriesArchivist(), () => `Unable to contact queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
200
234
  const routedQueryHash = (
201
235
  // Trust the signed hash if it's there
202
236
  routedQuery?.$hash ?? // TODO: What is the right way to find the dataHash
@@ -272,34 +306,38 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
272
306
  * Background process for processing incoming responses to previously issued queries
273
307
  */
274
308
  processIncomingResponses = async () => {
275
- const responseArchivist = assertEx2(await this.responsesArchivist(), () => `Unable to contact the responsesArchivist [${this.config?.intersect?.responses?.archivist}]`);
276
- const responseBoundWitnessDiviner = assertEx2(await this.responsesDiviner(), () => `Unable to contact responsesDiviner [${this.config?.intersect?.responses?.boundWitnessDiviner}]`);
277
- const pendingCommands = [
278
- ...this.queryCache.entries()
279
- ].filter(([_, status]) => status === Pending);
280
- await Promise.allSettled(pendingCommands.map(async ([sourceQuery, status]) => {
281
- if (status === Pending) {
282
- const divinerQuery = {
283
- schema: BoundWitnessDivinerQuerySchema,
284
- sourceQuery
285
- };
286
- const result = await responseBoundWitnessDiviner.divine([
287
- divinerQuery
288
- ]);
289
- if (result && result.length > 0) {
290
- const response = result.find(isBoundWitnessWithMeta);
291
- if (response && response?.$meta?.sourceQuery === sourceQuery) {
292
- this.logger?.debug(`Found response to query: ${sourceQuery}`);
293
- const payloads = response.payload_hashes?.length > 0 ? await responseArchivist.get(response.payload_hashes) : [];
294
- this.queryCache.set(sourceQuery, [
295
- response,
296
- payloads,
297
- []
309
+ const responseArchivist = await this.responsesArchivist();
310
+ if (responseArchivist) {
311
+ const responseBoundWitnessDiviner = await this.responsesDiviner();
312
+ if (responseBoundWitnessDiviner) {
313
+ const pendingCommands = [
314
+ ...this.queryCache.entries()
315
+ ].filter(([_, status]) => status === Pending);
316
+ await Promise.allSettled(pendingCommands.map(async ([sourceQuery, status]) => {
317
+ if (status === Pending) {
318
+ const divinerQuery = {
319
+ schema: BoundWitnessDivinerQuerySchema,
320
+ sourceQuery
321
+ };
322
+ const result = await responseBoundWitnessDiviner.divine([
323
+ divinerQuery
298
324
  ]);
325
+ if (result && result.length > 0) {
326
+ const response = result.find(isBoundWitnessWithMeta);
327
+ if (response && response?.$meta?.sourceQuery === sourceQuery) {
328
+ this.logger?.debug(`Found response to query: ${sourceQuery}`);
329
+ const payloads = response.payload_hashes?.length > 0 ? await responseArchivist.get(response.payload_hashes) : [];
330
+ this.queryCache.set(sourceQuery, [
331
+ response,
332
+ payloads,
333
+ []
334
+ ]);
335
+ }
336
+ }
299
337
  }
300
- }
338
+ }));
301
339
  }
302
- }));
340
+ }
303
341
  };
304
342
  start() {
305
343
  if (this._pollCount === 0) {
@@ -320,7 +358,7 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
320
358
 
321
359
  // src/AsyncQueryBus/AsyncQueryBusHost.ts
322
360
  import { containsAll } from "@xylabs/array";
323
- import { assertEx as assertEx3 } from "@xylabs/assert";
361
+ import { assertEx as assertEx2 } from "@xylabs/assert";
324
362
  import { clearTimeoutEx as clearTimeoutEx2, setTimeoutEx as setTimeoutEx2 } from "@xylabs/timer";
325
363
  import { isQueryBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
326
364
  import { BoundWitnessDivinerQuerySchema as BoundWitnessDivinerQuerySchema2 } from "@xyo-network/diviner-boundwitness-model";
@@ -347,7 +385,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
347
385
  }
348
386
  expose(address, options = {}) {
349
387
  const { failOnAlreadyExposed } = options;
350
- assertEx3(!failOnAlreadyExposed || !this._exposedAddresses.has(address), () => `Address already exposed [${address}]`);
388
+ assertEx2(!failOnAlreadyExposed || !this._exposedAddresses.has(address), () => `Address already exposed [${address}]`);
351
389
  this._exposedAddresses.add(address);
352
390
  this._exposeOptions[address] = {
353
391
  ...options
@@ -359,7 +397,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
359
397
  ...this.config?.listeningModules ?? [],
360
398
  ...this.exposedAddresses.values()
361
399
  ];
362
- const mods = await Promise.all(exposedModules.map(async (listeningModule) => assertEx3(asModuleInstance(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`)));
400
+ const mods = await Promise.all(exposedModules.map(async (listeningModule) => assertEx2(asModuleInstance(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`)));
363
401
  return mods;
364
402
  }
365
403
  start() {
@@ -377,15 +415,15 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
377
415
  this._pollId = void 0;
378
416
  }
379
417
  unexpose(address, validate = true) {
380
- assertEx3(!validate || this._exposedAddresses.has(address), () => `Address not exposed [${address}]`);
418
+ assertEx2(!validate || this._exposedAddresses.has(address), () => `Address not exposed [${address}]`);
381
419
  this._exposedAddresses.delete(address);
382
420
  delete this._exposeOptions[address];
383
421
  this.logger?.debug(`${address} unexposed`);
384
422
  }
385
423
  callLocalModule = async (localModule, query) => {
386
424
  const localModuleName = localModule.config.name ?? localModule.address;
387
- const queryArchivist = assertEx3(await this.queriesArchivist(), () => `Unable to contact queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
388
- const responsesArchivist = assertEx3(await this.responsesArchivist(), () => `Unable to contact responsesArchivist [${this.config?.intersect?.queries?.archivist}]`);
425
+ const queryArchivist = assertEx2(await this.queriesArchivist(), () => `Unable to contact queriesArchivist [${this.config?.intersect?.queries?.archivist}]`);
426
+ const responsesArchivist = assertEx2(await this.responsesArchivist(), () => `Unable to contact responsesArchivist [${this.config?.intersect?.queries?.archivist}]`);
389
427
  const queryDestination = query.$meta?.destination;
390
428
  if (queryDestination && queryDestination?.includes(localModule.address)) {
391
429
  const queryIndex = query.payload_hashes.indexOf(query.query);
@@ -432,26 +470,30 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
432
470
  * @param address The address to find commands for
433
471
  */
434
472
  findQueriesToAddress = async (address) => {
435
- const queryBoundWitnessDiviner = assertEx3(await this.queriesDiviner(), () => `Unable to resolve queriesDiviner [${this.config?.intersect?.queries?.boundWitnessDiviner}]`);
436
- const timestamp = await this.retrieveState(address);
437
- const destination = [
438
- address
439
- ];
440
- const limit = this.perAddressBatchQueryLimit;
441
- const divinerQuery = {
442
- destination,
443
- limit,
444
- schema: BoundWitnessDivinerQuerySchema2,
445
- sort: "asc",
446
- timestamp
447
- };
448
- const result = await queryBoundWitnessDiviner.divine([
449
- divinerQuery
450
- ]);
451
- const queries = result.filter(isQueryBoundWitnessWithMeta);
452
- const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp;
453
- await this.commitState(address, nextState);
454
- return queries;
473
+ const queryBoundWitnessDiviner = await this.queriesDiviner();
474
+ if (queryBoundWitnessDiviner) {
475
+ const timestamp = await this.retrieveState(address);
476
+ const destination = [
477
+ address
478
+ ];
479
+ const limit = this.perAddressBatchQueryLimit;
480
+ const divinerQuery = {
481
+ destination,
482
+ limit,
483
+ schema: BoundWitnessDivinerQuerySchema2,
484
+ sort: "asc",
485
+ timestamp
486
+ };
487
+ const result = await queryBoundWitnessDiviner.divine([
488
+ divinerQuery
489
+ ]);
490
+ const queries = result.filter(isQueryBoundWitnessWithMeta);
491
+ const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp;
492
+ await this.commitState(address, nextState);
493
+ return queries;
494
+ } else {
495
+ this.logger?.warn(`Unable to resolve queryBoundWitnessDiviner [${this.config?.intersect?.queries?.boundWitnessDiviner}]`);
496
+ }
455
497
  };
456
498
  /**
457
499
  * Runs the background divine process on a loop with a delay
@@ -481,7 +523,7 @@ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
481
523
  try {
482
524
  const localModuleName = localModule.config.name ?? localModule.address;
483
525
  this.logger?.debug(`Checking for inbound queries to ${localModuleName} [${localModule.address}]`);
484
- const queries = await this.findQueriesToAddress(localModule.address);
526
+ const queries = await this.findQueriesToAddress(localModule.address) ?? [];
485
527
  if (queries.length === 0)
486
528
  return;
487
529
  this.logger?.debug(`Found queries addressed to local module: ${localModuleName}`);
@@ -544,13 +586,13 @@ var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
544
586
  var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
545
587
 
546
588
  // src/PubSubBridge.ts
547
- import { assertEx as assertEx5 } from "@xylabs/assert";
589
+ import { assertEx as assertEx4 } from "@xylabs/assert";
548
590
  import { exists } from "@xylabs/exists";
549
591
  import { AbstractBridge } from "@xyo-network/abstract-bridge";
550
592
  import { creatableModule } from "@xyo-network/module-model";
551
593
 
552
594
  // src/PubSubBridgeModuleResolver.ts
553
- import { assertEx as assertEx4 } from "@xylabs/assert";
595
+ import { assertEx as assertEx3 } from "@xylabs/assert";
554
596
  import { isAddress } from "@xylabs/hex";
555
597
  import { AbstractBridgeModuleResolver, wrapModuleWithType } from "@xyo-network/abstract-bridge";
556
598
  import { Account } from "@xyo-network/account";
@@ -567,16 +609,16 @@ var PubSubBridgeModuleResolver = class extends AbstractBridgeModuleResolver {
567
609
  }
568
610
  const idParts = id.split(":");
569
611
  const firstPart = idParts.shift();
570
- assertEx4(isAddress(firstPart), () => `Invalid module address: ${firstPart}`);
612
+ assertEx3(isAddress(firstPart), () => `Invalid module address: ${firstPart}`);
571
613
  const remainderParts = idParts.join(":");
572
614
  const account = Account.randomSync();
573
615
  const params = {
574
616
  account,
575
- busClient: this.options.busClient,
617
+ busClient: this.params.busClient,
576
618
  config: {
577
619
  schema: ModuleConfigSchema2
578
620
  },
579
- host: this.options.bridge,
621
+ host: this.params.bridge,
580
622
  moduleAddress: firstPart
581
623
  };
582
624
  const proxy = new AsyncQueryBusModuleProxy(params);
@@ -584,13 +626,13 @@ var PubSubBridgeModuleResolver = class extends AbstractBridgeModuleResolver {
584
626
  const state = await proxy.state();
585
627
  if (state) {
586
628
  const configSchema = state.find((payload) => payload.schema === ConfigSchema)?.config;
587
- const config = assertEx4(state.find((payload) => payload.schema === configSchema), () => "Unable to locate config");
629
+ const config = assertEx3(state.find((payload) => payload.schema === configSchema), () => "Unable to locate config");
588
630
  proxy.setConfig(config);
589
631
  }
590
632
  }
591
633
  await proxy.start?.();
592
634
  const wrapped = wrapModuleWithType(proxy, account);
593
- const as = assertEx4(asModuleInstance2(wrapped, {}), () => `Failed to asModuleInstance [${id}]`);
635
+ const as = assertEx3(asModuleInstance2(wrapped, {}), () => `Failed to asModuleInstance [${id}]`);
594
636
  proxy.upResolver.add(as);
595
637
  proxy.downResolver.add(as);
596
638
  this.add(as);
@@ -629,7 +671,7 @@ var PubSubBridge = class extends AbstractBridge {
629
671
  get resolver() {
630
672
  this._resolver = this._resolver ?? new PubSubBridgeModuleResolver({
631
673
  bridge: this,
632
- busClient: assertEx5(this.busClient(), () => "busClient not configured"),
674
+ busClient: assertEx4(this.busClient(), () => "busClient not configured"),
633
675
  wrapperAccount: this.account
634
676
  });
635
677
  return this._resolver;
@@ -638,7 +680,7 @@ var PubSubBridge = class extends AbstractBridge {
638
680
  return `${this.config.name ?? moduleName}`;
639
681
  }
640
682
  get roots() {
641
- return assertEx5(this.config.roots, () => "roots not configured");
683
+ return assertEx4(this.config.roots, () => "roots not configured");
642
684
  }
643
685
  async discoverRoots() {
644
686
  const rootInstances = (await Promise.all(this.roots.map(async (root) => await this.resolver.resolve(root)))).filter(exists);
@@ -649,9 +691,9 @@ var PubSubBridge = class extends AbstractBridge {
649
691
  }
650
692
  async exposeHandler(id, options) {
651
693
  const { maxDepth = 2, direction = "all" } = options ?? {};
652
- const module = assertEx5(await super.resolve(id), () => `Expose failed to locate module [${id}]`);
694
+ const module = assertEx4(await super.resolve(id), () => `Expose failed to locate module [${id}]`);
653
695
  if (module) {
654
- const host = assertEx5(this.busHost(), () => "Not configured as a host");
696
+ const host = assertEx4(this.busHost(), () => "Not configured as a host");
655
697
  host.expose(module.address);
656
698
  const children = await module.resolve("*", {
657
699
  direction,
@@ -685,7 +727,7 @@ var PubSubBridge = class extends AbstractBridge {
685
727
  };
686
728
  const module = await super.resolve(id, filterOptions);
687
729
  if (module) {
688
- const host = assertEx5(this.busHost(), () => "Not configured as a host");
730
+ const host = assertEx4(this.busHost(), () => "Not configured as a host");
689
731
  host.unexpose(module.address);
690
732
  const children = await module.resolve("*", {
691
733
  direction,