@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
@@ -21,48 +21,197 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
+ AbstractModuleProxy: () => AbstractModuleProxy,
25
+ AsyncQueryBusClient: () => AsyncQueryBusClient,
26
+ AsyncQueryBusHost: () => AsyncQueryBusHost,
27
+ AsyncQueryBusModuleHost: () => AsyncQueryBusModuleHost,
28
+ AsyncQueryBusModuleProxy: () => AsyncQueryBusModuleProxy,
29
+ Pending: () => Pending,
24
30
  PubSubBridge: () => PubSubBridge,
25
31
  PubSubBridgeConfigSchema: () => PubSubBridgeConfigSchema,
26
32
  PubSubBridgeSchema: () => PubSubBridgeSchema
27
33
  });
28
34
  module.exports = __toCommonJS(src_exports);
29
35
 
30
- // src/Schema.ts
31
- var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
32
-
33
- // src/Config.ts
34
- var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
35
-
36
- // src/PubSubBridge.ts
37
- var import_assert4 = require("@xylabs/assert");
38
- var import_abstract_bridge = require("@xyo-network/abstract-bridge");
39
- var import_manifest_model = require("@xyo-network/manifest-model");
40
- var import_module_model3 = require("@xyo-network/module-model");
36
+ // src/AbstractModuleProxy/AbstractModuleProxy.ts
37
+ var import_assert = require("@xylabs/assert");
38
+ var import_lodash = require("@xylabs/lodash");
39
+ var import_object = require("@xylabs/object");
40
+ var import_promise = require("@xylabs/promise");
41
+ var import_boundwitness_builder = require("@xyo-network/boundwitness-builder");
42
+ var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
43
+ var import_module_model = require("@xyo-network/module-model");
41
44
  var import_payload_model = require("@xyo-network/payload-model");
