@upstash/redis 0.2.1 → 1.0.0-alpha.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.
@@ -1,564 +0,0 @@
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
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
16
- /**
17
- * Parse Options
18
- */
19
- function parseOptions(url, token, requestOptions = {}) {
20
- if (typeof url === 'object' && url !== null) {
21
- return parseOptions(url.url, url.token, url.requestOptions);
22
- }
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) {
43
- if (data.error)
44
- throw data.error;
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
- };
58
- }
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]));
71
- }
72
- /**
73
- * STRING
74
- */
75
- function append() {
76
- return fetchData(options, 'append', ...arguments);
77
- }
78
- function decr() {
79
- return fetchData(options, 'decr', ...arguments);
80
- }
81
- function decrby() {
82
- return fetchData(options, 'decrby', ...arguments);
83
- }
84
- function get() {
85
- return fetchData(options, 'get', ...arguments);
86
- }
87
- function getrange() {
88
- return fetchData(options, 'getrange', ...arguments);
89
- }
90
- function getset() {
91
- return fetchData(options, 'getset', ...arguments);
92
- }
93
- function incr() {
94
- return fetchData(options, 'incr', ...arguments);
95
- }
96
- function incrby() {
97
- return fetchData(options, 'incrby', ...arguments);
98
- }
99
- function incrbyfloat() {
100
- return fetchData(options, 'incrbyfloat', ...arguments);
101
- }
102
- function mget() {
103
- return fetchData(options, 'mget', ...arguments);
104
- }
105
- function mset() {
106
- return fetchData(options, 'mset', ...arguments);
107
- }
108
- function msetnx() {
109
- return fetchData(options, 'msetnx', ...arguments);
110
- }
111
- function psetex() {
112
- return fetchData(options, 'psetex', ...arguments);
113
- }
114
- function set() {
115
- return fetchData(options, 'set', ...arguments);
116
- }
117
- function setex() {
118
- return fetchData(options, 'setex', ...arguments);
119
- }
120
- function setnx() {
121
- return fetchData(options, 'setnx', ...arguments);
122
- }
123
- function setrange() {
124
- return fetchData(options, 'setrange', ...arguments);
125
- }
126
- function strlen() {
127
- return fetchData(options, 'strlen', ...arguments);
128
- }
129
- /**
130
- * BITMAPS
131
- */
132
- function bitcount() {
133
- return fetchData(options, 'bitcount', ...arguments);
134
- }
135
- function bitop() {
136
- return fetchData(options, 'bitop', ...arguments);
137
- }
138
- function bitpos() {
139
- return fetchData(options, 'bitpos', ...arguments);
140
- }
141
- function getbit() {
142
- return fetchData(options, 'getbit', ...arguments);
143
- }
144
- function setbit() {
145
- return fetchData(options, 'setbit', ...arguments);
146
- }
147
- /**
148
- * CONNECTION
149
- */
150
- function echo() {
151
- return fetchData(options, 'echo', ...arguments);
152
- }
153
- function ping() {
154
- return fetchData(options, 'ping', ...arguments);
155
- }
156
- /**
157
- * HASHES
158
- */
159
- function hdel() {
160
- return fetchData(options, 'hdel', ...arguments);
161
- }
162
- function hexists() {
163
- return fetchData(options, 'hexists', ...arguments);
164
- }
165
- function hget() {
166
- return fetchData(options, 'hget', ...arguments);
167
- }
168
- function hgetall() {
169
- return fetchData(options, 'hgetall', ...arguments);
170
- }
171
- function hincrby() {
172
- return fetchData(options, 'hincrby', ...arguments);
173
- }
174
- function hincrbyfloat() {
175
- return fetchData(options, 'hincrbyfloat', ...arguments);
176
- }
177
- function hkeys() {
178
- return fetchData(options, 'hkeys', ...arguments);
179
- }
180
- function hlen() {
181
- return fetchData(options, 'hlen', ...arguments);
182
- }
183
- function hmget() {
184
- return fetchData(options, 'hmget', ...arguments);
185
- }
186
- function hmset() {
187
- return fetchData(options, 'hmset', ...arguments);
188
- }
189
- function hscan() {
190
- return fetchData(options, 'hscan', ...arguments);
191
- }
192
- function hset() {
193
- return fetchData(options, 'hset', ...arguments);
194
- }
195
- function hsetnx() {
196
- return fetchData(options, 'hsetnx', ...arguments);
197
- }
198
- function hvals() {
199
- return fetchData(options, 'hvals', ...arguments);
200
- }
201
- /**
202
- * KEYS
203
- */
204
- function del() {
205
- return fetchData(options, 'del', ...arguments);
206
- }
207
- function exists() {
208
- return fetchData(options, 'exists', ...arguments);
209
- }
210
- function expire() {
211
- return fetchData(options, 'expire', ...arguments);
212
- }
213
- function expireat() {
214
- return fetchData(options, 'expireat', ...arguments);
215
- }
216
- function keys() {
217
- return fetchData(options, 'keys', ...arguments);
218
- }
219
- function persist() {
220
- return fetchData(options, 'persist', ...arguments);
221
- }
222
- function pexpire() {
223
- return fetchData(options, 'pexpire', ...arguments);
224
- }
225
- function pexpireat() {
226
- return fetchData(options, 'pexpireat', ...arguments);
227
- }
228
- function pttl() {
229
- return fetchData(options, 'pttl', ...arguments);
230
- }
231
- function randomkey() {
232
- return fetchData(options, 'randomkey', ...arguments);
233
- }
234
- function rename() {
235
- return fetchData(options, 'rename', ...arguments);
236
- }
237
- function renamenx() {
238
- return fetchData(options, 'renamenx', ...arguments);
239
- }
240
- function scan() {
241
- return fetchData(options, 'scan', ...arguments);
242
- }
243
- function touch() {
244
- return fetchData(options, 'touch', ...arguments);
245
- }
246
- function ttl() {
247
- return fetchData(options, 'ttl', ...arguments);
248
- }
249
- function type() {
250
- return fetchData(options, 'type', ...arguments);
251
- }
252
- function unlink() {
253
- return fetchData(options, 'unlink', ...arguments);
254
- }
255
- /**
256
- * LISTS
257
- */
258
- function lindex() {
259
- return fetchData(options, 'lindex', ...arguments);
260
- }
261
- function linsert() {
262
- return fetchData(options, 'linsert', ...arguments);
263
- }
264
- function llen() {
265
- return fetchData(options, 'llen', ...arguments);
266
- }
267
- function lpop() {
268
- return fetchData(options, 'lpop', ...arguments);
269
- }
270
- function lpush() {
271
- return fetchData(options, 'lpush', ...arguments);
272
- }
273
- function lpushx() {
274
- return fetchData(options, 'lpushx', ...arguments);
275
- }
276
- function lrange() {
277
- return fetchData(options, 'lrange', ...arguments);
278
- }
279
- function lrem() {
280
- return fetchData(options, 'lrem', ...arguments);
281
- }
282
- function lset() {
283
- return fetchData(options, 'lset', ...arguments);
284
- }
285
- function ltrim() {
286
- return fetchData(options, 'ltrim', ...arguments);
287
- }
288
- function rpop() {
289
- return fetchData(options, 'rpop', ...arguments);
290
- }
291
- function rpoplpush() {
292
- return fetchData(options, 'rpoplpush', ...arguments);
293
- }
294
- function rpush() {
295
- return fetchData(options, 'rpush', ...arguments);
296
- }
297
- function rpushx() {
298
- return fetchData(options, 'rpushx', ...arguments);
299
- }
300
- /**
301
- * SERVER
302
- */
303
- function dbsize() {
304
- return fetchData(options, 'dbsize', ...arguments);
305
- }
306
- function flushall() {
307
- return fetchData(options, 'flushall', ...arguments);
308
- }
309
- function flushdb() {
310
- return fetchData(options, 'flushdb', ...arguments);
311
- }
312
- function info() {
313
- return fetchData(options, 'info', ...arguments);
314
- }
315
- function time() {
316
- return fetchData(options, 'time', ...arguments);
317
- }
318
- /**
319
- * SET
320
- */
321
- function sadd() {
322
- return fetchData(options, 'sadd', ...arguments);
323
- }
324
- function scard() {
325
- return fetchData(options, 'scard', ...arguments);
326
- }
327
- function sdiff() {
328
- return fetchData(options, 'sdiff', ...arguments);
329
- }
330
- function sdiffstore() {
331
- return fetchData(options, 'sdiffstore', ...arguments);
332
- }
333
- function sinter() {
334
- return fetchData(options, 'sinter', ...arguments);
335
- }
336
- function sinterstore() {
337
- return fetchData(options, 'sinterstore', ...arguments);
338
- }
339
- function sismember() {
340
- return fetchData(options, 'sismember', ...arguments);
341
- }
342
- function smembers() {
343
- return fetchData(options, 'smembers', ...arguments);
344
- }
345
- function smove() {
346
- return fetchData(options, 'smove', ...arguments);
347
- }
348
- function spop() {
349
- return fetchData(options, 'spop', ...arguments);
350
- }
351
- function srandmember() {
352
- return fetchData(options, 'srandmember', ...arguments);
353
- }
354
- function srem() {
355
- return fetchData(options, 'srem', ...arguments);
356
- }
357
- function sscan() {
358
- return fetchData(options, 'sscan', ...arguments);
359
- }
360
- function sunion() {
361
- return fetchData(options, 'sunion', ...arguments);
362
- }
363
- function sunionstore() {
364
- return fetchData(options, 'sunionstore', ...arguments);
365
- }
366
- /**
367
- * SORTED SETS
368
- */
369
- function zadd() {
370
- return fetchData(options, 'zadd', ...arguments);
371
- }
372
- function zcard() {
373
- return fetchData(options, 'zcard', ...arguments);
374
- }
375
- function zcount() {
376
- return fetchData(options, 'zcount', ...arguments);
377
- }
378
- function zincrby() {
379
- return fetchData(options, 'zincrby', ...arguments);
380
- }
381
- function zinterstore() {
382
- return fetchData(options, 'zinterstore', ...arguments);
383
- }
384
- function zlexcount() {
385
- return fetchData(options, 'zlexcount', ...arguments);
386
- }
387
- function zpopmax() {
388
- return fetchData(options, 'zpopmax', ...arguments);
389
- }
390
- function zpopmin() {
391
- return fetchData(options, 'zpopmin', ...arguments);
392
- }
393
- function zrange() {
394
- return fetchData(options, 'zrange', ...arguments);
395
- }
396
- function zrangebylex() {
397
- return fetchData(options, 'zrangebylex', ...arguments);
398
- }
399
- function zrangebyscore() {
400
- return fetchData(options, 'zrangebyscore', ...arguments);
401
- }
402
- function zrank() {
403
- return fetchData(options, 'zrank', ...arguments);
404
- }
405
- function zrem() {
406
- return fetchData(options, 'zrem', ...arguments);
407
- }
408
- function zremrangebylex() {
409
- return fetchData(options, 'zremrangebylex', ...arguments);
410
- }
411
- function zremrangebyrank() {
412
- return fetchData(options, 'zremrangebyrank', ...arguments);
413
- }
414
- function zremrangebyscore() {
415
- return fetchData(options, 'zremrangebyscore', ...arguments);
416
- }
417
- function zrevrange() {
418
- return fetchData(options, 'zrevrange', ...arguments);
419
- }
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);
437
- }
438
- return {
439
- auth,
440
- // STRING
441
- append,
442
- decr,
443
- decrby,
444
- get,
445
- getrange,
446
- getset,
447
- incr,
448
- incrby,
449
- incrbyfloat,
450
- mget,
451
- mset,
452
- msetnx,
453
- psetex,
454
- set,
455
- setex,
456
- setnx,
457
- setrange,
458
- strlen,
459
- // BITMAPS
460
- bitcount,
461
- bitop,
462
- bitpos,
463
- getbit,
464
- setbit,
465
- // CONNECTION
466
- echo,
467
- ping,
468
- // HASHES
469
- hdel,
470
- hexists,
471
- hget,
472
- hgetall,
473
- hincrby,
474
- hincrbyfloat,
475
- hkeys,
476
- hlen,
477
- hmget,
478
- hmset,
479
- hscan,
480
- hset,
481
- hsetnx,
482
- hvals,
483
- // KEYS
484
- del,
485
- exists,
486
- expire,
487
- expireat,
488
- keys,
489
- persist,
490
- pexpire,
491
- pexpireat,
492
- pttl,
493
- randomkey,
494
- rename,
495
- renamenx,
496
- scan,
497
- touch,
498
- ttl,
499
- type,
500
- unlink,
501
- // LISTS
502
- lindex,
503
- linsert,
504
- llen,
505
- lpop,
506
- lpush,
507
- lpushx,
508
- lrange,
509
- lrem,
510
- lset,
511
- ltrim,
512
- rpop,
513
- rpoplpush,
514
- rpush,
515
- rpushx,
516
- // SERVER
517
- dbsize,
518
- flushall,
519
- flushdb,
520
- info,
521
- time,
522
- // SET
523
- sadd,
524
- scard,
525
- sdiff,
526
- sdiffstore,
527
- sinter,
528
- sinterstore,
529
- sismember,
530
- smembers,
531
- smove,
532
- spop,
533
- srandmember,
534
- srem,
535
- sscan,
536
- sunion,
537
- sunionstore,
538
- // SORTED SETS
539
- zadd,
540
- zcard,
541
- zcount,
542
- zincrby,
543
- zinterstore,
544
- zlexcount,
545
- zpopmax,
546
- zpopmin,
547
- zrange,
548
- zrangebylex,
549
- zrangebyscore,
550
- zrank,
551
- zrem,
552
- zremrangebylex,
553
- zremrangebyrank,
554
- zremrangebyscore,
555
- zrevrange,
556
- zrevrangebylex,
557
- zrevrangebyscore,
558
- zrevrank,
559
- zscan,
560
- zscore,
561
- zunionstore,
562
- };
563
- }
564
- exports.default = upstash;
@@ -1 +0,0 @@
1
- export {};
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const client_1 = __importDefault(require("./client"));
7
- const redis = (0, client_1.default)();
8
- module.exports = client_1.default;
9
- module.exports.auth = redis.auth;
10
- module.exports.append = redis.append;
11
- module.exports.decr = redis.decr;
12
- module.exports.decrby = redis.decrby;
13
- module.exports.get = redis.get;
14
- module.exports.getrange = redis.getrange;
15
- module.exports.getset = redis.getset;
16
- module.exports.incr = redis.incr;
17
- module.exports.incrby = redis.incrby;
18
- module.exports.incrbyfloat = redis.incrbyfloat;
19
- module.exports.mget = redis.mget;
20
- module.exports.mset = redis.mset;
21
- module.exports.msetnx = redis.msetnx;
22
- module.exports.psetex = redis.psetex;
23
- module.exports.set = redis.set;
24
- module.exports.setex = redis.setex;
25
- module.exports.setnx = redis.setnx;
26
- module.exports.setrange = redis.setrange;
27
- module.exports.strlen = redis.strlen;
28
- module.exports.bitcount = redis.bitcount;
29
- module.exports.bitop = redis.bitop;
30
- module.exports.bitpos = redis.bitpos;
31
- module.exports.getbit = redis.getbit;
32
- module.exports.setbit = redis.setbit;
33
- module.exports.echo = redis.echo;
34
- module.exports.ping = redis.ping;
35
- module.exports.hdel = redis.hdel;
36
- module.exports.hexists = redis.hexists;
37
- module.exports.hget = redis.hget;
38
- module.exports.hgetall = redis.hgetall;
39
- module.exports.hincrby = redis.hincrby;
40
- module.exports.hincrbyfloat = redis.hincrbyfloat;
41
- module.exports.hkeys = redis.hkeys;
42
- module.exports.hlen = redis.hlen;
43
- module.exports.hmget = redis.hmget;
44
- module.exports.hmset = redis.hmset;
45
- module.exports.hscan = redis.hscan;
46
- module.exports.hset = redis.hset;
47
- module.exports.hsetnx = redis.hsetnx;
48
- module.exports.hvals = redis.hvals;
49
- module.exports.del = redis.del;
50
- module.exports.exists = redis.exists;
51
- module.exports.expire = redis.expire;
52
- module.exports.expireat = redis.expireat;
53
- module.exports.keys = redis.keys;
54
- module.exports.persist = redis.persist;
55
- module.exports.pexpire = redis.pexpire;
56
- module.exports.pexpireat = redis.pexpireat;
57
- module.exports.pttl = redis.pttl;
58
- module.exports.randomkey = redis.randomkey;
59
- module.exports.rename = redis.rename;
60
- module.exports.renamenx = redis.renamenx;
61
- module.exports.scan = redis.scan;
62
- module.exports.touch = redis.touch;
63
- module.exports.ttl = redis.ttl;
64
- module.exports.type = redis.type;
65
- module.exports.unlink = redis.unlink;
66
- module.exports.lindex = redis.lindex;
67
- module.exports.linsert = redis.linsert;
68
- module.exports.llen = redis.llen;
69
- module.exports.lpop = redis.lpop;
70
- module.exports.lpush = redis.lpush;
71
- module.exports.lpushx = redis.lpushx;
72
- module.exports.lrange = redis.lrange;
73
- module.exports.lrem = redis.lrem;
74
- module.exports.lset = redis.lset;
75
- module.exports.ltrim = redis.ltrim;
76
- module.exports.rpop = redis.rpop;
77
- module.exports.rpoplpush = redis.rpoplpush;
78
- module.exports.rpush = redis.rpush;
79
- module.exports.rpushx = redis.rpushx;
80
- module.exports.dbsize = redis.dbsize;
81
- module.exports.flushall = redis.flushall;
82
- module.exports.flushdb = redis.flushdb;
83
- module.exports.info = redis.info;
84
- module.exports.time = redis.time;
85
- module.exports.sadd = redis.sadd;
86
- module.exports.scard = redis.scard;
87
- module.exports.sdiff = redis.sdiff;
88
- module.exports.sdiffstore = redis.sdiffstore;
89
- module.exports.sinter = redis.sinter;
90
- module.exports.sinterstore = redis.sinterstore;
91
- module.exports.sismember = redis.sismember;
92
- module.exports.smembers = redis.smembers;
93
- module.exports.smove = redis.smove;
94
- module.exports.spop = redis.spop;
95
- module.exports.srandmember = redis.srandmember;
96
- module.exports.srem = redis.srem;
97
- module.exports.sunion = redis.sunion;
98
- module.exports.sunionstore = redis.sunionstore;
99
- module.exports.zadd = redis.zadd;
100
- module.exports.zcard = redis.zcard;
101
- module.exports.zcount = redis.zcount;
102
- module.exports.zincrby = redis.zincrby;
103
- module.exports.zinterstore = redis.zinterstore;
104
- module.exports.zlexcount = redis.zlexcount;
105
- module.exports.zpopmax = redis.zpopmax;
106
- module.exports.zpopmin = redis.zpopmin;
107
- module.exports.zrange = redis.zrange;
108
- module.exports.zrangebylex = redis.zrangebylex;
109
- module.exports.zrangebyscore = redis.zrangebyscore;
110
- module.exports.zrank = redis.zrank;
111
- module.exports.zrem = redis.zrem;
112
- module.exports.zremrangebylex = redis.zremrangebylex;
113
- module.exports.zremrangebyrank = redis.zremrangebyrank;
114
- module.exports.zremrangebyscore = redis.zremrangebyscore;
115
- module.exports.zrevrange = redis.zrevrange;
116
- module.exports.zrevrangebylex = redis.zrevrangebylex;
117
- module.exports.zrevrangebyscore = redis.zrevrangebyscore;
118
- module.exports.zrevrank = redis.zrevrank;
119
- module.exports.zscore = redis.zscore;
120
- module.exports.zunionstore = redis.zunionstore;