@upstash/redis 1.34.3 → 1.34.5

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.
@@ -36,7 +36,23 @@ type UpstashRequest = {
36
36
  * Request body will be serialized to json
37
37
  */
38
38
  body?: unknown;
39
+ /**
40
+ * Additional headers for the request
41
+ */
42
+ headers?: Record<string, string>;
39
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;
40
56
  };
41
57
  type UpstashResponse<TResult> = {
42
58
  result?: TResult;
@@ -119,6 +135,31 @@ type CommandOptions<TResult, TData> = {
119
135
  */
120
136
  automaticDeserialization?: boolean;
121
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
+ };
122
163
  };
123
164
  /**
124
165
  * Command offers default (de)serialization and the exec method to all commands.
@@ -130,6 +171,11 @@ declare class Command<TResult, TData> {
130
171
  readonly command: (string | number | boolean)[];
131
172
  readonly serialize: Serialize;
132
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;
133
179
  /**
134
180
  * Create a new command instance.
135
181
  *
@@ -563,6 +609,50 @@ declare class GetDelCommand<TData = string> extends Command<unknown | null, TDat
563
609
  constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
564
610
  }
565
611
 
612
+ type GetExCommandOptions = {
613
+ ex: number;
614
+ px?: never;
615
+ exat?: never;
616
+ pxat?: never;
617
+ persist?: never;
618
+ } | {
619
+ ex?: never;
620
+ px: number;
621
+ exat?: never;
622
+ pxat?: never;
623
+ persist?: never;
624
+ } | {
625
+ ex?: never;
626
+ px?: never;
627
+ exat: number;
628
+ pxat?: never;
629
+ persist?: never;
630
+ } | {
631
+ ex?: never;
632
+ px?: never;
633
+ exat?: never;
634
+ pxat: number;
635
+ persist?: never;
636
+ } | {
637
+ ex?: never;
638
+ px?: never;
639
+ exat?: never;
640
+ pxat?: never;
641
+ persist: true;
642
+ } | {
643
+ ex?: never;
644
+ px?: never;
645
+ exat?: never;
646
+ pxat?: never;
647
+ persist?: never;
648
+ };
649
+ /**
650
+ * @see https://redis.io/commands/getex
651
+ */
652
+ declare class GetExCommand<TData = string> extends Command<unknown | null, TData | null> {
653
+ constructor([key, opts]: [key: string, opts?: GetExCommandOptions], cmdOpts?: CommandOptions<unknown | null, TData | null>);
654
+ }
655
+
566
656
  /**
567
657
  * @see https://redis.io/commands/getrange
568
658
  */
@@ -1599,6 +1689,42 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
1599
1689
  constructor(cmd: [key: string, member: TData], opts?: CommandOptions<string | null, number | null>);
1600
1690
  }
1601
1691
 
