@xyo-network/bridge-pub-sub 2.111.3 → 3.0.0

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 (426) hide show
  1. package/dist/neutral/index.d.ts +401 -8
  2. package/package.json +25 -44
  3. package/xy.config.ts +12 -0
  4. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.cts +0 -11
  5. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.cts.map +0 -1
  6. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.mts +0 -11
  7. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.mts.map +0 -1
  8. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.ts +0 -11
  9. package/dist/browser/AbstractModuleHost/AbstractModuleHost.d.ts.map +0 -1
  10. package/dist/browser/AbstractModuleHost/index.d.cts +0 -2
  11. package/dist/browser/AbstractModuleHost/index.d.cts.map +0 -1
  12. package/dist/browser/AbstractModuleHost/index.d.mts +0 -2
  13. package/dist/browser/AbstractModuleHost/index.d.mts.map +0 -1
  14. package/dist/browser/AbstractModuleHost/index.d.ts +0 -2
  15. package/dist/browser/AbstractModuleHost/index.d.ts.map +0 -1
  16. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts +0 -137
  17. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +0 -1
  18. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +0 -137
  19. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +0 -1
  20. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +0 -137
  21. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +0 -1
  22. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts +0 -23
  23. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +0 -1
  24. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts +0 -23
  25. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +0 -1
  26. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts +0 -23
  27. package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +0 -1
  28. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts +0 -64
  29. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +0 -1
  30. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts +0 -64
  31. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +0 -1
  32. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts +0 -64
  33. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +0 -1
  34. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.cts +0 -12
  35. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.cts.map +0 -1
  36. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.mts +0 -12
  37. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.mts.map +0 -1
  38. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.ts +0 -12
  39. package/dist/browser/AsyncQueryBus/ModuleHost/ModuleHost.d.ts.map +0 -1
  40. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.cts +0 -2
  41. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.cts.map +0 -1
  42. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.mts +0 -2
  43. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.mts.map +0 -1
  44. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.ts +0 -2
  45. package/dist/browser/AsyncQueryBus/ModuleHost/index.d.ts.map +0 -1
  46. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts +0 -27
  47. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +0 -1
  48. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts +0 -27
  49. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +0 -1
  50. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts +0 -27
  51. package/dist/browser/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +0 -1
  52. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.cts +0 -2
  53. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.cts.map +0 -1
  54. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.mts +0 -2
  55. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.mts.map +0 -1
  56. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.ts +0 -2
  57. package/dist/browser/AsyncQueryBus/ModuleProxy/index.d.ts.map +0 -1
  58. package/dist/browser/AsyncQueryBus/index.d.cts +0 -6
  59. package/dist/browser/AsyncQueryBus/index.d.cts.map +0 -1
  60. package/dist/browser/AsyncQueryBus/index.d.mts +0 -6
  61. package/dist/browser/AsyncQueryBus/index.d.mts.map +0 -1
  62. package/dist/browser/AsyncQueryBus/index.d.ts +0 -6
  63. package/dist/browser/AsyncQueryBus/index.d.ts.map +0 -1
  64. package/dist/browser/AsyncQueryBus/model/BaseConfig.d.cts +0 -8
  65. package/dist/browser/AsyncQueryBus/model/BaseConfig.d.cts.map +0 -1
  66. package/dist/browser/AsyncQueryBus/model/BaseConfig.d.mts +0 -8
  67. package/dist/browser/AsyncQueryBus/model/BaseConfig.d.mts.map +0 -1
  68. package/dist/browser/AsyncQueryBus/model/BaseConfig.d.ts +0 -8
  69. package/dist/browser/AsyncQueryBus/model/BaseConfig.d.ts.map +0 -1
  70. package/dist/browser/AsyncQueryBus/model/ClientConfig.d.cts +0 -7
  71. package/dist/browser/AsyncQueryBus/model/ClientConfig.d.cts.map +0 -1
  72. package/dist/browser/AsyncQueryBus/model/ClientConfig.d.mts +0 -7
  73. package/dist/browser/AsyncQueryBus/model/ClientConfig.d.mts.map +0 -1
  74. package/dist/browser/AsyncQueryBus/model/ClientConfig.d.ts +0 -7
  75. package/dist/browser/AsyncQueryBus/model/ClientConfig.d.ts.map +0 -1
  76. package/dist/browser/AsyncQueryBus/model/HostConfig.d.cts +0 -9
  77. package/dist/browser/AsyncQueryBus/model/HostConfig.d.cts.map +0 -1
  78. package/dist/browser/AsyncQueryBus/model/HostConfig.d.mts +0 -9
  79. package/dist/browser/AsyncQueryBus/model/HostConfig.d.mts.map +0 -1
  80. package/dist/browser/AsyncQueryBus/model/HostConfig.d.ts +0 -9
  81. package/dist/browser/AsyncQueryBus/model/HostConfig.d.ts.map +0 -1
  82. package/dist/browser/AsyncQueryBus/model/IntersectConfig.d.cts +0 -6
  83. package/dist/browser/AsyncQueryBus/model/IntersectConfig.d.cts.map +0 -1
  84. package/dist/browser/AsyncQueryBus/model/IntersectConfig.d.mts +0 -6
  85. package/dist/browser/AsyncQueryBus/model/IntersectConfig.d.mts.map +0 -1
  86. package/dist/browser/AsyncQueryBus/model/IntersectConfig.d.ts +0 -6
  87. package/dist/browser/AsyncQueryBus/model/IntersectConfig.d.ts.map +0 -1
  88. package/dist/browser/AsyncQueryBus/model/Params.d.cts +0 -16
  89. package/dist/browser/AsyncQueryBus/model/Params.d.cts.map +0 -1
  90. package/dist/browser/AsyncQueryBus/model/Params.d.mts +0 -16
  91. package/dist/browser/AsyncQueryBus/model/Params.d.mts.map +0 -1
  92. package/dist/browser/AsyncQueryBus/model/Params.d.ts +0 -16
  93. package/dist/browser/AsyncQueryBus/model/Params.d.ts.map +0 -1
  94. package/dist/browser/AsyncQueryBus/model/QueryStatus.d.cts +0 -3
  95. package/dist/browser/AsyncQueryBus/model/QueryStatus.d.cts.map +0 -1
  96. package/dist/browser/AsyncQueryBus/model/QueryStatus.d.mts +0 -3
  97. package/dist/browser/AsyncQueryBus/model/QueryStatus.d.mts.map +0 -1
  98. package/dist/browser/AsyncQueryBus/model/QueryStatus.d.ts +0 -3
  99. package/dist/browser/AsyncQueryBus/model/QueryStatus.d.ts.map +0 -1
  100. package/dist/browser/AsyncQueryBus/model/index.d.cts +0 -7
  101. package/dist/browser/AsyncQueryBus/model/index.d.cts.map +0 -1
  102. package/dist/browser/AsyncQueryBus/model/index.d.mts +0 -7
  103. package/dist/browser/AsyncQueryBus/model/index.d.mts.map +0 -1
  104. package/dist/browser/AsyncQueryBus/model/index.d.ts +0 -7
  105. package/dist/browser/AsyncQueryBus/model/index.d.ts.map +0 -1
  106. package/dist/browser/Config.d.cts +0 -12
  107. package/dist/browser/Config.d.cts.map +0 -1
  108. package/dist/browser/Config.d.mts +0 -12
  109. package/dist/browser/Config.d.mts.map +0 -1
  110. package/dist/browser/Config.d.ts +0 -12
  111. package/dist/browser/Config.d.ts.map +0 -1
  112. package/dist/browser/Params.d.cts +0 -5
  113. package/dist/browser/Params.d.cts.map +0 -1
  114. package/dist/browser/Params.d.mts +0 -5
  115. package/dist/browser/Params.d.mts.map +0 -1
  116. package/dist/browser/Params.d.ts +0 -5
  117. package/dist/browser/Params.d.ts.map +0 -1
  118. package/dist/browser/PubSubBridge.d.cts +0 -42
  119. package/dist/browser/PubSubBridge.d.cts.map +0 -1
  120. package/dist/browser/PubSubBridge.d.mts +0 -42
  121. package/dist/browser/PubSubBridge.d.mts.map +0 -1
  122. package/dist/browser/PubSubBridge.d.ts +0 -42
  123. package/dist/browser/PubSubBridge.d.ts.map +0 -1
  124. package/dist/browser/PubSubBridgeModuleResolver.d.cts +0 -26
  125. package/dist/browser/PubSubBridgeModuleResolver.d.cts.map +0 -1
  126. package/dist/browser/PubSubBridgeModuleResolver.d.mts +0 -26
  127. package/dist/browser/PubSubBridgeModuleResolver.d.mts.map +0 -1
  128. package/dist/browser/PubSubBridgeModuleResolver.d.ts +0 -26
  129. package/dist/browser/PubSubBridgeModuleResolver.d.ts.map +0 -1
  130. package/dist/browser/Schema.d.cts +0 -3
  131. package/dist/browser/Schema.d.cts.map +0 -1
  132. package/dist/browser/Schema.d.mts +0 -3
  133. package/dist/browser/Schema.d.mts.map +0 -1
  134. package/dist/browser/Schema.d.ts +0 -3
  135. package/dist/browser/Schema.d.ts.map +0 -1
  136. package/dist/browser/index.cjs +0 -1047
  137. package/dist/browser/index.cjs.map +0 -1
  138. package/dist/browser/index.d.cts +0 -8
  139. package/dist/browser/index.d.cts.map +0 -1
  140. package/dist/browser/index.d.mts +0 -8
  141. package/dist/browser/index.d.mts.map +0 -1
  142. package/dist/browser/index.d.ts +0 -8
  143. package/dist/browser/index.d.ts.map +0 -1
  144. package/dist/browser/index.mjs +0 -1026
  145. package/dist/browser/index.mjs.map +0 -1
  146. package/dist/neutral/AbstractModuleHost/AbstractModuleHost.d.cts +0 -11
  147. package/dist/neutral/AbstractModuleHost/AbstractModuleHost.d.cts.map +0 -1
  148. package/dist/neutral/AbstractModuleHost/AbstractModuleHost.d.mts +0 -11
  149. package/dist/neutral/AbstractModuleHost/AbstractModuleHost.d.mts.map +0 -1
  150. package/dist/neutral/AbstractModuleHost/AbstractModuleHost.d.ts +0 -11
  151. package/dist/neutral/AbstractModuleHost/AbstractModuleHost.d.ts.map +0 -1
  152. package/dist/neutral/AbstractModuleHost/index.d.cts +0 -2
  153. package/dist/neutral/AbstractModuleHost/index.d.cts.map +0 -1
  154. package/dist/neutral/AbstractModuleHost/index.d.mts +0 -2
  155. package/dist/neutral/AbstractModuleHost/index.d.mts.map +0 -1
  156. package/dist/neutral/AbstractModuleHost/index.d.ts +0 -2
  157. package/dist/neutral/AbstractModuleHost/index.d.ts.map +0 -1
  158. package/dist/neutral/AsyncQueryBus/AsyncQueryBusBase.d.cts +0 -137
  159. package/dist/neutral/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +0 -1
  160. package/dist/neutral/AsyncQueryBus/AsyncQueryBusBase.d.mts +0 -137
  161. package/dist/neutral/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +0 -1
  162. package/dist/neutral/AsyncQueryBus/AsyncQueryBusBase.d.ts +0 -137
  163. package/dist/neutral/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +0 -1
  164. package/dist/neutral/AsyncQueryBus/AsyncQueryBusClient.d.cts +0 -23
  165. package/dist/neutral/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +0 -1
  166. package/dist/neutral/AsyncQueryBus/AsyncQueryBusClient.d.mts +0 -23
  167. package/dist/neutral/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +0 -1
  168. package/dist/neutral/AsyncQueryBus/AsyncQueryBusClient.d.ts +0 -23
  169. package/dist/neutral/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +0 -1
  170. package/dist/neutral/AsyncQueryBus/AsyncQueryBusHost.d.cts +0 -64
  171. package/dist/neutral/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +0 -1
  172. package/dist/neutral/AsyncQueryBus/AsyncQueryBusHost.d.mts +0 -64
  173. package/dist/neutral/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +0 -1
  174. package/dist/neutral/AsyncQueryBus/AsyncQueryBusHost.d.ts +0 -64
  175. package/dist/neutral/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +0 -1
  176. package/dist/neutral/AsyncQueryBus/ModuleHost/ModuleHost.d.cts +0 -12
  177. package/dist/neutral/AsyncQueryBus/ModuleHost/ModuleHost.d.cts.map +0 -1
  178. package/dist/neutral/AsyncQueryBus/ModuleHost/ModuleHost.d.mts +0 -12
  179. package/dist/neutral/AsyncQueryBus/ModuleHost/ModuleHost.d.mts.map +0 -1
  180. package/dist/neutral/AsyncQueryBus/ModuleHost/ModuleHost.d.ts +0 -12
  181. package/dist/neutral/AsyncQueryBus/ModuleHost/ModuleHost.d.ts.map +0 -1
  182. package/dist/neutral/AsyncQueryBus/ModuleHost/index.d.cts +0 -2
  183. package/dist/neutral/AsyncQueryBus/ModuleHost/index.d.cts.map +0 -1
  184. package/dist/neutral/AsyncQueryBus/ModuleHost/index.d.mts +0 -2
  185. package/dist/neutral/AsyncQueryBus/ModuleHost/index.d.mts.map +0 -1
  186. package/dist/neutral/AsyncQueryBus/ModuleHost/index.d.ts +0 -2
  187. package/dist/neutral/AsyncQueryBus/ModuleHost/index.d.ts.map +0 -1
  188. package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts +0 -27
  189. package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +0 -1
  190. package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts +0 -27
  191. package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +0 -1
  192. package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts +0 -27
  193. package/dist/neutral/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +0 -1
  194. package/dist/neutral/AsyncQueryBus/ModuleProxy/index.d.cts +0 -2
  195. package/dist/neutral/AsyncQueryBus/ModuleProxy/index.d.cts.map +0 -1
  196. package/dist/neutral/AsyncQueryBus/ModuleProxy/index.d.mts +0 -2
  197. package/dist/neutral/AsyncQueryBus/ModuleProxy/index.d.mts.map +0 -1
  198. package/dist/neutral/AsyncQueryBus/ModuleProxy/index.d.ts +0 -2
  199. package/dist/neutral/AsyncQueryBus/ModuleProxy/index.d.ts.map +0 -1
  200. package/dist/neutral/AsyncQueryBus/index.d.cts +0 -6
  201. package/dist/neutral/AsyncQueryBus/index.d.cts.map +0 -1
  202. package/dist/neutral/AsyncQueryBus/index.d.mts +0 -6
  203. package/dist/neutral/AsyncQueryBus/index.d.mts.map +0 -1
  204. package/dist/neutral/AsyncQueryBus/index.d.ts +0 -6
  205. package/dist/neutral/AsyncQueryBus/index.d.ts.map +0 -1
  206. package/dist/neutral/AsyncQueryBus/model/BaseConfig.d.cts +0 -8
  207. package/dist/neutral/AsyncQueryBus/model/BaseConfig.d.cts.map +0 -1
  208. package/dist/neutral/AsyncQueryBus/model/BaseConfig.d.mts +0 -8
  209. package/dist/neutral/AsyncQueryBus/model/BaseConfig.d.mts.map +0 -1
  210. package/dist/neutral/AsyncQueryBus/model/BaseConfig.d.ts +0 -8
  211. package/dist/neutral/AsyncQueryBus/model/BaseConfig.d.ts.map +0 -1
  212. package/dist/neutral/AsyncQueryBus/model/ClientConfig.d.cts +0 -7
  213. package/dist/neutral/AsyncQueryBus/model/ClientConfig.d.cts.map +0 -1
  214. package/dist/neutral/AsyncQueryBus/model/ClientConfig.d.mts +0 -7
  215. package/dist/neutral/AsyncQueryBus/model/ClientConfig.d.mts.map +0 -1
  216. package/dist/neutral/AsyncQueryBus/model/ClientConfig.d.ts +0 -7
  217. package/dist/neutral/AsyncQueryBus/model/ClientConfig.d.ts.map +0 -1
  218. package/dist/neutral/AsyncQueryBus/model/HostConfig.d.cts +0 -9
  219. package/dist/neutral/AsyncQueryBus/model/HostConfig.d.cts.map +0 -1
  220. package/dist/neutral/AsyncQueryBus/model/HostConfig.d.mts +0 -9
  221. package/dist/neutral/AsyncQueryBus/model/HostConfig.d.mts.map +0 -1
  222. package/dist/neutral/AsyncQueryBus/model/HostConfig.d.ts +0 -9
  223. package/dist/neutral/AsyncQueryBus/model/HostConfig.d.ts.map +0 -1
  224. package/dist/neutral/AsyncQueryBus/model/IntersectConfig.d.cts +0 -6
  225. package/dist/neutral/AsyncQueryBus/model/IntersectConfig.d.cts.map +0 -1
  226. package/dist/neutral/AsyncQueryBus/model/IntersectConfig.d.mts +0 -6
  227. package/dist/neutral/AsyncQueryBus/model/IntersectConfig.d.mts.map +0 -1
  228. package/dist/neutral/AsyncQueryBus/model/IntersectConfig.d.ts +0 -6
  229. package/dist/neutral/AsyncQueryBus/model/IntersectConfig.d.ts.map +0 -1
  230. package/dist/neutral/AsyncQueryBus/model/Params.d.cts +0 -16
  231. package/dist/neutral/AsyncQueryBus/model/Params.d.cts.map +0 -1
  232. package/dist/neutral/AsyncQueryBus/model/Params.d.mts +0 -16
  233. package/dist/neutral/AsyncQueryBus/model/Params.d.mts.map +0 -1
  234. package/dist/neutral/AsyncQueryBus/model/Params.d.ts +0 -16
  235. package/dist/neutral/AsyncQueryBus/model/Params.d.ts.map +0 -1
  236. package/dist/neutral/AsyncQueryBus/model/QueryStatus.d.cts +0 -3
  237. package/dist/neutral/AsyncQueryBus/model/QueryStatus.d.cts.map +0 -1
  238. package/dist/neutral/AsyncQueryBus/model/QueryStatus.d.mts +0 -3
  239. package/dist/neutral/AsyncQueryBus/model/QueryStatus.d.mts.map +0 -1
  240. package/dist/neutral/AsyncQueryBus/model/QueryStatus.d.ts +0 -3
  241. package/dist/neutral/AsyncQueryBus/model/QueryStatus.d.ts.map +0 -1
  242. package/dist/neutral/AsyncQueryBus/model/index.d.cts +0 -7
  243. package/dist/neutral/AsyncQueryBus/model/index.d.cts.map +0 -1
  244. package/dist/neutral/AsyncQueryBus/model/index.d.mts +0 -7
  245. package/dist/neutral/AsyncQueryBus/model/index.d.mts.map +0 -1
  246. package/dist/neutral/AsyncQueryBus/model/index.d.ts +0 -7
  247. package/dist/neutral/AsyncQueryBus/model/index.d.ts.map +0 -1
  248. package/dist/neutral/Config.d.cts +0 -12
  249. package/dist/neutral/Config.d.cts.map +0 -1
  250. package/dist/neutral/Config.d.mts +0 -12
  251. package/dist/neutral/Config.d.mts.map +0 -1
  252. package/dist/neutral/Config.d.ts +0 -12
  253. package/dist/neutral/Config.d.ts.map +0 -1
  254. package/dist/neutral/Params.d.cts +0 -5
  255. package/dist/neutral/Params.d.cts.map +0 -1
  256. package/dist/neutral/Params.d.mts +0 -5
  257. package/dist/neutral/Params.d.mts.map +0 -1
  258. package/dist/neutral/Params.d.ts +0 -5
  259. package/dist/neutral/Params.d.ts.map +0 -1
  260. package/dist/neutral/PubSubBridge.d.cts +0 -42
  261. package/dist/neutral/PubSubBridge.d.cts.map +0 -1
  262. package/dist/neutral/PubSubBridge.d.mts +0 -42
  263. package/dist/neutral/PubSubBridge.d.mts.map +0 -1
  264. package/dist/neutral/PubSubBridge.d.ts +0 -42
  265. package/dist/neutral/PubSubBridge.d.ts.map +0 -1
  266. package/dist/neutral/PubSubBridgeModuleResolver.d.cts +0 -26
  267. package/dist/neutral/PubSubBridgeModuleResolver.d.cts.map +0 -1
  268. package/dist/neutral/PubSubBridgeModuleResolver.d.mts +0 -26
  269. package/dist/neutral/PubSubBridgeModuleResolver.d.mts.map +0 -1
  270. package/dist/neutral/PubSubBridgeModuleResolver.d.ts +0 -26
  271. package/dist/neutral/PubSubBridgeModuleResolver.d.ts.map +0 -1
  272. package/dist/neutral/Schema.d.cts +0 -3
  273. package/dist/neutral/Schema.d.cts.map +0 -1
  274. package/dist/neutral/Schema.d.mts +0 -3
  275. package/dist/neutral/Schema.d.mts.map +0 -1
  276. package/dist/neutral/Schema.d.ts +0 -3
  277. package/dist/neutral/Schema.d.ts.map +0 -1
  278. package/dist/neutral/index.cjs +0 -1047
  279. package/dist/neutral/index.cjs.map +0 -1
  280. package/dist/neutral/index.d.cts +0 -8
  281. package/dist/neutral/index.d.cts.map +0 -1
  282. package/dist/neutral/index.d.mts +0 -8
  283. package/dist/neutral/index.d.mts.map +0 -1
  284. package/dist/neutral/index.d.ts.map +0 -1
  285. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.cts +0 -11
  286. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.cts.map +0 -1
  287. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.mts +0 -11
  288. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.mts.map +0 -1
  289. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.ts +0 -11
  290. package/dist/node/AbstractModuleHost/AbstractModuleHost.d.ts.map +0 -1
  291. package/dist/node/AbstractModuleHost/index.d.cts +0 -2
  292. package/dist/node/AbstractModuleHost/index.d.cts.map +0 -1
  293. package/dist/node/AbstractModuleHost/index.d.mts +0 -2
  294. package/dist/node/AbstractModuleHost/index.d.mts.map +0 -1
  295. package/dist/node/AbstractModuleHost/index.d.ts +0 -2
  296. package/dist/node/AbstractModuleHost/index.d.ts.map +0 -1
  297. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +0 -137
  298. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +0 -1
  299. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +0 -137
  300. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +0 -1
  301. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +0 -137
  302. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +0 -1
  303. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts +0 -23
  304. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +0 -1
  305. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts +0 -23
  306. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +0 -1
  307. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts +0 -23
  308. package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +0 -1
  309. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts +0 -64
  310. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +0 -1
  311. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts +0 -64
  312. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +0 -1
  313. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts +0 -64
  314. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +0 -1
  315. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.cts +0 -12
  316. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.cts.map +0 -1
  317. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.mts +0 -12
  318. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.mts.map +0 -1
  319. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.ts +0 -12
  320. package/dist/node/AsyncQueryBus/ModuleHost/ModuleHost.d.ts.map +0 -1
  321. package/dist/node/AsyncQueryBus/ModuleHost/index.d.cts +0 -2
  322. package/dist/node/AsyncQueryBus/ModuleHost/index.d.cts.map +0 -1
  323. package/dist/node/AsyncQueryBus/ModuleHost/index.d.mts +0 -2
  324. package/dist/node/AsyncQueryBus/ModuleHost/index.d.mts.map +0 -1
  325. package/dist/node/AsyncQueryBus/ModuleHost/index.d.ts +0 -2
  326. package/dist/node/AsyncQueryBus/ModuleHost/index.d.ts.map +0 -1
  327. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts +0 -27
  328. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.cts.map +0 -1
  329. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts +0 -27
  330. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.mts.map +0 -1
  331. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts +0 -27
  332. package/dist/node/AsyncQueryBus/ModuleProxy/ModuleProxy.d.ts.map +0 -1
  333. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.cts +0 -2
  334. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.cts.map +0 -1
  335. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.mts +0 -2
  336. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.mts.map +0 -1
  337. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.ts +0 -2
  338. package/dist/node/AsyncQueryBus/ModuleProxy/index.d.ts.map +0 -1
  339. package/dist/node/AsyncQueryBus/index.d.cts +0 -6
  340. package/dist/node/AsyncQueryBus/index.d.cts.map +0 -1
  341. package/dist/node/AsyncQueryBus/index.d.mts +0 -6
  342. package/dist/node/AsyncQueryBus/index.d.mts.map +0 -1
  343. package/dist/node/AsyncQueryBus/index.d.ts +0 -6
  344. package/dist/node/AsyncQueryBus/index.d.ts.map +0 -1
  345. package/dist/node/AsyncQueryBus/model/BaseConfig.d.cts +0 -8
  346. package/dist/node/AsyncQueryBus/model/BaseConfig.d.cts.map +0 -1
  347. package/dist/node/AsyncQueryBus/model/BaseConfig.d.mts +0 -8
  348. package/dist/node/AsyncQueryBus/model/BaseConfig.d.mts.map +0 -1
  349. package/dist/node/AsyncQueryBus/model/BaseConfig.d.ts +0 -8
  350. package/dist/node/AsyncQueryBus/model/BaseConfig.d.ts.map +0 -1
  351. package/dist/node/AsyncQueryBus/model/ClientConfig.d.cts +0 -7
  352. package/dist/node/AsyncQueryBus/model/ClientConfig.d.cts.map +0 -1
  353. package/dist/node/AsyncQueryBus/model/ClientConfig.d.mts +0 -7
  354. package/dist/node/AsyncQueryBus/model/ClientConfig.d.mts.map +0 -1
  355. package/dist/node/AsyncQueryBus/model/ClientConfig.d.ts +0 -7
  356. package/dist/node/AsyncQueryBus/model/ClientConfig.d.ts.map +0 -1
  357. package/dist/node/AsyncQueryBus/model/HostConfig.d.cts +0 -9
  358. package/dist/node/AsyncQueryBus/model/HostConfig.d.cts.map +0 -1
  359. package/dist/node/AsyncQueryBus/model/HostConfig.d.mts +0 -9
  360. package/dist/node/AsyncQueryBus/model/HostConfig.d.mts.map +0 -1
  361. package/dist/node/AsyncQueryBus/model/HostConfig.d.ts +0 -9
  362. package/dist/node/AsyncQueryBus/model/HostConfig.d.ts.map +0 -1
  363. package/dist/node/AsyncQueryBus/model/IntersectConfig.d.cts +0 -6
  364. package/dist/node/AsyncQueryBus/model/IntersectConfig.d.cts.map +0 -1
  365. package/dist/node/AsyncQueryBus/model/IntersectConfig.d.mts +0 -6
  366. package/dist/node/AsyncQueryBus/model/IntersectConfig.d.mts.map +0 -1
  367. package/dist/node/AsyncQueryBus/model/IntersectConfig.d.ts +0 -6
  368. package/dist/node/AsyncQueryBus/model/IntersectConfig.d.ts.map +0 -1
  369. package/dist/node/AsyncQueryBus/model/Params.d.cts +0 -16
  370. package/dist/node/AsyncQueryBus/model/Params.d.cts.map +0 -1
  371. package/dist/node/AsyncQueryBus/model/Params.d.mts +0 -16
  372. package/dist/node/AsyncQueryBus/model/Params.d.mts.map +0 -1
  373. package/dist/node/AsyncQueryBus/model/Params.d.ts +0 -16
  374. package/dist/node/AsyncQueryBus/model/Params.d.ts.map +0 -1
  375. package/dist/node/AsyncQueryBus/model/QueryStatus.d.cts +0 -3
  376. package/dist/node/AsyncQueryBus/model/QueryStatus.d.cts.map +0 -1
  377. package/dist/node/AsyncQueryBus/model/QueryStatus.d.mts +0 -3
  378. package/dist/node/AsyncQueryBus/model/QueryStatus.d.mts.map +0 -1
  379. package/dist/node/AsyncQueryBus/model/QueryStatus.d.ts +0 -3
  380. package/dist/node/AsyncQueryBus/model/QueryStatus.d.ts.map +0 -1
  381. package/dist/node/AsyncQueryBus/model/index.d.cts +0 -7
  382. package/dist/node/AsyncQueryBus/model/index.d.cts.map +0 -1
  383. package/dist/node/AsyncQueryBus/model/index.d.mts +0 -7
  384. package/dist/node/AsyncQueryBus/model/index.d.mts.map +0 -1
  385. package/dist/node/AsyncQueryBus/model/index.d.ts +0 -7
  386. package/dist/node/AsyncQueryBus/model/index.d.ts.map +0 -1
  387. package/dist/node/Config.d.cts +0 -12
  388. package/dist/node/Config.d.cts.map +0 -1
  389. package/dist/node/Config.d.mts +0 -12
  390. package/dist/node/Config.d.mts.map +0 -1
  391. package/dist/node/Config.d.ts +0 -12
  392. package/dist/node/Config.d.ts.map +0 -1
  393. package/dist/node/Params.d.cts +0 -5
  394. package/dist/node/Params.d.cts.map +0 -1
  395. package/dist/node/Params.d.mts +0 -5
  396. package/dist/node/Params.d.mts.map +0 -1
  397. package/dist/node/Params.d.ts +0 -5
  398. package/dist/node/Params.d.ts.map +0 -1
  399. package/dist/node/PubSubBridge.d.cts +0 -42
  400. package/dist/node/PubSubBridge.d.cts.map +0 -1
  401. package/dist/node/PubSubBridge.d.mts +0 -42
  402. package/dist/node/PubSubBridge.d.mts.map +0 -1
  403. package/dist/node/PubSubBridge.d.ts +0 -42
  404. package/dist/node/PubSubBridge.d.ts.map +0 -1
  405. package/dist/node/PubSubBridgeModuleResolver.d.cts +0 -26
  406. package/dist/node/PubSubBridgeModuleResolver.d.cts.map +0 -1
  407. package/dist/node/PubSubBridgeModuleResolver.d.mts +0 -26
  408. package/dist/node/PubSubBridgeModuleResolver.d.mts.map +0 -1
  409. package/dist/node/PubSubBridgeModuleResolver.d.ts +0 -26
  410. package/dist/node/PubSubBridgeModuleResolver.d.ts.map +0 -1
  411. package/dist/node/Schema.d.cts +0 -3
  412. package/dist/node/Schema.d.cts.map +0 -1
  413. package/dist/node/Schema.d.mts +0 -3
  414. package/dist/node/Schema.d.mts.map +0 -1
  415. package/dist/node/Schema.d.ts +0 -3
  416. package/dist/node/Schema.d.ts.map +0 -1
  417. package/dist/node/index.cjs +0 -1103
  418. package/dist/node/index.cjs.map +0 -1
  419. package/dist/node/index.d.cts +0 -8
  420. package/dist/node/index.d.cts.map +0 -1
  421. package/dist/node/index.d.mts +0 -8
  422. package/dist/node/index.d.mts.map +0 -1
  423. package/dist/node/index.d.ts +0 -8
  424. package/dist/node/index.d.ts.map +0 -1
  425. package/dist/node/index.mjs +0 -1069
  426. package/dist/node/index.mjs.map +0 -1
