@upstash/redis 0.1.5 → 0.1.9

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.
@@ -0,0 +1,120 @@
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;
@@ -1,138 +1,161 @@
1
1
  export declare type ClientObjectProps = {
2
2
  url?: undefined | string;
3
3
  token?: undefined | string;
4
- edgeUrl?: undefined | string;
5
- readFromEdge?: boolean;
4
+ requestOptions?: undefined | RequestInit;
6
5
  };
7
- export declare type EdgeCacheType = null | 'miss' | 'hit';
8
6
  export declare type ReturnType = {
9
7
  data: string | number | [] | any;
10
8
  error: string | null;
11
- metadata?: {
12
- edge: boolean;
13
- cache: EdgeCacheType;
14
- };
15
9
  };
16
10
  export declare type MethodReturn = Promise<ReturnType>;
17
- export declare type RequestConfig = undefined | {
18
- edge?: boolean;
19
- };
20
11
  export declare type Part = string | boolean | number;
12
+ export declare type Bit = 0 | 1;
13
+ export declare type Infinities = '+inf' | '-inf';
14
+ export declare type ZSetNumber = Infinities | number | string;
21
15
  declare type Auth1 = (options?: ClientObjectProps) => void;
22
16
  declare type Auth2 = (url?: string, token?: string) => void;
23
17
  declare type Auth3 = (url?: string | ClientObjectProps, token?: string) => void;
