@hotmeshio/hotmesh 0.0.57 → 0.0.58

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 (90) hide show
  1. package/README.md +10 -10
  2. package/build/modules/enums.js +10 -1
  3. package/build/modules/key.d.ts +38 -0
  4. package/build/modules/key.js +46 -4
  5. package/build/modules/utils.d.ts +9 -0
  6. package/build/modules/utils.js +19 -1
  7. package/build/package.json +1 -1
  8. package/build/services/activities/activity.d.ts +28 -0
  9. package/build/services/activities/activity.js +46 -1
  10. package/build/services/activities/await.js +4 -0
  11. package/build/services/activities/cycle.d.ts +7 -0
  12. package/build/services/activities/cycle.js +16 -1
  13. package/build/services/activities/hook.d.ts +6 -0
  14. package/build/services/activities/hook.js +12 -2
  15. package/build/services/activities/interrupt.js +8 -0
  16. package/build/services/activities/signal.d.ts +6 -0
  17. package/build/services/activities/signal.js +15 -0
  18. package/build/services/activities/trigger.d.ts +4 -0
  19. package/build/services/activities/trigger.js +7 -1
  20. package/build/services/activities/worker.js +4 -0
  21. package/build/services/collator/index.d.ts +70 -0
  22. package/build/services/collator/index.js +91 -1
  23. package/build/services/compiler/deployer.js +38 -6
  24. package/build/services/compiler/index.d.ts +15 -0
  25. package/build/services/compiler/index.js +20 -0
  26. package/build/services/compiler/validator.d.ts +3 -0
  27. package/build/services/compiler/validator.js +25 -0
  28. package/build/services/connector/clients/ioredis.js +2 -0
  29. package/build/services/connector/clients/redis.js +2 -0
  30. package/build/services/connector/index.js +2 -0
  31. package/build/services/durable/client.d.ts +20 -0
  32. package/build/services/durable/client.js +25 -0
  33. package/build/services/durable/exporter.d.ts +22 -0
  34. package/build/services/durable/exporter.js +30 -1
  35. package/build/services/durable/handle.d.ts +36 -0
  36. package/build/services/durable/handle.js +46 -0
  37. package/build/services/durable/index.d.ts +4 -0
  38. package/build/services/durable/index.js +4 -0
  39. package/build/services/durable/schemas/factory.d.ts +29 -0
  40. package/build/services/durable/schemas/factory.js +29 -0
  41. package/build/services/durable/search.d.ts +97 -0
  42. package/build/services/durable/search.js +99 -0
  43. package/build/services/durable/worker.js +35 -6
  44. package/build/services/durable/workflow.d.ts +118 -0
  45. package/build/services/durable/workflow.js +153 -6
  46. package/build/services/engine/index.d.ts +5 -0
  47. package/build/services/engine/index.js +43 -1
  48. package/build/services/exporter/index.d.ts +27 -0
  49. package/build/services/exporter/index.js +33 -0
  50. package/build/services/hotmesh/index.js +8 -0
  51. package/build/services/logger/index.js +2 -0
  52. package/build/services/mapper/index.d.ts +14 -0
  53. package/build/services/mapper/index.js +14 -0
  54. package/build/services/pipe/functions/date.d.ts +7 -0
  55. package/build/services/pipe/functions/date.js +7 -0
  56. package/build/services/pipe/functions/math.js +2 -0
  57. package/build/services/pipe/index.d.ts +15 -0
  58. package/build/services/pipe/index.js +23 -2
  59. package/build/services/quorum/index.d.ts +7 -0
  60. package/build/services/quorum/index.js +21 -0
  61. package/build/services/reporter/index.d.ts +5 -0
  62. package/build/services/reporter/index.js +9 -0
  63. package/build/services/router/index.d.ts +9 -0
  64. package/build/services/router/index.js +30 -2
  65. package/build/services/serializer/index.js +23 -6
  66. package/build/services/store/cache.d.ts +19 -0
  67. package/build/services/store/cache.js +19 -0
  68. package/build/services/store/clients/ioredis.js +1 -0
  69. package/build/services/store/index.d.ts +55 -0
  70. package/build/services/store/index.js +81 -5
  71. package/build/services/stream/clients/ioredis.js +4 -1
  72. package/build/services/task/index.d.ts +9 -0
  73. package/build/services/task/index.js +31 -0
  74. package/build/services/telemetry/index.d.ts +7 -0
  75. package/build/services/telemetry/index.js +13 -1
  76. package/build/services/worker/index.d.ts +4 -0
  77. package/build/services/worker/index.js +6 -2
  78. package/build/types/activity.d.ts +81 -0
  79. package/build/types/durable.d.ts +255 -0
  80. package/build/types/exporter.d.ts +13 -0
  81. package/build/types/hotmesh.d.ts +10 -1
  82. package/build/types/hotmesh.js +3 -0
  83. package/build/types/index.js +1 -1
  84. package/build/types/job.d.ts +85 -0
  85. package/build/types/pipe.d.ts +65 -0
  86. package/build/types/quorum.d.ts +14 -0
  87. package/build/types/redis.d.ts +6 -0
  88. package/build/types/stream.d.ts +58 -0
  89. package/build/types/stream.js +4 -0
  90. package/package.json +1 -1