@@ -1,1069 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getProtoOf = Object.getPrototypeOf;
3
- var __reflectGet = Reflect.get;
4
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
- var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
8
-
9
- // src/AbstractModuleHost/AbstractModuleHost.ts
10
- import { Base } from "@xylabs/object";
11
- var _AbstractModuleHost = class _AbstractModuleHost extends Base {
12
- };
13
- __name(_AbstractModuleHost, "AbstractModuleHost");
14
- var AbstractModuleHost = _AbstractModuleHost;
15
-
16
- // src/AsyncQueryBus/AsyncQueryBusClient.ts
17
- import { assertEx as assertEx2 } from "@xylabs/assert";
18
- import { delay } from "@xylabs/delay";
19
- import { forget } from "@xylabs/forget";
20
- import { clearTimeoutEx, setTimeoutEx } from "@xylabs/timer";
21
- import { isBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
22
- import { BoundWitnessDivinerQuerySchema } from "@xyo-network/diviner-boundwitness-model";
23
- import { PayloadBuilder } from "@xyo-network/payload-builder";
24
- import { LRUCache as LRUCache2 } from "lru-cache";
25
-
26
- // src/AsyncQueryBus/AsyncQueryBusBase.ts
27
- import { assertEx } from "@xylabs/assert";
28
- import { Base as Base2 } from "@xylabs/object";
29
- import { isArchivistInstance } from "@xyo-network/archivist-model";
30
- import { isDivinerInstance } from "@xyo-network/diviner-model";
31
- import { ResolveHelper } from "@xyo-network/module-model";
32
- import { Mutex } from "async-mutex";
33
- import { LRUCache } from "lru-cache";
34
- var POLLING_FREQUENCY_MIN = 100;
35
- var POLLING_FREQUENCY_MAX = 6e4;
36
- var POLLING_FREQUENCY_DEFAULT = 1e3;
37
- var _AsyncQueryBusBase = class _AsyncQueryBusBase extends Base2 {
38
- _lastState;
39
- _targetConfigs = {};
40
- _targetQueries = {};
41
- _lastResolveFailure = {};
42
- _queriesArchivist;
43
- _queriesDiviner;
44
- _reResolveDelay = 1e3 * 5;
45
- _resolveMutex = new Mutex();
46
- _responsesArchivist;
47
- _responsesDiviner;
48
- constructor(params) {
49
- super(params);
50
- }
51
- get config() {
52
- return this.params.config;
53
- }
54
- get pollFrequency() {
55
- var _a;
56
- const frequency = ((_a = this.config) == null ? void 0 : _a.pollFrequency) ?? POLLING_FREQUENCY_DEFAULT;
57
- if (frequency < POLLING_FREQUENCY_MIN || frequency > POLLING_FREQUENCY_MAX) {
58
- return POLLING_FREQUENCY_DEFAULT;
59
- }
60
- return frequency;
61
- }
62
- get rootModule() {
63
- return this.params.rootModule;
64
- }
65
- /**
66
- * A cache of the last offset of the Diviner process per address
67
- */
68
- get lastState() {
69
- const requiredConfig = {
70
- max: 1e3,
71
- ttl: 0
72
- };
73
- this._lastState = this._lastState ?? new LRUCache(requiredConfig);
74
- return this._lastState;
75
- }
76
- async queriesArchivist() {
77
- return await this._resolveMutex.runExclusive(async () => {
78
- var _a, _b, _c;
79
- this._queriesArchivist = this._queriesArchivist ?? await this.resolve(assertEx((_c = (_b = (_a = this.config) == null ? void 0 : _a.intersect) == null ? void 0 : _b.queries) == null ? void 0 : _c.archivist, () => "No queries Archivist defined"), isArchivistInstance);
80
- return this._queriesArchivist;
81
- });
82
- }
83
- async queriesDiviner() {
84
- return await this._resolveMutex.runExclusive(async () => {
85
- var _a, _b, _c;
86
- this._queriesDiviner = this._queriesDiviner ?? await this.resolve(assertEx((_c = (_b = (_a = this.config) == null ? void 0 : _a.intersect) == null ? void 0 : _b.queries) == null ? void 0 : _c.boundWitnessDiviner, () => "No queries Diviner defined"), isDivinerInstance);
87
- return this._queriesDiviner;
88
- });
89
- }
90
- async responsesArchivist() {
91
- return await this._resolveMutex.runExclusive(async () => {
92
- var _a, _b, _c;
93
- this._responsesArchivist = this._responsesArchivist ?? await this.resolve(assertEx((_c = (_b = (_a = this.config) == null ? void 0 : _a.intersect) == null ? void 0 : _b.responses) == null ? void 0 : _c.archivist, () => "No responses Archivist defined"), isArchivistInstance);
94
- return this._responsesArchivist;
95
- });
96
- }
97
- async responsesDiviner() {
98
- return await this._resolveMutex.runExclusive(async () => {
99
- var _a, _b, _c;
100
- this._responsesDiviner = this._responsesDiviner ?? await this.resolve(assertEx((_c = (_b = (_a = this.config) == null ? void 0 : _a.intersect) == null ? void 0 : _b.responses) == null ? void 0 : _c.boundWitnessDiviner, () => "No responses Diviner defined"), isDivinerInstance);
101
- return this._responsesDiviner;
102
- });
103
- }
104
- /**
105
- * Commit the internal state of the process. This is similar
106
- * to a transaction completion in a database and should only be called
107
- * when results have been successfully persisted to the appropriate
108
- * external stores.
109
- * @param address The module address to commit the state for
110
- * @param nextState The state to commit
111
- */
112
- async commitState(address, nextState) {
113
- await Promise.resolve();
114
- const lastState = this.lastState.get(address);
115
- if (lastState && lastState >= nextState) return;
116
- this.lastState.set(address, nextState);
117
- }
118
- /**
119
- * Retrieves the last state of the process. Used to recover state after
120
- * preemptions, reboots, etc.
121
- */
122
- async retrieveState(address) {
123
- await Promise.resolve();
124
- const state = this.lastState.get(address);
125
- if (state === void 0) {
126
- const newState = Date.now() - 1e3;
127
- this.lastState.set(address, newState);
128
- return newState;
129
- } else {
130
- return state;
131
- }
132
- }
133
- async resolve(id, typeCheck) {
134
- var _a, _b, _c;
135
- if (Date.now() - (this._lastResolveFailure[id] ?? 0) < this._reResolveDelay) {
136
- return;
137
- }
138
- this._lastResolveFailure[id] = Date.now();
139
- const resolved = await ResolveHelper.resolveModuleIdentifier(this.rootModule, id);
140
- if (resolved) {
141
- if (typeCheck(resolved)) {
142
- delete this._lastResolveFailure[id];
143
- return resolved;
144
- } else {
145
- (_b = this.logger) == null ? void 0 : _b.warn(`Unable to resolve responsesDiviner as correct type [${id}][${(_a = resolved == null ? void 0 : resolved.constructor) == null ? void 0 : _a.name}]: ${resolved.id}`);
146
- }
147
- } else {
148
- (_c = this.logger) == null ? void 0 : _c.debug(`Unable to resolve queriesArchivist [${id}] [${await ResolveHelper.traceModuleIdentifier(this.rootModule, id)}]`);
149
- }
150
- }
151
- };
152
- __name(_AsyncQueryBusBase, "AsyncQueryBusBase");
153
- var AsyncQueryBusBase = _AsyncQueryBusBase;
154
-
155
- // src/AsyncQueryBus/model/QueryStatus.ts
156
- var Pending = "pending";
157
-
158
- // src/AsyncQueryBus/AsyncQueryBusClient.ts
159
- var _AsyncQueryBusClient = class _AsyncQueryBusClient extends AsyncQueryBusBase {
160
- _queryCache;
161
- _pollCount = 0;
162
- _pollId;
163
- constructor(params) {
164
- super(params);
165
- }
166
- get queryCacheConfig() {
167
- var _a, _b;
168
- const queryCacheConfig = ((_a = this.config) == null ? void 0 : _a.queryCache) === true ? {} : (_b = this.config) == null ? void 0 : _b.queryCache;
169
- return {
170
- max: 100,
171
- ttl: 1e3 * 60,
172
- ...queryCacheConfig
173
- };
174
- }
175
- get started() {
176
- return !!this._pollId;
177
- }
178
- /**
179
- * A cache of queries that have been issued
180
- */
181
- get queryCache() {
182
- const config = this.queryCacheConfig;
183
- const requiredConfig = {
184
- noUpdateTTL: false,
185
- ttlAutopurge: true
186
- };
187
- this._queryCache = this._queryCache ?? new LRUCache2({
188
- ...config,
189
- ...requiredConfig
190
- });
191
- return this._queryCache;
192
- }
193
- listeningAddresses() {
194
- var _a;
195
- return (_a = this._queryCache) == null ? void 0 : _a.keys();
196
- }
197
- async send(address, query, payloads) {
198
- var _a, _b, _c, _d;
199
- (_a = this.logger) == null ? void 0 : _a.debug(`Begin issuing query to: ${address}`);
200
- const $meta = {
201
- ...query == null ? void 0 : query.$meta,
202
- destination: [
203
- address
204
- ]
205
- };
206
- const routedQuery = await PayloadBuilder.build({
207
- ...query,
208
- $meta
209
- });
210
- const queryArchivist = assertEx2(await this.queriesArchivist(), () => {
211
- var _a2, _b2, _c2;
212
- return `Unable to contact queriesArchivist [${(_c2 = (_b2 = (_a2 = this.config) == null ? void 0 : _a2.intersect) == null ? void 0 : _b2.queries) == null ? void 0 : _c2.archivist}]`;
213
- });
214
- const routedQueryHash = (routedQuery == null ? void 0 : routedQuery.$hash) ?? Object.keys(await PayloadBuilder.dataHash(routedQuery));
215
- (_b = this.logger) == null ? void 0 : _b.debug(`Issuing query: ${routedQueryHash} to: ${address}`);
216
- const data = payloads ? [
217
- routedQuery,
218
- ...payloads
219
- ] : [
220
- routedQuery
221
- ];
222
- const insertResult = await ((_c = queryArchivist.insert) == null ? void 0 : _c.call(queryArchivist, data));
223
- (_d = this.logger) == null ? void 0 : _d.debug(`Issued query: ${routedQueryHash} to: ${address}`);
224
- this.queryCache.set(routedQueryHash, Pending);
225
- if (!insertResult) throw new Error("Unable to issue query to queryArchivist");
226
- return new Promise((resolve, reject) => {
227
- var _a2;
228
- (_a2 = this.logger) == null ? void 0 : _a2.debug(`Polling for response to query: ${routedQueryHash}`);
229
- let nextDelay = 100;
230
- const pollForResponse = /* @__PURE__ */ __name(async () => {
231
- var _a3, _b2;
232
- try {
233
- this.start();
234
- let response = this.queryCache.get(routedQueryHash);
235
- while (response !== void 0) {
236
- await delay(nextDelay);
237
- response = this.queryCache.get(routedQueryHash);
238
- if (response && response !== Pending) {
239
- (_a3 = this.logger) == null ? void 0 : _a3.log(`Returning response to query: ${routedQueryHash}`);
240
- resolve(response);
241
- return;
242
- }
243
- nextDelay = Math.floor(nextDelay * 1.2);
244
- if (nextDelay > 1e3) nextDelay = 1e3;
245
- }
246
- (_b2 = this.logger) == null ? void 0 : _b2.error("Timeout waiting for query response");
247
- const error = {
248
- message: "Timeout waiting for query response",
249
- query: "network.xyo.boundwitness",
250
- schema: "network.xyo.error.module",
251
- sources: [
252
- routedQueryHash
253
- ]
254
- };
255
- reject(error);
256
- return;
257
- } finally {
258
- this.stop();
259
- }
260
- }, "pollForResponse");
261
- forget(pollForResponse());
262
- });
263
- }
264
- /**
265
- * Runs the background divine process on a loop with a delay
266
- * specified by the `config.pollFrequency`
267
- */
268
- poll() {
269
- this._pollId = setTimeoutEx(async () => {
270
- var _a, _b;
271
- try {
272
- await this.processIncomingResponses();
273
- } catch (e) {
274
- (_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `Error in main loop: ${e}`);
275
- } finally {
276
- if (this._pollId) clearTimeoutEx(this._pollId);
277
- this._pollId = void 0;
278
- this.poll();
279
- }
280
- }, this.pollFrequency);
281
- }
282
- /**
283
- * Background process for processing incoming responses to previously issued queries
284
- */
285
- processIncomingResponses = /* @__PURE__ */ __name(async () => {
286
- const responseArchivist = await this.responsesArchivist();
287
- if (responseArchivist) {
288
- const responseBoundWitnessDiviner = await this.responsesDiviner();
289
- if (responseBoundWitnessDiviner) {
290
- const pendingCommands = [
291
- ...this.queryCache.entries()
292
- ].filter(([_, status]) => status === Pending);
293
- await Promise.allSettled(pendingCommands.map(async ([sourceQuery, status]) => {
294
- var _a, _b, _c;
295
- if (status === Pending) {
296
- const divinerQuery = {
297
- limit: 1,
298
- order: "desc",
299
- schema: BoundWitnessDivinerQuerySchema,
300
- sourceQuery
301
- };
302
- const result = await responseBoundWitnessDiviner.divine([
303
- divinerQuery
304
- ]);
305
- if (result && result.length > 0) {
306
- const response = result.find(isBoundWitnessWithMeta);
307
- if (response && ((_a = response == null ? void 0 : response.$meta) == null ? void 0 : _a.sourceQuery) === sourceQuery) {
308
- (_b = this.logger) == null ? void 0 : _b.debug(`Found response to query: ${sourceQuery}`);
309
- const payloads = ((_c = response.payload_hashes) == null ? void 0 : _c.length) > 0 ? await responseArchivist.get(response.payload_hashes) : [];
310
- this.queryCache.set(sourceQuery, [
311
- response,
312
- payloads,
313
- []
314
- ]);
315
- }
316
- }
317
- }
318
- }));
319
- }
320
- }
321
- }, "processIncomingResponses");
322
- start() {
323
- if (this._pollCount === 0) {
324
- this.poll();
325
- }
326
- this._pollCount++;
327
- }
328
- stop() {
329
- this._pollCount--;
330
- if (this._pollCount <= 0) {
331
- if (this._pollId) clearTimeoutEx(this._pollId);
332
- this._pollId = void 0;
333
- this._pollCount = 0;
334
- }
335
- }
336
- };
337
- __name(_AsyncQueryBusClient, "AsyncQueryBusClient");
338
- var AsyncQueryBusClient = _AsyncQueryBusClient;
339
-
340
- // src/AsyncQueryBus/AsyncQueryBusHost.ts
341
- import { containsAll } from "@xylabs/array";
342
- import { assertEx as assertEx3 } from "@xylabs/assert";
343
- import { clearTimeoutEx as clearTimeoutEx2, setTimeoutEx as setTimeoutEx2 } from "@xylabs/timer";
344
- import { isQueryBoundWitnessWithMeta } from "@xyo-network/boundwitness-model";
345
- import { isBridgeInstance } from "@xyo-network/bridge-model";
346
- import { BoundWitnessDivinerQuerySchema as BoundWitnessDivinerQuerySchema2 } from "@xyo-network/diviner-boundwitness-model";
347
- import { asModuleInstance, ModuleConfigSchema, resolveAddressToInstance, ResolveHelper as ResolveHelper2 } from "@xyo-network/module-model";
348
- import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
349
- var IDLE_POLLING_FREQUENCY_RATIO_MIN = 4;
350
- var IDLE_POLLING_FREQUENCY_RATIO_MAX = 64;
351
- var IDLE_POLLING_FREQUENCY_RATIO_DEFAULT = 16;
352
- var IDLE_THRESHOLD_RATIO_MIN = 4;
353
- var IDLE_THRESHOLD_RATIO_MAX = 64;
354
- var IDLE_THRESHOLD_RATIO_DEFAULT = 16;
355
- var _AsyncQueryBusHost = class _AsyncQueryBusHost extends AsyncQueryBusBase {
356
- _exposedAddresses = /* @__PURE__ */ new Set();
357
- _exposeOptions = {};
358
- _idle = false;
359
- _lastQueryTime;
360
- _pollId;
361
- constructor(params) {
362
- super(params);
363
- }
364
- get exposedAddresses() {
365
- return this._exposedAddresses;
366
- }
367
- get idlePollFrequency() {
368
- var _a;
369
- const frequency = ((_a = this.config) == null ? void 0 : _a.idlePollFrequency) ?? IDLE_POLLING_FREQUENCY_RATIO_DEFAULT * this.pollFrequency;
370
- if (frequency < this.pollFrequency * IDLE_POLLING_FREQUENCY_RATIO_MIN) {
371
- return IDLE_POLLING_FREQUENCY_RATIO_MIN * this.pollFrequency;
372
- }
373
- if (frequency > this.pollFrequency * IDLE_POLLING_FREQUENCY_RATIO_MAX) {
374
- return IDLE_POLLING_FREQUENCY_RATIO_MAX * this.pollFrequency;
375
- }
376
- return frequency;
377
- }
378
- get idleThreshold() {
379
- var _a;
380
- const threshold = ((_a = this.config) == null ? void 0 : _a.idleThreshold) ?? IDLE_THRESHOLD_RATIO_DEFAULT * this.idlePollFrequency;
381
- if (threshold < this.idlePollFrequency * IDLE_THRESHOLD_RATIO_MIN) {
382
- return IDLE_POLLING_FREQUENCY_RATIO_MIN * this.pollFrequency;
383
- }
384
- if (threshold > this.idlePollFrequency * IDLE_THRESHOLD_RATIO_MAX) {
385
- return IDLE_POLLING_FREQUENCY_RATIO_MAX * this.pollFrequency;
386
- }
387
- return threshold;
388
- }
389
- get perAddressBatchQueryLimit() {
390
- var _a;
391
- return ((_a = this.config) == null ? void 0 : _a.perAddressBatchQueryLimit) ?? 10;
392
- }
393
- get started() {
394
- return !!this._pollId;
395
- }
396
- expose(mod, options) {
397
- var _a, _b;
398
- const { failOnAlreadyExposed } = options ?? {};
399
- if (isBridgeInstance(mod)) {
400
- (_a = this.logger) == null ? void 0 : _a.warn(`Attempted to expose a BridgeModule [${mod.id}] - Not exposing`);
401
- } else {
402
- assertEx3(!failOnAlreadyExposed || !this._exposedAddresses.has(mod.address), () => `Address already exposed: ${mod.id} [${mod.address}]`);
403
- this._exposedAddresses.add(mod.address);
404
- this._exposeOptions[mod.address] = {
405
- ...options
406
- };
407
- (_b = this.logger) == null ? void 0 : _b.debug(`${mod.id} exposed [${mod.address}]`);
408
- return mod;
409
- }
410
- }
411
- async listeningModules() {
412
- var _a;
413
- const exposedModules = [
414
- ...((_a = this.config) == null ? void 0 : _a.listeningModules) ?? [],
415
- ...this.exposedAddresses.values()
416
- ];
417
- return await Promise.all(exposedModules.map(async (exposedModule) => assertEx3(asModuleInstance(await resolveAddressToInstance(this.rootModule, exposedModule)), () => `Unable to resolve listeningModule [${exposedModule}]`)));
418
- }
419
- start() {
420
- if (this.started) {
421
- console.warn("AsyncQueryBus starting when already started");
422
- }
423
- this.poll();
424
- }
425
- stop() {
426
- if (!this.started) {
427
- console.warn("AsyncQueryBus stopping when already stopped");
428
- }
429
- if (this._pollId) clearTimeoutEx2(this._pollId);
430
- this._pollId = void 0;
431
- }
432
- async unexpose(id, validate = true) {
433
- var _a;
434
- const mod = asModuleInstance(await this.rootModule.resolve(id, {
435
- maxDepth: 10
436
- }));
437
- if (mod) {
438
- assertEx3(!validate || this._exposedAddresses.has(mod.address), () => `Address not exposed [${mod.address}][${mod.id}]`);
439
- this._exposedAddresses.delete(mod.address);
440
- delete this._exposeOptions[mod.address];
441
- (_a = this.logger) == null ? void 0 : _a.debug(`${mod.address} [${mod.id}] unexposed`);
442
- }
443
- return mod;
444
- }
445
- // eslint-disable-next-line complexity
446
- callLocalModule = /* @__PURE__ */ __name(async (localModule, query) => {
447
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
448
- this._idle = false;
449
- this._lastQueryTime = Date.now();
450
- const localModuleName = localModule.id;
451
- const queryArchivist = assertEx3(await this.queriesArchivist(), () => {
452
- var _a2, _b2, _c2;
453
- return `Unable to contact queriesArchivist [${(_c2 = (_b2 = (_a2 = this.config) == null ? void 0 : _a2.intersect) == null ? void 0 : _b2.queries) == null ? void 0 : _c2.archivist}]`;
454
- });
455
- const responsesArchivist = assertEx3(await this.responsesArchivist(), () => {
456
- var _a2, _b2, _c2;
457
- return `Unable to contact responsesArchivist [${(_c2 = (_b2 = (_a2 = this.config) == null ? void 0 : _a2.intersect) == null ? void 0 : _b2.queries) == null ? void 0 : _c2.archivist}]`;
458
- });
459
- const queryDestination = (_a = query.$meta) == null ? void 0 : _a.destination;
460
- if (queryDestination && (queryDestination == null ? void 0 : queryDestination.includes(localModule.address))) {
461
- const queryIndex = query.payload_hashes.indexOf(query.query);
462
- if (queryIndex !== -1) {
463
- const querySchema = query.payload_schemas[queryIndex];
464
- if (localModule.queries.includes(querySchema)) {
465
- const queryPayloads = await queryArchivist.get(query.payload_hashes);
466
- (_c = (_b = this.params).onQueryFulfillStarted) == null ? void 0 : _c.call(_b, {
467
- payloads: queryPayloads,
468
- query
469
- });
470
- const queryPayloadsDict = await PayloadBuilder2.toAllHashMap(queryPayloads);
471
- const queryHash = (await PayloadBuilder2.build(query)).$hash;
472
- if (!containsAll(Object.keys(queryPayloadsDict), query.payload_hashes)) {
473
- (_d = this.logger) == null ? void 0 : _d.error(`Error processing command ${queryHash} for module ${localModuleName}, missing payloads`);
474
- return;
475
- }
476
- try {
477
- const querySchema2 = queryPayloadsDict[query.query].schema;
478
- (_e = this.logger) == null ? void 0 : _e.debug(`Issuing query ${querySchema2} (${queryHash}) addressed to module: ${localModuleName}`);
479
- const result = await localModule.query(query, queryPayloads, {
480
- allowedQueries: (_f = this._exposeOptions[localModule.address]) == null ? void 0 : _f.allowedQueries,
481
- schema: ModuleConfigSchema
482
- });
483
- const [bw, payloads, errors] = result;
484
- (_g = this.logger) == null ? void 0 : _g.debug(`Replying to query ${queryHash} addressed to module: ${localModuleName}`);
485
- const insertResult = await responsesArchivist.insert([
486
- bw,
487
- ...payloads,
488
- ...errors
489
- ]);
490
- if (insertResult.length === 0) {
491
- (_h = this.logger) == null ? void 0 : _h.error(`Error replying to query ${queryHash} addressed to module: ${localModuleName}`);
492
- }
493
- if (query == null ? void 0 : query.timestamp) {
494
- await this.commitState(localModule.address, query.timestamp);
495
- }
496
- (_j = (_i = this.params).onQueryFulfillFinished) == null ? void 0 : _j.call(_i, {
497
- payloads: queryPayloads,
498
- query,
499
- result,
500
- status: "success"
501
- });
502
- } catch (error) {
503
- (_l = (_k = this.params).onQueryFulfillFinished) == null ? void 0 : _l.call(_k, {
504
- payloads: queryPayloads,
505
- query,
506
- status: "failure"
507
- });
508
- (_m = this.logger) == null ? void 0 : _m.error(`Error processing query ${queryHash} for module ${localModuleName}: ${error}`);
509
- }
510
- }
511
- }
512
- }
513
- }, "callLocalModule");
514
- /**
515
- * Finds unprocessed commands addressed to the supplied address
516
- * @param address The address to find commands for
517
- */
518
- findQueriesToAddress = /* @__PURE__ */ __name(async (address) => {
519
- var _a, _b, _c, _d, _e;
520
- const queriesDivinerId = assertEx3((_c = (_b = (_a = this.config) == null ? void 0 : _a.intersect) == null ? void 0 : _b.queries) == null ? void 0 : _c.boundWitnessDiviner, () => "No queries Diviner defined");
521
- const queriesBoundWitnessDiviner = await this.queriesDiviner();
522
- if (queriesBoundWitnessDiviner) {
523
- const prevState = await this.retrieveState(address);
524
- const destination = [
525
- address
526
- ];
527
- const limit = this.perAddressBatchQueryLimit;
528
- const divinerQuery = {
529
- destination,
530
- limit,
531
- order: "asc",
532
- schema: BoundWitnessDivinerQuerySchema2,
533
- timestamp: prevState + 1
534
- };
535
- const result = await queriesBoundWitnessDiviner.divine([
536
- divinerQuery
537
- ]);
538
- const queries = result.filter(isQueryBoundWitnessWithMeta);
539
- const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? prevState)) + 1 : Date.now();
540
- await this.commitState(address, nextState);
541
- (_d = this.logger) == null ? void 0 : _d.debug("findQueriesToAddress", address, prevState, nextState);
542
- return queries;
543
- } else {
544
- (_e = this.logger) == null ? void 0 : _e.warn(`Unable to resolve queriesBoundWitnessDiviner [${queriesDivinerId}] [${await ResolveHelper2.traceModuleIdentifier(this.rootModule, queriesDivinerId)}]`);
545
- }
546
- }, "findQueriesToAddress");
547
- /**
548
- * Runs the background divine process on a loop with a delay
549
- * specified by the `config.pollFrequency`
550
- */
551
- poll() {
552
- this._pollId = setTimeoutEx2(async () => {
553
- var _a, _b;
554
- try {
555
- await this.processIncomingQueries();
556
- } catch (e) {
557
- (_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `Error in main loop: ${e}`);
558
- } finally {
559
- if (this._pollId) clearTimeoutEx2(this._pollId);
560
- this._pollId = void 0;
561
- this.poll();
562
- }
563
- const now = Date.now();
564
- if (this.idleThreshold < now - (this._lastQueryTime ?? now)) {
565
- this._idle = true;
566
- }
567
- }, this._idle ? this.idlePollFrequency : this.pollFrequency);
568
- }
569
- /**
570
- * Background process for checking for inbound queries
571
- */
572
- processIncomingQueries = /* @__PURE__ */ __name(async () => {
573
- var _a;
574
- (_a = this.logger) == null ? void 0 : _a.debug("Checking for inbound queries");
575
- const localModules = await this.listeningModules();
576
- await Promise.allSettled(localModules.map(async (localModule) => {
577
- var _a2, _b, _c;
578
- try {
579
- const localModuleName = localModule.id;
580
- (_a2 = this.logger) == null ? void 0 : _a2.debug(`Checking for inbound queries to ${localModuleName} [${localModule.address}]`);
581
- const queries = await this.findQueriesToAddress(localModule.address) ?? [];
582
- if (queries.length === 0) return;
583
- (_b = this.logger) == null ? void 0 : _b.debug(`Found queries addressed to local module: ${localModuleName}`);
584
- for (const query of queries) {
585
- await this.callLocalModule(localModule, query);
586
- }
587
- } catch (error) {
588
- (_c = this.logger) == null ? void 0 : _c.error(`Error processing queries for address ${localModule.address}: ${error}`);
589
- }
590
- }));
591
- }, "processIncomingQueries");
592
- };
593
- __name(_AsyncQueryBusHost, "AsyncQueryBusHost");
594
- var AsyncQueryBusHost = _AsyncQueryBusHost;
595
-
596
- // src/AsyncQueryBus/ModuleHost/ModuleHost.ts
597
- var _AsyncQueryBusModuleHost = class _AsyncQueryBusModuleHost extends AbstractModuleHost {
598
- _busHost;
599
- constructor(params) {
600
- super(params);
601
- }
602
- async start() {
603
- var _a;
604
- const listeningModules = this.params.config.listeningModules ?? (await this.params.mod.resolve("*", {
605
- direction: "down"
606
- })).map((m) => m.address);
607
- this._busHost = new AsyncQueryBusHost({
608
- config: {
609
- ...this.params.config,
610
- listeningModules
611
- },
612
- logger: this.params.logger,
613
- rootModule: this.params.mod
614
- });
615
- (_a = this._busHost) == null ? void 0 : _a.start();
616
- }
617
- stop() {
618
- var _a;
619
- (_a = this._busHost) == null ? void 0 : _a.stop();
620
- }
621
- };
622
- __name(_AsyncQueryBusModuleHost, "AsyncQueryBusModuleHost");
623
- var AsyncQueryBusModuleHost = _AsyncQueryBusModuleHost;
624
-
625
- // src/AsyncQueryBus/ModuleProxy/ModuleProxy.ts
626
- import { assertEx as assertEx4 } from "@xylabs/assert";
627
- import { exists } from "@xylabs/exists";
628
- import { forget as forget2 } from "@xylabs/forget";
629
- import { isAddress } from "@xylabs/hex";
630
- import { AbstractModuleProxy } from "@xyo-network/bridge-abstract";
631
- import { ResolveHelper as ResolveHelper3 } from "@xyo-network/module-model";
632
- var _AsyncQueryBusModuleProxy = class _AsyncQueryBusModuleProxy extends AbstractModuleProxy {
633
- constructor(params) {
634
- _AsyncQueryBusModuleProxy.createCount = _AsyncQueryBusModuleProxy.createCount + 1;
635
- if (Math.floor(_AsyncQueryBusModuleProxy.createCount / 10) === _AsyncQueryBusModuleProxy.createCount / 10) {
636
- console.log(`AsyncQueryBusModuleProxy.createCount: ${_AsyncQueryBusModuleProxy.createCount}`);
637
- }
638
- super(params);
639
- }
640
- get id() {
641
- return this.address;
642
- }
643
- get modName() {
644
- return void 0;
645
- }
646
- async proxyQueryHandler(query, payloads) {
647
- if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {
648
- forget2(this.storeToArchivists([
649
- query,
650
- ...payloads ?? []
651
- ]));
652
- }
653
- const result = await this.params.busClient.send(this.address, query, payloads);
654
- if (this.archiving && this.isAllowedArchivingQuery(query.schema)) {
655
- forget2(this.storeToArchivists(result.flat()));
656
- }
657
- return result;
658
- }
659
- async publicChildren() {
660
- return (await Promise.all(Object.keys(await this.childAddressMap()).filter(exists).map((address) => this.resolve(address)))).filter(exists);
661
- }
662
- async resolve(idOrFilter = "*", options = {}) {
663
- const config = {
664
- address: this.address,
665
- dead: this.dead,
666
- downResolver: this.downResolver,
667
- logger: this.logger,
668
- mod: this,
669
- transformers: this.moduleIdentifierTransformers,
670
- upResolver: this.upResolver
671
- };
672
- if (idOrFilter === "*") {
673
- return await this.publicChildren();
674
- }
675
- switch (typeof idOrFilter) {
676
- case "string": {
677
- const parts = idOrFilter.split(":");
678
- const first = assertEx4(parts.shift(), () => "Missing first");
679
- const remainingPath = parts.join(":");
680
- const address = isAddress(first) ? first : this.childAddressByName(first);
681
- if (!address) return void 0;
682
- const firstInstance = await this.params.host.resolve(address);
683
- return remainingPath ? await (firstInstance == null ? void 0 : firstInstance.resolve(remainingPath)) : firstInstance;
684
- }
685
- case "object": {
686
- return (await ResolveHelper3.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address);
687
- }
688
- default: {
689
- return (await ResolveHelper3.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address);
690
- }
691
- }
692
- }
693
- async startHandler() {
694
- return await super.startHandler();
695
- }
696
- };
697
- __name(_AsyncQueryBusModuleProxy, "AsyncQueryBusModuleProxy");
698
- __publicField(_AsyncQueryBusModuleProxy, "createCount", 0);
699
- var AsyncQueryBusModuleProxy = _AsyncQueryBusModuleProxy;
700
-
701
- // src/Schema.ts
702
- var PubSubBridgeSchema = "network.xyo.bridge.pubsub";
703
-
704
- // src/Config.ts
705
- var PubSubBridgeConfigSchema = `${PubSubBridgeSchema}.config`;
706
-
707
- // src/PubSubBridge.ts
708
- import { assertEx as assertEx6 } from "@xylabs/assert";
709
- import { exists as exists2 } from "@xylabs/exists";
710
- import { forget as forget3 } from "@xylabs/forget";
711
- import { isAddress as isAddress3 } from "@xylabs/hex";
712
- import { toJsonString } from "@xylabs/object";
713
- import { AbstractBridge } from "@xyo-network/bridge-abstract";
714
- import { AddressSchema, creatableModule, isAddressModuleFilter, resolveAddressToInstance as resolveAddressToInstance2, resolveAddressToInstanceUp, ResolveHelper as ResolveHelper5 } from "@xyo-network/module-model";
715
- import { asNodeInstance } from "@xyo-network/node-model";
716
- import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
717
- import { Mutex as Mutex3 } from "async-mutex";
718
-
719
- // src/PubSubBridgeModuleResolver.ts
720
- import { assertEx as assertEx5 } from "@xylabs/assert";
721
- import { isAddress as isAddress2 } from "@xylabs/hex";
722
- import { Account } from "@xyo-network/account";
723
- import { AbstractBridgeModuleResolver, wrapModuleWithType } from "@xyo-network/bridge-abstract";
724
- import { ConfigSchema } from "@xyo-network/config-payload-plugin";
725
- import { asModuleInstance as asModuleInstance2, ModuleConfigSchema as ModuleConfigSchema2, ResolveHelper as ResolveHelper4 } from "@xyo-network/module-model";
726
- import { Mutex as Mutex2 } from "async-mutex";
727
- import { LRUCache as LRUCache3 } from "lru-cache";
728
- var _PubSubBridgeModuleResolver = class _PubSubBridgeModuleResolver extends AbstractBridgeModuleResolver {
729
- _resolvedCache = new LRUCache3({
730
- max: 1e3
731
- });
732
- _resolvedCacheMutex = new Mutex2();
733
- async resolveHandler(id, options) {
734
- const parentResult = await super.resolveHandler(id, options);
735
- if (parentResult.length > 0) {
736
- return parentResult;
737
- }
738
- const idParts = id.split(":");
739
- const untransformedFirstPart = assertEx5(idParts.shift(), () => "Missing module identifier");
740
- const firstPart = await ResolveHelper4.transformModuleIdentifier(untransformedFirstPart);
741
- assertEx5(isAddress2(firstPart), () => `Invalid module address: ${firstPart}`);
742
- const remainderParts = idParts.join(":");
743
- const instance = await this._resolvedCacheMutex.runExclusive(async () => {
744
- var _a, _b;
745
- const cachedMod = this._resolvedCache.get(firstPart);
746
- if (cachedMod) {
747
- const result2 = idParts.length <= 0 ? cachedMod : cachedMod.resolve(remainderParts, {
748
- ...options,
749
- maxDepth: ((options == null ? void 0 : options.maxDepth) ?? 5) - 1
750
- });
751
- return result2;
752
- }
753
- const account = await Account.random();
754
- const finalParams = {
755
- account,
756
- archiving: this.params.archiving,
757
- busClient: this.params.busClient,
758
- config: {
759
- schema: ModuleConfigSchema2
760
- },
761
- host: this,
762
- moduleAddress: firstPart,
763
- onQuerySendFinished: this.params.onQuerySendFinished,
764
- onQuerySendStarted: this.params.onQuerySendStarted
765
- };
766
- const proxy = new AsyncQueryBusModuleProxy(finalParams);
767
- const state = await proxy.state();
768
- if (state) {
769
- const configSchema = (_a = state.find((payload) => payload.schema === ConfigSchema)) == null ? void 0 : _a.config;
770
- const config = assertEx5(state.find((payload) => payload.schema === configSchema), () => "Unable to locate config");
771
- proxy.setConfig(config);
772
- }
773
- await ((_b = proxy.start) == null ? void 0 : _b.call(proxy));
774
- const wrapped = wrapModuleWithType(proxy, account);
775
- assertEx5(asModuleInstance2(wrapped, {}), () => `Failed to asModuleInstance [${id}]`);
776
- this._resolvedCache.set(wrapped.address, wrapped);
777
- return wrapped;
778
- });
779
- const result = remainderParts.length > 0 ? await instance.resolve(remainderParts, options) : instance;
780
- return result ? [
781
- result
782
- ] : [];
783
- }
784
- };
785
- __name(_PubSubBridgeModuleResolver, "PubSubBridgeModuleResolver");
786
- var PubSubBridgeModuleResolver = _PubSubBridgeModuleResolver;
787
-
788
- // src/PubSubBridge.ts
789
- function _ts_decorate(decorators, target, key, desc) {
790
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
791
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
792
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
793
- return c > 3 && r && Object.defineProperty(target, key, r), r;
794
- }
795
- __name(_ts_decorate, "_ts_decorate");
796
- var moduleName = "PubSubBridge";
797
- var _PubSubBridge = class _PubSubBridge extends AbstractBridge {
798
- _configRootAddress = "";
799
- _configStateStoreArchivist = "";
800
- _configStateStoreBoundWitnessDiviner = "";
801
- _exposedAddresses = [];
802
- _lastState;
803
- _busClient;
804
- _busHost;
805
- _discoverRootsMutex = new Mutex3();
806
- _resolver;
807
- get resolver() {
808
- this._resolver = this._resolver ?? new PubSubBridgeModuleResolver({
809
- additionalSigners: this.additionalSigners,
810
- archiving: {
811
- ...this.archiving,
812
- resolveArchivists: this.resolveArchivingArchivists.bind(this)
813
- },
814
- bridge: this,
815
- busClient: assertEx6(this.busClient(), () => "busClient not configured"),
816
- onQuerySendFinished: /* @__PURE__ */ __name((args) => {
817
- forget3(this.emit("querySendFinished", {
818
- mod: this,
819
- ...args
820
- }));
821
- }, "onQuerySendFinished"),
822
- onQuerySendStarted: /* @__PURE__ */ __name((args) => {
823
- forget3(this.emit("querySendStarted", {
824
- mod: this,
825
- ...args
826
- }));
827
- }, "onQuerySendStarted"),
828
- root: this,
829
- wrapperAccount: this.account
830
- });
831
- return this._resolver;
832
- }
833
- get moduleName() {
834
- return this.modName ?? moduleName;
835
- }
836
- async connect(id, maxDepth = 5) {
837
- const transformedId = assertEx6(await ResolveHelper5.transformModuleIdentifier(id), () => `Unable to transform module identifier: ${id}`);
838
- const existingInstance = await this.resolve(transformedId);
839
- if (existingInstance) {
840
- return existingInstance.address;
841
- }
842
- const [instance] = await this.resolver.resolveHandler(id);
843
- return await this.connectInstance(instance, maxDepth);
844
- }
845
- async disconnect(id) {
846
- const transformedId = assertEx6(await ResolveHelper5.transformModuleIdentifier(id), () => `Unable to transform module identifier: ${id}`);
847
- const instance = await this.resolve(transformedId);
848
- if (instance) {
849
- this.downResolver.remove(instance.address);
850
- return instance.address;
851
- }
852
- }
853
- async exposeChild(mod, options) {
854
- var _a, _b;
855
- const { maxDepth = 5 } = options ?? {};
856
- console.log(`exposeChild: ${mod.address} ${mod == null ? void 0 : mod.id} ${maxDepth}`);
857
- const host = assertEx6(this.busHost(), () => "Not configured as a host");
858
- host.expose(mod);
859
- const children = maxDepth > 0 ? await ((_a = mod.publicChildren) == null ? void 0 : _a.call(mod)) ?? [] : [];
860
- this.logger.log(`childrenToExpose [${mod.id}][${mod.address}]: ${toJsonString(children.map((child) => child.id))}`);
861
- const exposedChildren = (await Promise.all(children.map((child) => this.exposeChild(child, {
862
- maxDepth: maxDepth - 1,
863
- required: false
864
- })))).flat().filter(exists2);
865
- const allExposed = [
866
- mod,
867
- ...exposedChildren
868
- ];
869
- for (const exposedMod of allExposed) (_b = this.logger) == null ? void 0 : _b.log(`exposed: ${exposedMod.address} [${mod.id}]`);
870
- return allExposed;
871
- }
872
- async exposeHandler(address, options) {
873
- const { required = true } = options ?? {};
874
- const mod = await resolveAddressToInstanceUp(this, address);
875
- console.log(`exposeHandler: ${address} ${mod == null ? void 0 : mod.id}`);
876
- if (required && !mod) {
877
- throw new Error(`Unable to find required module: ${address}`);
878
- }
879
- if (mod) {
880
- return this.exposeChild(mod, options);
881
- }
882
- return [];
883
- }
884
- exposedHandler() {
885
- var _a;
886
- const exposedSet = (_a = this.busHost()) == null ? void 0 : _a.exposedAddresses;
887
- return exposedSet ? [
888
- ...exposedSet
889
- ] : [];
890
- }
891
- async getRoots(force) {
892
- return await this._discoverRootsMutex.runExclusive(async () => {
893
- if (this._roots === void 0 || force) {
894
- const rootAddresses = (await Promise.all((this.config.roots ?? []).map((id) => {
895
- var _a;
896
- try {
897
- return ResolveHelper5.transformModuleIdentifier(id);
898
- } catch (ex) {
899
- (_a = this.logger) == null ? void 0 : _a.warn("Unable to transform module identifier:", id, ex);
900
- return;
901
- }
902
- }))).filter(exists2);
903
- const rootInstances = (await Promise.all(rootAddresses.map(async (root) => {
904
- var _a;
905
- try {
906
- return await this.resolver.resolveHandler(root);
907
- } catch (ex) {
908
- (_a = this.logger) == null ? void 0 : _a.warn("Unable to resolve root:", root, ex);
909
- return;
910
- }
911
- }))).flat().filter(exists2);
912
- for (const instance of rootInstances) {
913
- this.downResolver.add(instance);
914
- }
915
- this._roots = rootInstances;
916
- }
917
- return this._roots;
918
- });
919
- }
920
- async resolve(idOrFilter = "*", options = {}) {
921
- var _a;
922
- const roots = this._roots ?? [];
923
- const workingSet = options.direction === "up" ? [
924
- this
925
- ] : [
926
- ...roots,
927
- this
928
- ];
929
- if (idOrFilter === "*") {
930
- const remainingDepth = (options.maxDepth ?? 1) - 1;
931
- return remainingDepth <= 0 ? workingSet : [
932
- ...workingSet,
933
- ...(await Promise.all(roots.map((mod) => mod.resolve("*", {
934
- ...options,
935
- maxDepth: remainingDepth
936
- })))).flat()
937
- ];
938
- }
939
- switch (typeof idOrFilter) {
940
- case "string": {
941
- const parts = idOrFilter.split(":");
942
- const first = assertEx6(parts.shift(), () => "Missing first part");
943
- const firstInstance = isAddress3(first) ? await resolveAddressToInstance2(this, first, void 0, [], options.direction) : (_a = this._roots) == null ? void 0 : _a.find((mod) => mod.id === first);
944
- return parts.length === 0 ? firstInstance : firstInstance == null ? void 0 : firstInstance.resolve(parts.join(":"), options);
945
- }
946
- case "object": {
947
- const results = [];
948
- if (isAddressModuleFilter(idOrFilter)) {
949
- for (const mod of workingSet) {
950
- if (mod.modName && idOrFilter.address.includes(mod.address)) results.push(mod);
951
- }
952
- }
953
- return results;
954
- }
955
- default: {
956
- return;
957
- }
958
- }
959
- }
960
- async startHandler() {
961
- var _a;
962
- (_a = this.busHost()) == null ? void 0 : _a.start();
963
- return await super.startHandler();
964
- }
965
- async unexposeHandler(id, options) {
966
- var _a;
967
- const { maxDepth = 2, required = true } = options ?? {};
968
- const host = assertEx6(this.busHost(), () => "Not configured as a host");
969
- const mod = await host.unexpose(id, required);
970
- if (mod) {
971
- const children = maxDepth > 0 ? await ((_a = mod.publicChildren) == null ? void 0 : _a.call(mod)) ?? [] : [];
972
- const exposedChildren = (await Promise.all(children.map((child) => this.unexposeHandler(child.address, {
973
- maxDepth: maxDepth - 1,
974
- required: false
975
- })))).flat().filter(exists2);
976
- return [
977
- mod,
978
- ...exposedChildren
979
- ];
980
- }
981
- return [];
982
- }
983
- busClient() {
984
- if (!this._busClient && this.config.client) {
985
- this._busClient = new AsyncQueryBusClient({
986
- config: this.config.client,
987
- logger: this.logger,
988
- rootModule: this
989
- });
990
- }
991
- return this._busClient;
992
- }
993
- busHost() {
994
- if (!this._busHost && this.config.host) {
995
- this._busHost = new AsyncQueryBusHost({
996
- config: this.config.host,
997
- logger: this.logger,
998
- onQueryFulfillFinished: /* @__PURE__ */ __name((args) => {
999
- var _a;
1000
- if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
1001
- forget3(this.storeToArchivists(((_a = args.result) == null ? void 0 : _a.flat()) ?? []));
1002
- }
1003
- forget3(this.emit("queryFulfillFinished", {
1004
- mod: this,
1005
- ...args
1006
- }));
1007
- }, "onQueryFulfillFinished"),
1008
- onQueryFulfillStarted: /* @__PURE__ */ __name((args) => {
1009
- if (this.archiving && this.isAllowedArchivingQuery(args.query.schema)) {
1010
- forget3(this.storeToArchivists([
1011
- args.query,
1012
- ...args.payloads ?? []
1013
- ]));
1014
- }
1015
- forget3(this.emit("queryFulfillStarted", {
1016
- mod: this,
1017
- ...args
1018
- }));
1019
- }, "onQueryFulfillStarted"),
1020
- rootModule: this
1021
- });
1022
- }
1023
- return this._busHost;
1024
- }
1025
- async connectInstance(instance, maxDepth = 5) {
1026
- var _a;
1027
- if (instance) {
1028
- this.downResolver.add(instance);
1029
- if (maxDepth > 0) {
1030
- const node = asNodeInstance(instance);
1031
- if (node) {
1032
- const state = await node.state();
1033
- const children = ((state == null ? void 0 : state.filter(isPayloadOfSchemaType(AddressSchema)).map((s) => s.address)) ?? []).filter((a) => a !== instance.address);
1034
- await Promise.all(children.map((child) => this.connect(child, maxDepth - 1)));
1035
- }
1036
- }
1037
- (_a = this.logger) == null ? void 0 : _a.log(`Connect: ${instance.id}`);
1038
- return instance.address;
1039
- }
1040
- }
1041
- stopHandler(_timeout) {
1042
- var _a;
1043
- (_a = this.busHost()) == null ? void 0 : _a.stop();
1044
- return true;
1045
- }
1046
- };
1047
- __name(_PubSubBridge, "PubSubBridge");
1048
- __publicField(_PubSubBridge, "configSchemas", [
1049
- ...__superGet(_PubSubBridge, _PubSubBridge, "configSchemas"),
1050
- PubSubBridgeConfigSchema
1051
- ]);
1052
- __publicField(_PubSubBridge, "defaultConfigSchema", PubSubBridgeConfigSchema);
1053
- var PubSubBridge = _PubSubBridge;
1054
- PubSubBridge = _ts_decorate([
1055
- creatableModule()
1056
- ], PubSubBridge);
1057
- export {
1058
- AbstractModuleHost,
1059
- AsyncQueryBusClient,
1060
- AsyncQueryBusHost,
1061
- AsyncQueryBusModuleHost,
1062
- AsyncQueryBusModuleProxy,
1063
- Pending,
1064
- PubSubBridge,
1065
- PubSubBridgeConfigSchema,
1066
- PubSubBridgeModuleResolver,
1067
- PubSubBridgeSchema
1068
- };
1069
- //# sourceMappingURL=index.mjs.map