@hotmeshio/hotmesh 0.0.54 → 0.0.56

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 (182) hide show
  1. package/README.md +0 -3
  2. package/build/modules/enums.js +1 -10
  3. package/build/modules/key.d.ts +0 -38
  4. package/build/modules/key.js +4 -46
  5. package/build/modules/utils.d.ts +0 -8
  6. package/build/modules/utils.js +0 -14
  7. package/build/package.json +11 -4
  8. package/build/services/activities/activity.d.ts +0 -28
  9. package/build/services/activities/activity.js +1 -46
  10. package/build/services/activities/await.js +0 -4
  11. package/build/services/activities/cycle.d.ts +0 -7
  12. package/build/services/activities/cycle.js +1 -16
  13. package/build/services/activities/hook.d.ts +0 -6
  14. package/build/services/activities/hook.js +2 -12
  15. package/build/services/activities/interrupt.js +0 -8
  16. package/build/services/activities/signal.d.ts +0 -6
  17. package/build/services/activities/signal.js +0 -15
  18. package/build/services/activities/trigger.d.ts +0 -4
  19. package/build/services/activities/trigger.js +1 -7
  20. package/build/services/activities/worker.js +0 -4
  21. package/build/services/collator/index.d.ts +0 -70
  22. package/build/services/collator/index.js +1 -91
  23. package/build/services/compiler/deployer.js +6 -38
  24. package/build/services/compiler/index.d.ts +0 -15
  25. package/build/services/compiler/index.js +0 -20
  26. package/build/services/compiler/validator.d.ts +0 -3
  27. package/build/services/compiler/validator.js +0 -25
  28. package/build/services/connector/clients/ioredis.d.ts +2 -2
  29. package/build/services/connector/clients/ioredis.js +0 -2
  30. package/build/services/connector/clients/redis.d.ts +4 -4
  31. package/build/services/connector/clients/redis.js +1 -3
  32. package/build/services/connector/index.d.ts +1 -1
  33. package/build/services/connector/index.js +0 -2
  34. package/build/services/durable/client.d.ts +1 -26
  35. package/build/services/durable/client.js +0 -56
  36. package/build/services/durable/exporter.d.ts +0 -22
  37. package/build/services/durable/exporter.js +1 -30
  38. package/build/services/durable/handle.d.ts +0 -36
  39. package/build/services/durable/handle.js +0 -46
  40. package/build/services/durable/index.d.ts +0 -4
  41. package/build/services/durable/index.js +0 -4
  42. package/build/services/durable/schemas/factory.d.ts +0 -29
  43. package/build/services/durable/schemas/factory.js +0 -29
  44. package/build/services/durable/search.d.ts +1 -36
  45. package/build/services/durable/search.js +57 -56
  46. package/build/services/durable/worker.js +2 -22
  47. package/build/services/durable/workflow.d.ts +0 -114
  48. package/build/services/durable/workflow.js +4 -144
  49. package/build/services/engine/index.d.ts +1 -6
  50. package/build/services/engine/index.js +1 -43
  51. package/build/services/exporter/index.d.ts +0 -27
  52. package/build/services/exporter/index.js +0 -33
  53. package/build/services/hotmesh/index.d.ts +2 -2
  54. package/build/services/hotmesh/index.js +1 -9
  55. package/build/services/logger/index.js +0 -2
  56. package/build/services/mapper/index.d.ts +0 -14
  57. package/build/services/mapper/index.js +0 -14
  58. package/build/services/pipe/functions/date.d.ts +0 -7
  59. package/build/services/pipe/functions/date.js +0 -7
  60. package/build/services/pipe/functions/math.js +0 -2
  61. package/build/services/pipe/index.d.ts +0 -15
  62. package/build/services/pipe/index.js +2 -23
  63. package/build/services/quorum/index.d.ts +0 -7
  64. package/build/services/quorum/index.js +0 -21
  65. package/build/services/reporter/index.d.ts +0 -5
  66. package/build/services/reporter/index.js +0 -9
  67. package/build/services/router/index.d.ts +0 -9
  68. package/build/services/router/index.js +2 -38
  69. package/build/services/serializer/index.js +7 -26
  70. package/build/services/store/cache.d.ts +0 -18
  71. package/build/services/store/cache.js +0 -18
  72. package/build/services/store/clients/ioredis.d.ts +1 -1
  73. package/build/services/store/clients/ioredis.js +0 -1
  74. package/build/services/store/clients/redis.d.ts +1 -1
  75. package/build/services/store/index.d.ts +0 -55
  76. package/build/services/store/index.js +5 -81
  77. package/build/services/stream/clients/ioredis.d.ts +1 -1
  78. package/build/services/stream/clients/ioredis.js +1 -4
  79. package/build/services/stream/clients/redis.d.ts +1 -1
  80. package/build/services/sub/clients/ioredis.d.ts +1 -1
  81. package/build/services/sub/clients/redis.d.ts +1 -1
  82. package/build/services/task/index.d.ts +0 -9
  83. package/build/services/task/index.js +0 -31
  84. package/build/services/telemetry/index.d.ts +0 -7
  85. package/build/services/telemetry/index.js +1 -13
  86. package/build/services/worker/index.d.ts +0 -4
  87. package/build/services/worker/index.js +2 -6
  88. package/build/types/activity.d.ts +0 -81
  89. package/build/types/durable.d.ts +25 -177
  90. package/build/types/exporter.d.ts +0 -13
  91. package/build/types/hotmesh.d.ts +4 -16
  92. package/build/types/hotmesh.js +0 -3
  93. package/build/types/index.d.ts +4 -6
  94. package/build/types/index.js +4 -3
  95. package/build/types/job.d.ts +1 -86
  96. package/build/types/pipe.d.ts +0 -65
  97. package/build/types/quorum.d.ts +15 -10
  98. package/build/types/redis.d.ts +225 -7
  99. package/build/types/redis.js +9 -0
  100. package/build/types/stream.d.ts +0 -58
  101. package/build/types/stream.js +0 -4
  102. package/package.json +11 -4
  103. package/types/durable.ts +121 -3
  104. package/types/hotmesh.ts +3 -6
  105. package/types/index.ts +23 -10
  106. package/types/job.ts +1 -1
  107. package/types/quorum.ts +22 -0
  108. package/types/redis.ts +267 -18
  109. package/build/types/ioredisclient.d.ts +0 -5
  110. package/build/types/ioredisclient.js +0 -5
  111. package/build/types/redisclient.d.ts +0 -26
  112. package/build/types/redisclient.js +0 -2
  113. package/modules/enums.ts +0 -62
  114. package/modules/errors.ts +0 -280
  115. package/modules/key.ts +0 -101
  116. package/modules/storage.ts +0 -3
  117. package/modules/utils.ts +0 -242
  118. package/services/activities/activity.ts +0 -589
  119. package/services/activities/await.ts +0 -113
  120. package/services/activities/cycle.ts +0 -115
  121. package/services/activities/hook.ts +0 -197
  122. package/services/activities/index.ts +0 -19
  123. package/services/activities/interrupt.ts +0 -172
  124. package/services/activities/signal.ts +0 -148
  125. package/services/activities/trigger.ts +0 -295
  126. package/services/activities/worker.ts +0 -107
  127. package/services/collator/README.md +0 -102
  128. package/services/collator/index.ts +0 -291
  129. package/services/compiler/deployer.ts +0 -504
  130. package/services/compiler/index.ts +0 -98
  131. package/services/compiler/validator.ts +0 -158
  132. package/services/connector/clients/ioredis.ts +0 -57
  133. package/services/connector/clients/redis.ts +0 -72
  134. package/services/connector/index.ts +0 -42
  135. package/services/durable/client.ts +0 -266
  136. package/services/durable/connection.ts +0 -10
  137. package/services/durable/exporter.ts +0 -232
  138. package/services/durable/handle.ts +0 -160
  139. package/services/durable/index.ts +0 -27
  140. package/services/durable/schemas/factory.ts +0 -2358
  141. package/services/durable/search.ts +0 -196
  142. package/services/durable/worker.ts +0 -401
  143. package/services/durable/workflow.ts +0 -557
  144. package/services/engine/index.ts +0 -761
  145. package/services/exporter/index.ts +0 -146
  146. package/services/hotmesh/index.ts +0 -237
  147. package/services/logger/index.ts +0 -79
  148. package/services/mapper/index.ts +0 -89
  149. package/services/pipe/functions/array.ts +0 -78
  150. package/services/pipe/functions/bitwise.ts +0 -27
  151. package/services/pipe/functions/conditional.ts +0 -35
  152. package/services/pipe/functions/date.ts +0 -220
  153. package/services/pipe/functions/index.ts +0 -27
  154. package/services/pipe/functions/json.ts +0 -11
  155. package/services/pipe/functions/logical.ts +0 -11
  156. package/services/pipe/functions/math.ts +0 -217
  157. package/services/pipe/functions/number.ts +0 -75
  158. package/services/pipe/functions/object.ts +0 -98
  159. package/services/pipe/functions/string.ts +0 -86
  160. package/services/pipe/functions/symbol.ts +0 -39
  161. package/services/pipe/functions/unary.ts +0 -19
  162. package/services/pipe/index.ts +0 -216
  163. package/services/quorum/index.ts +0 -319
  164. package/services/reporter/index.ts +0 -387
  165. package/services/router/index.ts +0 -426
  166. package/services/serializer/README.md +0 -10
  167. package/services/serializer/index.ts +0 -285
  168. package/services/store/cache.ts +0 -172
  169. package/services/store/clients/ioredis.ts +0 -145
  170. package/services/store/clients/redis.ts +0 -191
  171. package/services/store/index.ts +0 -1091
  172. package/services/stream/clients/ioredis.ts +0 -157
  173. package/services/stream/clients/redis.ts +0 -158
  174. package/services/stream/index.ts +0 -58
  175. package/services/sub/clients/ioredis.ts +0 -83
  176. package/services/sub/clients/redis.ts +0 -74
  177. package/services/sub/index.ts +0 -25
  178. package/services/task/index.ts +0 -250
  179. package/services/telemetry/index.ts +0 -273
  180. package/services/worker/index.ts +0 -248
  181. package/types/ioredisclient.ts +0 -10
  182. package/types/redisclient.ts +0 -30
