@hotmeshio/hotmesh 0.2.4 → 0.3.0

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 (47) hide show
  1. package/README.md +14 -14
  2. package/build/modules/enums.d.ts +1 -0
  3. package/build/modules/enums.js +2 -1
  4. package/build/modules/errors.d.ts +1 -0
  5. package/build/modules/errors.js +1 -0
  6. package/build/modules/utils.d.ts +1 -0
  7. package/build/modules/utils.js +6 -10
  8. package/build/package.json +1 -1
  9. package/build/services/activities/activity.d.ts +3 -0
  10. package/build/services/activities/activity.js +24 -7
  11. package/build/services/activities/hook.js +3 -2
  12. package/build/services/activities/trigger.js +15 -5
  13. package/build/services/collator/index.d.ts +2 -0
  14. package/build/services/collator/index.js +12 -0
  15. package/build/services/compiler/deployer.js +1 -0
  16. package/build/services/exporter/index.js +1 -1
  17. package/build/services/meshcall/index.js +3 -9
  18. package/build/services/meshdata/index.d.ts +2 -2
  19. package/build/services/meshdata/index.js +25 -20
  20. package/build/services/meshflow/client.js +3 -8
  21. package/build/services/meshflow/schemas/factory.d.ts +1 -1
  22. package/build/services/meshflow/schemas/factory.js +56 -10
  23. package/build/services/meshflow/worker.js +3 -5
  24. package/build/services/meshflow/workflow.js +10 -12
  25. package/build/services/store/clients/ioredis.d.ts +1 -0
  26. package/build/services/store/clients/ioredis.js +4 -0
  27. package/build/services/store/clients/redis.d.ts +1 -0
  28. package/build/services/store/clients/redis.js +5 -0
  29. package/build/services/store/index.d.ts +2 -3
  30. package/build/services/store/index.js +5 -36
  31. package/build/services/task/index.d.ts +1 -1
  32. package/build/services/task/index.js +3 -6
  33. package/build/types/activity.d.ts +2 -0
  34. package/build/types/error.d.ts +1 -0
  35. package/build/types/hook.d.ts +1 -0
  36. package/build/types/hotmesh.d.ts +1 -0
  37. package/build/types/job.d.ts +1 -1
  38. package/build/types/meshdata.d.ts +1 -1
  39. package/build/types/meshflow.d.ts +3 -0
  40. package/package.json +1 -1
  41. package/types/activity.ts +3 -1
  42. package/types/error.ts +1 -0
  43. package/types/hook.ts +6 -1
  44. package/types/hotmesh.ts +35 -0
  45. package/types/job.ts +4 -14
  46. package/types/meshdata.ts +9 -5
  47. package/types/meshflow.ts +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
