@upstash/redis 0.1.11 → 0.2.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 +13 -26
- package/dist/main/client.d.ts +19 -156
- package/dist/main/client.js +317 -418
- package/dist/main/index-cjs.d.ts +1 -0
- package/dist/main/index-cjs.js +120 -0
- package/dist/main/types.d.ts +179 -0
- package/dist/main/types.js +2 -0
- package/dist/module/client.d.ts +19 -156
- package/dist/module/client.js +317 -417
- package/dist/module/index.d.ts +3 -34
- package/dist/module/index.js +3 -9
- package/dist/module/types.d.ts +179 -0
- package/dist/module/types.js +1 -0
- package/package.json +14 -23
- package/src/client.ts +626 -0
- package/src/index-cjs.ts +117 -0
- package/src/index.ts +118 -0
- package/src/types.ts +410 -0
- package/tsconfig.json +9 -7
- package/tsconfig.module.json +3 -2
- package/dist/main/client.d.ts.map +0 -1
- package/dist/main/client.js.map +0 -1
- package/dist/main/index.d.ts +0 -34
- package/dist/main/index.d.ts.map +0 -1
- package/dist/main/index.js +0 -125
- package/dist/main/index.js.map +0 -1
- package/dist/module/client.d.ts.map +0 -1
- package/dist/module/client.js.map +0 -1
- package/dist/module/index.d.ts.map +0 -1
- package/dist/module/index.js.map +0 -1
- package/dist/umd/upstash-redis.js +0 -1
- package/utils/sleep.ts +0 -3
- package/webpack.config.js +0 -34
package/dist/main/client.js
CHANGED
|
@@ -1,541 +1,439 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
15
|
const isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
|
|
7
16
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {string} url - database rest url
|
|
10
|
-
* @param {string} token - database rest token
|
|
17
|
+
* Parse Options
|
|
11
18
|
*/
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let authToken = (_c = token !== null && token !== void 0 ? token : process.env.UPSTASH_REDIS_REST_TOKEN) !== null && _c !== void 0 ? _c : '';
|
|
16
|
-
function auth(url, token) {
|
|
17
|
-
baseURL = url;
|
|
18
|
-
authToken = token;
|
|
19
|
+
function parseOptions(url, token, requestOptions = {}) {
|
|
20
|
+
if (typeof url === 'object' && url !== null) {
|
|
21
|
+
return parseOptions(url.url, url.token, url.requestOptions);
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
// try auto fill from env variables
|
|
24
|
+
if (!url && typeof window === 'undefined') {
|
|
25
|
+
url = process.env.UPSTASH_REDIS_REST_URL;
|
|
26
|
+
token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
27
|
+
}
|
|
28
|
+
return { url: url, token, requestOptions };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetch
|
|
32
|
+
*/
|
|
33
|
+
function fetchData(options, ...parts) {
|
|
34
|
+
var _a;
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
if (!options.url) {
|
|
37
|
+
throw 'Database url not found?';
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const res = yield (0, isomorphic_unfetch_1.default)(options.url, Object.assign({ method: 'POST', body: JSON.stringify(parts), headers: Object.assign({ Authorization: `Bearer ${options.token}` }, (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.headers) }, options.requestOptions));
|
|
41
|
+
const data = yield res.json();
|
|
42
|
+
if (!res.ok) {
|
|
36
43
|
if (data.error)
|
|
37
44
|
throw data.error;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return promise.then(callback);
|
|
45
|
+
throw `Upstash failed with (${res.status}): ${JSON.stringify(data, null, 2)}`;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
data: data.result,
|
|
49
|
+
error: null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
return {
|
|
54
|
+
data: null,
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
error: err,
|
|
57
|
+
};
|
|
52
58
|
}
|
|
53
|
-
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function upstash(url, token) {
|
|
62
|
+
const options = parseOptions(url, token);
|
|
63
|
+
/**
|
|
64
|
+
* Auth
|
|
65
|
+
*/
|
|
66
|
+
function auth() {
|
|
67
|
+
Object.assign(options, {
|
|
68
|
+
url: undefined,
|
|
69
|
+
token: undefined,
|
|
70
|
+
}, parseOptions(arguments[0], arguments[1]));
|
|
54
71
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
STRING
|
|
58
|
-
------------------------------------------------
|
|
72
|
+
/**
|
|
73
|
+
* STRING
|
|
59
74
|
*/
|
|
60
|
-
function append(
|
|
61
|
-
return
|
|
75
|
+
function append() {
|
|
76
|
+
return fetchData(options, 'append', ...arguments);
|
|
62
77
|
}
|
|
63
|
-
function decr(
|
|
64
|
-
return
|
|
78
|
+
function decr() {
|
|
79
|
+
return fetchData(options, 'decr', ...arguments);
|
|
65
80
|
}
|
|
66
|
-
function decrby(
|
|
67
|
-
return
|
|
81
|
+
function decrby() {
|
|
82
|
+
return fetchData(options, 'decrby', ...arguments);
|
|
68
83
|
}
|
|
69
|
-
function get(
|
|
70
|
-
return
|
|
84
|
+
function get() {
|
|
85
|
+
return fetchData(options, 'get', ...arguments);
|
|
71
86
|
}
|
|
72
|
-
function getrange(
|
|
73
|
-
return
|
|
87
|
+
function getrange() {
|
|
88
|
+
return fetchData(options, 'getrange', ...arguments);
|
|
74
89
|
}
|
|
75
|
-
function getset(
|
|
76
|
-
return
|
|
90
|
+
function getset() {
|
|
91
|
+
return fetchData(options, 'getset', ...arguments);
|
|
77
92
|
}
|
|
78
|
-
function incr(
|
|
79
|
-
return
|
|
93
|
+
function incr() {
|
|
94
|
+
return fetchData(options, 'incr', ...arguments);
|
|
80
95
|
}
|
|
81
|
-
function incrby(
|
|
82
|
-
return
|
|
96
|
+
function incrby() {
|
|
97
|
+
return fetchData(options, 'incrby', ...arguments);
|
|
83
98
|
}
|
|
84
|
-
function incrbyfloat(
|
|
85
|
-
return
|
|
99
|
+
function incrbyfloat() {
|
|
100
|
+
return fetchData(options, 'incrbyfloat', ...arguments);
|
|
86
101
|
}
|
|
87
|
-
function mget(
|
|
88
|
-
return
|
|
102
|
+
function mget() {
|
|
103
|
+
return fetchData(options, 'mget', ...arguments);
|
|
89
104
|
}
|
|
90
|
-
function mset(
|
|
91
|
-
return
|
|
105
|
+
function mset() {
|
|
106
|
+
return fetchData(options, 'mset', ...arguments);
|
|
92
107
|
}
|
|
93
|
-
function msetnx(
|
|
94
|
-
return
|
|
108
|
+
function msetnx() {
|
|
109
|
+
return fetchData(options, 'msetnx', ...arguments);
|
|
95
110
|
}
|
|
96
|
-
function psetex(
|
|
97
|
-
return
|
|
111
|
+
function psetex() {
|
|
112
|
+
return fetchData(options, 'psetex', ...arguments);
|
|
98
113
|
}
|
|
99
|
-
function set(
|
|
100
|
-
return
|
|
114
|
+
function set() {
|
|
115
|
+
return fetchData(options, 'set', ...arguments);
|
|
101
116
|
}
|
|
102
|
-
function setex(
|
|
103
|
-
return
|
|
117
|
+
function setex() {
|
|
118
|
+
return fetchData(options, 'setex', ...arguments);
|
|
104
119
|
}
|
|
105
|
-
function setnx(
|
|
106
|
-
return
|
|
120
|
+
function setnx() {
|
|
121
|
+
return fetchData(options, 'setnx', ...arguments);
|
|
107
122
|
}
|
|
108
|
-
function setrange(
|
|
109
|
-
return
|
|
123
|
+
function setrange() {
|
|
124
|
+
return fetchData(options, 'setrange', ...arguments);
|
|
110
125
|
}
|
|
111
|
-
function strlen(
|
|
112
|
-
return
|
|
126
|
+
function strlen() {
|
|
127
|
+
return fetchData(options, 'strlen', ...arguments);
|
|
113
128
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
BITMAPS
|
|
117
|
-
------------------------------------------------
|
|
129
|
+
/**
|
|
130
|
+
* BITMAPS
|
|
118
131
|
*/
|
|
119
|
-
function bitcount(
|
|
120
|
-
|
|
121
|
-
return request(callback, 'bitcount', key, start, end);
|
|
122
|
-
}
|
|
123
|
-
return request(callback, 'bitcount', key);
|
|
132
|
+
function bitcount() {
|
|
133
|
+
return fetchData(options, 'bitcount', ...arguments);
|
|
124
134
|
}
|
|
125
|
-
function bitop(
|
|
126
|
-
return
|
|
135
|
+
function bitop() {
|
|
136
|
+
return fetchData(options, 'bitop', ...arguments);
|
|
127
137
|
}
|
|
128
|
-
function bitpos(
|
|
129
|
-
|
|
130
|
-
return request(callback, 'bitpos', key, bit, start, end);
|
|
131
|
-
}
|
|
132
|
-
else if (start !== undefined) {
|
|
133
|
-
return request(callback, 'bitpos', key, bit, start);
|
|
134
|
-
}
|
|
135
|
-
return request(callback, 'bitpos', key, bit);
|
|
138
|
+
function bitpos() {
|
|
139
|
+
return fetchData(options, 'bitpos', ...arguments);
|
|
136
140
|
}
|
|
137
|
-
function getbit(
|
|
138
|
-
return
|
|
141
|
+
function getbit() {
|
|
142
|
+
return fetchData(options, 'getbit', ...arguments);
|
|
139
143
|
}
|
|
140
|
-
function setbit(
|
|
141
|
-
return
|
|
144
|
+
function setbit() {
|
|
145
|
+
return fetchData(options, 'setbit', ...arguments);
|
|
142
146
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
CONNECTION
|
|
146
|
-
------------------------------------------------
|
|
147
|
+
/**
|
|
148
|
+
* CONNECTION
|
|
147
149
|
*/
|
|
148
|
-
function echo(
|
|
149
|
-
return
|
|
150
|
+
function echo() {
|
|
151
|
+
return fetchData(options, 'echo', ...arguments);
|
|
150
152
|
}
|
|
151
|
-
function ping(
|
|
152
|
-
|
|
153
|
-
return request(callback, 'ping', value);
|
|
154
|
-
}
|
|
155
|
-
return request(callback, 'ping');
|
|
153
|
+
function ping() {
|
|
154
|
+
return fetchData(options, 'ping', ...arguments);
|
|
156
155
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
HASHES
|
|
160
|
-
------------------------------------------------
|
|
156
|
+
/**
|
|
157
|
+
* HASHES
|
|
161
158
|
*/
|
|
162
|
-
function hdel(
|
|
163
|
-
return
|
|
159
|
+
function hdel() {
|
|
160
|
+
return fetchData(options, 'hdel', ...arguments);
|
|
164
161
|
}
|
|
165
|
-
function hexists(
|
|
166
|
-
return
|
|
162
|
+
function hexists() {
|
|
163
|
+
return fetchData(options, 'hexists', ...arguments);
|
|
167
164
|
}
|
|
168
|
-
function hget(
|
|
169
|
-
return
|
|
165
|
+
function hget() {
|
|
166
|
+
return fetchData(options, 'hget', ...arguments);
|
|
170
167
|
}
|
|
171
|
-
function hgetall(
|
|
172
|
-
return
|
|
168
|
+
function hgetall() {
|
|
169
|
+
return fetchData(options, 'hgetall', ...arguments);
|
|
173
170
|
}
|
|
174
|
-
function hincrby(
|
|
175
|
-
return
|
|
171
|
+
function hincrby() {
|
|
172
|
+
return fetchData(options, 'hincrby', ...arguments);
|
|
176
173
|
}
|
|
177
|
-
function hincrbyfloat(
|
|
178
|
-
return
|
|
174
|
+
function hincrbyfloat() {
|
|
175
|
+
return fetchData(options, 'hincrbyfloat', ...arguments);
|
|
179
176
|
}
|
|
180
|
-
function hkeys(
|
|
181
|
-
return
|
|
177
|
+
function hkeys() {
|
|
178
|
+
return fetchData(options, 'hkeys', ...arguments);
|
|
182
179
|
}
|
|
183
|
-
function hlen(
|
|
184
|
-
return
|
|
180
|
+
function hlen() {
|
|
181
|
+
return fetchData(options, 'hlen', ...arguments);
|
|
185
182
|
}
|
|
186
|
-
function hmget(
|
|
187
|
-
return
|
|
183
|
+
function hmget() {
|
|
184
|
+
return fetchData(options, 'hmget', ...arguments);
|
|
188
185
|
}
|
|
189
|
-
function hmset(
|
|
190
|
-
return
|
|
186
|
+
function hmset() {
|
|
187
|
+
return fetchData(options, 'hmset', ...arguments);
|
|
191
188
|
}
|
|
192
|
-
function hscan(
|
|
193
|
-
|
|
194
|
-
return request(callback, 'hscan', key, cursor, 'match', options.match, 'count', options.count);
|
|
195
|
-
}
|
|
196
|
-
else if (options === null || options === void 0 ? void 0 : options.match) {
|
|
197
|
-
return request(callback, 'hscan', key, cursor, 'match', options.match);
|
|
198
|
-
}
|
|
199
|
-
else if (options === null || options === void 0 ? void 0 : options.count) {
|
|
200
|
-
return request(callback, 'hscan', key, cursor, 'count', options.count);
|
|
201
|
-
}
|
|
202
|
-
return request(callback, 'hscan', key, cursor);
|
|
189
|
+
function hscan() {
|
|
190
|
+
return fetchData(options, 'hscan', ...arguments);
|
|
203
191
|
}
|
|
204
|
-
function hset(
|
|
205
|
-
return
|
|
192
|
+
function hset() {
|
|
193
|
+
return fetchData(options, 'hset', ...arguments);
|
|
206
194
|
}
|
|
207
|
-
function hsetnx(
|
|
208
|
-
return
|
|
195
|
+
function hsetnx() {
|
|
196
|
+
return fetchData(options, 'hsetnx', ...arguments);
|
|
209
197
|
}
|
|
210
|
-
function hvals(
|
|
211
|
-
return
|
|
198
|
+
function hvals() {
|
|
199
|
+
return fetchData(options, 'hvals', ...arguments);
|
|
212
200
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
KEYS
|
|
216
|
-
------------------------------------------------
|
|
201
|
+
/**
|
|
202
|
+
* KEYS
|
|
217
203
|
*/
|
|
218
|
-
function del(
|
|
219
|
-
return
|
|
204
|
+
function del() {
|
|
205
|
+
return fetchData(options, 'del', ...arguments);
|
|
220
206
|
}
|
|
221
|
-
function exists(
|
|
222
|
-
return
|
|
207
|
+
function exists() {
|
|
208
|
+
return fetchData(options, 'exists', ...arguments);
|
|
223
209
|
}
|
|
224
|
-
function expire(
|
|
225
|
-
return
|
|
210
|
+
function expire() {
|
|
211
|
+
return fetchData(options, 'expire', ...arguments);
|
|
226
212
|
}
|
|
227
|
-
function expireat(
|
|
228
|
-
return
|
|
213
|
+
function expireat() {
|
|
214
|
+
return fetchData(options, 'expireat', ...arguments);
|
|
229
215
|
}
|
|
230
|
-
function keys(
|
|
231
|
-
return
|
|
216
|
+
function keys() {
|
|
217
|
+
return fetchData(options, 'keys', ...arguments);
|
|
232
218
|
}
|
|
233
|
-
function persist(
|
|
234
|
-
return
|
|
219
|
+
function persist() {
|
|
220
|
+
return fetchData(options, 'persist', ...arguments);
|
|
235
221
|
}
|
|
236
|
-
function pexpire(
|
|
237
|
-
return
|
|
222
|
+
function pexpire() {
|
|
223
|
+
return fetchData(options, 'pexpire', ...arguments);
|
|
238
224
|
}
|
|
239
|
-
function pexpireat(
|
|
240
|
-
return
|
|
225
|
+
function pexpireat() {
|
|
226
|
+
return fetchData(options, 'pexpireat', ...arguments);
|
|
241
227
|
}
|
|
242
|
-
function pttl(
|
|
243
|
-
return
|
|
228
|
+
function pttl() {
|
|
229
|
+
return fetchData(options, 'pttl', ...arguments);
|
|
244
230
|
}
|
|
245
|
-
function randomkey(
|
|
246
|
-
return
|
|
231
|
+
function randomkey() {
|
|
232
|
+
return fetchData(options, 'randomkey', ...arguments);
|
|
247
233
|
}
|
|
248
|
-
function rename(
|
|
249
|
-
return
|
|
234
|
+
function rename() {
|
|
235
|
+
return fetchData(options, 'rename', ...arguments);
|
|
250
236
|
}
|
|
251
|
-
function renamenx(
|
|
252
|
-
return
|
|
237
|
+
function renamenx() {
|
|
238
|
+
return fetchData(options, 'renamenx', ...arguments);
|
|
253
239
|
}
|
|
254
|
-
function scan(
|
|
255
|
-
|
|
256
|
-
return request(callback, 'scan', cursor, 'match', opitons.match, 'count', opitons.count);
|
|
257
|
-
}
|
|
258
|
-
else if (opitons === null || opitons === void 0 ? void 0 : opitons.match) {
|
|
259
|
-
return request(callback, 'scan', cursor, 'match', opitons.match);
|
|
260
|
-
}
|
|
261
|
-
else if (opitons === null || opitons === void 0 ? void 0 : opitons.count) {
|
|
262
|
-
return request(callback, 'scan', cursor, 'count', opitons.count);
|
|
263
|
-
}
|
|
264
|
-
return request(callback, 'scan', cursor);
|
|
240
|
+
function scan() {
|
|
241
|
+
return fetchData(options, 'scan', ...arguments);
|
|
265
242
|
}
|
|
266
|
-
function touch(
|
|
267
|
-
return
|
|
243
|
+
function touch() {
|
|
244
|
+
return fetchData(options, 'touch', ...arguments);
|
|
268
245
|
}
|
|
269
|
-
function ttl(
|
|
270
|
-
return
|
|
246
|
+
function ttl() {
|
|
247
|
+
return fetchData(options, 'ttl', ...arguments);
|
|
271
248
|
}
|
|
272
|
-
function type(
|
|
273
|
-
return
|
|
249
|
+
function type() {
|
|
250
|
+
return fetchData(options, 'type', ...arguments);
|
|
274
251
|
}
|
|
275
|
-
function unlink(
|
|
276
|
-
return
|
|
252
|
+
function unlink() {
|
|
253
|
+
return fetchData(options, 'unlink', ...arguments);
|
|
277
254
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
LISTS
|
|
281
|
-
------------------------------------------------
|
|
255
|
+
/**
|
|
256
|
+
* LISTS
|
|
282
257
|
*/
|
|
283
|
-
function lindex(
|
|
284
|
-
return
|
|
258
|
+
function lindex() {
|
|
259
|
+
return fetchData(options, 'lindex', ...arguments);
|
|
285
260
|
}
|
|
286
|
-
function linsert(
|
|
287
|
-
return
|
|
261
|
+
function linsert() {
|
|
262
|
+
return fetchData(options, 'linsert', ...arguments);
|
|
288
263
|
}
|
|
289
|
-
function llen(
|
|
290
|
-
return
|
|
264
|
+
function llen() {
|
|
265
|
+
return fetchData(options, 'llen', ...arguments);
|
|
291
266
|
}
|
|
292
|
-
function lpop(
|
|
293
|
-
return
|
|
267
|
+
function lpop() {
|
|
268
|
+
return fetchData(options, 'lpop', ...arguments);
|
|
294
269
|
}
|
|
295
|
-
function lpush(
|
|
296
|
-
return
|
|
270
|
+
function lpush() {
|
|
271
|
+
return fetchData(options, 'lpush', ...arguments);
|
|
297
272
|
}
|
|
298
|
-
function lpushx(
|
|
299
|
-
return
|
|
273
|
+
function lpushx() {
|
|
274
|
+
return fetchData(options, 'lpushx', ...arguments);
|
|
300
275
|
}
|
|
301
|
-
function lrange(
|
|
302
|
-
return
|
|
276
|
+
function lrange() {
|
|
277
|
+
return fetchData(options, 'lrange', ...arguments);
|
|
303
278
|
}
|
|
304
|
-
function lrem(
|
|
305
|
-
return
|
|
279
|
+
function lrem() {
|
|
280
|
+
return fetchData(options, 'lrem', ...arguments);
|
|
306
281
|
}
|
|
307
|
-
function lset(
|
|
308
|
-
return
|
|
282
|
+
function lset() {
|
|
283
|
+
return fetchData(options, 'lset', ...arguments);
|
|
309
284
|
}
|
|
310
|
-
function ltrim(
|
|
311
|
-
return
|
|
285
|
+
function ltrim() {
|
|
286
|
+
return fetchData(options, 'ltrim', ...arguments);
|
|
312
287
|
}
|
|
313
|
-
function rpop(
|
|
314
|
-
return
|
|
288
|
+
function rpop() {
|
|
289
|
+
return fetchData(options, 'rpop', ...arguments);
|
|
315
290
|
}
|
|
316
|
-
function rpoplpush(
|
|
317
|
-
return
|
|
291
|
+
function rpoplpush() {
|
|
292
|
+
return fetchData(options, 'rpoplpush', ...arguments);
|
|
318
293
|
}
|
|
319
|
-
function rpush(
|
|
320
|
-
return
|
|
294
|
+
function rpush() {
|
|
295
|
+
return fetchData(options, 'rpush', ...arguments);
|
|
321
296
|
}
|
|
322
|
-
function rpushx(
|
|
323
|
-
return
|
|
297
|
+
function rpushx() {
|
|
298
|
+
return fetchData(options, 'rpushx', ...arguments);
|
|
324
299
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
SERVER
|
|
328
|
-
------------------------------------------------
|
|
300
|
+
/**
|
|
301
|
+
* SERVER
|
|
329
302
|
*/
|
|
330
|
-
function dbsize(
|
|
331
|
-
return
|
|
303
|
+
function dbsize() {
|
|
304
|
+
return fetchData(options, 'dbsize', ...arguments);
|
|
332
305
|
}
|
|
333
|
-
function flushall(
|
|
334
|
-
|
|
335
|
-
return request(callback, 'flushall', mode);
|
|
336
|
-
}
|
|
337
|
-
return request(callback, 'flushall');
|
|
306
|
+
function flushall() {
|
|
307
|
+
return fetchData(options, 'flushall', ...arguments);
|
|
338
308
|
}
|
|
339
|
-
function flushdb(
|
|
340
|
-
|
|
341
|
-
return request(callback, 'flushdb', mode);
|
|
342
|
-
}
|
|
343
|
-
return request(callback, 'flushdb');
|
|
309
|
+
function flushdb() {
|
|
310
|
+
return fetchData(options, 'flushdb', ...arguments);
|
|
344
311
|
}
|
|
345
|
-
function info(
|
|
346
|
-
return
|
|
312
|
+
function info() {
|
|
313
|
+
return fetchData(options, 'info', ...arguments);
|
|
347
314
|
}
|
|
348
|
-
function time(
|
|
349
|
-
return
|
|
315
|
+
function time() {
|
|
316
|
+
return fetchData(options, 'time', ...arguments);
|
|
350
317
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
SET
|
|
354
|
-
------------------------------------------------
|
|
318
|
+
/**
|
|
319
|
+
* SET
|
|
355
320
|
*/
|
|
356
|
-
function sadd(
|
|
357
|
-
return
|
|
321
|
+
function sadd() {
|
|
322
|
+
return fetchData(options, 'sadd', ...arguments);
|
|
358
323
|
}
|
|
359
|
-
function scard(
|
|
360
|
-
return
|
|
324
|
+
function scard() {
|
|
325
|
+
return fetchData(options, 'scard', ...arguments);
|
|
361
326
|
}
|
|
362
|
-
function sdiff(
|
|
363
|
-
return
|
|
327
|
+
function sdiff() {
|
|
328
|
+
return fetchData(options, 'sdiff', ...arguments);
|
|
364
329
|
}
|
|
365
|
-
function sdiffstore(
|
|
366
|
-
return
|
|
330
|
+
function sdiffstore() {
|
|
331
|
+
return fetchData(options, 'sdiffstore', ...arguments);
|
|
367
332
|
}
|
|
368
|
-
function sinter(
|
|
369
|
-
return
|
|
333
|
+
function sinter() {
|
|
334
|
+
return fetchData(options, 'sinter', ...arguments);
|
|
370
335
|
}
|
|
371
|
-
function sinterstore(
|
|
372
|
-
return
|
|
336
|
+
function sinterstore() {
|
|
337
|
+
return fetchData(options, 'sinterstore', ...arguments);
|
|
373
338
|
}
|
|
374
|
-
function sismember(
|
|
375
|
-
return
|
|
339
|
+
function sismember() {
|
|
340
|
+
return fetchData(options, 'sismember', ...arguments);
|
|
376
341
|
}
|
|
377
|
-
function smembers(
|
|
378
|
-
return
|
|
342
|
+
function smembers() {
|
|
343
|
+
return fetchData(options, 'smembers', ...arguments);
|
|
379
344
|
}
|
|
380
|
-
function smove(
|
|
381
|
-
return
|
|
345
|
+
function smove() {
|
|
346
|
+
return fetchData(options, 'smove', ...arguments);
|
|
382
347
|
}
|
|
383
|
-
function spop(
|
|
384
|
-
|
|
385
|
-
return request(callback, 'spop', key, count);
|
|
386
|
-
}
|
|
387
|
-
return request(callback, 'spop', key);
|
|
348
|
+
function spop() {
|
|
349
|
+
return fetchData(options, 'spop', ...arguments);
|
|
388
350
|
}
|
|
389
|
-
function srandmember(
|
|
390
|
-
|
|
391
|
-
return request(callback, 'srandmember', key, count);
|
|
392
|
-
}
|
|
393
|
-
return request(callback, 'srandmember', key);
|
|
351
|
+
function srandmember() {
|
|
352
|
+
return fetchData(options, 'srandmember', ...arguments);
|
|
394
353
|
}
|
|
395
|
-
function srem(
|
|
396
|
-
return
|
|
354
|
+
function srem() {
|
|
355
|
+
return fetchData(options, 'srem', ...arguments);
|
|
397
356
|
}
|
|
398
|
-
function
|
|
399
|
-
return
|
|
357
|
+
function sscan() {
|
|
358
|
+
return fetchData(options, 'sscan', ...arguments);
|
|
400
359
|
}
|
|
401
|
-
function
|
|
402
|
-
return
|
|
360
|
+
function sunion() {
|
|
361
|
+
return fetchData(options, 'sunion', ...arguments);
|
|
403
362
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
363
|
+
function sunionstore() {
|
|
364
|
+
return fetchData(options, 'sunionstore', ...arguments);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* SORTED SETS
|
|
408
368
|
*/
|
|
409
|
-
function zadd(
|
|
410
|
-
|
|
411
|
-
const allOptions = Object.entries(options)
|
|
412
|
-
.filter((e) => ['string', 'number', 'boolean'].includes(typeof e[1]))
|
|
413
|
-
.map((e) => e[0].toUpperCase());
|
|
414
|
-
return request(callback, 'zadd', key, ...allOptions, ...values);
|
|
415
|
-
}
|
|
416
|
-
return request(callback, 'zadd', key, ...values);
|
|
369
|
+
function zadd() {
|
|
370
|
+
return fetchData(options, 'zadd', ...arguments);
|
|
417
371
|
}
|
|
418
|
-
function zcard(
|
|
419
|
-
return
|
|
372
|
+
function zcard() {
|
|
373
|
+
return fetchData(options, 'zcard', ...arguments);
|
|
420
374
|
}
|
|
421
|
-
function zcount(
|
|
422
|
-
return
|
|
375
|
+
function zcount() {
|
|
376
|
+
return fetchData(options, 'zcount', ...arguments);
|
|
423
377
|
}
|
|
424
|
-
function zincrby(
|
|
425
|
-
return
|
|
378
|
+
function zincrby() {
|
|
379
|
+
return fetchData(options, 'zincrby', ...arguments);
|
|
426
380
|
}
|
|
427
|
-
function zinterstore(
|
|
428
|
-
|
|
429
|
-
if (options.weights && options.aggregate) {
|
|
430
|
-
return request(callback, 'zinterstore', destination, keys.length, ...keys, 'weights', ...options.weights, 'aggregate', options.aggregate);
|
|
431
|
-
}
|
|
432
|
-
else if (options.weights) {
|
|
433
|
-
return request(callback, 'zinterstore', destination, keys.length, ...keys, 'weights', ...options.weights);
|
|
434
|
-
}
|
|
435
|
-
else if (options.aggregate) {
|
|
436
|
-
return request(callback, 'zinterstore', destination, keys.length, ...keys, 'aggregate', options.aggregate);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
return request(callback, 'zinterstore', destination, keys.length, ...keys);
|
|
381
|
+
function zinterstore() {
|
|
382
|
+
return fetchData(options, 'zinterstore', ...arguments);
|
|
440
383
|
}
|
|
441
|
-
function zlexcount(
|
|
442
|
-
return
|
|
384
|
+
function zlexcount() {
|
|
385
|
+
return fetchData(options, 'zlexcount', ...arguments);
|
|
443
386
|
}
|
|
444
|
-
function zpopmax(
|
|
445
|
-
|
|
446
|
-
return request(callback, 'zpopmax', key, count);
|
|
447
|
-
}
|
|
448
|
-
return request(callback, 'zpopmax', key);
|
|
387
|
+
function zpopmax() {
|
|
388
|
+
return fetchData(options, 'zpopmax', ...arguments);
|
|
449
389
|
}
|
|
450
|
-
function zpopmin(
|
|
451
|
-
|
|
452
|
-
return request(callback, 'zpopmin', key, count);
|
|
453
|
-
}
|
|
454
|
-
return request(callback, 'zpopmin', key);
|
|
390
|
+
function zpopmin() {
|
|
391
|
+
return fetchData(options, 'zpopmin', ...arguments);
|
|
455
392
|
}
|
|
456
|
-
function zrange(
|
|
457
|
-
|
|
458
|
-
return request(callback, 'zrange', key, min, max, 'WITHSCORES');
|
|
459
|
-
}
|
|
460
|
-
return request(callback, 'zrange', key, min, max);
|
|
393
|
+
function zrange() {
|
|
394
|
+
return fetchData(options, 'zrange', ...arguments);
|
|
461
395
|
}
|
|
462
|
-
function zrangebylex(
|
|
463
|
-
|
|
464
|
-
return request(callback, 'zrangebylex', key, min, max, 'LIMIT', offset, count);
|
|
465
|
-
}
|
|
466
|
-
return request(callback, 'zrangebylex', key, min, max);
|
|
396
|
+
function zrangebylex() {
|
|
397
|
+
return fetchData(options, 'zrangebylex', ...arguments);
|
|
467
398
|
}
|
|
468
|
-
function zrangebyscore(
|
|
469
|
-
|
|
470
|
-
return request(callback, 'zrangebyscore', key, min, max, 'WITHSCORES', 'LIMIT', options.limit.offset, options.limit.count);
|
|
471
|
-
}
|
|
472
|
-
else if (options === null || options === void 0 ? void 0 : options.withScores) {
|
|
473
|
-
return request(callback, 'zrangebyscore', key, min, max, 'WITHSCORES');
|
|
474
|
-
}
|
|
475
|
-
else if (options === null || options === void 0 ? void 0 : options.limit) {
|
|
476
|
-
return request(callback, 'zrangebyscore', key, min, max, 'LIMIT', options.limit.offset, options.limit.count);
|
|
477
|
-
}
|
|
478
|
-
return request(callback, 'zrangebyscore', key, min, max);
|
|
399
|
+
function zrangebyscore() {
|
|
400
|
+
return fetchData(options, 'zrangebyscore', ...arguments);
|
|
479
401
|
}
|
|
480
|
-
function zrank(
|
|
481
|
-
return
|
|
402
|
+
function zrank() {
|
|
403
|
+
return fetchData(options, 'zrank', ...arguments);
|
|
482
404
|
}
|
|
483
|
-
function zrem(
|
|
484
|
-
return
|
|
405
|
+
function zrem() {
|
|
406
|
+
return fetchData(options, 'zrem', ...arguments);
|
|
485
407
|
}
|
|
486
|
-
function zremrangebylex(
|
|
487
|
-
return
|
|
408
|
+
function zremrangebylex() {
|
|
409
|
+
return fetchData(options, 'zremrangebylex', ...arguments);
|
|
488
410
|
}
|
|
489
|
-
function zremrangebyrank(
|
|
490
|
-
return
|
|
411
|
+
function zremrangebyrank() {
|
|
412
|
+
return fetchData(options, 'zremrangebyrank', ...arguments);
|
|
491
413
|
}
|
|
492
|
-
function zremrangebyscore(
|
|
493
|
-
return
|
|
414
|
+
function zremrangebyscore() {
|
|
415
|
+
return fetchData(options, 'zremrangebyscore', ...arguments);
|
|
494
416
|
}
|
|
495
|
-
function zrevrange(
|
|
496
|
-
|
|
497
|
-
return request(callback, 'zrevrange', key, start, stop, 'WITHSCORES');
|
|
498
|
-
}
|
|
499
|
-
return request(callback, 'zrevrange', key, start, stop);
|
|
417
|
+
function zrevrange() {
|
|
418
|
+
return fetchData(options, 'zrevrange', ...arguments);
|
|
500
419
|
}
|
|
501
|
-
function zrevrangebylex(
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
return
|
|
506
|
-
}
|
|
507
|
-
function
|
|
508
|
-
return
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
// if (options?.withScores) {
|
|
519
|
-
// return request(callback, 'zrevrank', key, start, stop, 'WITHSCORES');
|
|
520
|
-
// }
|
|
521
|
-
// return request(callback, 'zrevrank', key, start, stop);
|
|
522
|
-
// }
|
|
523
|
-
function zscore(key, member, callback) {
|
|
524
|
-
return request(callback, 'zscore', key, member);
|
|
525
|
-
}
|
|
526
|
-
function zunionstore(destination, keys, options, callback) {
|
|
527
|
-
if (options) {
|
|
528
|
-
if (options.weights && options.aggregate) {
|
|
529
|
-
return request(callback, 'zunionstore', destination, keys.length, ...keys, 'weights', ...options.weights, 'aggregate', options.aggregate);
|
|
530
|
-
}
|
|
531
|
-
else if (options.weights) {
|
|
532
|
-
return request(callback, 'zunionstore', destination, keys.length, ...keys, 'weights', ...options.weights);
|
|
533
|
-
}
|
|
534
|
-
else if (options.aggregate) {
|
|
535
|
-
return request(callback, 'zunionstore', destination, keys.length, ...keys, 'aggregate', options.aggregate);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
return request(callback, 'zunionstore', destination, keys.length, ...keys);
|
|
420
|
+
function zrevrangebylex() {
|
|
421
|
+
return fetchData(options, 'zrevrangebylex', ...arguments);
|
|
422
|
+
}
|
|
423
|
+
function zrevrangebyscore() {
|
|
424
|
+
return fetchData(options, 'zrevrangebyscore', ...arguments);
|
|
425
|
+
}
|
|
426
|
+
function zrevrank() {
|
|
427
|
+
return fetchData(options, 'zrevrank', ...arguments);
|
|
428
|
+
}
|
|
429
|
+
function zscan() {
|
|
430
|
+
return fetchData(options, 'zscan', ...arguments);
|
|
431
|
+
}
|
|
432
|
+
function zscore() {
|
|
433
|
+
return fetchData(options, 'zscore', ...arguments);
|
|
434
|
+
}
|
|
435
|
+
function zunionstore() {
|
|
436
|
+
return fetchData(options, 'zunionstore', ...arguments);
|
|
539
437
|
}
|
|
540
438
|
return {
|
|
541
439
|
auth,
|
|
@@ -567,7 +465,7 @@ function client(url, token) {
|
|
|
567
465
|
// CONNECTION
|
|
568
466
|
echo,
|
|
569
467
|
ping,
|
|
570
|
-
//HASHES
|
|
468
|
+
// HASHES
|
|
571
469
|
hdel,
|
|
572
470
|
hexists,
|
|
573
471
|
hget,
|
|
@@ -578,10 +476,10 @@ function client(url, token) {
|
|
|
578
476
|
hlen,
|
|
579
477
|
hmget,
|
|
580
478
|
hmset,
|
|
479
|
+
hscan,
|
|
581
480
|
hset,
|
|
582
481
|
hsetnx,
|
|
583
482
|
hvals,
|
|
584
|
-
hscan,
|
|
585
483
|
// KEYS
|
|
586
484
|
del,
|
|
587
485
|
exists,
|
|
@@ -600,7 +498,7 @@ function client(url, token) {
|
|
|
600
498
|
ttl,
|
|
601
499
|
type,
|
|
602
500
|
unlink,
|
|
603
|
-
//
|
|
501
|
+
// LISTS
|
|
604
502
|
lindex,
|
|
605
503
|
linsert,
|
|
606
504
|
llen,
|
|
@@ -621,7 +519,7 @@ function client(url, token) {
|
|
|
621
519
|
flushdb,
|
|
622
520
|
info,
|
|
623
521
|
time,
|
|
624
|
-
//SET
|
|
522
|
+
// SET
|
|
625
523
|
sadd,
|
|
626
524
|
scard,
|
|
627
525
|
sdiff,
|
|
@@ -634,9 +532,10 @@ function client(url, token) {
|
|
|
634
532
|
spop,
|
|
635
533
|
srandmember,
|
|
636
534
|
srem,
|
|
535
|
+
sscan,
|
|
637
536
|
sunion,
|
|
638
537
|
sunionstore,
|
|
639
|
-
//
|
|
538
|
+
// SORTED SETS
|
|
640
539
|
zadd,
|
|
641
540
|
zcard,
|
|
642
541
|
zcount,
|
|
@@ -656,10 +555,10 @@ function client(url, token) {
|
|
|
656
555
|
zrevrange,
|
|
657
556
|
zrevrangebylex,
|
|
658
557
|
zrevrangebyscore,
|
|
659
|
-
|
|
558
|
+
zrevrank,
|
|
559
|
+
zscan,
|
|
660
560
|
zscore,
|
|
661
561
|
zunionstore,
|
|
662
562
|
};
|
|
663
563
|
}
|
|
664
|
-
exports.default =
|
|
665
|
-
//# sourceMappingURL=client.js.map
|
|
564
|
+
exports.default = upstash;
|