@upstash/redis 0.0.0-ci.998046a844b4998e6b7de8c128d5f41be5545cdf-20241002104435 → 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.
- package/README.md +9 -0
- package/{chunk-K53GSI5K.mjs → chunk-WTYE7OV3.mjs} +807 -90
- package/cloudflare.d.mts +3 -3
- package/cloudflare.d.ts +3 -3
- package/cloudflare.js +822 -113
- package/cloudflare.mjs +16 -14
- package/fastly.d.mts +2 -2
- package/fastly.d.ts +2 -2
- package/fastly.js +817 -108
- package/fastly.mjs +11 -9
- package/nodejs.d.mts +14 -6
- package/nodejs.d.ts +14 -6
- package/nodejs.js +832 -118
- package/nodejs.mjs +26 -19
- package/package.json +1 -1
- package/{zmscore-BLgYk16R.d.mts → zmscore-xbfRql7X.d.mts} +626 -56
- package/{zmscore-BLgYk16R.d.ts → zmscore-xbfRql7X.d.ts} +626 -56
|
@@ -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;
|
|
@@ -61,7 +77,7 @@ type RetryConfig = false | {
|
|
|
61
77
|
*/
|
|
62
78
|
retries?: number;
|
|
63
79
|
/**
|
|
64
|
-
* A backoff function receives the current retry
|
|
80
|
+
* A backoff function receives the current retry count and returns a number in milliseconds to wait before retrying.
|
|
65
81
|
*
|
|
66
82
|
* @default
|
|
67
83
|
* ```ts
|
|
@@ -70,6 +86,9 @@ type RetryConfig = false | {
|
|
|
70
86
|
*/
|
|
71
87
|
backoff?: (retryCount: number) => number;
|
|
72
88
|
};
|
|
89
|
+
type Options$1 = {
|
|
90
|
+
backend?: string;
|
|
91
|
+
};
|
|
73
92
|
type RequesterConfig = {
|
|
74
93
|
/**
|
|
75
94
|
* Configure the retry behaviour in case of network errors
|
|
@@ -104,6 +123,19 @@ type RequesterConfig = {
|
|
|
104
123
|
*/
|
|
105
124
|
cache?: CacheSetting;
|
|
106
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;
|
|
107
139
|
|
|
108
140
|
type Serialize = (data: unknown) => string | number | boolean;
|
|
109
141
|
type Deserialize<TResult, TData> = (result: TResult) => TData;
|
|
@@ -119,6 +151,31 @@ type CommandOptions<TResult, TData> = {
|
|
|
119
151
|
*/
|
|
120
152
|
automaticDeserialization?: boolean;
|
|
121
153
|
latencyLogging?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Additional headers to be sent with the request
|
|
156
|
+
*/
|
|
157
|
+
headers?: Record<string, string>;
|
|
158
|
+
/**
|
|
159
|
+
* Path to append to the URL
|
|
160
|
+
*/
|
|
161
|
+
path?: string[];
|
|
162
|
+
/**
|
|
163
|
+
* Options for streaming requests, mainly used for subscribe, monitor commands
|
|
164
|
+
**/
|
|
165
|
+
streamOptions?: {
|
|
166
|
+
/**
|
|
167
|
+
* Callback to be called when a message is received
|
|
168
|
+
*/
|
|
169
|
+
onMessage?: (data: string) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Whether the request is streaming
|
|
172
|
+
*/
|
|
173
|
+
isStreaming?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Signal to abort the request
|
|
176
|
+
*/
|
|
177
|
+
signal?: AbortSignal;
|
|
178
|
+
};
|
|
122
179
|
};
|
|
123
180
|
/**
|
|
124
181
|
* Command offers default (de)serialization and the exec method to all commands.
|
|
@@ -130,6 +187,11 @@ declare class Command<TResult, TData> {
|
|
|
130
187
|
readonly command: (string | number | boolean)[];
|
|
131
188
|
readonly serialize: Serialize;
|
|
132
189
|
readonly deserialize: Deserialize<TResult, TData>;
|
|
190
|
+
protected readonly headers?: Record<string, string>;
|
|
191
|
+
protected readonly path?: string[];
|
|
192
|
+
protected readonly onMessage?: (data: string) => void;
|
|
193
|
+
protected readonly isStreaming: boolean;
|
|
194
|
+
protected readonly signal?: AbortSignal;
|
|
133
195
|
/**
|
|
134
196
|
* Create a new command instance.
|
|
135
197
|
*
|
|
@@ -225,18 +287,6 @@ declare class ScriptFlushCommand extends Command<"OK", "OK"> {
|
|
|
225
287
|
constructor([opts]: [opts?: ScriptFlushCommandOptions], cmdOpts?: CommandOptions<"OK", "OK">);
|
|
226
288
|
}
|
|
227
289
|
|
|
228
|
-
type ScanCommandOptions = {
|
|
229
|
-
match?: string;
|
|
230
|
-
count?: number;
|
|
231
|
-
type?: string;
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* @see https://redis.io/commands/scan
|
|
235
|
-
*/
|
|
236
|
-
declare class ScanCommand extends Command<[string, string[]], [string, string[]]> {
|
|
237
|
-
constructor([cursor, opts]: [cursor: string | number, opts?: ScanCommandOptions], cmdOpts?: CommandOptions<[string, string[]], [string, string[]]>);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
290
|
type GeoAddCommandOptions = {
|
|
241
291
|
nx?: boolean;
|
|
242
292
|
xx?: never;
|
|
@@ -262,6 +312,11 @@ declare class GeoAddCommand<TMemberType = string> extends Command<number | null,
|
|
|
262
312
|
], opts?: CommandOptions<number | null, number | null>);
|
|
263
313
|
}
|
|
264
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
|
+
|
|
265
320
|
/**
|
|
266
321
|
* @see https://redis.io/commands/append
|
|
267
322
|
*/
|
|
@@ -358,6 +413,13 @@ declare class EchoCommand extends Command<string, string> {
|
|
|
358
413
|
constructor(cmd: [message: string], opts?: CommandOptions<string, string>);
|
|
359
414
|
}
|
|
360
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
|
+
|
|
361
423
|
/**
|
|
362
424
|
* @see https://redis.io/commands/eval
|
|
363
425
|
*/
|
|
@@ -365,6 +427,13 @@ declare class EvalCommand<TArgs extends unknown[], TData> extends Command<unknow
|
|
|
365
427
|
constructor([script, keys, args]: [script: string, keys: string[], args: TArgs], opts?: CommandOptions<unknown, TData>);
|
|
366
428
|
}
|
|
367
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
|
+
|
|
368
437
|
/**
|
|
369
438
|
* @see https://redis.io/commands/evalsha
|
|
370
439
|
*/
|
|
@@ -379,16 +448,11 @@ declare class ExistsCommand extends Command<number, number> {
|
|
|
379
448
|
constructor(cmd: [...keys: string[]], opts?: CommandOptions<number, number>);
|
|
380
449
|
}
|
|
381
450
|
|
|
382
|
-
type ExpireOptions = "NX" | "nx" | "XX" | "xx" | "GT" | "gt" | "LT" | "lt";
|
|
383
|
-
declare class ExpireCommand extends Command<"0" | "1", 0 | 1> {
|
|
384
|
-
constructor(cmd: [key: string, seconds: number, option?: ExpireOptions], opts?: CommandOptions<"0" | "1", 0 | 1>);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
451
|
/**
|
|
388
452
|
* @see https://redis.io/commands/expireat
|
|
389
453
|
*/
|
|
390
454
|
declare class ExpireAtCommand extends Command<"0" | "1", 0 | 1> {
|
|
391
|
-
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>);
|
|
392
456
|
}
|
|
393
457
|
|
|
394
458
|
/**
|
|
@@ -563,6 +627,50 @@ declare class GetDelCommand<TData = string> extends Command<unknown | null, TDat
|
|
|
563
627
|
constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
|
|
564
628
|
}
|
|
565
629
|
|
|
630
|
+
type GetExCommandOptions = {
|
|
631
|
+
ex: number;
|
|
632
|
+
px?: never;
|
|
633
|
+
exat?: never;
|
|
634
|
+
pxat?: never;
|
|
635
|
+
persist?: never;
|
|
636
|
+
} | {
|
|
637
|
+
ex?: never;
|
|
638
|
+
px: number;
|
|
639
|
+
exat?: never;
|
|
640
|
+
pxat?: never;
|
|
641
|
+
persist?: never;
|
|
642
|
+
} | {
|
|
643
|
+
ex?: never;
|
|
644
|
+
px?: never;
|
|
645
|
+
exat: number;
|
|
646
|
+
pxat?: never;
|
|
647
|
+
persist?: never;
|
|
648
|
+
} | {
|
|
649
|
+
ex?: never;
|
|
650
|
+
px?: never;
|
|
651
|
+
exat?: never;
|
|
652
|
+
pxat: number;
|
|
653
|
+
persist?: never;
|
|
654
|
+
} | {
|
|
655
|
+
ex?: never;
|
|
656
|
+
px?: never;
|
|
657
|
+
exat?: never;
|
|
658
|
+
pxat?: never;
|
|
659
|
+
persist: true;
|
|
660
|
+
} | {
|
|
661
|
+
ex?: never;
|
|
662
|
+
px?: never;
|
|
663
|
+
exat?: never;
|
|
664
|
+
pxat?: never;
|
|
665
|
+
persist?: never;
|
|
666
|
+
};
|
|
667
|
+
/**
|
|
668
|
+
* @see https://redis.io/commands/getex
|
|
669
|
+
*/
|
|
670
|
+
declare class GetExCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
671
|
+
constructor([key, opts]: [key: string, opts?: GetExCommandOptions], cmdOpts?: CommandOptions<unknown | null, TData | null>);
|
|
672
|
+
}
|
|
673
|
+
|
|
566
674
|
/**
|
|
567
675
|
* @see https://redis.io/commands/getrange
|
|
568
676
|
*/
|
|
@@ -591,6 +699,58 @@ declare class HExistsCommand extends Command<number, number> {
|
|
|
591
699
|
constructor(cmd: [key: string, field: string], opts?: CommandOptions<number, number>);
|
|
592
700
|
}
|
|
593
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
|
+
|
|
594
754
|
/**
|
|
595
755
|
* @see https://redis.io/commands/hget
|
|
596
756
|
*/
|
|
@@ -664,6 +824,39 @@ declare class HRandFieldCommand<TData extends string | string[] | Record<string,
|
|
|
664
824
|
constructor(cmd: [key: string, count: number, withValues: boolean], opts?: CommandOptions<string[], Partial<TData>>);
|
|
665
825
|
}
|
|
666
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
|
+
|
|
667
860
|
/**
|
|
668
861
|
* @see https://redis.io/commands/hscan
|
|
669
862
|
*/
|
|
@@ -698,6 +891,10 @@ declare class HStrLenCommand extends Command<number, number> {
|
|
|
698
891
|
constructor(cmd: [key: string, field: string], opts?: CommandOptions<number, number>);
|
|
699
892
|
}
|
|
700
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
|
+
|
|
701
898
|
/**
|
|
702
899
|
* @see https://redis.io/commands/hvals
|
|
703
900
|
*/
|
|
@@ -804,6 +1001,13 @@ declare class JsonGetCommand<TData extends (unknown | Record<string, unknown>) |
|
|
|
804
1001
|
] | [key: string, ...path: string[]], opts?: CommandOptions<TData | null, TData | null>);
|
|
805
1002
|
}
|
|
806
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
|
+
|
|
807
1011
|
/**
|
|
808
1012
|
* @see https://redis.io/commands/json.mget
|
|
809
1013
|
*/
|
|
@@ -1006,14 +1210,14 @@ declare class PersistCommand extends Command<"0" | "1", 0 | 1> {
|
|
|
1006
1210
|
* @see https://redis.io/commands/pexpire
|
|
1007
1211
|
*/
|
|
1008
1212
|
declare class PExpireCommand extends Command<"0" | "1", 0 | 1> {
|
|
1009
|
-
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>);
|
|
1010
1214
|
}
|
|
1011
1215
|
|
|
1012
1216
|
/**
|
|
1013
1217
|
* @see https://redis.io/commands/pexpireat
|
|
1014
1218
|
*/
|
|
1015
1219
|
declare class PExpireAtCommand extends Command<"0" | "1", 0 | 1> {
|
|
1016
|
-
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>);
|
|
1017
1221
|
}
|
|
1018
1222
|
|
|
1019
1223
|
/**
|
|
@@ -1373,16 +1577,33 @@ type XReadCommandOptions = [
|
|
|
1373
1577
|
id: string | string[],
|
|
1374
1578
|
options?: {
|
|
1375
1579
|
count?: number;
|
|
1580
|
+
/**
|
|
1581
|
+
* @deprecated block is not yet supported in Upstash Redis
|
|
1582
|
+
*/
|
|
1376
1583
|
blockMS?: number;
|
|
1377
1584
|
}
|
|
1378
1585
|
];
|
|
1379
|
-
type XReadOptions = XReadCommandOptions extends [infer K, infer I, ...any[]] ? K extends string ? I extends string ? [
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
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;
|
|
1386
1607
|
/**
|
|
1387
1608
|
* @see https://redis.io/commands/xread
|
|
1388
1609
|
*/
|
|
@@ -1392,6 +1613,9 @@ declare class XReadCommand extends Command<number, unknown[]> {
|
|
|
1392
1613
|
|
|
1393
1614
|
type Options = {
|
|
1394
1615
|
count?: number;
|
|
1616
|
+
/**
|
|
1617
|
+
* @deprecated block is not yet supported in Upstash Redis
|
|
1618
|
+
*/
|
|
1395
1619
|
blockMS?: number;
|
|
1396
1620
|
NOACK?: boolean;
|
|
1397
1621
|
};
|
|
@@ -1599,9 +1823,79 @@ declare class ZScoreCommand<TData> extends Command<string | null, number | null>
|
|
|
1599
1823
|
constructor(cmd: [key: string, member: TData], opts?: CommandOptions<string | null, number | null>);
|
|
1600
1824
|
}
|
|
1601
1825
|
|
|
1826
|
+
type BaseMessageData<TMessage> = {
|
|
1827
|
+
channel: string;
|
|
1828
|
+
message: TMessage;
|
|
1829
|
+
};
|
|
1830
|
+
type PatternMessageData<TMessage> = BaseMessageData<TMessage> & {
|
|
1831
|
+
pattern: string;
|
|
1832
|
+
};
|
|
1833
|
+
type SubscriptionCountEvent = number;
|
|
1834
|
+
type MessageEventMap<TMessage> = {
|
|
1835
|
+
message: BaseMessageData<TMessage>;
|
|
1836
|
+
subscribe: SubscriptionCountEvent;
|
|
1837
|
+
unsubscribe: SubscriptionCountEvent;
|
|
1838
|
+
pmessage: PatternMessageData<TMessage>;
|
|
1839
|
+
psubscribe: SubscriptionCountEvent;
|
|
1840
|
+
punsubscribe: SubscriptionCountEvent;
|
|
1841
|
+
error: Error;
|
|
1842
|
+
[key: `message:${string}`]: BaseMessageData<TMessage>;
|
|
1843
|
+
[key: `pmessage:${string}`]: PatternMessageData<TMessage>;
|
|
1844
|
+
};
|
|
1845
|
+
type EventType = keyof MessageEventMap<any>;
|
|
1846
|
+
type Listener<TMessage, T extends EventType> = (event: MessageEventMap<TMessage>[T]) => void;
|
|
1847
|
+
declare class Subscriber<TMessage = any> extends EventTarget {
|
|
1848
|
+
private subscriptions;
|
|
1849
|
+
private client;
|
|
1850
|
+
private listeners;
|
|
1851
|
+
private opts?;
|
|
1852
|
+
constructor(client: Requester, channels: string[], isPattern?: boolean, opts?: Pick<RedisOptions, "automaticDeserialization">);
|
|
1853
|
+
private subscribeToChannel;
|
|
1854
|
+
private subscribeToPattern;
|
|
1855
|
+
private handleMessage;
|
|
1856
|
+
private dispatchToListeners;
|
|
1857
|
+
on<T extends keyof MessageEventMap<TMessage>>(type: T, listener: Listener<TMessage, T>): void;
|
|
1858
|
+
removeAllListeners(): void;
|
|
1859
|
+
unsubscribe(channels?: string[]): Promise<void>;
|
|
1860
|
+
getSubscribedChannels(): string[];
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1602
1863
|
type InferResponseData<T extends unknown[]> = {
|
|
1603
1864
|
[K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
|
|
1604
1865
|
};
|
|
1866
|
+
interface ExecMethod<TCommands extends Command<any, any>[]> {
|
|
1867
|
+
/**
|
|
1868
|
+
* Send the pipeline request to upstash.
|
|
1869
|
+
*
|
|
1870
|
+
* Returns an array with the results of all pipelined commands.
|
|
1871
|
+
*
|
|
1872
|
+
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
1873
|
+
* ```ts
|
|
1874
|
+
* const p = redis.pipeline()
|
|
1875
|
+
* p.get("key")
|
|
1876
|
+
* const result = p.exec<[{ greeting: string }]>()
|
|
1877
|
+
* ```
|
|
1878
|
+
*
|
|
1879
|
+
* 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.
|
|
1880
|
+
*
|
|
1881
|
+
* 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 }`.
|
|
1882
|
+
*
|
|
1883
|
+
* ```ts
|
|
1884
|
+
* const p = redis.pipeline()
|
|
1885
|
+
* p.get("key")
|
|
1886
|
+
*
|
|
1887
|
+
* const result = await p.exec({ keepErrors: true });
|
|
1888
|
+
* const getResult = result[0].result
|
|
1889
|
+
* const getError = result[0].error
|
|
1890
|
+
* ```
|
|
1891
|
+
*/
|
|
1892
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(): Promise<TCommandResults>;
|
|
1893
|
+
<TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData<TCommands>>(options: {
|
|
1894
|
+
keepErrors: true;
|
|
1895
|
+
}): Promise<{
|
|
1896
|
+
[K in keyof TCommandResults]: UpstashResponse<TCommandResults[K]>;
|
|
1897
|
+
}>;
|
|
1898
|
+
}
|
|
1605
1899
|
/**
|
|
1606
1900
|
* Upstash REST API supports command pipelining to send multiple commands in
|
|
1607
1901
|
* batch, instead of sending each command one by one and waiting for a response.
|
|
@@ -1650,19 +1944,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1650
1944
|
commandOptions?: CommandOptions<any, any>;
|
|
1651
1945
|
multiExec?: boolean;
|
|
1652
1946
|
});
|
|
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>;
|
|
1947
|
+
exec: ExecMethod<TCommands>;
|
|
1666
1948
|
/**
|
|
1667
1949
|
* Returns the length of pipeline before the execution
|
|
1668
1950
|
*/
|
|
@@ -1738,10 +2020,18 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1738
2020
|
* @see https://redis.io/commands/echo
|
|
1739
2021
|
*/
|
|
1740
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>]>;
|
|
1741
2027
|
/**
|
|
1742
2028
|
* @see https://redis.io/commands/eval
|
|
1743
2029
|
*/
|
|
1744
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>]>;
|
|
1745
2035
|
/**
|
|
1746
2036
|
* @see https://redis.io/commands/evalsha
|
|
1747
2037
|
*/
|
|
@@ -1753,11 +2043,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1753
2043
|
/**
|
|
1754
2044
|
* @see https://redis.io/commands/expire
|
|
1755
2045
|
*/
|
|
1756
|
-
expire: (key: string, seconds: number, option?:
|
|
2046
|
+
expire: (key: string, seconds: number, option?: ExpireOption | undefined) => Pipeline<[...TCommands, Command<any, 0 | 1>]>;
|
|
1757
2047
|
/**
|
|
1758
2048
|
* @see https://redis.io/commands/expireat
|
|
1759
2049
|
*/
|
|
1760
|
-
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>]>;
|
|
1761
2051
|
/**
|
|
1762
2052
|
* @see https://redis.io/commands/flushall
|
|
1763
2053
|
*/
|
|
@@ -1870,6 +2160,46 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1870
2160
|
* @see https://redis.io/commands/getdel
|
|
1871
2161
|
*/
|
|
1872
2162
|
getdel: <TData>(key: string) => Pipeline<[...TCommands, Command<any, TData | null>]>;
|
|
2163
|
+
/**
|
|
2164
|
+
* @see https://redis.io/commands/getex
|
|
2165
|
+
*/
|
|
2166
|
+
getex: <TData>(key: string, opts?: ({
|
|
2167
|
+
ex: number;
|
|
2168
|
+
px?: never;
|
|
2169
|
+
exat?: never;
|
|
2170
|
+
pxat?: never;
|
|
2171
|
+
persist?: never;
|
|
2172
|
+
} | {
|
|
2173
|
+
ex?: never;
|
|
2174
|
+
px: number;
|
|
2175
|
+
exat?: never;
|
|
2176
|
+
pxat?: never;
|
|
2177
|
+
persist?: never;
|
|
2178
|
+
} | {
|
|
2179
|
+
ex?: never;
|
|
2180
|
+
px?: never;
|
|
2181
|
+
exat: number;
|
|
2182
|
+
pxat?: never;
|
|
2183
|
+
persist?: never;
|
|
2184
|
+
} | {
|
|
2185
|
+
ex?: never;
|
|
2186
|
+
px?: never;
|
|
2187
|
+
exat?: never;
|
|
2188
|
+
pxat: number;
|
|
2189
|
+
persist?: never;
|
|
2190
|
+
} | {
|
|
2191
|
+
ex?: never;
|
|
2192
|
+
px?: never;
|
|
2193
|
+
exat?: never;
|
|
2194
|
+
pxat?: never;
|
|
2195
|
+
persist: true;
|
|
2196
|
+
} | {
|
|
2197
|
+
ex?: never;
|
|
2198
|
+
px?: never;
|
|
2199
|
+
exat?: never;
|
|
2200
|
+
pxat?: never;
|
|
2201
|
+
persist?: never;
|
|
2202
|
+
}) | undefined) => Pipeline<[...TCommands, Command<any, TData | null>]>;
|
|
1873
2203
|
/**
|
|
1874
2204
|
* @see https://redis.io/commands/getrange
|
|
1875
2205
|
*/
|
|
@@ -1886,6 +2216,42 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
1886
2216
|
* @see https://redis.io/commands/hexists
|
|
1887
2217
|
*/
|
|
1888
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)[]>]>;
|
|
1889
2255
|
/**
|
|
1890
2256
|
* @see https://redis.io/commands/hget
|
|
1891
2257
|
*/
|
|
@@ -2033,11 +2399,11 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
2033
2399
|
/**
|
|
2034
2400
|
* @see https://redis.io/commands/pexpire
|
|
2035
2401
|
*/
|
|
2036
|
-
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>]>;
|
|
2037
2403
|
/**
|
|
2038
2404
|
* @see https://redis.io/commands/pexpireat
|
|
2039
2405
|
*/
|
|
2040
|
-
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>]>;
|
|
2041
2407
|
/**
|
|
2042
2408
|
* @see https://redis.io/commands/pfadd
|
|
2043
2409
|
*/
|
|
@@ -2097,7 +2463,7 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
2097
2463
|
/**
|
|
2098
2464
|
* @see https://redis.io/commands/scan
|
|
2099
2465
|
*/
|
|
2100
|
-
scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any,
|
|
2466
|
+
scan: (cursor: string | number, opts?: ScanCommandOptions | undefined) => Pipeline<[...TCommands, Command<any, any>]>;
|
|
2101
2467
|
/**
|
|
2102
2468
|
* @see https://redis.io/commands/scard
|
|
2103
2469
|
*/
|
|
@@ -2459,6 +2825,10 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
2459
2825
|
* @see https://redis.io/commands/json.get
|
|
2460
2826
|
*/
|
|
2461
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>]>;
|
|
2462
2832
|
/**
|
|
2463
2833
|
* @see https://redis.io/commands/json.mget
|
|
2464
2834
|
*/
|
|
@@ -2534,9 +2904,20 @@ declare class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
|
2534
2904
|
*/
|
|
2535
2905
|
declare class Script<TResult = unknown> {
|
|
2536
2906
|
readonly script: string;
|
|
2537
|
-
|
|
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;
|
|
2538
2915
|
private readonly redis;
|
|
2539
2916
|
constructor(redis: Redis, script: string);
|
|
2917
|
+
/**
|
|
2918
|
+
* Initialize the script by computing its SHA-1 hash.
|
|
2919
|
+
*/
|
|
2920
|
+
private init;
|
|
2540
2921
|
/**
|
|
2541
2922
|
* Send an `EVAL` command to redis.
|
|
2542
2923
|
*/
|
|
@@ -2558,6 +2939,56 @@ declare class Script<TResult = unknown> {
|
|
|
2558
2939
|
private digest;
|
|
2559
2940
|
}
|
|
2560
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
|
+
|
|
2561
2992
|
/**
|
|
2562
2993
|
* Serverless redis client for upstash.
|
|
2563
2994
|
*/
|
|
@@ -2621,6 +3052,10 @@ declare class Redis {
|
|
|
2621
3052
|
* @see https://redis.io/commands/json.get
|
|
2622
3053
|
*/
|
|
2623
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>;
|
|
2624
3059
|
/**
|
|
2625
3060
|
* @see https://redis.io/commands/json.mget
|
|
2626
3061
|
*/
|
|
@@ -2684,7 +3119,37 @@ declare class Redis {
|
|
|
2684
3119
|
* Technically this is not private, we can hide it from intellisense by doing this
|
|
2685
3120
|
*/
|
|
2686
3121
|
protected addTelemetry: (telemetry: Telemetry) => void;
|
|
2687
|
-
|
|
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>;
|
|
2688
3153
|
/**
|
|
2689
3154
|
* Create a new pipeline that allows you to send requests in bulk.
|
|
2690
3155
|
*
|
|
@@ -2763,14 +3228,26 @@ declare class Redis {
|
|
|
2763
3228
|
* @see https://redis.io/commands/echo
|
|
2764
3229
|
*/
|
|
2765
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>;
|
|
2766
3235
|
/**
|
|
2767
3236
|
* @see https://redis.io/commands/eval
|
|
2768
3237
|
*/
|
|
2769
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>;
|
|
2770
3243
|
/**
|
|
2771
3244
|
* @see https://redis.io/commands/evalsha
|
|
2772
3245
|
*/
|
|
2773
3246
|
evalsha: <TArgs extends unknown[], TData = unknown>(sha1: string, keys: string[], args: TArgs) => Promise<TData>;
|
|
3247
|
+
/**
|
|
3248
|
+
* Generic method to execute any Redis command.
|
|
3249
|
+
*/
|
|
3250
|
+
exec: <TResult>(args: [command: string, ...args: (string | number | boolean)[]]) => Promise<TResult>;
|
|
2774
3251
|
/**
|
|
2775
3252
|
* @see https://redis.io/commands/exists
|
|
2776
3253
|
*/
|
|
@@ -2778,11 +3255,11 @@ declare class Redis {
|
|
|
2778
3255
|
/**
|
|
2779
3256
|
* @see https://redis.io/commands/expire
|
|
2780
3257
|
*/
|
|
2781
|
-
expire: (key: string, seconds: number, option?:
|
|
3258
|
+
expire: (key: string, seconds: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
|
|
2782
3259
|
/**
|
|
2783
3260
|
* @see https://redis.io/commands/expireat
|
|
2784
3261
|
*/
|
|
2785
|
-
expireat: (key: string, unix: number) => Promise<0 | 1>;
|
|
3262
|
+
expireat: (key: string, unix: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
|
|
2786
3263
|
/**
|
|
2787
3264
|
* @see https://redis.io/commands/flushall
|
|
2788
3265
|
*/
|
|
@@ -2895,6 +3372,46 @@ declare class Redis {
|
|
|
2895
3372
|
* @see https://redis.io/commands/getdel
|
|
2896
3373
|
*/
|
|
2897
3374
|
getdel: <TData>(key: string) => Promise<TData | null>;
|
|
3375
|
+
/**
|
|
3376
|
+
* @see https://redis.io/commands/getex
|
|
3377
|
+
*/
|
|
3378
|
+
getex: <TData>(key: string, opts?: ({
|
|
3379
|
+
ex: number;
|
|
3380
|
+
px?: never;
|
|
3381
|
+
exat?: never;
|
|
3382
|
+
pxat?: never;
|
|
3383
|
+
persist?: never;
|
|
3384
|
+
} | {
|
|
3385
|
+
ex?: never;
|
|
3386
|
+
px: number;
|
|
3387
|
+
exat?: never;
|
|
3388
|
+
pxat?: never;
|
|
3389
|
+
persist?: never;
|
|
3390
|
+
} | {
|
|
3391
|
+
ex?: never;
|
|
3392
|
+
px?: never;
|
|
3393
|
+
exat: number;
|
|
3394
|
+
pxat?: never;
|
|
3395
|
+
persist?: never;
|
|
3396
|
+
} | {
|
|
3397
|
+
ex?: never;
|
|
3398
|
+
px?: never;
|
|
3399
|
+
exat?: never;
|
|
3400
|
+
pxat: number;
|
|
3401
|
+
persist?: never;
|
|
3402
|
+
} | {
|
|
3403
|
+
ex?: never;
|
|
3404
|
+
px?: never;
|
|
3405
|
+
exat?: never;
|
|
3406
|
+
pxat?: never;
|
|
3407
|
+
persist: true;
|
|
3408
|
+
} | {
|
|
3409
|
+
ex?: never;
|
|
3410
|
+
px?: never;
|
|
3411
|
+
exat?: never;
|
|
3412
|
+
pxat?: never;
|
|
3413
|
+
persist?: never;
|
|
3414
|
+
}) | undefined) => Promise<TData | null>;
|
|
2898
3415
|
/**
|
|
2899
3416
|
* @see https://redis.io/commands/getrange
|
|
2900
3417
|
*/
|
|
@@ -2911,6 +3428,42 @@ declare class Redis {
|
|
|
2911
3428
|
* @see https://redis.io/commands/hexists
|
|
2912
3429
|
*/
|
|
2913
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)[]>;
|
|
2914
3467
|
/**
|
|
2915
3468
|
* @see https://redis.io/commands/hget
|
|
2916
3469
|
*/
|
|
@@ -3062,11 +3615,11 @@ declare class Redis {
|
|
|
3062
3615
|
/**
|
|
3063
3616
|
* @see https://redis.io/commands/pexpire
|
|
3064
3617
|
*/
|
|
3065
|
-
pexpire: (key: string, milliseconds: number) => Promise<0 | 1>;
|
|
3618
|
+
pexpire: (key: string, milliseconds: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
|
|
3066
3619
|
/**
|
|
3067
3620
|
* @see https://redis.io/commands/pexpireat
|
|
3068
3621
|
*/
|
|
3069
|
-
pexpireat: (key: string, unix: number) => Promise<0 | 1>;
|
|
3622
|
+
pexpireat: (key: string, unix: number, option?: ExpireOption | undefined) => Promise<0 | 1>;
|
|
3070
3623
|
/**
|
|
3071
3624
|
* @see https://redis.io/commands/pfadd
|
|
3072
3625
|
*/
|
|
@@ -3087,6 +3640,10 @@ declare class Redis {
|
|
|
3087
3640
|
* @see https://redis.io/commands/psetex
|
|
3088
3641
|
*/
|
|
3089
3642
|
psetex: <TData>(key: string, ttl: number, value: TData) => Promise<string>;
|
|
3643
|
+
/**
|
|
3644
|
+
* @see https://redis.io/commands/psubscribe
|
|
3645
|
+
*/
|
|
3646
|
+
psubscribe: <TMessage>(patterns: string | string[]) => Subscriber<TMessage>;
|
|
3090
3647
|
/**
|
|
3091
3648
|
* @see https://redis.io/commands/pttl
|
|
3092
3649
|
*/
|
|
@@ -3126,7 +3683,10 @@ declare class Redis {
|
|
|
3126
3683
|
/**
|
|
3127
3684
|
* @see https://redis.io/commands/scan
|
|
3128
3685
|
*/
|
|
3129
|
-
scan
|
|
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>;
|
|
3130
3690
|
/**
|
|
3131
3691
|
* @see https://redis.io/commands/scard
|
|
3132
3692
|
*/
|
|
@@ -3215,6 +3775,10 @@ declare class Redis {
|
|
|
3215
3775
|
* @see https://redis.io/commands/strlen
|
|
3216
3776
|
*/
|
|
3217
3777
|
strlen: (key: string) => Promise<number>;
|
|
3778
|
+
/**
|
|
3779
|
+
* @see https://redis.io/commands/subscribe
|
|
3780
|
+
*/
|
|
3781
|
+
subscribe: <TMessage>(channels: string | string[]) => Subscriber<TMessage>;
|
|
3218
3782
|
/**
|
|
3219
3783
|
* @see https://redis.io/commands/sunion
|
|
3220
3784
|
*/
|
|
@@ -3453,22 +4017,28 @@ declare class Redis {
|
|
|
3453
4017
|
zunionstore: (destination: string, numKeys: number, keys: string[], opts?: ZUnionStoreCommandOptions | undefined) => Promise<number>;
|
|
3454
4018
|
}
|
|
3455
4019
|
|
|
4020
|
+
type UpstashErrorOptions = Pick<NonNullable<ConstructorParameters<typeof Error>[1]>, "cause">;
|
|
3456
4021
|
/**
|
|
3457
4022
|
* Result of a bad request to upstash
|
|
3458
4023
|
*/
|
|
3459
4024
|
declare class UpstashError extends Error {
|
|
3460
|
-
constructor(message: string);
|
|
4025
|
+
constructor(message: string, options?: ErrorOptions);
|
|
3461
4026
|
}
|
|
3462
4027
|
declare class UrlError extends Error {
|
|
3463
4028
|
constructor(url: string);
|
|
3464
4029
|
}
|
|
4030
|
+
declare class UpstashJSONParseError extends UpstashError {
|
|
4031
|
+
constructor(body: string, options?: UpstashErrorOptions);
|
|
4032
|
+
}
|
|
3465
4033
|
|
|
3466
4034
|
type error_UpstashError = UpstashError;
|
|
3467
4035
|
declare const error_UpstashError: typeof UpstashError;
|
|
4036
|
+
type error_UpstashJSONParseError = UpstashJSONParseError;
|
|
4037
|
+
declare const error_UpstashJSONParseError: typeof UpstashJSONParseError;
|
|
3468
4038
|
type error_UrlError = UrlError;
|
|
3469
4039
|
declare const error_UrlError: typeof UrlError;
|
|
3470
4040
|
declare namespace error {
|
|
3471
|
-
export { error_UpstashError as UpstashError, error_UrlError as UrlError };
|
|
4041
|
+
export { error_UpstashError as UpstashError, error_UpstashJSONParseError as UpstashJSONParseError, error_UrlError as UrlError };
|
|
3472
4042
|
}
|
|
3473
4043
|
|
|
3474
4044
|
/**
|
|
@@ -3485,4 +4055,4 @@ declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] |
|
|
|
3485
4055
|
constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
|
|
3486
4056
|
}
|
|
3487
4057
|
|
|
3488
|
-
export {
|
|
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 };
|