@xyo-network/bridge-pub-sub 2.91.0 → 2.91.2

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
@@ -3,18 +3,15 @@ import { Address } from '@xylabs/hex'
3
3
  import { Base } from '@xylabs/object'
4
4
  import { asArchivistInstance } from '@xyo-network/archivist-model'
5
5
  import { BoundWitness, QueryBoundWitness } from '@xyo-network/boundwitness-model'
6
- import { CacheConfig } from '@xyo-network/bridge-model'
7
6
  import { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'
8
7
  import { asDivinerInstance, DivinerInstance } from '@xyo-network/diviner-model'
9
- import { ModuleConfig, ModuleQueryResult } from '@xyo-network/module-model'
8
+ import { ModuleConfig } from '@xyo-network/module-model'
10
9
  import { LRUCache } from 'lru-cache'
11
10
 
12
- import { Pending } from './Config'
13
11
  import { AsyncQueryBusParams } from './Params'
14
12
 
15
13
  export class AsyncQueryBusBase<TParams extends AsyncQueryBusParams = AsyncQueryBusParams> extends Base<TParams> {
16
14
  protected _lastState?: LRUCache<Address, number>
17
- protected _queryCache?: LRUCache<Address, Pending | ModuleQueryResult>
18
15
  protected _targetConfigs: Record<Address, ModuleConfig> = {}
19
16
  protected _targetQueries: Record<Address, string[]> = {}
20
17
 
@@ -22,21 +19,12 @@ export class AsyncQueryBusBase<TParams extends AsyncQueryBusParams = AsyncQueryB
22
19
  super(params)
23
20
  }
24
21
 
25
- get config() {
22
+ get config(): TParams['config'] {
26
23
  return this.params.config
27
24
  }
28
25
 
29
- get individualAddressBatchQueryLimitConfig(): number {
30
- return this.config.individualAddressBatchQueryLimit ?? 10
31
- }
32
-
33
26
  get pollFrequencyConfig(): number {
34
- return this.config.pollFrequency ?? 1000
35
- }
36
-
37
- get queryCacheConfig(): LRUCache.Options<Address, Pending | ModuleQueryResult, unknown> {
38
- const queryCacheConfig: CacheConfig | undefined = this.config.queryCache === true ? {} : this.config.queryCache
39
- return { max: 100, ttl: 1000 * 60, ...queryCacheConfig }
27
+ return this.config?.pollFrequency ?? 1000
40
28
  }
41
29
 
42
30
  get resolver() {
@@ -52,41 +40,31 @@ export class AsyncQueryBusBase<TParams extends AsyncQueryBusParams = AsyncQueryB
52
40
  return this._lastState
53
41
  }
54
42
 
55
- /**
56
- * A cache of queries that have been issued
57
- */
58
- protected get queryCache(): LRUCache<Address, Pending | ModuleQueryResult> {
59
- const config = this.queryCacheConfig
60
- const requiredConfig = { noUpdateTTL: false, ttlAutopurge: true }
61
- this._queryCache = this._queryCache ?? new LRUCache<Address, Pending | ModuleQueryResult>({ ...config, ...requiredConfig })
62
- return this._queryCache
63
- }
64
-
65
43
  async queriesArchivist() {
66
44
  return assertEx(
67
- asArchivistInstance(await this.resolver.resolve(this.config.queries?.archivist)),
68
- () => `Unable to resolve queriesArchivist [${this.config.queries?.archivist}]`,
45
+ asArchivistInstance(await this.resolver.resolve(this.config?.clearingHouse?.queries?.archivist)),
46
+ () => `Unable to resolve queriesArchivist [${this.config?.clearingHouse?.queries?.archivist}]`,
69
47
  )
70
48
  }
71
49
 
72
50
  async queriesDiviner() {
73
51
  return assertEx(
74
- asDivinerInstance(await this.resolver.resolve(this.config.queries?.boundWitnessDiviner)),
75
- () => `Unable to resolve queriesDiviner [${this.config.queries?.boundWitnessDiviner}]`,
52
+ asDivinerInstance(await this.resolver.resolve(this.config?.clearingHouse?.queries?.boundWitnessDiviner)),
53
+ () => `Unable to resolve queriesDiviner [${this.config?.clearingHouse?.queries?.boundWitnessDiviner}]`,
76
54
  ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, QueryBoundWitness>
77
55
  }
78
56
 
79
57
  async responsesArchivist() {
80
58
  return assertEx(
81
- asArchivistInstance(await this.resolver.resolve(this.config.responses?.archivist)),
82
- () => `Unable to resolve responsesArchivist [${this.config.responses?.archivist}]`,
59
+ asArchivistInstance(await this.resolver.resolve(this.config?.clearingHouse?.responses?.archivist)),
60
+ () => `Unable to resolve responsesArchivist [${this.config?.clearingHouse?.responses?.archivist}]`,
83
61
  )
84
62
  }
85
63
 
86
64
  async responsesDiviner() {
87
65
  return assertEx(
88
- asDivinerInstance(await this.resolver.resolve(this.config.responses?.boundWitnessDiviner)),
89
- () => `Unable to resolve responsesDiviner [${this.config.responses?.boundWitnessDiviner}]`,
66
+ asDivinerInstance(await this.resolver.resolve(this.config?.clearingHouse?.responses?.boundWitnessDiviner)),
67
+ () => `Unable to resolve responsesDiviner [${this.config?.clearingHouse?.responses?.boundWitnessDiviner}]`,
90
68
  ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>
91
69
  }
92
70
 
@@ -1,42 +1,49 @@
1
- import { assertEx } from '@xylabs/assert'
2
1
  import { delay } from '@xylabs/delay'
3
2
  import { forget } from '@xylabs/forget'
4
3
  import { Address } from '@xylabs/hex'
5
4
  import { clearTimeoutEx, setTimeoutEx } from '@xylabs/timer'
6
5
  import { isBoundWitnessWithMeta, QueryBoundWitness } from '@xyo-network/boundwitness-model'
6
+ import { CacheConfig } from '@xyo-network/bridge-model'
7
7
  import { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'
8
- import { asModuleInstance, ModuleQueryResult } from '@xyo-network/module-model'
8
+ import { ModuleQueryResult } from '@xyo-network/module-model'
9
9
  import { PayloadBuilder } from '@xyo-network/payload-builder'
10
10
  import { ModuleError, Payload, PayloadWithMeta, WithMeta } from '@xyo-network/payload-model'
11
+ import { LRUCache } from 'lru-cache'
11
12
 
12
13
  import { AsyncQueryBusBase } from './AsyncQueryBusBase'
13
14
  import { Pending } from './Config'
14
- import { AsyncQueryBusParams } from './Params'
15
+ import { AsyncQueryBusClientParams } from './Params'
15
16
 
16
- export class AsyncQueryBusClient<TParams extends AsyncQueryBusParams = AsyncQueryBusParams> extends AsyncQueryBusBase<TParams> {
17
+ export class AsyncQueryBusClient<TParams extends AsyncQueryBusClientParams = AsyncQueryBusClientParams> extends AsyncQueryBusBase<TParams> {
18
+ protected _queryCache?: LRUCache<Address, Pending | ModuleQueryResult>
19
+ private _pollCount = 0
17
20
  private _pollId?: string
18
21
 
19
22
  constructor(params: TParams) {
20
23
  super(params)
21
24
  }
22
25
 
26
+ get queryCacheConfig(): LRUCache.Options<Address, Pending | ModuleQueryResult, unknown> {
27
+ const queryCacheConfig: CacheConfig | undefined = this.config?.queryCache === true ? {} : this.config?.queryCache
28
+ return { max: 100, ttl: 1000 * 60, ...queryCacheConfig }
29
+ }
30
+
23
31
  get started() {
24
32
  return !!this._pollId
25
33
  }
26
34
 
27
- async listeningModules() {
28
- const mods =
29
- this.config.listeningModules ?
30
- await Promise.all(
31
- this.config.listeningModules.map(async (listeningModule) =>
32
- assertEx(
33
- asModuleInstance(await this.resolver.resolve(listeningModule)),
34
- () => `Unable to resolve all listeningModule [${listeningModule}]`,
35
- ),
36
- ),
37
- )
38
- : await this.resolver.resolve({ direction: 'all' })
39
- return mods
35
+ /**
36
+ * A cache of queries that have been issued
37
+ */
38
+ protected get queryCache(): LRUCache<Address, Pending | ModuleQueryResult> {
39
+ const config = this.queryCacheConfig
40
+ const requiredConfig = { noUpdateTTL: false, ttlAutopurge: true }
41
+ this._queryCache = this._queryCache ?? new LRUCache<Address, Pending | ModuleQueryResult>({ ...config, ...requiredConfig })
42
+ return this._queryCache
43
+ }
44
+
45
+ listeningAddresses() {
46
+ return this._queryCache?.keys()
40
47
  }
41
48
 
42
49
  async send(address: Address, query: QueryBoundWitness, payloads?: Payload[] | undefined): Promise<ModuleQueryResult> {
@@ -45,11 +52,6 @@ export class AsyncQueryBusClient<TParams extends AsyncQueryBusParams = AsyncQuer
45
52
  const routedQuery = await PayloadBuilder.build({ ...query, $meta })
46
53
  const queryArchivist = await this.queriesArchivist()
47
54
 
48
- const sourceAddress = query.addresses.at(0)
49
- if (sourceAddress && !this.config.listeningModules?.includes(sourceAddress)) {
50
- this.config.listeningModules?.push(sourceAddress)
51
- }
52
-
53
55
  // TODO: Should we always re-hash to true up timestamps? We can't
54
56
  // re-sign correctly so we would lose that information if we did and
55
57
  // would also be replying to consumers with a different query hash than
@@ -71,53 +73,43 @@ export class AsyncQueryBusClient<TParams extends AsyncQueryBusParams = AsyncQuer
71
73
  const context = new Promise<ModuleQueryResult>((resolve) => {
72
74
  this.logger?.debug(`Polling for response to query: ${routedQueryHash}`)
73
75
  const pollForResponse = async () => {
74
- let response = this.queryCache.get(routedQueryHash)
75
- // Poll for response until cache key expires (response timed out)
76
- while (response !== undefined) {
77
- // Wait a bit
78
- await delay(100)
79
- // Check the status of the response
80
- response = this.queryCache.get(routedQueryHash)
81
- // If status is no longer pending that means we received a response
82
- if (response && response !== Pending) {
83
- this.logger?.debug(`Returning response to query: ${routedQueryHash}`)
84
- resolve(response)
85
- return
76
+ try {
77
+ this.start()
78
+ let response = this.queryCache.get(routedQueryHash)
79
+ // Poll for response until cache key expires (response timed out)
80
+ while (response !== undefined) {
81
+ // Wait a bit
82
+ await delay(100)
83
+ // Check the status of the response
84
+ response = this.queryCache.get(routedQueryHash)
85
+ // If status is no longer pending that means we received a response
86
+ if (response && response !== Pending) {
87
+ this.logger?.debug(`Returning response to query: ${routedQueryHash}`)
88
+ resolve(response)
89
+ return
90
+ }
86
91
  }
92
+ // If we got here waiting for a response timed out
93
+ this.logger?.error('Timeout waiting for query response')
94
+ // Resolve with error to match what a local module would do if it were to error
95
+ // TODO: BW Builder/Sign result as this module?
96
+ const error: ModuleError = {
97
+ message: 'Timeout waiting for query response',
98
+ query: 'network.xyo.boundwitness',
99
+ schema: 'network.xyo.error.module',
100
+ sources: [routedQueryHash],
101
+ }
102
+ resolve([routedQuery, [], [await PayloadBuilder.build(error)]])
103
+ return
104
+ } finally {
105
+ this.stop()
87
106
  }
88
- // If we got here waiting for a response timed out
89
- this.logger?.error('Timeout waiting for query response')
90
- // Resolve with error to match what a local module would do if it were to error
91
- // TODO: BW Builder/Sign result as this module?
92
- const error: ModuleError = {
93
- message: 'Timeout waiting for query response',
94
- query: 'network.xyo.boundwitness',
95
- schema: 'network.xyo.error.module',
96
- sources: [routedQueryHash],
97
- }
98
- resolve([routedQuery, [], [await PayloadBuilder.build(error)]])
99
- return
100
107
  }
101
108
  forget(pollForResponse())
102
109
  })
103
110
  return context
104
111
  }
105
112
 
106
- start() {
107
- if (this.started) {
108
- console.warn('AsyncQueryBus starting when already started')
109
- }
110
- this.poll()
111
- }
112
-
113
- stop() {
114
- if (!this.started) {
115
- console.warn('AsyncQueryBus stopping when already stopped')
116
- }
117
- if (this._pollId) clearTimeoutEx(this._pollId)
118
- this._pollId = undefined
119
- }
120
-
121
113
  /**
122
114
  * Runs the background divine process on a loop with a delay
123
115
  * specified by the `config.pollFrequency`
@@ -162,4 +154,20 @@ export class AsyncQueryBusClient<TParams extends AsyncQueryBusParams = AsyncQuer
162
154
  }),
163
155
  )
164
156
  }
157
+
158
+ private start() {
159
+ if (this._pollCount === 0) {
160
+ this.poll()
161
+ }
162
+ this._pollCount++
163
+ }
164
+
165
+ private stop() {
166
+ this._pollCount--
167
+ if (this._pollCount <= 0) {
168
+ if (this._pollId) clearTimeoutEx(this._pollId)
169
+ this._pollId = undefined
170
+ this._pollCount = 0
171
+ }
172
+ }
165
173
  }
@@ -6,30 +6,35 @@ import { isQueryBoundWitnessWithMeta, QueryBoundWitness } from '@xyo-network/bou
6
6
  import { BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'
7
7
  import { asModuleInstance, ModuleInstance } from '@xyo-network/module-model'
8
8
  import { PayloadBuilder } from '@xyo-network/payload-builder'
9
+ import { WithMeta } from '@xyo-network/payload-model'
9
10
 
10
11
  import { AsyncQueryBusBase } from './AsyncQueryBusBase'
11
- import { AsyncQueryBusParams } from './Params'
12
+ import { AsyncQueryBusHostParams } from './Params'
12
13
 
13
- export class AsyncQueryBusServer<TParams extends AsyncQueryBusParams = AsyncQueryBusParams> extends AsyncQueryBusBase<TParams> {
14
+ export class AsyncQueryBusHost<TParams extends AsyncQueryBusHostParams = AsyncQueryBusHostParams> extends AsyncQueryBusBase<TParams> {
14
15
  private _pollId?: string
15
16
 
16
17
  constructor(params: TParams) {
17
18
  super(params)
18
19
  }
19
20
 
21
+ get perAddressBatchQueryLimit(): number {
22
+ return this.config?.perAddressBatchQueryLimit ?? 10
23
+ }
24
+
20
25
  get started() {
21
26
  return !!this._pollId
22
27
  }
23
28
 
24
- async listeningModules() {
29
+ async listeningModules(): Promise<ModuleInstance[]> {
25
30
  const mods =
26
- this.config.listeningModules ?
31
+ this.config?.listeningModules ?
27
32
  await Promise.all(
28
33
  this.config.listeningModules.map(async (listeningModule) =>
29
34
  assertEx(asModuleInstance(await this.resolver.resolve(listeningModule)), () => `Unable to resolve listeningModule [${listeningModule}]`),
30
35
  ),
31
36
  )
32
- : await this.resolver.resolve({ direction: 'all' })
37
+ : await this.resolver.resolve(undefined, { direction: 'down' })
33
38
  return mods
34
39
  }
35
40
 
@@ -48,46 +53,47 @@ export class AsyncQueryBusServer<TParams extends AsyncQueryBusParams = AsyncQuer
48
53
  this._pollId = undefined
49
54
  }
50
55
 
51
- protected callLocalModule = async (localModule: ModuleInstance, command: QueryBoundWitness) => {
56
+ protected callLocalModule = async (localModule: ModuleInstance, query: WithMeta<QueryBoundWitness>) => {
57
+ //console.log(`callLocalModule: ${query.$hash}`)
52
58
  const localModuleName = localModule.config.name ?? localModule.address
53
59
  const queryArchivist = await this.queriesArchivist()
54
60
  const responseArchivist = await this.responsesArchivist()
55
- const commandDestination = (command.$meta as { destination?: string[] })?.destination
61
+ const commandDestination = (query.$meta as { destination?: string[] })?.destination
56
62
  if (commandDestination && commandDestination?.includes(localModule.address)) {
57
63
  // Find the query
58
- const queryIndex = command.payload_hashes.indexOf(command.query)
64
+ const queryIndex = query.payload_hashes.indexOf(query.query)
59
65
  if (queryIndex !== -1) {
60
- const querySchema = command.payload_schemas[queryIndex]
66
+ const querySchema = query.payload_schemas[queryIndex]
61
67
  // If the destination can process this type of query
62
68
  if (localModule.queries.includes(querySchema)) {
63
69
  // Get the associated payloads
64
- const commandPayloads = await queryArchivist.get(command.payload_hashes)
70
+ const commandPayloads = await queryArchivist.get(query.payload_hashes)
65
71
  const commandPayloadsDict = await PayloadBuilder.toAllHashMap(commandPayloads)
66
- const commandHash = (await PayloadBuilder.build(command)).$hash
72
+ const commandHash = (await PayloadBuilder.build(query)).$hash
67
73
  // Check that we have all the arguments for the command
68
- if (!containsAll(Object.keys(commandPayloadsDict), command.payload_hashes)) {
74
+ if (!containsAll(Object.keys(commandPayloadsDict), query.payload_hashes)) {
69
75
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}, missing payloads`)
70
76
  return
71
77
  }
72
78
  try {
73
79
  // Issue the query against module
74
- const commandSchema = commandPayloadsDict[command.query].schema
80
+ const commandSchema = commandPayloadsDict[query.query].schema
75
81
  this.logger?.debug(`Issuing command ${commandSchema} (${commandHash}) addressed to module: ${localModuleName}`)
76
- const response = await localModule.query(command, commandPayloads)
82
+ const response = await localModule.query(query, commandPayloads)
77
83
  const [bw, payloads, errors] = response
78
84
  this.logger?.debug(`Replying to command ${commandHash} addressed to module: ${localModuleName}`)
79
85
  const insertResult = await responseArchivist.insert([bw, ...payloads, ...errors])
80
86
  // NOTE: If all archivists support the contract that numPayloads inserted === numPayloads returned we can
81
87
  // do some deeper assertions here like lenIn === lenOut, but for now this should be good enough since BWs
82
88
  // should always be unique causing at least one insertion
83
- if (insertResult.length > 0) {
89
+ if (insertResult.length === 0) {
84
90
  this.logger?.error(`Error replying to command ${commandHash} addressed to module: ${localModuleName}`)
85
91
  }
86
- if (command?.timestamp) {
92
+ if (query?.timestamp) {
87
93
  // TODO: This needs to be thought through as we can't use a distributed timestamp
88
94
  // because of collisions. We need to ensure we are using the timestamp of the store
89
95
  // so there's no chance of multiple commands at the same time
90
- await this.commitState(localModule.address, command.timestamp)
96
+ await this.commitState(localModule.address, query.timestamp)
91
97
  }
92
98
  } catch (error) {
93
99
  this.logger?.error(`Error processing command ${commandHash} for module ${localModuleName}: ${error}`)
@@ -101,22 +107,22 @@ export class AsyncQueryBusServer<TParams extends AsyncQueryBusParams = AsyncQuer
101
107
  * Finds unprocessed commands addressed to the supplied address
102
108
  * @param address The address to find commands for
103
109
  */
104
- protected findCommandsToAddress = async (address: Address) => {
110
+ protected findQueriesToAddress = async (address: Address) => {
105
111
  const queryBoundWitnessDiviner = await this.queriesDiviner()
106
112
  // Retrieve last offset from state store
107
113
  const timestamp = await this.retrieveState(address)
108
114
  const destination = [address]
109
- const limit = this.individualAddressBatchQueryLimitConfig
115
+ const limit = this.perAddressBatchQueryLimit
110
116
  // Filter for commands to us by destination address
111
117
  const divinerQuery = { destination, limit, schema: BoundWitnessDivinerQuerySchema, sort: 'asc', timestamp }
112
118
  const result = await queryBoundWitnessDiviner.divine([divinerQuery])
113
- const commands = result.filter(isQueryBoundWitnessWithMeta)
114
- const nextState = Math.max(...commands.map((c) => c.timestamp ?? 0))
119
+ const queries = result.filter(isQueryBoundWitnessWithMeta)
120
+ const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp
115
121
  // TODO: This needs to be thought through as we can't use a distributed timestamp
116
122
  // because of collisions. We need to use the timestamp of the store so there's no
117
123
  // chance of multiple commands at the same time
118
124
  await this.commitState(address, nextState)
119
- return commands
125
+ return queries
120
126
  }
121
127
 
122
128
  /**
@@ -151,11 +157,11 @@ export class AsyncQueryBusServer<TParams extends AsyncQueryBusParams = AsyncQuer
151
157
  try {
152
158
  const localModuleName = localModule.config.name ?? localModule.address
153
159
  this.logger?.debug(`Checking for inbound commands to ${localModuleName}`)
154
- const commands = await this.findCommandsToAddress(localModule.address)
155
- if (commands.length === 0) return
160
+ const queries = await this.findQueriesToAddress(localModule.address)
161
+ if (queries.length === 0) return
156
162
  this.logger?.debug(`Found commands addressed to local module: ${localModuleName}`)
157
- for (const command of commands) {
158
- await this.callLocalModule(localModule, command)
163
+ for (const query of queries) {
164
+ await this.callLocalModule(localModule, query)
159
165
  }
160
166
  } catch (error) {
161
167
  this.logger?.error(`Error processing commands for address ${localModule.address}: ${error}`)
@@ -1,4 +1,5 @@
1
1
  import { CacheConfig } from '@xyo-network/bridge-model'
2
+ import { ModuleIdentifier } from '@xyo-network/module-model'
2
3
 
3
4
  export const Pending = 'pending' as const
4
5
  export type Pending = typeof Pending
@@ -6,67 +7,56 @@ export type Pending = typeof Pending
6
7
  /**
7
8
  * Configuration for searchable storage of local state
8
9
  */
9
- export interface SearchableStorage<TArchivist = string, TDiviner = string> {
10
+ export interface SearchableStorage {
10
11
  /**
11
12
  * Name/Address of the archivist where intermediate communications are stored
12
13
  */
13
- archivist: TArchivist
14
+ archivist: ModuleIdentifier
14
15
  /**
15
16
  * Name/Address of the diviner where intermediate communications are filtered
16
17
  */
17
- boundWitnessDiviner: TDiviner
18
+ boundWitnessDiviner: ModuleIdentifier
18
19
  }
19
20
 
20
- /**
21
- * Configuration for the mutually accessible
22
- * modules between the modules being connected
23
- */
24
- export interface Intermediary<TArchivist = string, TDiviner = string> {
21
+ export interface AsyncQueryBusClearingHouseConfig {
25
22
  /**
26
- * Name/Address of the archivist where intermediate communications are stored
27
- */
28
- archivist: TArchivist
29
- /**
30
- * Name/Address of the diviner where intermediate communications are filtered
23
+ * Configuration for intermediary query storage
31
24
  */
32
- boundWitnessDiviner: TDiviner
33
- }
25
+ queries?: SearchableStorage
34
26
 
35
- export interface AsyncQueryBusConfig<TArchivist = string, TDiviner = string> {
36
27
  /**
37
- * How many queries to process at once when retrieving queries
38
- * for an address
28
+ * Configuration for intermediary response storage
39
29
  */
40
- individualAddressBatchQueryLimit?: number
30
+ responses?: SearchableStorage
31
+ }
41
32
 
42
- listeningModules?: string[]
33
+ export interface AsyncQueryBusBaseConfig {
34
+ clearingHouse?: AsyncQueryBusClearingHouseConfig
43
35
 
44
36
  /**
45
37
  * How often to poll for new queries/responses
46
38
  */
47
39
  pollFrequency?: number
48
- /**
49
- * Configuration for intermediary query storage
50
- */
51
- queries?: Intermediary<TArchivist, TDiviner>
52
40
 
53
41
  /**
54
- * Configuration for intermediary response storage
42
+ * Where the archivist should persist its internal state
55
43
  */
56
- queryCache?: CacheConfig | true
44
+ stateStore?: SearchableStorage
45
+ }
57
46
 
47
+ export interface AsyncQueryBusClientConfig extends AsyncQueryBusBaseConfig {
58
48
  /**
59
49
  * Configuration for intermediary response storage
60
50
  */
61
- responses?: Intermediary<TArchivist, TDiviner>
51
+ queryCache?: CacheConfig | true
52
+ }
62
53
 
63
- /**
64
- * The root address to connect the bridge to
65
- */
66
- rootAddress?: string
54
+ export interface AsyncQueryBusHostConfig extends AsyncQueryBusBaseConfig {
55
+ listeningModules?: string[]
67
56
 
68
57
  /**
69
- * Where the archivist should persist its internal state
58
+ * How many queries to process at once when retrieving queries
59
+ * for an address
70
60
  */
71
- stateStore?: SearchableStorage<TArchivist, TDiviner>
61
+ perAddressBatchQueryLimit?: number
72
62
  }
@@ -0,0 +1,29 @@
1
+ import { AbstractModuleHost, ModuleHostParams } from '../../AbstractModuleHost'
2
+ import { AsyncQueryBusHost } from '../AsyncQueryBusHost'
3
+ import { AsyncQueryBusHostConfig } from '../Config'
4
+
5
+ export type AsyncQueryBusModuleHostParams = ModuleHostParams & {
6
+ config: AsyncQueryBusHostConfig
7
+ }
8
+
9
+ export class AsyncQueryBusModuleHost extends AbstractModuleHost<AsyncQueryBusModuleHostParams> {
10
+ private _busHost?: AsyncQueryBusHost
11
+
12
+ constructor(params: AsyncQueryBusModuleHostParams) {
13
+ super(params)
14
+ }
15
+
16
+ override async start(): Promise<void> {
17
+ const listeningModules =
18
+ this.params.config.listeningModules ?? (await this.params.module.resolve(undefined, { direction: 'down' })).map((m) => m.address)
19
+ this._busHost = new AsyncQueryBusHost({
20
+ config: { ...this.params.config, listeningModules },
21
+ logger: this.params.logger,
22
+ resolver: this.params.module,
23
+ })
24
+ this._busHost?.start()
25
+ }
26
+ override stop() {
27
+ this._busHost?.stop()
28
+ }
29
+ }
@@ -0,0 +1 @@
1
+ export * from './ModuleHost'
@@ -0,0 +1,19 @@
1
+ import { QueryBoundWitness } from '@xyo-network/boundwitness-model'
2
+ import { Module, ModuleInstance, ModuleQueryResult } from '@xyo-network/module-model'
3
+ import { Payload } from '@xyo-network/payload-model'
4
+
5
+ import { AbstractModuleProxy, ModuleProxyParams } from '../../AbstractModuleProxy'
6
+ import { AsyncQueryBusClient } from '../AsyncQueryBusClient'
7
+
8
+ export type AsyncQueryBusModuleProxyParams = ModuleProxyParams & {
9
+ bridgeClient: AsyncQueryBusClient
10
+ }
11
+
12
+ export class AsyncQueryBusModuleProxy<TWrappedModule extends Module = Module>
13
+ extends AbstractModuleProxy<AsyncQueryBusModuleProxyParams, TWrappedModule>
14
+ implements ModuleInstance<TWrappedModule['params'], TWrappedModule['eventData']>
15
+ {
16
+ async query<T extends QueryBoundWitness = QueryBoundWitness>(query: T, payloads?: Payload[]): Promise<ModuleQueryResult> {
17
+ return await this.proxyParams.bridgeClient.send(this.address, query, payloads)
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ export * from './ModuleProxy'
@@ -1,9 +1,12 @@
1
1
  import { BaseParams } from '@xylabs/object'
2
2
  import { ModuleResolver } from '@xyo-network/module-model'
3
3
 
4
- import { AsyncQueryBusConfig } from './Config'
4
+ import { AsyncQueryBusBaseConfig, AsyncQueryBusClientConfig, AsyncQueryBusHostConfig } from './Config'
5
5
 
6
- export type AsyncQueryBusParams = BaseParams<{
7
- config: AsyncQueryBusConfig
6
+ export type AsyncQueryBusParams<TConfig extends AsyncQueryBusBaseConfig = AsyncQueryBusBaseConfig> = BaseParams<{
7
+ config?: TConfig
8
8
  resolver: ModuleResolver
9
9
  }>
10
+
11
+ export type AsyncQueryBusClientParams = AsyncQueryBusParams<AsyncQueryBusClientConfig>
12
+ export type AsyncQueryBusHostParams = AsyncQueryBusParams<AsyncQueryBusHostConfig>
@@ -1,4 +1,6 @@
1
1
  export * from './AsyncQueryBusClient'
2
- export * from './AsyncQueryBusServer'
2
+ export * from './AsyncQueryBusHost'
3
3
  export * from './Config'
4
+ export * from './ModuleHost'
5
+ export * from './ModuleProxy'
4
6
  export * from './Params'
package/src/Config.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EmptyObject } from '@xylabs/object'
2
2
  import { BridgeConfig } from '@xyo-network/bridge-model'
3
3
 
4
- import { AsyncQueryBusConfig } from './AsyncQueryBus'
4
+ import { AsyncQueryBusClientConfig, AsyncQueryBusHostConfig } from './AsyncQueryBus'
5
5
  import { PubSubBridgeSchema } from './Schema'
6
6
 
7
7
  export const PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`
@@ -11,6 +11,9 @@ export type PubSubBridgeConfigSchema = typeof PubSubBridgeConfigSchema
11
11
  * Configuration for the PubSubBridge
12
12
  */
13
13
  export type PubSubBridgeConfig<TConfig extends EmptyObject = EmptyObject, TSchema extends string | void = void> = BridgeConfig<
14
- AsyncQueryBusConfig & TConfig,
14
+ {
15
+ client?: AsyncQueryBusClientConfig
16
+ host?: AsyncQueryBusHostConfig
17
+ } & TConfig,
15
18
  TSchema extends string ? TSchema : PubSubBridgeConfigSchema
16
19
  >