@upstash/redis 0.0.0-ci.9846a4b6d92b334b3956b0947a58e9bef9c92a42-20250303091249 → 0.0.0-ci.9a0f7fcd9dc38c0a4ce2b192f3f9c3542ccc791c-20251125190254

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.
@@ -77,7 +77,7 @@ type RetryConfig = false | {
77
77
  */
78
78
  retries?: number;
79
79
  /**
80
- * A backoff function receives the current retry cound and returns a number in milliseconds to wait before retrying.
80
+ * A backoff function receives the current retry count and returns a number in milliseconds to wait before retrying.
81
81
  *
82
82
  * @default
83
83
  * ```ts
@@ -86,6 +86,9 @@ type RetryConfig = false | {
86
86
  */
87
87
  backoff?: (retryCount: number) => number;
88
88
  };
89
+ type Options$1 = {
90
+ backend?: string;
91
+ };
89
92
  type RequesterConfig = {
90
93
  /**
91
94
  * Configure the retry behaviour in case of network errors
@@ -120,6 +123,19 @@ type RequesterConfig = {
120
123
  */
121
124
  cache?: CacheSetting;
122
125
  };
126
+ type HttpClientConfig = {
127
+ headers?: Record<string, string>;
128
+ baseUrl: string;
129
+ options?: Options$1;
130
+ retry?: RetryConfig;
131
+ agent?: any;
132
+ signal?: AbortSignal | (() => AbortSignal);
133
+ keepAlive?: boolean;
134
+ /**
135
+ * 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.
136
+ */
137
+ readYourWrites?: boolean;
138
+ } & RequesterConfig;
123
139
 
124
140
  type Serialize = (data: unknown) => string | number | boolean;
125
141
  type Deserialize<TResult, TData> = (result: TResult) => TData;
@@ -271,18 +287,6 @@ declare class ScriptFlushCommand extends Command<"OK", "OK"> {
271
287
  constructor([opts]: [opts?: ScriptFlushCommandOptions], cmdOpts?: CommandOptions<"OK", "OK">);
272
288
  }
273
289
 
274
- type ScanCommandOptions = {
275
- match?: string;
276
- count?: number;
277
- type?: string;
278
- };
279
- /**
280
- * @see https://redis.io/commands/scan
281
- */
282
- declare class ScanCommand extends Command<[string, string[]], [string, string[]]> {
283
- constructor([cursor, opts]: [cursor: string | number, opts?: ScanCommandOptions], cmdOpts?: CommandOptions<[string, string[]], [string, string[]]>);
284
- }
285
-
286
290
  type GeoAddCommandOptions = {
287
291
  nx?: boolean;
288
292
  xx?: never;
@@ -308,6 +312,11 @@ declare class GeoAddCommand<TMemberType = string> extends Command<number | null,
308
312
  ], opts?: CommandOptions<number | null, number | null>);
309
313
  }
310
314
 
315
+ type ExpireOption = "NX" | "nx" | "XX" | "xx" | "GT" | "gt" | "LT" | "lt";
316
+ declare class ExpireCommand extends Command<"0" | "1", 0 | 1> {
317
+ constructor(cmd: [key: string, seconds: number, option?: ExpireOption], opts?: CommandOptions<"0" | "1", 0 | 1>);
318
+ }
319
+
311
320
  /**
312
321
  * @see https://redis.io/commands/append
313
322
  */
@@ -404,6 +413,13 @@ declare class EchoCommand extends Command<string, string> {
404
413
  constructor(cmd: [message: string], opts?: CommandOptions<string, string>);
405
414
  }
406
415
 
416
+ /**
417
+ * @see https://redis.io/commands/eval_ro
418
+ */
419
+ declare class EvalROCommand<TArgs extends unknown[], TData> extends Command<unknown, TData> {
420
+ constructor([script, keys, args]: [script: string, keys: string[], args: TArgs], opts?: CommandOptions<unknown, TData>);
421
+ }
422
+
407
423
  /**
408
424
  * @see https://redis.io/commands/eval
409
425
  */
@@ -411,6 +427,13 @@ declare class EvalCommand<TArgs extends unknown[], TData> extends Command<unknow
411
427
  constructor([script, keys, args]: [script: string, keys: string[], args: TArgs], opts?: CommandOptions<unknown, TData>);
412
428
  }
413
429
 
430
+ /**
431
+ * @see https://redis.io/commands/evalsha_ro
432
+ */
433
+ declare class EvalshaROCommand<TArgs extends unknown[], TData> extends Command<unknown, TData> {
434
+ constructor([sha, keys, args]: [sha: string, keys: string[], args?: TArgs], opts?: CommandOptions<unknown, TData>);
435
+ }
436
+
414
437
  /**
415
438
  * @see https://redis.io/commands/evalsha
416
439
  */
@@ -425,16 +448,11 @@ declare class ExistsCommand extends Command<number, number> {
425
448
  constructor(cmd: [...keys: string[]], opts?: CommandOptions<number, number>);
426
449
  }
427
450
 
428
- type ExpireOptions = "NX" | "nx" | "XX" | "xx" | "GT" | "gt" | "LT" | "lt";
429
- declare class ExpireCommand extends Command<"0" | "1", 0 | 1> {
430
- constructor(cmd: [key: string, seconds: number, option?: ExpireOptions], opts?: CommandOptions<"0" | "1", 0 | 1>);
431
- }
432
-
433
451
  /**
434
452
  * @see https://redis.io/commands/expireat
435
453
  */
