@hotmeshio/hotmesh 0.0.55 → 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 (181) hide show
  1. package/build/modules/enums.js +1 -10
  2. package/build/modules/key.d.ts +0 -38
  3. package/build/modules/key.js +4 -46
  4. package/build/modules/utils.d.ts +0 -8
  5. package/build/modules/utils.js +0 -14
  6. package/build/package.json +11 -4
  7. package/build/services/activities/activity.d.ts +0 -28
  8. package/build/services/activities/activity.js +1 -46
  9. package/build/services/activities/await.js +0 -4
  10. package/build/services/activities/cycle.d.ts +0 -7
  11. package/build/services/activities/cycle.js +1 -16
  12. package/build/services/activities/hook.d.ts +0 -6
  13. package/build/services/activities/hook.js +2 -12
  14. package/build/services/activities/interrupt.js +0 -8
  15. package/build/services/activities/signal.d.ts +0 -6
  16. package/build/services/activities/signal.js +0 -15
  17. package/build/services/activities/trigger.d.ts +0 -4
  18. package/build/services/activities/trigger.js +1 -7
  19. package/build/services/activities/worker.js +0 -4
  20. package/build/services/collator/index.d.ts +0 -70
  21. package/build/services/collator/index.js +1 -91
  22. package/build/services/compiler/deployer.js +6 -38
  23. package/build/services/compiler/index.d.ts +0 -15
  24. package/build/services/compiler/index.js +0 -20
  25. package/build/services/compiler/validator.d.ts +0 -3
  26. package/build/services/compiler/validator.js +0 -25
  27. package/build/services/connector/clients/ioredis.d.ts +2 -2
  28. package/build/services/connector/clients/ioredis.js +0 -2
  29. package/build/services/connector/clients/redis.d.ts +4 -4
  30. package/build/services/connector/clients/redis.js +1 -3
  31. package/build/services/connector/index.d.ts +1 -1
  32. package/build/services/connector/index.js +0 -2
  33. package/build/services/durable/client.d.ts +1 -26
  34. package/build/services/durable/client.js +0 -56
  35. package/build/services/durable/exporter.d.ts +0 -22
  36. package/build/services/durable/exporter.js +1 -30
  37. package/build/services/durable/handle.d.ts +0 -36
  38. package/build/services/durable/handle.js +0 -46
  39. package/build/services/durable/index.d.ts +0 -4
  40. package/build/services/durable/index.js +0 -4
  41. package/build/services/durable/schemas/factory.d.ts +0 -29
  42. package/build/services/durable/schemas/factory.js +0 -29
  43. package/build/services/durable/search.d.ts +1 -36
  44. package/build/services/durable/search.js +57 -56
  45. package/build/services/durable/worker.js +2 -22
  46. package/build/services/durable/workflow.d.ts +0 -114
  47. package/build/services/durable/workflow.js +1 -141
  48. package/build/services/engine/index.d.ts +1 -6
  49. package/build/services/engine/index.js +1 -43
  50. package/build/services/exporter/index.d.ts +0 -27
  51. package/build/services/exporter/index.js +0 -33
  52. package/build/services/hotmesh/index.d.ts +2 -2
  53. package/build/services/hotmesh/index.js +1 -9
  54. package/build/services/logger/index.js +0 -2
  55. package/build/services/mapper/index.d.ts +0 -14
  56. package/build/services/mapper/index.js +0 -14
  57. package/build/services/pipe/functions/date.d.ts +0 -7
  58. package/build/services/pipe/functions/date.js +0 -7
  59. package/build/services/pipe/functions/math.js +0 -2
  60. package/build/services/pipe/index.d.ts +0 -15
  61. package/build/services/pipe/index.js +2 -23
  62. package/build/services/quorum/index.d.ts +0 -7
  63. package/build/services/quorum/index.js +0 -21
  64. package/build/services/reporter/index.d.ts +0 -5
  65. package/build/services/reporter/index.js +0 -9
  66. package/build/services/router/index.d.ts +0 -9
  67. package/build/services/router/index.js +2 -38
  68. package/build/services/serializer/index.js +7 -26
  69. package/build/services/store/cache.d.ts +0 -18
  70. package/build/services/store/cache.js +0 -18
  71. package/build/services/store/clients/ioredis.d.ts +1 -1
  72. package/build/services/store/clients/ioredis.js +0 -1
  73. package/build/services/store/clients/redis.d.ts +1 -1
  74. package/build/services/store/index.d.ts +0 -55
  75. package/build/services/store/index.js +5 -81
  76. package/build/services/stream/clients/ioredis.d.ts +1 -1
  77. package/build/services/stream/clients/ioredis.js +1 -4
  78. package/build/services/stream/clients/redis.d.ts +1 -1
  79. package/build/services/sub/clients/ioredis.d.ts +1 -1
  80. package/build/services/sub/clients/redis.d.ts +1 -1
  81. package/build/services/task/index.d.ts +0 -9
  82. package/build/services/task/index.js +0 -31
  83. package/build/services/telemetry/index.d.ts +0 -7
  84. package/build/services/telemetry/index.js +1 -13
  85. package/build/services/worker/index.d.ts +0 -4
  86. package/build/services/worker/index.js +2 -6
  87. package/build/types/activity.d.ts +0 -81
  88. package/build/types/durable.d.ts +25 -177
  89. package/build/types/exporter.d.ts +0 -13
  90. package/build/types/hotmesh.d.ts +4 -16
  91. package/build/types/hotmesh.js +0 -3
  92. package/build/types/index.d.ts +4 -6
  93. package/build/types/index.js +4 -3
  94. package/build/types/job.d.ts +1 -86
  95. package/build/types/pipe.d.ts +0 -65
  96. package/build/types/quorum.d.ts +15 -10
  97. package/build/types/redis.d.ts +225 -7
  98. package/build/types/redis.js +9 -0
  99. package/build/types/stream.d.ts +0 -58
  100. package/build/types/stream.js +0 -4
  101. package/package.json +11 -4
  102. package/types/durable.ts +121 -3
  103. package/types/hotmesh.ts +3 -6
  104. package/types/index.ts +23 -10
  105. package/types/job.ts +1 -1
  106. package/types/quorum.ts +22 -0
  107. package/types/redis.ts +267 -18
  108. package/build/types/ioredisclient.d.ts +0 -5
  109. package/build/types/ioredisclient.js +0 -5
  110. package/build/types/redisclient.d.ts +0 -26
  111. package/build/types/redisclient.js +0 -2
  112. package/modules/enums.ts +0 -62
  113. package/modules/errors.ts +0 -280
  114. package/modules/key.ts +0 -101
  115. package/modules/storage.ts +0 -3
  116. package/modules/utils.ts +0 -242
  117. package/services/activities/activity.ts +0 -589
  118. package/services/activities/await.ts +0 -113
  119. package/services/activities/cycle.ts +0 -115
  120. package/services/activities/hook.ts +0 -197
  121. package/services/activities/index.ts +0 -19
  122. package/services/activities/interrupt.ts +0 -172
  123. package/services/activities/signal.ts +0 -148
  124. package/services/activities/trigger.ts +0 -295
  125. package/services/activities/worker.ts +0 -107
  126. package/services/collator/README.md +0 -102
  127. package/services/collator/index.ts +0 -291
  128. package/services/compiler/deployer.ts +0 -504
  129. package/services/compiler/index.ts +0 -98
  130. package/services/compiler/validator.ts +0 -158
  131. package/services/connector/clients/ioredis.ts +0 -57
  132. package/services/connector/clients/redis.ts +0 -72
  133. package/services/connector/index.ts +0 -42
  134. package/services/durable/client.ts +0 -266
  135. package/services/durable/connection.ts +0 -10
  136. package/services/durable/exporter.ts +0 -232
  137. package/services/durable/handle.ts +0 -160
  138. package/services/durable/index.ts +0 -27
  139. package/services/durable/schemas/factory.ts +0 -2358
  140. package/services/durable/search.ts +0 -196
  141. package/services/durable/worker.ts +0 -401
  142. package/services/durable/workflow.ts +0 -557
  143. package/services/engine/index.ts +0 -761
  144. package/services/exporter/index.ts +0 -146
  145. package/services/hotmesh/index.ts +0 -237
  146. package/services/logger/index.ts +0 -79
  147. package/services/mapper/index.ts +0 -89
  148. package/services/pipe/functions/array.ts +0 -78
  149. package/services/pipe/functions/bitwise.ts +0 -27
  150. package/services/pipe/functions/conditional.ts +0 -35
  151. package/services/pipe/functions/date.ts +0 -220
  152. package/services/pipe/functions/index.ts +0 -27
  153. package/services/pipe/functions/json.ts +0 -11
  154. package/services/pipe/functions/logical.ts +0 -11
  155. package/services/pipe/functions/math.ts +0 -217
  156. package/services/pipe/functions/number.ts +0 -75
  157. package/services/pipe/functions/object.ts +0 -98
  158. package/services/pipe/functions/string.ts +0 -86
  159. package/services/pipe/functions/symbol.ts +0 -39
  160. package/services/pipe/functions/unary.ts +0 -19
  161. package/services/pipe/index.ts +0 -216
  162. package/services/quorum/index.ts +0 -319
  163. package/services/reporter/index.ts +0 -387
  164. package/services/router/index.ts +0 -426
  165. package/services/serializer/README.md +0 -10
  166. package/services/serializer/index.ts +0 -285
  167. package/services/store/cache.ts +0 -172
  168. package/services/store/clients/ioredis.ts +0 -145
  169. package/services/store/clients/redis.ts +0 -191
  170. package/services/store/index.ts +0 -1091
  171. package/services/stream/clients/ioredis.ts +0 -157
  172. package/services/stream/clients/redis.ts +0 -158
  173. package/services/stream/index.ts +0 -58
  174. package/services/sub/clients/ioredis.ts +0 -83
  175. package/services/sub/clients/redis.ts +0 -74
  176. package/services/sub/index.ts +0 -25
  177. package/services/task/index.ts +0 -250
  178. package/services/telemetry/index.ts +0 -273
  179. package/services/worker/index.ts +0 -248
  180. package/types/ioredisclient.ts +0 -10
  181. package/types/redisclient.ts +0 -30
