@upstash/redis 0.0.0-ci.f8d46c0e → 0.0.0-ci.fb6b986f-20221006

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 (55) hide show
  1. package/esm/deps/deno.land/x/base64@v0.2.1/base.js +100 -0
  2. package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +9 -0
  3. package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
  4. package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +191 -0
  5. package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +50 -0
  6. package/esm/pkg/commands/lpos.js +19 -0
  7. package/esm/pkg/commands/mod.js +1 -0
  8. package/esm/pkg/commands/scan.js +3 -0
  9. package/esm/pkg/commands/sdiffstore.js +1 -1
  10. package/esm/pkg/commands/set.js +16 -4
  11. package/esm/pkg/commands/zmscore.js +10 -0
  12. package/esm/pkg/commands/zrange.js +6 -0
  13. package/esm/pkg/http.js +53 -2
  14. package/esm/pkg/pipeline.js +20 -1
  15. package/esm/pkg/redis.js +36 -1
  16. package/esm/pkg/script.js +77 -0
  17. package/package.json +1 -39
  18. package/script/deps/deno.land/x/base64@v0.2.1/base.js +104 -0
  19. package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +13 -0
  20. package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +6 -0
  21. package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +196 -0
  22. package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +55 -0
  23. package/script/pkg/commands/lpos.js +23 -0
  24. package/script/pkg/commands/mod.js +1 -0
  25. package/script/pkg/commands/scan.js +3 -0
  26. package/script/pkg/commands/sdiffstore.js +1 -1
  27. package/script/pkg/commands/set.js +16 -4
  28. package/script/pkg/commands/zmscore.js +14 -0
  29. package/script/pkg/commands/zrange.js +6 -0
  30. package/script/pkg/http.js +53 -2
  31. package/script/pkg/pipeline.js +19 -0
  32. package/script/pkg/redis.js +35 -0
  33. package/script/pkg/script.js +81 -0
  34. package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +5 -0
  35. package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +1 -0
  36. package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
  37. package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +26 -0
  38. package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +3 -0
  39. package/types/pkg/commands/bitop.d.ts +0 -1
  40. package/types/pkg/commands/bitpos.d.ts +1 -1
  41. package/types/pkg/commands/lpop.d.ts +1 -1
  42. package/types/pkg/commands/lpos.d.ts +15 -0
  43. package/types/pkg/commands/mget.d.ts +1 -1
  44. package/types/pkg/commands/mod.d.ts +1 -0
  45. package/types/pkg/commands/rpop.d.ts +2 -2
  46. package/types/pkg/commands/scan.d.ts +1 -0
  47. package/types/pkg/commands/sdiffstore.d.ts +1 -1
  48. package/types/pkg/commands/set.d.ts +31 -2
  49. package/types/pkg/commands/spop.d.ts +2 -2
  50. package/types/pkg/commands/zadd.d.ts +1 -1
  51. package/types/pkg/commands/zmscore.d.ts +7 -0
  52. package/types/pkg/commands/zrange.d.ts +7 -0
  53. package/types/pkg/pipeline.d.ts +18 -6
  54. package/types/pkg/redis.d.ts +26 -8
  55. package/types/pkg/script.d.ts +42 -0
@@ -29,7 +29,11 @@ class HttpClient {
29
29
  value: void 0
30
30
  });
31
31
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
32
- this.headers = { "Content-Type": "application/json", ...config.headers };
32
+ this.headers = {
33
+ "Content-Type": "application/json",
34
+ "Upstash-Encoding": "base64",
35
+ ...config.headers,
36
+ };
33
37
  this.options = { backend: config.options?.backend };