436
454
  declare class ExpireAtCommand extends Command<"0" | "1", 0 | 1> {
437
- constructor(cmd: [key: string, unix: number], opts?: CommandOptions<"0" | "1", 0 | 1>);
455
+ constructor(cmd: [key: string, unix: number, option?: ExpireOption], opts?: CommandOptions<"0" | "1", 0 | 1>);
438
456
  }
439
457
 
440
458
  /**
@@ -681,6 +699,58 @@ declare class HExistsCommand extends Command<number, number> {
681
699
  constructor(cmd: [key: string, field: string], opts?: CommandOptions<number, number>);
682
700
  }
683
701
 
702
+ declare class HExpireCommand extends Command<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]> {
703
+ constructor(cmd: [
704
+ key: string,
705
+ fields: (string | number) | (string | number)[],
706
+ seconds: number,
707
+ option?: ExpireOption
708
+ ], opts?: CommandOptions<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]>);
709
+ }
710
+
711
+ declare class HExpireAtCommand extends Command<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]> {
712
+ constructor(cmd: [
713
+ key: string,
714
+ fields: (string | number) | (string | number)[],
715
+ timestamp: number,
716
+ option?: ExpireOption
717
+ ], opts?: CommandOptions<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]>);
718
+ }
719
+
720
+ declare class HExpireTimeCommand extends Command<number[], number[]> {
721
+ constructor(cmd: [key: string, fields: (string | number) | (string | number)[]], opts?: CommandOptions<number[], number[]>);
722
+ }
723
+
724
+ declare class HPersistCommand extends Command<(-2 | -1 | 1)[], (-2 | -1 | 1)[]> {
725
+ constructor(cmd: [key: string, fields: (string | number) | (string | number)[]], opts?: CommandOptions<(-2 | -1 | 1)[], (-2 | -1 | 1)[]>);
726
+ }
727
+
728
+ declare class HPExpireCommand extends Command<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]> {
729
+ constructor(cmd: [
730
+ key: string,
731
+ fields: (string | number) | (string | number)[],
732
+ milliseconds: number,
733
+ option?: ExpireOption
734
+ ], opts?: CommandOptions<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]>);
735
+ }
736
+
737
+ declare class HPExpireAtCommand extends Command<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]> {
738
+ constructor(cmd: [
739
+ key: string,
740
+ fields: (string | number) | (string | number)[],
741
+ timestamp: number,
742
+ option?: ExpireOption
743
+ ], opts?: CommandOptions<(-2 | 0 | 1 | 2)[], (-2 | 0 | 1 | 2)[]>);
744
+ }
745
+
746
+ declare class HPExpireTimeCommand extends Command<number[], number[]> {
747
+ constructor(cmd: [key: string, fields: (string | number) | (string | number)[]], opts?: CommandOptions<number[], number[]>);
748
+ }
749
+
750
+ declare class HPTtlCommand extends Command<number[], number[]> {
751
+ constructor(cmd: [key: string, fields: (string | number) | (string | number)[]], opts?: CommandOptions<number[], number[]>);
752
+ }
753
+
684
754
  /**
685
755
  * @see https://redis.io/commands/hget
686
756
  */
@@ -754,6 +824,39 @@ declare class HRandFieldCommand<TData extends string | string[] | Record<string,
754
824
  constructor(cmd: [key: string, count: number, withValues: boolean], opts?: CommandOptions<string[], Partial<TData>>);
755
825
  }
756
826
 
827
+ type ScanCommandOptionsStandard = {
828
+ match?: string;
829
+ count?: number;
830
+ type?: string;
831
+ withType?: false;
832
+ };
833
+ type ScanCommandOptionsWithType = {
834
+ match?: string;
835
+ count?: number;
836
+ /**
837
+ * Includes types of each key in the result
838
+ *
839
+ * @example
840
+ * ```typescript
841
+ * await redis.scan("0", { withType: true })
842
+ * // ["0", [{ key: "key1", type: "string" }, { key: "key2", type: "list" }]]
843
+ * ```
844
+ */
845
+ withType: true;
846
+ };
847
+ type ScanCommandOptions = ScanCommandOptionsStandard | ScanCommandOptionsWithType;
848
+ type ScanResultStandard = [string, string[]];
849
+ type ScanResultWithType = [string, {
850
+ key: string;
851
+ type: string;
852
+ }[]];
853
+ /**
854
+ * @see https://redis.io/commands/scan
855
+ */
856
+ declare class ScanCommand<TData = ScanResultStandard> extends Command<[string, string[]], TData> {
857
+ constructor([cursor, opts]: [cursor: string | number, opts?: ScanCommandOptions], cmdOpts?: CommandOptions<[string, string[]], TData>);
858
+ }
859
+
757
860
  /**
758
861
  * @see https://redis.io/commands/hscan
759
862
  */
@@ -788,6 +891,10 @@ declare class HStrLenCommand extends Command<number, number> {
788
891
  constructor(cmd: [key: string, field: string], opts?: CommandOptions<number, number>);
789
892
  }
790
893
 
894
+ declare class HTtlCommand extends Command<number[], number[]> {
895
+ constructor(cmd: [key: string, fields: (string | number) | (string | number)[]], opts?: CommandOptions<number[], number[]>);
896
+ }
897
+
791
898
  /**
792
899
  * @see https://redis.io/commands/hvals
793
900
  */