42
- var import_lru_cache2 = require("lru-cache");
45
+ var AbstractModuleProxy = class extends import_object.Base {
46
+ static {
47
+ __name(this, "AbstractModuleProxy");
48
+ }
49
+ static requiredQueries = [
50
+ import_module_model.ModuleDiscoverQuerySchema
51
+ ];
52
+ eventData = {};
53
+ proxyParams;
54
+ constructor(params) {
55
+ super({
56
+ config: {
57
+ schema: import_module_model.ModuleConfigSchema
58
+ }
59
+ });
60
+ this.proxyParams = params;
61
+ }
62
+ get account() {
63
+ return this.proxyParams.account;
64
+ }
65
+ get address() {
66
+ return this.proxyParams.moduleAddress;
67
+ }
68
+ get config() {
69
+ return this.params.config;
70
+ }
71
+ get downResolver() {
72
+ throw new Error("Unsupported");
73
+ }
74
+ get id() {
75
+ return this.proxyParams.moduleAddress;
76
+ }
77
+ get queries() {
78
+ return this.proxyParams.queries;
79
+ }
80
+ get upResolver() {
81
+ throw new Error("Unsupported");
82
+ }
83
+ static hasRequiredQueries(module2) {
84
+ return this.missingRequiredQueries(module2).length === 0;
85
+ }
86
+ static missingRequiredQueries(module2) {
87
+ const moduleQueries = module2.queries;
88
+ return (0, import_lodash.compact)(this.requiredQueries.map((query) => {
89
+ return moduleQueries.includes(query) ? null : query;
90
+ }));
91
+ }
92
+ async addressPreviousHash() {
93
+ const queryPayload = {
94
+ schema: import_module_model.ModuleAddressQuerySchema
95
+ };
96
+ return (0, import_assert.assertEx)((await this.sendQuery(queryPayload)).find((payload) => payload.schema === import_module_model.AddressPreviousHashSchema), "Result did not include correct payload");
97
+ }
98
+ clearListeners(_eventNames) {
99
+ throw new Error("Unsupported");
100
+ }
101
+ //TODO: Make ModuleDescription into real payload
102
+ async describe() {
103
+ const queryPayload = {
104
+ schema: import_module_model.ModuleDescribeQuerySchema
105
+ };
106
+ return (await this.sendQuery(queryPayload))[0];
107
+ }
108
+ async discover() {
109
+ const queryPayload = {
110
+ schema: import_module_model.ModuleDiscoverQuerySchema
111
+ };
112
+ return await this.sendQuery(queryPayload);
113
+ }
114
+ emit(_eventName, _eventArgs) {
115
+ throw new Error("Unsupported");
116
+ }
117
+ emitSerial(_eventName, _eventArgs) {
118
+ throw new Error("Unsupported");
119
+ }
120
+ listenerCount(_eventNames) {
121
+ throw new Error("Unsupported");
122
+ }
123
+ async manifest(maxDepth) {
124
+ const queryPayload = {
125
+ schema: import_module_model.ModuleManifestQuerySchema,
126
+ ...maxDepth === void 0 ? {} : {
127
+ maxDepth
128
+ }
129
+ };
130
+ return (await this.sendQuery(queryPayload))[0];
131
+ }
132
+ async moduleAddress() {
133
+ const queryPayload = {
134
+ schema: import_module_model.ModuleAddressQuerySchema
135
+ };
136
+ return await this.sendQuery(queryPayload);
137
+ }
138
+ off(_eventNames, _listener) {
139
+ throw new Error("Unsupported");
140
+ }
141
+ offAny(_listener) {
142
+ throw new Error("Unsupported");
143
+ }
144
+ on(_eventNames, _listener) {
145
+ throw new Error("Unsupported");
146
+ }
147
+ onAny(_listener) {
148
+ throw new Error("Unsupported");
149
+ }
150
+ once(_eventName, _listener) {
151
+ throw new Error("Unsupported");
152
+ }
153
+ async previousHash() {
154
+ const queryPayload = {
155
+ schema: import_module_model.ModuleAddressQuerySchema
156
+ };
157
+ return (await this.sendQuery(queryPayload)).pop().previousHash;
158
+ }
159
+ queryable(_query, _payloads) {
160
+ return true;
161
+ }
162
+ resolve(nameOrAddressOrFilter, _options) {
163
+ return typeof nameOrAddressOrFilter === "string" ? void 0 : [];
164
+ }
165
+ state() {
166
+ return [];
167
+ }
168
+ bindQuery(query, payloads, account = this.account) {
169
+ const promise = new import_promise.PromiseEx(async (resolve) => {
170
+ const result = await this.bindQueryInternal(query, payloads, account);
171
+ resolve?.(result);
172
+ return result;
173
+ }, account);
174
+ return promise;
175
+ }
176
+ async bindQueryInternal(query, payloads, account = this.account) {
177
+ const builder = await new import_boundwitness_builder.QueryBoundWitnessBuilder().payloads(payloads).query(query);
178
+ const result = await (account ? builder.witness(account) : builder).build();
179
+ return result;
180
+ }
181
+ async filterErrors(result) {
182
+ const wrapper = await import_boundwitness_wrapper.BoundWitnessWrapper.wrap(result[0], result[1]);
183
+ return wrapper.payloadsBySchema(import_payload_model.ModuleErrorSchema);
184
+ }
185
+ async sendQuery(queryPayload, payloads) {
186
+ const query = await this.bindQuery(queryPayload, payloads);
187
+ const [, resultPayloads, errors] = await this.query(query[0], query[1]);
188
+ if (errors && errors.length > 0) {
189
+ throw errors[0];
190
+ }
191
+ return resultPayloads;
192
+ }
193
+ };
43
194
 
44
195
  // src/AsyncQueryBus/AsyncQueryBusClient.ts
45
- var import_assert2 = require("@xylabs/assert");
46
196
  var import_delay = require("@xylabs/delay");
47
197
  var import_forget = require("@xylabs/forget");
48
198
  var import_timer = require("@xylabs/timer");
49
199
  var import_boundwitness_model = require("@xyo-network/boundwitness-model");
50
200
  var import_diviner_boundwitness_model = require("@xyo-network/diviner-boundwitness-model");
51
- var import_module_model = require("@xyo-network/module-model");
52
201
  var import_payload_builder = require("@xyo-network/payload-builder");
202
+ var import_lru_cache2 = require("lru-cache");
53
203
 
54
204
  // src/AsyncQueryBus/AsyncQueryBusBase.ts
55
- var import_assert = require("@xylabs/assert");
56
- var import_object = require("@xylabs/object");
205
+ var import_assert2 = require("@xylabs/assert");
206
+ var import_object2 = require("@xylabs/object");
57
207
  var import_archivist_model = require("@xyo-network/archivist-model");
58
208
  var import_diviner_model = require("@xyo-network/diviner-model");
59
209
  var import_lru_cache = require("lru-cache");
