@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
@@ -1,13 +1,45 @@
1
1
  import { LogLevel } from './logger';
2
2
  import { RedisClass, RedisOptions } from './redis';
3
- import { StringStringType } from './serializer';
3
+ import { StringAnyType, StringStringType } from './serializer';
4
+ import { StreamData, StreamError } from './stream';
5
+ /**
6
+ * Type definition for workflow configuration.
7
+ */
4
8
  type WorkflowConfig = {
9
+ /**
10
+ * Backoff coefficient for retry mechanism.
11
+ * @default 10 (HMSH_DURABLE_EXP_BACKOFF)
12
+ */
5
13
  backoffCoefficient?: number;
14
+ /**
15
+ * Maximum number of attempts for retries.
16
+ * @default 5 (HMSH_DURABLE_MAX_ATTEMPTS)
17
+ */
6
18
  maximumAttempts?: number;
19
+ /**
20
+ * Maximum interval between retries.
21
+ * @default 120s (HMSH_DURABLE_MAX_INTERVAL)
22
+ */
7
23
  maximumInterval?: string;
8
- initialInterval?: string;
24
+ /**
25
+ * Whether to throw an error on final failure after retries are exhausted
26
+ * or return the error object as a standard response containing error-related
27
+ * fields like `stack`, `code`, `message`.
28
+ * @default true
29
+ */
30
+ throwOnError?: boolean;
9
31
  };