34
38
  if (typeof config?.retry === "boolean" && config?.retry === false) {
35
39
  this.retry = {
@@ -75,7 +79,54 @@ class HttpClient {
75
79
  if (!res.ok) {
76
80
  throw new error_js_1.UpstashError(body.error);
77
81
  }
78
- return body;
82
+ return Array.isArray(body) ? body.map(decode) : decode(body);
79
83
  }
80
84
  }
81
85
  exports.HttpClient = HttpClient;
86
+ function base64decode(b64) {
87
+ let dec = "";
88
+ try {
89
+ dec = atob(b64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("");
90
+ }
91
+ catch (e) {
92
+ console.warn(`Unable to decode base64 [${dec}]: ${e.message}`);
93
+ return dec;
94
+ }
95
+ try {
96
+ return decodeURIComponent(dec);
97
+ }
98
+ catch (e) {
99
+ console.warn(`Unable to decode URI [${dec}]: ${e.message}`);
100
+ return dec;
101
+ }
102
+ }
103
+ function decode(raw) {
104
+ let result = undefined;
105
+ switch (typeof raw.result) {
106
+ case "undefined":
107
+ return raw;
108
+ case "number":
109
+ result = raw.result;
110
+ break;
111
+ case "object":
112
+ if (Array.isArray(raw.result)) {
113
+ result = raw.result.map((v) => typeof v === "string"
114
+ ? base64decode(v)
115
+ : Array.isArray(v)
116
+ ? v.map(base64decode)
117
+ : v);
118
+ }
119
+ else {
120
+ // If it's not an array it must be null
121
+ // Apparently null is an object in javascript
122
+ result = null;
123
+ }
124
+ break;
125
+ case "string":
126
+ result = raw.result === "OK" ? "OK" : base64decode(raw.result);
127
+ break;
128
+ default:
129
+ break;
130
+ }
131
+ return { result, error: raw.error };
132
+ }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Pipeline = void 0;
4
4
  const mod_js_1 = require("./commands/mod.js");
5
5
  const error_js_1 = require("./error.js");
6
+ const zmscore_js_1 = require("./commands/zmscore.js");
6
7
  /**
7
8
  * Upstash REST API supports command pipelining to send multiple commands in
8
9
  * batch, instead of sending each command one by one and waiting for a response.
@@ -478,6 +479,15 @@ class Pipeline {
478
479
  writable: true,
479
480
  value: (...args) => this.chain(new mod_js_1.LPopCommand(args, this.commandOptions))
480
481
  });
482
+ /**
483
+ * @see https://redis.io/commands/lpos
484
+ */
485
+ Object.defineProperty(this, "lpos", {
486
+ enumerable: true,
487
+ configurable: true,
488
+ writable: true,
489
+ value: (...args) => this.chain(new mod_js_1.LPosCommand(args, this.commandOptions))
490
+ });
481
491
  /**
482
492
  * @see https://redis.io/commands/lpush
483
493
  */
@@ -1005,6 +1015,15 @@ class Pipeline {
1005
1015
  writable: true,
1006
1016
  value: (...args) => this.chain(new mod_js_1.ZLexCountCommand(args, this.commandOptions))
1007
1017
  });
1018
+ /**
1019
+ * @see https://redis.io/commands/zmscore
1020
+ */
1021
+ Object.defineProperty(this, "zmscore", {
1022
+ enumerable: true,
1023
+ configurable: true,
1024
+ writable: true,
1025
+ value: (...args) => this.chain(new zmscore_js_1.ZMScoreCommand(args, this.commandOptions))
1026
+ });
1008
1027
  /**
1009
1028
  * @see https://redis.io/commands/zpopmax
1010
1029
  */
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Redis = void 0;
4
4
  const mod_js_1 = require("./commands/mod.js");
5
5
  const pipeline_js_1 = require("./pipeline.js");
6
+ const script_js_1 = require("./script.js");
7
+ const zmscore_js_1 = require("./commands/zmscore.js");
6
8
  /**
7
9
  * Serverless redis client for upstash.
8
10
  */
@@ -31,6 +33,18 @@ class Redis {
31
33
  writable: true,
32
34
  value: void 0
33
35
  });
36
+ /**
37
+ * Wrap a new middleware around the HTTP client.
38
+ */
39
+ Object.defineProperty(this, "use", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: (middleware) => {
44
+ const makeRequest = this.client.request.bind(this.client);
45
+ this.client.request = (req) => middleware(req, makeRequest);
46
+ }
47
+ });
34
48
  /**
35
49
  * Create a new pipeline that allows you to send requests in bulk.
36
50
  *
@@ -429,6 +443,15 @@ class Redis {
429
443
  writable: true,
430
444
  value: (...args) => new mod_js_1.LPopCommand(args, this.opts).exec(this.client)
431
445
  });
446
+ /**
447
+ * @see https://redis.io/commands/lpos
448
+ */
449
+ Object.defineProperty(this, "lpos", {
450
+ enumerable: true,
451
+ configurable: true,
452
+ writable: true,
453
+ value: (...args) => new mod_js_1.LPosCommand(args, this.opts).exec(this.client)
454
+ });
432
455
  /**
433
456
  * @see https://redis.io/commands/lpush
434
457
  */