@@ -2,85 +2,306 @@ import { LogLevel } from './logger';
2
2
  import { RedisClass, RedisOptions } from './redis';
3
3
  import { StringAnyType, StringStringType } from './serializer';
4
4
  import { StreamData, StreamError } from './stream';
5
+ /**
6
+ * Type definition for workflow configuration.
7
+ */
5
8
  type WorkflowConfig = {
9
+ /**
10
+ * Backoff coefficient for retry mechanism.
11
+ * @default 10 (HMSH_DURABLE_EXP_BACKOFF)
12
+ */
6
13
  backoffCoefficient?: number;
14
+ /**
15
+ * Maximum number of attempts for retries.
16
+ * @default 5 (HMSH_DURABLE_MAX_ATTEMPTS)
17
+ */
7
18
  maximumAttempts?: number;
19
+ /**
20
+ * Maximum interval between retries.
21
+ * @default 120s (HMSH_DURABLE_MAX_INTERVAL)
22
+ */
8
23
  maximumInterval?: 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
+ */
9
30
  throwOnError?: boolean;
10
31
  };
11
32
  type WorkflowContext = {
33
+ /**
34
+ * can the workflow be retried if an error occurs
35
+ */
12
36
  canRetry: boolean;
13
37
  COUNTER: {
38
+ /**
39
+ * the reentrant semaphore parent counter object for object reference during increment
40
+ */
14
41
  counter: number;
15
42
  };
43
+ /**
44
+ * the reentrant semaphore, incremented in real-time as idempotent statements are re-traversed upon reentry. Indicates the current semaphore count.
45
+ */
16
46
  counter: number;
47
+ /**
48
+ * number as string for the replay cursor
49
+ */
17
50
  cursor: string;
51
+ /**
52
+ * the replay hash of name/value pairs representing prior executions
53
+ */
18
54
  replay: StringStringType;
55
+ /**
56
+ * the HotMesh App namespace. `durable` is the default.
57
+ */
19
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
+ */
20
62
  interruptionRegistry: any[];
63
+ /**
64
+ * entry point ancestor flow; might be the parent; will never be self
65
+ */
21
66
  originJobId: string;
67
+ /**
68
+ * the workflow/job ID
69
+ */
22
70
  workflowId: string;
71
+ /**
72
+ * the dimensional isolation for the reentrant hook, expressed in the format `0,0`, `0,1`, etc
73
+ */
23
74
  workflowDimension: string;
75
+ /**
76
+ * a concatenation of the task queue and workflow name (e.g., `${taskQueueName}-${workflowName}`)
77
+ */
24
78
  workflowTopic: string;
79
+ /**
80
+ * the open telemetry trace context for the workflow, used for logging and tracing. If a sink is enabled, this will be sent to the sink.
81
+ */
25
82
  workflowTrace: string;
83
+ /**
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.
85
+ */
26
86
  workflowSpan: string;
87
+ /**
88
+ * the native HotMesh message that encapsulates the arguments, metadata, and raw data for the workflow
89
+ */
27
90
  raw: StreamData;
28
91
  };
