@xyo-network/bridge-pub-sub 2.94.15 → 2.94.17

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 (42) hide show
  1. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts +7 -68
  2. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  3. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +7 -68
  4. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  5. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +7 -68
  6. package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  7. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts +24 -3
  8. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
  9. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts +24 -3
  10. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
  11. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts +24 -3
  12. package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
  13. package/dist/browser/PubSubBridge.d.cts.map +1 -1
  14. package/dist/browser/PubSubBridge.d.mts.map +1 -1
  15. package/dist/browser/PubSubBridge.d.ts.map +1 -1
  16. package/dist/browser/index.cjs +106 -132
  17. package/dist/browser/index.cjs.map +1 -1
  18. package/dist/browser/index.js +103 -129
  19. package/dist/browser/index.js.map +1 -1
  20. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +7 -68
  21. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
  22. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +7 -68
  23. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
  24. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +7 -68
  25. package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
  26. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts +24 -3
  27. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
  28. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts +24 -3
  29. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
  30. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts +24 -3
  31. package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
  32. package/dist/node/PubSubBridge.d.cts.map +1 -1
  33. package/dist/node/PubSubBridge.d.mts.map +1 -1
  34. package/dist/node/PubSubBridge.d.ts.map +1 -1
  35. package/dist/node/index.cjs +111 -136
  36. package/dist/node/index.cjs.map +1 -1
  37. package/dist/node/index.js +108 -133
  38. package/dist/node/index.js.map +1 -1
  39. package/package.json +19 -18
  40. package/src/AsyncQueryBus/AsyncQueryBusBase.ts +59 -89
  41. package/src/AsyncQueryBus/AsyncQueryBusHost.ts +29 -14
  42. package/src/PubSubBridge.ts +21 -20
@@ -3,7 +3,7 @@ import { exists } from '@xylabs/exists'
3
3
  import { Address } from '@xylabs/hex'
4
4
  import { AbstractBridge } from '@xyo-network/abstract-bridge'
5
5
  import { BridgeExposeOptions, BridgeModule, BridgeUnexposeOptions } from '@xyo-network/bridge-model'
6
- import { creatableModule, ModuleFilterOptions, ModuleIdentifier, ModuleInstance, ModuleResolverInstance } from '@xyo-network/module-model'
6
+ import { creatableModule, ModuleIdentifier, ModuleInstance, ModuleResolverInstance } from '@xyo-network/module-model'
7
7
  import { LRUCache } from 'lru-cache'
8
8
 
9
9
  import { AsyncQueryBusClient, AsyncQueryBusHost } from './AsyncQueryBus'
@@ -55,16 +55,17 @@ export class PubSubBridge<TParams extends PubSubBridgeParams = PubSubBridgeParam
55
55
  }
56
56
 
57
57
  async exposeHandler(id: ModuleIdentifier, options?: BridgeExposeOptions | undefined): Promise<ModuleInstance[]> {
58
- const { maxDepth = 2, direction = 'all' } = options ?? {}
59
- const module = assertEx(await super.resolve(id), () => `Expose failed to locate module [${id}]`)
58
+ const { maxDepth = 2, direction = 'all', required = true } = options ?? {}
59
+ const host = assertEx(this.busHost(), () => 'Not configured as a host')
60
+ const module = await host.expose(id, { required })
60
61
  if (module) {
61
- const host = assertEx(this.busHost(), () => 'Not configured as a host')
62
- host.expose(module.address)
63
- const children = await module.resolve('*', { direction, maxDepth, visibility: 'public' })
64
- for (const child of children) {
65
- host.expose(child.address)
66
- }
67
- return [module, ...children]
62
+ const children = maxDepth > 0 ? await module.resolve('*', { direction, maxDepth, visibility: 'public' }) : []
63
+ const exposedChildren = (
64
+ await Promise.all(children.map((child) => this.exposeHandler(child.address, { maxDepth: maxDepth - 1, required: false })))
65
+ )
66
+ .flat()
67
+ .filter(exists)
68
+ return [module, ...exposedChildren]
68
69
  }
69
70
  return []
70
71
  }
@@ -80,17 +81,17 @@ export class PubSubBridge<TParams extends PubSubBridgeParams = PubSubBridgeParam
80
81
  }
81
82
 
82
83
  async unexposeHandler(id: ModuleIdentifier, options?: BridgeUnexposeOptions | undefined): Promise<ModuleInstance[]> {
83
- const { maxDepth = 10, direction } = options ?? {}
84
- const filterOptions: ModuleFilterOptions = { direction }
85
- const module = await super.resolve(id, filterOptions)
84
+ const { maxDepth = 2, direction = 'all', required = true } = options ?? {}
85
+ const host = assertEx(this.busHost(), () => 'Not configured as a host')
86
+ const module = await host.unexpose(id, required)
86
87
  if (module) {
87
- const host = assertEx(this.busHost(), () => 'Not configured as a host')
88
- host.unexpose(module.address)
89
- const children = await module.resolve('*', { direction, maxDepth, visibility: 'public' })
90
- for (const child of children) {
91
- host.unexpose(child.address)
92
- }
93
- return [module, ...children]
88
+ const children = maxDepth > 0 ? await module.resolve('*', { direction, maxDepth, visibility: 'public' }) : []
89
+ const exposedChildren = (
90
+ await Promise.all(children.map((child) => this.unexposeHandler(child.address, { maxDepth: maxDepth - 1, required: false })))
91
+ )
92
+ .flat()
93
+ .filter(exists)
94
+ return [module, ...exposedChildren]
94
95
  }
95
96
  return []
96
97
  }