@xyo-network/bridge-pub-sub 2.90.23 → 2.91.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.cts +11 -0
  2. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.cts.map +1 -0
  3. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.mts +11 -0
  4. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.mts.map +1 -0
  5. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.ts +11 -0
  6. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.ts.map +1 -0
  7. package/dist/browser/AbstractModuleHost/index.d.cts +2 -0
  8. package/dist/browser/AbstractModuleHost/index.d.cts.map +1 -0
  9. package/dist/browser/AbstractModuleHost/index.d.mts +2 -0
  10. package/dist/browser/AbstractModuleHost/index.d.mts.map +1 -0
  11. package/dist/browser/AbstractModuleHost/index.d.ts +2 -0
  12. package/dist/browser/AbstractModuleHost/index.d.ts.map +1 -0
  13. package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.cts +90 -0
  14. package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.cts.map +1 -0
  15. package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.mts +90 -0
  16. package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.mts.map +1 -0
  17. package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.ts +90 -0
  18. package/dist/browser/AbstractModuleProxy/AbstractModuleProxy.d.ts.map +1 -0
  19. package/dist/browser/AbstractModuleProxy/index.d.cts +2 -0
  20. package/dist/browser/AbstractModuleProxy/index.d.cts.map +1 -0
  21. package/dist/browser/AbstractModuleProxy/index.d.mts +2 -0
  22. package/dist/browser/AbstractModuleProxy/index.d.mts.map +1 -0
  23. package/dist/browser/AbstractModuleProxy/index.d.ts +2 -0
  24. package/dist/browser/AbstractModuleProxy/index.d.ts.map +1 -0
  25. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts +75 -38
  26. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  27. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +75 -38
  28. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  29. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +75 -38
  30. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  31. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts +16 -46
  32. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
  33. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts +16 -46
  34. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
  35. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts +16 -46
  36. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
  37. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts +37 -0
  38. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -0
  39. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts +37 -0
  40. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -0
  41. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts +37 -0
  42. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -0
  43. package/dist/browser/AsyncQueryBus/Config.d.cts +21 -31
  44. package/dist/browser/AsyncQueryBus/Config.d.cts.map +1 -1
  45. package/dist/browser/AsyncQueryBus/Config.d.mts +21 -31
  46. package/dist/browser/AsyncQueryBus/Config.d.mts.map +1 -1
  47. package/dist/browser/AsyncQueryBus/Config.d.ts +21 -31
  48. package/dist/browser/AsyncQueryBus/Config.d.ts.map +1 -1
  49. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.cts +12 -0
  50. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.cts.map +1 -0
  51. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.mts +12 -0
  52. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.mts.map +1 -0
  53. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.ts +12 -0
  54. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.ts.map +1 -0
  55. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.cts +2 -0
  56. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.cts.map +1 -0
  57. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.mts +2 -0
  58. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.mts.map +1 -0
  59. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.ts +2 -0
  60. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.ts.map +1 -0
  61. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts +12 -0
  62. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +1 -0
  63. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts +12 -0
  64. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +1 -0
  65. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts +12 -0
  66. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +1 -0
  67. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.cts +2 -0
  68. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.cts.map +1 -0
  69. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.mts +2 -0
  70. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.mts.map +1 -0
  71. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.ts +2 -0
  72. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.ts.map +1 -0
  73. package/dist/browser/AsyncQueryBus/Params.d.cts +5 -3
  74. package/dist/browser/AsyncQueryBus/Params.d.cts.map +1 -1
  75. package/dist/browser/AsyncQueryBus/Params.d.mts +5 -3
  76. package/dist/browser/AsyncQueryBus/Params.d.mts.map +1 -1
  77. package/dist/browser/AsyncQueryBus/Params.d.ts +5 -3
  78. package/dist/browser/AsyncQueryBus/Params.d.ts.map +1 -1
  79. package/dist/browser/AsyncQueryBus/index.d.cts +3 -1
  80. package/dist/browser/AsyncQueryBus/index.d.cts.map +1 -1
  81. package/dist/browser/AsyncQueryBus/index.d.mts +3 -1
  82. package/dist/browser/AsyncQueryBus/index.d.mts.map +1 -1
  83. package/dist/browser/AsyncQueryBus/index.d.ts +3 -1
  84. package/dist/browser/AsyncQueryBus/index.d.ts.map +1 -1
  85. package/dist/browser/Config.d.cts +5 -2
  86. package/dist/browser/Config.d.cts.map +1 -1
  87. package/dist/browser/Config.d.mts +5 -2
  88. package/dist/browser/Config.d.mts.map +1 -1
  89. package/dist/browser/Config.d.ts +5 -2
  90. package/dist/browser/Config.d.ts.map +1 -1
  91. package/dist/browser/PubSubBridge.d.cts +14 -19
  92. package/dist/browser/PubSubBridge.d.cts.map +1 -1
  93. package/dist/browser/PubSubBridge.d.mts +14 -19
  94. package/dist/browser/PubSubBridge.d.mts.map +1 -1
  95. package/dist/browser/PubSubBridge.d.ts +14 -19
  96. package/dist/browser/PubSubBridge.d.ts.map +1 -1
  97. package/dist/browser/index.cjs +341 -135
  98. package/dist/browser/index.cjs.map +1 -1
  99. package/dist/browser/index.d.cts +2 -0
  100. package/dist/browser/index.d.cts.map +1 -1
  101. package/dist/browser/index.d.mts +2 -0
  102. package/dist/browser/index.d.mts.map +1 -1
  103. package/dist/browser/index.d.ts +2 -0
  104. package/dist/browser/index.d.ts.map +1 -1
  105. package/dist/browser/index.js +343 -137
  106. package/dist/browser/index.js.map +1 -1
  107. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.cts +11 -0
  108. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.cts.map +1 -0
  109. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.mts +11 -0
  110. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.mts.map +1 -0
  111. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.ts +11 -0
  112. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.ts.map +1 -0
  113. package/dist/node/AbstractModuleHost/index.d.cts +2 -0
  114. package/dist/node/AbstractModuleHost/index.d.cts.map +1 -0
  115. package/dist/node/AbstractModuleHost/index.d.mts +2 -0
  116. package/dist/node/AbstractModuleHost/index.d.mts.map +1 -0
  117. package/dist/node/AbstractModuleHost/index.d.ts +2 -0
  118. package/dist/node/AbstractModuleHost/index.d.ts.map +1 -0
  119. package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.cts +90 -0
  120. package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.cts.map +1 -0
  121. package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.mts +90 -0
  122. package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.mts.map +1 -0
  123. package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.ts +90 -0
  124. package/dist/node/AbstractModuleProxy/AbstractModuleProxy.d.ts.map +1 -0
  125. package/dist/node/AbstractModuleProxy/index.d.cts +2 -0
  126. package/dist/node/AbstractModuleProxy/index.d.cts.map +1 -0
  127. package/dist/node/AbstractModuleProxy/index.d.mts +2 -0
  128. package/dist/node/AbstractModuleProxy/index.d.mts.map +1 -0
  129. package/dist/node/AbstractModuleProxy/index.d.ts +2 -0
  130. package/dist/node/AbstractModuleProxy/index.d.ts.map +1 -0
  131. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +75 -38
  132. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  133. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +75 -38
  134. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  135. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +75 -38
  136. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  137. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts +16 -46
  138. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
  139. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts +16 -46
  140. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
  141. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts +16 -46
  142. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
  143. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts +37 -0
  144. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -0
  145. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts +37 -0
  146. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -0
  147. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts +37 -0
  148. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -0
  149. package/dist/node/AsyncQueryBus/Config.d.cts +21 -31
  150. package/dist/node/AsyncQueryBus/Config.d.cts.map +1 -1
  151. package/dist/node/AsyncQueryBus/Config.d.mts +21 -31
  152. package/dist/node/AsyncQueryBus/Config.d.mts.map +1 -1
  153. package/dist/node/AsyncQueryBus/Config.d.ts +21 -31
  154. package/dist/node/AsyncQueryBus/Config.d.ts.map +1 -1
  155. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.cts +12 -0
  156. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.cts.map +1 -0
  157. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.mts +12 -0
  158. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.mts.map +1 -0
  159. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.ts +12 -0
  160. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.ts.map +1 -0
  161. package/dist/node/AsyncQueryBus/ModuleHost/index.d.cts +2 -0
  162. package/dist/node/AsyncQueryBus/ModuleHost/index.d.cts.map +1 -0
  163. package/dist/node/AsyncQueryBus/ModuleHost/index.d.mts +2 -0
  164. package/dist/node/AsyncQueryBus/ModuleHost/index.d.mts.map +1 -0
  165. package/dist/node/AsyncQueryBus/ModuleHost/index.d.ts +2 -0
  166. package/dist/node/AsyncQueryBus/ModuleHost/index.d.ts.map +1 -0
  167. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts +12 -0
  168. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +1 -0
  169. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts +12 -0
  170. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +1 -0
  171. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts +12 -0
  172. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +1 -0
  173. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.cts +2 -0
  174. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.cts.map +1 -0
  175. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.mts +2 -0
  176. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.mts.map +1 -0
  177. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.ts +2 -0
  178. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.ts.map +1 -0
  179. package/dist/node/AsyncQueryBus/Params.d.cts +5 -3
  180. package/dist/node/AsyncQueryBus/Params.d.cts.map +1 -1
  181. package/dist/node/AsyncQueryBus/Params.d.mts +5 -3
  182. package/dist/node/AsyncQueryBus/Params.d.mts.map +1 -1
  183. package/dist/node/AsyncQueryBus/Params.d.ts +5 -3
  184. package/dist/node/AsyncQueryBus/Params.d.ts.map +1 -1
  185. package/dist/node/AsyncQueryBus/index.d.cts +3 -1
  186. package/dist/node/AsyncQueryBus/index.d.cts.map +1 -1
  187. package/dist/node/AsyncQueryBus/index.d.mts +3 -1
  188. package/dist/node/AsyncQueryBus/index.d.mts.map +1 -1
  189. package/dist/node/AsyncQueryBus/index.d.ts +3 -1
  190. package/dist/node/AsyncQueryBus/index.d.ts.map +1 -1
  191. package/dist/node/Config.d.cts +5 -2
  192. package/dist/node/Config.d.cts.map +1 -1
  193. package/dist/node/Config.d.mts +5 -2
  194. package/dist/node/Config.d.mts.map +1 -1
  195. package/dist/node/Config.d.ts +5 -2
  196. package/dist/node/Config.d.ts.map +1 -1
  197. package/dist/node/PubSubBridge.d.cts +14 -19
  198. package/dist/node/PubSubBridge.d.cts.map +1 -1
  199. package/dist/node/PubSubBridge.d.mts +14 -19
  200. package/dist/node/PubSubBridge.d.mts.map +1 -1
  201. package/dist/node/PubSubBridge.d.ts +14 -19
  202. package/dist/node/PubSubBridge.d.ts.map +1 -1
  203. package/dist/node/index.cjs +367 -152
  204. package/dist/node/index.cjs.map +1 -1
  205. package/dist/node/index.d.cts +2 -0
  206. package/dist/node/index.d.cts.map +1 -1
  207. package/dist/node/index.d.mts +2 -0
  208. package/dist/node/index.d.mts.map +1 -1
  209. package/dist/node/index.d.ts +2 -0
  210. package/dist/node/index.d.ts.map +1 -1
  211. package/dist/node/index.js +363 -154
  212. package/dist/node/index.js.map +1 -1
  213. package/package.json +32 -25
  214. package/src/AbstractModuleHost/AbstractModuleHost.ts +12 -0
  215. package/src/AbstractModuleHost/index.ts +1 -0
  216. package/src/AbstractModuleProxy/AbstractModuleProxy.ts +239 -0
  217. package/src/AbstractModuleProxy/index.ts +1 -0
  218. package/src/AsyncQueryBus/AsyncQueryBusBase.ts +19 -40
  219. package/src/AsyncQueryBus/AsyncQueryBusClient.ts +73 -63
  220. package/src/AsyncQueryBus/{AsyncQueryBusServer.ts → AsyncQueryBusHost.ts} +35 -27
  221. package/src/AsyncQueryBus/Config.ts +23 -33
  222. package/src/AsyncQueryBus/ModuleHost/ModuleHost.ts +29 -0
  223. package/src/AsyncQueryBus/ModuleHost/index.ts +1 -0
  224. package/src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts +19 -0
  225. package/src/AsyncQueryBus/ModuleProxy/index.ts +1 -0
  226. package/src/AsyncQueryBus/Params.ts +6 -3
  227. package/src/AsyncQueryBus/index.ts +3 -1
  228. package/src/Config.ts +5 -2
  229. package/src/PubSubBridge.ts +19 -20
  230. package/src/index.ts +2 -0
  231. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -74
  232. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
  233. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -74
  234. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
  235. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -74
  236. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
  237. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -74
  238. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
  239. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -74
  240. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
  241. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -74
  242. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