package/types/redis.ts CHANGED
@@ -1,27 +1,276 @@
1
- import {
2
- RedisClassType,
3
- RedisClientType as RCT,
4
- RedisMultiType as RMT,
5
- RedisClientOptions as RCO
6
- } from './redisclient';
7
- import {
8
- RedisClassType as IORRedisClassType,
9
- RedisClientType as IORCT,
10
- RedisMultiType as IORMT,
11
- RedisClientOptions as IORCO
12
- } from './ioredisclient';
13
-
14
- type RedisClass = RedisClassType | IORRedisClassType;
15
- type RedisClient = RCT | IORCT;
16
- type RedisMulti = RMT | IORMT;
17
- type RedisOptions = RCO | IORCO;
1
+ import { StringStringType } from './serializer';
2
+ import { ReclaimedMessageType } from './stream';
18
3
 
19
4
  type MultiResponseFlags = (string | number)[]; // e.g., [3, 2, '0']
20
5
 
6
+ /**
7
+ * Redis types
8
+ */
9
+ interface ConnectionOptions {
10
+ //[key: string]: any;
11
+ host?: string;
12
+ port?: number;
13
+ path?: string; // Creates unix socket connection to path. If this option is specified, host and port are ignored.
14
+ socket?: any; // Establish secure connection on a given socket rather than creating a new socket
15
+ NPNProtocols?: string[] | Buffer[]; // Defaults to []
16
+ ALPNProtocols?: string[] | Buffer[]; // Defaults to []
17
+ servername?: string; // SNI TLS Extension
18
+ checkServerIdentity?: (servername: string, cert: Buffer) => Error | undefined;
19
+ session?: Buffer;
20
+ minDHSize?: number;
21
+ secureContext?: any; // If not provided, the entire ConnectionOptions object will be passed to tls.createSecureContext()
22
+ secureProtocol?: string; // The SSL method to use, e.g., SSLv3_method
23
+ ciphers?: string;
24
+ honorCipherOrder?: boolean;
25
+ requestCert?: boolean;
26
+ rejectUnauthorized?: boolean;
27
+ maxVersion?: 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
28
+ minVersion?: 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
29
+ }
30
+
31
+ interface RedisRedisClientOptions {
32
+ url?: string;
33
+ socket?: {
34
+ host?: string;
35
+ port?: number;
36
+ tls?: boolean;
37
+ servername?: string;
38
+ //[key: string]: any;
39
+ };
40
+ username?: string;
41
+ password?: string;
42
+ database?: number;
43
+ name?: string;
44
+ readonly?: boolean;
45
+ legacyMode?: boolean;
46
+ commandsQueueMaxLength?: number;
47
+ disableOfflineQueue?: boolean;
48
+ connectTimeout?: number;
49
+ autoResubscribe?: boolean;
50
+ autoResendUnfulfilledCommands?: boolean;
51
+ lazyConnect?: boolean;
52
+ tls?: boolean | ConnectionOptions;
53
+ enableReadyCheck?: boolean;
54
+ keepAlive?: number;
55
+ family?: 'IPv4' | 'IPv6';
56
+ keyPrefix?: string;
57
+ retry?: {
58
+ maxReconnectionAttempts?: number;
59
+ initialReconnectionDelay?: number;
60
+ reconnectionBackoffFactor?: number;
61
+ totalReconnectionTimeout?: number;
62
+ maxRetryCount?: number;
63
+ };
64
+ stringNumbers?: boolean;
65
+ }
66
+
67
+ interface RedisRedisMultiType {
68
+ sendCommand(command: string, ...args: string[]): Promise<any>;
69
+ exec: () => Promise<unknown[]>;
70
+
71
+ XADD(key: string, id: string, fields: any): this;
72
+ XACK(key: string, group: string, id: string): this;
73
+ XDEL(key: string, id: string): this;
74
+ XLEN(key: string): this;
75
+ DEL(key: string): this;
76
+ EXISTS(key: string): this;
77
+ HDEL(key: string, itemId: string): this;
78
+ HGET(key: string, itemId: string): this;
79
+ HGETALL(key: string): this;
80
+ HINCRBYFLOAT(key: string, itemId: string, value: number): this;
81
+ HMGET(key: string, itemIds: string[]): Promise<string[]>;
82
+ HSET(key: string, values: Record<string, string>): this;
83
+ LPUSH(key: string, items: string[]): this;
84
+ LRANGE(key: string, start: number, end: number): this;
85
+ RPUSH(key: string, items: string[]): this;
86
+ SET(key: string, value: string): this;
87
+ ZADD(key: string, values: { score: string, value: string }, opts?: { NX: boolean }): this;
88
+ ZRANGE_WITHSCORES(key: string, start: number, end: number): this;
89
+ ZRANK(key: string, member: string): this;
90
+ ZSCORE(key: string, value: string): this;
91
+ }
92
+
93
+ interface RedisRedisClientType {
94
+ multi(): Partial<RedisRedisMultiType>;
95
+ connect(): Promise<void>;
96
+ sendCommand(args: any[]): Promise<any>;
97
+ exec(): Promise<unknown[]>;
98
+ flushDb(): Promise<string>;
99
+ quit(): Promise<string>;
100
+ disconnect(): void;
101
+ duplicate(): RedisRedisClientType;
102
+ on(event: string, callback: (...args: any[]) => void): void;
103
+ publish(channel: string, message: string): Promise<number>;
104
+ pSubscribe(pattern: string, callback: (channel: string, message: string) => void): void;
105
+ pUnsubscribe(pattern: string): void;
106
+ subscribe(channel: string, callback: (channel: string, message: string) => void): void;
107
+ unsubscribe(channel: string): void;
108
+ punsubscribe(channel: string): void;
109
+ get(key: string): Promise<string | null>;
110
+ set(key: string, value: string): Promise<string>;
111
+
112
+ XADD(key: string, id: string, fields: any): Promise<string>;
113
+ XACK(key: string, group: string, id: string): Promise<number>;
114
+ XDEL(key: string, id: string): Promise<number>;
115
+ XLEN(key: string): Promise<number>;
116
+ DEL(key: string): Promise<number>;
117
+ EXISTS(key: string): Promise<number>;
118
+ HDEL(key: string, itemId: string): Promise<number>;
119
+ HGET(key: string, itemId: string): Promise<string | null>;
120
+ HGETALL(key: string): Promise<StringStringType>;
121
+ HINCRBYFLOAT(key: string, itemId: string, value: number): Promise<number>;
122
+ HMGET(key: string, itemIds: string[]): Promise<string[]>;
123
+ HSET(key: string, values: Record<string, string>): this;
124
+ LPUSH(key: string, items: string[]): Promise<number>;
125
+ LRANGE(key: string, start: number, end: number): Promise<string[]>;
126
+ RPUSH(key: string, items: string[]): Promise<number>;
127
+ SET(key: string, value: string): Promise<string>;
128
+ ZADD(key: string, values: { score: string, value: string }, opts?: { NX: boolean }): Promise<number>;
129
+ ZRANGE_WITHSCORES(key: string, start: number, end: number): Promise<{ score: number, value: string }>;
130
+ ZRANK(key: string, member: string): Promise<number>;
131
+ ZSCORE(key: string, value: string): Promise<number>;
132
+ }
133
+
134
+ interface RedisRedisClassType {
135
+ createClient(options: RedisRedisClientOptions): Partial<RedisRedisClientType>;
136
+ }
137
+
138
+ /**
139
+ * IORedis types
140
+ */
141
+ interface IORedisClientOptions {
142
+ port?: number;
143
+ host?: string;
144
+ family?: 'IPv4' | 'IPv6';
145
+ path?: string;
146
+ keepAlive?: number;
147
+ noDelay?: boolean;
148
+ connectionName?: string;
149
+ db?: number;
150
+ password?: string;
151
+ username?: string;
152
+ sentinels?: Array<{ host: string; port: number }>;
153
+ name?: string;
154
+ readOnly?: boolean;
155
+ keyPrefix?: string;
156
+ reconnectOnError?: (err: Error) => boolean;
157
+ }
158
+
159
+ interface IORedisClient {
160
+ multi(): IORedisMultiType;
161
+ exec(): Promise<unknown[]>;
162
+ sendCommand(args: any[]): Promise<any>;
163
+ call(command: string, ...args: any[]): Promise<any>;
164
+ quit(): Promise<string>;
165
+ flushdb(): Promise<string>;
166
+
167
+ publish(channel: string, message: string): Promise<number>;
168
+ psubscribe(pattern: string, callback: (channel: string, message: string) => void): Promise<void>;
169
+ punsubscribe(pattern: string): void;
170
+ subscribe(channel: string, callback: (channel: string, message: string) => void): void;
171
+ unsubscribe(channel: string): void;
172
+ punsubscribe(channel: string): void;
173
+
174
+ xadd(key: string, id: string, fields: any, message?: string): Promise<string>;
175
+ xack(key: string, group: string, id: string): Promise<number>;
176
+ xdel(key: string, id: string): Promise<number>;
177
+ xlen(key: string): Promise<number>;
178
+ xpending(
179
+ key: string,
180
+ group: string,
181
+ start?: string,
182
+ end?: string,
183
+ count?: number,
184
+ consumer?: string
185
+ ): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
186
+ xclaim(
187
+ key: string,
188
+ group: string,
189
+ consumer: string,
190
+ minIdleTime: number,
191
+ id: string,
192
+ ...args: string[]
193
+ ): Promise<ReclaimedMessageType>;
194
+ xinfo(command: 'GROUPS' | string, key: string): Promise<unknown>;
195
+ xrange(key: string, start: string, end: string): Promise<string[][]>;
196
+ del(key: string): Promise<number>;
197
+ exists(key: string): Promise<number>
198
+ get(key: string): Promise<string | null>;
199
+ hdel(key: string, itemId: string): Promise<number>;
200
+ hget(key: string, itemId: string): Promise<string | null>;
201
+ hgetall(key: string): Promise<StringStringType>;
202
+ hincrbyfloat(key: string, itemId: string, value: number): Promise<number>;
203
+ hmget(key: string, itemIds: string[]): Promise<string[]>;
204
+ hset(key: string, values: Record<string, string>): this;
205
+ lpush(key: string, ...args: string[]): Promise<number>;
206
+ lrange(key: string, start: number, end: number): Promise<string[]>;
207
+ on(event: string, callback: (...args: any[]) => void): void;
208
+ rpush(key: string, ...args: string[]): Promise<number>;
209
+ set(key: string, value: string): Promise<string>;
210
+ zadd(...args: Array<string | number>): Promise<number>;
211
+ zrange(key: string, start: number, end: number, withScores?: 'WITHSCORES'): Promise<string[]>;
212
+ zrank(key: string, member: string): Promise<number>;
213
+ zscore(key: string, value: string): Promise<number>;
214
+ xgroup(command: 'CREATE' | string, key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<string>;
215
+ }
216
+
217
+ type IORedisClassType = new (options: IORedisClientOptions, ...args: any[]) => IORedisClient;
218
+ interface IORedisMultiType {
219
+ xadd(key: string, id: string, fields: any, message?: string): this;
220
+ xack(key: string, group: string, id: string): this;
221
+ xdel(key: string, id: string): this;
222
+ xlen(key: string): this;
223
+ xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): this;
224
+ xclaim(
225
+ key: string,
226
+ group: string,
227
+ consumer: string,
228
+ minIdleTime: number,
229
+ id: string,
230
+ ...args: string[]
231
+ ): this;
232
+ hdel(key: string, itemId: string): this;
233
+ hget(key: string, itemId: string): this;
234
+ hgetall(key: string): this;
235
+ hincrbyfloat(key: string, itemId: string, value: number): this;
236
+ hmget(key: string, itemIds: string[]): this;
237
+ hset(key: string, values: Record<string, string>): this;
238
+ lrange(key: string, start: number, end: number): this;
239
+ rpush(key: string, value: string): this;
240
+ zadd(...args: Array<string | number>): this;
241
+ xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): this;
242
+
243
+ sendCommand(command: string[]): Promise<any>;
244
+ exec: () => Promise<unknown[]>;
245
+ }
246
+
247
+ type RedisClass = RedisRedisClassType | IORedisClassType;
248
+ type RedisClient = RedisRedisClientType | IORedisClient;
249
+ type RedisOptions = RedisRedisClientOptions | IORedisClientOptions;
250
+ type RedisMulti = RedisRedisMultiType | IORedisMultiType;
251
+
252
+ function isRedisClient(client: RedisClient): client is RedisRedisClientType {
253
+ return 'sendCommand' in client;
254
+ }
255
+
256
+ function isIORedisClient(client: RedisClient): client is IORedisClient {
257
+ return 'pipeline' in client;
258
+ }
259
+
21
260
  export {
22
261
  RedisClass,
262
+ RedisRedisClientType,
263
+ RedisRedisClientOptions,
264
+ RedisRedisClassType,
265
+ IORedisClient as IORedisClientType,
23
266
  RedisClient,
24
267
  RedisMulti,
268
+ RedisRedisMultiType,
269
+ IORedisClientOptions,
270
+ IORedisClassType,
271
+ IORedisMultiType,
25
272
  RedisOptions,
26
273
  MultiResponseFlags,
27
- }
274
+ isRedisClient,
275
+ isIORedisClient,
276
+ };
@@ -1,5 +0,0 @@
1
- import { Redis, ChainableCommander, RedisOptions } from 'ioredis';
2
- type RedisClassType = {
3
- new (options: RedisOptions): Redis;
4
- };
5
- export { RedisClassType, Redis as RedisClientType, ChainableCommander as RedisMultiType, RedisOptions as RedisClientOptions, };
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedisClientType = void 0;
4
- const ioredis_1 = require("ioredis");
5
- Object.defineProperty(exports, "RedisClientType", { enumerable: true, get: function () { return ioredis_1.Redis; } });
@@ -1,26 +0,0 @@
1
- import { createClient, RedisClientOptions } from 'redis';
2
- type RedisClientType = ReturnType<typeof createClient>;
3
- interface RedisMultiType {
4
- XADD(key: string, id: string, fields: any): this;
5
- XACK(key: string, group: string, id: string): this;
6
- XDEL(key: string, id: string): this;
7
- XLEN(key: string): this;
8
- HDEL(key: string, itemId: string): this;
9
- HGET(key: string, itemId: string): this;
10
- HGETALL(key: string): this;
11
- HINCRBYFLOAT(key: string, itemId: string, value: number): this;
12
- HMGET(key: string, itemIds: string[]): this;
13
- HSET(key: string, values: Record<string, string>): this;
14
- LRANGE(key: string, start: number, end: number): this;
15
- RPUSH(key: string, value: string): this;
16
- ZADD(key: string, values: {
17
- score: string;
18
- value: string;
19
- }): this;
20
- sendCommand(command: string[]): Promise<any>;
21
- exec: () => Promise<unknown[]>;
22
- }
23
- type RedisClassType = {
24
- createClient: (options: RedisClientOptions) => any;
25
- };
26
- export { RedisClassType, RedisClientType, RedisMultiType, RedisClientOptions, };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/modules/enums.ts DELETED
@@ -1,62 +0,0 @@
1
- import { LogLevel } from "../types/logger";
2
-
3
- // HOTMESH SYSTEM
4
- export const HMSH_LOGLEVEL = process.env.HMSH_LOGLEVEL as LogLevel || 'info';
5
-
6
- // HOTMESH STATUS CODES
7
- export const HMSH_CODE_SUCCESS = 200;
8
- export const HMSH_CODE_PENDING = 202;
9
- export const HMSH_CODE_NOTFOUND = 404;
10
- export const HMSH_CODE_INTERRUPT = 410;
11
- export const HMSH_CODE_UNKNOWN = 500;
12
- export const HMSH_CODE_TIMEOUT = 504;
13
- export const HMSH_CODE_UNACKED = 999;
14
- // DURABLE STATUS CODES
15
- export const HMSH_CODE_DURABLE_SLEEP = 588;
16
- export const HMSH_CODE_DURABLE_ALL = 589;
17
- export const HMSH_CODE_DURABLE_CHILD = 590;
18
- export const HMSH_CODE_DURABLE_PROXY = 591;
19
- export const HMSH_CODE_DURABLE_WAIT = 595;
20
- export const HMSH_CODE_DURABLE_TIMEOUT = 596;
21
- export const HMSH_CODE_DURABLE_MAXED = 597;
22
- export const HMSH_CODE_DURABLE_FATAL = 598;
23
- export const HMSH_CODE_DURABLE_RETRYABLE = 599;
24
-
25
- // HOTMESH MESSAGES
26
- export const HMSH_STATUS_UNKNOWN = 'unknown';
27
-
28
- // QUORUM
29
- export const HMSH_QUORUM_ROLLCALL_CYCLES = 12; //max iterations
30
- export const HMSH_QUORUM_DELAY_MS = 250;
31
- export const HMSH_ACTIVATION_MAX_RETRY = 3;
32
-
33
- // ENGINE
34
- export const HMSH_OTT_WAIT_TIME = parseInt(process.env.HMSH_OTT_WAIT_TIME, 10) || 1000;
35
- export const HMSH_EXPIRE_JOB_SECONDS = parseInt(process.env.HMSH_EXPIRE_JOB_SECONDS, 10) || 1;
36
-
37
- // STREAM ROUTER
38
- export const HMSH_MAX_RETRIES = parseInt(process.env.HMSH_MAX_RETRIES, 10) || 3;
39
- export const HMSH_MAX_TIMEOUT_MS = parseInt(process.env.HMSH_MAX_TIMEOUT_MS, 10) || 60000;
40
- export const HMSH_GRADUATED_INTERVAL_MS = parseInt(process.env.HMSH_GRADUATED_INTERVAL_MS, 10) || 5000;
41
-
42
- // DURABLE
43
- export const HMSH_DURABLE_MAX_ATTEMPTS = 3;
44
- export const HMSH_DURABLE_MAX_INTERVAL = '120s';
45
- export const HMSH_DURABLE_EXP_BACKOFF = 10;
46
-
47
- const BASE_BLOCK_DURATION = 10000;
48
- const TEST_BLOCK_DURATION = 1000;
49
- export const HMSH_BLOCK_TIME_MS = process.env.HMSH_BLOCK_TIME_MS ? parseInt(process.env.HMSH_BLOCK_TIME_MS, 10) : (process.env.NODE_ENV === 'test' ? TEST_BLOCK_DURATION : BASE_BLOCK_DURATION);
50
-
51
- export const HMSH_XCLAIM_DELAY_MS = parseInt(process.env.HMSH_XCLAIM_DELAY_MS, 10) || 1000 * 60;
52
- export const HMSH_XCLAIM_COUNT = parseInt(process.env.HMSH_XCLAIM_COUNT, 10) || 3;
53
- export const HMSH_XPENDING_COUNT = parseInt(process.env.HMSH_XPENDING_COUNT, 10) || 10;
54
-
55
- // TASK WORKER
56
- export const HMSH_EXPIRE_DURATION = parseInt(process.env.HMSH_EXPIRE_DURATION, 10) || 1;
57
-
58
- const BASE_FIDELITY_SECONDS = 5;
59
- const TEST_FIDELITY_SECONDS = 1;
60
- export const HMSH_FIDELITY_SECONDS = process.env.HMSH_FIDELITY_SECONDS ? parseInt(process.env.HMSH_FIDELITY_SECONDS, 10) : (process.env.NODE_ENV === 'test' ? TEST_FIDELITY_SECONDS : BASE_FIDELITY_SECONDS);
61
-
62
- export const HMSH_SCOUT_INTERVAL_SECONDS = parseInt(process.env.HMSH_SCOUT_INTERVAL_SECONDS, 10) || 60;
package/modules/errors.ts DELETED
@@ -1,280 +0,0 @@
1
- import {
2
- HMSH_CODE_DURABLE_MAXED,
3
- HMSH_CODE_DURABLE_TIMEOUT,
4
- HMSH_CODE_DURABLE_FATAL,
5
- HMSH_CODE_NOTFOUND,
6
- HMSH_CODE_DURABLE_RETRYABLE,
7
- HMSH_CODE_DURABLE_WAIT,
8
- HMSH_CODE_DURABLE_PROXY,
9
- HMSH_CODE_DURABLE_CHILD,
10
- HMSH_CODE_DURABLE_ALL,
11
- HMSH_CODE_DURABLE_SLEEP } from "./enums";
12
- import { ActivityDuplex } from "../types/activity";
13
- import { CollationFaultType, CollationStage } from "../types/collator";
14
- import {
15
- DurableChildErrorType,
16
- DurableProxyErrorType,
17
- DurableSleepErrorType,
18
- DurableWaitForAllErrorType,
19
- DurableWaitForErrorType } from "../types/error";
20
-
21
- class GetStateError extends Error {
22
- jobId: string;
23
- code = HMSH_CODE_NOTFOUND;
24
- constructor(jobId: string) {
25
- super(`${jobId} Not Found`);
26
- this.jobId = jobId;
27
- }
28
- }
29
- class SetStateError extends Error {
30
- constructor() {
31
- super("Error occurred while setting job state");
32
- }
33
- }
34
-
35
- class DurableWaitForError extends Error {
36
- code: number;
37
- signalId: string;
38
- workflowId: string;
39
- index: number;
40
- workflowDimension: string; //hook workflowDimension (e.g., ',0,1,0') (use empty string for `null`)
41
- constructor(params: DurableWaitForErrorType) {
42
- super(`WaitFor Interruption`);
43
- this.signalId = params.signalId;
44
- this.index = params.index;
45
- this.workflowDimension = params.workflowDimension;
46
- this.code = HMSH_CODE_DURABLE_WAIT;
47
- }
48
- }
49
-
50
- class DurableProxyError extends Error {
51
- activityName: string;
52
- arguments: string[];
53
- backoffCoefficient: number;
54
- code: number;
55
- index: number;
56
- maximumAttempts: number;
57
- maximumInterval: number;
58
- originJobId: string | null;
59
- parentWorkflowId: string;
60
- workflowDimension: string;
61
- workflowId: string;
62
- workflowTopic: string;
63
- constructor(params: DurableProxyErrorType) {
64
- super(`ProxyActivity Interruption`);
65
- this.arguments = params.arguments;
66
- this.workflowId = params.workflowId;
67
- this.workflowTopic = params.workflowTopic;
68
- this.parentWorkflowId = params.parentWorkflowId;
69
- this.originJobId = params.originJobId;
70
- this.index = params.index;
71
- this.activityName = params.activityName;
72
- this.workflowDimension = params.workflowDimension;
73
- this.backoffCoefficient = params.backoffCoefficient;
74
- this.maximumAttempts = params.maximumAttempts;
75
- this.maximumInterval = params.maximumInterval;
76
- this.code = HMSH_CODE_DURABLE_PROXY;
77
- }
78
- }
79
-
80
- class DurableChildError extends Error {
81
- await: boolean;
82
- arguments: string[];
83
- backoffCoefficient: number;
84
- code: number;
85
- workflowDimension: string;
86
- index: number;
87
- maximumAttempts: number;
88
- maximumInterval: number;
89
- originJobId: string | null;
90
- parentWorkflowId: string;
91
- workflowId: string;
92
- workflowTopic: string;
93
- constructor(params: DurableChildErrorType) {
94
- super(`ExecChild Interruption`);
95
- this.arguments = params.arguments;
96
- this.workflowId = params.workflowId;
97
- this.workflowTopic = params.workflowTopic;
98
- this.parentWorkflowId = params.parentWorkflowId;
99
- this.originJobId = params.originJobId;
100
- this.index = params.index;
101
- this.workflowDimension = params.workflowDimension;
102
- this.code = HMSH_CODE_DURABLE_CHILD;
103
- this.await = params.await;
104
- this.backoffCoefficient = params.backoffCoefficient;
105
- this.maximumAttempts = params.maximumAttempts;
106
- this.maximumInterval = params.maximumInterval;
107
- }
108
- }
109
-
110
- class DurableWaitForAllError extends Error {
111
- items: any[];
112
- code: number;
113
- workflowDimension: string;
114
- size: number;
115
- index: number;
116
- originJobId: string | null;
117
- parentWorkflowId: string;
118
- workflowId: string;
119
- workflowTopic: string;
120
- constructor(params: DurableWaitForAllErrorType) {
121
- super(`Collation Interruption`);
122
- this.items = params.items;
123
- this.size = params.size;
124
- this.workflowId = params.workflowId;
125
- this.workflowTopic = params.workflowTopic;
126
- this.parentWorkflowId = params.parentWorkflowId;
127
- this.originJobId = params.originJobId;
128
- this.index = params.index;
129
- this.workflowDimension = params.workflowDimension;
130
- this.code = HMSH_CODE_DURABLE_ALL;
131
- }
132
- }
133
-
134
- class DurableSleepError extends Error {
135
- workflowId: string;
136
- code: number;
137
- duration: number; //seconds
138
- index: number;
139
- workflowDimension: string; //empty string for null
140
- constructor(params: DurableSleepErrorType) {
141
- super(`SleepFor Interruption`);
142
- this.duration = params.duration;
143
- this.workflowId = params.workflowId;
144
- this.index = params.index;
145
- this.workflowDimension = params.workflowDimension;
146
- this.code = HMSH_CODE_DURABLE_SLEEP;
147
- }
148
- }
149
-
150
- class DurableTimeoutError extends Error {
151
- code: number;
152
- constructor(message: string, stack?: string) {
153
- super(message);
154
- if (this.stack) {
155
- this.stack = stack;
156
- }
157
- this.code = HMSH_CODE_DURABLE_TIMEOUT;
158
- }
159
- }
160
- class DurableMaxedError extends Error {
161
- code: number;
162
- constructor(message: string, stackTrace?: string) {
163
- super(message);
164
- if (stackTrace) {
165
- this.stack = stackTrace;
166
- }
167
- this.code = HMSH_CODE_DURABLE_MAXED;
168
- }
169
- }
170
- class DurableFatalError extends Error {
171
- code: number;
172
- constructor(message: string, stackTrace?: string) {
173
- super(message);
174
- if (stackTrace) {
175
- this.stack = stackTrace;
176
- }
177
- this.code = HMSH_CODE_DURABLE_FATAL;
178
- }
179
- }
180
- class DurableRetryError extends Error {
181
- code: number;
182
- constructor(message: string, stackTrace?: string) {
183
- super(message);
184
- if (stackTrace) {
185
- this.stack = stackTrace;
186
- }
187
- this.code = HMSH_CODE_DURABLE_RETRYABLE;
188
- }
189
- }
190
-
191
- class MapDataError extends Error {
192
- constructor() {
193
- super("Error occurred while mapping data");
194
- }
195
- }
196
-
197
- class RegisterTimeoutError extends Error {
198
- constructor() {
199
- super("Error occurred while registering activity timeout");
200
- }
201
- }
202
-
203
- class DuplicateJobError extends Error {
204
- jobId: string;
205
- constructor(jobId: string) {
206
- super("Duplicate job");
207
- this.jobId = jobId;
208
- this.message = `Duplicate job: ${jobId}`;
209
- }
210
- }
211
- class InactiveJobError extends Error {
212
- jobId: string;
213
- activityId: string;
214
- status: number; //non-positive integer
215
- constructor(jobId: string, status: number, activityId: string) {
216
- super("Inactive job");
217
- this.jobId = jobId;
218
- this.activityId = activityId;
219
- this.message = `Inactive job: ${jobId}`;
220
- this.status = status;
221
- }
222
- }
223
- class GenerationalError extends Error {
224
- expected: string;
225
- actual: string;
226
- jobId: string;
227
- activityId: string;
228
- dimensionalAddress: string;
229
-
230
- constructor(expected: string, actual: string, jobId: string, activityId: string, dimensionalAddress: string) {
231
- super("Generational Error");
232
- this.expected = expected;
233
- this.actual = actual;
234
- this.jobId = jobId;
235
- this.activityId = activityId;
236
- this.dimensionalAddress = dimensionalAddress;
237
- }
238
- }
239
-
240
- class ExecActivityError extends Error {
241
- constructor() {
242
- super("Error occurred while executing activity");
243
- }
244
- }
245
-
246
- class CollationError extends Error {
247
- status: number; //15-digit activity collation integer (889000001000001)
248
- leg: ActivityDuplex;
249
- stage: CollationStage; //enter | exit | confirm
250
- fault: CollationFaultType; //missing, invalid, etc
251
-
252
- constructor(status: number, leg: ActivityDuplex, stage: CollationStage, fault?: CollationFaultType) {
253
- super("collation-error");
254
- this.leg = leg;
255
- this.status = status;
256
- this.stage = stage;
257
- this.fault = fault;
258
- }
259
- }
260
-
261
- export {
262
- CollationError,
263
- DurableChildError,
264
- DurableFatalError,
265
- DurableMaxedError,
266
- DurableProxyError,
267
- DurableRetryError,
268
- DurableSleepError,
269
- DurableTimeoutError,
270
- DurableWaitForAllError,
271
- DurableWaitForError,
272
- DuplicateJobError,
273
- ExecActivityError,
274
- GenerationalError,
275
- GetStateError,
276
- InactiveJobError,
277
- MapDataError,
278
- RegisterTimeoutError,
279
- SetStateError,
280
- };