ioredis-om 5.10.2

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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1571 -0
  3. package/built/Command.d.ts +166 -0
  4. package/built/Command.js +450 -0
  5. package/built/DataHandler.d.ts +37 -0
  6. package/built/DataHandler.js +224 -0
  7. package/built/Pipeline.d.ts +31 -0
  8. package/built/Pipeline.js +342 -0
  9. package/built/Redis.d.ts +243 -0
  10. package/built/Redis.js +800 -0
  11. package/built/ScanStream.d.ts +23 -0
  12. package/built/ScanStream.js +51 -0
  13. package/built/Script.d.ts +11 -0
  14. package/built/Script.js +62 -0
  15. package/built/SubscriptionSet.d.ts +14 -0
  16. package/built/SubscriptionSet.js +41 -0
  17. package/built/autoPipelining.d.ts +8 -0
  18. package/built/autoPipelining.js +167 -0
  19. package/built/cluster/ClusterOptions.d.ts +172 -0
  20. package/built/cluster/ClusterOptions.js +22 -0
  21. package/built/cluster/ClusterSubscriber.d.ts +29 -0
  22. package/built/cluster/ClusterSubscriber.js +223 -0
  23. package/built/cluster/ClusterSubscriberGroup.d.ts +108 -0
  24. package/built/cluster/ClusterSubscriberGroup.js +373 -0
  25. package/built/cluster/ConnectionPool.d.ts +37 -0
  26. package/built/cluster/ConnectionPool.js +154 -0
  27. package/built/cluster/DelayQueue.d.ts +20 -0
  28. package/built/cluster/DelayQueue.js +53 -0
  29. package/built/cluster/ShardedSubscriber.d.ts +36 -0
  30. package/built/cluster/ShardedSubscriber.js +147 -0
  31. package/built/cluster/index.d.ts +163 -0
  32. package/built/cluster/index.js +937 -0
  33. package/built/cluster/util.d.ts +25 -0
  34. package/built/cluster/util.js +100 -0
  35. package/built/connectors/AbstractConnector.d.ts +12 -0
  36. package/built/connectors/AbstractConnector.js +26 -0
  37. package/built/connectors/ConnectorConstructor.d.ts +5 -0
  38. package/built/connectors/ConnectorConstructor.js +2 -0
  39. package/built/connectors/SentinelConnector/FailoverDetector.d.ts +11 -0
  40. package/built/connectors/SentinelConnector/FailoverDetector.js +45 -0
  41. package/built/connectors/SentinelConnector/SentinelIterator.d.ts +13 -0
  42. package/built/connectors/SentinelConnector/SentinelIterator.js +37 -0
  43. package/built/connectors/SentinelConnector/index.d.ts +72 -0
  44. package/built/connectors/SentinelConnector/index.js +305 -0
  45. package/built/connectors/SentinelConnector/types.d.ts +21 -0
  46. package/built/connectors/SentinelConnector/types.js +2 -0
  47. package/built/connectors/StandaloneConnector.d.ts +17 -0
  48. package/built/connectors/StandaloneConnector.js +69 -0
  49. package/built/connectors/index.d.ts +3 -0
  50. package/built/connectors/index.js +7 -0
  51. package/built/constants/TLSProfiles.d.ts +9 -0
  52. package/built/constants/TLSProfiles.js +149 -0
  53. package/built/errors/ClusterAllFailedError.d.ts +7 -0
  54. package/built/errors/ClusterAllFailedError.js +15 -0
  55. package/built/errors/MaxRetriesPerRequestError.d.ts +5 -0
  56. package/built/errors/MaxRetriesPerRequestError.js +14 -0
  57. package/built/errors/index.d.ts +2 -0
  58. package/built/errors/index.js +5 -0
  59. package/built/index.d.ts +44 -0
  60. package/built/index.js +62 -0
  61. package/built/redis/RedisOptions.d.ts +197 -0
  62. package/built/redis/RedisOptions.js +58 -0
  63. package/built/redis/event_handler.d.ts +4 -0
  64. package/built/redis/event_handler.js +315 -0
  65. package/built/tracing.d.ts +26 -0
  66. package/built/tracing.js +96 -0
  67. package/built/transaction.d.ts +13 -0
  68. package/built/transaction.js +100 -0
  69. package/built/types.d.ts +33 -0
  70. package/built/types.js +2 -0
  71. package/built/utils/Commander.d.ts +50 -0
  72. package/built/utils/Commander.js +117 -0
  73. package/built/utils/RedisCommander.d.ts +8950 -0
  74. package/built/utils/RedisCommander.js +7 -0
  75. package/built/utils/applyMixin.d.ts +3 -0
  76. package/built/utils/applyMixin.js +8 -0
  77. package/built/utils/argumentParsers.d.ts +14 -0
  78. package/built/utils/argumentParsers.js +74 -0
  79. package/built/utils/debug.d.ts +16 -0
  80. package/built/utils/debug.js +95 -0
  81. package/built/utils/index.d.ts +124 -0
  82. package/built/utils/index.js +332 -0
  83. package/built/utils/lodash.d.ts +4 -0
  84. package/built/utils/lodash.js +9 -0
  85. package/package.json +103 -0
