@hotmeshio/hotmesh 0.0.51 → 0.0.53

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 (126) hide show
  1. package/README.md +13 -9
  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 +98 -18
  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 +65 -16
  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 +4 -4
  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.js +12 -3
  20. package/build/services/activities/worker.js +6 -6
  21. package/build/services/compiler/deployer.js +33 -5
  22. package/build/services/compiler/validator.d.ts +2 -0
  23. package/build/services/compiler/validator.js +5 -1
  24. package/build/services/durable/client.d.ts +7 -1
  25. package/build/services/durable/client.js +56 -30
  26. package/build/services/durable/exporter.d.ts +7 -72
  27. package/build/services/durable/exporter.js +105 -295
  28. package/build/services/durable/handle.d.ts +11 -6
  29. package/build/services/durable/handle.js +59 -46
  30. package/build/services/durable/index.d.ts +0 -2
  31. package/build/services/durable/index.js +0 -2
  32. package/build/services/durable/schemas/factory.d.ts +33 -0
  33. package/build/services/durable/schemas/factory.js +2356 -0
  34. package/build/services/durable/search.js +8 -8
  35. package/build/services/durable/worker.js +117 -25
  36. package/build/services/durable/workflow.d.ts +46 -43
  37. package/build/services/durable/workflow.js +273 -277
  38. package/build/services/engine/index.js +3 -0
  39. package/build/services/exporter/index.d.ts +2 -4
  40. package/build/services/exporter/index.js +4 -5
  41. package/build/services/mapper/index.d.ts +6 -2
  42. package/build/services/mapper/index.js +6 -2
  43. package/build/services/pipe/functions/array.d.ts +2 -10
  44. package/build/services/pipe/functions/array.js +30 -28
  45. package/build/services/pipe/functions/conditional.d.ts +1 -0
  46. package/build/services/pipe/functions/conditional.js +3 -0
  47. package/build/services/pipe/functions/date.d.ts +1 -0
  48. package/build/services/pipe/functions/date.js +4 -0
  49. package/build/services/pipe/functions/index.d.ts +2 -0
  50. package/build/services/pipe/functions/index.js +2 -0
  51. package/build/services/pipe/functions/logical.d.ts +5 -0
  52. package/build/services/pipe/functions/logical.js +12 -0
  53. package/build/services/pipe/functions/object.d.ts +3 -0
  54. package/build/services/pipe/functions/object.js +25 -7
  55. package/build/services/pipe/index.d.ts +20 -3
  56. package/build/services/pipe/index.js +82 -16
  57. package/build/services/router/index.js +14 -3
  58. package/build/services/serializer/index.d.ts +3 -2
  59. package/build/services/serializer/index.js +11 -4
  60. package/build/services/store/clients/ioredis.js +6 -6
  61. package/build/services/store/clients/redis.js +7 -7
  62. package/build/services/store/index.d.ts +2 -0
  63. package/build/services/store/index.js +4 -1
  64. package/build/services/stream/clients/ioredis.js +8 -8
  65. package/build/services/stream/clients/redis.js +1 -1
  66. package/build/types/activity.d.ts +60 -5
  67. package/build/types/durable.d.ts +168 -33
  68. package/build/types/exporter.d.ts +26 -4
  69. package/build/types/index.d.ts +2 -2
  70. package/build/types/job.d.ts +69 -5
  71. package/build/types/pipe.d.ts +81 -3
  72. package/build/types/stream.d.ts +61 -1
  73. package/build/types/stream.js +4 -0
  74. package/index.ts +1 -2
  75. package/modules/enums.ts +16 -8
  76. package/modules/errors.ts +174 -32
  77. package/package.json +7 -2
  78. package/services/activities/activity.ts +67 -18
  79. package/services/activities/await.ts +6 -6
  80. package/services/activities/cycle.ts +7 -6
  81. package/services/activities/hook.ts +4 -4
  82. package/services/activities/interrupt.ts +19 -9
  83. package/services/activities/signal.ts +6 -5
  84. package/services/activities/trigger.ts +16 -4
  85. package/services/activities/worker.ts +7 -7
  86. package/services/compiler/deployer.ts +33 -6
  87. package/services/compiler/validator.ts +7 -3
  88. package/services/durable/client.ts +47 -14
  89. package/services/durable/exporter.ts +110 -318
  90. package/services/durable/handle.ts +63 -50
  91. package/services/durable/index.ts +0 -2
  92. package/services/durable/schemas/factory.ts +2358 -0
  93. package/services/durable/search.ts +8 -8
  94. package/services/durable/worker.ts +128 -29
  95. package/services/durable/workflow.ts +304 -288
  96. package/services/engine/index.ts +4 -0
  97. package/services/exporter/index.ts +10 -12
  98. package/services/mapper/index.ts +6 -2
  99. package/services/pipe/functions/array.ts +24 -37
  100. package/services/pipe/functions/conditional.ts +4 -0
  101. package/services/pipe/functions/date.ts +6 -0
  102. package/services/pipe/functions/index.ts +7 -5
  103. package/services/pipe/functions/logical.ts +11 -0
  104. package/services/pipe/functions/object.ts +26 -7
  105. package/services/pipe/index.ts +99 -21
  106. package/services/quorum/index.ts +1 -3
  107. package/services/router/index.ts +14 -3
  108. package/services/serializer/index.ts +12 -5
  109. package/services/store/clients/ioredis.ts +6 -6
  110. package/services/store/clients/redis.ts +7 -7
  111. package/services/store/index.ts +4 -1
  112. package/services/stream/clients/ioredis.ts +8 -8
  113. package/services/stream/clients/redis.ts +1 -1
  114. package/types/activity.ts +87 -15
  115. package/types/durable.ts +246 -73
  116. package/types/exporter.ts +31 -5
  117. package/types/index.ts +6 -7
  118. package/types/job.ts +130 -36
  119. package/types/pipe.ts +84 -3
  120. package/types/stream.ts +82 -23
  121. package/build/services/durable/factory.d.ts +0 -17
  122. package/build/services/durable/factory.js +0 -817
  123. package/build/services/durable/meshos.d.ts +0 -127
  124. package/build/services/durable/meshos.js +0 -380
  125. package/services/durable/factory.ts +0 -818
  126. package/services/durable/meshos.ts +0 -441
