@imqueue/rpc 1.13.14 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/rpc",
3
- "version": "1.13.14",
3
+ "version": "1.14.1",
4
4
  "description": "RPC-like client-service implementation over messaging queue",
5
5
  "keywords": [
6
6
  "redis",
@@ -38,33 +38,32 @@
38
38
  "author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
39
39
  "license": "ISC",
40
40
  "dependencies": {
41
- "@imqueue/core": "^1.11.9",
42
- "@types/acorn": "^4.0.6",
43
- "@types/node": "^16.11.6",
44
- "acorn": "^8.5.0",
41
+ "@imqueue/core": "^1.12.0",
42
+ "@types/node": "^20.1.4",
43
+ "acorn": "^8.8.2",
45
44
  "murmurhash-native": "^3.5.0",
46
45
  "node-machine-id": "^1.1.12",
47
46
  "reflect-metadata": "^0.1.13",
48
- "typescript": "^4.4.4"
47
+ "typescript": "^5.0.4"
49
48
  },
50
49
  "devDependencies": {
51
- "@types/chai": "^4.2.22",
52
- "@types/mocha": "^9.0.0",
53
- "@types/mock-require": "^2.0.0",
54
- "@types/sinon": "^10.0.6",
55
- "chai": "^4.3.4",
50
+ "@types/chai": "^4.3.5",
51
+ "@types/mocha": "^10.0.1",
52
+ "@types/mock-require": "^2.0.1",
53
+ "@types/sinon": "^10.0.15",
54
+ "chai": "^4.3.7",
56
55
  "codeclimate-test-reporter": "^0.5.1",
57
56
  "coveralls": "^3.1.1",
58
- "minimist": ">=1.2.2",
59
- "mocha": "^9.1.3",
57
+ "minimist": "^1.2.8",
58
+ "mocha": "^10.2.0",
60
59
  "mocha-lcov-reporter": "^1.3.0",
61
60
  "mock-require": "^3.0.3",
62
61
  "nyc": "^15.1.0",
63
- "open": "^8.4.0",
64
- "sinon": "^11.1.2",
65
- "source-map-support": "^0.5.20",
66
- "ts-node": "^10.4.0",
67
- "typedoc": "^0.22.7"
62
+ "open": "^9.1.0",
63
+ "sinon": "^15.0.4",
64
+ "source-map-support": "^0.5.21",
65
+ "ts-node": "^10.9.1",
66
+ "typedoc": "^0.24.7"
68
67
  },
69
68
  "main": "index.js",
70
69
  "typescript": {
package/src/IMQCache.js CHANGED
@@ -84,7 +84,7 @@ class IMQCache {
84
84
  : adapter.name];
85
85
  }
86
86
  }
87
- exports.IMQCache = IMQCache;
88
87
  IMQCache.options = {};
89
88
  IMQCache.adapters = {};
89
+ exports.IMQCache = IMQCache;
90
90
  //# sourceMappingURL=IMQCache.js.map
package/src/IMQDelay.js CHANGED
@@ -19,10 +19,6 @@ exports.IMQDelay = void 0;
19
19
  * PERFORMANCE OF THIS SOFTWARE.
20
20
  */
