@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.
- package/README.md +2 -17
- package/build/index.d.ts +4 -2
- package/build/index.js +6 -3
- package/build/modules/key.js +1 -1
- package/build/modules/utils.d.ts +12 -4
- package/build/modules/utils.js +1 -1
- package/build/package.json +14 -7
- package/build/services/activities/activity.d.ts +9 -9
- package/build/services/activities/activity.js +1 -1
- package/build/services/activities/await.d.ts +2 -2
- package/build/services/activities/await.js +1 -1
- package/build/services/activities/cycle.d.ts +2 -2
- package/build/services/activities/cycle.js +1 -1
- package/build/services/activities/hook.d.ts +2 -2
- package/build/services/activities/hook.js +1 -1
- package/build/services/activities/index.js +1 -1
- package/build/services/activities/interrupt.js +1 -1
- package/build/services/activities/signal.js +1 -1
- package/build/services/activities/trigger.d.ts +3 -3
- package/build/services/activities/trigger.js +1 -1
- package/build/services/activities/worker.d.ts +2 -2
- package/build/services/activities/worker.js +1 -1
- package/build/services/collator/index.d.ts +9 -9
- package/build/services/collator/index.js +1 -1
- package/build/services/compiler/deployer.d.ts +4 -4
- package/build/services/compiler/deployer.js +1 -1
- package/build/services/compiler/index.d.ts +4 -4
- package/build/services/compiler/index.js +1 -1
- package/build/services/compiler/validator.d.ts +3 -3
- package/build/services/compiler/validator.js +1 -1
- package/build/services/connector/factory.d.ts +6 -0
- package/build/services/connector/factory.js +56 -0
- package/build/services/connector/index.d.ts +13 -4
- package/build/services/connector/index.js +30 -23
- package/build/services/connector/providers/ioredis.d.ts +9 -0
- package/build/services/connector/providers/ioredis.js +26 -0
- package/build/services/connector/providers/nats.d.ts +9 -0
- package/build/services/connector/providers/nats.js +26 -0
- package/build/services/connector/providers/postgres.d.ts +9 -0
- package/build/services/connector/providers/postgres.js +39 -0
- package/build/services/connector/providers/redis.d.ts +9 -0
- package/build/services/connector/providers/redis.js +38 -0
- package/build/services/engine/index.d.ts +12 -12
- package/build/services/engine/index.js +1 -1
- package/build/services/exporter/index.d.ts +3 -3
- package/build/services/exporter/index.js +1 -1
- package/build/services/hotmesh/index.js +4 -4
- package/build/services/mapper/index.js +1 -1
- package/build/services/meshcall/index.d.ts +5 -4
- package/build/services/meshcall/index.js +31 -14
- package/build/services/meshdata/index.d.ts +6 -6
- package/build/services/meshdata/index.js +7 -15
- package/build/services/meshflow/connection.d.ts +3 -2
- package/build/services/meshflow/exporter.d.ts +3 -3
- package/build/services/meshflow/exporter.js +1 -1
- package/build/services/meshflow/search.js +12 -4
- package/build/services/meshflow/worker.js +7 -7
- package/build/services/meshos/index.d.ts +1 -4
- package/build/services/meshos/index.js +11 -44
- package/build/services/pipe/functions/array.js +1 -1
- package/build/services/pipe/functions/bitwise.js +1 -1
- package/build/services/pipe/functions/conditional.js +1 -1
- package/build/services/pipe/functions/cron.d.ts +2 -0
- package/build/services/pipe/functions/cron.js +1 -1
- package/build/services/pipe/functions/date.js +1 -1
- package/build/services/pipe/functions/index.js +1 -1
- package/build/services/pipe/functions/json.js +1 -1
- package/build/services/pipe/functions/logical.js +1 -1
- package/build/services/pipe/functions/math.js +1 -1
- package/build/services/pipe/functions/number.js +1 -1
- package/build/services/pipe/functions/object.js +1 -1
- package/build/services/pipe/functions/string.js +1 -1
- package/build/services/pipe/functions/symbol.js +1 -1
- package/build/services/pipe/functions/unary.js +1 -1
- package/build/services/pipe/index.js +1 -1
- package/build/services/quorum/index.d.ts +5 -5
- package/build/services/quorum/index.js +1 -1
- package/build/services/reporter/index.d.ts +2 -2
- package/build/services/reporter/index.js +1 -1
- package/build/services/router/index.d.ts +8 -13
- package/build/services/router/index.js +1 -1
- package/build/services/search/factory.d.ts +2 -2
- package/build/services/search/factory.js +1 -1
- package/build/services/search/index.d.ts +5 -4
- package/build/services/search/providers/redis/ioredis.js +1 -1
- package/build/services/search/providers/redis/redis.js +1 -1
- package/build/services/serializer/index.js +1 -1
- package/build/services/store/factory.d.ts +3 -3
- package/build/services/store/factory.js +1 -1
- package/build/services/store/index.d.ts +18 -17
- package/build/services/store/providers/redis/_base.d.ts +13 -15
- package/build/services/store/providers/redis/_base.js +1 -1
- package/build/services/store/providers/redis/ioredis.d.ts +2 -2
- package/build/services/store/providers/redis/ioredis.js +1 -1
- package/build/services/store/providers/redis/redis.d.ts +2 -2
- package/build/services/store/providers/redis/redis.js +1 -1
- package/build/services/store/providers/store-initializable.js +1 -1
- package/build/services/stream/factory.d.ts +3 -3
- package/build/services/stream/factory.js +16 -4
- package/build/services/stream/index.d.ts +57 -18
- package/build/services/stream/index.js +2 -1
- package/build/services/stream/providers/nats/nats.d.ts +59 -0
- package/build/services/stream/providers/nats/nats.js +1 -0
- package/build/services/stream/providers/postgres/_deploy.d.ts +2 -1
- package/build/services/stream/providers/postgres/_deploy.js +1 -1
- package/build/services/stream/providers/postgres/postgres.d.ts +0 -0
- package/build/services/stream/providers/postgres/postgres.js +0 -0
- package/build/services/stream/providers/redis/ioredis.d.ts +53 -14
- package/build/services/stream/providers/redis/ioredis.js +1 -1
- package/build/services/stream/providers/redis/redis.d.ts +54 -15
- package/build/services/stream/providers/redis/redis.js +1 -1
- package/build/services/stream/providers/stream-initializable.d.ts +1 -2
- package/build/services/stream/providers/stream-initializable.js +1 -1
- package/build/services/sub/factory.d.ts +2 -2
- package/build/services/sub/factory.js +1 -1
- package/build/services/sub/index.d.ts +6 -5
- package/build/services/sub/providers/redis/ioredis.d.ts +1 -1
- package/build/services/sub/providers/redis/ioredis.js +1 -1
- package/build/services/sub/providers/redis/redis.d.ts +4 -4
- package/build/services/sub/providers/redis/redis.js +1 -1
- package/build/services/task/index.d.ts +5 -5
- package/build/services/task/index.js +1 -1
- package/build/services/telemetry/index.js +1 -1
- package/build/services/worker/index.d.ts +9 -9
- package/build/services/worker/index.js +1 -1
- package/build/types/hotmesh.d.ts +26 -14
- package/build/types/index.d.ts +6 -5
- package/build/types/manifest.d.ts +1 -9
- package/build/types/meshcall.d.ts +12 -7
- package/build/types/meshflow.d.ts +3 -7
- package/build/types/nats.d.ts +150 -0
- package/build/types/nats.js +2 -0
- package/build/types/postgres.d.ts +48 -0
- package/build/types/postgres.js +2 -0
- package/build/types/provider.d.ts +26 -0
- package/build/types/provider.js +2 -0
- package/build/types/redis.d.ts +33 -15
- package/build/types/stream.d.ts +65 -1
- package/index.ts +8 -5
- package/package.json +14 -7
- package/types/hotmesh.ts +139 -22
- package/types/index.ts +26 -17
- package/types/manifest.ts +1 -10
- package/types/meshcall.ts +38 -13
- package/types/meshflow.ts +2 -7
- package/types/nats.ts +231 -0
- package/types/postgres.ts +54 -0
- package/types/provider.ts +71 -0
- package/types/redis.ts +63 -18
- package/types/stream.ts +85 -1
- package/build/services/connector/clients/ioredis.d.ts +0 -13
- package/build/services/connector/clients/ioredis.js +0 -48
- package/build/services/connector/clients/redis.d.ts +0 -13
- package/build/services/connector/clients/redis.js +0 -60
package/types/meshcall.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
36
|
+
* Redis configuration; use 'connection' instead of 'redis'
|
|
37
|
+
* @deprecated
|
|
37
38
|
*/
|
|
38
|
-
redis
|
|
39
|
+
redis?: ProviderConfig;
|
|
39
40
|
/**
|
|
40
|
-
*
|
|
41
|
+
* Provider configuration
|
|
41
42
|
*/
|
|
42
|
-
|
|
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
|
|
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
|
|
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
|
|
162
|
+
* Redis configuration; use 'connection' instead of 'redis'
|
|
163
|
+
* @deprecated
|
|
164
|
+
*/
|
|
165
|
+
redis?: ProviderConfig;
|
|
166
|
+
/**
|
|
167
|
+
* Provider configuration
|
|
148
168
|
*/
|
|
149
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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,231 @@
|
|
|
1
|
+
import { ProviderClient, ProviderTransaction } from './provider';
|
|
2
|
+
|
|
3
|
+
// NOTE: Manually defines NATS types to avoid importing 'nats' package
|
|
4
|
+
// TODO: Generate file using 'nats' package/interface definitions
|
|
5
|
+
|
|
6
|
+
/** Connection Options for NATS */
|
|
7
|
+
export interface NatsConnectionOptions {
|
|
8
|
+
servers?: string | string[];
|
|
9
|
+
timeout?: number;
|
|
10
|
+
name?: string;
|
|
11
|
+
user?: string;
|
|
12
|
+
pass?: string;
|
|
13
|
+
token?: string;
|
|
14
|
+
// Add other connection options as needed
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Additional JetStream Options */
|
|
18
|
+
export interface NatsJetStreamOptions {
|
|
19
|
+
domain?: string;
|
|
20
|
+
prefix?: string;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Combined Stream Options */
|
|
25
|
+
export interface NatsStreamOptions extends NatsConnectionOptions {
|
|
26
|
+
jetstream?: NatsJetStreamOptions;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Type for NATS Client Options */
|
|
30
|
+
export type NatsClientOptions = NatsStreamOptions;
|
|
31
|
+
|
|
32
|
+
/** Interface representing a NATS Connection */
|
|
33
|
+
export interface NatsConnection extends ProviderClient {
|
|
34
|
+
jetstream(options?: NatsJetStreamOptions): NatsJetStreamClient;
|
|
35
|
+
jetstreamManager(options?: NatsJetStreamOptions): Promise<NatsJetStreamManager>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Type representing the NATS Connection */
|
|
40
|
+
export type NatsClientType = NatsConnection;
|
|
41
|
+
|
|
42
|
+
/** Type representing the NATS Connection Function */
|
|
43
|
+
export type NatsClassType = (options: NatsClientOptions) => Promise<NatsConnection>;
|
|
44
|
+
|
|
45
|
+
/** Interface for JetStream Client */
|
|
46
|
+
export interface NatsJetStreamClient {
|
|
47
|
+
publish(subject: string, data: Uint8Array, options?: NatsPublishOptions): Promise<NatsPubAck>;
|
|
48
|
+
consumers: any; // Simplify as needed
|
|
49
|
+
jetstreamManager(): Promise<NatsJetStreamManager>;
|
|
50
|
+
// Additional methods as needed
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** **NatsJetStreamType** */
|
|
54
|
+
export type NatsJetStreamType = NatsJetStreamClient;
|
|
55
|
+
|
|
56
|
+
/** Interface for JetStream Manager */
|
|
57
|
+
export interface NatsJetStreamManager {
|
|
58
|
+
streams: NatsStreamManager;
|
|
59
|
+
consumers: NatsConsumerManager;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Interface for Stream Manager */
|
|
63
|
+
export interface NatsStreamManager {
|
|
64
|
+
add(config: Partial<NatsStreamConfig>): Promise<void>;
|
|
65
|
+
delete(stream: string): Promise<boolean>;
|
|
66
|
+
info(stream: string): Promise<NatsStreamInfo>;
|
|
67
|
+
list(): AsyncIterable<NatsStreamInfo>;
|
|
68
|
+
deleteMessage(stream: string, seq: number): Promise<boolean>;
|
|
69
|
+
update(stream: string, config: NatsStreamConfig ): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Interface for Consumer Manager */
|
|
73
|
+
export interface NatsConsumerManager {
|
|
74
|
+
add(stream: string, config: NatsConsumerConfig): Promise<void>;
|
|
75
|
+
delete(stream: string, consumer: string): Promise<boolean>;
|
|
76
|
+
info(stream: string, consumer: string): Promise<NatsConsumerInfo>;
|
|
77
|
+
list(stream: string): AsyncIterable<NatsConsumerInfo>;
|
|
78
|
+
// Additional methods as needed
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Stream Configuration */
|
|
82
|
+
export interface NatsStreamConfig {
|
|
83
|
+
name: string;
|
|
84
|
+
subjects?: string[];
|
|
85
|
+
retention?: NatsRetentionPolicy;
|
|
86
|
+
storage?: NatsStorageType;
|
|
87
|
+
num_replicas?: number;
|
|
88
|
+
max_msgs?: number;
|
|
89
|
+
max_age?: number; // In nanoseconds
|
|
90
|
+
// Add other stream configurations as needed
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Consumer Configuration */
|
|
94
|
+
export interface NatsConsumerConfig {
|
|
95
|
+
durable_name?: string;
|
|
96
|
+
deliver_subject?: string;
|
|
97
|
+
deliver_group?: string;
|
|
98
|
+
ack_policy?: NatsAckPolicy;
|
|
99
|
+
ack_wait?: number; // In nanoseconds
|
|
100
|
+
max_deliver?: number;
|
|
101
|
+
// Add other consumer configurations as needed
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Interface for JetStream Message */
|
|
105
|
+
export interface NatsJsMsg {
|
|
106
|
+
seq: number;
|
|
107
|
+
ack(): void;
|
|
108
|
+
nak(): void;
|
|
109
|
+
term(): void;
|
|
110
|
+
inProgress(): void;
|
|
111
|
+
working(): void;
|
|
112
|
+
data: Uint8Array;
|
|
113
|
+
subject: string;
|
|
114
|
+
headers?: { [key: string]: string };
|
|
115
|
+
info: NatsDeliveryInfo;
|
|
116
|
+
// Additional properties and methods as needed
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Delivery Info for a Message */
|
|
120
|
+
export interface NatsDeliveryInfo {
|
|
121
|
+
stream: string;
|
|
122
|
+
consumer: string;
|
|
123
|
+
redeliveryCount: number;
|
|
124
|
+
timestampNanos: number;
|
|
125
|
+
pending: number;
|
|
126
|
+
// Additional properties as needed
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Interface for Publish Acknowledgment */
|
|
130
|
+
export interface NatsPubAck extends ProviderTransaction {
|
|
131
|
+
stream: string;
|
|
132
|
+
seq: number;
|
|
133
|
+
duplicate: boolean;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Interface for Stream Information */
|
|
137
|
+
export interface NatsStreamInfo {
|
|
138
|
+
config: NatsStreamConfig;
|
|
139
|
+
state: NatsStreamState;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Stream State Information */
|
|
143
|
+
export interface NatsStreamState {
|
|
144
|
+
messages: number;
|
|
145
|
+
bytes: number;
|
|
146
|
+
first_seq: number;
|
|
147
|
+
last_seq: number;
|
|
148
|
+
// Additional state properties as needed
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Interface for Consumer Information */
|
|
152
|
+
export interface NatsConsumerInfo {
|
|
153
|
+
name: string;
|
|
154
|
+
stream_name: string;
|
|
155
|
+
config: NatsConsumerConfig;
|
|
156
|
+
delivered: NatsSequenceInfo;
|
|
157
|
+
ack_floor: NatsSequenceInfo;
|
|
158
|
+
num_ack_pending: number;
|
|
159
|
+
num_redelivered: number;
|
|
160
|
+
num_waiting: number;
|
|
161
|
+
num_pending: number;
|
|
162
|
+
// Additional properties as needed
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Sequence Information */
|
|
166
|
+
export interface NatsSequenceInfo {
|
|
167
|
+
consumer_seq: number;
|
|
168
|
+
stream_seq: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Publish Options */
|
|
172
|
+
export interface NatsPublishOptions {
|
|
173
|
+
msgID?: string;
|
|
174
|
+
expect?: NatsMsgExpect;
|
|
175
|
+
headers?: { [key: string]: string };
|
|
176
|
+
// Additional options as needed
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Message Expectation */
|
|
180
|
+
export interface NatsMsgExpect {
|
|
181
|
+
lastMsgID?: string;
|
|
182
|
+
streamName?: string;
|
|
183
|
+
lastSequence?: number;
|
|
184
|
+
// Additional expectations as needed
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** NATS Error */
|
|
188
|
+
export interface NatsError extends Error {
|
|
189
|
+
code?: string;
|
|
190
|
+
// Additional properties as needed
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Retention Policies */
|
|
194
|
+
export type NatsRetentionPolicy = 'limits' | 'interest' | 'workqueue';
|
|
195
|
+
|
|
196
|
+
/** Storage Types */
|
|
197
|
+
export type NatsStorageType = 'file' | 'memory';
|
|
198
|
+
|
|
199
|
+
/** Acknowledgment Policies */
|
|
200
|
+
export type NatsAckPolicy = 'none' | 'all' | 'explicit';
|
|
201
|
+
|
|
202
|
+
/** Types for Specific Policies */
|
|
203
|
+
export type NatsRetentionPolicyWorkqueueType = 'workqueue';
|
|
204
|
+
export type NatsStorageMemoryType = 'memory';
|
|
205
|
+
export type NatsAckPolicyExplicitType = 'explicit';
|
|
206
|
+
|
|
207
|
+
/** NATS Message Type */
|
|
208
|
+
export type NatsMessageType = NatsJsMsg;
|
|
209
|
+
|
|
210
|
+
/** NATS Transaction Interface */
|
|
211
|
+
export interface NatsTransaction {
|
|
212
|
+
msgs: NatsMessageType[];
|
|
213
|
+
pubAcks: NatsPubAck[];
|
|
214
|
+
execute(): Promise<void>;
|
|
215
|
+
rollback(): Promise<void>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** NATS Client Error Type */
|
|
219
|
+
export type NatsErrorType = NatsError;
|
|
220
|
+
|
|
221
|
+
/** NATS Stream Info Type */
|
|
222
|
+
export type NatsStreamInfoType = NatsStreamInfo;
|
|
223
|
+
|
|
224
|
+
/** NATS Stream Config Type */
|
|
225
|
+
export type NatsStreamConfigType = Partial<NatsStreamConfig>;
|
|
226
|
+
|
|
227
|
+
/** NATS Consumer Config Type */
|
|
228
|
+
export type NatsConsumerConfigType = Partial<NatsConsumerConfig>;
|
|
229
|
+
|
|
230
|
+
/** NATS Publish Ack Type */
|
|
231
|
+
export type NatsPubAckType = NatsPubAck;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Pool, PoolConfig, PoolClient, QueryResult, QueryConfig } from 'pg';
|
|
2
|
+
|
|
3
|
+
export interface PostgresStreamOptions extends PoolConfig {
|
|
4
|
+
schema?: string;
|
|
5
|
+
maxRetries?: number;
|
|
6
|
+
retryDelay?: number;
|
|
7
|
+
streamTablePrefix?: string;
|
|
8
|
+
consumerTablePrefix?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type PostgresClientOptions = PoolConfig;
|
|
12
|
+
export type PostgresClientType = Pool;
|
|
13
|
+
export type PostgresClassType = typeof Pool;
|
|
14
|
+
export type PostgresPoolClientType = PoolClient;
|
|
15
|
+
export type PostgresQueryResultType = QueryResult;
|
|
16
|
+
export type PostgresQueryConfigType = QueryConfig;
|
|
17
|
+
|
|
18
|
+
export interface PostgresStreamMessage {
|
|
19
|
+
id: string;
|
|
20
|
+
stream: string;
|
|
21
|
+
message: any;
|
|
22
|
+
created_at: Date;
|
|
23
|
+
sequence?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface PostgresConsumerGroup {
|
|
27
|
+
stream: string;
|
|
28
|
+
group_name: string;
|
|
29
|
+
last_message_id: string;
|
|
30
|
+
created_at: Date;
|
|
31
|
+
updated_at: Date;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PostgresPendingMessage {
|
|
35
|
+
stream: string;
|
|
36
|
+
group_name: string;
|
|
37
|
+
consumer_name: string;
|
|
38
|
+
message_id: string;
|
|
39
|
+
delivered_at: Date;
|
|
40
|
+
delivery_count: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface PostgresTransaction {
|
|
44
|
+
client: PoolClient;
|
|
45
|
+
queryBuffer: {
|
|
46
|
+
text: string;
|
|
47
|
+
values: any[];
|
|
48
|
+
}[];
|
|
49
|
+
begin(): Promise<void>;
|
|
50
|
+
query(text: string, values?: any[]): Promise<PostgresQueryResultType>;
|
|
51
|
+
commit(): Promise<void>;
|
|
52
|
+
rollback(): Promise<void>;
|
|
53
|
+
release(): void;
|
|
54
|
+
}
|
|
@@ -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
|
+
};
|
package/types/redis.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProviderClient,
|
|
3
|
+
ProviderConfig,
|
|
4
|
+
ProviderTransaction,
|
|
5
|
+
} from './provider';
|
|
1
6
|
import { StringStringType } from './serializer';
|
|
2
7
|
import { ReclaimedMessageType } from './stream';
|
|
3
8
|
|
|
4
|
-
type MultiResponseFlags = (string | number)[]; // e.g., [3, 2, '0']
|
|
5
|
-
|
|
6
9
|
/**
|
|
7
10
|
* Redis types
|
|
8
11
|
*/
|
|
@@ -64,14 +67,10 @@ interface RedisRedisClientOptions {
|
|
|
64
67
|
stringNumbers?: boolean;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
interface RedisRedisMultiType {
|
|
70
|
+
interface RedisRedisMultiType extends ProviderTransaction {
|
|
68
71
|
sendCommand(command: string, ...args: string[]): Promise<any>;
|
|
69
72
|
exec: () => Promise<unknown[]>;
|
|
70
73
|
|
|
71
|
-
XADD(key: string, id: string, fields: any): this;
|
|
72
|
-
XACK(key: string, group: string, id: string): this;
|
|
73
|
-
XDEL(key: string, id: string): this;
|
|
74
|
-
XLEN(key: string): this;
|
|
75
74
|
DEL(key: string): this;
|
|
76
75
|
EXISTS(key: string): this;
|
|
77
76
|
EXPIRE(key: string, seconds: number): this;
|
|
@@ -87,6 +86,11 @@ interface RedisRedisMultiType {
|
|
|
87
86
|
LRANGE(key: string, start: number, end: number): this;
|
|
88
87
|
RPUSH(key: string, items: string[]): this;
|
|
89
88
|
SET(key: string, value: string): this;
|
|
89
|
+
XADD(key: string, id: string, fields: any): this;
|
|
90
|
+
XACK(key: string, group: string, id: string): this;
|
|
91
|
+
XACK(key: string, group: string, ...ids: string[]): this;
|
|
92
|
+
XDEL(key: string, id: string): this;
|
|
93
|
+
XDEL(key: string, ...ids: string[]): this;
|
|
90
94
|
XCLAIM(
|
|
91
95
|
key: string,
|
|
92
96
|
group: string,
|
|
@@ -95,6 +99,7 @@ interface RedisRedisMultiType {
|
|
|
95
99
|
id: string,
|
|
96
100
|
...args: string[]
|
|
97
101
|
): this;
|
|
102
|
+
XLEN(key: string): this;
|
|
98
103
|
XGROUP(
|
|
99
104
|
command: 'CREATE' | string,
|
|
100
105
|
key: string,
|
|
@@ -120,7 +125,7 @@ interface RedisRedisMultiType {
|
|
|
120
125
|
ZSCORE(key: string, value: string): this;
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
interface RedisRedisClientType {
|
|
128
|
+
interface RedisRedisClientType extends ProviderClient {
|
|
124
129
|
multi(): Partial<RedisRedisMultiType>;
|
|
125
130
|
connect(): Promise<void>;
|
|
126
131
|
sendCommand(args: any[]): Promise<any>;
|
|
@@ -145,10 +150,6 @@ interface RedisRedisClientType {
|
|
|
145
150
|
get(key: string): Promise<string | null>;
|
|
146
151
|
set(key: string, value: string): Promise<string>;
|
|
147
152
|
|
|
148
|
-
XADD(key: string, id: string, fields: any): Promise<string>;
|
|
149
|
-
XACK(key: string, group: string, id: string): Promise<number>;
|
|
150
|
-
XDEL(key: string, id: string): Promise<number>;
|
|
151
|
-
XLEN(key: string): Promise<number>;
|
|
152
153
|
DEL(key: string): Promise<number>;
|
|
153
154
|
EXISTS(key: string): Promise<number>;
|
|
154
155
|
HDEL(key: string, fields: string[] | string): Promise<number>;
|
|
@@ -161,6 +162,31 @@ interface RedisRedisClientType {
|
|
|
161
162
|
LRANGE(key: string, start: number, end: number): Promise<string[]>;
|
|
162
163
|
RPUSH(key: string, items: string[]): Promise<number>;
|
|
163
164
|
SET(key: string, value: string): Promise<string>;
|
|
165
|
+
XADD(key: string, id: string, fields: any): Promise<string>;
|
|
166
|
+
XACK(key: string, group: string, ...ids: string[]): Promise<number>;
|
|
167
|
+
XACK(key: string, group: string, id: string): Promise<number>;
|
|
168
|
+
XCLAIM(
|
|
169
|
+
key: string,
|
|
170
|
+
group: string,
|
|
171
|
+
consumer: string,
|
|
172
|
+
minIdleTime: number,
|
|
173
|
+
id: string,
|
|
174
|
+
...args: string[]
|
|
175
|
+
): Promise<ReclaimedMessageType>;
|
|
176
|
+
XDEL(key: string, id: string): Promise<number>;
|
|
177
|
+
XDEL(key: string, ...ids: string[]): Promise<number>;
|
|
178
|
+
xGroupDestroy(key: string, groupName: string): Promise<boolean>;
|
|
179
|
+
XINFO(command: 'GROUPS' | string, key: string): Promise<unknown>;
|
|
180
|
+
XINFO_GROUPS(key: string): Promise<unknown>;
|
|
181
|
+
XLEN(key: string): Promise<number>;
|
|
182
|
+
XPENDING(
|
|
183
|
+
key: string,
|
|
184
|
+
group: string,
|
|
185
|
+
start?: string,
|
|
186
|
+
end?: string,
|
|
187
|
+
count?: number,
|
|
188
|
+
consumer?: string,
|
|
189
|
+
): this;
|
|
164
190
|
ZADD(
|
|
165
191
|
key: string,
|
|
166
192
|
values: { score: string; value: string },
|
|
@@ -200,7 +226,7 @@ interface IORedisClientOptions {
|
|
|
200
226
|
reconnectOnError?: (err: Error) => boolean;
|
|
201
227
|
}
|
|
202
228
|
|
|
203
|
-
interface IORedisClient {
|
|
229
|
+
interface IORedisClient extends ProviderClient {
|
|
204
230
|
multi(): IORedisMultiType;
|
|
205
231
|
exec(): Promise<unknown[]>;
|
|
206
232
|
sendCommand(args: any[]): Promise<any>;
|
|
@@ -223,7 +249,9 @@ interface IORedisClient {
|
|
|
223
249
|
|
|
224
250
|
xadd(key: string, id: string, fields: any, message?: string): Promise<string>;
|
|
225
251
|
xack(key: string, group: string, id: string): Promise<number>;
|
|
252
|
+
xack(key: string, group: string, ...ids: string[]): Promise<number>;
|
|
226
253
|
xdel(key: string, id: string): Promise<number>;
|
|
254
|
+
xdel(key: string, ...ids: string[]): Promise<number>;
|
|
227
255
|
xlen(key: string): Promise<number>;
|
|
228
256
|
xpending(
|
|
229
257
|
key: string,
|
|
@@ -247,6 +275,16 @@ interface IORedisClient {
|
|
|
247
275
|
): Promise<ReclaimedMessageType>;
|
|
248
276
|
xinfo(command: 'GROUPS' | string, key: string): Promise<unknown>;
|
|
249
277
|
xrange(key: string, start: string, end: string): Promise<string[][]>;
|
|
278
|
+
xreadgroup(
|
|
279
|
+
command: 'GROUP',
|
|
280
|
+
groupName: string,
|
|
281
|
+
consumerName: string,
|
|
282
|
+
blockOption: string,
|
|
283
|
+
blockTime: number,
|
|
284
|
+
streamsOption: string,
|
|
285
|
+
streamName: string,
|
|
286
|
+
key: string,
|
|
287
|
+
): Promise<string[][]>;
|
|
250
288
|
del(key: string): Promise<number>;
|
|
251
289
|
exists(key: string): Promise<number>;
|
|
252
290
|
get(key: string): Promise<string | null>;
|
|
@@ -271,22 +309,24 @@ interface IORedisClient {
|
|
|
271
309
|
zrank(key: string, member: string): Promise<number>;
|
|
272
310
|
zscore(key: string, value: string): Promise<number>;
|
|
273
311
|
xgroup(
|
|
274
|
-
command: 'CREATE' | string,
|
|
312
|
+
command: 'CREATE' | 'DESTROY' | string,
|
|
275
313
|
key: string,
|
|
276
314
|
groupName: string,
|
|
277
|
-
id
|
|
315
|
+
id?: string,
|
|
278
316
|
mkStream?: 'MKSTREAM',
|
|
279
|
-
): Promise<string>;
|
|
317
|
+
): Promise<string | number>;
|
|
280
318
|
}
|
|
281
319
|
|
|
282
320
|
type IORedisClassType = new (
|
|
283
321
|
options: IORedisClientOptions,
|
|
284
322
|
...args: any[]
|
|
285
323
|
) => IORedisClient;
|
|
286
|
-
interface IORedisMultiType {
|
|
324
|
+
interface IORedisMultiType extends ProviderTransaction {
|
|
287
325
|
xadd(key: string, id: string, fields: any, message?: string): this;
|
|
288
326
|
xack(key: string, group: string, id: string): this;
|
|
327
|
+
xack(key: string, group: string, ...ids: string[]): this;
|
|
289
328
|
xdel(key: string, id: string): this;
|
|
329
|
+
xdel(key: string, ...ids: string[]): this;
|
|
290
330
|
xlen(key: string): this;
|
|
291
331
|
xpending(
|
|
292
332
|
key: string,
|
|
@@ -340,8 +380,14 @@ function isIORedisClient(client: RedisClient): client is IORedisClient {
|
|
|
340
380
|
return 'pipeline' in client;
|
|
341
381
|
}
|
|
342
382
|
|
|
383
|
+
interface RedisConfig extends ProviderConfig {
|
|
384
|
+
class: Partial<RedisClass>;
|
|
385
|
+
options: Partial<RedisOptions>;
|
|
386
|
+
}
|
|
387
|
+
|
|
343
388
|
export {
|
|
344
389
|
RedisClass,
|
|
390
|
+
RedisConfig,
|
|
345
391
|
RedisRedisClientType,
|
|
346
392
|
RedisRedisClientOptions,
|
|
347
393
|
RedisRedisClassType,
|
|
@@ -353,7 +399,6 @@ export {
|
|
|
353
399
|
IORedisClassType,
|
|
354
400
|
IORedisMultiType,
|
|
355
401
|
RedisOptions,
|
|
356
|
-
MultiResponseFlags,
|
|
357
402
|
isRedisClient,
|
|
358
403
|
isIORedisClient,
|
|
359
404
|
};
|