@@ -1,18 +1,38 @@
1
+ /** Represents a policy for retrying stream operations based on error codes */
1
2
  export interface StreamRetryPolicy {
2
- [key: string]: [number, 'x'];
3
+ /**
4
+ * Key is error code, value is the retry profile.
5
+ * Tuple contains: [max retry count, retry type].
6
+ * 'x' denotes exponential backoff (default). Only 10, 100, 1000, 10000 are allowed retry intervals.
7
+ */
8
+ [key: string]: [number, 'x'?];
3
9
  }
10
+ /** A 3-digit status code representing the outcome of a stream operation */
4
11
  export type StreamCode = number;
12
+ /** Describes the structure of a stream error */
5
13
  export type StreamError = {
14
+ /** Descriptive message of the error */
6
15
  message: string;
16
+ /** Numeric code corresponding to the type of error */
7
17
  code: number;
18
+ /** Optional job identifier, used when communicating errors externally */
8
19
  job_id?: string;
20
+ /** Stack trace of the error if unhandled */
9
21
  stack?: string;
22
+ /** Name of the error if unhandled */
10
23
  name?: string;
24
+ /** Custom user-defined error details */
11
25
  error?: Record<string, unknown>;
26
+ /** True if originating via a standard transition message with an `error` status */
27
+ is_stream_error?: boolean;
12
28
  };
29
+ /** Enumerated status values for stream operations */
13
30
  export declare enum StreamStatus {
31
+ /** Indicates successful completion of the stream operation */
14
32
  SUCCESS = "success",
33
+ /** Indicates an error occurred during the stream operation */
15
34
  ERROR = "error",
35
+ /** Indicates the stream operation is still pending */
16
36
  PENDING = "pending"
17
37
  }
