redis-smq-common 1.0.0-rc.9 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.0.0 (20220-06-18)
4
+
5
+ * Rename logger/test00018 (f20fdf9)
6
+ * Test PowerManager (8d6f5e6)
7
+ * Complete async tests to reach 9x% code coverage (ea57f8f)
8
+ * Test async.waterfall() (ae4a283)
9
+ * Increase code coverage (c5e3f2b)
10
+
11
+ ## 1.0.0-rc.11 (2022-05-31)
12
+
13
+ * Update RedisClient and IRedisClientMulti interfaces (8732c97)
14
+
15
+ ## 1.0.0-rc.10 (2022-05-31)
16
+
17
+ * Fix broken promisify(All) because of ICallback typing (4250e32)
18
+
3
19
  ## 1.0.0-rc.9 (2022-05-31)
4
20
 
5
21
  * Improve RedisClient typings (27219a6)
@@ -10,12 +10,14 @@ export declare class IoredisClientMulti implements IRedisClientMulti {
10
10
  rpop(key: string): this;
11
11
  rpush(key: string, element: string): this;
12
12
  zadd(key: string, score: number, element: string): this;
13
- zrem(key: string, element: string): this;
13
+ zrem(key: string, element: string | string[]): this;
14
14
  sadd(key: string, element: string): this;
15
15
  srem(key: string, element: string | string[]): this;
16
16
  hset(key: string, field: string, value: string): this;
17
- hdel(key: string, field: string): this;
17
+ hdel(key: string, field: string | string[]): this;
18
+ hincrby(key: string, field: string, by: number): this;
18
19
  pexpire(key: string, millis: number): this;
20
+ expire(key: string, secs: number): this;
19
21
  rpoplpush(source: string, destination: string): this;
20
22
  del(key: string | string[]): this;
21
23
  exec(cb: ICallback<unknown[]>): void;
@@ -36,7 +36,7 @@ class IoredisClientMulti {
36
36
  return this;
37
37
  }
38
38
  zrem(key, element) {
39
- this.multi.zrem(key, element);
39
+ this.multi.zrem(key, ...(typeof element === 'string' ? [element] : element));
40
40
  return this;
41
41
  }
42
42
  sadd(key, element) {
@@ -52,13 +52,21 @@ class IoredisClientMulti {
52
52
  return this;
53
53
  }
54
54
  hdel(key, field) {
55
- this.multi.hdel(key, field);
55
+ this.multi.hdel(key, ...(typeof field === 'string' ? [field] : field));
56
+ return this;
57
+ }
58
+ hincrby(key, field, by) {
59
+ this.multi.hincrby(key, field, by);
56
60
  return this;
57
61
  }
58
62
  pexpire(key, millis) {
59
63
  this.multi.pexpire(key, millis);
60
64
  return this;
61
65
  }
66
+ expire(key, secs) {
67
+ this.multi.expire(key, secs);
68
+ return this;
69
+ }
62
70
  rpoplpush(source, destination) {
63
71
  this.multi.rpoplpush(source, destination);
64
72
  return this;
@@ -21,6 +21,8 @@ export declare class IoredisClient extends RedisClient {
21
21
  zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
22
22
  psubscribe(pattern: string): void;
23
23
  punsubscribe(channel: string): void;
24
+ subscribe(channel: string): void;
25
+ unsubscribe(channel: string): void;
24
26
  zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
25
27
  smembers(key: string, cb: ICallback<string[]>): void;
26
28
  sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -59,6 +59,12 @@ class IoredisClient extends redis_client_1.RedisClient {
59
59
  punsubscribe(channel) {
60
60
  this.client.punsubscribe(channel);
61
61
  }
62
+ subscribe(channel) {
63
+ this.client.subscribe(channel);
64
+ }
65
+ unsubscribe(channel) {
66
+ this.client.unsubscribe(channel);
67
+ }
62
68
  zrangebyscore(key, min, max, cb) {
63
69
  this.client.zrangebyscore(key, min, max, cb);
64
70
  }
@@ -10,12 +10,14 @@ export declare class NodeRedisV3ClientMulti implements IRedisClientMulti {
10
10
  rpop(key: string): this;
11
11
  rpush(key: string, element: string): this;
12
12
  zadd(key: string, score: number, element: string): this;
13
- zrem(key: string, element: string): this;
13
+ zrem(key: string, element: string | string[]): this;
14
14
  sadd(key: string, element: string): this;
15
15
  srem(key: string, element: string | string[]): this;
16
16
  hset(key: string, field: string, value: string): this;
17
- hdel(key: string, field: string): this;
17
+ hdel(key: string, field: string | string[]): this;
18
+ hincrby(key: string, field: string, by: number): this;
18
19
  pexpire(key: string, millis: number): this;
20
+ expire(key: string, secs: number): this;
19
21
  rpoplpush(source: string, destination: string): this;
20
22
  del(key: string | string[]): this;
21
23
  exec(cb: ICallback<unknown[]>): void;
@@ -54,10 +54,18 @@ class NodeRedisV3ClientMulti {
54
54
  this.multi.hdel(key, field);
55
55
  return this;
56
56
  }
57
+ hincrby(key, field, by) {
58
+ this.multi.hincrby(key, field, by);
59
+ return this;
60
+ }
57
61
  pexpire(key, millis) {
58
62
  this.multi.pexpire(key, millis);
59
63
  return this;
60
64
  }
65
+ expire(key, secs) {
66
+ this.multi.expire(key, secs);
67
+ return this;
68
+ }
61
69
  rpoplpush(source, destination) {
62
70
  this.multi.rpoplpush(source, destination);
63
71
  return this;
@@ -21,6 +21,8 @@ export declare class NodeRedisV3Client extends RedisClient {
21
21
  zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
22
22
  psubscribe(pattern: string): void;
23
23
  punsubscribe(channel: string): void;
24
+ subscribe(channel: string): void;
25
+ unsubscribe(channel: string): void;
24
26
  zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
25
27
  smembers(key: string, cb: ICallback<string[]>): void;
26
28
  sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -86,6 +86,12 @@ class NodeRedisV3Client extends redis_client_1.RedisClient {
86
86
  punsubscribe(channel) {
87
87
  this.client.punsubscribe(channel);
88
88
  }
89
+ subscribe(channel) {
90
+ this.client.subscribe(channel);
91
+ }
92
+ unsubscribe(channel) {
93
+ this.client.unsubscribe(channel);
94
+ }
89
95
  zrangebyscore(key, min, max, cb) {
90
96
  this.client.zrangebyscore(key, min, max, cb);
91
97
  }
@@ -9,12 +9,14 @@ export declare class NodeRedisV4ClientMulti implements IRedisClientMulti {
9
9
  rpop(key: string): this;
10
10
  rpush(key: string, element: string): this;
11
11
  zadd(key: string, score: number, element: string): this;
12
- zrem(key: string, element: string): this;
12
+ zrem(key: string, element: string | string[]): this;
13
13
  sadd(key: string, element: string): this;
14
14
  srem(key: string, element: string | string[]): this;
15
15
  hset(key: string, field: string, value: string): this;
16
- hdel(key: string, field: string): this;
16
+ hdel(key: string, field: string | string[]): this;
17
+ hincrby(key: string, field: string, by: number): this;
17
18
  pexpire(key: string, millis: number): this;
19
+ expire(key: string, secs: number): this;
18
20
  rpoplpush(source: string, destination: string): this;
19
21
  del(key: string | string[]): this;
20
22
  exec(cb: ICallback<unknown[]>): void;
@@ -55,10 +55,18 @@ class NodeRedisV4ClientMulti {
55
55
  this.multi.hDel(key, field);
56
56
  return this;
57
57
  }
58
+ hincrby(key, field, by) {
59
+ this.multi.hIncrBy(key, field, by);
60
+ return this;
61
+ }
58
62
  pexpire(key, millis) {
59
63
  this.multi.pExpire(key, millis);
60
64
  return this;
61
65
  }
66
+ expire(key, secs) {
67
+ this.multi.expire(key, secs);
68
+ return this;
69
+ }
62
70
  rpoplpush(source, destination) {
63
71
  this.multi.rPopLPush(source, destination);
64
72
  return this;
@@ -21,6 +21,8 @@ export declare class NodeRedisV4Client extends RedisClient {
21
21
  zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
22
22
  psubscribe(pattern: string): void;
23
23
  punsubscribe(channel: string): void;
24
+ subscribe(channel: string): void;
25
+ unsubscribe(channel: string): void;
24
26
  zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
25
27
  smembers(key: string, cb: ICallback<string[]>): void;
26
28
  sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -74,6 +74,14 @@ class NodeRedisV4Client extends redis_client_1.RedisClient {
74
74
  punsubscribe(channel) {
75
75
  this.client.pUnsubscribe(channel).catch(() => void 0);
76
76
  }
77
+ subscribe(channel) {
78
+ this.client.subscribe(channel, (message, channel) => {
79
+ this.client.emit('message', channel, message);
80
+ });
81
+ }
82
+ unsubscribe(channel) {
83
+ this.client.unsubscribe(channel).catch(() => void 0);
84
+ }
77
85
  zrangebyscore(key, min, max, cb) {
78
86
  this.client
79
87
  .zRangeByScore(key, min, max)
@@ -179,7 +187,7 @@ class NodeRedisV4Client extends redis_client_1.RedisClient {
179
187
  flushall(cb) {
180
188
  this.client
181
189
  .flushAll()
182
- .then(() => cb())
190
+ .then((reply) => cb(null, reply))
183
191
  .catch(cb);
184
192
  }
185
193
  loadScript(script, cb) {
@@ -29,6 +29,8 @@ export declare abstract class RedisClient extends EventEmitter {
29
29
  abstract zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
30
30
  abstract psubscribe(pattern: string): void;
31
31
  abstract punsubscribe(channel: string): void;
32
+ abstract subscribe(channel: string): void;
33
+ abstract unsubscribe(channel: string): void;
32
34
  abstract zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
33
35
  abstract smembers(key: string, cb: ICallback<string[]>): void;
34
36
  abstract sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -41,8 +43,8 @@ export declare abstract class RedisClient extends EventEmitter {
41
43
  abstract hlen(key: string, cb: ICallback<number>): void;
42
44
  abstract brpoplpush(source: string, destination: string, timeout: number, cb: ICallback<string | null>): void;
43
45
  abstract rpoplpush(source: string, destination: string, cb: ICallback<string | null>): void;
44
- zpophgetrpush(source: string, sourceHash: string, destination: string, cb: ICallback<string>): void;
45
- lpoprpushextra(source: string, destination: string, listSize: number, expire: number, cb: ICallback<string>): void;
46
+ zpophgetrpush(source: string, sourceHash: string, destination: string, cb: ICallback<string | null>): void;
47
+ lpoprpushextra(source: string, destination: string, listSize: number, expire: number, cb: ICallback<string | null>): void;
46
48
  lpoprpush(source: string, destination: string, cb: ICallback<string | null>): void;
47
49
  abstract zrangebyscorewithscores(source: string, min: number, max: number, cb: ICallback<Record<string, string>>): void;
48
50
  abstract rpop(key: string, cb: ICallback<string | null>): void;
@@ -29,20 +29,16 @@ class RedisClient extends events_1.EventEmitter {
29
29
  this.runScript(ELuaScriptName.ZPOPHGETRPUSH, [source, sourceHash, destination], [], (err, res) => {
30
30
  if (err)
31
31
  cb(err);
32
- else if (typeof res !== 'string')
33
- cb();
34
32
  else
35
- cb(null, res);
33
+ cb(null, typeof res === 'string' ? res : null);
36
34
  });
37
35
  }
38
36
  lpoprpushextra(source, destination, listSize, expire, cb) {
39
37
  this.runScript(ELuaScriptName.LPOPRPUSHEXTRA, [source, destination], [listSize, expire], (err, res) => {
40
38
  if (err)
41
39
  cb(err);
42
- else if (typeof res !== 'string')
43
- cb();
44
40
  else
45
- cb(null, res);
41
+ cb(null, typeof res === 'string' ? res : null);
46
42
  });
47
43
  }
48
44
  lpoprpush(source, destination, cb) {
@@ -53,10 +49,8 @@ class RedisClient extends events_1.EventEmitter {
53
49
  this.runScript(ELuaScriptName.LPOPRPUSH, [source, destination], [], (err, res) => {
54
50
  if (err)
55
51
  cb(err);
56
- else if (typeof res !== 'string')
57
- cb();
58
52
  else
59
- cb(null, res);
53
+ cb(null, typeof res === 'string' ? res : null);
60
54
  });
61
55
  }
62
56
  }
@@ -29,14 +29,16 @@ export interface IRedisClientMulti {
29
29
  rpush(key: string, element: string): this;
30
30
  rpop(key: string): this;
31
31
  lpush(key: string, element: string): this;
32
- hdel(key: string, field: string): this;
32
+ hdel(key: string, field: string | string[]): this;
33
+ hincrby(key: string, field: string, by: number): this;
33
34
  del(key: string | string[]): this;
34
35
  srem(key: string, element: string | string[]): this;
35
36
  sadd(key: string, element: string): this;
36
- zrem(key: string, element: string): this;
37
+ zrem(key: string, element: string | string[]): this;
37
38
  zadd(key: string, score: number, element: string): this;
38
39
  hset(key: string, field: string, value: string): this;
39
40
  pexpire(key: string, millis: number): this;
41
+ expire(key: string, secs: number): this;
40
42
  ltrim(key: string, start: number, stop: number): this;
41
43
  rpoplpush(source: string, destination: string): this;
42
44
  exec(cb: ICallback<unknown[]>): void;
@@ -57,6 +59,7 @@ declare module 'ioredis' {
57
59
  }
58
60
  export interface ICallback<T> {
59
61
  (err?: Error | null, reply?: T): void;
62
+ (err: undefined | null, reply: T): void;
60
63
  }
61
64
  export declare type TFunction<TReturn = void, TArgs = any> = (...args: TArgs[]) => TReturn;
62
65
  export declare type TUnaryFunction<T, E = void> = (reply: T) => E;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redis-smq-common",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.0.0",
4
4
  "description": "RedisSMQ shared components that may be used by integrated applications and extensions.",
5
5
  "author": "Weyoss <weyoss@protonmail.com>",
6
6
  "license": "MIT",