@upstash/redis 0.0.0-ci.ba39ba1e → 0.0.0-ci.bafaa360-20230119
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 +19 -17
- package/esm/deps/deno.land/x/base64@v0.2.1/base.js +100 -0
- package/esm/deps/deno.land/x/base64@v0.2.1/base64url.js +9 -0
- package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
- package/esm/deps/deno.land/x/sha1@v1.0.3/mod.js +191 -0
- package/esm/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +50 -0
- package/esm/pkg/commands/getdel.js +9 -0
- package/esm/pkg/commands/hgetall.js +0 -4
- package/esm/pkg/commands/hrandfield.js +39 -0
- package/esm/pkg/commands/lmove.js +9 -0
- package/esm/pkg/commands/lpos.js +19 -0
- package/esm/pkg/commands/mod.js +5 -0
- package/esm/pkg/commands/scan.js +3 -0
- package/esm/pkg/commands/sdiffstore.js +1 -1
- package/esm/pkg/commands/set.js +16 -4
- package/esm/pkg/commands/smismember.js +9 -0
- package/esm/pkg/commands/zdiffstore.js +9 -0
- package/esm/pkg/commands/zmscore.js +10 -0
- package/esm/pkg/commands/zrange.js +6 -0
- package/esm/pkg/http.js +99 -2
- package/esm/pkg/pipeline.js +80 -6
- package/esm/pkg/redis.js +125 -2
- package/esm/pkg/script.js +77 -0
- package/esm/platforms/cloudflare.js +10 -2
- package/esm/platforms/fastly.js +1 -0
- package/esm/platforms/node_with_fetch.js +27 -1
- package/esm/platforms/nodejs.js +22 -1
- package/esm/version.js +1 -0
- package/package.json +1 -39
- package/script/deps/deno.land/x/base64@v0.2.1/base.js +104 -0
- package/script/deps/deno.land/x/base64@v0.2.1/base64url.js +13 -0
- package/script/deps/deno.land/x/sha1@v1.0.3/deps.js +6 -0
- package/script/deps/deno.land/x/sha1@v1.0.3/mod.js +196 -0
- package/script/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js +55 -0
- package/script/pkg/commands/getdel.js +13 -0
- package/script/pkg/commands/hgetall.js +0 -4
- package/script/pkg/commands/hrandfield.js +43 -0
- package/script/pkg/commands/lmove.js +13 -0
- package/script/pkg/commands/lpos.js +23 -0
- package/script/pkg/commands/mod.js +5 -0
- package/script/pkg/commands/scan.js +3 -0
- package/script/pkg/commands/sdiffstore.js +1 -1
- package/script/pkg/commands/set.js +16 -4
- package/script/pkg/commands/smismember.js +13 -0
- package/script/pkg/commands/zdiffstore.js +13 -0
- package/script/pkg/commands/zmscore.js +14 -0
- package/script/pkg/commands/zrange.js +6 -0
- package/script/pkg/http.js +99 -2
- package/script/pkg/pipeline.js +79 -5
- package/script/pkg/redis.js +124 -1
- package/script/pkg/script.js +81 -0
- package/script/platforms/cloudflare.js +10 -2
- package/script/platforms/fastly.js +1 -0
- package/script/platforms/node_with_fetch.js +27 -1
- package/script/platforms/nodejs.js +22 -1
- package/script/version.js +4 -0
- package/types/deps/deno.land/x/base64@v0.2.1/base.d.ts +5 -0
- package/types/deps/deno.land/x/base64@v0.2.1/base64url.d.ts +1 -0
- package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
- package/types/deps/deno.land/x/sha1@v1.0.3/mod.d.ts +26 -0
- package/types/deps/denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.d.ts +3 -0
- package/types/pkg/commands/bitop.d.ts +0 -1
- package/types/pkg/commands/bitpos.d.ts +1 -1
- package/types/pkg/commands/getdel.d.ts +7 -0
- package/types/pkg/commands/hrandfield.d.ts +9 -0
- package/types/pkg/commands/lmove.d.ts +12 -0
- package/types/pkg/commands/lpop.d.ts +1 -1
- package/types/pkg/commands/lpos.d.ts +15 -0
- package/types/pkg/commands/mget.d.ts +1 -1
- package/types/pkg/commands/mod.d.ts +5 -0
- package/types/pkg/commands/rpop.d.ts +2 -2
- package/types/pkg/commands/scan.d.ts +1 -0
- package/types/pkg/commands/sdiffstore.d.ts +1 -1
- package/types/pkg/commands/set.d.ts +31 -2
- package/types/pkg/commands/smembers.d.ts +2 -2
- package/types/pkg/commands/smismember.d.ts +7 -0
- package/types/pkg/commands/spop.d.ts +2 -2
- package/types/pkg/commands/zadd.d.ts +1 -1
- package/types/pkg/commands/zdiffstore.d.ts +7 -0
- package/types/pkg/commands/zmscore.d.ts +7 -0
- package/types/pkg/commands/zrange.d.ts +7 -0
- package/types/pkg/http.d.ts +38 -4
- package/types/pkg/pipeline.d.ts +46 -9
- package/types/pkg/redis.d.ts +65 -9
- package/types/pkg/script.d.ts +42 -0
- package/types/pkg/types.d.ts +17 -0
- package/types/platforms/cloudflare.d.ts +8 -7
- package/types/platforms/fastly.d.ts +2 -6
- package/types/platforms/node_with_fetch.d.ts +2 -21
- package/types/platforms/nodejs.d.ts +3 -6
- package/types/version.d.ts +1 -0
|
@@ -27,7 +27,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
exports.Redis = void 0;
|
|
28
28
|
const core = __importStar(require("../pkg/redis.js"));
|
|
29
29
|
const http_js_1 = require("../pkg/http.js");
|
|
30
|
+
const version_js_1 = require("../version.js");
|
|
30
31
|
require("isomorphic-fetch");
|
|
32
|
+
// @ts-ignore Deno can't compile
|
|
33
|
+
// import https from "https";
|
|
34
|
+
// @ts-ignore Deno can't compile
|
|
35
|
+
// import http from "http";
|
|
36
|
+
// import "isomorphic-fetch";
|
|
37
|
+
/**
|
|
38
|
+
* Workaround for nodejs 14, where atob is not included in the standardlib
|
|
39
|
+
*/
|
|
40
|
+
if (typeof atob === "undefined") {
|
|
41
|
+
global.atob = function (b64) {
|
|
42
|
+
return Buffer.from(b64, "base64").toString("utf-8");
|
|
43
|
+
};
|
|
44
|
+
}
|
|
31
45
|
/**
|
|
32
46
|
* Serverless redis client for upstash.
|
|
33
47
|
*/
|
|
@@ -47,11 +61,23 @@ class Redis extends core.Redis {
|
|
|
47
61
|
/\r|\n/.test(configOrRequester.token)) {
|
|
48
62
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
49
63
|
}
|
|
64
|
+
const telemetry = {};
|
|
65
|
+
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
66
|
+
telemetry.runtime = `node@${process.version}`;
|
|
67
|
+
telemetry.platform = process.env.VERCEL
|
|
68
|
+
? "vercel"
|
|
69
|
+
: process.env.AWS_REGION
|
|
70
|
+
? "aws"
|
|
71
|
+
: "unknown";
|
|
72
|
+
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
73
|
+
}
|
|
50
74
|
const client = new http_js_1.HttpClient({
|
|
51
75
|
baseUrl: configOrRequester.url,
|
|
52
76
|
retry: configOrRequester.retry,
|
|
53
77
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
54
|
-
//
|
|
78
|
+
// agent: configOrRequester.agent,
|
|
79
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
80
|
+
telemetry,
|
|
55
81
|
});
|
|
56
82
|
super(client, {
|
|
57
83
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
@@ -27,6 +27,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
exports.Redis = void 0;
|
|
28
28
|
const core = __importStar(require("../pkg/redis.js"));
|
|
29
29
|
const http_js_1 = require("../pkg/http.js");
|
|
30
|
+
const version_js_1 = require("../version.js");
|
|
31
|
+
/**
|
|
32
|
+
* Workaround for nodejs 14, where atob is not included in the standardlib
|
|
33
|
+
*/
|
|
34
|
+
if (typeof atob === "undefined") {
|
|
35
|
+
global.atob = function (b64) {
|
|
36
|
+
return Buffer.from(b64, "base64").toString("utf-8");
|
|
37
|
+
};
|
|
38
|
+
}
|
|
30
39
|
/**
|
|
31
40
|
* Serverless redis client for upstash.
|
|
32
41
|
*/
|
|
@@ -46,11 +55,23 @@ class Redis extends core.Redis {
|
|
|
46
55
|
/\r|\n/.test(configOrRequester.token)) {
|
|
47
56
|
console.warn("The redis token contains whitespace or newline, which can cause errors!");
|
|
48
57
|
}
|
|
58
|
+
const telemetry = {};
|
|
59
|
+
if (!process.env.UPSTASH_DISABLE_TELEMETRY) {
|
|
60
|
+
telemetry.runtime = `node@${process.version}`;
|
|
61
|
+
telemetry.platform = process.env.VERCEL
|
|
62
|
+
? "vercel"
|
|
63
|
+
: process.env.AWS_REGION
|
|
64
|
+
? "aws"
|
|
65
|
+
: "unknown";
|
|
66
|
+
telemetry.sdk = `@upstash/redis@${version_js_1.VERSION}`;
|
|
67
|
+
}
|
|
49
68
|
const client = new http_js_1.HttpClient({
|
|
50
69
|
baseUrl: configOrRequester.url,
|
|
51
70
|
retry: configOrRequester.retry,
|
|
52
71
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
53
|
-
|
|
72
|
+
agent: configOrRequester.agent,
|
|
73
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
74
|
+
telemetry,
|
|
54
75
|
});
|
|
55
76
|
super(client, {
|
|
56
77
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
@@ -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;
|
|
@@ -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,
|
|
6
|
+
constructor(cmd: [key: string, bit: 0 | 1, start?: number, end?: number], opts?: CommandOptions<number, number>);
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/getdel
|
|
4
|
+
*/
|
|
5
|
+
export declare class GetDelCommand<TData = string> extends Command<unknown | null, TData | null> {
|
|
6
|
+
constructor(cmd: [key: string], opts?: CommandOptions<unknown | null, TData | null>);
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/hrandfield
|
|
4
|
+
*/
|
|
5
|
+
export declare class HRandFieldCommand<TData extends string | string[] | Record<string, unknown>> extends Command<string | string[], TData> {
|
|
6
|
+
constructor(cmd: [key: string], opts?: CommandOptions<string, string>);
|
|
7
|
+
constructor(cmd: [key: string, count: number], opts?: CommandOptions<string[], string[]>);
|
|
8
|
+
constructor(cmd: [key: string, count: number, withValues: boolean], opts?: CommandOptions<string[], Partial<TData>>);
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/lmove
|
|
4
|
+
*/
|
|
5
|
+
export declare class LMoveCommand<TData = string> extends Command<TData, TData> {
|
|
6
|
+
constructor(cmd: [
|
|
7
|
+
source: string,
|
|
8
|
+
destination: string,
|
|
9
|
+
whereFrom: "left" | "right",
|
|
10
|
+
whereTo: "left" | "right"
|
|
11
|
+
], opts?: CommandOptions<TData, TData>);
|
|
12
|
+
}
|
|
@@ -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:
|
|
6
|
+
constructor(cmd: [...keys: string[]], opts?: CommandOptions<(string | null)[], TData>);
|
|
7
7
|
}
|
|
@@ -17,11 +17,13 @@ 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";
|
|
23
24
|
export * from "./hexists.js";
|
|
24
25
|
export * from "./hget.js";
|
|
26
|
+
export * from "./smismember.js";
|
|
25
27
|
export * from "./hgetall.js";
|
|
26
28
|
export * from "./hincrby.js";
|
|
27
29
|
export * from "./hincrbyfloat.js";
|
|
@@ -29,6 +31,7 @@ export * from "./hkeys.js";
|
|
|
29
31
|
export * from "./hlen.js";
|
|
30
32
|
export * from "./hmget.js";
|
|
31
33
|
export * from "./hmset.js";
|
|
34
|
+
export * from "./hrandfield.js";
|
|
32
35
|
export * from "./hscan.js";
|
|
33
36
|
export * from "./hset.js";
|
|
34
37
|
export * from "./hsetnx.js";
|
|
@@ -41,7 +44,9 @@ export * from "./keys.js";
|
|
|
41
44
|
export * from "./lindex.js";
|
|
42
45
|
export * from "./linsert.js";
|
|
43
46
|
export * from "./llen.js";
|
|
47
|
+
export * from "./lmove.js";
|
|
44
48
|
export * from "./lpop.js";
|
|
49
|
+
export * from "./lpos.js";
|
|
45
50
|
export * from "./lpush.js";
|
|
46
51
|
export * from "./lpushx.js";
|
|
47
52
|
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
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command, CommandOptions } from "./command.js";
|
|
2
2
|
/**
|
|
3
|
-
* @see https://redis.io/commands/
|
|
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/smembers
|
|
4
4
|
*/
|
|
5
|
-
export declare class SMembersCommand<TData = string> extends Command<unknown[], TData
|
|
6
|
-
constructor(cmd: [key: string], opts?: CommandOptions<unknown[], TData
|
|
5
|
+
export declare class SMembersCommand<TData extends unknown[] = string[]> extends Command<unknown[], TData> {
|
|
6
|
+
constructor(cmd: [key: string], opts?: CommandOptions<unknown[], TData>);
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Command, CommandOptions } from "./command.js";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://redis.io/commands/smismember
|
|
4
|
+
*/
|
|
5
|
+
export declare class SMIsMemberCommand<TMembers extends unknown[]> extends Command<("0" | "1")[], (0 | 1)[]> {
|
|
6
|
+
constructor(cmd: [key: string, members: TMembers], opts?: CommandOptions<("0" | "1")[], (0 | 1)[]>);
|
|
7
|
+
}
|
|
@@ -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:
|
|
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/zdiffstore
|
|
4
|
+
*/
|
|
5
|
+
export declare class ZDiffStoreCommand extends Command<number, number> {
|
|
6
|
+
constructor(cmd: [destination: string, numkeys: number, ...keys: string[]], opts?: CommandOptions<number, number>);
|
|
7
|
+
}
|
|
@@ -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
|
package/types/pkg/http.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Telemetry } from "./types.js";
|
|
1
2
|
export declare type UpstashRequest = {
|
|
2
3
|
path?: string[];
|
|
3
4
|
/**
|
|
@@ -29,26 +30,59 @@ export declare type RetryConfig = false | {
|
|
|
29
30
|
*/
|
|
30
31
|
backoff?: (retryCount: number) => number;
|
|
31
32
|
};
|
|
32
|
-
declare type Options = {
|
|
33
|
+
export declare type Options = {
|
|
33
34
|
backend?: string;
|
|
34
35
|
};
|
|
36
|
+
export declare type RequesterConfig = {
|
|
37
|
+
/**
|
|
38
|
+
* Configure the retry behaviour in case of network errors
|
|
39
|
+
*/
|
|
40
|
+
retry?: RetryConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Due to the nature of dynamic and custom data, it is possible to write data to redis that is not
|
|
43
|
+
* valid json and will therefore cause errors when deserializing. This used to happen very
|
|
44
|
+
* frequently with non-utf8 data, such as emojis.
|
|
45
|
+
*
|
|
46
|
+
* By default we will therefore encode the data as base64 on the server, before sending it to the
|
|
47
|
+
* client. The client will then decode the base64 data and parse it as utf8.
|
|
48
|
+
*
|
|
49
|
+
* For very large entries, this can add a few milliseconds, so if you are sure that your data is
|
|
50
|
+
* valid utf8, you can disable this behaviour by setting this option to false.
|
|
51
|
+
*
|
|
52
|
+
* Here's what the response body looks like:
|
|
53
|
+
*
|
|
54
|
+
* ```json
|
|
55
|
+
* {
|
|
56
|
+
* result?: "base64-encoded",
|
|
57
|
+
* error?: string
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @default "base64"
|
|
62
|
+
*/
|
|
63
|
+
responseEncoding?: false | "base64";
|
|
64
|
+
};
|
|
35
65
|
export declare type HttpClientConfig = {
|
|
36
66
|
headers?: Record<string, string>;
|
|
37
67
|
baseUrl: string;
|
|
38
68
|
options?: Options;
|
|
39
69
|
retry?: RetryConfig;
|
|
40
|
-
|
|
70
|
+
agent?: any;
|
|
71
|
+
telemetry?: Telemetry;
|
|
72
|
+
} & RequesterConfig;
|
|
41
73
|
export declare class HttpClient implements Requester {
|
|
42
74
|
baseUrl: string;
|
|
43
75
|
headers: Record<string, string>;
|
|
44
|
-
readonly options
|
|
76
|
+
readonly options: {
|
|
45
77
|
backend?: string;
|
|
78
|
+
agent: any;
|
|
79
|
+
responseEncoding?: false | "base64";
|
|
46
80
|
};
|
|
47
81
|
readonly retry: {
|
|
48
82
|
attempts: number;
|
|
49
83
|
backoff: (retryCount: number) => number;
|
|
50
84
|
};
|
|
51
85
|
constructor(config: HttpClientConfig);
|
|
86
|
+
mergeTelemetry(telemetry: Telemetry): void;
|
|
52
87
|
request<TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>>;
|
|
53
88
|
}
|
|
54
|
-
export {};
|
package/types/pkg/pipeline.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,11 @@ export declare class Pipeline {
|
|
|
79
84
|
/**
|
|
80
85
|
* @see https://redis.io/commands/bitpos
|
|
81
86
|
*/
|
|
82
|
-
bitpos: (key: string,
|
|
87
|
+
bitpos: (key: string, bit: 0 | 1, start?: number | undefined, end?: number | undefined) => this;
|
|
88
|
+
/**
|
|
89
|
+
* @see https://redis.io/commands/zdiffstore
|
|
90
|
+
*/
|
|
91
|
+
zdiffstore: (destination: string, numkeys: number, ...keys: string[]) => this;
|
|
83
92
|
/**
|
|
84
93
|
* @see https://redis.io/commands/dbsize
|
|
85
94
|
*/
|
|
@@ -138,6 +147,10 @@ export declare class Pipeline {
|
|
|
138
147
|
* @see https://redis.io/commands/getbit
|
|
139
148
|
*/
|
|
140
149
|
getbit: (key: string, offset: number) => this;
|
|
150
|
+
/**
|
|
151
|
+
* @see https://redis.io/commands/getdel
|
|
152
|
+
*/
|
|
153
|
+
getdel: <TData>(key: string) => this;
|
|
141
154
|
/**
|
|
142
155
|
* @see https://redis.io/commands/getrange
|
|
143
156
|
*/
|
|
@@ -188,6 +201,10 @@ export declare class Pipeline {
|
|
|
188
201
|
hmset: <TData>(key: string, kv: {
|
|
189
202
|
[field: string]: TData;
|
|
190
203
|
}) => this;
|
|
204
|
+
/**
|
|
205
|
+
* @see https://redis.io/commands/hrandfield
|
|
206
|
+
*/
|
|
207
|
+
hrandfield: <TData extends string | string[] | Record<string, unknown>>(key: string, count?: number, withValues?: boolean) => this;
|
|
191
208
|
/**
|
|
192
209
|
* @see https://redis.io/commands/hscan
|
|
193
210
|
*/
|
|
@@ -238,10 +255,22 @@ export declare class Pipeline {
|
|
|
238
255
|
* @see https://redis.io/commands/llen
|
|
239
256
|
*/
|
|
240
257
|
llen: (key: string) => this;
|
|
258
|
+
/**
|
|
259
|
+
* @see https://redis.io/commands/lmove
|
|
260
|
+
*/
|
|
261
|
+
lmove: <TData = string>(source: string, destination: string, whereFrom: "left" | "right", whereTo: "left" | "right") => this;
|
|
241
262
|
/**
|
|
242
263
|
* @see https://redis.io/commands/lpop
|
|
243
264
|
*/
|
|
244
|
-
lpop: <TData>(key: string) => this;
|
|
265
|
+
lpop: <TData>(key: string, count?: number | undefined) => this;
|
|
266
|
+
/**
|
|
267
|
+
* @see https://redis.io/commands/lpos
|
|
268
|
+
*/
|
|
269
|
+
lpos: <TData>(key: string, element: unknown, opts?: {
|
|
270
|
+
rank?: number | undefined;
|
|
271
|
+
count?: number | undefined;
|
|
272
|
+
maxLen?: number | undefined;
|
|
273
|
+
} | undefined) => this;
|
|
245
274
|
/**
|
|
246
275
|
* @see https://redis.io/commands/lpush
|
|
247
276
|
*/
|
|
@@ -269,7 +298,7 @@ export declare class Pipeline {
|
|
|
269
298
|
/**
|
|
270
299
|
* @see https://redis.io/commands/mget
|
|
271
300
|
*/
|
|
272
|
-
mget: <TData extends unknown[]>(
|
|
301
|
+
mget: <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) => this;
|
|
273
302
|
/**
|
|
274
303
|
* @see https://redis.io/commands/mset
|
|
275
304
|
*/
|
|
@@ -325,7 +354,7 @@ export declare class Pipeline {
|
|
|
325
354
|
/**
|
|
326
355
|
* @see https://redis.io/commands/rpop
|
|
327
356
|
*/
|
|
328
|
-
rpop: <TData = string>(key: string) => this;
|
|
357
|
+
rpop: <TData = string>(key: string, count?: number | undefined) => this;
|
|
329
358
|
/**
|
|
330
359
|
* @see https://redis.io/commands/rpush
|
|
331
360
|
*/
|
|
@@ -366,7 +395,7 @@ export declare class Pipeline {
|
|
|
366
395
|
/**
|
|
367
396
|
* @see https://redis.io/commands/set
|
|
368
397
|
*/
|
|
369
|
-
set: <TData>(key: string, value: TData, opts?: SetCommandOptions
|
|
398
|
+
set: <TData>(key: string, value: TData, opts?: SetCommandOptions) => this;
|
|
370
399
|
/**
|
|
371
400
|
* @see https://redis.io/commands/setbit
|
|
372
401
|
*/
|
|
@@ -398,7 +427,11 @@ export declare class Pipeline {
|
|
|
398
427
|
/**
|
|
399
428
|
* @see https://redis.io/commands/smembers
|
|
400
429
|
*/
|
|
401
|
-
smembers: (key: string) => this;
|
|
430
|
+
smembers: <TData extends unknown[] = string[]>(key: string) => this;
|
|
431
|
+
/**
|
|
432
|
+
* @see https://redis.io/commands/smismember
|
|
433
|
+
*/
|
|
434
|
+
smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => this;
|
|
402
435
|
/**
|
|
403
436
|
* @see https://redis.io/commands/smove
|
|
404
437
|
*/
|
|
@@ -475,6 +508,10 @@ export declare class Pipeline {
|
|
|
475
508
|
* @see https://redis.io/commands/zlexcount
|
|
476
509
|
*/
|
|
477
510
|
zlexcount: (key: string, min: string, max: string) => this;
|
|
511
|
+
/**
|
|
512
|
+
* @see https://redis.io/commands/zmscore
|
|
513
|
+
*/
|
|
514
|
+
zmscore: (key: string, members: unknown[]) => this;
|
|
478
515
|
/**
|
|
479
516
|
* @see https://redis.io/commands/zpopmax
|
|
480
517
|
*/
|