29
92
  type WorkflowSearchOptions = {
93
+ /** FT index name (myapp:myindex) */
30
94
  index?: string;
95
+ /** FT prefixes (['myapp:myindex:prefix1', 'myapp:myindex:prefix2']) */
31
96
  prefix?: string[];
97
+ /**
98
+ * Schema mapping each field. Each field is a key-value pair where the key is the field name
99
+ * and the value is a record of field options. If the fieldName is provided,
100
+ * it will be used as the indexed field name. If not provided
101
+ * key will be used as the indexed field name with an underscore prefix.
102
+ *
103
+ */
32
104
  schema?: Record<string, {
105
+ /**
106
+ * The FT.SEARCH field type. One of: TEXT, NUMERIC, TAG. TEXT is
107
+ * most expensive, but also most expressive.
108
+ */
33
109
  type: 'TEXT' | 'NUMERIC' | 'TAG';
110
+ /**
111
+ * FT.SEARCH SORTABLE field. If true, results may be sorted according to this field
112
+ * @default false
113
+ */
34
114
  sortable?: boolean;
115
+ /**
116
+ * FT.SEARCH NOSTEM field. applies to TEXT fields types.
117
+ * If true, the text field index will not stem words
118
+ * @default false
119
+ */
35
120
  nostem?: boolean;
121
+ /**
122
+ * FT.SEARCH NOINDEX field. If true and if the field is sortable, the field will aid
123
+ * in sorting results but not be directly indexed as a standalone
124
+ * @default false
125
+ */
36
126
  noindex?: boolean;
127
+ /**
128
+ * if true, the field is indexed and searchable within the FT.SEARCH index
129
+ * This is different from `noindex` which is FT.SEARCH specific and relates
130
+ * to sorting and indexing. This is a general flag for the field that will
131
+ * enable or disable indexing and searching entirely. Use for fields with
132
+ * absolutely no meaning to query or sorting but which are important
133
+ * nonetheless as part of the data record that is saved and returned.
134
+ * @default true
135
+ */
37
136
  indexed?: boolean;
137
+ /**
138
+ * An array of possible values for the field
139
+ */
38
140
  examples?: string[];
141
+ /**
142
+ * The 'nilable' setting may NOT be set to `true` for
143
+ * NUMBER types as it causes an indexing error;
144
+ * consider a custom (e.g., negative number) value to represent
145
+ * `null` if desired for a NUMERIC field.
146
+ * Set to true only if the field is a TEXT or TAG type and
147
+ * you wish to save the string `null` as a value to search
148
+ * on (the tag, {null}, or the string, (null)
149
+ * @default false
150
+ */
39
151
  nilable?: boolean;
152
+ /**
153
+ * possible scalar/primitive types for the field. Use when
154
+ * serializing and restoring data to ensure the field is
155
+ * properly typed. If not provided, the field will be
156
+ * treated as a string.
157
+ */
40
158
  primitive?: 'string' | 'number' | 'boolean' | 'array' | 'object';
159
+ /**
160
+ * if true, the field is required to be present in the data record
161
+ * @default false
162
+ */
41
163
  required?: boolean;
164
+ /**
165
+ * an enumerated list of allowed values; if field is nilable, it is implied
166
+ * and therefore not necessary to include `null` in the list
167
+ * @default []
168
+ */
42
169
  enum?: string[];
170
+ /**
171
+ * a regular expression pattern for the field
172
+ * @default '.*'
173
+ * @example '^[a-zA-Z0-9_]*$'
174
+ */
43
175
  pattern?: string;
176
+ /**
177
+ * literal value to use for the indexed field name (without including the standard underscore (_) prefix isolate)
178
+ */
44
179
  fieldName?: string;
45
180
  }>;
181
+ /** Additional data as a key-value record */
46
182
  data?: StringStringType;
47
183
  };
48
184
  type SearchResults = {
185
+ /**
186
+ * the total number of results
187
+ */
49
188
  count: number;
189
+ /**
190
+ * the raw FT.SEARCH query string
191
+ */
50
192
  query: string;
193
+ /**
194
+ * the raw FT.SEARCH results as an array of objects
195
+ */
51
196
  data: StringStringType[];
52
197
  };
