@hotmeshio/hotmesh 0.14.0 → 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 (32) 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/router/error-handling/index.js +7 -1
  29. package/build/services/virtual/index.js +6 -0
  30. package/build/services/virtual/schemas/factory.js +1 -1
  31. package/build/types/virtual.d.ts +21 -0
  32. package/package.json +1 -1
@@ -1,21 +1,279 @@
1
+ /**
2
+ * Provides functional transformations for numbers within HotMesh mapping
3
+ * rules. These functions facilitate the manipulation and transformation
4
+ * of numbers during the mapping process. Although inspired by JavaScript,
5
+ * they have been adapted to follow a functional approach. Each transformation
6
+ * is a function that expects one or more input parameters from the prior
7
+ * row in the `@pipe` structure.
8
+ *
9
+ * @remarks Invoked via `{@number.<method>}` in YAML mapping rules.
10
+ */
1
11
  declare class NumberHandler {
12
+ /**
13
+ * Checks if a number is finite. Returns false for Infinity, -Infinity,
14
+ * and NaN.
15
+ *
16
+ * @param {number} input - The number to check
17
+ * @returns {boolean} True if the number is finite, otherwise false
18
+ * @example
19
+ * ```yaml
20
+ * is_finite:
21
+ * "@pipe":
22
+ * - ["{a.output.data.value}"]
23
+ * - ["{@number.isFinite}"]
24
+ * ```
25
+ */
2
26
  isFinite(input: number): boolean;
27
+ /**
28
+ * Checks if a number is even.
29
+ *
30
+ * @param {number} input - The number to check
31
+ * @returns {boolean} True if the number is even, otherwise false
32
+ * @example
33
+ * ```yaml
34
+ * is_even:
35
+ * "@pipe":
36
+ * - ["{a.output.data.value}"]
37
+ * - ["{@number.isEven}"]
38
+ * ```
39
+ */
3
40
  isEven(input: number): boolean;
41
+ /**
42
+ * Checks if a number is odd.
43
+ *
44
+ * @param {number} input - The number to check
45
+ * @returns {boolean} True if the number is odd, otherwise false
46
+ * @example
47
+ * ```yaml
48
+ * is_odd:
49
+ * "@pipe":
50
+ * - ["{a.output.data.value}"]
51
+ * - ["{@number.isOdd}"]
52
+ * ```
53
+ */
4
54
  isOdd(input: number): boolean;
55
+ /**
56
+ * Checks if a number is an integer (has no fractional component).
57
+ *
58
+ * @param {number} input - The number to check
59
+ * @returns {boolean} True if the number is an integer, otherwise false
60
+ * @example
61
+ * ```yaml
62
+ * is_integer:
63
+ * "@pipe":
64
+ * - ["{a.output.data.value}"]
65
+ * - ["{@number.isInteger}"]
66
+ * ```
67
+ */
5
68
  isInteger(input: number): boolean;
69
+ /**
70
+ * Checks if the given value is NaN (Not-a-Number).
71
+ *
72
+ * @param {number} input - The value to check
73
+ * @returns {boolean} True if the value is NaN, otherwise false
74
+ * @example
75
+ * ```yaml
76
+ * is_nan:
77
+ * "@pipe":
78
+ * - ["{a.output.data.value}"]
79
+ * - ["{@number.isNaN}"]
80
+ * ```
81
+ */
6
82
  isNaN(input: number): boolean;
83
+ /**
84
+ * Parses a string and returns a floating-point number.
85
+ *
86
+ * @param {string} input - The string to parse
87
+ * @returns {number} The parsed floating-point number, or NaN if the string cannot be parsed
88
+ * @example
89
+ * ```yaml
90
+ * float_value:
91
+ * "@pipe":
92
+ * - ["{a.output.data.string_value}"]
93
+ * - ["{@number.parseFloat}"]
94
+ * ```
95
+ */
7
96
  parseFloat(input: string): number;
97
+ /**
98
+ * Parses a string and returns an integer of the specified radix (base).
99
+ *
100
+ * @param {string} input - The string to parse
101
+ * @param {number} [radix] - The radix (base) to use for parsing (e.g., 10 for decimal, 16 for hexadecimal)
102
+ * @returns {number} The parsed integer, or NaN if the string cannot be parsed
103
+ * @example
104
+ * ```yaml
105
+ * decimal_value:
106
+ * "@pipe":
107
+ * - ["{a.output.data.hex_value}", 16]
108
+ * - ["{@number.parseInt}"]
109
+ * ```
110
+ */
8
111
  parseInt(input: string, radix?: number): number;
112
+ /**
113
+ * Formats a number using fixed-point notation with a specified number
114
+ * of digits after the decimal point.
115
+ *
116
+ * @param {number} input - The number to format
117
+ * @param {number} [digits] - The number of digits to appear after the decimal point
118
+ * @returns {string} A string representing the number in fixed-point notation
119
+ * @example
120
+ * ```yaml
121
+ * fixed_value:
122
+ * "@pipe":
123
+ * - ["{a.output.data.value}", 2]
124
+ * - ["{@number.toFixed}"]
125
+ * ```
126
+ */
9
127
  toFixed(input: number, digits?: number): string;
128
+ /**
129
+ * Formats a number using exponential (scientific) notation with a
130
+ * specified number of fractional digits.
131
+ *
132
+ * @param {number} input - The number to format
133
+ * @param {number} [fractionalDigits] - The number of digits after the decimal point
134
+ * @returns {string} A string representing the number in exponential notation
135
+ * @example
136
+ * ```yaml
137
+ * exponential_value:
138
+ * "@pipe":
139
+ * - ["{a.output.data.value}", 2]
140
+ * - ["{@number.toExponential}"]
141
+ * ```
142
+ */
10
143
  toExponential(input: number, fractionalDigits?: number): string;
144
+ /**
145
+ * Formats a number to a specified precision (total number of significant
146
+ * digits), using either fixed-point or exponential notation depending
147
+ * on the value.
148
+ *
149
+ * @param {number} input - The number to format
150
+ * @param {number} [precision] - The number of significant digits
151
+ * @returns {string} A string representing the number to the specified precision
152
+ * @example
153
+ * ```yaml
154
+ * precise_value:
155
+ * "@pipe":
156
+ * - ["{a.output.data.value}", 4]
157
+ * - ["{@number.toPrecision}"]
158
+ * ```
159
+ */
11
160
  toPrecision(input: number, precision?: number): string;
161
+ /**
162
+ * Checks if a number is greater than or equal to a comparison value.
163
+ *
164
+ * @param {number} input - The number to compare
165
+ * @param {number} compareValue - The value to compare against
166
+ * @returns {boolean} True if input is greater than or equal to compareValue
167
+ * @example
168
+ * ```yaml
169
+ * is_gte:
170
+ * "@pipe":
171
+ * - ["{a.output.data.value}", 10]
172
+ * - ["{@number.gte}"]
173
+ * ```
174
+ */
12
175
  gte(input: number, compareValue: number): boolean;
176
+ /**
177
+ * Checks if a number is less than or equal to a comparison value.
178
+ *
179
+ * @param {number} input - The number to compare
180
+ * @param {number} compareValue - The value to compare against
181
+ * @returns {boolean} True if input is less than or equal to compareValue
182
+ * @example
183
+ * ```yaml
184
+ * is_lte:
185
+ * "@pipe":
186
+ * - ["{a.output.data.value}", 10]
187
+ * - ["{@number.lte}"]
188
+ * ```
189
+ */
13
190
  lte(input: number, compareValue: number): boolean;
191
+ /**
192
+ * Checks if a number is strictly greater than a comparison value.
193
+ *
194
+ * @param {number} input - The number to compare
195
+ * @param {number} compareValue - The value to compare against
196
+ * @returns {boolean} True if input is greater than compareValue
197
+ * @example
198
+ * ```yaml
199
+ * is_gt:
200
+ * "@pipe":
201
+ * - ["{a.output.data.value}", 10]
202
+ * - ["{@number.gt}"]
203
+ * ```
204
+ */
14
205
  gt(input: number, compareValue: number): boolean;
206
+ /**
207
+ * Checks if a number is strictly less than a comparison value.
208
+ *
209
+ * @param {number} input - The number to compare
210
+ * @param {number} compareValue - The value to compare against
211
+ * @returns {boolean} True if input is less than compareValue
212
+ * @example
213
+ * ```yaml
214
+ * is_lt:
215
+ * "@pipe":
216
+ * - ["{a.output.data.value}", 10]
217
+ * - ["{@number.lt}"]
218
+ * ```
219
+ */
15
220
  lt(input: number, compareValue: number): boolean;
221
+ /**
222
+ * Returns the largest of the provided numbers.
223
+ *
224
+ * @param {...number[]} values - The numbers to compare
225
+ * @returns {number} The largest number among the provided values
226
+ * @example
227
+ * ```yaml
228
+ * maximum:
229
+ * "@pipe":
230
+ * - ["{a.output.data.val1}", "{a.output.data.val2}", "{a.output.data.val3}"]
231
+ * - ["{@number.max}"]
232
+ * ```
233
+ */
16
234
  max(...values: number[]): number;
235
+ /**
236
+ * Returns the smallest of the provided numbers.
237
+ *
238
+ * @param {...number[]} values - The numbers to compare
239
+ * @returns {number} The smallest number among the provided values
240
+ * @example
241
+ * ```yaml
242
+ * minimum:
243
+ * "@pipe":
244
+ * - ["{a.output.data.val1}", "{a.output.data.val2}", "{a.output.data.val3}"]
245
+ * - ["{@number.min}"]
246
+ * ```
247
+ */
17
248
  min(...values: number[]): number;
249
+ /**
250
+ * Returns the base raised to the exponent power.
251
+ *
252
+ * @param {number} base - The base number
253
+ * @param {number} exponent - The exponent to raise the base to
254
+ * @returns {number} The result of base raised to the power of exponent
255
+ * @example
256
+ * ```yaml
257
+ * power:
258
+ * "@pipe":
259
+ * - ["{a.output.data.base}", "{a.output.data.exponent}"]
260
+ * - ["{@number.pow}"]
261
+ * ```
262
+ */
18
263
  pow(base: number, exponent: number): number;
264
+ /**
265
+ * Rounds a number to the nearest integer.
266
+ *
267
+ * @param {number} input - The number to round
268
+ * @returns {number} The value of the number rounded to the nearest integer
269
+ * @example
270
+ * ```yaml
271
+ * rounded:
272
+ * "@pipe":
273
+ * - ["{a.output.data.value}"]
274
+ * - ["{@number.round}"]
275
+ * ```
276
+ */
19
277
  round(input: number): number;
20
278
  }
