@upstash/redis 0.0.0-ci.b1b216d3-20230414 → 0.0.0-ci.b3f07153-20231018

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 (39) hide show
  1. package/esm/pkg/commands/geo_add.js +27 -0
  2. package/esm/pkg/commands/geo_dist.js +11 -0
  3. package/esm/pkg/commands/hgetall.js +9 -1
  4. package/esm/pkg/commands/mod.js +5 -0
  5. package/esm/pkg/commands/set.js +1 -1
  6. package/esm/pkg/commands/xadd.js +26 -0
  7. package/esm/pkg/commands/xrange.js +36 -0
  8. package/esm/pkg/commands/zunion.js +30 -0
  9. package/esm/pkg/http.js +16 -9
  10. package/esm/pkg/pipeline.js +32 -8
  11. package/esm/pkg/redis.js +36 -1
  12. package/esm/platforms/nodejs.js +4 -2
  13. package/esm/version.js +1 -1
  14. package/package.json +13 -5
  15. package/script/pkg/commands/geo_add.js +31 -0
  16. package/script/pkg/commands/geo_dist.js +15 -0
  17. package/script/pkg/commands/hgetall.js +9 -1
  18. package/script/pkg/commands/mod.js +5 -0
  19. package/script/pkg/commands/set.js +1 -1
  20. package/script/pkg/commands/xadd.js +30 -0
  21. package/script/pkg/commands/xrange.js +40 -0
  22. package/script/pkg/commands/zunion.js +34 -0
  23. package/script/pkg/http.js +16 -9
  24. package/script/pkg/pipeline.js +31 -7
  25. package/script/pkg/redis.js +35 -0
  26. package/script/platforms/nodejs.js +4 -2
  27. package/script/version.js +1 -1
  28. package/types/pkg/commands/geo_add.d.ts +25 -0
  29. package/types/pkg/commands/geo_dist.d.ts +12 -0
  30. package/types/pkg/commands/hdel.d.ts +1 -1
  31. package/types/pkg/commands/mod.d.ts +5 -0
  32. package/types/pkg/commands/set.d.ts +2 -2
  33. package/types/pkg/commands/xadd.d.ts +31 -0
  34. package/types/pkg/commands/xrange.d.ts +9 -0
  35. package/types/pkg/commands/zunion.d.ts +29 -0
  36. package/types/pkg/http.d.ts +5 -1
  37. package/types/pkg/pipeline.d.ts +241 -150
  38. package/types/pkg/redis.d.ts +42 -4
  39. package/types/version.d.ts +1 -1
