@hotmeshio/hotmesh 0.0.60 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/build/modules/enums.d.ts +1 -1
  3. package/build/modules/enums.js +10 -2
  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 +5 -5
  9. package/build/modules/utils.js +20 -16
  10. package/build/package.json +41 -38
  11. package/build/services/activities/activity.js +37 -20
  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.js +3 -3
  61. package/build/services/store/clients/redis.js +24 -4
  62. package/build/services/store/index.d.ts +9 -3
  63. package/build/services/store/index.js +122 -60
  64. package/build/services/stream/clients/ioredis.js +4 -4
  65. package/build/services/stream/clients/redis.js +31 -4
  66. package/build/services/task/index.js +8 -11
  67. package/build/services/telemetry/index.js +21 -14
  68. package/build/services/worker/index.d.ts +6 -6
  69. package/build/services/worker/index.js +12 -7
  70. package/build/types/activity.d.ts +3 -3
  71. package/build/types/exporter.d.ts +2 -2
  72. package/build/types/exporter.js +0 -6
  73. package/build/types/hook.d.ts +1 -1
  74. package/build/types/hotmesh.js +0 -1
  75. package/build/types/index.d.ts +12 -12
  76. package/build/types/job.d.ts +1 -1
  77. package/build/types/logger.js +0 -1
  78. package/build/types/quorum.d.ts +1 -1
  79. package/build/types/stats.d.ts +1 -1
  80. package/build/types/stream.d.ts +1 -2
  81. package/build/types/telemetry.d.ts +1 -1
  82. package/build/types/transition.d.ts +1 -1
  83. package/package.json +41 -38
  84. package/types/activity.ts +56 -39
  85. package/types/async.ts +2 -3
  86. package/types/collator.ts +5 -5
  87. package/types/durable.ts +161 -161
  88. package/types/error.ts +37 -37
  89. package/types/exporter.ts +14 -9
  90. package/types/hook.ts +11 -4
  91. package/types/hotmesh.ts +26 -25
  92. package/types/index.ts +53 -53
  93. package/types/job.ts +33 -33
  94. package/types/logger.ts +1 -1
  95. package/types/map.ts +1 -1
  96. package/types/pipe.ts +10 -8
  97. package/types/quorum.ts +20 -13
  98. package/types/redis.ts +70 -15
  99. package/types/serializer.ts +8 -6
  100. package/types/stats.ts +22 -6
  101. package/types/stream.ts +9 -9
  102. package/types/task.ts +7 -1
  103. package/types/telemetry.ts +2 -1
  104. package/types/transition.ts +8 -8