@@ -0,0 +1,243 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from "events";
3
+ import Cluster from "./cluster";
4
+ import Command from "./Command";
5
+ import { DataHandledable, FlushQueueOptions, Condition } from "./DataHandler";
6
+ import { RedisOptions } from "./redis/RedisOptions";
7
+ import ScanStream from "./ScanStream";
8
+ import { Transaction } from "./transaction";
9
+ import { Callback, CommandItem, NetStream, ScanStreamOptions, WriteableStream } from "./types";
10
+ import { type BatchOperationContext } from "./tracing";
11
+ import Commander from "./utils/Commander";
12
+ import Deque = require("denque");
13
+ declare type RedisStatus = "wait" | "reconnecting" | "connecting" | "connect" | "ready" | "close" | "end";
14
+ /**
15
+ * This is the major component of ioredis-om.
16
+ * Use it to connect to a standalone Redis server or Sentinels.
17
+ *
18
+ * ```typescript
19
+ * const redis = new Redis(); // Default port is 6379
20
+ * async function main() {
21
+ * redis.set("foo", "bar");
22
+ * redis.get("foo", (err, result) => {
23
+ * // `result` should be "bar"
24
+ * console.log(err, result);
25
+ * });
26
+ * // Or use Promise
27
+ * const result = await redis.get("foo");
28
+ * }
29
+ * ```
30
+ */
31
+ declare class Redis extends Commander implements DataHandledable {
32
+ static Cluster: typeof Cluster;
33
+ static Command: typeof Command;
34
+ /**
35
+ * Default options
36
+ */
37
+ private static defaultOptions;
38
+ /**
39
+ * Create a Redis instance.
40
+ * This is the same as `new Redis()` but is included for compatibility with node-redis.
41
+ */
42
+ static createClient(...args: ConstructorParameters<typeof Redis>): Redis;
43
+ options: RedisOptions;
44
+ status: RedisStatus;
45
+ /**
46
+ * @ignore
47
+ */
48
+ stream: NetStream;
49
+ /**
50
+ * @ignore
51
+ */
52
+ isCluster: boolean;
53
+ /**
54
+ * @ignore
55
+ */
56
+ condition: Condition | null;
57
+ /**
58
+ * @ignore
59
+ */
60
+ commandQueue: Deque<CommandItem>;
61
+ private connector;
62
+ private reconnectTimeout;
63
+ private offlineQueue;
64
+ private connectionEpoch;
65
+ private retryAttempts;
66
+ private manuallyClosing;
67
+ private socketTimeoutTimer;
68
+ private _autoPipelines;
69
+ private _runningAutoPipelines;
70
+ constructor(port: number, host: string, options: RedisOptions);
71
+ constructor(path: string, options: RedisOptions);
72
+ constructor(port: number, options: RedisOptions);
73
+ constructor(port: number, host: string);
74
+ constructor(options: RedisOptions);
75
+ constructor(port: number);
76
+ constructor(path: string);
77
+ constructor();
78
+ get autoPipelineQueueSize(): number;
79
+ /**
80
+ * Create a connection to Redis.
81
+ * This method will be invoked automatically when creating a new Redis instance
82
+ * unless `lazyConnect: true` is passed.
83
+ *
84
+ * When calling this method manually, a Promise is returned, which will
85
+ * be resolved when the connection status is ready. The promise can reject
86
+ * if the connection fails, times out, or if Redis is already connecting/connected.
87
+ */
88
+ connect(callback?: Callback<void>): Promise<void>;
89
+ private _connect;
90
+ /**
91
+ * Disconnect from Redis.
92
+ *
93
+ * This method closes the connection immediately,
94
+ * and may lose some pending replies that haven't written to client.
95
+ * If you want to wait for the pending replies, use Redis#quit instead.
96
+ */
97
+ disconnect(reconnect?: boolean): void;
98
+ /**
99
+ * Disconnect from Redis.
100
+ *
101
+ * @deprecated
102
+ */
103
+ end(): void;
104
+ /**
105
+ * Create a new instance with the same options as the current one.
106
+ *
107
+ * @example
108
+ * ```js
109
+ * var redis = new Redis(6380);
110
+ * var anotherRedis = redis.duplicate();
111
+ * ```
112
+ */
113
+ duplicate(override?: Partial<RedisOptions>): Redis;
114
+ /**
115
+ * Mode of the connection.
116
+ *
117
+ * One of `"normal"`, `"subscriber"`, or `"monitor"`. When the connection is
118
+ * not in `"normal"` mode, certain commands are not allowed.
119
+ */
120
+ get mode(): "normal" | "subscriber" | "monitor";
121
+ /**
122
+ * Listen for all requests received by the server in real time.
123
+ *
124
+ * This command will create a new connection to Redis and send a
125
+ * MONITOR command via the new connection in order to avoid disturbing
126
+ * the current connection.
127
+ *
128
+ * @param callback The callback function. If omit, a promise will be returned.
129
+ * @example
130
+ * ```js
131
+ * var redis = new Redis();
132
+ * redis.monitor(function (err, monitor) {
133
+ * // Entering monitoring mode.
134
+ * monitor.on('monitor', function (time, args, source, database) {
135
+ * console.log(time + ": " + util.inspect(args));
136
+ * });
137
+ * });
138
+ *
139
+ * // supports promise as well as other commands
140
+ * redis.monitor().then(function (monitor) {
141
+ * monitor.on('monitor', function (time, args, source, database) {
142
+ * console.log(time + ": " + util.inspect(args));
143
+ * });
144
+ * });
145
+ * ```
146
+ */
147
+ monitor(callback?: Callback<Redis>): Promise<Redis>;
148
+ /**
149
+ * Send a command to Redis
150
+ *
151
+ * This method is used internally and in most cases you should not
152
+ * use it directly. If you need to send a command that is not supported
153
+ * by the library, you can use the `call` method:
154
+ *
155
+ * ```js
156
+ * const redis = new Redis();
157
+ *
158
+ * redis.call('set', 'foo', 'bar');
159
+ * // or
160
+ * redis.call(['set', 'foo', 'bar']);
161
+ * ```
162
+ *
163
+ * @ignore
164
+ */
165
+ sendCommand(command: Command, stream?: WriteableStream): unknown;
166
+ private getBlockingTimeoutInMs;
167
+ private getConfiguredBlockingTimeout;
168
+ private setSocketTimeout;
169
+ scanStream(options?: ScanStreamOptions): ScanStream;
170
+ scanBufferStream(options?: ScanStreamOptions): ScanStream;
171
+ sscanStream(key: string, options?: ScanStreamOptions): ScanStream;
172
+ sscanBufferStream(key: string, options?: ScanStreamOptions): ScanStream;
173
+ hscanStream(key: string, options?: ScanStreamOptions): ScanStream;
174
+ hscanBufferStream(key: string, options?: ScanStreamOptions): ScanStream;
175
+ zscanStream(key: string, options?: ScanStreamOptions): ScanStream;
176
+ zscanBufferStream(key: string, options?: ScanStreamOptions): ScanStream;
177
+ /**
178
+ * Emit only when there's at least one listener.
179
+ *
180
+ * @ignore
181
+ */
182
+ silentEmit(eventName: string, arg?: unknown): boolean;
183
+ /**
184
+ * @ignore
185
+ */
186
+ recoverFromFatalError(_commandError: Error, err: Error, options: FlushQueueOptions): void;
187
+ /**
188
+ * @ignore
189
+ */
190
+ handleReconnection(err: Error, item: CommandItem): void;
191
+ /**
192
+ * @ignore
193
+ */
194
+ _getServerAddress(): {
195
+ address: string;
196
+ port: number | undefined;
197
+ };
198
+ private _buildCommandContext;
199
+ _buildBatchContext(batchSize: number): BatchOperationContext;
200
+ /**
201
+ * Get description of the connection. Used for debugging.
202
+ */
203
+ private _getDescription;
204
+ private resetCommandQueue;
205
+ private resetOfflineQueue;
206
+ private parseOptions;
207
+ /**
208
+ * Change instance's status
209
+ */
210
+ private setStatus;
211
+ private createScanStream;
212
+ /**
213
+ * Flush offline queue and command queue with error.
214
+ *
215
+ * @param error The error object to send to the commands
216
+ * @param options options
217
+ */
218
+ private flushQueue;
219
+ /**
220
+ * Check whether Redis has finished loading the persistent data and is able to
221
+ * process commands.
222
+ */
223
+ private _readyCheck;
224
+ }
225
+ interface Redis extends EventEmitter {
226
+ on(event: "message", cb: (channel: string, message: string) => void): this;
227
+ once(event: "message", cb: (channel: string, message: string) => void): this;
228
+ on(event: "messageBuffer", cb: (channel: Buffer, message: Buffer) => void): this;
229
+ once(event: "messageBuffer", cb: (channel: Buffer, message: Buffer) => void): this;
230
+ on(event: "pmessage", cb: (pattern: string, channel: string, message: string) => void): this;
231
+ once(event: "pmessage", cb: (pattern: string, channel: string, message: string) => void): this;
232
+ on(event: "pmessageBuffer", cb: (pattern: string, channel: Buffer, message: Buffer) => void): this;
233
+ once(event: "pmessageBuffer", cb: (pattern: string, channel: Buffer, message: Buffer) => void): this;
234
+ on(event: "error", cb: (error: Error) => void): this;
235
+ once(event: "error", cb: (error: Error) => void): this;
236
+ on(event: RedisStatus, cb: () => void): this;
237
+ once(event: RedisStatus, cb: () => void): this;
238
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
239
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
240
+ }
241
+ interface Redis extends Transaction {
242
+ }
243
+ export default Redis;