@hotmeshio/hotmesh 0.0.52 → 0.0.54

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 (134) hide show
  1. package/README.md +22 -18
  2. package/build/index.d.ts +1 -2
  3. package/build/index.js +1 -3
  4. package/build/modules/enums.d.ts +8 -3
  5. package/build/modules/enums.js +16 -8
  6. package/build/modules/errors.d.ts +58 -20
  7. package/build/modules/errors.js +90 -33
  8. package/build/package.json +7 -2
  9. package/build/services/activities/activity.d.ts +8 -0
  10. package/build/services/activities/activity.js +63 -14
  11. package/build/services/activities/await.js +6 -6
  12. package/build/services/activities/cycle.d.ts +2 -2
  13. package/build/services/activities/cycle.js +5 -5
  14. package/build/services/activities/hook.js +9 -5
  15. package/build/services/activities/interrupt.d.ts +3 -3
  16. package/build/services/activities/interrupt.js +15 -6
  17. package/build/services/activities/signal.d.ts +2 -2
  18. package/build/services/activities/signal.js +4 -4
  19. package/build/services/activities/trigger.d.ts +5 -2
  20. package/build/services/activities/trigger.js +34 -4
  21. package/build/services/activities/worker.js +6 -6
  22. package/build/services/compiler/deployer.js +33 -5
  23. package/build/services/compiler/validator.d.ts +2 -0
  24. package/build/services/compiler/validator.js +5 -1
  25. package/build/services/durable/client.d.ts +7 -1
  26. package/build/services/durable/client.js +57 -38
  27. package/build/services/durable/exporter.d.ts +27 -81
  28. package/build/services/durable/exporter.js +153 -325
  29. package/build/services/durable/handle.d.ts +13 -8
  30. package/build/services/durable/handle.js +61 -48
  31. package/build/services/durable/index.d.ts +0 -2
  32. package/build/services/durable/index.js +0 -2
  33. package/build/services/durable/schemas/factory.d.ts +33 -0
  34. package/build/services/durable/schemas/factory.js +2356 -0
  35. package/build/services/durable/search.js +8 -8
  36. package/build/services/durable/worker.js +117 -25
  37. package/build/services/durable/workflow.d.ts +67 -52
  38. package/build/services/durable/workflow.js +322 -306
  39. package/build/services/engine/index.d.ts +2 -2
  40. package/build/services/engine/index.js +5 -2
  41. package/build/services/exporter/index.d.ts +2 -4
  42. package/build/services/exporter/index.js +4 -5
  43. package/build/services/hotmesh/index.d.ts +2 -2
  44. package/build/services/hotmesh/index.js +2 -2
  45. package/build/services/mapper/index.d.ts +6 -2
  46. package/build/services/mapper/index.js +6 -2
  47. package/build/services/pipe/functions/array.d.ts +2 -10
  48. package/build/services/pipe/functions/array.js +30 -28
  49. package/build/services/pipe/functions/conditional.d.ts +1 -0
  50. package/build/services/pipe/functions/conditional.js +3 -0
  51. package/build/services/pipe/functions/date.d.ts +1 -0
  52. package/build/services/pipe/functions/date.js +4 -0
  53. package/build/services/pipe/functions/index.d.ts +2 -0
  54. package/build/services/pipe/functions/index.js +2 -0
  55. package/build/services/pipe/functions/logical.d.ts +5 -0
  56. package/build/services/pipe/functions/logical.js +12 -0
  57. package/build/services/pipe/functions/object.d.ts +3 -0
  58. package/build/services/pipe/functions/object.js +25 -7
  59. package/build/services/pipe/index.d.ts +20 -3
  60. package/build/services/pipe/index.js +82 -16
  61. package/build/services/router/index.js +14 -3
  62. package/build/services/serializer/index.d.ts +3 -2
  63. package/build/services/serializer/index.js +11 -4
  64. package/build/services/store/clients/ioredis.js +6 -6
  65. package/build/services/store/clients/redis.js +7 -7
  66. package/build/services/store/index.d.ts +2 -0
  67. package/build/services/store/index.js +4 -1
  68. package/build/services/stream/clients/ioredis.js +8 -8
  69. package/build/services/stream/clients/redis.js +1 -1
  70. package/build/types/activity.d.ts +60 -5
  71. package/build/types/durable.d.ts +183 -36
  72. package/build/types/error.d.ts +48 -0
  73. package/build/types/error.js +2 -0
  74. package/build/types/exporter.d.ts +35 -7
  75. package/build/types/index.d.ts +4 -3
  76. package/build/types/job.d.ts +93 -6
  77. package/build/types/pipe.d.ts +81 -3
  78. package/build/types/stream.d.ts +61 -1
  79. package/build/types/stream.js +4 -0
  80. package/index.ts +1 -2
  81. package/modules/enums.ts +16 -8
  82. package/modules/errors.ts +139 -34
  83. package/package.json +7 -2
  84. package/services/activities/activity.ts +63 -14
  85. package/services/activities/await.ts +6 -6
  86. package/services/activities/cycle.ts +7 -6
  87. package/services/activities/hook.ts +12 -5
  88. package/services/activities/interrupt.ts +19 -9
  89. package/services/activities/signal.ts +6 -5
  90. package/services/activities/trigger.ts +43 -6
  91. package/services/activities/worker.ts +7 -7
  92. package/services/compiler/deployer.ts +33 -6
  93. package/services/compiler/validator.ts +7 -3
  94. package/services/durable/client.ts +49 -22
  95. package/services/durable/exporter.ts +162 -349
  96. package/services/durable/handle.ts +66 -53
  97. package/services/durable/index.ts +0 -2
  98. package/services/durable/schemas/factory.ts +2358 -0
  99. package/services/durable/search.ts +8 -8
  100. package/services/durable/worker.ts +128 -29
  101. package/services/durable/workflow.ts +371 -322
  102. package/services/engine/index.ts +8 -3
  103. package/services/exporter/index.ts +10 -12
  104. package/services/hotmesh/index.ts +4 -3
  105. package/services/mapper/index.ts +6 -2
  106. package/services/pipe/functions/array.ts +24 -37
  107. package/services/pipe/functions/conditional.ts +4 -0
  108. package/services/pipe/functions/date.ts +6 -0
  109. package/services/pipe/functions/index.ts +7 -5
  110. package/services/pipe/functions/logical.ts +11 -0
  111. package/services/pipe/functions/object.ts +26 -7
  112. package/services/pipe/index.ts +99 -21
  113. package/services/quorum/index.ts +1 -3
  114. package/services/router/index.ts +14 -3
  115. package/services/serializer/index.ts +12 -5
  116. package/services/store/clients/ioredis.ts +6 -6
  117. package/services/store/clients/redis.ts +7 -7
  118. package/services/store/index.ts +4 -1
  119. package/services/stream/clients/ioredis.ts +8 -8
  120. package/services/stream/clients/redis.ts +1 -1
  121. package/types/activity.ts +87 -15
  122. package/types/durable.ts +263 -75
  123. package/types/error.ts +52 -0
  124. package/types/exporter.ts +43 -9
  125. package/types/index.ts +14 -8
  126. package/types/job.ts +157 -36
  127. package/types/pipe.ts +84 -3
  128. package/types/stream.ts +82 -23
  129. package/build/services/durable/factory.d.ts +0 -17
  130. package/build/services/durable/factory.js +0 -817
  131. package/build/services/durable/meshos.d.ts +0 -127
  132. package/build/services/durable/meshos.js +0 -380
  133. package/services/durable/factory.ts +0 -818
  134. package/services/durable/meshos.ts +0 -441