@@ -1,7 +1,10 @@
1
- import { DelCommand, ExistsCommand, FlushAllCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMGetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
- import { CommandOptions } from "./commands/command.js";
1
+ import { BitOpCommand, DelCommand, ExistsCommand, FlushAllCommand, JsonGetCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
+ import { Command, CommandOptions } from "./commands/command.js";
3
3
  import { Requester } from "./http.js";
4
4
  import { CommandArgs } from "./types.js";
5
+ type InferResponseData<T extends unknown[]> = {
6
+ [K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
7
+ };
5
8
  /**
6
9
  * Upstash REST API supports command pipelining to send multiple commands in
7
10
  * batch, instead of sending each command one by one and waiting for a response.
@@ -30,7 +33,7 @@ import { CommandArgs } from "./types.js";
30
33
  * const res = await p.set("key","value").get("key").exec()
31
34
  * ```
32
35
  *
33
- * It's not possible to infer correct types with a dynamic pipeline, so you can
36
+ * Return types are inferred if all commands are chained, but you can still
34
37
  * override the response type manually:
35
38
  * ```ts
36
39
  * redis.pipeline()
@@ -40,7 +43,7 @@ import { CommandArgs } from "./types.js";
40
43
  *
41
44
  * ```
42
45
  */
43
- export declare class Pipeline {
46
+ export declare class Pipeline<TCommands extends Command<any, any>[] = []> {
44
47
  private client;
45
48
  private commands;
46
49
  private commandOptions?;
@@ -55,214 +58,220 @@ export declare class Pipeline {
55
58
  *
56
59
  * Returns an array with the results of all pipelined commands.
57
60
  *
58
- * You can define a return type manually to make working in typescript easier
61
+ * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
59
62
  * ```ts
60
- * redis.pipeline().get("key").exec<[{ greeting: string }]>()
63
+ * const p = redis.pipeline()
64
+ * p.get("key")
65
+ * const result = p.exec<[{ greeting: string }]>()
61
66
  * ```
62
67
  */
63
- exec: <TCommandResults extends unknown[] = unknown[]>() => Promise<TCommandResults>;
68
+ exec: <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>() => Promise<TCommandResults>;
64
69
  /**
65
- * Pushes a command into the pipelien and returns a chainable instance of the
70
+ * Returns the length of pipeline before the execution
71
+ */
72
+ length(): number;
73
+ /**
74
+ * Pushes a command into the pipeline and returns a chainable instance of the
66
75
  * pipeline
67
76
  */
68
77
  private chain;
69
78
  /**
70
79
  * @see https://redis.io/commands/append
71
80
  */
72
- append: (key: string, value: string) => this;
81
+ append: (key: string, value: string) => Pipeline<[...TCommands, Command<any, number>]>;
73
82
  /**
74
83
  * @see https://redis.io/commands/bitcount
75
84
  */
76
- bitcount: (key: string, start: number, end: number) => this;
85
+ bitcount: (key: string, start: number, end: number) => Pipeline<[...TCommands, Command<any, number>]>;
77
86
  /**
78
87
  * @see https://redis.io/commands/bitop
79
88
  */
80
89
  bitop: {
81
- (op: "and" | "or" | "xor", destinationKey: string, sourceKey: string, ...sourceKeys: string[]): Pipeline;
82
- (op: "not", destinationKey: string, sourceKey: string): Pipeline;
90
+ (op: "and" | "or" | "xor", destinationKey: string, sourceKey: string, ...sourceKeys: string[]): Pipeline<[...TCommands, BitOpCommand]>;
91
+ (op: "not", destinationKey: string, sourceKey: string): Pipeline<[...TCommands, BitOpCommand]>;
83
92
  };
84
93
  /**
85
94
  * @see https://redis.io/commands/bitpos
86
95
  */
87
- bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => this;
96
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
88
97
  /**
89
98
  * @see https://redis.io/commands/zdiffstore
90
99
  */
91
- zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => this;
100
+ zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => Pipeline<[...TCommands, Command<any, number>]>;
92
101
  /**
93
102
  * @see https://redis.io/commands/dbsize
94
103
  */
95
- dbsize: () => this;
104
+ dbsize: () => Pipeline<[...TCommands, Command<any, number>]>;
96
105
  /**
97
106
  * @see https://redis.io/commands/decr
98
107
  */
99
- decr: (key: string) => this;
108
+ decr: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
100
109
  /**
101
110
  * @see https://redis.io/commands/decrby
102
111
  */
103
- decrby: (key: string, decrement: number) => this;
112
+ decrby: (key: string, decrement: number) => Pipeline<[...TCommands, Command<any, number>]>;
104
113
  /**
105
114
  * @see https://redis.io/commands/del
106
115
  */
107
- del: (...args: CommandArgs<typeof DelCommand>) => this;
116
+ del: (...args: CommandArgs<typeof DelCommand>) => Pipeline<[...TCommands, Command<any, number>]>;
108
117
  /**
109
118
  * @see https://redis.io/commands/echo
110
119
  */
111
- echo: (message: string) => this;
120
+ echo: (message: string) => Pipeline<[...TCommands, Command<any, string>]>;
112
121
  /**
113
122
  * @see https://redis.io/commands/eval
114
123
  */
115
- eval: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => this;
124
+ eval: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
116
125
  /**
117
126
  * @see https://redis.io/commands/evalsha
118
127
  */
119
- evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => this;
128
+ evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
120
129
  /**
121
130
  * @see https://redis.io/commands/exists
122
131
  */
123
- exists: (...args: CommandArgs<typeof ExistsCommand>) => this;
132
+ exists: (...args: CommandArgs<typeof ExistsCommand>) => Pipeline<[...TCommands, Command<any, number>]>;
124
133
  /**
125
134
  * @see https://redis.io/commands/expire
126
135
  */
127
- expire: (key: string, seconds: number) => this;
136
+ expire: (key: string, seconds: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
128
137
  /**
129
138
  * @see https://redis.io/commands/expireat
130
139
  */
131
- expireat: (key: string, unix: number) => this;
140
+ expireat: (key: string, unix: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
132
141
  /**
133
142
  * @see https://redis.io/commands/flushall
134
143
  */
135
- flushall: (args?: CommandArgs<typeof FlushAllCommand>) => this;
144
+ flushall: (args?: CommandArgs<typeof FlushAllCommand>) => Pipeline<[...TCommands, Command<any, "OK">]>;
136
145
  /**
137
146
  * @see https://redis.io/commands/flushdb
138
147
  */
139
148
  flushdb: (opts?: {
140
149
  async?: boolean | undefined;
141
- } | undefined) => this;
150
+ } | undefined) => Pipeline<[...TCommands, Command<any, "OK">]>;
142
151
  /**
143
152
  * @see https://redis.io/commands/get
144
153
  */
145
- get: <TData>(key: string) => this;
154
+ get: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
146
155
  /**
147
156
  * @see https://redis.io/commands/getbit
148
157
  */
149
- getbit: (key: string, offset: number) => this;
158
+ getbit: (key: string, offset: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
150
159
  /**
151
160
  * @see https://redis.io/commands/getdel
152
161
  */
153
- getdel: <TData>(key: string) => this;
162
+ getdel: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
154
163
  /**
155
164
  * @see https://redis.io/commands/getrange
156
165
  */
157
- getrange: (key: string, start: number, end: number) => this;
166
+ getrange: (key: string, start: number, end: number) => Pipeline<[...TCommands, Command<any, string>]>;
158
167
  /**
159
168
  * @see https://redis.io/commands/getset
160
169
  */
161
- getset: <TData>(key: string, value: TData) => this;
170
+ getset: <TData>(key: string, value: TData) => Pipeline<[...TCommands, Command<any, TData | null>]>;
162
171
  /**
163
172
  * @see https://redis.io/commands/hdel
164
173
  */
165
- hdel: (key: string, field: string) => this;
174
+ hdel: (key: string, ...fields: string[]) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
166
175
  /**
167
176
  * @see https://redis.io/commands/hexists
168
177
  */
169
- hexists: (key: string, field: string) => this;
178
+ hexists: (key: string, field: string) => Pipeline<[...TCommands, Command<any, number>]>;
170
179
  /**
171
180
  * @see https://redis.io/commands/hget
172
181
  */
173
- hget: <TData>(key: string, field: string) => this;
182
+ hget: <TData>(key: string, field: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
174
183
  /**
175
184
  * @see https://redis.io/commands/hgetall
176
185
  */
177
- hgetall: <TData extends Record<string, unknown>>(key: string) => this;
186
+ hgetall: <TData extends Record<string, unknown>>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
178
187
  /**
179
188
  * @see https://redis.io/commands/hincrby
180
189
  */
181
- hincrby: (key: string, field: string, increment: number) => this;
190
+ hincrby: (key: string, field: string, increment: number) => Pipeline<[...TCommands, Command<any, number>]>;
182
191
  /**
183
192
  * @see https://redis.io/commands/hincrbyfloat
184
193
  */
185
- hincrbyfloat: (key: string, field: string, increment: number) => this;
194
+ hincrbyfloat: (key: string, field: string, increment: number) => Pipeline<[...TCommands, Command<any, number>]>;
186
195
  /**
187
196
  * @see https://redis.io/commands/hkeys
188
197
  */
189
- hkeys: (key: string) => this;
198
+ hkeys: (key: string) => Pipeline<[...TCommands, Command<any, string[]>]>;
190
199
  /**
191
200
  * @see https://redis.io/commands/hlen
192
201
  */
193
- hlen: (key: string) => this;
202
+ hlen: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
194
203
  /**
195
204
  * @see https://redis.io/commands/hmget
196
205
  */
197
- hmget: <TData extends Record<string, unknown>>(key: string, ...fields: string[]) => this;
206
+ hmget: <TData extends Record<string, unknown>>(key: string, ...fields: string[]) => Pipeline<[...TCommands, Command<any, TData | null>]>;
198
207
  /**
199
208
  * @see https://redis.io/commands/hmset
200
209
  */
201
210
  hmset: <TData>(key: string, kv: {
202
211
  [field: string]: TData;
203
- }) => this;
212
+ }) => Pipeline<[...TCommands, Command<any, "OK">]>;
204
213
  /**
205
214
  * @see https://redis.io/commands/hrandfield
206
215
  */
207
- hrandfield: <TData extends string | string[] | Record<string, unknown>>(key: string, count?: number, withValues?: boolean) => this;
216
+ hrandfield: <TData extends string | string[] | Record<string, unknown>>(key: string, count?: number, withValues?: boolean) => Pipeline<[...TCommands, Command<any, TData>]>;
208
217
  /**
209
218
  * @see https://redis.io/commands/hscan
210
219
  */
211
- hscan: (key: string, cursor: number, cmdOpts?: import("./commands/scan.js").ScanCommandOptions | undefined) => this;
220
+ hscan: (key: string, cursor: number, cmdOpts?: import("./commands/scan.js").ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, [number, (string | number)[]]>]>;
212
221
  /**
213
222
  * @see https://redis.io/commands/hset
214
223
  */
215
224
  hset: <TData>(key: string, kv: {
216
225
  [field: string]: TData;
217
- }) => this;
226
+ }) => Pipeline<[...TCommands, Command<any, number>]>;
218
227
  /**
219
228
  * @see https://redis.io/commands/hsetnx
220
229
  */
221
- hsetnx: <TData>(key: string, field: string, value: TData) => this;
230
+ hsetnx: <TData>(key: string, field: string, value: TData) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
222
231
  /**
223
232
  * @see https://redis.io/commands/hstrlen
224
233
  */
225
- hstrlen: (key: string, field: string) => this;
234
+ hstrlen: (key: string, field: string) => Pipeline<[...TCommands, Command<any, number>]>;
226
235
  /**
227
236
  * @see https://redis.io/commands/hvals
228
237
  */
229
- hvals: (key: string) => this;
238
+ hvals: (key: string) => Pipeline<[...TCommands, Command<any, any>]>;
230
239
  /**
231
240
  * @see https://redis.io/commands/incr
232
241
  */
233
- incr: (key: string) => this;
242
+ incr: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
234
243
  /**
235
244
  * @see https://redis.io/commands/incrby
236
245
  */
237
- incrby: (key: string, value: number) => this;
246
+ incrby: (key: string, value: number) => Pipeline<[...TCommands, Command<any, number>]>;
238
247
  /**
239
248
  * @see https://redis.io/commands/incrbyfloat
240
249
  */
241
- incrbyfloat: (key: string, value: number) => this;
250
+ incrbyfloat: (key: string, value: number) => Pipeline<[...TCommands, Command<any, number>]>;
242
251
  /**
243
252
  * @see https://redis.io/commands/keys
244
253
  */
245
- keys: (pattern: string) => this;
254
+ keys: (pattern: string) => Pipeline<[...TCommands, Command<any, string[]>]>;
246
255
  /**
247
256
  * @see https://redis.io/commands/lindex
248
257
  */
249
- lindex: (key: string, index: number) => this;
258
+ lindex: (key: string, index: number) => Pipeline<[...TCommands, Command<any, any>]>;
250
259
  /**
251
260
  * @see https://redis.io/commands/linsert
252
261
  */
253
- linsert: <TData>(key: string, direction: "before" | "after", pivot: TData, value: TData) => Pipeline;
262
+ linsert: <TData>(key: string, direction: "before" | "after", pivot: TData, value: TData) => Pipeline<[...TCommands, Command<any, number>]>;
254
263
  /**
255
264
  * @see https://redis.io/commands/llen
256
265
  */
257
- llen: (key: string) => this;
266
+ llen: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
258
267
  /**
259
268
  * @see https://redis.io/commands/lmove
260
269
  */
261
- lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => this;
270
+ lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => Pipeline<[...TCommands, Command<any, TData>]>;
262
271
  /**
263
272
  * @see https://redis.io/commands/lpop
264
273
  */
265
- lpop: <TData>(key: string, count?: number | undefined) => this;
274
+ lpop: <TData>(key: string, count?: number | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
266
275
  /**
267
276
  * @see https://redis.io/commands/lpos
268
277
  */
@@ -270,256 +279,256 @@ export declare class Pipeline {
270
279
  rank?: number | undefined;
271
280
  count?: number | undefined;
272
281
  maxLen?: number | undefined;
273
- } | undefined) => this;
282
+ } | undefined) => Pipeline<[...TCommands, Command<any, TData>]>;
274
283
  /**
275
284
  * @see https://redis.io/commands/lpush
276
285
  */
277
- lpush: <TData>(key: string, ...elements: TData[]) => this;
286
+ lpush: <TData>(key: string, ...elements: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
278
287
  /**
279
288
  * @see https://redis.io/commands/lpushx
280
289
  */
281
- lpushx: <TData>(key: string, ...elements: TData[]) => this;
290
+ lpushx: <TData>(key: string, ...elements: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
282
291
  /**
283
292
  * @see https://redis.io/commands/lrange
284
293
  */
285
- lrange: <TResult = string>(key: string, start: number, end: number) => this;
294
+ lrange: <TResult = string>(key: string, start: number, end: number) => Pipeline<[...TCommands, Command<any, TResult[]>]>;
286
295
  /**
287
296
  * @see https://redis.io/commands/lrem
288
297
  */
289
- lrem: <TData>(key: string, count: number, value: TData) => this;
298
+ lrem: <TData>(key: string, count: number, value: TData) => Pipeline<[...TCommands, Command<any, number>]>;
290
299
  /**
291
300
  * @see https://redis.io/commands/lset
292
301
  */
293
- lset: <TData>(key: string, index: number, value: TData) => this;
302
+ lset: <TData>(key: string, index: number, value: TData) => Pipeline<[...TCommands, Command<any, "OK">]>;
294
303
  /**
295
304
  * @see https://redis.io/commands/ltrim
296
305
  */
297
- ltrim: (key: string, start: number, end: number) => this;
306
+ ltrim: (key: string, start: number, end: number) => Pipeline<[...TCommands, Command<any, "OK">]>;
298
307
  /**
299
308
  * @see https://redis.io/commands/mget
300
309
  */
301
- mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => this;
310
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => Pipeline<[...TCommands, Command<any, TData>]>;
302
311
  /**
303
312
  * @see https://redis.io/commands/mset
304
313
  */
305
314
  mset: <TData>(kv: {
306
315
  [key: string]: TData;
307
- }) => this;
316
+ }) => Pipeline<[...TCommands, Command<any, "OK">]>;
308
317
  /**
309
318
  * @see https://redis.io/commands/msetnx
310
319
  */
311
320
  msetnx: <TData>(kv: {
312
321
  [key: string]: TData;
313
- }) => this;
322
+ }) => Pipeline<[...TCommands, Command<any, number>]>;
314
323
  /**
315
324
  * @see https://redis.io/commands/persist
316
325
  */
