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