21
279
  export { NumberHandler };
@@ -1,58 +1,316 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NumberHandler = void 0;
4
+ /**
5
+ * Provides functional transformations for numbers within HotMesh mapping
6
+ * rules. These functions facilitate the manipulation and transformation
7
+ * of numbers during the mapping process. Although inspired by JavaScript,
8
+ * they have been adapted to follow a functional approach. Each transformation
9
+ * is a function that expects one or more input parameters from the prior
10
+ * row in the `@pipe` structure.
11
+ *
12
+ * @remarks Invoked via `{@number.<method>}` in YAML mapping rules.
13
+ */
4
14
  class NumberHandler {
15
+ /**
16
+ * Checks if a number is finite. Returns false for Infinity, -Infinity,
17
+ * and NaN.
18
+ *
19
+ * @param {number} input - The number to check
20
+ * @returns {boolean} True if the number is finite, otherwise false
21
+ * @example
22
+ * ```yaml
23
+ * is_finite:
24
+ * "@pipe":
25
+ * - ["{a.output.data.value}"]
26
+ * - ["{@number.isFinite}"]
27
+ * ```
28
+ */
5
29
  isFinite(input) {
6
30
  return Number.isFinite(input);
7
31
  }
32
+ /**
33
+ * Checks if a number is even.
34
+ *
35
+ * @param {number} input - The number to check
36
+ * @returns {boolean} True if the number is even, otherwise false
37
+ * @example
38
+ * ```yaml
39
+ * is_even:
40
+ * "@pipe":
41
+ * - ["{a.output.data.value}"]
42
+ * - ["{@number.isEven}"]
43
+ * ```
44
+ */
8
45
  isEven(input) {
9
46
  return !isNaN(input) && input % 2 === 0;
10
47
  }
48
+ /**
49
+ * Checks if a number is odd.
50
+ *
51
+ * @param {number} input - The number to check
52
+ * @returns {boolean} True if the number is odd, otherwise false
53
+ * @example
54
+ * ```yaml
55
+ * is_odd:
56
+ * "@pipe":
57
+ * - ["{a.output.data.value}"]
58
+ * - ["{@number.isOdd}"]
59
+ * ```
60
+ */
11
61
  isOdd(input) {
12
62
  return !isNaN(input) && input % 2 !== 0;
13
63
  }
64
+ /**
65
+ * Checks if a number is an integer (has no fractional component).
66
+ *
67
+ * @param {number} input - The number to check
68
+ * @returns {boolean} True if the number is an integer, otherwise false
69
+ * @example
70
+ * ```yaml
71
+ * is_integer:
72
+ * "@pipe":
73
+ * - ["{a.output.data.value}"]
74
+ * - ["{@number.isInteger}"]
75
+ * ```
76
+ */
14
77
  isInteger(input) {
15
78
  return Number.isInteger(input);
16
79
  }
80
+ /**
81
+ * Checks if the given value is NaN (Not-a-Number).
82
+ *
83
+ * @param {number} input - The value to check
84
+ * @returns {boolean} True if the value is NaN, otherwise false
85
+ * @example
86
+ * ```yaml
87
+ * is_nan:
88
+ * "@pipe":
89
+ * - ["{a.output.data.value}"]
90
+ * - ["{@number.isNaN}"]
91
+ * ```
92
+ */
17
93
  isNaN(input) {
18
94
  return Number.isNaN(input);
19
95
  }
96
+ /**
97
+ * Parses a string and returns a floating-point number.
98
+ *
99
+ * @param {string} input - The string to parse
100
+ * @returns {number} The parsed floating-point number, or NaN if the string cannot be parsed
101
+ * @example
102
+ * ```yaml
103
+ * float_value:
104
+ * "@pipe":
105
+ * - ["{a.output.data.string_value}"]
106
+ * - ["{@number.parseFloat}"]
107
+ * ```
108
+ */
20
109
  parseFloat(input) {
21
110
  return parseFloat(input);
22
111
  }
112
+ /**
113
+ * Parses a string and returns an integer of the specified radix (base).
114
+ *
115
+ * @param {string} input - The string to parse
116
+ * @param {number} [radix] - The radix (base) to use for parsing (e.g., 10 for decimal, 16 for hexadecimal)
117
+ * @returns {number} The parsed integer, or NaN if the string cannot be parsed
118
+ * @example
119
+ * ```yaml
120
+ * decimal_value:
121
+ * "@pipe":
122
+ * - ["{a.output.data.hex_value}", 16]
123
+ * - ["{@number.parseInt}"]
124
+ * ```
125
+ */
23
126
  parseInt(input, radix) {
24
127
  return parseInt(input, radix);
25
128
  }
129
+ /**
130
+ * Formats a number using fixed-point notation with a specified number
131
+ * of digits after the decimal point.
132
+ *
133
+ * @param {number} input - The number to format
134
+ * @param {number} [digits] - The number of digits to appear after the decimal point
135
+ * @returns {string} A string representing the number in fixed-point notation
136
+ * @example
137
+ * ```yaml
138
+ * fixed_value:
139
+ * "@pipe":
140
+ * - ["{a.output.data.value}", 2]
141
+ * - ["{@number.toFixed}"]
142
+ * ```
143
+ */
26
144
  toFixed(input, digits) {
27
145
  return input.toFixed(digits);
28
146
  }
147
+ /**
148
+ * Formats a number using exponential (scientific) notation with a
149
+ * specified number of fractional digits.
150
+ *
151
+ * @param {number} input - The number to format
152
+ * @param {number} [fractionalDigits] - The number of digits after the decimal point
153
+ * @returns {string} A string representing the number in exponential notation
154
+ * @example
155
+ * ```yaml
156
+ * exponential_value:
157
+ * "@pipe":
158
+ * - ["{a.output.data.value}", 2]
159
+ * - ["{@number.toExponential}"]
160
+ * ```
161
+ */
29
162
  toExponential(input, fractionalDigits) {
30
163
  return input.toExponential(fractionalDigits);
31
164
  }
165
+ /**
166
+ * Formats a number to a specified precision (total number of significant
167
+ * digits), using either fixed-point or exponential notation depending
168
+ * on the value.
169
+ *
170
+ * @param {number} input - The number to format
171
+ * @param {number} [precision] - The number of significant digits
172
+ * @returns {string} A string representing the number to the specified precision
173
+ * @example
174
+ * ```yaml
175
+ * precise_value:
176
+ * "@pipe":
177
+ * - ["{a.output.data.value}", 4]
178
+ * - ["{@number.toPrecision}"]
179
+ * ```
180
+ */
32
181
  toPrecision(input, precision) {
33
182
  return input.toPrecision(precision);
34
183
  }
184
+ /**
185
+ * Checks if a number is greater than or equal to a comparison value.
186
+ *
187
+ * @param {number} input - The number to compare
188
+ * @param {number} compareValue - The value to compare against
189
+ * @returns {boolean} True if input is greater than or equal to compareValue
190
+ * @example
191
+ * ```yaml
192
+ * is_gte:
193
+ * "@pipe":
194
+ * - ["{a.output.data.value}", 10]
195
+ * - ["{@number.gte}"]
196
+ * ```
197
+ */
35
198
  gte(input, compareValue) {
36
199
  return input >= compareValue;
37
200
  }
201
+ /**
202
+ * Checks if a number is less than or equal to a comparison value.
203
+ *
204
+ * @param {number} input - The number to compare
205
+ * @param {number} compareValue - The value to compare against
206
+ * @returns {boolean} True if input is less than or equal to compareValue
207
+ * @example
208
+ * ```yaml
209
+ * is_lte:
210
+ * "@pipe":
211
+ * - ["{a.output.data.value}", 10]
212
+ * - ["{@number.lte}"]
213
+ * ```
214
+ */
38
215
  lte(input, compareValue) {
39
216
  return input <= compareValue;
40
217
  }
218
+ /**
219
+ * Checks if a number is strictly greater than a comparison value.
220
+ *
221
+ * @param {number} input - The number to compare
222
+ * @param {number} compareValue - The value to compare against
223
+ * @returns {boolean} True if input is greater than compareValue
224
+ * @example
225
+ * ```yaml
226
+ * is_gt:
227
+ * "@pipe":
228
+ * - ["{a.output.data.value}", 10]
229
+ * - ["{@number.gt}"]
230
+ * ```
231
+ */
41
232
  gt(input, compareValue) {
42
233
  return input > compareValue;
43
234
  }
235
+ /**
236
+ * Checks if a number is strictly less than a comparison value.
237
+ *
238
+ * @param {number} input - The number to compare
239
+ * @param {number} compareValue - The value to compare against
240
+ * @returns {boolean} True if input is less than compareValue
241
+ * @example
242
+ * ```yaml
243
+ * is_lt:
244
+ * "@pipe":
245
+ * - ["{a.output.data.value}", 10]
246
+ * - ["{@number.lt}"]
247
+ * ```
248
+ */
44
249
  lt(input, compareValue) {
45
250
  return input < compareValue;
46
251
  }
252
+ /**
253
+ * Returns the largest of the provided numbers.
254
+ *
255
+ * @param {...number[]} values - The numbers to compare
256
+ * @returns {number} The largest number among the provided values
257
+ * @example
258
+ * ```yaml
259
+ * maximum:
260
+ * "@pipe":
261
+ * - ["{a.output.data.val1}", "{a.output.data.val2}", "{a.output.data.val3}"]
262
+ * - ["{@number.max}"]
263
+ * ```
264
+ */
47
265
  max(...values) {
48
266
  return Math.max(...values);
49
267
  }
268
+ /**
269
+ * Returns the smallest of the provided numbers.
270
+ *
271
+ * @param {...number[]} values - The numbers to compare
272
+ * @returns {number} The smallest number among the provided values
273
+ * @example
274
+ * ```yaml
275
+ * minimum:
276
+ * "@pipe":
277
+ * - ["{a.output.data.val1}", "{a.output.data.val2}", "{a.output.data.val3}"]
278
+ * - ["{@number.min}"]
279
+ * ```
280
+ */
50
281
  min(...values) {
51
282
  return Math.min(...values);
52
283
  }
284
+ /**
285
+ * Returns the base raised to the exponent power.
286
+ *
287
+ * @param {number} base - The base number
288
+ * @param {number} exponent - The exponent to raise the base to
289
+ * @returns {number} The result of base raised to the power of exponent
290
+ * @example
291
+ * ```yaml
292
+ * power:
293
+ * "@pipe":
294
+ * - ["{a.output.data.base}", "{a.output.data.exponent}"]
295
+ * - ["{@number.pow}"]
296
+ * ```
297
+ */
53
298
  pow(base, exponent) {
54
299
  return Math.pow(base, exponent);
55
300
  }
301
+ /**
302
+ * Rounds a number to the nearest integer.
303
+ *
304
+ * @param {number} input - The number to round
305
+ * @returns {number} The value of the number rounded to the nearest integer
306
+ * @example
307
+ * ```yaml
308
+ * rounded:
309
+ * "@pipe":
310
+ * - ["{a.output.data.value}"]
311
+ * - ["{@number.round}"]
312
+ * ```
313
+ */
56
314
  round(input) {
57
315
  return Math.round(input);
58
316
  }