@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
@@ -26,45 +26,193 @@ var __publicField = (obj, key, value) => {
26
26
  // src/index.ts
27
27
  var src_exports = {};
28
28
  __export(src_exports, {
29
+ AbstractModuleProxy: () => AbstractModuleProxy,
30
+ AsyncQueryBusClient: () => AsyncQueryBusClient,
31
+ AsyncQueryBusHost: () => AsyncQueryBusHost,
32
+ AsyncQueryBusModuleHost: () => AsyncQueryBusModuleHost,
33
+ AsyncQueryBusModuleProxy: () => AsyncQueryBusModuleProxy,
34
+ Pending: () => Pending,
29
35
  PubSubBridge: () => PubSubBridge,
30
36
  PubSubBridgeConfigSchema: () => PubSubBridgeConfigSchema,
31
37
  PubSubBridgeSchema: () => PubSubBridgeSchema
32
38
  });
33
39
  module.exports = __toCommonJS(src_exports);
34
40
 
35
- // src/Schema.ts
36
- var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
37
-
38
- // src/Config.ts
39
- var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
40
-
41
- // src/PubSubBridge.ts
42
- var import_assert4 = require("@xylabs/assert");
43
- var import_abstract_bridge = require("@xyo-network/abstract-bridge");
44
- var import_manifest_model = require("@xyo-network/manifest-model");
45
- var import_module_model3 = require("@xyo-network/module-model");
41
+ // src/AbstractModuleProxy/AbstractModuleProxy.ts
42
+ var import_assert = require("@xylabs/assert");
43
+ var import_lodash = require("@xylabs/lodash");
44
+ var import_object = require("@xylabs/object");
45
+ var import_promise = require("@xylabs/promise");
46
+ var import_boundwitness_builder = require("@xyo-network/boundwitness-builder");
47
+ var import_boundwitness_wrapper = require("@xyo-network/boundwitness-wrapper");
48
+ var import_module_model = require("@xyo-network/module-model");
46
49
  var import_payload_model = require("@xyo-network/payload-model");
47
- var import_lru_cache2 = require("lru-cache");
50
+ var _AbstractModuleProxy = class _AbstractModuleProxy extends import_object.Base {
51
+ eventData = {};
52
+ proxyParams;
53
+ constructor(params) {
54
+ super({
55
+ config: {
56
+ schema: import_module_model.ModuleConfigSchema
57
+ }
58
+ });
59
+ this.proxyParams = params;
60
+ }
61
+ get account() {
62
+ return this.proxyParams.account;
63
+ }
64
+ get address() {
65
+ return this.proxyParams.moduleAddress;
66
+ }
67
+ get config() {
68
+ return this.params.config;
69
+ }
70
+ get downResolver() {
71
+ throw new Error("Unsupported");
72
+ }
73
+ get id() {
74
+ return this.proxyParams.moduleAddress;
75
+ }
76
+ get queries() {
77
+ return this.proxyParams.queries;
78
+ }
79
+ get upResolver() {
80
+ throw new Error("Unsupported");
81
+ }
82
+ static hasRequiredQueries(module2) {
83
+ return this.missingRequiredQueries(module2).length === 0;
84
+ }
85
+ static missingRequiredQueries(module2) {
86
+ const moduleQueries = module2.queries;
87
+ return (0, import_lodash.compact)(this.requiredQueries.map((query) => {
88
+ return moduleQueries.includes(query) ? null : query;
89
+ }));
90
+ }
91
+ async addressPreviousHash() {
92
+ const queryPayload = {
93
+ schema: import_module_model.ModuleAddressQuerySchema
94
+ };
95
+ return (0, import_assert.assertEx)((await this.sendQuery(queryPayload)).find((payload) => payload.schema === import_module_model.AddressPreviousHashSchema), "Result did not include correct payload");
96
+ }
97
+ clearListeners(_eventNames) {
98
+ throw new Error("Unsupported");
99
+ }
100
+ //TODO: Make ModuleDescription into real payload
101
+ async describe() {
102
+ const queryPayload = {
103
+ schema: import_module_model.ModuleDescribeQuerySchema
104
+ };
105
+ return (await this.sendQuery(queryPayload))[0];
106
+ }
107
+ async discover() {
108
+ const queryPayload = {
109
+ schema: import_module_model.ModuleDiscoverQuerySchema
110
+ };
111
+ return await this.sendQuery(queryPayload);
112
+ }
113
+ emit(_eventName, _eventArgs) {
114
+ throw new Error("Unsupported");
115
+ }
116
+ emitSerial(_eventName, _eventArgs) {
117
+ throw new Error("Unsupported");
118
+ }
119
+ listenerCount(_eventNames) {
120
+ throw new Error("Unsupported");
121
+ }
122
+ async manifest(maxDepth) {
123
+ const queryPayload = {
124
+ schema: import_module_model.ModuleManifestQuerySchema,
125
+ ...maxDepth === void 0 ? {} : {
126
+ maxDepth
127
+ }
128
+ };
129
+ return (await this.sendQuery(queryPayload))[0];
130
+ }
131
+ async moduleAddress() {
132
+ const queryPayload = {
133
+ schema: import_module_model.ModuleAddressQuerySchema
134
+ };
135
+ return await this.sendQuery(queryPayload);
136
+ }
137
+ off(_eventNames, _listener) {
138
+ throw new Error("Unsupported");
139
+ }
140
+ offAny(_listener) {
141
+ throw new Error("Unsupported");
142
+ }
143
+ on(_eventNames, _listener) {
144
+ throw new Error("Unsupported");
145
+ }
146
+ onAny(_listener) {
147
+ throw new Error("Unsupported");
148
+ }
149
+ once(_eventName, _listener) {
150
+ throw new Error("Unsupported");
151
+ }
152
+ async previousHash() {
153
+ const queryPayload = {
154
+ schema: import_module_model.ModuleAddressQuerySchema
155
+ };
156
+ return (await this.sendQuery(queryPayload)).pop().previousHash;
157
+ }
158
+ queryable(_query, _payloads) {
159
+ return true;
160
+ }
161
+ resolve(nameOrAddressOrFilter, _options) {
162
+ return typeof nameOrAddressOrFilter === "string" ? void 0 : [];
163
+ }
164
+ state() {
165
+ return [];
166
+ }
167
+ bindQuery(query, payloads, account = this.account) {
168
+ const promise = new import_promise.PromiseEx(async (resolve) => {
169
+ const result = await this.bindQueryInternal(query, payloads, account);
170
+ resolve == null ? void 0 : resolve(result);
171
+ return result;
172
+ }, account);
173
+ return promise;
174
+ }
175
+ async bindQueryInternal(query, payloads, account = this.account) {
176
+ const builder = await new import_boundwitness_builder.QueryBoundWitnessBuilder().payloads(payloads).query(query);
177
+ const result = await (account ? builder.witness(account) : builder).build();
178
+ return result;
179
+ }
180
+ async filterErrors(result) {
181
+ const wrapper = await import_boundwitness_wrapper.BoundWitnessWrapper.wrap(result[0], result[1]);
182
+ return wrapper.payloadsBySchema(import_payload_model.ModuleErrorSchema);
183
+ }
184
+ async sendQuery(queryPayload, payloads) {
185
+ const query = await this.bindQuery(queryPayload, payloads);
186
+ const [, resultPayloads, errors] = await this.query(query[0], query[1]);
187
+ if (errors && errors.length > 0) {
188
+ throw errors[0];
189
+ }
190
+ return resultPayloads;
191
+ }
192
+ };
193
+ __name(_AbstractModuleProxy, "AbstractModuleProxy");
194
+ __publicField(_AbstractModuleProxy, "requiredQueries", [
195
+ import_module_model.ModuleDiscoverQuerySchema
196
+ ]);
197
+ var AbstractModuleProxy = _AbstractModuleProxy;
48
198
 
49
199
  // src/AsyncQueryBus/AsyncQueryBusClient.ts
50
- var import_assert2 = require("@xylabs/assert");
51
200
  var import_delay = require("@xylabs/delay");
52
201
  var import_forget = require("@xylabs/forget");
53
202
  var import_timer = require("@xylabs/timer");
54
203
  var import_boundwitness_model = require("@xyo-network/boundwitness-model");
55
204
  var import_diviner_boundwitness_model = require("@xyo-network/diviner-boundwitness-model");
56
- var import_module_model = require("@xyo-network/module-model");
57
205
  var import_payload_builder = require("@xyo-network/payload-builder");
206
+ var import_lru_cache2 = require("lru-cache");
58
207
 
59
208
  // src/AsyncQueryBus/AsyncQueryBusBase.ts
60
- var import_assert = require("@xylabs/assert");
61
- var import_object = require("@xylabs/object");
209
+ var import_assert2 = require("@xylabs/assert");
210
+ var import_object2 = require("@xylabs/object");
62
211
  var import_archivist_model = require("@xyo-network/archivist-model");
63
212
  var import_diviner_model = require("@xyo-network/diviner-model");
64
213
  var import_lru_cache = require("lru-cache");
65
- var _AsyncQueryBusBase = class _AsyncQueryBusBase extends import_object.Base {
214
+ var _AsyncQueryBusBase = class _AsyncQueryBusBase extends import_object2.Base {
66
215
  _lastState;
67
- _queryCache;
68
216
  _targetConfigs = {};
69
217
  _targetQueries = {};
70
218
  constructor(params) {
@@ -73,19 +221,9 @@ var _AsyncQueryBusBase = class _AsyncQueryBusBase extends import_object.Base {
73
221
  get config() {
74
222
  return this.params.config;
75
223
  }
76
- get individualAddressBatchQueryLimitConfig() {
77
- return this.config.individualAddressBatchQueryLimit ?? 10;
78
- }
79
224
  get pollFrequencyConfig() {
80
- return this.config.pollFrequency ?? 1e3;
81
- }
82
- get queryCacheConfig() {
83
- const queryCacheConfig = this.config.queryCache === true ? {} : this.config.queryCache;
84
- return {
85
- max: 100,
86
- ttl: 1e3 * 60,
87
- ...queryCacheConfig
88
- };
225
+ var _a;
226
+ return ((_a = this.config) == null ? void 0 : _a.pollFrequency) ?? 1e3;
89
227
  }
90
228
  get resolver() {
91
229
  return this.params.resolver;
@@ -101,47 +239,32 @@ var _AsyncQueryBusBase = class _AsyncQueryBusBase extends import_object.Base {
101
239
  this._lastState = this._lastState ?? new import_lru_cache.LRUCache(requiredConfig);
102
240
  return this._lastState;
103
241
  }
104
- /**
105
- * A cache of queries that have been issued
106
- */
107
- get queryCache() {
108
- const config = this.queryCacheConfig;
109
- const requiredConfig = {
110
- noUpdateTTL: false,
111
- ttlAutopurge: true
112
- };
113
- this._queryCache = this._queryCache ?? new import_lru_cache.LRUCache({
114
- ...config,
115
- ...requiredConfig
116
- });
117
- return this._queryCache;
118
- }
119
242
  async queriesArchivist() {
120
- var _a;
121
- return (0, import_assert.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve((_a = this.config.queries) == null ? void 0 : _a.archivist)), () => {
122
- var _a2;
123
- return `Unable to resolve queriesArchivist [${(_a2 = this.config.queries) == null ? void 0 : _a2.archivist}]`;
243
+ var _a, _b, _c;
244
+ return (0, import_assert2.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve((_c = (_b = (_a = this.config) == null ? void 0 : _a.clearingHouse) == null ? void 0 : _b.queries) == null ? void 0 : _c.archivist)), () => {
245
+ var _a2, _b2, _c2;
246
+ return `Unable to resolve queriesArchivist [${(_c2 = (_b2 = (_a2 = this.config) == null ? void 0 : _a2.clearingHouse) == null ? void 0 : _b2.queries) == null ? void 0 : _c2.archivist}]`;
124
247
  });
125
248
  }
126
249
  async queriesDiviner() {
127
- var _a;
128
- return (0, import_assert.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve((_a = this.config.queries) == null ? void 0 : _a.boundWitnessDiviner)), () => {
129
- var _a2;
130
- return `Unable to resolve queriesDiviner [${(_a2 = this.config.queries) == null ? void 0 : _a2.boundWitnessDiviner}]`;
250
+ var _a, _b, _c;
251
+ return (0, import_assert2.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve((_c = (_b = (_a = this.config) == null ? void 0 : _a.clearingHouse) == null ? void 0 : _b.queries) == null ? void 0 : _c.boundWitnessDiviner)), () => {
252
+ var _a2, _b2, _c2;
253
+ return `Unable to resolve queriesDiviner [${(_c2 = (_b2 = (_a2 = this.config) == null ? void 0 : _a2.clearingHouse) == null ? void 0 : _b2.queries) == null ? void 0 : _c2.boundWitnessDiviner}]`;
131
254
  });
132
255
  }
133
256
  async responsesArchivist() {
134
- var _a;
135
- return (0, import_assert.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve((_a = this.config.responses) == null ? void 0 : _a.archivist)), () => {
136
- var _a2;
137
- return `Unable to resolve responsesArchivist [${(_a2 = this.config.responses) == null ? void 0 : _a2.archivist}]`;
257
+ var _a, _b, _c;
258
+ return (0, import_assert2.assertEx)((0, import_archivist_model.asArchivistInstance)(await this.resolver.resolve((_c = (_b = (_a = this.config) == null ? void 0 : _a.clearingHouse) == null ? void 0 : _b.responses) == null ? void 0 : _c.archivist)), () => {
259
+ var _a2, _b2, _c2;
260
+ return `Unable to resolve responsesArchivist [${(_c2 = (_b2 = (_a2 = this.config) == null ? void 0 : _a2.clearingHouse) == null ? void 0 : _b2.responses) == null ? void 0 : _c2.archivist}]`;
138
261
  });
139
262
  }
140
263
  async responsesDiviner() {
141
- var _a;
142
- return (0, import_assert.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve((_a = this.config.responses) == null ? void 0 : _a.boundWitnessDiviner)), () => {
143
- var _a2;
144
- return `Unable to resolve responsesDiviner [${(_a2 = this.config.responses) == null ? void 0 : _a2.boundWitnessDiviner}]`;
264
+ var _a, _b, _c;
265
+ return (0, import_assert2.assertEx)((0, import_diviner_model.asDivinerInstance)(await this.resolver.resolve((_c = (_b = (_a = this.config) == null ? void 0 : _a.clearingHouse) == null ? void 0 : _b.responses) == null ? void 0 : _c.boundWitnessDiviner)), () => {
266
+ var _a2, _b2, _c2;
267
+ return `Unable to resolve responsesDiviner [${(_c2 = (_b2 = (_a2 = this.config) == null ? void 0 : _a2.clearingHouse) == null ? void 0 : _b2.responses) == null ? void 0 : _c2.boundWitnessDiviner}]`;
145
268
  });
146
269
  }
147
270
  /**
@@ -183,21 +306,45 @@ var Pending = "pending";
183
306
 
184
307
  // src/AsyncQueryBus/AsyncQueryBusClient.ts
185
308
  var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase {
309
+ _queryCache;
310
+ _pollCount = 0;
186
311
  _pollId;
187
312
  constructor(params) {
188
313
  super(params);
189
314
  }
315
+ get queryCacheConfig() {
316
+ var _a, _b;
317
+ const queryCacheConfig = ((_a = this.config) == null ? void 0 : _a.queryCache) === true ? {} : (_b = this.config) == null ? void 0 : _b.queryCache;
318
+ return {
319
+ max: 100,
320
+ ttl: 1e3 * 60,
321
+ ...queryCacheConfig
322
+ };
323
+ }
190
324
  get started() {
191
325
  return !!this._pollId;
192
326
  }
193
- async listeningModules() {
194
- 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({
195
- direction: "all"
327
+ /**
328
+ * A cache of queries that have been issued
329
+ */
330
+ get queryCache() {
331
+ const config = this.queryCacheConfig;
332
+ const requiredConfig = {
333
+ noUpdateTTL: false,
334
+ ttlAutopurge: true
335
+ };
336
+ this._queryCache = this._queryCache ?? new import_lru_cache2.LRUCache({
337
+ ...config,
338
+ ...requiredConfig
196
339
  });
197
- return mods;
340
+ return this._queryCache;
341
+ }
342
+ listeningAddresses() {
343
+ var _a;
344
+ return (_a = this._queryCache) == null ? void 0 : _a.keys();
198
345
  }
199
346
  async send(address, query, payloads) {
200
- var _a, _b, _c, _d, _e, _f;
347
+ var _a, _b, _c, _d;
201
348
  (_a = this.logger) == null ? void 0 : _a.debug(`Begin issuing query to: ${address}`);
202
349
  const $meta = {
203
350
  ...query == null ? void 0 : query.$meta,
@@ -210,10 +357,6 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
210
357
  $meta
211
358
  });
212
359
  const queryArchivist = await this.queriesArchivist();
213
- const sourceAddress = query.addresses.at(0);
214
- if (sourceAddress && !((_b = this.config.listeningModules) == null ? void 0 : _b.includes(sourceAddress))) {
215
- (_c = this.config.listeningModules) == null ? void 0 : _c.push(sourceAddress);
216
- }
217
360
  const routedQueryHash = (
218
361
  // Trust the signed hash if it's there
219
362
  (routedQuery == null ? void 0 : routedQuery.$hash) ?? // TODO: What is the right way to find the dataHash
@@ -221,15 +364,15 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
221
364
  routedQuery
222
365
  ]))[0]
223
366
  );
224
- (_d = this.logger) == null ? void 0 : _d.debug(`Issuing query: ${routedQueryHash} to: ${address}`);
367
+ (_b = this.logger) == null ? void 0 : _b.debug(`Issuing query: ${routedQueryHash} to: ${address}`);
225
368
  const data = payloads ? [
226
369
  routedQuery,
227
370
  ...payloads
228
371
  ] : [
229
372
  routedQuery
230
373
  ];
231
- const insertResult = await ((_e = queryArchivist.insert) == null ? void 0 : _e.call(queryArchivist, data));
232
- (_f = this.logger) == null ? void 0 : _f.debug(`Issued query: ${routedQueryHash} to: ${address}`);
374
+ const insertResult = await ((_c = queryArchivist.insert) == null ? void 0 : _c.call(queryArchivist, data));
375
+ (_d = this.logger) == null ? void 0 : _d.debug(`Issued query: ${routedQueryHash} to: ${address}`);
233
376
  this.queryCache.set(routedQueryHash, Pending);
234
377
  if (!insertResult)
235
378
  throw new Error("Unable to issue query to queryArchivist");
@@ -238,52 +381,43 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
238
381
  (_a2 = this.logger) == null ? void 0 : _a2.debug(`Polling for response to query: ${routedQueryHash}`);
239
382
  const pollForResponse = /* @__PURE__ */ __name(async () => {
240
383
  var _a3, _b2;
241
- let response = this.queryCache.get(routedQueryHash);
242
- while (response !== void 0) {
243
- await (0, import_delay.delay)(100);
244
- response = this.queryCache.get(routedQueryHash);
245
- if (response && response !== Pending) {
246
- (_a3 = this.logger) == null ? void 0 : _a3.debug(`Returning response to query: ${routedQueryHash}`);
247
- resolve(response);
248
- return;
384
+ try {
385
+ this.start();
386
+ let response = this.queryCache.get(routedQueryHash);
387
+ while (response !== void 0) {
388
+ await (0, import_delay.delay)(100);
389
+ response = this.queryCache.get(routedQueryHash);
390
+ if (response && response !== Pending) {
391
+ (_a3 = this.logger) == null ? void 0 : _a3.debug(`Returning response to query: ${routedQueryHash}`);
392
+ resolve(response);
393
+ return;
394
+ }
249
395
  }
396
+ (_b2 = this.logger) == null ? void 0 : _b2.error("Timeout waiting for query response");
397
+ const error = {
398
+ message: "Timeout waiting for query response",
399
+ query: "network.xyo.boundwitness",
400
+ schema: "network.xyo.error.module",
401
+ sources: [
402
+ routedQueryHash
403
+ ]
404
+ };
405
+ resolve([
406
+ routedQuery,
407
+ [],
408
+ [
409
+ await import_payload_builder.PayloadBuilder.build(error)
410
+ ]
411
+ ]);
412
+ return;
413
+ } finally {
414
+ this.stop();
250
415
  }
251
- (_b2 = this.logger) == null ? void 0 : _b2.error("Timeout waiting for query response");
252
- const error = {
253
- message: "Timeout waiting for query response",
254
- query: "network.xyo.boundwitness",
255
- schema: "network.xyo.error.module",
256
- sources: [
257
- routedQueryHash
258
- ]
259
- };
260
- resolve([
261
- routedQuery,
262
- [],
263
- [
264
- await import_payload_builder.PayloadBuilder.build(error)
265
- ]
266
- ]);
267
- return;
268
416
  }, "pollForResponse");
269
417
  (0, import_forget.forget)(pollForResponse());
270
418
  });
271
419
  return context;
272
420
  }
273
- start() {
274
- if (this.started) {
275
- console.warn("AsyncQueryBus starting when already started");
276
- }
277
- this.poll();
278
- }
279
- stop() {
280
- if (!this.started) {
281
- console.warn("AsyncQueryBus stopping when already stopped");
282
- }
283
- if (this._pollId)
284
- (0, import_timer.clearTimeoutEx)(this._pollId);
285
- this._pollId = void 0;
286
- }
287
421
  /**
288
422
  * Runs the background divine process on a loop with a delay
289
423
  * specified by the `config.pollFrequency`
@@ -337,11 +471,26 @@ var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase
337
471
  }
338
472
  }));
339
473
  };
474
+ start() {
475
+ if (this._pollCount === 0) {
476
+ this.poll();
477
+ }
478
+ this._pollCount++;
479
+ }
480
+ stop() {
481
+ this._pollCount--;
482
+ if (this._pollCount <= 0) {
483
+ if (this._pollId)
484
+ (0, import_timer.clearTimeoutEx)(this._pollId);
485
+ this._pollId = void 0;
486
+ this._pollCount = 0;
487
+ }
488
+ }
340
489
  };
341
490
  __name(_AsyncQueryBusClient, "AsyncQueryBusClient");
342
491
  var AsyncQueryBusClient = _AsyncQueryBusClient;
343
492
 
344
- // src/AsyncQueryBus/AsyncQueryBusServer.ts
493
+ // src/AsyncQueryBus/AsyncQueryBusHost.ts
345
494
  var import_array = require("@xylabs/array");
346
495
  var import_assert3 = require("@xylabs/assert");
347
496
  var import_timer2 = require("@xylabs/timer");
@@ -349,17 +498,22 @@ var import_boundwitness_model2 = require("@xyo-network/boundwitness-model");
349
498
  var import_diviner_boundwitness_model2 = require("@xyo-network/diviner-boundwitness-model");
350
499
  var import_module_model2 = require("@xyo-network/module-model");
351
500
  var import_payload_builder2 = require("@xyo-network/payload-builder");
352
- var _AsyncQueryBusServer = class _AsyncQueryBusServer extends AsyncQueryBusBase {
501
+ var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
353
502
  _pollId;
354
503
  constructor(params) {
355
504
  super(params);
356
505
  }
506
+ get perAddressBatchQueryLimit() {
507
+ var _a;
508
+ return ((_a = this.config) == null ? void 0 : _a.perAddressBatchQueryLimit) ?? 10;
509
+ }
357
510
  get started() {
358
511
  return !!this._pollId;
359
512
  }
360
513
  async listeningModules() {
361
- 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({
362
- direction: "all"
514
+ var _a;
515
+ const mods = ((_a = this.config) == null ? void 0 : _a.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, {
516
+ direction: "down"
363
517
  });
364
518
  return mods;
365
519
  }
@@ -377,28 +531,28 @@ var _AsyncQueryBusServer = class _AsyncQueryBusServer extends AsyncQueryBusBase
377
531
  (0, import_timer2.clearTimeoutEx)(this._pollId);
378
532
  this._pollId = void 0;
379
533
  }
380
- callLocalModule = async (localModule, command) => {
534
+ callLocalModule = async (localModule, query) => {
381
535
  var _a, _b, _c, _d, _e, _f;
382
536
  const localModuleName = localModule.config.name ?? localModule.address;
383
537
  const queryArchivist = await this.queriesArchivist();
384
538
  const responseArchivist = await this.responsesArchivist();
385
- const commandDestination = (_a = command.$meta) == null ? void 0 : _a.destination;
539
+ const commandDestination = (_a = query.$meta) == null ? void 0 : _a.destination;
386
540
  if (commandDestination && (commandDestination == null ? void 0 : commandDestination.includes(localModule.address))) {
387
- const queryIndex = command.payload_hashes.indexOf(command.query);
541
+ const queryIndex = query.payload_hashes.indexOf(query.query);
388
542
  if (queryIndex !== -1) {
389
- const querySchema = command.payload_schemas[queryIndex];
543
+ const querySchema = query.payload_schemas[queryIndex];
390
544
  if (localModule.queries.includes(querySchema)) {
391
- const commandPayloads = await queryArchivist.get(command.payload_hashes);
545
+ const commandPayloads = await queryArchivist.get(query.payload_hashes);
392
546
  const commandPayloadsDict = await import_payload_builder2.PayloadBuilder.toAllHashMap(commandPayloads);
393
- const commandHash = (await import_payload_builder2.PayloadBuilder.build(command)).$hash;
394
- if (!(0, import_array.containsAll)(Object.keys(commandPayloadsDict), command.payload_hashes)) {
547
+ const commandHash = (await import_payload_builder2.PayloadBuilder.build(query)).$hash;
548
+ if (!(0, import_array.containsAll)(Object.keys(commandPayloadsDict), query.payload_hashes)) {
395
549
  (_b = this.logger) == null ? void 0 : _b.error(`Error processing command ${commandHash} for module ${localModuleName}, missing payloads`);
396
550
  return;
397
551
  }
398
552
  try {
399
- const commandSchema = commandPayloadsDict[command.query].schema;
553
+ const commandSchema = commandPayloadsDict[query.query].schema;
400
554
  (_c = this.logger) == null ? void 0 : _c.debug(`Issuing command ${commandSchema} (${commandHash}) addressed to module: ${localModuleName}`);
401
- const response = await localModule.query(command, commandPayloads);
555
+ const response = await localModule.query(query, commandPayloads);
402
556
  const [bw, payloads, errors] = response;
403
557
  (_d = this.logger) == null ? void 0 : _d.debug(`Replying to command ${commandHash} addressed to module: ${localModuleName}`);
404
558
  const insertResult = await responseArchivist.insert([
@@ -406,11 +560,11 @@ var _AsyncQueryBusServer = class _AsyncQueryBusServer extends AsyncQueryBusBase
406
560
  ...payloads,
407
561
  ...errors
408
562
  ]);
409
- if (insertResult.length > 0) {
563
+ if (insertResult.length === 0) {
410
564
  (_e = this.logger) == null ? void 0 : _e.error(`Error replying to command ${commandHash} addressed to module: ${localModuleName}`);
411
565
  }
412
- if (command == null ? void 0 : command.timestamp) {
413
- await this.commitState(localModule.address, command.timestamp);
566
+ if (query == null ? void 0 : query.timestamp) {
567
+ await this.commitState(localModule.address, query.timestamp);
414
568
  }
415
569
  } catch (error) {
416
570
  (_f = this.logger) == null ? void 0 : _f.error(`Error processing command ${commandHash} for module ${localModuleName}: ${error}`);
@@ -423,13 +577,13 @@ var _AsyncQueryBusServer = class _AsyncQueryBusServer extends AsyncQueryBusBase
423
577
  * Finds unprocessed commands addressed to the supplied address
424
578
  * @param address The address to find commands for
425
579
  */
426
- findCommandsToAddress = async (address) => {
580
+ findQueriesToAddress = async (address) => {
427
581
  const queryBoundWitnessDiviner = await this.queriesDiviner();
428
582
  const timestamp = await this.retrieveState(address);
429
583
  const destination = [
430
584
  address
431
585
  ];
432
- const limit = this.individualAddressBatchQueryLimitConfig;
586
+ const limit = this.perAddressBatchQueryLimit;
433
587
  const divinerQuery = {
434
588
  destination,
435
589
  limit,
@@ -440,10 +594,10 @@ var _AsyncQueryBusServer = class _AsyncQueryBusServer extends AsyncQueryBusBase
440
594
  const result = await queryBoundWitnessDiviner.divine([
441
595
  divinerQuery
442
596
  ]);
443
- const commands = result.filter(import_boundwitness_model2.isQueryBoundWitnessWithMeta);
444
- const nextState = Math.max(...commands.map((c) => c.timestamp ?? 0));
597
+ const queries = result.filter(import_boundwitness_model2.isQueryBoundWitnessWithMeta);
598
+ const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp;
445
599
  await this.commitState(address, nextState);
446
- return commands;
600
+ return queries;
447
601
  };
448
602
  /**
449
603
  * Runs the background divine process on a loop with a delay
@@ -476,12 +630,12 @@ var _AsyncQueryBusServer = class _AsyncQueryBusServer extends AsyncQueryBusBase
476
630
  try {
477
631
  const localModuleName = localModule.config.name ?? localModule.address;
478
632
  (_a2 = this.logger) == null ? void 0 : _a2.debug(`Checking for inbound commands to ${localModuleName}`);
479
- const commands = await this.findCommandsToAddress(localModule.address);
480
- if (commands.length === 0)
633
+ const queries = await this.findQueriesToAddress(localModule.address);
634
+ if (queries.length === 0)
481
635
  return;
482
636
  (_b = this.logger) == null ? void 0 : _b.debug(`Found commands addressed to local module: ${localModuleName}`);
483
- for (const command of commands) {
484
- await this.callLocalModule(localModule, command);
637
+ for (const query of queries) {
638
+ await this.callLocalModule(localModule, query);
485
639
  }
486
640
  } catch (error) {
487
641
  (_c = this.logger) == null ? void 0 : _c.error(`Error processing commands for address ${localModule.address}: ${error}`);
@@ -489,10 +643,67 @@ var _AsyncQueryBusServer = class _AsyncQueryBusServer extends AsyncQueryBusBase
489
643
  }));
490
644
  };
491
645
  };
492
- __name(_AsyncQueryBusServer, "AsyncQueryBusServer");
493
- var AsyncQueryBusServer = _AsyncQueryBusServer;
646
+ __name(_AsyncQueryBusHost, "AsyncQueryBusHost");
647
+ var AsyncQueryBusHost = _AsyncQueryBusHost;
648
+
649
+ // src/AbstractModuleHost/AbstractModuleHost.ts
650
+ var import_object3 = require("@xylabs/object");
651
+ var _AbstractModuleHost = class _AbstractModuleHost extends import_object3.Base {
652
+ };
653
+ __name(_AbstractModuleHost, "AbstractModuleHost");
654
+ var AbstractModuleHost = _AbstractModuleHost;
655
+
656
+ // src/AsyncQueryBus/ModuleHost/ModuleHost.ts
657
+ var _AsyncQueryBusModuleHost = class _AsyncQueryBusModuleHost extends AbstractModuleHost {
658
+ _busHost;
659
+ constructor(params) {
660
+ super(params);
661
+ }
662
+ async start() {
663
+ var _a;
664
+ const listeningModules = this.params.config.listeningModules ?? (await this.params.module.resolve(void 0, {
665
+ direction: "down"
666
+ })).map((m) => m.address);
667
+ this._busHost = new AsyncQueryBusHost({
668
+ config: {
669
+ ...this.params.config,
670
+ listeningModules
671
+ },
672
+ logger: this.params.logger,
673
+ resolver: this.params.module
674
+ });
675
+ (_a = this._busHost) == null ? void 0 : _a.start();
676
+ }
677
+ stop() {
678
+ var _a;
679
+ (_a = this._busHost) == null ? void 0 : _a.stop();
680
+ }
681
+ };
682
+ __name(_AsyncQueryBusModuleHost, "AsyncQueryBusModuleHost");
683
+ var AsyncQueryBusModuleHost = _AsyncQueryBusModuleHost;
684
+
685
+ // src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts
686
+ var _AsyncQueryBusModuleProxy = class _AsyncQueryBusModuleProxy extends AbstractModuleProxy {
687
+ async query(query, payloads) {
688
+ return await this.proxyParams.bridgeClient.send(this.address, query, payloads);
689
+ }
690
+ };
691
+ __name(_AsyncQueryBusModuleProxy, "AsyncQueryBusModuleProxy");
692
+ var AsyncQueryBusModuleProxy = _AsyncQueryBusModuleProxy;
693
+
694
+ // src/Schema.ts
695
+ var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
696
+
697
+ // src/Config.ts
698
+ var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
494
699
 
495
700
  // src/PubSubBridge.ts
701
+ var import_assert4 = require("@xylabs/assert");
702
+ var import_abstract_bridge = require("@xyo-network/abstract-bridge");
703
+ var import_manifest_model = require("@xyo-network/manifest-model");
704
+ var import_module_model3 = require("@xyo-network/module-model");
705
+ var import_payload_model2 = require("@xyo-network/payload-model");
706
+ var import_lru_cache3 = require("lru-cache");
496
707
  function _ts_decorate(decorators, target, key, desc) {
497
708
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
498
709
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -514,10 +725,10 @@ var _PubSubBridge = class _PubSubBridge extends import_abstract_bridge.AbstractB
514
725
  _targetConfigs = {};
515
726
  _targetQueries = {};
516
727
  _busClient;
517
- _busServer;
728
+ _busHost;
518
729
  get discoverCache() {
519
730
  const config = this.discoverCacheConfig;
520
- this._discoverCache = this._discoverCache ?? new import_lru_cache2.LRUCache({
731
+ this._discoverCache = this._discoverCache ?? new import_lru_cache3.LRUCache({
521
732
  ttlAutopurge: true,
522
733
  ...config
523
734
  });
@@ -579,7 +790,7 @@ var _PubSubBridge = class _PubSubBridge extends import_abstract_bridge.AbstractB
579
790
  };
580
791
  const boundQuery = await this.bindQuery(queryPayload);
581
792
  const manifest = (0, import_assert4.assertEx)(await this.targetQuery(addressToCall, boundQuery[0], boundQuery[1]), () => `Unable to resolve [${address}]`)[1];
582
- return (0, import_assert4.assertEx)(manifest.find((0, import_payload_model.isPayloadOfSchemaType)(import_manifest_model.ModuleManifestPayloadSchema)), "Did not receive manifest");
793
+ return (0, import_assert4.assertEx)(manifest.find((0, import_payload_model2.isPayloadOfSchemaType)(import_manifest_model.ModuleManifestPayloadSchema)), "Did not receive manifest");
583
794
  }
584
795
  targetQueries(address) {
585
796
  if (!this.connected)
@@ -599,32 +810,30 @@ var _PubSubBridge = class _PubSubBridge extends import_abstract_bridge.AbstractB
599
810
  busClient() {
600
811
  if (!this._busClient) {
601
812
  this._busClient = new AsyncQueryBusClient({
602
- config: this.config,
813
+ config: this.config.client,
603
814
  logger: this.logger,
604
815
  resolver: this
605
816
  });
606
817
  }
607
818
  return this._busClient;
608
819
  }
609
- busServer() {
610
- if (!this._busServer) {
611
- this._busServer = new AsyncQueryBusServer({
612
- config: this.config,
820
+ busHost() {
821
+ if (!this._busHost) {
822
+ this._busHost = new AsyncQueryBusHost({
823
+ config: this.config.host,
613
824
  logger: this.logger,
614
825
  resolver: this
615
826
  });
616
827
  }
617
- return this._busServer;
828
+ return this._busHost;
618
829
  }
619
830
  async startHandler() {
620
831
  await Promise.resolve(this.connect());
621
- this.busServer().start();
622
- this.busClient().start();
832
+ this.busHost().start();
623
833
  return true;
624
834
  }
625
835
  stopHandler(_timeout) {
626
- this.busClient().stop();
627
- this.busServer().stop();
836
+ this.busHost().stop();
628
837
  return true;
629
838
  }
630
839
  };
@@ -638,6 +847,12 @@ PubSubBridge = _ts_decorate([
638
847
  ], PubSubBridge);
639
848
  // Annotate the CommonJS export names for ESM import in node:
640
849
  0 && (module.exports = {
850
+ AbstractModuleProxy,
851
+ AsyncQueryBusClient,
852
+ AsyncQueryBusHost,
853
+ AsyncQueryBusModuleHost,
854
+ AsyncQueryBusModuleProxy,
855
+ Pending,
641
856
  PubSubBridge,
642
857
  PubSubBridgeConfigSchema,
643
858
  PubSubBridgeSchema