@hotmeshio/hotmesh 0.0.18 → 0.0.20

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 (60) hide show
  1. package/README.md +4 -4
  2. package/build/modules/errors.d.ts +2 -1
  3. package/build/modules/errors.js +2 -1
  4. package/build/modules/utils.js +7 -0
  5. package/build/package.json +2 -1
  6. package/build/services/activities/activity.d.ts +2 -2
  7. package/build/services/activities/activity.js +10 -8
  8. package/build/services/activities/hook.d.ts +4 -3
  9. package/build/services/activities/hook.js +15 -12
  10. package/build/services/activities/signal.d.ts +4 -0
  11. package/build/services/activities/signal.js +16 -2
  12. package/build/services/durable/client.d.ts +15 -5
  13. package/build/services/durable/client.js +45 -54
  14. package/build/services/durable/factory.d.ts +2 -16
  15. package/build/services/durable/factory.js +276 -46
  16. package/build/services/durable/handle.d.ts +1 -1
  17. package/build/services/durable/handle.js +18 -5
  18. package/build/services/durable/search.d.ts +8 -1
  19. package/build/services/durable/search.js +34 -7
  20. package/build/services/durable/worker.d.ts +10 -7
  21. package/build/services/durable/worker.js +59 -49
  22. package/build/services/durable/workflow.d.ts +20 -2
  23. package/build/services/durable/workflow.js +97 -84
  24. package/build/services/engine/index.d.ts +2 -2
  25. package/build/services/engine/index.js +7 -12
  26. package/build/services/hotmesh/index.d.ts +2 -2
  27. package/build/services/hotmesh/index.js +2 -2
  28. package/build/services/signaler/store.d.ts +2 -2
  29. package/build/services/signaler/store.js +17 -7
  30. package/build/services/signaler/stream.js +1 -0
  31. package/build/services/store/clients/redis.js +1 -1
  32. package/build/services/store/index.js +3 -0
  33. package/build/services/telemetry/index.js +7 -1
  34. package/build/types/activity.d.ts +5 -3
  35. package/build/types/durable.d.ts +17 -4
  36. package/build/types/hook.d.ts +0 -1
  37. package/build/types/index.d.ts +1 -1
  38. package/modules/errors.ts +4 -2
  39. package/modules/utils.ts +6 -0
  40. package/package.json +2 -1
  41. package/services/activities/activity.ts +10 -8
  42. package/services/activities/hook.ts +17 -14
  43. package/services/activities/signal.ts +17 -3
  44. package/services/durable/client.ts +48 -56
  45. package/services/durable/factory.ts +274 -46
  46. package/services/durable/handle.ts +18 -5
  47. package/services/durable/search.ts +36 -7
  48. package/services/durable/worker.ts +61 -51
  49. package/services/durable/workflow.ts +110 -84
  50. package/services/engine/index.ts +8 -12
  51. package/services/hotmesh/index.ts +3 -3
  52. package/services/signaler/store.ts +18 -8
  53. package/services/signaler/stream.ts +1 -0
  54. package/services/store/clients/redis.ts +1 -1
  55. package/services/store/index.ts +2 -0
  56. package/services/telemetry/index.ts +6 -1
  57. package/types/activity.ts +10 -8
  58. package/types/durable.ts +18 -3
  59. package/types/hook.ts +0 -1
  60. package/types/index.ts +1 -0
@@ -504,6 +504,8 @@ abstract class StoreService<T, U extends AbstractRedisClient> {
504
504
  delete state[':'];
505
505
  }
506
506
  return [state, status];
507
+ } else {
508
+ throw new Error(`Job ${jobId} not found`);
507
509
  }
508
510
  }
509
511
 
