@upstash/redis 0.0.0-ci.ba685120 → 0.0.0-ci.bc3aba1f-20221124

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.
Files changed (80) hide show
  1. package/README.md +14 -19
  2. package/esm/deps/deno.land/x/base64@v0.2.1/base.js +100 -0
  3. package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +9 -0
  4. package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
  5. package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +191 -0
  6. package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +50 -0
  7. package/esm/pkg/commands/getdel.js +9 -0
  8. package/esm/pkg/commands/hgetall.js +0 -4
  9. package/esm/pkg/commands/hrandfield.js +39 -0
  10. package/esm/pkg/commands/lpos.js +19 -0
  11. package/esm/pkg/commands/mod.js +3 -0
  12. package/esm/pkg/commands/scan.js +3 -0
  13. package/esm/pkg/commands/sdiffstore.js +1 -1
  14. package/esm/pkg/commands/set.js +16 -4
  15. package/esm/pkg/commands/zmscore.js +10 -0
  16. package/esm/pkg/commands/zrange.js +6 -0
  17. package/esm/pkg/http.js +82 -2
  18. package/esm/pkg/pipeline.js +52 -6
  19. package/esm/pkg/redis.js +79 -2
  20. package/esm/pkg/script.js +77 -0
  21. package/esm/platforms/cloudflare.js +10 -2
  22. package/esm/platforms/fastly.js +1 -0
  23. package/esm/platforms/node_with_fetch.js +14 -1
  24. package/esm/platforms/nodejs.js +14 -1
  25. package/esm/version.js +1 -0
  26. package/package.json +1 -39
  27. package/script/deps/deno.land/x/base64@v0.2.1/base.js +104 -0
  28. package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +13 -0
  29. package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +6 -0
  30. package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +196 -0
  31. package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +55 -0
  32. package/script/pkg/commands/getdel.js +13 -0
  33. package/script/pkg/commands/hgetall.js +0 -4
  34. package/script/pkg/commands/hrandfield.js +43 -0
  35. package/script/pkg/commands/lpos.js +23 -0
  36. package/script/pkg/commands/mod.js +3 -0
  37. package/script/pkg/commands/scan.js +3 -0
  38. package/script/pkg/commands/sdiffstore.js +1 -1
  39. package/script/pkg/commands/set.js +16 -4
  40. package/script/pkg/commands/zmscore.js +14 -0
  41. package/script/pkg/commands/zrange.js +6 -0
  42. package/script/pkg/http.js +82 -2
  43. package/script/pkg/pipeline.js +51 -5
  44. package/script/pkg/redis.js +78 -1
  45. package/script/pkg/script.js +81 -0
  46. package/script/platforms/cloudflare.js +10 -2
  47. package/script/platforms/fastly.js +1 -0
  48. package/script/platforms/node_with_fetch.js +14 -1
  49. package/script/platforms/nodejs.js +14 -1
  50. package/script/version.js +4 -0
  51. package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +5 -0
  52. package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +1 -0
  53. package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
  54. package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +26 -0
  55. package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +3 -0
  56. package/types/pkg/commands/bitop.d.ts +0 -1
  57. package/types/pkg/commands/bitpos.d.ts +1 -1
  58. package/types/pkg/commands/getdel.d.ts +7 -0
  59. package/types/pkg/commands/hrandfield.d.ts +9 -0
  60. package/types/pkg/commands/lpop.d.ts +1 -1
  61. package/types/pkg/commands/lpos.d.ts +15 -0
  62. package/types/pkg/commands/mget.d.ts +1 -1
  63. package/types/pkg/commands/mod.d.ts +3 -0
  64. package/types/pkg/commands/rpop.d.ts +2 -2
  65. package/types/pkg/commands/scan.d.ts +1 -0
  66. package/types/pkg/commands/sdiffstore.d.ts +1 -1
  67. package/types/pkg/commands/set.d.ts +31 -2
  68. package/types/pkg/commands/spop.d.ts +2 -2
  69. package/types/pkg/commands/zadd.d.ts +1 -1
  70. package/types/pkg/commands/zmscore.d.ts +7 -0
  71. package/types/pkg/commands/zrange.d.ts +7 -0
  72. package/types/pkg/http.d.ts +52 -4
  73. package/types/pkg/pipeline.d.ts +33 -8
  74. package/types/pkg/redis.d.ts +48 -8
  75. package/types/pkg/script.d.ts +42 -0
  76. package/types/platforms/cloudflare.d.ts +8 -7
  77. package/types/platforms/fastly.d.ts +2 -6
  78. package/types/platforms/node_with_fetch.d.ts +2 -21
  79. package/types/platforms/nodejs.d.ts +3 -6
  80. package/types/version.d.ts +1 -0
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/mget
4
4
  */