18
38
  export declare enum StreamDataType {
@@ -26,27 +46,51 @@ export declare enum StreamDataType {
26
46
  SIGNAL = "signal",
27
47
  INTERRUPT = "interrupt"
28
48
  }
49
+ /** Defines the structure of stream data used when passing stream messages (transitions) */
29
50
  export interface StreamData {
51
+ /** Metadata associated with the stream data */
30
52
  metadata: {
53
+ /** Globally unique identifier for the StreamData message to distinguish `retries` from new 'reentry/cycles' */
31
54
  guid: string;
55
+ /** Workflow/job topic */
32
56
  topic?: string;
57
+ /** Workflow/job ID */
33
58
  jid?: string;
59
+ /** Workflow Generational ID (internal GUID) */
34
60
  gid?: string;
61
+ /** Dimensional address indicating the message routing specifics */
35
62
  dad?: string;
63
+ /** Activity ID */
36
64
  aid: string;
65
+ /** OpenTelemetry Trace identifier */
37
66
  trc?: string;
67
+ /** OpenTelemetry Span identifier */
38
68
  spn?: string;
69
+ /** Current try count, used for retry logic */
39
70
  try?: number;
71
+ /**
72
+ * Indicates if the message should wait for a response.
73
+ * If explicitly false, the connection is severed immediately
74
+ * upon verifying (and returning) the Job ID.
75
+ */
40
76
  await?: boolean;
41
77
  };
78
+ /** Type of the data being streamed, optional */
42
79
  type?: StreamDataType;
80
+ /** Actual data being transmitted as a record of key-value pairs */
43
81
  data: Record<string, unknown>;
82
+ /** Policies related to retry logic, optional */
44
83
  policies?: {
45
84
  retry?: StreamRetryPolicy;
46
85
  };
86
+ /** Status of the stream, default assumed as 'success' */
47
87
  status?: StreamStatus;
88
+ /** HTTP-like status code for the stream, default assumed as 200 */
48
89
  code?: number;
90
+ /** Error stack trace */
91
+ stack?: string;
49
92
  }
93
+ /** Extends StreamData for responses, allowing for inheritance of the base properties */
50
94
  export interface StreamDataResponse extends StreamData {
51
95
  }
52
96
  export declare enum StreamRole {
@@ -54,19 +98,35 @@ export declare enum StreamRole {
54
98
  ENGINE = "engine",
55
99
  SYSTEM = "system"
56
100
  }
101
+ /**
102
+ * Represents a type for messages that have been reclaimed from a stream.
103
+ * Each item is a tuple containing a messageId and its details.
104
+ */
57
105
  export type ReclaimedMessageType = [
106
+ /** The stream ID, typically formatted as `<timestamp>-<count>` */
58
107
  messageId: string,
108
+ /** Details of the message, consisting of a key and its value */
59
109
  details: [
110
+ /** Key is always 'message' */
60
111
  key: string,
112
+ /** Value is a stringified representation of StreamData */
61
113
  value: string
62
114
  ]
63
115
  ][];
116
+ /** Configuration parameters for a stream */
64
117
  export type StreamConfig = {
118
+ /** Namespace under which the stream operates */
65
119
  namespace: string;
120
+ /** Application identifier */
66
121
  appId: string;
122
+ /** Globally unique identifier for the stream */
67
123
  guid: string;
124
+ /** Role associated with the stream */
68
125
  role: StreamRole;
126
+ /** Optional topic for the stream */
69
127
  topic?: string;
128
+ /** Delay before a message can be reclaimed, defaults to 60,000 milliseconds */
70
129
  reclaimDelay?: number;
130
+ /** Maximum number of reclaims allowed, defaults to 3. Values greater throw an error */
71
131
  reclaimCount?: number;
72
132
  };
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StreamRole = exports.StreamDataType = exports.StreamStatus = void 0;
4
+ /** Enumerated status values for stream operations */
4
5
  var StreamStatus;
5
6
  (function (StreamStatus) {
7
+ /** Indicates successful completion of the stream operation */
6
8
  StreamStatus["SUCCESS"] = "success";
9
+ /** Indicates an error occurred during the stream operation */
7
10
  StreamStatus["ERROR"] = "error";
11
+ /** Indicates the stream operation is still pending */
8
12
  StreamStatus["PENDING"] = "pending";
9
13
  })(StreamStatus = exports.StreamStatus || (exports.StreamStatus = {}));
10
14
  var StreamDataType;
package/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Durable } from './services/durable';
2
- import { MeshOSService as MeshOS } from './services/durable/meshos';
3
2
  import { HotMeshService as HotMesh } from './services/hotmesh';
4
3
  import { HotMeshConfig } from './types/hotmesh';
5
4
 
6
- export { Durable, HotMesh, HotMeshConfig, MeshOS };
5
+ export { Durable, HotMesh, HotMeshConfig };
7
6
  export * as Types from './types';
package/modules/enums.ts CHANGED
@@ -3,7 +3,7 @@ import { LogLevel } from "../types/logger";
3
3
  // HOTMESH SYSTEM
4
4
  export const HMSH_LOGLEVEL = process.env.HMSH_LOGLEVEL as LogLevel || 'info';
5
5
 
6
- // STATUS CODES AND MESSAGES
6
+ // HOTMESH STATUS CODES
7
7
  export const HMSH_CODE_SUCCESS = 200;
8
8
  export const HMSH_CODE_PENDING = 202;
9
9
  export const HMSH_CODE_NOTFOUND = 404;
@@ -11,15 +11,18 @@ export const HMSH_CODE_INTERRUPT = 410;
11
11
  export const HMSH_CODE_UNKNOWN = 500;
12
12
  export const HMSH_CODE_TIMEOUT = 504;
13
13
  export const HMSH_CODE_UNACKED = 999;
14
-
15
- export const HMSH_CODE_DURABLE_SLEEPFOR = 592;
16
- export const HMSH_CODE_DURABLE_INCOMPLETE = 593;
17
- export const HMSH_CODE_DURABLE_WAITFOR = 594;
14
+ // DURABLE STATUS CODES
15
+ export const HMSH_CODE_DURABLE_SLEEP = 588;
16
+ export const HMSH_CODE_DURABLE_ALL = 589;
17
+ export const HMSH_CODE_DURABLE_CHILD = 590;
18
+ export const HMSH_CODE_DURABLE_PROXY = 591;
19
+ export const HMSH_CODE_DURABLE_WAIT = 595;
18
20
  export const HMSH_CODE_DURABLE_TIMEOUT = 596;
19
21
  export const HMSH_CODE_DURABLE_MAXED = 597;
20
22
  export const HMSH_CODE_DURABLE_FATAL = 598;
21
23
  export const HMSH_CODE_DURABLE_RETRYABLE = 599;
22
24
 
25
+ // HOTMESH MESSAGES
23
26
  export const HMSH_STATUS_UNKNOWN = 'unknown';
24
27
 
25
28
  // QUORUM
@@ -36,8 +39,13 @@ export const HMSH_MAX_RETRIES = parseInt(process.env.HMSH_MAX_RETRIES, 10) || 3;
36
39
  export const HMSH_MAX_TIMEOUT_MS = parseInt(process.env.HMSH_MAX_TIMEOUT_MS, 10) || 60000;
37
40
  export const HMSH_GRADUATED_INTERVAL_MS = parseInt(process.env.HMSH_GRADUATED_INTERVAL_MS, 10) || 5000;
38
41
 
39
- const BASE_BLOCK_DURATION = 10000; // Modified for clarity
40
- const TEST_BLOCK_DURATION = 1000; // Modified for clarity
42
+ // DURABLE
43
+ export const HMSH_DURABLE_MAX_ATTEMPTS = 3;
44
+ export const HMSH_DURABLE_MAX_INTERVAL = '120s';
45
+ export const HMSH_DURABLE_EXP_BACKOFF = 10;
46
+
47
+ const BASE_BLOCK_DURATION = 10000;
48
+ const TEST_BLOCK_DURATION = 1000;
41
49
  export const HMSH_BLOCK_TIME_MS = process.env.HMSH_BLOCK_TIME_MS ? parseInt(process.env.HMSH_BLOCK_TIME_MS, 10) : (process.env.NODE_ENV === 'test' ? TEST_BLOCK_DURATION : BASE_BLOCK_DURATION);
42
50
 
43
51
  export const HMSH_XCLAIM_DELAY_MS = parseInt(process.env.HMSH_XCLAIM_DELAY_MS, 10) || 1000 * 60;
@@ -48,7 +56,7 @@ export const HMSH_XPENDING_COUNT = parseInt(process.env.HMSH_XPENDING_COUNT, 10)
48
56
  export const HMSH_EXPIRE_DURATION = parseInt(process.env.HMSH_EXPIRE_DURATION, 10) || 1;
49
57
 
50
58
  const BASE_FIDELITY_SECONDS = 5;
51
- const TEST_FIDELITY_SECONDS = 5;
59
+ const TEST_FIDELITY_SECONDS = 1;
52
60
  export const HMSH_FIDELITY_SECONDS = process.env.HMSH_FIDELITY_SECONDS ? parseInt(process.env.HMSH_FIDELITY_SECONDS, 10) : (process.env.NODE_ENV === 'test' ? TEST_FIDELITY_SECONDS : BASE_FIDELITY_SECONDS);
53
61
 
54
62
  export const HMSH_SCOUT_INTERVAL_SECONDS = parseInt(process.env.HMSH_SCOUT_INTERVAL_SECONDS, 10) || 60;
package/modules/errors.ts CHANGED
@@ -4,11 +4,13 @@ import {
4
4
  HMSH_CODE_DURABLE_MAXED,
5
5
  HMSH_CODE_DURABLE_TIMEOUT,
6
6
  HMSH_CODE_DURABLE_FATAL,
7
- HMSH_CODE_DURABLE_INCOMPLETE,
8
7
  HMSH_CODE_NOTFOUND,
9
8
  HMSH_CODE_DURABLE_RETRYABLE,
10
- HMSH_CODE_DURABLE_SLEEPFOR,
11
- HMSH_CODE_DURABLE_WAITFOR } from "./enums";
9
+ HMSH_CODE_DURABLE_WAIT,
10
+ HMSH_CODE_DURABLE_PROXY,
11
+ HMSH_CODE_DURABLE_CHILD,
12
+ HMSH_CODE_DURABLE_ALL,
13
+ HMSH_CODE_DURABLE_SLEEP } from "./enums";
12
14
 