60
- var AsyncQueryBusBase = class extends import_object.Base {
210
+ var AsyncQueryBusBase = class extends import_object2.Base {
61
211
  static {
62
212
  __name(this, "AsyncQueryBusBase");
63
213
  }
64
214
  _lastState;
65
- _queryCache;
66
215
  _targetConfigs = {};
67
216
  _targetQueries = {};
68
217
  constructor(params) {
@@ -71,19 +220,8 @@ var AsyncQueryBusBase = class extends import_object.Base {
71
220
  get config() {
72
221
  return this.params.config;
73
222
  }
74
- get individualAddressBatchQueryLimitConfig() {
75
- return this.config.individualAddressBatchQueryLimit ?? 10;
76
- }
77
223
  get pollFrequencyConfig() {
78
- return this.config.pollFrequency ?? 1e3;
79
- }
80
- get queryCacheConfig() {
81
- const queryCacheConfig = this.config.queryCache === true ? {} : this.config.queryCache;
82
- return {
83
- max: 100,
84
- ttl: 1e3 * 60,
85
- ...queryCacheConfig
86
- };
224
+ return this.config?.pollFrequency ?? 1e3;
87
225
  }
88
226
  get resolver() {
89
227
  return this.params.resolver;
@@ -99,32 +237,17 @@ var AsyncQueryBusBase = class extends import_object.Base {
99
237
  this._lastState = this._lastState ?? new import_lru_cache.LRUCache(requiredConfig);
100
238
  return this._lastState;
101
239
  }
102
- /**
103
- * A cache of queries that have been issued
104
- */
105
- get queryCache() {
106
- const config = this.queryCacheConfig;
107
- const requiredConfig = {
108
- noUpdateTTL: false,
109
- ttlAutopurge: true
110
- };
111
- this._queryCache = this._queryCache ?? new import_lru_cache.LRUCache({
112
- ...config,
113
- ...requiredConfig
114
- });
115
- return this._queryCache;
116
- }
117
240
  async queriesArchivist() {
118
- return (0, import_assert.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve(this.config.queries?.archivist)), () => `Unable to resolve queriesArchivist [${this.config.queries?.archivist}]`);
241
+ return (0, import_assert2.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve(this.config?.clearingHouse?.queries?.archivist)), () => `Unable to resolve queriesArchivist [${this.config?.clearingHouse?.queries?.archivist}]`);
119
242
  }
120
243
  async queriesDiviner() {
121
- return (0, import_assert.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve(this.config.queries?.boundWitnessDiviner)), () => `Unable to resolve queriesDiviner [${this.config.queries?.boundWitnessDiviner}]`);
244
+ return (0, import_assert2.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve(this.config?.clearingHouse?.queries?.boundWitnessDiviner)), () => `Unable to resolve queriesDiviner [${this.config?.clearingHouse?.queries?.boundWitnessDiviner}]`);
122
245
  }
123
246
  async responsesArchivist() {
124
- return (0, import_assert.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve(this.config.responses?.archivist)), () => `Unable to resolve responsesArchivist [${this.config.responses?.archivist}]`);
247
+ return (0, import_assert2.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve(this.config?.clearingHouse?.responses?.archivist)), () => `Unable to resolve responsesArchivist [${this.config?.clearingHouse?.responses?.archivist}]`);
125
248
  }
126
249
  async responsesDiviner() {
127
- return (0, import_assert.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve(this.config.responses?.boundWitnessDiviner)), () => `Unable to resolve responsesDiviner [${this.config.responses?.boundWitnessDiviner}]`);
250
+ return (0, import_assert2.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve(this.config?.clearingHouse?.responses?.boundWitnessDiviner)), () => `Unable to resolve responsesDiviner [${this.config?.clearingHouse?.responses?.boundWitnessDiviner}]`);
128
251
  }
