@upstash/redis 0.0.0-ci.c00b02de3221a40eb48a9e0e9fecd434abda4dc2-20240704001524 → 0.0.0-ci.c2204f830cf3ca85c9f85a7dc63bd93a0e228f4b-20250403110828

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.
@@ -26,6 +26,7 @@ type RedisOptions = {
26
26
  latencyLogging?: boolean;
27
27
  enableTelemetry?: boolean;
28
28
  enableAutoPipelining?: boolean;
29
+ readYourWrites?: boolean;
29
30
  };
30
31
 
31
32
  type CacheSetting = "default" | "force-cache" | "no-cache" | "no-store" | "only-if-cached" | "reload";
@@ -35,12 +36,37 @@ type UpstashRequest = {
35
36
  * Request body will be serialized to json
36
37
  */
37
38
  body?: unknown;
39
+ /**
40
+ * Additional headers for the request
41
+ */
42
+ headers?: Record<string, string>;
43
+ upstashSyncToken?: string;
44
+ /**
45
+ * Callback for handling streaming messages
46
+ */
47
+ onMessage?: (data: string) => void;
48
+ /**
49
+ * Whether this request expects a streaming response
50
+ */
51
+ isStreaming?: boolean;
52
+ /**
53
+ * Abort signal for the request
54
+ */
55
+ signal?: AbortSignal;
38
56
  };
39
57
  type UpstashResponse<TResult> = {
40
58
  result?: TResult;
41
59
  error?: string;
42
60
  };
43
61
  interface Requester {
62
+ /**
63
+ * When this flag is enabled, any subsequent commands issued by this client are guaranteed to observe the effects of all earlier writes submitted by the same client.
64
+ */
65
+ readYourWrites?: boolean;
66
+ /**
67
+ * This token is used to ensure that the client is in sync with the server. On each request, we send this token in the header, and the server will return a new token.
68
+ */
69
+ upstashSyncToken?: string;
44
70
  request: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>;
45
71
  }
