@upstash/redis 0.1.22 → 0.2.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 +13 -53
- package/dist/main/client.d.ts +21 -0
- package/dist/main/client.js +556 -0
- package/dist/main/index-cjs.d.ts +1 -0
- package/dist/main/index-cjs.js +120 -0
- package/dist/main/types.d.ts +177 -0
- package/dist/main/{src/type.js → types.js} +0 -1
- package/dist/module/client.d.ts +21 -0
- package/dist/module/client.js +551 -0
- package/dist/module/index.d.ts +3 -0
- package/dist/module/index.js +3 -0
- package/dist/module/types.d.ts +177 -0
- package/dist/module/types.js +1 -0
- package/package.json +16 -25
- package/src/client.ts +307 -921
- package/src/index-cjs.ts +117 -0
- package/src/index.ts +4 -119
- package/src/types.ts +408 -0
- package/tsconfig.json +9 -7
- package/tsconfig.module.json +3 -2
- package/dist/main/src/client.d.ts +0 -25
- package/dist/main/src/client.d.ts.map +0 -1
- package/dist/main/src/client.js +0 -748
- package/dist/main/src/client.js.map +0 -1
- package/dist/main/src/index.d.ts +0 -73
- package/dist/main/src/index.d.ts.map +0 -1
- package/dist/main/src/index.js +0 -124
- package/dist/main/src/index.js.map +0 -1
- package/dist/main/src/type.d.ts +0 -466
- package/dist/main/src/type.d.ts.map +0 -1
- package/dist/main/src/type.js.map +0 -1
- package/dist/main/utils/helper.d.ts +0 -5
- package/dist/main/utils/helper.d.ts.map +0 -1
- package/dist/main/utils/helper.js +0 -20
- package/dist/main/utils/helper.js.map +0 -1
- package/dist/module/src/client.d.ts +0 -25
- package/dist/module/src/client.d.ts.map +0 -1
- package/dist/module/src/client.js +0 -743
- package/dist/module/src/client.js.map +0 -1
- package/dist/module/src/index.d.ts +0 -73
- package/dist/module/src/index.d.ts.map +0 -1
- package/dist/module/src/index.js +0 -5
- package/dist/module/src/index.js.map +0 -1
- package/dist/module/src/type.d.ts +0 -466
- package/dist/module/src/type.d.ts.map +0 -1
- package/dist/module/src/type.js +0 -2
- package/dist/module/src/type.js.map +0 -1
- package/dist/module/utils/helper.d.ts +0 -5
- package/dist/module/utils/helper.d.ts.map +0 -1
- package/dist/module/utils/helper.js +0 -13
- package/dist/module/utils/helper.js.map +0 -1
- package/dist/umd/upstash-redis.js +0 -1
- package/src/type.ts +0 -1194
- package/utils/helper.ts +0 -17
- package/webpack.config.js +0 -34
package/src/client.ts
CHANGED
|
@@ -1,647 +1,355 @@
|
|
|
1
1
|
import fetch from 'isomorphic-unfetch';
|
|
2
|
-
import { isFunction, isObject, isString } from '../utils/helper';
|
|
3
2
|
import {
|
|
4
3
|
ClientObjectProps,
|
|
5
|
-
ReturnType,
|
|
6
|
-
RequestConfig,
|
|
7
|
-
Callback,
|
|
8
4
|
MethodReturn,
|
|
9
5
|
Part,
|
|
6
|
+
ReturnType,
|
|
10
7
|
Upstash,
|
|
11
|
-
|
|
12
|
-
ZSetNumber,
|
|
13
|
-
EdgeCacheType,
|
|
14
|
-
} from './type';
|
|
8
|
+
} from './types';
|
|
15
9
|
|
|
16
10
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @constructor
|
|
20
|
-
* @param {string} url - database rest url
|
|
21
|
-
* @param {string} token - database rest token
|
|
22
|
-
* @param {Object} options - database config
|
|
23
|
-
* @param {string} [options.url] - database rest url
|
|
24
|
-
* @param {string} [options.token] - database rest token
|
|
25
|
-
* @param {string} [options.edgeUrl] - database rest edge url
|
|
26
|
-
* @param {string} [options.readFromEdge] - database rest read from edge
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```js
|
|
30
|
-
* import Upstash from '@upstash/redis'
|
|
31
|
-
*
|
|
32
|
-
* const redis1 = new Upstash('url', token);
|
|
33
|
-
* const redis2 = new Upstash({ url: '', token: '', edgeUrl: '', readFromEdge: false });
|
|
34
|
-
* ```
|
|
11
|
+
* Parse Options
|
|
35
12
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
token
|
|
43
|
-
edgeUrl?: string;
|
|
44
|
-
readFromEdge?: boolean;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
parseOptions(arguments[0], arguments[1]);
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Parse Options
|
|
52
|
-
*/
|
|
53
|
-
function parseOptions() {
|
|
54
|
-
const arg0 = arguments[0];
|
|
55
|
-
const arg1 = arguments[1];
|
|
56
|
-
|
|
57
|
-
OPTIONS = { url: '', token: '', edgeUrl: '', readFromEdge: false };
|
|
58
|
-
|
|
59
|
-
// Upstash({})
|
|
60
|
-
if (isObject(arg0)) {
|
|
61
|
-
const { url, token, edgeUrl, readFromEdge } = arg0;
|
|
62
|
-
OPTIONS.url = url;
|
|
63
|
-
OPTIONS.token = token;
|
|
64
|
-
OPTIONS.edgeUrl = edgeUrl;
|
|
65
|
-
OPTIONS.readFromEdge = readFromEdge ?? !!edgeUrl;
|
|
66
|
-
}
|
|
67
|
-
// Upstash(url, token)
|
|
68
|
-
else if (isString(arg0) && isString(arg1)) {
|
|
69
|
-
OPTIONS.url = arg0;
|
|
70
|
-
OPTIONS.token = arg1;
|
|
71
|
-
}
|
|
72
|
-
// try auto fill from env variable
|
|
73
|
-
else if (process) {
|
|
74
|
-
const {
|
|
75
|
-
UPSTASH_REDIS_REST_URL,
|
|
76
|
-
UPSTASH_REDIS_REST_TOKEN,
|
|
77
|
-
UPSTASH_REDIS_EDGE_URL,
|
|
78
|
-
} = process.env;
|
|
79
|
-
OPTIONS.url = UPSTASH_REDIS_REST_URL ?? '';
|
|
80
|
-
OPTIONS.token = UPSTASH_REDIS_REST_TOKEN ?? '';
|
|
81
|
-
OPTIONS.edgeUrl = UPSTASH_REDIS_EDGE_URL ?? '';
|
|
82
|
-
OPTIONS.readFromEdge = !!UPSTASH_REDIS_EDGE_URL;
|
|
83
|
-
}
|
|
13
|
+
function parseOptions(
|
|
14
|
+
url?: string | ClientObjectProps,
|
|
15
|
+
token?: string,
|
|
16
|
+
requestOptions: undefined | RequestInit = {}
|
|
17
|
+
): ClientObjectProps {
|
|
18
|
+
if (typeof url === 'object' && url !== null) {
|
|
19
|
+
return parseOptions(url.url, url.token, url.requestOptions);
|
|
84
20
|
}
|
|
85
21
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let cache: EdgeCacheType = null;
|
|
91
|
-
let edge: boolean = false;
|
|
92
|
-
return new Promise((resolve) => {
|
|
93
|
-
fetch(url, {
|
|
94
|
-
...options,
|
|
95
|
-
headers: {
|
|
96
|
-
Authorization: `Bearer ${OPTIONS.token}`,
|
|
97
|
-
},
|
|
98
|
-
})
|
|
99
|
-
.then((res) => {
|
|
100
|
-
switch (res.headers.get('x-cache')) {
|
|
101
|
-
case 'Hit from cloudfront':
|
|
102
|
-
edge = true;
|
|
103
|
-
cache = 'hit';
|
|
104
|
-
break;
|
|
105
|
-
case 'Miss from cloudfront':
|
|
106
|
-
edge = true;
|
|
107
|
-
cache = 'miss';
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
return res.json().then();
|
|
111
|
-
})
|
|
112
|
-
.then((data) => {
|
|
113
|
-
if (data.error) throw data.error;
|
|
114
|
-
resolve({
|
|
115
|
-
data: data.result,
|
|
116
|
-
error: null,
|
|
117
|
-
metadata: { edge, cache },
|
|
118
|
-
});
|
|
119
|
-
})
|
|
120
|
-
.catch((error) => {
|
|
121
|
-
resolve({
|
|
122
|
-
data: null,
|
|
123
|
-
error: typeof error === 'object' ? error.message : error,
|
|
124
|
-
metadata: { edge, cache },
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
22
|
+
// try auto fill from env variables
|
|
23
|
+
if (!url && typeof window === 'undefined') {
|
|
24
|
+
url = process.env.UPSTASH_REDIS_REST_URL;
|
|
25
|
+
token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
128
26
|
}
|
|
129
27
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*/
|
|
133
|
-
function request(
|
|
134
|
-
configOrCallback?: RequestConfig | Callback,
|
|
135
|
-
callback?: Callback,
|
|
136
|
-
...parts: Part[]
|
|
137
|
-
): MethodReturn {
|
|
138
|
-
if (!OPTIONS.url) {
|
|
139
|
-
return new Promise((resolve) =>
|
|
140
|
-
resolve({ data: null, error: 'Database url not found?' })
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!OPTIONS.edgeUrl && OPTIONS.readFromEdge) {
|
|
145
|
-
return new Promise((resolve) =>
|
|
146
|
-
resolve({
|
|
147
|
-
data: null,
|
|
148
|
-
error: 'You need to set Edge Url to read from edge.',
|
|
149
|
-
})
|
|
150
|
-
);
|
|
151
|
-
}
|
|
28
|
+
return { url: url as string, token, requestOptions };
|
|
29
|
+
}
|
|
152
30
|
|
|
153
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Fetch
|
|
33
|
+
*/
|
|
34
|
+
async function fetchData(
|
|
35
|
+
options: ClientObjectProps,
|
|
36
|
+
...parts: Part[]
|
|
37
|
+
): Promise<ReturnType> {
|
|
38
|
+
if (!options.url) {
|
|
39
|
+
throw 'Database url not found?';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const res = await fetch(options.url!, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
body: JSON.stringify(parts),
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: `Bearer ${options.token}`,
|
|
48
|
+
...options.requestOptions?.headers,
|
|
49
|
+
},
|
|
50
|
+
...options.requestOptions,
|
|
51
|
+
});
|
|
154
52
|
|
|
155
|
-
|
|
156
|
-
let isRequestCustomEdge = isRequestDefaultEdge;
|
|
53
|
+
const data = await res.json();
|
|
157
54
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// @ts-ignore
|
|
166
|
-
if (!OPTIONS.edgeUrl && configOrCallback?.edge) {
|
|
167
|
-
return new Promise((resolve) =>
|
|
168
|
-
resolve({
|
|
169
|
-
data: null,
|
|
170
|
-
error: 'You need to set Edge Url to read from edge.',
|
|
171
|
-
})
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
if (OPTIONS.edgeUrl) {
|
|
175
|
-
// @ts-ignore
|
|
176
|
-
isRequestCustomEdge = configOrCallback?.edge;
|
|
177
|
-
}
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
if (data.error) throw data.error;
|
|
57
|
+
throw `Upstash failed with (${res.status}): ${JSON.stringify(
|
|
58
|
+
data,
|
|
59
|
+
null,
|
|
60
|
+
2
|
|
61
|
+
)}`;
|
|
178
62
|
}
|
|
179
63
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
promise = fetchData(OPTIONS.url, {
|
|
188
|
-
method: 'POST',
|
|
189
|
-
body: JSON.stringify(parts),
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (isFunction(configOrCallback)) {
|
|
64
|
+
return {
|
|
65
|
+
data: data.result,
|
|
66
|
+
error: null,
|
|
67
|
+
};
|
|
68
|
+
} catch (err) {
|
|
69
|
+
return {
|
|
70
|
+
data: null,
|
|
194
71
|
// @ts-ignore
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
return promise.then(callback);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return promise;
|
|
72
|
+
error: err,
|
|
73
|
+
};
|
|
201
74
|
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a Upstash Redis instance
|
|
79
|
+
*
|
|
80
|
+
* @constructor
|
|
81
|
+
* @param {Object} options
|
|
82
|
+
* @param {string} [options.url]
|
|
83
|
+
* @param {string} [options.token]
|
|
84
|
+
* @param {Object} [options.requestOptions]
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```js
|
|
88
|
+
* import upstash from '@upstash/redis'
|
|
89
|
+
*
|
|
90
|
+
* const redis1 = upstash('url', token);
|
|
91
|
+
* const redis2 = upstash({ url: '', token: '', requestOptions: {} });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
function upstash(options?: ClientObjectProps): Upstash;
|
|
96
|
+
function upstash(url?: string, token?: string): Upstash;
|
|
97
|
+
function upstash(url?: string | ClientObjectProps, token?: string): Upstash {
|
|
98
|
+
const options: ClientObjectProps = parseOptions(url, token);
|
|
202
99
|
|
|
203
100
|
/**
|
|
204
101
|
* Auth
|
|
205
102
|
*/
|
|
206
|
-
|
|
207
|
-
function auth(options?: ClientObjectProps): void;
|
|
103
|
+
|
|
208
104
|
function auth(): void {
|
|
209
|
-
|
|
210
|
-
|
|
105
|
+
Object.assign(
|
|
106
|
+
options,
|
|
107
|
+
{
|
|
108
|
+
url: undefined,
|
|
109
|
+
token: undefined,
|
|
110
|
+
},
|
|
111
|
+
parseOptions(arguments[0], arguments[1])
|
|
112
|
+
);
|
|
211
113
|
}
|
|
212
114
|
|
|
213
115
|
/**
|
|
214
116
|
* STRING
|
|
215
117
|
*/
|
|
216
118
|
|
|
217
|
-
function append(
|
|
218
|
-
return
|
|
119
|
+
function append() {
|
|
120
|
+
return fetchData(options, 'append', ...arguments);
|
|
219
121
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return request(false, arguments[1], 'decr', key);
|
|
122
|
+
function decr() {
|
|
123
|
+
return fetchData(options, 'decr', ...arguments);
|
|
223
124
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return request(false, arguments[2], 'decrby', key, decrement);
|
|
125
|
+
function decrby() {
|
|
126
|
+
return fetchData(options, 'decrby', ...arguments);
|
|
227
127
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return request(arguments[1], arguments[2], 'get', key);
|
|
128
|
+
function get() {
|
|
129
|
+
return fetchData(options, 'get', ...arguments);
|
|
231
130
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return request(arguments[3], arguments[4], 'getrange', key, start, end);
|
|
131
|
+
function getrange() {
|
|
132
|
+
return fetchData(options, 'getrange', ...arguments);
|
|
235
133
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return request(false, arguments[2], 'getset', key, value);
|
|
134
|
+
function getset() {
|
|
135
|
+
return fetchData(options, 'getset', ...arguments);
|
|
239
136
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return request(false, arguments[1], 'incr', key);
|
|
137
|
+
function incr() {
|
|
138
|
+
return fetchData(options, 'incr', ...arguments);
|
|
243
139
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return request(false, arguments[2], 'incrby', key, value);
|
|
140
|
+
function incrby() {
|
|
141
|
+
return fetchData(options, 'incrby', ...arguments);
|
|
247
142
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return request(false, arguments[2], 'incrbyfloat', key, value);
|
|
143
|
+
function incrbyfloat() {
|
|
144
|
+
return fetchData(options, 'incrbyfloat', ...arguments);
|
|
251
145
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return request(arguments[1], arguments[2], 'mget', ...values);
|
|
146
|
+
function mget() {
|
|
147
|
+
return fetchData(options, 'mget', ...arguments);
|
|
255
148
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return request(false, arguments[1], 'mset', ...values);
|
|
149
|
+
function mset() {
|
|
150
|
+
return fetchData(options, 'mset', ...arguments);
|
|
259
151
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return request(false, arguments[1], 'msetnx', ...values);
|
|
152
|
+
function msetnx() {
|
|
153
|
+
return fetchData(options, 'msetnx', ...arguments);
|
|
263
154
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
key: string,
|
|
267
|
-
miliseconds: number,
|
|
268
|
-
value: string | number
|
|
269
|
-
): MethodReturn {
|
|
270
|
-
return request(false, arguments[3], 'psetex', key, miliseconds, value);
|
|
155
|
+
function psetex() {
|
|
156
|
+
return fetchData(options, 'psetex', ...arguments);
|
|
271
157
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return request(false, arguments[2], 'set', key, value);
|
|
158
|
+
function set() {
|
|
159
|
+
return fetchData(options, 'set', ...arguments);
|
|
275
160
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
key: string,
|
|
279
|
-
seconds: number,
|
|
280
|
-
value: string | number
|
|
281
|
-
): MethodReturn {
|
|
282
|
-
return request(false, arguments[3], 'setex', key, seconds, value);
|
|
161
|
+
function setex() {
|
|
162
|
+
return fetchData(options, 'setex', ...arguments);
|
|
283
163
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return request(false, arguments[2], 'setnx', key, value);
|
|
164
|
+
function setnx() {
|
|
165
|
+
return fetchData(options, 'setnx', ...arguments);
|
|
287
166
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
key: string,
|
|
291
|
-
offset: number | string,
|
|
292
|
-
value: string
|
|
293
|
-
): MethodReturn {
|
|
294
|
-
return request(false, arguments[3], 'setrange', key, offset, value);
|
|
167
|
+
function setrange() {
|
|
168
|
+
return fetchData(options, 'setrange', ...arguments);
|
|
295
169
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return request(arguments[1], arguments[2], 'strlen', key);
|
|
170
|
+
function strlen() {
|
|
171
|
+
return fetchData(options, 'strlen', ...arguments);
|
|
299
172
|
}
|
|
300
173
|
|
|
301
174
|
/**
|
|
302
175
|
* BITMAPS
|
|
303
176
|
*/
|
|
304
177
|
|
|
305
|
-
function bitcount(
|
|
306
|
-
|
|
307
|
-
return request(arguments[3], arguments[4], 'bitcount', key, start, end);
|
|
308
|
-
}
|
|
309
|
-
return request(arguments[3], arguments[4], 'bitcount', key);
|
|
178
|
+
function bitcount() {
|
|
179
|
+
return fetchData(options, 'bitcount', ...arguments);
|
|
310
180
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
operation: 'AND' | 'OR' | 'XOR' | 'NOT',
|
|
314
|
-
destinationKey: string,
|
|
315
|
-
sourceKeys: string[]
|
|
316
|
-
): MethodReturn {
|
|
317
|
-
return request(
|
|
318
|
-
false,
|
|
319
|
-
arguments[3],
|
|
320
|
-
'bitop',
|
|
321
|
-
operation,
|
|
322
|
-
destinationKey,
|
|
323
|
-
...sourceKeys
|
|
324
|
-
);
|
|
181
|
+
function bitop() {
|
|
182
|
+
return fetchData(options, 'bitop', ...arguments);
|
|
325
183
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
key: string,
|
|
329
|
-
bit: Bit,
|
|
330
|
-
start?: number,
|
|
331
|
-
end?: number
|
|
332
|
-
): MethodReturn {
|
|
333
|
-
if (start !== undefined && end !== undefined) {
|
|
334
|
-
return request(
|
|
335
|
-
arguments[4],
|
|
336
|
-
arguments[5],
|
|
337
|
-
'bitpos',
|
|
338
|
-
key,
|
|
339
|
-
bit,
|
|
340
|
-
start,
|
|
341
|
-
end
|
|
342
|
-
);
|
|
343
|
-
} else if (start !== undefined) {
|
|
344
|
-
return request(arguments[4], arguments[5], 'bitpos', key, bit, start);
|
|
345
|
-
}
|
|
346
|
-
return request(arguments[4], arguments[5], 'bitpos', key, bit);
|
|
184
|
+
function bitpos() {
|
|
185
|
+
return fetchData(options, 'bitpos', ...arguments);
|
|
347
186
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
return request(arguments[2], arguments[3], 'getbit', key, offset);
|
|
187
|
+
function getbit() {
|
|
188
|
+
return fetchData(options, 'getbit', ...arguments);
|
|
351
189
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
return request(false, arguments[3], 'setbit', key, offset, value);
|
|
190
|
+
function setbit() {
|
|
191
|
+
return fetchData(options, 'setbit', ...arguments);
|
|
355
192
|
}
|
|
356
193
|
|
|
357
194
|
/**
|
|
358
195
|
* CONNECTION
|
|
359
196
|
*/
|
|
360
197
|
|
|
361
|
-
function echo(
|
|
362
|
-
return
|
|
198
|
+
function echo() {
|
|
199
|
+
return fetchData(options, 'echo', ...arguments);
|
|
363
200
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if (value) {
|
|
367
|
-
return request(arguments[1], arguments[2], 'ping', value);
|
|
368
|
-
}
|
|
369
|
-
return request(arguments[1], arguments[2], 'ping');
|
|
201
|
+
function ping() {
|
|
202
|
+
return fetchData(options, 'ping', ...arguments);
|
|
370
203
|
}
|
|
371
204
|
|
|
372
205
|
/**
|
|
373
206
|
* HASHES
|
|
374
207
|
*/
|
|
375
208
|
|
|
376
|
-
function hdel(
|
|
377
|
-
return
|
|
209
|
+
function hdel(): MethodReturn {
|
|
210
|
+
return fetchData(options, 'hdel', ...arguments);
|
|
378
211
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
return request(arguments[2], arguments[3], 'hexists', key, field);
|
|
212
|
+
function hexists(): MethodReturn {
|
|
213
|
+
return fetchData(options, 'hexists', ...arguments);
|
|
382
214
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return request(arguments[2], arguments[3], 'hget', key, field);
|
|
215
|
+
function hget(): MethodReturn {
|
|
216
|
+
return fetchData(options, 'hget', ...arguments);
|
|
386
217
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return request(arguments[1], arguments[2], 'hgetall', key);
|
|
218
|
+
function hgetall(): MethodReturn {
|
|
219
|
+
return fetchData(options, 'hgetall', ...arguments);
|
|
390
220
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
key: string,
|
|
394
|
-
field: string,
|
|
395
|
-
increment: number | string
|
|
396
|
-
): MethodReturn {
|
|
397
|
-
return request(false, arguments[3], 'hincrby', key, field, increment);
|
|
221
|
+
function hincrby(): MethodReturn {
|
|
222
|
+
return fetchData(options, 'hincrby', ...arguments);
|
|
398
223
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
key: string,
|
|
402
|
-
field: string,
|
|
403
|
-
increment: number | string
|
|
404
|
-
): MethodReturn {
|
|
405
|
-
return request(false, arguments[3], 'hincrbyfloat', key, field, increment);
|
|
224
|
+
function hincrbyfloat(): MethodReturn {
|
|
225
|
+
return fetchData(options, 'hincrbyfloat', ...arguments);
|
|
406
226
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return request(arguments[1], arguments[2], 'hkeys', key);
|
|
227
|
+
function hkeys(): MethodReturn {
|
|
228
|
+
return fetchData(options, 'hkeys', ...arguments);
|
|
410
229
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return request(arguments[1], arguments[2], 'hlen', key);
|
|
230
|
+
function hlen(): MethodReturn {
|
|
231
|
+
return fetchData(options, 'hlen', ...arguments);
|
|
414
232
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return request(arguments[2], arguments[3], 'hmget', key, ...fields);
|
|
233
|
+
function hmget(): MethodReturn {
|
|
234
|
+
return fetchData(options, 'hmget', ...arguments);
|
|
418
235
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return request(false, arguments[2], 'hmset', key, ...values);
|
|
236
|
+
function hmset(): MethodReturn {
|
|
237
|
+
return fetchData(options, 'hmset', ...arguments);
|
|
422
238
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
key: string,
|
|
426
|
-
cursor: number,
|
|
427
|
-
options?: { match?: number | string; count?: number | string }
|
|
428
|
-
): MethodReturn {
|
|
429
|
-
if (options?.match && options?.count) {
|
|
430
|
-
return request(
|
|
431
|
-
false,
|
|
432
|
-
arguments[3],
|
|
433
|
-
'hscan',
|
|
434
|
-
key,
|
|
435
|
-
cursor,
|
|
436
|
-
'match',
|
|
437
|
-
options.match,
|
|
438
|
-
'count',
|
|
439
|
-
options.count
|
|
440
|
-
);
|
|
441
|
-
} else if (options?.match) {
|
|
442
|
-
return request(
|
|
443
|
-
false,
|
|
444
|
-
arguments[3],
|
|
445
|
-
'hscan',
|
|
446
|
-
key,
|
|
447
|
-
cursor,
|
|
448
|
-
'match',
|
|
449
|
-
options.match
|
|
450
|
-
);
|
|
451
|
-
} else if (options?.count) {
|
|
452
|
-
return request(
|
|
453
|
-
false,
|
|
454
|
-
arguments[3],
|
|
455
|
-
'hscan',
|
|
456
|
-
key,
|
|
457
|
-
cursor,
|
|
458
|
-
'count',
|
|
459
|
-
options.count
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
return request(false, arguments[3], 'hscan', key, cursor);
|
|
239
|
+
function hscan(): MethodReturn {
|
|
240
|
+
return fetchData(options, 'hscan', ...arguments);
|
|
463
241
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
return request(false, arguments[2], 'hset', key, ...values);
|
|
242
|
+
function hset(): MethodReturn {
|
|
243
|
+
return fetchData(options, 'hset', ...arguments);
|
|
467
244
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
return request(false, arguments[3], 'hsetnx', key, field, value);
|
|
245
|
+
function hsetnx(): MethodReturn {
|
|
246
|
+
return fetchData(options, 'hsetnx', ...arguments);
|
|
471
247
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
return request(arguments[1], arguments[2], 'hvals', key);
|
|
248
|
+
function hvals(): MethodReturn {
|
|
249
|
+
return fetchData(options, 'hvals', ...arguments);
|
|
475
250
|
}
|
|
476
251
|
|
|
477
252
|
/**
|
|
478
253
|
* KEYS
|
|
479
254
|
*/
|
|
480
255
|
|
|
481
|
-
function del(
|
|
482
|
-
return
|
|
256
|
+
function del(): MethodReturn {
|
|
257
|
+
return fetchData(options, 'del', ...arguments);
|
|
483
258
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return request(arguments[1], arguments[2], 'exists', ...keys);
|
|
259
|
+
function exists(): MethodReturn {
|
|
260
|
+
return fetchData(options, 'exists', ...arguments);
|
|
487
261
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return request(false, arguments[2], 'expire', key, seconds);
|
|
262
|
+
function expire(): MethodReturn {
|
|
263
|
+
return fetchData(options, 'expire', ...arguments);
|
|
491
264
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
return request(false, arguments[2], 'expireat', key, timestamp);
|
|
265
|
+
function expireat(): MethodReturn {
|
|
266
|
+
return fetchData(options, 'expireat', ...arguments);
|
|
495
267
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return request(arguments[1], arguments[2], 'keys', pattern);
|
|
268
|
+
function keys(): MethodReturn {
|
|
269
|
+
return fetchData(options, 'keys', ...arguments);
|
|
499
270
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return request(false, arguments[1], 'persist', key);
|
|
271
|
+
function persist(): MethodReturn {
|
|
272
|
+
return fetchData(options, 'persist', ...arguments);
|
|
503
273
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
return request(false, arguments[2], 'pexpire', key, miliseconds);
|
|
274
|
+
function pexpire(): MethodReturn {
|
|
275
|
+
return fetchData(options, 'pexpire', ...arguments);
|
|
507
276
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return request(false, arguments[2], 'pexpireat', key, miliseconds);
|
|
277
|
+
function pexpireat(): MethodReturn {
|
|
278
|
+
return fetchData(options, 'pexpireat', ...arguments);
|
|
511
279
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return request(arguments[1], arguments[2], 'pttl', key);
|
|
280
|
+
function pttl(): MethodReturn {
|
|
281
|
+
return fetchData(options, 'pttl', ...arguments);
|
|
515
282
|
}
|
|
516
|
-
|
|
517
283
|
function randomkey(): MethodReturn {
|
|
518
|
-
return
|
|
284
|
+
return fetchData(options, 'randomkey', ...arguments);
|
|
519
285
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
return request(false, arguments[2], 'rename', key, newKey);
|
|
286
|
+
function rename(): MethodReturn {
|
|
287
|
+
return fetchData(options, 'rename', ...arguments);
|
|
523
288
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
return request(false, arguments[2], 'renamenx', key, newKey);
|
|
289
|
+
function renamenx(): MethodReturn {
|
|
290
|
+
return fetchData(options, 'renamenx', ...arguments);
|
|
527
291
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
cursor: number,
|
|
531
|
-
opitons?: { match?: number | string; count?: number | string }
|
|
532
|
-
): MethodReturn {
|
|
533
|
-
if (opitons?.match && opitons?.count) {
|
|
534
|
-
return request(
|
|
535
|
-
false,
|
|
536
|
-
arguments[2],
|
|
537
|
-
'scan',
|
|
538
|
-
cursor,
|
|
539
|
-
'match',
|
|
540
|
-
opitons.match,
|
|
541
|
-
'count',
|
|
542
|
-
opitons.count
|
|
543
|
-
);
|
|
544
|
-
} else if (opitons?.match) {
|
|
545
|
-
return request(
|
|
546
|
-
false,
|
|
547
|
-
arguments[2],
|
|
548
|
-
'scan',
|
|
549
|
-
cursor,
|
|
550
|
-
'match',
|
|
551
|
-
opitons.match
|
|
552
|
-
);
|
|
553
|
-
} else if (opitons?.count) {
|
|
554
|
-
return request(
|
|
555
|
-
false,
|
|
556
|
-
arguments[2],
|
|
557
|
-
'scan',
|
|
558
|
-
cursor,
|
|
559
|
-
'count',
|
|
560
|
-
opitons.count
|
|
561
|
-
);
|
|
562
|
-
}
|
|
563
|
-
return request(false, arguments[2], 'scan', cursor);
|
|
292
|
+
function scan(): MethodReturn {
|
|
293
|
+
return fetchData(options, 'scan', ...arguments);
|
|
564
294
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
return request(false, arguments[1], 'touch', ...keys);
|
|
295
|
+
function touch(): MethodReturn {
|
|
296
|
+
return fetchData(options, 'touch', ...arguments);
|
|
568
297
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
return request(arguments[1], arguments[2], 'ttl', key);
|
|
298
|
+
function ttl(): MethodReturn {
|
|
299
|
+
return fetchData(options, 'ttl', ...arguments);
|
|
572
300
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return request(arguments[1], arguments[2], 'type', key);
|
|
301
|
+
function type(): MethodReturn {
|
|
302
|
+
return fetchData(options, 'type', ...arguments);
|
|
576
303
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
return request(false, arguments[1], 'unlink', ...keys);
|
|
304
|
+
function unlink(): MethodReturn {
|
|
305
|
+
return fetchData(options, 'unlink', ...arguments);
|
|
580
306
|
}
|
|
581
307
|
|
|
582
308
|
/**
|
|
583
309
|
* LISTS
|
|
584
310
|
*/
|
|
585
311
|
|
|
586
|
-
function lindex(
|
|
587
|
-
return
|
|
312
|
+
function lindex(): MethodReturn {
|
|
313
|
+
return fetchData(options, 'lindex', ...arguments);
|
|
588
314
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
key: string,
|
|
592
|
-
option: 'BEFORE' | 'AFTER',
|
|
593
|
-
pivot: string,
|
|
594
|
-
element: string
|
|
595
|
-
): MethodReturn {
|
|
596
|
-
return request(false, arguments[4], 'linsert', key, option, pivot, element);
|
|
315
|
+
function linsert(): MethodReturn {
|
|
316
|
+
return fetchData(options, 'linsert', ...arguments);
|
|
597
317
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
return request(arguments[1], arguments[2], 'llen', key);
|
|
318
|
+
function llen(): MethodReturn {
|
|
319
|
+
return fetchData(options, 'llen', ...arguments);
|
|
601
320
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
return request(false, arguments[1], 'lpop', key);
|
|
321
|
+
function lpop(): MethodReturn {
|
|
322
|
+
return fetchData(options, 'lpop', ...arguments);
|
|
605
323
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
return request(false, arguments[2], 'lpush', key, ...elements);
|
|
324
|
+
function lpush(): MethodReturn {
|
|
325
|
+
return fetchData(options, 'lpush', ...arguments);
|
|
609
326
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return request(false, arguments[2], 'lpushx', key, ...elements);
|
|
327
|
+
function lpushx(): MethodReturn {
|
|
328
|
+
return fetchData(options, 'lpushx', ...arguments);
|
|
613
329
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
return request(arguments[3], arguments[4], 'lrange', key, start, stop);
|
|
330
|
+
function lrange(): MethodReturn {
|
|
331
|
+
return fetchData(options, 'lrange', ...arguments);
|
|
617
332
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
return request(false, arguments[3], 'lrem', key, count, element);
|
|
333
|
+
function lrem(): MethodReturn {
|
|
334
|
+
return fetchData(options, 'lrem', ...arguments);
|
|
621
335
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
return request(false, arguments[3], 'lset', key, index, element);
|
|
336
|
+
function lset(): MethodReturn {
|
|
337
|
+
return fetchData(options, 'lset', ...arguments);
|
|
625
338
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return request(false, arguments[3], 'ltrim', key, start, stop);
|
|
339
|
+
function ltrim(): MethodReturn {
|
|
340
|
+
return fetchData(options, 'ltrim', ...arguments);
|
|
629
341
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
return request(false, arguments[1], 'rpop', key);
|
|
342
|
+
function rpop(): MethodReturn {
|
|
343
|
+
return fetchData(options, 'rpop', ...arguments);
|
|
633
344
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
return request(false, arguments[2], 'rpoplpush', source, destination);
|
|
345
|
+
function rpoplpush(): MethodReturn {
|
|
346
|
+
return fetchData(options, 'rpoplpush', ...arguments);
|
|
637
347
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
return request(false, arguments[2], 'rpush', key, ...elements);
|
|
348
|
+
function rpush(): MethodReturn {
|
|
349
|
+
return fetchData(options, 'rpush', ...arguments);
|
|
641
350
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
return request(false, arguments[2], 'rpushx', key, ...elements);
|
|
351
|
+
function rpushx(): MethodReturn {
|
|
352
|
+
return fetchData(options, 'rpushx', ...arguments);
|
|
645
353
|
}
|
|
646
354
|
|
|
647
355
|
/**
|
|
@@ -649,461 +357,137 @@ function Upstash(): Upstash {
|
|
|
649
357
|
*/
|
|
650
358
|
|
|
651
359
|
function dbsize(): MethodReturn {
|
|
652
|
-
return
|
|
360
|
+
return fetchData(options, 'dbsize', ...arguments);
|
|
653
361
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (mode) {
|
|
657
|
-
return request(false, arguments[1], 'flushall', mode);
|
|
658
|
-
}
|
|
659
|
-
return request(false, arguments[1], 'flushall');
|
|
362
|
+
function flushall(): MethodReturn {
|
|
363
|
+
return fetchData(options, 'flushall', ...arguments);
|
|
660
364
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (mode) {
|
|
664
|
-
return request(false, arguments[1], 'flushdb', mode);
|
|
665
|
-
}
|
|
666
|
-
return request(false, arguments[1], 'flushdb');
|
|
365
|
+
function flushdb(): MethodReturn {
|
|
366
|
+
return fetchData(options, 'flushdb', ...arguments);
|
|
667
367
|
}
|
|
668
|
-
|
|
669
368
|
function info(): MethodReturn {
|
|
670
|
-
return
|
|
369
|
+
return fetchData(options, 'info', ...arguments);
|
|
671
370
|
}
|
|
672
|
-
|
|
673
371
|
function time(): MethodReturn {
|
|
674
|
-
return
|
|
372
|
+
return fetchData(options, 'time', ...arguments);
|
|
675
373
|
}
|
|
676
374
|
|
|
677
375
|
/**
|
|
678
376
|
* SET
|
|
679
377
|
*/
|
|
680
378
|
|
|
681
|
-
function sadd(
|
|
682
|
-
return
|
|
379
|
+
function sadd(): MethodReturn {
|
|
380
|
+
return fetchData(options, 'sadd', ...arguments);
|
|
683
381
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
return request(false, arguments[1], 'scard', key);
|
|
382
|
+
function scard(): MethodReturn {
|
|
383
|
+
return fetchData(options, 'scard', ...arguments);
|
|
687
384
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
return request(arguments[1], arguments[2], 'sdiff', ...keys);
|
|
385
|
+
function sdiff(): MethodReturn {
|
|
386
|
+
return fetchData(options, 'sdiff', ...arguments);
|
|
691
387
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
return request(false, arguments[2], 'sdiffstore', destination, ...keys);
|
|
388
|
+
function sdiffstore(): MethodReturn {
|
|
389
|
+
return fetchData(options, 'sdiffstore', ...arguments);
|
|
695
390
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
return request(arguments[1], arguments[2], 'sinter', ...keys);
|
|
391
|
+
function sinter(): MethodReturn {
|
|
392
|
+
return fetchData(options, 'sinter', ...arguments);
|
|
699
393
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
return request(false, arguments[2], 'sinterstore', destination, ...keys);
|
|
394
|
+
function sinterstore(): MethodReturn {
|
|
395
|
+
return fetchData(options, 'sinterstore', ...arguments);
|
|
703
396
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
return request(arguments[2], arguments[3], 'sismember', key, member);
|
|
397
|
+
function sismember(): MethodReturn {
|
|
398
|
+
return fetchData(options, 'sismember', ...arguments);
|
|
707
399
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
return request(arguments[1], arguments[2], 'smembers', key);
|
|
400
|
+
function smembers(): MethodReturn {
|
|
401
|
+
return fetchData(options, 'smembers', ...arguments);
|
|
711
402
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
source: string,
|
|
715
|
-
destination: string,
|
|
716
|
-
member: string
|
|
717
|
-
): MethodReturn {
|
|
718
|
-
return request(false, arguments[3], 'smove', source, destination, member);
|
|
403
|
+
function smove(): MethodReturn {
|
|
404
|
+
return fetchData(options, 'smove', ...arguments);
|
|
719
405
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
if (count) {
|
|
723
|
-
return request(false, arguments[2], 'spop', key, count);
|
|
724
|
-
}
|
|
725
|
-
return request(false, arguments[2], 'spop', key);
|
|
406
|
+
function spop(): MethodReturn {
|
|
407
|
+
return fetchData(options, 'spop', ...arguments);
|
|
726
408
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
if (count) {
|
|
730
|
-
return request(arguments[2], arguments[3], 'srandmember', key, count);
|
|
731
|
-
}
|
|
732
|
-
return request(arguments[2], arguments[3], 'srandmember', key);
|
|
409
|
+
function srandmember(): MethodReturn {
|
|
410
|
+
return fetchData(options, 'srandmember', ...arguments);
|
|
733
411
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
return request(false, arguments[2], 'srem', key, ...members);
|
|
412
|
+
function srem(): MethodReturn {
|
|
413
|
+
return fetchData(options, 'srem', ...arguments);
|
|
737
414
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return request(arguments[1], arguments[2], 'sunion', ...keys);
|
|
415
|
+
function sunion(): MethodReturn {
|
|
416
|
+
return fetchData(options, 'sunion', ...arguments);
|
|
741
417
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
return request(false, arguments[2], 'sunionstore', destination, ...keys);
|
|
418
|
+
function sunionstore(): MethodReturn {
|
|
419
|
+
return fetchData(options, 'sunionstore', ...arguments);
|
|
745
420
|
}
|
|
746
421
|
|
|
747
422
|
/**
|
|
748
423
|
* SORTED SETS
|
|
749
424
|
*/
|
|
750
425
|
|
|
751
|
-
function zadd(
|
|
752
|
-
|
|
753
|
-
values: ZSetNumber[],
|
|
754
|
-
options?: ({ xx?: boolean } | { nx?: boolean }) & {
|
|
755
|
-
ch?: boolean;
|
|
756
|
-
incr: boolean;
|
|
757
|
-
}
|
|
758
|
-
): MethodReturn {
|
|
759
|
-
if (options) {
|
|
760
|
-
const allOptions = Object.entries(options)
|
|
761
|
-
.filter((e) => ['string', 'number', 'boolean'].includes(typeof e[1]))
|
|
762
|
-
.map((e) => e[0].toUpperCase());
|
|
763
|
-
|
|
764
|
-
return request(
|
|
765
|
-
false,
|
|
766
|
-
arguments[3],
|
|
767
|
-
'zadd',
|
|
768
|
-
key,
|
|
769
|
-
...allOptions,
|
|
770
|
-
...values
|
|
771
|
-
);
|
|
772
|
-
}
|
|
773
|
-
return request(arguments[3], arguments[4], 'zadd', key, ...values);
|
|
426
|
+
function zadd(): MethodReturn {
|
|
427
|
+
return fetchData(options, 'zadd', ...arguments);
|
|
774
428
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
return request(arguments[1], arguments[2], 'zcard', key);
|
|
429
|
+
function zcard(): MethodReturn {
|
|
430
|
+
return fetchData(options, 'zcard', ...arguments);
|
|
778
431
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
return request(arguments[3], arguments[4], 'zcount', key, min, max);
|
|
432
|
+
function zcount(): MethodReturn {
|
|
433
|
+
return fetchData(options, 'zcount', ...arguments);
|
|
782
434
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
key: string,
|
|
786
|
-
increment: number | string,
|
|
787
|
-
member: string
|
|
788
|
-
): MethodReturn {
|
|
789
|
-
return request(false, arguments[3], 'zincrby', key, increment, member);
|
|
435
|
+
function zincrby(): MethodReturn {
|
|
436
|
+
return fetchData(options, 'zincrby', ...arguments);
|
|
790
437
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
destination: string,
|
|
794
|
-
keys: string[],
|
|
795
|
-
options?: { weights?: number[]; aggregate?: 'MIN' | 'MAX' | 'SUM' }
|
|
796
|
-
): MethodReturn {
|
|
797
|
-
if (options) {
|
|
798
|
-
if (options.weights && options.aggregate) {
|
|
799
|
-
return request(
|
|
800
|
-
false,
|
|
801
|
-
arguments[3],
|
|
802
|
-
'zinterstore',
|
|
803
|
-
destination,
|
|
804
|
-
keys.length,
|
|
805
|
-
...keys,
|
|
806
|
-
'weights',
|
|
807
|
-
...options.weights,
|
|
808
|
-
'aggregate',
|
|
809
|
-
options.aggregate
|
|
810
|
-
);
|
|
811
|
-
} else if (options.weights) {
|
|
812
|
-
return request(
|
|
813
|
-
false,
|
|
814
|
-
arguments[3],
|
|
815
|
-
'zinterstore',
|
|
816
|
-
destination,
|
|
817
|
-
keys.length,
|
|
818
|
-
...keys,
|
|
819
|
-
'weights',
|
|
820
|
-
...options.weights
|
|
821
|
-
);
|
|
822
|
-
} else if (options.aggregate) {
|
|
823
|
-
return request(
|
|
824
|
-
false,
|
|
825
|
-
arguments[3],
|
|
826
|
-
'zinterstore',
|
|
827
|
-
destination,
|
|
828
|
-
keys.length,
|
|
829
|
-
...keys,
|
|
830
|
-
'aggregate',
|
|
831
|
-
options.aggregate
|
|
832
|
-
);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
return request(
|
|
836
|
-
false,
|
|
837
|
-
arguments[3],
|
|
838
|
-
'zinterstore',
|
|
839
|
-
destination,
|
|
840
|
-
keys.length,
|
|
841
|
-
...keys
|
|
842
|
-
);
|
|
438
|
+
function zinterstore(): MethodReturn {
|
|
439
|
+
return fetchData(options, 'zinterstore', ...arguments);
|
|
843
440
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
key: string,
|
|
847
|
-
min: ZSetNumber,
|
|
848
|
-
max: ZSetNumber
|
|
849
|
-
): MethodReturn {
|
|
850
|
-
return request(arguments[3], arguments[4], 'zlexcount', key, min, max);
|
|
441
|
+
function zlexcount(): MethodReturn {
|
|
442
|
+
return fetchData(options, 'zlexcount', ...arguments);
|
|
851
443
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
if (count) {
|
|
855
|
-
return request(false, arguments[2], 'zpopmax', key, count);
|
|
856
|
-
}
|
|
857
|
-
return request(false, arguments[2], 'zpopmax', key);
|
|
444
|
+
function zpopmax(): MethodReturn {
|
|
445
|
+
return fetchData(options, 'zpopmax', ...arguments);
|
|
858
446
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if (count) {
|
|
862
|
-
return request(false, arguments[2], 'zpopmin', key, count);
|
|
863
|
-
}
|
|
864
|
-
return request(false, arguments[2], 'zpopmin', key);
|
|
447
|
+
function zpopmin(): MethodReturn {
|
|
448
|
+
return fetchData(options, 'zpopmin', ...arguments);
|
|
865
449
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
key: string,
|
|
869
|
-
min: ZSetNumber,
|
|
870
|
-
max: ZSetNumber,
|
|
871
|
-
options?: { withScores: boolean }
|
|
872
|
-
): MethodReturn {
|
|
873
|
-
if (options?.withScores) {
|
|
874
|
-
return request(
|
|
875
|
-
arguments[4],
|
|
876
|
-
arguments[5],
|
|
877
|
-
'zrange',
|
|
878
|
-
key,
|
|
879
|
-
min,
|
|
880
|
-
max,
|
|
881
|
-
'WITHSCORES'
|
|
882
|
-
);
|
|
883
|
-
}
|
|
884
|
-
return request(arguments[4], arguments[5], 'zrange', key, min, max);
|
|
450
|
+
function zrange(): MethodReturn {
|
|
451
|
+
return fetchData(options, 'zrange', ...arguments);
|
|
885
452
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
key: string,
|
|
889
|
-
min: ZSetNumber,
|
|
890
|
-
max: ZSetNumber,
|
|
891
|
-
offset?: number,
|
|
892
|
-
count?: number
|
|
893
|
-
): MethodReturn {
|
|
894
|
-
if (offset && count) {
|
|
895
|
-
return request(
|
|
896
|
-
arguments[5],
|
|
897
|
-
arguments[6],
|
|
898
|
-
'zrangebylex',
|
|
899
|
-
key,
|
|
900
|
-
min,
|
|
901
|
-
max,
|
|
902
|
-
'LIMIT',
|
|
903
|
-
offset,
|
|
904
|
-
count
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
return request(arguments[5], arguments[6], 'zrangebylex', key, min, max);
|
|
453
|
+
function zrangebylex(): MethodReturn {
|
|
454
|
+
return fetchData(options, 'zrangebylex', ...arguments);
|
|
908
455
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
key: string,
|
|
912
|
-
min: ZSetNumber,
|
|
913
|
-
max: ZSetNumber,
|
|
914
|
-
options?: {
|
|
915
|
-
withScores?: boolean;
|
|
916
|
-
limit?: { offset: number; count: number };
|
|
917
|
-
}
|
|
918
|
-
): MethodReturn {
|
|
919
|
-
if (options?.withScores && options?.limit) {
|
|
920
|
-
return request(
|
|
921
|
-
arguments[4],
|
|
922
|
-
arguments[5],
|
|
923
|
-
'zrangebyscore',
|
|
924
|
-
key,
|
|
925
|
-
min,
|
|
926
|
-
max,
|
|
927
|
-
'WITHSCORES',
|
|
928
|
-
'LIMIT',
|
|
929
|
-
options.limit.offset,
|
|
930
|
-
options.limit.count
|
|
931
|
-
);
|
|
932
|
-
} else if (options?.withScores) {
|
|
933
|
-
return request(
|
|
934
|
-
arguments[4],
|
|
935
|
-
arguments[5],
|
|
936
|
-
'zrangebyscore',
|
|
937
|
-
key,
|
|
938
|
-
min,
|
|
939
|
-
max,
|
|
940
|
-
'WITHSCORES'
|
|
941
|
-
);
|
|
942
|
-
} else if (options?.limit) {
|
|
943
|
-
return request(
|
|
944
|
-
arguments[4],
|
|
945
|
-
arguments[5],
|
|
946
|
-
'zrangebyscore',
|
|
947
|
-
key,
|
|
948
|
-
min,
|
|
949
|
-
max,
|
|
950
|
-
'LIMIT',
|
|
951
|
-
options.limit.offset,
|
|
952
|
-
options.limit.count
|
|
953
|
-
);
|
|
954
|
-
}
|
|
955
|
-
return request(arguments[4], arguments[5], 'zrangebyscore', key, min, max);
|
|
456
|
+
function zrangebyscore(): MethodReturn {
|
|
457
|
+
return fetchData(options, 'zrangebyscore', ...arguments);
|
|
956
458
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
return request(arguments[2], arguments[3], 'zrank', key, member);
|
|
459
|
+
function zrank(): MethodReturn {
|
|
460
|
+
return fetchData(options, 'zrank', ...arguments);
|
|
960
461
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
return request(false, arguments[2], 'zrem', key, ...members);
|
|
462
|
+
function zrem(): MethodReturn {
|
|
463
|
+
return fetchData(options, 'zrem', ...arguments);
|
|
964
464
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
key: string,
|
|
968
|
-
min: ZSetNumber,
|
|
969
|
-
max: ZSetNumber
|
|
970
|
-
): MethodReturn {
|
|
971
|
-
return request(false, arguments[3], 'zremrangebylex', key, min, max);
|
|
465
|
+
function zremrangebylex(): MethodReturn {
|
|
466
|
+
return fetchData(options, 'zremrangebylex', ...arguments);
|
|
972
467
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
key: string,
|
|
976
|
-
start: number,
|
|
977
|
-
stop: number
|
|
978
|
-
): MethodReturn {
|
|
979
|
-
return request(false, arguments[3], 'zremrangebyrank', key, start, stop);
|
|
468
|
+
function zremrangebyrank(): MethodReturn {
|
|
469
|
+
return fetchData(options, 'zremrangebyrank', ...arguments);
|
|
980
470
|
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
key: string,
|
|
984
|
-
min: ZSetNumber,
|
|
985
|
-
max: ZSetNumber
|
|
986
|
-
): MethodReturn {
|
|
987
|
-
return request(false, arguments[3], 'zremrangebyscore', key, min, max);
|
|
471
|
+
function zremrangebyscore(): MethodReturn {
|
|
472
|
+
return fetchData(options, 'zremrangebyscore', ...arguments);
|
|
988
473
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
key: string,
|
|
992
|
-
start: number,
|
|
993
|
-
stop: number,
|
|
994
|
-
options?: { withScores: boolean }
|
|
995
|
-
): MethodReturn {
|
|
996
|
-
if (options?.withScores) {
|
|
997
|
-
return request(
|
|
998
|
-
arguments[4],
|
|
999
|
-
arguments[5],
|
|
1000
|
-
'zrevrange',
|
|
1001
|
-
key,
|
|
1002
|
-
start,
|
|
1003
|
-
stop,
|
|
1004
|
-
'WITHSCORES'
|
|
1005
|
-
);
|
|
1006
|
-
}
|
|
1007
|
-
return request(arguments[4], arguments[5], 'zrevrange', key, start, stop);
|
|
474
|
+
function zrevrange(): MethodReturn {
|
|
475
|
+
return fetchData(options, 'zrevrange', ...arguments);
|
|
1008
476
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
key: string,
|
|
1012
|
-
max: ZSetNumber,
|
|
1013
|
-
min: ZSetNumber,
|
|
1014
|
-
offset?: number,
|
|
1015
|
-
count?: number
|
|
1016
|
-
): MethodReturn {
|
|
1017
|
-
if (offset && count) {
|
|
1018
|
-
return request(
|
|
1019
|
-
arguments[5],
|
|
1020
|
-
arguments[6],
|
|
1021
|
-
'zrevrangebylex',
|
|
1022
|
-
key,
|
|
1023
|
-
max,
|
|
1024
|
-
min,
|
|
1025
|
-
'LIMIT',
|
|
1026
|
-
offset,
|
|
1027
|
-
count
|
|
1028
|
-
);
|
|
1029
|
-
}
|
|
1030
|
-
return request(arguments[5], arguments[6], 'zrevrangebylex', key, max, min);
|
|
477
|
+
function zrevrangebylex(): MethodReturn {
|
|
478
|
+
return fetchData(options, 'zrevrangebylex', ...arguments);
|
|
1031
479
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
key: string,
|
|
1035
|
-
min: ZSetNumber,
|
|
1036
|
-
max: ZSetNumber
|
|
1037
|
-
): MethodReturn {
|
|
1038
|
-
return request(
|
|
1039
|
-
arguments[3],
|
|
1040
|
-
arguments[4],
|
|
1041
|
-
'zrevrangebyscore',
|
|
1042
|
-
key,
|
|
1043
|
-
min,
|
|
1044
|
-
max
|
|
1045
|
-
);
|
|
480
|
+
function zrevrangebyscore(): MethodReturn {
|
|
481
|
+
return fetchData(options, 'zrevrangebyscore', ...arguments);
|
|
1046
482
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
return request(arguments[2], arguments[3], 'zrevrank', key, member);
|
|
483
|
+
function zrevrank(): MethodReturn {
|
|
484
|
+
return fetchData(options, 'zrevrank', ...arguments);
|
|
1050
485
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
return request(arguments[2], arguments[3], 'zscore', key, member);
|
|
486
|
+
function zscore(): MethodReturn {
|
|
487
|
+
return fetchData(options, 'zscore', ...arguments);
|
|
1054
488
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
destination: string,
|
|
1058
|
-
keys: string[],
|
|
1059
|
-
options?: { weights?: number[]; aggregate?: 'MIN' | 'MAX' | 'SUM' }
|
|
1060
|
-
): MethodReturn {
|
|
1061
|
-
if (options) {
|
|
1062
|
-
if (options.weights && options.aggregate) {
|
|
1063
|
-
return request(
|
|
1064
|
-
false,
|
|
1065
|
-
arguments[3],
|
|
1066
|
-
'zunionstore',
|
|
1067
|
-
destination,
|
|
1068
|
-
keys.length,
|
|
1069
|
-
...keys,
|
|
1070
|
-
'weights',
|
|
1071
|
-
...options.weights,
|
|
1072
|
-
'aggregate',
|
|
1073
|
-
options.aggregate
|
|
1074
|
-
);
|
|
1075
|
-
} else if (options.weights) {
|
|
1076
|
-
return request(
|
|
1077
|
-
false,
|
|
1078
|
-
arguments[3],
|
|
1079
|
-
'zunionstore',
|
|
1080
|
-
destination,
|
|
1081
|
-
keys.length,
|
|
1082
|
-
...keys,
|
|
1083
|
-
'weights',
|
|
1084
|
-
...options.weights
|
|
1085
|
-
);
|
|
1086
|
-
} else if (options.aggregate) {
|
|
1087
|
-
return request(
|
|
1088
|
-
false,
|
|
1089
|
-
arguments[3],
|
|
1090
|
-
'zunionstore',
|
|
1091
|
-
destination,
|
|
1092
|
-
keys.length,
|
|
1093
|
-
...keys,
|
|
1094
|
-
'aggregate',
|
|
1095
|
-
options.aggregate
|
|
1096
|
-
);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
return request(
|
|
1100
|
-
false,
|
|
1101
|
-
arguments[3],
|
|
1102
|
-
'zunionstore',
|
|
1103
|
-
destination,
|
|
1104
|
-
keys.length,
|
|
1105
|
-
...keys
|
|
1106
|
-
);
|
|
489
|
+
function zunionstore(): MethodReturn {
|
|
490
|
+
return fetchData(options, 'zunionstore', ...arguments);
|
|
1107
491
|
}
|
|
1108
492
|
|
|
1109
493
|
return {
|
|
@@ -1230,3 +614,5 @@ function Upstash(): Upstash {
|
|
|
1230
614
|
zunionstore,
|
|
1231
615
|
};
|
|
1232
616
|
}
|
|
617
|
+
|
|
618
|
+
export default upstash;
|