@hotmeshio/hotmesh 0.14.1 → 0.14.3

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 (52) hide show
  1. package/build/package.json +2 -1
  2. package/build/services/engine/init.js +1 -1
  3. package/build/services/engine/schema.js +5 -1
  4. package/build/services/pipe/functions/array.d.ts +219 -0
  5. package/build/services/pipe/functions/array.js +219 -0
  6. package/build/services/pipe/functions/bitwise.d.ts +94 -0
  7. package/build/services/pipe/functions/bitwise.js +94 -0
  8. package/build/services/pipe/functions/conditional.d.ts +161 -0
  9. package/build/services/pipe/functions/conditional.js +161 -0
  10. package/build/services/pipe/functions/cron.d.ts +23 -4
  11. package/build/services/pipe/functions/cron.js +23 -4
  12. package/build/services/pipe/functions/date.d.ts +737 -6
  13. package/build/services/pipe/functions/date.js +742 -5
  14. package/build/services/pipe/functions/json.d.ts +42 -0
  15. package/build/services/pipe/functions/json.js +42 -0
  16. package/build/services/pipe/functions/logical.d.ts +38 -0
  17. package/build/services/pipe/functions/logical.js +38 -0
  18. package/build/services/pipe/functions/math.d.ts +533 -0
  19. package/build/services/pipe/functions/math.js +533 -0
  20. package/build/services/pipe/functions/number.d.ts +258 -0
  21. package/build/services/pipe/functions/number.js +258 -0
  22. package/build/services/pipe/functions/object.d.ts +321 -0
  23. package/build/services/pipe/functions/object.js +321 -0
  24. package/build/services/pipe/functions/string.d.ts +306 -0
  25. package/build/services/pipe/functions/string.js +306 -0
  26. package/build/services/pipe/functions/symbol.d.ts +112 -0
  27. package/build/services/pipe/functions/symbol.js +112 -0
  28. package/build/services/pipe/functions/unary.d.ts +65 -0
  29. package/build/services/pipe/functions/unary.js +65 -0
  30. package/build/services/quorum/index.js +1 -1
  31. package/build/services/router/consumption/index.js +20 -2
  32. package/build/services/router/error-handling/index.js +1 -1
  33. package/build/services/store/factory.d.ts +1 -1
  34. package/build/services/store/factory.js +2 -2
  35. package/build/services/store/index.d.ts +1 -1
  36. package/build/services/store/providers/postgres/kvsql.d.ts +11 -1
  37. package/build/services/store/providers/postgres/kvsql.js +22 -12
  38. package/build/services/store/providers/postgres/kvtables.js +39 -6
  39. package/build/services/store/providers/postgres/kvtypes/hash/basic.js +6 -6
  40. package/build/services/store/providers/postgres/kvtypes/hash/scan.js +2 -1
  41. package/build/services/store/providers/postgres/kvtypes/list.js +7 -6
  42. package/build/services/store/providers/postgres/kvtypes/string.js +3 -3
  43. package/build/services/store/providers/postgres/kvtypes/zset.js +7 -7
  44. package/build/services/store/providers/postgres/postgres.d.ts +3 -2
  45. package/build/services/store/providers/postgres/postgres.js +55 -55
  46. package/build/services/store/providers/postgres/time-notify.js +18 -25
  47. package/build/services/store/providers/store-initializable.d.ts +1 -1
  48. package/build/services/virtual/index.js +6 -0
  49. package/build/services/virtual/schemas/factory.js +1 -1
  50. package/build/services/worker/index.js +1 -1
  51. package/build/types/virtual.d.ts +21 -0
  52. package/package.json +2 -1