53
198
  type WorkflowOptions = {
199
+ /**
200
+ * the namespace for the workflow; `durable` is the default namespace if not provided
201
+ */
54
202
  namespace?: string;
203
+ /**
204
+ * the task queue for the workflow; optional if entity is provided
205
+ */
55
206
  taskQueue?: string;
207
+ /**
208
+ * input arguments to pass in
209
+ */
56
210
  args: any[];
211
+ /**
212
+ * the job id
213
+ */
57
214
  workflowId?: string;
215
+ /**
216
+ * 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.
217
+ */
58
218
  entity?: string;
219
+ /**
220
+ * the name of the user's workflow function; optional if 'entity' is provided
221
+ */
59
222
  workflowName?: string;
223
+ /**
224
+ * the parent workflow id; adjacent ancestor ID
225
+ */
60
226
  parentWorkflowId?: string;
227
+ /**
228
+ * the entry point workflow id
229
+ */
61
230
  originJobId?: string;
231
+ /**
232
+ * OpenTelemetry trace context for the workflow
233
+ */
62
234
  workflowTrace?: string;
235
+ /**
236
+ * OpenTelemetry span context for the workflow
237
+ */
63
238
  workflowSpan?: string;
239
+ /**
240
+ * the full-text-search (RediSearch) options for the workflow
241
+ */
64
242
  search?: WorkflowSearchOptions;
243
+ /**
244
+ * marker data (begins with a -)
245
+ */
65
246
  marker?: StringStringType;
247
+ /**
248
+ * the workflow configuration object
249
+ */
66
250
  config?: WorkflowConfig;
251
+ /**
252
+ * 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.
253
+ */
67
254
  expire?: number;
255
+ /**
256
+ * default is true; if false, will not await the execution
257
+ */
68
258
  await?: boolean;
69
259
  };
260
+ /**
261
+ * Options for setting up a hook.
262
+ * 'durable' is the default namespace if not provided; similar to setting `appid` in the YAML
263
+ */
70
264
  type HookOptions = {
265
+ /** Optional namespace under which the hook function will be grouped */
71
266
  namespace?: string;
267
+ /** Optional task queue, needed unless 'entity' is provided */
72
268
  taskQueue?: string;
269
+ /** Input arguments to pass into the hook */
73
270
  args: any[];
271
+ /**
272
+ * Optional entity name. If provided, applies as the workflowName,
273
+ * taskQueue, and prefix. This scopes the FT.SEARCH index appropriately.
274
+ * This is a convenience method but limits options.
275
+ */
74
276
  entity?: string;
277
+ /** Execution ID, also known as the job ID to hook into */
75
278
  workflowId?: string;
279
+ /** The name of the user's hook function */
76
280
  workflowName?: string;
281
+ /** Bind additional search terms immediately before hook reentry */
77
282
  search?: WorkflowSearchOptions;
283
+ /** Hook function constraints (backoffCoefficient, maximumAttempts, maximumInterval) */
78
284
  config?: WorkflowConfig;
79
285
  };
286
+ /**
287
+ * Options for sending signals in a workflow.
288
+ */
80
289
  type SignalOptions = {
290
+ /**
291
+ * Task queue associated with the workflow
292
+ */
81
293
  taskQueue: string;
294
+ /**
295
+ * Input data for the signal (any serializable object)
296
+ */
82
297
  data: StringAnyType;
298
+ /**
299
+ * Execution ID, also known as the job ID
300
+ */
83
301
  workflowId: string;
302
+ /**
303
+ * Optional name of the user's workflow function
304
+ */
84
305
  workflowName?: string;
85
306
  };