46
72
  type RetryConfig = false | {
@@ -109,6 +135,31 @@ type CommandOptions<TResult, TData> = {
109
135
  */
110
136
  automaticDeserialization?: boolean;
111
137
  latencyLogging?: boolean;
138
+ /**
139
+ * Additional headers to be sent with the request
140
+ */
141
+ headers?: Record<string, string>;
142
+ /**
143
+ * Path to append to the URL
144
+ */
145
+ path?: string[];
146
+ /**
147
+ * Options for streaming requests, mainly used for subscribe, monitor commands
148
+ **/
149
+ streamOptions?: {
150
+ /**
151
+ * Callback to be called when a message is received
152
+ */
153
+ onMessage?: (data: string) => void;
154
+ /**
155
+ * Whether the request is streaming
156
+ */
157
+ isStreaming?: boolean;
158
+ /**
159
+ * Signal to abort the request
160
+ */
161
+ signal?: AbortSignal;
162
+ };
112
163
  };
113
164
  /**
114
165
  * Command offers default (de)serialization and the exec method to all commands.
@@ -120,6 +171,11 @@ declare class Command<TResult, TData> {
120
171
  readonly command: (string | number | boolean)[];
121
172
  readonly serialize: Serialize;
122
173
  readonly deserialize: Deserialize<TResult, TData>;
174
+ protected readonly headers?: Record<string, string>;
175
+ protected readonly path?: string[];
176
+ protected readonly onMessage?: (data: string) => void;
177
+ protected readonly isStreaming: boolean;
178
+ protected readonly signal?: AbortSignal;
123
179
  /**
124
180
  * Create a new command instance.
125
181
  *
@@ -132,8 +188,7 @@ declare class Command<TResult, TData> {
132
188
  exec(client: Requester): Promise<TData>;
133
189
  }
134
190
 
135
- type ZUnionCommandOptions = {
136
- withScores?: boolean;
191
+ type ZUnionStoreCommandOptions = {
137
192
  aggregate?: "sum" | "min" | "max";
138
193
  } & ({
139
194
  weight: number;
@@ -146,14 +201,15 @@ type ZUnionCommandOptions = {
146
201
  weights?: never;
147
202
  });
148
203
  /**
149
- * @see https://redis.io/commands/zunion
204
+ * @see https://redis.io/commands/zunionstore
150
205
  */
151
- declare class ZUnionCommand<TData extends unknown[]> extends Command<string[], TData> {
152
- constructor(cmd: [numKeys: 1, key: string, opts?: ZUnionCommandOptions], cmdOpts?: CommandOptions<string[], TData>);
153
- constructor(cmd: [numKeys: number, keys: string[], opts?: ZUnionCommandOptions], cmdOpts?: CommandOptions<string[], TData>);
206
+ declare class ZUnionStoreCommand extends Command<number, number> {
207
+ constructor(cmd: [destination: string, numKeys: 1, key: string, opts?: ZUnionStoreCommandOptions], cmdOpts?: CommandOptions<number, number>);
208
+ constructor(cmd: [destination: string, numKeys: number, keys: string[], opts?: ZUnionStoreCommandOptions], cmdOpts?: CommandOptions<number, number>);
154
209
  }
155
210
 
156
- type ZUnionStoreCommandOptions = {
211
+ type ZUnionCommandOptions = {
212
+ withScores?: boolean;
157
213
  aggregate?: "sum" | "min" | "max";
158
214
  } & ({
159
215
  weight: number;
@@ -166,11 +222,11 @@ type ZUnionStoreCommandOptions = {
166
222
  weights?: never;
167
223
  });
168
224
  /**
169
- * @see https://redis.io/commands/zunionstore
225
+ * @see https://redis.io/commands/zunion
170
226
  */
171
- declare class ZUnionStoreCommand extends Command<number, number> {
172
- constructor(cmd: [destination: string, numKeys: 1, key: string, opts?: ZUnionStoreCommandOptions], cmdOpts?: CommandOptions<number, number>);
173
- constructor(cmd: [destination: string, numKeys: number, keys: string[], opts?: ZUnionStoreCommandOptions], cmdOpts?: CommandOptions<number, number>);
227
+ declare class ZUnionCommand<TData extends unknown[]> extends Command<string[], TData> {
228
+ constructor(cmd: [numKeys: 1, key: string, opts?: ZUnionCommandOptions], cmdOpts?: CommandOptions<string[], TData>);
229
+ constructor(cmd: [numKeys: number, keys: string[], opts?: ZUnionCommandOptions], cmdOpts?: CommandOptions<string[], TData>);
174
230
  }
175
231
 
176
232
  type ZInterStoreCommandOptions = {
@@ -236,11 +292,11 @@ type GeoAddCommandOptions = {
236
292
  } & {
237
293
  ch?: boolean;
238
294
  });
239
- interface GeoMember<TMemberType> {
295
+ type GeoMember<TMemberType> = {
240
296
  latitude: number;
241
297
  longitude: number;
242
298
  member: TMemberType;
243
- }
299
+ };
244
300
  /**
245
301
  * @see https://redis.io/commands/geoadd
246
302
  */
@@ -270,7 +326,7 @@ declare class BitCountCommand extends Command<number, number> {
270
326
  type SubCommandArgs<TRest extends unknown[] = []> = [
271
327
  encoding: string,
272
328
  offset: number | string,
273
- ...TRest
329
+ ...rest: TRest
274
330
  ];
275
331
  /**
276
332
  * @see https://redis.io/commands/bitfield
@@ -348,6 +404,13 @@ declare class EchoCommand extends Command<string, string> {
348
404
  constructor(cmd: [message: string], opts?: CommandOptions<string, string>);
349
405
  }
350
406
 
407
+ /**
408
+ * @see https://redis.io/commands/eval_ro
409
+ */
410
+ declare class EvalROCommand<TArgs extends unknown[], TData> extends Command<unknown, TData> {
411
+ constructor([script, keys, args]: [script: string, keys: string[], args: TArgs], opts?: CommandOptions<unknown, TData>);
412
+ }
413
+
351
414
  /**
352
415
  * @see https://redis.io/commands/eval
353
416
  */
@@ -355,6 +418,13 @@ declare class EvalCommand<TArgs extends unknown[], TData> extends Command<unknow
355
418
  constructor([script, keys, args]: [script: string, keys: string[], args: TArgs], opts?: CommandOptions<unknown, TData>);
356
419
  }
357
420
 
421
+ /**
422
+ * @see https://redis.io/commands/evalsha_ro
423
+ */
424
+ declare class EvalshaROCommand<TArgs extends unknown[], TData> extends Command<unknown, TData> {
425
+ constructor([sha, keys, args]: [sha: string, keys: string[], args?: TArgs], opts?: CommandOptions<unknown, TData>);
426
+ }
427
+
358
428
  /**
359
429
  * @see https://redis.io/commands/evalsha
360
430
  */
@@ -415,7 +485,7 @@ declare class GeoDistCommand<TMemberType = string> extends Command<number | null
415
485
  * @see https://redis.io/commands/geohash
416
486
  */
417
487
  declare class GeoHashCommand<TMember = string> extends Command<(string | null)[], (string | null)[]> {
418
- constructor(cmd: [string, ...(TMember[] | TMember[])], opts?: CommandOptions<(string | null)[], (string | null)[]>);
488
+ constructor(cmd: [string, ...TMember[]], opts?: CommandOptions<(string | null)[], (string | null)[]>);
419
489
  }
420
490
 
421
491
  type Coordinates = {
@@ -553,6 +623,50 @@ declare class GetDelCommand<TData = string> extends Command<unknown | null, TDat
553
623
  constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
554
624
  }
555
625
 
626
+ type GetExCommandOptions = {
627
+ ex: number;
628
+ px?: never;
629
+ exat?: never;
630
+ pxat?: never;
631
+ persist?: never;
632
+ } | {
633
+ ex?: never;
634
+ px: number;
635
+ exat?: never;
636
+ pxat?: never;
637
+ persist?: never;
638
+ } | {
639
+ ex?: never;
640
+ px?: never;
641
+ exat: number;
642
+ pxat?: never;
643
+ persist?: never;
644
+ } | {
645
+ ex?: never;
646
+ px?: never;
647
+ exat?: never;
648
+ pxat: number;
649
+ persist?: never;
650
+ } | {
651
+ ex?: never;
652
+ px?: never;
653
+ exat?: never;
654
+ pxat?: never;
655
+ persist: true;
656
+ } | {
657
+ ex?: never;
658
+ px?: never;
659
+ exat?: never;
660
+ pxat?: never;
661
+ persist?: never;
662
+ };
663
+ /**
664
+ * @see https://redis.io/commands/getex
665
+ */
666
+ declare class GetExCommand<TData = string> extends Command<unknown | null, TData | null> {
667
+ constructor([key, opts]: [key: string, opts?: GetExCommandOptions], cmdOpts?: CommandOptions<unknown | null, TData | null>);
668
+ }
669
+
556
670
  /**
557
671
  * @see https://redis.io/commands/getrange
558
672
  */
@@ -642,9 +756,7 @@ declare class HMGetCommand<TData extends Record<string, unknown>> extends Comman
642
756
  * @see https://redis.io/commands/hmset
643
757
  */
644
758
  declare class HMSetCommand<TData> extends Command<"OK", "OK"> {
645
- constructor([key, kv]: [key: string, kv: {
646
- [field: string]: TData;
647
- }], opts?: CommandOptions<"OK", "OK">);
759
+ constructor([key, kv]: [key: string, kv: Record<string, TData>], opts?: CommandOptions<"OK", "OK">);
648
760
  }
649
761
 
650
762
  /**
@@ -673,9 +785,7 @@ declare class HScanCommand extends Command<[
673
785
  * @see https://redis.io/commands/hset
674
786
  */
675
787
  declare class HSetCommand<TData> extends Command<number, number> {
676
- constructor([key, kv]: [key: string, kv: {
677
- [field: string]: TData;
678
- }], opts?: CommandOptions<number, number>);
788
+ constructor([key, kv]: [key: string, kv: Record<string, TData>], opts?: CommandOptions<number, number>);
679
789
  }
680
790
 
681
791
  /**
@@ -798,6 +908,13 @@ declare class JsonGetCommand<TData extends (unknown | Record<string, unknown>) |
798
908
  ] | [key: string, ...path: string[]], opts?: CommandOptions<TData | null, TData | null>);
799
909
  }
800
910
 
911
+ /**
912
+ * @see https://redis.io/commands/json.merge
913
+ */
914
+ declare class JsonMergeCommand<TData extends string | number | Record<string, unknown> | Array<unknown>> extends Command<"OK" | null, "OK" | null> {
915
+ constructor(cmd: [key: string, path: string, value: TData], opts?: CommandOptions<"OK" | null, "OK" | null>);
916
+ }
917
+
801
918
  /**
802
919
  * @see https://redis.io/commands/json.mget
803
920
  */
@@ -805,6 +922,17 @@ declare class JsonMGetCommand<TData = unknown[]> extends Command<TData, TData> {
805
922
  constructor(cmd: [keys: string[], path: string], opts?: CommandOptions<TData, TData>);
806
923
  }
807
924
 
925
+ /**
926
+ * @see https://redis.io/commands/json.mset
927
+ */
928
+ declare class JsonMSetCommand<TData extends number | string | boolean | Record<string, unknown> | (number | string | boolean | Record<string, unknown>)[]> extends Command<"OK" | null, "OK" | null> {
929
+ constructor(cmd: {
930
+ key: string;
931
+ path: string;
932
+ value: TData;
933
+ }[], opts?: CommandOptions<"OK" | null, "OK" | null>);
934
+ }
935
+
808
936
  /**
809
937
  * @see https://redis.io/commands/json.numincrby
810
938
  */
@@ -961,25 +1089,21 @@ declare class LTrimCommand extends Command<"OK", "OK"> {
961
1089
  * @see https://redis.io/commands/mget
962
1090
  */
963
1091
  declare class MGetCommand<TData extends unknown[]> extends Command<(string | null)[], TData> {
964
- constructor(cmd: [string[]] | [...(string[] | string[])], opts?: CommandOptions<(string | null)[], TData>);
1092
+ constructor(cmd: [string[]] | [...string[]], opts?: CommandOptions<(string | null)[], TData>);
965
1093
  }
966
1094
 
967
1095
  /**
968
1096
  * @see https://redis.io/commands/mset
969
1097
  */
970
1098
  declare class MSetCommand<TData> extends Command<"OK", "OK"> {
971
- constructor([kv]: [kv: {
972
- [key: string]: TData;
973
- }], opts?: CommandOptions<"OK", "OK">);
1099
+ constructor([kv]: [kv: Record<string, TData>], opts?: CommandOptions<"OK", "OK">);
974
1100
  }
975
1101
 
976
1102
  /**
977
1103
  * @see https://redis.io/commands/msetnx
978
1104
  */
979
1105
  declare class MSetNXCommand<TData = string> extends Command<number, number> {
980
- constructor([kv]: [kv: {
981
- [key: string]: TData;
982
- }], opts?: CommandOptions<number, number>);
1106
+ constructor([kv]: [kv: Record<string, TData>], opts?: CommandOptions<number, number>);
983
1107
  }
984
1108
 
985
1109
  /**
@@ -1077,7 +1201,7 @@ declare class RPushXCommand<TData = string> extends Command<number, number> {
1077
1201
  * @see https://redis.io/commands/sadd
1078
1202
  */
1079
1203
  declare class SAddCommand<TData = string> extends Command<number, number> {
1080
- constructor(cmd: [key: string, ...members: TData[]], opts?: CommandOptions<number, number>);
1204
+ constructor(cmd: [key: string, member: TData, ...members: TData[]], opts?: CommandOptions<number, number>);
1081
1205
  }
1082
1206
 
1083
1207
  /**
@@ -1346,9 +1470,7 @@ declare class XAddCommand extends Command<string, string> {
1346
1470
  constructor([key, id, entries, opts]: [
1347
1471
  key: string,
1348
1472
  id: "*" | string,
1349
- entries: {
1350
- [field: string]: unknown;
1351
- },
1473
+ entries: Record<string, unknown>,
1352
1474
  opts?: XAddCommandOptions
1353
1475
  ], commandOptions?: CommandOptions<string, string>);
1354
1476
  }
@@ -1588,9 +1710,78 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
1588
1710
  constructor(cmd: [key: string, member: TData], opts?: CommandOptions<string | null, number | null>);
1589
1711
  }
1590
1712
 
1713
+ type BaseMessageData<TMessage> = {
1714
+ channel: string;
1715
+ message: TMessage;
1716
+ };
1717
+ type PatternMessageData<TMessage> = BaseMessageData<TMessage> & {
1718
+ pattern: string;
1719
+ };
1720
+ type SubscriptionCountEvent = number;
1721
+ type MessageEventMap<TMessage> = {
1722
+ message: BaseMessageData<TMessage>;
1723
+ subscribe: SubscriptionCountEvent;
1724
+ unsubscribe: SubscriptionCountEvent;
1725
+ pmessage: PatternMessageData<TMessage>;
1726
+ psubscribe: SubscriptionCountEvent;
1727
+ punsubscribe: SubscriptionCountEvent;
1728
+ error: Error;
1729
+ [key: `message:${string}`]: BaseMessageData<TMessage>;
1730
+ [key: `pmessage:${string}`]: PatternMessageData<TMessage>;
1731
+ };
1732
+ type EventType = keyof MessageEventMap<any>;
1733
+ type Listener<TMessage, T extends EventType> = (event: MessageEventMap<TMessage>[T]) => void;
1734
+ declare class Subscriber<TMessage = any> extends EventTarget {
1735
+ private subscriptions;
1736
+ private client;
1737
+ private listeners;
1738
+ constructor(client: Requester, channels: string[], isPattern?: boolean);
1739
+ private subscribeToChannel;
1740
+ private subscribeToPattern;
1741
+ private handleMessage;
1742
+ private dispatchToListeners;
1743
+ on<T extends keyof MessageEventMap<TMessage>>(type: T, listener: Listener<TMessage, T>): void;
1744
+ removeAllListeners(): void;
1745
+ unsubscribe(channels?: string[]): Promise<void>;
1746
+ getSubscribedChannels(): string[];
1747
+ }
1748
+
1591
1749
  type InferResponseData<T extends unknown[]> = {
1592
1750
  [K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
1593
1751
  };
1752
+ interface ExecMethod<TCommands extends Command<any, any>[]> {
1753
+ /**
1754
+ * Send the pipeline request to upstash.
1755
+ *
1756
+ * Returns an array with the results of all pipelined commands.
1757
+ *
1758
+ * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
1759
+ * ```ts
1760
+ * const p = redis.pipeline()
1761
+ * p.get("key")
1762
+ * const result = p.exec<[{ greeting: string }]>()
1763
+ * ```
1764
+ *
1765
+ * If one of the commands get an error, the whole pipeline fails. Alternatively, you can set the keepErrors option to true in order to get the errors individually.
1766
+ *
1767
+ * If keepErrors is set to true, a list of objects is returned where each object corresponds to a command and is of type: `{ result: unknown, error?: string }`.
1768
+ *
1769
+ * ```ts
1770
+ * const p = redis.pipeline()
1771
+ * p.get("key")
1772
+ *
1773
+ * const result = await p.exec({ keepErrors: true });
1774
+ * const getResult = result[0].result
1775
+ * const getError = result[0].error
1776
+ * ```
1777
+ */
1778
+ <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(): Promise<TCommandResults>;
1779
+ <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(options: {
1780
+ keepErrors: true;
1781
+ }): Promise<{
1782
+ [K in keyof TCommandResults]: UpstashResponse<TCommandResults[K]>;
1783
+ }>;
1784
+ }
1594
1785
  /**
1595
1786
  * Upstash REST API supports command pipelining to send multiple commands in
1596
1787
  * batch, instead of sending each command one by one and waiting for a response.
@@ -1639,19 +1830,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1639
1830
  commandOptions?: CommandOptions<any, any>;
1640
1831
  multiExec?: boolean;
1641
1832
  });
1642
- /**
1643
- * Send the pipeline request to upstash.
1644
- *
1645
- * Returns an array with the results of all pipelined commands.
1646
- *
1647
- * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
1648
- * ```ts
1649
- * const p = redis.pipeline()
1650
- * p.get("key")
1651
- * const result = p.exec<[{ greeting: string }]>()
1652
- * ```
1653
- */
1654
- exec: <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>() => Promise<TCommandResults>;
1833
+ exec: ExecMethod<TCommands>;
1655
1834
  /**
1656
1835
  * Returns the length of pipeline before the execution
1657
1836
  */
@@ -1727,10 +1906,18 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1727
1906
  * @see https://redis.io/commands/echo
1728
1907
  */
1729
1908
  echo: (message: string) => Pipeline<[...TCommands, Command<any, string>]>;
1909
+ /**
1910
+ * @see https://redis.io/commands/eval_ro
1911
+ */
1912
+ evalRo: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
1730
1913
  /**
1731
1914
  * @see https://redis.io/commands/eval
1732
1915
  */
1733
1916
  eval: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
1917
+ /**
1918
+ * @see https://redis.io/commands/evalsha_ro
1919
+ */
1920
+ evalshaRo: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
1734
1921
  /**
1735
1922
  * @see https://redis.io/commands/evalsha
1736
1923
  */
@@ -1755,7 +1942,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1755
1942
  * @see https://redis.io/commands/flushdb
1756
1943
  */
1757
1944
  flushdb: (opts?: {
1758
- async?: boolean | undefined;
1945
+ async?: boolean;
1759
1946
  } | undefined) => Pipeline<[...TCommands, Command<any, "OK">]>;
1760
1947
  /**
1761
1948
  * @see https://redis.io/commands/geoadd
@@ -1802,11 +1989,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1802
1989
  }, order: "ASC" | "DESC" | "asc" | "desc", opts?: {
1803
1990
  count?: {
1804
1991
  limit: number;
1805
- any?: boolean | undefined;
1806
- } | undefined;
1807
- withCoord?: boolean | undefined;
1808
- withDist?: boolean | undefined;
1809
- withHash?: boolean | undefined;
1992
+ any?: boolean;
1993
+ };
1994
+ withCoord?: boolean;
1995
+ withDist?: boolean;
1996
+ withHash?: boolean;
1810
1997
  } | undefined) => Pipeline<[...TCommands, Command<any, ({
1811
1998
  member: TData;
1812
1999
  } & {
@@ -1843,9 +2030,9 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1843
2030
  }, order: "ASC" | "DESC" | "asc" | "desc", opts?: {
1844
2031
  count?: {
1845
2032
  limit: number;
1846
- any?: boolean | undefined;
1847
- } | undefined;
1848
- storeDist?: boolean | undefined;
2033
+ any?: boolean;
2034
+ };
2035
+ storeDist?: boolean;
1849
2036
  } | undefined) => Pipeline<[...TCommands, Command<any, number>]>;
1850
2037
  /**
1851
2038
  * @see https://redis.io/commands/get
@@ -1859,6 +2046,46 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1859
2046
  * @see https://redis.io/commands/getdel
1860
2047
  */
1861
2048
  getdel: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
2049
+ /**
2050
+ * @see https://redis.io/commands/getex
2051
+ */
2052
+ getex: <TData>(key: string, opts?: ({
2053
+ ex: number;
2054
+ px?: never;
2055
+ exat?: never;
2056
+ pxat?: never;
2057
+ persist?: never;
2058
+ } | {
2059
+ ex?: never;
2060
+ px: number;
2061
+ exat?: never;
2062
+ pxat?: never;
2063
+ persist?: never;
2064
+ } | {
2065
+ ex?: never;
2066
+ px?: never;
2067
+ exat: number;
2068
+ pxat?: never;
2069
+ persist?: never;
2070
+ } | {
2071
+ ex?: never;
2072
+ px?: never;
2073
+ exat?: never;
2074
+ pxat: number;
2075
+ persist?: never;
2076
+ } | {
2077
+ ex?: never;
2078
+ px?: never;
2079
+ exat?: never;
2080
+ pxat?: never;
2081
+ persist: true;
2082
+ } | {
2083
+ ex?: never;
2084
+ px?: never;
2085
+ exat?: never;
2086
+ pxat?: never;
2087
+ persist?: never;
2088
+ }) | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
1862
2089
  /**
1863
2090
  * @see https://redis.io/commands/getrange
1864
2091
  */
@@ -1906,13 +2133,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1906
2133
  /**
1907
2134
  * @see https://redis.io/commands/hmset
1908
2135
  */
1909
- hmset: <TData>(key: string, kv: {
1910
- [field: string]: TData;
1911
- }) => Pipeline<[...TCommands, Command<any, "OK">]>;
2136
+ hmset: <TData>(key: string, kv: Record<string, TData>) => Pipeline<[...TCommands, Command<any, "OK">]>;
1912
2137
  /**
1913
2138
  * @see https://redis.io/commands/hrandfield
1914
2139
  */
1915
- hrandfield: <TData extends string | Record<string, unknown> | string[]>(key: string, count?: number, withValues?: boolean) => Pipeline<[...TCommands, Command<any, TData>]>;
2140
+ hrandfield: <TData extends string | string[] | Record<string, unknown>>(key: string, count?: number, withValues?: boolean) => Pipeline<[...TCommands, Command<any, TData>]>;
1916
2141
  /**
1917
2142
  * @see https://redis.io/commands/hscan
1918
2143
  */
@@ -1920,9 +2145,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1920
2145
  /**
1921
2146
  * @see https://redis.io/commands/hset
1922
2147
  */
1923
- hset: <TData>(key: string, kv: {
1924
- [field: string]: TData;
1925
- }) => Pipeline<[...TCommands, Command<any, number>]>;
2148
+ hset: <TData>(key: string, kv: Record<string, TData>) => Pipeline<[...TCommands, Command<any, number>]>;
1926
2149
  /**
1927
2150
  * @see https://redis.io/commands/hsetnx
1928
2151
  */
@@ -1979,9 +2202,9 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1979
2202
  * @see https://redis.io/commands/lpos
1980
2203
  */
1981
2204
  lpos: <TData>(key: string, element: unknown, opts?: {
1982
- rank?: number | undefined;
1983
- count?: number | undefined;
1984
- maxLen?: number | undefined;
2205
+ rank?: number;
2206
+ count?: number;
2207
+ maxLen?: number;
1985
2208
  } | undefined) => Pipeline<[...TCommands, Command<any, TData>]>;
1986
2209
  /**
1987
2210
  * @see https://redis.io/commands/lpush
@@ -2014,15 +2237,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2014
2237
  /**
2015
2238
  * @see https://redis.io/commands/mset
2016
2239
  */
2017
- mset: <TData>(kv: {
2018
- [key: string]: TData;
2019
- }) => Pipeline<[...TCommands, Command<any, "OK">]>;
2240
+ mset: <TData>(kv: Record<string, TData>) => Pipeline<[...TCommands, Command<any, "OK">]>;
2020
2241
  /**
2021
2242
  * @see https://redis.io/commands/msetnx
2022
2243
  */
2023
- msetnx: <TData>(kv: {
2024
- [key: string]: TData;
2025
- }) => Pipeline<[...TCommands, Command<any, number>]>;
2244
+ msetnx: <TData>(kv: Record<string, TData>) => Pipeline<[...TCommands, Command<any, number>]>;
2026
2245
  /**
2027
2246
  * @see https://redis.io/commands/persist
2028
2247
  */
@@ -2090,7 +2309,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2090
2309
  /**
2091
2310
  * @see https://redis.io/commands/sadd
2092
2311
  */
2093
- sadd: <TData>(key: string, ...members: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
2312
+ sadd: <TData>(key: string, member: TData, ...members: TData[]) => Pipeline<[...TCommands, Command<any, number>]>;
2094
2313
  /**
2095
2314
  * @see https://redis.io/commands/scan
2096
2315
  */
@@ -2211,19 +2430,13 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2211
2430
  /**
2212
2431
  * @see https://redis.io/commands/zadd
2213
2432
  */
2214
- zadd: <TData>(...args: [key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]] | [
2215
- key: string,
2216
- opts: ZAddCommandOptions,
2217
- ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]
2218
- ]) => Pipeline<[...TCommands, Command<any, number | null>]>;
2433
+ zadd: <TData>(...args: [key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]] | [key: string, opts: ZAddCommandOptions, ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]]) => Pipeline<[...TCommands, Command<any, number | null>]>;
2219
2434
  /**
2220
2435
  * @see https://redis.io/commands/xadd
2221
2436
  */
2222
- xadd: (key: string, id: string, entries: {
2223
- [field: string]: unknown;
2224
- }, opts?: {
2225
- nomkStream?: boolean | undefined;
2226
- trim?: (({
2437
+ xadd: (key: string, id: string, entries: Record<string, unknown>, opts?: {
2438
+ nomkStream?: boolean;
2439
+ trim?: ({
2227
2440
  type: "MAXLEN" | "maxlen";
2228
2441
  threshold: number;
2229
2442
  } | {
@@ -2231,11 +2444,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2231
2444
  threshold: string;
2232
2445
  }) & ({
2233
2446
  comparison: "~";
2234
- limit?: number | undefined;
2447
+ limit?: number;
2235
2448
  } | {
2236
2449
  comparison: "=";
2237
- limit?: undefined;
2238
- })) | undefined;
2450
+ limit?: never;
2451
+ });
2239
2452
  } | undefined) => Pipeline<[...TCommands, Command<any, string>]>;
2240
2453
  /**
2241
2454
  * @see https://redis.io/commands/xack
@@ -2251,11 +2464,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2251
2464
  xgroup: (key: string, opts: {
2252
2465
  type: "CREATE";
2253
2466
  group: string;
2254
- id: string;
2467
+ id: `$` | string;
2255
2468
  options?: {
2256
- MKSTREAM?: boolean | undefined;
2257
- ENTRIESREAD?: number | undefined;
2258
- } | undefined;
2469
+ MKSTREAM?: boolean;
2470
+ ENTRIESREAD?: number;
2471
+ };
2259
2472
  } | {
2260
2473
  type: "CREATECONSUMER";
2261
2474
  group: string;
@@ -2270,10 +2483,10 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2270
2483
  } | {
2271
2484
  type: "SETID";
2272
2485
  group: string;
2273
- id: string;
2486
+ id: `$` | string;
2274
2487
  options?: {
2275
- ENTRIESREAD?: number | undefined;
2276
- } | undefined;
2488
+ ENTRIESREAD?: number;
2489
+ };
2277
2490
  }) => Pipeline<[...TCommands, Command<any, never>]>;
2278
2491
  /**
2279
2492
  * @see https://redis.io/commands/xread
@@ -2300,35 +2513,35 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2300
2513
  * @see https://redis.io/commands/xpending
2301
2514
  */
2302
2515
  xpending: (key: string, group: string, start: string, end: string, count: number, options?: {
2303
- idleTime?: number | undefined;
2304
- consumer?: string | string[] | undefined;
2516
+ idleTime?: number;
2517
+ consumer?: string | string[];
2305
2518
  } | undefined) => Pipeline<[...TCommands, Command<any, unknown[]>]>;
2306
2519
  /**
2307
2520
  * @see https://redis.io/commands/xclaim
2308
2521
  */
2309
2522
  xclaim: (key: string, group: string, consumer: string, minIdleTime: number, id: string | string[], options?: {
2310
- idleMS?: number | undefined;
2311
- timeMS?: number | undefined;
2312
- retryCount?: number | undefined;
2313
- force?: boolean | undefined;
2314
- justId?: boolean | undefined;
2315
- lastId?: number | undefined;
2523
+ idleMS?: number;
2524
+ timeMS?: number;
2525
+ retryCount?: number;
2526
+ force?: boolean;
2527
+ justId?: boolean;
2528
+ lastId?: number;
2316
2529
  } | undefined) => Pipeline<[...TCommands, Command<any, unknown[]>]>;
2317
2530
  /**
2318
2531
  * @see https://redis.io/commands/xautoclaim
2319
2532
  */
2320
2533
  xautoclaim: (key: string, group: string, consumer: string, minIdleTime: number, start: string, options?: {
2321
- count?: number | undefined;
2322
- justId?: boolean | undefined;
2534
+ count?: number;
2535
+ justId?: boolean;
2323
2536
  } | undefined) => Pipeline<[...TCommands, Command<any, unknown[]>]>;
2324
2537
  /**
2325
2538
  * @see https://redis.io/commands/xtrim
2326
2539
  */
2327
2540
  xtrim: (key: string, options: {
2328
2541
  strategy: "MAXLEN" | "MINID";
2329
- exactness?: "~" | "=" | undefined;
2330
- threshold: string | number;
2331
- limit?: number | undefined;
2542
+ exactness?: "~" | "=";
2543
+ threshold: number | string;
2544
+ limit?: number;
2332
2545
  }) => Pipeline<[...TCommands, Command<any, number>]>;
2333
2546
  /**
2334
2547
  * @see https://redis.io/commands/xrange
@@ -2373,21 +2586,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2373
2586
  /**
2374
2587
  * @see https://redis.io/commands/zrange
2375
2588
  */
2376
- zrange: <TData extends unknown[]>(...args: [key: string, min: number, max: number, opts?: ZRangeCommandOptions] | [
2377
- key: string,
2378
- min: `(${string}` | `[${string}` | "-" | "+",
2379
- max: `(${string}` | `[${string}` | "-" | "+",
2380
- opts: {
2381
- byLex: true;
2382
- } & ZRangeCommandOptions
2383
- ] | [
2384
- key: string,
2385
- min: number | `(${number}` | "-inf" | "+inf",
2386
- max: number | `(${number}` | "-inf" | "+inf",
2387
- opts: {
2388
- byScore: true;
2389
- } & ZRangeCommandOptions
2390
- ]) => Pipeline<[...TCommands, Command<any, TData>]>;
2589
+ zrange: <TData extends unknown[]>(...args: [key: string, min: number, max: number, opts?: ZRangeCommandOptions] | [key: string, min: `(${string}` | `[${string}` | "-" | "+", max: `(${string}` | `[${string}` | "-" | "+", opts: {
2590
+ byLex: true;
2591
+ } & ZRangeCommandOptions] | [key: string, min: number | `(${number}` | "-inf" | "+inf", max: number | `(${number}` | "-inf" | "+inf", opts: {
2592
+ byScore: true;
2593
+ } & ZRangeCommandOptions]) => Pipeline<[...TCommands, Command<any, TData>]>;
2391
2594
  /**
2392
2595
  * @see https://redis.io/commands/zrank
2393
2596
  */
@@ -2472,10 +2675,18 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2472
2675
  * @see https://redis.io/commands/json.get
2473
2676
  */
2474
2677
  get: (...args: CommandArgs<typeof JsonGetCommand>) => Pipeline<[...TCommands, Command<any, any>]>;
2678
+ /**
2679
+ * @see https://redis.io/commands/json.merge
2680
+ */
2681
+ merge: (key: string, path: string, value: string | number | unknown[] | Record<string, unknown>) => Pipeline<[...TCommands, Command<any, "OK" | null>]>;
2475
2682
  /**
2476
2683
  * @see https://redis.io/commands/json.mget
2477
2684
  */
2478
2685
  mget: (keys: string[], path: string) => Pipeline<[...TCommands, Command<any, any>]>;
2686
+ /**
2687
+ * @see https://redis.io/commands/json.mset
2688
+ */
2689
+ mset: (...args: CommandArgs<typeof JsonMSetCommand>) => Pipeline<[...TCommands, Command<any, "OK" | null>]>;
2479
2690
  /**
2480
2691
  * @see https://redis.io/commands/json.numincrby
2481
2692
  */
@@ -2501,9 +2712,9 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2501
2712
  */
2502
2713
  set: (key: string, path: string, value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[], opts?: {
2503
2714
  nx: true;
2504
- xx?: undefined;
2715
+ xx?: never;
2505
2716
  } | {
2506
- nx?: undefined;
2717
+ nx?: never;
2507
2718
  xx: true;
2508
2719
  } | undefined) => Pipeline<[...TCommands, Command<any, "OK" | null>]>;
2509
2720
  /**
@@ -2567,6 +2778,48 @@ declare class Script<TResult = unknown> {
2567
2778
  private digest;
2568
2779
  }
2569
2780
 
2781
+ /**
2782
+ * Creates a new script.
2783
+ *
2784
+ * Scripts offer the ability to optimistically try to execute a script without having to send the
2785
+ * entire script to the server. If the script is loaded on the server, it tries again by sending
2786
+ * the entire script. Afterwards, the script is cached on the server.
2787
+ *
2788
+ * @example
2789
+ * ```ts
2790
+ * const redis = new Redis({...})
2791
+ *
2792
+ * const script = redis.createScript<string>("return ARGV[1];", { readOnly: true })
2793
+ * const arg1 = await script.evalRo([], ["Hello World"])
2794
+ * expect(arg1, "Hello World")
2795
+ * ```
2796
+ */
2797
+ declare class ScriptRO<TResult = unknown> {
2798
+ readonly script: string;
2799
+ readonly sha1: string;
2800
+ private readonly redis;
2801
+ constructor(redis: Redis, script: string);
2802
+ /**
2803
+ * Send an `EVAL_RO` command to redis.
2804
+ */
2805
+ evalRo(keys: string[], args: string[]): Promise<TResult>;
2806
+ /**
2807
+ * Calculates the sha1 hash of the script and then calls `EVALSHA_RO`.
2808
+ */
2809
+ evalshaRo(keys: string[], args: string[]): Promise<TResult>;
2810
+ /**
2811
+ * Optimistically try to run `EVALSHA_RO` first.
2812
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL_RO`.
2813
+ *
2814
+ * Following calls will be able to use the cached script
2815
+ */
2816
+ exec(keys: string[], args: string[]): Promise<TResult>;
2817
+ /**
2818
+ * Compute the sha1 hash of the script and return its hex representation.
2819
+ */
2820
+ private digest;
2821
+ }
2822
+
2570
2823
  /**
2571
2824
  * Serverless redis client for upstash.
2572
2825
  */
@@ -2587,6 +2840,8 @@ declare class Redis {
2587
2840
  * ```
2588
2841
  */
2589
2842
  constructor(client: Requester, opts?: RedisOptions);
2843
+ get readYourWritesSyncToken(): string | undefined;
2844
+ set readYourWritesSyncToken(session: string | undefined);
2590
2845
  get json(): {
2591
2846
  /**
2592
2847
  * @see https://redis.io/commands/json.arrappend
@@ -2628,10 +2883,18 @@ declare class Redis {
2628
2883
  * @see https://redis.io/commands/json.get
2629
2884
  */
2630
2885
  get: <TData>(...args: CommandArgs<typeof JsonGetCommand>) => Promise<TData | null>;
2886
+ /**
2887
+ * @see https://redis.io/commands/json.merge
2888
+ */
2889
+ merge: (key: string, path: string, value: string | number | unknown[] | Record<string, unknown>) => Promise<"OK" | null>;
2631
2890
  /**
2632
2891
  * @see https://redis.io/commands/json.mget
2633
2892
  */
2634
- mget: <TData_1>(keys: string[], path: string) => Promise<TData_1>;
2893
+ mget: <TData>(keys: string[], path: string) => Promise<TData>;
2894
+ /**
2895
+ * @see https://redis.io/commands/json.mset
2896
+ */
2897
+ mset: (...args: CommandArgs<typeof JsonMSetCommand>) => Promise<"OK" | null>;
2635
2898
  /**
2636
2899
  * @see https://redis.io/commands/json.numincrby
2637
2900
  */
@@ -2657,9 +2920,9 @@ declare class Redis {
2657
2920
  */
2658
2921
  set: (key: string, path: string, value: string | number | boolean | Record<string, unknown> | (string | number | boolean | Record<string, unknown>)[], opts?: {
2659
2922
  nx: true;
2660
- xx?: undefined;
2923
+ xx?: never;
2661
2924
  } | {
2662
- nx?: undefined;
2925
+ nx?: never;
2663
2926
  xx: true;
2664
2927
  } | undefined) => Promise<"OK" | null>;
2665
2928
  /**
@@ -2687,7 +2950,41 @@ declare class Redis {
2687
2950
  * Technically this is not private, we can hide it from intellisense by doing this
2688
2951
  */
2689
2952
  protected addTelemetry: (telemetry: Telemetry) => void;
2953
+ /**
2954
+ * Creates a new script.
2955
+ *
2956
+ * Scripts offer the ability to optimistically try to execute a script without having to send the
2957
+ * entire script to the server. If the script is loaded on the server, it tries again by sending
2958
+ * the entire script. Afterwards, the script is cached on the server.
2959
+ *
2960
+ * @param script - The script to create
2961
+ * @param opts - Optional options to pass to the script `{ readonly?: boolean }`
2962
+ * @returns A new script
2963
+ *
2964
+ * @example
2965
+ * ```ts
2966
+ * const redis = new Redis({...})
2967
+ *
2968
+ * const script = redis.createScript<string>("return ARGV[1];")
2969
+ * const arg1 = await script.eval([], ["Hello World"])
2970
+ * expect(arg1, "Hello World")
2971
+ * ```
2972
+ * @example
2973
+ * ```ts
2974
+ * const redis = new Redis({...})
2975
+ *
2976
+ * const script = redis.createScript<string>("return ARGV[1];", { readonly: true })
2977
+ * const arg1 = await script.evalRo([], ["Hello World"])
2978
+ * expect(arg1, "Hello World")
2979
+ * ```
2980
+ */
2690
2981
  createScript(script: string): Script;
2982
+ createScript(script: string, opts: {
2983
+ readonly?: false;
2984
+ }): Script;
2985
+ createScript(script: string, opts: {
2986
+ readonly: true;
2987
+ }): ScriptRO;
2691
2988
  /**
2692
2989
  * Create a new pipeline that allows you to send requests in bulk.
2693
2990
  *
@@ -2766,14 +3063,26 @@ declare class Redis {
2766
3063
  * @see https://redis.io/commands/echo
2767
3064
  */
2768
3065
  echo: (message: string) => Promise<string>;
3066
+ /**
3067
+ * @see https://redis.io/commands/eval_ro
3068
+ */
3069
+ evalRo: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Promise<TData>;
2769
3070
  /**
2770
3071
  * @see https://redis.io/commands/eval
2771
3072
  */
2772
3073
  eval: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Promise<TData>;
3074
+ /**
3075
+ * @see https://redis.io/commands/evalsha_ro
3076
+ */
3077
+ evalshaRo: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
2773
3078
  /**
2774
3079
  * @see https://redis.io/commands/evalsha
2775
3080
  */
2776
3081
  evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
3082
+ /**
3083
+ * Generic method to execute any Redis command.
3084
+ */
3085
+ exec: <TResult>(args: [command: string, ...args: (string | number | boolean)[]]) => Promise<TResult>;
2777
3086
  /**
2778
3087
  * @see https://redis.io/commands/exists
2779
3088
  */
@@ -2794,7 +3103,7 @@ declare class Redis {
2794
3103
  * @see https://redis.io/commands/flushdb
2795
3104
  */
2796
3105
  flushdb: (opts?: {
2797
- async?: boolean | undefined;
3106
+ async?: boolean;
2798
3107
  } | undefined) => Promise<"OK">;
2799
3108
  /**
2800
3109
  * @see https://redis.io/commands/geoadd
@@ -2841,11 +3150,11 @@ declare class Redis {
2841
3150
  }, order: "ASC" | "DESC" | "asc" | "desc", opts?: {
2842
3151
  count?: {
2843
3152
  limit: number;
2844
- any?: boolean | undefined;
2845
- } | undefined;
2846
- withCoord?: boolean | undefined;
2847
- withDist?: boolean | undefined;
2848
- withHash?: boolean | undefined;
3153
+ any?: boolean;
3154
+ };
3155
+ withCoord?: boolean;
3156
+ withDist?: boolean;
3157
+ withHash?: boolean;
2849
3158
  } | undefined) => Promise<({
2850
3159
  member: TData;
2851
3160
  } & {
@@ -2882,9 +3191,9 @@ declare class Redis {
2882
3191
  }, order: "ASC" | "DESC" | "asc" | "desc", opts?: {
2883
3192
  count?: {
2884
3193
  limit: number;
2885
- any?: boolean | undefined;
2886
- } | undefined;
2887
- storeDist?: boolean | undefined;
3194
+ any?: boolean;
3195
+ };
3196
+ storeDist?: boolean;
2888
3197
  } | undefined) => Promise<number>;
2889
3198
  /**
2890
3199
  * @see https://redis.io/commands/get
@@ -2898,6 +3207,46 @@ declare class Redis {
2898
3207
  * @see https://redis.io/commands/getdel
2899
3208
  */
2900
3209
  getdel: <TData>(key: string) => Promise<TData | null>;
3210
+ /**
3211
+ * @see https://redis.io/commands/getex
3212
+ */
3213
+ getex: <TData>(key: string, opts?: ({
3214
+ ex: number;
3215
+ px?: never;
3216
+ exat?: never;
3217
+ pxat?: never;
3218
+ persist?: never;
3219
+ } | {
3220
+ ex?: never;
3221
+ px: number;
3222
+ exat?: never;
3223
+ pxat?: never;
3224
+ persist?: never;
3225
+ } | {
3226
+ ex?: never;
3227
+ px?: never;
3228
+ exat: number;
3229
+ pxat?: never;
3230
+ persist?: never;
3231
+ } | {
3232
+ ex?: never;
3233
+ px?: never;
3234
+ exat?: never;
3235
+ pxat: number;
3236
+ persist?: never;
3237
+ } | {
3238
+ ex?: never;
3239
+ px?: never;
3240
+ exat?: never;
3241
+ pxat?: never;
3242
+ persist: true;
3243
+ } | {
3244
+ ex?: never;
3245
+ px?: never;
3246
+ exat?: never;
3247
+ pxat?: never;
3248
+ persist?: never;
3249
+ }) | undefined) => Promise<TData | null>;
2901
3250
  /**
2902
3251
  * @see https://redis.io/commands/getrange
2903
3252
  */
@@ -2945,9 +3294,7 @@ declare class Redis {
2945
3294
  /**
2946
3295
  * @see https://redis.io/commands/hmset
2947
3296
  */
2948
- hmset: <TData>(key: string, kv: {
2949
- [field: string]: TData;
2950
- }) => Promise<"OK">;
3297
+ hmset: <TData>(key: string, kv: Record<string, TData>) => Promise<"OK">;
2951
3298
  /**
2952
3299
  * @see https://redis.io/commands/hrandfield
2953
3300
  */
@@ -2963,9 +3310,7 @@ declare class Redis {
2963
3310
  /**
2964
3311
  * @see https://redis.io/commands/hset
2965
3312
  */
2966
- hset: <TData>(key: string, kv: {
2967
- [field: string]: TData;
2968
- }) => Promise<number>;
3313
+ hset: <TData>(key: string, kv: Record<string, TData>) => Promise<number>;
2969
3314
  /**
2970
3315
  * @see https://redis.io/commands/hsetnx
2971
3316
  */
@@ -3022,9 +3367,9 @@ declare class Redis {
3022
3367
  * @see https://redis.io/commands/lpos
3023
3368
  */
3024
3369
  lpos: <TData = number>(key: string, element: unknown, opts?: {
3025
- rank?: number | undefined;
3026
- count?: number | undefined;
3027
- maxLen?: number | undefined;
3370
+ rank?: number;
3371
+ count?: number;
3372
+ maxLen?: number;
3028
3373
  } | undefined) => Promise<TData>;
3029
3374
  /**
3030
3375
  * @see https://redis.io/commands/lpush
@@ -3057,15 +3402,11 @@ declare class Redis {
3057
3402
  /**
3058
3403
  * @see https://redis.io/commands/mset
3059
3404
  */
3060
- mset: <TData>(kv: {
3061
- [key: string]: TData;
3062
- }) => Promise<"OK">;
3405
+ mset: <TData>(kv: Record<string, TData>) => Promise<"OK">;
3063
3406
  /**
3064
3407
  * @see https://redis.io/commands/msetnx
3065
3408
  */
3066
- msetnx: <TData>(kv: {
3067
- [key: string]: TData;
3068
- }) => Promise<number>;
3409
+ msetnx: <TData>(kv: Record<string, TData>) => Promise<number>;
3069
3410
  /**
3070
3411
  * @see https://redis.io/commands/persist
3071
3412
  */
@@ -3098,6 +3439,10 @@ declare class Redis {
3098
3439
  * @see https://redis.io/commands/psetex
3099
3440
  */
3100
3441
  psetex: <TData>(key: string, ttl: number, value: TData) => Promise<string>;
3442
+ /**
3443
+ * @see https://redis.io/commands/psubscribe
3444
+ */
3445
+ psubscribe: <TMessage>(patterns: string | string[]) => Subscriber<TMessage>;
3101
3446
  /**
3102
3447
  * @see https://redis.io/commands/pttl
3103
3448
  */
@@ -3133,7 +3478,7 @@ declare class Redis {
3133
3478
  /**
3134
3479
  * @see https://redis.io/commands/sadd
3135
3480
  */
3136
- sadd: <TData>(key: string, ...members: TData[]) => Promise<number>;
3481
+ sadd: <TData>(key: string, member: TData, ...members: TData[]) => Promise<number>;
3137
3482
  /**
3138
3483
  * @see https://redis.io/commands/scan
3139
3484
  */
@@ -3226,6 +3571,10 @@ declare class Redis {
3226
3571
  * @see https://redis.io/commands/strlen
3227
3572
  */
3228
3573
  strlen: (key: string) => Promise<number>;
3574
+ /**
3575
+ * @see https://redis.io/commands/subscribe
3576
+ */
3577
+ subscribe: <TMessage>(channels: string | string[]) => Subscriber<TMessage>;
3229
3578
  /**
3230
3579
  * @see https://redis.io/commands/sunion
3231
3580
  */
@@ -3257,11 +3606,9 @@ declare class Redis {
3257
3606
  /**
3258
3607
  * @see https://redis.io/commands/xadd
3259
3608
  */
3260
- xadd: (key: string, id: string, entries: {
3261
- [field: string]: unknown;
3262
- }, opts?: {
3263
- nomkStream?: boolean | undefined;
3264
- trim?: (({
3609
+ xadd: (key: string, id: string, entries: Record<string, unknown>, opts?: {
3610
+ nomkStream?: boolean;
3611
+ trim?: ({
3265
3612
  type: "MAXLEN" | "maxlen";
3266
3613
  threshold: number;
3267
3614
  } | {
@@ -3269,11 +3616,11 @@ declare class Redis {
3269
3616
  threshold: string;
3270
3617
  }) & ({
3271
3618
  comparison: "~";
3272
- limit?: number | undefined;
3619
+ limit?: number;
3273
3620
  } | {
3274
3621
  comparison: "=";
3275
- limit?: undefined;
3276
- })) | undefined;
3622
+ limit?: never;
3623
+ });
3277
3624
  } | undefined) => Promise<string>;
3278
3625
  /**
3279
3626
  * @see https://redis.io/commands/xack
@@ -3289,11 +3636,11 @@ declare class Redis {
3289
3636
  xgroup: (key: string, opts: {
3290
3637
  type: "CREATE";
3291
3638
  group: string;
3292
- id: string;
3639
+ id: `$` | string;
3293
3640
  options?: {
3294
- MKSTREAM?: boolean | undefined;
3295
- ENTRIESREAD?: number | undefined;
3296
- } | undefined;
3641
+ MKSTREAM?: boolean;
3642
+ ENTRIESREAD?: number;
3643
+ };
3297
3644
  } | {
3298
3645
  type: "CREATECONSUMER";
3299
3646
  group: string;
@@ -3308,10 +3655,10 @@ declare class Redis {
3308
3655
  } | {
3309
3656
  type: "SETID";
3310
3657
  group: string;
3311
- id: string;
3658
+ id: `$` | string;
3312
3659
  options?: {
3313
- ENTRIESREAD?: number | undefined;
3314
- } | undefined;
3660
+ ENTRIESREAD?: number;
3661
+ };
3315
3662
  }) => Promise<never>;
3316
3663
  /**
3317
3664
  * @see https://redis.io/commands/xread
@@ -3338,35 +3685,35 @@ declare class Redis {
3338
3685
  * @see https://redis.io/commands/xpending
3339
3686
  */
3340
3687
  xpending: (key: string, group: string, start: string, end: string, count: number, options?: {
3341
- idleTime?: number | undefined;
3342
- consumer?: string | string[] | undefined;
3688
+ idleTime?: number;
3689
+ consumer?: string | string[];
3343
3690
  } | undefined) => Promise<unknown[]>;
3344
3691
  /**
3345
3692
  * @see https://redis.io/commands/xclaim
3346
3693
  */
3347
3694
  xclaim: (key: string, group: string, consumer: string, minIdleTime: number, id: string | string[], options?: {
3348
- idleMS?: number | undefined;
3349
- timeMS?: number | undefined;
3350
- retryCount?: number | undefined;
3351
- force?: boolean | undefined;
3352
- justId?: boolean | undefined;
3353
- lastId?: number | undefined;
3695
+ idleMS?: number;
3696
+ timeMS?: number;
3697
+ retryCount?: number;
3698
+ force?: boolean;
3699
+ justId?: boolean;
3700
+ lastId?: number;
3354
3701
  } | undefined) => Promise<unknown[]>;
3355
3702
  /**
3356
3703
  * @see https://redis.io/commands/xautoclaim
3357
3704
  */
3358
3705
  xautoclaim: (key: string, group: string, consumer: string, minIdleTime: number, start: string, options?: {
3359
- count?: number | undefined;
3360
- justId?: boolean | undefined;
3706
+ count?: number;
3707
+ justId?: boolean;
3361
3708
  } | undefined) => Promise<unknown[]>;
3362
3709
  /**
3363
3710
  * @see https://redis.io/commands/xtrim
3364
3711
  */
3365
3712
  xtrim: (key: string, options: {
3366
3713
  strategy: "MAXLEN" | "MINID";
3367
- exactness?: "~" | "=" | undefined;
3368
- threshold: string | number;
3369
- limit?: number | undefined;
3714
+ exactness?: "~" | "=";
3715
+ threshold: number | string;
3716
+ limit?: number;
3370
3717
  }) => Promise<number>;
3371
3718
  /**
3372
3719
  * @see https://redis.io/commands/xrange
@@ -3379,11 +3726,7 @@ declare class Redis {
3379
3726
  /**
3380
3727
  * @see https://redis.io/commands/zadd
3381
3728
  */
3382
- zadd: <TData>(...args: [key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]] | [
3383
- key: string,
3384
- opts: ZAddCommandOptions,
3385
- ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]
3386
- ]) => Promise<number | null>;
3729
+ zadd: <TData>(...args: [key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]] | [key: string, opts: ZAddCommandOptions, ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]]) => Promise<number | null>;
3387
3730
  /**
3388
3731
  * @see https://redis.io/commands/zcard
3389
3732
  */
@@ -3423,21 +3766,11 @@ declare class Redis {
3423
3766
  /**
3424
3767
  * @see https://redis.io/commands/zrange
3425
3768
  */
3426
- zrange: <TData extends unknown[]>(...args: [key: string, min: number, max: number, opts?: ZRangeCommandOptions] | [
3427
- key: string,
3428
- min: `(${string}` | `[${string}` | "-" | "+",
3429
- max: `(${string}` | `[${string}` | "-" | "+",
3430
- opts: {
3431
- byLex: true;
3432
- } & ZRangeCommandOptions
3433
- ] | [
3434
- key: string,
3435
- min: number | `(${number}` | "-inf" | "+inf",
3436
- max: number | `(${number}` | "-inf" | "+inf",
3437
- opts: {
3438
- byScore: true;
3439
- } & ZRangeCommandOptions
3440
- ]) => Promise<TData>;
3769
+ zrange: <TData extends unknown[]>(...args: [key: string, min: number, max: number, opts?: ZRangeCommandOptions] | [key: string, min: `(${string}` | `[${string}` | "-" | "+", max: `(${string}` | `[${string}` | "-" | "+", opts: {
3770
+ byLex: true;
3771
+ } & ZRangeCommandOptions] | [key: string, min: number | `(${number}` | "-inf" | "+inf", max: number | `(${number}` | "-inf" | "+inf", opts: {
3772
+ byScore: true;
3773
+ } & ZRangeCommandOptions]) => Promise<TData>;
3441
3774
  /**
3442
3775
  * @see https://redis.io/commands/zrank
3443
3776
  */
@@ -3495,10 +3828,7 @@ declare const error_UpstashError: typeof UpstashError;
3495
3828
  type error_UrlError = UrlError;
3496
3829
  declare const error_UrlError: typeof UrlError;
3497
3830
  declare namespace error {
3498
- export {
3499
- error_UpstashError as UpstashError,
3500
- error_UrlError as UrlError,
3501
- };
3831
+ export { error_UpstashError as UpstashError, error_UrlError as UrlError };
3502
3832
  }
3503
3833
 
3504
3834
  /**
@@ -3515,4 +3845,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
3515
3845
  constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
3516
3846
  }
3517
3847
 
3518
- export { HValsCommand as $, AppendCommand as A, BitCountCommand as B, CopyCommand as C, DBSizeCommand as D, EchoCommand as E, FlushAllCommand as F, GeoAddCommand as G, GetRangeCommand as H, GetSetCommand as I, HDelCommand as J, HExistsCommand as K, HGetCommand as L, HGetAllCommand as M, HIncrByCommand as N, HIncrByFloatCommand as O, Pipeline as P, HKeysCommand as Q, RedisOptions as R, HLenCommand as S, HMGetCommand as T, UpstashRequest as U, HMSetCommand as V, HRandFieldCommand as W, HScanCommand as X, HSetCommand as Y, HSetNXCommand as Z, HStrLenCommand as _, RequesterConfig as a, SetBitCommand as a$, IncrCommand as a0, IncrByCommand as a1, IncrByFloatCommand as a2, JsonArrAppendCommand as a3, JsonArrIndexCommand as a4, JsonArrInsertCommand as a5, JsonArrLenCommand as a6, JsonArrPopCommand as a7, JsonArrTrimCommand as a8, JsonClearCommand as a9, MGetCommand as aA, MSetCommand as aB, MSetNXCommand as aC, PersistCommand as aD, PExpireCommand as aE, PExpireAtCommand as aF, PingCommand as aG, PSetEXCommand as aH, PTtlCommand as aI, PublishCommand as aJ, RandomKeyCommand as aK, RenameCommand as aL, RenameNXCommand as aM, RPopCommand as aN, RPushCommand as aO, RPushXCommand as aP, SAddCommand as aQ, ScanCommand as aR, ScanCommandOptions as aS, SCardCommand as aT, ScriptExistsCommand as aU, ScriptFlushCommand as aV, ScriptLoadCommand as aW, SDiffCommand as aX, SDiffStoreCommand as aY, SetCommand as aZ, SetCommandOptions as a_, JsonDelCommand as aa, JsonForgetCommand as ab, JsonGetCommand as ac, JsonMGetCommand as ad, JsonNumIncrByCommand as ae, JsonNumMultByCommand as af, JsonObjKeysCommand as ag, JsonObjLenCommand as ah, JsonRespCommand as ai, JsonSetCommand as aj, JsonStrAppendCommand as ak, JsonStrLenCommand as al, JsonToggleCommand as am, JsonTypeCommand as an, KeysCommand as ao, LIndexCommand as ap, LInsertCommand as aq, LLenCommand as ar, LMoveCommand as as, LPopCommand as at, LPushCommand as au, LPushXCommand as av, LRangeCommand as aw, LRemCommand as ax, LSetCommand as ay, LTrimCommand as az, Redis as b, SetExCommand as b0, SetNxCommand as b1, SetRangeCommand as b2, SInterCommand as b3, SInterStoreCommand as b4, SIsMemberCommand as b5, SMembersCommand as b6, SMIsMemberCommand as b7, SMoveCommand as b8, SPopCommand as b9, ZPopMinCommand as bA, ZRangeCommand as bB, ZRangeCommandOptions as bC, ZRankCommand as bD, ZRemCommand as bE, ZRemRangeByLexCommand as bF, ZRemRangeByRankCommand as bG, ZRemRangeByScoreCommand as bH, ZRevRankCommand as bI, ZScanCommand as bJ, ZScoreCommand as bK, ZUnionCommand as bL, ZUnionCommandOptions as bM, ZUnionStoreCommand as bN, ZUnionStoreCommandOptions as bO, SRandMemberCommand as ba, SRemCommand as bb, SScanCommand as bc, StrLenCommand as bd, SUnionCommand as be, SUnionStoreCommand as bf, TimeCommand as bg, TouchCommand as bh, TtlCommand as bi, Type as bj, TypeCommand as bk, UnlinkCommand as bl, XAddCommand as bm, XRangeCommand as bn, ScoreMember as bo, ZAddCommandOptions as bp, ZAddCommand as bq, ZCardCommand as br, ZCountCommand as bs, ZDiffStoreCommand as bt, ZIncrByCommand as bu, ZInterStoreCommand as bv, ZInterStoreCommandOptions as bw, ZLexCountCommand as bx, ZMScoreCommand as by, ZPopMaxCommand as bz, Requester as c, UpstashResponse as d, error as e, BitOpCommand as f, BitPosCommand as g, DecrCommand as h, DecrByCommand as i, DelCommand as j, EvalCommand as k, EvalshaCommand as l, ExistsCommand as m, ExpireCommand as n, ExpireAtCommand as o, FlushDBCommand as p, GeoAddCommandOptions as q, GeoMember as r, GeoDistCommand as s, GeoHashCommand as t, GeoPosCommand as u, GeoSearchCommand as v, GeoSearchStoreCommand as w, GetCommand as x, GetBitCommand as y, GetDelCommand as z };
3848
+ export { HSetCommand as $, AppendCommand as A, BitCountCommand as B, CopyCommand as C, DBSizeCommand as D, EchoCommand as E, FlushAllCommand as F, GeoAddCommand as G, GetBitCommand as H, GetDelCommand as I, GetExCommand as J, GetRangeCommand as K, GetSetCommand as L, HDelCommand as M, HExistsCommand as N, HGetCommand as O, Pipeline as P, HGetAllCommand as Q, type RedisOptions as R, HIncrByCommand as S, HIncrByFloatCommand as T, type UpstashRequest as U, HKeysCommand as V, HLenCommand as W, HMGetCommand as X, HMSetCommand as Y, HRandFieldCommand as Z, HScanCommand as _, type RequesterConfig as a, SDiffCommand as a$, HSetNXCommand as a0, HStrLenCommand as a1, HValsCommand as a2, IncrCommand as a3, IncrByCommand as a4, IncrByFloatCommand as a5, JsonArrAppendCommand as a6, JsonArrIndexCommand as a7, JsonArrInsertCommand as a8, JsonArrLenCommand as a9, LRangeCommand as aA, LRemCommand as aB, LSetCommand as aC, LTrimCommand as aD, MGetCommand as aE, MSetCommand as aF, MSetNXCommand as aG, PersistCommand as aH, PExpireCommand as aI, PExpireAtCommand as aJ, PingCommand as aK, PSetEXCommand as aL, PTtlCommand as aM, PublishCommand as aN, RandomKeyCommand as aO, RenameCommand as aP, RenameNXCommand as aQ, RPopCommand as aR, RPushCommand as aS, RPushXCommand as aT, SAddCommand as aU, ScanCommand as aV, type ScanCommandOptions as aW, SCardCommand as aX, ScriptExistsCommand as aY, ScriptFlushCommand as aZ, ScriptLoadCommand as a_, JsonArrPopCommand as aa, JsonArrTrimCommand as ab, JsonClearCommand as ac, JsonDelCommand as ad, JsonForgetCommand as ae, JsonGetCommand as af, JsonMergeCommand as ag, JsonMGetCommand as ah, JsonNumIncrByCommand as ai, JsonNumMultByCommand as aj, JsonObjKeysCommand as ak, JsonObjLenCommand as al, JsonRespCommand as am, JsonSetCommand as an, JsonStrAppendCommand as ao, JsonStrLenCommand as ap, JsonToggleCommand as aq, JsonTypeCommand as ar, KeysCommand as as, LIndexCommand as at, LInsertCommand as au, LLenCommand as av, LMoveCommand as aw, LPopCommand as ax, LPushCommand as ay, LPushXCommand as az, Redis as b, SDiffStoreCommand as b0, SetCommand as b1, type SetCommandOptions as b2, SetBitCommand as b3, SetExCommand as b4, SetNxCommand as b5, SetRangeCommand as b6, SInterCommand as b7, SInterStoreCommand as b8, SIsMemberCommand as b9, type ZInterStoreCommandOptions as bA, ZLexCountCommand as bB, ZMScoreCommand as bC, ZPopMaxCommand as bD, ZPopMinCommand as bE, ZRangeCommand as bF, type ZRangeCommandOptions as bG, ZRankCommand as bH, ZRemCommand as bI, ZRemRangeByLexCommand as bJ, ZRemRangeByRankCommand as bK, ZRemRangeByScoreCommand as bL, ZRevRankCommand as bM, ZScanCommand as bN, ZScoreCommand as bO, ZUnionCommand as bP, type ZUnionCommandOptions as bQ, ZUnionStoreCommand as bR, type ZUnionStoreCommandOptions as bS, SMembersCommand as ba, SMIsMemberCommand as bb, SMoveCommand as bc, SPopCommand as bd, SRandMemberCommand as be, SRemCommand as bf, SScanCommand as bg, StrLenCommand as bh, SUnionCommand as bi, SUnionStoreCommand as bj, TimeCommand as bk, TouchCommand as bl, TtlCommand as bm, type Type as bn, TypeCommand as bo, UnlinkCommand as bp, XAddCommand as bq, XRangeCommand as br, type ScoreMember as bs, type ZAddCommandOptions as bt, ZAddCommand as bu, ZCardCommand as bv, ZCountCommand as bw, ZDiffStoreCommand as bx, ZIncrByCommand as by, ZInterStoreCommand as bz, type UpstashResponse as c, type Requester as d, error as e, BitOpCommand as f, BitPosCommand as g, DecrCommand as h, DecrByCommand as i, DelCommand as j, EvalROCommand as k, EvalCommand as l, EvalshaROCommand as m, EvalshaCommand as n, ExistsCommand as o, ExpireCommand as p, ExpireAtCommand as q, FlushDBCommand as r, type GeoAddCommandOptions as s, type GeoMember as t, GeoDistCommand as u, GeoHashCommand as v, GeoPosCommand as w, GeoSearchCommand as x, GeoSearchStoreCommand as y, GetCommand as z };