@hotmeshio/hotmesh 0.3.8 → 0.3.10

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 (155) hide show
  1. package/README.md +7 -13
  2. package/build/index.d.ts +5 -2
  3. package/build/index.js +8 -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 +15 -8
  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 +7 -0
  32. package/build/services/connector/factory.js +65 -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 +44 -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/postgres.d.ts +68 -0
  105. package/build/services/stream/providers/postgres/postgres.js +1 -0
  106. package/build/services/stream/providers/redis/ioredis.d.ts +53 -14
  107. package/build/services/stream/providers/redis/ioredis.js +1 -1
  108. package/build/services/stream/providers/redis/redis.d.ts +54 -15
  109. package/build/services/stream/providers/redis/redis.js +1 -1
  110. package/build/services/stream/providers/stream-initializable.d.ts +1 -2
  111. package/build/services/stream/providers/stream-initializable.js +1 -1
  112. package/build/services/sub/factory.d.ts +2 -2
  113. package/build/services/sub/factory.js +1 -1
  114. package/build/services/sub/index.d.ts +6 -5
  115. package/build/services/sub/providers/redis/ioredis.d.ts +1 -1
  116. package/build/services/sub/providers/redis/ioredis.js +1 -1
  117. package/build/services/sub/providers/redis/redis.d.ts +4 -4
  118. package/build/services/sub/providers/redis/redis.js +1 -1
  119. package/build/services/task/index.d.ts +5 -5
  120. package/build/services/task/index.js +1 -1
  121. package/build/services/telemetry/index.js +1 -1
  122. package/build/services/worker/index.d.ts +9 -9
  123. package/build/services/worker/index.js +1 -1
  124. package/build/types/hotmesh.d.ts +26 -14
  125. package/build/types/index.d.ts +8 -5
  126. package/build/types/manifest.d.ts +1 -9
  127. package/build/types/meshcall.d.ts +12 -7
  128. package/build/types/meshflow.d.ts +3 -7
  129. package/build/types/nats.d.ts +150 -0
  130. package/build/types/nats.js +2 -0
  131. package/build/types/postgres.d.ts +70 -0
  132. package/build/types/postgres.js +2 -0
  133. package/build/types/provider.d.ts +26 -0
  134. package/build/types/provider.js +2 -0
  135. package/build/types/redis.d.ts +33 -15
  136. package/build/types/stream.d.ts +65 -1
  137. package/index.ts +10 -5
  138. package/package.json +15 -8
  139. package/typedoc.json +6 -0
  140. package/types/hotmesh.ts +139 -22
  141. package/types/index.ts +80 -17
  142. package/types/manifest.ts +1 -10
  143. package/types/meshcall.ts +38 -13
  144. package/types/meshflow.ts +2 -7
  145. package/types/nats.ts +236 -0
  146. package/types/postgres.ts +85 -0
  147. package/types/provider.ts +71 -0
  148. package/types/redis.ts +63 -18
  149. package/types/stream.ts +85 -1
  150. package/build/services/connector/clients/ioredis.d.ts +0 -13
  151. package/build/services/connector/clients/ioredis.js +0 -48
  152. package/build/services/connector/clients/redis.d.ts +0 -13
  153. package/build/services/connector/clients/redis.js +0 -60
  154. package/build/services/stream/providers/postgres/_deploy.d.ts +0 -4
  155. package/build/services/stream/providers/postgres/_deploy.js +0 -1
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,15 @@ 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
+ ProviderNativeClient,
137
+ ProviderOptions,
138
+ } from './provider';
132
139
  export {
133
140
  MeshCallConnectParams,
134
141
  MeshCallExecParams,
@@ -146,6 +153,19 @@ export {
146
153
  ConnectionInput,
147
154
  ExecInput,
148
155
  } from './meshdata';
156
+ export {
157
+ PostgresClassType,
158
+ PostgresClientOptions,
159
+ PostgresClientType,
160
+ PostgresConsumerGroup,
161
+ PostgresPendingMessage,
162
+ PostgresPoolClientType,
163
+ PostgresQueryConfigType,
164
+ PostgresQueryResultType,
165
+ PostgresStreamMessage,
166
+ PostgresStreamOptions,
167
+ PostgresTransaction,
168
+ } from './postgres'
149
169
  export {
150
170
  ActivateMessage,
151
171
  CronMessage,
@@ -165,6 +185,45 @@ export {
165
185
  ThrottleOptions,
166
186
  WorkMessage,
167
187
  } from './quorum';
188
+ export {
189
+ NatsAckPolicy,
190
+ NatsAckPolicyExplicitType,
191
+ NatsClassType,
192
+ NatsClientType,
193
+ NatsClientOptions,
194
+ NatsConsumerConfigType,
195
+ NatsJetStreamManager,
196
+ NatsConnection,
197
+ NatsJetStreamType,
198
+ NatsConnectionOptions,
199
+ NatsConsumerConfig,
200
+ NatsConsumerInfo,
201
+ NatsConsumerManager,
202
+ NatsDeliveryInfo,
203
+ NatsJetStreamOptions,
204
+ NatsError,
205
+ NatsErrorType,
206
+ NatsJetStreamClient,
207
+ NatsJsMsg,
208
+ NatsMessageType,
209
+ NatsMsgExpect,
210
+ NatsPubAck,
211
+ NatsPubAckType,
212
+ NatsPublishOptions,
213
+ NatsRetentionPolicy,
214
+ NatsRetentionPolicyWorkqueueType,
215
+ NatsSequenceInfo,
216
+ NatsStorageMemoryType,
217
+ NatsStorageType,
218
+ NatsStreamConfig,
219
+ NatsStreamInfo,
220
+ NatsStreamManager,
221
+ NatsStreamConfigType,
222
+ NatsStreamInfoType,
223
+ NatsStreamOptions,
224
+ NatsStreamState,
225
+ NatsTransaction,
226
+ } from './nats'
168
227
  export {
169
228
  RedisClass,
170
229
  RedisRedisClientType,
@@ -178,10 +237,9 @@ export {
178
237
  IORedisClassType,
179
238
  IORedisMultiType,
180
239
  RedisOptions,
181
- MultiResponseFlags,
182
240
  isRedisClient,
183
241
  isIORedisClient,
184
- } from './redis'; //common redis types
242
+ } from './redis';
185
243
  export {
186
244
  JSONSchema,
187
245
  StringAnyType,
@@ -213,14 +271,19 @@ export {
213
271
  } from './stats';
214
272
  export {
215
273
  ReclaimedMessageType,
274
+ RouterConfig,
216
275
  StreamCode,
217
276
  StreamConfig,
218
277
  StreamData,
219
278
  StreamDataType,
220
279
  StreamError,
221
280
  StreamDataResponse,
281
+ StreamMessage,
282
+ StreamMessageMetadata,
283
+ StreamProviderType,
222
284
  StreamRetryPolicy,
223
285
  StreamRole,
286
+ StreamStats,
224
287
  StreamStatus,
225
288
  } from './stream';
226
289
  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 (
package/types/meshcall.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RedisConfig } from './hotmesh';
1
+ import { ProviderConfig } from './provider';
2
2
  import { LogLevel } from './logger';
3
3
 
4
4
  interface MeshCallExecOptions {
@@ -33,13 +33,18 @@ interface MeshCallConnectParams {
33
33
  */
34
34
  topic: string;
35
35
  /**
36
- * Redis configuration for the worker
36
+ * Redis configuration; use 'connection' instead of 'redis'
37
+ * @deprecated
37
38
  */
38
- redis: RedisConfig;
39
+ redis?: ProviderConfig;
39
40
  /**
40
- * The linked worker function that will be called
41
+ * Provider configuration
41
42
  */
42
- callback: (...args: any[]) => any;
43
+ connection?: ProviderConfig;
44
+ /**
45
+ * The linked worker function that will be called; optional if read only
46
+ */
47
+ callback?: (...args: any[]) => any;
43
48
  }
44
49
 
45
50
  interface MeshCallExecParams {
@@ -56,9 +61,14 @@ interface MeshCallExecParams {
56
61
  */
57
62
  args: any[];
58
63
  /**
59
- * Redis configuration
64
+ * Redis configuration; use 'connection' instead of 'redis'
65
+ * @deprecated
60
66
  */
61
- redis: RedisConfig;
67
+ redis?: ProviderConfig;
68
+ /**
69
+ * Provider configuration
70
+ */
71
+ connection?: ProviderConfig;
62
72
  /**
63
73
  * Execution options like caching ttl
64
74
  */
@@ -86,9 +96,14 @@ interface MeshCallFlushParams {
86
96
  */
87
97
  topic: string;
88
98
  /**
89
- * Redis configuration
99
+ * Redis configuration; use 'connection' instead of 'redis'
100
+ * @deprecated
90
101
  */
91
- redis: RedisConfig;
102
+ redis?: ProviderConfig;
103
+ /**
104
+ * Provider configuration
105
+ */
106
+ connection?: ProviderConfig;
92
107
  /**
93
108
  * Options for the flush
94
109
  */
@@ -144,9 +159,14 @@ interface MeshCallCronParams {
144
159
  */
145
160
  topic: string;
146
161
  /**
147
- * Redis configuration for the cron job
162
+ * Redis configuration; use 'connection' instead of 'redis'
163
+ * @deprecated
164
+ */
165
+ redis?: ProviderConfig;
166
+ /**
167
+ * Provider configuration
148
168
  */
149
- redis: RedisConfig;
169
+ connection?: ProviderConfig;
150
170
  /**
151
171
  * Arguments to pass to the cron job; arguments will be passed to the callback
152
172
  * each time it runs
@@ -188,9 +208,14 @@ interface MeshCallInterruptParams {
188
208
  */
189
209
  topic: string;
190
210
  /**
191
- * Redis configuration
211
+ * Redis configuration; use 'connection' instead of 'redis'
212
+ * @deprecated
213
+ */
214
+ redis?: ProviderConfig;
215
+ /**
216
+ * Provider configuration
192
217
  */
193
- redis: RedisConfig;
218
+ connection?: ProviderConfig;
194
219
  /**
195
220
  * Options for interrupting the cron
196
221
  */
package/types/meshflow.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { WorkflowHandleService } from '../services/meshflow/handle';
2
2
 
3
3
  import { LogLevel } from './logger';
4
- import { RedisClass, RedisOptions } from './redis';
4
+ import { ProviderConfig } from './provider';
5
5
  import { StringAnyType, StringStringType } from './serializer';
6
6
  import { StreamData, StreamError } from './stream';
7
7
 
@@ -435,11 +435,7 @@ type WorkflowDataType = {
435
435
  expire?: number;
436
436
  };
437
437
 
438
- type ConnectionConfig = {
439
- class: Partial<RedisClass>;
440
- options: Partial<RedisOptions>;
441
- };
442
- type Connection = ConnectionConfig;
438
+ type Connection = ProviderConfig;
443
439
 
444
440
  type ClientConfig = {
445
441
  connection: Connection;
@@ -628,7 +624,6 @@ export {
628
624
  ClientConfig,
629
625
  ClientWorkflow,
630
626
  ContextType,
631
- ConnectionConfig,
632
627
  Connection,
633
628
  ProxyResponseType,
634
629
  ProxyType,
package/types/nats.ts ADDED
@@ -0,0 +1,236 @@
1
+ import { ProviderClient, ProviderTransaction } from './provider';
2
+
3
+ /** Connection Options for NATS */
4
+ export interface NatsConnectionOptions {
5
+ servers?: string | string[];
6
+ timeout?: number;
7
+ name?: string;
8
+ user?: string;
9
+ pass?: string;
10
+ token?: string;
11
+ // Add other connection options as needed
12
+ }
13
+
14
+ /** Additional JetStream Options */
15
+ export interface NatsJetStreamOptions {
16
+ domain?: string;
17
+ prefix?: string;
18
+ timeout?: number;
19
+ }
20
+
21
+ /** Combined Stream Options */
22
+ export interface NatsStreamOptions extends NatsConnectionOptions {
23
+ jetstream?: NatsJetStreamOptions;
24
+ }
25
+
26
+ /** Type for NATS Client Options */
27
+ export type NatsClientOptions = NatsStreamOptions;
28
+
29
+ /** Interface representing a NATS Connection */
30
+ export interface NatsConnection extends ProviderClient {
31
+ jetstream(options?: NatsJetStreamOptions): NatsJetStreamClient;
32
+ jetstreamManager(
33
+ options?: NatsJetStreamOptions,
34
+ ): Promise<NatsJetStreamManager>;
35
+ close(): Promise<void>;
36
+ }
37
+
38
+ /** Type representing the NATS Connection */
39
+ export type NatsClientType = NatsConnection;
40
+
41
+ /** Type representing the NATS Connection Function */
42
+ export type NatsClassType = (
43
+ options: NatsClientOptions,
44
+ ) => Promise<NatsConnection>;
45
+
46
+ /** Interface for JetStream Client */
47
+ export interface NatsJetStreamClient {
48
+ publish(
49
+ subject: string,
50
+ data: Uint8Array,
51
+ options?: NatsPublishOptions,
52
+ ): Promise<NatsPubAck>;
53
+ consumers: any; // Simplify as needed
54
+ jetstreamManager(): Promise<NatsJetStreamManager>;
55
+ // Additional methods as needed
56
+ }
57
+
58
+ /** **NatsJetStreamType** */
59
+ export type NatsJetStreamType = NatsJetStreamClient;
60
+
61
+ /** Interface for JetStream Manager */
62
+ export interface NatsJetStreamManager {
63
+ streams: NatsStreamManager;
64
+ consumers: NatsConsumerManager;
65
+ }
66
+
67
+ /** Interface for Stream Manager */
68
+ export interface NatsStreamManager {
69
+ add(config: Partial<NatsStreamConfig>): Promise<void>;
70
+ delete(stream: string): Promise<boolean>;
71
+ info(stream: string): Promise<NatsStreamInfo>;
72
+ list(): AsyncIterable<NatsStreamInfo>;
73
+ deleteMessage(stream: string, seq: number): Promise<boolean>;
74
+ update(stream: string, config: NatsStreamConfig): Promise<void>;
75
+ }
76
+
77
+ /** Interface for Consumer Manager */
78
+ export interface NatsConsumerManager {
79
+ add(stream: string, config: NatsConsumerConfig): Promise<void>;
80
+ delete(stream: string, consumer: string): Promise<boolean>;
81
+ info(stream: string, consumer: string): Promise<NatsConsumerInfo>;
82
+ list(stream: string): AsyncIterable<NatsConsumerInfo>;
83
+ // Additional methods as needed
84
+ }
85
+
86
+ /** Stream Configuration */
87
+ export interface NatsStreamConfig {
88
+ name: string;
89
+ subjects?: string[];
90
+ retention?: NatsRetentionPolicy;
91
+ storage?: NatsStorageType;
92
+ num_replicas?: number;
93
+ max_msgs?: number;
94
+ max_age?: number; // In nanoseconds
95
+ // Add other stream configurations as needed
96
+ }
97
+
98
+ /** Consumer Configuration */
99
+ export interface NatsConsumerConfig {
100
+ durable_name?: string;
101
+ deliver_subject?: string;
102
+ deliver_group?: string;
103
+ ack_policy?: NatsAckPolicy;
104
+ ack_wait?: number; // In nanoseconds
105
+ max_deliver?: number;
106
+ // Add other consumer configurations as needed
107
+ }
108
+
109
+ /** Interface for JetStream Message */
110
+ export interface NatsJsMsg {
111
+ seq: number;
112
+ ack(): void;
113
+ nak(): void;
114
+ term(): void;
115
+ inProgress(): void;
116
+ working(): void;
117
+ data: Uint8Array;
118
+ subject: string;
119
+ headers?: { [key: string]: string };
120
+ info: NatsDeliveryInfo;
121
+ // Additional properties and methods as needed
122
+ }
123
+
124
+ /** Delivery Info for a Message */
125
+ export interface NatsDeliveryInfo {
126
+ stream: string;
127
+ consumer: string;
128
+ redeliveryCount: number;
129
+ timestampNanos: number;
130
+ pending: number;
131
+ // Additional properties as needed
132
+ }
133
+
134
+ /** Interface for Publish Acknowledgment */
135
+ export interface NatsPubAck extends ProviderTransaction {
136
+ stream: string;
137
+ seq: number;
138
+ duplicate: boolean;
139
+ }
140
+
141
+ /** Interface for Stream Information */
142
+ export interface NatsStreamInfo {
143
+ config: NatsStreamConfig;
144
+ state: NatsStreamState;
145
+ }
146
+
147
+ /** Stream State Information */
148
+ export interface NatsStreamState {
149
+ messages: number;
150
+ bytes: number;
151
+ first_seq: number;
152
+ last_seq: number;
153
+ // Additional state properties as needed
154
+ }
155
+
156
+ /** Interface for Consumer Information */
157
+ export interface NatsConsumerInfo {
158
+ name: string;
159
+ stream_name: string;
160
+ config: NatsConsumerConfig;
161
+ delivered: NatsSequenceInfo;
162
+ ack_floor: NatsSequenceInfo;
163
+ num_ack_pending: number;
164
+ num_redelivered: number;
165
+ num_waiting: number;
166
+ num_pending: number;
167
+ // Additional properties as needed
168
+ }
169
+
170
+ /** Sequence Information */
171
+ export interface NatsSequenceInfo {
172
+ consumer_seq: number;
173
+ stream_seq: number;
174
+ }
175
+
176
+ /** Publish Options */
177
+ export interface NatsPublishOptions {
178
+ msgID?: string;
179
+ expect?: NatsMsgExpect;
180
+ headers?: { [key: string]: string };
181
+ // Additional options as needed
182
+ }
183
+
184
+ /** Message Expectation */
185
+ export interface NatsMsgExpect {
186
+ lastMsgID?: string;
187
+ streamName?: string;
188
+ lastSequence?: number;
189
+ // Additional expectations as needed
190
+ }
191
+
192
+ /** NATS Error */
193
+ export interface NatsError extends Error {
194
+ code?: string;
195
+ // Additional properties as needed
196
+ }
197
+
198
+ /** Retention Policies */
199
+ export type NatsRetentionPolicy = 'limits' | 'interest' | 'workqueue';
200
+
201
+ /** Storage Types */
202
+ export type NatsStorageType = 'file' | 'memory';
203
+
204
+ /** Acknowledgment Policies */
205
+ export type NatsAckPolicy = 'none' | 'all' | 'explicit';
206
+
207
+ /** Types for Specific Policies */
208
+ export type NatsRetentionPolicyWorkqueueType = 'workqueue';
209
+ export type NatsStorageMemoryType = 'memory';
210
+ export type NatsAckPolicyExplicitType = 'explicit';
211
+
212
+ /** NATS Message Type */
213
+ export type NatsMessageType = NatsJsMsg;
214
+
215
+ /** NATS Transaction Interface */
216
+ export interface NatsTransaction {
217
+ msgs: NatsMessageType[];
218
+ pubAcks: NatsPubAck[];
219
+ execute(): Promise<void>;
220
+ rollback(): Promise<void>;
221
+ }
222
+
223
+ /** NATS Client Error Type */
224
+ export type NatsErrorType = NatsError;
225
+
226
+ /** NATS Stream Info Type */
227
+ export type NatsStreamInfoType = NatsStreamInfo;
228
+
229
+ /** NATS Stream Config Type */
230
+ export type NatsStreamConfigType = Partial<NatsStreamConfig>;
231
+
232
+ /** NATS Consumer Config Type */
233
+ export type NatsConsumerConfigType = Partial<NatsConsumerConfig>;
234
+
235
+ /** NATS Publish Ack Type */
236
+ export type NatsPubAckType = NatsPubAck;
@@ -0,0 +1,85 @@
1
+ // /app/types/postgres.ts
2
+ export interface PostgresClientOptions {
3
+ host?: string;
4
+ port?: number;
5
+ user?: string;
6
+ password?: string;
7
+ database?: string;
8
+ max?: number;
9
+ idleTimeoutMillis?: number;
10
+ // Add any other options you might need
11
+ }
12
+
13
+ export type PostgresClassType = {
14
+ new (options: PostgresClientOptions): PostgresClientType;
15
+ connect: (options: PostgresClientOptions) => Promise<PostgresClientType>;
16
+ };
17
+
18
+ export interface PostgresClientType {
19
+ query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
20
+ end: () => Promise<void>;
21
+ // Include other methods if necessary
22
+ }
23
+
24
+ export interface PostgresPoolClientType {
25
+ query: (text: string, values?: any[]) => Promise<PostgresQueryResultType>;
26
+ release: () => void;
27
+ // Include other methods if necessary
28
+ }
29
+
30
+ export interface PostgresQueryResultType {
31
+ rows: any[];
32
+ rowCount: number;
33
+ // Include other properties if necessary
34
+ }
35
+
36
+ export interface PostgresQueryConfigType {
37
+ text: string;
38
+ values?: any[];
39
+ }
40
+
41
+ export interface PostgresStreamOptions extends PostgresClientOptions {
42
+ schema?: string;
43
+ maxRetries?: number;
44
+ retryDelay?: number;
45
+ streamTablePrefix?: string;
46
+ consumerTablePrefix?: string;
47
+ }
48
+
49
+ export interface PostgresStreamMessage {
50
+ id: string;
51
+ stream: string;
52
+ message: any;
53
+ created_at: Date;
54
+ sequence?: number;
55
+ }
56
+
57
+ export interface PostgresConsumerGroup {
58
+ stream: string;
59
+ group_name: string;
60
+ last_message_id: string;
61
+ created_at: Date;
62
+ updated_at: Date;
63
+ }
64
+
65
+ export interface PostgresPendingMessage {
66
+ stream: string;
67
+ group_name: string;
68
+ consumer_name: string;
69
+ message_id: string;
70
+ delivered_at: Date;
71
+ delivery_count: number;
72
+ }
73
+
74
+ export interface PostgresTransaction {
75
+ client: PostgresPoolClientType;
76
+ queryBuffer: {
77
+ text: string;
78
+ values: any[];
79
+ }[];
80
+ begin(): Promise<void>;
81
+ query(text: string, values?: any[]): Promise<PostgresQueryResultType>;
82
+ commit(): Promise<void>;
83
+ rollback(): Promise<void>;
84
+ release(): void;
85
+ }
@@ -0,0 +1,71 @@
1
+ import { KeyStoreParams } from '../modules/key';
2
+
3
+ import { StringAnyType } from './serializer';
4
+
5
+ /**
6
+ * Generic type for provider class
7
+ */
8
+ export interface ProviderClass {
9
+ [key: string]: any;
10
+ }
11
+
12
+ /**
13
+ * Generic type for provider options
14
+ */
15
+ export interface ProviderOptions {
16
+ [key: string]: any;
17
+ }
18
+
19
+ export type Providers = 'redis' | 'nats' | 'postgres' | 'ioredis';
20
+
21
+ /**
22
+ * A provider transaction is a set of operations that are executed
23
+ * atomically by the provider. The transaction is created by calling
24
+ * the `transact` method on the provider. The transaction object
25
+ * contains methods specific to the provider allowing it to optionally
26
+ * choose to execute a single command or collect all commands and
27
+ * execute as a single transaction.
28
+ */
29
+ export interface ProviderTransaction {
30
+ //outside callers can execute the transaction, regardless of provider by calling this method
31
+ exec(): Promise<any>;
32
+
33
+ // All other transaction methods are provider specific
34
+ [key: string]: any;
35
+ }
36
+
37
+ /**
38
+ * A provider native client is the raw client object provided by the
39
+ * connecter service. This object is passed to the ProviderClient
40
+ * (which wraps it), providing a standardized interface for all
41
+ * providers.
42
+ */
43
+ export interface ProviderNativeClient {
44
+ [key: string]: any;
45
+ }
46
+
47
+ /**
48
+ * Wrapped provider native client object that standardizes the
49
+ * interface for all providers.
50
+ */
51
+ export interface ProviderClient {
52
+ /** The provider-specific transaction object */
53
+ transact(): ProviderTransaction;
54
+
55
+ /** Mint a provider-specific key */
56
+ mintKey(type: KeyType, params: KeyStoreParams): string;
57
+
58
+ /** The provider-specific client object */
59
+ [key: string]: any;
60
+ }
61
+
62
+ /**
63
+ * an array of outputs generic to all providers
64
+ * e.g., [3, 2, '0']
65
+ */
66
+ export type TransactionResultList = (string | number)[]; // e.g., [3, 2, '0']
67
+
68
+ export type ProviderConfig = {
69
+ class: any;
70
+ options: StringAnyType;
71
+ };