@hotmeshio/hotmesh 0.0.60 → 0.1.1

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 (108) hide show
  1. package/README.md +1 -1
  2. package/build/modules/enums.d.ts +2 -1
  3. package/build/modules/enums.js +12 -3
  4. package/build/modules/errors.d.ts +3 -3
  5. package/build/modules/errors.js +8 -8
  6. package/build/modules/key.d.ts +1 -1
  7. package/build/modules/key.js +3 -3
  8. package/build/modules/utils.d.ts +6 -5
  9. package/build/modules/utils.js +24 -16
  10. package/build/package.json +41 -38
  11. package/build/services/activities/activity.js +40 -23
  12. package/build/services/activities/await.d.ts +1 -1
  13. package/build/services/activities/await.js +15 -7
  14. package/build/services/activities/cycle.d.ts +1 -1
  15. package/build/services/activities/cycle.js +16 -8
  16. package/build/services/activities/hook.d.ts +1 -1
  17. package/build/services/activities/hook.js +8 -4
  18. package/build/services/activities/interrupt.d.ts +1 -1
  19. package/build/services/activities/interrupt.js +14 -6
  20. package/build/services/activities/signal.d.ts +1 -1
  21. package/build/services/activities/signal.js +12 -4
  22. package/build/services/activities/trigger.d.ts +1 -1
  23. package/build/services/activities/trigger.js +19 -12
  24. package/build/services/activities/worker.d.ts +1 -1
  25. package/build/services/activities/worker.js +15 -7
  26. package/build/services/collator/index.js +12 -12
  27. package/build/services/compiler/deployer.js +17 -12
  28. package/build/services/compiler/index.js +4 -4
  29. package/build/services/compiler/validator.d.ts +3 -3
  30. package/build/services/compiler/validator.js +12 -3
  31. package/build/services/durable/client.d.ts +1 -1
  32. package/build/services/durable/client.js +18 -12
  33. package/build/services/durable/connection.d.ts +1 -1
  34. package/build/services/durable/exporter.d.ts +1 -1
  35. package/build/services/durable/exporter.js +3 -4
  36. package/build/services/durable/handle.d.ts +1 -1
  37. package/build/services/durable/handle.js +4 -1
  38. package/build/services/durable/index.d.ts +1 -1
  39. package/build/services/durable/index.js +2 -2
  40. package/build/services/durable/schemas/factory.d.ts +1 -1
  41. package/build/services/durable/search.js +19 -11
  42. package/build/services/durable/worker.js +50 -30
  43. package/build/services/durable/workflow.d.ts +5 -5
  44. package/build/services/durable/workflow.js +34 -18
  45. package/build/services/engine/index.js +33 -26
  46. package/build/services/exporter/index.d.ts +1 -1
  47. package/build/services/exporter/index.js +3 -3
  48. package/build/services/hotmesh/index.js +1 -1
  49. package/build/services/logger/index.js +1 -1
  50. package/build/services/mapper/index.js +3 -1
  51. package/build/services/pipe/functions/date.js +1 -1
  52. package/build/services/pipe/index.js +37 -10
  53. package/build/services/quorum/index.js +14 -11
  54. package/build/services/reporter/index.js +15 -12
  55. package/build/services/router/index.d.ts +2 -2
  56. package/build/services/router/index.js +73 -23
  57. package/build/services/serializer/index.js +48 -26
  58. package/build/services/store/cache.d.ts +5 -5
  59. package/build/services/store/cache.js +2 -2
  60. package/build/services/store/clients/ioredis.d.ts +6 -0
  61. package/build/services/store/clients/ioredis.js +85 -3
  62. package/build/services/store/clients/redis.d.ts +6 -0
  63. package/build/services/store/clients/redis.js +140 -4
  64. package/build/services/store/index.d.ts +9 -3
  65. package/build/services/store/index.js +121 -60
  66. package/build/services/stream/clients/ioredis.js +4 -4
  67. package/build/services/stream/clients/redis.js +31 -4
  68. package/build/services/task/index.js +8 -11
  69. package/build/services/telemetry/index.js +21 -14
  70. package/build/services/worker/index.d.ts +6 -6
  71. package/build/services/worker/index.js +12 -7
  72. package/build/types/activity.d.ts +3 -3
  73. package/build/types/durable.d.ts +81 -77
  74. package/build/types/exporter.d.ts +2 -2
  75. package/build/types/exporter.js +0 -6
  76. package/build/types/hook.d.ts +1 -1
  77. package/build/types/hotmesh.js +0 -1
  78. package/build/types/index.d.ts +13 -13
  79. package/build/types/job.d.ts +1 -1
  80. package/build/types/logger.js +0 -1
  81. package/build/types/quorum.d.ts +1 -1
  82. package/build/types/redis.d.ts +6 -1
  83. package/build/types/stats.d.ts +1 -1
  84. package/build/types/stream.d.ts +1 -2
  85. package/build/types/telemetry.d.ts +1 -1
  86. package/build/types/transition.d.ts +1 -1
  87. package/package.json +41 -38
  88. package/types/activity.ts +56 -39
  89. package/types/async.ts +2 -3
  90. package/types/collator.ts +5 -5
  91. package/types/durable.ts +90 -86
  92. package/types/error.ts +37 -37
  93. package/types/exporter.ts +14 -9
  94. package/types/hook.ts +11 -4
  95. package/types/hotmesh.ts +26 -25
  96. package/types/index.ts +54 -53
  97. package/types/job.ts +33 -33
  98. package/types/logger.ts +1 -1
  99. package/types/map.ts +1 -1
  100. package/types/pipe.ts +10 -8
  101. package/types/quorum.ts +20 -13
  102. package/types/redis.ts +96 -16
  103. package/types/serializer.ts +8 -6
  104. package/types/stats.ts +22 -6
  105. package/types/stream.ts +9 -9
  106. package/types/task.ts +7 -1
  107. package/types/telemetry.ts +2 -1
  108. package/types/transition.ts +8 -8