@@ -6,81 +6,36 @@ type ActivityData = {
6
6
  metadata?: Record<string, unknown>;
7
7
  };
8
8
  type JobMetadata = {
9
- /** job_key */
10
9
  key?: string;
11
- /** system assigned guid that corresponds to the transition message guid that spawned reentry */
12
10
  guid?: string;
13
- /** system assigned guid; ensured created/deleted/created jobs are unique */
14
11
  gid: string;
15
- /** job_id (jid+dad+aid) is composite key for activity */
16
12
  jid: string;
17
- /** dimensional address for the activity (,0,0,1) */
18
13
  dad: string;
19
- /** activity_id as in the YAML file */
20
14
  aid: string;
21
- /** parent_job_id (pj+pd+pa) is composite key for parent activity */
22
15
  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) */
24
16
  pg?: string;
25
- /** parent_dimensional_address */
26
17
  pd?: string;
27
- /** parent_activity_id */
28
18
  pa?: string;
29
- /** sever the dependency chain if true (startChild/vs/execChild) */
30
19
  px?: boolean;
31
- /** engine guid (one time subscriptions) */
32
20
  ngn?: string;
33
- /** app_id */
34
21
  app: string;
35
- /** app version */
36
22
  vrs: string;
37
- /** subscription topic */
38
23
  tpc: string;