@@ -15,7 +15,7 @@ import { TaskService } from '../task';
15
15
  import { AppVID } from '../../types/app';
16
16
  import { ActivityType } from '../../types/activity';
17
17
  import { CacheMode } from '../../types/cache';
18
- import { JobState, JobData, JobMetadata, JobOutput, JobStatus, JobInterruptOptions, JobCompletionOptions } from '../../types/job';
18
+ import { JobState, JobData, JobMetadata, JobOutput, JobStatus, JobInterruptOptions, JobCompletionOptions, ExtensionType } from '../../types/job';
19
19
  import { HotMeshApps, HotMeshConfig, HotMeshManifest, HotMeshSettings } from '../../types/hotmesh';
20
20
  import { JobMessageCallback } from '../../types/quorum';
21
21
  import { RedisClient, RedisMulti } from '../../types/redis';
@@ -72,7 +72,7 @@ declare class EngineService {
72
72
  hook(topic: string, data: JobData, status?: StreamStatus, code?: StreamCode): Promise<string>;
73
73
  hookTime(jobId: string, gId: string, topicOrActivity: string, type?: WorkListTaskType): Promise<string | void>;
74
74
  hookAll(hookTopic: string, data: JobData, keyResolver: JobStatsInput, queryFacets?: string[]): Promise<string[]>;
75
- pub(topic: string, data: JobData, context?: JobState): Promise<string>;
75
+ pub(topic: string, data: JobData, context?: JobState, extended?: ExtensionType): Promise<string>;
76
76
  sub(topic: string, callback: JobMessageCallback): Promise<void>;
77
77
  unsub(topic: string): Promise<void>;
78
78
  psub(wild: string, callback: JobMessageCallback): Promise<void>;
@@ -305,6 +305,7 @@ class EngineService {
305
305
  streamData.status = stream_1.StreamStatus.ERROR;
306
306
  streamData.data = error;
307
307
  streamData.code = error.code;
308
+ streamData.stack = error.stack;
308
309
  }
309
310
  else if (emit) {
310
311
  streamData.status = stream_1.StreamStatus.PENDING;
@@ -330,7 +331,9 @@ class EngineService {
330
331
  }
331
332
  // ****************** `INTERRUPT` ACTIVE JOBS *****************
332
333
  async interrupt(topic, jobId, options = {}) {
334
+ //immediately interrupt the job, going directly to the data source
333
335
  await this.store.interrupt(topic, jobId, options);
336
+ //now that the job is interrupted, we can clean up
334
337
  const context = await this.getState(topic, jobId);
335
338
  const completionOpts = {
336
339
  interrupt: options.descend,
@@ -405,10 +408,10 @@ class EngineService {
405
408
  }
406
409
  // ********************** PUB/SUB ENTRY POINT **********************
407
410
  //publish (returns just the job id)
408
- async pub(topic, data, context) {
411
+ async pub(topic, data, context, extended) {
409
412
  const activityHandler = await this.initActivity(topic, data, context);
410
413
  if (activityHandler) {
411
- return await activityHandler.process();
414
+ return await activityHandler.process(extended);
412
415
  }
413
416
  else {
414
417
  throw new Error(`unable to process activity for topic ${topic}`);
@@ -1,9 +1,8 @@
1
1
  import { ILogger } from '../logger';
2
2
  import { StoreService } from '../store';
3
- import { StringStringType, Symbols } from "../../types/serializer";
4
- import { RedisClient, RedisMulti } from '../../types/redis';
5
3
  import { DependencyExport, ExportOptions, JobActionExport, JobExport } from '../../types/exporter';
6
- import { SerializerService } from '../serializer';
4
+ import { RedisClient, RedisMulti } from '../../types/redis';
5
+ import { StringStringType, Symbols } from "../../types/serializer";
7
6
  /**
8
7
  * Downloads job data from Redis (hscan, hmget, hgetall)
9
8
  * Expands process data and includes dependency list
@@ -11,7 +10,6 @@ import { SerializerService } from '../serializer';
11
10
  declare class ExporterService {
12
11
  appId: string;
13
12
  logger: ILogger;
14
- serializer: SerializerService;
15
13
  store: StoreService<RedisClient, RedisMulti>;
16
14
  symbols: Promise<Symbols> | Symbols;
17
15
  constructor(appId: string, store: StoreService<RedisClient, RedisMulti>, logger: ILogger);
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExporterService = void 0;
4
- const serializer_1 = require("../serializer");
5
- const utils_1 = require("../../modules/utils");
6
4
  const key_1 = require("../../modules/key");
5
+ const utils_1 = require("../../modules/utils");
6
+ const serializer_1 = require("../serializer");
7
7
  /**
8
8
  * Downloads job data from Redis (hscan, hmget, hgetall)
9
9
  * Expands process data and includes dependency list
@@ -13,7 +13,6 @@ class ExporterService {
13
13
  this.appId = appId;
14
14
  this.logger = logger;
15
15
  this.store = store;
16
- this.serializer = new serializer_1.SerializerService();
17
16
  }
18
17
  /**
19
18
  * Convert the job hash and dependency list into a JobExport object.
@@ -63,12 +62,12 @@ class ExporterService {
63
62
  const [_, letters, numbers] = match;
64
63
  const path = this.inflateKey(letters);
65
64
  const dimensions = `${numbers.replace(/,/g, '/')}`;
66
- const resolved = this.serializer.fromString(value);
65
+ const resolved = serializer_1.SerializerService.fromString(value);
67
66
  process[`${dimensions}/${path}`] = resolved;
68
67
  }
69
68
  else if (key.length === 3) {
70
69
  //job state
71
- process[this.inflateKey(key)] = this.serializer.fromString(value);
70
+ process[this.inflateKey(key)] = serializer_1.SerializerService.fromString(value);
72
71
  }
73
72
  });
74
73
  return {
@@ -2,7 +2,7 @@ import { EngineService } from '../engine';
2
2
  import { ILogger } from '../logger';
3
3
  import { QuorumService } from '../quorum';
4
4
  import { WorkerService } from '../worker';
5
- import { JobState, JobData, JobOutput, JobStatus, JobInterruptOptions } from '../../types/job';
5
+ import { JobState, JobData, JobOutput, JobStatus, JobInterruptOptions, ExtensionType } from '../../types/job';
6
6
  import { HotMeshConfig, HotMeshManifest } from '../../types/hotmesh';
7
7
  import { JobMessageCallback, QuorumProfile, ThrottleOptions } from '../../types/quorum';
8
8
  import { JobStatsInput, GetStatsOptions, IdsResponse, StatsResponse } from '../../types/stats';
@@ -25,7 +25,7 @@ declare class HotMeshService {
25
25
  initEngine(config: HotMeshConfig, logger: ILogger): Promise<void>;
26
26
  initQuorum(config: HotMeshConfig, engine: EngineService, logger: ILogger): Promise<void>;
27
27
  doWork(config: HotMeshConfig, logger: ILogger): Promise<void>;
28
- pub(topic: string, data?: JobData, context?: JobState): Promise<string>;
28
+ pub(topic: string, data?: JobData, context?: JobState, extended?: ExtensionType): Promise<string>;
29
29
  sub(topic: string, callback: JobMessageCallback): Promise<void>;
30
30
  unsub(topic: string): Promise<void>;
31
31
  psub(wild: string, callback: JobMessageCallback): Promise<void>;
@@ -68,8 +68,8 @@ class HotMeshService {
68
68
  this.workers = await worker_1.WorkerService.init(this.namespace, this.appId, this.guid, config, logger);
69
69
  }
70
70
  // ************* PUB/SUB METHODS *************
71
- async pub(topic, data = {}, context) {
72
- return await this.engine?.pub(topic, data, context);
71
+ async pub(topic, data = {}, context, extended) {
72
+ return await this.engine?.pub(topic, data, context, extended);
73
73
  }
74
74
  async sub(topic, callback) {
75
75
  return await this.engine?.sub(topic, callback);
@@ -8,17 +8,21 @@ declare class MapperService {
8
8
  mapRules(): Record<string, unknown>;
9
9
  private traverseRules;
10
10
  /**
11
- * resolve a pipe expression of the form: { @pipe: [["{data.foo.bar}", 2, false, "hello world"]] }
11
+ * resolves a pipe expression of the form: { @pipe: [["{data.foo.bar}", 2, false, "hello world"]] }
12
12
  * @param value
13
13
  * @returns
14
14
  */
15
15
  private pipe;
16
16
  /**
17
- * resolve a simple mapping expression in the form: "{data.foo.bar}" or 2 or false or "hello world"
17
+ * resolves a mapping expression in the form: "{data.foo.bar}" or 2 or false or "hello world"
18
18
  * @param value
19
19
  * @returns
20
20
  */
21
21
  private resolve;
22
+ /**
23
+ * Evaluates a transition rule against the current job state and incoming Stream message
24
+ * to determine which (if any) transition should be taken.
25
+ */
22
26
  static evaluate(transitionRule: TransitionRule | boolean, context: JobState, code: StreamCode): boolean;
23
27
  }
24
28
  export { MapperService };
@@ -28,7 +28,7 @@ class MapperService {
28
28
  }
29
29
  }
30
30
  /**
31
- * resolve a pipe expression of the form: { @pipe: [["{data.foo.bar}", 2, false, "hello world"]] }
31
+ * resolves a pipe expression of the form: { @pipe: [["{data.foo.bar}", 2, false, "hello world"]] }
32
32
  * @param value
33
33
  * @returns
34
34
  */
@@ -37,7 +37,7 @@ class MapperService {
37
37
  return pipe.process();
38
38
  }
39
39
  /**
40
- * resolve a simple mapping expression in the form: "{data.foo.bar}" or 2 or false or "hello world"
40
+ * resolves a mapping expression in the form: "{data.foo.bar}" or 2 or false or "hello world"
41
41
  * @param value
42
42
  * @returns
43
43
  */
@@ -45,6 +45,10 @@ class MapperService {
45
45
  const pipe = new pipe_1.Pipe([[value]], this.data);
46
46
  return pipe.process();
47
47
  }
48
+ /**
49
+ * Evaluates a transition rule against the current job state and incoming Stream message
50
+ * to determine which (if any) transition should be taken.
51
+ */
48
52
  static evaluate(transitionRule, context, code) {
49
53
  if (typeof transitionRule === 'boolean') {
50
54
  return transitionRule;
@@ -2,23 +2,15 @@ declare class ArrayHandler {
2
2
  get(array: any[], index: number): any;
3
3
  length(array: any[]): any;
4
4
  concat(array1: any[], array2: any[]): any[];
5
- every(array: any[], callback: (value: any, index: number, array: any[]) => boolean): boolean;
6
- filter(array: any[], callback: (value: any, index: number, array: any[]) => boolean): any[];
7
- find(array: any[], callback: (value: any, index: number, array: any[]) => boolean): any;
8
- findIndex(array: any[], callback: (value: any, index: number, array: any[]) => boolean): number;
9
- forEach(array: any[], callback: (value: any, index: number, array: any[]) => void): void;
10
5
  indexOf(array: any[], searchElement: any, fromIndex?: number): number;
11
6
  join(array: any[], separator: string): string;
12
7
  lastIndexOf(array: any[], searchElement: any, fromIndex?: number): number;
13
- map(array: any[], callback: (value: any, index: number, array: any[]) => any): any[];
14
8
  pop(array: any[]): any;
15
- push(array: any[], ...items: any[]): number;
16
- reduce(array: any[], callback: (accumulator: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any;
9
+ push(array: any[], ...items: any[]): any[];
17
10
  reverse(array: any[]): any[];
18
11
  shift(array: any[]): any;
19
12
  slice(array: any[], start?: number, end?: number): any[];
20
- some(array: any[], callback: (value: any, index: number, array: any[]) => boolean): boolean;
21
- sort(array: any[], compareFunction?: (a: any, b: any) => number): any[];
13
+ sort(array: any[], order?: 'ASCENDING' | 'DESCENDING'): any[];
22
14
  splice(array: any[], start: number, deleteCount?: number, ...items: any[]): any[];
23
15
  unshift(array: any[], ...items: any[]): number;
24
16
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArrayHandler = void 0;
4
4
  class ArrayHandler {
5
5
  get(array, index) {
6
- return array[index];
6
+ return array?.[index || 0];
7
7
  }
8
8
  length(array) {
9
9
  return array?.length;
@@ -11,21 +11,6 @@ class ArrayHandler {
11
11
  concat(array1, array2) {
12
12
  return array1.concat(array2);
13
13
  }
14
- every(array, callback) {
15
- return array.every(callback);
16
- }
17
- filter(array, callback) {
18
- return array.filter(callback);
19
- }
20
- find(array, callback) {
21
- return array.find(callback);
22
- }
23
- findIndex(array, callback) {
24
- return array.findIndex(callback);
25
- }
26
- forEach(array, callback) {
27
- array.forEach(callback);
28
- }
29
14
  indexOf(array, searchElement, fromIndex) {
30
15
  return array.indexOf(searchElement, fromIndex);
31
16
  }
@@ -35,17 +20,12 @@ class ArrayHandler {
35
20
  lastIndexOf(array, searchElement, fromIndex) {
36
21
  return array.lastIndexOf(searchElement, fromIndex);
37
22
  }
38
- map(array, callback) {
39
- return array.map(callback);
40
- }
41
23
  pop(array) {
42
24
  return array.pop();
43
25
  }
44
26
  push(array, ...items) {
45
- return array.push(...items);
46
- }
47
- reduce(array, callback, initialValue) {
48
- return array.reduce(callback, initialValue);
27
+ array.push(...items);
28
+ return array;
49
29
  }
50
30
  reverse(array) {
51
31
  return array.reverse();
@@ -56,11 +36,33 @@ class ArrayHandler {
56
36
  slice(array, start, end) {
57
37
  return array.slice(start, end);
58
38
  }
59
- some(array, callback) {
60
- return array.some(callback);
61
- }
62
- sort(array, compareFunction) {
63
- return array.sort(compareFunction);
39
+ sort(array, order = 'ASCENDING') {
40
+ return array.sort((a, b) => {
41
+ if (order === 'ASCENDING') {
42
+ if (a === b)
43
+ return 0;
44
+ if (a === null || a === undefined)
45
+ return -1;
46
+ if (b === null || b === undefined)
47
+ return 1;
48
+ if (typeof a === 'string' && typeof b === 'string') {
49
+ return a.localeCompare(b);
50
+ }
51
+ return a < b ? -1 : 1;
52
+ }
53
+ else {
54
+ if (a === b)
55
+ return 0;
56
+ if (a === null || a === undefined)
57
+ return 1;
58
+ if (b === null || b === undefined)
59
+ return -1;
60
+ if (typeof a === 'string' && typeof b === 'string') {
61
+ return b.localeCompare(a);
62
+ }
63
+ return a > b ? -1 : 1;
64
+ }
65
+ });
64
66
  }
65
67
  splice(array, start, deleteCount, ...items) {
66
68
  return array.splice(start, deleteCount, ...items);
@@ -6,5 +6,6 @@ declare class ConditionalHandler {
6
6
  less_than(value1: number, value2: number): boolean;
7
7
  greater_than_or_equal(value1: number, value2: number): boolean;
8
8
  less_than_or_equal(value1: number, value2: number): boolean;
9
+ nullish(value1: any, value2: any): any;
9
10
  }
10
11
  export { ConditionalHandler };
@@ -23,5 +23,8 @@ class ConditionalHandler {
23
23
  less_than_or_equal(value1, value2) {
24
24
  return value1 <= value2;
25
25
  }
26
+ nullish(value1, value2) {
27
+ return value1 ?? value2;
28
+ }
26
29
  }
27
30
  exports.ConditionalHandler = ConditionalHandler;
@@ -46,6 +46,7 @@ declare class DateHandler {
46
46
  setHours(date: DateInput, hours: number, minutes?: number, seconds?: number, ms?: number): number;
47
47
  toDateString(date: DateInput): string;
48
48
  toISOString(date: DateInput): string;
49
+ toISOXString(date?: DateInput): string;
49
50
  toJSON(date: DateInput): string;
50
51
  toLocaleDateString(date: DateInput, locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
51
52
  toLocaleString(date: DateInput, locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DateHandler = void 0;
4
+ const utils_1 = require("../../../modules/utils");
4
5
  class DateHandler {
5
6
  /**
6
7
  * It is so common in mapping operations to use a string (ISO) date as input. This helper
@@ -142,6 +143,9 @@ class DateHandler {
142
143
  toISOString(date) {
143
144
  return DateHandler.getDateInstance(date).toISOString();
144
145
  }
146
+ toISOXString(date) {
147
+ return (0, utils_1.formatISODate)(date ? DateHandler.getDateInstance(date) : new Date());
148
+ }
145
149
  toJSON(date) {
146
150
  return DateHandler.getDateInstance(date).toJSON();
147
151
  }
@@ -3,6 +3,7 @@ import { BitwiseHandler } from './bitwise';
3
3
  import { ConditionalHandler } from './conditional';
4
4
  import { DateHandler } from './date';
5
5
  import { JsonHandler } from './json';
6
+ import { LogicalHandler } from './logical';
6
7
  import { MathHandler } from './math';
7
8
  import { NumberHandler } from './number';
8
9
  import { ObjectHandler } from './object';
@@ -15,6 +16,7 @@ declare const _default: {
15
16
  conditional: ConditionalHandler;
16
17
  date: DateHandler;
17
18
  json: JsonHandler;
19
+ logical: LogicalHandler;
18
20
  math: MathHandler;
19
21
  number: NumberHandler;
20
22
  object: ObjectHandler;
@@ -5,6 +5,7 @@ const bitwise_1 = require("./bitwise");
5
5
  const conditional_1 = require("./conditional");
6
6
  const date_1 = require("./date");
7
7
  const json_1 = require("./json");
8
+ const logical_1 = require("./logical");
8
9
  const math_1 = require("./math");
9
10
  const number_1 = require("./number");
10
11
  const object_1 = require("./object");
@@ -17,6 +18,7 @@ exports.default = {
17
18
  conditional: new conditional_1.ConditionalHandler(),
18
19
  date: new date_1.DateHandler(),
19
20
  json: new json_1.JsonHandler(),
21
+ logical: new logical_1.LogicalHandler(),
20
22
  math: new math_1.MathHandler(),
21
23
  number: new number_1.NumberHandler(),
22
24
  object: new object_1.ObjectHandler(),
@@ -0,0 +1,5 @@
1
+ declare class LogicalHandler {
2
+ and(firstValue: boolean, secondValue: boolean): boolean;
3
+ or(firstValue: boolean, secondValue: boolean): boolean;
4
+ }
5
+ export { LogicalHandler };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogicalHandler = void 0;
4
+ class LogicalHandler {
5
+ and(firstValue, secondValue) {
6
+ return firstValue && secondValue;
7
+ }
8
+ or(firstValue, secondValue) {
9
+ return firstValue || secondValue;
10
+ }
11
+ }
12
+ exports.LogicalHandler = LogicalHandler;
@@ -1,4 +1,7 @@
1
1
  declare class ObjectHandler {
2
+ get(obj: object, prop: string | symbol): any;
3
+ set(obj: object, prop: string | symbol, value: any): any;
4
+ create(...args: any[]): object;
2
5
  keys(obj: object): string[];
3
6
  values(obj: object): any[];
4
7
  entries(obj: object): [string, any][];
@@ -2,29 +2,47 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectHandler = void 0;
4
4
  class ObjectHandler {
5
+ get(obj, prop) {
6
+ return obj?.[prop];
7
+ }
8
+ set(obj, prop, value) {
9
+ if (!obj)
10
+ obj = {};
11
+ obj[prop] = value;
12
+ return obj;
13
+ }
14
+ create(...args) {
15
+ const obj = {};
16
+ if (args.length === 0)
17
+ return obj;
18
+ for (let i = 0; i < args.length; i += 2) {
19
+ obj[args[i]] = args[i + 1];
20
+ }
21
+ return obj;
22
+ }
5
23
  keys(obj) {
6
- return Object.keys(obj);
24
+ return obj && Object.keys(obj) || [];
7
25
  }
8
26
  values(obj) {
9
- return Object.values(obj);
27
+ return obj && Object.values(obj) || [];
10
28
  }
11
29
  entries(obj) {
12
- return Object.entries(obj);
30
+ return obj && Object.entries(obj) || [];
13
31
  }
14
32
  fromEntries(iterable) {
15
33
  return Object.fromEntries(iterable);
16
34
  }
17
35
  assign(target, ...sources) {
18
- return Object.assign(target, ...sources);
36
+ return Object.assign(target || {}, ...sources);
19
37
  }
20
38
  getOwnPropertyNames(obj) {
21
- return Object.getOwnPropertyNames(obj);
39
+ return Object.getOwnPropertyNames(obj || {});
22
40
  }
23
41
  getOwnPropertySymbols(obj) {
24
- return Object.getOwnPropertySymbols(obj);
42
+ return Object.getOwnPropertySymbols(obj || {});
25
43
  }
26
44
  getOwnPropertyDescriptor(obj, prop) {
27
- return Object.getOwnPropertyDescriptor(obj, prop);
45
+ return Object.getOwnPropertyDescriptor(obj || {}, prop);
28
46
  }
29
47
  defineProperty(obj, prop, descriptor) {
30
48
  return Object.defineProperty(obj, prop, descriptor);
@@ -1,10 +1,12 @@
1
1
  import { JobState, JobData } from '../../types/job';
2
- import { PipeItem, PipeItems, Pipe as PipeType } from '../../types/pipe';
2
+ import { PipeContext, PipeItem, PipeItems, Pipe as PipeType } from '../../types/pipe';
3
3
  declare class Pipe {
4
4
  rules: PipeType;
5
5
  jobData: JobData;
6
- constructor(rules: PipeType, jobData: JobData);
6
+ context: PipeContext;
7
+ constructor(rules: PipeType, jobData: JobData, context?: PipeContext);
7
8
  private isPipeType;
9
+ private isreduceType;
8
10
  static isPipeObject(obj: {
9
11
  [key: string]: unknown;
10
12
  } | PipeItem): boolean;
@@ -15,15 +17,30 @@ declare class Pipe {
15
17
  * loop through each PipeItem row in this Pipe, resolving and transforming line by line
16
18
  * @returns {any} the result of the pipe
17
19
  */
18
- process(): any;
20
+ process(resolved?: unknown[] | null): any;
21
+ /**
22
+ * Transforms iterable `input` into a single value. Vars $output, $item, $key
23
+ * and $input are available. The final statement in the iterator (the reduction)
24
+ * is assumed to be the return value. A default $output object may be provided
25
+ * to the iterator by placing the the second cell of the preceding row. Otherwise,
26
+ * construct the object during first run and ensure it is the first cell of the
27
+ * last row of the iterator, so it is returned as the $output for the next cycle
28
+ * @param {unknown[]} input
29
+ * @returns {unknown}
30
+ * @private
31
+ */
32
+ reduce(input: Array<unknown[]>): unknown;
19
33
  private processRow;
20
34
  static resolveFunction(functionName: string): any;
21
35
  processCells(cells: PipeItems): unknown[];
22
36
  private isFunction;
37
+ private isContextVariable;
23
38
  private isMappable;
24
39
  resolveCellValue(currentCell: PipeItem): unknown;
25
40
  private getNestedProperty;
26
41
  resolveMappableValue(currentCell: string): unknown;
42
+ resolveContextValue(currentCell: string): unknown;
43
+ resolveContextTerm(currentCell: string): string;
27
44
  resolveFunctionTerm(currentCell: string): string;
28
45
  resolveMapTerm(currentCell: string): string;
29
46
  }