package/types/redis.ts CHANGED
@@ -78,13 +78,42 @@ interface RedisRedisMultiType {
78
78
  HGET(key: string, itemId: string): this;
79
79
  HGETALL(key: string): this;
80
80
  HINCRBYFLOAT(key: string, itemId: string, value: number): this;
81
- HMGET(key: string, itemIds: string[]): Promise<string[]>;
81
+ HMPUSH(key: string, values: Record<string, string>): this;
82
+ RPUSH(key: string, items: string[]): this;
83
+ HMGET(key: string, itemIds: string[]): this;
82
84
  HSET(key: string, values: Record<string, string>): this;
83
85
  LPUSH(key: string, items: string[]): this;
84
86
  LRANGE(key: string, start: number, end: number): this;
85
87
  RPUSH(key: string, items: string[]): this;
86
88
  SET(key: string, value: string): this;
87
- ZADD(key: string, values: { score: string, value: string }, opts?: { NX: boolean }): this;
89
+ XCLAIM(
90
+ key: string,
91
+ group: string,
92
+ consumer: string,
93
+ minIdleTime: number,
94
+ id: string,
95
+ ...args: string[]
96
+ ): this;
97
+ XGROUP(
98
+ command: 'CREATE' | string,
99
+ key: string,
100
+ groupName: string,
101
+ id: string,
102
+ mkStream?: 'MKSTREAM',
103
+ ): this;
104
+ XPENDING(
105
+ key: string,
106
+ group: string,
107
+ start?: string,
108
+ end?: string,
109
+ count?: number,
110
+ consumer?: string,
111
+ ): this;
112
+ ZADD(
113
+ key: string,
114
+ values: { score: string; value: string },
115
+ opts?: { NX: boolean },
116
+ ): this;
88
117
  ZRANGE_WITHSCORES(key: string, start: number, end: number): this;
89
118
  ZRANK(key: string, member: string): this;
90
119
  ZSCORE(key: string, value: string): this;
@@ -101,9 +130,15 @@ interface RedisRedisClientType {
101
130
  duplicate(): RedisRedisClientType;
102
131
  on(event: string, callback: (...args: any[]) => void): void;
103
132
  publish(channel: string, message: string): Promise<number>;
104
- pSubscribe(pattern: string, callback: (channel: string, message: string) => void): void;
133
+ pSubscribe(
134
+ pattern: string,
135
+ callback: (channel: string, message: string) => void,
136
+ ): void;
105
137
  pUnsubscribe(pattern: string): void;
106
- subscribe(channel: string, callback: (channel: string, message: string) => void): void;
138
+ subscribe(
139
+ channel: string,
140
+ callback: (channel: string, message: string) => void,
141
+ ): void;
107
142
  unsubscribe(channel: string): void;
108
143
  punsubscribe(channel: string): void;
109
144
  get(key: string): Promise<string | null>;
@@ -125,8 +160,16 @@ interface RedisRedisClientType {
125
160
  LRANGE(key: string, start: number, end: number): Promise<string[]>;
126
161
  RPUSH(key: string, items: string[]): Promise<number>;
127
162
  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 }>;
163
+ ZADD(
164
+ key: string,
165
+ values: { score: string; value: string },
166
+ opts?: { NX: boolean },
167
+ ): Promise<number>;
168
+ ZRANGE_WITHSCORES(
169
+ key: string,
170
+ start: number,
171
+ end: number,
172
+ ): Promise<{ score: number; value: string }>;
130
173
  ZRANK(key: string, member: string): Promise<number>;
131
174
  ZSCORE(key: string, value: string): Promise<number>;
132
175
  }
@@ -165,9 +208,15 @@ interface IORedisClient {
165
208
  flushdb(): Promise<string>;
166
209
 
167
210
  publish(channel: string, message: string): Promise<number>;
168
- psubscribe(pattern: string, callback: (channel: string, message: string) => void): Promise<void>;
211
+ psubscribe(
212
+ pattern: string,
213
+ callback: (channel: string, message: string) => void,
214
+ ): Promise<void>;
169
215
  punsubscribe(pattern: string): void;
170
- subscribe(channel: string, callback: (channel: string, message: string) => void): void;
216
+ subscribe(
217
+ channel: string,
218
+ callback: (channel: string, message: string) => void,
219
+ ): void;
171
220
  unsubscribe(channel: string): void;
172
221
  punsubscribe(channel: string): void;
173
222
 
@@ -181,8 +230,12 @@ interface IORedisClient {
181
230
  start?: string,
182
231
  end?: string,
183
232
  count?: number,
184
- consumer?: string
185
- ): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
233
+ consumer?: string,
234
+ ): Promise<
235
+ | [string, string, number, [string, number][]][]
236
+ | [string, string, number, number]
237
+ | unknown[]
238
+ >;
186
239
  xclaim(
187
240
  key: string,
188
241
  group: string,
@@ -194,7 +247,7 @@ interface IORedisClient {
194
247
  xinfo(command: 'GROUPS' | string, key: string): Promise<unknown>;
195
248
  xrange(key: string, start: string, end: string): Promise<string[][]>;
196
249
  del(key: string): Promise<number>;
197
- exists(key: string): Promise<number>
250
+ exists(key: string): Promise<number>;
198
251
  get(key: string): Promise<string | null>;
199
252
  hdel(key: string, itemId: string): Promise<number>;
200
253
  hget(key: string, itemId: string): Promise<string | null>;
@@ -208,19 +261,40 @@ interface IORedisClient {
208
261
  rpush(key: string, ...args: string[]): Promise<number>;
209
262
  set(key: string, value: string): Promise<string>;
210
263
  zadd(...args: Array<string | number>): Promise<number>;
211
- zrange(key: string, start: number, end: number, withScores?: 'WITHSCORES'): Promise<string[]>;
264
+ zrange(
265
+ key: string,
266
+ start: number,
267
+ end: number,
268
+ withScores?: 'WITHSCORES',
269
+ ): Promise<string[]>;
212
270
  zrank(key: string, member: string): Promise<number>;
213
271
  zscore(key: string, value: string): Promise<number>;
214
- xgroup(command: 'CREATE' | string, key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<string>;
272
+ xgroup(
273
+ command: 'CREATE' | string,
274
+ key: string,
275
+ groupName: string,
276
+ id: string,
277
+ mkStream?: 'MKSTREAM',
278
+ ): Promise<string>;
215
279
  }
216
280
 
217
- type IORedisClassType = new (options: IORedisClientOptions, ...args: any[]) => IORedisClient;
281
+ type IORedisClassType = new (
282
+ options: IORedisClientOptions,
283
+ ...args: any[]
284
+ ) => IORedisClient;
218
285
  interface IORedisMultiType {
219
286
  xadd(key: string, id: string, fields: any, message?: string): this;
220
287
  xack(key: string, group: string, id: string): this;
221
288
  xdel(key: string, id: string): this;
222
289
  xlen(key: string): this;
223
- xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): this;
290
+ xpending(
291
+ key: string,
292
+ group: string,
293
+ start?: string,
294
+ end?: string,
295
+ count?: number,
296
+ consumer?: string,
297
+ ): this;
224
298
  xclaim(
225
299
  key: string,
226
300
  group: string,
@@ -238,7 +312,13 @@ interface IORedisMultiType {
238
312
  lrange(key: string, start: number, end: number): this;
239
313
  rpush(key: string, value: string): this;
240
314
  zadd(...args: Array<string | number>): this;
241
- xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): this;
315
+ xgroup(
316
+ command: 'CREATE',
317
+ key: string,
318
+ groupName: string,
319
+ id: string,
320
+ mkStream?: 'MKSTREAM',
321
+ ): this;
242
322
 
243
323
  sendCommand(command: string[]): Promise<any>;
244
324
  exec: () => Promise<unknown[]>;
@@ -8,19 +8,21 @@ export interface JSONSchema {
8
8
  'x-train'?: boolean; //extension property to mark item `values` as not being trainable (ssn, dob, guids are examples of fields that should never have their `values` trained)
9
9
  }
10
10
 
11
- export type SymbolRanges = { //keyname is <ns>:<app>:symbols:
11
+ export type SymbolRanges = {
12
+ //keyname is <ns>:<app>:symbols:
12
13
  [key: string]: number; //eg: {"$": 0, "a1": 26, "a2" 39, "$metadata_cursor": 39, "$data_cursor": 2704} (job ($) holds range 0-26; every other activity has a number that increments by 13; up to 200+ unique activities may be modeled; the :cursor fields are used by the sytem to track the next reserved tranche using hincrby
13
- }
14
+ };
14
15
 
15
- export type Symbols = { //keyname is <ns>:<app>:symbols:<aid> (where aid can be $ for job or a1, a2, etc. for activities)
16
+ export type Symbols = {
17
+ //keyname is <ns>:<app>:symbols:<aid> (where aid can be $ for job or a1, a2, etc. for activities)
16
18
  [key: string]: string; //eg: {"operation/name": "26", "a2" 39, ":cursor": 39} (job holds range 0-26; every other activity has a number that increments by 13; up to 200 activity ranges may be listed; one field called $count is used by the sytem to track the next reserved tranche using hincrby; job always seeds with 26
17
- }
19
+ };
18
20
 
19
21
  export type SymbolSets = {
20
22
  [key: string]: {
21
23
  [key: string]: string;
22
- }
23
- }
24
+ };
25
+ };
24
26
 
25
27
  export type StringStringType = {
26
28
  [key: string]: string;
package/types/stats.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  type MetricTypes = 'count' | 'sum' | 'avg' | 'mdn' | 'max' | 'min' | 'index';
2
2
 
3
3
  interface StatType {
4
- target: string; //e.g, (a target on the input data: `<activity>.input.data`) => {`object/type:widgetA|widgetB:sum`: <sum>}, {`object/type:widgetA|widgetB:count`: <count>}
5
- metric: MetricTypes; //count, avg, etc
6
- value: number|string; //a value to increment (sum); value to save to sorted set (mdn) or an id to add to an `index` or just '1' for a count
4
+ target: string; //e.g, (a target on the input data: `<activity>.input.data`) => {`object/type:widgetA|widgetB:sum`: <sum>}, {`object/type:widgetA|widgetB:count`: <count>}
5
+ metric: MetricTypes; //count, avg, etc
6
+ value: number | string; //a value to increment (sum); value to save to sorted set (mdn) or an id to add to an `index` or just '1' for a count
7
7
  }
8
8
 
9
9
  interface Measure {
@@ -30,7 +30,7 @@ interface JobStats {
30
30
  }
31
31
 
32
32
  interface JobStatsRange {
33
- [key: string]: JobStats
33
+ [key: string]: JobStats;
34
34
  }
35
35
 
36
36
  interface JobStatsInput {
@@ -82,7 +82,6 @@ interface TimeSegment {
82
82
  measures: MeasureIds[];
83
83
  }
84
84
 
85
-
86
85
  interface CountByFacet {
87
86
  facet: string;
88
87
  count: number;
@@ -98,4 +97,21 @@ interface IdsResponse {
98
97
  segments: TimeSegment[];
99
98
  }
100
99
 
101
- export { StatsType, StatType, MetricTypes, JobStats, JobStatsRange, JobStatsInput, GetStatsOptions, StatsResponse, AggregatedData, Measure, Segment, IdsData, MeasureIds, TimeSegment, IdsResponse, CountByFacet };
100
+ export {
101
+ StatsType,
102
+ StatType,
103
+ MetricTypes,
104
+ JobStats,
105
+ JobStatsRange,
106
+ JobStatsInput,
107
+ GetStatsOptions,
108
+ StatsResponse,
109
+ AggregatedData,
110
+ Measure,
111
+ Segment,
112
+ IdsData,
113
+ MeasureIds,
114
+ TimeSegment,
115
+ IdsResponse,
116
+ CountByFacet,
117
+ };
package/types/stream.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Represents a policy for retrying stream operations based on error codes */
2
2
  export interface StreamRetryPolicy {
3
- /**
3
+ /**
4
4
  * Key is error code, value is the retry profile.
5
5
  * Tuple contains: [max retry count, retry type].
6
6
  * 'x' denotes exponential backoff (default). Only 10, 100, 1000, 10000 are allowed retry intervals.
@@ -27,7 +27,7 @@ export type StreamError = {
27
27
  error?: Record<string, unknown>;
28
28
  /** True if originating via a standard transition message with an `error` status */
29
29
  is_stream_error?: boolean;
30
- }
30
+ };
31
31
 
32
32
  /** Enumerated status values for stream operations */
33
33
  export enum StreamStatus {
@@ -73,7 +73,7 @@ export interface StreamData {
73
73
  spn?: string;
74
74
  /** Current try count, used for retry logic */
75
75
  try?: number;
76
- /**
76
+ /**
77
77
  * Indicates if the message should wait for a response.
78
78
  * If explicitly false, the connection is severed immediately
79
79
  * upon verifying (and returning) the Job ID.
@@ -97,15 +97,15 @@ export interface StreamData {
97
97
  }
98
98
 
99
99
  /** Extends StreamData for responses, allowing for inheritance of the base properties */
100
- export interface StreamDataResponse extends StreamData {}
100
+ export type StreamDataResponse = StreamData;
101
101
 
102
102
  export enum StreamRole {
103
103
  WORKER = 'worker',
104
104
  ENGINE = 'engine',
105
105
  SYSTEM = 'system', //reserved for system use (i.e, if worker or engine fails)
106
106
  }
107
- /**
108
- * Represents a type for messages that have been reclaimed from a stream.
107
+ /**
108
+ * Represents a type for messages that have been reclaimed from a stream.
109
109
  * Each item is a tuple containing a messageId and its details.
110
110
  */
111
111
  export type ReclaimedMessageType = [
@@ -116,8 +116,8 @@ export type ReclaimedMessageType = [
116
116
  /** Key is always 'message' */
117
117
  key: string,
118
118
  /** Value is a stringified representation of StreamData */
119
- value: string
120
- ]
119
+ value: string,
120
+ ],
121
121
  ][];
122
122
 
123
123
  /** Configuration parameters for a stream */
@@ -136,4 +136,4 @@ export type StreamConfig = {
136
136
  reclaimDelay?: number;
137
137
  /** Maximum number of reclaims allowed, defaults to 3. Values greater throw an error */
138
138
  reclaimCount?: number;
139
- }
139
+ };
package/types/task.ts CHANGED
@@ -1 +1,7 @@
1
- export type WorkListTaskType = 'sleep' | 'expire' | 'expire-child' | 'interrupt' | 'delist' | 'child';
1
+ export type WorkListTaskType =
2
+ | 'sleep'
3
+ | 'expire'
4
+ | 'expire-child'
5
+ | 'interrupt'
6
+ | 'delist'
7
+ | 'child';
@@ -12,4 +12,5 @@ export {
12
12
  SpanKind,
13
13
  trace,
14
14
  Tracer,
15
- ValueType } from '@opentelemetry/api';
15
+ ValueType,
16
+ } from '@opentelemetry/api';
@@ -1,20 +1,20 @@
1
- import { Pipe } from "./pipe";
1
+ import { Pipe } from './pipe';
2
2
 
3
3
  //TransitionMatch type: { expected: false, actual: '{a2.output.data.approved}' }
4
4
  export type TransitionMatch = {
5
5
  expected: boolean | string | number | null;
6
6
  actual: boolean | string | number | null | { '@pipe': Pipe };
7
- }
7
+ };
8
8
 
9
9
  export type TransitionRule = {
10
- gate?: 'and'|'or'; //`and` is default
10
+ gate?: 'and' | 'or'; //`and` is default
11
11
  code?: string; //200 is default; must be an eplicit 3-digit code and must have an associated output schema matching this value to compile
12
12
  match: Array<TransitionMatch>;
13
- }
13
+ };
14
14
 
15
15
  //this is format for how all transitions for a single app are returned from the datastore
16
- export type Transitions = {
16
+ export type Transitions = {
17
17
  [key: string]: {
18
- [key: string]: TransitionRule
19
- }
20
- }
18
+ [key: string]: TransitionRule;
19
+ };
20
+ };