@xyo-network/sentinel 2.85.4 → 2.85.6

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.
Files changed (74) hide show
  1. package/dist/browser/index.cjs +1 -283
  2. package/dist/browser/index.cjs.map +1 -1
  3. package/dist/browser/index.d.cts +1 -4
  4. package/dist/browser/index.d.cts.map +1 -1
  5. package/dist/browser/index.d.mts +1 -4
  6. package/dist/browser/index.d.mts.map +1 -1
  7. package/dist/browser/index.d.ts +1 -4
  8. package/dist/browser/index.d.ts.map +1 -1
  9. package/dist/browser/index.js +1 -286
  10. package/dist/browser/index.js.map +1 -1
  11. package/dist/node/index.cjs +2 -290
  12. package/dist/node/index.cjs.map +1 -1
  13. package/dist/node/index.d.cts +1 -4
  14. package/dist/node/index.d.cts.map +1 -1
  15. package/dist/node/index.d.mts +1 -4
  16. package/dist/node/index.d.mts.map +1 -1
  17. package/dist/node/index.d.ts +1 -4
  18. package/dist/node/index.d.ts.map +1 -1
  19. package/dist/node/index.js +1 -289
  20. package/dist/node/index.js.map +1 -1
  21. package/package.json +4 -21
  22. package/src/index.ts +1 -4
  23. package/dist/browser/MemorySentinel.d.cts +0 -16
  24. package/dist/browser/MemorySentinel.d.cts.map +0 -1
  25. package/dist/browser/MemorySentinel.d.mts +0 -16
  26. package/dist/browser/MemorySentinel.d.mts.map +0 -1
  27. package/dist/browser/MemorySentinel.d.ts +0 -16
  28. package/dist/browser/MemorySentinel.d.ts.map +0 -1
  29. package/dist/browser/SentinelIntervalAutomationWrapper.d.cts +0 -21
  30. package/dist/browser/SentinelIntervalAutomationWrapper.d.cts.map +0 -1
  31. package/dist/browser/SentinelIntervalAutomationWrapper.d.mts +0 -21
  32. package/dist/browser/SentinelIntervalAutomationWrapper.d.mts.map +0 -1
  33. package/dist/browser/SentinelIntervalAutomationWrapper.d.ts +0 -21
  34. package/dist/browser/SentinelIntervalAutomationWrapper.d.ts.map +0 -1
  35. package/dist/browser/SentinelRunner.d.cts +0 -23
  36. package/dist/browser/SentinelRunner.d.cts.map +0 -1
  37. package/dist/browser/SentinelRunner.d.mts +0 -23
  38. package/dist/browser/SentinelRunner.d.mts.map +0 -1
  39. package/dist/browser/SentinelRunner.d.ts +0 -23
  40. package/dist/browser/SentinelRunner.d.ts.map +0 -1
  41. package/dist/browser/Wrapper.d.cts +0 -14
  42. package/dist/browser/Wrapper.d.cts.map +0 -1
  43. package/dist/browser/Wrapper.d.mts +0 -14
  44. package/dist/browser/Wrapper.d.mts.map +0 -1
  45. package/dist/browser/Wrapper.d.ts +0 -14
  46. package/dist/browser/Wrapper.d.ts.map +0 -1
  47. package/dist/node/MemorySentinel.d.cts +0 -16
  48. package/dist/node/MemorySentinel.d.cts.map +0 -1
  49. package/dist/node/MemorySentinel.d.mts +0 -16
  50. package/dist/node/MemorySentinel.d.mts.map +0 -1
  51. package/dist/node/MemorySentinel.d.ts +0 -16
  52. package/dist/node/MemorySentinel.d.ts.map +0 -1
  53. package/dist/node/SentinelIntervalAutomationWrapper.d.cts +0 -21
  54. package/dist/node/SentinelIntervalAutomationWrapper.d.cts.map +0 -1
  55. package/dist/node/SentinelIntervalAutomationWrapper.d.mts +0 -21
  56. package/dist/node/SentinelIntervalAutomationWrapper.d.mts.map +0 -1
  57. package/dist/node/SentinelIntervalAutomationWrapper.d.ts +0 -21
  58. package/dist/node/SentinelIntervalAutomationWrapper.d.ts.map +0 -1
  59. package/dist/node/SentinelRunner.d.cts +0 -23
  60. package/dist/node/SentinelRunner.d.cts.map +0 -1
  61. package/dist/node/SentinelRunner.d.mts +0 -23
  62. package/dist/node/SentinelRunner.d.mts.map +0 -1
  63. package/dist/node/SentinelRunner.d.ts +0 -23
  64. package/dist/node/SentinelRunner.d.ts.map +0 -1
  65. package/dist/node/Wrapper.d.cts +0 -14
  66. package/dist/node/Wrapper.d.cts.map +0 -1
  67. package/dist/node/Wrapper.d.mts +0 -14
  68. package/dist/node/Wrapper.d.mts.map +0 -1
  69. package/dist/node/Wrapper.d.ts +0 -14
  70. package/dist/node/Wrapper.d.ts.map +0 -1
  71. package/src/MemorySentinel.ts +0 -115
  72. package/src/SentinelIntervalAutomationWrapper.ts +0 -76
  73. package/src/SentinelRunner.ts +0 -114
  74. package/src/Wrapper.ts +0 -36