@@ -1,22 +1,116 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BitwiseHandler = void 0;
4
+ /**
5
+ * Provides bitwise operation functions for use in HotMesh mapping rules.
6
+ * Although inspired by JavaScript, they have been adapted to follow a
7
+ * functional approach. Each transformation is a function that expects
8
+ * one or more input parameters from the prior row in the `@pipe` structure.
9
+ *
10
+ * @remarks
11
+ * Invoked in mapping rules using `{@bitwise.<method>}` syntax.
12
+ */
4
13
  class BitwiseHandler {
14
+ /**
15
+ * Performs a bitwise AND operation on two numbers.
16
+ *
17
+ * @param {number} a - The first operand
18
+ * @param {number} b - The second operand
19
+ * @returns {number} The result of `a & b`
20
+ * @example
21
+ * ```yaml
22
+ * bitwise_and_result:
23
+ * "@pipe":
24
+ * - ["{a.numbers.a}", "{a.numbers.b}"]
25
+ * - ["{@bitwise.and}"]
26
+ * ```
27
+ */
5
28
  and(a, b) {
6
29
  return a & b;
7
30
  }
31
+ /**
32
+ * Performs a bitwise OR operation on two numbers.
33
+ *
34
+ * @param {number} a - The first operand
35
+ * @param {number} b - The second operand
36
+ * @returns {number} The result of `a | b`
37
+ * @example
38
+ * ```yaml
39
+ * bitwise_or_result:
40
+ * "@pipe":
41
+ * - ["{a.numbers.a}", "{a.numbers.b}"]
42
+ * - ["{@bitwise.or}"]
43
+ * ```
44
+ */
8
45
  or(a, b) {
9
46
  return a | b;
10
47
  }
48
+ /**
49
+ * Performs a bitwise XOR operation on two numbers.
50
+ *
51
+ * @param {number} a - The first operand
52
+ * @param {number} b - The second operand
53
+ * @returns {number} The result of `a ^ b`
54
+ * @example
55
+ * ```yaml
56
+ * bitwise_xor_result:
57
+ * "@pipe":
58
+ * - ["{a.numbers.a}", "{a.numbers.b}"]
59
+ * - ["{@bitwise.xor}"]
60
+ * ```
61
+ */
11
62
  xor(a, b) {
12
63
  return a ^ b;
13
64
  }
65
+ /**
66
+ * Performs a bitwise left shift operation on a number.
67
+ *
68
+ * @param {number} a - The number to shift
69
+ * @param {number} b - The number of positions to shift left
70
+ * @returns {number} The result of `a << b`
71
+ * @example
72
+ * ```yaml
73
+ * bitwise_left_shift_result:
74
+ * "@pipe":
75
+ * - ["{a.numbers.a}", "{a.numbers.shift}"]
76
+ * - ["{@bitwise.leftShift}"]
77
+ * ```
78
+ */
14
79
  leftShift(a, b) {
15
80
  return a << b;
16
81
  }
82
+ /**
83
+ * Performs a bitwise right shift operation on a number,
84
+ * preserving the sign bit.
85
+ *
86
+ * @param {number} a - The number to shift
87
+ * @param {number} b - The number of positions to shift right
88
+ * @returns {number} The result of `a >> b`
89
+ * @example
90
+ * ```yaml
91
+ * bitwise_right_shift_result:
92
+ * "@pipe":
93
+ * - ["{a.numbers.a}", "{a.numbers.shift}"]
94
+ * - ["{@bitwise.rightShift}"]
95
+ * ```
96
+ */
17
97
  rightShift(a, b) {
18
98
  return a >> b;
19
99
  }
100
+ /**
101
+ * Performs a bitwise unsigned right shift operation on a number.
102
+ *
103
+ * @param {number} a - The number to shift
104
+ * @param {number} b - The number of positions to shift right
105
+ * @returns {number} The result of `a >>> b`
106
+ * @example
107
+ * ```yaml
108
+ * bitwise_unsigned_right_shift_result:
109
+ * "@pipe":
110
+ * - ["{a.numbers.a}", "{a.numbers.shift}"]
111
+ * - ["{@bitwise.unsignedRightShift}"]
112
+ * ```
113
+ */
20
114
  unsignedRightShift(a, b) {
21
115
  return a >>> b;
22
116
  }
@@ -1,13 +1,174 @@
1
+ /**
2
+ * Provides conditional logic functions for use within HotMesh mapping
3
+ * rules. Although inspired by JavaScript operators, these methods have
4
+ * been adapted to follow a functional approach. Each transformation is
5
+ * a function that expects one or more input parameters from the prior
6
+ * row in the `@pipe` structure.
7
+ *
8
+ * @remarks Invoked via `{@conditional.<method>}` in YAML mapping rules.
9
+ */
1
10
  declare class ConditionalHandler {
11
+ /**
12
+ * Evaluates a condition and returns one of two provided values based
13
+ * on the result. Equivalent to the JavaScript ternary operator
14
+ * (`condition ? valueIfTrue : valueIfFalse`).
15
+ *
16
+ * @param {boolean} condition - The condition to evaluate
17
+ * @param {any} valueIfTrue - The value to return if the condition is true
18
+ * @param {any} valueIfFalse - The value to return if the condition is false
19
+ * @returns {any} The value corresponding to the condition result
20
+ * @example
21
+ * ```yaml
22
+ * status_label:
23
+ * "@pipe":
24
+ * - ["{a.data.isActive}", "{a.data.activeLabel}", "{a.data.inactiveLabel}"]
25
+ * - ["{@conditional.ternary}"]
26
+ * ```
27
+ */
2
28
  ternary(condition: boolean, valueIfTrue: any, valueIfFalse: any): any;
29
+ /**
30
+ * Checks whether two values are equal using non-strict equality (`==`).
31
+ * Type coercion is applied, so `42 == "42"` returns true.
32
+ *
33
+ * @param {any} value1 - The first value to compare
34
+ * @param {any} value2 - The second value to compare
35
+ * @returns {boolean} True if the values are loosely equal, otherwise false
36
+ * @example
37
+ * ```yaml
38
+ * are_values_equal:
39
+ * "@pipe":
40
+ * - ["{a.data.value1}", "{a.data.value2}"]
41
+ * - ["{@conditional.equality}"]
42
+ * ```
43
+ */
3
44
  equality(value1: any, value2: any): boolean;
45
+ /**
46
+ * Checks whether two values are equal using strict equality (`===`).
47
+ * No type coercion is applied, so `42 === "42"` returns false.
48
+ *
49
+ * @param {any} value1 - The first value to compare
50
+ * @param {any} value2 - The second value to compare
51
+ * @returns {boolean} True if the values are strictly equal, otherwise false
52
+ * @example
53
+ * ```yaml
54
+ * are_values_strictly_equal:
55
+ * "@pipe":
56
+ * - ["{a.data.value1}", "{a.data.value2}"]
57
+ * - ["{@conditional.strict_equality}"]
58
+ * ```
59
+ */
4
60
  strict_equality(value1: any, value2: any): boolean;
61
+ /**
62
+ * Checks whether two values are not equal using non-strict inequality
63
+ * (`!=`). Type coercion is applied, so `42 != "42"` returns false.
64
+ *
65
+ * @param {any} value1 - The first value to compare
66
+ * @param {any} value2 - The second value to compare
67
+ * @returns {boolean} True if the values are not loosely equal, otherwise false
68
+ * @example
69
+ * ```yaml
70
+ * are_values_not_equal:
71
+ * "@pipe":
72
+ * - ["{a.data.value1}", "{a.data.value2}"]
73
+ * - ["{@conditional.inequality}"]
74
+ * ```
75
+ */
5
76
  inequality(value1: any, value2: any): boolean;
77
+ /**
78
+ * Checks whether two values are not equal using strict inequality
79
+ * (`!==`). No type coercion is applied, so `42 !== "42"` returns true.
80
+ *
81
+ * @param {any} value1 - The first value to compare
82
+ * @param {any} value2 - The second value to compare
83
+ * @returns {boolean} True if the values are strictly not equal, otherwise false
84
+ * @example
85
+ * ```yaml
86
+ * are_values_strictly_not_equal:
87
+ * "@pipe":
88
+ * - ["{a.data.value1}", "{a.data.value2}"]
89
+ * - ["{@conditional.strict_inequality}"]
90
+ * ```
91
+ */
6
92
  strict_inequality(value1: any, value2: any): boolean;
93
+ /**
94
+ * Checks whether the first value is greater than the second value.
95
+ *
96
+ * @param {number} value1 - The first number to compare
97
+ * @param {number} value2 - The second number to compare
98
+ * @returns {boolean} True if value1 is greater than value2, otherwise false
99
+ * @example
100
+ * ```yaml
101
+ * is_greater:
102
+ * "@pipe":
103
+ * - ["{a.data.value1}", "{a.data.value2}"]
104
+ * - ["{@conditional.greater_than}"]
105
+ * ```
106
+ */
7
107
  greater_than(value1: number, value2: number): boolean;
108
+ /**
109
+ * Checks whether the first value is less than the second value.
110
+ *
111
+ * @param {number} value1 - The first number to compare
112
+ * @param {number} value2 - The second number to compare
113
+ * @returns {boolean} True if value1 is less than value2, otherwise false
114
+ * @example
115
+ * ```yaml
116
+ * is_less:
117
+ * "@pipe":
118
+ * - ["{a.data.value1}", "{a.data.value2}"]
119
+ * - ["{@conditional.less_than}"]
120
+ * ```
121
+ */
8
122
  less_than(value1: number, value2: number): boolean;
123
+ /**
124
+ * Checks whether the first value is greater than or equal to the
125
+ * second value.
126
+ *
127
+ * @param {number} value1 - The first number to compare
128
+ * @param {number} value2 - The second number to compare
129
+ * @returns {boolean} True if value1 is greater than or equal to value2, otherwise false
130
+ * @example
131
+ * ```yaml
132
+ * is_gte:
133
+ * "@pipe":
134
+ * - ["{a.data.value1}", "{a.data.value2}"]
135
+ * - ["{@conditional.greater_than_or_equal}"]
136
+ * ```
137
+ */
9
138
  greater_than_or_equal(value1: number, value2: number): boolean;
139
+ /**
140
+ * Checks whether the first value is less than or equal to the second
141
+ * value.
142
+ *
143
+ * @param {number} value1 - The first number to compare
144
+ * @param {number} value2 - The second number to compare
145
+ * @returns {boolean} True if value1 is less than or equal to value2, otherwise false
146
+ * @example
147
+ * ```yaml
148
+ * is_lte:
149
+ * "@pipe":
150
+ * - ["{a.data.value1}", "{a.data.value2}"]
151
+ * - ["{@conditional.less_than_or_equal}"]
152
+ * ```
153
+ */
10
154
  less_than_or_equal(value1: number, value2: number): boolean;
155
+ /**
156
+ * Returns the first value if it is not null or undefined, otherwise
157
+ * returns the second value. Equivalent to the JavaScript nullish
158
+ * coalescing operator (`??`). Unlike logical OR, this allows falsy
159
+ * values like `0` and `false` to pass through.
160
+ *
161
+ * @param {any} value1 - The value to test for null/undefined
162
+ * @param {any} value2 - The fallback value if value1 is null or undefined
163
+ * @returns {any} value1 if it is not null/undefined, otherwise value2
164
+ * @example
165
+ * ```yaml
166
+ * non_null_value:
167
+ * "@pipe":
168
+ * - ["{a.data.value1}", "{a.data.value2}"]
169
+ * - ["{@conditional.nullish}"]
170
+ * ```
171
+ */
11
172
  nullish(value1: any, value2: any): any;
12
173
  }
13
174
  export { ConditionalHandler };
@@ -1,34 +1,195 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConditionalHandler = void 0;
4
+ /**
5
+ * Provides conditional logic functions for use within HotMesh mapping
6
+ * rules. Although inspired by JavaScript operators, these methods have
7
+ * been adapted to follow a functional approach. Each transformation is
8
+ * a function that expects one or more input parameters from the prior
9
+ * row in the `@pipe` structure.
10
+ *
11
+ * @remarks Invoked via `{@conditional.<method>}` in YAML mapping rules.
12
+ */
4
13
  class ConditionalHandler {
14
+ /**
15
+ * Evaluates a condition and returns one of two provided values based
16
+ * on the result. Equivalent to the JavaScript ternary operator
17
+ * (`condition ? valueIfTrue : valueIfFalse`).
18
+ *
19
+ * @param {boolean} condition - The condition to evaluate
20
+ * @param {any} valueIfTrue - The value to return if the condition is true
21
+ * @param {any} valueIfFalse - The value to return if the condition is false
22
+ * @returns {any} The value corresponding to the condition result
23
+ * @example
24
+ * ```yaml
25
+ * status_label:
26
+ * "@pipe":
27
+ * - ["{a.data.isActive}", "{a.data.activeLabel}", "{a.data.inactiveLabel}"]
28
+ * - ["{@conditional.ternary}"]
29
+ * ```
30
+ */
5
31
  ternary(condition, valueIfTrue, valueIfFalse) {
6
32
  return condition ? valueIfTrue : valueIfFalse;
7
33
  }
34
+ /**
35
+ * Checks whether two values are equal using non-strict equality (`==`).
36
+ * Type coercion is applied, so `42 == "42"` returns true.
37
+ *
38
+ * @param {any} value1 - The first value to compare
39
+ * @param {any} value2 - The second value to compare
40
+ * @returns {boolean} True if the values are loosely equal, otherwise false
41
+ * @example
42
+ * ```yaml
43
+ * are_values_equal:
44
+ * "@pipe":
45
+ * - ["{a.data.value1}", "{a.data.value2}"]
46
+ * - ["{@conditional.equality}"]
47
+ * ```
48
+ */
8
49
  equality(value1, value2) {
9
50
  return value1 == value2;
10
51
  }
52
+ /**
53
+ * Checks whether two values are equal using strict equality (`===`).
54
+ * No type coercion is applied, so `42 === "42"` returns false.
55
+ *
56
+ * @param {any} value1 - The first value to compare
57
+ * @param {any} value2 - The second value to compare
58
+ * @returns {boolean} True if the values are strictly equal, otherwise false
59
+ * @example
60
+ * ```yaml
61
+ * are_values_strictly_equal:
62
+ * "@pipe":
63
+ * - ["{a.data.value1}", "{a.data.value2}"]
64
+ * - ["{@conditional.strict_equality}"]
65
+ * ```
66
+ */
11
67
  strict_equality(value1, value2) {
12
68
  return value1 === value2;
13
69
  }
70
+ /**
71
+ * Checks whether two values are not equal using non-strict inequality
72
+ * (`!=`). Type coercion is applied, so `42 != "42"` returns false.
73
+ *
74
+ * @param {any} value1 - The first value to compare
75
+ * @param {any} value2 - The second value to compare
76
+ * @returns {boolean} True if the values are not loosely equal, otherwise false
77
+ * @example
78
+ * ```yaml
79
+ * are_values_not_equal:
80
+ * "@pipe":
81
+ * - ["{a.data.value1}", "{a.data.value2}"]
82
+ * - ["{@conditional.inequality}"]
83
+ * ```
84
+ */
14
85
  inequality(value1, value2) {
15
86
  return value1 != value2;
16
87
  }
88
+ /**
89
+ * Checks whether two values are not equal using strict inequality
90
+ * (`!==`). No type coercion is applied, so `42 !== "42"` returns true.
91
+ *
92
+ * @param {any} value1 - The first value to compare
93
+ * @param {any} value2 - The second value to compare
94
+ * @returns {boolean} True if the values are strictly not equal, otherwise false
95
+ * @example
96
+ * ```yaml
97
+ * are_values_strictly_not_equal:
98
+ * "@pipe":
99
+ * - ["{a.data.value1}", "{a.data.value2}"]
100
+ * - ["{@conditional.strict_inequality}"]
101
+ * ```
102
+ */
17
103
  strict_inequality(value1, value2) {
18
104
  return value1 !== value2;
19
105
  }
106
+ /**
107
+ * Checks whether the first value is greater than the second value.
108
+ *
109
+ * @param {number} value1 - The first number to compare
110
+ * @param {number} value2 - The second number to compare
111
+ * @returns {boolean} True if value1 is greater than value2, otherwise false
112
+ * @example
113
+ * ```yaml
114
+ * is_greater:
115
+ * "@pipe":
116
+ * - ["{a.data.value1}", "{a.data.value2}"]
117
+ * - ["{@conditional.greater_than}"]
118
+ * ```
119
+ */
20
120
  greater_than(value1, value2) {
21
121
  return value1 > value2;
22
122
  }
123
+ /**
124
+ * Checks whether the first value is less than the second value.
125
+ *
126
+ * @param {number} value1 - The first number to compare
127
+ * @param {number} value2 - The second number to compare
128
+ * @returns {boolean} True if value1 is less than value2, otherwise false
129
+ * @example
130
+ * ```yaml
131
+ * is_less:
132
+ * "@pipe":
133
+ * - ["{a.data.value1}", "{a.data.value2}"]
134
+ * - ["{@conditional.less_than}"]
135
+ * ```
136
+ */
23
137
  less_than(value1, value2) {
24
138
  return value1 < value2;
25
139
  }
140
+ /**
141
+ * Checks whether the first value is greater than or equal to the
142
+ * second value.
143
+ *
144
+ * @param {number} value1 - The first number to compare
145
+ * @param {number} value2 - The second number to compare
146
+ * @returns {boolean} True if value1 is greater than or equal to value2, otherwise false
147
+ * @example
148
+ * ```yaml
149
+ * is_gte:
150
+ * "@pipe":
151
+ * - ["{a.data.value1}", "{a.data.value2}"]
152
+ * - ["{@conditional.greater_than_or_equal}"]
153
+ * ```
154
+ */
26
155
  greater_than_or_equal(value1, value2) {
27
156
  return value1 >= value2;
28
157
  }
158
+ /**
159
+ * Checks whether the first value is less than or equal to the second
160
+ * value.
161
+ *
162
+ * @param {number} value1 - The first number to compare
163
+ * @param {number} value2 - The second number to compare
164
+ * @returns {boolean} True if value1 is less than or equal to value2, otherwise false
165
+ * @example
166
+ * ```yaml
167
+ * is_lte:
168
+ * "@pipe":
169
+ * - ["{a.data.value1}", "{a.data.value2}"]
170
+ * - ["{@conditional.less_than_or_equal}"]
171
+ * ```
172
+ */
29
173
  less_than_or_equal(value1, value2) {
30
174
  return value1 <= value2;
31
175
  }
176
+ /**
177
+ * Returns the first value if it is not null or undefined, otherwise
178
+ * returns the second value. Equivalent to the JavaScript nullish
179
+ * coalescing operator (`??`). Unlike logical OR, this allows falsy
180
+ * values like `0` and `false` to pass through.
181
+ *
182
+ * @param {any} value1 - The value to test for null/undefined
183
+ * @param {any} value2 - The fallback value if value1 is null or undefined
184
+ * @returns {any} value1 if it is not null/undefined, otherwise value2
185
+ * @example
186
+ * ```yaml
187
+ * non_null_value:
188
+ * "@pipe":
189
+ * - ["{a.data.value1}", "{a.data.value2}"]
190
+ * - ["{@conditional.nullish}"]
191
+ * ```
192
+ */
32
193
  nullish(value1, value2) {
33
194
  return value1 ?? value2;
34
195
  }
@@ -1,12 +1,31 @@
1
1
  import { ILogger } from '../../../types/logger';
2
2
  /**
3
- * Safely calculates the delay in seconds until the next execution of a cron job.
4
- * Fails silently and returns -1 if the cron expression is invalid.
5
- * @param cronExpression The cron expression to parse (e.g. '0 0 * * *').
6
- * @returns The delay in seconds until the next cron job execution (minimum 5 seconds).
3
+ * Provides cron-related utility functions based on the
4
+ * [cron](https://en.wikipedia.org/wiki/Cron) format for use
5
+ * in HotMesh mapping rules.
6
+ *
7
+ * @remarks
8
+ * Invoked in mapping rules using `{@cron.<method>}` syntax.
7
9
  */
8
10
  declare class CronHandler {
9
11
  static logger: ILogger;
12
+ /**
13
+ * Safely calculates the delay in seconds until the next execution
14
+ * of a cron job. Calculates the next date and time (per the system
15
+ * clock) that satisfies the cron expression, then returns the value
16
+ * in seconds from now. Fails silently and returns `-1` if the cron
17
+ * expression is invalid or the next execution time is in the past.
18
+ *
19
+ * @param {string} cronExpression - The cron expression to parse (e.g. `'0 0 * * *'`)
20
+ * @returns {number} The delay in seconds until the next cron job execution (minimum `HMSH_FIDELITY_SECONDS`), or `-1` on error
21
+ * @example
22
+ * ```yaml
23
+ * cron_next_result:
24
+ * "@pipe":
25
+ * - ["{a.expressions.cron}"]
26
+ * - ["{@cron.nextDelay}"]
27
+ * ```
28
+ */
10
29
  nextDelay(cronExpression: string): number;
11
30
  }
12
31
  export { CronHandler };
@@ -6,12 +6,31 @@ const enums_1 = require("../../../modules/enums");
6
6
  const utils_1 = require("../../../modules/utils");
7
7
  const logger_1 = require("../../logger");
8
8
  /**
9
- * Safely calculates the delay in seconds until the next execution of a cron job.
10
- * Fails silently and returns -1 if the cron expression is invalid.
11
- * @param cronExpression The cron expression to parse (e.g. '0 0 * * *').
12
- * @returns The delay in seconds until the next cron job execution (minimum 5 seconds).
9
+ * Provides cron-related utility functions based on the
10
+ * [cron](https://en.wikipedia.org/wiki/Cron) format for use
11
+ * in HotMesh mapping rules.
12
+ *
13
+ * @remarks
14
+ * Invoked in mapping rules using `{@cron.<method>}` syntax.
13
15
  */
14
16
  class CronHandler {
17
+ /**
18
+ * Safely calculates the delay in seconds until the next execution
19
+ * of a cron job. Calculates the next date and time (per the system
20
+ * clock) that satisfies the cron expression, then returns the value
21
+ * in seconds from now. Fails silently and returns `-1` if the cron
22
+ * expression is invalid or the next execution time is in the past.
23
+ *
24
+ * @param {string} cronExpression - The cron expression to parse (e.g. `'0 0 * * *'`)
25
+ * @returns {number} The delay in seconds until the next cron job execution (minimum `HMSH_FIDELITY_SECONDS`), or `-1` on error
26
+ * @example
27
+ * ```yaml
28
+ * cron_next_result:
29
+ * "@pipe":
30
+ * - ["{a.expressions.cron}"]
31
+ * - ["{@cron.nextDelay}"]
32
+ * ```
33
+ */
15
34
  nextDelay(cronExpression) {
16
35
  try {
17
36
  if (!(0, utils_1.isValidCron)(cronExpression)) {