129
252
  /**
130
253
  * Commit the internal state of the process. This is similar
@@ -166,18 +289,40 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
166
289
  static {
167
290
  __name(this, "AsyncQueryBusClient");
168
291
  }
292
+ _queryCache;
293
+ _pollCount = 0;
169
294
  _pollId;
170
295
  constructor(params) {
171
296
  super(params);
172
297
  }
298
+ get queryCacheConfig() {
299
+ const queryCacheConfig = this.config?.queryCache === true ? {} : this.config?.queryCache;
300
+ return {
301
+ max: 100,
302
+ ttl: 1e3 * 60,
303
+ ...queryCacheConfig
304
+ };
305
+ }
173
306
  get started() {
174
307
  return !!this._pollId;
175
308
  }
176
- async listeningModules() {
177
- const mods = this.config.listeningModules ? await Promise.all(this.config.listeningModules.map(async (listeningModule) => (0, import_assert2.assertEx)((0, import_module_model.asModuleInstance)(await this.resolver.resolve(listeningModule)), () => `Unable to resolve all listeningModule [${listeningModule}]`))) : await this.resolver.resolve({
178
- direction: "all"
309
+ /**
310
+ * A cache of queries that have been issued
311
+ */
312
+ get queryCache() {
313
+ const config = this.queryCacheConfig;
314
+ const requiredConfig = {
315
+ noUpdateTTL: false,
316
+ ttlAutopurge: true
317
+ };
318
+ this._queryCache = this._queryCache ?? new import_lru_cache2.LRUCache({
319
+ ...config,
320
+ ...requiredConfig
179
321
  });
180
- return mods;
322
+ return this._queryCache;
323
+ }
324
+ listeningAddresses() {
325
+ return this._queryCache?.keys();
181
326
  }
182
327
  async send(address, query, payloads) {
183
328
  this.logger?.debug(`Begin issuing query to: ${address}`);
@@ -192,10 +337,6 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
192
337
  $meta
193
338
  });
194
339
  const queryArchivist = await this.queriesArchivist();
