@upstash/redis 1.2.0 → 1.3.0
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 +21 -0
- package/{chunk-HIDCSH5S.mjs → chunk-5LZNFEHI.mjs} +1 -3
- package/{chunk-FR62Y7XB.mjs → chunk-C2RGMNOQ.mjs} +23 -7
- package/{chunk-256N7RVN.mjs → chunk-CTSQDNTV.mjs} +16 -1
- package/{chunk-HZBBCLMC.mjs → chunk-K2UC7PHG.mjs} +66 -6
- package/cloudflare.d.ts +18 -16
- package/cloudflare.js +73 -12
- package/cloudflare.mjs +4 -6
- package/commands.d.ts +37 -3
- package/commands.js +71 -6
- package/commands.mjs +11 -1
- package/fastly.d.ts +23 -21
- package/fastly.js +73 -12
- package/fastly.mjs +4 -6
- package/http.d.ts +13 -6
- package/http.js +1 -3
- package/http.mjs +1 -1
- package/index.d.ts +5 -3
- package/index.js +98 -14
- package/index.mjs +4 -4
- package/nodejs.d.ts +46 -25
- package/nodejs.js +98 -14
- package/nodejs.mjs +4 -4
- package/package.json +1 -1
- package/{redis-a9efcf58.d.ts → redis-338577a3.d.ts} +508 -464
- package/{zunionstore-342168a6.d.ts → zunionstore-633a2e7a.d.ts} +17 -3
package/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -29,6 +31,9 @@ var __reExport = (target, module2, copyDefault, desc) => {
|
|
|
29
31
|
}
|
|
30
32
|
return target;
|
|
31
33
|
};
|
|
34
|
+
var __toESM = (module2, isNodeMode) => {
|
|
35
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
36
|
+
};
|
|
32
37
|
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
33
38
|
return (module2, temp) => {
|
|
34
39
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
@@ -163,6 +168,20 @@ var EchoCommand = class extends Command {
|
|
|
163
168
|
}
|
|
164
169
|
};
|
|
165
170
|
|
|
171
|
+
// pkg/commands/eval.ts
|
|
172
|
+
var EvalCommand = class extends Command {
|
|
173
|
+
constructor(script, keys, args) {
|
|
174
|
+
super(["eval", script, keys.length, ...keys, ...args != null ? args : []]);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// pkg/commands/evalsha.ts
|
|
179
|
+
var EvalshaCommand = class extends Command {
|
|
180
|
+
constructor(sha, keys, args) {
|
|
181
|
+
super(["evalsha", sha, keys.length, ...keys, ...args != null ? args : []]);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
166
185
|
// pkg/commands/exists.ts
|
|
167
186
|
var ExistsCommand = class extends Command {
|
|
168
187
|
constructor(...keys) {
|
|
@@ -323,16 +342,18 @@ function deserialize2(fields, result) {
|
|
|
323
342
|
}
|
|
324
343
|
var HMGetCommand = class extends Command {
|
|
325
344
|
constructor(key, ...fields) {
|
|
326
|
-
super(["hmget", key, ...fields], {
|
|
327
|
-
deserialize: (result) => deserialize2(fields, result)
|
|
328
|
-
});
|
|
345
|
+
super(["hmget", key, ...fields], { deserialize: (result) => deserialize2(fields, result) });
|
|
329
346
|
}
|
|
330
347
|
};
|
|
331
348
|
|
|
332
349
|
// pkg/commands/hmset.ts
|
|
333
350
|
var HMSetCommand = class extends Command {
|
|
334
351
|
constructor(key, kv) {
|
|
335
|
-
super([
|
|
352
|
+
super([
|
|
353
|
+
"hmset",
|
|
354
|
+
key,
|
|
355
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
356
|
+
]);
|
|
336
357
|
}
|
|
337
358
|
};
|
|
338
359
|
|
|
@@ -353,7 +374,11 @@ var HScanCommand = class extends Command {
|
|
|
353
374
|
// pkg/commands/hset.ts
|
|
354
375
|
var HSetCommand = class extends Command {
|
|
355
376
|
constructor(key, kv) {
|
|
356
|
-
super([
|
|
377
|
+
super([
|
|
378
|
+
"hset",
|
|
379
|
+
key,
|
|
380
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
381
|
+
]);
|
|
357
382
|
}
|
|
358
383
|
};
|
|
359
384
|
|
|
@@ -486,7 +511,10 @@ var MGetCommand = class extends Command {
|
|
|
486
511
|
// pkg/commands/mset.ts
|
|
487
512
|
var MSetCommand = class extends Command {
|
|
488
513
|
constructor(kv) {
|
|
489
|
-
super([
|
|
514
|
+
super([
|
|
515
|
+
"mset",
|
|
516
|
+
...Object.entries(kv).flatMap(([key, value]) => [key, value])
|
|
517
|
+
]);
|
|
490
518
|
}
|
|
491
519
|
};
|
|
492
520
|
|
|
@@ -620,6 +648,38 @@ var SCardCommand = class extends Command {
|
|
|
620
648
|
}
|
|
621
649
|
};
|
|
622
650
|
|
|
651
|
+
// pkg/commands/script_exists.ts
|
|
652
|
+
var ScriptExistsCommand = class extends Command {
|
|
653
|
+
constructor(...hash) {
|
|
654
|
+
super(["script", "exists", ...hash], {
|
|
655
|
+
deserialize: (result) => {
|
|
656
|
+
const parsed = result;
|
|
657
|
+
return parsed.length === 1 ? parsed[0] : parsed;
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
// pkg/commands/script_flush.ts
|
|
664
|
+
var ScriptFlushCommand = class extends Command {
|
|
665
|
+
constructor(opts) {
|
|
666
|
+
const cmd = ["script", "flush"];
|
|
667
|
+
if (opts == null ? void 0 : opts.sync) {
|
|
668
|
+
cmd.push("sync");
|
|
669
|
+
} else if (opts == null ? void 0 : opts.async) {
|
|
670
|
+
cmd.push("async");
|
|
671
|
+
}
|
|
672
|
+
super(cmd);
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// pkg/commands/script_load.ts
|
|
677
|
+
var ScriptLoadCommand = class extends Command {
|
|
678
|
+
constructor(script) {
|
|
679
|
+
super(["script", "load", script]);
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
|
|
623
683
|
// pkg/commands/sdiff.ts
|
|
624
684
|
var SDiffCommand = class extends Command {
|
|
625
685
|
constructor(key, ...keys) {
|
|
@@ -1042,6 +1102,8 @@ var Pipeline = class {
|
|
|
1042
1102
|
this.decrby = (...args) => this.chain(new DecrByCommand(...args));
|
|
1043
1103
|
this.del = (...args) => this.chain(new DelCommand(...args));
|
|
1044
1104
|
this.echo = (...args) => this.chain(new EchoCommand(...args));
|
|
1105
|
+
this.eval = (...args) => this.chain(new EvalCommand(...args));
|
|
1106
|
+
this.evalsha = (...args) => this.chain(new EvalshaCommand(...args));
|
|
1045
1107
|
this.exists = (...args) => this.chain(new ExistsCommand(...args));
|
|
1046
1108
|
this.expire = (...args) => this.chain(new ExpireCommand(...args));
|
|
1047
1109
|
this.expireat = (...args) => this.chain(new ExpireAtCommand(...args));
|
|
@@ -1099,6 +1161,9 @@ var Pipeline = class {
|
|
|
1099
1161
|
this.sadd = (key, ...members) => this.chain(new SAddCommand(key, ...members));
|
|
1100
1162
|
this.scan = (...args) => this.chain(new ScanCommand(...args));
|
|
1101
1163
|
this.scard = (...args) => this.chain(new SCardCommand(...args));
|
|
1164
|
+
this.scriptExists = (...args) => this.chain(new ScriptExistsCommand(...args));
|
|
1165
|
+
this.scriptFlush = (...args) => this.chain(new ScriptFlushCommand(...args));
|
|
1166
|
+
this.scriptLoad = (...args) => this.chain(new ScriptLoadCommand(...args));
|
|
1102
1167
|
this.sdiff = (...args) => this.chain(new SDiffCommand(...args));
|
|
1103
1168
|
this.sdiffstore = (...args) => this.chain(new SDiffStoreCommand(...args));
|
|
1104
1169
|
this.set = (key, value, opts) => this.chain(new SetCommand(key, value, opts));
|
|
@@ -1168,6 +1233,8 @@ var Redis = class {
|
|
|
1168
1233
|
this.decrby = (...args) => new DecrByCommand(...args).exec(this.client);
|
|
1169
1234
|
this.del = (...args) => new DelCommand(...args).exec(this.client);
|
|
1170
1235
|
this.echo = (...args) => new EchoCommand(...args).exec(this.client);
|
|
1236
|
+
this.eval = (...args) => new EvalCommand(...args).exec(this.client);
|
|
1237
|
+
this.evalsha = (...args) => new EvalshaCommand(...args).exec(this.client);
|
|
1171
1238
|
this.exists = (...args) => new ExistsCommand(...args).exec(this.client);
|
|
1172
1239
|
this.expire = (...args) => new ExpireCommand(...args).exec(this.client);
|
|
1173
1240
|
this.expireat = (...args) => new ExpireAtCommand(...args).exec(this.client);
|
|
@@ -1225,6 +1292,9 @@ var Redis = class {
|
|
|
1225
1292
|
this.sadd = (key, ...members) => new SAddCommand(key, ...members).exec(this.client);
|
|
1226
1293
|
this.scan = (...args) => new ScanCommand(...args).exec(this.client);
|
|
1227
1294
|
this.scard = (...args) => new SCardCommand(...args).exec(this.client);
|
|
1295
|
+
this.scriptExists = (...args) => new ScriptExistsCommand(...args).exec(this.client);
|
|
1296
|
+
this.scriptFlush = (...args) => new ScriptFlushCommand(...args).exec(this.client);
|
|
1297
|
+
this.scriptLoad = (...args) => new ScriptLoadCommand(...args).exec(this.client);
|
|
1228
1298
|
this.sdiff = (...args) => new SDiffCommand(...args).exec(this.client);
|
|
1229
1299
|
this.sdiffstore = (...args) => new SDiffStoreCommand(...args).exec(this.client);
|
|
1230
1300
|
this.set = (key, value, opts) => new SetCommand(key, value, opts).exec(this.client);
|
|
@@ -1280,9 +1350,7 @@ var Redis = class {
|
|
|
1280
1350
|
var HttpClient = class {
|
|
1281
1351
|
constructor(config) {
|
|
1282
1352
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
1283
|
-
this.headers = __spreadValues({
|
|
1284
|
-
"Content-Type": "application/json"
|
|
1285
|
-
}, config.headers);
|
|
1353
|
+
this.headers = __spreadValues({ "Content-Type": "application/json" }, config.headers);
|
|
1286
1354
|
this.options = config.options;
|
|
1287
1355
|
}
|
|
1288
1356
|
async request(req) {
|
|
@@ -1305,14 +1373,30 @@ var HttpClient = class {
|
|
|
1305
1373
|
};
|
|
1306
1374
|
|
|
1307
1375
|
// pkg/nodejs.ts
|
|
1376
|
+
var import_https = __toESM(require("https"));
|
|
1308
1377
|
var import_isomorphic_fetch = require("isomorphic-fetch");
|
|
1309
1378
|
var Redis2 = class extends Redis {
|
|
1310
|
-
constructor(
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1379
|
+
constructor(configOrRequester) {
|
|
1380
|
+
if ("request" in configOrRequester) {
|
|
1381
|
+
super(configOrRequester);
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
let agent = void 0;
|
|
1385
|
+
if (typeof window === "undefined") {
|
|
1386
|
+
const protocol = new URL(configOrRequester.url).protocol;
|
|
1387
|
+
switch (protocol) {
|
|
1388
|
+
case "https:":
|
|
1389
|
+
agent = new import_https.default.Agent({ keepAlive: true });
|
|
1390
|
+
break;
|
|
1391
|
+
case "http:":
|
|
1392
|
+
agent = new import_https.default.Agent({ keepAlive: true });
|
|
1393
|
+
break;
|
|
1315
1394
|
}
|
|
1395
|
+
}
|
|
1396
|
+
const client = new HttpClient({
|
|
1397
|
+
baseUrl: configOrRequester.url,
|
|
1398
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
1399
|
+
options: { agent }
|
|
1316
1400
|
});
|
|
1317
1401
|
super(client);
|
|
1318
1402
|
}
|
package/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Redis
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-C2RGMNOQ.mjs";
|
|
4
|
+
import "./chunk-CTSQDNTV.mjs";
|
|
5
|
+
import "./chunk-K2UC7PHG.mjs";
|
|
6
|
+
import "./chunk-5LZNFEHI.mjs";
|
|
7
7
|
import {
|
|
8
8
|
UpstashError
|
|
9
9
|
} from "./chunk-7YUZYRJS.mjs";
|
package/nodejs.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { R as Redis$1 } from './redis-
|
|
2
|
-
import './http';
|
|
3
|
-
|
|
1
|
+
import { R as Redis$1 } from './redis-338577a3';
|
|
2
|
+
import { Requester } from './http';
|
|
3
|
+
export { Requester, UpstashRequest, UpstashResponse } from './http';
|
|
4
|
+
import './zunionstore-633a2e7a';
|
|
5
|
+
import 'https';
|
|
6
|
+
import 'http';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Connection credentials for upstash redis.
|
|
@@ -8,12 +11,12 @@ import './zunionstore-342168a6';
|
|
|
8
11
|
*/
|
|
9
12
|
declare type RedisConfigNodejs = {
|
|
10
13
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
* UPSTASH_REDIS_REST_URL
|
|
15
|
+
*/
|
|
13
16
|
url: string;
|
|
14
17
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
* UPSTASH_REDIS_REST_TOKEN
|
|
19
|
+
*/
|
|
17
20
|
token: string;
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
@@ -21,26 +24,44 @@ declare type RedisConfigNodejs = {
|
|
|
21
24
|
*/
|
|
22
25
|
declare class Redis extends Redis$1 {
|
|
23
26
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
* Create a new redis client by providing the url and token
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const redis = new Redis({
|
|
32
|
+
* url: "<UPSTASH_REDIS_REST_URL>",
|
|
33
|
+
* token: "<UPSTASH_REDIS_REST_TOKEN>",
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
34
37
|
constructor(config: RedisConfigNodejs);
|
|
35
38
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
* Create a new redis client by providing a custom `Requester` implementation
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
*
|
|
44
|
+
* import { UpstashRequest, Requester, UpstashResponse, Redis } from "@upstash/redis"
|
|
45
|
+
*
|
|
46
|
+
* const requester: Requester = {
|
|
47
|
+
* request: <TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> => {
|
|
48
|
+
* // ...
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* const redis = new Redis(requester)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
constructor(requesters: Requester);
|
|
56
|
+
/**
|
|
57
|
+
* Create a new Upstash Redis instance from environment variables.
|
|
58
|
+
*
|
|
59
|
+
* Use this to automatically load connection secrets from your environment
|
|
60
|
+
* variables. For instance when using the Vercel integration.
|
|
61
|
+
*
|
|
62
|
+
* This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
|
|
63
|
+
* your environment using `process.env`.
|
|
64
|
+
*/
|
|
44
65
|
static fromEnv(): Redis;
|
|
45
66
|
}
|
|
46
67
|
|
package/nodejs.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -29,6 +31,9 @@ var __reExport = (target, module2, copyDefault, desc) => {
|
|
|
29
31
|
}
|
|
30
32
|
return target;
|
|
31
33
|
};
|
|
34
|
+
var __toESM = (module2, isNodeMode) => {
|
|
35
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
36
|
+
};
|
|
32
37
|
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
33
38
|
return (module2, temp) => {
|
|
34
39
|
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
@@ -162,6 +167,20 @@ var EchoCommand = class extends Command {
|
|
|
162
167
|
}
|
|
163
168
|
};
|
|
164
169
|
|
|
170
|
+
// pkg/commands/eval.ts
|
|
171
|
+
var EvalCommand = class extends Command {
|
|
172
|
+
constructor(script, keys, args) {
|
|
173
|
+
super(["eval", script, keys.length, ...keys, ...args != null ? args : []]);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// pkg/commands/evalsha.ts
|
|
178
|
+
var EvalshaCommand = class extends Command {
|
|
179
|
+
constructor(sha, keys, args) {
|
|
180
|
+
super(["evalsha", sha, keys.length, ...keys, ...args != null ? args : []]);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
165
184
|
// pkg/commands/exists.ts
|
|
166
185
|
var ExistsCommand = class extends Command {
|
|
167
186
|
constructor(...keys) {
|
|
@@ -322,16 +341,18 @@ function deserialize2(fields, result) {
|
|
|
322
341
|
}
|
|
323
342
|
var HMGetCommand = class extends Command {
|
|
324
343
|
constructor(key, ...fields) {
|
|
325
|
-
super(["hmget", key, ...fields], {
|
|
326
|
-
deserialize: (result) => deserialize2(fields, result)
|
|
327
|
-
});
|
|
344
|
+
super(["hmget", key, ...fields], { deserialize: (result) => deserialize2(fields, result) });
|
|
328
345
|
}
|
|
329
346
|
};
|
|
330
347
|
|
|
331
348
|
// pkg/commands/hmset.ts
|
|
332
349
|
var HMSetCommand = class extends Command {
|
|
333
350
|
constructor(key, kv) {
|
|
334
|
-
super([
|
|
351
|
+
super([
|
|
352
|
+
"hmset",
|
|
353
|
+
key,
|
|
354
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
355
|
+
]);
|
|
335
356
|
}
|
|
336
357
|
};
|
|
337
358
|
|
|
@@ -352,7 +373,11 @@ var HScanCommand = class extends Command {
|
|
|
352
373
|
// pkg/commands/hset.ts
|
|
353
374
|
var HSetCommand = class extends Command {
|
|
354
375
|
constructor(key, kv) {
|
|
355
|
-
super([
|
|
376
|
+
super([
|
|
377
|
+
"hset",
|
|
378
|
+
key,
|
|
379
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
380
|
+
]);
|
|
356
381
|
}
|
|
357
382
|
};
|
|
358
383
|
|
|
@@ -485,7 +510,10 @@ var MGetCommand = class extends Command {
|
|
|
485
510
|
// pkg/commands/mset.ts
|
|
486
511
|
var MSetCommand = class extends Command {
|
|
487
512
|
constructor(kv) {
|
|
488
|
-
super([
|
|
513
|
+
super([
|
|
514
|
+
"mset",
|
|
515
|
+
...Object.entries(kv).flatMap(([key, value]) => [key, value])
|
|
516
|
+
]);
|
|
489
517
|
}
|
|
490
518
|
};
|
|
491
519
|
|
|
@@ -619,6 +647,38 @@ var SCardCommand = class extends Command {
|
|
|
619
647
|
}
|
|
620
648
|
};
|
|
621
649
|
|
|
650
|
+
// pkg/commands/script_exists.ts
|
|
651
|
+
var ScriptExistsCommand = class extends Command {
|
|
652
|
+
constructor(...hash) {
|
|
653
|
+
super(["script", "exists", ...hash], {
|
|
654
|
+
deserialize: (result) => {
|
|
655
|
+
const parsed = result;
|
|
656
|
+
return parsed.length === 1 ? parsed[0] : parsed;
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// pkg/commands/script_flush.ts
|
|
663
|
+
var ScriptFlushCommand = class extends Command {
|
|
664
|
+
constructor(opts) {
|
|
665
|
+
const cmd = ["script", "flush"];
|
|
666
|
+
if (opts == null ? void 0 : opts.sync) {
|
|
667
|
+
cmd.push("sync");
|
|
668
|
+
} else if (opts == null ? void 0 : opts.async) {
|
|
669
|
+
cmd.push("async");
|
|
670
|
+
}
|
|
671
|
+
super(cmd);
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
// pkg/commands/script_load.ts
|
|
676
|
+
var ScriptLoadCommand = class extends Command {
|
|
677
|
+
constructor(script) {
|
|
678
|
+
super(["script", "load", script]);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
|
|
622
682
|
// pkg/commands/sdiff.ts
|
|
623
683
|
var SDiffCommand = class extends Command {
|
|
624
684
|
constructor(key, ...keys) {
|
|
@@ -1041,6 +1101,8 @@ var Pipeline = class {
|
|
|
1041
1101
|
this.decrby = (...args) => this.chain(new DecrByCommand(...args));
|
|
1042
1102
|
this.del = (...args) => this.chain(new DelCommand(...args));
|
|
1043
1103
|
this.echo = (...args) => this.chain(new EchoCommand(...args));
|
|
1104
|
+
this.eval = (...args) => this.chain(new EvalCommand(...args));
|
|
1105
|
+
this.evalsha = (...args) => this.chain(new EvalshaCommand(...args));
|
|
1044
1106
|
this.exists = (...args) => this.chain(new ExistsCommand(...args));
|
|
1045
1107
|
this.expire = (...args) => this.chain(new ExpireCommand(...args));
|
|
1046
1108
|
this.expireat = (...args) => this.chain(new ExpireAtCommand(...args));
|
|
@@ -1098,6 +1160,9 @@ var Pipeline = class {
|
|
|
1098
1160
|
this.sadd = (key, ...members) => this.chain(new SAddCommand(key, ...members));
|
|
1099
1161
|
this.scan = (...args) => this.chain(new ScanCommand(...args));
|
|
1100
1162
|
this.scard = (...args) => this.chain(new SCardCommand(...args));
|
|
1163
|
+
this.scriptExists = (...args) => this.chain(new ScriptExistsCommand(...args));
|
|
1164
|
+
this.scriptFlush = (...args) => this.chain(new ScriptFlushCommand(...args));
|
|
1165
|
+
this.scriptLoad = (...args) => this.chain(new ScriptLoadCommand(...args));
|
|
1101
1166
|
this.sdiff = (...args) => this.chain(new SDiffCommand(...args));
|
|
1102
1167
|
this.sdiffstore = (...args) => this.chain(new SDiffStoreCommand(...args));
|
|
1103
1168
|
this.set = (key, value, opts) => this.chain(new SetCommand(key, value, opts));
|
|
@@ -1167,6 +1232,8 @@ var Redis = class {
|
|
|
1167
1232
|
this.decrby = (...args) => new DecrByCommand(...args).exec(this.client);
|
|
1168
1233
|
this.del = (...args) => new DelCommand(...args).exec(this.client);
|
|
1169
1234
|
this.echo = (...args) => new EchoCommand(...args).exec(this.client);
|
|
1235
|
+
this.eval = (...args) => new EvalCommand(...args).exec(this.client);
|
|
1236
|
+
this.evalsha = (...args) => new EvalshaCommand(...args).exec(this.client);
|
|
1170
1237
|
this.exists = (...args) => new ExistsCommand(...args).exec(this.client);
|
|
1171
1238
|
this.expire = (...args) => new ExpireCommand(...args).exec(this.client);
|
|
1172
1239
|
this.expireat = (...args) => new ExpireAtCommand(...args).exec(this.client);
|
|
@@ -1224,6 +1291,9 @@ var Redis = class {
|
|
|
1224
1291
|
this.sadd = (key, ...members) => new SAddCommand(key, ...members).exec(this.client);
|
|
1225
1292
|
this.scan = (...args) => new ScanCommand(...args).exec(this.client);
|
|
1226
1293
|
this.scard = (...args) => new SCardCommand(...args).exec(this.client);
|
|
1294
|
+
this.scriptExists = (...args) => new ScriptExistsCommand(...args).exec(this.client);
|
|
1295
|
+
this.scriptFlush = (...args) => new ScriptFlushCommand(...args).exec(this.client);
|
|
1296
|
+
this.scriptLoad = (...args) => new ScriptLoadCommand(...args).exec(this.client);
|
|
1227
1297
|
this.sdiff = (...args) => new SDiffCommand(...args).exec(this.client);
|
|
1228
1298
|
this.sdiffstore = (...args) => new SDiffStoreCommand(...args).exec(this.client);
|
|
1229
1299
|
this.set = (key, value, opts) => new SetCommand(key, value, opts).exec(this.client);
|
|
@@ -1279,9 +1349,7 @@ var Redis = class {
|
|
|
1279
1349
|
var HttpClient = class {
|
|
1280
1350
|
constructor(config) {
|
|
1281
1351
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
1282
|
-
this.headers = __spreadValues({
|
|
1283
|
-
"Content-Type": "application/json"
|
|
1284
|
-
}, config.headers);
|
|
1352
|
+
this.headers = __spreadValues({ "Content-Type": "application/json" }, config.headers);
|
|
1285
1353
|
this.options = config.options;
|
|
1286
1354
|
}
|
|
1287
1355
|
async request(req) {
|
|
@@ -1304,14 +1372,30 @@ var HttpClient = class {
|
|
|
1304
1372
|
};
|
|
1305
1373
|
|
|
1306
1374
|
// pkg/nodejs.ts
|
|
1375
|
+
var import_https = __toESM(require("https"));
|
|
1307
1376
|
var import_isomorphic_fetch = require("isomorphic-fetch");
|
|
1308
1377
|
var Redis2 = class extends Redis {
|
|
1309
|
-
constructor(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1378
|
+
constructor(configOrRequester) {
|
|
1379
|
+
if ("request" in configOrRequester) {
|
|
1380
|
+
super(configOrRequester);
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
let agent = void 0;
|
|
1384
|
+
if (typeof window === "undefined") {
|
|
1385
|
+
const protocol = new URL(configOrRequester.url).protocol;
|
|
1386
|
+
switch (protocol) {
|
|
1387
|
+
case "https:":
|
|
1388
|
+
agent = new import_https.default.Agent({ keepAlive: true });
|
|
1389
|
+
break;
|
|
1390
|
+
case "http:":
|
|
1391
|
+
agent = new import_https.default.Agent({ keepAlive: true });
|
|
1392
|
+
break;
|
|
1314
1393
|
}
|
|
1394
|
+
}
|
|
1395
|
+
const client = new HttpClient({
|
|
1396
|
+
baseUrl: configOrRequester.url,
|
|
1397
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
1398
|
+
options: { agent }
|
|
1315
1399
|
});
|
|
1316
1400
|
super(client);
|
|
1317
1401
|
}
|
package/nodejs.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Redis
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-C2RGMNOQ.mjs";
|
|
4
|
+
import "./chunk-CTSQDNTV.mjs";
|
|
5
|
+
import "./chunk-K2UC7PHG.mjs";
|
|
6
|
+
import "./chunk-5LZNFEHI.mjs";
|
|
7
7
|
import "./chunk-7YUZYRJS.mjs";
|
|
8
8
|
export {
|
|
9
9
|
Redis
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "@upstash/redis", "version": "v1.
|
|
1
|
+
{ "name": "@upstash/redis", "version": "v1.3.0", "description": "An HTTP/REST based Redis client built on top of Upstash REST API.", "main": "./index.js", "module": "./index.mjs", "types": "./index.d.ts", "scripts": { "test": "jest -i", "fmt": "rome format .", "build": "tsup && cp package.json ./dist/ && pnpm size-limit" }, "repository": { "type": "git", "url": "git+https://github.com/upstash/upstash-redis.git" }, "keywords": [ "redis", "database", "serverless", "edge", "upstash" ], "author": "Andreas Thomas <andreas.thomas@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/upstash-redis/issues" }, "homepage": "https://github.com/upstash/upstash-redis#readme", "directories": { "examples": "examples" }, "devDependencies": { "@jest/globals": "^27.4.6", "@size-limit/preset-small-lib": "^7.0.8", "@types/jest": "^27.4.0", "@types/node": "^17.0.8", "dotenv": "^12.0.3", "jest": "^27.4.7", "rome": "^0.4.2-next", "size-limit": "^7.0.8", "ts-jest": "^27.1.3", "tsup": "^5.11.11", "typescript": "^4.5.5" }, "dependencies": { "isomorphic-fetch": "^3.0.0" }, "browser": { "isomorphic-fetch": false, "http": false, "https": false }, "size-limit": [ { "path": "dist/index.js", "limit": "6 KB" }, { "path": "dist/index.mjs", "limit": "6 KB" }, { "path": "dist/cloudflare.js", "limit": "6 KB" }, { "path": "dist/cloudflare.mjs", "limit": "6 KB" }, { "path": "dist/nodejs.js", "limit": "6 KB" }, { "path": "dist/nodejs.mjs", "limit": "6 KB" }, { "path": "dist/fastly.js", "limit": "6 KB" }, { "path": "dist/fastly.mjs", "limit": "6 KB" } ] }
|