@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.
Files changed (56) hide show
  1. package/dist/cjs/AbstractSentinel.js +9 -4
  2. package/dist/cjs/AbstractSentinel.js.map +1 -1
  3. package/dist/cjs/MemorySentinel.js +7 -4
  4. package/dist/cjs/MemorySentinel.js.map +1 -1
  5. package/dist/cjs/SentinelIntervalAutomationWrapper.js +14 -12
  6. package/dist/cjs/SentinelIntervalAutomationWrapper.js.map +1 -1
  7. package/dist/cjs/SentinelRunner.js +3 -3
  8. package/dist/cjs/SentinelRunner.js.map +1 -1
  9. package/dist/docs.json +5763 -4851
  10. package/dist/esm/AbstractSentinel.js +9 -4
  11. package/dist/esm/AbstractSentinel.js.map +1 -1
  12. package/dist/esm/MemorySentinel.js +7 -4
  13. package/dist/esm/MemorySentinel.js.map +1 -1
  14. package/dist/esm/SentinelIntervalAutomationWrapper.js +14 -12
  15. package/dist/esm/SentinelIntervalAutomationWrapper.js.map +1 -1
  16. package/dist/esm/SentinelRunner.js +3 -3
  17. package/dist/esm/SentinelRunner.js.map +1 -1
  18. package/dist/types/AbstractSentinel.d.ts.map +1 -1
  19. package/dist/types/MemorySentinel.d.ts.map +1 -1
  20. package/dist/types/SentinelIntervalAutomationWrapper.d.ts.map +1 -1
  21. package/docs/assets/search.js +1 -1
  22. package/docs/classes/AbstractSentinel.html +15 -15
  23. package/docs/classes/MemorySentinel.html +14 -14
  24. package/docs/classes/SentinelIntervalAutomationWrapper.html +286 -113
  25. package/docs/classes/SentinelRunner.html +17 -17
  26. package/docs/classes/SentinelWrapper.html +14 -14
  27. package/docs/interfaces/Sentinel.html +2 -2
  28. package/docs/interfaces/SentinelModuleEventData.html +3 -3
  29. package/docs/interfaces/SentinelReportEndEventData.html +2 -2
  30. package/docs/interfaces/SentinelReportStartEventData.html +2 -2
  31. package/docs/types/MemorySentinelParams.html +1 -1
  32. package/docs/types/OnSentinelRunnerTriggerResult.html +1 -1
  33. package/docs/types/SentinelAutomationPayload.html +1 -1
  34. package/docs/types/SentinelAutomationSchema.html +2 -2
  35. package/docs/types/SentinelBaseAutomationPayload.html +1 -1
  36. package/docs/types/SentinelChangeAutomationPayload.html +1 -1
  37. package/docs/types/SentinelConfig.html +1 -1
  38. package/docs/types/SentinelConfigSchema.html +2 -2
  39. package/docs/types/SentinelIntervalAutomationPayload.html +1 -1
  40. package/docs/types/SentinelModule.html +1 -1
  41. package/docs/types/SentinelModuleQueries.html +1 -1
  42. package/docs/types/SentinelParams.html +1 -1
  43. package/docs/types/SentinelQuery.html +1 -1
  44. package/docs/types/SentinelQueryBase.html +1 -1
  45. package/docs/types/SentinelReportEndEventArgs.html +1 -1
  46. package/docs/types/SentinelReportQuery.html +1 -1
  47. package/docs/types/SentinelReportQuerySchema.html +2 -2
  48. package/docs/types/SentinelReportStartEventArgs.html +1 -1
  49. package/docs/variables/SentinelAutomationSchema-1.html +2 -2
  50. package/docs/variables/SentinelConfigSchema-1.html +2 -2
  51. package/docs/variables/SentinelReportQuerySchema-1.html +2 -2
  52. package/package.json +14 -13
  53. package/src/AbstractSentinel.ts +13 -4
  54. package/src/MemorySentinel.ts +9 -4
  55. package/src/SentinelIntervalAutomationWrapper.ts +14 -12
  56. 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">&quot;network.xyo.node.sentinel&quot;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/218908d8b/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/218908d8b/packages/modules/packages/sentinel/src/Config.ts#L6">modules/packages/sentinel/src/Config.ts:6</a></li></ul></aside></div>
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">&quot;network.xyo.query.sentinel.report&quot;</span></div><aside class="tsd-sources">
19
19
  <ul>
20
- <li>Defined in <a href="https://github.com/XYOracleNetwork/sdk-xyo-client-js/blob/218908d8b/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/218908d8b/packages/modules/packages/sentinel/src/Queries/Report.ts#L4">modules/packages/sentinel/src/Queries/Report.ts:4</a></li></ul></aside></div>
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.59.0",
16
- "@xyo-network/account-model": "^2.59.0",
17
- "@xyo-network/archivist": "^2.59.0",
18
- "@xyo-network/archivist-wrapper": "^2.59.0",
19
- "@xyo-network/boundwitness-model": "^2.59.0",
20
- "@xyo-network/core": "^2.59.0",
21
- "@xyo-network/module": "^2.59.0",
22
- "@xyo-network/module-model": "^2.59.0",
23
- "@xyo-network/payload-model": "^2.59.0",
24
- "@xyo-network/payload-wrapper": "^2.59.0",
25
- "@xyo-network/promise": "^2.59.0",
26
- "@xyo-network/witness": "^2.59.0",
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.59.0"
68
+ "version": "2.60.0-rc.2",
69
+ "stableVersion": "2.59.0"
69
70
  }
@@ -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 typedQuery = wrapper.query.payload
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 (typedQuery.schema) {
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(typedQuery, [new ModuleErrorBuilder().sources([wrapper.hash]).message(error.message).build()], [queryAccount])
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(typedQuery, resultPayloads, [queryAccount])
125
+ return await this.bindQueryResult(queryPayload, resultPayloads, [queryAccount])
117
126
  }
118
127
 
119
128
  abstract report(payloads?: Payload[]): Promise<Payload[]>
@@ -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 typedQuery = wrapper.query.payload
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 (typedQuery.schema) {
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(new ModuleErrorBuilder().sources([wrapper.hash]).message(error.message).build())
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(typedQuery, resultPayloads, [queryAccount])
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
- if (this.payload.frequency === undefined) return Infinity
10
- switch (this.payload.frequencyUnits ?? 'hour') {
9
+ const frequency = this.payload().frequency
10
+ if (frequency === undefined) return Infinity
11
+ switch (this.payload().frequencyUnits ?? 'hour') {
11
12
  case 'minute':
12
- return this.payload.frequency * 60 * 1000
13
+ return frequency * 60 * 1000
13
14
  case 'hour':
14
- return this.payload.frequency * 60 * 60 * 1000
15
+ return frequency * 60 * 60 * 1000
15
16
  case 'day':
16
- return this.payload.frequency * 24 * 60 * 60 * 1000
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
- this.payload.remaining = this.remaining - count
40
+ const remaining = this.remaining - count
41
+ this.payload().remaining = remaining
40
42
 
41
- if (this.payload.remaining <= 0) {
42
- this.payload.start = Infinity
43
+ if (remaining <= 0) {
44
+ this.payload().start = Infinity
43
45
  }
44
46
  }
45
47
  }
@@ -33,7 +33,7 @@ export class SentinelRunner {
33
33
  }
34
34
 
35
35
  async add(automation: SentinelAutomationPayload, restart = true) {
36
- const hash = new PayloadWrapper(automation).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.hash, false)
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()