@@ -956,6 +979,15 @@ class Redis {
956
979
  writable: true,
957
980
  value: (...args) => new mod_js_1.ZLexCountCommand(args, this.opts).exec(this.client)
958
981
  });
982
+ /**
983
+ * @see https://redis.io/commands/zmscore
984
+ */
985
+ Object.defineProperty(this, "zmscore", {
986
+ enumerable: true,
987
+ configurable: true,
988
+ writable: true,
989
+ value: (...args) => new zmscore_js_1.ZMScoreCommand(args, this.opts).exec(this.client)
990
+ });
959
991
  /**
960
992
  * @see https://redis.io/commands/zpopmax
961
993
  */
@@ -1067,5 +1099,8 @@ class Redis {
1067
1099
  this.client = client;
1068
1100
  this.opts = opts;
1069
1101
  }
1102
+ createScript(script) {
1103
+ return new script_js_1.Script(this, script);
1104
+ }
1070
1105
  }
1071
1106
  exports.Redis = Redis;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Script = void 0;
4
+ const mod_js_1 = require("../deps/deno.land/x/sha1@v1.0.3/mod.js");
5
+ /**
6
+ * Creates a new script.
7
+ *
8
+ * Scripts offer the ability to optimistically try to execute a script without having to send the
9
+ * entire script to the server. If the script is loaded on the server, it tries again by sending
10
+ * the entire script. Afterwards, the script is cached on the server.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const redis = new Redis({...})
15
+ *
16
+ * const script = redis.createScript<string>("return ARGV[1];")
17
+ * const arg1 = await script.eval([], ["Hello World"])
18
+ * assertEquals(arg1, "Hello World")
19
+ * ```
20
+ */
21
+ class Script {
22
+ constructor(redis, script) {
23
+ Object.defineProperty(this, "script", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "sha1", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+ Object.defineProperty(this, "redis", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: void 0
40
+ });
41
+ this.redis = redis;
42
+ this.sha1 = this.digest(script);
43
+ this.script = script;
44
+ }
45
+ /**
46
+ * Send an `EVAL` command to redis.
47
+ */
48
+ async eval(keys, args) {
49
+ return await this.redis.eval(this.script, keys, args);
50
+ }
51
+ /**
52
+ * Calculates the sha1 hash of the script and then calls `EVALSHA`.
53
+ */
54
+ async evalsha(keys, args) {
55
+ return await this.redis.evalsha(this.sha1, keys, args);
56
+ }
57
+ /**
58
+ * Optimistically try to run `EVALSHA` first.
59
+ * If the script is not loaded in redis, it will fall back and try again with `EVAL`.
60
+ *
61
+ * Following calls will be able to use the cached script
62
+ */
63
+ async exec(keys, args) {
64
+ const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (err) => {
65
+ if (err instanceof Error &&
66
+ err.message.toLowerCase().includes("noscript")) {
67
+ return await this.redis.eval(this.script, keys, args);
68
+ }
69
+ throw err;
70
+ });
71
+ return res;
72
+ }
73
+ /**
74
+ * Compute the sha1 hash of the script and return its hex representation.
75
+ */
76
+ digest(s) {
77
+ const hash = (0, mod_js_1.sha1)(s, "utf8", "hex");
78
+ return typeof hash === "string" ? hash : new TextDecoder().decode(hash);
79
+ }
80
+ }
81
+ exports.Script = Script;
@@ -0,0 +1,5 @@
1
+ export declare function init(lookup: string[], revLookup: number[], urlsafe?: boolean): {
2
+ byteLength(b64: string): number;
3
+ toUint8Array(b64: string): Uint8Array;
4
+ fromUint8Array(buf: Uint8Array): string;
5
+ };
@@ -0,0 +1 @@
1
+ export declare const byteLength: (b64: string) => number, toUint8Array: (b64: string) => Uint8Array, fromUint8Array: (buf: Uint8Array) => string;
@@ -0,0 +1 @@
1
+ export { encode, decode } from "../../../denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js";
@@ -0,0 +1,26 @@
1
+ /** Byte length of a SHA1 digest. */
2
+ export declare const BYTES: number;
3
+ /** A class representation of the SHA1 algorithm. */
4
+ export declare class SHA1 {
5
+ readonly hashSize: number;
6
+ private _buf;
7
+ private _bufIdx;
8
+ private _count;
9
+ private _K;
10
+ private _H;
11
+ private _finalized;
12
+ /** Creates a SHA1 instance. */
13
+ constructor();
14
+ /** Reduces the four input numbers to a single one. */
15
+ protected static F(t: number, b: number, c: number, d: number): number;
16
+ /** Initializes a hash instance. */
17
+ init(): SHA1;
18
+ /** Updates a hash with additional message data. */
19
+ update(msg: string | Uint8Array, inputEncoding?: string): SHA1;
20
+ /** Finalizes a hash with additional message data. */
21
+ digest(outputEncoding?: string): string | Uint8Array;
22
+ /** Performs one transformation cycle. */
23
+ private transform;
24
+ }
25
+ /** Generates a SHA1 hash of the input data. */
26
+ export declare function sha1(msg: string | Uint8Array, inputEncoding?: string, outputEncoding?: string): string | Uint8Array;
@@ -0,0 +1,3 @@
1
+ /** Decodes a Uint8Array to utf8-, base64-, or hex-encoded string. */
2
+ export declare function decode(buf: Uint8Array, encoding?: string): string;
3
+ export declare function encode(str: string, encoding?: string): Uint8Array;
@@ -6,7 +6,6 @@ export declare class BitOpCommand extends Command<number, number> {
6
6
  constructor(cmd: [
7
7
  op: "and" | "or" | "xor",
8
8
  destinationKey: string,
9
- sourceKey: string,
10
9
  ...sourceKeys: string[]
11
10
  ], opts?: CommandOptions<number, number>);
12
11
  constructor(cmd: [op: "not", destinationKey: string, sourceKey: string], opts?: CommandOptions<number, number>);
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/bitpos
4
4
  */
5
5
  export declare class BitPosCommand extends Command<number, number> {
6
- constructor(cmd: [key: string, start: number, end: number], opts?: CommandOptions<number, number>);
6
+ constructor(cmd: [key: string, bit: 0 | 1, start?: number, end?: number], opts?: CommandOptions<number, number>);
7
7
  }
@@ -3,5 +3,5 @@ import { Command, CommandOptions } from "./command.js";
3
3
  * @see https://redis.io/commands/lpop
4
4
  */
5
5
  export declare class LPopCommand<TData = string> extends Command<unknown | null, TData | null> {
6
- constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
6
+ constructor(cmd: [key: string, count?: number], opts?: CommandOptions<unknown | null, TData | null>);
7
7
  }
@@ -0,0 +1,15 @@
1
+ import { Command, CommandOptions } from "./command.js";
2
+ /**
3
+ * @see https://redis.io/commands/lpos
4
+ */
5
+ export declare class LPosCommand<TData = number> extends Command<TData, TData> {
6
+ constructor(cmd: [
7
+ key: string,
8
+ element: unknown,
9
+ opts?: {
10
+ rank?: number;
11
+ count?: number;
12
+ maxLen?: number;
13
+ }
14
+ ], opts?: CommandOptions<TData, TData>);
15
+ }
@@ -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
  }