@@ -252,10 +252,15 @@ class TelemetryService {
252
252
 
253
253
  static bindActivityTelemetryToState(state: StringAnyType, config: ActivityType, metadata: ActivityMetadata, context: JobState, leg: number): void {
254
254
  if (config.type === 'trigger') {
255
+ //trigger activities run non-duplexed and only have a single leg (2)
255
256
  state[`${metadata.aid}/output/metadata/l1s`] = context['$self'].output.metadata.l1s;
256
257
  state[`${metadata.aid}/output/metadata/l2s`] = context['$self'].output.metadata.l2s;
257
258
  } else if (polyfill.resolveActivityType(config.type) === 'hook' && leg === 1) {
258
- //activities run non-duplexed and only have a single leg
259
+ //hook activities run non-duplexed and only have a single leg (1)
260
+ state[`${metadata.aid}/output/metadata/l1s`] = context['$self'].output.metadata.l1s;
261
+ state[`${metadata.aid}/output/metadata/l2s`] = context['$self'].output.metadata.l1s;
262
+ } else if (config.type === 'signal' && leg === 1) {
263
+ //signal activities run non-duplexed and only have a single leg (1)
259
264
  state[`${metadata.aid}/output/metadata/l1s`] = context['$self'].output.metadata.l1s;
260
265
  state[`${metadata.aid}/output/metadata/l2s`] = context['$self'].output.metadata.l1s;
261
266
  } else {
package/types/activity.ts CHANGED
@@ -70,14 +70,16 @@ interface HookActivity extends BaseActivity {
70
70
  }
71
71
 
72
72
  interface SignalActivity extends BaseActivity {
73
- type: 'signal'; //signal activities call hook/hookAll
74
- subtype: 'one' | 'all'; //trigger: hook(One) or hookAll
75
- topic: string; //e.g., 'hook.resume'
76
- key_name: string; //e.g., 'parent_job_id'
77
- key_value: string; //e.g., '1234567890'
78
- scrub: boolean; //if true, the index will be deleted after use
79
- signal?: Record<string, any>; //used to define/map the signal input data
80
- resolver?: Record<string, any>; //used to define/map the signal key resolver
73
+ type: 'signal'; //signal activities call hook/hookAll
74
+ subtype: 'one' | 'all'; //trigger: hook(One) or hookAll
75
+ topic: string; //e.g., 'hook.resume'
76
+ key_name?: string; //e.g., 'parent_job_id'
77
+ key_value?: string; //e.g., '1234567890'
78
+ scrub?: boolean; //if true, the index will be deleted after use
79
+ signal?: Record<string, any>; //used to define/map the signal input data (what to send/singnal into the job(s))
80
+ resolver?: Record<string, any>; //used to define/map the signal key resolver (the key used to lookup the job(s that are assigned to the key)
81
+ status?: string; //pending, success (default), error
82
+ code?: number; //202, 200 (default)
81
83
  }
82
84
 
83
85
  interface IterateActivity extends BaseActivity {
package/types/durable.ts CHANGED
@@ -8,12 +8,14 @@ type WorkflowConfig = {
8
8
  }
9
9
 
10
10
  type WorkflowSearchOptions = {
11
- index: string; //FT index name (myapp:myindex)
12
- prefix: string[]; //FT prefixes (['myapp:myindex:prefix1', 'myapp:myindex:prefix2'])
13
- schema: Record<string, {type: 'TEXT' | 'NUMERIC' | 'TAG', sortable: boolean}>;
11
+ index?: string; //FT index name (myapp:myindex)
12
+ prefix?: string[]; //FT prefixes (['myapp:myindex:prefix1', 'myapp:myindex:prefix2'])
13
+ schema?: Record<string, {type: 'TEXT' | 'NUMERIC' | 'TAG', sortable: boolean}>;
14
+ data?: Record<string, string>;
14
15
  }
15
16
 
16
17
  type WorkflowOptions = {
18
+ namespace?: string; //'durable' is the default namespace if not provided; similar to setting `appid` in the YAML
17
19
  taskQueue: string;
18
20
  args: any[]; //input arguments to pass in
19
21
  workflowId: string; //execution id (the job id)
@@ -25,6 +27,16 @@ type WorkflowOptions = {
25
27
  config?: WorkflowConfig;
26
28
  }
27
29
 
30
+ type HookOptions = {
31
+ namespace?: string; //'durable' is the default namespace if not provided; similar to setting `appid` in the YAML
32
+ taskQueue: string;
33
+ args: any[]; //input arguments to pass into the hook
34
+ workflowId: string; //execution id (the job id to hook into)
35
+ workflowName?: string; //the name of the user's hook function
36
+ search?: WorkflowSearchOptions //bind additional search terms immediately before hook reentry
37
+ config?: WorkflowConfig; //hook function constraints (backoffCoefficient, maximumAttempts, maximumInterval, initialInterval)
38
+ }
39
+
28
40
  type SignalOptions = {
29
41
  taskQueue: string;
30
42
  data: Record<string, any>; //input data (any serializable object)
@@ -66,9 +78,11 @@ type WorkerConfig = {
66
78
  taskQueue: string; //`subscribes` in the YAML (e.g, 'hello-world')
67
79
  workflow: Function; //target function to run
68
80
  options?: WorkerOptions;
81
+ search?: WorkflowSearchOptions;
69
82
  }
70
83
 
71
84
  type WorkerOptions = {
85
+ logLevel?: string; //debug, info, warn, error
72
86
  maxSystemRetries?: number; //1-3 (10ms, 100ms, 1_000ms)
73
87
  backoffCoefficient?: number; //2-10ish
74
88
  }
@@ -105,6 +119,7 @@ export {
105
119
  ProxyType,
106
120
  Registry,
107
121
  SignalOptions,
122
+ HookOptions,
108
123
  WorkerConfig,
109
124
  WorkflowConfig,
110
125
  WorkerOptions,
package/types/hook.ts CHANGED
@@ -16,7 +16,6 @@ interface HookConditions {
16
16
 
17
17
  interface HookRule {
18
18
  to: string;
19
- keep_alive?: boolean; //if true, the hook will not be deleted after use
20
19
  conditions: HookConditions;
21
20
  }
22
21
 
package/types/index.ts CHANGED
@@ -37,6 +37,7 @@ export {
37
37
  NativeConnection,
38
38
  ProxyType,
39
39
  Registry,
40
+ HookOptions,
40
41
  WorkflowConfig,
41
42
  WorkerConfig,
42
43
  WorkerOptions,