86
307
  type ActivityWorkflowDataType = {
@@ -109,11 +330,20 @@ type Registry = {
109
330
  [key: string]: Function;
110
331
  };
111
332
  type WorkerConfig = {
333
+ /** Connection configuration for the worker */
112
334
  connection: Connection;
335
+ /**
336
+ * Namespace used in the app configuration, denoted as `appid` in the YAML (e.g., 'durable')
337
+ * @default durable
338
+ */
113
339
  namespace?: string;
340
+ /** Task queue name, denoted as `subscribes` in the YAML (e.g., 'hello-world') */
114
341
  taskQueue: string;
342
+ /** Target function or a record type with a name (string) and reference function */
115
343
  workflow: Function | Record<string | symbol, Function>;
344
+ /** Additional options for configuring the worker */
116
345
  options?: WorkerOptions;
346
+ /** Search options for workflow execution details */
117
347
  search?: WorkflowSearchOptions;
118
348
  };
119
349
  type FindWhereQuery = {
@@ -140,16 +370,25 @@ type FindWhereOptions = {
140
370
  };
141
371
  };
142
372
  type FindJobsOptions = {
373
+ /** The workflow name; include an asterisk for wilcard search; refer to Redis SCAN for the allowed format */
143
374
  match?: string;
375
+ /** application namespace; defaults to 'durable' */
144
376
  namespace?: string;
377
+ /** The suggested response limit. Reduce batch size to reduce the likelihood of large overages. */
145
378
  limit?: number;
379
+ /** How many records to scan at a time */
146
380
  batch?: number;
381
+ /** The start cursor; defaults to 0 */
147
382
  cursor?: string;
148
383
  };
149
384
  type WorkerOptions = {
385
+ /** Log level: debug, info, warn, error */
150
386
  logLevel?: LogLevel;
387
+ /** Maximum number of attempts, default 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
151
388
  maximumAttempts?: number;
389
+ /** Backoff coefficient for retry logic, default 10 (HMSH_DURABLE_EXP_BACKOFF) */
152
390
  backoffCoefficient?: number;
391
+ /** Maximum interval between retries, default 120s (HMSH_DURABLE_MAX_INTERVAL) */
153
392
  maximumInterval?: string;
154
393
  };
155
394
  type ContextType = {
@@ -160,16 +399,29 @@ type FunctionSignature<T> = T extends (...args: infer A) => infer R ? (...args:
160
399
  type ProxyType<ACT> = {
161
400
  [K in keyof ACT]: FunctionSignature<ACT[K]>;
162
401
  };
402
+ /**
403
+ * Configuration settings for activities within a workflow.
404
+ */
163
405
  type ActivityConfig = {
406
+ /** Start to close timeout for the activity; not yet implemented */
164
407
  startToCloseTimeout?: string;
408
+ /** Configuration for specific activities, type not yet specified */
165
409
  activities?: any;
410
+ /** Retry policy configuration for activities */
166
411
  retryPolicy?: {
412
+ /** Maximum number of retry attempts, default is 5 (HMSH_DURABLE_MAX_ATTEMPTS) */
167
413
  maximumAttempts?: number;
414
+ /** Factor by which the retry timeout increases, default is 10 (HMSH_DURABLE_MAX_INTERVAL) */
168
415
  backoffCoefficient?: number;
416
+ /** Maximum interval between retries, default is '120s' (HMSH_DURABLE_EXP_BACKOFF) */
169
417
  maximumInterval?: string;
418
+ /** Whether to throw an error on failure, default is true */
170
419
  throwOnError?: boolean;
171
420
  };
172
421
  };
422
+ /**
423
+ * The proxy response object returned from the activity proxy flow
424
+ */
173
425
  type ProxyResponseType<T> = {
174
426
  data?: T;
175
427
  $error?: StreamError;
@@ -177,6 +429,9 @@ type ProxyResponseType<T> = {
177
429
  jc: string;
178
430
  ju: string;
179
431
  };
432
+ /**
433
+ * The child flow response object returned from the main flow during recursion
434
+ */
180
435
  type ChildResponseType<T> = {
181
436
  data?: T;
182
437
  $error?: StreamError;
@@ -1,9 +1,22 @@
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
+ */
3
6
  export type ExportFields = 'data' | 'state' | 'status' | 'timeline' | 'transitions';
4
7
  export interface ExportOptions {
8
+ /**
9
+ * limit the export byte size by specifying an allowlist
10
+ */
5
11
  allow?: Array<ExportFields>;
12
+ /**
13
+ * limit the export byte size by specifying a block list
14
+ */
6
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
+ */
7
20
  values?: boolean;
8
21
  }
9
22
  export type JobAction = {
@@ -4,6 +4,9 @@ import { HookRules } from './hook';
4
4
  import { RedisClass, RedisClient, RedisOptions } from './redis';
5
5
  import { StreamData, StreamDataResponse } from './stream';
6
6
  import { LogLevel } from './logger';
7
+ /**
8
+ * the full set of entity types that are stored in the key/value store
9
+ */
7
10
  declare enum KeyType {
8
11
  APP = "APP",
9
12
  ENGINE_ID = "ENGINE",
@@ -25,6 +28,9 @@ declare enum KeyType {
25
28
  TIME_RANGE = "TIME_RANGE",
26
29
  WORK_ITEMS = "WORK_ITEMS"
27
30
  }
31
+ /**
32
+ * minting keys, requires one or more of the following parameters
33
+ */
28
34
  type KeyStoreParams = {
29
35
  appId?: string;
30
36
  engineId?: string;
@@ -108,4 +114,7 @@ type HotMeshApp = VersionedFields & {
108
114
  type HotMeshApps = {
109
115
  [appId: string]: HotMeshApp;
110
116
  };
111
- export { HotMesh, HotMeshEngine, RedisConfig, HotMeshWorker, HotMeshSettings, HotMeshApp, HotMeshApps, HotMeshConfig, HotMeshManifest, HotMeshGraph, KeyType, KeyStoreParams, };
117
+ export { HotMesh, HotMeshEngine, RedisConfig, HotMeshWorker, HotMeshSettings, HotMeshApp, //a single app in the db
118
+ HotMeshApps, //object array of all apps in the db
119
+ HotMeshConfig, //customer config
120
+ HotMeshManifest, HotMeshGraph, KeyType, KeyStoreParams, };
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KeyType = void 0;
4
+ /**
5
+ * the full set of entity types that are stored in the key/value store
6
+ */
4
7
  var KeyType;
5
8
  (function (KeyType) {
6
9
  KeyType["APP"] = "APP";
@@ -7,7 +7,7 @@ var hook_1 = require("./hook");
7
7
  Object.defineProperty(exports, "HookGate", { enumerable: true, get: function () { return hook_1.HookGate; } });
8
8
  var hotmesh_1 = require("./hotmesh");
9
9
  Object.defineProperty(exports, "KeyType", { enumerable: true, get: function () { return hotmesh_1.KeyType; } });
10
- var redis_1 = require("./redis");
10
+ var redis_1 = require("./redis"); //common redis types
11
11
  Object.defineProperty(exports, "isRedisClient", { enumerable: true, get: function () { return redis_1.isRedisClient; } });
12
12
  Object.defineProperty(exports, "isIORedisClient", { enumerable: true, get: function () { return redis_1.isIORedisClient; } });
13
13
  var stream_1 = require("./stream");
@@ -6,36 +6,81 @@ type ActivityData = {
6
6
  metadata?: Record<string, unknown>;
7
7
  };
8
8
  type JobMetadata = {
9
+ /** job_key */
9
10
  key?: string;
11
+ /** system assigned guid that corresponds to the transition message guid that spawned reentry */
10
12
  guid?: string;
13
+ /** system assigned guid; ensured created/deleted/created jobs are unique */
11
14
  gid: string;
15
+ /** job_id (jid+dad+aid) is composite key for activity */
12
16
  jid: string;
17
+ /** dimensional address for the activity (,0,0,1) */
13
18
  dad: string;
19
+ /** activity_id as in the YAML file */
14
20
  aid: string;
21
+ /** parent_job_id (pj+pd+pa) is composite key for parent activity */
15
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) */
16
24
  pg?: string;
25
+ /** parent_dimensional_address */
17
26
  pd?: string;
27
+ /** parent_activity_id */
18
28
  pa?: string;
29
+ /** sever the dependency chain if true (startChild/vs/execChild) */
19
30
  px?: boolean;
31
+ /** engine guid (one time subscriptions) */
20
32
  ngn?: string;
33
+ /** app_id */
21
34
  app: string;
35
+ /** app version */
22
36
  vrs: string;
37
+ /** subscription topic */
23
38
  tpc: string;
39
+ /** 201203120005 (slice of time) //time series */
24
40
  ts: string;
41
+ /** GMT created //job_created */
25
42
  jc: string;
43
+ /** GMT updated //job_updated */
26
44
  ju: string;
27
45
  js: JobStatus;
46
+ /** activity_type */
28
47
  atp: string;
48
+ /** activity_subtype */
29
49
  stp: string;
50
+ /** open telemetry span context */
30
51
  spn: string;
52
+ /** open telemetry trace context */
31
53
  trc: string;
54
+ /** stringified job error json: {message: string, code: number, error?} */
32
55
  err?: string;
56
+ /** process data expire policy */
33
57
  expire?: number;
34
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
+ */
35
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
+ */
36
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
+ */
37
79
  marker?: StringStringType;
38
80
  };
81
+ /**
82
+ * job_status semaphore
83
+ */
39
84
  type JobStatus = number;
40
85
  type JobState = {
41
86
  metadata: JobMetadata;
@@ -49,25 +94,65 @@ type JobState = {
49
94
  };
50
95
  };
51
96
  type JobInterruptOptions = {
97
+ /**
98
+ * optional Reason; will be used as the error `message` when thrown
99
+ * @default 'Job Interrupted'
100
+ */
52
101
  reason?: string;
102
+ /**
103
+ * throw JobInterrupted error upon interrupting
104
+ * @default true
105
+ */
53
106
  throw?: boolean;
107
+ /**
108
+ * interrupt child/descendant jobs
109
+ * @default false
110
+ */
54
111
  descend?: boolean;
112
+ /**
113
+ * if true, errors related to inactivation (like overage...already inactive) are suppressed/ignored
114
+ * @default false
115
+ */
55
116
  suppress?: boolean;
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
+ */
57
127
  code?: number;
128
+ /**
129
+ * Optional stack trace
130
+ */
58
131
  stack?: string;
59
132
  };
133
+ /**
134
+ * format when publishing job meta/data on the wire when it completes
135
+ */
60
136
  type JobOutput = {
61
137
  metadata: JobMetadata;
62
138
  data: JobData;
63
139
  };
140
+ /**
141
+ * jid+dad+aid is a composite guid; signal in and restore the full job context
142
+ */
64
143
  type PartialJobState = {
65
144
  metadata: JobMetadata | Pick<JobMetadata, 'jid' | 'dad' | 'aid'>;
66
145
  data: JobData;
67
146
  };
68
147
  type JobCompletionOptions = {
148
+ /** default false */
69
149
  emit?: boolean;
150
+ /** default undefined */
70
151
  interrupt?: boolean;
152
+ /**
153
+ * in seconds to wait before deleting/expiring job hash
154
+ * @default 1 second
155
+ */
71
156
  expire?: number;
72
157
  };
73
158
  export { JobCompletionOptions, JobData, JobsData, JobInterruptOptions, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, ExtensionType, };
@@ -1,17 +1,82 @@
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
+ */
1
5
  type PipeItem = string | boolean | number | null | object;
6
+ /**
7
+ * Array of `PipeItem` types.
8
+ */
2
9
  type PipeItems = PipeItem[];
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
+ */
3
15
  type PipeObject = {
4
16
  '@pipe': Array<PipeItem[] | PipeObject | ReduceObject>;
5
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
+ */
6
50
  type ReduceObject = {
7
51
  '@reduce': Array<PipeItem[] | PipeObject | ReduceObject>;
8
52
  };
53
+ /**
54
+ * Represents a sequence in the pipeline that can include arrays of `PipeItem`, `PipeObject`, or `ReduceObject`.
55
+ */
9
56
  type Pipe = (PipeItem[] | PipeObject | ReduceObject)[];
57
+ /**
58
+ * Defines the context of a pipeline operation.
59
+ */
10
60
  type PipeContext = {
61
+ /**
62
+ * Input of the current iteration.
63
+ */
11
64
  $input: unknown[];
65
+ /**
66
+ * Output of the current iteration and the final output for the reducer.
67
+ */
12
68
  $output: unknown;
69
+ /**
70
+ * Target item in the iterator.
71
+ */
13
72
  $item: unknown;
73
+ /**
74
+ * Array index as string or object key.
75
+ */
14
76
  $key: string;
77
+ /**
78
+ * Numeric index of the iterator.
79
+ */
15
80
  $index: number;
16
81
  };
17
82
  export { Pipe, PipeContext, PipeItem, PipeItems, PipeObject, ReduceObject };