@@ -894,6 +1001,13 @@ declare class JsonGetCommand<TData extends (unknown | Record<string, unknown>) |
894
1001
  ] | [key: string, ...path: string[]], opts?: CommandOptions<TData | null, TData | null>);
895
1002
  }
896
1003
 
1004
+ /**
1005
+ * @see https://redis.io/commands/json.merge
1006
+ */
1007
+ declare class JsonMergeCommand<TData extends string | number | Record<string, unknown> | Array<unknown>> extends Command<"OK" | null, "OK" | null> {
1008
+ constructor(cmd: [key: string, path: string, value: TData], opts?: CommandOptions<"OK" | null, "OK" | null>);
1009
+ }
1010
+
897
1011
  /**
898
1012
  * @see https://redis.io/commands/json.mget
899
1013
  */
@@ -1096,14 +1210,14 @@ declare class PersistCommand extends Command<"0" | "1", 0 | 1> {
1096
1210
  * @see https://redis.io/commands/pexpire
1097
1211
  */
1098
1212
  declare class PExpireCommand extends Command<"0" | "1", 0 | 1> {
1099
- constructor(cmd: [key: string, milliseconds: number], opts?: CommandOptions<"0" | "1", 0 | 1>);
1213
+ constructor(cmd: [key: string, milliseconds: number, option?: ExpireOption], opts?: CommandOptions<"0" | "1", 0 | 1>);
1100
1214
  }
1101
1215
 
1102
1216
  /**
1103
1217
  * @see https://redis.io/commands/pexpireat
1104
1218
  */
1105
1219
  declare class PExpireAtCommand extends Command<"0" | "1", 0 | 1> {
1106
- constructor(cmd: [key: string, unix: number], opts?: CommandOptions<"0" | "1", 0 | 1>);
1220
+ constructor(cmd: [key: string, unix: number, option?: ExpireOption], opts?: CommandOptions<"0" | "1", 0 | 1>);
1107
1221
  }
1108
1222
 
1109
1223
  /**
@@ -1463,16 +1577,33 @@ type XReadCommandOptions = [
1463
1577
  id: string | string[],
1464
1578
  options?: {
1465
1579
  count?: number;
1580
+ /**
1581
+ * @deprecated block is not yet supported in Upstash Redis
1582
+ */
1466
1583
  blockMS?: number;
1467
1584
  }
1468
1585
  ];
1469
- type XReadOptions = XReadCommandOptions extends [infer K, infer I, ...any[]] ? K extends string ? I extends string ? [key: string, id: string, options?: {
1470
- count?: number;
1471
- blockMS?: number;
1472
- }] : never : K extends string[] ? I extends string[] ? [key: string[], id: string[], options?: {
1473
- count?: number;
1474
- blockMS?: number;
1475
- }] : never : never : never;
1586
+ type XReadOptions = XReadCommandOptions extends [infer K, infer I, ...any[]] ? K extends string ? I extends string ? [
1587
+ key: string,
1588
+ id: string,
1589
+ options?: {
1590
+ count?: number;
1591
+ /**
1592
+ * @deprecated block is not yet supported in Upstash Redis
1593
+ */
1594
+ blockMS?: number;
1595
+ }
1596
+ ] : never : K extends string[] ? I extends string[] ? [
1597
+ key: string[],
1598
+ id: string[],
1599
+ options?: {
1600
+ count?: number;
1601
+ /**
1602
+ * @deprecated block is not yet supported in Upstash Redis
1603
+ */
1604
+ blockMS?: number;
1605
+ }
1606
+ ] : never : never : never;
1476
1607
  /**
1477
1608
  * @see https://redis.io/commands/xread
1478
1609
  */