1692
+ type BaseMessageData<TMessage> = {
1693
+ channel: string;
1694
+ message: TMessage;
1695
+ };
1696
+ type PatternMessageData<TMessage> = BaseMessageData<TMessage> & {
1697
+ pattern: string;
1698
+ };
1699
+ type SubscriptionCountEvent = number;
1700
+ type MessageEventMap<TMessage> = {
1701
+ message: BaseMessageData<TMessage>;
1702
+ subscribe: SubscriptionCountEvent;
1703
+ unsubscribe: SubscriptionCountEvent;
1704
+ pmessage: PatternMessageData<TMessage>;
1705
+ psubscribe: SubscriptionCountEvent;
1706
+ punsubscribe: SubscriptionCountEvent;
1707
+ error: Error;
1708
+ [key: `message:${string}`]: BaseMessageData<TMessage>;
1709
+ [key: `pmessage:${string}`]: PatternMessageData<TMessage>;
1710
+ };
1711
+ type EventType = keyof MessageEventMap<any>;
1712
+ type Listener<TMessage, T extends EventType> = (event: MessageEventMap<TMessage>[T]) => void;
1713
+ declare class Subscriber<TMessage = any> extends EventTarget {
1714
+ private subscriptions;
1715
+ private client;
1716
+ private listeners;
1717
+ constructor(client: Requester, channels: string[], isPattern?: boolean);
1718
+ private subscribeToChannel;
1719
+ private subscribeToPattern;
1720
+ private handleMessage;
1721
+ private dispatchToListeners;
1722
+ on<T extends keyof MessageEventMap<TMessage>>(type: T, listener: Listener<TMessage, T>): void;
1723
+ removeAllListeners(): void;
1724
+ unsubscribe(channels?: string[]): Promise<void>;
1725
+ getSubscribedChannels(): string[];
1726
+ }
1727
+
1602
1728
  type InferResponseData<T extends unknown[]> = {
1603
1729
  [K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
1604
1730
  };
@@ -1891,6 +2017,46 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1891
2017
  * @see https://redis.io/commands/getdel
1892
2018
  */
1893
2019
  getdel: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
2020
+ /**
2021
+ * @see https://redis.io/commands/getex
2022
+ */
2023
+ getex: <TData>(key: string, opts?: ({
2024
+ ex: number;
2025
+ px?: never;
2026
+ exat?: never;
2027
+ pxat?: never;
2028
+ persist?: never;
2029
+ } | {
2030
+ ex?: never;
2031
+ px: number;
2032
+ exat?: never;
2033
+ pxat?: never;
2034
+ persist?: never;
2035
+ } | {
2036
+ ex?: never;
2037
+ px?: never;
2038
+ exat: number;
2039
+ pxat?: never;
2040
+ persist?: never;
2041
+ } | {
2042
+ ex?: never;
2043
+ px?: never;
2044
+ exat?: never;
2045
+ pxat: number;
2046
+ persist?: never;
2047
+ } | {
2048
+ ex?: never;
2049
+ px?: never;
2050
+ exat?: never;
2051
+ pxat?: never;
2052
+ persist: true;
2053
+ } | {
2054
+ ex?: never;
2055
+ px?: never;
2056
+ exat?: never;
2057
+ pxat?: never;
2058
+ persist?: never;
2059
+ }) | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
1894
2060
  /**
1895
2061
  * @see https://redis.io/commands/getrange
1896
2062
  */
@@ -2792,6 +2958,10 @@ declare class Redis {
2792
2958
  * @see https://redis.io/commands/evalsha
2793
2959
  */
2794
2960
  evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
2961
+ /**
2962
+ * Generic method to execute any Redis command.
2963
+ */
2964
+ exec: <TResult>(args: [command: string, ...args: (string | number | boolean)[]]) => Promise<TResult>;
2795
2965
  /**
2796
2966
  * @see https://redis.io/commands/exists
2797
2967
  */
@@ -2916,6 +3086,46 @@ declare class Redis {
2916
3086
  * @see https://redis.io/commands/getdel
2917
3087
  */
2918
3088
  getdel: <TData>(key: string) => Promise<TData | null>;
3089
+ /**
3090
+ * @see https://redis.io/commands/getex
3091
+ */
3092
+ getex: <TData>(key: string, opts?: ({
3093
+ ex: number;
3094
+ px?: never;
3095
+ exat?: never;
3096
+ pxat?: never;
3097
+ persist?: never;
3098
+ } | {
3099
+ ex?: never;
3100
+ px: number;
3101
+ exat?: never;
3102
+ pxat?: never;
3103
+ persist?: never;
3104
+ } | {
3105
+ ex?: never;
3106
+ px?: never;
3107
+ exat: number;
3108
+ pxat?: never;
3109
+ persist?: never;
3110
+ } | {
3111
+ ex?: never;
3112
+ px?: never;
3113
+ exat?: never;
3114
+ pxat: number;
3115
+ persist?: never;
3116
+ } | {
3117
+ ex?: never;
3118
+ px?: never;
3119
+ exat?: never;
3120
+ pxat?: never;
3121
+ persist: true;
3122
+ } | {
3123
+ ex?: never;
3124
+ px?: never;
3125
+ exat?: never;
3126
+ pxat?: never;
3127
+ persist?: never;
3128
+ }) | undefined) => Promise<TData | null>;
2919
3129
  /**
2920
3130
  * @see https://redis.io/commands/getrange
2921
3131
  */
@@ -3108,6 +3318,10 @@ declare class Redis {
3108
3318
  * @see https://redis.io/commands/psetex
3109
3319
  */
3110
3320
  psetex: <TData>(key: string, ttl: number, value: TData) => Promise<string>;
3321
+ /**
3322
+ * @see https://redis.io/commands/psubscribe
3323
+ */
3324
+ psubscribe: <TMessage>(patterns: string | string[]) => Subscriber<TMessage>;
3111
3325
  /**
3112
3326
  * @see https://redis.io/commands/pttl
3113
3327
  */
@@ -3236,6 +3450,10 @@ declare class Redis {
3236
3450
  * @see https://redis.io/commands/strlen
3237
3451
  */
3238
3452
  strlen: (key: string) => Promise<number>;
3453
+ /**
3454
+ * @see https://redis.io/commands/subscribe
3455
+ */
3456
+ subscribe: <TMessage>(channels: string | string[]) => Subscriber<TMessage>;
3239
3457
  /**
3240
3458
  * @see https://redis.io/commands/sunion
3241
3459
  */
@@ -3506,4 +3724,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
3506
3724
  constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
3507
3725
  }
3508
3726
 
3509
- 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 };
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 };
@@ -36,7 +36,23 @@ type UpstashRequest = {
36
36
  * Request body will be serialized to json
37
37
  */
38
38
  body?: unknown;
39
+ /**
40
+ * Additional headers for the request
41
+ */
42
+ headers?: Record<string, string>;
39
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;
40
56
  };
41
57
  type UpstashResponse<TResult> = {
42
58
  result?: TResult;
@@ -119,6 +135,31 @@ type CommandOptions<TResult, TData> = {
119
135
  */
120
136
  automaticDeserialization?: boolean;
121
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
+ };
122
163
  };
123
164
  /**
124
165
  * Command offers default (de)serialization and the exec method to all commands.
@@ -130,6 +171,11 @@ declare class Command<TResult, TData> {
130
171
  readonly command: (string | number | boolean)[];
131
172
  readonly serialize: Serialize;
132
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;
133
179
  /**
134
180
  * Create a new command instance.
135
181
  *
@@ -563,6 +609,50 @@ declare class GetDelCommand<TData = string> extends Command<unknown | null, TDat
563
609
  constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
564
610
  }
565
611
 
612
+ type GetExCommandOptions = {
613
+ ex: number;
614
+ px?: never;
615
+ exat?: never;
616
+ pxat?: never;
617
+ persist?: never;
618
+ } | {
619
+ ex?: never;
620
+ px: number;
621
+ exat?: never;
622
+ pxat?: never;
623
+ persist?: never;
624
+ } | {
625
+ ex?: never;
626
+ px?: never;
627
+ exat: number;
628
+ pxat?: never;
629
+ persist?: never;
630
+ } | {
631
+ ex?: never;
632
+ px?: never;
633
+ exat?: never;
634
+ pxat: number;
635
+ persist?: never;
636
+ } | {
637
+ ex?: never;
638
+ px?: never;
639
+ exat?: never;
640
+ pxat?: never;
641
+ persist: true;
642
+ } | {
643
+ ex?: never;
644
+ px?: never;
645
+ exat?: never;
646
+ pxat?: never;
647
+ persist?: never;
648
+ };
649
+ /**
650
+ * @see https://redis.io/commands/getex
651
+ */
652
+ declare class GetExCommand<TData = string> extends Command<unknown | null, TData | null> {
653
+ constructor([key, opts]: [key: string, opts?: GetExCommandOptions], cmdOpts?: CommandOptions<unknown | null, TData | null>);
654
+ }
655
+
566
656
  /**
567
657
  * @see https://redis.io/commands/getrange
568
658
  */
@@ -1599,6 +1689,42 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
1599
1689
  constructor(cmd: [key: string, member: TData], opts?: CommandOptions<string | null, number | null>);
1600
1690
  }
1601
1691
 
1692
+ type BaseMessageData<TMessage> = {
1693
+ channel: string;
1694
+ message: TMessage;
1695
+ };
1696
+ type PatternMessageData<TMessage> = BaseMessageData<TMessage> & {
1697
+ pattern: string;
1698
+ };
1699
+ type SubscriptionCountEvent = number;
1700
+ type MessageEventMap<TMessage> = {
1701
+ message: BaseMessageData<TMessage>;
1702
+ subscribe: SubscriptionCountEvent;
1703
+ unsubscribe: SubscriptionCountEvent;
1704
+ pmessage: PatternMessageData<TMessage>;
1705
+ psubscribe: SubscriptionCountEvent;
1706
+ punsubscribe: SubscriptionCountEvent;
1707
+ error: Error;
1708
+ [key: `message:${string}`]: BaseMessageData<TMessage>;
1709
+ [key: `pmessage:${string}`]: PatternMessageData<TMessage>;
1710
+ };
1711
+ type EventType = keyof MessageEventMap<any>;
1712
+ type Listener<TMessage, T extends EventType> = (event: MessageEventMap<TMessage>[T]) => void;
1713
+ declare class Subscriber<TMessage = any> extends EventTarget {
1714
+ private subscriptions;
1715
+ private client;
1716
+ private listeners;
1717
+ constructor(client: Requester, channels: string[], isPattern?: boolean);
1718
+ private subscribeToChannel;
1719
+ private subscribeToPattern;
1720
+ private handleMessage;
1721
+ private dispatchToListeners;
1722
+ on<T extends keyof MessageEventMap<TMessage>>(type: T, listener: Listener<TMessage, T>): void;
1723
+ removeAllListeners(): void;
1724
+ unsubscribe(channels?: string[]): Promise<void>;
1725
+ getSubscribedChannels(): string[];
1726
+ }
1727
+
1602
1728
  type InferResponseData<T extends unknown[]> = {
1603
1729
  [K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
1604
1730
  };
@@ -1891,6 +2017,46 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
1891
2017
  * @see https://redis.io/commands/getdel
1892
2018
  */
1893
2019
  getdel: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
2020
+ /**
2021
+ * @see https://redis.io/commands/getex
2022
+ */
2023
+ getex: <TData>(key: string, opts?: ({
2024
+ ex: number;
2025
+ px?: never;
2026
+ exat?: never;
2027
+ pxat?: never;
2028
+ persist?: never;
2029
+ } | {
2030
+ ex?: never;
2031
+ px: number;
2032
+ exat?: never;
2033
+ pxat?: never;
2034
+ persist?: never;
2035
+ } | {
2036
+ ex?: never;
2037
+ px?: never;
2038
+ exat: number;
2039
+ pxat?: never;
2040
+ persist?: never;
2041
+ } | {
2042
+ ex?: never;
2043
+ px?: never;
2044
+ exat?: never;
2045
+ pxat: number;
2046
+ persist?: never;
2047
+ } | {
2048
+ ex?: never;
2049
+ px?: never;
2050
+ exat?: never;
2051
+ pxat?: never;
2052
+ persist: true;
2053
+ } | {
2054
+ ex?: never;
2055
+ px?: never;
2056
+ exat?: never;
2057
+ pxat?: never;
2058
+ persist?: never;
2059
+ }) | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
1894
2060
  /**
1895
2061
  * @see https://redis.io/commands/getrange
1896
2062
  */
@@ -2792,6 +2958,10 @@ declare class Redis {
2792
2958
  * @see https://redis.io/commands/evalsha
2793
2959
  */
2794
2960
  evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
2961
+ /**
2962
+ * Generic method to execute any Redis command.
2963
+ */
2964
+ exec: <TResult>(args: [command: string, ...args: (string | number | boolean)[]]) => Promise<TResult>;
2795
2965
  /**
2796
2966
  * @see https://redis.io/commands/exists
2797
2967
  */
@@ -2916,6 +3086,46 @@ declare class Redis {
2916
3086
  * @see https://redis.io/commands/getdel
2917
3087
  */
2918
3088
  getdel: <TData>(key: string) => Promise<TData | null>;
3089
+ /**
3090
+ * @see https://redis.io/commands/getex
3091
+ */
3092
+ getex: <TData>(key: string, opts?: ({
3093
+ ex: number;
3094
+ px?: never;
3095
+ exat?: never;
3096
+ pxat?: never;
3097
+ persist?: never;
3098
+ } | {
3099
+ ex?: never;
3100
+ px: number;
3101
+ exat?: never;
3102
+ pxat?: never;
3103
+ persist?: never;
3104
+ } | {
3105
+ ex?: never;
3106
+ px?: never;
3107
+ exat: number;
3108
+ pxat?: never;
3109
+ persist?: never;
3110
+ } | {
3111
+ ex?: never;
3112
+ px?: never;
3113
+ exat?: never;
3114
+ pxat: number;
3115
+ persist?: never;
3116
+ } | {
3117
+ ex?: never;
3118
+ px?: never;
3119
+ exat?: never;
3120
+ pxat?: never;
3121
+ persist: true;
3122
+ } | {
3123
+ ex?: never;
3124
+ px?: never;
3125
+ exat?: never;
3126
+ pxat?: never;
3127
+ persist?: never;
3128
+ }) | undefined) => Promise<TData | null>;
2919
3129
  /**
2920
3130
  * @see https://redis.io/commands/getrange
2921
3131
  */
@@ -3108,6 +3318,10 @@ declare class Redis {
3108
3318
  * @see https://redis.io/commands/psetex
3109
3319
  */
3110
3320
  psetex: <TData>(key: string, ttl: number, value: TData) => Promise<string>;
3321
+ /**
3322
+ * @see https://redis.io/commands/psubscribe
3323
+ */
3324
+ psubscribe: <TMessage>(patterns: string | string[]) => Subscriber<TMessage>;
3111
3325
  /**
3112
3326
  * @see https://redis.io/commands/pttl
3113
3327
  */
@@ -3236,6 +3450,10 @@ declare class Redis {
3236
3450
  * @see https://redis.io/commands/strlen
3237
3451
  */
3238
3452
  strlen: (key: string) => Promise<number>;
3453
+ /**
3454
+ * @see https://redis.io/commands/subscribe
3455
+ */
3456
+ subscribe: <TMessage>(channels: string | string[]) => Subscriber<TMessage>;
3239
3457
  /**
3240
3458
  * @see https://redis.io/commands/sunion
3241
3459
  */
@@ -3506,4 +3724,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
3506
3724
  constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
3507
3725
  }
3508
3726
 
3509
- 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 };
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 };