@hotmeshio/hotmesh 0.3.8 → 0.3.9

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 (154) hide show
  1. package/README.md +2 -17
  2. package/build/index.d.ts +4 -2
  3. package/build/index.js +6 -3
  4. package/build/modules/key.js +1 -1
  5. package/build/modules/utils.d.ts +12 -4
  6. package/build/modules/utils.js +1 -1
  7. package/build/package.json +14 -7
  8. package/build/services/activities/activity.d.ts +9 -9
  9. package/build/services/activities/activity.js +1 -1
  10. package/build/services/activities/await.d.ts +2 -2
  11. package/build/services/activities/await.js +1 -1
  12. package/build/services/activities/cycle.d.ts +2 -2
  13. package/build/services/activities/cycle.js +1 -1
  14. package/build/services/activities/hook.d.ts +2 -2
  15. package/build/services/activities/hook.js +1 -1
  16. package/build/services/activities/index.js +1 -1
  17. package/build/services/activities/interrupt.js +1 -1
  18. package/build/services/activities/signal.js +1 -1
  19. package/build/services/activities/trigger.d.ts +3 -3
  20. package/build/services/activities/trigger.js +1 -1
  21. package/build/services/activities/worker.d.ts +2 -2
  22. package/build/services/activities/worker.js +1 -1
  23. package/build/services/collator/index.d.ts +9 -9
  24. package/build/services/collator/index.js +1 -1
  25. package/build/services/compiler/deployer.d.ts +4 -4
  26. package/build/services/compiler/deployer.js +1 -1
  27. package/build/services/compiler/index.d.ts +4 -4
  28. package/build/services/compiler/index.js +1 -1
  29. package/build/services/compiler/validator.d.ts +3 -3
  30. package/build/services/compiler/validator.js +1 -1
  31. package/build/services/connector/factory.d.ts +6 -0
  32. package/build/services/connector/factory.js +56 -0
  33. package/build/services/connector/index.d.ts +13 -4
  34. package/build/services/connector/index.js +30 -23
  35. package/build/services/connector/providers/ioredis.d.ts +9 -0
  36. package/build/services/connector/providers/ioredis.js +26 -0
  37. package/build/services/connector/providers/nats.d.ts +9 -0
  38. package/build/services/connector/providers/nats.js +26 -0
  39. package/build/services/connector/providers/postgres.d.ts +9 -0
  40. package/build/services/connector/providers/postgres.js +39 -0
  41. package/build/services/connector/providers/redis.d.ts +9 -0
  42. package/build/services/connector/providers/redis.js +38 -0
  43. package/build/services/engine/index.d.ts +12 -12
  44. package/build/services/engine/index.js +1 -1
  45. package/build/services/exporter/index.d.ts +3 -3
  46. package/build/services/exporter/index.js +1 -1
  47. package/build/services/hotmesh/index.js +4 -4
  48. package/build/services/mapper/index.js +1 -1
  49. package/build/services/meshcall/index.d.ts +5 -4
  50. package/build/services/meshcall/index.js +31 -14
  51. package/build/services/meshdata/index.d.ts +6 -6
  52. package/build/services/meshdata/index.js +7 -15
  53. package/build/services/meshflow/connection.d.ts +3 -2
  54. package/build/services/meshflow/exporter.d.ts +3 -3
  55. package/build/services/meshflow/exporter.js +1 -1
  56. package/build/services/meshflow/search.js +12 -4
  57. package/build/services/meshflow/worker.js +7 -7
  58. package/build/services/meshos/index.d.ts +1 -4
  59. package/build/services/meshos/index.js +11 -44
  60. package/build/services/pipe/functions/array.js +1 -1
  61. package/build/services/pipe/functions/bitwise.js +1 -1
  62. package/build/services/pipe/functions/conditional.js +1 -1
  63. package/build/services/pipe/functions/cron.d.ts +2 -0
  64. package/build/services/pipe/functions/cron.js +1 -1
  65. package/build/services/pipe/functions/date.js +1 -1
  66. package/build/services/pipe/functions/index.js +1 -1
  67. package/build/services/pipe/functions/json.js +1 -1
  68. package/build/services/pipe/functions/logical.js +1 -1
  69. package/build/services/pipe/functions/math.js +1 -1
  70. package/build/services/pipe/functions/number.js +1 -1
  71. package/build/services/pipe/functions/object.js +1 -1
  72. package/build/services/pipe/functions/string.js +1 -1
  73. package/build/services/pipe/functions/symbol.js +1 -1
  74. package/build/services/pipe/functions/unary.js +1 -1
  75. package/build/services/pipe/index.js +1 -1
  76. package/build/services/quorum/index.d.ts +5 -5
  77. package/build/services/quorum/index.js +1 -1
  78. package/build/services/reporter/index.d.ts +2 -2
  79. package/build/services/reporter/index.js +1 -1
  80. package/build/services/router/index.d.ts +8 -13
  81. package/build/services/router/index.js +1 -1
  82. package/build/services/search/factory.d.ts +2 -2
  83. package/build/services/search/factory.js +1 -1
  84. package/build/services/search/index.d.ts +5 -4
  85. package/build/services/search/providers/redis/ioredis.js +1 -1
  86. package/build/services/search/providers/redis/redis.js +1 -1
  87. package/build/services/serializer/index.js +1 -1
  88. package/build/services/store/factory.d.ts +3 -3
  89. package/build/services/store/factory.js +1 -1
  90. package/build/services/store/index.d.ts +18 -17
  91. package/build/services/store/providers/redis/_base.d.ts +13 -15
  92. package/build/services/store/providers/redis/_base.js +1 -1
  93. package/build/services/store/providers/redis/ioredis.d.ts +2 -2
  94. package/build/services/store/providers/redis/ioredis.js +1 -1
  95. package/build/services/store/providers/redis/redis.d.ts +2 -2
  96. package/build/services/store/providers/redis/redis.js +1 -1
  97. package/build/services/store/providers/store-initializable.js +1 -1
  98. package/build/services/stream/factory.d.ts +3 -3
  99. package/build/services/stream/factory.js +16 -4
  100. package/build/services/stream/index.d.ts +57 -18
  101. package/build/services/stream/index.js +2 -1
  102. package/build/services/stream/providers/nats/nats.d.ts +59 -0
  103. package/build/services/stream/providers/nats/nats.js +1 -0
  104. package/build/services/stream/providers/postgres/_deploy.d.ts +2 -1
  105. package/build/services/stream/providers/postgres/_deploy.js +1 -1
  106. package/build/services/stream/providers/postgres/postgres.d.ts +0 -0
  107. package/build/services/stream/providers/postgres/postgres.js +0 -0
  108. package/build/services/stream/providers/redis/ioredis.d.ts +53 -14
  109. package/build/services/stream/providers/redis/ioredis.js +1 -1
  110. package/build/services/stream/providers/redis/redis.d.ts +54 -15
  111. package/build/services/stream/providers/redis/redis.js +1 -1
  112. package/build/services/stream/providers/stream-initializable.d.ts +1 -2
  113. package/build/services/stream/providers/stream-initializable.js +1 -1
  114. package/build/services/sub/factory.d.ts +2 -2
  115. package/build/services/sub/factory.js +1 -1
  116. package/build/services/sub/index.d.ts +6 -5
  117. package/build/services/sub/providers/redis/ioredis.d.ts +1 -1
  118. package/build/services/sub/providers/redis/ioredis.js +1 -1
  119. package/build/services/sub/providers/redis/redis.d.ts +4 -4
  120. package/build/services/sub/providers/redis/redis.js +1 -1
  121. package/build/services/task/index.d.ts +5 -5
  122. package/build/services/task/index.js +1 -1
  123. package/build/services/telemetry/index.js +1 -1
  124. package/build/services/worker/index.d.ts +9 -9
  125. package/build/services/worker/index.js +1 -1
  126. package/build/types/hotmesh.d.ts +26 -14
  127. package/build/types/index.d.ts +6 -5
  128. package/build/types/manifest.d.ts +1 -9
  129. package/build/types/meshcall.d.ts +12 -7
  130. package/build/types/meshflow.d.ts +3 -7
  131. package/build/types/nats.d.ts +150 -0
  132. package/build/types/nats.js +2 -0
  133. package/build/types/postgres.d.ts +48 -0
  134. package/build/types/postgres.js +2 -0
  135. package/build/types/provider.d.ts +26 -0
  136. package/build/types/provider.js +2 -0
  137. package/build/types/redis.d.ts +33 -15
  138. package/build/types/stream.d.ts +65 -1
  139. package/index.ts +8 -5
  140. package/package.json +14 -7
  141. package/types/hotmesh.ts +139 -22
  142. package/types/index.ts +26 -17
  143. package/types/manifest.ts +1 -10
  144. package/types/meshcall.ts +38 -13
  145. package/types/meshflow.ts +2 -7
  146. package/types/nats.ts +231 -0
  147. package/types/postgres.ts +54 -0
  148. package/types/provider.ts +71 -0
  149. package/types/redis.ts +63 -18
  150. package/types/stream.ts +85 -1
  151. package/build/services/connector/clients/ioredis.d.ts +0 -13
  152. package/build/services/connector/clients/ioredis.js +0 -48
  153. package/build/services/connector/clients/redis.d.ts +0 -13
  154. package/build/services/connector/clients/redis.js +0 -60
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
+ import { ProviderClient, ProviderConfig, ProviderTransaction } from './provider';
2
3
  import { StringStringType } from './serializer';
