@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.
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts +7 -68
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +7 -68
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +7 -68
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts +24 -3
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts +24 -3
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts +24 -3
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
- package/dist/browser/PubSubBridge.d.cts.map +1 -1
- package/dist/browser/PubSubBridge.d.mts.map +1 -1
- package/dist/browser/PubSubBridge.d.ts.map +1 -1
- package/dist/browser/index.cjs +106 -132
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +103 -129
- package/dist/browser/index.js.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +7 -68
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +7 -68
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +7 -68
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts +24 -3
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts +24 -3
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts +24 -3
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
- package/dist/node/PubSubBridge.d.cts.map +1 -1
- package/dist/node/PubSubBridge.d.mts.map +1 -1
- package/dist/node/PubSubBridge.d.ts.map +1 -1
- package/dist/node/index.cjs +111 -136
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +108 -133
- package/dist/node/index.js.map +1 -1
- package/package.json +19 -18
- package/src/AsyncQueryBus/AsyncQueryBusBase.ts +59 -89
- package/src/AsyncQueryBus/AsyncQueryBusHost.ts +29 -14
- package/src/PubSubBridge.ts +21 -20
package/src/PubSubBridge.ts
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return [module, ...
|
|
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 =
|
|
84
|
-
const
|
|
85
|
-
const module = await
|
|
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
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return [module, ...
|
|
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
|
}
|