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