@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,16 +1,71 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectHandler = void 0;
4
+ /**
5
+ * Provides functional transformations for JavaScript objects within
6
+ * HotMesh mapping rules. Although inspired by JavaScript, these methods
7
+ * have been adapted to follow a functional approach. Each transformation
8
+ * is a function that expects one or more input parameters from the prior
9
+ * row in the `@pipe` structure.
10
+ *
11
+ * @remarks Invoked via `{@object.<method>}` in YAML mapping rules.
12
+ */
4
13
  class ObjectHandler {
14
+ /**
15
+ * Retrieves a property value from an object by its property name.
16
+ *
17
+ * @param {object} obj - The object from which to retrieve the property value
18
+ * @param {string | symbol} prop - The name of the property to retrieve
19
+ * @returns {any} The value of the specified property, or undefined if the object is nullish
20
+ * @example
21
+ * ```yaml
22
+ * second_color:
23
+ * "@pipe":
24
+ * - ["{a.output.data.colors}", "second"]
25
+ * - ["{@object.get}"]
26
+ * ```
27
+ */
5
28
  get(obj, prop) {
6
29
  return obj?.[prop];
7
30
  }
31
+ /**
32
+ * Sets a property on an object with a specified value and returns the
33
+ * object. If the input object is `undefined` or `null`, a new object
34
+ * will be created.
35
+ *
36
+ * @param {object} obj - The object to set the property on
37
+ * @param {string | symbol} prop - The name of the property to set
38
+ * @param {any} value - The value to assign to the property
39
+ * @returns {any} The modified object with the new property value
40
+ * @example
41
+ * ```yaml
42
+ * output:
43
+ * "@pipe":
44
+ * - ["{a.output.data.colors}", "third", "blue"]
45
+ * - ["{@object.set}"]
46
+ * ```
47
+ */
8
48
  set(obj, prop, value) {
9
49
  if (!obj)
10
50
  obj = {};
11
51
  obj[prop] = value;
12
52
  return obj;
13
53
  }
54
+ /**
55
+ * Creates a new object with specified key-value pairs. Arguments are
56
+ * provided as alternating key-value pairs. If no arguments are provided,
57
+ * an empty object will be created.
58
+ *
59
+ * @param {...any[]} args - Alternating key-value pairs (key1, value1, key2, value2, ...)
60
+ * @returns {object} A new object constructed from the provided key-value pairs
61
+ * @example
62
+ * ```yaml
63
+ * person:
64
+ * "@pipe":
65
+ * - ["name", "John", "age", 30, "city", "New York"]
66
+ * - ["{@object.create}"]
67
+ * ```
68
+ */
14
69
  create(...args) {
15
70
  const obj = {};
16
71
  if (args.length === 0)
@@ -20,60 +75,326 @@ class ObjectHandler {
20
75
  }
21
76
  return obj;
22
77
  }
78
+ /**
79
+ * Retrieves an array of a given object's own enumerable property names.
80
+ *
81
+ * @param {object} obj - The object whose property names are to be retrieved
82
+ * @returns {string[]} An array of the object's own enumerable property names
83
+ * @example
84
+ * ```yaml
85
+ * property_names:
86
+ * "@pipe":
87
+ * - ["{a.output.data}"]
88
+ * - ["{@object.keys}"]
89
+ * ```
90
+ */
23
91
  keys(obj) {
24
92
  return obj && Object.keys(obj) || [];
25
93
  }
94
+ /**
95
+ * Retrieves an array of a given object's own enumerable property values.
96
+ *
97
+ * @param {object} obj - The object from which to extract the values
98
+ * @returns {any[]} An array of the object's own enumerable property values
99
+ * @example
100
+ * ```yaml
101
+ * color_values:
102
+ * "@pipe":
103
+ * - ["{a.output.data.colors}"]
104
+ * - ["{@object.values}"]
105
+ * ```
106
+ */
26
107
  values(obj) {
27
108
  return obj && Object.values(obj) || [];
28
109
  }
110
+ /**
111
+ * Retrieves an array of the object's own enumerable key-value pairs.
112
+ *
113
+ * @param {object} obj - The object from which to extract the entries
114
+ * @returns {[string, any][]} An array of [key, value] pairs
115
+ * @example
116
+ * ```yaml
117
+ * color_entries:
118
+ * "@pipe":
119
+ * - ["{a.output.data.colors}"]
120
+ * - ["{@object.entries}"]
121
+ * ```
122
+ */
29
123
  entries(obj) {
30
124
  return obj && Object.entries(obj) || [];
31
125
  }
126
+ /**
127
+ * Transforms an array of key-value pairs into an object.
128
+ *
129
+ * @param {Iterable<[string, any]>} iterable - An iterable of key-value pairs (e.g., an array of [key, value] arrays)
130
+ * @returns {object} A new object constructed from the key-value pairs
131
+ * @example
132
+ * ```yaml
133
+ * color_object:
134
+ * "@pipe":
135
+ * - ["{a.output.data.pairs}"]
136
+ * - ["{@object.fromEntries}"]
137
+ * ```
138
+ */
32
139
  fromEntries(iterable) {
33
140
  return Object.fromEntries(iterable);
34
141
  }
142
+ /**
143
+ * Merges one or more source objects into a target object. Properties
144
+ * in later sources overwrite earlier ones.
145
+ *
146
+ * @param {object} target - The target object to merge into
147
+ * @param {...object[]} sources - One or more source objects to merge from
148
+ * @returns {object} The target object with all source properties merged in
149
+ * @example
150
+ * ```yaml
151
+ * combined_colors:
152
+ * "@pipe":
153
+ * - ["{@symbol.object}", "{a.output.data.colors}", "{b.output.data.colors}"]
154
+ * - ["{@object.assign}"]
155
+ * ```
156
+ */
35
157
  assign(target, ...sources) {
36
158
  return Object.assign(target || {}, ...sources);
37
159
  }
160
+ /**
161
+ * Returns an array of all property names (including non-enumerable) of
162
+ * an object.
163
+ *
164
+ * @param {object} obj - The object to retrieve property names from
165
+ * @returns {string[]} An array of all own property names
166
+ * @example
167
+ * ```yaml
168
+ * propertyNames:
169
+ * "@pipe":
170
+ * - ["{a.person}"]
171
+ * - ["{@object.getOwnPropertyNames}"]
172
+ * ```
173
+ */
38
174
  getOwnPropertyNames(obj) {
39
175
  return Object.getOwnPropertyNames(obj || {});
40
176
  }
177
+ /**
178
+ * Returns an array of all symbol properties of an object.
179
+ *
180
+ * @param {object} obj - The object to retrieve symbol properties from
181
+ * @returns {symbol[]} An array of all own symbol properties
182
+ * @example
183
+ * ```yaml
184
+ * symbolProperties:
185
+ * "@pipe":
186
+ * - ["{a.person}"]
187
+ * - ["{@object.getOwnPropertySymbols}"]
188
+ * ```
189
+ */
41
190
  getOwnPropertySymbols(obj) {
42
191
  return Object.getOwnPropertySymbols(obj || {});
43
192
  }
193
+ /**
194
+ * Returns a property descriptor for an own property of an object.
195
+ *
196
+ * @param {object} obj - The object to retrieve the property descriptor from
197
+ * @param {string | symbol} prop - The name of the property
198
+ * @returns {PropertyDescriptor | undefined} The property descriptor, or undefined if the property does not exist
199
+ * @example
200
+ * ```yaml
201
+ * ageDescriptor:
202
+ * "@pipe":
203
+ * - ["{a.person}", "age"]
204
+ * - ["{@object.getOwnPropertyDescriptor}"]
205
+ * ```
206
+ */
44
207
  getOwnPropertyDescriptor(obj, prop) {
45
208
  return Object.getOwnPropertyDescriptor(obj || {}, prop);
46
209
  }
210
+ /**
211
+ * Defines a new property or modifies an existing property on an object
212
+ * and returns the object.
213
+ *
214
+ * @param {object} obj - The object to define the property on
215
+ * @param {string | symbol} prop - The name of the property to define or modify
216
+ * @param {PropertyDescriptor} descriptor - The descriptor for the property being defined or modified
217
+ * @returns {object} The object with the defined property
218
+ * @example
219
+ * ```yaml
220
+ * person:
221
+ * "@pipe":
222
+ * - ["{a.person}", "city", {"value": "New York", "writable": false}]
223
+ * - ["{@object.defineProperty}"]
224
+ * ```
225
+ */
47
226
  defineProperty(obj, prop, descriptor) {
48
227
  return Object.defineProperty(obj, prop, descriptor);
49
228
  }
229
+ /**
230
+ * Defines new properties or modifies existing properties on an object
231
+ * and returns the object.
232
+ *
233
+ * @param {object} obj - The object to define properties on
234
+ * @param {PropertyDescriptorMap} props - An object whose keys represent property names and whose values are property descriptors
235
+ * @returns {object} The object with the defined properties
236
+ * @example
237
+ * ```yaml
238
+ * person:
239
+ * "@pipe":
240
+ * - ["{a.person}", {"age": {"value": 30}, "city": {"value": "New York", "writable": false}}]
241
+ * - ["{@object.defineProperties}"]
242
+ * ```
243
+ */
50
244
  defineProperties(obj, props) {
51
245
  return Object.defineProperties(obj, props);
52
246
  }
247
+ /**
248
+ * Freezes an object, making it immutable. Prevents new properties from
249
+ * being added, existing properties from being removed, and values of
250
+ * existing properties from being modified.
251
+ *
252
+ * @param {object} obj - The object to freeze
253
+ * @returns {object} The frozen object
254
+ * @example
255
+ * ```yaml
256
+ * person:
257
+ * "@pipe":
258
+ * - ["{a.person}"]
259
+ * - ["{@object.freeze}"]
260
+ * ```
261
+ */
53
262
  freeze(obj) {
54
263
  return Object.freeze(obj);
55
264
  }
265
+ /**
266
+ * Determines if an object is frozen.
267
+ *
268
+ * @param {object} obj - The object to check
269
+ * @returns {boolean} True if the object is frozen, otherwise false
270
+ * @example
271
+ * ```yaml
272
+ * isFrozen:
273
+ * "@pipe":
274
+ * - ["{a.person}"]
275
+ * - ["{@object.isFrozen}"]
276
+ * ```
277
+ */
56
278
  isFrozen(obj) {
57
279
  return Object.isFrozen(obj);
58
280
  }
281
+ /**
282
+ * Seals an object, preventing new properties from being added and
283
+ * marking all existing properties as non-configurable. Values of
284
+ * existing properties can still be modified.
285
+ *
286
+ * @param {object} obj - The object to seal
287
+ * @returns {object} The sealed object
288
+ * @example
289
+ * ```yaml
290
+ * person:
291
+ * "@pipe":
292
+ * - ["{a.person}"]
293
+ * - ["{@object.seal}"]
294
+ * ```
295
+ */
59
296
  seal(obj) {
60
297
  return Object.seal(obj);
61
298
  }
299
+ /**
300
+ * Determines if an object is sealed.
301
+ *
302
+ * @param {object} obj - The object to check
303
+ * @returns {boolean} True if the object is sealed, otherwise false
304
+ * @example
305
+ * ```yaml
306
+ * isSealed:
307
+ * "@pipe":
308
+ * - ["{a.person}"]
309
+ * - ["{@object.isSealed}"]
310
+ * ```
311
+ */
62
312
  isSealed(obj) {
63
313
  return Object.isSealed(obj);
64
314
  }
315
+ /**
316
+ * Prevents new properties from being added to an object. Existing
317
+ * properties can still be modified or deleted.
318
+ *
319
+ * @param {object} obj - The object to make non-extensible
320
+ * @returns {object} The non-extensible object
321
+ * @example
322
+ * ```yaml
323
+ * person:
324
+ * "@pipe":
325
+ * - ["{a.person}"]
326
+ * - ["{@object.preventExtensions}"]
327
+ * ```
328
+ */
65
329
  preventExtensions(obj) {
66
330
  return Object.preventExtensions(obj);
67
331
  }
332
+ /**
333
+ * Determines if an object is extensible (i.e., whether new properties
334
+ * can be added to it).
335
+ *
336
+ * @param {object} obj - The object to check
337
+ * @returns {boolean} True if the object is extensible, otherwise false
338
+ * @example
339
+ * ```yaml
340
+ * isExtensible:
341
+ * "@pipe":
342
+ * - ["{a.person}"]
343
+ * - ["{@object.isExtensible}"]
344
+ * ```
345
+ */
68
346
  isExtensible(obj) {
69
347
  return Object.isExtensible(obj);
70
348
  }
349
+ /**
350
+ * Determines if an object has a specified property as its own property
351
+ * (as opposed to inheriting it from the prototype chain).
352
+ *
353
+ * @param {object} obj - The object to check
354
+ * @param {string | symbol} prop - The name of the property to test
355
+ * @returns {boolean} True if the object has the specified own property, otherwise false
356
+ * @example
357
+ * ```yaml
358
+ * hasAge:
359
+ * "@pipe":
360
+ * - ["{a.person}", "age"]
361
+ * - ["{@object.hasOwnProperty}"]
362
+ * ```
363
+ */
71
364
  hasOwnProperty(obj, prop) {
72
365
  return Object.prototype.hasOwnProperty.call(obj, prop);
73
366
  }
367
+ /**
368
+ * Determines if an object exists in another object's prototype chain.
369
+ *
370
+ * @param {object} obj - The object whose prototype chain is to be checked
371
+ * @param {object} prototypeObj - The prototype object to search for
372
+ * @returns {boolean} True if the prototype object is found in the object's prototype chain, otherwise false
373
+ * @example
374
+ * ```yaml
375
+ * isPersonPrototypeOfEmployee:
376
+ * "@pipe":
377
+ * - ["{a.person}", "{a.employee}"]
378
+ * - ["{@object.isPrototypeOf}"]
379
+ * ```
380
+ */
74
381
  isPrototypeOf(obj, prototypeObj) {
75
382
  return Object.prototype.isPrototypeOf.call(obj, prototypeObj);
76
383
  }
384
+ /**
385
+ * Determines if a specified property on an object is enumerable.
386
+ *
387
+ * @param {object} obj - The object to check
388
+ * @param {string | symbol} prop - The name of the property to test
389
+ * @returns {boolean} True if the specified property is enumerable, otherwise false
390
+ * @example
391
+ * ```yaml
392
+ * isAgeEnumerable:
393
+ * "@pipe":
394
+ * - ["{a.person}", "age"]
395
+ * - ["{@object.propertyIsEnumerable}"]
396
+ * ```
397
+ */
77
398
  propertyIsEnumerable(obj, prop) {
78
399
  return Object.prototype.propertyIsEnumerable.call(obj, prop);
79
400
  }