21
21
  class IMQDelay {
22
- constructor(timer, unit = 'ms') {
23
- this.timer = timer;
24
- this.unit = unit;
25
- }
26
22
  get ms() {
27
23
  switch (this.unit) {
28
24
  case 'ms': return this.timer;
@@ -32,6 +28,10 @@ class IMQDelay {
32
28
  case 'd': return this.timer * 86400000;
33
29
  }
34
30
  }
31
+ constructor(timer, unit = 'ms') {
32
+ this.timer = timer;
33
+ this.unit = unit;
34
+ }
35
35
  }
36
36
  exports.IMQDelay = IMQDelay;
37
37
  //# sourceMappingURL=IMQDelay.js.map
package/src/IMQLock.d.ts CHANGED
@@ -16,9 +16,9 @@
16
16
  * PERFORMANCE OF THIS SOFTWARE.
17
17
  */
18
18
  import { ILogger } from '@imqueue/core';
19
- export declare type AcquiredLock<T> = T | boolean;
20
- export declare type IMQLockTask = [(...args: any[]) => any, (...args: any[]) => any];
21
- export declare type IMQLockQueue = Array<IMQLockTask>;
19
+ export type AcquiredLock<T> = T | boolean;
20
+ export type IMQLockTask = [(...args: any[]) => any, (...args: any[]) => any];
21
+ export type IMQLockQueue = Array<IMQLockTask>;
22
22
  export interface IMQLockMetadataItem {
23
23
  className: string;
24
24
  methodName: string | symbol;
package/src/IMQLock.js CHANGED
@@ -147,7 +147,6 @@ class IMQLock {
147
147
  return !!IMQLock.acquiredLocks[key];
148
148
  }
149
149
  }
150
- exports.IMQLock = IMQLock;
151
150
  IMQLock.acquiredLocks = {};
152
151
  IMQLock.queues = {};
153
152
  IMQLock.metadata = {};
@@ -163,4 +162,5 @@ IMQLock.deadlockTimeout = 10000;
163
162
  * @type {ILogger}
164
163
  */
165
164
  IMQLock.logger = console;
165
+ exports.IMQLock = IMQLock;
166
166
  //# sourceMappingURL=IMQLock.js.map
@@ -20,7 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.IMQRPCDescription = void 0;
21
21
  class IMQRPCDescription {
22
22
  }
23
- exports.IMQRPCDescription = IMQRPCDescription;
24
23
  IMQRPCDescription.serviceDescription = {};
25
24
  IMQRPCDescription.typesDescription = {};
25
+ exports.IMQRPCDescription = IMQRPCDescription;
26
26
  //# sourceMappingURL=IMQRPCDescription.js.map
@@ -27,4 +27,4 @@ export interface ICache {
27
27
  del(key: string): Promise<boolean>;
28
28
  purge(keyMask: string): Promise<boolean>;
29
29
  }
30
- export declare type ICacheAdapter = ICacheConstructor | ICache | string;
30
+ export type ICacheAdapter = ICacheConstructor | ICache | string;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,13 +1,18 @@
1
+ export interface LockOptions {
2
+ disabled?: boolean;
3
+ skipArgs?: number[];
4
+ }
1
5
  /**
2
6
  * \@lock() decorator implementation
3
7
  * Will make all simultaneous similar method calls locked to be resolved with
4
8
  * the first obtained values. Similarity is identified by a bypassed method
5
9
  * argument values.
6
10
  *
11
+ * @param {boolean|LockOptions} enabledOrOptions - whether to enable locks or not
7
12
  * @return {(
8
13
  * target: any,
9
14
  * methodName: (string),
10
15
  * descriptor: TypedPropertyDescriptor<(...args: any[]) => any>
11
16
  * ) => void}
12
17
  */
13
- export declare function lock(enabled?: boolean): (target: any, methodName: string | symbol, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => void;
18
+ export declare function lock(enabledOrOptions?: boolean | LockOptions): (target: any, methodName: string | symbol, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => void;
@@ -25,14 +25,21 @@ const __1 = require("..");
25
25
  * the first obtained values. Similarity is identified by a bypassed method
26
26
  * argument values.
27
27
  *
28
+ * @param {boolean|LockOptions} enabledOrOptions - whether to enable locks or not
28
29
  * @return {(
29
30
  * target: any,
30
31
  * methodName: (string),
31
32
  * descriptor: TypedPropertyDescriptor<(...args: any[]) => any>
32
33
  * ) => void}
33
34
  */
34
- function lock(enabled = true) {
35
+ function lock(enabledOrOptions = true) {
35
36
  return function (target, methodName, descriptor) {
37
+ const enabled = typeof enabledOrOptions === 'boolean'
38
+ ? enabledOrOptions
39
+ : !enabledOrOptions.disabled;
40
+ const skipArgs = typeof enabledOrOptions === 'boolean'
41
+ ? undefined
42
+ : enabledOrOptions.skipArgs;
36
43
  const original = descriptor.value;
37
44
  const className = typeof target === 'function'
38
45
  ? target.name // static
@@ -42,7 +49,7 @@ function lock(enabled = true) {
42
49
  let lock;
43
50
  let sig = '';
44
51
  if (withLocks) {
45
- sig = (0, __1.signature)(className, methodName, args);
52
+ sig = (0, __1.signature)(className, methodName, skipArgs ? args.filter((_, index) => !~skipArgs.indexOf(index)) : args);
46
53
  lock = await __1.IMQLock.acquire(sig, undefined, {
47
54
  className,
48
55
  methodName,
@@ -16,7 +16,7 @@
16
16
  * PERFORMANCE OF THIS SOFTWARE.
17
17
  */
18
18
  import { ILogger } from '@imqueue/core';
19
- export declare type LoggedLogLevel = 'info' | 'log' | 'warn' | 'error';
19
+ export type LoggedLogLevel = 'info' | 'log' | 'warn' | 'error';
20
20
  export interface LoggedDecoratorOptions {
21
21
  level?: LoggedLogLevel;
22
22
  logger?: ILogger;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/src/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];