@upstash/redis 1.34.3-canary-2 → 1.34.4

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.
@@ -563,6 +563,50 @@ declare class GetDelCommand<TData = string> extends Command<unknown | null, TDat
563
563
  constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
564
564
  }
565
565
 
566
+ type GetExCommandOptions = {
567
+ ex: number;
568
+ px?: never;
569
+ exat?: never;
570
+ pxat?: never;
571
+ persist?: never;
572
+ } | {
573
+ ex?: never;
574
+ px: number;
575
+ exat?: never;
576
+ pxat?: never;
577
+ persist?: never;
578
+ } | {
579
+ ex?: never;
580
+ px?: never;
581
+ exat: number;
582
+ pxat?: never;
583
+ persist?: never;
584
+ } | {
585
+ ex?: never;
586
+ px?: never;
587
+ exat?: never;
588
+ pxat: number;
589
+ persist?: never;
590
+ } | {
591
+ ex?: never;
592
+ px?: never;
593
+ exat?: never;
594
+ pxat?: never;
595
+ persist: true;
596
+ } | {
597
+ ex?: never;
598
+ px?: never;
599
+ exat?: never;
600
+ pxat?: never;
601
+ persist?: never;
602
+ };
603
+ /**
604
+ * @see https://redis.io/commands/getex
605
+ */
606
+ declare class GetExCommand<TData = string> extends Command<unknown | null, TData | null> {
607
+ constructor([key, opts]: [key: string, opts?: GetExCommandOptions], cmdOpts?: CommandOptions<unknown | null, TData | null>);
608
+ }
609
+
566
610
  /**
567
611
  * @see https://redis.io/commands/getrange
568
612
  */