5
5
  export declare class MGetCommand<TData extends unknown[]> extends Command<(string | null)[], TData> {
6
- constructor(cmd: [...keys: [string, ...string[]]], opts?: CommandOptions<(string | null)[], TData>);
6
+ constructor(cmd: [...keys: string[]], opts?: CommandOptions<(string | null)[], TData>);
7
7
  }
@@ -17,6 +17,7 @@ export * from "./flushall.js";
17
17
  export * from "./flushdb.js";
18
18
  export * from "./get.js";
19
19
  export * from "./getbit.js";
20
+ export * from "./getdel.js";
20
21
  export * from "./getrange.js";
21
22
  export * from "./getset.js";
22
23
  export * from "./hdel.js";
@@ -29,6 +30,7 @@ export * from "./hkeys.js";
29
30
  export * from "./hlen.js";
30
31
  export * from "./hmget.js";
31
32
  export * from "./hmset.js";
33
+ export * from "./hrandfield.js";
32
34
  export * from "./hscan.js";
33
35
  export * from "./hset.js";
34
36
  export * from "./hsetnx.js";
@@ -42,6 +44,7 @@ export * from "./lindex.js";
42
44
  export * from "./linsert.js";
43
45
  export * from "./llen.js";
44
46
  export * from "./lpop.js";
47
+ export * from "./lpos.js";
45
48
  export * from "./lpush.js";
46
49
  export * from "./lpushx.js";
47
50
  export * from "./lrange.js";
@@ -2,6 +2,6 @@ import { Command, CommandOptions } from "./command.js";
2
2
  /**
3
3
  * @see https://redis.io/commands/rpop
4
4
  */
