@hotmeshio/hotmesh 0.14.1 → 0.14.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 (31) hide show
  1. package/build/package.json +1 -1
  2. package/build/services/pipe/functions/array.d.ts +219 -0
  3. package/build/services/pipe/functions/array.js +219 -0
  4. package/build/services/pipe/functions/bitwise.d.ts +94 -0
  5. package/build/services/pipe/functions/bitwise.js +94 -0
  6. package/build/services/pipe/functions/conditional.d.ts +161 -0
  7. package/build/services/pipe/functions/conditional.js +161 -0
  8. package/build/services/pipe/functions/cron.d.ts +23 -4
  9. package/build/services/pipe/functions/cron.js +23 -4
  10. package/build/services/pipe/functions/date.d.ts +737 -6
  11. package/build/services/pipe/functions/date.js +742 -5
  12. package/build/services/pipe/functions/json.d.ts +42 -0
  13. package/build/services/pipe/functions/json.js +42 -0
  14. package/build/services/pipe/functions/logical.d.ts +38 -0
  15. package/build/services/pipe/functions/logical.js +38 -0
  16. package/build/services/pipe/functions/math.d.ts +533 -0
  17. package/build/services/pipe/functions/math.js +533 -0
  18. package/build/services/pipe/functions/number.d.ts +258 -0
  19. package/build/services/pipe/functions/number.js +258 -0
  20. package/build/services/pipe/functions/object.d.ts +321 -0
  21. package/build/services/pipe/functions/object.js +321 -0
  22. package/build/services/pipe/functions/string.d.ts +306 -0
  23. package/build/services/pipe/functions/string.js +306 -0
  24. package/build/services/pipe/functions/symbol.d.ts +112 -0
  25. package/build/services/pipe/functions/symbol.js +112 -0
  26. package/build/services/pipe/functions/unary.d.ts +65 -0
  27. package/build/services/pipe/functions/unary.js +65 -0
  28. package/build/services/virtual/index.js +6 -0
  29. package/build/services/virtual/schemas/factory.js +1 -1
  30. package/build/types/virtual.d.ts +21 -0
  31. package/package.json +1 -1
@@ -1,12 +1,124 @@
1
+ /**
2
+ * Provides methods for returning common symbolic values and objects,
3
+ * such as `null`, `undefined`, `whitespace`, `object`, `array`, and `date`.
4
+ * These methods can be used in a variety of contexts where it is necessary
5
+ * to represent these values or objects programmatically.
6
+ *
7
+ * @remarks
8
+ * Invoked in mapping rules using `{@symbol.<method>}` syntax.
9
+ * Symbol methods take no parameters; they are called directly
10
+ * in the `@pipe` structure.
11
+ */
1
12
  declare class SymbolHandler {
13
+ /**
14
+ * Returns the value `null`, representing a deliberate non-value.
15
+ *
16
+ * @returns {null} The null value
17
+ * @example
18
+ * ```yaml
19
+ * set_null:
20
+ * "@pipe":
21
+ * - ["{@symbol.null}"]
22
+ * ```
23
+ */
2
24
  null(): null;
25
+ /**
26
+ * Returns the value `undefined`, representing a variable
27
+ * that has not been assigned a value.
28
+ *
29
+ * @returns {undefined} The undefined value
30
+ * @example
31
+ * ```yaml
32
+ * set_undefined:
33
+ * "@pipe":
34
+ * - ["{@symbol.undefined}"]
35
+ * ```
36
+ */
3
37
  undefined(): undefined;
38
+ /**
39
+ * Returns a single whitespace character as a string.
40
+ *
41
+ * @returns {string} A single space character
42
+ * @example
43
+ * ```yaml
44
+ * set_whitespace:
45
+ * "@pipe":
46
+ * - ["{@symbol.whitespace}"]
47
+ * ```
48
+ */
4
49
  whitespace(): string;
50
+ /**
51
+ * Returns an empty object (`{}`).
52
+ *
53
+ * @returns {object} An empty object
54
+ * @example
55
+ * ```yaml
56
+ * set_object:
57
+ * "@pipe":
58
+ * - ["{@symbol.object}"]
59
+ * ```
60
+ */
5
61
  object(): object;
62
+ /**
63
+ * Returns an empty array (`[]`).
64
+ *
65
+ * @returns {any[]} An empty array
66
+ * @example
67
+ * ```yaml
68
+ * set_array:
69
+ * "@pipe":
70
+ * - ["{@symbol.array}"]
71
+ * ```
72
+ */
6
73
  array(): any[];
74
+ /**
75
+ * Returns the positive infinity value (`Infinity`).
76
+ *
77
+ * @returns {number} Positive infinity
78
+ * @example
79
+ * ```yaml
80
+ * set_pos_infinity:
81
+ * "@pipe":
82
+ * - ["{@symbol.posInfinity}"]
83
+ * ```
84
+ */
7
85
  posInfinity(): number;
86
+ /**
87
+ * Returns the negative infinity value (`-Infinity`).
88
+ *
89
+ * @returns {number} Negative infinity
90
+ * @example
91
+ * ```yaml
92
+ * set_neg_infinity:
93
+ * "@pipe":
94
+ * - ["{@symbol.negInfinity}"]
95
+ * ```
96
+ */
8
97
  negInfinity(): number;
98
+ /**
99
+ * Returns the not-a-number value (`NaN`).
100
+ *
101
+ * @returns {number} NaN
102
+ * @example
103
+ * ```yaml
104
+ * set_nan:
105
+ * "@pipe":
106
+ * - ["{@symbol.NaN}"]
107
+ * ```
108
+ */
9
109
  NaN(): number;
110
+ /**
111
+ * Returns the current date and time as a Date object.
112
+ *
113
+ * @returns {Date} The current date and time
114
+ * @example
115
+ * ```yaml
116
+ * set_date:
117
+ * "@pipe":
118
+ * - ["{@symbol.date}"]
119
+ * - ["{@json.stringify}"]
120
+ * ```
121
+ */
10
122
  date(): Date;
11
123
  }
