@xyo-network/bridge-pub-sub 2.91.0 → 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 +51 -15
  26. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  27. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +51 -15
  28. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  29. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +51 -15
  30. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  31. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts +14 -45
  32. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
  33. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts +14 -45
  34. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
  35. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts +14 -45
  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 +4 -10
  92. package/dist/browser/PubSubBridge.d.cts.map +1 -1
  93. package/dist/browser/PubSubBridge.d.mts +4 -10
  94. package/dist/browser/PubSubBridge.d.mts.map +1 -1
  95. package/dist/browser/PubSubBridge.d.ts +4 -10
  96. package/dist/browser/PubSubBridge.d.ts.map +1 -1
  97. package/dist/browser/index.cjs +331 -126
  98. package/dist/browser/index.cjs.map +1 -1
  99. package/dist/browser/index.d.cts +1 -0
  100. package/dist/browser/index.d.cts.map +1 -1
  101. package/dist/browser/index.d.mts +1 -0
  102. package/dist/browser/index.d.mts.map +1 -1
  103. package/dist/browser/index.d.ts +1 -0
  104. package/dist/browser/index.d.ts.map +1 -1
  105. package/dist/browser/index.js +332 -127
  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 +51 -15
  132. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  133. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +51 -15
  134. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  135. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +51 -15
  136. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  137. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts +14 -45
  138. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
  139. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts +14 -45
  140. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
  141. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts +14 -45
  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 +4 -10
  198. package/dist/node/PubSubBridge.d.cts.map +1 -1
  199. package/dist/node/PubSubBridge.d.mts +4 -10
  200. package/dist/node/PubSubBridge.d.mts.map +1 -1
  201. package/dist/node/PubSubBridge.d.ts +4 -10
  202. package/dist/node/PubSubBridge.d.ts.map +1 -1
  203. package/dist/node/index.cjs +355 -144
  204. package/dist/node/index.cjs.map +1 -1
  205. package/dist/node/index.d.cts +1 -0
  206. package/dist/node/index.d.cts.map +1 -1
  207. package/dist/node/index.d.mts +1 -0
  208. package/dist/node/index.d.mts.map +1 -1
  209. package/dist/node/index.d.ts +1 -0
  210. package/dist/node/index.d.ts.map +1 -1
  211. package/dist/node/index.js +352 -144
  212. package/dist/node/index.js.map +1 -1
  213. package/package.json +30 -24
  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 +11 -33
  219. package/src/AsyncQueryBus/AsyncQueryBusClient.ts +69 -61
  220. package/src/AsyncQueryBus/{AsyncQueryBusServer.ts → AsyncQueryBusHost.ts} +32 -26
  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 +10 -12
  230. package/src/index.ts +1 -0
  231. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -75
  232. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
  233. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -75
  234. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
  235. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -75
  236. package/dist/browser/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
  237. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts +0 -75
  238. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.cts.map +0 -1
  239. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts +0 -75
  240. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.mts.map +0 -1
  241. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts +0 -75
  242. package/dist/node/AsyncQueryBus/AsyncQueryBusServer.d.ts.map +0 -1
@@ -21,8 +21,11 @@ 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,
24
25
  AsyncQueryBusClient: () => AsyncQueryBusClient,
25
- AsyncQueryBusServer: () => AsyncQueryBusServer,
26
+ AsyncQueryBusHost: () => AsyncQueryBusHost,
27
+ AsyncQueryBusModuleHost: () => AsyncQueryBusModuleHost,
28
+ AsyncQueryBusModuleProxy: () => AsyncQueryBusModuleProxy,
26
29
  Pending: () => Pending,
27
30
  PubSubBridge: () => PubSubBridge,
28
31
  PubSubBridgeConfigSchema: () => PubSubBridgeConfigSchema,
@@ -30,28 +33,185 @@ __export(src_exports, {
30
33
  });
31
34
  module.exports = __toCommonJS(src_exports);
32
35
 
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");
44
+ var import_payload_model = require("@xyo-network/payload-model");
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
+ };
194
+
33
195
  // src/AsyncQueryBus/AsyncQueryBusClient.ts