317
- persist: (key: string) => this;
326
+ persist: (key: string) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
318
327
  /**
319
328
  * @see https://redis.io/commands/pexpire
320
329
  */
321
- pexpire: (key: string, milliseconds: number) => this;
330
+ pexpire: (key: string, milliseconds: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
322
331
  /**
323
332
  * @see https://redis.io/commands/pexpireat
324
333
  */
325
- pexpireat: (key: string, unix: number) => this;
334
+ pexpireat: (key: string, unix: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
326
335
  /**
327
336
  * @see https://redis.io/commands/ping
328
337
  */
329
- ping: (args?: CommandArgs<typeof PingCommand>) => this;
338
+ ping: (args?: CommandArgs<typeof PingCommand>) => Pipeline<[...TCommands, Command<any, string>]>;
330
339
  /**
331
340
  * @see https://redis.io/commands/psetex
332
341
  */
333
- psetex: <TData>(key: string, ttl: number, value: TData) => this;
342
+ psetex: <TData>(key: string, ttl: number, value: TData) => Pipeline<[...TCommands, Command<any, string>]>;
334
343
  /**
335
344
  * @see https://redis.io/commands/pttl
336
345
  */
337
- pttl: (key: string) => this;
346
+ pttl: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
338
347
  /**
339
348
  * @see https://redis.io/commands/publish
340
349
  */
341
- publish: (channel: string, message: unknown) => this;
350
+ publish: (channel: string, message: unknown) => Pipeline<[...TCommands, Command<any, number>]>;
342
351
  /**
343
352
  * @see https://redis.io/commands/randomkey
344
353
  */
345
- randomkey: () => this;
354
+ randomkey: () => Pipeline<[...TCommands, Command<any, string | null>]>;
346
355
  /**
347
356
  * @see https://redis.io/commands/rename
348
357
  */
349
- rename: (source: string, destination: string) => this;
358
+ rename: (source: string, destination: string) => Pipeline<[...TCommands, Command<any, "OK">]>;
350
359
  /**
351
360
  * @see https://redis.io/commands/renamenx
352
361
  */
353
- renamenx: (source: string, destination: string) => this;
362
+ renamenx: (source: string, destination: string) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
354
363
  /**
355
364
  * @see https://redis.io/commands/rpop
356
365
  */
357
- rpop: <TData = string>(key: string, count?: number | undefined) => this;
366
+ rpop: <TData = string>(key: string, count?: number | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
358
367
  /**
359
368
  * @see https://redis.io/commands/rpush
360
369
  */
361
- rpush: <TData>(key: string, ...elements: TData[]) => this;
370
+ rpush: <TData>(key: string, ...elements: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
362
371
  /**
363
372
  * @see https://redis.io/commands/rpushx
364
373
  */
365
- rpushx: <TData>(key: string, ...elements: TData[]) => this;
374
+ rpushx: <TData>(key: string, ...elements: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
366
375
  /**
367
376
  * @see https://redis.io/commands/sadd
368
377
  */
369
- sadd: <TData>(key: string, ...members: TData[]) => this;
378
+ sadd: <TData>(key: string, ...members: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
370
379
  /**
371
380
  * @see https://redis.io/commands/scan
372
381
  */
373
- scan: (cursor: number, opts?: import("./commands/scan.js").ScanCommandOptions | undefined) => this;
382
+ scan: (cursor: number, opts?: import("./commands/scan.js").ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, [number, string[]]>]>;
374
383
  /**
375
384
  * @see https://redis.io/commands/scard
376
385
  */
377
- scard: (key: string) => this;
386
+ scard: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
378
387
  /**
379
388
  * @see https://redis.io/commands/script-exists
380
389
  */
381
- scriptExists: (...args: CommandArgs<typeof ScriptExistsCommand>) => this;
390
+ scriptExists: (...args: CommandArgs<typeof ScriptExistsCommand>) => Pipeline<[...TCommands, Command<any, number[]>]>;
382
391
  /**
383
392
  * @see https://redis.io/commands/script-flush
384
393
  */
385
- scriptFlush: (opts?: import("./commands/script_flush.js").ScriptFlushCommandOptions | undefined) => this;
394
+ scriptFlush: (opts?: import("./commands/script_flush.js").ScriptFlushCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, "OK">]>;
386
395
  /**
387
396
  * @see https://redis.io/commands/script-load
388
397
  */
389
- scriptLoad: (script: string) => this;
390
- sdiff: (key: string, ...keys: string[]) => this;
398
+ scriptLoad: (script: string) => Pipeline<[...TCommands, Command<any, string>]>;
399
+ sdiff: (key: string, ...keys: string[]) => Pipeline<[...TCommands, Command<any, unknown[]>]>;
391
400
  /**
392
401
  * @see https://redis.io/commands/sdiffstore
393
402
  */
394
- sdiffstore: (destination: string, ...keys: string[]) => this;
403
+ sdiffstore: (destination: string, ...keys: string[]) => Pipeline<[...TCommands, Command<any, number>]>;
395
404
  /**
396
405
  * @see https://redis.io/commands/set
397
406
  */
398
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => this;
407
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => Pipeline<[...TCommands, Command<any, "OK" | TData | null>]>;
399
408
  /**
400
409
  * @see https://redis.io/commands/setbit
401
410
  */
402
- setbit: (key: string, offset: number, value: 0 | 1) => this;
411
+ setbit: (key: string, offset: number, value: 0 | 1) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
403
412
  /**
404
413
  * @see https://redis.io/commands/setex
405
414
  */
406
- setex: <TData>(key: string, ttl: number, value: TData) => this;
415
+ setex: <TData>(key: string, ttl: number, value: TData) => Pipeline<[...TCommands, Command<any, "OK">]>;
407
416
  /**
408
417
  * @see https://redis.io/commands/setnx
409
418
  */
410
- setnx: <TData>(key: string, value: TData) => this;
419
+ setnx: <TData>(key: string, value: TData) => Pipeline<[...TCommands, Command<any, number>]>;
411
420
  /**
412
421
  * @see https://redis.io/commands/setrange
413
422
  */
414
- setrange: (key: string, offset: number, value: string) => this;
423
+ setrange: (key: string, offset: number, value: string) => Pipeline<[...TCommands, Command<any, number>]>;
415
424
  /**
416
425
  * @see https://redis.io/commands/sinter
417
426
  */
418
- sinter: (key: string, ...keys: string[]) => this;
427
+ sinter: (key: string, ...keys: string[]) => Pipeline<[...TCommands, Command<any, string[]>]>;
419
428
  /**
420
429
  * @see https://redis.io/commands/sinterstore
421
430
  */
422
- sinterstore: (destination: string, key: string, ...keys: string[]) => this;
431
+ sinterstore: (destination: string, key: string, ...keys: string[]) => Pipeline<[...TCommands, Command<any, number>]>;
423
432
  /**
424
433
  * @see https://redis.io/commands/sismember
425
434
  */
426
- sismember: <TData>(key: string, member: TData) => this;
435
+ sismember: <TData>(key: string, member: TData) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
427
436
  /**
428
437
  * @see https://redis.io/commands/smembers
429
438
  */
430
- smembers: <TData extends unknown[] = string[]>(key: string) => this;
439
+ smembers: <TData extends unknown[] = string[]>(key: string) => Pipeline<[...TCommands, Command<any, TData>]>;
431
440
  /**
432
441
  * @see https://redis.io/commands/smismember
433
442
  */
434
- smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => this;
443
+ smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => Pipeline<[...TCommands, Command<any, (0 | 1)[]>]>;
435
444
  /**
436
445
  * @see https://redis.io/commands/smove
437
446
  */
438
- smove: <TData>(source: string, destination: string, member: TData) => this;
447
+ smove: <TData>(source: string, destination: string, member: TData) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
439
448
  /**
440
449
  * @see https://redis.io/commands/spop
441
450
  */
442
- spop: <TData>(key: string, count?: number | undefined) => this;
451
+ spop: <TData>(key: string, count?: number | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
443
452
  /**
444
453
  * @see https://redis.io/commands/srandmember
445
454
  */
446
- srandmember: <TData>(key: string, count?: number | undefined) => this;
455
+ srandmember: <TData>(key: string, count?: number | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
447
456
  /**
448
457
  * @see https://redis.io/commands/srem
449
458
  */
450
- srem: <TData>(key: string, ...members: TData[]) => this;
459
+ srem: <TData>(key: string, ...members: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
451
460
  /**
452
461
  * @see https://redis.io/commands/sscan
453
462
  */
454
- sscan: (key: string, cursor: number, opts?: import("./commands/scan.js").ScanCommandOptions | undefined) => this;
463
+ sscan: (key: string, cursor: number, opts?: import("./commands/scan.js").ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, [number, (string | number)[]]>]>;
455
464
  /**
456
465
  * @see https://redis.io/commands/strlen
457
466
  */
458
- strlen: (key: string) => this;
467
+ strlen: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
459
468
  /**
460
469
  * @see https://redis.io/commands/sunion
461
470
  */
462
- sunion: (key: string, ...keys: string[]) => this;
471
+ sunion: (key: string, ...keys: string[]) => Pipeline<[...TCommands, Command<any, unknown[]>]>;
463
472
  /**
464
473
  * @see https://redis.io/commands/sunionstore
465
474
  */
466
- sunionstore: (destination: string, key: string, ...keys: string[]) => this;
475
+ sunionstore: (destination: string, key: string, ...keys: string[]) => Pipeline<[...TCommands, Command<any, number>]>;
467
476
  /**
468
477
  * @see https://redis.io/commands/time
469
478
  */
470
- time: () => this;
479
+ time: () => Pipeline<[...TCommands, Command<any, [number, number]>]>;
471
480
  /**
472
481
  * @see https://redis.io/commands/touch
473
482
  */
474
- touch: (...args: CommandArgs<typeof TouchCommand>) => this;
483
+ touch: (...args: CommandArgs<typeof TouchCommand>) => Pipeline<[...TCommands, Command<any, number>]>;
475
484
  /**
476
485
  * @see https://redis.io/commands/ttl
477
486
  */
478
- ttl: (key: string) => this;
487
+ ttl: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
479
488
  /**
480
489
  * @see https://redis.io/commands/type
481
490
  */
482
- type: (key: string) => this;
491
+ type: (key: string) => Pipeline<[...TCommands, Command<any, import("./commands/type.js").Type>]>;
483
492
  /**
484
493
  * @see https://redis.io/commands/unlink
485
494
  */
486
- unlink: (...args: CommandArgs<typeof UnlinkCommand>) => this;
495
+ unlink: (...args: CommandArgs<typeof UnlinkCommand>) => Pipeline<[...TCommands, Command<any, number>]>;
487
496
  /**
488
497
  * @see https://redis.io/commands/zadd
489
498
  */
490
- zadd: <TData>(...args: [key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]] | [string, ZAddCommandOptions | ZAddCommandOptionsWithIncr, ScoreMember<TData>, ...ScoreMember<TData>[]]) => this;
499
+ zadd: <TData>(...args: [key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]] | [string, ZAddCommandOptions | ZAddCommandOptionsWithIncr, ScoreMember<TData>, ...ScoreMember<TData>[]]) => Pipeline<[...TCommands, Command<any, number | null>]>;
491
500
  /**
492
501
  * @see https://redis.io/commands/zcard
493
502
  */
494
- zcard: (key: string) => this;
503
+ zcard: (key: string) => Pipeline<[...TCommands, Command<any, number>]>;
495
504
  /**
496
505
  * @see https://redis.io/commands/zcount
497
506
  */
498
- zcount: (key: string, min: string | number, max: string | number) => this;
507
+ zcount: (key: string, min: string | number, max: string | number) => Pipeline<[...TCommands, Command<any, number>]>;
499
508
  /**
500
509
  * @see https://redis.io/commands/zincrby
501
510
  */
502
- zincrby: <TData>(key: string, increment: number, member: TData) => this;
511
+ zincrby: <TData>(key: string, increment: number, member: TData) => Pipeline<[...TCommands, Command<any, number>]>;
503
512
  /**
504
513
  * @see https://redis.io/commands/zinterstore
505
514
  */
506
- zinterstore: (destination: string, numKeys: number, keys: string[], opts?: import("./commands/zinterstore.js").ZInterStoreCommandOptions | undefined) => this;
515
+ zinterstore: (destination: string, numKeys: number, keys: string[], opts?: import("./commands/zinterstore.js").ZInterStoreCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
507
516
  /**
508
517
  * @see https://redis.io/commands/zlexcount
509
518
  */
510
- zlexcount: (key: string, min: string, max: string) => this;
519
+ zlexcount: (key: string, min: string, max: string) => Pipeline<[...TCommands, Command<any, number>]>;
511
520
  /**
512
521
  * @see https://redis.io/commands/zmscore
513
522
  */
514
- zmscore: (key: string, members: unknown[]) => this;
523
+ zmscore: (key: string, members: unknown[]) => Pipeline<[...TCommands, Command<any, number[] | null>]>;
515
524
  /**
516
525
  * @see https://redis.io/commands/zpopmax
517
526
  */
518
- zpopmax: <TData>(key: string, count?: number | undefined) => this;
527
+ zpopmax: <TData>(key: string, count?: number | undefined) => Pipeline<[...TCommands, Command<any, TData[]>]>;
519
528
  /**
520
529
  * @see https://redis.io/commands/zpopmin
521
530
  */
522
- zpopmin: <TData>(key: string, count?: number | undefined) => this;
531
+ zpopmin: <TData>(key: string, count?: number | undefined) => Pipeline<[...TCommands, Command<any, TData[]>]>;
523
532
  /**
524
533
  * @see https://redis.io/commands/zrange
525
534
  */
@@ -537,67 +546,149 @@ export declare class Pipeline {
537
546
  opts: {
538
547
  byScore: true;
539
548
  } & ZRangeCommandOptions
540
- ]) => this;
549
+ ]) => Pipeline<[...TCommands, Command<any, TData>]>;
541
550
  /**
542
551
  * @see https://redis.io/commands/zrank
543
552
  */
544
- zrank: <TData>(key: string, member: TData) => this;
553
+ zrank: <TData>(key: string, member: TData) => Pipeline<[...TCommands, Command<any, number | null>]>;
545
554
  /**
546
555
  * @see https://redis.io/commands/zrem
547
556
  */
548
- zrem: <TData>(key: string, ...members: TData[]) => this;
557
+ zrem: <TData>(key: string, ...members: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
549
558
  /**
550
559
  * @see https://redis.io/commands/zremrangebylex
551
560
  */
552
- zremrangebylex: (key: string, min: string, max: string) => this;
561
+ zremrangebylex: (key: string, min: string, max: string) => Pipeline<[...TCommands, Command<any, number>]>;
553
562
  /**
554
563
  * @see https://redis.io/commands/zremrangebyrank
555
564
  */
556
- zremrangebyrank: (key: string, start: number, stop: number) => this;
565
+ zremrangebyrank: (key: string, start: number, stop: number) => Pipeline<[...TCommands, Command<any, number>]>;
557
566
  /**
558
567
  * @see https://redis.io/commands/zremrangebyscore
559
568
  */
560
- zremrangebyscore: (key: string, min: number, max: number) => this;
569
+ zremrangebyscore: (key: string, min: number, max: number) => Pipeline<[...TCommands, Command<any, number>]>;
561
570
  /**
562
571
  * @see https://redis.io/commands/zrevrank
563
572
  */
564
- zrevrank: <TData>(key: string, member: TData) => this;
573
+ zrevrank: <TData>(key: string, member: TData) => Pipeline<[...TCommands, Command<any, number | null>]>;
565
574
  /**
566
575
  * @see https://redis.io/commands/zscan
567
576
  */
568
- zscan: (key: string, cursor: number, opts?: import("./commands/scan.js").ScanCommandOptions | undefined) => this;
577
+ zscan: (key: string, cursor: number, opts?: import("./commands/scan.js").ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, [number, (string | number)[]]>]>;
569
578
  /**
570
579
  * @see https://redis.io/commands/zscore
571
580
  */
572
- zscore: <TData>(key: string, member: TData) => this;
581
+ zscore: <TData>(key: string, member: TData) => Pipeline<[...TCommands, Command<any, number | null>]>;
573
582
  /**
574
583
  * @see https://redis.io/commands/zunionstore
575
584
  */
576
- zunionstore: (destination: string, numKeys: number, keys: string[], opts?: import("./commands/zunionstore.js").ZUnionStoreCommandOptions | undefined) => this;
585
+ zunionstore: (destination: string, numKeys: number, keys: string[], opts?: import("./commands/zunionstore.js").ZUnionStoreCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
586
+ /**
587
+ * @see https://redis.io/commands/zunion
588
+ */
589
+ zunion: (numKeys: number, keys: string[], opts?: import("./commands/zunion.js").ZUnionCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, any>]>;
577
590
  /**
578
591
  * @see https://redis.io/commands/?group=json
579
592
  */
580
593
  get json(): {
581
- arrappend: (...args: CommandArgs<typeof JsonArrAppendCommand>) => Pipeline;
582
- arrindex: (...args: CommandArgs<typeof JsonArrIndexCommand>) => Pipeline;
583
- arrinsert: (...args: CommandArgs<typeof JsonArrInsertCommand>) => Pipeline;
584
- arrlen: (...args: CommandArgs<typeof JsonArrLenCommand>) => Pipeline;
585
- arrpop: (...args: CommandArgs<typeof JsonArrPopCommand>) => Pipeline;
586
- arrtrim: (...args: CommandArgs<typeof JsonArrTrimCommand>) => Pipeline;
587
- clear: (...args: CommandArgs<typeof JsonClearCommand>) => Pipeline;
588
- del: (...args: CommandArgs<typeof JsonDelCommand>) => Pipeline;
589
- forget: (...args: CommandArgs<typeof JsonForgetCommand>) => Pipeline;
590
- get: (...args: CommandArgs<typeof JsonGetCommand>) => Pipeline;
591
- mget: (...args: CommandArgs<typeof JsonMGetCommand>) => Pipeline;
592
- numincrby: (...args: CommandArgs<typeof JsonNumIncrByCommand>) => Pipeline;
593
- nummultby: (...args: CommandArgs<typeof JsonNumMultByCommand>) => Pipeline;
594
- objkeys: (...args: CommandArgs<typeof JsonObjKeysCommand>) => Pipeline;
595
- objlen: (...args: CommandArgs<typeof JsonObjLenCommand>) => Pipeline;
596
- resp: (...args: CommandArgs<typeof JsonRespCommand>) => Pipeline;
597
- set: (...args: CommandArgs<typeof JsonSetCommand>) => Pipeline;
598
- strappend: (...args: CommandArgs<typeof JsonStrAppendCommand>) => Pipeline;
599
- strlen: (...args: CommandArgs<typeof JsonStrLenCommand>) => Pipeline;
600
- toggle: (...args: CommandArgs<typeof JsonToggleCommand>) => Pipeline;
601
- type: (...args: CommandArgs<typeof JsonTypeCommand>) => Pipeline;
594
+ /**
595
+ * @see https://redis.io/commands/json.arrappend
596
+ */
597
+ arrappend: (key: string, path: string, ...values: unknown[]) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
598
+ /**
599
+ * @see https://redis.io/commands/json.arrindex
600
+ */
601
+ arrindex: (key: string, path: string, value: unknown, start?: number | undefined, stop?: number | undefined) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
602
+ /**
603
+ * @see https://redis.io/commands/json.arrinsert
604
+ */
605
+ arrinsert: (key: string, path: string, index: number, ...values: unknown[]) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
606
+ /**
607
+ * @see https://redis.io/commands/json.arrlen
608
+ */
609
+ arrlen: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
610
+ /**
611
+ * @see https://redis.io/commands/json.arrpop
612
+ */
613
+ arrpop: (key: string, path?: string | undefined, index?: number | undefined) => Pipeline<[...TCommands, Command<any, unknown[]>]>;
614
+ /**
615
+ * @see https://redis.io/commands/json.arrtrim
616
+ */
617
+ arrtrim: (key: string, path?: string | undefined, start?: number | undefined, stop?: number | undefined) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
618
+ /**
619
+ * @see https://redis.io/commands/json.clear
620
+ */
621
+ clear: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
622
+ /**
623
+ * @see https://redis.io/commands/json.del
624
+ */
625
+ del: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
626
+ /**
627
+ * @see https://redis.io/commands/json.forget
628
+ */
629
+ forget: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
630
+ /**
631
+ * @see https://redis.io/commands/geoadd
632
+ */
633
+ geoadd: (args_0: string, args_1: import("./commands/geo_add.js").GeoAddCommandOptions | import("./commands/geo_add.js").GeoMember<unknown>, ...args_2: import("./commands/geo_add.js").GeoMember<unknown>[]) => Promise<number | null>;
634
+ /**
635
+ * @see https://redis.io/commands/geodist
636
+ */
637
+ geodist: (key: string, member1: string, member2: string, unit?: "M" | "KM" | "FT" | "MI" | undefined) => Promise<number | null>;
638
+ /**
639
+ * @see https://redis.io/commands/json.get
640
+ */
641
+ get: (...args: CommandArgs<typeof JsonGetCommand>) => Pipeline<[...TCommands, Command<any, any>]>;
642
+ /**
643
+ * @see https://redis.io/commands/json.mget
644
+ */
645
+ mget: (keys: string[], path: string) => Pipeline<[...TCommands, Command<any, any>]>;
646
+ /**
647
+ * @see https://redis.io/commands/json.numincrby
648
+ */
649
+ numincrby: (key: string, path: string, value: number) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
650
+ /**
651
+ * @see https://redis.io/commands/json.nummultby
652
+ */
653
+ nummultby: (key: string, path: string, value: number) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
654
+ /**
655
+ * @see https://redis.io/commands/json.objkeys
656
+ */
657
+ objkeys: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, (string[] | null)[]>]>;
658
+ /**
659
+ * @see https://redis.io/commands/json.objlen
660
+ */
661
+ objlen: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
662
+ /**
663
+ * @see https://redis.io/commands/json.resp
664
+ */
665
+ resp: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, any>]>;
666
+ /**
667
+ * @see https://redis.io/commands/json.set
668
+ */
669
+ set: (key: string, path: string, value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[], opts?: {
670
+ nx: true;
671
+ xx?: undefined;
672
+ } | {
673
+ nx?: undefined;
674
+ xx: true;
675
+ } | undefined) => Pipeline<[...TCommands, Command<any, "OK" | null>]>;
676
+ /**
677
+ * @see https://redis.io/commands/json.strappend
678
+ */
679
+ strappend: (key: string, path: string, value: string) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
680
+ /**
681
+ * @see https://redis.io/commands/json.strlen
682
+ */
683
+ strlen: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, (number | null)[]>]>;
684
+ /**
685
+ * @see https://redis.io/commands/json.toggle
686
+ */
687
+ toggle: (key: string, path: string) => Pipeline<[...TCommands, Command<any, number[]>]>;
688
+ /**
689
+ * @see https://redis.io/commands/json.type
690
+ */
691
+ type: (key: string, path?: string | undefined) => Pipeline<[...TCommands, Command<any, string[]>]>;
602
692
  };
603
693
  }
694
+ export {};