@upstash/redis 0.0.0-ci.c4f9e888-20220808 → 0.0.0-ci.c586e271-20221116
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 +0 -21
- package/esm/deps/deno.land/x/sha1@v1.0.3/deps.js +1 -0
- package/esm/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/mod.js +0 -0
- package/esm/deps/denopkg.com/chiefbiiko/{std-encoding@v1.1.1 → std-encoding@v1.0.0}/mod.js +4 -8
- package/esm/pkg/commands/getdel.js +9 -0
- package/esm/pkg/commands/mod.js +1 -0
- package/esm/pkg/commands/scan.js +3 -0
- package/esm/pkg/commands/zmscore.js +10 -0
- package/esm/pkg/http.js +73 -2
- package/esm/pkg/pipeline.js +33 -6
- package/esm/pkg/redis.js +44 -2
- package/esm/pkg/script.js +1 -1
- package/esm/platforms/cloudflare.js +1 -0
- package/esm/platforms/fastly.js +1 -0
- package/esm/platforms/node_with_fetch.js +2 -1
- package/esm/platforms/nodejs.js +2 -1
- package/package.json +1 -39
- package/script/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/deps.js +1 -1
- package/script/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/mod.js +0 -0
- package/script/deps/denopkg.com/chiefbiiko/{std-encoding@v1.1.1 → std-encoding@v1.0.0}/mod.js +4 -31
- package/script/pkg/commands/getdel.js +13 -0
- package/script/pkg/commands/mod.js +1 -0
- package/script/pkg/commands/scan.js +3 -0
- package/script/pkg/commands/zmscore.js +14 -0
- package/script/pkg/http.js +73 -2
- package/script/pkg/pipeline.js +32 -5
- package/script/pkg/redis.js +43 -1
- package/script/pkg/script.js +1 -1
- package/script/platforms/cloudflare.js +1 -0
- package/script/platforms/fastly.js +1 -0
- package/script/platforms/node_with_fetch.js +2 -1
- package/script/platforms/nodejs.js +2 -1
- package/types/deps/deno.land/x/sha1@v1.0.3/deps.d.ts +1 -0
- package/types/deps/{denopkg.com/chiefbiiko/sha1@master → deno.land/x/sha1@v1.0.3}/mod.d.ts +0 -0
- package/types/deps/denopkg.com/chiefbiiko/{std-encoding@v1.1.1 → std-encoding@v1.0.0}/mod.d.ts +0 -0
- package/types/pkg/commands/getdel.d.ts +7 -0
- package/types/pkg/commands/mod.d.ts +1 -0
- package/types/pkg/commands/scan.d.ts +1 -0
- package/types/pkg/commands/zmscore.d.ts +7 -0
- package/types/pkg/http.d.ts +35 -4
- package/types/pkg/pipeline.d.ts +16 -3
- package/types/pkg/redis.d.ts +19 -1
- package/types/platforms/cloudflare.d.ts +3 -6
- 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/esm/deps/deno.land/x/base64@v0.2.1/mod.js +0 -13
- package/esm/deps/denopkg.com/chiefbiiko/sha1@master/deps.js +0 -1
- package/script/deps/deno.land/x/base64@v0.2.1/mod.js +0 -17
- package/types/deps/deno.land/x/base64@v0.2.1/mod.d.ts +0 -1
- package/types/deps/denopkg.com/chiefbiiko/sha1@master/deps.d.ts +0 -1
package/README.md
CHANGED
|
@@ -81,24 +81,6 @@ data = await redis.spop('animals', 1)
|
|
|
81
81
|
console.log(data)
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
### Upgrading to v1.4.0 **(ReferenceError: fetch is not defined)**
|
|
85
|
-
|
|
86
|
-
If you are running on nodejs v17 and earlier, `fetch` will not be natively
|
|
87
|
-
supported. Platforms like Vercel, Netlify, Deno, Fastly etc. provide a polyfill
|
|
88
|
-
for you. But if you are running on bare node, you need to either specify a
|
|
89
|
-
polyfill yourself or change the import path to:
|
|
90
|
-
|
|
91
|
-
```typescript
|
|
92
|
-
import { Redis } from "@upstash/redis/with-fetch";
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Upgrading from v0.2.0?
|
|
96
|
-
|
|
97
|
-
Please read the
|
|
98
|
-
[migration guide](https://docs.upstash.com/redis/sdks/javascriptsdk/migration).
|
|
99
|
-
For further explanation we wrote a
|
|
100
|
-
[blog post](https://blog.upstash.com/upstash-redis-sdk-v1).
|
|
101
|
-
|
|
102
84
|
## Docs
|
|
103
85
|
|
|
104
86
|
See [the documentation](https://docs.upstash.com/features/javascriptsdk) for
|
|
@@ -118,6 +100,3 @@ the url and token
|
|
|
118
100
|
```sh
|
|
119
101
|
UPSTASH_REDIS_REST_URL=".." UPSTASH_REDIS_REST_TOKEN=".." deno test -A
|
|
120
102
|
```
|
|
121
|
-
|
|
122
|
-
```
|
|
123
|
-
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { encode, decode } from "../../../denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js";
|
|
File without changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as base64url from "../../../deno.land/x/base64@v0.2.1/base64url.js";
|
|
1
|
+
import { toUint8Array, fromUint8Array } from "../../../deno.land/x/base64@v0.2.1/base64url.js";
|
|
3
2
|
const decoder = new TextDecoder();
|
|
4
3
|
const encoder = new TextEncoder();
|
|
5
4
|
/** Serializes a Uint8Array to a hexadecimal string. */
|
|
@@ -26,10 +25,7 @@ export function decode(buf, encoding = "utf8") {
|
|
|
26
25
|
return decoder.decode(buf);
|
|
27
26
|
}
|
|
28
27
|
else if (/^base64$/i.test(encoding)) {
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
else if (/^base64url$/i.test(encoding)) {
|
|
32
|
-
return base64url.fromUint8Array(buf);
|
|
28
|
+
return fromUint8Array(buf);
|
|
33
29
|
}
|
|
34
30
|
else if (/^hex(?:adecimal)?$/i.test(encoding)) {
|
|
35
31
|
return toHexString(buf);
|
|
@@ -42,8 +38,8 @@ export function encode(str, encoding = "utf8") {
|
|
|
42
38
|
if (/^utf-?8$/i.test(encoding)) {
|
|
43
39
|
return encoder.encode(str);
|
|
44
40
|
}
|
|
45
|
-
else if (/^base64
|
|
46
|
-
return
|
|
41
|
+
else if (/^base64$/i.test(encoding)) {
|
|
42
|
+
return toUint8Array(str);
|
|
47
43
|
}
|
|
48
44
|
else if (/^hex(?:adecimal)?$/i.test(encoding)) {
|
|
49
45
|
return fromHexString(str);
|
package/esm/pkg/commands/mod.js
CHANGED
package/esm/pkg/commands/scan.js
CHANGED
package/esm/pkg/http.js
CHANGED
|
@@ -25,9 +25,19 @@ export class HttpClient {
|
|
|
25
25
|
writable: true,
|
|
26
26
|
value: void 0
|
|
27
27
|
});
|
|
28
|
+
this.options = {
|
|
29
|
+
backend: config.options?.backend,
|
|
30
|
+
agent: config.agent,
|
|
31
|
+
responseEncoding: config.responseEncoding ?? "base64", // default to base64
|
|
32
|
+
};
|
|
28
33
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
29
|
-
this.headers = {
|
|
30
|
-
|
|
34
|
+
this.headers = {
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
...config.headers,
|
|
37
|
+
};
|
|
38
|
+
if (this.options.responseEncoding === "base64") {
|
|
39
|
+
this.headers["Upstash-Encoding"] = "base64";
|
|
40
|
+
}
|
|
31
41
|
if (typeof config?.retry === "boolean" && config?.retry === false) {
|
|
32
42
|
this.retry = {
|
|
33
43
|
attempts: 1,
|
|
@@ -48,6 +58,7 @@ export class HttpClient {
|
|
|
48
58
|
headers: this.headers,
|
|
49
59
|
body: JSON.stringify(req.body),
|
|
50
60
|
keepalive: true,
|
|
61
|
+
agent: this.options?.agent,
|
|
51
62
|
/**
|
|
52
63
|
* Fastly specific
|
|
53
64
|
*/
|
|
@@ -72,6 +83,66 @@ export class HttpClient {
|
|
|
72
83
|
if (!res.ok) {
|
|
73
84
|
throw new UpstashError(body.error);
|
|
74
85
|
}
|
|
86
|
+
if (this.options?.responseEncoding === "base64") {
|
|
87
|
+
return Array.isArray(body) ? body.map(decode) : decode(body);
|
|
88
|
+
}
|
|
75
89
|
return body;
|
|
76
90
|
}
|
|
77
91
|
}
|
|
92
|
+
function base64decode(b64) {
|
|
93
|
+
let dec = "";
|
|
94
|
+
try {
|
|
95
|
+
/**
|
|
96
|
+
* Using only atob() is not enough because it doesn't work with unicode characters
|
|
97
|
+
*/
|
|
98
|
+
const binString = atob(b64);
|
|
99
|
+
const size = binString.length;
|
|
100
|
+
const bytes = new Uint8Array(size);
|
|
101
|
+
for (let i = 0; i < size; i++) {
|
|
102
|
+
bytes[i] = binString.charCodeAt(i);
|
|
103
|
+
}
|
|
104
|
+
dec = new TextDecoder().decode(bytes);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
dec = b64;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
return decodeURIComponent(dec);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return dec;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function decode(raw) {
|
|
117
|
+
let result = undefined;
|
|
118
|
+
switch (typeof raw.result) {
|
|
119
|
+
case "undefined":
|
|
120
|
+
return raw;
|
|
121
|
+
case "number": {
|
|
122
|
+
result = raw.result;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "object": {
|
|
126
|
+
if (Array.isArray(raw.result)) {
|
|
127
|
+
result = raw.result.map((v) => typeof v === "string"
|
|
128
|
+
? base64decode(v)
|
|
129
|
+
: Array.isArray(v)
|
|
130
|
+
? v.map(base64decode)
|
|
131
|
+
: v);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// If it's not an array it must be null
|
|
135
|
+
// Apparently null is an object in javascript
|
|
136
|
+
result = null;
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "string": {
|
|
141
|
+
result = raw.result === "OK" ? "OK" : base64decode(raw.result);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
default:
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
return { result, error: raw.error };
|
|
148
|
+
}
|
package/esm/pkg/pipeline.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
|
|
1
|
+
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
|
|
2
2
|
import { UpstashError } from "./error.js";
|
|
3
|
+
import { ZMScoreCommand } from "./commands/zmscore.js";
|
|
3
4
|
/**
|
|
4
5
|
* Upstash REST API supports command pipelining to send multiple commands in
|
|
5
6
|
* batch, instead of sending each command one by one and waiting for a response.
|
|
@@ -16,7 +17,7 @@ import { UpstashError } from "./error.js";
|
|
|
16
17
|
* **Examples:**
|
|
17
18
|
*
|
|
18
19
|
* ```ts
|
|
19
|
-
* const p = redis.pipeline()
|
|
20
|
+
* const p = redis.pipeline() // or redis.multi()
|
|
20
21
|
* p.set("key","value")
|
|
21
22
|
* p.get("key")
|
|
22
23
|
* const res = await p.exec()
|
|
@@ -39,7 +40,7 @@ import { UpstashError } from "./error.js";
|
|
|
39
40
|
* ```
|
|
40
41
|
*/
|
|
41
42
|
export class Pipeline {
|
|
42
|
-
constructor(
|
|
43
|
+
constructor(opts) {
|
|
43
44
|
Object.defineProperty(this, "client", {
|
|
44
45
|
enumerable: true,
|
|
45
46
|
configurable: true,
|
|
@@ -58,6 +59,12 @@ export class Pipeline {
|
|
|
58
59
|
writable: true,
|
|
59
60
|
value: void 0
|
|
60
61
|
});
|
|
62
|
+
Object.defineProperty(this, "multiExec", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
61
68
|
/**
|
|
62
69
|
* Send the pipeline request to upstash.
|
|
63
70
|
*
|
|
@@ -76,8 +83,9 @@ export class Pipeline {
|
|
|
76
83
|
if (this.commands.length === 0) {
|
|
77
84
|
throw new Error("Pipeline is empty");
|
|
78
85
|
}
|
|
86
|
+
const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
|
|
79
87
|
const res = (await this.client.request({
|
|
80
|
-
path
|
|
88
|
+
path,
|
|
81
89
|
body: Object.values(this.commands).map((c) => c.command),
|
|
82
90
|
}));
|
|
83
91
|
return res.map(({ error, result }, i) => {
|
|
@@ -250,6 +258,15 @@ export class Pipeline {
|
|
|
250
258
|
writable: true,
|
|
251
259
|
value: (...args) => this.chain(new GetBitCommand(args, this.commandOptions))
|
|
252
260
|
});
|
|
261
|
+
/**
|
|
262
|
+
* @see https://redis.io/commands/getdel
|
|
263
|
+
*/
|
|
264
|
+
Object.defineProperty(this, "getdel", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
configurable: true,
|
|
267
|
+
writable: true,
|
|
268
|
+
value: (...args) => this.chain(new GetDelCommand(args, this.commandOptions))
|
|
269
|
+
});
|
|
253
270
|
/**
|
|
254
271
|
* @see https://redis.io/commands/getrange
|
|
255
272
|
*/
|
|
@@ -1011,6 +1028,15 @@ export class Pipeline {
|
|
|
1011
1028
|
writable: true,
|
|
1012
1029
|
value: (...args) => this.chain(new ZLexCountCommand(args, this.commandOptions))
|
|
1013
1030
|
});
|
|
1031
|
+
/**
|
|
1032
|
+
* @see https://redis.io/commands/zmscore
|
|
1033
|
+
*/
|
|
1034
|
+
Object.defineProperty(this, "zmscore", {
|
|
1035
|
+
enumerable: true,
|
|
1036
|
+
configurable: true,
|
|
1037
|
+
writable: true,
|
|
1038
|
+
value: (...args) => this.chain(new ZMScoreCommand(args, this.commandOptions))
|
|
1039
|
+
});
|
|
1014
1040
|
/**
|
|
1015
1041
|
* @see https://redis.io/commands/zpopmax
|
|
1016
1042
|
*/
|
|
@@ -1119,9 +1145,10 @@ export class Pipeline {
|
|
|
1119
1145
|
writable: true,
|
|
1120
1146
|
value: (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions))
|
|
1121
1147
|
});
|
|
1122
|
-
this.client = client;
|
|
1148
|
+
this.client = opts.client;
|
|
1123
1149
|
this.commands = [];
|
|
1124
|
-
this.commandOptions = commandOptions;
|
|
1150
|
+
this.commandOptions = opts.commandOptions;
|
|
1151
|
+
this.multiExec = opts.multiExec ?? false;
|
|
1125
1152
|
}
|
|
1126
1153
|
/**
|
|
1127
1154
|
* Pushes a command into the pipelien and returns a chainable instance of the
|
package/esm/pkg/redis.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
|
|
1
|
+
import { AppendCommand, BitCountCommand, BitOpCommand, BitPosCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FlushAllCommand, FlushDBCommand, GetBitCommand, GetCommand, GetDelCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HGetAllCommand, HGetCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, MGetCommand, MSetCommand, MSetNXCommand, PersistCommand, PExpireAtCommand, PExpireCommand, PingCommand, PSetEXCommand, PTtlCommand, PublishCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, RPopCommand, RPushCommand, RPushXCommand, SAddCommand, ScanCommand, SCardCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SDiffCommand, SDiffStoreCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, SInterCommand, SInterStoreCommand, SIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, StrLenCommand, SUnionCommand, SUnionStoreCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionStoreCommand, } from "./commands/mod.js";
|
|
2
2
|
import { Pipeline } from "./pipeline.js";
|
|
3
3
|
import { Script } from "./script.js";
|
|
4
|
+
import { ZMScoreCommand } from "./commands/zmscore.js";
|
|
4
5
|
/**
|
|
5
6
|
* Serverless redis client for upstash.
|
|
6
7
|
*/
|
|
@@ -50,7 +51,30 @@ export class Redis {
|
|
|
50
51
|
enumerable: true,
|
|
51
52
|
configurable: true,
|
|
52
53
|
writable: true,
|
|
53
|
-
value: () => new Pipeline(
|
|
54
|
+
value: () => new Pipeline({
|
|
55
|
+
client: this.client,
|
|
56
|
+
commandOptions: this.opts,
|
|
57
|
+
multiExec: false,
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Create a new transaction to allow executing multiple steps atomically.
|
|
62
|
+
*
|
|
63
|
+
* All the commands in a transaction are serialized and executed sequentially. A request sent by
|
|
64
|
+
* another client will never be served in the middle of the execution of a Redis Transaction. This
|
|
65
|
+
* guarantees that the commands are executed as a single isolated operation.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link Pipeline}
|
|
68
|
+
*/
|
|
69
|
+
Object.defineProperty(this, "multi", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
value: () => new Pipeline({
|
|
74
|
+
client: this.client,
|
|
75
|
+
commandOptions: this.opts,
|
|
76
|
+
multiExec: true,
|
|
77
|
+
})
|
|
54
78
|
});
|
|
55
79
|
/**
|
|
56
80
|
* @see https://redis.io/commands/append
|
|
@@ -214,6 +238,15 @@ export class Redis {
|
|
|
214
238
|
writable: true,
|
|
215
239
|
value: (...args) => new GetBitCommand(args, this.opts).exec(this.client)
|
|
216
240
|
});
|
|
241
|
+
/**
|
|
242
|
+
* @see https://redis.io/commands/getdel
|
|
243
|
+
*/
|
|
244
|
+
Object.defineProperty(this, "getdel", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
configurable: true,
|
|
247
|
+
writable: true,
|
|
248
|
+
value: (...args) => new GetDelCommand(args, this.opts).exec(this.client)
|
|
249
|
+
});
|
|
217
250
|
/**
|
|
218
251
|
* @see https://redis.io/commands/getrange
|
|
219
252
|
*/
|
|
@@ -975,6 +1008,15 @@ export class Redis {
|
|
|
975
1008
|
writable: true,
|
|
976
1009
|
value: (...args) => new ZLexCountCommand(args, this.opts).exec(this.client)
|
|
977
1010
|
});
|
|
1011
|
+
/**
|
|
1012
|
+
* @see https://redis.io/commands/zmscore
|
|
1013
|
+
*/
|
|
1014
|
+
Object.defineProperty(this, "zmscore", {
|
|
1015
|
+
enumerable: true,
|
|
1016
|
+
configurable: true,
|
|
1017
|
+
writable: true,
|
|
1018
|
+
value: (...args) => new ZMScoreCommand(args, this.opts).exec(this.client)
|
|
1019
|
+
});
|
|
978
1020
|
/**
|
|
979
1021
|
* @see https://redis.io/commands/zpopmax
|
|
980
1022
|
*/
|
package/esm/pkg/script.js
CHANGED
|
@@ -30,6 +30,7 @@ export class Redis extends core.Redis {
|
|
|
30
30
|
retry: config.retry,
|
|
31
31
|
baseUrl: config.url,
|
|
32
32
|
headers: { authorization: `Bearer ${config.token}` },
|
|
33
|
+
responseEncoding: config.responseEncoding,
|
|
33
34
|
});
|
|
34
35
|
super(client, {
|
|
35
36
|
automaticDeserialization: config.automaticDeserialization,
|
package/esm/platforms/fastly.js
CHANGED
|
@@ -32,6 +32,7 @@ export class Redis extends core.Redis {
|
|
|
32
32
|
retry: config.retry,
|
|
33
33
|
headers: { authorization: `Bearer ${config.token}` },
|
|
34
34
|
options: { backend: config.backend },
|
|
35
|
+
responseEncoding: config.responseEncoding,
|
|
35
36
|
});
|
|
36
37
|
super(client, {
|
|
37
38
|
automaticDeserialization: config.automaticDeserialization,
|
|
@@ -25,7 +25,8 @@ export class Redis extends core.Redis {
|
|
|
25
25
|
baseUrl: configOrRequester.url,
|
|
26
26
|
retry: configOrRequester.retry,
|
|
27
27
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
28
|
-
//
|
|
28
|
+
// agent: configOrRequester.agent,
|
|
29
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
29
30
|
});
|
|
30
31
|
super(client, {
|
|
31
32
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
package/esm/platforms/nodejs.js
CHANGED
|
@@ -24,7 +24,8 @@ export class Redis extends core.Redis {
|
|
|
24
24
|
baseUrl: configOrRequester.url,
|
|
25
25
|
retry: configOrRequester.retry,
|
|
26
26
|
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
27
|
-
|
|
27
|
+
agent: configOrRequester.agent,
|
|
28
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
28
29
|
});
|
|
29
30
|
super(client, {
|
|
30
31
|
automaticDeserialization: configOrRequester.automaticDeserialization,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "./script/platforms/nodejs.js",
|
|
4
4
|
"types": "./types/platforms/nodejs.d.ts",
|
|
5
5
|
"name": "@upstash/redis",
|
|
6
|
-
"version": "v0.0.0-ci.
|
|
6
|
+
"version": "v0.0.0-ci.c586e271-20221116",
|
|
7
7
|
"description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -22,10 +22,6 @@
|
|
|
22
22
|
"url": "https://github.com/upstash/upstash-redis/issues"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/upstash/upstash-redis#readme",
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@size-limit/preset-small-lib": "latest",
|
|
27
|
-
"size-limit": "latest"
|
|
28
|
-
},
|
|
29
25
|
"dependencies": {
|
|
30
26
|
"isomorphic-fetch": "^3.0.0"
|
|
31
27
|
},
|
|
@@ -37,40 +33,6 @@
|
|
|
37
33
|
"with-fetch": "./types/platforms/node_with_fetch.d.ts"
|
|
38
34
|
}
|
|
39
35
|
},
|
|
40
|
-
"size-limit": [
|
|
41
|
-
{
|
|
42
|
-
"path": "esm/platforms/nodejs.js",
|
|
43
|
-
"limit": "6 KB"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"path": "esm/platforms/fastly.js",
|
|
47
|
-
"limit": "6 KB"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"path": "esm/platforms/cloudflare.js",
|
|
51
|
-
"limit": "6 KB"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"path": "esm/platforms/node_with_fetch.js",
|
|
55
|
-
"limit": "15 KB"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"path": "script/platforms/nodejs.js",
|
|
59
|
-
"limit": "10 KB"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"path": "script/platforms/fastly.js",
|
|
63
|
-
"limit": "10 KB"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"path": "script/platforms/cloudflare.js",
|
|
67
|
-
"limit": "10 KB"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"path": "script/platforms/node_with_fetch.js",
|
|
71
|
-
"limit": "15 KB"
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
36
|
"exports": {
|
|
75
37
|
".": {
|
|
76
38
|
"import": "./esm/platforms/nodejs.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decode = exports.encode = void 0;
|
|
4
|
-
var mod_js_1 = require("
|
|
4
|
+
var mod_js_1 = require("../../../denopkg.com/chiefbiiko/std-encoding@v1.0.0/mod.js");
|
|
5
5
|
Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return mod_js_1.encode; } });
|
|
6
6
|
Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return mod_js_1.decode; } });
|
|
File without changes
|
package/script/deps/denopkg.com/chiefbiiko/{std-encoding@v1.1.1 → std-encoding@v1.0.0}/mod.js
RENAMED
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.encode = exports.decode = void 0;
|
|
27
|
-
const
|
|
28
|
-
const base64url = __importStar(require("../../../deno.land/x/base64@v0.2.1/base64url.js"));
|
|
4
|
+
const base64url_js_1 = require("../../../deno.land/x/base64@v0.2.1/base64url.js");
|
|
29
5
|
const decoder = new TextDecoder();
|
|
30
6
|
const encoder = new TextEncoder();
|
|
31
7
|
/** Serializes a Uint8Array to a hexadecimal string. */
|
|
@@ -52,10 +28,7 @@ function decode(buf, encoding = "utf8") {
|
|
|
52
28
|
return decoder.decode(buf);
|
|
53
29
|
}
|
|
54
30
|
else if (/^base64$/i.test(encoding)) {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
else if (/^base64url$/i.test(encoding)) {
|
|
58
|
-
return base64url.fromUint8Array(buf);
|
|
31
|
+
return (0, base64url_js_1.fromUint8Array)(buf);
|
|
59
32
|
}
|
|
60
33
|
else if (/^hex(?:adecimal)?$/i.test(encoding)) {
|
|
61
34
|
return toHexString(buf);
|
|
@@ -69,8 +42,8 @@ function encode(str, encoding = "utf8") {
|
|
|
69
42
|
if (/^utf-?8$/i.test(encoding)) {
|
|
70
43
|
return encoder.encode(str);
|
|
71
44
|
}
|
|
72
|
-
else if (/^base64
|
|
73
|
-
return
|
|
45
|
+
else if (/^base64$/i.test(encoding)) {
|
|
46
|
+
return (0, base64url_js_1.toUint8Array)(str);
|
|
74
47
|
}
|
|
75
48
|
else if (/^hex(?:adecimal)?$/i.test(encoding)) {
|
|
76
49
|
return fromHexString(str);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetDelCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/getdel
|
|
7
|
+
*/
|
|
8
|
+
class GetDelCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
super(["getdel", ...cmd], opts);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.GetDelCommand = GetDelCommand;
|
|
@@ -35,6 +35,7 @@ __exportStar(require("./get.js"), exports);
|
|
|
35
35
|
__exportStar(require("./getbit.js"), exports);
|
|
36
36
|
__exportStar(require("./getrange.js"), exports);
|
|
37
37
|
__exportStar(require("./getset.js"), exports);
|
|
38
|
+
__exportStar(require("./getdel.js"), exports);
|
|
38
39
|
__exportStar(require("./hdel.js"), exports);
|
|
39
40
|
__exportStar(require("./hexists.js"), exports);
|
|
40
41
|
__exportStar(require("./hget.js"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZMScoreCommand = void 0;
|
|
4
|
+
const command_js_1 = require("./command.js");
|
|
5
|
+
/**
|
|
6
|
+
* @see https://redis.io/commands/zmscore
|
|
7
|
+
*/
|
|
8
|
+
class ZMScoreCommand extends command_js_1.Command {
|
|
9
|
+
constructor(cmd, opts) {
|
|
10
|
+
const [key, members] = cmd;
|
|
11
|
+
super(["zmscore", key, ...members], opts);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ZMScoreCommand = ZMScoreCommand;
|