39
- /** 201203120005 (slice of time) //time series */
40
24
  ts: string;
41
- /** GMT created //job_created */
42
25
  jc: string;
43
- /** GMT updated //job_updated */
44
26
  ju: string;
45
27
  js: JobStatus;
46
- /** activity_type */
47
28
  atp: string;
48
- /** activity_subtype */
49
29
  stp: string;
50
- /** open telemetry span context */
51
30
  spn: string;
52
- /** open telemetry trace context */
53
31
  trc: string;
54
- /** stringified job error json: {message: string, code: number, error?} */
55
32
  err?: string;
56
- /** process data expire policy */
57
33
  expire?: number;
58
34
  };
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
35
  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
36
  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
37
  marker?: StringStringType;
80
38
  };
81
- /**
82
- * job_status semaphore
83
- */
84
39
  type JobStatus = number;
85
40
  type JobState = {
86
41
  metadata: JobMetadata;
@@ -94,65 +49,25 @@ type JobState = {
94
49
  };
95
50
  };
96
51
  type JobInterruptOptions = {
97
- /**
98
- * optional Reason; will be used as the error `message` when thrown
99
- * @default 'Job Interrupted'
100
- */
101
52
  reason?: string;
102
- /**
103
- * throw JobInterrupted error upon interrupting
104
- * @default true
105
- */
106
53
  throw?: boolean;
107
- /**
108
- * interrupt child/descendant jobs
109
- * @default false
110
- */
111
54
  descend?: boolean;
112
- /**
113
- * if true, errors related to inactivation (like overage...already inactive) are suppressed/ignored
114
- * @default false
115
- */
116
55
  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
- */
122
56
  expire?: number;
123
- /**
124
- * Optional Error Code; will be used as the error `code` when thrown
125
- * @default 410
126
- */
127
57
  code?: number;
128
- /**
129
- * Optional stack trace
130
- */
131
58
  stack?: string;
132
59
  };
133
- /**
134
- * format when publishing job meta/data on the wire when it completes
135
- */
136
60
  type JobOutput = {
137
61
  metadata: JobMetadata;
138
62
  data: JobData;
139
63
  };
140
- /**
141
- * jid+dad+aid is a composite guid; signal in and restore the full job context
142
- */
143
64
  type PartialJobState = {
144
65
  metadata: JobMetadata | Pick<JobMetadata, 'jid' | 'dad' | 'aid'>;
145
66
  data: JobData;
146
67
  };