@@ -1602,6 +1646,39 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
1602
1646
  type InferResponseData<T extends unknown[]> = {
1603
1647
  [K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
1604
1648
  };
1649
+ interface ExecMethod<TCommands extends Command<any, any>[]> {
1650
+ /**
1651
+ * Send the pipeline request to upstash.
1652
+ *
1653
+ * Returns an array with the results of all pipelined commands.
1654
+ *
1655
+ * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
1656
+ * ```ts
1657
+ * const p = redis.pipeline()
1658
+ * p.get("key")
1659
+ * const result = p.exec<[{ greeting: string }]>()
1660
+ * ```
1661
+ *
1662
+ * 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.
1663
+ *
1664
+ * 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 }`.
1665
+ *
1666
+ * ```ts
1667
+ * const p = redis.pipeline()
1668
+ * p.get("key")
1669
+ *
1670
+ * const result = await p.exec({ keepErrors: true });
1671
+ * const getResult = result[0].result
1672
+ * const getError = result[0].error
1673
+ * ```
1674
+ */
1675
+ <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(): Promise<TCommandResults>;
1676
+ <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(options: {
1677
+ keepErrors: true;
1678
+ }): Promise<{
1679
+ [K in keyof TCommandResults]: UpstashResponse<TCommandResults[K]>;
1680
+ }>;
1681
+ }
1605
1682
  /**
1606
1683
  * Upstash REST API supports command pipelining to send multiple commands in
1607
1684
  * batch, instead of sending each command one by one and waiting for a response.
@@ -1650,19 +1727,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1650
1727
  commandOptions?: CommandOptions<any, any>;
1651
1728
  multiExec?: boolean;
1652
1729
  });
1653
- /**
1654
- * Send the pipeline request to upstash.
1655
- *
1656
- * Returns an array with the results of all pipelined commands.
1657
- *
1658
- * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
1659
- * ```ts
1660
- * const p = redis.pipeline()
1661
- * p.get("key")
1662
- * const result = p.exec<[{ greeting: string }]>()
1663
- * ```
1664
- */
1665
- exec: <TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>() => Promise<TCommandResults>;
1730
+ exec: ExecMethod<TCommands>;
1666
1731
  /**
1667
1732
  * Returns the length of pipeline before the execution
1668
1733
  */
@@ -1870,6 +1935,46 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1870
1935
  * @see https://redis.io/commands/getdel
1871
1936
  */
1872
1937
  getdel: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
1938
+ /**
1939
+ * @see https://redis.io/commands/getex
1940
+ */
1941
+ getex: <TData>(key: string, opts?: ({
1942
+ ex: number;
1943
+ px?: never;
1944
+ exat?: never;
1945
+ pxat?: never;
1946
+ persist?: never;
1947
+ } | {
1948
+ ex?: never;
1949
+ px: number;
1950
+ exat?: never;
1951
+ pxat?: never;
1952
+ persist?: never;
1953
+ } | {
1954
+ ex?: never;
1955
+ px?: never;
1956
+ exat: number;
1957
+ pxat?: never;
1958
+ persist?: never;
1959
+ } | {
1960
+ ex?: never;
1961
+ px?: never;
1962
+ exat?: never;
1963
+ pxat: number;
1964
+ persist?: never;
1965
+ } | {
1966
+ ex?: never;
1967
+ px?: never;
1968
+ exat?: never;
1969
+ pxat?: never;
1970
+ persist: true;
1971
+ } | {
1972
+ ex?: never;
1973
+ px?: never;
1974
+ exat?: never;
1975
+ pxat?: never;
1976
+ persist?: never;
1977
+ }) | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
1873
1978
  /**
1874
1979
  * @see https://redis.io/commands/getrange
1875
1980
  */
@@ -2771,6 +2876,10 @@ declare class Redis {
2771
2876
  * @see https://redis.io/commands/evalsha
2772
2877
  */
2773
2878
  evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
2879
+ /**
2880
+ * Generic method to execute any Redis command.
2881
+ */
2882
+ exec: <TResult>(args: [command: string, ...args: (string | number | boolean)[]]) => Promise<TResult>;
2774
2883
  /**
2775
2884
  * @see https://redis.io/commands/exists
2776
2885
  */
@@ -2895,6 +3004,46 @@ declare class Redis {
2895
3004
  * @see https://redis.io/commands/getdel
2896
3005
  */
2897
3006
  getdel: <TData>(key: string) => Promise<TData | null>;
3007
+ /**
3008
+ * @see https://redis.io/commands/getex
3009
+ */
3010
+ getex: <TData>(key: string, opts?: ({
3011
+ ex: number;
3012
+ px?: never;
3013
+ exat?: never;
3014
+ pxat?: never;
3015
+ persist?: never;
3016
+ } | {
3017
+ ex?: never;
3018
+ px: number;
3019
+ exat?: never;
3020
+ pxat?: never;
3021
+ persist?: never;
3022
+ } | {
3023
+ ex?: never;
3024
+ px?: never;
3025
+ exat: number;
3026
+ pxat?: never;
3027
+ persist?: never;
3028
+ } | {
3029
+ ex?: never;
3030
+ px?: never;
3031
+ exat?: never;
3032
+ pxat: number;
3033
+ persist?: never;
3034
+ } | {
3035
+ ex?: never;
3036
+ px?: never;
3037
+ exat?: never;
3038
+ pxat?: never;
3039
+ persist: true;
3040
+ } | {
3041
+ ex?: never;
3042
+ px?: never;
3043
+ exat?: never;
3044
+ pxat?: never;
3045
+ persist?: never;
3046
+ }) | undefined) => Promise<TData | null>;
2898
3047
  /**
2899
3048
  * @see https://redis.io/commands/getrange
2900
3049
  */
@@ -3485,4 +3634,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
3485
3634
  constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
3486
3635
  }
3487
3636
 
3488
- 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, type RedisOptions as R, HLenCommand as S, HMGetCommand as T, type UpstashRequest as U, HMSetCommand as V, HRandFieldCommand as W, HScanCommand as X, HSetCommand as Y, HSetNXCommand as Z, HStrLenCommand as _, type 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, type ScanCommandOptions as aS, SCardCommand as aT, ScriptExistsCommand as aU, ScriptFlushCommand as aV, ScriptLoadCommand as aW, SDiffCommand as aX, SDiffStoreCommand as aY, SetCommand as aZ, type 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, type 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, type ZUnionCommandOptions as bM, ZUnionStoreCommand as bN, type 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 Type as bj, TypeCommand as bk, UnlinkCommand as bl, XAddCommand as bm, XRangeCommand as bn, type ScoreMember as bo, type ZAddCommandOptions as bp, ZAddCommand as bq, ZCardCommand as br, ZCountCommand as bs, ZDiffStoreCommand as bt, ZIncrByCommand as bu, ZInterStoreCommand as bv, type ZInterStoreCommandOptions as bw, ZLexCountCommand as bx, ZMScoreCommand as by, ZPopMaxCommand 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 };
3637
+ 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 };