@upstash/redis 1.3.0-alpha.1 → 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-T3BIHZ2F.mjs → chunk-C2RGMNOQ.mjs} +23 -7
- package/{chunk-KI7YOGWS.mjs → chunk-CTSQDNTV.mjs} +5 -41
- package/{chunk-5567SQFQ.mjs → chunk-K2UC7PHG.mjs} +58 -6
- package/cloudflare.d.ts +18 -16
- package/cloudflare.js +56 -51
- package/cloudflare.mjs +4 -6
- package/commands.d.ts +30 -3
- package/commands.js +62 -6
- package/commands.mjs +9 -1
- package/fastly.d.ts +23 -21
- package/fastly.js +56 -51
- 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 +81 -53
- package/index.mjs +4 -4
- package/nodejs.d.ts +46 -25
- package/nodejs.js +81 -53
- package/nodejs.mjs +4 -4
- package/package.json +1 -1
- package/{redis-364a4445.d.ts → redis-338577a3.d.ts} +488 -496
- 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);
|
|
@@ -170,6 +175,13 @@ var EvalCommand = class extends Command {
|
|
|
170
175
|
}
|
|
171
176
|
};
|
|
172
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
|
+
|
|
173
185
|
// pkg/commands/exists.ts
|
|
174
186
|
var ExistsCommand = class extends Command {
|
|
175
187
|
constructor(...keys) {
|
|
@@ -330,16 +342,18 @@ function deserialize2(fields, result) {
|
|
|
330
342
|
}
|
|
331
343
|
var HMGetCommand = class extends Command {
|
|
332
344
|
constructor(key, ...fields) {
|
|
333
|
-
super(["hmget", key, ...fields], {
|
|
334
|
-
deserialize: (result) => deserialize2(fields, result)
|
|
335
|
-
});
|
|
345
|
+
super(["hmget", key, ...fields], { deserialize: (result) => deserialize2(fields, result) });
|
|
336
346
|
}
|
|
337
347
|
};
|
|
338
348
|
|
|
339
349
|
// pkg/commands/hmset.ts
|
|
340
350
|
var HMSetCommand = class extends Command {
|
|
341
351
|
constructor(key, kv) {
|
|
342
|
-
super([
|
|
352
|
+
super([
|
|
353
|
+
"hmset",
|
|
354
|
+
key,
|
|
355
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
356
|
+
]);
|
|
343
357
|
}
|
|
344
358
|
};
|
|
345
359
|
|
|
@@ -360,7 +374,11 @@ var HScanCommand = class extends Command {
|
|
|
360
374
|
// pkg/commands/hset.ts
|
|
361
375
|
var HSetCommand = class extends Command {
|
|
362
376
|
constructor(key, kv) {
|
|
363
|
-
super([
|
|
377
|
+
super([
|
|
378
|
+
"hset",
|
|
379
|
+
key,
|
|
380
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
381
|
+
]);
|
|
364
382
|
}
|
|
365
383
|
};
|
|
366
384
|
|
|
@@ -493,7 +511,10 @@ var MGetCommand = class extends Command {
|
|
|
493
511
|
// pkg/commands/mset.ts
|
|
494
512
|
var MSetCommand = class extends Command {
|
|
495
513
|
constructor(kv) {
|
|
496
|
-
super([
|
|
514
|
+
super([
|
|
515
|
+
"mset",
|
|
516
|
+
...Object.entries(kv).flatMap(([key, value]) => [key, value])
|
|
517
|
+
]);
|
|
497
518
|
}
|
|
498
519
|
};
|
|
499
520
|
|
|
@@ -627,6 +648,38 @@ var SCardCommand = class extends Command {
|
|
|
627
648
|
}
|
|
628
649
|
};
|
|
629
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
|
+
|
|
630
683
|
// pkg/commands/sdiff.ts
|
|
631
684
|
var SDiffCommand = class extends Command {
|
|
632
685
|
constructor(key, ...keys) {
|
|
@@ -1022,45 +1075,6 @@ var ZUnionStoreCommand = class extends Command {
|
|
|
1022
1075
|
}
|
|
1023
1076
|
};
|
|
1024
1077
|
|
|
1025
|
-
// pkg/commands/evalsha.ts
|
|
1026
|
-
var EvalshaCommand = class extends Command {
|
|
1027
|
-
constructor(sha, keys, args) {
|
|
1028
|
-
super(["evalsha", sha, keys.length, ...keys, ...args != null ? args : []]);
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
// pkg/commands/script_exists.ts
|
|
1033
|
-
var ScriptExistsCommand = class extends Command {
|
|
1034
|
-
constructor(...hash) {
|
|
1035
|
-
super(["script", "exists", ...hash], {
|
|
1036
|
-
deserialize: (result) => {
|
|
1037
|
-
const parsed = result;
|
|
1038
|
-
return parsed.length === 1 ? parsed[0] : parsed;
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
// pkg/commands/script_flush.ts
|
|
1045
|
-
var ScriptFlushCommand = class extends Command {
|
|
1046
|
-
constructor(opts) {
|
|
1047
|
-
const cmd = ["script", "flush"];
|
|
1048
|
-
if (opts == null ? void 0 : opts.sync) {
|
|
1049
|
-
cmd.push("sync");
|
|
1050
|
-
} else if (opts == null ? void 0 : opts.async) {
|
|
1051
|
-
cmd.push("async");
|
|
1052
|
-
}
|
|
1053
|
-
super(cmd);
|
|
1054
|
-
}
|
|
1055
|
-
};
|
|
1056
|
-
|
|
1057
|
-
// pkg/commands/script_load.ts
|
|
1058
|
-
var ScriptLoadCommand = class extends Command {
|
|
1059
|
-
constructor(script) {
|
|
1060
|
-
super(["script", "load", script]);
|
|
1061
|
-
}
|
|
1062
|
-
};
|
|
1063
|
-
|
|
1064
1078
|
// pkg/pipeline.ts
|
|
1065
1079
|
var Pipeline = class {
|
|
1066
1080
|
constructor(client) {
|
|
@@ -1336,9 +1350,7 @@ var Redis = class {
|
|
|
1336
1350
|
var HttpClient = class {
|
|
1337
1351
|
constructor(config) {
|
|
1338
1352
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
1339
|
-
this.headers = __spreadValues({
|
|
1340
|
-
"Content-Type": "application/json"
|
|
1341
|
-
}, config.headers);
|
|
1353
|
+
this.headers = __spreadValues({ "Content-Type": "application/json" }, config.headers);
|
|
1342
1354
|
this.options = config.options;
|
|
1343
1355
|
}
|
|
1344
1356
|
async request(req) {
|
|
@@ -1361,14 +1373,30 @@ var HttpClient = class {
|
|
|
1361
1373
|
};
|
|
1362
1374
|
|
|
1363
1375
|
// pkg/nodejs.ts
|
|
1376
|
+
var import_https = __toESM(require("https"));
|
|
1364
1377
|
var import_isomorphic_fetch = require("isomorphic-fetch");
|
|
1365
1378
|
var Redis2 = class extends Redis {
|
|
1366
|
-
constructor(
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
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;
|
|
1371
1394
|
}
|
|
1395
|
+
}
|
|
1396
|
+
const client = new HttpClient({
|
|
1397
|
+
baseUrl: configOrRequester.url,
|
|
1398
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
1399
|
+
options: { agent }
|
|
1372
1400
|
});
|
|
1373
1401
|
super(client);
|
|
1374
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);
|
|
@@ -169,6 +174,13 @@ var EvalCommand = class extends Command {
|
|
|
169
174
|
}
|
|
170
175
|
};
|
|
171
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
|
+
|
|
172
184
|
// pkg/commands/exists.ts
|
|
173
185
|
var ExistsCommand = class extends Command {
|
|
174
186
|
constructor(...keys) {
|
|
@@ -329,16 +341,18 @@ function deserialize2(fields, result) {
|
|
|
329
341
|
}
|
|
330
342
|
var HMGetCommand = class extends Command {
|
|
331
343
|
constructor(key, ...fields) {
|
|
332
|
-
super(["hmget", key, ...fields], {
|
|
333
|
-
deserialize: (result) => deserialize2(fields, result)
|
|
334
|
-
});
|
|
344
|
+
super(["hmget", key, ...fields], { deserialize: (result) => deserialize2(fields, result) });
|
|
335
345
|
}
|
|
336
346
|
};
|
|
337
347
|
|
|
338
348
|
// pkg/commands/hmset.ts
|
|
339
349
|
var HMSetCommand = class extends Command {
|
|
340
350
|
constructor(key, kv) {
|
|
341
|
-
super([
|
|
351
|
+
super([
|
|
352
|
+
"hmset",
|
|
353
|
+
key,
|
|
354
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
355
|
+
]);
|
|
342
356
|
}
|
|
343
357
|
};
|
|
344
358
|
|
|
@@ -359,7 +373,11 @@ var HScanCommand = class extends Command {
|
|
|
359
373
|
// pkg/commands/hset.ts
|
|
360
374
|
var HSetCommand = class extends Command {
|
|
361
375
|
constructor(key, kv) {
|
|
362
|
-
super([
|
|
376
|
+
super([
|
|
377
|
+
"hset",
|
|
378
|
+
key,
|
|
379
|
+
...Object.entries(kv).flatMap(([field, value]) => [field, value])
|
|
380
|
+
]);
|
|
363
381
|
}
|
|
364
382
|
};
|
|
365
383
|
|
|
@@ -492,7 +510,10 @@ var MGetCommand = class extends Command {
|
|
|
492
510
|
// pkg/commands/mset.ts
|
|
493
511
|
var MSetCommand = class extends Command {
|
|
494
512
|
constructor(kv) {
|
|
495
|
-
super([
|
|
513
|
+
super([
|
|
514
|
+
"mset",
|
|
515
|
+
...Object.entries(kv).flatMap(([key, value]) => [key, value])
|
|
516
|
+
]);
|
|
496
517
|
}
|
|
497
518
|
};
|
|
498
519
|
|
|
@@ -626,6 +647,38 @@ var SCardCommand = class extends Command {
|
|
|
626
647
|
}
|
|
627
648
|
};
|
|
628
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
|
+
|
|
629
682
|
// pkg/commands/sdiff.ts
|
|
630
683
|
var SDiffCommand = class extends Command {
|
|
631
684
|
constructor(key, ...keys) {
|
|
@@ -1021,45 +1074,6 @@ var ZUnionStoreCommand = class extends Command {
|
|
|
1021
1074
|
}
|
|
1022
1075
|
};
|
|
1023
1076
|
|
|
1024
|
-
// pkg/commands/evalsha.ts
|
|
1025
|
-
var EvalshaCommand = class extends Command {
|
|
1026
|
-
constructor(sha, keys, args) {
|
|
1027
|
-
super(["evalsha", sha, keys.length, ...keys, ...args != null ? args : []]);
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
|
|
1031
|
-
// pkg/commands/script_exists.ts
|
|
1032
|
-
var ScriptExistsCommand = class extends Command {
|
|
1033
|
-
constructor(...hash) {
|
|
1034
|
-
super(["script", "exists", ...hash], {
|
|
1035
|
-
deserialize: (result) => {
|
|
1036
|
-
const parsed = result;
|
|
1037
|
-
return parsed.length === 1 ? parsed[0] : parsed;
|
|
1038
|
-
}
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
|
|
1043
|
-
// pkg/commands/script_flush.ts
|
|
1044
|
-
var ScriptFlushCommand = class extends Command {
|
|
1045
|
-
constructor(opts) {
|
|
1046
|
-
const cmd = ["script", "flush"];
|
|
1047
|
-
if (opts == null ? void 0 : opts.sync) {
|
|
1048
|
-
cmd.push("sync");
|
|
1049
|
-
} else if (opts == null ? void 0 : opts.async) {
|
|
1050
|
-
cmd.push("async");
|
|
1051
|
-
}
|
|
1052
|
-
super(cmd);
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
// pkg/commands/script_load.ts
|
|
1057
|
-
var ScriptLoadCommand = class extends Command {
|
|
1058
|
-
constructor(script) {
|
|
1059
|
-
super(["script", "load", script]);
|
|
1060
|
-
}
|
|
1061
|
-
};
|
|
1062
|
-
|
|
1063
1077
|
// pkg/pipeline.ts
|
|
1064
1078
|
var Pipeline = class {
|
|
1065
1079
|
constructor(client) {
|
|
@@ -1335,9 +1349,7 @@ var Redis = class {
|
|
|
1335
1349
|
var HttpClient = class {
|
|
1336
1350
|
constructor(config) {
|
|
1337
1351
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
1338
|
-
this.headers = __spreadValues({
|
|
1339
|
-
"Content-Type": "application/json"
|
|
1340
|
-
}, config.headers);
|
|
1352
|
+
this.headers = __spreadValues({ "Content-Type": "application/json" }, config.headers);
|
|
1341
1353
|
this.options = config.options;
|
|
1342
1354
|
}
|
|
1343
1355
|
async request(req) {
|
|
@@ -1360,14 +1372,30 @@ var HttpClient = class {
|
|
|
1360
1372
|
};
|
|
1361
1373
|
|
|
1362
1374
|
// pkg/nodejs.ts
|
|
1375
|
+
var import_https = __toESM(require("https"));
|
|
1363
1376
|
var import_isomorphic_fetch = require("isomorphic-fetch");
|
|
1364
1377
|
var Redis2 = class extends Redis {
|
|
1365
|
-
constructor(
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
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;
|
|
1370
1393
|
}
|
|
1394
|
+
}
|
|
1395
|
+
const client = new HttpClient({
|
|
1396
|
+
baseUrl: configOrRequester.url,
|
|
1397
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
1398
|
+
options: { agent }
|
|
1371
1399
|
});
|
|
1372
1400
|
super(client);
|
|
1373
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.3.0
|
|
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" } ] }
|