34
- var import_assert2 = require("@xylabs/assert");
35
196
  var import_delay = require("@xylabs/delay");
36
197
  var import_forget = require("@xylabs/forget");
37
198
  var import_timer = require("@xylabs/timer");
38
199
  var import_boundwitness_model = require("@xyo-network/boundwitness-model");
39
200
  var import_diviner_boundwitness_model = require("@xyo-network/diviner-boundwitness-model");
40
- var import_module_model = require("@xyo-network/module-model");
41
201
  var import_payload_builder = require("@xyo-network/payload-builder");
202
+ var import_lru_cache2 = require("lru-cache");
42
203
 
43
204
  // src/AsyncQueryBus/AsyncQueryBusBase.ts
44
- var import_assert = require("@xylabs/assert");
45
- var import_object = require("@xylabs/object");
205
+ var import_assert2 = require("@xylabs/assert");
206
+ var import_object2 = require("@xylabs/object");
46
207
  var import_archivist_model = require("@xyo-network/archivist-model");
47
208
  var import_diviner_model = require("@xyo-network/diviner-model");
48
209
  var import_lru_cache = require("lru-cache");
49
- var AsyncQueryBusBase = class extends import_object.Base {
210
+ var AsyncQueryBusBase = class extends import_object2.Base {
50
211
  static {
51
212
  __name(this, "AsyncQueryBusBase");
52
213
  }
53
214
  _lastState;
54
- _queryCache;
55
215
  _targetConfigs = {};
56
216
  _targetQueries = {};
57
217
  constructor(params) {
@@ -60,19 +220,8 @@ var AsyncQueryBusBase = class extends import_object.Base {
60
220
  get config() {
61
221
  return this.params.config;
62
222
  }
63
- get individualAddressBatchQueryLimitConfig() {
64
- return this.config.individualAddressBatchQueryLimit ?? 10;
65
- }
66
223
  get pollFrequencyConfig() {
67
- return this.config.pollFrequency ?? 1e3;
68
- }
69
- get queryCacheConfig() {
70
- const queryCacheConfig = this.config.queryCache === true ? {} : this.config.queryCache;
71
- return {
72
- max: 100,
73
- ttl: 1e3 * 60,
74
- ...queryCacheConfig
75
- };
224
+ return this.config?.pollFrequency ?? 1e3;
76
225
  }
77
226
  get resolver() {
78
227
  return this.params.resolver;
@@ -88,32 +237,17 @@ var AsyncQueryBusBase = class extends import_object.Base {
88
237
  this._lastState = this._lastState ?? new import_lru_cache.LRUCache(requiredConfig);
89
238
  return this._lastState;
90
239
  }
91
- /**
92
- * A cache of queries that have been issued
93
- */
94
- get queryCache() {
95
- const config = this.queryCacheConfig;
96
- const requiredConfig = {
97
- noUpdateTTL: false,
98
- ttlAutopurge: true
99
- };
100
- this._queryCache = this._queryCache ?? new import_lru_cache.LRUCache({
101
- ...config,
102
- ...requiredConfig
103
- });
104
- return this._queryCache;
105
- }
106
240
  async queriesArchivist() {
107
- 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}]`);
108
242
  }
109
243
  async queriesDiviner() {
110
- 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}]`);
111
245
  }
112
246
  async responsesArchivist() {
113
- 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}]`);
114
248
  }
115
249
  async responsesDiviner() {
116
- 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}]`);
117
251
  }