3
4
  import { ReclaimedMessageType } from './stream';
4
- type MultiResponseFlags = (string | number)[];
5
5
  interface ConnectionOptions {
6
6
  host?: string;
7
7
  port?: number;
@@ -56,13 +56,9 @@ interface RedisRedisClientOptions {
56
56
  };
57
57
  stringNumbers?: boolean;
58
58
  }
59
- interface RedisRedisMultiType {
59
+ interface RedisRedisMultiType extends ProviderTransaction {
60
60
  sendCommand(command: string, ...args: string[]): Promise<any>;
61
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
62
  DEL(key: string): this;
67
63
  EXISTS(key: string): this;
68
64
  EXPIRE(key: string, seconds: number): this;
@@ -78,7 +74,13 @@ interface RedisRedisMultiType {
78
74
  LRANGE(key: string, start: number, end: number): this;
79
75
  RPUSH(key: string, items: string[]): this;
80
76
  SET(key: string, value: string): this;
77
+ XADD(key: string, id: string, fields: any): this;
78
+ XACK(key: string, group: string, id: string): this;
79
+ XACK(key: string, group: string, ...ids: string[]): this;
80
+ XDEL(key: string, id: string): this;
81
+ XDEL(key: string, ...ids: string[]): this;
81
82
  XCLAIM(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): this;
83
+ XLEN(key: string): this;
82
84
  XGROUP(command: 'CREATE' | string, key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): this;
83
85
  XPENDING(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): this;
84
86
  ZADD(key: string, values: {
@@ -91,7 +93,7 @@ interface RedisRedisMultiType {
91
93
  ZRANK(key: string, member: string): this;
92
94
  ZSCORE(key: string, value: string): this;
93
95
  }
94
- interface RedisRedisClientType {
96
+ interface RedisRedisClientType extends ProviderClient {
95
97
  multi(): Partial<RedisRedisMultiType>;
96
98
  connect(): Promise<void>;
97
99
  sendCommand(args: any[]): Promise<any>;
@@ -109,10 +111,6 @@ interface RedisRedisClientType {
109
111
  punsubscribe(channel: string): void;
110
112
  get(key: string): Promise<string | null>;
111
113
  set(key: string, value: string): Promise<string>;
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
114
  DEL(key: string): Promise<number>;
117
115
  EXISTS(key: string): Promise<number>;
118
116
  HDEL(key: string, fields: string[] | string): Promise<number>;
@@ -125,6 +123,17 @@ interface RedisRedisClientType {
125
123
  LRANGE(key: string, start: number, end: number): Promise<string[]>;
126
124
  RPUSH(key: string, items: string[]): Promise<number>;
127
125
  SET(key: string, value: string): Promise<string>;
126
+ XADD(key: string, id: string, fields: any): Promise<string>;
127
+ XACK(key: string, group: string, ...ids: string[]): Promise<number>;
128
+ XACK(key: string, group: string, id: string): Promise<number>;
129
+ XCLAIM(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
130
+ XDEL(key: string, id: string): Promise<number>;
131
+ XDEL(key: string, ...ids: string[]): Promise<number>;
132
+ xGroupDestroy(key: string, groupName: string): Promise<boolean>;
133
+ XINFO(command: 'GROUPS' | string, key: string): Promise<unknown>;
134
+ XINFO_GROUPS(key: string): Promise<unknown>;
135
+ XLEN(key: string): Promise<number>;
136
+ XPENDING(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): this;
128
137
  ZADD(key: string, values: {
129
138
  score: string;
130
139
  value: string;
@@ -161,7 +170,7 @@ interface IORedisClientOptions {
161
170
  keyPrefix?: string;
162
171
  reconnectOnError?: (err: Error) => boolean;
163
172
  }
164
- interface IORedisClient {
173
+ interface IORedisClient extends ProviderClient {
165
174
  multi(): IORedisMultiType;
166
175
  exec(): Promise<unknown[]>;
167
176
  sendCommand(args: any[]): Promise<any>;
@@ -176,12 +185,15 @@ interface IORedisClient {
176
185
  punsubscribe(channel: string): void;
177
186
  xadd(key: string, id: string, fields: any, message?: string): Promise<string>;
178
187
  xack(key: string, group: string, id: string): Promise<number>;
188
+ xack(key: string, group: string, ...ids: string[]): Promise<number>;
179
189
  xdel(key: string, id: string): Promise<number>;
190
+ xdel(key: string, ...ids: string[]): Promise<number>;
180
191
  xlen(key: string): Promise<number>;
181
192
  xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): Promise<[string, string, number, [string, number][]][] | [string, string, number, number] | unknown[]>;
182
193
  xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): Promise<ReclaimedMessageType>;
183
194
  xinfo(command: 'GROUPS' | string, key: string): Promise<unknown>;
184
195
  xrange(key: string, start: string, end: string): Promise<string[][]>;
196
+ xreadgroup(command: 'GROUP', groupName: string, consumerName: string, blockOption: string, blockTime: number, streamsOption: string, streamName: string, key: string): Promise<string[][]>;
185
197
  del(key: string): Promise<number>;
186
198
  exists(key: string): Promise<number>;
187
199
  get(key: string): Promise<string | null>;
@@ -200,13 +212,15 @@ interface IORedisClient {
200
212
  zrange(key: string, start: number, end: number, withScores?: 'WITHSCORES'): Promise<string[]>;
201
213
  zrank(key: string, member: string): Promise<number>;
202
214
  zscore(key: string, value: string): Promise<number>;
203
- xgroup(command: 'CREATE' | string, key: string, groupName: string, id: string, mkStream?: 'MKSTREAM'): Promise<string>;
215
+ xgroup(command: 'CREATE' | 'DESTROY' | string, key: string, groupName: string, id?: string, mkStream?: 'MKSTREAM'): Promise<string | number>;
204
216
  }
205
217
  type IORedisClassType = new (options: IORedisClientOptions, ...args: any[]) => IORedisClient;
206
- interface IORedisMultiType {
218
+ interface IORedisMultiType extends ProviderTransaction {
207
219
  xadd(key: string, id: string, fields: any, message?: string): this;
208
220
  xack(key: string, group: string, id: string): this;
221
+ xack(key: string, group: string, ...ids: string[]): this;
209
222
  xdel(key: string, id: string): this;
223
+ xdel(key: string, ...ids: string[]): this;
210
224
  xlen(key: string): this;
211
225
  xpending(key: string, group: string, start?: string, end?: string, count?: number, consumer?: string): this;
212
226
  xclaim(key: string, group: string, consumer: string, minIdleTime: number, id: string, ...args: string[]): this;
@@ -231,4 +245,8 @@ type RedisOptions = RedisRedisClientOptions | IORedisClientOptions;
231
245
  type RedisMulti = RedisRedisMultiType | IORedisMultiType;
232
246
  declare function isRedisClient(client: RedisClient): client is RedisRedisClientType;
233
247
  declare function isIORedisClient(client: RedisClient): client is IORedisClient;
234
- export { RedisClass, RedisRedisClientType, RedisRedisClientOptions, RedisRedisClassType, IORedisClient as IORedisClientType, RedisClient, RedisMulti, RedisRedisMultiType, IORedisClientOptions, IORedisClassType, IORedisMultiType, RedisOptions, MultiResponseFlags, isRedisClient, isIORedisClient, };
248
+ interface RedisConfig extends ProviderConfig {
249
+ class: Partial<RedisClass>;
250
+ options: Partial<RedisOptions>;
251
+ }
252
+ export { RedisClass, RedisConfig, RedisRedisClientType, RedisRedisClientOptions, RedisRedisClassType, IORedisClient as IORedisClientType, RedisClient, RedisMulti, RedisRedisMultiType, IORedisClientOptions, IORedisClassType, IORedisMultiType, RedisOptions, isRedisClient, isIORedisClient, };
@@ -1,3 +1,4 @@
1
+ import { ProviderTransaction } from './provider';
1
2
  export interface StreamRetryPolicy {
2
3
  [key: string]: [number, 'x'?];
3
4
  }
@@ -62,7 +63,7 @@ export type ReclaimedMessageType = [
62
63
  value: string
63
64
  ]
64
65
  ][];
65
- export type StreamConfig = {
66
+ export type RouterConfig = {
66
67
  namespace: string;
67
68
  appId: string;
68
69
  guid: string;
@@ -73,3 +74,66 @@ export type StreamConfig = {
73
74
  reclaimCount?: number;
74
75
  readonly?: boolean;
75
76
  };
77
+ export type StreamProviderType = 'redis' | 'ioredis' | 'postgres' | 'nats' | 'sqs';
78
+ export interface StreamConfig {
79
+ provider?: StreamProviderType;
80
+ namespace?: string;
81
+ appId?: string;
82
+ maxRetries?: number;
83
+ batchSize?: number;
84
+ timeout?: number;
85
+ redis?: {
86
+ claimTimeout?: number;
87
+ blockingTimeout?: number;
88
+ minIdleTime?: number;
89
+ };
90
+ postgres?: {
91
+ pollInterval?: number;
92
+ vacuumInterval?: number;
93
+ partitionInterval?: 'daily' | 'weekly' | 'monthly';
94
+ cleanupInterval?: number;
95
+ };
96
+ nats?: {
97
+ jetstream?: boolean;
98
+ durableName?: string;
99
+ deliverPolicy?: 'all' | 'last' | 'new' | 'byStartSequence' | 'byStartTime';
100
+ ackWait?: number;
101
+ };
102
+ sqs?: {
103
+ deadLetterQueue?: string;
104
+ visibilityTimeout?: number;
105
+ waitTimeSeconds?: number;
106
+ messageRetentionPeriod?: number;
107
+ dlqArn?: string;
108
+ };
109
+ }
110
+ export interface StreamMessage {
111
+ id: string;
112
+ data: StreamData;
113
+ metadata?: StreamMessageMetadata;
114
+ }
115
+ export interface StreamMessageMetadata {
116
+ timestamp?: number;
117
+ stream?: string;
118
+ groupName?: string;
119
+ consumerName?: string;
120
+ retryCount?: number;
121
+ deliveryTime?: number;
122
+ originalMessageId?: string;
123
+ [key: string]: any;
124
+ }
125
+ export interface StreamStats {
126
+ messageCount: number;
127
+ consumerCount?: number;
128
+ bytesInMemory?: number;
129
+ oldestMessageTimestamp?: number;
130
+ pendingMessages?: number;
131
+ deadLetterQueueMessageCount?: number;
132
+ averageProcessingTime?: number;
133
+ lastErrorTimestamp?: number;
134
+ lastErrorMessage?: string;
135
+ [key: string]: any;
136
+ }
137
+ export interface PublishMessageConfig {
138
+ transaction?: ProviderTransaction;
139
+ }
package/index.ts CHANGED
@@ -2,26 +2,29 @@ import { HotMesh } from './services/hotmesh';
2
2
  import { HotMeshConfig } from './types/hotmesh';
3
3
  import { MeshCall } from './services/meshcall';
4
4
  import { MeshFlow } from './services/meshflow';
5
+ import { WorkflowHandleService as WorkflowHandle } from './services/meshflow/handle';
5
6
  import { MeshData } from './services/meshdata';
6
7
  import { MeshOS } from './services/meshos';
8
+ import * as Errors from './modules/errors';
7
9
  import * as Utils from './modules/utils';
8
10
 
9
- const { Client, Connection, Handle, Search, Worker, workflow } = MeshFlow;
11
+ const { Client, Connection, Search, Worker, workflow } = MeshFlow;
10
12
 
11
13
  export {
14
+ Client,
15
+ Connection,
16
+ Errors,
12
17
  HotMesh,
13
18
  HotMeshConfig,
14
19
  MeshCall,
15
20
  MeshData,
16
- MeshOS,
17
21
  MeshFlow,
18
- Client,
19
- Connection,
20
- Handle,
22
+ MeshOS,
21
23
  Search,
22
24
  Utils,
23
25
  Worker,
24
26
  workflow,
27
+ WorkflowHandle,
25
28
  };
26
29
 
27
30
  export * as Types from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Unbreakable Workflows",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "test:await": "NODE_ENV=test jest ./tests/functional/awaiter/index.test.ts --detectOpenHandles --forceExit --verbose",
26
26
  "test:compile": "NODE_ENV=test jest ./tests/functional/compile/index.test.ts --detectOpenHandles --forceExit --verbose",
27
27
  "test:connect": "NODE_ENV=test jest ./tests/unit/services/connector/index.test.ts --detectOpenHandles --forceExit --verbose",
28
- "test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
29
- "test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/clients/redis.test.ts --detectOpenHandles --forceExit --verbose",
28
+ "test:connect:ioredis": "NODE_ENV=test jest ./tests/unit/services/connector/providers/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
29
+ "test:connect:redis": "NODE_ENV=test jest ./tests/unit/services/connector/providers/redis.test.ts --detectOpenHandles --forceExit --verbose",
30
30
  "test:cycle": "NODE_ENV=test jest ./tests/functional/cycle/index.test.ts --detectOpenHandles --forceExit --verbose",
31
31
  "test:meshflow": "NODE_ENV=test jest ./tests/meshflow/*/index.test.ts --detectOpenHandles --forceExit --verbose",
32
32
  "test:meshflow:basic": "NODE_ENV=test jest ./tests/meshflow/basic/index.test.ts --detectOpenHandles --forceExit --verbose",
@@ -63,12 +63,14 @@
63
63
  "test:store:redis": "NODE_ENV=test jest ./tests/functional/store/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
64
64
  "test:stream:ioredis": "NODE_ENV=test jest ./tests/functional/stream/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
65
65
  "test:stream:redis": "NODE_ENV=test jest ./tests/functional/stream/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
66
+ "test:stream:postgres": "NODE_ENV=test jest ./tests/functional/stream/providers/postgres.test.ts --detectOpenHandles --forceExit --verbose",
67
+ "test:stream:nats": "NODE_ENV=test jest ./tests/functional/stream/providers/nats/nats.test.ts --detectOpenHandles --forceExit --verbose",
66
68
  "test:sub:ioredis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/ioredis.test.ts --detectOpenHandles --forceExit --verbose",
67
69
  "test:sub:redis": "NODE_ENV=test jest ./tests/functional/sub/providers/redis/redis.test.ts --detectOpenHandles --forceExit --verbose",
68
70
  "test:trigger": "NODE_ENV=test jest ./tests/unit/services/activities/trigger.test.ts --detectOpenHandles --forceExit --verbose",
69
- "test:meshdata": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshdata/index.test.ts --forceExit --verbose --detectOpenHandles",
71
+ "test:meshdata": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshdata/index.test.ts --forceExit --verbose",
70
72
  "test:meshos": "NODE_ENV=test HMSH_IS_CLUSTER=true jest ./tests/meshos/index.test.ts --forceExit --verbose --detectOpenHandles",
71
- "test:meshcall": "NODE_ENV=test HMSH_LOGLEVEL=debug jest ./tests/meshcall/index.test.ts --forceExit --verbose --detectOpenHandles",
73
+ "test:meshcall": "NODE_ENV=test jest ./tests/meshcall/index.test.ts --forceExit --verbose --detectOpenHandles",
72
74
  "test:unit": "NODE_ENV=test jest ./tests/unit/*/*/index.test.ts --detectOpenHandles --forceExit --verbose"
73
75
  },
74
76
  "keywords": [
@@ -111,10 +113,15 @@
111
113
  "ts-node": "^10.9.1",
112
114
  "ts-node-dev": "^2.0.0",
113
115
  "typedoc": "^0.26.4",
114
- "typescript": "^5.0.4"
116
+ "typescript": "^5.0.4",
117
+ "@types/pg": "^8.10.0",
118
+ "nats": "^2.28.0",
119
+ "pg": "^8.10.0"
115
120
  },
116
121
  "peerDependencies": {
117
122
  "ioredis": "^4.0.0 || ^5.0.0",
118
- "redis": "^4.0.0"
123
+ "redis": "^4.0.0",
124
+ "nats": "^2.0.0",
125
+ "pg": "^8.0.0"
119
126
  }
120
127
  }
package/types/hotmesh.ts CHANGED
@@ -2,9 +2,9 @@ import { ILogger } from '../services/logger';
2
2
  import { HotMesh as HotMeshService } from '../services/hotmesh';
3
3
 
4
4
  import { HookRules } from './hook';
5
- import { RedisClass, RedisClient, RedisOptions } from './redis';
6
5
  import { StreamData, StreamDataResponse } from './stream';
7
6
  import { LogLevel } from './logger';
7
+ import { ProviderClient, ProviderConfig } from './provider';
8
8
 
9
9
  /**
10
10
  * the full set of entity types that are stored in the key/value store
@@ -50,29 +50,147 @@ type KeyStoreParams = {
50
50
 
51
51
  type HotMesh = typeof HotMeshService;
52
52
 
53
- type RedisConfig = {
54
- class: Partial<RedisClass>;
55
- options: Partial<RedisOptions>;
56
- };
57
-
58
53
  type HotMeshEngine = {
59
- store?: RedisClient; //set by hotmesh using instanced `redis` class
60
- stream?: RedisClient; //set by hotmesh using instanced `redis` class
61
- sub?: RedisClient; //set by hotmesh using instanced `redis` class
62
- redis?: RedisConfig;
63
- reclaimDelay?: number; //milliseconds
54
+ /**
55
+ * set by hotmesh once the connnector service instances the provider
56
+ * @private
57
+ */
58
+ store?: ProviderClient;
59
+ /**
60
+ * set by hotmesh once the connnector service instances the provider
61
+ * @private
62
+ */
63
+ stream?: ProviderClient;
64
+ /**
65
+ * set by hotmesh once the connnector service instances the provider
66
+ * @private
67
+ */
68
+ sub?: ProviderClient;
69
+ /**
70
+ * set by hotmesh once the connnector service instances the provider
71
+ * @private
72
+ */
73
+ search?: ProviderClient;
74
+
75
+ /**
76
+ * redis connection options; replaced with 'connection'
77
+ * @deprecated
78
+ */
79
+ redis?: ProviderConfig;
80
+
81
+ /**
82
+ * short-form format for the connection options for the
83
+ * store, stream, sub, and search clients
84
+ */
85
+ connection?: ProviderConfig;
86
+
87
+ /**
88
+ * long-form format for the connection options for the
89
+ * store, stream, sub, and search clients
90
+ */
91
+ connections?: {
92
+ store: ProviderConfig;
93
+ stream: ProviderConfig;
94
+ sub: ProviderConfig;
95
+ search?: ProviderConfig; //inherits from store if not set
96
+ };
97
+
98
+ /**
99
+ * the number of milliseconds to wait before reclaiming a stream;
100
+ * depending upon the provider this may be an explicit retry event,
101
+ * consuming a message from the stream and re-queueing it (dlq, etc),
102
+ * or it may be a configurable delay before the provider exposes the
103
+ * message to the consumer again. It is up to the provider, but expressed
104
+ * in milliseconds here.
105
+ */
106
+ reclaimDelay?: number;
107
+
108
+ /**
109
+ * the number of times to reclaim a stream before giving up
110
+ * and moving the message to a dead-letter queue or other
111
+ * error handling mechanism
112
+ */
64
113
  reclaimCount?: number;
65
- readonly?: boolean; //if true, the engine will not route stream messages
114
+
115
+ /**
116
+ * if true, the engine will not route stream messages
117
+ * to the worker
118
+ * @default false
119
+ */
120
+ readonly?: boolean;
66
121
  };
67
122
 
68
123
  type HotMeshWorker = {
124
+ /**
125
+ * the topic that the worker subscribes to
126
+ */
69
127
  topic: string;
70
- store?: RedisClient; //set by hotmesh using instanced `redis` class
71
- stream?: RedisClient; //set by hotmesh using instanced `redis` class
72
- sub?: RedisClient; //set by hotmesh using instanced `redis` class
73
- redis?: RedisConfig;
74
- reclaimDelay?: number; //milliseconds
75
- reclaimCount?: number; //max number of times to reclaim a stream
128
+
129
+ /**
130
+ * set by hotmesh once the connnector service instances the provider
131
+ * @private
132
+ */
133
+ store?: ProviderClient;
134
+ /**
135
+ * set by hotmesh once the connnector service instances the provider
136
+ * @private
137
+ */
138
+ stream?: ProviderClient;
139
+ /**
140
+ * set by hotmesh once the connnector service instances the provider
141
+ * @private
142
+ */
143
+ sub?: ProviderClient;
144
+ /**
145
+ * set by hotmesh once the connnector service instances the provider
146
+ * @private
147
+ */
148
+ search?: ProviderClient;
149
+
150
+ /**
151
+ * redis connection options; replaced with 'connection'
152
+ * @deprecated
153
+ */
154
+ redis?: ProviderConfig;
155
+
156
+ /**
157
+ * short-form format for the connection options for the
158
+ * store, stream, sub, and search clients
159
+ */
160
+ connection?: ProviderConfig;
161
+
162
+ /**
163
+ * long-form format for the connection options for the
164
+ * store, stream, sub, and search clients
165
+ */
166
+ connections?: {
167
+ store: ProviderConfig;
168
+ stream: ProviderConfig;
169
+ sub: ProviderConfig;
170
+ search?: ProviderConfig; //inherits from store if not set
171
+ };
172
+
173
+ /**
174
+ * the number of milliseconds to wait before reclaiming a stream;
175
+ * depending upon the provider this may be an explicit retry event,
176
+ * consuming a message from the stream and re-queueing it (dlq, etc),
177
+ * or it may be a configurable delay before the provider exposes the
178
+ * message to the consumer again. It is up to the provider, but expressed
179
+ * in milliseconds here.
180
+ */
181
+ reclaimDelay?: number;
182
+
183
+ /**
184
+ * the number of times to reclaim a stream before giving up
185
+ * and moving the message to a dead-letter queue or other
186
+ * error handling mechanism
187
+ */
188
+ reclaimCount?: number;
189
+
190
+ /**
191
+ * The callback function to execute when a message is dequeued
192
+ * from the target stream
193
+ */
76
194
  callback: (payload: StreamData) => Promise<StreamDataResponse>;
77
195
  };
78
196
 
@@ -169,12 +287,11 @@ type HotMeshApps = {
169
287
  export {
170
288
  HotMesh,
171
289
  HotMeshEngine,
172
- RedisConfig,
173
290
  HotMeshWorker,
174
291
  HotMeshSettings,
175
- HotMeshApp, //a single app in the db
176
- HotMeshApps, //object array of all apps in the db
177
- HotMeshConfig, //customer config
292
+ HotMeshApp,
293
+ HotMeshApps,
294
+ HotMeshConfig,
178
295
  HotMeshManifest,
179
296
  HotMeshGraph,
180
297
  KeyType,
package/types/index.ts CHANGED
@@ -28,7 +28,6 @@ export {
28
28
  ClientConfig,
29
29
  ClientWorkflow,
30
30
  ContextType,
31
- ConnectionConfig,
32
31
  Connection,
33
32
  ProxyResponseType,
34
33
  ProxyType,
@@ -78,6 +77,19 @@ export {
78
77
  HookRules,
79
78
  HookSignal,
80
79
  } from './hook';
80
+ export {
81
+ HotMesh,
82
+ HotMeshEngine,
83
+ HotMeshWorker,
84
+ HotMeshSettings,
85
+ HotMeshApp,
86
+ HotMeshApps,
87
+ HotMeshConfig,
88
+ HotMeshManifest,
89
+ HotMeshGraph,
90
+ KeyType,
91
+ KeyStoreParams,
92
+ } from './hotmesh';
81
93
  export { ILogger, LogLevel } from './logger';
82
94
  export {
83
95
  ExtensionType,
@@ -93,7 +105,6 @@ export {
93
105
  } from './job';
94
106
  export {
95
107
  DB,
96
- DBConfig,
97
108
  Profile,
98
109
  Namespaces,
99
110
  Entity,
@@ -116,19 +127,13 @@ export {
116
127
  ReduceObject,
117
128
  } from './pipe';
118
129
  export {
119
- HotMesh,
120
- HotMeshApp,
121
- HotMeshApps,
122
- HotMeshConfig,
123
- HotMeshEngine,
124
- RedisConfig,
125
- HotMeshGraph,
126
- HotMeshManifest,
127
- HotMeshSettings,
128
- HotMeshWorker,
129
- KeyStoreParams,
130
- KeyType,
131
- } from './hotmesh';
130
+ ProviderClass,
131
+ ProviderClient,
132
+ ProviderConfig,
133
+ ProviderTransaction,
134
+ Providers,
135
+ TransactionResultList,
136
+ } from './provider';
132
137
  export {
133
138
  MeshCallConnectParams,
134
139
  MeshCallExecParams,
@@ -178,10 +183,9 @@ export {
178
183
  IORedisClassType,
179
184
  IORedisMultiType,
180
185
  RedisOptions,
181
- MultiResponseFlags,
182
186
  isRedisClient,
183
187
  isIORedisClient,
184
- } from './redis'; //common redis types
188
+ } from './redis';
185
189
  export {
186
190
  JSONSchema,
187
191
  StringAnyType,
@@ -213,14 +217,19 @@ export {
213
217
  } from './stats';
214
218
  export {
215
219
  ReclaimedMessageType,
220
+ RouterConfig,
216
221
  StreamCode,
217
222
  StreamConfig,
218
223
  StreamData,
219
224
  StreamDataType,
220
225
  StreamError,
221
226
  StreamDataResponse,
227
+ StreamMessage,
228
+ StreamMessageMetadata,
229
+ StreamProviderType,
222
230
  StreamRetryPolicy,
223
231
  StreamRole,
232
+ StreamStats,
224
233
  StreamStatus,
225
234
  } from './stream';
226
235
  export {
package/types/manifest.ts CHANGED
@@ -2,20 +2,11 @@ import { MeshOS } from '../services/meshos';
2
2
 
3
3
  import * as Types from './index';
4
4
 
5
- export type DBConfig = {
6
- REDIS_DATABASE: number;
7
- REDIS_HOST: string | undefined;
8
- REDIS_PORT: number;
9
- REDIS_USERNAME: string;
10
- REDIS_PASSWORD: string;
11
- REDIS_USE_TLS: boolean;
12
- };
13
-
14
5
  export type DB = {
15
6
  name: string;
16
7
  label: string;
17
8
  search: boolean;
18
- config: DBConfig;
9
+ connection: Types.ProviderConfig;
19
10
  };
20
11
 
21
12
  export type SubClassInstance<T extends typeof MeshOS> = T extends abstract new (