@xyo-network/sentinel 2.66.9 → 2.67.0-rc.2
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/cjs/AbstractSentinel.js +3 -14
- package/dist/cjs/AbstractSentinel.js.map +1 -1
- package/dist/cjs/MemorySentinel.js +10 -4
- package/dist/cjs/MemorySentinel.js.map +1 -1
- package/dist/cjs/Wrapper.js +1 -2
- package/dist/cjs/Wrapper.js.map +1 -1
- package/dist/cjs/typeChecks.js +5 -4
- package/dist/cjs/typeChecks.js.map +1 -1
- package/dist/esm/AbstractSentinel.js +5 -11
- package/dist/esm/AbstractSentinel.js.map +1 -1
- package/dist/esm/MemorySentinel.js +11 -5
- package/dist/esm/MemorySentinel.js.map +1 -1
- package/dist/esm/Wrapper.js +1 -2
- package/dist/esm/Wrapper.js.map +1 -1
- package/dist/esm/typeChecks.js +6 -5
- package/dist/esm/typeChecks.js.map +1 -1
- package/dist/types/AbstractSentinel.d.ts +5 -7
- package/dist/types/AbstractSentinel.d.ts.map +1 -1
- package/dist/types/MemorySentinel.d.ts +1 -1
- package/dist/types/MemorySentinel.d.ts.map +1 -1
- package/dist/types/SentinelModel.d.ts +2 -2
- package/dist/types/SentinelModel.d.ts.map +1 -1
- package/dist/types/Wrapper.d.ts +3 -3
- package/dist/types/Wrapper.d.ts.map +1 -1
- package/dist/types/typeChecks.d.ts +5 -5
- package/dist/types/typeChecks.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/AbstractSentinel.ts +8 -16
- package/src/MemorySentinel.ts +12 -6
- package/src/SentinelModel.ts +2 -2
- package/src/Wrapper.ts +6 -4
- package/src/typeChecks.ts +6 -5
- package/dist/docs.json +0 -68058
package/src/MemorySentinel.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { fulfilled } from '@xylabs/promise'
|
|
2
|
+
import { fulfilled, rejected } from '@xylabs/promise'
|
|
3
3
|
import { Account } from '@xyo-network/account'
|
|
4
4
|
import { QueryBoundWitness, QueryBoundWitnessWrapper } from '@xyo-network/boundwitness-builder'
|
|
5
5
|
import { handleError, handleErrorAsync } from '@xyo-network/error'
|
|
6
6
|
import { AnyConfigSchema, ModuleConfig, ModuleErrorBuilder, ModuleQueryResult } from '@xyo-network/module'
|
|
7
7
|
import { ModuleError, Payload } from '@xyo-network/payload-model'
|
|
8
|
-
import {
|
|
9
|
-
import compact from 'lodash/compact'
|
|
8
|
+
import { WitnessInstance } from '@xyo-network/witness'
|
|
10
9
|
|
|
11
10
|
import { AbstractSentinel } from './AbstractSentinel'
|
|
12
11
|
import { SentinelConfig, SentinelConfigSchema } from './Config'
|
|
@@ -34,9 +33,10 @@ export class MemorySentinel<
|
|
|
34
33
|
const resultPayloads: Payload[] = []
|
|
35
34
|
|
|
36
35
|
try {
|
|
37
|
-
const generatedPayloads =
|
|
36
|
+
const [generatedPayloads, generatedErrors] = await this.generateResults(allWitnesses)
|
|
38
37
|
const combinedPayloads = [...generatedPayloads, ...payloads]
|
|
39
38
|
resultPayloads.push(...combinedPayloads)
|
|
39
|
+
errors.push(...generatedErrors)
|
|
40
40
|
} catch (ex) {
|
|
41
41
|
handleError(ex, (error) => {
|
|
42
42
|
errors.push(error)
|
|
@@ -84,10 +84,16 @@ export class MemorySentinel<
|
|
|
84
84
|
return (await this.bindQueryResult(queryPayload, resultPayloads, [queryAccount], errorPayloads))[0]
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
private async
|
|
88
|
-
|
|
87
|
+
private async generateResults(witnesses: WitnessInstance[]): Promise<[Payload[], Error[]]> {
|
|
88
|
+
const results = await Promise.allSettled(witnesses?.map((witness) => witness.observe()))
|
|
89
|
+
const payloads = results
|
|
89
90
|
.filter(fulfilled)
|
|
90
91
|
.map((result) => result.value)
|
|
91
92
|
.flat()
|
|
93
|
+
const errors = results
|
|
94
|
+
.filter(rejected)
|
|
95
|
+
.map((result) => result.reason)
|
|
96
|
+
.flat()
|
|
97
|
+
return [payloads, errors]
|
|
92
98
|
}
|
|
93
99
|
}
|
package/src/SentinelModel.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
2
2
|
import { AnyObject } from '@xyo-network/core'
|
|
3
|
-
import { AnyConfigSchema, EventData, Module, ModuleEventArgs, ModuleEventData, ModuleParams } from '@xyo-network/module'
|
|
3
|
+
import { AnyConfigSchema, EventData, Module, ModuleEventArgs, ModuleEventData, ModuleInstance, ModuleParams } from '@xyo-network/module'
|
|
4
4
|
import { Payload } from '@xyo-network/payload-model'
|
|
5
5
|
import { Promisable } from '@xyo-network/promise'
|
|
6
6
|
|
|
@@ -50,4 +50,4 @@ export type SentinelModule<
|
|
|
50
50
|
export type SentinelInstance<
|
|
51
51
|
TParams extends SentinelParams = SentinelParams,
|
|
52
52
|
TEventData extends SentinelModuleEventData = SentinelModuleEventData,
|
|
53
|
-
> = SentinelModule<TParams, TEventData> & Sentinel
|
|
53
|
+
> = SentinelModule<TParams, TEventData> & ModuleInstance & Sentinel
|
package/src/Wrapper.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { constructableModuleWrapper, ModuleWrapper } from '@xyo-network/module'
|
|
2
2
|
import { Payload } from '@xyo-network/payload-model'
|
|
3
|
-
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
4
3
|
|
|
5
4
|
import { SentinelReportQuery, SentinelReportQuerySchema } from './Queries'
|
|
6
|
-
import { SentinelModule } from './SentinelModel'
|
|
5
|
+
import { SentinelInstance, SentinelModule } from './SentinelModel'
|
|
7
6
|
import { isSentinelInstance, isSentinelModule } from './typeChecks'
|
|
8
7
|
|
|
9
8
|
constructableModuleWrapper()
|
|
10
|
-
export class SentinelWrapper<TModule extends SentinelModule = SentinelModule>
|
|
9
|
+
export class SentinelWrapper<TModule extends SentinelModule = SentinelModule>
|
|
10
|
+
extends ModuleWrapper<TModule>
|
|
11
|
+
implements SentinelInstance<TModule['params']>
|
|
12
|
+
{
|
|
11
13
|
static override instanceIdentityCheck = isSentinelInstance
|
|
12
14
|
static override moduleIdentityCheck = isSentinelModule
|
|
13
15
|
static override requiredQueries = [SentinelReportQuerySchema, ...super.requiredQueries]
|
|
14
16
|
|
|
15
17
|
async report(payloads?: Payload[]): Promise<Payload[]> {
|
|
16
|
-
const queryPayload =
|
|
18
|
+
const queryPayload: SentinelReportQuery = { schema: SentinelReportQuerySchema }
|
|
17
19
|
const result = await this.sendQuery(queryPayload, payloads)
|
|
18
20
|
return result
|
|
19
21
|
}
|
package/src/typeChecks.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IsInstanceFactory, IsModuleFactory, isModuleInstance, WithFactory } from '@xyo-network/module-model'
|
|
2
|
+
import { AsObjectFactory } from '@xyo-network/object-identity'
|
|
2
3
|
|
|
3
4
|
import { SentinelReportQuerySchema } from './Queries'
|
|
4
5
|
import { SentinelInstance, SentinelModule } from './SentinelModel'
|
|
5
6
|
|
|
6
|
-
export const isSentinelInstance = IsInstanceFactory
|
|
7
|
-
export const isSentinelModule = IsModuleFactory
|
|
7
|
+
export const isSentinelInstance = new IsInstanceFactory<SentinelInstance>().create({ report: 'function' }, [isModuleInstance])
|
|
8
|
+
export const isSentinelModule = new IsModuleFactory<SentinelModule>().create([SentinelReportQuerySchema])
|
|
8
9
|
|
|
9
|
-
export const asSentinelModule =
|
|
10
|
-
export const asSentinelInstance =
|
|
10
|
+
export const asSentinelModule = AsObjectFactory.create(isSentinelModule)
|
|
11
|
+
export const asSentinelInstance = AsObjectFactory.create(isSentinelInstance)
|
|
11
12
|
export const withSentinelModule = WithFactory.create(isSentinelModule)
|
|
12
13
|
export const withSentinelInstance = WithFactory.create(isSentinelInstance)
|