@xyo-network/sentinel 2.59.0 → 2.60.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 +9 -4
- package/dist/cjs/AbstractSentinel.js.map +1 -1
- package/dist/cjs/MemorySentinel.js +7 -4
- package/dist/cjs/MemorySentinel.js.map +1 -1
- package/dist/cjs/SentinelIntervalAutomationWrapper.js +14 -12
- package/dist/cjs/SentinelIntervalAutomationWrapper.js.map +1 -1
- package/dist/cjs/SentinelRunner.js +3 -3
- package/dist/cjs/SentinelRunner.js.map +1 -1
- package/dist/docs.json +5763 -4851
- package/dist/esm/AbstractSentinel.js +9 -4
- package/dist/esm/AbstractSentinel.js.map +1 -1
- package/dist/esm/MemorySentinel.js +7 -4
- package/dist/esm/MemorySentinel.js.map +1 -1
- package/dist/esm/SentinelIntervalAutomationWrapper.js +14 -12
- package/dist/esm/SentinelIntervalAutomationWrapper.js.map +1 -1
- package/dist/esm/SentinelRunner.js +3 -3
- package/dist/esm/SentinelRunner.js.map +1 -1
- package/dist/types/AbstractSentinel.d.ts.map +1 -1
- package/dist/types/MemorySentinel.d.ts.map +1 -1
- package/dist/types/SentinelIntervalAutomationWrapper.d.ts.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AbstractSentinel.html +15 -15
- package/docs/classes/MemorySentinel.html +14 -14
- package/docs/classes/SentinelIntervalAutomationWrapper.html +286 -113
- package/docs/classes/SentinelRunner.html +17 -17
- package/docs/classes/SentinelWrapper.html +14 -14
- package/docs/interfaces/Sentinel.html +2 -2
- package/docs/interfaces/SentinelModuleEventData.html +3 -3
- package/docs/interfaces/SentinelReportEndEventData.html +2 -2
- package/docs/interfaces/SentinelReportStartEventData.html +2 -2
- package/docs/types/MemorySentinelParams.html +1 -1
- package/docs/types/OnSentinelRunnerTriggerResult.html +1 -1
- package/docs/types/SentinelAutomationPayload.html +1 -1
- package/docs/types/SentinelAutomationSchema.html +2 -2
- package/docs/types/SentinelBaseAutomationPayload.html +1 -1
- package/docs/types/SentinelChangeAutomationPayload.html +1 -1
- package/docs/types/SentinelConfig.html +1 -1
- package/docs/types/SentinelConfigSchema.html +2 -2
- package/docs/types/SentinelIntervalAutomationPayload.html +1 -1
- package/docs/types/SentinelModule.html +1 -1
- package/docs/types/SentinelModuleQueries.html +1 -1
- package/docs/types/SentinelParams.html +1 -1
- package/docs/types/SentinelQuery.html +1 -1
- package/docs/types/SentinelQueryBase.html +1 -1
- package/docs/types/SentinelReportEndEventArgs.html +1 -1
- package/docs/types/SentinelReportQuery.html +1 -1
- package/docs/types/SentinelReportQuerySchema.html +2 -2
- package/docs/types/SentinelReportStartEventArgs.html +1 -1
- package/docs/variables/SentinelAutomationSchema-1.html +2 -2
- package/docs/variables/SentinelConfigSchema-1.html +2 -2
- package/docs/variables/SentinelReportQuerySchema-1.html +2 -2
- package/package.json +14 -13
- package/src/AbstractSentinel.ts +13 -4
- package/src/MemorySentinel.ts +9 -4
- package/src/SentinelIntervalAutomationWrapper.ts +14 -12
- package/src/SentinelRunner.ts +3 -3
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
<h1>Variable SentinelConfigSchema</h1></div>
|
|
18
18
|
<div class="tsd-signature"><span class="tsd-kind-variable">Sentinel<wbr/>Config<wbr/>Schema</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"network.xyo.node.sentinel"</span></div><aside class="tsd-sources">
|
|
19
19
|
<ul>
|
|
20
|
-
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
21
|
-
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
20
|
+
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/07894923abf1/packages/modules/packages/sentinel/src/Config.ts#L5">modules/packages/sentinel/src/Config.ts:5</a></li>
|
|
21
|
+
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/07894923abf1/packages/modules/packages/sentinel/src/Config.ts#L6">modules/packages/sentinel/src/Config.ts:6</a></li></ul></aside></div>
|
|
22
22
|
<div class="col-sidebar">
|
|
23
23
|
<div class="page-menu">
|
|
24
24
|
<div class="tsd-navigation settings">
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
<h1>Variable SentinelReportQuerySchema</h1></div>
|
|
18
18
|
<div class="tsd-signature"><span class="tsd-kind-variable">Sentinel<wbr/>Report<wbr/>Query<wbr/>Schema</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"network.xyo.query.sentinel.report"</span></div><aside class="tsd-sources">
|
|
19
19
|
<ul>
|
|
20
|
-
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
21
|
-
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/
|
|
20
|
+
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/07894923abf1/packages/modules/packages/sentinel/src/Queries/Report.ts#L3">modules/packages/sentinel/src/Queries/Report.ts:3</a></li>
|
|
21
|
+
<li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/07894923abf1/packages/modules/packages/sentinel/src/Queries/Report.ts#L4">modules/packages/sentinel/src/Queries/Report.ts:4</a></li></ul></aside></div>
|
|
22
22
|
<div class="col-sidebar">
|
|
23
23
|
<div class="page-menu">
|
|
24
24
|
<div class="tsd-navigation settings">
|
package/package.json
CHANGED
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/assert": "^2.8.1",
|
|
14
14
|
"@xylabs/promise": "^2.8.1",
|
|
15
|
-
"@xyo-network/account": "^2.
|
|
16
|
-
"@xyo-network/account-model": "^2.
|
|
17
|
-
"@xyo-network/archivist": "^2.
|
|
18
|
-
"@xyo-network/archivist-wrapper": "^2.
|
|
19
|
-
"@xyo-network/boundwitness-model": "^2.
|
|
20
|
-
"@xyo-network/core": "^2.
|
|
21
|
-
"@xyo-network/module": "^2.
|
|
22
|
-
"@xyo-network/module-model": "^2.
|
|
23
|
-
"@xyo-network/payload-model": "^2.
|
|
24
|
-
"@xyo-network/payload-wrapper": "^2.
|
|
25
|
-
"@xyo-network/promise": "^2.
|
|
26
|
-
"@xyo-network/witness": "^2.
|
|
15
|
+
"@xyo-network/account": "^2.60.0-rc.2",
|
|
16
|
+
"@xyo-network/account-model": "^2.60.0-rc.2",
|
|
17
|
+
"@xyo-network/archivist": "^2.60.0-rc.2",
|
|
18
|
+
"@xyo-network/archivist-wrapper": "^2.60.0-rc.2",
|
|
19
|
+
"@xyo-network/boundwitness-model": "^2.60.0-rc.2",
|
|
20
|
+
"@xyo-network/core": "^2.60.0-rc.2",
|
|
21
|
+
"@xyo-network/module": "^2.60.0-rc.2",
|
|
22
|
+
"@xyo-network/module-model": "^2.60.0-rc.2",
|
|
23
|
+
"@xyo-network/payload-model": "^2.60.0-rc.2",
|
|
24
|
+
"@xyo-network/payload-wrapper": "^2.60.0-rc.2",
|
|
25
|
+
"@xyo-network/promise": "^2.60.0-rc.2",
|
|
26
|
+
"@xyo-network/witness": "^2.60.0-rc.2",
|
|
27
27
|
"lodash": "^4.17.21"
|
|
28
28
|
},
|
|
29
29
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
@@ -65,5 +65,6 @@
|
|
|
65
65
|
},
|
|
66
66
|
"sideEffects": false,
|
|
67
67
|
"types": "dist/types/index.d.ts",
|
|
68
|
-
"version": "2.
|
|
68
|
+
"version": "2.60.0-rc.2",
|
|
69
|
+
"stableVersion": "2.59.0"
|
|
69
70
|
}
|
package/src/AbstractSentinel.ts
CHANGED
|
@@ -93,12 +93,12 @@ export abstract class AbstractSentinel<
|
|
|
93
93
|
queryConfig?: TConfig,
|
|
94
94
|
): Promise<ModuleQueryResult> {
|
|
95
95
|
const wrapper = QueryBoundWitnessWrapper.parseQuery<SentinelQueryBase>(query, payloads)
|
|
96
|
-
const
|
|
96
|
+
const queryPayload = await wrapper.getQuery()
|
|
97
97
|
assertEx(this.queryable(query, payloads, queryConfig))
|
|
98
98
|
const queryAccount = new Account()
|
|
99
99
|
const resultPayloads: Payload[] = []
|
|
100
100
|
try {
|
|
101
|
-
switch (
|
|
101
|
+
switch (queryPayload.schema) {
|
|
102
102
|
case SentinelReportQuerySchema: {
|
|
103
103
|
await this.emit('reportStart', { inPayloads: payloads, module: this })
|
|
104
104
|
resultPayloads.push(...(await this.report(payloads)))
|
|
@@ -111,9 +111,18 @@ export abstract class AbstractSentinel<
|
|
|
111
111
|
}
|
|
112
112
|
} catch (ex) {
|
|
113
113
|
const error = ex as Error
|
|
114
|
-
return this.bindQueryResult(
|
|
114
|
+
return this.bindQueryResult(
|
|
115
|
+
queryPayload,
|
|
116
|
+
[
|
|
117
|
+
new ModuleErrorBuilder()
|
|
118
|
+
.sources([await wrapper.hashAsync()])
|
|
119
|
+
.message(error.message)
|
|
120
|
+
.build(),
|
|
121
|
+
],
|
|
122
|
+
[queryAccount],
|
|
123
|
+
)
|
|
115
124
|
}
|
|
116
|
-
return await this.bindQueryResult(
|
|
125
|
+
return await this.bindQueryResult(queryPayload, resultPayloads, [queryAccount])
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
abstract report(payloads?: Payload[]): Promise<Payload[]>
|
package/src/MemorySentinel.ts
CHANGED
|
@@ -57,12 +57,12 @@ export class MemorySentinel<
|
|
|
57
57
|
queryConfig?: TConfig,
|
|
58
58
|
): Promise<ModuleQueryResult> {
|
|
59
59
|
const wrapper = QueryBoundWitnessWrapper.parseQuery<SentinelQuery>(query, payloads)
|
|
60
|
-
const
|
|
60
|
+
const queryPayload = await wrapper.getQuery()
|
|
61
61
|
assertEx(this.queryable(query, payloads, queryConfig))
|
|
62
62
|
const queryAccount = new Account()
|
|
63
63
|
const resultPayloads: Payload[] = []
|
|
64
64
|
try {
|
|
65
|
-
switch (
|
|
65
|
+
switch (queryPayload.schema) {
|
|
66
66
|
case SentinelReportQuerySchema: {
|
|
67
67
|
resultPayloads.push(...(await this.report(payloads)))
|
|
68
68
|
break
|
|
@@ -72,9 +72,14 @@ export class MemorySentinel<
|
|
|
72
72
|
}
|
|
73
73
|
} catch (ex) {
|
|
74
74
|
const error = ex as Error
|
|
75
|
-
resultPayloads.push(
|
|
75
|
+
resultPayloads.push(
|
|
76
|
+
new ModuleErrorBuilder()
|
|
77
|
+
.sources([await wrapper.hashAsync()])
|
|
78
|
+
.message(error.message)
|
|
79
|
+
.build(),
|
|
80
|
+
)
|
|
76
81
|
}
|
|
77
|
-
return await this.bindQueryResult(
|
|
82
|
+
return await this.bindQueryResult(queryPayload, resultPayloads, [queryAccount])
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
private async generatePayloads(witnesses: WitnessWrapper[]): Promise<Payload[]> {
|
|
@@ -6,40 +6,42 @@ export class SentinelIntervalAutomationWrapper<
|
|
|
6
6
|
T extends SentinelIntervalAutomationPayload = SentinelIntervalAutomationPayload,
|
|
7
7
|
> extends PayloadWrapper<T> {
|
|
8
8
|
protected get frequencyMillis() {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const frequency = this.payload().frequency
|
|
10
|
+
if (frequency === undefined) return Infinity
|
|
11
|
+
switch (this.payload().frequencyUnits ?? 'hour') {
|
|
11
12
|
case 'minute':
|
|
12
|
-
return
|
|
13
|
+
return frequency * 60 * 1000
|
|
13
14
|
case 'hour':
|
|
14
|
-
return
|
|
15
|
+
return frequency * 60 * 60 * 1000
|
|
15
16
|
case 'day':
|
|
16
|
-
return
|
|
17
|
+
return frequency * 24 * 60 * 60 * 1000
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
protected get remaining() {
|
|
21
22
|
//if remaining is not defined, we assume Infinity
|
|
22
|
-
return this.payload.remaining ?? Infinity
|
|
23
|
+
return this.payload().remaining ?? Infinity
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
next() {
|
|
26
|
-
this.payload.start = this.payload.start + this.frequencyMillis
|
|
27
|
+
this.payload().start = this.payload().start + this.frequencyMillis
|
|
27
28
|
this.consumeRemaining()
|
|
28
29
|
this.checkEnd()
|
|
29
30
|
return this
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
protected checkEnd() {
|
|
33
|
-
if (this.payload.start > (this.payload.end ?? Infinity)) {
|
|
34
|
-
this.payload.start = Infinity
|
|
34
|
+
if (this.payload().start > (this.payload().end ?? Infinity)) {
|
|
35
|
+
this.payload().start = Infinity
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
protected consumeRemaining(count = 1) {
|
|
39
|
-
|
|
40
|
+
const remaining = this.remaining - count
|
|
41
|
+
this.payload().remaining = remaining
|
|
40
42
|
|
|
41
|
-
if (
|
|
42
|
-
this.payload.start = Infinity
|
|
43
|
+
if (remaining <= 0) {
|
|
44
|
+
this.payload().start = Infinity
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
}
|
package/src/SentinelRunner.ts
CHANGED
|
@@ -33,7 +33,7 @@ export class SentinelRunner {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async add(automation: SentinelAutomationPayload, restart = true) {
|
|
36
|
-
const hash =
|
|
36
|
+
const hash = await PayloadWrapper.hashAsync(automation)
|
|
37
37
|
this._automations[hash] = automation
|
|
38
38
|
if (restart) await this.restart()
|
|
39
39
|
return hash
|
|
@@ -93,9 +93,9 @@ export class SentinelRunner {
|
|
|
93
93
|
|
|
94
94
|
private async trigger(automation: SentinelIntervalAutomationPayload) {
|
|
95
95
|
const wrapper = new SentinelIntervalAutomationWrapper(automation)
|
|
96
|
-
await this.remove(wrapper.
|
|
96
|
+
await this.remove(await wrapper.hashAsync(), false)
|
|
97
97
|
wrapper.next()
|
|
98
|
-
await this.add(wrapper.payload, false)
|
|
98
|
+
await this.add(wrapper.payload(), false)
|
|
99
99
|
const triggerResult = await this.sentinel.report()
|
|
100
100
|
this.onTriggerResult?.(triggerResult)
|
|
101
101
|
await this.start()
|