147
68
  type JobCompletionOptions = {
148
- /** default false */
149
69
  emit?: boolean;
150
- /** default undefined */
151
70
  interrupt?: boolean;
152
- /**
153
- * in seconds to wait before deleting/expiring job hash
154
- * @default 1 second
155
- */
156
71
  expire?: number;
157
72
  };
158
- export { JobCompletionOptions, JobInterruptOptions, JobData, JobsData, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, ExtensionType, };
73
+ export { JobCompletionOptions, JobData, JobsData, JobInterruptOptions, JobMetadata, JobOutput, JobState, JobStatus, PartialJobState, ExtensionType, };
@@ -1,82 +1,17 @@
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
1
  type PipeItem = string | boolean | number | null | object;
6
- /**
7
- * Array of `PipeItem` types.
8
- */
9
2
  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
- */
15
3
  type PipeObject = {
16
4
  '@pipe': Array<PipeItem[] | PipeObject | ReduceObject>;
17
5
  };
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
6
  type ReduceObject = {
51
7
  '@reduce': Array<PipeItem[] | PipeObject | ReduceObject>;
52
8
  };
53
- /**
54
- * Represents a sequence in the pipeline that can include arrays of `PipeItem`, `PipeObject`, or `ReduceObject`.
55
- */
56
9
  type Pipe = (PipeItem[] | PipeObject | ReduceObject)[];
57
- /**
58
- * Defines the context of a pipeline operation.
59
- */
60
10
  type PipeContext = {
61
- /**
62
- * Input of the current iteration.
63
- */
64
11
  $input: unknown[];
65
- /**
66
- * Output of the current iteration and the final output for the reducer.
67
- */
68
12
  $output: unknown;
69
- /**
70
- * Target item in the iterator.
71
- */
72
13
  $item: unknown;
73
- /**
74
- * Array index as string or object key.
75
- */
76
14
  $key: string;
77
- /**
78
- * Numeric index of the iterator.
79
- */
80
15
  $index: number;
81
16
  };
82
17
  export { Pipe, PipeContext, PipeItem, PipeItems, PipeObject, ReduceObject };
@@ -15,7 +15,6 @@ interface NetworkStat {
15
15
  tx_sec: number;
16
16
  ms: number;
17
17
  }