24
18
  export declare type Upstash = {
25
19
  auth: Auth1 & Auth2 & Auth3;
26
- append: (...args: any) => MethodReturn;
27
- decr: (...args: any) => MethodReturn;
28
- decrby: (...args: any) => MethodReturn;
29
- get: (...args: any) => MethodReturn;
30
- getrange: (...args: any) => MethodReturn;
31
- getset: (...args: any) => MethodReturn;
32
- incr: (...args: any) => MethodReturn;
33
- incrby: (...args: any) => MethodReturn;
34
- incrbyfloat: (...args: any) => MethodReturn;
35
- mget: (...args: any) => MethodReturn;
36
- mset: (...args: any) => MethodReturn;
37
- msetnx: (...args: any) => MethodReturn;
38
- psetex: (...args: any) => MethodReturn;
39
- set: (...args: any) => MethodReturn;
40
- setex: (...args: any) => MethodReturn;
41
- setnx: (...args: any) => MethodReturn;
42
- setrange: (...args: any) => MethodReturn;
43
- strlen: (...args: any) => MethodReturn;
44
- bitcount: (...args: any) => MethodReturn;
45
- bitop: (...args: any) => MethodReturn;
46
- bitpos: (...args: any) => MethodReturn;
47
- getbit: (...args: any) => MethodReturn;
48
- setbit: (...args: any) => MethodReturn;
49
- echo: (...args: any) => MethodReturn;
50
- ping: (...args: any) => MethodReturn;
51
- hdel: (...args: any) => MethodReturn;
52
- hexists: (...args: any) => MethodReturn;
53
- hget: (...args: any) => MethodReturn;
54
- hgetall: (...args: any) => MethodReturn;
55
- hincrby: (...args: any) => MethodReturn;
56
- hincrbyfloat: (...args: any) => MethodReturn;
57
- hkeys: (...args: any) => MethodReturn;
58
- hlen: (...args: any) => MethodReturn;
59
- hmget: (...args: any) => MethodReturn;
60
- hmset: (...args: any) => MethodReturn;
61
- hscan: (...args: any) => MethodReturn;
62
- hset: (...args: any) => MethodReturn;
63
- hsetnx: (...args: any) => MethodReturn;
64
- hvals: (...args: any) => MethodReturn;
65
- del: (...args: any) => MethodReturn;
66
- exists: (...args: any) => MethodReturn;
67
- expire: (...args: any) => MethodReturn;
68
- expireat: (...args: any) => MethodReturn;
69
- keys: (...args: any) => MethodReturn;
70
- persist: (...args: any) => MethodReturn;
71
- pexpire: (...args: any) => MethodReturn;
72
- pexpireat: (...args: any) => MethodReturn;
73
- pttl: (...args: any) => MethodReturn;
74
- randomkey: (...args: any) => MethodReturn;
75
- rename: (...args: any) => MethodReturn;
76
- renamenx: (...args: any) => MethodReturn;
77
- scan: (...args: any) => MethodReturn;
78
- touch: (...args: any) => MethodReturn;
79
- ttl: (...args: any) => MethodReturn;
80
- type: (...args: any) => MethodReturn;
81
- unlink: (...args: any) => MethodReturn;
82
- lindex: (...args: any) => MethodReturn;
83
- linsert: (...args: any) => MethodReturn;
84
- llen: (...args: any) => MethodReturn;
85
- lpop: (...args: any) => MethodReturn;
86
- lpush: (...args: any) => MethodReturn;
87
- lpushx: (...args: any) => MethodReturn;
88
- lrange: (...args: any) => MethodReturn;
89
- lrem: (...args: any) => MethodReturn;
90
- lset: (...args: any) => MethodReturn;
91
- ltrim: (...args: any) => MethodReturn;
92
- rpop: (...args: any) => MethodReturn;
93
- rpoplpush: (...args: any) => MethodReturn;
94
- rpush: (...args: any) => MethodReturn;
95
- rpushx: (...args: any) => MethodReturn;
96
- dbsize: (...args: any) => MethodReturn;
97
- flushall: (...args: any) => MethodReturn;
98
- flushdb: (...args: any) => MethodReturn;
99
- info: (...args: any) => MethodReturn;
100
- time: (...args: any) => MethodReturn;
101
- sadd: (...args: any) => MethodReturn;
102
- scard: (...args: any) => MethodReturn;
103
- sdiff: (...args: any) => MethodReturn;
104
- sdiffstore: (...args: any) => MethodReturn;
105
- sinter: (...args: any) => MethodReturn;
106
- sinterstore: (...args: any) => MethodReturn;
107
- sismember: (...args: any) => MethodReturn;
108
- smembers: (...args: any) => MethodReturn;
109
- smove: (...args: any) => MethodReturn;
110
- spop: (...args: any) => MethodReturn;
111
- srandmember: (...args: any) => MethodReturn;
112
- srem: (...args: any) => MethodReturn;
113
- sunion: (...args: any) => MethodReturn;
114
- sunionstore: (...args: any) => MethodReturn;
115
- zadd: (...args: any) => MethodReturn;
116
- zcard: (...args: any) => MethodReturn;
117
- zcount: (...args: any) => MethodReturn;
118
- zincrby: (...args: any) => MethodReturn;
119
- zinterstore: (...args: any) => MethodReturn;
120
- zlexcount: (...args: any) => MethodReturn;
121
- zpopmax: (...args: any) => MethodReturn;
122
- zpopmin: (...args: any) => MethodReturn;
123
- zrange: (...args: any) => MethodReturn;
124
- zrangebylex: (...args: any) => MethodReturn;
125
- zrangebyscore: (...args: any) => MethodReturn;
126
- zrank: (...args: any) => MethodReturn;
127
- zrem: (...args: any) => MethodReturn;
128
- zremrangebylex: (...args: any) => MethodReturn;
129
- zremrangebyrank: (...args: any) => MethodReturn;
130
- zremrangebyscore: (...args: any) => MethodReturn;
131
- zrevrange: (...args: any) => MethodReturn;
132
- zrevrangebylex: (...args: any) => MethodReturn;
133
- zrevrangebyscore: (...args: any) => MethodReturn;
134
- zrevrank: (...args: any) => MethodReturn;
135
- zscore: (...args: any) => MethodReturn;
136
- zunionstore: (...args: any) => MethodReturn;
20
+ append: (key: string, value: string) => MethodReturn;
21
+ decr: (key: string) => MethodReturn;
22
+ decrby: (key: string, decrement: number) => MethodReturn;
23
+ get: (key: string) => MethodReturn;
24
+ getrange: (key: string, start: number, end: number) => MethodReturn;
25
+ getset: (key: string, value: string) => MethodReturn;
26
+ incr: (key: string) => MethodReturn;
27
+ incrby: (key: string, value: number | string) => MethodReturn;
28
+ incrbyfloat: (key: string, value: number | string) => MethodReturn;
29
+ mget: (values: string[]) => MethodReturn;
30
+ mset: (values: string[]) => MethodReturn;
31
+ msetnx: (values: string[]) => MethodReturn;
32
+ psetex: (key: string, miliseconds: number, value: string | number) => MethodReturn;
33
+ set: (key: string, value: number | string) => MethodReturn;
34
+ setex: (key: string, seconds: number, value: string | number) => MethodReturn;
35
+ setnx: (key: string, value: string) => MethodReturn;
36
+ setrange: (key: string, offset: number | string, value: string) => MethodReturn;
37
+ strlen: (key: string) => MethodReturn;
38
+ bitcount: (key: string, start?: number, end?: number) => MethodReturn;
39
+ bitop: (operation: 'AND' | 'OR' | 'XOR' | 'NOT', destinationKey: string, sourceKeys: string[]) => MethodReturn;
40
+ bitpos: (key: string, bit: Bit, start?: number, end?: number) => MethodReturn;
41
+ getbit: (key: string, offset: number) => MethodReturn;
42
+ setbit: (key: string, offset: number, value: Bit) => MethodReturn;
43
+ echo: (value: string) => MethodReturn;
44
+ ping: (value?: string) => MethodReturn;
45
+ hdel: (key: string, fields: string[]) => MethodReturn;
46
+ hexists: (key: string, field: string) => MethodReturn;
47
+ hget: (key: string, field: string) => MethodReturn;
48
+ hgetall: (key: string) => MethodReturn;
49
+ hincrby: (key: string, field: string, increment: number | string) => MethodReturn;
50
+ hincrbyfloat: (key: string, field: string, increment: number | string) => MethodReturn;
51
+ hkeys: (key: string) => MethodReturn;
52
+ hlen: (key: string) => MethodReturn;
53
+ hmget: (key: string, fields: string[]) => MethodReturn;
54
+ hmset: (key: string, values: string[]) => MethodReturn;
55
+ hscan: (key: string, cursor: number, options?: {
56
+ match?: number | string;
57
+ count?: number | string;
58
+ }) => MethodReturn;
59
+ hset: (key: string, values: string[]) => MethodReturn;
60
+ hsetnx: (key: string, field: string, value: string) => MethodReturn;
61
+ hvals: (key: string) => MethodReturn;
62
+ del: (keys: string[]) => MethodReturn;
63
+ exists: (keys: string[]) => MethodReturn;
64
+ expire: (key: string, seconds: number) => MethodReturn;
65
+ expireat: (key: string, timestamp: number | string) => MethodReturn;
66
+ keys: (pattern: string) => MethodReturn;
67
+ persist: (key: string) => MethodReturn;
68
+ pexpire: (key: string, miliseconds: number) => MethodReturn;
69
+ pexpireat: (key: string, miliseconds: number) => MethodReturn;
70
+ pttl: (key: string) => MethodReturn;
71
+ randomkey: () => MethodReturn;
72
+ rename: (key: string, newKey: string) => MethodReturn;
73
+ renamenx: (key: string, newKey: string) => MethodReturn;
74
+ scan: (cursor: number, opitons?: {
75
+ match?: number | string;
76
+ count?: number | string;
77
+ }) => MethodReturn;
78
+ touch: (keys: string[]) => MethodReturn;
79
+ ttl: (key: string) => MethodReturn;
80
+ type: (key: string) => MethodReturn;
81
+ unlink: (keys: string[]) => MethodReturn;
82
+ lindex: (key: string, index: number) => MethodReturn;
83
+ linsert: (key: string, option: 'BEFORE' | 'AFTER', pivot: string, element: string) => MethodReturn;
84
+ llen: (key: string) => MethodReturn;
85
+ lpop: (key: string) => MethodReturn;
86
+ lpush: (key: string, elements: string[]) => MethodReturn;
87
+ lpushx: (key: string, elements: string[]) => MethodReturn;
88
+ lrange: (key: string, start: number, stop: number) => MethodReturn;
89
+ lrem: (key: string, count: number, element: string) => MethodReturn;
90
+ lset: (key: string, index: number, element: string) => MethodReturn;
91
+ ltrim: (key: string, start: number, stop: number) => MethodReturn;
92
+ rpop: (key: string) => MethodReturn;
93
+ rpoplpush: (source: string, destination: string) => MethodReturn;
94
+ rpush: (key: string, elements: string[]) => MethodReturn;
95
+ rpushx: (key: string, elements: string[]) => MethodReturn;
96
+ dbsize: () => MethodReturn;
97
+ flushall: (mode?: 'ASYNC') => MethodReturn;
98
+ flushdb: (mode?: 'ASYNC') => MethodReturn;
99
+ info: () => MethodReturn;
100
+ time: () => MethodReturn;
101
+ sadd: (key: string, members: string[]) => MethodReturn;
102
+ scard: (key: string) => MethodReturn;
103
+ sdiff: (keys: string[]) => MethodReturn;
104
+ sdiffstore: (destination: string, keys: string[]) => MethodReturn;
105
+ sinter: (keys: string[]) => MethodReturn;
106
+ sinterstore: (destination: string, keys: string[]) => MethodReturn;
107
+ sismember: (key: string, member: string) => MethodReturn;
108
+ smembers: (key: string) => MethodReturn;
109
+ smove: (source: string, destination: string, member: string) => MethodReturn;
110
+ spop: (key: string, count?: number) => MethodReturn;
111
+ srandmember: (key: string, count?: number) => MethodReturn;
112
+ srem: (key: string, members: string[]) => MethodReturn;
113
+ sunion: (keys: string[]) => MethodReturn;
114
+ sunionstore: (destination: string, keys: string[]) => MethodReturn;
115
+ zadd: (key: string, values: ZSetNumber[], options?: ({
116
+ xx?: boolean;
117
+ } | {
118
+ nx?: boolean;
119
+ }) & {
120
+ ch?: boolean;
121
+ incr: boolean;
122
+ }) => MethodReturn;
123
+ zcard: (key: string) => MethodReturn;
124
+ zcount: (key: string, min: ZSetNumber, max: ZSetNumber) => MethodReturn;
125
+ zincrby: (key: string, increment: number | string, member: string) => MethodReturn;
126
+ zinterstore: (destination: string, keys: string[], options?: {
127
+ weights?: number[];
128
+ aggregate?: 'MIN' | 'MAX' | 'SUM';
129
+ }) => MethodReturn;
130
+ zlexcount: (key: string, min: ZSetNumber, max: ZSetNumber) => MethodReturn;
131
+ zpopmax: (key: string, count?: number) => MethodReturn;
132
+ zpopmin: (key: string, count?: number) => MethodReturn;
133
+ zrange: (key: string, min: ZSetNumber, max: ZSetNumber, options?: {
134
+ withScores: boolean;
135
+ }) => MethodReturn;
136
+ zrangebylex: (key: string, min: ZSetNumber, max: ZSetNumber, offset?: number, count?: number) => MethodReturn;
137
+ zrangebyscore: (key: string, min: ZSetNumber, max: ZSetNumber, options?: {
138
+ withScores?: boolean;
139
+ limit?: {
140
+ offset: number;
141
+ count: number;
142
+ };
143
+ }) => MethodReturn;
144
+ zrank: (key: string, member: string) => MethodReturn;
145
+ zrem: (key: string, members: string[]) => MethodReturn;
146
+ zremrangebylex: (key: string, min: ZSetNumber, max: ZSetNumber) => MethodReturn;
147
+ zremrangebyrank: (key: string, start: number, stop: number) => MethodReturn;
148
+ zremrangebyscore: (key: string, min: ZSetNumber, max: ZSetNumber) => MethodReturn;
149
+ zrevrange: (key: string, start: number, stop: number, options?: {
150
+ withScores: boolean;
151
+ }) => MethodReturn;
152
+ zrevrangebylex: (key: string, max: ZSetNumber, min: ZSetNumber, offset?: number, count?: number) => MethodReturn;
153
+ zrevrangebyscore: (key: string, min: ZSetNumber, max: ZSetNumber) => MethodReturn;
154
+ zrevrank: (key: string, member: string) => MethodReturn;
155
+ zscore: (key: string, member: string) => MethodReturn;
156
+ zunionstore: (destination: string, keys: string[], options?: {
157
+ weights?: number[];
158
+ aggregate?: 'MIN' | 'MAX' | 'SUM';
159
+ }) => MethodReturn;
137
160
  };
138
161
  export {};
@@ -3,20 +3,17 @@ import { ClientObjectProps, Upstash } from './types';
3
3
  * Creates a Upstash Redis instance
4
4
  *
5
5
  * @constructor
6
- * @param {string} url - database rest url
7
- * @param {string} token - database rest token
8
- * @param {Object} options - database config
9
- * @param {string} [options.url] - database rest url
10
- * @param {string} [options.token] - database rest token
11
- * @param {string} [options.edgeUrl] - database rest edge url
12
- * @param {string} [options.readFromEdge] - database rest read from edge
6
+ * @param {Object} options
7
+ * @param {string} [options.url]
8
+ * @param {string} [options.token]
9
+ * @param {Object} [options.requestOptions]
13
10
  *
14
11
  * @example
15
12
  * ```js
16
13
  * import upstash from '@upstash/redis'
17
14
  *
18
15
  * const redis1 = upstash('url', token);
19
- * const redis2 = upstash({ url: '', token: '', edgeUrl: '', readFromEdge: false });
16
+ * const redis2 = upstash({ url: '', token: '', requestOptions: {} });
20
17
  * ```
21
18
  */
22
19
  declare function upstash(options?: ClientObjectProps): Upstash;