@xyo-network/sentinel 2.84.6 → 2.84.8
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/MemorySentinel.d.cts +3 -0
- package/dist/browser/MemorySentinel.d.cts.map +1 -1
- package/dist/browser/MemorySentinel.d.mts +3 -0
- package/dist/browser/MemorySentinel.d.mts.map +1 -1
- package/dist/browser/MemorySentinel.d.ts +3 -0
- package/dist/browser/MemorySentinel.d.ts.map +1 -1
- package/dist/browser/SentinelIntervalAutomationWrapper.d.cts +11 -1
- package/dist/browser/SentinelIntervalAutomationWrapper.d.cts.map +1 -1
- package/dist/browser/SentinelIntervalAutomationWrapper.d.mts +11 -1
- package/dist/browser/SentinelIntervalAutomationWrapper.d.mts.map +1 -1
- package/dist/browser/SentinelIntervalAutomationWrapper.d.ts +11 -1
- package/dist/browser/SentinelIntervalAutomationWrapper.d.ts.map +1 -1
- package/dist/browser/SentinelRunner.d.cts +1 -2
- package/dist/browser/SentinelRunner.d.cts.map +1 -1
- package/dist/browser/SentinelRunner.d.mts +1 -2
- package/dist/browser/SentinelRunner.d.mts.map +1 -1
- package/dist/browser/SentinelRunner.d.ts +1 -2
- package/dist/browser/SentinelRunner.d.ts.map +1 -1
- package/dist/browser/index.cjs +148 -110
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +0 -1
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +0 -1
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +0 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +143 -103
- package/dist/browser/index.js.map +1 -1
- package/dist/node/MemorySentinel.d.cts +3 -0
- package/dist/node/MemorySentinel.d.cts.map +1 -1
- package/dist/node/MemorySentinel.d.mts +3 -0
- package/dist/node/MemorySentinel.d.mts.map +1 -1
- package/dist/node/MemorySentinel.d.ts +3 -0
- package/dist/node/MemorySentinel.d.ts.map +1 -1
- package/dist/node/SentinelIntervalAutomationWrapper.d.cts +11 -1
- package/dist/node/SentinelIntervalAutomationWrapper.d.cts.map +1 -1
- package/dist/node/SentinelIntervalAutomationWrapper.d.mts +11 -1
- package/dist/node/SentinelIntervalAutomationWrapper.d.mts.map +1 -1
- package/dist/node/SentinelIntervalAutomationWrapper.d.ts +11 -1
- package/dist/node/SentinelIntervalAutomationWrapper.d.ts.map +1 -1
- package/dist/node/SentinelRunner.d.cts +1 -2
- package/dist/node/SentinelRunner.d.cts.map +1 -1
- package/dist/node/SentinelRunner.d.mts +1 -2
- package/dist/node/SentinelRunner.d.mts.map +1 -1
- package/dist/node/SentinelRunner.d.ts +1 -2
- package/dist/node/SentinelRunner.d.ts.map +1 -1
- package/dist/node/index.cjs +150 -114
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +0 -1
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +0 -1
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +0 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +145 -103
- package/dist/node/index.js.map +1 -1
- package/package.json +18 -18
- package/src/MemorySentinel.ts +28 -5
- package/src/SentinelIntervalAutomationWrapper.ts +41 -18
- package/src/SentinelRunner.ts +27 -19
- package/src/Wrapper.ts +2 -2
- package/src/index.ts +0 -1
- package/dist/browser/Automation.d.cts +0 -71
- package/dist/browser/Automation.d.cts.map +0 -1
- package/dist/browser/Automation.d.mts +0 -71
- package/dist/browser/Automation.d.mts.map +0 -1
- package/dist/browser/Automation.d.ts +0 -71
- package/dist/browser/Automation.d.ts.map +0 -1
- package/dist/node/Automation.d.cts +0 -71
- package/dist/node/Automation.d.cts.map +0 -1
- package/dist/node/Automation.d.mts +0 -71
- package/dist/node/Automation.d.mts.map +0 -1
- package/dist/node/Automation.d.ts +0 -71
- package/dist/node/Automation.d.ts.map +0 -1
- package/src/Automation.ts +0 -55
|
@@ -5,7 +5,10 @@ import { SentinelConfig, SentinelInstance, SentinelModuleEventData, SentinelPara
|
|
|
5
5
|
export type MemorySentinelParams<TConfig extends AnyConfigSchema<SentinelConfig> = AnyConfigSchema<SentinelConfig>> = SentinelParams<TConfig>;
|
|
6
6
|
export declare class MemorySentinel<TParams extends MemorySentinelParams = MemorySentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
|
|
7
7
|
static configSchemas: "network.xyo.sentinel.config"[];
|
|
8
|
+
private runner?;
|
|
8
9
|
reportHandler(inPayloads?: Payload[]): Promise<Payload[]>;
|
|
10
|
+
start(timeout?: number | undefined): Promise<boolean>;
|
|
11
|
+
stop(timeout?: number | undefined): Promise<boolean>;
|
|
9
12
|
private generateResults;
|
|
10
13
|
private inputAddresses;
|
|
11
14
|
private processPreviousResults;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemorySentinel.d.ts","sourceRoot":"","sources":["../../src/MemorySentinel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACf,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"MemorySentinel.d.ts","sourceRoot":"","sources":["../../src/MemorySentinel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACf,MAAM,6BAA6B,CAAA;AAKpC,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,eAAe,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;AAE7I,qBAAa,cAAc,CACzB,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,EAC3D,UAAU,SAAS,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAC1H,SAAQ,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7C,OAAgB,aAAa,kCAAyB;IAEtD,OAAO,CAAC,MAAM,CAAC,CAAgB;IAEzB,aAAa,CAAC,UAAU,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAcpD,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAWrD,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;YAQrD,eAAe;YAoCf,cAAc;IAS5B,OAAO,CAAC,sBAAsB;CAG/B"}
|
|
@@ -5,7 +5,10 @@ import { SentinelConfig, SentinelInstance, SentinelModuleEventData, SentinelPara
|
|
|
5
5
|
export type MemorySentinelParams<TConfig extends AnyConfigSchema<SentinelConfig> = AnyConfigSchema<SentinelConfig>> = SentinelParams<TConfig>;
|
|
6
6
|
export declare class MemorySentinel<TParams extends MemorySentinelParams = MemorySentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
|
|
7
7
|
static configSchemas: "network.xyo.sentinel.config"[];
|
|
8
|
+
private runner?;
|
|
8
9
|
reportHandler(inPayloads?: Payload[]): Promise<Payload[]>;
|
|
10
|
+
start(timeout?: number | undefined): Promise<boolean>;
|
|
11
|
+
stop(timeout?: number | undefined): Promise<boolean>;
|
|
9
12
|
private generateResults;
|
|
10
13
|
private inputAddresses;
|
|
11
14
|
private processPreviousResults;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemorySentinel.d.ts","sourceRoot":"","sources":["../../src/MemorySentinel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACf,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"MemorySentinel.d.ts","sourceRoot":"","sources":["../../src/MemorySentinel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACf,MAAM,6BAA6B,CAAA;AAKpC,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,eAAe,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;AAE7I,qBAAa,cAAc,CACzB,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,EAC3D,UAAU,SAAS,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAC1H,SAAQ,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7C,OAAgB,aAAa,kCAAyB;IAEtD,OAAO,CAAC,MAAM,CAAC,CAAgB;IAEzB,aAAa,CAAC,UAAU,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAcpD,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAWrD,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;YAQrD,eAAe;YAoCf,cAAc;IAS5B,OAAO,CAAC,sBAAsB;CAG/B"}
|
|
@@ -5,7 +5,10 @@ import { SentinelConfig, SentinelInstance, SentinelModuleEventData, SentinelPara
|
|
|
5
5
|
export type MemorySentinelParams<TConfig extends AnyConfigSchema<SentinelConfig> = AnyConfigSchema<SentinelConfig>> = SentinelParams<TConfig>;
|
|
6
6
|
export declare class MemorySentinel<TParams extends MemorySentinelParams = MemorySentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
|
|
7
7
|
static configSchemas: "network.xyo.sentinel.config"[];
|
|
8
|
+
private runner?;
|
|
8
9
|
reportHandler(inPayloads?: Payload[]): Promise<Payload[]>;
|
|
10
|
+
start(timeout?: number | undefined): Promise<boolean>;
|
|
11
|
+
stop(timeout?: number | undefined): Promise<boolean>;
|
|
9
12
|
private generateResults;
|
|
10
13
|
private inputAddresses;
|
|
11
14
|
private processPreviousResults;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemorySentinel.d.ts","sourceRoot":"","sources":["../../src/MemorySentinel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACf,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"MemorySentinel.d.ts","sourceRoot":"","sources":["../../src/MemorySentinel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACf,MAAM,6BAA6B,CAAA;AAKpC,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,eAAe,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;AAE7I,qBAAa,cAAc,CACzB,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,EAC3D,UAAU,SAAS,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,uBAAuB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAC1H,SAAQ,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7C,OAAgB,aAAa,kCAAyB;IAEtD,OAAO,CAAC,MAAM,CAAC,CAAgB;IAEzB,aAAa,CAAC,UAAU,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAcpD,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAWrD,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;YAQrD,eAAe;YAoCf,cAAc;IAS5B,OAAO,CAAC,sBAAsB;CAG/B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PayloadWrapper } from '@xyo-network/payload-wrapper';
|
|
2
|
-
import { SentinelIntervalAutomationPayload } from '
|
|
2
|
+
import { SentinelIntervalAutomationPayload } from '@xyo-network/sentinel-model';
|
|
3
3
|
export declare class SentinelIntervalAutomationWrapper<T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload> extends PayloadWrapper<T> {
|
|
4
4
|
constructor(payload: T);
|
|
5
5
|
protected get frequencyMillis(): number;
|
|
@@ -7,5 +7,15 @@ export declare class SentinelIntervalAutomationWrapper<T extends SentinelInterva
|
|
|
7
7
|
next(): this;
|
|
8
8
|
protected checkEnd(): void;
|
|
9
9
|
protected consumeRemaining(count?: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the remaining of the wrapped automation
|
|
12
|
+
* @param remaining The remaining time in milliseconds
|
|
13
|
+
*/
|
|
14
|
+
protected setRemaining(remaining: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the start of the wrapped automation
|
|
17
|
+
* @param start The start time in milliseconds
|
|
18
|
+
*/
|
|
19
|
+
protected setStart(start: number): void;
|
|
10
20
|
}
|
|
11
21
|
//# sourceMappingURL=SentinelIntervalAutomationWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentinelIntervalAutomationWrapper.d.ts","sourceRoot":"","sources":["../../src/SentinelIntervalAutomationWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"SentinelIntervalAutomationWrapper.d.ts","sourceRoot":"","sources":["../../src/SentinelIntervalAutomationWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAA;AAE/E,qBAAa,iCAAiC,CAC5C,CAAC,SAAS,iCAAiC,GAAG,iCAAiC,CAC/E,SAAQ,cAAc,CAAC,CAAC,CAAC;gBACb,OAAO,EAAE,CAAC;IAItB,SAAS,KAAK,eAAe,WAqB5B;IAED,SAAS,KAAK,SAAS,WAEtB;IAED,IAAI;IAWJ,SAAS,CAAC,QAAQ;IAMlB,SAAS,CAAC,gBAAgB,CAAC,KAAK,SAAI;IAMpC;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM;IAIxC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;CAGjC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PayloadWrapper } from '@xyo-network/payload-wrapper';
|
|
2
|
-
import { SentinelIntervalAutomationPayload } from '
|
|
2
|
+
import { SentinelIntervalAutomationPayload } from '@xyo-network/sentinel-model';
|
|
3
3
|
export declare class SentinelIntervalAutomationWrapper<T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload> extends PayloadWrapper<T> {
|
|
4
4
|
constructor(payload: T);
|
|
5
5
|
protected get frequencyMillis(): number;
|
|
@@ -7,5 +7,15 @@ export declare class SentinelIntervalAutomationWrapper<T extends SentinelInterva
|
|
|
7
7
|
next(): this;
|
|
8
8
|
protected checkEnd(): void;
|
|
9
9
|
protected consumeRemaining(count?: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the remaining of the wrapped automation
|
|
12
|
+
* @param remaining The remaining time in milliseconds
|
|
13
|
+
*/
|
|
14
|
+
protected setRemaining(remaining: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the start of the wrapped automation
|
|
17
|
+
* @param start The start time in milliseconds
|
|
18
|
+
*/
|
|
19
|
+
protected setStart(start: number): void;
|
|
10
20
|
}
|
|
11
21
|
//# sourceMappingURL=SentinelIntervalAutomationWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentinelIntervalAutomationWrapper.d.ts","sourceRoot":"","sources":["../../src/SentinelIntervalAutomationWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"SentinelIntervalAutomationWrapper.d.ts","sourceRoot":"","sources":["../../src/SentinelIntervalAutomationWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAA;AAE/E,qBAAa,iCAAiC,CAC5C,CAAC,SAAS,iCAAiC,GAAG,iCAAiC,CAC/E,SAAQ,cAAc,CAAC,CAAC,CAAC;gBACb,OAAO,EAAE,CAAC;IAItB,SAAS,KAAK,eAAe,WAqB5B;IAED,SAAS,KAAK,SAAS,WAEtB;IAED,IAAI;IAWJ,SAAS,CAAC,QAAQ;IAMlB,SAAS,CAAC,gBAAgB,CAAC,KAAK,SAAI;IAMpC;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM;IAIxC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;CAGjC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PayloadWrapper } from '@xyo-network/payload-wrapper';
|
|
2
|
-
import { SentinelIntervalAutomationPayload } from '
|
|
2
|
+
import { SentinelIntervalAutomationPayload } from '@xyo-network/sentinel-model';
|
|
3
3
|
export declare class SentinelIntervalAutomationWrapper<T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload> extends PayloadWrapper<T> {
|
|
4
4
|
constructor(payload: T);
|
|
5
5
|
protected get frequencyMillis(): number;
|
|
@@ -7,5 +7,15 @@ export declare class SentinelIntervalAutomationWrapper<T extends SentinelInterva
|
|
|
7
7
|
next(): this;
|
|
8
8
|
protected checkEnd(): void;
|
|
9
9
|
protected consumeRemaining(count?: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the remaining of the wrapped automation
|
|
12
|
+
* @param remaining The remaining time in milliseconds
|
|
13
|
+
*/
|
|
14
|
+
protected setRemaining(remaining: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the start of the wrapped automation
|
|
17
|
+
* @param start The start time in milliseconds
|
|
18
|
+
*/
|
|
19
|
+
protected setStart(start: number): void;
|
|
10
20
|
}
|
|
11
21
|
//# sourceMappingURL=SentinelIntervalAutomationWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentinelIntervalAutomationWrapper.d.ts","sourceRoot":"","sources":["../../src/SentinelIntervalAutomationWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"SentinelIntervalAutomationWrapper.d.ts","sourceRoot":"","sources":["../../src/SentinelIntervalAutomationWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAA;AAE/E,qBAAa,iCAAiC,CAC5C,CAAC,SAAS,iCAAiC,GAAG,iCAAiC,CAC/E,SAAQ,cAAc,CAAC,CAAC,CAAC;gBACb,OAAO,EAAE,CAAC;IAItB,SAAS,KAAK,eAAe,WAqB5B;IAED,SAAS,KAAK,SAAS,WAEtB;IAED,IAAI;IAWJ,SAAS,CAAC,QAAQ;IAMlB,SAAS,CAAC,gBAAgB,CAAC,KAAK,SAAI;IAMpC;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM;IAIxC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;CAGjC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Payload } from '@xyo-network/payload-model';
|
|
3
|
-
import { SentinelInstance } from '@xyo-network/sentinel-model';
|
|
4
|
-
import { SentinelAutomationPayload } from './Automation';
|
|
3
|
+
import { SentinelAutomationPayload, SentinelInstance } from '@xyo-network/sentinel-model';
|
|
5
4
|
export type OnSentinelRunnerTriggerResult = (result: Payload[]) => void;
|
|
6
5
|
export declare class SentinelRunner {
|
|
7
6
|
protected _automations: Record<string, SentinelAutomationPayload>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentinelRunner.d.ts","sourceRoot":"","sources":["../../src/SentinelRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,
|
|
1
|
+
{"version":3,"file":"SentinelRunner.d.ts","sourceRoot":"","sources":["../../src/SentinelRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAEL,yBAAyB,EACzB,gBAAgB,EAEjB,MAAM,6BAA6B,CAAA;AAIpC,MAAM,MAAM,6BAA6B,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AAEvE,qBAAa,cAAc;IACzB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAK;IACtE,SAAS,CAAC,eAAe,EAAE,6BAA6B,GAAG,SAAS,CAAA;IACpE,SAAS,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACpC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;gBAE1C,QAAQ,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,yBAAyB,EAAE,EAAE,eAAe,CAAC,EAAE,6BAA6B;IAMlI,IAAI,WAAW,8CAEd;IAED,OAAO,KAAK,IAAI,GASf;IAEK,GAAG,CAAC,UAAU,EAAE,yBAAyB,EAAE,OAAO,UAAO;IAO/D,IAAI,CAAC,IAAI,EAAE,MAAM;IAIX,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAO;IAKzC,SAAS;IAKH,OAAO;IAKP,KAAK;IAwBX,IAAI;IAOE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE,OAAO,UAAO;YAMlE,OAAO;CAStB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Payload } from '@xyo-network/payload-model';
|
|
3
|
-
import { SentinelInstance } from '@xyo-network/sentinel-model';
|
|
4
|
-
import { SentinelAutomationPayload } from './Automation';
|
|
3
|
+
import { SentinelAutomationPayload, SentinelInstance } from '@xyo-network/sentinel-model';
|
|
5
4
|
export type OnSentinelRunnerTriggerResult = (result: Payload[]) => void;
|
|
6
5
|
export declare class SentinelRunner {
|
|
7
6
|
protected _automations: Record<string, SentinelAutomationPayload>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentinelRunner.d.ts","sourceRoot":"","sources":["../../src/SentinelRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,
|
|
1
|
+
{"version":3,"file":"SentinelRunner.d.ts","sourceRoot":"","sources":["../../src/SentinelRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAEL,yBAAyB,EACzB,gBAAgB,EAEjB,MAAM,6BAA6B,CAAA;AAIpC,MAAM,MAAM,6BAA6B,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AAEvE,qBAAa,cAAc;IACzB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAK;IACtE,SAAS,CAAC,eAAe,EAAE,6BAA6B,GAAG,SAAS,CAAA;IACpE,SAAS,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACpC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;gBAE1C,QAAQ,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,yBAAyB,EAAE,EAAE,eAAe,CAAC,EAAE,6BAA6B;IAMlI,IAAI,WAAW,8CAEd;IAED,OAAO,KAAK,IAAI,GASf;IAEK,GAAG,CAAC,UAAU,EAAE,yBAAyB,EAAE,OAAO,UAAO;IAO/D,IAAI,CAAC,IAAI,EAAE,MAAM;IAIX,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAO;IAKzC,SAAS;IAKH,OAAO;IAKP,KAAK;IAwBX,IAAI;IAOE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE,OAAO,UAAO;YAMlE,OAAO;CAStB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Payload } from '@xyo-network/payload-model';
|
|
3
|
-
import { SentinelInstance } from '@xyo-network/sentinel-model';
|
|
4
|
-
import { SentinelAutomationPayload } from './Automation';
|
|
3
|
+
import { SentinelAutomationPayload, SentinelInstance } from '@xyo-network/sentinel-model';
|
|
5
4
|
export type OnSentinelRunnerTriggerResult = (result: Payload[]) => void;
|
|
6
5
|
export declare class SentinelRunner {
|
|
7
6
|
protected _automations: Record<string, SentinelAutomationPayload>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentinelRunner.d.ts","sourceRoot":"","sources":["../../src/SentinelRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,
|
|
1
|
+
{"version":3,"file":"SentinelRunner.d.ts","sourceRoot":"","sources":["../../src/SentinelRunner.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAEL,yBAAyB,EACzB,gBAAgB,EAEjB,MAAM,6BAA6B,CAAA;AAIpC,MAAM,MAAM,6BAA6B,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AAEvE,qBAAa,cAAc;IACzB,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAK;IACtE,SAAS,CAAC,eAAe,EAAE,6BAA6B,GAAG,SAAS,CAAA;IACpE,SAAS,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACpC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;gBAE1C,QAAQ,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,yBAAyB,EAAE,EAAE,eAAe,CAAC,EAAE,6BAA6B;IAMlI,IAAI,WAAW,8CAEd;IAED,OAAO,KAAK,IAAI,GASf;IAEK,GAAG,CAAC,UAAU,EAAE,yBAAyB,EAAE,OAAO,UAAO;IAO/D,IAAI,CAAC,IAAI,EAAE,MAAM;IAIX,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAO;IAKzC,SAAS;IAKH,OAAO;IAKP,KAAK;IAwBX,IAAI;IAOE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE,OAAO,UAAO;YAMlE,OAAO;CAStB"}
|
package/dist/browser/index.cjs
CHANGED
|
@@ -22,85 +22,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
24
|
MemorySentinel: () => MemorySentinel,
|
|
25
|
-
SentinelAutomationSchema: () => SentinelAutomationSchema,
|
|
26
|
-
SentinelEventAutomationSchema: () => SentinelEventAutomationSchema,
|
|
27
|
-
SentinelIntervalAutomationSchema: () => SentinelIntervalAutomationSchema,
|
|
28
25
|
SentinelIntervalAutomationWrapper: () => SentinelIntervalAutomationWrapper,
|
|
29
26
|
SentinelRunner: () => SentinelRunner,
|
|
30
|
-
SentinelWrapper: () => SentinelWrapper
|
|
31
|
-
isSentinelIntervalAutomation: () => isSentinelIntervalAutomation
|
|
27
|
+
SentinelWrapper: () => SentinelWrapper
|
|
32
28
|
});
|
|
33
29
|
module.exports = __toCommonJS(src_exports);
|
|
34
30
|
|
|
35
|
-
// src/Automation.ts
|
|
36
|
-
var import_payload_model = require("@xyo-network/payload-model");
|
|
37
|
-
var SentinelAutomationSchema = "network.xyo.automation";
|
|
38
|
-
var SentinelIntervalAutomationSchema = "network.xyo.automation.interval";
|
|
39
|
-
var SentinelEventAutomationSchema = "network.xyo.automation.event";
|
|
40
|
-
var isSentinelIntervalAutomation = (0, import_payload_model.isPayloadOfSchemaType)(SentinelIntervalAutomationSchema);
|
|
41
|
-
|
|
42
31
|
// src/MemorySentinel.ts
|
|
43
32
|
var import_promise = require("@xylabs/promise");
|
|
44
33
|
var import_diviner_model = require("@xyo-network/diviner-model");
|
|
45
34
|
var import_sentinel_abstract = require("@xyo-network/sentinel-abstract");
|
|
46
|
-
var
|
|
35
|
+
var import_sentinel_model2 = require("@xyo-network/sentinel-model");
|
|
47
36
|
var import_witness_model = require("@xyo-network/witness-model");
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
let index = 0;
|
|
54
|
-
let previousResults = {};
|
|
55
|
-
while (index < job.tasks.length) {
|
|
56
|
-
const generatedPayloads = await this.generateResults(job.tasks[index], previousResults, inPayloads);
|
|
57
|
-
previousResults = generatedPayloads;
|
|
58
|
-
index++;
|
|
59
|
-
}
|
|
60
|
-
return Object.values(previousResults).flat();
|
|
61
|
-
}
|
|
62
|
-
async generateResults(tasks, previousResults, inPayloads) {
|
|
63
|
-
const results = await Promise.allSettled(
|
|
64
|
-
tasks?.map(async (task) => {
|
|
65
|
-
const witness = (0, import_witness_model.asWitnessInstance)(task.module);
|
|
66
|
-
const input = task.input ?? false;
|
|
67
|
-
const inPayloadsFound = input === true ? inPayloads : input === false ? [] : this.processPreviousResults(previousResults, await this.inputAddresses(input));
|
|
68
|
-
if (witness) {
|
|
69
|
-
return [witness.address, await witness.observe(inPayloadsFound)];
|
|
70
|
-
}
|
|
71
|
-
const diviner = (0, import_diviner_model.asDivinerInstance)(task.module);
|
|
72
|
-
if (diviner) {
|
|
73
|
-
return [diviner.address, await diviner.divine(inPayloadsFound)];
|
|
74
|
-
}
|
|
75
|
-
throw Error("Unsupported module type");
|
|
76
|
-
})
|
|
77
|
-
);
|
|
78
|
-
const finalResult = {};
|
|
79
|
-
results.filter(import_promise.fulfilled).forEach((result) => {
|
|
80
|
-
const [address, payloads] = result.value;
|
|
81
|
-
finalResult[address] = finalResult[address] ?? [];
|
|
82
|
-
finalResult[address].push(...payloads);
|
|
83
|
-
});
|
|
84
|
-
if (this.throwErrors) {
|
|
85
|
-
const errors = results.filter(import_promise.rejected).map((result) => result.reason);
|
|
86
|
-
if (errors.length > 0) {
|
|
87
|
-
throw Error("At least one module failed");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return finalResult;
|
|
91
|
-
}
|
|
92
|
-
async inputAddresses(input) {
|
|
93
|
-
if (Array.isArray(input)) {
|
|
94
|
-
return (await Promise.all(input.map(async (inputItem) => await this.inputAddresses(inputItem)))).flat();
|
|
95
|
-
} else {
|
|
96
|
-
const resolved = await this.resolve(input);
|
|
97
|
-
return resolved ? [resolved.address] : [];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
processPreviousResults(payloads, inputs) {
|
|
101
|
-
return inputs.map((input) => payloads[input] ?? []).flat();
|
|
102
|
-
}
|
|
103
|
-
};
|
|
37
|
+
|
|
38
|
+
// src/SentinelRunner.ts
|
|
39
|
+
var import_assert = require("@xylabs/assert");
|
|
40
|
+
var import_payload_wrapper2 = require("@xyo-network/payload-wrapper");
|
|
41
|
+
var import_sentinel_model = require("@xyo-network/sentinel-model");
|
|
104
42
|
|
|
105
43
|
// src/SentinelIntervalAutomationWrapper.ts
|
|
106
44
|
var import_payload_wrapper = require("@xyo-network/payload-wrapper");
|
|
@@ -111,44 +49,67 @@ var SentinelIntervalAutomationWrapper = class extends import_payload_wrapper.Pay
|
|
|
111
49
|
get frequencyMillis() {
|
|
112
50
|
const frequency = this.jsonPayload().frequency;
|
|
113
51
|
if (frequency === void 0)
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
52
|
+
return Number.POSITIVE_INFINITY;
|
|
53
|
+
const frequencyUnits = this.jsonPayload().frequencyUnits;
|
|
54
|
+
switch (frequencyUnits ?? "hour") {
|
|
55
|
+
case "second": {
|
|
117
56
|
return frequency * 1e3;
|
|
118
|
-
|
|
57
|
+
}
|
|
58
|
+
case "minute": {
|
|
119
59
|
return frequency * 60 * 1e3;
|
|
120
|
-
|
|
60
|
+
}
|
|
61
|
+
case "hour": {
|
|
121
62
|
return frequency * 60 * 60 * 1e3;
|
|
122
|
-
|
|
63
|
+
}
|
|
64
|
+
case "day": {
|
|
123
65
|
return frequency * 24 * 60 * 60 * 1e3;
|
|
66
|
+
}
|
|
67
|
+
default: {
|
|
68
|
+
return Number.POSITIVE_INFINITY;
|
|
69
|
+
}
|
|
124
70
|
}
|
|
125
71
|
}
|
|
126
72
|
get remaining() {
|
|
127
|
-
return this.
|
|
73
|
+
return this.jsonPayload().remaining ?? Number.POSITIVE_INFINITY;
|
|
128
74
|
}
|
|
129
75
|
next() {
|
|
130
|
-
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
const previousStart = this.jsonPayload()?.start ?? now;
|
|
78
|
+
const start = Math.max(previousStart, now);
|
|
79
|
+
const nextStart = start + this.frequencyMillis;
|
|
80
|
+
this.setStart(nextStart);
|
|
131
81
|
this.consumeRemaining();
|
|
132
82
|
this.checkEnd();
|
|
133
83
|
return this;
|
|
134
84
|
}
|
|
135
85
|
checkEnd() {
|
|
136
|
-
if (this.jsonPayload().start > (this.jsonPayload().end ??
|
|
137
|
-
this.
|
|
86
|
+
if (this.jsonPayload().start > (this.jsonPayload().end ?? Number.POSITIVE_INFINITY)) {
|
|
87
|
+
this.setStart(Number.POSITIVE_INFINITY);
|
|
138
88
|
}
|
|
139
89
|
}
|
|
140
90
|
consumeRemaining(count = 1) {
|
|
141
|
-
const remaining = this.remaining - count;
|
|
142
|
-
this.
|
|
143
|
-
if (remaining <= 0)
|
|
144
|
-
this.
|
|
145
|
-
|
|
91
|
+
const remaining = Math.max(this.remaining - count, 0);
|
|
92
|
+
this.setRemaining(remaining);
|
|
93
|
+
if (remaining <= 0)
|
|
94
|
+
this.setStart(Number.POSITIVE_INFINITY);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Sets the remaining of the wrapped automation
|
|
98
|
+
* @param remaining The remaining time in milliseconds
|
|
99
|
+
*/
|
|
100
|
+
setRemaining(remaining) {
|
|
101
|
+
this.obj.remaining = remaining;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Sets the start of the wrapped automation
|
|
105
|
+
* @param start The start time in milliseconds
|
|
106
|
+
*/
|
|
107
|
+
setStart(start) {
|
|
108
|
+
this.obj.start = start;
|
|
146
109
|
}
|
|
147
110
|
};
|
|
148
111
|
|
|
149
112
|
// src/SentinelRunner.ts
|
|
150
|
-
var import_assert = require("@xylabs/assert");
|
|
151
|
-
var import_payload_wrapper2 = require("@xyo-network/payload-wrapper");
|
|
152
113
|
var SentinelRunner = class {
|
|
153
114
|
_automations = {};
|
|
154
115
|
onTriggerResult;
|
|
@@ -157,17 +118,17 @@ var SentinelRunner = class {
|
|
|
157
118
|
constructor(sentinel, automations, onTriggerResult) {
|
|
158
119
|
this.sentinel = sentinel;
|
|
159
120
|
this.onTriggerResult = onTriggerResult;
|
|
160
|
-
|
|
121
|
+
if (automations)
|
|
122
|
+
for (const automation of automations)
|
|
123
|
+
this.add(automation);
|
|
161
124
|
}
|
|
162
125
|
get automations() {
|
|
163
126
|
return this._automations;
|
|
164
127
|
}
|
|
165
128
|
get next() {
|
|
166
129
|
return Object.values(this._automations).reduce((previous, current) => {
|
|
167
|
-
if (isSentinelIntervalAutomation(current)) {
|
|
168
|
-
|
|
169
|
-
return current.start < (previous?.start ?? Infinity) ? current : previous;
|
|
170
|
-
}
|
|
130
|
+
if ((0, import_sentinel_model.isSentinelIntervalAutomation)(current) && (0, import_sentinel_model.isSentinelIntervalAutomation)(previous)) {
|
|
131
|
+
return current.start < (previous?.start ?? Number.POSITIVE_INFINITY) ? current : previous;
|
|
171
132
|
}
|
|
172
133
|
return current;
|
|
173
134
|
}, void 0);
|
|
@@ -196,20 +157,22 @@ var SentinelRunner = class {
|
|
|
196
157
|
await this.start();
|
|
197
158
|
}
|
|
198
159
|
async start() {
|
|
160
|
+
await Promise.resolve();
|
|
199
161
|
(0, import_assert.assertEx)(this.timeoutId === void 0, "Already started");
|
|
200
162
|
const automation = this.next;
|
|
201
|
-
if (isSentinelIntervalAutomation(automation)) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this.timeoutId = setTimeout(
|
|
207
|
-
|
|
208
|
-
this.
|
|
163
|
+
if ((0, import_sentinel_model.isSentinelIntervalAutomation)(automation)) {
|
|
164
|
+
const now = Date.now();
|
|
165
|
+
const start = Math.max(automation.start ?? now, now);
|
|
166
|
+
const delay = Math.max(start - now, 0);
|
|
167
|
+
if (delay < Number.POSITIVE_INFINITY) {
|
|
168
|
+
this.timeoutId = setTimeout(async () => {
|
|
169
|
+
try {
|
|
170
|
+
await this.trigger(automation);
|
|
171
|
+
this.stop();
|
|
172
|
+
} finally {
|
|
209
173
|
await this.start();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
);
|
|
174
|
+
}
|
|
175
|
+
}, delay);
|
|
213
176
|
}
|
|
214
177
|
}
|
|
215
178
|
}
|
|
@@ -232,28 +195,103 @@ var SentinelRunner = class {
|
|
|
232
195
|
await this.add(wrapper.jsonPayload(), false);
|
|
233
196
|
const triggerResult = await this.sentinel.report();
|
|
234
197
|
this.onTriggerResult?.(triggerResult);
|
|
235
|
-
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// src/MemorySentinel.ts
|
|
202
|
+
var MemorySentinel = class extends import_sentinel_abstract.AbstractSentinel {
|
|
203
|
+
static configSchemas = [import_sentinel_model2.SentinelConfigSchema];
|
|
204
|
+
runner;
|
|
205
|
+
async reportHandler(inPayloads = []) {
|
|
206
|
+
await this.started("throw");
|
|
207
|
+
const job = await this.jobPromise;
|
|
208
|
+
let index = 0;
|
|
209
|
+
let previousResults = {};
|
|
210
|
+
while (index < job.tasks.length) {
|
|
211
|
+
const generatedPayloads = await this.generateResults(job.tasks[index], previousResults, inPayloads);
|
|
212
|
+
previousResults = generatedPayloads;
|
|
213
|
+
index++;
|
|
214
|
+
}
|
|
215
|
+
return Object.values(previousResults).flat();
|
|
216
|
+
}
|
|
217
|
+
async start(timeout) {
|
|
218
|
+
if (await super.start(timeout)) {
|
|
219
|
+
if ((this.config.automations?.length ?? 0) > 0) {
|
|
220
|
+
this.runner = new SentinelRunner(this, this.config.automations);
|
|
221
|
+
await this.runner.start();
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
async stop(timeout) {
|
|
228
|
+
if (this.runner) {
|
|
229
|
+
this.runner.stop();
|
|
230
|
+
this.runner = void 0;
|
|
231
|
+
}
|
|
232
|
+
return await super.stop(timeout);
|
|
233
|
+
}
|
|
234
|
+
async generateResults(tasks, previousResults, inPayloads) {
|
|
235
|
+
const results = await Promise.allSettled(
|
|
236
|
+
tasks?.map(async (task) => {
|
|
237
|
+
const witness = (0, import_witness_model.asWitnessInstance)(task.module);
|
|
238
|
+
const input = task.input ?? false;
|
|
239
|
+
const inPayloadsFound = input === true ? inPayloads : input === false ? [] : this.processPreviousResults(previousResults, await this.inputAddresses(input));
|
|
240
|
+
if (witness) {
|
|
241
|
+
return [witness.address, await witness.observe(inPayloadsFound)];
|
|
242
|
+
}
|
|
243
|
+
const diviner = (0, import_diviner_model.asDivinerInstance)(task.module);
|
|
244
|
+
if (diviner) {
|
|
245
|
+
return [diviner.address, await diviner.divine(inPayloadsFound)];
|
|
246
|
+
}
|
|
247
|
+
throw new Error("Unsupported module type");
|
|
248
|
+
})
|
|
249
|
+
);
|
|
250
|
+
const finalResult = {};
|
|
251
|
+
for (const result of results.filter(import_promise.fulfilled)) {
|
|
252
|
+
const [address, payloads] = result.value;
|
|
253
|
+
finalResult[address] = finalResult[address] ?? [];
|
|
254
|
+
finalResult[address].push(...payloads);
|
|
255
|
+
}
|
|
256
|
+
if (this.throwErrors) {
|
|
257
|
+
const errors = results.filter(import_promise.rejected).map((result) => result.reason);
|
|
258
|
+
if (errors.length > 0) {
|
|
259
|
+
throw new Error("At least one module failed");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return finalResult;
|
|
263
|
+
}
|
|
264
|
+
async inputAddresses(input) {
|
|
265
|
+
if (Array.isArray(input)) {
|
|
266
|
+
return (await Promise.all(input.map(async (inputItem) => await this.inputAddresses(inputItem)))).flat();
|
|
267
|
+
} else {
|
|
268
|
+
const resolved = await this.resolve(input);
|
|
269
|
+
return resolved ? [resolved.address] : [];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
processPreviousResults(payloads, inputs) {
|
|
273
|
+
return inputs.flatMap((input) => payloads[input] ?? []);
|
|
236
274
|
}
|
|
237
275
|
};
|
|
238
276
|
|
|
239
277
|
// src/Wrapper.ts
|
|
240
278
|
var import_module_wrapper = require("@xyo-network/module-wrapper");
|
|
241
|
-
var
|
|
279
|
+
var import_sentinel_model3 = require("@xyo-network/sentinel-model");
|
|
242
280
|
(0, import_module_wrapper.constructableModuleWrapper)();
|
|
243
281
|
var SentinelWrapper = class extends import_module_wrapper.ModuleWrapper {
|
|
244
|
-
static instanceIdentityCheck =
|
|
245
|
-
static moduleIdentityCheck =
|
|
246
|
-
static requiredQueries = [
|
|
282
|
+
static instanceIdentityCheck = import_sentinel_model3.isSentinelInstance;
|
|
283
|
+
static moduleIdentityCheck = import_sentinel_model3.isSentinelModule;
|
|
284
|
+
static requiredQueries = [import_sentinel_model3.SentinelReportQuerySchema, ...super.requiredQueries];
|
|
247
285
|
archivists() {
|
|
248
|
-
throw Error("Not supported");
|
|
286
|
+
throw new Error("Not supported");
|
|
249
287
|
}
|
|
250
288
|
async report(payloads) {
|
|
251
|
-
const queryPayload = { schema:
|
|
289
|
+
const queryPayload = { schema: import_sentinel_model3.SentinelReportQuerySchema };
|
|
252
290
|
const result = await this.sendQuery(queryPayload, payloads);
|
|
253
291
|
return result;
|
|
254
292
|
}
|
|
255
293
|
witnesses() {
|
|
256
|
-
throw Error("Not supported");
|
|
294
|
+
throw new Error("Not supported");
|
|
257
295
|
}
|
|
258
296
|
};
|
|
259
297
|
|