@@ -1,14 +0,0 @@
1
- import { ArchivistInstance } from '@xyo-network/archivist';
2
- import { ModuleWrapper } from '@xyo-network/module-wrapper';
3
- import { Payload } from '@xyo-network/payload-model';
4
- import { SentinelInstance, SentinelModule } from '@xyo-network/sentinel-model';
5
- import { WitnessInstance } from '@xyo-network/witness-model';
6
- export declare class SentinelWrapper<TModule extends SentinelModule = SentinelModule> extends ModuleWrapper<TModule> implements SentinelInstance<TModule['params']> {
7
- static instanceIdentityCheck: import("@xyo-network/object").TypeCheck<SentinelInstance>;
8
- static moduleIdentityCheck: import("@xyo-network/module-model").ModuleTypeCheck<SentinelModule>;
9
- static requiredQueries: string[];
10
- archivists(): Promise<ArchivistInstance[]>;
11
- report(payloads?: Payload[]): Promise<Payload[]>;
12
- witnesses(): Promise<WitnessInstance[]>;
13
- }
14
- //# sourceMappingURL=Wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Wrapper.d.ts","sourceRoot":"","sources":["../../src/Wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAA8B,aAAa,EAAE,MAAM,6BAA6B,CAAA;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAGL,gBAAgB,EAChB,cAAc,EAGf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,qBAAa,eAAe,CAAC,OAAO,SAAS,cAAc,GAAG,cAAc,CAC1E,SAAQ,aAAa,CAAC,OAAO,CAC7B,YAAW,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAgB,qBAAqB,4DAAqB;IAC1D,OAAgB,mBAAmB,sEAAmB;IACtD,OAAgB,eAAe,WAAwD;IAEvF,UAAU,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMtD,SAAS,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAGxC"}
@@ -1,14 +0,0 @@
1
- import { ArchivistInstance } from '@xyo-network/archivist';
2
- import { ModuleWrapper } from '@xyo-network/module-wrapper';
3
- import { Payload } from '@xyo-network/payload-model';
4
- import { SentinelInstance, SentinelModule } from '@xyo-network/sentinel-model';
5
- import { WitnessInstance } from '@xyo-network/witness-model';
6
- export declare class SentinelWrapper<TModule extends SentinelModule = SentinelModule> extends ModuleWrapper<TModule> implements SentinelInstance<TModule['params']> {
7
- static instanceIdentityCheck: import("@xyo-network/object").TypeCheck<SentinelInstance>;
8
- static moduleIdentityCheck: import("@xyo-network/module-model").ModuleTypeCheck<SentinelModule>;
9
- static requiredQueries: string[];
10
- archivists(): Promise<ArchivistInstance[]>;
11
- report(payloads?: Payload[]): Promise<Payload[]>;
12
- witnesses(): Promise<WitnessInstance[]>;
13
- }
14
- //# sourceMappingURL=Wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Wrapper.d.ts","sourceRoot":"","sources":["../../src/Wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAA8B,aAAa,EAAE,MAAM,6BAA6B,CAAA;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAGL,gBAAgB,EAChB,cAAc,EAGf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,qBAAa,eAAe,CAAC,OAAO,SAAS,cAAc,GAAG,cAAc,CAC1E,SAAQ,aAAa,CAAC,OAAO,CAC7B,YAAW,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAgB,qBAAqB,4DAAqB;IAC1D,OAAgB,mBAAmB,sEAAmB;IACtD,OAAgB,eAAe,WAAwD;IAEvF,UAAU,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMtD,SAAS,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAGxC"}
@@ -1,16 +0,0 @@
1
- import { AnyConfigSchema } from '@xyo-network/module-model';
2
- import { Payload } from '@xyo-network/payload-model';
3
- import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
4
- import { SentinelConfig, SentinelInstance, SentinelModuleEventData, SentinelParams } from '@xyo-network/sentinel-model';
5
- export type MemorySentinelParams<TConfig extends AnyConfigSchema<SentinelConfig> = AnyConfigSchema<SentinelConfig>> = SentinelParams<TConfig>;
6
- export declare class MemorySentinel<TParams extends MemorySentinelParams = MemorySentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
7
- static configSchemas: string[];
8
- private runner?;
9
- reportHandler(inPayloads?: Payload[]): Promise<Payload[]>;
10
- start(timeout?: number | undefined): Promise<boolean>;
11
- stop(timeout?: number | undefined): Promise<boolean>;
12
- private generateResults;
13
- private inputAddresses;
14
- private processPreviousResults;
15
- }
16
- //# sourceMappingURL=MemorySentinel.d.ts.map
@@ -1 +0,0 @@
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,EAGL,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,WAAyB;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;YAwCf,cAAc;IAS5B,OAAO,CAAC,sBAAsB;CAG/B"}
@@ -1,16 +0,0 @@
1
- import { AnyConfigSchema } from '@xyo-network/module-model';
2
- import { Payload } from '@xyo-network/payload-model';
3
- import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
4
- import { SentinelConfig, SentinelInstance, SentinelModuleEventData, SentinelParams } from '@xyo-network/sentinel-model';
5
- export type MemorySentinelParams<TConfig extends AnyConfigSchema<SentinelConfig> = AnyConfigSchema<SentinelConfig>> = SentinelParams<TConfig>;
6
- export declare class MemorySentinel<TParams extends MemorySentinelParams = MemorySentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
7
- static configSchemas: string[];
8
- private runner?;
9
- reportHandler(inPayloads?: Payload[]): Promise<Payload[]>;
10
- start(timeout?: number | undefined): Promise<boolean>;
11
- stop(timeout?: number | undefined): Promise<boolean>;
12
- private generateResults;
13
- private inputAddresses;
14
- private processPreviousResults;
15
- }
16
- //# sourceMappingURL=MemorySentinel.d.ts.map
@@ -1 +0,0 @@
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,EAGL,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,WAAyB;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;YAwCf,cAAc;IAS5B,OAAO,CAAC,sBAAsB;CAG/B"}
@@ -1,16 +0,0 @@
1
- import { AnyConfigSchema } from '@xyo-network/module-model';
2
- import { Payload } from '@xyo-network/payload-model';
3
- import { AbstractSentinel } from '@xyo-network/sentinel-abstract';
4
- import { SentinelConfig, SentinelInstance, SentinelModuleEventData, SentinelParams } from '@xyo-network/sentinel-model';
5
- export type MemorySentinelParams<TConfig extends AnyConfigSchema<SentinelConfig> = AnyConfigSchema<SentinelConfig>> = SentinelParams<TConfig>;
6
- export declare class MemorySentinel<TParams extends MemorySentinelParams = MemorySentinelParams, TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>> extends AbstractSentinel<TParams, TEventData> {
7
- static configSchemas: string[];
8
- private runner?;
9
- reportHandler(inPayloads?: Payload[]): Promise<Payload[]>;
10
- start(timeout?: number | undefined): Promise<boolean>;
11
- stop(timeout?: number | undefined): Promise<boolean>;
12
- private generateResults;
13
- private inputAddresses;
14
- private processPreviousResults;
15
- }
16
- //# sourceMappingURL=MemorySentinel.d.ts.map
@@ -1 +0,0 @@
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,EAGL,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,WAAyB;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;YAwCf,cAAc;IAS5B,OAAO,CAAC,sBAAsB;CAG/B"}
@@ -1,21 +0,0 @@
1
- import { PayloadWrapper } from '@xyo-network/payload-wrapper';
2
- import { SentinelIntervalAutomationPayload } from '@xyo-network/sentinel-model';
3
- export declare class SentinelIntervalAutomationWrapper<T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload> extends PayloadWrapper<T> {
4
- constructor(payload: T);
5
- protected get frequencyMillis(): number;
6
- protected get remaining(): number;
7
- next(): this;
8
- protected checkEnd(): void;
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;
20
- }
21
- //# sourceMappingURL=SentinelIntervalAutomationWrapper.d.ts.map
@@ -1 +0,0 @@
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,21 +0,0 @@
1
- import { PayloadWrapper } from '@xyo-network/payload-wrapper';
2
- import { SentinelIntervalAutomationPayload } from '@xyo-network/sentinel-model';
3
- export declare class SentinelIntervalAutomationWrapper<T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload> extends PayloadWrapper<T> {
4
- constructor(payload: T);
5
- protected get frequencyMillis(): number;
6
- protected get remaining(): number;
7
- next(): this;
8
- protected checkEnd(): void;
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;
20
- }
21
- //# sourceMappingURL=SentinelIntervalAutomationWrapper.d.ts.map
@@ -1 +0,0 @@
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,21 +0,0 @@
1
- import { PayloadWrapper } from '@xyo-network/payload-wrapper';
2
- import { SentinelIntervalAutomationPayload } from '@xyo-network/sentinel-model';
3
- export declare class SentinelIntervalAutomationWrapper<T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload> extends PayloadWrapper<T> {
4
- constructor(payload: T);
5
- protected get frequencyMillis(): number;
6
- protected get remaining(): number;
7
- next(): this;
8
- protected checkEnd(): void;
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;
20
- }
21
- //# sourceMappingURL=SentinelIntervalAutomationWrapper.d.ts.map
@@ -1 +0,0 @@
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,23 +0,0 @@
1
- /// <reference types="node" />
2
- import { Payload } from '@xyo-network/payload-model';
3
- import { SentinelAutomationPayload, SentinelInstance } from '@xyo-network/sentinel-model';
4
- export type OnSentinelRunnerTriggerResult = (result: Payload[]) => void;
5
- export declare class SentinelRunner {
6
- protected _automations: Record<string, SentinelAutomationPayload>;
7
- protected onTriggerResult: OnSentinelRunnerTriggerResult | undefined;
8
- protected sentinel: SentinelInstance;
9
- protected timeoutId?: NodeJS.Timeout | string | number;
10
- constructor(sentinel: SentinelInstance, automations?: SentinelAutomationPayload[], onTriggerResult?: OnSentinelRunnerTriggerResult);
11
- get automations(): Record<string, SentinelAutomationPayload>;
12
- private get next();
13
- add(automation: SentinelAutomationPayload, restart?: boolean): Promise<string>;
14
- find(hash: string): void;
15
- remove(hash: string, restart?: boolean): Promise<void>;
16
- removeAll(): void;
17
- restart(): Promise<void>;
18
- start(): Promise<void>;
19
- stop(): void;
20
- update(hash: string, automation: SentinelAutomationPayload, restart?: boolean): Promise<void>;
21
- private trigger;
22
- }
23
- //# sourceMappingURL=SentinelRunner.d.ts.map
@@ -1 +0,0 @@
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,23 +0,0 @@
1
- /// <reference types="node" />
2
- import { Payload } from '@xyo-network/payload-model';
3
- import { SentinelAutomationPayload, SentinelInstance } from '@xyo-network/sentinel-model';
4
- export type OnSentinelRunnerTriggerResult = (result: Payload[]) => void;
5
- export declare class SentinelRunner {
6
- protected _automations: Record<string, SentinelAutomationPayload>;
7
- protected onTriggerResult: OnSentinelRunnerTriggerResult | undefined;
8
- protected sentinel: SentinelInstance;
9
- protected timeoutId?: NodeJS.Timeout | string | number;
10
- constructor(sentinel: SentinelInstance, automations?: SentinelAutomationPayload[], onTriggerResult?: OnSentinelRunnerTriggerResult);
11
- get automations(): Record<string, SentinelAutomationPayload>;
12
- private get next();
13
- add(automation: SentinelAutomationPayload, restart?: boolean): Promise<string>;
14
- find(hash: string): void;
15
- remove(hash: string, restart?: boolean): Promise<void>;
16
- removeAll(): void;
17
- restart(): Promise<void>;
18
- start(): Promise<void>;
19
- stop(): void;
20
- update(hash: string, automation: SentinelAutomationPayload, restart?: boolean): Promise<void>;
21
- private trigger;
22
- }
23
- //# sourceMappingURL=SentinelRunner.d.ts.map
@@ -1 +0,0 @@
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,23 +0,0 @@
1
- /// <reference types="node" />
2
- import { Payload } from '@xyo-network/payload-model';
3
- import { SentinelAutomationPayload, SentinelInstance } from '@xyo-network/sentinel-model';
4
- export type OnSentinelRunnerTriggerResult = (result: Payload[]) => void;
5
- export declare class SentinelRunner {
6
- protected _automations: Record<string, SentinelAutomationPayload>;
7
- protected onTriggerResult: OnSentinelRunnerTriggerResult | undefined;
8
- protected sentinel: SentinelInstance;
9
- protected timeoutId?: NodeJS.Timeout | string | number;
10
- constructor(sentinel: SentinelInstance, automations?: SentinelAutomationPayload[], onTriggerResult?: OnSentinelRunnerTriggerResult);
11
- get automations(): Record<string, SentinelAutomationPayload>;
12
- private get next();
13
- add(automation: SentinelAutomationPayload, restart?: boolean): Promise<string>;
14
- find(hash: string): void;
15
- remove(hash: string, restart?: boolean): Promise<void>;
16
- removeAll(): void;
17
- restart(): Promise<void>;
18
- start(): Promise<void>;
19
- stop(): void;
20
- update(hash: string, automation: SentinelAutomationPayload, restart?: boolean): Promise<void>;
21
- private trigger;
22
- }
23
- //# sourceMappingURL=SentinelRunner.d.ts.map
@@ -1 +0,0 @@
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,14 +0,0 @@
1
- import { ArchivistInstance } from '@xyo-network/archivist';
2
- import { ModuleWrapper } from '@xyo-network/module-wrapper';
3
- import { Payload } from '@xyo-network/payload-model';
4
- import { SentinelInstance, SentinelModule } from '@xyo-network/sentinel-model';
5
- import { WitnessInstance } from '@xyo-network/witness-model';
6
- export declare class SentinelWrapper<TModule extends SentinelModule = SentinelModule> extends ModuleWrapper<TModule> implements SentinelInstance<TModule['params']> {
7
- static instanceIdentityCheck: import("@xyo-network/object").TypeCheck<SentinelInstance>;
8
- static moduleIdentityCheck: import("@xyo-network/module-model").ModuleTypeCheck<SentinelModule>;
9
- static requiredQueries: string[];
10
- archivists(): Promise<ArchivistInstance[]>;
11
- report(payloads?: Payload[]): Promise<Payload[]>;
12
- witnesses(): Promise<WitnessInstance[]>;
13
- }
14
- //# sourceMappingURL=Wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Wrapper.d.ts","sourceRoot":"","sources":["../../src/Wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAA8B,aAAa,EAAE,MAAM,6BAA6B,CAAA;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAGL,gBAAgB,EAChB,cAAc,EAGf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,qBAAa,eAAe,CAAC,OAAO,SAAS,cAAc,GAAG,cAAc,CAC1E,SAAQ,aAAa,CAAC,OAAO,CAC7B,YAAW,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAgB,qBAAqB,4DAAqB;IAC1D,OAAgB,mBAAmB,sEAAmB;IACtD,OAAgB,eAAe,WAAwD;IAEvF,UAAU,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMtD,SAAS,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAGxC"}
@@ -1,14 +0,0 @@
1
- import { ArchivistInstance } from '@xyo-network/archivist';
2
- import { ModuleWrapper } from '@xyo-network/module-wrapper';
3
- import { Payload } from '@xyo-network/payload-model';
4
- import { SentinelInstance, SentinelModule } from '@xyo-network/sentinel-model';
5
- import { WitnessInstance } from '@xyo-network/witness-model';
6
- export declare class SentinelWrapper<TModule extends SentinelModule = SentinelModule> extends ModuleWrapper<TModule> implements SentinelInstance<TModule['params']> {
7
- static instanceIdentityCheck: import("@xyo-network/object").TypeCheck<SentinelInstance>;
8
- static moduleIdentityCheck: import("@xyo-network/module-model").ModuleTypeCheck<SentinelModule>;
9
- static requiredQueries: string[];
10
- archivists(): Promise<ArchivistInstance[]>;
11
- report(payloads?: Payload[]): Promise<Payload[]>;
12
- witnesses(): Promise<WitnessInstance[]>;
13
- }
14
- //# sourceMappingURL=Wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Wrapper.d.ts","sourceRoot":"","sources":["../../src/Wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAA8B,aAAa,EAAE,MAAM,6BAA6B,CAAA;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAGL,gBAAgB,EAChB,cAAc,EAGf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,qBAAa,eAAe,CAAC,OAAO,SAAS,cAAc,GAAG,cAAc,CAC1E,SAAQ,aAAa,CAAC,OAAO,CAC7B,YAAW,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAgB,qBAAqB,4DAAqB;IAC1D,OAAgB,mBAAmB,sEAAmB;IACtD,OAAgB,eAAe,WAAwD;IAEvF,UAAU,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMtD,SAAS,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAGxC"}
@@ -1,14 +0,0 @@
1
- import { ArchivistInstance } from '@xyo-network/archivist';
2
- import { ModuleWrapper } from '@xyo-network/module-wrapper';
3
- import { Payload } from '@xyo-network/payload-model';
4
- import { SentinelInstance, SentinelModule } from '@xyo-network/sentinel-model';
5
- import { WitnessInstance } from '@xyo-network/witness-model';
6
- export declare class SentinelWrapper<TModule extends SentinelModule = SentinelModule> extends ModuleWrapper<TModule> implements SentinelInstance<TModule['params']> {
7
- static instanceIdentityCheck: import("@xyo-network/object").TypeCheck<SentinelInstance>;
8
- static moduleIdentityCheck: import("@xyo-network/module-model").ModuleTypeCheck<SentinelModule>;
9
- static requiredQueries: string[];
10
- archivists(): Promise<ArchivistInstance[]>;
11
- report(payloads?: Payload[]): Promise<Payload[]>;
12
- witnesses(): Promise<WitnessInstance[]>;
13
- }
14
- //# sourceMappingURL=Wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Wrapper.d.ts","sourceRoot":"","sources":["../../src/Wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAA8B,aAAa,EAAE,MAAM,6BAA6B,CAAA;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAGL,gBAAgB,EAChB,cAAc,EAGf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAG5D,qBAAa,eAAe,CAAC,OAAO,SAAS,cAAc,GAAG,cAAc,CAC1E,SAAQ,aAAa,CAAC,OAAO,CAC7B,YAAW,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAgB,qBAAqB,4DAAqB;IAC1D,OAAgB,mBAAmB,sEAAmB;IACtD,OAAgB,eAAe,WAAwD;IAEvF,UAAU,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAMtD,SAAS,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAGxC"}
@@ -1,115 +0,0 @@
1
- import { Address } from '@xylabs/hex'
2
- import { fulfilled, rejected } from '@xylabs/promise'
3
- import { asDivinerInstance } from '@xyo-network/diviner-model'
4
- import { AnyConfigSchema } from '@xyo-network/module-model'
5
- import { Payload } from '@xyo-network/payload-model'
6
- import { AbstractSentinel } from '@xyo-network/sentinel-abstract'
7
- import {
8
- asSentinelInstance,
9
- ResolvedTask,
10
- SentinelConfig,
11
- SentinelConfigSchema,
12
- SentinelInstance,
13
- SentinelModuleEventData,
14
- SentinelParams,
15
- } from '@xyo-network/sentinel-model'
16
- import { asWitnessInstance } from '@xyo-network/witness-model'
17
-
18
- import { SentinelRunner } from './SentinelRunner'
19
-
20
- export type MemorySentinelParams<TConfig extends AnyConfigSchema<SentinelConfig> = AnyConfigSchema<SentinelConfig>> = SentinelParams<TConfig>
21
-
22
- export class MemorySentinel<
23
- TParams extends MemorySentinelParams = MemorySentinelParams,
24
- TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>,
25
- > extends AbstractSentinel<TParams, TEventData> {
26
- static override configSchemas = [SentinelConfigSchema]
27
-
28
- private runner?: SentinelRunner
29
-
30
- async reportHandler(inPayloads: Payload[] = []): Promise<Payload[]> {
31
- await this.started('throw')
32
- const job = await this.jobPromise
33
-
34
- let index = 0
35
- let previousResults: Record<Address, Payload[]> = {}
36
- while (index < job.tasks.length) {
37
- const generatedPayloads = await this.generateResults(job.tasks[index], previousResults, inPayloads)
38
- previousResults = generatedPayloads
39
- index++
40
- }
41
- return Object.values(previousResults).flat()
42
- }
43
-
44
- override async start(timeout?: number | undefined): Promise<boolean> {
45
- if (await super.start(timeout)) {
46
- if ((this.config.automations?.length ?? 0) > 0) {
47
- this.runner = new SentinelRunner(this, this.config.automations)
48
- await this.runner.start()
49
- }
50
- return true
51
- }
52
- return false
53
- }
54
-
55
- override async stop(timeout?: number | undefined): Promise<boolean> {
56
- if (this.runner) {
57
- this.runner.stop()
58
- this.runner = undefined
59
- }
60
- return await super.stop(timeout)
61
- }
62
-
63
- private async generateResults(
64
- tasks: ResolvedTask[],
65
- previousResults: Record<Address, Payload[]>,
66
- inPayloads?: Payload[],
67
- ): Promise<Record<Address, Payload[]>> {
68
- const results: PromiseSettledResult<[Address, Payload[]]>[] = await Promise.allSettled(
69
- tasks?.map(async (task) => {
70
- const input = task.input ?? false
71
- const inPayloadsFound =
72
- input === true ? inPayloads : input === false ? [] : this.processPreviousResults(previousResults, await this.inputAddresses(input))
73
- const witness = asWitnessInstance(task.module)
74
- if (witness) {
75
- return [witness.address, await witness.observe(inPayloadsFound)]
76
- }
77
- const diviner = asDivinerInstance(task.module)
78
- if (diviner) {
79
- return [diviner.address, await diviner.divine(inPayloadsFound)]
80
- }
81
- const sentinel = asSentinelInstance(task.module)
82
- if (sentinel) {
83
- return [sentinel.address, await sentinel.report(inPayloadsFound)]
84
- }
85
- throw new Error('Unsupported module type')
86
- }),
87
- )
88
- const finalResult: Record<Address, Payload[]> = {}
89
- for (const result of results.filter(fulfilled)) {
90
- const [address, payloads] = result.value
91
- finalResult[address] = finalResult[address] ?? []
92
- finalResult[address].push(...payloads)
93
- }
94
- if (this.throwErrors) {
95
- const errors = results.filter(rejected).map((result) => result.reason)
96
- if (errors.length > 0) {
97
- throw new Error('At least one module failed')
98
- }
99
- }
100
- return finalResult
101
- }
102
-
103
- private async inputAddresses(input: string | string[]): Promise<string[]> {
104
- if (Array.isArray(input)) {
105
- return (await Promise.all(input.map(async (inputItem) => await this.inputAddresses(inputItem)))).flat()
106
- } else {
107
- const resolved = await this.resolve(input)
108
- return resolved ? [resolved.address] : []
109
- }
110
- }
111
-
112
- private processPreviousResults(payloads: Record<string, Payload[]>, inputs: string[]) {
113
- return inputs.flatMap((input) => payloads[input] ?? [])
114
- }
115
- }
@@ -1,76 +0,0 @@
1
- import { PayloadWrapper } from '@xyo-network/payload-wrapper'
2
- import { SentinelIntervalAutomationPayload } from '@xyo-network/sentinel-model'
3
-
4
- export class SentinelIntervalAutomationWrapper<
5
- T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload,
6
- > extends PayloadWrapper<T> {
7
- constructor(payload: T) {
8
- super(payload)
9
- }
10
-
11
- protected get frequencyMillis() {
12
- const frequency = this.jsonPayload().frequency
13
- if (frequency === undefined) return Number.POSITIVE_INFINITY
14
- const frequencyUnits = this.jsonPayload().frequencyUnits
15
- switch (frequencyUnits ?? 'hour') {
16
- case 'second': {
17
- return frequency * 1000
18
- }
19
- case 'minute': {
20
- return frequency * 60 * 1000
21
- }
22
- case 'hour': {
23
- return frequency * 60 * 60 * 1000
24
- }
25
- case 'day': {
26
- return frequency * 24 * 60 * 60 * 1000
27
- }
28
- default: {
29
- return Number.POSITIVE_INFINITY
30
- }
31
- }
32
- }
33
-
34
- protected get remaining() {
35
- return this.jsonPayload().remaining ?? Number.POSITIVE_INFINITY
36
- }
37
-
38
- next() {
39
- const now = Date.now()
40
- const previousStart = this.jsonPayload()?.start ?? now
41
- const start = Math.max(previousStart, now)
42
- const nextStart = start + this.frequencyMillis
43
- this.setStart(nextStart)
44
- this.consumeRemaining()
45
- this.checkEnd()
46
- return this
47
- }
48
-
49
- protected checkEnd() {
50
- if (this.jsonPayload().start > (this.jsonPayload().end ?? Number.POSITIVE_INFINITY)) {
51
- this.setStart(Number.POSITIVE_INFINITY)
52
- }
53
- }
54
-
55
- protected consumeRemaining(count = 1) {
56
- const remaining = Math.max(this.remaining - count, 0)
57
- this.setRemaining(remaining)
58
- if (remaining <= 0) this.setStart(Number.POSITIVE_INFINITY)
59
- }
60
-
61
- /**
62
- * Sets the remaining of the wrapped automation
63
- * @param remaining The remaining time in milliseconds
64
- */
65
- protected setRemaining(remaining: number) {
66
- this.obj.remaining = remaining
67
- }
68
-
69
- /**
70
- * Sets the start of the wrapped automation
71
- * @param start The start time in milliseconds
72
- */
73
- protected setStart(start: number) {
74
- this.obj.start = start
75
- }
76
- }
@@ -1,114 +0,0 @@
1
- import { assertEx } from '@xylabs/assert'
2
- import { Payload } from '@xyo-network/payload-model'
3
- import { PayloadWrapper } from '@xyo-network/payload-wrapper'
4
- import {
5
- isSentinelIntervalAutomation,
6
- SentinelAutomationPayload,
7
- SentinelInstance,
8
- SentinelIntervalAutomationPayload,
9
- } from '@xyo-network/sentinel-model'
10
-
11
- import { SentinelIntervalAutomationWrapper } from './SentinelIntervalAutomationWrapper'
12
-
13
- export type OnSentinelRunnerTriggerResult = (result: Payload[]) => void
14
-
15
- export class SentinelRunner {
16
- protected _automations: Record<string, SentinelAutomationPayload> = {}
17
- protected onTriggerResult: OnSentinelRunnerTriggerResult | undefined
18
- protected sentinel: SentinelInstance
19
- protected timeoutId?: NodeJS.Timeout | string | number
20
-
21
- constructor(sentinel: SentinelInstance, automations?: SentinelAutomationPayload[], onTriggerResult?: OnSentinelRunnerTriggerResult) {
22
- this.sentinel = sentinel
23
- this.onTriggerResult = onTriggerResult
24
- if (automations) for (const automation of automations) this.add(automation)
25
- }
26
-
27
- get automations() {
28
- return this._automations
29
- }
30
-
31
- private get next() {
32
- // eslint-disable-next-line unicorn/no-array-reduce
33
- return Object.values(this._automations).reduce<SentinelAutomationPayload | undefined>((previous, current) => {
34
- if (isSentinelIntervalAutomation(current) && isSentinelIntervalAutomation(previous)) {
35
- return current.start < (previous?.start ?? Number.POSITIVE_INFINITY) ? current : previous
36
- }
37
- return current
38
- // eslint-disable-next-line unicorn/no-useless-undefined
39
- }, undefined)
40
- }
41
-
42
- async add(automation: SentinelAutomationPayload, restart = true) {
43
- const hash = await PayloadWrapper.hashAsync(automation)
44
- this._automations[hash] = automation
45
- if (restart) await this.restart()
46
- return hash
47
- }
48
-
49
- find(hash: string) {
50
- Object.entries(this._automations).find(([key]) => key === hash)
51
- }
52
-
53
- async remove(hash: string, restart = true) {
54
- delete this._automations[hash]
55
- if (restart) await this.restart()
56
- }
57
-
58
- removeAll() {
59
- this.stop()
60
- this._automations = {}
61
- }
62
-
63
- async restart() {
64
- this.stop()
65
- await this.start()
66
- }
67
-
68
- async start() {
69
- // NOTE: Keep async to match module start signature
70
- await Promise.resolve()
71
- assertEx(this.timeoutId === undefined, 'Already started')
72
- const automation = this.next
73
- if (isSentinelIntervalAutomation(automation)) {
74
- const now = Date.now()
75
- const start = Math.max(automation.start ?? now, now)
76
- const delay = Math.max(start - now, 0)
77
- if (delay < Number.POSITIVE_INFINITY) {
78
- this.timeoutId = setTimeout(async () => {
79
- try {
80
- // Run the automation
81
- await this.trigger(automation)
82
- this.stop()
83
- } finally {
84
- // No matter what start the next automation
85
- await this.start()
86
- }
87
- }, delay)
88
- }
89
- }
90
- }
91
-
92
- stop() {
93
- if (this.timeoutId) {
94
- clearTimeout(this.timeoutId)
95
- this.timeoutId = undefined
96
- }
97
- }
98
-
99
- async update(hash: string, automation: SentinelAutomationPayload, restart = true) {
100
- await this.remove(hash, false)
101
- await this.add(automation, false)
102
- if (restart) await this.restart()
103
- }
104
-
105
- private async trigger(automation: SentinelIntervalAutomationPayload) {
106
- const wrapper = new SentinelIntervalAutomationWrapper(automation)
107
- await this.remove(await wrapper.hashAsync(), false)
108
- wrapper.next()
109
- await this.add(wrapper.jsonPayload(), false)
110
- const triggerResult = await this.sentinel.report()
111
- this.onTriggerResult?.(triggerResult)
112
- // await this.start()
113
- }
114
- }