10
32
  type WorkflowContext = {
33
+ /**
34
+ * can the workflow be retried if an error occurs
35
+ */
36
+ canRetry: boolean;
37
+ COUNTER: {
38
+ /**
39
+ * the reentrant semaphore parent counter object for object reference during increment
40
+ */
41
+ counter: number;
42
+ };
11
43
  /**
12
44
  * the reentrant semaphore, incremented in real-time as idempotent statements are re-traversed upon reentry. Indicates the current semaphore count.
13
45
  */
@@ -24,6 +56,14 @@ type WorkflowContext = {
24
56
  * the HotMesh App namespace. `durable` is the default.
25
57
  */
26
58
  namespace: string;
59
+ /**
60
+ * holds list of interruption payloads; if list is longer than 1 when the error is thrown, a `collator` subflow will be used
61
+ */
62
+ interruptionRegistry: any[];
63
+ /**
64
+ * entry point ancestor flow; might be the parent; will never be self
65
+ */
66
+ originJobId: string;
27
67
  /**
28
68
  * the workflow/job ID
29
69
  */
@@ -44,45 +84,133 @@ type WorkflowContext = {
44
84
  * the open telemetry span context for the workflow, used for logging and tracing. If a sink is enabled, this will be sent to the sink.
45
85
  */
46
86
  workflowSpan: string;
87
+ /**
88
+ * the native HotMesh message that encapsulates the arguments, metadata, and raw data for the workflow
89
+ */
90
+ raw: StreamData;
47
91
  };
48
92
  type WorkflowSearchOptions = {
93
+ /** FT index name (myapp:myindex) */
49
94
  index?: string;
95
+ /** FT prefixes (['myapp:myindex:prefix1', 'myapp:myindex:prefix2']) */
50
96
  prefix?: string[];
97
+ /**
98
+ * Schema mapping each field to a type with an optional sortable flag
99
+ */
51
100
  schema?: Record<string, {
52
101
  type: 'TEXT' | 'NUMERIC' | 'TAG';
53
102
  sortable?: boolean;
54
103
  }>;
55
- data?: Record<string, string>;
104
+ /** Additional data as a key-value record */
105
+ data?: StringStringType;
56
106
  };
57
107
  type WorkflowOptions = {
108
+ /**
109
+ * the namespace for the workflow; `durable` is the default namespace if not provided
110
+ */
58
111
  namespace?: string;
112
+ /**
113
+ * the task queue for the workflow; optional if entity is provided
114
+ */
59
115
  taskQueue?: string;
116
+ /**
117
+ * input arguments to pass in
118
+ */
60
119
  args: any[];
120
+ /**
121
+ * the job id
122
+ */
61
123
  workflowId?: string;
124
+ /**
125
+ * if invoking a workflow, passing 'entity' will apply the value as the workflowName, taskQueue, and prefix, ensuring the FT.SEARCH index is properly scoped. This is a convenience method but limits options.
126
+ */
62
127
  entity?: string;
128
+ /**
129
+ * the name of the user's workflow function; optional if 'entity' is provided
130
+ */
63
131
  workflowName?: string;
132
+ /**
133
+ * the parent workflow id; adjacent ancestor ID
134
+ */
64
135
  parentWorkflowId?: string;
136
+ /**
137
+ * the entry point workflow id
138
+ */
65
139
  originJobId?: string;
140
+ /**
141
+ * OpenTelemetry trace context for the workflow
142
+ */
66
143
  workflowTrace?: string;
144
+ /**
145
+ * OpenTelemetry span context for the workflow
146
+ */
67
147
  workflowSpan?: string;
148
+ /**
149
+ * the full-text-search (RediSearch) options for the workflow
150
+ */
68
151
  search?: WorkflowSearchOptions;
152
+ /**
153
+ * marker data (begins with a -)
154
+ */
155
+ marker?: StringStringType;
156
+ /**
157
+ * the workflow configuration object
158
+ */
69
159
  config?: WorkflowConfig;
160
+ /**
161
+ * sets the number of seconds a workflow may exist after completion. As the process engine is an in-memory cache, the default policy is to expire and scrub the job hash as soon as it completes.
162
+ */
70
163
  expire?: number;
164
+ /**
165
+ * default is true; if false, will not await the execution
166
+ */
167
+ await?: boolean;
71
168
  };
169
+ /**
170
+ * Options for setting up a hook.
171
+ * 'durable' is the default namespace if not provided; similar to setting `appid` in the YAML
172
+ */
72
173
  type HookOptions = {
174
+ /** Optional namespace under which the hook function will be grouped */
73
175
  namespace?: string;
176
+ /** Optional task queue, needed unless 'entity' is provided */
74
177
  taskQueue?: string;
178
+ /** Input arguments to pass into the hook */
75
179
  args: any[];
180
+ /**
181
+ * Optional entity name. If provided, applies as the workflowName,
182
+ * taskQueue, and prefix. This scopes the FT.SEARCH index appropriately.
183
+ * This is a convenience method but limits options.
184
+ */
76
185
  entity?: string;
186
+ /** Execution ID, also known as the job ID to hook into */
77
187
  workflowId?: string;
188
+ /** The name of the user's hook function */
78
189
  workflowName?: string;
190
+ /** Bind additional search terms immediately before hook reentry */
79
191
  search?: WorkflowSearchOptions;
192
+ /** Hook function constraints (backoffCoefficient, maximumAttempts, maximumInterval) */
80
193
  config?: WorkflowConfig;
81
194
  };
195
+ /**
196
+ * Options for sending signals in a workflow.
197
+ */
82
198
  type SignalOptions = {
199
+ /**
200
+ * Task queue associated with the workflow
201
+ */
83
202
  taskQueue: string;
84
- data: Record<string, any>;
203
+ /**
204
+ * Input data for the signal (any serializable object)
205
+ */
206
+ data: StringAnyType;
207
+ /**
208
+ * Execution ID, also known as the job ID
209
+ */
85
210
  workflowId: string;
211
+ /**
212
+ * Optional name of the user's workflow function
213
+ */
86
214
  workflowName?: string;
87
215
  };
88
216
  type ActivityWorkflowDataType = {
@@ -97,17 +225,7 @@ type WorkflowDataType = {
97
225
  workflowTopic: string;
98
226
  workflowDimension?: string;
99
227
  originJobId?: string;
100
- };
101
- type MeshOSClassConfig = {
102
- namespace: string;
103
- taskQueue: string;
104
- redisOptions: RedisOptions;
105
- redisClass: RedisClass;
106
- };
107
- type MeshOSConfig = {
108
- id?: string;
109
- await?: boolean;
110
- taskQueue?: string;
228
+ canRetry?: boolean;
111
229
  };
112
230
  type ConnectionConfig = {
113
231
  class: RedisClass;
@@ -121,11 +239,20 @@ type Registry = {
121
239
  [key: string]: Function;
122
240
  };
123
241
  type WorkerConfig = {
242
+ /** Connection configuration for the worker */
124
243
  connection: Connection;
244
+ /**
245
+ * Namespace used in the app configuration, denoted as `appid` in the YAML (e.g., 'durable')
246
+ * @default durable
247
+ */
125
248
  namespace?: string;
249
+ /** Task queue name, denoted as `subscribes` in the YAML (e.g., 'hello-world') */
126
250
  taskQueue: string;
251
+ /** Target function or a record type with a name (string) and reference function */
127
252
  workflow: Function | Record<string | symbol, Function>;
253
+ /** Additional options for configuring the worker */
128
254
  options?: WorkerOptions;
255
+ /** Search options for workflow execution details */
129
256
  search?: WorkflowSearchOptions;
130
257
  };
131
258
  type FindWhereQuery = {
@@ -150,25 +277,15 @@ type FindWhereOptions = {
150
277
  size: number;
151
278
  };
152
279
  };
153
- type MeshOSOptions = {
154
- name: string;
155
- options: WorkerOptions;
156
- };
157
- type MeshOSActivityOptions = {
158
- name: string;
159
- options: ActivityConfig;
160
- };
161
- type MeshOSWorkerOptions = {
162
- taskQueue?: string;
163
- allowList?: Array<MeshOSOptions | string>;
164
- logLevel?: LogLevel;
165
- maxSystemRetries?: number;
166
- backoffCoefficient?: number;
167
- };
168
280
  type WorkerOptions = {
281
+ /** Log level: debug, info, warn, error */
169
282
  logLevel?: LogLevel;
170
- maxSystemRetries?: number;
283
+ /** Maximum number of attempts, default 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
284
+ maximumAttempts?: number;
285
+ /** Backoff coefficient for retry logic, default 10 (HMSH_DURABLE_EXP_BACKOFF) */
171
286
  backoffCoefficient?: number;
287
+ /** Maximum interval between retries, default 120s (HMSH_DURABLE_MAX_INTERVAL) */
288
+ maximumInterval?: string;
172
289
  };
173
290
  type ContextType = {
174
291
  workflowId: string;
@@ -178,14 +295,44 @@ type FunctionSignature<T> = T extends (...args: infer A) => infer R ? (...args:
178
295
  type ProxyType<ACT> = {
179
296
  [K in keyof ACT]: FunctionSignature<ACT[K]>;
180
297
  };
298
+ /**
299
+ * Configuration settings for activities within a workflow.
300
+ */
181
301
  type ActivityConfig = {
302
+ /** Start to close timeout for the activity; not yet implemented */
182
303
  startToCloseTimeout?: string;
304
+ /** Configuration for specific activities, type not yet specified */
183
305
  activities?: any;
306
+ /** Retry policy configuration for activities */
184
307
  retryPolicy?: {
185
- initialInterval: string;
186
- maximumAttempts: number;
187
- backoffCoefficient: number;
188
- maximumInterval: string;
308
+ /** Maximum number of retry attempts, default is 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
309
+ maximumAttempts?: number;
310
+ /** Factor by which the retry timeout increases, default is 10 (HMSH_DURABLE_MAX_INTERVAL) */
311
+ backoffCoefficient?: number;
312
+ /** Maximum interval between retries, default is '120s' (HMSH_DURABLE_EXP_BACKOFF) */
313
+ maximumInterval?: string;
314
+ /** Whether to throw an error on failure, default is true */
315
+ throwOnError?: boolean;
189
316
  };
190
317
  };
191
- export { ActivityConfig, ActivityWorkflowDataType, ClientConfig, ContextType, ConnectionConfig, Connection, ProxyType, Registry, SignalOptions, FindOptions, FindWhereOptions, FindWhereQuery, HookOptions, MeshOSActivityOptions, MeshOSWorkerOptions, MeshOSClassConfig, MeshOSConfig, MeshOSOptions, WorkerConfig, WorkflowConfig, WorkerOptions, WorkflowSearchOptions, WorkflowDataType, WorkflowOptions, WorkflowContext, };
318
+ /**
319
+ * The proxy response object returned from the activity proxy flow
320
+ */
321
+ type ProxyResponseType<T> = {
322
+ data?: T;
323
+ $error?: StreamError;
324
+ done?: boolean;
325
+ jc: string;
326
+ ju: string;
327
+ };
328
+ /**
329
+ * The child flow response object returned from the main flow during recursion
330
+ */
331
+ type ChildResponseType<T> = {
332
+ data?: T;
333
+ $error?: StreamError;
334
+ done?: boolean;
335
+ jc: string;
336
+ ju: string;
337
+ };
338
+ export { ActivityConfig, ActivityWorkflowDataType, ChildResponseType, ClientConfig, ContextType, ConnectionConfig, Connection, ProxyResponseType, ProxyType, Registry, SignalOptions, FindOptions, FindWhereOptions, FindWhereQuery, HookOptions, WorkerConfig, WorkflowConfig, WorkerOptions, WorkflowSearchOptions, WorkflowDataType, WorkflowOptions, WorkflowContext, };
@@ -0,0 +1,48 @@
1
+ export type DurableChildErrorType = {
2
+ arguments: string[];
3
+ await?: boolean;
4
+ backoffCoefficient?: number;
5
+ index: number;
6
+ maximumAttempts?: number;
7
+ maximumInterval?: number;
8
+ originJobId: string | null;
9
+ parentWorkflowId: string;
10
+ workflowDimension: string;
11
+ workflowId: string;
12
+ workflowTopic: string;
13
+ };
14
+ export type DurableWaitForAllErrorType = {
15
+ items: string[];
16
+ workflowId: string;
17
+ workflowTopic: string;
18
+ parentWorkflowId: string;
19
+ originJobId: string | null;
20
+ size: number;
21
+ index: number;
22
+ workflowDimension: string;
23
+ };
24
+ export type DurableProxyErrorType = {
25
+ arguments: string[];
26
+ activityName: string;
27
+ backoffCoefficient?: number;
28
+ index: number;
29
+ maximumAttempts?: number;
30
+ maximumInterval?: number;
31
+ originJobId: string | null;
32
+ parentWorkflowId: string;
33
+ workflowDimension: string;
34
+ workflowId: string;
35
+ workflowTopic: string;
36
+ };
37
+ export type DurableWaitForErrorType = {
38
+ signalId: string;
39
+ index: number;
40
+ workflowDimension: string;
41
+ workflowId: string;
42
+ };
43
+ export type DurableSleepErrorType = {
44
+ duration: number;
45
+ index: number;
46
+ workflowDimension: string;
47
+ workflowId: string;
48
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,23 @@
1
1
  import { StringAnyType } from "./serializer";
2
2
  export type ExportItem = [(string | null), string, any];
3
+ /**
4
+ * job export data can be large, particularly transitions the timeline
5
+ */
6
+ export type ExportFields = 'data' | 'state' | 'status' | 'timeline' | 'transitions';
3
7
  export interface ExportOptions {
8
+ /**
9
+ * limit the export byte size by specifying an allowlist
10
+ */
11
+ allow?: Array<ExportFields>;
12
+ /**
13
+ * limit the export byte size by specifying a block list
14
+ */
15
+ block?: Array<ExportFields>;
16
+ /**
17
+ * If false, do not return timeline values (like child job response, proxy activity response, etc)
18
+ * @default true
19
+ */
20
+ values?: boolean;
4
21
  }
5
22
  export type JobAction = {
6
23
  cursor: number;
@@ -37,14 +54,25 @@ export interface ExportTransitions {
37
54
  export interface ExportCycles {
38
55
  [key: string]: string[];
39
56
  }
57
+ export type TimelineType = {
58
+ key: string;
59
+ value: Record<string, any> | string | number | null;
60
+ index: number;
61
+ secondary?: number;
62
+ dimension?: string;
63
+ };
64
+ export interface TransitionType {
65
+ activity: string;
66
+ dimensions: string;
67
+ created: string;
68
+ updated: string;
69
+ }
40
70
  export interface DurableJobExport {
41
- data: StringAnyType;
42
- dependencies: DependencyExport[];
43
- state: StringAnyType;
44
- status: string;
45
- timeline: JobTimeline[];
46
- transitions: ExportTransitions;
47
- cycles: ExportCycles;
71
+ data?: StringAnyType;
72
+ state?: StringAnyType;
73
+ status?: number;
74
+ timeline?: TimelineType[];
75
+ transitions?: TransitionType[];
48
76
  }
49
77
  export interface JobExport {
50
78
  dependencies: DependencyExport[];
@@ -3,14 +3,15 @@ export { App, AppVID, AppTransitions, AppSubscriptions } from './app';
3
3
  export { AsyncSignal } from './async';
4
4
  export { CacheMode } from './cache';
5
5
  export { CollationFaultType, CollationStage } from './collator';
6
- export { ActivityConfig, ActivityWorkflowDataType, ClientConfig, ContextType, ConnectionConfig, Connection, ProxyType, Registry, SignalOptions, FindOptions, FindWhereOptions, FindWhereQuery, HookOptions, MeshOSActivityOptions, MeshOSWorkerOptions, MeshOSClassConfig, MeshOSConfig, MeshOSOptions, WorkflowConfig, WorkerConfig, WorkerOptions, WorkflowContext, WorkflowSearchOptions, WorkflowDataType, WorkflowOptions, } from './durable';
6
+ export { ActivityConfig, ActivityWorkflowDataType, ChildResponseType, ClientConfig, ContextType, ConnectionConfig, Connection, ProxyResponseType, ProxyType, Registry, SignalOptions, FindOptions, FindWhereOptions, FindWhereQuery, HookOptions, WorkflowConfig, WorkerConfig, WorkerOptions, WorkflowContext, WorkflowSearchOptions, WorkflowDataType, WorkflowOptions, } from './durable';
7
+ export { DurableChildErrorType, DurableProxyErrorType, DurableSleepErrorType, DurableWaitForAllErrorType, DurableWaitForErrorType } from "./error";
7
8
  export { ActivityAction, DependencyExport, DurableJobExport, ExportCycles, ExportItem, ExportOptions, ExportTransitions, JobAction, JobExport, JobActionExport, JobTimeline } from './exporter';
8
9
  export { HookCondition, HookConditions, HookGate, HookInterface, HookRule, HookRules, HookSignal } from './hook';
9
10
  export { RedisClientType as IORedisClientType, RedisMultiType as IORedisMultiType } from './ioredisclient';
10
11
  export { ILogger } from './logger';
11
- export { JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState } from './job';
12
+ export { JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, ExtensionType } from './job';
12
13
  export { MappingStatements } from './map';
13
- export { Pipe, PipeItem, PipeItems } from './pipe';
14
+ export { Pipe, PipeContext, PipeItem, PipeItems, PipeObject, ReduceObject } from './pipe';
14
15
  export { HotMesh, HotMeshApp, HotMeshApps, HotMeshConfig, HotMeshEngine, RedisConfig, HotMeshGraph, HotMeshManifest, HotMeshSettings, HotMeshWorker, KeyStoreParams, KeyType } from './hotmesh';
15
16
  export { ActivateMessage, CronMessage, JobMessage, JobMessageCallback, PingMessage, PongMessage, QuorumMessage, QuorumMessageCallback, QuorumProfile, RollCallMessage, SubscriptionCallback, SystemHealth, ThrottleMessage, ThrottleOptions, WorkMessage } from './quorum';
16
17
  export { MultiResponseFlags, RedisClient, RedisMulti } from './redis';
@@ -1,3 +1,4 @@
1
+ import { StringStringType } from "./serializer";
1
2
  type JobData = Record<string, unknown | Record<string, unknown>>;
2
3
  type JobsData = Record<string, unknown>;
3
4
  type ActivityData = {
@@ -5,32 +6,81 @@ type ActivityData = {
5
6
  metadata?: Record<string, unknown>;
6
7
  };
7
8
  type JobMetadata = {
9
+ /** job_key */
8
10
  key?: string;
11
+ /** system assigned guid that corresponds to the transition message guid that spawned reentry */
9
12
  guid?: string;
13
+ /** system assigned guid; ensured created/deleted/created jobs are unique */
10
14
  gid: string;
15
+ /** job_id (jid+dad+aid) is composite key for activity */
11
16
  jid: string;
17
+ /** dimensional address for the activity (,0,0,1) */
12
18
  dad: string;
19
+ /** activity_id as in the YAML file */
13
20
  aid: string;
21
+ /** parent_job_id (pj+pd+pa) is composite key for parent activity */
14
22
  pj?: string;
23
+ /** parent_generational_id (system assigned at trigger inception); pg is the parent job's gid (just in case user created/deleted/created a job with same jid) */
15
24
  pg?: string;
25
+ /** parent_dimensional_address */
16
26
  pd?: string;
27
+ /** parent_activity_id */
17
28
  pa?: string;
29
+ /** sever the dependency chain if true (startChild/vs/execChild) */
18
30
  px?: boolean;
31
+ /** engine guid (one time subscriptions) */
19
32
  ngn?: string;
33
+ /** app_id */
20
34
  app: string;
35
+ /** app version */
21
36
  vrs: string;
37
+ /** subscription topic */
22
38
  tpc: string;
39
+ /** 201203120005 (slice of time) //time series */
23
40
  ts: string;
41
+ /** GMT created //job_created */
24
42
  jc: string;
43
+ /** GMT updated //job_updated */
25
44
  ju: string;
26
45
  js: JobStatus;
46
+ /** activity_type */
27
47
  atp: string;
48
+ /** activity_subtype */
28
49
  stp: string;
50
+ /** open telemetry span context */
29
51
  spn: string;
52
+ /** open telemetry trace context */
30
53
  trc: string;
54
+ /** stringified job error json: {message: string, code: number, error?} */
31
55
  err?: string;
56
+ /** process data expire policy */
32
57
  expire?: number;
33
58
  };
59
+ /**
60
+ * User-defined (extended) types for job data. Users may interleave
61
+ * data into the job hash safely by using the `ExtensionType` interface.
62
+ * The data will be prefixed as necessary using an underscore or
63
+ * dash to ensure it is not confused with system process data.
64
+ */
65
+ type ExtensionType = {
66
+ /**
67
+ * Custom search data field (name/value pairs) to seed the Hash.
68
+ * Every field will be prefixed with an underscore before being
69
+ * stored with the initial Hash data set along side system
70
+ * process data.
71
+ */
72
+ search?: StringStringType;
73
+ /**
74
+ * Custom marker data field used for adding a searchable marker to the job.
75
+ * markers always begin with a dash (-). Any field that does not
76
+ * begin with a dash will be removed and will not be inserted with
77
+ * the initial data set.
78
+ */
79
+ marker?: StringStringType;
80
+ };
81
+ /**
82
+ * job_status semaphore
83
+ */
34
84
  type JobStatus = number;
35
85
  type JobState = {
36
86
  metadata: JobMetadata;
@@ -44,28 +94,65 @@ type JobState = {
44
94
  };
45
95
  };
46
96
  type JobInterruptOptions = {
47
- /** Optional reason when throwing the error */
97
+ /**
98
+ * optional Reason; will be used as the error `message` when thrown
99
+ * @default 'Job Interrupted'
100
+ */
48
101
  reason?: string;
49
- /** default is `true` when `undefined` (throw JobInterrupted/410 error) */
102
+ /**
103
+ * throw JobInterrupted error upon interrupting
104
+ * @default true
105
+ */
50
106
  throw?: boolean;
51
- /** default behavior is `false` when `undefined` (do NOT interrupt child jobs) */
107
+ /**
108
+ * interrupt child/descendant jobs
109
+ * @default false
110
+ */
52
111
  descend?: boolean;
53
- /** default is false; if true, errors related to inactivation (like overage...already inactive) are suppressed/ignored */
112
+ /**
113
+ * if true, errors related to inactivation (like overage...already inactive) are suppressed/ignored
114
+ * @default false
115
+ */
54
116
  suppress?: boolean;
55
- /** how long to wait in seconds before fully expiring/removing the hash from Redis; the job is inactive, but can remain in the cache indefinitely. minimum 1 second.*/
117
+ /**
118
+ * how long to wait in seconds before fully expiring/removing the hash from Redis;
119
+ * the job is inactive, but can remain in the cache indefinitely;
120
+ * @default 1 second.
121
+ */
56
122
  expire?: number;
123
+ /**
124
+ * Optional Error Code; will be used as the error `code` when thrown
125
+ * @default 410
126
+ */
127
+ code?: number;
128
+ /**
129
+ * Optional stack trace
130
+ */
131
+ stack?: string;
57
132
  };
133
+ /**
134
+ * format when publishing job meta/data on the wire when it completes
135
+ */
58
136
  type JobOutput = {
59
137
  metadata: JobMetadata;
60
138
  data: JobData;
61
139
  };
140
+ /**
141
+ * jid+dad+aid is a composite guid; signal in and restore the full job context
142
+ */
62
143
  type PartialJobState = {
63
144
  metadata: JobMetadata | Pick<JobMetadata, 'jid' | 'dad' | 'aid'>;
64
145
  data: JobData;
65
146
  };
66
147
  type JobCompletionOptions = {
148
+ /** default false */
67
149
  emit?: boolean;
150
+ /** default undefined */
68
151
  interrupt?: boolean;
152
+ /**
153
+ * in seconds to wait before deleting/expiring job hash
154
+ * @default 1 second
155
+ */
69
156
  expire?: number;
70
157
  };
71
- export { JobCompletionOptions, JobInterruptOptions, JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, };
158
+ export { JobCompletionOptions, JobInterruptOptions, JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, ExtensionType, };
@@ -1,4 +1,82 @@
1
- type PipeItem = string | boolean | number | null;
1
+ /**
2
+ * Represents a single cell value in a pipeline row
3
+ * If the value is a string, the value will be a literal OR mapping expression
4
+ */
5
+ type PipeItem = string | boolean | number | null | object;
6
+ /**
7
+ * Array of `PipeItem` types.
8
+ */
2
9
  type PipeItems = PipeItem[];
3
- type Pipe = (PipeItem[] | Pipe)[];
4
- export { Pipe, PipeItem, PipeItems };
10
+ /**
11
+ * Represents a new nested context in the pipeline.
12
+ * As the structure is recursive, the nested pipe may contain an
13
+ * array of `PipeItem[]`, `PipeObject`, OR `ReduceObject` items.
14
+ */
15
+ type PipeObject = {
16
+ '@pipe': Array<PipeItem[] | PipeObject | ReduceObject>;
17
+ };
18
+ /**
19
+ * Reduce is similar to Pipe in that it represents a new context
20
+ * and may include an array of `PipeItem[]`, `PipeObject`, or `ReduceObject`.
21
+ * But it also iterates and produces output. The context variables,
22
+ * `$input`, `$output`, `$item`, `$key`, and `$index` are available.
23
+ * @example
24
+ *
25
+ * // Example of a reduce expression. The optional object is empty and
26
+ * // serves as the $output during iteration. The last step in the iteration
27
+ * // sets $output. if ther are no more iterations, the $output is returned
28
+ * // and provided to the next step in the pipeline.
29
+ *
30
+ * // If data is:
31
+ * // { response: ['a', 'b', 'c'] }
32
+ *
33
+ * // The reduced/transformed expression will be:
34
+ * // { 'a': 0, 'b': 1, 'c': 2 }
35
+ *
36
+ * // Arrays and objects may be iterated over and transformed.
37
+ *
38
+ * //YAML
39
+ * '@pipe':
40
+ * - ['{data.response}', {}]
41
+ * - '@reduce':
42
+ * - '@pipe':
43
+ * - ['{$output}']
44
+ * - '@pipe':
45
+ * - ['{$item}']
46
+ * - '@pipe':
47
+ * - ['{$index}']
48
+ * - ['{@object.set}']
49
+ */
50
+ type ReduceObject = {
51
+ '@reduce': Array<PipeItem[] | PipeObject | ReduceObject>;
52
+ };
53
+ /**
54
+ * Represents a sequence in the pipeline that can include arrays of `PipeItem`, `PipeObject`, or `ReduceObject`.
55
+ */
56
+ type Pipe = (PipeItem[] | PipeObject | ReduceObject)[];
57
+ /**
58
+ * Defines the context of a pipeline operation.
59
+ */
60
+ type PipeContext = {
61
+ /**
62
+ * Input of the current iteration.
63
+ */
64
+ $input: unknown[];
65
+ /**
66
+ * Output of the current iteration and the final output for the reducer.
67
+ */
68
+ $output: unknown;
69
+ /**
70
+ * Target item in the iterator.
71
+ */
72
+ $item: unknown;
73
+ /**
74
+ * Array index as string or object key.
75
+ */
76
+ $key: string;
77
+ /**
78
+ * Numeric index of the iterator.
79
+ */
80
+ $index: number;
81
+ };
82
+ export { Pipe, PipeContext, PipeItem, PipeItems, PipeObject, ReduceObject };