18
- /** reveals: memory, cpu, network */
19
18
  export interface SystemHealth {
20
19
  TotalMemoryGB: string;
21
20
  FreeMemoryGB: string;
@@ -24,17 +23,17 @@ export interface SystemHealth {
24
23
  NetworkStats: NetworkStat[];
25
24
  }
26
25
  export type ThrottleOptions = {
27
- /** target an engine OR worker by GUID */
28
26
  guid?: string;
29
- /** target a worker quorum */
30
27
  topic?: string;
31
- /** in milliseconds; default is 0 */
28
+ entity?: string;
32
29
  throttle: number;
30
+ namespace?: string;
33
31
  };
34
32
  export interface QuorumProfile {
35
33
  namespace: string;
36
34
  app_id: string;
37
35
  engine_id: string;
36
+ entity?: string;
38
37
  worker_topic?: string;
39
38
  stream?: string;
40
39
  stream_depth?: number;
@@ -48,6 +47,7 @@ export interface QuorumProfile {
48
47
  signature?: string;
49
48
  }
50
49
  interface QuorumMessageBase {
50
+ entity?: string;
51
51
  guid?: string;
52
52
  topic?: string;
53
53
  type?: string;
@@ -69,6 +69,7 @@ export interface PongMessage extends QuorumMessageBase {
69
69
  type: 'pong';
70
70
  guid: string;
71
71
  originator: string;
72
+ entity?: string;
72
73
  profile?: QuorumProfile;
73
74
  }
74
75
  export interface ActivateMessage extends QuorumMessageBase {
@@ -78,18 +79,21 @@ export interface ActivateMessage extends QuorumMessageBase {
78
79
  }
79
80
  export interface JobMessage extends QuorumMessageBase {
80
81
  type: 'job';
82
+ entity?: string;
81
83
  topic: string;
82
84
  job: JobOutput;
83
85
  }
84
86
  export interface ThrottleMessage extends QuorumMessageBase {
85
87
  type: 'throttle';
86
88
  guid?: string;
89
+ entity?: string;
87
90
  topic?: string;
88
91
  throttle: number;
89
92
  }
90
93
  export interface RollCallMessage extends QuorumMessageBase {
91
94
  type: 'rollcall';
92
95
  guid?: string;
96
+ entity?: string;
93
97
  topic?: string | null;
94
98
  interval: number;
95
99
  max?: number;
@@ -104,11 +108,12 @@ export interface SubscriptionCallback {
104
108
  export interface QuorumMessageCallback {
105
109
  (topic: string, message: QuorumMessage): void;
106
110
  }
107
- /**
108
- * The types in this file are used to define those messages that are sent
109
- * to hotmesh client instances when a new version is about to be activated.
110
- * These messages serve to coordinate the cache invalidation and switch-over
111
- * to the new version without any downtime and a coordinating parent server.
112
- */
111
+ export type RollCallOptions = {
112
+ delay?: number;
113
+ namespace?: string;
114
+ };
115
+ export type SubscriptionOptions = {
116
+ namespace?: string;
117
+ };
113
118
  export type QuorumMessage = PingMessage | PongMessage | ActivateMessage | WorkMessage | JobMessage | ThrottleMessage | RollCallMessage | CronMessage;
114
119
  export {};
@@ -1,8 +1,226 @@
1
- import { RedisClassType, RedisClientType as RCT, RedisMultiType as RMT, RedisClientOptions as RCO } from './redisclient';
2
- import { RedisClassType as IORRedisClassType, RedisClientType as IORCT, RedisMultiType as IORMT, RedisClientOptions as IORCO } from './ioredisclient';
3
- type RedisClass = RedisClassType | IORRedisClassType;
4
- type RedisClient = RCT | IORCT;
5
- type RedisMulti = RMT | IORMT;
6
- type RedisOptions = RCO | IORCO;
1
+ /// <reference types="node" />
2
+ import { StringStringType } from './serializer';
3
+ import { ReclaimedMessageType } from './stream';
7
4
  type MultiResponseFlags = (string | number)[];
8
- export { RedisClass, RedisClient, RedisMulti, RedisOptions, MultiResponseFlags, };
5
+ interface ConnectionOptions {
6
+ host?: string;
7
+ port?: number;
8
+ path?: string;
9
+ socket?: any;
10
+ NPNProtocols?: string[] | Buffer[];
11
+ ALPNProtocols?: string[] | Buffer[];
12
+ servername?: string;
13
+ checkServerIdentity?: (servername: string, cert: Buffer) => Error | undefined;
14
+ session?: Buffer;
15
+ minDHSize?: number;
16
+ secureContext?: any;
17
+ secureProtocol?: string;
18
+ ciphers?: string;
19
+ honorCipherOrder?: boolean;
20
+ requestCert?: boolean;
21
+ rejectUnauthorized?: boolean;
22
+ maxVersion?: 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
23
+ minVersion?: 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
24
+ }
25
+ interface RedisRedisClientOptions {
26
+ url?: string;
27
+ socket?: {
28
+ host?: string;
29
+ port?: number;
30
+ tls?: boolean;
31
+ servername?: string;
32
+ };
33
+ username?: string;
34
+ password?: string;
35
+ database?: number;
36
+ name?: string;
37
+ readonly?: boolean;
38
+ legacyMode?: boolean;
39
+ commandsQueueMaxLength?: number;
40
+ disableOfflineQueue?: boolean;
41
+ connectTimeout?: number;
42
+ autoResubscribe?: boolean;
43
+ autoResendUnfulfilledCommands?: boolean;
44
+ lazyConnect?: boolean;
45
+ tls?: boolean | ConnectionOptions;
46
+ enableReadyCheck?: boolean;
47
+ keepAlive?: number;
48
+ family?: 'IPv4' | 'IPv6';
49
+ keyPrefix?: string;
50
+ retry?: {
51
+ maxReconnectionAttempts?: number;
52
+ initialReconnectionDelay?: number;
53
+ reconnectionBackoffFactor?: number;
54
+ totalReconnectionTimeout?: number;
55
+ maxRetryCount?: number;
56
+ };
57
+ stringNumbers?: boolean;
58
+ }
59
+ interface RedisRedisMultiType {
60
+ sendCommand(command: string, ...args: string[]): Promise<any>;
61
+ exec: () => Promise<unknown[]>;
62
+ XADD(key: string, id: string, fields: any): this;
63
+ XACK(key: string, group: string, id: string): this;
64
+ XDEL(key: string, id: string): this;
65
+ XLEN(key: string): this;
66
+ DEL(key: string): this;
67
+ EXISTS(key: string): this;
68
+ HDEL(key: string, itemId: string): this;
69
+ HGET(key: string, itemId: string): this;
70
+ HGETALL(key: string): this;
71
+ HINCRBYFLOAT(key: string, itemId: string, value: number): this;
72
+ HMGET(key: string, itemIds: string[]): Promise<string[]>;
73
+ HSET(key: string, values: Record<string, string>): this;
74
+ LPUSH(key: string, items: string[]): this;
75
+ LRANGE(key: string, start: number, end: number): this;
76
+ RPUSH(key: string, items: string[]): this;
77
+ SET(key: string, value: string): this;
78
+ ZADD(key: string, values: {
79
+ score: string;
80
+ value: string;
81
+ }, opts?: {
82
+ NX: boolean;
83
+ }): this;
84
+ ZRANGE_WITHSCORES(key: string, start: number, end: number): this;
85
+ ZRANK(key: string, member: string): this;
86
+ ZSCORE(key: string, value: string): this;
87
+ }
88
+ interface RedisRedisClientType {
89
+ multi(): Partial<RedisRedisMultiType>;
90
+ connect(): Promise<void>;
91
+ sendCommand(args: any[]): Promise<any>;
92
+ exec(): Promise<unknown[]>;
93
+ flushDb(): Promise<string>;
94
+ quit(): Promise<string>;
95
+ disconnect(): void;
96
+ duplicate(): RedisRedisClientType;
97
+ on(event: string, callback: (...args: any[]) => void): void;
98
+ publish(channel: string, message: string): Promise<number>;
99
+ pSubscribe(pattern: string, callback: (channel: string, message: string) => void): void;
100
+ pUnsubscribe(pattern: string): void;
101
+ subscribe(channel: string, callback: (channel: string, message: string) => void): void;
102
+ unsubscribe(channel: string): void;
103
+ punsubscribe(channel: string): void;
104
+ get(key: string): Promise<string | null>;
105
+ set(key: string, value: string): Promise<string>;
106
+ XADD(key: string, id: string, fields: any): Promise<string>;
107
+ XACK(key: string, group: string, id: string): Promise<number>;
108
+ XDEL(key: string, id: string): Promise<number>;
109
+ XLEN(key: string): Promise<number>;
110
+ DEL(key: string): Promise<number>;
111
+ EXISTS(key: string): Promise<number>;
112
+ HDEL(key: string, itemId: string): Promise<number>;
113
+ HGET(key: string, itemId: string): Promise<string | null>;
114
+ HGETALL(key: string): Promise<StringStringType>;
115
+ HINCRBYFLOAT(key: string, itemId: string, value: number): Promise<number>;
116
+ HMGET(key: string, itemIds: string[]): Promise<string[]>;
117
+ HSET(key: string, values: Record<string, string>): this;
118
+ LPUSH(key: string, items: string[]): Promise<number>;
119
+ LRANGE(key: string, start: number, end: number): Promise<string[]>;
120
+ RPUSH(key: string, items: string[]): Promise<number>;
121
+ SET(key: string, value: string): Promise<string>;
122
+ ZADD(key: string, values: {
123
+ score: string;
124
+ value: string;
125
+ }, opts?: {
126
+ NX: boolean;
127
+ }): Promise<number>;
128
+ ZRANGE_WITHSCORES(key: string, start: number, end: number): Promise<{
129
+ score: number;
130
+ value: string;
131
+ }>;
132
+ ZRANK(key: string, member: string): Promise<number>;
133
+ ZSCORE(key: string, value: string): Promise<number>;
134
+ }
135
+ interface RedisRedisClassType {
136
+ createClient(options: RedisRedisClientOptions): Partial<RedisRedisClientType>;
137
+ }
138
+ interface IORedisClientOptions {
139
+ port?: number;
140
+ host?: string;
141
+ family?: 'IPv4' | 'IPv6';
142
+ path?: string;
143
+ keepAlive?: number;
144
+ noDelay?: boolean;
145
+ connectionName?: string;
146
+ db?: number;
147
+ password?: string;
148
+ username?: string;
149
+ sentinels?: Array<{
150
+ host: string;
151
+ port: number;
152
+ }>;
153
+ name?: string;
154
+ readOnly?: boolean;
155
+ keyPrefix?: string;
156
+ reconnectOnError?: (err: Error) => boolean;
157
+ }
158
+ interface IORedisClient {
159
+ multi(): IORedisMultiType;
160
+ exec(): Promise<unknown[]>;
161
+ sendCommand(args: any[]): Promise<any>;
162
+ call(command: string, ...args: any[]): Promise<any>;
163
+ quit(): Promise<string>;
164
+ flushdb(): Promise<string>;
165
+ publish(channel: string, message: string): Promise<number>;
166
+ psubscribe(pattern: string, callback: (channel: string, message: string) => void): Promise<void>;
167
+ punsubscribe(pattern: string): void;
168
+ subscribe(channel: string, callback: (channel: string, message: string) => void): void;
169
+ unsubscribe(channel: string): void;
170
+ punsubscribe(channel: string): void;
171
+ xadd(key: string, id: string, fields: any, message?: string): Promise<string>;
172
+ xack(key: string, group: string, id: string): Promise<number>;
173
+ xdel(key: string, id: string): Promise<number>;
174
+ xlen(key: string): Promise<number>;
175
+ xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
176
+ xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
177
+ xinfo(command: 'GROUPS' | string, key: string): Promise<unknown>;
178
+ xrange(key: string, start: string, end: string): Promise<string[][]>;
179
+ del(key: string): Promise<number>;
180
+ exists(key: string): Promise<number>;
181
+ get(key: string): Promise<string | null>;
182
+ hdel(key: string, itemId: string): Promise<number>;
183
+ hget(key: string, itemId: string): Promise<string | null>;
184
+ hgetall(key: string): Promise<StringStringType>;
185
+ hincrbyfloat(key: string, itemId: string, value: number): Promise<number>;
186
+ hmget(key: string, itemIds: string[]): Promise<string[]>;
187
+ hset(key: string, values: Record<string, string>): this;
188
+ lpush(key: string, ...args: string[]): Promise<number>;
189
+ lrange(key: string, start: number, end: number): Promise<string[]>;
190
+ on(event: string, callback: (...args: any[]) => void): void;
191
+ rpush(key: string, ...args: string[]): Promise<number>;
192
+ set(key: string, value: string): Promise<string>;
193
+ zadd(...args: Array<string | number>): Promise<number>;
194
+ zrange(key: string, start: number, end: number, withScores?: 'WITHSCORES'): Promise<string[]>;
195
+ zrank(key: string, member: string): Promise<number>;
196
+ zscore(key: string, value: string): Promise<number>;
197
+ xgroup(command: 'CREATE' | string, key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<string>;
198
+ }
199
+ type IORedisClassType = new (options: IORedisClientOptions, ...args: any[]) => IORedisClient;
200
+ interface IORedisMultiType {
201
+ xadd(key: string, id: string, fields: any, message?: string): this;
202
+ xack(key: string, group: string, id: string): this;
203
+ xdel(key: string, id: string): this;
204
+ xlen(key: string): this;
205
+ xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): this;
206
+ xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): this;
207
+ hdel(key: string, itemId: string): this;
208
+ hget(key: string, itemId: string): this;
209
+ hgetall(key: string): this;
210
+ hincrbyfloat(key: string, itemId: string, value: number): this;
211
+ hmget(key: string, itemIds: string[]): this;
212
+ hset(key: string, values: Record<string, string>): this;
213
+ lrange(key: string, start: number, end: number): this;
214
+ rpush(key: string, value: string): this;
215
+ zadd(...args: Array<string | number>): this;
216
+ xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): this;
217
+ sendCommand(command: string[]): Promise<any>;
218
+ exec: () => Promise<unknown[]>;
219
+ }
220
+ type RedisClass = RedisRedisClassType | IORedisClassType;
221
+ type RedisClient = RedisRedisClientType | IORedisClient;
222
+ type RedisOptions = RedisRedisClientOptions | IORedisClientOptions;
223
+ type RedisMulti = RedisRedisMultiType | IORedisMultiType;
224
+ declare function isRedisClient(client: RedisClient): client is RedisRedisClientType;
225
+ declare function isIORedisClient(client: RedisClient): client is IORedisClient;
226
+ export { RedisClass, RedisRedisClientType, RedisRedisClientOptions, RedisRedisClassType, IORedisClient as IORedisClientType, RedisClient, RedisMulti, RedisRedisMultiType, IORedisClientOptions, IORedisClassType, IORedisMultiType, RedisOptions, MultiResponseFlags, isRedisClient, isIORedisClient, };
@@ -1,2 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isIORedisClient = exports.isRedisClient = void 0;
4
+ function isRedisClient(client) {
5
+ return 'sendCommand' in client;
6
+ }
7
+ exports.isRedisClient = isRedisClient;
8
+ function isIORedisClient(client) {
9
+ return 'pipeline' in client;
10
+ }
11
+ exports.isIORedisClient = isIORedisClient;
@@ -1,38 +1,19 @@
1
- /** Represents a policy for retrying stream operations based on error codes */
2
1
  export interface StreamRetryPolicy {
3
- /**
4
- * Key is error code, value is the retry profile.
5
- * Tuple contains: [max retry count, retry type].
6
- * 'x' denotes exponential backoff (default). Only 10, 100, 1000, 10000 are allowed retry intervals.
7
- */
8
2
  [key: string]: [number, 'x'?];
9
3
  }
10
- /** A 3-digit status code representing the outcome of a stream operation */
11
4
  export type StreamCode = number;
12
- /** Describes the structure of a stream error */
13
5
  export type StreamError = {
14
- /** Descriptive message of the error */
15
6
  message: string;
16
- /** Numeric code corresponding to the type of error */
17
7
  code: number;
18
- /** Optional job identifier, used when communicating errors externally */
19
8
  job_id?: string;
20
- /** Stack trace of the error if unhandled */
21
9
  stack?: string;
22
- /** Name of the error if unhandled */
23
10
  name?: string;
24
- /** Custom user-defined error details */
25
11
  error?: Record<string, unknown>;
26
- /** True if originating via a standard transition message with an `error` status */
27
12
  is_stream_error?: boolean;
28
13
  };
29
- /** Enumerated status values for stream operations */
30
14
  export declare enum StreamStatus {
31
- /** Indicates successful completion of the stream operation */
32
15
  SUCCESS = "success",
33
- /** Indicates an error occurred during the stream operation */
34
16
  ERROR = "error",
35
- /** Indicates the stream operation is still pending */
36
17
  PENDING = "pending"
37
18
  }
38
19
  export declare enum StreamDataType {
@@ -46,51 +27,28 @@ export declare enum StreamDataType {
46
27
  SIGNAL = "signal",
47
28
  INTERRUPT = "interrupt"
48
29
  }
49
- /** Defines the structure of stream data used when passing stream messages (transitions) */
50
30
  export interface StreamData {
51
- /** Metadata associated with the stream data */
52
31
  metadata: {
53
- /** Globally unique identifier for the StreamData message to distinguish `retries` from new 'reentry/cycles' */
54
32
  guid: string;
55
- /** Workflow/job topic */
56
33
  topic?: string;
57
- /** Workflow/job ID */
58
34
  jid?: string;
59
- /** Workflow Generational ID (internal GUID) */
60
35
  gid?: string;
61
- /** Dimensional address indicating the message routing specifics */
62
36
  dad?: string;
63
- /** Activity ID */
64
37
  aid: string;
65
- /** OpenTelemetry Trace identifier */
66
38
  trc?: string;
67
- /** OpenTelemetry Span identifier */
68
39
  spn?: string;
69
- /** Current try count, used for retry logic */
70
40
  try?: number;
71
- /**
72
- * Indicates if the message should wait for a response.
73
- * If explicitly false, the connection is severed immediately
74
- * upon verifying (and returning) the Job ID.
75
- */
76
41
  await?: boolean;
77
42
  };
78
- /** Type of the data being streamed, optional */
79
43
  type?: StreamDataType;
80
- /** Actual data being transmitted as a record of key-value pairs */
81
44
  data: Record<string, unknown>;
82
- /** Policies related to retry logic, optional */
83
45
  policies?: {
84
46
  retry?: StreamRetryPolicy;
85
47
  };
86
- /** Status of the stream, default assumed as 'success' */
87
48
  status?: StreamStatus;
88
- /** HTTP-like status code for the stream, default assumed as 200 */
89
49
  code?: number;
90
- /** Error stack trace */
91
50
  stack?: string;
92
51
  }
93
- /** Extends StreamData for responses, allowing for inheritance of the base properties */
94
52
  export interface StreamDataResponse extends StreamData {
95
53
  }
96
54
  export declare enum StreamRole {
@@ -98,35 +56,19 @@ export declare enum StreamRole {
98
56
  ENGINE = "engine",
99
57
  SYSTEM = "system"
100
58
  }
101
- /**
102
- * Represents a type for messages that have been reclaimed from a stream.
103
- * Each item is a tuple containing a messageId and its details.
104
- */
105
59
  export type ReclaimedMessageType = [
106
- /** The stream ID, typically formatted as `<timestamp>-<count>` */
107
60
  messageId: string,
108
- /** Details of the message, consisting of a key and its value */
109
61
  details: [
110
- /** Key is always 'message' */
111
62
  key: string,
112
- /** Value is a stringified representation of StreamData */
113
63
  value: string
114
64
  ]
115
65
  ][];
116
- /** Configuration parameters for a stream */
117
66
  export type StreamConfig = {
118
- /** Namespace under which the stream operates */
119
67
  namespace: string;
120
- /** Application identifier */
121
68
  appId: string;
122
- /** Globally unique identifier for the stream */
123
69
  guid: string;
124
- /** Role associated with the stream */
125
70
  role: StreamRole;
126
- /** Optional topic for the stream */
127
71
  topic?: string;
128
- /** Delay before a message can be reclaimed, defaults to 60,000 milliseconds */
129
72
  reclaimDelay?: number;
130
- /** Maximum number of reclaims allowed, defaults to 3. Values greater throw an error */
131
73
  reclaimCount?: number;
132
74
  };