@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,13 +1,45 @@
1
1
  import { LogLevel } from './logger';
2
2
  import { RedisClass, RedisOptions } from './redis';
3
3
  import { 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
  */
@@ -44,45 +76,129 @@ type WorkflowContext = {
44
76
  * 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
77
  */
46
78
  workflowSpan: string;
79
+ /**
80
+ * the native HotMesh message that encapsulates the arguments, metadata, and raw data for the workflow
81
+ */
82
+ raw: StreamData;
47
83
  };
48
84
  type WorkflowSearchOptions = {
85
+ /** FT index name (myapp:myindex) */
49
86
  index?: string;
87
+ /** FT prefixes (['myapp:myindex:prefix1', 'myapp:myindex:prefix2']) */
50
88
  prefix?: string[];
89
+ /**
90
+ * Schema mapping each field to a type with an optional sortable flag
91
+ */
51
92
  schema?: Record<string, {
52
93
  type: 'TEXT' | 'NUMERIC' | 'TAG';
53
94
  sortable?: boolean;
54
95
  }>;
96
+ /** Additional data as a key-value record */
55
97
  data?: Record<string, string>;
56
98
  };
57
99
  type WorkflowOptions = {
100
+ /**
101
+ * the namespace for the workflow; `durable` is the default namespace if not provided
102
+ */
58
103
  namespace?: string;
104
+ /**
105
+ * the task queue for the workflow; optional if entity is provided
106
+ */
59
107
  taskQueue?: string;
108
+ /**
109
+ * input arguments to pass in
110
+ */
60
111
  args: any[];
112
+ /**
113
+ * the job id
114
+ */
61
115
  workflowId?: string;
116
+ /**
117
+ * 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.
118
+ */
62
119
  entity?: string;
120
+ /**
121
+ * the name of the user's workflow function; optional if 'entity' is provided
122
+ */
63
123
  workflowName?: string;
124
+ /**
125
+ * the parent workflow id; adjacent ancestor ID
126
+ */
64
127
  parentWorkflowId?: string;
128
+ /**
129
+ * the entry point workflow id
130
+ */
65
131
  originJobId?: string;
132
+ /**
133
+ * OpenTelemetry trace context for the workflow
134
+ */
66
135
  workflowTrace?: string;
136
+ /**
137
+ * OpenTelemetry span context for the workflow
138
+ */
67
139
  workflowSpan?: string;
140
+ /**
141
+ * the full-text-search (RediSearch) options for the workflow
142
+ */
68
143
  search?: WorkflowSearchOptions;
144
+ /**
145
+ * the workflow configuration object
146
+ */
69
147
  config?: WorkflowConfig;
148
+ /**
149
+ * 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.
150
+ */
70
151
  expire?: number;
152
+ /**
153
+ * default is true; if false, will not await the execution
154
+ */
155
+ await?: boolean;
71
156
  };
157
+ /**
158
+ * Options for setting up a hook.
159
+ * 'durable' is the default namespace if not provided; similar to setting `appid` in the YAML
160
+ */
72
161
  type HookOptions = {
162
+ /** Optional namespace under which the hook function will be grouped */
73
163
  namespace?: string;
164
+ /** Optional task queue, needed unless 'entity' is provided */
74
165
  taskQueue?: string;
166
+ /** Input arguments to pass into the hook */
75
167
  args: any[];
168
+ /**
169
+ * Optional entity name. If provided, applies as the workflowName,
170
+ * taskQueue, and prefix. This scopes the FT.SEARCH index appropriately.
171
+ * This is a convenience method but limits options.
172
+ */
76
173
  entity?: string;
174
+ /** Execution ID, also known as the job ID to hook into */
77
175
  workflowId?: string;
176
+ /** The name of the user's hook function */
78
177
  workflowName?: string;
178
+ /** Bind additional search terms immediately before hook reentry */
79
179
  search?: WorkflowSearchOptions;
180
+ /** Hook function constraints (backoffCoefficient, maximumAttempts, maximumInterval) */
80
181
  config?: WorkflowConfig;
81
182
  };
183
+ /**
184
+ * Options for sending signals in a workflow.
185
+ */
82
186
  type SignalOptions = {
187
+ /**
188
+ * Task queue associated with the workflow
189
+ */
83
190
  taskQueue: string;
191
+ /**
192
+ * Input data for the signal (any serializable object)
193
+ */
84
194
  data: Record<string, any>;
195
+ /**
196
+ * Execution ID, also known as the job ID
197
+ */
85
198
  workflowId: string;
199
+ /**
200
+ * Optional name of the user's workflow function
201
+ */
86
202
  workflowName?: string;
87
203
  };
88
204
  type ActivityWorkflowDataType = {
@@ -97,17 +213,7 @@ type WorkflowDataType = {
97
213
  workflowTopic: string;
98
214
  workflowDimension?: string;
99
215
  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;
216
+ canRetry?: boolean;
111
217
  };
112
218
  type ConnectionConfig = {
113
219
  class: RedisClass;
@@ -121,11 +227,20 @@ type Registry = {
121
227
  [key: string]: Function;
122
228
  };
123
229
  type WorkerConfig = {
230
+ /** Connection configuration for the worker */
124
231
  connection: Connection;
232
+ /**
233
+ * Namespace used in the app configuration, denoted as `appid` in the YAML (e.g., 'durable')
234
+ * @default durable
235
+ */
125
236
  namespace?: string;
237
+ /** Task queue name, denoted as `subscribes` in the YAML (e.g., 'hello-world') */
126
238
  taskQueue: string;
239
+ /** Target function or a record type with a name (string) and reference function */
127
240
  workflow: Function | Record<string | symbol, Function>;
241
+ /** Additional options for configuring the worker */
128
242
  options?: WorkerOptions;
243
+ /** Search options for workflow execution details */
129
244
  search?: WorkflowSearchOptions;
130
245
  };
131
246
  type FindWhereQuery = {
@@ -150,25 +265,15 @@ type FindWhereOptions = {
150
265
  size: number;
151
266
  };
152
267
  };
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
268
  type WorkerOptions = {
269
+ /** Log level: debug, info, warn, error */
169
270
  logLevel?: LogLevel;
170
- maxSystemRetries?: number;
271
+ /** Maximum number of attempts, default 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
272
+ maximumAttempts?: number;
273
+ /** Backoff coefficient for retry logic, default 10 (HMSH_DURABLE_EXP_BACKOFF) */
171
274
  backoffCoefficient?: number;
275
+ /** Maximum interval between retries, default 120s (HMSH_DURABLE_MAX_INTERVAL) */
276
+ maximumInterval?: string;
172
277
  };
173
278
  type ContextType = {
174
279
  workflowId: string;
@@ -178,14 +283,44 @@ type FunctionSignature<T> = T extends (...args: infer A) => infer R ? (...args:
178
283
  type ProxyType<ACT> = {
179
284
  [K in keyof ACT]: FunctionSignature<ACT[K]>;
180
285
  };
286
+ /**
287
+ * Configuration settings for activities within a workflow.
288
+ */
181
289
  type ActivityConfig = {
290
+ /** Start to close timeout for the activity; not yet implemented */
182
291
  startToCloseTimeout?: string;
292
+ /** Configuration for specific activities, type not yet specified */
183
293
  activities?: any;
294
+ /** Retry policy configuration for activities */
184
295
  retryPolicy?: {
185
- initialInterval: string;
186
- maximumAttempts: number;
187
- backoffCoefficient: number;
188
- maximumInterval: string;
296
+ /** Maximum number of retry attempts, default is 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
297
+ maximumAttempts?: number;
298
+ /** Factor by which the retry timeout increases, default is 10 (HMSH_DURABLE_MAX_INTERVAL) */
299
+ backoffCoefficient?: number;
300
+ /** Maximum interval between retries, default is '120s' (HMSH_DURABLE_EXP_BACKOFF) */
301
+ maximumInterval?: string;
302
+ /** Whether to throw an error on failure, default is true */
303
+ throwOnError?: boolean;
189
304
  };
190
305
  };
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, };
306
+ /**
307
+ * The proxy response object returned from the activity proxy flow
308
+ */
309
+ type ProxyResponseType<T> = {
310
+ data?: T;
311
+ $error?: StreamError;
312
+ done?: boolean;
313
+ jc: string;
314
+ ju: string;
315
+ };
316
+ /**
317
+ * The child flow response object returned from the main flow during recursion
318
+ */
319
+ type ChildResponseType<T> = {
320
+ data?: T;
321
+ $error?: StreamError;
322
+ done?: boolean;
323
+ jc: string;
324
+ ju: string;
325
+ };
326
+ export { ActivityConfig, ActivityWorkflowDataType, ChildResponseType, ClientConfig, ContextType, ConnectionConfig, Connection, ProxyResponseType, ProxyType, Registry, SignalOptions, FindOptions, FindWhereOptions, FindWhereQuery, HookOptions, WorkerConfig, WorkflowConfig, WorkerOptions, WorkflowSearchOptions, WorkflowDataType, WorkflowOptions, WorkflowContext, };
@@ -37,14 +37,36 @@ export interface ExportTransitions {
37
37
  export interface ExportCycles {
38
38
  [key: string]: string[];
39
39
  }
40
+ export type IdemParts = {
41
+ index: number;
42
+ secondary?: number;
43
+ dimension?: string;
44
+ };
45
+ export type IdemType = {
46
+ key: string;
47
+ value: string;
48
+ parts: IdemParts;
49
+ };
50
+ export interface TimelineEntry {
51
+ activity: string;
52
+ dimensions: string;
53
+ created: string;
54
+ updated: string;
55
+ }
56
+ export interface TimestampParts {
57
+ activity: string;
58
+ dimensions: string;
59
+ created: string;
60
+ updated: string;
61
+ }
40
62
  export interface DurableJobExport {
41
63
  data: StringAnyType;
42
- dependencies: DependencyExport[];
64
+ dependencies?: Record<string, any>[];
43
65
  state: StringAnyType;
44
66
  status: string;
45
- timeline: JobTimeline[];
46
- transitions: ExportTransitions;
47
- cycles: ExportCycles;
67
+ timeline?: JobTimeline[];
68
+ idempotents: IdemType[];
69
+ replay: TimestampParts[];
48
70
  }
49
71
  export interface JobExport {
50
72
  dependencies: DependencyExport[];
@@ -3,14 +3,14 @@ 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
7
  export { ActivityAction, DependencyExport, DurableJobExport, ExportCycles, ExportItem, ExportOptions, ExportTransitions, JobAction, JobExport, JobActionExport, JobTimeline } from './exporter';
8
8
  export { HookCondition, HookConditions, HookGate, HookInterface, HookRule, HookRules, HookSignal } from './hook';
9
9
  export { RedisClientType as IORedisClientType, RedisMultiType as IORedisMultiType } from './ioredisclient';
10
10
  export { ILogger } from './logger';
11
11
  export { JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState } from './job';
12
12
  export { MappingStatements } from './map';
13
- export { Pipe, PipeItem, PipeItems } from './pipe';
13
+ export { Pipe, PipeContext, PipeItem, PipeItems, PipeObject, ReduceObject } from './pipe';
14
14
  export { HotMesh, HotMeshApp, HotMeshApps, HotMeshConfig, HotMeshEngine, RedisConfig, HotMeshGraph, HotMeshManifest, HotMeshSettings, HotMeshWorker, KeyStoreParams, KeyType } from './hotmesh';
15
15
  export { ActivateMessage, CronMessage, JobMessage, JobMessageCallback, PingMessage, PongMessage, QuorumMessage, QuorumMessageCallback, QuorumProfile, RollCallMessage, SubscriptionCallback, SystemHealth, ThrottleMessage, ThrottleOptions, WorkMessage } from './quorum';
16
16
  export { MultiResponseFlags, RedisClient, RedisMulti } from './redis';
@@ -5,32 +5,59 @@ type ActivityData = {
5
5
  metadata?: Record<string, unknown>;
6
6
  };
7
7
  type JobMetadata = {
8
+ /** job_key */
8
9
  key?: string;
10
+ /** system assigned guid that corresponds to the transition message guid that spawned reentry */
9
11
  guid?: string;
12
+ /** system assigned guid; ensured created/deleted/created jobs are unique */
10
13
  gid: string;
14
+ /** job_id (jid+dad+aid) is composite key for activity */
11
15
  jid: string;
16
+ /** dimensional address for the activity (,0,0,1) */
12
17
  dad: string;
18
+ /** activity_id as in the YAML file */
13
19
  aid: string;
20
+ /** parent_job_id (pj+pd+pa) is composite key for parent activity */
14
21
  pj?: string;
22
+ /** 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
23
  pg?: string;
24
+ /** parent_dimensional_address */
16
25
  pd?: string;
26
+ /** parent_activity_id */
17
27
  pa?: string;
28
+ /** sever the dependency chain if true (startChild/vs/execChild) */
18
29
  px?: boolean;
30
+ /** engine guid (one time subscriptions) */
19
31
  ngn?: string;
32
+ /** app_id */
20
33
  app: string;
34
+ /** app version */
21
35
  vrs: string;
36
+ /** subscription topic */
22
37
  tpc: string;
38
+ /** 201203120005 (slice of time) //time series */
23
39
  ts: string;
40
+ /** GMT created //job_created */
24
41
  jc: string;
42
+ /** GMT updated //job_updated */
25
43
  ju: string;
26
44
  js: JobStatus;
45
+ /** activity_type */
27
46
  atp: string;
47
+ /** activity_subtype */
28
48
  stp: string;
49
+ /** open telemetry span context */
29
50
  spn: string;
51
+ /** open telemetry trace context */
30
52
  trc: string;
53
+ /** stringified job error json: {message: string, code: number, error?} */
31
54
  err?: string;
55
+ /** process data expire policy */
32
56
  expire?: number;
33
57
  };
58
+ /**
59
+ * job_status semaphore
60
+ */
34
61
  type JobStatus = number;
35
62
  type JobState = {
36
63
  metadata: JobMetadata;
@@ -44,28 +71,65 @@ type JobState = {
44
71
  };
45
72
  };
46
73
  type JobInterruptOptions = {
47
- /** Optional reason when throwing the error */
74
+ /**
75
+ * optional Reason; will be used as the error `message` when thrown
76
+ * @default 'Job Interrupted'
77
+ */
48
78
  reason?: string;
49
- /** default is `true` when `undefined` (throw JobInterrupted/410 error) */
79
+ /**
80
+ * throw JobInterrupted error upon interrupting
81
+ * @default true
82
+ */
50
83
  throw?: boolean;
51
- /** default behavior is `false` when `undefined` (do NOT interrupt child jobs) */
84
+ /**
85
+ * interrupt child/descendant jobs
86
+ * @default false
87
+ */
52
88
  descend?: boolean;
53
- /** default is false; if true, errors related to inactivation (like overage...already inactive) are suppressed/ignored */
89
+ /**
90
+ * if true, errors related to inactivation (like overage...already inactive) are suppressed/ignored
91
+ * @default false
92
+ */
54
93
  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.*/
94
+ /**
95
+ * how long to wait in seconds before fully expiring/removing the hash from Redis;
96
+ * the job is inactive, but can remain in the cache indefinitely;
97
+ * @default 1 second.
98
+ */
56
99
  expire?: number;
100
+ /**
101
+ * Optional Error Code; will be used as the error `code` when thrown
102
+ * @default 410
103
+ */
104
+ code?: number;
105
+ /**
106
+ * Optional stack trace
107
+ */
108
+ stack?: string;
57
109
  };
110
+ /**
111
+ * format when publishing job meta/data on the wire when it completes
112
+ */
58
113
  type JobOutput = {
59
114
  metadata: JobMetadata;
60
115
  data: JobData;
61
116
  };
117
+ /**
118
+ * jid+dad+aid is a composite guid; signal in and restore the full job context
119
+ */
62
120
  type PartialJobState = {
63
121
  metadata: JobMetadata | Pick<JobMetadata, 'jid' | 'dad' | 'aid'>;
64
122
  data: JobData;
65
123
  };
66
124
  type JobCompletionOptions = {
125
+ /** default false */
67
126
  emit?: boolean;
127
+ /** default undefined */
68
128
  interrupt?: boolean;
129
+ /**
130
+ * in seconds to wait before deleting/expiring job hash
131
+ * @default 1 second
132
+ */
69
133
  expire?: number;
70
134
  };
71
135
  export { JobCompletionOptions, JobInterruptOptions, JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, };
@@ -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 };