12
124
  export { SymbolHandler };
@@ -1,31 +1,143 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SymbolHandler = void 0;
4
+ /**
5
+ * Provides methods for returning common symbolic values and objects,
6
+ * such as `null`, `undefined`, `whitespace`, `object`, `array`, and `date`.
7
+ * These methods can be used in a variety of contexts where it is necessary
8
+ * to represent these values or objects programmatically.
9
+ *
10
+ * @remarks
11
+ * Invoked in mapping rules using `{@symbol.<method>}` syntax.
12
+ * Symbol methods take no parameters; they are called directly
13
+ * in the `@pipe` structure.
14
+ */
4
15
  class SymbolHandler {
16
+ /**
17
+ * Returns the value `null`, representing a deliberate non-value.
18
+ *
19
+ * @returns {null} The null value
20
+ * @example
21
+ * ```yaml
22
+ * set_null:
23
+ * "@pipe":
24
+ * - ["{@symbol.null}"]
25
+ * ```
26
+ */
5
27
  null() {
6
28
  return null;
7
29
  }
30
+ /**
31
+ * Returns the value `undefined`, representing a variable
32
+ * that has not been assigned a value.
33
+ *
34
+ * @returns {undefined} The undefined value
35
+ * @example
36
+ * ```yaml
37
+ * set_undefined:
38
+ * "@pipe":
39
+ * - ["{@symbol.undefined}"]
40
+ * ```
41
+ */
8
42
  undefined() {
9
43
  return undefined;
10
44
  }
45
+ /**
46
+ * Returns a single whitespace character as a string.
47
+ *
48
+ * @returns {string} A single space character
49
+ * @example
50
+ * ```yaml
51
+ * set_whitespace:
52
+ * "@pipe":
53
+ * - ["{@symbol.whitespace}"]
54
+ * ```
55
+ */
11
56
  whitespace() {
12
57
  return ' ';
13
58
  }
59
+ /**
60
+ * Returns an empty object (`{}`).
61
+ *
62
+ * @returns {object} An empty object
63
+ * @example
64
+ * ```yaml
65
+ * set_object:
66
+ * "@pipe":
67
+ * - ["{@symbol.object}"]
68
+ * ```
69
+ */
14
70
  object() {
15
71
  return {};
16
72
  }
73
+ /**
74
+ * Returns an empty array (`[]`).
75
+ *
76
+ * @returns {any[]} An empty array
77
+ * @example
78
+ * ```yaml
79
+ * set_array:
80
+ * "@pipe":
81
+ * - ["{@symbol.array}"]
82
+ * ```
83
+ */
17
84
  array() {
18
85
  return [];
19
86
  }
87
+ /**
88
+ * Returns the positive infinity value (`Infinity`).
89
+ *
90
+ * @returns {number} Positive infinity
91
+ * @example
92
+ * ```yaml
93
+ * set_pos_infinity:
94
+ * "@pipe":
95
+ * - ["{@symbol.posInfinity}"]
96
+ * ```
97
+ */
20
98
  posInfinity() {
21
99
  return Infinity;
22
100
  }
101
+ /**
102
+ * Returns the negative infinity value (`-Infinity`).
103
+ *
104
+ * @returns {number} Negative infinity
105
+ * @example
106
+ * ```yaml
107
+ * set_neg_infinity:
108
+ * "@pipe":
109
+ * - ["{@symbol.negInfinity}"]
110
+ * ```
111
+ */
23
112
  negInfinity() {
24
113
  return -Infinity;
25
114
  }
115
+ /**
116
+ * Returns the not-a-number value (`NaN`).
117
+ *
118
+ * @returns {number} NaN
119
+ * @example
120
+ * ```yaml
121
+ * set_nan:
122
+ * "@pipe":
123
+ * - ["{@symbol.NaN}"]
124
+ * ```
125
+ */
26
126
  NaN() {
27
127
  return NaN;
28
128
  }
129
+ /**
130
+ * Returns the current date and time as a Date object.
131
+ *
132
+ * @returns {Date} The current date and time
133
+ * @example
134
+ * ```yaml
135
+ * set_date:
136
+ * "@pipe":
137
+ * - ["{@symbol.date}"]
138
+ * - ["{@json.stringify}"]
139
+ * ```
140
+ */
29
141
  date() {
30
142
  return new Date();
31
143
  }
@@ -1,7 +1,72 @@
1
+ /**
2
+ * Provides unary operation functions for use in HotMesh mapping rules.
3
+ * The functions facilitate unary operations such as logical negation,
4
+ * making a number positive or negative, and bitwise negation during
5
+ * the mapping process. Each transformation is a function that expects
6
+ * one input parameter from the prior row in the `@pipe` structure.
7
+ *
8
+ * @remarks
9
+ * Invoked in mapping rules using `{@unary.<method>}` syntax.
10
+ */
1
11
  declare class UnaryHandler {
12
+ /**
13
+ * Returns the logical negation of a boolean value.
14
+ *
15
+ * @param {boolean} value - The boolean value to negate
16
+ * @returns {boolean} The negated boolean value
17
+ * @example
18
+ * ```yaml
19
+ * not_value:
20
+ * "@pipe":
21
+ * - ["{a.output.data.value}"]
22
+ * - ["{@unary.not}"]
23
+ * ```
24
+ */
2
25
  not(value: boolean): boolean;
26
+ /**
27
+ * Returns the positive representation of a number using
28
+ * the unary plus operator.
29
+ *
30
+ * @param {number} value - The number to convert
31
+ * @returns {number} The positive representation of the value
32
+ * @example
33
+ * ```yaml
34
+ * positive_value:
35
+ * "@pipe":
36
+ * - ["{a.output.data.value}"]
37
+ * - ["{@unary.positive}"]
38
+ * ```
39
+ */
3
40
  positive(value: number): number;
41
+ /**
42
+ * Returns the negative representation of a number using
43
+ * the unary negation operator.
44
+ *
45
+ * @param {number} value - The number to negate
46
+ * @returns {number} The negated number
47
+ * @example
48
+ * ```yaml
49
+ * negative_value:
50
+ * "@pipe":
51
+ * - ["{a.output.data.value}"]
52
+ * - ["{@unary.negative}"]
53
+ * ```
54
+ */
4
55
  negative(value: number): number;
56
+ /**
57
+ * Returns the bitwise negation of a number using the
58
+ * bitwise NOT operator (`~`).
59
+ *
60
+ * @param {number} value - The number to bitwise negate
61
+ * @returns {number} The bitwise negation of the value
62
+ * @example
63
+ * ```yaml
64
+ * bitwise_not_value:
65
+ * "@pipe":
66
+ * - ["{a.output.data.value}"]
67
+ * - ["{@unary.bitwise_not}"]
68
+ * ```
69
+ */
5
70
  bitwise_not(value: number): number;
6
71
  }
7
72
  export { UnaryHandler };
@@ -1,16 +1,81 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnaryHandler = void 0;
4
+ /**
5
+ * Provides unary operation functions for use in HotMesh mapping rules.
6
+ * The functions facilitate unary operations such as logical negation,
7
+ * making a number positive or negative, and bitwise negation during
8
+ * the mapping process. Each transformation is a function that expects
9
+ * one input parameter from the prior row in the `@pipe` structure.
10
+ *
11
+ * @remarks
12
+ * Invoked in mapping rules using `{@unary.<method>}` syntax.
13
+ */
4
14
  class UnaryHandler {
15
+ /**
16
+ * Returns the logical negation of a boolean value.
17
+ *
18
+ * @param {boolean} value - The boolean value to negate
19
+ * @returns {boolean} The negated boolean value
20
+ * @example
21
+ * ```yaml
22
+ * not_value:
23
+ * "@pipe":
24
+ * - ["{a.output.data.value}"]
25
+ * - ["{@unary.not}"]
26
+ * ```
27
+ */
5
28
  not(value) {
6
29
  return !value;
7
30
  }
31
+ /**
32
+ * Returns the positive representation of a number using
33
+ * the unary plus operator.
34
+ *
35
+ * @param {number} value - The number to convert
36
+ * @returns {number} The positive representation of the value
37
+ * @example
38
+ * ```yaml
39
+ * positive_value:
40
+ * "@pipe":
41
+ * - ["{a.output.data.value}"]
42
+ * - ["{@unary.positive}"]
43
+ * ```
44
+ */
8
45
  positive(value) {
9
46
  return +value;
10
47
  }
48
+ /**
49
+ * Returns the negative representation of a number using
50
+ * the unary negation operator.
51
+ *
52
+ * @param {number} value - The number to negate
53
+ * @returns {number} The negated number
54
+ * @example
55
+ * ```yaml
56
+ * negative_value:
57
+ * "@pipe":
58
+ * - ["{a.output.data.value}"]
59
+ * - ["{@unary.negative}"]
60
+ * ```
61
+ */
11
62
  negative(value) {
12
63
  return -value;
13
64
  }
65
+ /**
66
+ * Returns the bitwise negation of a number using the
67
+ * bitwise NOT operator (`~`).
68
+ *
69
+ * @param {number} value - The number to bitwise negate
70
+ * @returns {number} The bitwise negation of the value
71
+ * @example
72
+ * ```yaml
73
+ * bitwise_not_value:
74
+ * "@pipe":
75
+ * - ["{a.output.data.value}"]
76
+ * - ["{@unary.bitwise_not}"]
77
+ * ```
78
+ */
14
79
  bitwise_not(value) {
15
80
  return ~value;
16
81
  }
@@ -173,6 +173,11 @@ class Virtual {
173
173
  {
174
174
  topic: params.topic,
175
175
  connection,
176
+ retry: params.retry ?? {
177
+ maximumAttempts: 3,
178
+ backoffCoefficient: 2,
179
+ maximumInterval: 30,
180
+ },
176
181
  callback: async function (input) {
177
182
  const response = await params.callback.apply(this, input.data.args);
178
183
  return {
@@ -296,6 +301,7 @@ class Virtual {
296
301
  connection: utils_1.polyfill.providerConfig(params),
297
302
  callback: params.callback,
298
303
  namespace: params.namespace,
304
+ retry: params.retry,
299
305
  });
300
306
  readonly = false;
301
307
  }
@@ -180,7 +180,7 @@ const getWorkflowYAML = (appId = key_1.HMNS, version = exports.VERSION) => {
180
180
  conditions:
181
181
  match:
182
182
  - expected: true
183
- actual:
183
+ actual:
184
184
  '@pipe':
185
185
  - ['{cycle_hook_cron.output.data.iterationCount}', '{trigger_cron.output.data.maxCycles}']
186
186
  - ['{@conditional.less_than}']
@@ -1,5 +1,6 @@
1
1
  import { ProviderConfig, ProvidersConfig } from './provider';
2
2
  import { LogLevel } from './logger';
3
+ import { RetryPolicy } from './stream';
3
4
  interface VirtualExecOptions {
4
5
  /**
5
6
  * Cache id when caching, flushing and retrieving function results.
@@ -39,6 +40,16 @@ interface VirtualConnectParams {
39
40
  * The linked worker function that will be called; optional if read only
40
41
  */
41
42
  callback?: (...args: any[]) => any;
43
+ /**
44
+ * Retry policy for the worker. Controls retry behavior with
45
+ * exponential backoff when the callback throws.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * { maximumAttempts: 3, backoffCoefficient: 2, maximumInterval: 30 }
50
+ * ```
51
+ */
52
+ retry?: RetryPolicy;
42
53
  }
43
54
  interface VirtualExecParams {
44
55
  /**
@@ -156,6 +167,16 @@ interface VirtualCronParams {
156
167
  * Options for the cron job
157
168
  */
158
169
  options: VirtualCronOptions;
170
+ /**
171
+ * Retry policy for the cron worker. Controls retry behavior with
172
+ * exponential backoff when the callback throws.
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * { maximumAttempts: 3, backoffCoefficient: 2, maximumInterval: 30 }
177
+ * ```
178
+ */
179
+ retry?: RetryPolicy;
159
180
  }
160
181
  interface VirtualInstanceOptions {
161
182
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",