@rc-ex/debug 1.1.3 → 1.1.5
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 +1 -5
- package/lib/index.d.ts +3 -3
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +11 -20
package/README.md
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Provide debug mode for this SDK.
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
## Install
|
|
7
6
|
|
|
8
7
|
```
|
|
9
8
|
yarn add @rc-ex/debug
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
## Usage
|
|
14
12
|
|
|
15
13
|
```ts
|
|
@@ -84,12 +82,10 @@ Request:
|
|
|
84
82
|
|
|
85
83
|
For a working sample, please check this [test case](../../../test/debug-extension.spec.ts).
|
|
86
84
|
|
|
87
|
-
|
|
88
85
|
## loggingAction
|
|
89
86
|
|
|
90
87
|
Optionally, you can specify a `loggingAction` function to the extension constructor.
|
|
91
88
|
|
|
92
|
-
|
|
93
89
|
```ts
|
|
94
90
|
export type LoggingAction = (message: string) => void;
|
|
95
91
|
```
|
|
@@ -97,5 +93,5 @@ export type LoggingAction = (message: string) => void;
|
|
|
97
93
|
`loggingAction` determines how debug messages are logged. By default it is:
|
|
98
94
|
|
|
99
95
|
```ts
|
|
100
|
-
message => console.debug(message);
|
|
96
|
+
(message) => console.debug(message);
|
|
101
97
|
```
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import RingCentral from '@rc-ex/core';
|
|
1
|
+
import type RingCentral from '@rc-ex/core';
|
|
2
2
|
import SdkExtension from '@rc-ex/core/lib/SdkExtension';
|
|
3
|
-
export
|
|
3
|
+
export interface DebugOptions {
|
|
4
4
|
loggingAction?: (message: string) => void;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
declare class DebugExtension extends SdkExtension {
|
|
7
7
|
options: DebugOptions;
|
|
8
8
|
constructor(options?: DebugOptions);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAEA,kEAA0C;AAC1C,gFAAwD;AAMxD,MAAM,cAAe,SAAQ,sBAAY;IAGvC,YAAmB,UAAwB,EAAE;;;QAC3C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,sCAAsC;QACtC,YAAA,IAAI,CAAC,OAAO,EAAC,aAAa,uCAAb,aAAa,GAAK,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAC;IACrE,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,EAAe;QAClC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpC,EAAE,CAAC,OAAO,GAAG,KAAK,EAChB,MAAkB,EAClB,QAAgB,EAChB,OAAY,EACZ,WAAgB,EAChB,MAA0B,EAEA,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,OAAO,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,CAAC,GAAG,MAAM,OAAO,CAAI,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;YAC3E,IAAI,CAAC,OAAO,CAAC,aAAc,CAAC,eAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,OAAO,CAAC,CAAC;QACX,CAAC,CAAC;IACJ,CAAC;IAED,wFAAwF;IACjF,KAAK,CAAC,MAAM,KAAmB,CAAC;CACxC;AAED,kBAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-ex/debug",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Debug extension for ringcentral-extensible project",
|
|
5
5
|
"author": "Tyler Liu <tyler.liu@ringcentral.com>",
|
|
6
6
|
"homepage": "https://github.com/ringcentral/ringcentral-extensible/tree/master/packages/extensions/debug",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@rc-ex/core": "^1.3.
|
|
21
|
+
"@rc-ex/core": "^1.3.5"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "7b3b72e4d70ce3d45f21325d8bd31ded3d287626"
|
|
24
24
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import RingCentral from '@rc-ex/core';
|
|
2
|
-
import {
|
|
3
|
-
RestRequestConfig,
|
|
4
|
-
RestResponse,
|
|
5
|
-
RestMethod,
|
|
6
|
-
} from '@rc-ex/core/lib/types';
|
|
1
|
+
import type RingCentral from '@rc-ex/core';
|
|
2
|
+
import type { RestRequestConfig, RestResponse, RestMethod } from '@rc-ex/core/lib/types';
|
|
7
3
|
import Utils from '@rc-ex/core/lib/Utils';
|
|
8
4
|
import SdkExtension from '@rc-ex/core/lib/SdkExtension';
|
|
9
5
|
|
|
10
|
-
export
|
|
6
|
+
export interface DebugOptions {
|
|
11
7
|
loggingAction?: (message: string) => void;
|
|
12
|
-
}
|
|
8
|
+
}
|
|
13
9
|
|
|
14
10
|
class DebugExtension extends SdkExtension {
|
|
15
|
-
options: DebugOptions;
|
|
11
|
+
public options: DebugOptions;
|
|
16
12
|
|
|
17
|
-
constructor(options: DebugOptions = {}) {
|
|
13
|
+
public constructor(options: DebugOptions = {}) {
|
|
18
14
|
super();
|
|
19
15
|
this.options = options;
|
|
20
16
|
// eslint-disable-next-line no-console
|
|
21
17
|
this.options.loggingAction ??= (message) => console.debug(message);
|
|
22
18
|
}
|
|
23
19
|
|
|
24
|
-
async install(rc: RingCentral) {
|
|
20
|
+
public async install(rc: RingCentral) {
|
|
25
21
|
const request = rc.request.bind(rc);
|
|
26
22
|
rc.request = async <T>(
|
|
27
23
|
method: RestMethod,
|
|
@@ -29,24 +25,19 @@ class DebugExtension extends SdkExtension {
|
|
|
29
25
|
content?: {},
|
|
30
26
|
queryParams?: {},
|
|
31
27
|
config?: RestRequestConfig,
|
|
28
|
+
// eslint-disable-next-line max-params
|
|
32
29
|
): Promise<RestResponse<T>> => {
|
|
33
30
|
if (!this.enabled) {
|
|
34
|
-
return request
|
|
31
|
+
return request(method, endpoint, content, queryParams, config);
|
|
35
32
|
}
|
|
36
|
-
const r = await request<T>(
|
|
37
|
-
method,
|
|
38
|
-
endpoint,
|
|
39
|
-
content,
|
|
40
|
-
queryParams,
|
|
41
|
-
config,
|
|
42
|
-
);
|
|
33
|
+
const r = await request<T>(method, endpoint, content, queryParams, config);
|
|
43
34
|
this.options.loggingAction!(Utils.formatTraffic(r));
|
|
44
35
|
return r;
|
|
45
36
|
};
|
|
46
37
|
}
|
|
47
38
|
|
|
48
39
|
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function
|
|
49
|
-
async revoke(): Promise<void> {
|
|
40
|
+
public async revoke(): Promise<void> {}
|
|
50
41
|
}
|
|
51
42
|
|
|
52
43
|
export default DebugExtension;
|