package/types/activity.ts CHANGED
@@ -28,7 +28,9 @@ interface BaseActivity {
28
28
  telemetry?: Record<string, any>;
29
29
  emit?: boolean; //if true, the activity will emit a message to the `publishes` topic immediately before transitioning to adjacent activities
30
30
  sleep?: number; //@pipe /in seconds
31
- expire?: number; //-1 forever; 0 persists the flow until the parent flow that expired it is dismissed; 15 seconds is the default
31
+ expire?: number; //-1 forever; 0 persists the flow until the parent flow that expired it is dismissed; 15 seconds is the default (copied from the YAML at compile time)
32
+ persistent?: boolean; //if true, the job will persist beyond completion (copied from the YAML at compile time)
33
+ persist?: boolean; //when true, the activity will emit the job completed event and start the `persistence countdown`, using the 'expire' value
32
34
  retry?: StreamRetryPolicy;
33
35
  cycle?: boolean; //if true, the `notary` will leave leg 2 open, so it can be re/cycled
34
36
  collationInt?: number; //compiler
package/types/error.ts CHANGED
@@ -4,6 +4,7 @@ export type MeshFlowChildErrorType = {
4
4
  backoffCoefficient?: number;
5
5
  index: number;
6
6
  expire?: number;
7
+ persistent?: boolean;
7
8
  signalIn?: boolean;
8
9
  maximumAttempts?: number;
9
10
  maximumInterval?: number;
package/types/hook.ts CHANGED
@@ -22,7 +22,12 @@ interface HookRules {
22
22
  [eventName: string]: HookRule[];
23
23
  }
24
24
 
25
- type HookSignal = { topic: string; resolved: string; jobId: string };
25
+ type HookSignal = {
26
+ topic: string;
27
+ resolved: string;
28
+ jobId: string;
29
+ expire: number;
30
+ };
26
31
 
27
32
  interface HookInterface {
28
33
  (topic: string, data: { [key: string]: any; id: string }): Promise<void>;
package/types/hotmesh.ts CHANGED
@@ -88,17 +88,52 @@ type HotMeshConfig = {
88
88
  };
89
89
 
90
90
  type HotMeshGraph = {
91
+ /**
92
+ * the unique topic that the graph subscribes to, creating one
93
+ * job for each idempotent message that is received
94
+ */
91
95
  subscribes: string;
96
+ /**
97
+ * the unique topic that the graph publishes/emits to when the job completes
98
+ */
92
99
  publishes?: string;
100
+ /**
101
+ * the number of seconds that the completed job should be
102
+ * left in the store before it is deleted
103
+ */
93
104
  expire?: number;
105
+ /**
106
+ * if the graph is reentrant and has open activities, the
107
+ * `persistent` flag will emit the job completed event.
108
+ * This allows the 'main' thread/trigger that started the job to
109
+ * signal to subscribers (or the parent) that the job
110
+ * is 'done', while still leaving the job in a
111
+ * state that allows for reentry (such as cyclical hooks).
112
+ */
113
+ persistent?: boolean;
114
+ /**
115
+ * the schema for the output of the graph
116
+ */
94
117
  output?: {
95
118
  schema: Record<string, any>;
96
119
  };
120
+ /**
121
+ * the schema for the input of the graph
122
+ */
97
123
  input?: {
98
124
  schema: Record<string, any>;
99
125
  };
126
+ /**
127
+ * the activities that define the graph
128
+ */
100
129
  activities: Record<string, any>;
130
+ /**
131
+ * the transitions that define how activities are connected
132
+ */
101
133
  transitions?: Record<string, any>;
134
+ /**
135
+ * the reentrant hook rules that define how to reenter a running graph
136
+ */
102
137
  hooks?: HookRules;
103
138
  };
104
139
 
package/types/job.ts CHANGED
@@ -63,6 +63,7 @@ type JobMetadata = {
63
63
  /** GMT updated //job_updated */
64
64
  ju: string;
65
65
 
66
+ /** job status semaphore */
66
67
  js: JobStatus;
67
68
 
68
69
  /** activity_type */
@@ -82,6 +83,9 @@ type JobMetadata = {
82
83
 
83
84
  /** process data expire policy */
84
85
  expire?: number;
86
+
87
+ /** job persistence (beyond main thread completion) */
88
+ persistent?: boolean;
85
89
  };
86
90
 
87
91
  /**
@@ -122,20 +126,6 @@ type ExtensionType = {
122
126
  * will be added after the job is resumed if relevant.
123
127
  */
124
128
  pending?: number;
125
-
126
- /**
127
- * Workflows that apply a status threshold will be initialized
128
- * with a status value of 1m - statusThreshold.
129
- *
130
- * The value provided should be the count of descendant activities
131
- * (those that descend from the trigger) that should be allowed to
132
- * remain open once 'done' event is emitted.
133
- *
134
- * If the job should not be removed from the cache, the `expire` field
135
- * should be set to `0`.
136
- *
137
- */
138
- statusThreshold?: number;
139
129
  };
140
130
 
141
131
  /**
package/types/meshdata.ts CHANGED
@@ -63,10 +63,6 @@ export type CallOptions = {
63
63
  };
64
64
 
65
65
  export type ConnectOptions = {
66
- /**
67
- * if set to infinity, callers may not override (the function will be durable)
68
- */
69
- ttl?: string;
70
66
  /**
71
67
  * the task queue for the connected function for greater specificity
72
68
  */
@@ -265,8 +261,16 @@ export type MeshDataWorkflowOptions = {
265
261
  expire?: number;
266
262
 
267
263
  /**
268
- * set to false to optimize workflows that do not require a `signal in`
264
+ * set to false to optimize workflows that do not require a `signal in`.
265
+ * explicitly set to true to force the workflow to remain open and persistent.
269
266
  * @default true
270
267
  */
271
268
  signalIn?: boolean;
269
+
270
+ /**
271
+ * set to `true` by the system when a workflow is started with a ttl, ensuring
272
+ * that the workflow will remain active until the ttl expires and the workflow
273
+ * is scrubbed. This is a system flag and should not be set by the user.
274
+ */
275
+ persistent?: boolean;
272
276
  };
package/types/meshflow.ts CHANGED
@@ -113,6 +113,11 @@ type WorkflowContext = {
113
113
  * the HotMesh connection configuration (io/redis NPM package reference and login credentials)
114
114
  */
115
115
  connection: Connection;
116
+
117
+ /**
118
+ * if present, the workflow will delay expiration for the specified number of seconds
119
+ */
120
+ expire?: number;
116
121
  };
117
122
 
118
123
  /**
@@ -316,6 +321,11 @@ type WorkflowOptions = {
316
321
  */
317
322
  expire?: number;
318
323
 
324
+ /**
325
+ * system flag to indicate that the flow should remain open beyond main method completion while still emitting the 'job done' event
326
+ */
327
+ persistent?: boolean;
328
+
319
329
  /**
320
330
  * default is true; set to false to optimize workflows that do not require a `signal in`
321
331
  */
@@ -417,8 +427,9 @@ type WorkflowDataType = {
417
427
  workflowId: string;
418
428
  workflowTopic: string;
419
429
  workflowDimension?: string; //is present if hook (not main workflow)
420
- originJobId?: string; //is present if there is an originating ancestor job (should rename to originJobId)
430
+ originJobId?: string; //is present if there is an originating ancestor job
421
431
  canRetry?: boolean;
432
+ expire?: number;
422
433
  };
423
434
 
424
435
  type ConnectionConfig = {