@@ -1482,6 +1613,9 @@ declare class XReadCommand extends Command<number, unknown[]> {
1482
1613
 
1483
1614
  type Options = {
1484
1615
  count?: number;
1616
+ /**
1617
+ * @deprecated block is not yet supported in Upstash Redis
1618
+ */
1485
1619
  blockMS?: number;
1486
1620
  NOACK?: boolean;
1487
1621
  };
@@ -1714,7 +1848,8 @@ declare class Subscriber<TMessage = any> extends EventTarget {
1714
1848
  private subscriptions;
1715
1849
  private client;
1716
1850
  private listeners;
1717
- constructor(client: Requester, channels: string[], isPattern?: boolean);
1851
+ private opts?;
1852
+ constructor(client: Requester, channels: string[], isPattern?: boolean, opts?: Pick<RedisOptions, "automaticDeserialization">);
1718
1853
  private subscribeToChannel;
1719
1854
  private subscribeToPattern;
1720
1855
  private handleMessage;
@@ -1885,10 +2020,18 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1885
2020
  * @see https://redis.io/commands/echo
1886
2021
  */
1887
2022
  echo: (message: string) => Pipeline<[...TCommands, Command<any, string>]>;
2023
+ /**
2024
+ * @see https://redis.io/commands/eval_ro
2025
+ */
2026
+ evalRo: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
1888
2027
  /**
1889
2028
  * @see https://redis.io/commands/eval
1890
2029
  */
1891
2030
  eval: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
2031
+ /**
2032
+ * @see https://redis.io/commands/evalsha_ro
2033
+ */
2034
+ evalshaRo: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Pipeline<[...TCommands, Command<any, TData>]>;
1892
2035
  /**
1893
2036
  * @see https://redis.io/commands/evalsha
1894
2037
  */
@@ -1900,11 +2043,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1900
2043
  /**
1901
2044
  * @see https://redis.io/commands/expire
1902
2045
  */
1903
- expire: (key: string, seconds: number, option?: ("NX" | "nx" | "XX" | "xx" | "GT" | "gt" | "LT" | "lt") | undefined) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
2046
+ expire: (key: string, seconds: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
1904
2047
  /**
1905
2048
  * @see https://redis.io/commands/expireat
1906
2049
  */
1907
- expireat: (key: string, unix: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
2050
+ expireat: (key: string, unix: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
1908
2051
  /**
1909
2052
  * @see https://redis.io/commands/flushall
1910
2053
  */
@@ -2073,6 +2216,42 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2073
2216
  * @see https://redis.io/commands/hexists
2074
2217
  */
2075
2218
  hexists: (key: string, field: string) => Pipeline<[...TCommands, Command<any, number>]>;
2219
+ /**
2220
+ * @see https://redis.io/commands/hexpire
2221
+ */
2222
+ hexpire: (key: string, fields: string | number | (string | number)[], seconds: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, (0 | 1 | 2 | -2)[]>]>;
2223
+ /**
2224
+ * @see https://redis.io/commands/hexpireat
2225
+ */
2226
+ hexpireat: (key: string, fields: string | number | (string | number)[], timestamp: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, (0 | 1 | 2 | -2)[]>]>;
2227
+ /**
2228
+ * @see https://redis.io/commands/hexpiretime
2229
+ */
2230
+ hexpiretime: (key: string, fields: string | number | (string | number)[]) => Pipeline<[...TCommands, Command<any, number[]>]>;
2231
+ /**
2232
+ * @see https://redis.io/commands/httl
2233
+ */
2234
+ httl: (key: string, fields: string | number | (string | number)[]) => Pipeline<[...TCommands, Command<any, number[]>]>;
2235
+ /**
2236
+ * @see https://redis.io/commands/hpexpire
2237
+ */
2238
+ hpexpire: (key: string, fields: string | number | (string | number)[], milliseconds: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, (0 | 1 | 2 | -2)[]>]>;
2239
+ /**
2240
+ * @see https://redis.io/commands/hpexpireat
2241
+ */
2242
+ hpexpireat: (key: string, fields: string | number | (string | number)[], timestamp: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, (0 | 1 | 2 | -2)[]>]>;
2243
+ /**
2244
+ * @see https://redis.io/commands/hpexpiretime
2245
+ */
2246
+ hpexpiretime: (key: string, fields: string | number | (string | number)[]) => Pipeline<[...TCommands, Command<any, number[]>]>;
2247
+ /**
2248
+ * @see https://redis.io/commands/hpttl
2249
+ */
2250
+ hpttl: (key: string, fields: string | number | (string | number)[]) => Pipeline<[...TCommands, Command<any, number[]>]>;
2251
+ /**
2252
+ * @see https://redis.io/commands/hpersist
2253
+ */
2254
+ hpersist: (key: string, fields: string | number | (string | number)[]) => Pipeline<[...TCommands, Command<any, (1 | -2 | -1)[]>]>;
2076
2255
  /**
2077
2256
  * @see https://redis.io/commands/hget
2078
2257
  */
@@ -2220,11 +2399,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2220
2399
  /**
2221
2400
  * @see https://redis.io/commands/pexpire
2222
2401
  */
2223
- pexpire: (key: string, milliseconds: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
2402
+ pexpire: (key: string, milliseconds: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
2224
2403
  /**
2225
2404
  * @see https://redis.io/commands/pexpireat
2226
2405
  */
2227
- pexpireat: (key: string, unix: number) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
2406
+ pexpireat: (key: string, unix: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
2228
2407
  /**
2229
2408
  * @see https://redis.io/commands/pfadd
2230
2409
  */
@@ -2284,7 +2463,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2284
2463
  /**
2285
2464
  * @see https://redis.io/commands/scan
2286
2465
  */
2287
- scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, [string, string[]]>]>;
2466
+ scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, any>]>;
2288
2467
  /**
2289
2468
  * @see https://redis.io/commands/scard
2290
2469
  */
@@ -2646,6 +2825,10 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2646
2825
  * @see https://redis.io/commands/json.get
2647
2826
  */
2648
2827
  get: (...args: CommandArgs<typeof JsonGetCommand>) => Pipeline<[...TCommands, Command<any, any>]>;
2828
+ /**
2829
+ * @see https://redis.io/commands/json.merge
2830
+ */
2831
+ merge: (key: string, path: string, value: string | number | unknown[] | Record<string, unknown>) => Pipeline<[...TCommands, Command<any, "OK" | null>]>;
2649
2832
  /**
2650
2833
  * @see https://redis.io/commands/json.mget
2651
2834
  */
@@ -2721,9 +2904,20 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
2721
2904
  */
2722
2905
  declare class Script<TResult = unknown> {
2723
2906
  readonly script: string;
2724
- readonly sha1: string;
2907
+ /**
2908
+ * @deprecated This property is initialized to an empty string and will be set in the init method
2909
+ * asynchronously. Do not use this property immidiately after the constructor.
2910
+ *
2911
+ * This property is only exposed for backwards compatibility and will be removed in the
2912
+ * future major release.
2913
+ */
2914
+ sha1: string;
2725
2915
  private readonly redis;
2726
2916
  constructor(redis: Redis, script: string);
2917
+ /**
2918
+ * Initialize the script by computing its SHA-1 hash.
2919
+ */
2920
+ private init;
2727
2921
  /**
2728
2922
  * Send an `EVAL` command to redis.
2729
2923
  */
@@ -2745,6 +2939,56 @@ declare class Script<TResult = unknown> {
2745
2939
  private digest;
2746
2940
  }
2747
2941
 
2942
+ /**
2943
+ * Creates a new script.
2944
+ *
2945
+ * Scripts offer the ability to optimistically try to execute a script without having to send the
2946
+ * entire script to the server. If the script is loaded on the server, it tries again by sending
2947
+ * the entire script. Afterwards, the script is cached on the server.
2948
+ *
2949
+ * @example
2950
+ * ```ts
2951
+ * const redis = new Redis({...})
2952
+ *
2953
+ * const script = redis.createScript<string>("return ARGV[1];", { readOnly: true })
2954
+ * const arg1 = await script.evalRo([], ["Hello World"])
2955
+ * expect(arg1, "Hello World")
2956
+ * ```
2957
+ */
2958
+ declare class ScriptRO<TResult = unknown> {
2959
+ readonly script: string;
2960
+ /**
2961
+ * @deprecated This property is initialized to an empty string and will be set in the init method
2962
+ * asynchronously. Do not use this property immidiately after the constructor.
2963
+ *
2964
+ * This property is only exposed for backwards compatibility and will be removed in the
2965
+ * future major release.
2966
+ */
2967
+ sha1: string;
2968
+ private readonly redis;
2969
+ constructor(redis: Redis, script: string);
2970
+ private init;
2971
+ /**
2972
+ * Send an `EVAL_RO` command to redis.
2973
+ */
2974
+ evalRo(keys: string[], args: string[]): Promise<TResult>;
2975
+ /**
2976
+ * Calculates the sha1 hash of the script and then calls `EVALSHA_RO`.
2977
+ */
2978
+ evalshaRo(keys: string[], args: string[]): Promise<TResult>;
2979
+ /**
2980
+ * Optimistically try to run `EVALSHA_RO` first.
2981
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL_RO`.
2982
+ *
2983
+ * Following calls will be able to use the cached script
2984
+ */
2985
+ exec(keys: string[], args: string[]): Promise<TResult>;
2986
+ /**
2987
+ * Compute the sha1 hash of the script and return its hex representation.
2988
+ */
2989
+ private digest;
2990
+ }
2991
+
2748
2992
  /**
2749
2993
  * Serverless redis client for upstash.
2750
2994
  */
@@ -2808,6 +3052,10 @@ declare class Redis {
2808
3052
  * @see https://redis.io/commands/json.get
2809
3053
  */
2810
3054
  get: <TData>(...args: CommandArgs<typeof JsonGetCommand>) => Promise<TData | null>;
3055
+ /**
3056
+ * @see https://redis.io/commands/json.merge
3057
+ */
3058
+ merge: (key: string, path: string, value: string | number | unknown[] | Record<string, unknown>) => Promise<"OK" | null>;
2811
3059
  /**
2812
3060
  * @see https://redis.io/commands/json.mget
2813
3061
  */
@@ -2871,7 +3119,37 @@ declare class Redis {
2871
3119
  * Technically this is not private, we can hide it from intellisense by doing this
2872
3120
  */
2873
3121
  protected addTelemetry: (telemetry: Telemetry) => void;
2874
- createScript(script: string): Script;
3122
+ /**
3123
+ * Creates a new script.
3124
+ *
3125
+ * Scripts offer the ability to optimistically try to execute a script without having to send the
3126
+ * entire script to the server. If the script is loaded on the server, it tries again by sending
3127
+ * the entire script. Afterwards, the script is cached on the server.
3128
+ *
3129
+ * @param script - The script to create
3130
+ * @param opts - Optional options to pass to the script `{ readonly?: boolean }`
3131
+ * @returns A new script
3132
+ *
3133
+ * @example
3134
+ * ```ts
3135
+ * const redis = new Redis({...})
3136
+ *
3137
+ * const script = redis.createScript<string>("return ARGV[1];")
3138
+ * const arg1 = await script.eval([], ["Hello World"])
3139
+ * expect(arg1, "Hello World")
3140
+ * ```
3141
+ * @example
3142
+ * ```ts
3143
+ * const redis = new Redis({...})
3144
+ *
3145
+ * const script = redis.createScript<string>("return ARGV[1];", { readonly: true })
3146
+ * const arg1 = await script.evalRo([], ["Hello World"])
3147
+ * expect(arg1, "Hello World")
3148
+ * ```
3149
+ */
3150
+ createScript<TResult = unknown, TReadonly extends boolean = false>(script: string, opts?: {
3151
+ readonly?: TReadonly;
3152
+ }): TReadonly extends true ? ScriptRO<TResult> : Script<TResult>;
2875
3153
  /**
2876
3154
  * Create a new pipeline that allows you to send requests in bulk.
2877
3155
  *
@@ -2950,10 +3228,18 @@ declare class Redis {
2950
3228
  * @see https://redis.io/commands/echo
2951
3229
  */
2952
3230
  echo: (message: string) => Promise<string>;
3231
+ /**
3232
+ * @see https://redis.io/commands/eval_ro
3233
+ */
3234
+ evalRo: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Promise<TData>;
2953
3235
  /**
2954
3236
  * @see https://redis.io/commands/eval
2955
3237
  */
2956
3238
  eval: <TArgs extends unknown[], TData = unknown>(script: string, keys: string[], args: TArgs) => Promise<TData>;
3239
+ /**
3240
+ * @see https://redis.io/commands/evalsha_ro
3241
+ */
3242
+ evalshaRo: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
2957
3243
  /**
2958
3244
  * @see https://redis.io/commands/evalsha
2959
3245
  */
@@ -2969,11 +3255,11 @@ declare class Redis {
2969
3255
  /**
2970
3256
  * @see https://redis.io/commands/expire
2971
3257
  */
2972
- expire: (key: string, seconds: number, option?: ("NX" | "nx" | "XX" | "xx" | "GT" | "gt" | "LT" | "lt") | undefined) => Promise<0 | 1>;
3258
+ expire: (key: string, seconds: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
2973
3259
  /**
2974
3260
  * @see https://redis.io/commands/expireat
2975
3261
  */
2976
- expireat: (key: string, unix: number) => Promise<0 | 1>;
3262
+ expireat: (key: string, unix: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
2977
3263
  /**
2978
3264
  * @see https://redis.io/commands/flushall
2979
3265
  */
@@ -3142,6 +3428,42 @@ declare class Redis {
3142
3428
  * @see https://redis.io/commands/hexists
3143
3429
  */
3144
3430
  hexists: (key: string, field: string) => Promise<number>;
3431
+ /**
3432
+ * @see https://redis.io/commands/hexpire
3433
+ */
3434
+ hexpire: (key: string, fields: string | number | (string | number)[], seconds: number, option?: ExpireOption | undefined) => Promise<(0 | 1 | 2 | -2)[]>;
3435
+ /**
3436
+ * @see https://redis.io/commands/hexpireat
3437
+ */
3438
+ hexpireat: (key: string, fields: string | number | (string | number)[], timestamp: number, option?: ExpireOption | undefined) => Promise<(0 | 1 | 2 | -2)[]>;
3439
+ /**
3440
+ * @see https://redis.io/commands/hexpiretime
3441
+ */
3442
+ hexpiretime: (key: string, fields: string | number | (string | number)[]) => Promise<number[]>;
3443
+ /**
3444
+ * @see https://redis.io/commands/httl
3445
+ */
3446
+ httl: (key: string, fields: string | number | (string | number)[]) => Promise<number[]>;
3447
+ /**
3448
+ * @see https://redis.io/commands/hpexpire
3449
+ */
3450
+ hpexpire: (key: string, fields: string | number | (string | number)[], milliseconds: number, option?: ExpireOption | undefined) => Promise<(0 | 1 | 2 | -2)[]>;
3451
+ /**
3452
+ * @see https://redis.io/commands/hpexpireat
3453
+ */
3454
+ hpexpireat: (key: string, fields: string | number | (string | number)[], timestamp: number, option?: ExpireOption | undefined) => Promise<(0 | 1 | 2 | -2)[]>;
3455
+ /**
3456
+ * @see https://redis.io/commands/hpexpiretime
3457
+ */
3458
+ hpexpiretime: (key: string, fields: string | number | (string | number)[]) => Promise<number[]>;
3459
+ /**
3460
+ * @see https://redis.io/commands/hpttl
3461
+ */
3462
+ hpttl: (key: string, fields: string | number | (string | number)[]) => Promise<number[]>;
3463
+ /**
3464
+ * @see https://redis.io/commands/hpersist
3465
+ */
3466
+ hpersist: (key: string, fields: string | number | (string | number)[]) => Promise<(1 | -2 | -1)[]>;
3145
3467
  /**
3146
3468
  * @see https://redis.io/commands/hget
3147
3469
  */
@@ -3293,11 +3615,11 @@ declare class Redis {
3293
3615
  /**
3294
3616
  * @see https://redis.io/commands/pexpire
3295
3617
  */
3296
- pexpire: (key: string, milliseconds: number) => Promise<0 | 1>;
3618
+ pexpire: (key: string, milliseconds: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
3297
3619
  /**
3298
3620
  * @see https://redis.io/commands/pexpireat
3299
3621
  */
3300
- pexpireat: (key: string, unix: number) => Promise<0 | 1>;
3622
+ pexpireat: (key: string, unix: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
3301
3623
  /**
3302
3624
  * @see https://redis.io/commands/pfadd
3303
3625
  */
@@ -3361,7 +3683,10 @@ declare class Redis {
3361
3683
  /**
3362
3684
  * @see https://redis.io/commands/scan
3363
3685
  */
3364
- scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Promise<[string, string[]]>;
3686
+ scan(cursor: string | number): Promise<ScanResultStandard>;
3687
+ scan<TOptions extends ScanCommandOptions>(cursor: string | number, opts: TOptions): Promise<TOptions extends {
3688
+ withType: true;
3689
+ } ? ScanResultWithType : ScanResultStandard>;
3365
3690
  /**
3366
3691
  * @see https://redis.io/commands/scard
3367
3692
  */
@@ -3692,22 +4017,28 @@ declare class Redis {
3692
4017
  zunionstore: (destination: string, numKeys: number, keys: string[], opts?: ZUnionStoreCommandOptions | undefined) => Promise<number>;
3693
4018
  }
3694
4019
 
4020
+ type UpstashErrorOptions = Pick<NonNullable<ConstructorParameters<typeof Error>[1]>, "cause">;
3695
4021
  /**
3696
4022
  * Result of a bad request to upstash
3697
4023
  */
3698
4024
  declare class UpstashError extends Error {
3699
- constructor(message: string);
4025
+ constructor(message: string, options?: ErrorOptions);
3700
4026
  }
3701
4027
  declare class UrlError extends Error {
3702
4028
  constructor(url: string);
3703
4029
  }
4030
+ declare class UpstashJSONParseError extends UpstashError {
4031
+ constructor(body: string, options?: UpstashErrorOptions);
4032
+ }
3704
4033
 
3705
4034
  type error_UpstashError = UpstashError;
3706
4035
  declare const error_UpstashError: typeof UpstashError;
4036
+ type error_UpstashJSONParseError = UpstashJSONParseError;
4037
+ declare const error_UpstashJSONParseError: typeof UpstashJSONParseError;
3707
4038
  type error_UrlError = UrlError;
3708
4039
  declare const error_UrlError: typeof UrlError;
3709
4040
  declare namespace error {
3710
- export { error_UpstashError as UpstashError, error_UrlError as UrlError };
4041
+ export { error_UpstashError as UpstashError, error_UpstashJSONParseError as UpstashJSONParseError, error_UrlError as UrlError };
3711
4042
  }
3712
4043
 
3713
4044
  /**
@@ -3724,4 +4055,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
3724
4055
  constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
3725
4056
  }
3726
4057
 
3727
- export { HStrLenCommand as $, AppendCommand as A, BitCountCommand as B, CopyCommand as C, DBSizeCommand as D, EchoCommand as E, FlushAllCommand as F, GeoAddCommand as G, GetExCommand as H, GetRangeCommand as I, GetSetCommand as J, HDelCommand as K, HExistsCommand as L, HGetCommand as M, HGetAllCommand as N, HIncrByCommand as O, Pipeline as P, HIncrByFloatCommand as Q, type RedisOptions as R, HKeysCommand as S, HLenCommand as T, type UpstashRequest as U, HMGetCommand as V, HMSetCommand as W, HRandFieldCommand as X, HScanCommand as Y, HSetCommand as Z, HSetNXCommand as _, type RequesterConfig as a, type SetCommandOptions as a$, HValsCommand as a0, IncrCommand as a1, IncrByCommand as a2, IncrByFloatCommand as a3, JsonArrAppendCommand as a4, JsonArrIndexCommand as a5, JsonArrInsertCommand as a6, JsonArrLenCommand as a7, JsonArrPopCommand as a8, JsonArrTrimCommand as a9, LTrimCommand as aA, MGetCommand as aB, MSetCommand as aC, MSetNXCommand as aD, PersistCommand as aE, PExpireCommand as aF, PExpireAtCommand as aG, PingCommand as aH, PSetEXCommand as aI, PTtlCommand as aJ, PublishCommand as aK, RandomKeyCommand as aL, RenameCommand as aM, RenameNXCommand as aN, RPopCommand as aO, RPushCommand as aP, RPushXCommand as aQ, SAddCommand as aR, ScanCommand as aS, type ScanCommandOptions as aT, SCardCommand as aU, ScriptExistsCommand as aV, ScriptFlushCommand as aW, ScriptLoadCommand as aX, SDiffCommand as aY, SDiffStoreCommand as aZ, SetCommand as a_, JsonClearCommand as aa, JsonDelCommand as ab, JsonForgetCommand as ac, JsonGetCommand as ad, JsonMGetCommand as ae, JsonNumIncrByCommand as af, JsonNumMultByCommand as ag, JsonObjKeysCommand as ah, JsonObjLenCommand as ai, JsonRespCommand as aj, JsonSetCommand as ak, JsonStrAppendCommand as al, JsonStrLenCommand as am, JsonToggleCommand as an, JsonTypeCommand as ao, KeysCommand as ap, LIndexCommand as aq, LInsertCommand as ar, LLenCommand as as, LMoveCommand as at, LPopCommand as au, LPushCommand as av, LPushXCommand as aw, LRangeCommand as ax, LRemCommand as ay, LSetCommand as az, Redis as b, SetBitCommand as b0, SetExCommand as b1, SetNxCommand as b2, SetRangeCommand as b3, SInterCommand as b4, SInterStoreCommand as b5, SIsMemberCommand as b6, SMembersCommand as b7, SMIsMemberCommand as b8, SMoveCommand as b9, ZPopMaxCommand as bA, ZPopMinCommand as bB, ZRangeCommand as bC, type ZRangeCommandOptions as bD, ZRankCommand as bE, ZRemCommand as bF, ZRemRangeByLexCommand as bG, ZRemRangeByRankCommand as bH, ZRemRangeByScoreCommand as bI, ZRevRankCommand as bJ, ZScanCommand as bK, ZScoreCommand as bL, ZUnionCommand as bM, type ZUnionCommandOptions as bN, ZUnionStoreCommand as bO, type ZUnionStoreCommandOptions as bP, SPopCommand as ba, SRandMemberCommand as bb, SRemCommand as bc, SScanCommand as bd, StrLenCommand as be, SUnionCommand as bf, SUnionStoreCommand as bg, TimeCommand as bh, TouchCommand as bi, TtlCommand as bj, type Type as bk, TypeCommand as bl, UnlinkCommand as bm, XAddCommand as bn, XRangeCommand as bo, type ScoreMember as bp, type ZAddCommandOptions as bq, ZAddCommand as br, ZCardCommand as bs, ZCountCommand as bt, ZDiffStoreCommand as bu, ZIncrByCommand as bv, ZInterStoreCommand as bw, type ZInterStoreCommandOptions as bx, ZLexCountCommand as by, ZMScoreCommand 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, EvalCommand as k, EvalshaCommand as l, ExistsCommand as m, ExpireCommand as n, ExpireAtCommand as o, FlushDBCommand as p, type GeoAddCommandOptions as q, type 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 };
4058
+ export { HPersistCommand as $, AppendCommand as A, BitCountCommand as B, CopyCommand as C, DBSizeCommand as D, EchoCommand as E, FlushAllCommand as F, GeoAddCommand as G, type HttpClientConfig as H, GetCommand as I, GetBitCommand as J, GetDelCommand as K, GetExCommand as L, GetRangeCommand as M, GetSetCommand as N, HDelCommand as O, Pipeline as P, HExistsCommand as Q, type RedisOptions as R, HExpireCommand as S, HExpireAtCommand as T, type UpstashRequest as U, HExpireTimeCommand as V, HTtlCommand as W, HPExpireCommand as X, HPExpireAtCommand as Y, HPExpireTimeCommand as Z, HPTtlCommand as _, type RequesterConfig as a, RenameNXCommand as a$, HGetCommand as a0, HGetAllCommand as a1, HIncrByCommand as a2, HIncrByFloatCommand as a3, HKeysCommand as a4, HLenCommand as a5, HMGetCommand as a6, HMSetCommand as a7, HRandFieldCommand as a8, HScanCommand as a9, JsonStrLenCommand as aA, JsonToggleCommand as aB, JsonTypeCommand as aC, KeysCommand as aD, LIndexCommand as aE, LInsertCommand as aF, LLenCommand as aG, LMoveCommand as aH, LPopCommand as aI, LPushCommand as aJ, LPushXCommand as aK, LRangeCommand as aL, LRemCommand as aM, LSetCommand as aN, LTrimCommand as aO, MGetCommand as aP, MSetCommand as aQ, MSetNXCommand as aR, PersistCommand as aS, PExpireCommand as aT, PExpireAtCommand as aU, PingCommand as aV, PSetEXCommand as aW, PTtlCommand as aX, PublishCommand as aY, RandomKeyCommand as aZ, RenameCommand as a_, HSetCommand as aa, HSetNXCommand as ab, HStrLenCommand as ac, HValsCommand as ad, IncrCommand as ae, IncrByCommand as af, IncrByFloatCommand as ag, JsonArrAppendCommand as ah, JsonArrIndexCommand as ai, JsonArrInsertCommand as aj, JsonArrLenCommand as ak, JsonArrPopCommand as al, JsonArrTrimCommand as am, JsonClearCommand as an, JsonDelCommand as ao, JsonForgetCommand as ap, JsonGetCommand as aq, JsonMergeCommand as ar, JsonMGetCommand as as, JsonNumIncrByCommand as at, JsonNumMultByCommand as au, JsonObjKeysCommand as av, JsonObjLenCommand as aw, JsonRespCommand as ax, JsonSetCommand as ay, JsonStrAppendCommand as az, Redis as b, type ZUnionCommandOptions as b$, RPopCommand as b0, RPushCommand as b1, RPushXCommand as b2, SAddCommand as b3, ScanCommand as b4, type ScanCommandOptions as b5, SCardCommand as b6, ScriptExistsCommand as b7, ScriptFlushCommand as b8, ScriptLoadCommand as b9, UnlinkCommand as bA, XAddCommand as bB, XRangeCommand as bC, type ScoreMember as bD, type ZAddCommandOptions as bE, ZAddCommand as bF, ZCardCommand as bG, ZCountCommand as bH, ZDiffStoreCommand as bI, ZIncrByCommand as bJ, ZInterStoreCommand as bK, type ZInterStoreCommandOptions as bL, ZLexCountCommand as bM, ZMScoreCommand as bN, ZPopMaxCommand as bO, ZPopMinCommand as bP, ZRangeCommand as bQ, type ZRangeCommandOptions as bR, ZRankCommand as bS, ZRemCommand as bT, ZRemRangeByLexCommand as bU, ZRemRangeByRankCommand as bV, ZRemRangeByScoreCommand as bW, ZRevRankCommand as bX, ZScanCommand as bY, ZScoreCommand as bZ, ZUnionCommand as b_, SDiffCommand as ba, SDiffStoreCommand as bb, SetCommand as bc, type SetCommandOptions as bd, SetBitCommand as be, SetExCommand as bf, SetNxCommand as bg, SetRangeCommand as bh, SInterCommand as bi, SInterStoreCommand as bj, SIsMemberCommand as bk, SMembersCommand as bl, SMIsMemberCommand as bm, SMoveCommand as bn, SPopCommand as bo, SRandMemberCommand as bp, SRemCommand as bq, SScanCommand as br, StrLenCommand as bs, SUnionCommand as bt, SUnionStoreCommand as bu, TimeCommand as bv, TouchCommand as bw, TtlCommand as bx, type Type as by, TypeCommand as bz, type Requester as c, ZUnionStoreCommand as c0, type ZUnionStoreCommandOptions as c1, type UpstashResponse 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, type ExpireOption as q, ExpireAtCommand as r, FlushDBCommand as s, type GeoAddCommandOptions as t, type GeoMember as u, GeoDistCommand as v, GeoHashCommand as w, GeoPosCommand as x, GeoSearchCommand as y, GeoSearchStoreCommand as z };