@upstash/redis 1.3.0-alpha.0 → 1.3.1
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-CWZSFQQQ.mjs → chunk-CTSQDNTV.mjs} +13 -1
- package/{chunk-TLMWNHIZ.mjs → chunk-K2UC7PHG.mjs} +60 -8
- package/{chunk-4PD625HD.mjs → chunk-WRHUFPCZ.mjs} +24 -7
- package/cloudflare.d.ts +18 -16
- package/cloudflare.js +66 -14
- package/cloudflare.mjs +4 -6
- package/commands.d.ts +31 -4
- package/commands.js +64 -8
- package/commands.mjs +9 -1
- package/fastly.d.ts +23 -21
- package/fastly.js +66 -14
- 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 +92 -16
- package/index.mjs +4 -4
- package/nodejs.d.ts +25 -4
- package/nodejs.js +92 -16
- package/nodejs.mjs +4 -4
- package/package.json +1 -1
- package/{redis-5b966c20.d.ts → redis-338577a3.d.ts} +506 -471
- 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);
|
|
@@ -165,8 +170,15 @@ var EchoCommand = class extends Command {
|
|
|
165
170
|
|
|
166
171
|
// pkg/commands/eval.ts
|
|
167
172
|
var EvalCommand = class extends Command {
|
|
168
|
-
constructor(script,
|
|
169
|
-
super(["eval", script,
|
|
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 : []]);
|
|
170
182
|
}
|
|
171
183
|
};
|
|
172
184
|
|
|
@@ -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) {
|
|
@@ -1050,6 +1103,7 @@ var Pipeline = class {
|
|
|
1050
1103
|
this.del = (...args) => this.chain(new DelCommand(...args));
|
|
1051
1104
|
this.echo = (...args) => this.chain(new EchoCommand(...args));
|
|
1052
1105
|
this.eval = (...args) => this.chain(new EvalCommand(...args));
|
|
1106
|
+
this.evalsha = (...args) => this.chain(new EvalshaCommand(...args));
|
|
1053
1107
|
this.exists = (...args) => this.chain(new ExistsCommand(...args));
|
|
1054
1108
|
this.expire = (...args) => this.chain(new ExpireCommand(...args));
|
|
1055
1109
|
this.expireat = (...args) => this.chain(new ExpireAtCommand(...args));
|
|
@@ -1107,6 +1161,9 @@ var Pipeline = class {
|
|
|
1107
1161
|
this.sadd = (key, ...members) => this.chain(new SAddCommand(key, ...members));
|
|
1108
1162
|
this.scan = (...args) => this.chain(new ScanCommand(...args));
|
|
1109
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));
|
|
1110
1167
|
this.sdiff = (...args) => this.chain(new SDiffCommand(...args));
|
|
1111
1168
|
this.sdiffstore = (...args) => this.chain(new SDiffStoreCommand(...args));
|
|
1112
1169
|
this.set = (key, value, opts) => this.chain(new SetCommand(key, value, opts));
|
|
@@ -1177,6 +1234,7 @@ var Redis = class {
|
|
|
1177
1234
|
this.del = (...args) => new DelCommand(...args).exec(this.client);
|
|
1178
1235
|
this.echo = (...args) => new EchoCommand(...args).exec(this.client);
|
|
1179
1236
|
this.eval = (...args) => new EvalCommand(...args).exec(this.client);
|
|
1237
|
+
this.evalsha = (...args) => new EvalshaCommand(...args).exec(this.client);
|
|
1180
1238
|
this.exists = (...args) => new ExistsCommand(...args).exec(this.client);
|
|
1181
1239
|
this.expire = (...args) => new ExpireCommand(...args).exec(this.client);
|
|
1182
1240
|
this.expireat = (...args) => new ExpireAtCommand(...args).exec(this.client);
|
|
@@ -1234,6 +1292,9 @@ var Redis = class {
|
|
|
1234
1292
|
this.sadd = (key, ...members) => new SAddCommand(key, ...members).exec(this.client);
|
|
1235
1293
|
this.scan = (...args) => new ScanCommand(...args).exec(this.client);
|
|
1236
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);
|
|
1237
1298
|
this.sdiff = (...args) => new SDiffCommand(...args).exec(this.client);
|
|
1238
1299
|
this.sdiffstore = (...args) => new SDiffStoreCommand(...args).exec(this.client);
|
|
1239
1300
|
this.set = (key, value, opts) => new SetCommand(key, value, opts).exec(this.client);
|
|
@@ -1289,9 +1350,7 @@ var Redis = class {
|
|
|
1289
1350
|
var HttpClient = class {
|
|
1290
1351
|
constructor(config) {
|
|
1291
1352
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
1292
|
-
this.headers = __spreadValues({
|
|
1293
|
-
"Content-Type": "application/json"
|
|
1294
|
-
}, config.headers);
|
|
1353
|
+
this.headers = __spreadValues({ "Content-Type": "application/json" }, config.headers);
|
|
1295
1354
|
this.options = config.options;
|
|
1296
1355
|
}
|
|
1297
1356
|
async request(req) {
|
|
@@ -1314,14 +1373,31 @@ var HttpClient = class {
|
|
|
1314
1373
|
};
|
|
1315
1374
|
|
|
1316
1375
|
// pkg/nodejs.ts
|
|
1376
|
+
var import_https = __toESM(require("https"));
|
|
1317
1377
|
var import_isomorphic_fetch = require("isomorphic-fetch");
|
|
1318
1378
|
var Redis2 = class extends Redis {
|
|
1319
|
-
constructor(
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1379
|
+
constructor(configOrRequester) {
|
|
1380
|
+
var _a;
|
|
1381
|
+
if ("request" in configOrRequester) {
|
|
1382
|
+
super(configOrRequester);
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
let agent = void 0;
|
|
1386
|
+
if (typeof window === "undefined" && typeof process !== "undefined" && ((_a = process.release) == null ? void 0 : _a.name) === "node") {
|
|
1387
|
+
const protocol = new URL(configOrRequester.url).protocol;
|
|
1388
|
+
switch (protocol) {
|
|
1389
|
+
case "https:":
|
|
1390
|
+
agent = new import_https.default.Agent({ keepAlive: true });
|
|
1391
|
+
break;
|
|
1392
|
+
case "http:":
|
|
1393
|
+
agent = new import_https.default.Agent({ keepAlive: true });
|
|
1394
|
+
break;
|
|
1324
1395
|
}
|
|
1396
|
+
}
|
|
1397
|
+
const client = new HttpClient({
|
|
1398
|
+
baseUrl: configOrRequester.url,
|
|
1399
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
1400
|
+
options: { agent }
|
|
1325
1401
|
});
|
|
1326
1402
|
super(client);
|
|
1327
1403
|
}
|
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-WRHUFPCZ.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.
|
|
@@ -21,7 +24,7 @@ declare type RedisConfigNodejs = {
|
|
|
21
24
|
*/
|
|
22
25
|
declare class Redis extends Redis$1 {
|
|
23
26
|
/**
|
|
24
|
-
* Create a new redis client
|
|
27
|
+
* Create a new redis client by providing the url and token
|
|
25
28
|
*
|
|
26
29
|
* @example
|
|
27
30
|
* ```typescript
|
|
@@ -32,6 +35,24 @@ declare class Redis extends Redis$1 {
|
|
|
32
35
|
* ```
|
|
33
36
|
*/
|
|
34
37
|
constructor(config: RedisConfigNodejs);
|
|
38
|
+
/**
|
|
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);
|
|
35
56
|
/**
|
|
36
57
|
* Create a new Upstash Redis instance from environment variables.
|
|
37
58
|
*
|
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);
|
|
@@ -164,8 +169,15 @@ var EchoCommand = class extends Command {
|
|
|
164
169
|
|
|
165
170
|
// pkg/commands/eval.ts
|
|
166
171
|
var EvalCommand = class extends Command {
|
|
167
|
-
constructor(script,
|
|
168
|
-
super(["eval", script,
|
|
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 : []]);
|
|
169
181
|
}
|
|
170
182
|
};
|
|
171
183
|
|
|
@@ -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) {
|
|
@@ -1049,6 +1102,7 @@ var Pipeline = class {
|
|
|
1049
1102
|
this.del = (...args) => this.chain(new DelCommand(...args));
|
|
1050
1103
|
this.echo = (...args) => this.chain(new EchoCommand(...args));
|
|
1051
1104
|
this.eval = (...args) => this.chain(new EvalCommand(...args));
|
|
1105
|
+
this.evalsha = (...args) => this.chain(new EvalshaCommand(...args));
|
|
1052
1106
|
this.exists = (...args) => this.chain(new ExistsCommand(...args));
|
|
1053
1107
|
this.expire = (...args) => this.chain(new ExpireCommand(...args));
|
|
1054
1108
|
this.expireat = (...args) => this.chain(new ExpireAtCommand(...args));
|
|
@@ -1106,6 +1160,9 @@ var Pipeline = class {
|
|
|
1106
1160
|
this.sadd = (key, ...members) => this.chain(new SAddCommand(key, ...members));
|
|
1107
1161
|
this.scan = (...args) => this.chain(new ScanCommand(...args));
|
|
1108
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));
|
|
1109
1166
|
this.sdiff = (...args) => this.chain(new SDiffCommand(...args));
|
|
1110
1167
|
this.sdiffstore = (...args) => this.chain(new SDiffStoreCommand(...args));
|
|
1111
1168
|
this.set = (key, value, opts) => this.chain(new SetCommand(key, value, opts));
|
|
@@ -1176,6 +1233,7 @@ var Redis = class {
|
|
|
1176
1233
|
this.del = (...args) => new DelCommand(...args).exec(this.client);
|
|
1177
1234
|
this.echo = (...args) => new EchoCommand(...args).exec(this.client);
|
|
1178
1235
|
this.eval = (...args) => new EvalCommand(...args).exec(this.client);
|
|
1236
|
+
this.evalsha = (...args) => new EvalshaCommand(...args).exec(this.client);
|
|
1179
1237
|
this.exists = (...args) => new ExistsCommand(...args).exec(this.client);
|
|
1180
1238
|
this.expire = (...args) => new ExpireCommand(...args).exec(this.client);
|
|
1181
1239
|
this.expireat = (...args) => new ExpireAtCommand(...args).exec(this.client);
|
|
@@ -1233,6 +1291,9 @@ var Redis = class {
|
|
|
1233
1291
|
this.sadd = (key, ...members) => new SAddCommand(key, ...members).exec(this.client);
|
|
1234
1292
|
this.scan = (...args) => new ScanCommand(...args).exec(this.client);
|
|
1235
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);
|
|
1236
1297
|
this.sdiff = (...args) => new SDiffCommand(...args).exec(this.client);
|
|
1237
1298
|
this.sdiffstore = (...args) => new SDiffStoreCommand(...args).exec(this.client);
|
|
1238
1299
|
this.set = (key, value, opts) => new SetCommand(key, value, opts).exec(this.client);
|
|
@@ -1288,9 +1349,7 @@ var Redis = class {
|
|
|
1288
1349
|
var HttpClient = class {
|
|
1289
1350
|
constructor(config) {
|
|
1290
1351
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
1291
|
-
this.headers = __spreadValues({
|
|
1292
|
-
"Content-Type": "application/json"
|
|
1293
|
-
}, config.headers);
|
|
1352
|
+
this.headers = __spreadValues({ "Content-Type": "application/json" }, config.headers);
|
|
1294
1353
|
this.options = config.options;
|
|
1295
1354
|
}
|
|
1296
1355
|
async request(req) {
|
|
@@ -1313,14 +1372,31 @@ var HttpClient = class {
|
|
|
1313
1372
|
};
|
|
1314
1373
|
|
|
1315
1374
|
// pkg/nodejs.ts
|
|
1375
|
+
var import_https = __toESM(require("https"));
|
|
1316
1376
|
var import_isomorphic_fetch = require("isomorphic-fetch");
|
|
1317
1377
|
var Redis2 = class extends Redis {
|
|
1318
|
-
constructor(
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1378
|
+
constructor(configOrRequester) {
|
|
1379
|
+
var _a;
|
|
1380
|
+
if ("request" in configOrRequester) {
|
|
1381
|
+
super(configOrRequester);
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
let agent = void 0;
|
|
1385
|
+
if (typeof window === "undefined" && typeof process !== "undefined" && ((_a = process.release) == null ? void 0 : _a.name) === "node") {
|
|
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;
|
|
1323
1394
|
}
|
|
1395
|
+
}
|
|
1396
|
+
const client = new HttpClient({
|
|
1397
|
+
baseUrl: configOrRequester.url,
|
|
1398
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
1399
|
+
options: { agent }
|
|
1324
1400
|
});
|
|
1325
1401
|
super(client);
|
|
1326
1402
|
}
|
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-WRHUFPCZ.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.
|
|
1
|
+
{ "name": "@upstash/redis", "version": "v1.3.1", "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" } ] }
|