118
252
  /**
119
253
  * Commit the internal state of the process. This is similar
@@ -155,18 +289,40 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
155
289
  static {
156
290
  __name(this, "AsyncQueryBusClient");
157
291
  }
292
+ _queryCache;
293
+ _pollCount = 0;
158
294
  _pollId;
159
295
  constructor(params) {
160
296
  super(params);
161
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
+ }
162
306
  get started() {
163
307
  return !!this._pollId;
164
308
  }
165
- async listeningModules() {
166
- 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({
167
- 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
168
321
  });
169
- return mods;
322
+ return this._queryCache;
323
+ }
324
+ listeningAddresses() {
325
+ return this._queryCache?.keys();
170
326
  }
171
327
  async send(address, query, payloads) {
172
328
  this.logger?.debug(`Begin issuing query to: ${address}`);
@@ -181,10 +337,6 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
181
337
  $meta
182
338
  });
183
339
  const queryArchivist = await this.queriesArchivist();
184
- const sourceAddress = query.addresses.at(0);
185
- if (sourceAddress && !this.config.listeningModules?.includes(sourceAddress)) {
186
- this.config.listeningModules?.push(sourceAddress);
187
- }
188
340
  const routedQueryHash = (
189
341
  // Trust the signed hash if it's there
190
342
  routedQuery?.$hash ?? // TODO: What is the right way to find the dataHash
@@ -207,52 +359,43 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
207
359
  const context = new Promise((resolve) => {
208
360
  this.logger?.debug(`Polling for response to query: ${routedQueryHash}`);
209
361
  const pollForResponse = /* @__PURE__ */ __name(async () => {
210
- let response = this.queryCache.get(routedQueryHash);
211
- while (response !== void 0) {
212
- await (0, import_delay.delay)(100);
213
- response = this.queryCache.get(routedQueryHash);
214
- if (response && response !== Pending) {
215
- this.logger?.debug(`Returning response to query: ${routedQueryHash}`);
216
- resolve(response);
217
- 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
+ }
218
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();
219
393
  }
220
- this.logger?.error("Timeout waiting for query response");
221
- const error = {
222
- message: "Timeout waiting for query response",
223
- query: "network.xyo.boundwitness",
224
- schema: "network.xyo.error.module",
225
- sources: [
226
- routedQueryHash
227
- ]
228
- };
229
- resolve([
230
- routedQuery,
231
- [],
232
- [
233
- await import_payload_builder.PayloadBuilder.build(error)
234
- ]
235
- ]);
236
- return;
237
394
  }, "pollForResponse");
238
395
  (0, import_forget.forget)(pollForResponse());
239
396
  });
240
397
  return context;
241
398
  }