13
15
  class GetStateError extends Error {
14
16
  jobId: string;
@@ -24,65 +26,201 @@ class SetStateError extends Error {
24
26
  }
25
27
  }
26
28
 
27
- //thrown when a signal set is incomplete but already configured
28
- //if a waitFor set has 'n' items, this can be thrown `n - 1` times
29
- class DurableIncompleteSignalError extends Error {
29
+ class DurableWaitForError extends Error {
30
30
  code: number;
31
- constructor(message: string) {
32
- super(message);
33
- this.code = HMSH_CODE_DURABLE_INCOMPLETE;
31
+ signalId: string;
32
+ workflowId: string;
33
+ index: number;
34
+ workflowDimension: string; //hook workflowDimension (e.g., ',0,1,0') (use empty string for `null`)
35
+ constructor(params: {
36
+ signalId: string,
37
+ index: number,
38
+ workflowDimension: string
39
+ workflowId: string;
40
+ }) {
41
+ super(`Durable WaitFor Error [${params.workflowId}]`);
42
+ this.signalId = params.signalId;
43
+ this.index = params.index;
44
+ this.workflowDimension = params.workflowDimension;
45
+ this.code = HMSH_CODE_DURABLE_WAIT;
34
46
  }
35
47
  }
36
48
 
37
- //the original waitFor error that is thrown for a new signal set
38
- class DurableWaitForSignalError extends Error {
49
+ class DurableProxyError extends Error {
50
+ activityName: string;
51
+ arguments: string[];
52
+ backoffCoefficient: number;
39
53
  code: number;
40
- signals: {signal: string, index: number}[]; //signal id and execution order in the workflow
41
- constructor(message: string, signals: {signal: string, index: number}[]) {
42
- super(message);
43
- this.signals = signals;
44
- this.code = HMSH_CODE_DURABLE_WAITFOR;
54
+ index: number;
55
+ maximumAttempts: number;
56
+ maximumInterval: number;
57
+ originJobId: string | null;
58
+ parentWorkflowId: string;
59
+ workflowDimension: string;
60
+ workflowId: string;
61
+ workflowTopic: string;
62
+ constructor(params: {
63
+ arguments: string[],
64
+ activityName: string,
65
+ backoffCoefficient?: number,
66
+ index: number,
67
+ maximumAttempts?: number,
68
+ maximumInterval?: number,
69
+ originJobId: string | null,
70
+ parentWorkflowId: string,
71
+ workflowDimension: string,
72
+ workflowId: string,
73
+ workflowTopic: string,
74
+ }) {
75
+ super(`Durable Proxy Activity Error [${params.parentWorkflowId}] => [${params.workflowId}]`);
76
+ this.arguments = params.arguments;
77
+ this.workflowId = params.workflowId;
78
+ this.workflowTopic = params.workflowTopic;
79
+ this.parentWorkflowId = params.parentWorkflowId;
80
+ this.originJobId = params.originJobId;
81
+ this.index = params.index;
82
+ this.activityName = params.activityName;
83
+ this.workflowDimension = params.workflowDimension;
84
+ this.backoffCoefficient = params.backoffCoefficient;
85
+ this.maximumAttempts = params.maximumAttempts;
86
+ this.maximumInterval = params.maximumInterval;
87
+ this.code = HMSH_CODE_DURABLE_PROXY;
88
+ }
89
+ }
90
+
91
+ class DurableChildError extends Error {
92
+ await: boolean;
93
+ arguments: string[];
94
+ backoffCoefficient: number;
95
+ code: number;
96
+ workflowDimension: string;
97
+ index: number;
98
+ maximumAttempts: number;
99
+ maximumInterval: number;
100
+ originJobId: string | null;
101
+ parentWorkflowId: string;
102
+ workflowId: string;
103
+ workflowTopic: string;
104
+ constructor(params: {
105
+ arguments: string[],
106
+ await?: boolean,
107
+ backoffCoefficient?: number,
108
+ index: number,
109
+ maximumAttempts?: number,
110
+ maximumInterval?: number,
111
+ originJobId: string | null,
112
+ parentWorkflowId: string,
113
+ workflowDimension: string,
114
+ workflowId: string,
115
+ workflowTopic: string,
116
+ }) {
117
+ super(`Durable Child Error [${params.parentWorkflowId}] => [${params.workflowId}]`);
118
+ this.arguments = params.arguments;
119
+ this.workflowId = params.workflowId;
120
+ this.workflowTopic = params.workflowTopic;
121
+ this.parentWorkflowId = params.parentWorkflowId;
122
+ this.originJobId = params.originJobId;
123
+ this.index = params.index;
124
+ this.workflowDimension = params.workflowDimension;
125
+ this.code = HMSH_CODE_DURABLE_CHILD;
126
+ this.await = params.await;
127
+ this.backoffCoefficient = params.backoffCoefficient;
128
+ this.maximumAttempts = params.maximumAttempts;
129
+ this.maximumInterval = params.maximumInterval;
130
+ }
131
+ }
132
+
133
+ class DurableWaitForAllError extends Error {
134
+ items: any[];
135
+ code: number;
136
+ workflowDimension: string;
137
+ size: number;
138
+ index: number;
139
+ originJobId: string | null;
140
+ parentWorkflowId: string;
141
+ workflowId: string;
142
+ workflowTopic: string;
143
+ constructor(params: {
144
+ items: string[],
145
+ workflowId: string,
146
+ workflowTopic: string,
147
+ parentWorkflowId: string,
148
+ originJobId: string | null,
149
+ size: number,
150
+ index: number,
151
+ workflowDimension: string
152
+ }) {
153
+ super(`Durable Wait for All Error [${params.parentWorkflowId}] => [${params.workflowId}]`);
154
+ this.items = params.items;
155
+ this.size = params.size;
156
+ this.workflowId = params.workflowId;
157
+ this.workflowTopic = params.workflowTopic;
158
+ this.parentWorkflowId = params.parentWorkflowId;
159
+ this.originJobId = params.originJobId;
160
+ this.index = params.index;
161
+ this.workflowDimension = params.workflowDimension;
162
+ this.code = HMSH_CODE_DURABLE_ALL;
45
163
  }
46
164
  }
47
165
 
48
- class DurableSleepForError extends Error {
166
+ class DurableSleepError extends Error {
167
+ workflowId: string;
49
168
  code: number;
50
169
  duration: number; //seconds
51
- index: number; //execution order in the workflow
52
- dimension: string; //hook dimension (e.g., ',0,1,0') (uses empty string for `null`)
53
- constructor(message: string, duration: number, index: number, dimension: string) {
54
- super(message);
55
- this.duration = duration;
56
- this.index = index;
57
- this.dimension = dimension;
58
- this.code = HMSH_CODE_DURABLE_SLEEPFOR;
170
+ index: number;
171
+ workflowDimension: string; //empty string for null
172
+ constructor(params: {
173
+ duration: number,
174
+ index: number,
175
+ workflowDimension: string,
176
+ workflowId: string,
177
+ }) {
178
+ super(`Durable Sleep Error [${params.workflowId}]`);
179
+ this.duration = params.duration;
180
+ this.workflowId = params.workflowId;
181
+ this.index = params.index;
182
+ this.workflowDimension = params.workflowDimension;
183
+ this.code = HMSH_CODE_DURABLE_SLEEP;
59
184
  }
60
185
  }
186
+
61
187
  class DurableTimeoutError extends Error {
62
188
  code: number;
63
- constructor(message: string) {
189
+ constructor(message: string, stack?: string) {
64
190
  super(message);
191
+ if (this.stack) {
192
+ this.stack = stack;
193
+ }
65
194
  this.code = HMSH_CODE_DURABLE_TIMEOUT;
66
195
  }
67
196
  }
68
197
  class DurableMaxedError extends Error {
69
198
  code: number;
70
- constructor(message: string) {
199
+ constructor(message: string, stackTrace?: string) {
71
200
  super(message);
201
+ if (stackTrace) {
202
+ this.stack = stackTrace;
203
+ }
72
204
  this.code = HMSH_CODE_DURABLE_MAXED;
73
205
  }
74
206
  }
75
207
  class DurableFatalError extends Error {
76
208
  code: number;
77
- constructor(message: string) {
209
+ constructor(message: string, stackTrace?: string) {
78
210
  super(message);
211
+ if (stackTrace) {
212
+ this.stack = stackTrace;
213
+ }
79
214
  this.code = HMSH_CODE_DURABLE_FATAL;
80
215
  }
81
216
  }
82
217
  class DurableRetryError extends Error {
83
218
  code: number;
84
- constructor(message: string) {
219
+ constructor(message: string, stackTrace?: string) {
85
220
  super(message);
221
+ if (stackTrace) {
222
+ this.stack = stackTrace;
223
+ }
86
224
  this.code = HMSH_CODE_DURABLE_RETRYABLE;
87
225
  }
88
226
  }
@@ -100,8 +238,10 @@ class RegisterTimeoutError extends Error {
100
238
  }
101
239
 
102
240
  class DuplicateJobError extends Error {
241
+ jobId: string;
103
242
  constructor(jobId: string) {
104
243
  super("Duplicate job");
244
+ this.jobId = jobId;
105
245
  this.message = `Duplicate job: ${jobId}`;
106
246
  }
107
247
  }
@@ -157,13 +297,15 @@ class CollationError extends Error {
157
297
 
158
298
  export {
159
299
  CollationError,
300
+ DurableChildError,
160
301
  DurableFatalError,
161
- DurableIncompleteSignalError,
162
302
  DurableMaxedError,
303
+ DurableProxyError,
163
304
  DurableRetryError,
164
- DurableSleepForError,
305
+ DurableSleepError,
165
306
  DurableTimeoutError,
166
- DurableWaitForSignalError,
307
+ DurableWaitForAllError,
308
+ DurableWaitForError,
167
309
  DuplicateJobError,
168
310
  ExecActivityError,
169
311
  GenerationalError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -21,13 +21,16 @@
21
21
  "start": "ts-node src/index.ts",
22
22
  "test": "NODE_ENV=test jest --detectOpenHandles --forceExit --verbose",
23
23
  "test:hmsh": "NODE_ENV=test jest ./tests/functional/index.test.ts --detectOpenHandles --verbose",
24
+ "test:pipe": "NODE_ENV=test jest ./tests/unit/services/pipe/index.test.ts --detectOpenHandles --forceExit --verbose",
24
25
  "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
25
26
  "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/index.test.ts --detectOpenHandles --forceExit --verbose",
26
27
  "test:trigger": "NODE_ENV=test jest ./tests/unit/services/activities/trigger.test.ts --detectOpenHandles --forceExit --verbose",
27
28
  "test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/index.test.ts --detectOpenHandles --forceExit --verbose",
28
29
  "test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
29
30
  "test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
31
+ "test:functional": "NODE_ENV=test jest ./tests/functional/*/index.test.ts --detectOpenHandles --forceExit --verbose",
30
32
  "test:emit": "NODE_ENV=test jest ./tests/functional/emit/index.test.ts --detectOpenHandles --forceExit --verbose",
33
+ "test:reentrant": "NODE_ENV=test jest ./tests/functional/reentrant/index.test.ts --detectOpenHandles --forceExit --verbose",
31
34
  "test:await": "NODE_ENV=test jest ./tests/functional/awaiter/index.test.ts --detectOpenHandles --forceExit --verbose",
32
35
  "test:hook": "NODE_ENV=test jest ./tests/functional/hook/index.test.ts --detectOpenHandles --forceExit --verbose",
33
36
  "test:signal": "NODE_ENV=test jest ./tests/functional/signal/index.test.ts --detectOpenHandles --forceExit --verbose",
@@ -46,13 +49,15 @@
46
49
  "test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
47
50
  "test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
48
51
  "test:durable": "NODE_ENV=test jest ./tests/durable/*/index.test.ts --detectOpenHandles --forceExit --verbose",
49
- "test:durable:meshos": "NODE_ENV=test jest ./tests/durable/meshos/index.test.ts --detectOpenHandles --forceExit --verbose",
52
+ "test:durable:basic": "NODE_ENV=test jest ./tests/durable/basic/index.test.ts --detectOpenHandles --forceExit --verbose",
53
+ "test:durable:collision": "NODE_ENV=test jest ./tests/durable/collision/index.test.ts --detectOpenHandles --forceExit --verbose",
50
54
  "test:durable:hello": "NODE_ENV=test jest ./tests/durable/helloworld/index.test.ts --detectOpenHandles --forceExit --verbose",
51
55
  "test:durable:interrupt": "NODE_ENV=test jest ./tests/durable/interrupt/index.test.ts --detectOpenHandles --forceExit --verbose",
52
56
  "test:durable:goodbye": "NODE_ENV=test jest ./tests/durable/goodbye/index.test.ts --detectOpenHandles --forceExit --verbose",
53
57
  "test:durable:hook": "NODE_ENV=test jest ./tests/durable/hook/index.test.ts --detectOpenHandles --forceExit --verbose",
54
58
  "test:durable:retry": "NODE_ENV=test jest ./tests/durable/retry/index.test.ts --detectOpenHandles --forceExit --verbose",
55
59
  "test:durable:fatal": "NODE_ENV=test jest ./tests/durable/fatal/index.test.ts --detectOpenHandles --forceExit --verbose",
60
+ "test:durable:unknown": "NODE_ENV=test jest ./tests/durable/unknown/index.test.ts --detectOpenHandles --forceExit --verbose",
56
61
  "test:durable:sleep": "NODE_ENV=test jest ./tests/durable/sleep/index.test.ts --detectOpenHandles --forceExit --verbose",
57
62
  "test:durable:signal": "NODE_ENV=test jest ./tests/durable/signal/index.test.ts --detectOpenHandles --forceExit --verbose",
58
63
  "test:durable:loopactivity": "NODE_ENV=test jest ./tests/durable/loopactivity/index.test.ts --detectOpenHandles --forceExit --verbose",