@@ -1,42 +1,185 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/Schema.ts
5
- var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
6
-
7
- // src/Config.ts
8
- var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
9
-
10
- // src/PubSubBridge.ts
11
- import { assertEx as assertEx4 } from "@xylabs/assert";
12
- import { AbstractBridge } from "@xyo-network/abstract-bridge";
13
- import { ModuleManifestPayloadSchema } from "@xyo-network/manifest-model";
14
- import { creatableModule, ModuleManifestQuerySchema } from "@xyo-network/module-model";
15
- import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
16
- import { LRUCache as LRUCache2 } from "lru-cache";
4
+ // src/AbstractModuleProxy/AbstractModuleProxy.ts
5
+ import { assertEx } from "@xylabs/assert";
6
+ import { compact } from "@xylabs/lodash";
7
+ import { Base } from "@xylabs/object";
8
+ import { PromiseEx } from "@xylabs/promise";
9
+ import { QueryBoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
10
+ import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
11
+ import { AddressPreviousHashSchema, ModuleAddressQuerySchema, ModuleConfigSchema, ModuleDescribeQuerySchema, ModuleDiscoverQuerySchema, ModuleManifestQuerySchema } from "@xyo-network/module-model";
12
+ import { ModuleErrorSchema } from "@xyo-network/payload-model";
13
+ var AbstractModuleProxy = class extends Base {
14
+ static {
15
+ __name(this, "AbstractModuleProxy");
16
+ }
17
+ static requiredQueries = [
18
+ ModuleDiscoverQuerySchema
19
+ ];
20
+ eventData = {};
21
+ proxyParams;
22
+ constructor(params) {
23
+ super({
24
+ config: {
25
+ schema: ModuleConfigSchema
26
+ }
27
+ });
28
+ this.proxyParams = params;
29
+ }
30
+ get account() {
31
+ return this.proxyParams.account;
32
+ }
33
+ get address() {
34
+ return this.proxyParams.moduleAddress;
35
+ }
36
+ get config() {
37
+ return this.params.config;
38
+ }
39
+ get downResolver() {
40
+ throw new Error("Unsupported");
41
+ }
42
+ get id() {
43
+ return this.proxyParams.moduleAddress;
44
+ }
45
+ get queries() {
46
+ return this.proxyParams.queries;
47
+ }
48
+ get upResolver() {
49
+ throw new Error("Unsupported");
50
+ }
51
+ static hasRequiredQueries(module) {
52
+ return this.missingRequiredQueries(module).length === 0;
53
+ }
54
+ static missingRequiredQueries(module) {
55
+ const moduleQueries = module.queries;
56
+ return compact(this.requiredQueries.map((query) => {
57
+ return moduleQueries.includes(query) ? null : query;
58
+ }));
59
+ }
60
+ async addressPreviousHash() {
61
+ const queryPayload = {
62
+ schema: ModuleAddressQuerySchema
63
+ };
64
+ return assertEx((await this.sendQuery(queryPayload)).find((payload) => payload.schema === AddressPreviousHashSchema), "Result did not include correct payload");
65
+ }
66
+ clearListeners(_eventNames) {
67
+ throw new Error("Unsupported");
68
+ }
69
+ //TODO: Make ModuleDescription into real payload
70
+ async describe() {
71
+ const queryPayload = {
72
+ schema: ModuleDescribeQuerySchema
73
+ };
74
+ return (await this.sendQuery(queryPayload))[0];
75
+ }
76
+ async discover() {
77
+ const queryPayload = {
78
+ schema: ModuleDiscoverQuerySchema
79
+ };
80
+ return await this.sendQuery(queryPayload);
81
+ }
82
+ emit(_eventName, _eventArgs) {
83
+ throw new Error("Unsupported");
84
+ }
85
+ emitSerial(_eventName, _eventArgs) {
86
+ throw new Error("Unsupported");
87
+ }
88
+ listenerCount(_eventNames) {
89
+ throw new Error("Unsupported");
90
+ }
91
+ async manifest(maxDepth) {
92
+ const queryPayload = {
93
+ schema: ModuleManifestQuerySchema,
94
+ ...maxDepth === void 0 ? {} : {
95
+ maxDepth
96
+ }
97
+ };
98
+ return (await this.sendQuery(queryPayload))[0];
99
+ }
100
+ async moduleAddress() {
101
+ const queryPayload = {
102
+ schema: ModuleAddressQuerySchema
103
+ };
104
+ return await this.sendQuery(queryPayload);
105
+ }
106
+ off(_eventNames, _listener) {
107
+ throw new Error("Unsupported");
108
+ }
109
+ offAny(_listener) {
110
+ throw new Error("Unsupported");
111
+ }
112
+ on(_eventNames, _listener) {
113
+ throw new Error("Unsupported");
114
+ }
115
+ onAny(_listener) {
116
+ throw new Error("Unsupported");
117
+ }
118
+ once(_eventName, _listener) {
119
+ throw new Error("Unsupported");
120
+ }
121
+ async previousHash() {
122
+ const queryPayload = {
123
+ schema: ModuleAddressQuerySchema
124
+ };
125
+ return (await this.sendQuery(queryPayload)).pop().previousHash;
126
+ }
127
+ queryable(_query, _payloads) {
128
+ return true;
129
+ }
130
+ resolve(nameOrAddressOrFilter, _options) {
131
+ return typeof nameOrAddressOrFilter === "string" ? void 0 : [];
132
+ }
133
+ state() {
134
+ return [];
135
+ }
136
+ bindQuery(query, payloads, account = this.account) {
137
+ const promise = new PromiseEx(async (resolve) => {
138
+ const result = await this.bindQueryInternal(query, payloads, account);
139
+ resolve?.(result);
140
+ return result;
141
+ }, account);
142
+ return promise;
143
+ }
144
+ async bindQueryInternal(query, payloads, account = this.account) {
145
+ const builder = await new QueryBoundWitnessBuilder().payloads(payloads).query(query);
146
+ const result = await (account ? builder.witness(account) : builder).build();
147
+ return result;
148
+ }
149
+ async filterErrors(result) {
150
+ const wrapper = await BoundWitnessWrapper.wrap(result[0], result[1]);
151
+ return wrapper.payloadsBySchema(ModuleErrorSchema);
152
+ }
153
+ async sendQuery(queryPayload, payloads) {
154
+ const query = await this.bindQuery(queryPayload, payloads);
155
+ const [, resultPayloads, errors] = await this.query(query[0], query[1]);
156
+ if (errors && errors.length > 0) {
157
+ throw errors[0];
158
+ }
159
+ return resultPayloads;
160
+ }
161
+ };
17
162
 
18
163
  // src/AsyncQueryBus/AsyncQueryBusClient.ts
19
- import { assertEx as assertEx2 } from "@xylabs/assert";
20
164
  import { delay } from "@xylabs/delay";
21
165
  import { forget } from "@xylabs/forget";
22
166
  import { clearTimeoutEx, setTimeoutEx } from "@xylabs/timer";
23
167
  import { isBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
24
168
  import { BoundWitnessDivinerQuerySchema } from "@xyo-network/diviner-boundwitness-model";
25
- import { asModuleInstance } from "@xyo-network/module-model";
26
169
  import { PayloadBuilder } from "@xyo-network/payload-builder";
170
+ import { LRUCache as LRUCache2 } from "lru-cache";
27
171
 
28
172
  // src/AsyncQueryBus/AsyncQueryBusBase.ts
29
- import { assertEx } from "@xylabs/assert";
30
- import { Base } from "@xylabs/object";
173
+ import { assertEx as assertEx2 } from "@xylabs/assert";
174
+ import { Base as Base2 } from "@xylabs/object";
31
175
  import { asArchivistInstance } from "@xyo-network/archivist-model";
32
176
  import { asDivinerInstance } from "@xyo-network/diviner-model";
33
177
  import { LRUCache } from "lru-cache";
34
- var AsyncQueryBusBase = class extends Base {
178
+ var AsyncQueryBusBase = class extends Base2 {
35
179
  static {
36
180
  __name(this, "AsyncQueryBusBase");
37
181
  }
38
182
  _lastState;
39
- _queryCache;
40
183
  _targetConfigs = {};
41
184
  _targetQueries = {};
42
185
  constructor(params) {
@@ -45,19 +188,8 @@ var AsyncQueryBusBase = class extends Base {
45
188
  get config() {
46
189
  return this.params.config;
47
190
  }
48
- get individualAddressBatchQueryLimitConfig() {
49
- return this.config.individualAddressBatchQueryLimit ?? 10;
50
- }
51
191
  get pollFrequencyConfig() {
52
- return this.config.pollFrequency ?? 1e3;
53
- }
54
- get queryCacheConfig() {
55
- const queryCacheConfig = this.config.queryCache === true ? {} : this.config.queryCache;
56
- return {
57
- max: 100,
58
- ttl: 1e3 * 60,
59
- ...queryCacheConfig
60
- };
192
+ return this.config?.pollFrequency ?? 1e3;
61
193
  }
62
194
  get resolver() {
63
195
  return this.params.resolver;
@@ -73,32 +205,17 @@ var AsyncQueryBusBase = class extends Base {
73
205
  this._lastState = this._lastState ?? new LRUCache(requiredConfig);
74
206
  return this._lastState;
75
207
  }
76
- /**
77
- * A cache of queries that have been issued
78
- */
79
- get queryCache() {
80
- const config = this.queryCacheConfig;
81
- const requiredConfig = {
82
- noUpdateTTL: false,
83
- ttlAutopurge: true
84
- };
85
- this._queryCache = this._queryCache ?? new LRUCache({
86
- ...config,
87
- ...requiredConfig
88
- });
89
- return this._queryCache;
90
- }
91
208
  async queriesArchivist() {
92
- return assertEx(asArchivistInstance(await this.resolver.resolve(this.config.queries?.archivist)), () => `Unable to resolve queriesArchivist [${this.config.queries?.archivist}]`);
209
+ return assertEx2(asArchivistInstance(await this.resolver.resolve(this.config?.clearingHouse?.queries?.archivist)), () => `Unable to resolve queriesArchivist [${this.config?.clearingHouse?.queries?.archivist}]`);
93
210
  }
94
211
  async queriesDiviner() {
95
- return assertEx(asDivinerInstance(await this.resolver.resolve(this.config.queries?.boundWitnessDiviner)), () => `Unable to resolve queriesDiviner [${this.config.queries?.boundWitnessDiviner}]`);
212
+ return assertEx2(asDivinerInstance(await this.resolver.resolve(this.config?.clearingHouse?.queries?.boundWitnessDiviner)), () => `Unable to resolve queriesDiviner [${this.config?.clearingHouse?.queries?.boundWitnessDiviner}]`);
96
213
  }
97
214
  async responsesArchivist() {
98
- return assertEx(asArchivistInstance(await this.resolver.resolve(this.config.responses?.archivist)), () => `Unable to resolve responsesArchivist [${this.config.responses?.archivist}]`);
215
+ return assertEx2(asArchivistInstance(await this.resolver.resolve(this.config?.clearingHouse?.responses?.archivist)), () => `Unable to resolve responsesArchivist [${this.config?.clearingHouse?.responses?.archivist}]`);
99
216
  }
100
217
  async responsesDiviner() {
101
- return assertEx(asDivinerInstance(await this.resolver.resolve(this.config.responses?.boundWitnessDiviner)), () => `Unable to resolve responsesDiviner [${this.config.responses?.boundWitnessDiviner}]`);
218
+ return assertEx2(asDivinerInstance(await this.resolver.resolve(this.config?.clearingHouse?.responses?.boundWitnessDiviner)), () => `Unable to resolve responsesDiviner [${this.config?.clearingHouse?.responses?.boundWitnessDiviner}]`);
102
219
  }
103
220
  /**
104
221
  * Commit the internal state of the process. This is similar
@@ -140,18 +257,40 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
140
257
  static {
141
258
  __name(this, "AsyncQueryBusClient");
142
259
  }
260
+ _queryCache;
261
+ _pollCount = 0;
143
262
  _pollId;
144
263
  constructor(params) {
145
264
  super(params);
146
265
  }
266
+ get queryCacheConfig() {
267
+ const queryCacheConfig = this.config?.queryCache === true ? {} : this.config?.queryCache;
268
+ return {
269
+ max: 100,
270
+ ttl: 1e3 * 60,
271
+ ...queryCacheConfig
272
+ };
273
+ }
147
274
  get started() {
148
275
  return !!this._pollId;
149
276
  }
150
- async listeningModules() {
151
- const mods = this.config.listeningModules ? await Promise.all(this.config.listeningModules.map(async (listeningModule) => assertEx2(asModuleInstance(await this.resolver.resolve(listeningModule)), () => `Unable to resolve all listeningModule [${listeningModule}]`))) : await this.resolver.resolve({
152
- direction: "all"
277
+ /**
278
+ * A cache of queries that have been issued
279
+ */
280
+ get queryCache() {
281
+ const config = this.queryCacheConfig;
282
+ const requiredConfig = {
283
+ noUpdateTTL: false,
284
+ ttlAutopurge: true
285
+ };
286
+ this._queryCache = this._queryCache ?? new LRUCache2({
287
+ ...config,
288
+ ...requiredConfig
153
289
  });
154
- return mods;
290
+ return this._queryCache;
291
+ }
292
+ listeningAddresses() {
293
+ return this._queryCache?.keys();
155
294
  }
156
295
  async send(address, query, payloads) {
157
296
  this.logger?.debug(`Begin issuing query to: ${address}`);
@@ -166,10 +305,6 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
166
305
  $meta
167
306
  });
168
307
  const queryArchivist = await this.queriesArchivist();
169
- const sourceAddress = query.addresses.at(0);
170
- if (sourceAddress && !this.config.listeningModules?.includes(sourceAddress)) {
171
- this.config.listeningModules?.push(sourceAddress);
172
- }
173
308
  const routedQueryHash = (
174
309
  // Trust the signed hash if it's there
175
310
  routedQuery?.$hash ?? // TODO: What is the right way to find the dataHash
@@ -192,52 +327,43 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
192
327
  const context = new Promise((resolve) => {
193
328
  this.logger?.debug(`Polling for response to query: ${routedQueryHash}`);
194
329
  const pollForResponse = /* @__PURE__ */ __name(async () => {
195
- let response = this.queryCache.get(routedQueryHash);
196
- while (response !== void 0) {
197
- await delay(100);
198
- response = this.queryCache.get(routedQueryHash);
199
- if (response && response !== Pending) {
200
- this.logger?.debug(`Returning response to query: ${routedQueryHash}`);
201
- resolve(response);
202
- return;
330
+ try {
331
+ this.start();
332
+ let response = this.queryCache.get(routedQueryHash);
333
+ while (response !== void 0) {
334
+ await delay(100);
335
+ response = this.queryCache.get(routedQueryHash);
336
+ if (response && response !== Pending) {
337
+ this.logger?.debug(`Returning response to query: ${routedQueryHash}`);
338
+ resolve(response);
339
+ return;
340
+ }
203
341
  }
342
+ this.logger?.error("Timeout waiting for query response");
343
+ const error = {
344
+ message: "Timeout waiting for query response",
345
+ query: "network.xyo.boundwitness",
346
+ schema: "network.xyo.error.module",
347
+ sources: [
348
+ routedQueryHash
349
+ ]
350
+ };
351
+ resolve([
352
+ routedQuery,
353
+ [],
354
+ [
355
+ await PayloadBuilder.build(error)
356
+ ]
357
+ ]);
358
+ return;
359
+ } finally {
360
+ this.stop();
204
361
  }
205
- this.logger?.error("Timeout waiting for query response");
206
- const error = {
207
- message: "Timeout waiting for query response",
208
- query: "network.xyo.boundwitness",
209
- schema: "network.xyo.error.module",
210
- sources: [
211
- routedQueryHash
212
- ]
213
- };
214
- resolve([
215
- routedQuery,
216
- [],
217
- [
218
- await PayloadBuilder.build(error)
219
- ]
220
- ]);
221
- return;
222
362
  }, "pollForResponse");
223
363
  forget(pollForResponse());
224
364
  });
225
365
  return context;
226
366
  }
227
- start() {
228
- if (this.started) {
229
- console.warn("AsyncQueryBus starting when already started");
230
- }
231
- this.poll();
232
- }
233
- stop() {
234
- if (!this.started) {
235
- console.warn("AsyncQueryBus stopping when already stopped");
236
- }
237
- if (this._pollId)
238
- clearTimeoutEx(this._pollId);
239
- this._pollId = void 0;
240
- }
241
367
  /**
242
368
  * Runs the background divine process on a loop with a delay
243
369
  * specified by the `config.pollFrequency`
@@ -289,30 +415,48 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
289
415
  }
290
416
  }));
291
417
  };
418
+ start() {
419
+ if (this._pollCount === 0) {
420
+ this.poll();
421
+ }
422
+ this._pollCount++;
423
+ }
424
+ stop() {
425
+ this._pollCount--;
426
+ if (this._pollCount <= 0) {
427
+ if (this._pollId)
428
+ clearTimeoutEx(this._pollId);
429
+ this._pollId = void 0;
430
+ this._pollCount = 0;
431
+ }
432
+ }
292
433
  };
293
434
 
294
- // src/AsyncQueryBus/AsyncQueryBusServer.ts
435
+ // src/AsyncQueryBus/AsyncQueryBusHost.ts
295
436
  import { containsAll } from "@xylabs/array";
296
437
  import { assertEx as assertEx3 } from "@xylabs/assert";
297
438
  import { clearTimeoutEx as clearTimeoutEx2, setTimeoutEx as setTimeoutEx2 } from "@xylabs/timer";
298
439
  import { isQueryBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
299
440
  import { BoundWitnessDivinerQuerySchema as BoundWitnessDivinerQuerySchema2 } from "@xyo-network/diviner-boundwitness-model";
300
- import { asModuleInstance as asModuleInstance2 } from "@xyo-network/module-model";
441
+ import { asModuleInstance } from "@xyo-network/module-model";
301
442
  import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
302
- var AsyncQueryBusServer = class extends AsyncQueryBusBase {
443
+ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
303
444
  static {
304
- __name(this, "AsyncQueryBusServer");
445
+ __name(this, "AsyncQueryBusHost");
305
446
  }
306
447
  _pollId;
307
448
  constructor(params) {
308
449
  super(params);
309
450
  }
451
+ get perAddressBatchQueryLimit() {
452
+ return this.config?.perAddressBatchQueryLimit ?? 10;
453
+ }
310
454
  get started() {
311
455
  return !!this._pollId;
312
456
  }
313
457
  async listeningModules() {
314
- const mods = this.config.listeningModules ? await Promise.all(this.config.listeningModules.map(async (listeningModule) => assertEx3(asModuleInstance2(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`))) : await this.resolver.resolve({
315
- direction: "all"
458
+ const mods = this.config?.listeningModules ? await Promise.all(this.config.listeningModules.map(async (listeningModule) => assertEx3(asModuleInstance(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`))) : await this.resolver.resolve(void 0, {
459
+ direction: "down"
316
460
  });
317
461
  return mods;
318
462
  }
@@ -330,27 +474,27 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
330
474
  clearTimeoutEx2(this._pollId);
331
475
  this._pollId = void 0;
332
476
  }
333
- callLocalModule = async (localModule, command) => {
477
+ callLocalModule = async (localModule, query) => {
334
478
  const localModuleName = localModule.config.name ?? localModule.address;
335
479
  const queryArchivist = await this.queriesArchivist();
336
480
  const responseArchivist = await this.responsesArchivist();
337
- const commandDestination = command.$meta?.destination;
481
+ const commandDestination = query.$meta?.destination;
338
482
  if (commandDestination && commandDestination?.includes(localModule.address)) {
339
- const queryIndex = command.payload_hashes.indexOf(command.query);
483
+ const queryIndex = query.payload_hashes.indexOf(query.query);
340
484
  if (queryIndex !== -1) {
341
- const querySchema = command.payload_schemas[queryIndex];
485
+ const querySchema = query.payload_schemas[queryIndex];
342
486
  if (localModule.queries.includes(querySchema)) {
343
- const commandPayloads = await queryArchivist.get(command.payload_hashes);
487
+ const commandPayloads = await queryArchivist.get(query.payload_hashes);
344
488
  const commandPayloadsDict = await PayloadBuilder2.toAllHashMap(commandPayloads);
345
- const commandHash = (await PayloadBuilder2.build(command)).$hash;
346
- if (!containsAll(Object.keys(commandPayloadsDict), command.payload_hashes)) {
489
+ const commandHash = (await PayloadBuilder2.build(query)).$hash;
490
+ if (!containsAll(Object.keys(commandPayloadsDict), query.payload_hashes)) {
347
491
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}, missing payloads`);
348
492
  return;
349
493
  }
350
494
  try {
351
- const commandSchema = commandPayloadsDict[command.query].schema;
495
+ const commandSchema = commandPayloadsDict[query.query].schema;
352
496
  this.logger?.debug(`Issuing command ${commandSchema} (${commandHash}) addressed to module: ${localModuleName}`);
353
- const response = await localModule.query(command, commandPayloads);
497
+ const response = await localModule.query(query, commandPayloads);
354
498
  const [bw, payloads, errors] = response;
355
499
  this.logger?.debug(`Replying to command ${commandHash} addressed to module: ${localModuleName}`);
356
500
  const insertResult = await responseArchivist.insert([
@@ -358,11 +502,11 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
358
502
  ...payloads,
359
503
  ...errors
360
504
  ]);
361
- if (insertResult.length > 0) {
505
+ if (insertResult.length === 0) {
362
506
  this.logger?.error(`Error replying to command ${commandHash} addressed to module: ${localModuleName}`);
363
507
  }
364
- if (command?.timestamp) {
365
- await this.commitState(localModule.address, command.timestamp);
508
+ if (query?.timestamp) {
509
+ await this.commitState(localModule.address, query.timestamp);
366
510
  }
367
511
  } catch (error) {
368
512
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}: ${error}`);
@@ -375,13 +519,13 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
375
519
  * Finds unprocessed commands addressed to the supplied address
376
520
  * @param address The address to find commands for
377
521
  */
378
- findCommandsToAddress = async (address) => {
522
+ findQueriesToAddress = async (address) => {
379
523
  const queryBoundWitnessDiviner = await this.queriesDiviner();
380
524
  const timestamp = await this.retrieveState(address);
381
525
  const destination = [
382
526
  address
383
527
  ];
384
- const limit = this.individualAddressBatchQueryLimitConfig;
528
+ const limit = this.perAddressBatchQueryLimit;
385
529
  const divinerQuery = {
386
530
  destination,
387
531
  limit,
@@ -392,10 +536,10 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
392
536
  const result = await queryBoundWitnessDiviner.divine([
393
537
  divinerQuery
394
538
  ]);
395
- const commands = result.filter(isQueryBoundWitnessWithMeta);
396
- const nextState = Math.max(...commands.map((c) => c.timestamp ?? 0));
539
+ const queries = result.filter(isQueryBoundWitnessWithMeta);
540
+ const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp;
397
541
  await this.commitState(address, nextState);
398
- return commands;
542
+ return queries;
399
543
  };
400
544
  /**
401
545
  * Runs the background divine process on a loop with a delay
@@ -425,12 +569,12 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
425
569
  try {
426
570
  const localModuleName = localModule.config.name ?? localModule.address;
427
571
  this.logger?.debug(`Checking for inbound commands to ${localModuleName}`);
428
- const commands = await this.findCommandsToAddress(localModule.address);
429
- if (commands.length === 0)
572
+ const queries = await this.findQueriesToAddress(localModule.address);
573
+ if (queries.length === 0)
430
574
  return;
431
575
  this.logger?.debug(`Found commands addressed to local module: ${localModuleName}`);
432
- for (const command of commands) {
433
- await this.callLocalModule(localModule, command);
576
+ for (const query of queries) {
577
+ await this.callLocalModule(localModule, query);
434
578
  }
435
579
  } catch (error) {
436
580
  this.logger?.error(`Error processing commands for address ${localModule.address}: ${error}`);
@@ -439,7 +583,65 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
439
583
  };
440
584
  };
441
585
 
586
+ // src/AbstractModuleHost/AbstractModuleHost.ts
587
+ import { Base as Base3 } from "@xylabs/object";
588
+ var AbstractModuleHost = class extends Base3 {
589
+ static {
590
+ __name(this, "AbstractModuleHost");
591
+ }
592
+ };
593
+
594
+ // src/AsyncQueryBus/ModuleHost/ModuleHost.ts
595
+ var AsyncQueryBusModuleHost = class extends AbstractModuleHost {
596
+ static {
597
+ __name(this, "AsyncQueryBusModuleHost");
598
+ }
599
+ _busHost;
600
+ constructor(params) {
601
+ super(params);
602
+ }
603
+ async start() {
604
+ const listeningModules = this.params.config.listeningModules ?? (await this.params.module.resolve(void 0, {
605
+ direction: "down"
606
+ })).map((m) => m.address);
607
+ this._busHost = new AsyncQueryBusHost({
608
+ config: {
609
+ ...this.params.config,
610
+ listeningModules
611
+ },
612
+ logger: this.params.logger,
613
+ resolver: this.params.module
614
+ });
615
+ this._busHost?.start();
616
+ }
617
+ stop() {
618
+ this._busHost?.stop();
619
+ }
620
+ };
621
+
622
+ // src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts
623
+ var AsyncQueryBusModuleProxy = class extends AbstractModuleProxy {
624
+ static {
625
+ __name(this, "AsyncQueryBusModuleProxy");
626
+ }
627
+ async query(query, payloads) {
628
+ return await this.proxyParams.bridgeClient.send(this.address, query, payloads);
629
+ }
630
+ };
631
+
632
+ // src/Schema.ts
633
+ var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
634
+
635
+ // src/Config.ts
636
+ var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
637
+
442
638
  // src/PubSubBridge.ts
639
+ import { assertEx as assertEx4 } from "@xylabs/assert";
640
+ import { AbstractBridge } from "@xyo-network/abstract-bridge";
641
+ import { ModuleManifestPayloadSchema } from "@xyo-network/manifest-model";
642
+ import { creatableModule, ModuleManifestQuerySchema as ModuleManifestQuerySchema2 } from "@xyo-network/module-model";
643
+ import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
644
+ import { LRUCache as LRUCache3 } from "lru-cache";
443
645
  function _ts_decorate(decorators, target, key, desc) {
444
646
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
445
647
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -467,10 +669,10 @@ var PubSubBridge = class extends AbstractBridge {
467
669
  _targetConfigs = {};
468
670
  _targetQueries = {};
469
671
  _busClient;
470
- _busServer;
672
+ _busHost;
471
673
  get discoverCache() {
472
674
  const config = this.discoverCacheConfig;
473
- this._discoverCache = this._discoverCache ?? new LRUCache2({
675
+ this._discoverCache = this._discoverCache ?? new LRUCache3({
474
676
  ttlAutopurge: true,
475
677
  ...config
476
678
  });
@@ -527,7 +729,7 @@ var PubSubBridge = class extends AbstractBridge {
527
729
  const addressToCall = address ?? this.getRootAddress();
528
730
  const queryPayload = {
529
731
  maxDepth,
530
- schema: ModuleManifestQuerySchema
732
+ schema: ModuleManifestQuerySchema2
531
733
  };
532
734
  const boundQuery = await this.bindQuery(queryPayload);
533
735
  const manifest = assertEx4(await this.targetQuery(addressToCall, boundQuery[0], boundQuery[1]), () => `Unable to resolve [${address}]`)[1];
@@ -551,32 +753,30 @@ var PubSubBridge = class extends AbstractBridge {
551
753
  busClient() {
552
754
  if (!this._busClient) {
553
755
  this._busClient = new AsyncQueryBusClient({
554
- config: this.config,
756
+ config: this.config.client,
555
757
  logger: this.logger,
556
758
  resolver: this
557
759
  });
558
760
  }
559
761
  return this._busClient;
560
762
  }
561
- busServer() {
562
- if (!this._busServer) {
563
- this._busServer = new AsyncQueryBusServer({
564
- config: this.config,
763
+ busHost() {
764
+ if (!this._busHost) {
765
+ this._busHost = new AsyncQueryBusHost({
766
+ config: this.config.host,
565
767
  logger: this.logger,
566
768
  resolver: this
567
769
  });
568
770
  }
569
- return this._busServer;
771
+ return this._busHost;
570
772
  }
571
773
  async startHandler() {
572
774
  await Promise.resolve(this.connect());
573
- this.busServer().start();
574
- this.busClient().start();
775
+ this.busHost().start();
575
776
  return true;
576
777
  }
577
778
  stopHandler(_timeout) {
578
- this.busClient().stop();
579
- this.busServer().stop();
779
+ this.busHost().stop();
580
780
  return true;
581
781
  }
582
782
  };
@@ -584,6 +784,12 @@ PubSubBridge = _ts_decorate([
584
784
  creatableModule()
585
785
  ], PubSubBridge);
586
786
  export {
787
+ AbstractModuleProxy,
788
+ AsyncQueryBusClient,
789
+ AsyncQueryBusHost,
790
+ AsyncQueryBusModuleHost,
791
+ AsyncQueryBusModuleProxy,
792
+ Pending,
587
793
  PubSubBridge,
588
794
  PubSubBridgeConfigSchema,
589
795
  PubSubBridgeSchema