242
- start() {
243
- if (this.started) {
244
- console.warn("AsyncQueryBus starting when already started");
245
- }
246
- this.poll();
247
- }
248
- stop() {
249
- if (!this.started) {
250
- console.warn("AsyncQueryBus stopping when already stopped");
251
- }
252
- if (this._pollId)
253
- (0, import_timer.clearTimeoutEx)(this._pollId);
254
- this._pollId = void 0;
255
- }
256
399
  /**
257
400
  * Runs the background divine process on a loop with a delay
258
401
  * specified by the `config.pollFrequency`
@@ -304,9 +447,24 @@ var AsyncQueryBusClient = class extends AsyncQueryBusBase {
304
447
  }
305
448
  }));
306
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
+ }
307
465
  };
308
466
 
309
- // src/AsyncQueryBus/AsyncQueryBusServer.ts
467
+ // src/AsyncQueryBus/AsyncQueryBusHost.ts
310
468
  var import_array = require("@xylabs/array");
311
469
  var import_assert3 = require("@xylabs/assert");
312
470
  var import_timer2 = require("@xylabs/timer");
@@ -314,20 +472,23 @@ var import_boundwitness_model2 = require("@xyo-network/boundwitness-model");
314
472
  var import_diviner_boundwitness_model2 = require("@xyo-network/diviner-boundwitness-model");
315
473
  var import_module_model2 = require("@xyo-network/module-model");
316
474
  var import_payload_builder2 = require("@xyo-network/payload-builder");
317
- var AsyncQueryBusServer = class extends AsyncQueryBusBase {
475
+ var AsyncQueryBusHost = class extends AsyncQueryBusBase {
318
476
  static {
319
- __name(this, "AsyncQueryBusServer");
477
+ __name(this, "AsyncQueryBusHost");
320
478
  }
321
479
  _pollId;
322
480
  constructor(params) {
323
481
  super(params);
324
482
  }
483
+ get perAddressBatchQueryLimit() {
484
+ return this.config?.perAddressBatchQueryLimit ?? 10;
485
+ }
325
486
  get started() {
326
487
  return !!this._pollId;
327
488
  }
328
489
  async listeningModules() {
329
- 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({
330
- 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"
331
492
  });
332
493
  return mods;
333
494
  }
@@ -345,27 +506,27 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
345
506
  (0, import_timer2.clearTimeoutEx)(this._pollId);
346
507
  this._pollId = void 0;
347
508
  }
348
- callLocalModule = async (localModule, command) => {
509
+ callLocalModule = async (localModule, query) => {
349
510
  const localModuleName = localModule.config.name ?? localModule.address;
350
511
  const queryArchivist = await this.queriesArchivist();
351
512
  const responseArchivist = await this.responsesArchivist();
352
- const commandDestination = command.$meta?.destination;
513
+ const commandDestination = query.$meta?.destination;
353
514
  if (commandDestination && commandDestination?.includes(localModule.address)) {
354
- const queryIndex = command.payload_hashes.indexOf(command.query);
515
+ const queryIndex = query.payload_hashes.indexOf(query.query);
355
516
  if (queryIndex !== -1) {
356
- const querySchema = command.payload_schemas[queryIndex];
517
+ const querySchema = query.payload_schemas[queryIndex];
357
518
  if (localModule.queries.includes(querySchema)) {
358
- const commandPayloads = await queryArchivist.get(command.payload_hashes);
519
+ const commandPayloads = await queryArchivist.get(query.payload_hashes);
359
520
  const commandPayloadsDict = await import_payload_builder2.PayloadBuilder.toAllHashMap(commandPayloads);
360
- const commandHash = (await import_payload_builder2.PayloadBuilder.build(command)).$hash;
361
- 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)) {
362
523
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}, missing payloads`);
363
524
  return;
364
525
  }
365
526
  try {
366
- const commandSchema = commandPayloadsDict[command.query].schema;
527
+ const commandSchema = commandPayloadsDict[query.query].schema;
367
528
  this.logger?.debug(`Issuing command ${commandSchema} (${commandHash}) addressed to module: ${localModuleName}`);
368
- const response = await localModule.query(command, commandPayloads);
529
+ const response = await localModule.query(query, commandPayloads);
369
530
  const [bw, payloads, errors] = response;
370
531
  this.logger?.debug(`Replying to command ${commandHash} addressed to module: ${localModuleName}`);
371
532
  const insertResult = await responseArchivist.insert([
@@ -373,11 +534,11 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
373
534
  ...payloads,
374
535
  ...errors
375
536
  ]);
376
- if (insertResult.length > 0) {
537
+ if (insertResult.length === 0) {
377
538
  this.logger?.error(`Error replying to command ${commandHash} addressed to module: ${localModuleName}`);
378
539
  }
379
- if (command?.timestamp) {
380
- await this.commitState(localModule.address, command.timestamp);
540
+ if (query?.timestamp) {
541
+ await this.commitState(localModule.address, query.timestamp);
381
542
  }
382
543
  } catch (error) {
383
544
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}: ${error}`);
@@ -390,13 +551,13 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
390
551
  * Finds unprocessed commands addressed to the supplied address
391
552
  * @param address The address to find commands for
392
553
  */