@@ -42,6 +42,7 @@ export * from "./lindex.js";
42
42
  export * from "./linsert.js";
43
43
  export * from "./llen.js";
44
44
  export * from "./lpop.js";
45
+ export * from "./lpos.js";
45
46
  export * from "./lpush.js";
46
47
  export * from "./lpushx.js";
47
48
  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
@@ -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";
@@ -79,7 +79,7 @@ export declare class Pipeline {
79
79
  /**
80
80
  * @see https://redis.io/commands/bitpos
81
81
  */
82
- bitpos: (key: string, start: number, end: number) => this;
82
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => this;
83
83
  /**
84
84
  * @see https://redis.io/commands/dbsize
85
85
  */
@@ -241,7 +241,15 @@ export declare class Pipeline {
241
241
  /**
242
242
  * @see https://redis.io/commands/lpop
243
243
  */
244
- lpop: <TData>(key: string) => this;
244
+ lpop: <TData>(key: string, count?: number | undefined) => this;
245
+ /**
246
+ * @see https://redis.io/commands/lpos
247
+ */
248
+ lpos: <TData>(key: string, element: unknown, opts?: {
249
+ rank?: number | undefined;
250
+ count?: number | undefined;
251
+ maxLen?: number | undefined;
252
+ } | undefined) => this;
245
253
  /**
246
254
  * @see https://redis.io/commands/lpush
247
255
  */
@@ -269,7 +277,7 @@ export declare class Pipeline {
269
277
  /**
270
278
  * @see https://redis.io/commands/mget
271
279
  */
272
- mget: <TData extends unknown[]>(args_0: string, ...args_1: string[]) => this;
280
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => this;
273
281
  /**
274
282
  * @see https://redis.io/commands/mset
275
283
  */
@@ -325,7 +333,7 @@ export declare class Pipeline {
325
333
  /**
326
334
  * @see https://redis.io/commands/rpop
327
335
  */
328
- rpop: <TData = string>(key: string) => this;
336
+ rpop: <TData = string>(key: string, count?: number | undefined) => this;
329
337
  /**
330
338
  * @see https://redis.io/commands/rpush
331
339
  */
@@ -366,7 +374,7 @@ export declare class Pipeline {
366
374
  /**
367
375
  * @see https://redis.io/commands/set
368
376
  */
369
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => this;
377
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => this;
370
378
  /**
371
379
  * @see https://redis.io/commands/setbit
372
380
  */
@@ -475,6 +483,10 @@ export declare class Pipeline {
475
483
  * @see https://redis.io/commands/zlexcount
476
484
  */
477
485
  zlexcount: (key: string, min: string, max: string) => this;
486
+ /**
487
+ * @see https://redis.io/commands/zmscore
488
+ */
489
+ zmscore: (key: string, members: unknown[]) => this;
478
490
  /**
479
491
  * @see https://redis.io/commands/zpopmax
480
492
  */
@@ -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,6 +29,11 @@ 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
  *
@@ -52,7 +58,7 @@ export declare class Redis {
52
58
  /**
53
59
  * @see https://redis.io/commands/bitpos
54
60
  */
55
- bitpos: (key: string, start: number, end: number) => Promise<number>;
61
+ bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => Promise<number>;
56
62
  /**
57
63
  * @see https://redis.io/commands/dbsize
58
64
  */
@@ -214,7 +220,15 @@ export declare class Redis {
214
220
  /**
215
221
  * @see https://redis.io/commands/lpop
216
222
  */
217
- lpop: <TData>(key: string) => Promise<TData | null>;
223
+ lpop: <TData>(key: string, count?: number | undefined) => Promise<TData | null>;
224
+ /**
225
+ * @see https://redis.io/commands/lpos
226
+ */
227
+ lpos: <TData = number>(key: string, element: unknown, opts?: {
228
+ rank?: number | undefined;
229
+ count?: number | undefined;
230
+ maxLen?: number | undefined;
231
+ } | undefined) => Promise<TData>;
218
232
  /**
219
233
  * @see https://redis.io/commands/lpush
220
234
  */
@@ -242,7 +256,7 @@ export declare class Redis {
242
256
  /**
243
257
  * @see https://redis.io/commands/mget
244
258
  */
245
- mget: <TData extends unknown[]>(args_0: string, ...args_1: string[]) => Promise<TData>;
259
+ mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => Promise<TData>;
246
260
  /**
247
261
  * @see https://redis.io/commands/mset
248
262
  */
@@ -298,7 +312,7 @@ export declare class Redis {
298
312
  /**
299
313
  * @see https://redis.io/commands/rpop
300
314
  */
301
- rpop: <TData = string>(key: string) => Promise<TData | null>;
315
+ rpop: <TData = string>(key: string, count?: number | undefined) => Promise<TData | null>;
302
316
  /**
303
317
  * @see https://redis.io/commands/rpush
304
318
  */
@@ -342,7 +356,7 @@ export declare class Redis {
342
356
  /**
343
357
  * @see https://redis.io/commands/set
344
358
  */
345
- set: <TData>(key: string, value: TData, opts?: SetCommandOptions | undefined) => Promise<TData>;
359
+ set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => Promise<"OK" | TData | null>;
346
360
  /**
347
361
  * @see https://redis.io/commands/setbit
348
362
  */
@@ -451,6 +465,10 @@ export declare class Redis {
451
465
  * @see https://redis.io/commands/zlexcount
452
466
  */
453
467
  zlexcount: (key: string, min: string, max: string) => Promise<number>;
468
+ /**
469
+ * @see https://redis.io/commands/zmscore
470
+ */
471
+ zmscore: (key: string, members: unknown[]) => Promise<number[] | null>;
454
472
  /**
455
473
  * @see https://redis.io/commands/zpopmax
456
474
  */