@xyo-network/bridge-pub-sub 2.94.11 → 2.94.13
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 +66 -6
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts +66 -6
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts +66 -6
- package/dist/browser/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts +1 -1
- package/dist/browser/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
- package/dist/browser/PubSubBridgeModuleResolver.d.cts +3 -3
- package/dist/browser/PubSubBridgeModuleResolver.d.cts.map +1 -1
- package/dist/browser/PubSubBridgeModuleResolver.d.mts +3 -3
- package/dist/browser/PubSubBridgeModuleResolver.d.mts.map +1 -1
- package/dist/browser/PubSubBridgeModuleResolver.d.ts +3 -3
- package/dist/browser/PubSubBridgeModuleResolver.d.ts.map +1 -1
- package/dist/browser/index.cjs +135 -93
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +135 -93
- package/dist/browser/index.js.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts +66 -6
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts +66 -6
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts +66 -6
- package/dist/node/AsyncQueryBus/AsyncQueryBusBase.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusClient.d.ts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.cts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.mts.map +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts +1 -1
- package/dist/node/AsyncQueryBus/AsyncQueryBusHost.d.ts.map +1 -1
- package/dist/node/PubSubBridgeModuleResolver.d.cts +3 -3
- package/dist/node/PubSubBridgeModuleResolver.d.cts.map +1 -1
- package/dist/node/PubSubBridgeModuleResolver.d.mts +3 -3
- package/dist/node/PubSubBridgeModuleResolver.d.mts.map +1 -1
- package/dist/node/PubSubBridgeModuleResolver.d.ts +3 -3
- package/dist/node/PubSubBridgeModuleResolver.d.ts.map +1 -1
- package/dist/node/index.cjs +141 -122
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +141 -122
- package/dist/node/index.js.map +1 -1
- package/package.json +18 -17
- package/src/AsyncQueryBus/AsyncQueryBusBase.ts +69 -40
- package/src/AsyncQueryBus/AsyncQueryBusClient.ts +24 -26
- package/src/AsyncQueryBus/AsyncQueryBusHost.ts +20 -19
- package/src/PubSubBridgeModuleResolver.ts +5 -5
|
@@ -141,24 +141,25 @@ export class AsyncQueryBusHost<TParams extends AsyncQueryBusHostParams = AsyncQu
|
|
|
141
141
|
* @param address The address to find commands for
|
|
142
142
|
*/
|
|
143
143
|
protected findQueriesToAddress = async (address: Address) => {
|
|
144
|
-
const queryBoundWitnessDiviner =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
144
|
+
const queryBoundWitnessDiviner = await this.queriesDiviner()
|
|
145
|
+
if (queryBoundWitnessDiviner) {
|
|
146
|
+
// Retrieve last offset from state store
|
|
147
|
+
const timestamp = await this.retrieveState(address)
|
|
148
|
+
const destination = [address]
|
|
149
|
+
const limit = this.perAddressBatchQueryLimit
|
|
150
|
+
// Filter for commands to us by destination address
|
|
151
|
+
const divinerQuery = { destination, limit, schema: BoundWitnessDivinerQuerySchema, sort: 'asc', timestamp }
|
|
152
|
+
const result = await queryBoundWitnessDiviner.divine([divinerQuery])
|
|
153
|
+
const queries = result.filter(isQueryBoundWitnessWithMeta)
|
|
154
|
+
const nextState = queries.length > 0 ? Math.max(...queries.map((c) => c.timestamp ?? 0)) + 1 : timestamp
|
|
155
|
+
// TODO: This needs to be thought through as we can't use a distributed timestamp
|
|
156
|
+
// because of collisions. We need to use the timestamp of the store so there's no
|
|
157
|
+
// chance of multiple commands at the same time
|
|
158
|
+
await this.commitState(address, nextState)
|
|
159
|
+
return queries
|
|
160
|
+
} else {
|
|
161
|
+
this.logger?.warn(`Unable to resolve queryBoundWitnessDiviner [${this.config?.intersect?.queries?.boundWitnessDiviner}]`)
|
|
162
|
+
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
/**
|
|
@@ -193,7 +194,7 @@ export class AsyncQueryBusHost<TParams extends AsyncQueryBusHostParams = AsyncQu
|
|
|
193
194
|
try {
|
|
194
195
|
const localModuleName = localModule.config.name ?? localModule.address
|
|
195
196
|
this.logger?.debug(`Checking for inbound queries to ${localModuleName} [${localModule.address}]`)
|
|
196
|
-
const queries = await this.findQueriesToAddress(localModule.address)
|
|
197
|
+
const queries = (await this.findQueriesToAddress(localModule.address)) ?? []
|
|
197
198
|
if (queries.length === 0) return
|
|
198
199
|
this.logger?.debug(`Found queries addressed to local module: ${localModuleName}`)
|
|
199
200
|
for (const query of queries) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { Address, isAddress } from '@xylabs/hex'
|
|
3
|
-
import { AbstractBridgeModuleResolver,
|
|
3
|
+
import { AbstractBridgeModuleResolver, BridgeModuleResolverParams, wrapModuleWithType } from '@xyo-network/abstract-bridge'
|
|
4
4
|
import { Account } from '@xyo-network/account'
|
|
5
5
|
import { ConfigPayload, ConfigSchema } from '@xyo-network/config-payload-plugin'
|
|
6
6
|
import { asModuleInstance, ModuleConfig, ModuleConfigSchema, ModuleFilterOptions, ModuleIdentifier, ModuleInstance } from '@xyo-network/module-model'
|
|
7
7
|
|
|
8
8
|
import { AsyncQueryBusClient, AsyncQueryBusModuleProxy, AsyncQueryBusModuleProxyParams } from './AsyncQueryBus'
|
|
9
9
|
|
|
10
|
-
export interface
|
|
10
|
+
export interface PubSubBridgeModuleResolverParams extends BridgeModuleResolverParams {
|
|
11
11
|
busClient: AsyncQueryBusClient
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export class PubSubBridgeModuleResolver extends AbstractBridgeModuleResolver<
|
|
14
|
+
export class PubSubBridgeModuleResolver extends AbstractBridgeModuleResolver<PubSubBridgeModuleResolverParams> {
|
|
15
15
|
override async resolveHandler<T extends ModuleInstance = ModuleInstance>(
|
|
16
16
|
id: ModuleIdentifier,
|
|
17
17
|
options?: ModuleFilterOptions<T>,
|
|
@@ -27,9 +27,9 @@ export class PubSubBridgeModuleResolver extends AbstractBridgeModuleResolver<Pub
|
|
|
27
27
|
const account = Account.randomSync()
|
|
28
28
|
const params: AsyncQueryBusModuleProxyParams = {
|
|
29
29
|
account,
|
|
30
|
-
busClient: this.
|
|
30
|
+
busClient: this.params.busClient,
|
|
31
31
|
config: { schema: ModuleConfigSchema },
|
|
32
|
-
host: this.
|
|
32
|
+
host: this.params.bridge,
|
|
33
33
|
moduleAddress: firstPart as Address,
|
|
34
34
|
}
|
|
35
35
|
const proxy = new AsyncQueryBusModuleProxy<T, AsyncQueryBusModuleProxyParams>(params)
|