393
- findCommandsToAddress = async (address) => {
554
+ findQueriesToAddress = async (address) => {
394
555
  const queryBoundWitnessDiviner = await this.queriesDiviner();
395
556
  const timestamp = await this.retrieveState(address);
396
557
  const destination = [
397
558
  address
398
559
  ];
399
- const limit = this.individualAddressBatchQueryLimitConfig;
560
+ const limit = this.perAddressBatchQueryLimit;
400
561
  const divinerQuery = {
401
562
  destination,
402
563
  limit,
@@ -407,10 +568,10 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
407
568
  const result = await queryBoundWitnessDiviner.divine([
408
569
  divinerQuery
409
570
  ]);
410
- const commands = result.filter(import_boundwitness_model2.isQueryBoundWitnessWithMeta);
411
- 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;
412
573
  await this.commitState(address, nextState);
413
- return commands;
574
+ return queries;
414
575
  };
415
576
  /**
416
577
  * Runs the background divine process on a loop with a delay
@@ -440,12 +601,12 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
440
601
  try {
441
602
  const localModuleName = localModule.config.name ?? localModule.address;
442
603
  this.logger?.debug(`Checking for inbound commands to ${localModuleName}`);
443
- const commands = await this.findCommandsToAddress(localModule.address);
444
- if (commands.length === 0)
604
+ const queries = await this.findQueriesToAddress(localModule.address);
605
+ if (queries.length === 0)
445
606
  return;
446
607
  this.logger?.debug(`Found commands addressed to local module: ${localModuleName}`);
447
- for (const command of commands) {
448
- await this.callLocalModule(localModule, command);
608
+ for (const query of queries) {
609
+ await this.callLocalModule(localModule, query);
449
610
  }
450
611
  } catch (error) {
451
612
  this.logger?.error(`Error processing commands for address ${localModule.address}: ${error}`);
@@ -454,6 +615,52 @@ var AsyncQueryBusServer = class extends AsyncQueryBusBase {
454
615
  };
455
616
  };
456
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
+
457
664
  // src/Schema.ts
458
665
  var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
459
666
 
@@ -465,8 +672,8 @@ var import_assert4 = require("@xylabs/assert");
465
672
  var import_abstract_bridge = require("@xyo-network/abstract-bridge");
466
673
  var import_manifest_model = require("@xyo-network/manifest-model");
467
674
  var import_module_model3 = require("@xyo-network/module-model");
468
- var import_payload_model = require("@xyo-network/payload-model");
469
- var import_lru_cache2 = require("lru-cache");
675
+ var import_payload_model2 = require("@xyo-network/payload-model");
676
+ var import_lru_cache3 = require("lru-cache");
470
677
  function _ts_decorate(decorators, target, key, desc) {
471
678
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
472
679
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -494,10 +701,10 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
494
701
  _targetConfigs = {};
495
702
  _targetQueries = {};
496
703
  _busClient;
497
- _busServer;
704
+ _busHost;
498
705
  get discoverCache() {
499
706
  const config = this.discoverCacheConfig;
500
- this._discoverCache = this._discoverCache ?? new import_lru_cache2.LRUCache({
707
+ this._discoverCache = this._discoverCache ?? new import_lru_cache3.LRUCache({
501
708
  ttlAutopurge: true,
502
709
  ...config
503
710
  });
@@ -558,7 +765,7 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
558
765
  };
559
766
  const boundQuery = await this.bindQuery(queryPayload);
560
767
  const manifest = (0, import_assert4.assertEx)(await this.targetQuery(addressToCall, boundQuery[0], boundQuery[1]), () => `Unable to resolve [${address}]`)[1];
561
- 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");
562
769
  }
563
770
  targetQueries(address) {
564
771
  if (!this.connected)
@@ -578,32 +785,30 @@ var PubSubBridge = class extends import_abstract_bridge.AbstractBridge {
578
785
  busClient() {
579
786
  if (!this._busClient) {
580
787
  this._busClient = new AsyncQueryBusClient({
581
- config: this.config,
788
+ config: this.config.client,
582
789
  logger: this.logger,
583
790
  resolver: this
584
791
  });
585
792
  }
586
793
  return this._busClient;
587
794
  }
588
- busServer() {
589
- if (!this._busServer) {
590
- this._busServer = new AsyncQueryBusServer({
591
- config: this.config,
795
+ busHost() {
796
+ if (!this._busHost) {
797
+ this._busHost = new AsyncQueryBusHost({
798
+ config: this.config.host,
592
799
  logger: this.logger,
593
800
  resolver: this
594
801
  });
595
802
  }
596
- return this._busServer;
803
+ return this._busHost;
597
804
  }
598
805
  async startHandler() {
599
806
  await Promise.resolve(this.connect());
600
- this.busServer().start();
601
- this.busClient().start();
807
+ this.busHost().start();
602
808
  return true;
603
809
  }
604
810
  stopHandler(_timeout) {
605
- this.busClient().stop();
606
- this.busServer().stop();
811
+ this.busHost().stop();
607
812
  return true;
608
813
  }
609
814
  };