5
- export declare class RPopCommand<TData = string> extends Command<unknown | null, TData | null> {
6
- constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
5
+ export declare class RPopCommand<TData extends unknown | unknown[] = string> extends Command<unknown | null, TData | null> {
6
+ constructor(cmd: [key: string, count?: number], opts?: CommandOptions<unknown | null, TData | null>);
7
7
  }
@@ -2,6 +2,7 @@ import { Command, CommandOptions } from "./command.js";
2
2
  export declare type ScanCommandOptions = {
3
3
  match?: string;
4
4
  count?: number;
5
+ type?: string;
5
6
  };
6
7
  /**
7
8
  * @see https://redis.io/commands/scan
@@ -1,6 +1,6 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
2
  /**
3
- * @see https://redis.io/commands/sdiffstpre
3
+ * @see https://redis.io/commands/sdiffstore
4
4
  */
5
5
  export declare class SDiffStoreCommand extends Command<number, number> {
6
6
  constructor(cmd: [destination: string, ...keys: string[]], opts?: CommandOptions<number, number>);
@@ -1,13 +1,42 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
- export declare type SetCommandOptions = ({
2
+ export declare type SetCommandOptions = {
3
+ get: boolean;
4
+ } | ({
3
5
  ex: number;
4
6
  px?: never;
7
+ exat?: never;
8
+ pxat?: never;
9
+ keepTtl?: never;
5
10
  } | {
6
11
  ex?: never;
7
12
  px: number;
13
+ exat?: never;
14
+ pxat?: never;
15
+ keepTtl?: never;
8
16
  } | {
9
17
  ex?: never;
10
18
  px?: never;
19
+ exat: number;
20
+ pxat?: never;
21
+ keepTtl?: never;
22
+ } | {
23
+ ex?: never;
24
+ px?: never;
25
+ exat?: never;
26
+ pxat: number;
27
+ keepTtl?: never;
28
+ } | {
29
+ ex?: never;
30
+ px?: never;
31
+ exat?: never;
32
+ pxat?: never;
33
+ keepTtl: true;
34
+ } | {
35
+ ex?: never;
36
+ px?: never;
37
+ exat?: never;
38
+ pxat?: never;
39
+ keepTtl?: never;
11
40
  }) & ({
12
41
  nx: true;
13
42
  xx?: never;
@@ -21,6 +50,6 @@ export declare type SetCommandOptions = ({
21
50
  /**
22
51
  * @see https://redis.io/commands/set
23
52
  */
24
- export declare class SetCommand<TData, TResult = "OK"> extends Command<TResult, TData> {
53
+ export declare class SetCommand<TData, TResult = TData | "OK" | null> extends Command<TResult, TData | "OK" | null> {
25
54
  constructor([key, value, opts]: [key: string, value: TData, opts?: SetCommandOptions], cmdOpts?: CommandOptions<TResult, TData>);
26
55
  }
@@ -2,6 +2,6 @@ import { Command, CommandOptions } from "./command.js";
2
2
  /**
3
3
  * @see https://redis.io/commands/spop
4
4
  */
5
- export declare class SPopCommand<TData> extends Command<string | null, TData | null> {
6
- constructor([key, count]: [key: string, count?: number], opts?: CommandOptions<string | null, TData | null>);
5
+ export declare class SPopCommand<TData> extends Command<string | string[] | null, TData | null> {
6
+ constructor([key, count]: [key: string, count?: number], opts?: CommandOptions<string | string[] | null, TData | null>);
7
7
  }
@@ -30,6 +30,6 @@ export declare class ZAddCommand<TData = string> extends Command<number | null,
30
30
  constructor(cmd: [
31
31
  key: string,
32
32
  opts: ZAddCommandOptions | ZAddCommandOptionsWithIncr,
33
- ...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]
33
+ ...scoreMemberPairs: ScoreMember<TData>[]
34
34
  ], opts?: CommandOptions<number | null, number | null>);
35
35
  }
@@ -0,0 +1,7 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/zmscore
4
+ */
5
+ export declare class ZMScoreCommand<TData> extends Command<string[] | null, number[] | null> {
6
+ constructor(cmd: [key: string, members: TData[]], opts?: CommandOptions<string[] | null, number[] | null>);
7
+ }
@@ -1,6 +1,7 @@
1
1
  import { Command, CommandOptions } from "./command.js";
2
2
  export declare type ZRangeCommandOptions = {
3
3
  withScores?: boolean;
4
+ rev?: boolean;
4
5
  } & ({
5
6
  byScore: true;
6
7
  byLex?: never;
@@ -10,6 +11,12 @@ export declare type ZRangeCommandOptions = {
10
11
  } | {
11
12
  byScore?: never;
12
13
  byLex?: never;
14
+ }) & ({
15
+ offset: number;
16
+ count: number;
17
+ } | {
18
+ offset?: never;
19
+ count?: never;
13
20
  });
14
21
  /**
15
22
  * @see https://redis.io/commands/zrange
@@ -29,20 +29,69 @@ export declare type RetryConfig = false | {
29
29
  */
30
30
  backoff?: (retryCount: number) => number;
31
31
  };
32
- declare type Options = {
32
+ export declare type Options = {
33
33
  backend?: string;
34
34
  };
35
+ export declare type RequesterConfig = {
36
+ /**
37
+ * Configure the retry behaviour in case of network errors
38
+ */
39
+ retry?: RetryConfig;
40
+ /**
41
+ * Due to the nature of dynamic and custom data, it is possible to write data to redis that is not
42
+ * valid json and will therefore cause errors when deserializing. This used to happen very
43
+ * frequently with non-utf8 data, such as emojis.
44
+ *
45
+ * By default we will therefore encode the data as base64 on the server, before sending it to the
46
+ * client. The client will then decode the base64 data and parse it as utf8.
47
+ *
48
+ * For very large entries, this can add a few milliseconds, so if you are sure that your data is
49
+ * valid utf8, you can disable this behaviour by setting this option to false.
50
+ *
51
+ * Here's what the response body looks like:
52
+ *
53
+ * ```json
54
+ * {
55
+ * result?: "base64-encoded",
56
+ * error?: string
57
+ * }
58
+ * ```
59
+ *
60
+ * @default "base64"
61
+ */
62
+ responseEncoding?: false | "base64";
63
+ };
35
64
  export declare type HttpClientConfig = {
36
65
  headers?: Record<string, string>;
37
66
  baseUrl: string;
38
67
  options?: Options;
39
68
  retry?: RetryConfig;
40
- };
69
+ agent?: any;
70
+ telemetry?: {
71
+ /**
72
+ * Upstash-Telemetry-Sdk
73
+ * @example @upstash/redis@v1.1.1
74
+ */
75
+ sdk?: string;
76
+ /**
77
+ * Upstash-Telemetry-Platform
78
+ * @example cloudflare
79
+ */
80
+ platform?: string;
81
+ /**
82
+ * Upstash-Telemetry-Runtime
83
+ * @example node@v18
84
+ */
85
+ runtime?: string;
86
+ };
87
+ } & RequesterConfig;
41
88
  export declare class HttpClient implements Requester {
42
89
  baseUrl: string;
43
90
  headers: Record<string, string>;
44
- readonly options?: {
91
+ readonly options: {
45
92
  backend?: string;
93
+ agent: any;
94
+ responseEncoding?: false | "base64";
46
95
  };
47
96
  readonly retry: {
48
97
  attempts: number;
@@ -51,4 +100,3 @@ export declare class HttpClient implements Requester {
51
100
  constructor(config: HttpClientConfig);
52
101
  request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
53
102
  }
54
- export {};
@@ -1,4 +1,4 @@
1
- import { DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
1
+ import { DelCommand, ExistsCommand, FlushAllCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
2
  import { CommandOptions } from "./commands/command.js";
3
3
  import { Requester } from "./http.js";
4
4
  import { CommandArgs } from "./types.js";
@@ -18,7 +18,7 @@ import { CommandArgs } from "./types.js";
18
18
  * **Examples:**
19
19
  *
20
20
  * ```ts
21
- * const p = redis.pipeline()
21
+ * const p = redis.pipeline() // or redis.multi()
22
22
  * p.set("key","value")
23
23
  * p.get("key")
24
24
  * const res = await p.exec()
@@ -44,7 +44,12 @@ export declare class Pipeline {
44
44
  private client;
45
45
  private commands;
46
46
  private commandOptions?;
47
- constructor(client: Requester, commandOptions?: CommandOptions<any, any>);
47
+ private multiExec;
48
+ constructor(opts: {
49
+ client: Requester;
50
+ commandOptions?: CommandOptions<any, any>;
51
+ multiExec?: boolean;
52
+ });
48
53
  /**
49
54
  * Send the pipeline request to upstash.
50
55
  *
@@ -79,7 +84,7 @@ export declare class Pipeline {
79
84
  /**
80
85
  * @see https://redis.io/commands/bitpos
81
86
  */
82
- bitpos: (key: string, start: number, end: number) => this;
87
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => this;
83
88
  /**
84
89
  * @see https://redis.io/commands/dbsize
85
90
  */
@@ -138,6 +143,10 @@ export declare class Pipeline {
138
143
  * @see https://redis.io/commands/getbit
139
144
  */
140
145
  getbit: (key: string, offset: number) => this;
146
+ /**
147
+ * @see https://redis.io/commands/getdel
148
+ */
149
+ getdel: <TData>(key: string) => this;
141
150
  /**
142
151
  * @see https://redis.io/commands/getrange
143
152
  */
@@ -188,6 +197,10 @@ export declare class Pipeline {
188
197
  hmset: <TData>(key: string, kv: {
189
198
  [field: string]: TData;
190
199
  }) => this;
200
+ /**
201
+ * @see https://redis.io/commands/hrandfield
202
+ */
203
+ hrandfield: <TData extends string | string[] | Record<string, unknown>>(key: string, count?: number, withValues?: boolean) => this;
191
204
  /**
192
205
  * @see https://redis.io/commands/hscan
193
206
  */
@@ -241,7 +254,15 @@ export declare class Pipeline {
241
254
  /**
242
255
  * @see https://redis.io/commands/lpop
243
256
  */
244
- lpop: <TData>(key: string) => this;
257
+ lpop: <TData>(key: string, count?: number | undefined) => this;
258
+ /**
259
+ * @see https://redis.io/commands/lpos
260
+ */
261
+ lpos: <TData>(key: string, element: unknown, opts?: {
262
+ rank?: number | undefined;
263
+ count?: number | undefined;
264
+ maxLen?: number | undefined;
265
+ } | undefined) => this;
245
266
  /**
246
267
  * @see https://redis.io/commands/lpush
247
268
  */
@@ -269,7 +290,7 @@ export declare class Pipeline {
269
290
  /**
270
291
  * @see https://redis.io/commands/mget
271
292
  */
272
- mget: <TData extends unknown[]>(args_0: string, ...args_1: string[]) => this;
293
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => this;
273
294
  /**
274
295
  * @see https://redis.io/commands/mset
275
296
  */
@@ -325,7 +346,7 @@ export declare class Pipeline {
325
346
  /**
326
347
  * @see https://redis.io/commands/rpop
327
348
  */
328
- rpop: <TData = string>(key: string) => this;
349
+ rpop: <TData = string>(key: string, count?: number | undefined) => this;
329
350
  /**
330
351
  * @see https://redis.io/commands/rpush
331
352
  */
@@ -366,7 +387,7 @@ export declare class Pipeline {
366
387
  /**
367
388
  * @see https://redis.io/commands/set
368
389
  */
369
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => this;
390
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => this;
370
391
  /**
371
392
  * @see https://redis.io/commands/setbit
372
393
  */
@@ -475,6 +496,10 @@ export declare class Pipeline {
475
496
  * @see https://redis.io/commands/zlexcount
476
497
  */
477
498
  zlexcount: (key: string, min: string, max: string) => this;
499
+ /**
500
+ * @see https://redis.io/commands/zmscore
501
+ */
502
+ zmscore: (key: string, members: unknown[]) => this;
478
503
  /**
479
504
  * @see https://redis.io/commands/zpopmax
480
505
  */
@@ -1,7 +1,8 @@
1
- import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
- import { Requester } from "./http.js";
1
+ import { CommandOptions, DelCommand, ExistsCommand, FlushAllCommand, MGetCommand, PingCommand, ScoreMember, ScriptExistsCommand, SetCommandOptions, TouchCommand, UnlinkCommand, ZAddCommandOptions, ZAddCommandOptionsWithIncr, ZRangeCommandOptions } from "./commands/mod.js";
2
+ import { Requester, UpstashRequest, UpstashResponse } from "./http.js";
3
3
  import { Pipeline } from "./pipeline.js";
4
4
  import type { CommandArgs } from "./types.js";
5
+ import { Script } from "./script.js";
5
6
  export declare type RedisOptions = {
6
7
  /**
7
8
  * Automatically try to deserialize the returned data from upstash using `JSON.deserialize`
@@ -14,7 +15,7 @@ export declare type RedisOptions = {
14
15
  * Serverless redis client for upstash.
15
16
  */
16
17
  export declare class Redis {
17
- protected readonly client: Requester;
18
+ protected client: Requester;
18
19
  protected opts?: CommandOptions<any, any>;
19
20
  /**
20
21
  * Create a new redis client
@@ -28,12 +29,27 @@ export declare class Redis {
28
29
  * ```
29
30
  */
30
31
  constructor(client: Requester, opts?: RedisOptions);
32
+ /**
33
+ * Wrap a new middleware around the HTTP client.
34
+ */
35
+ use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult_1 = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult_1>>) => Promise<UpstashResponse<TResult>>) => void;
36
+ createScript(script: string): Script;
31
37
  /**
32
38
  * Create a new pipeline that allows you to send requests in bulk.
33
39
  *
34
40
  * @see {@link Pipeline}
35
41
  */
36
42
  pipeline: () => Pipeline;
43
+ /**
44
+ * Create a new transaction to allow executing multiple steps atomically.
45
+ *
46
+ * All the commands in a transaction are serialized and executed sequentially. A request sent by
47
+ * another client will never be served in the middle of the execution of a Redis Transaction. This
48
+ * guarantees that the commands are executed as a single isolated operation.
49
+ *
50
+ * @see {@link Pipeline}
51
+ */
52
+ multi: () => Pipeline;
37
53
  /**
38
54
  * @see https://redis.io/commands/append
39
55
  */
@@ -52,7 +68,7 @@ export declare class Redis {
52
68
  /**
53
69
  * @see https://redis.io/commands/bitpos
54
70
  */
55
- bitpos: (key: string, start: number, end: number) => Promise<number>;
71
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => Promise<number>;
56
72
  /**
57
73
  * @see https://redis.io/commands/dbsize
58
74
  */
@@ -111,6 +127,10 @@ export declare class Redis {
111
127
  * @see https://redis.io/commands/getbit
112
128
  */
113
129
  getbit: (key: string, offset: number) => Promise<0 | 1>;
130
+ /**
131
+ * @see https://redis.io/commands/getdel
132
+ */
133
+ getdel: <TData>(key: string) => Promise<TData | null>;
114
134
  /**
115
135
  * @see https://redis.io/commands/getrange
116
136
  */
@@ -161,6 +181,14 @@ export declare class Redis {
161
181
  hmset: <TData>(key: string, kv: {
162
182
  [field: string]: TData;
163
183
  }) => Promise<"OK">;
184
+ /**
185
+ * @see https://redis.io/commands/hrandfield
186
+ */
187
+ hrandfield: {
188
+ (key: string): Promise<string>;
189
+ (key: string, count: number): Promise<string[]>;
190
+ <TData extends Record<string, unknown>>(key: string, count: number, withValues: boolean): Promise<Partial<TData>>;
191
+ };
164
192
  /**
165
193
  * @see https://redis.io/commands/hscan
166
194
  */
@@ -214,7 +242,15 @@ export declare class Redis {
214
242
  /**
215
243
  * @see https://redis.io/commands/lpop
216
244
  */
217
- lpop: <TData>(key: string) => Promise<TData | null>;
245
+ lpop: <TData>(key: string, count?: number | undefined) => Promise<TData | null>;
246
+ /**
247
+ * @see https://redis.io/commands/lpos
248
+ */
249
+ lpos: <TData = number>(key: string, element: unknown, opts?: {
250
+ rank?: number | undefined;
251
+ count?: number | undefined;
252
+ maxLen?: number | undefined;
253
+ } | undefined) => Promise<TData>;
218
254
  /**
219
255
  * @see https://redis.io/commands/lpush
220
256
  */
@@ -242,7 +278,7 @@ export declare class Redis {
242
278
  /**
243
279
  * @see https://redis.io/commands/mget
244
280
  */
245
- mget: <TData extends unknown[]>(args_0: string, ...args_1: string[]) => Promise<TData>;
281
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => Promise<TData>;
246
282
  /**
247
283
  * @see https://redis.io/commands/mset
248
284
  */
@@ -298,7 +334,7 @@ export declare class Redis {
298
334
  /**
299
335
  * @see https://redis.io/commands/rpop
300
336
  */
301
- rpop: <TData = string>(key: string) => Promise<TData | null>;
337
+ rpop: <TData = string>(key: string, count?: number | undefined) => Promise<TData | null>;
302
338
  /**
303
339
  * @see https://redis.io/commands/rpush
304
340
  */
@@ -342,7 +378,7 @@ export declare class Redis {
342
378
  /**
343
379
  * @see https://redis.io/commands/set
344
380
  */
345
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => Promise<TData>;
381
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => Promise<"OK" | TData | null>;
346
382
  /**
347
383
  * @see https://redis.io/commands/setbit
348
384
  */
@@ -451,6 +487,10 @@ export declare class Redis {
451
487
  * @see https://redis.io/commands/zlexcount
452
488
  */
453
489
  zlexcount: (key: string, min: string, max: string) => Promise<number>;
490
+ /**
491
+ * @see https://redis.io/commands/zmscore
492
+ */
493
+ zmscore: (key: string, members: unknown[]) => Promise<number[] | null>;
454
494
  /**
455
495
  * @see https://redis.io/commands/zpopmax
456
496
  */
@@ -0,0 +1,42 @@
1
+ import { Redis } from "./redis.js";
2
+ /**
3
+ * Creates a new script.
4
+ *
5
+ * Scripts offer the ability to optimistically try to execute a script without having to send the
6
+ * entire script to the server. If the script is loaded on the server, it tries again by sending
7
+ * the entire script. Afterwards, the script is cached on the server.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const redis = new Redis({...})
12
+ *
13
+ * const script = redis.createScript<string>("return ARGV[1];")
14
+ * const arg1 = await script.eval([], ["Hello World"])
15
+ * assertEquals(arg1, "Hello World")
16
+ * ```
17
+ */
18
+ export declare class Script<TResult = unknown> {
19
+ readonly script: string;
20
+ readonly sha1: string;
21
+ private readonly redis;
22
+ constructor(redis: Redis, script: string);
23
+ /**
24
+ * Send an `EVAL` command to redis.
25
+ */
26
+ eval(keys: string[], args: string[]): Promise<TResult>;
27
+ /**
28
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
29
+ */
30
+ evalsha(keys: string[], args: string[]): Promise<TResult>;
31
+ /**
32
+ * Optimistically try to run `EVALSHA` first.
33
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
34
+ *
35
+ * Following calls will be able to use the cached script
36
+ */
37
+ exec(keys: string[], args: string[]): Promise<TResult>;
38
+ /**
39
+ * Compute the sha1 hash of the script and return its hex representation.
40
+ */
41
+ private digest;
42
+ }
@@ -1,5 +1,9 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import type { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import type { Requester, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
+ import { RequesterConfig } from "../pkg/http.js";
4
+ declare type Env = {
5
+ UPSTASH_DISABLE_TELEMETRY?: string;
6
+ };
3
7
  export type { Requester, UpstashRequest, UpstashResponse };
4
8
  /**
5
9
  * Connection credentials for upstash redis.
@@ -14,11 +18,7 @@ export declare type RedisConfigCloudflare = {
14
18
  * UPSTASH_REDIS_REST_TOKEN
15
19
  */
16
20
  token: string;
17
- /**
18
- * Configure the retry behaviour in case of network errors
19
- */
20
- retry?: RetryConfig;
21
- } & core.RedisOptions;
21
+ } & core.RedisOptions & RequesterConfig & Env;
22
22
  /**
23
23
  * Serverless redis client for upstash.
24
24
  */
@@ -34,9 +34,10 @@ export declare class Redis extends core.Redis {
34
34
  * });
35
35
  * ```
36
36
  */
37
- constructor(config: RedisConfigCloudflare);
37
+ constructor(config: RedisConfigCloudflare, env?: Env);
38
38
  static fromEnv(env?: {
39
39
  UPSTASH_REDIS_REST_URL: string;
40
40
  UPSTASH_REDIS_REST_TOKEN: string;
41
+ UPSTASH_DISABLE_TELEMETRY?: string;
41
42
  }, opts?: Omit<RedisConfigCloudflare, "url" | "token">): Redis;
42
43
  }
@@ -1,5 +1,5 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import type { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import type { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  export type { Requester, UpstashRequest, UpstashResponse };
4
4
  /**
5
5
  * Connection credentials for upstash redis.
@@ -20,11 +20,7 @@ export declare type RedisConfigFastly = {
20
20
  * referenced by name.
21
21
  */
22
22
  backend: string;
23
- /**
24
- * Configure the retry behaviour in case of network errors
25
- */
26
- retry?: RetryConfig;
27
- } & core.RedisOptions;
23
+ } & core.RedisOptions & RequesterConfig;
28
24
  /**
29
25
  * Serverless redis client for upstash.
30
26
  */
@@ -1,5 +1,5 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  import "isomorphic-fetch";
4
4
  export type { Requester, UpstashRequest, UpstashResponse };
5
5
  /**
@@ -15,26 +15,7 @@ export declare type RedisConfigNodejs = {
15
15
  * UPSTASH_REDIS_REST_TOKEN
16
16
  */
17
17
  token: string;
18
- /**
19
- * An agent allows you to reuse connections to reduce latency for multiple sequential requests.
20
- *
21
- * This is a node specific implementation and is not supported in various runtimes like Vercel
22
- * edge functions.
23
- *
24
- * @example
25
- * ```ts
26
- * import https from "https"
27
- *
28
- * const options: RedisConfigNodejs = {
29
- * agent: new https.Agent({ keepAlive: true })
30
- * }
31
- * ```
32
- */
33
- /**
34
- * Configure the retry behaviour in case of network errors
35
- */
36
- retry?: RetryConfig;
37
- } & core.RedisOptions;
18
+ } & core.RedisOptions & RequesterConfig;
38
19
  /**
39
20
  * Serverless redis client for upstash.
40
21
  */
@@ -1,5 +1,5 @@
1
1
  import * as core from "../pkg/redis.js";
2
- import { Requester, RetryConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
2
+ import { Requester, RequesterConfig, UpstashRequest, UpstashResponse } from "../pkg/http.js";
3
3
  export type { Requester, UpstashRequest, UpstashResponse };
4
4
  /**
5
5
  * Connection credentials for upstash redis.
@@ -29,11 +29,8 @@ export declare type RedisConfigNodejs = {
29
29
  * }
30
30
  * ```
31
31
  */
32
- /**
33
- * Configure the retry behaviour in case of network errors
34
- */
35
- retry?: RetryConfig;
36
- } & core.RedisOptions;
32
+ agent?: any;
33
+ } & core.RedisOptions & RequesterConfig;
37
34
  /**
38
35
  * Serverless redis client for upstash.
39
36
  */
@@ -0,0 +1 @@
1
+ export declare const VERSION = "v0.0.0-ci.bc3aba1f-20221124";