195
- const sourceAddress = query.addresses.at(0);
196
- if (sourceAddress && !this.config.listeningModules?.includes(sourceAddress)) {
197
- this.config.listeningModules?.push(sourceAddress);
198
- }
199
340
  const routedQueryHash = (
200
341
  // Trust the signed hash if it's there
201
342
  routedQuery?.$hash ?? // TODO: What is the right way to find the dataHash
@@ -218,52 +359,43 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
218
359
  const context = new Promise((resolve) => {
219
360
  this.logger?.debug(`Polling for response to query: ${routedQueryHash}`);
220
361
  const pollForResponse = /* @__PURE__ */ __name(async () => {
221
- let response = this.queryCache.get(routedQueryHash);
222
- while (response !== void 0) {
223
- await (0, import_delay.delay)(100);
224
- response = this.queryCache.get(routedQueryHash);
225
- if (response && response !== Pending) {
226
- this.logger?.debug(`Returning response to query: ${routedQueryHash}`);
227
- resolve(response);
228
- return;
362
+ try {
363
+ this.start();
364
+ let response = this.queryCache.get(routedQueryHash);
365
+ while (response !== void 0) {
366
+ await (0, import_delay.delay)(100);
367
+ response = this.queryCache.get(routedQueryHash);
368
+ if (response && response !== Pending) {
369
+ this.logger?.debug(`Returning response to query: ${routedQueryHash}`);
370
+ resolve(response);
371
+ return;
372
+ }
229
373
  }
374
+ this.logger?.error("Timeout waiting for query response");
375
+ const error = {
376
+ message: "Timeout waiting for query response",
377
+ query: "network.xyo.boundwitness",
378
+ schema: "network.xyo.error.module",
379
+ sources: [
380
+ routedQueryHash
381
+ ]
382
+ };
383
+ resolve([
384
+ routedQuery,
385
+ [],
386
+ [
387
+ await import_payload_builder.PayloadBuilder.build(error)
388
+ ]
389
+ ]);
390
+ return;
391
+ } finally {
392
+ this.stop();
230
393
  }
231
- this.logger?.error("Timeout waiting for query response");
232
- const error = {
233
- message: "Timeout waiting for query response",
234
- query: "network.xyo.boundwitness",
235
- schema: "network.xyo.error.module",
236
- sources: [
237
- routedQueryHash
238
- ]
239
- };
240
- resolve([
241
- routedQuery,
242
- [],
243
- [
244
- await import_payload_builder.PayloadBuilder.build(error)
245
- ]
246
- ]);
247
- return;
248
394
  }, "pollForResponse");
249
395
  (0, import_forget.forget)(pollForResponse());
250
396
  });
251
397
  return context;
252
398
  }
253
- start() {
254
- if (this.started) {
255
- console.warn("AsyncQueryBus starting when already started");
256
- }
257
- this.poll();
258
- }
259
- stop() {
260
- if (!this.started) {
261
- console.warn("AsyncQueryBus stopping when already stopped");
262
- }
263
- if (this._pollId)
264
- (0, import_timer.clearTimeoutEx)(this._pollId);
265
- this._pollId = void 0;
266
- }
267
399
  /**
268
400
  * Runs the background divine process on a loop with a delay
269
401
  * specified by the `config.pollFrequency`
@@ -315,9 +447,24 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
315
447
  }
316
448
  }));
317
449
  };
450
+ start() {
451
+ if (this._pollCount === 0) {
452
+ this.poll();
453
+ }
454
+ this._pollCount++;
455
+ }
456
+ stop() {
457
+ this._pollCount--;
458
+ if (this._pollCount <= 0) {
459
+ if (this._pollId)
460
+ (0, import_timer.clearTimeoutEx)(this._pollId);
461
+ this._pollId = void 0;
462
+ this._pollCount = 0;
463
+ }
464
+ }
318
465
  };
319
466
 
320
- // src/AsyncQueryBus/AsyncQueryBusServer.ts
467
+ // src/AsyncQueryBus/AsyncQueryBusHost.ts
321
468
  var import_array = require("@xylabs/array");
322
469
  var import_assert3 = require("@xylabs/assert");
323
470
  var import_timer2 = require("@xylabs/timer");
@@ -325,20 +472,23 @@ var import_boundwitness_model2 = require("@xyo-network/boundwitness-model");
325
472
  var import_diviner_boundwitness_model2 = require("@xyo-network/diviner-boundwitness-model");
326
473
  var import_module_model2 = require("@xyo-network/module-model");
327
474
  var import_payload_builder2 = require("@xyo-network/payload-builder");
328
- var AsyncQueryBusServer = class extends AsyncQueryBusBase {
475
+ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
329
476
  static {
330
- __name(this, "AsyncQueryBusServer");
477
+ __name(this, "AsyncQueryBusHost");
331
478
  }
332
479
  _pollId;
333
480
  constructor(params) {
334
481
  super(params);
335
482
  }
483
+ get perAddressBatchQueryLimit() {
484
+ return this.config?.perAddressBatchQueryLimit ?? 10;
485
+ }
336
486
  get started() {
337
487
  return !!this._pollId;
338
488
  }
339
489
  async listeningModules() {
340
- const mods = this.config.listeningModules ? await Promise.all(this.config.listeningModules.map(async (listeningModule) => (0, import_assert3.assertEx)((0, import_module_model2.asModuleInstance)(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`))) : await this.resolver.resolve({
341
- direction: "all"
490
+ const mods = this.config?.listeningModules ? await Promise.all(this.config.listeningModules.map(async (listeningModule) => (0, import_assert3.assertEx)((0, import_module_model2.asModuleInstance)(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`))) : await this.resolver.resolve(void 0, {
491
+ direction: "down"
342
492
  });
343
493
  return mods;
344
494
  }
@@ -356,27 +506,27 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
356
506
  (0, import_timer2.clearTimeoutEx)(this._pollId);
357
507
  this._pollId = void 0;
358
508
  }
359
- callLocalModule = async (localModule, command) => {
509
+ callLocalModule = async (localModule, query) => {
360
510
  const localModuleName = localModule.config.name ?? localModule.address;
361
511
  const queryArchivist = await this.queriesArchivist();
362
512
  const responseArchivist = await this.responsesArchivist();
363
- const commandDestination = command.$meta?.destination;
513
+ const commandDestination = query.$meta?.destination;
364
514
  if (commandDestination && commandDestination?.includes(localModule.address)) {
365
- const queryIndex = command.payload_hashes.indexOf(command.query);
515
+ const queryIndex = query.payload_hashes.indexOf(query.query);
366
516
  if (queryIndex !== -1) {
367
- const querySchema = command.payload_schemas[queryIndex];
517
+ const querySchema = query.payload_schemas[queryIndex];
368
518
  if (localModule.queries.includes(querySchema)) {
369
- const commandPayloads = await queryArchivist.get(command.payload_hashes);
519
+ const commandPayloads = await queryArchivist.get(query.payload_hashes);
370
520
  const commandPayloadsDict = await import_payload_builder2.PayloadBuilder.toAllHashMap(commandPayloads);
371
- const commandHash = (await import_payload_builder2.PayloadBuilder.build(command)).$hash;
372
- if (!(0, import_array.containsAll)(Object.keys(commandPayloadsDict), command.payload_hashes)) {
521
+ const commandHash = (await import_payload_builder2.PayloadBuilder.build(query)).$hash;
522
+ if (!(0, import_array.containsAll)(Object.keys(commandPayloadsDict), query.payload_hashes)) {
373
523
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}, missing payloads`);
374
524
  return;
375
525
  }
376
526
  try {
377
- const commandSchema = commandPayloadsDict[command.query].schema;
527
+ const commandSchema = commandPayloadsDict[query.query].schema;
378
528
  this.logger?.debug(`Issuing command ${commandSchema} (${commandHash}) addressed to module: ${localModuleName}`);
379
- const response = await localModule.query(command, commandPayloads);
529
+ const response = await localModule.query(query, commandPayloads);
380
530
  const [bw, payloads, errors] = response;
381
531
  this.logger?.debug(`Replying to command ${commandHash} addressed to module: ${localModuleName}`);
382
532
  const insertResult = await responseArchivist.insert([
@@ -384,11 +534,11 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
384
534
  ...payloads,
385
535
  ...errors
386
536
  ]);
387
- if (insertResult.length > 0) {
537
+ if (insertResult.length === 0) {
388
538
  this.logger?.error(`Error replying to command ${commandHash} addressed to module: ${localModuleName}`);
389
539
  }
390
- if (command?.timestamp) {
391
- await this.commitState(localModule.address, command.timestamp);
540
+ if (query?.timestamp) {
541
+ await this.commitState(localModule.address, query.timestamp);
392
542
  }
393
543
  } catch (error) {
394
544
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}: ${error}`);
@@ -401,13 +551,13 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
401
551
  * Finds unprocessed commands addressed to the supplied address
402
552
  * @param address The address to find commands for
403
553
  */
404
- findCommandsToAddress = async (address) => {
554
+ findQueriesToAddress = async (address) => {
405
555
  const queryBoundWitnessDiviner = await this.queriesDiviner();
406
556
  const timestamp = await this.retrieveState(address);
407
557
  const destination = [
408
558
  address
409
559
  ];
410
- const limit = this.individualAddressBatchQueryLimitConfig;
560
+ const limit = this.perAddressBatchQueryLimit;
411
561
  const divinerQuery = {
412
562
  destination,
413
563
  limit,
@@ -418,10 +568,10 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
418
568
  const result = await queryBoundWitnessDiviner.divine([
419
569
  divinerQuery
420
570
  ]);
421
- const commands = result.filter(import_boundwitness_model2.isQueryBoundWitnessWithMeta);
422
- const nextState = Math.max(...commands.map((c) => c.timestamp ?? 0));
571
+ const queries = result.filter(import_boundwitness_model2.isQueryBoundWitnessWithMeta);
572
+ const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp;
423
573
  await this.commitState(address, nextState);
424
- return commands;
574
+ return queries;
425
575
  };
426
576
  /**
427
577
  * Runs the background divine process on a loop with a delay
@@ -451,12 +601,12 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
451
601
  try {
452
602
  const localModuleName = localModule.config.name ?? localModule.address;
453
603
  this.logger?.debug(`Checking for inbound commands to ${localModuleName}`);
454
- const commands = await this.findCommandsToAddress(localModule.address);
455
- if (commands.length === 0)
604
+ const queries = await this.findQueriesToAddress(localModule.address);
605
+ if (queries.length === 0)
456
606
  return;
457
607
  this.logger?.debug(`Found commands addressed to local module: ${localModuleName}`);
458
- for (const command of commands) {
459
- await this.callLocalModule(localModule, command);
608
+ for (const query of queries) {
609
+ await this.callLocalModule(localModule, query);
460
610
  }
461
611
  } catch (error) {
462
612
  this.logger?.error(`Error processing commands for address ${localModule.address}: ${error}`);
@@ -465,7 +615,65 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
465
615
  };
466
616
  };
467
617
 
618
+ // src/AbstractModuleHost/AbstractModuleHost.ts
619
+ var import_object3 = require("@xylabs/object");
620
+ var AbstractModuleHost = class extends import_object3.Base {
621
+ static {
622
+ __name(this, "AbstractModuleHost");
623
+ }
624
+ };
625
+
626
+ // src/AsyncQueryBus/ModuleHost/ModuleHost.ts
627
+ var AsyncQueryBusModuleHost = class extends AbstractModuleHost {
628
+ static {
629
+ __name(this, "AsyncQueryBusModuleHost");
630
+ }
631
+ _busHost;
632
+ constructor(params) {
633
+ super(params);
634
+ }
635
+ async start() {
636
+ const listeningModules = this.params.config.listeningModules ?? (await this.params.module.resolve(void 0, {
637
+ direction: "down"
638
+ })).map((m) => m.address);
639
+ this._busHost = new AsyncQueryBusHost({
640
+ config: {
641
+ ...this.params.config,
642
+ listeningModules
643
+ },
644
+ logger: this.params.logger,
645
+ resolver: this.params.module
646
+ });
647
+ this._busHost?.start();
648
+ }
649
+ stop() {
650
+ this._busHost?.stop();
651
+ }
652
+ };
653
+
654
+ // src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts
655
+ var AsyncQueryBusModuleProxy = class extends AbstractModuleProxy {
656
+ static {
657
+ __name(this, "AsyncQueryBusModuleProxy");
658
+ }
659
+ async query(query, payloads) {
660
+ return await this.proxyParams.bridgeClient.send(this.address, query, payloads);
661
+ }
662
+ };
663
+
664
+ // src/Schema.ts
665
+ var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
666
+
667
+ // src/Config.ts
668
+ var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
669
+
468
670
  // src/PubSubBridge.ts
671
+ var import_assert4 = require("@xylabs/assert");
672
+ var import_abstract_bridge = require("@xyo-network/abstract-bridge");
673
+ var import_manifest_model = require("@xyo-network/manifest-model");
674
+ var import_module_model3 = require("@xyo-network/module-model");
675
+ var import_payload_model2 = require("@xyo-network/payload-model");
676
+ var import_lru_cache3 = require("lru-cache");
469
677
  function _ts_decorate(decorators, target, key, desc) {
470
678
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
471
679
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -493,10 +701,10 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
493
701
  _targetConfigs = {};
494
702
  _targetQueries = {};
495
703
  _busClient;
496
- _busServer;
704
+ _busHost;
497
705
  get discoverCache() {
498
706
  const config = this.discoverCacheConfig;
499
- this._discoverCache = this._discoverCache ?? new import_lru_cache2.LRUCache({
707
+ this._discoverCache = this._discoverCache ?? new import_lru_cache3.LRUCache({
500
708
  ttlAutopurge: true,
501
709
  ...config
502
710
  });
@@ -557,7 +765,7 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
557
765
  };
558
766
  const boundQuery = await this.bindQuery(queryPayload);
559
767
  const manifest = (0, import_assert4.assertEx)(await this.targetQuery(addressToCall, boundQuery[0], boundQuery[1]), () => `Unable to resolve [${address}]`)[1];
560
- return (0, import_assert4.assertEx)(manifest.find((0, import_payload_model.isPayloadOfSchemaType)(import_manifest_model.ModuleManifestPayloadSchema)), "Did not receive manifest");
768
+ return (0, import_assert4.assertEx)(manifest.find((0, import_payload_model2.isPayloadOfSchemaType)(import_manifest_model.ModuleManifestPayloadSchema)), "Did not receive manifest");
561
769
  }
562
770
  targetQueries(address) {
563
771
  if (!this.connected)
@@ -577,32 +785,30 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
577
785
  busClient() {
578
786
  if (!this._busClient) {
579
787
  this._busClient = new AsyncQueryBusClient({
580
- config: this.config,
788
+ config: this.config.client,
581
789
  logger: this.logger,
582
790
  resolver: this
583
791
  });
584
792
  }
585
793
  return this._busClient;
586
794
  }
587
- busServer() {
588
- if (!this._busServer) {
589
- this._busServer = new AsyncQueryBusServer({
590
- config: this.config,
795
+ busHost() {
796
+ if (!this._busHost) {
797
+ this._busHost = new AsyncQueryBusHost({
798
+ config: this.config.host,
591
799
  logger: this.logger,
592
800
  resolver: this
593
801
  });
594
802
  }
595
- return this._busServer;
803
+ return this._busHost;
596
804
  }
597
805
  async startHandler() {
598
806
  await Promise.resolve(this.connect());
599
- this.busServer().start();
600
- this.busClient().start();
807
+ this.busHost().start();
601
808
  return true;
602
809
  }
603
810
  stopHandler(_timeout) {
604
- this.busClient().stop();
605
- this.busServer().stop();
811
+ this.busHost().stop();
606
812
  return true;
607
813
  }
608
814
  };