package/types/redis.ts CHANGED
@@ -84,7 +84,11 @@ interface RedisRedisMultiType {
84
84
  LRANGE(key: string, start: number, end: number): this;
85
85
  RPUSH(key: string, items: string[]): this;
86
86
  SET(key: string, value: string): this;
87
- ZADD(key: string, values: { score: string, value: string }, opts?: { NX: boolean }): this;
87
+ ZADD(
88
+ key: string,
89
+ values: { score: string; value: string },
90
+ opts?: { NX: boolean },
91
+ ): this;
88
92
  ZRANGE_WITHSCORES(key: string, start: number, end: number): this;
89
93
  ZRANK(key: string, member: string): this;
90
94
  ZSCORE(key: string, value: string): this;
@@ -101,9 +105,15 @@ interface RedisRedisClientType {
101
105
  duplicate(): RedisRedisClientType;
102
106
  on(event: string, callback: (...args: any[]) => void): void;
103
107
  publish(channel: string, message: string): Promise<number>;
104
- pSubscribe(pattern: string, callback: (channel: string, message: string) => void): void;
108
+ pSubscribe(
109
+ pattern: string,
110
+ callback: (channel: string, message: string) => void,
111
+ ): void;
105
112
  pUnsubscribe(pattern: string): void;
106
- subscribe(channel: string, callback: (channel: string, message: string) => void): void;
113
+ subscribe(
114
+ channel: string,
115
+ callback: (channel: string, message: string) => void,
116
+ ): void;
107
117
  unsubscribe(channel: string): void;
108
118
  punsubscribe(channel: string): void;
109
119
  get(key: string): Promise<string | null>;
@@ -125,8 +135,16 @@ interface RedisRedisClientType {
125
135
  LRANGE(key: string, start: number, end: number): Promise<string[]>;
126
136
  RPUSH(key: string, items: string[]): Promise<number>;
127
137
  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 }>;
138
+ ZADD(
139
+ key: string,
140
+ values: { score: string; value: string },
141
+ opts?: { NX: boolean },
142
+ ): Promise<number>;
143
+ ZRANGE_WITHSCORES(
144
+ key: string,
145
+ start: number,
146
+ end: number,
147
+ ): Promise<{ score: number; value: string }>;
130
148
  ZRANK(key: string, member: string): Promise<number>;
131
149
  ZSCORE(key: string, value: string): Promise<number>;
132
150
  }
@@ -165,9 +183,15 @@ interface IORedisClient {
165
183
  flushdb(): Promise<string>;
166
184
 
167
185
  publish(channel: string, message: string): Promise<number>;
168
- psubscribe(pattern: string, callback: (channel: string, message: string) => void): Promise<void>;
186
+ psubscribe(
187
+ pattern: string,
188
+ callback: (channel: string, message: string) => void,
189
+ ): Promise<void>;
169
190
  punsubscribe(pattern: string): void;
170
- subscribe(channel: string, callback: (channel: string, message: string) => void): void;
191
+ subscribe(
192
+ channel: string,
193
+ callback: (channel: string, message: string) => void,
194
+ ): void;
171
195
  unsubscribe(channel: string): void;
172
196
  punsubscribe(channel: string): void;
173
197
 
@@ -181,8 +205,12 @@ interface IORedisClient {
181
205
  start?: string,
182
206
  end?: string,
183
207
  count?: number,
184
- consumer?: string
185
- ): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
208
+ consumer?: string,
209
+ ): Promise<
210
+ | [string, string, number, [string, number][]][]
211
+ | [string, string, number, number]
212
+ | unknown[]
213
+ >;
186
214
  xclaim(
187
215
  key: string,
188
216
  group: string,
@@ -194,7 +222,7 @@ interface IORedisClient {
194
222
  xinfo(command: 'GROUPS' | string, key: string): Promise<unknown>;
195
223
  xrange(key: string, start: string, end: string): Promise<string[][]>;
196
224
  del(key: string): Promise<number>;
197
- exists(key: string): Promise<number>
225
+ exists(key: string): Promise<number>;
198
226
  get(key: string): Promise<string | null>;
199
227
  hdel(key: string, itemId: string): Promise<number>;
200
228
  hget(key: string, itemId: string): Promise<string | null>;
@@ -208,19 +236,40 @@ interface IORedisClient {
208
236
  rpush(key: string, ...args: string[]): Promise<number>;
209
237
  set(key: string, value: string): Promise<string>;
210
238
  zadd(...args: Array<string | number>): Promise<number>;
211
- zrange(key: string, start: number, end: number, withScores?: 'WITHSCORES'): Promise<string[]>;
239
+ zrange(
240
+ key: string,
241
+ start: number,
242
+ end: number,
243
+ withScores?: 'WITHSCORES',
244
+ ): Promise<string[]>;
212
245
  zrank(key: string, member: string): Promise<number>;
213
246
  zscore(key: string, value: string): Promise<number>;
214
- xgroup(command: 'CREATE' | string, key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<string>;
247
+ xgroup(
248
+ command: 'CREATE' | string,
249
+ key: string,
250
+ groupName: string,
251
+ id: string,
252
+ mkStream?: 'MKSTREAM',
253
+ ): Promise<string>;
215
254
  }
216
255
 
217
- type IORedisClassType = new (options: IORedisClientOptions, ...args: any[]) => IORedisClient;
256
+ type IORedisClassType = new (
257
+ options: IORedisClientOptions,
258
+ ...args: any[]
259
+ ) => IORedisClient;
218
260
  interface IORedisMultiType {
219
261
  xadd(key: string, id: string, fields: any, message?: string): this;
220
262
  xack(key: string, group: string, id: string): this;
221
263
  xdel(key: string, id: string): this;
222
264
  xlen(key: string): this;
223
- xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): this;
265
+ xpending(
266
+ key: string,
267
+ group: string,
268
+ start?: string,
269
+ end?: string,
270
+ count?: number,
271
+ consumer?: string,
272
+ ): this;
224
273
  xclaim(
225
274
  key: string,
226
275
  group: string,
@@ -238,7 +287,13 @@ interface IORedisMultiType {
238
287
  lrange(key: string, start: number, end: number): this;
239
288
  rpush(key: string, value: string): this;
240
289
  zadd(...args: Array<string | number>): this;
241
- xgroup(command: 'CREATE', key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): this;
290
+ xgroup(
291
+ command: 'CREATE',
292
+ key: string,
293
+ groupName: string,
294
+ id: string,
295
+ mkStream?: 'MKSTREAM',
296
+ ): this;
242
297
 
243
298
  sendCommand(command: string[]): Promise<any>;
244
299
  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
+ };