@rc-ex/rcsdk 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 +3 -7
- package/lib/index.d.ts +4 -4
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +11 -14
package/README.md
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
This extension makes [@ringcentral/sdk](https://www.npmjs.com/package/@ringcentral/sdk) the HTTP engine.
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
## Install
|
|
7
6
|
|
|
8
7
|
```
|
|
9
8
|
yarn add @rc-ex/rcsdk
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
## Usage
|
|
14
12
|
|
|
15
13
|
```ts
|
|
@@ -18,12 +16,12 @@ import RingCentral from '@rc-ex/core';
|
|
|
18
16
|
import RcSdkExtension from '@rc-ex/rcsdk';
|
|
19
17
|
|
|
20
18
|
// @ringcentral/sdk
|
|
21
|
-
const sdk = new SDK({clientId, clientSecret, server});
|
|
22
|
-
await sdk.login({username, extension, password});
|
|
19
|
+
const sdk = new SDK({ clientId, clientSecret, server });
|
|
20
|
+
await sdk.login({ username, extension, password });
|
|
23
21
|
|
|
24
22
|
// ringcentral-extensible + rcsdk extension
|
|
25
23
|
const rc = new RingCentral();
|
|
26
|
-
const rcSdkExtension = new RcSdkExtension({rcSdk: sdk});
|
|
24
|
+
const rcSdkExtension = new RcSdkExtension({ rcSdk: sdk });
|
|
27
25
|
await rc.installExtension(rcSdkExtension);
|
|
28
26
|
|
|
29
27
|
// API call with @ringcentral/sdk as HTTP engine
|
|
@@ -32,7 +30,6 @@ const extensionInfo = await rc.restapi().account().extension().get();
|
|
|
32
30
|
|
|
33
31
|
For a working sample, please check this [test case](../../../test/rcsdk-extension.spec.ts).
|
|
34
32
|
|
|
35
|
-
|
|
36
33
|
## Known issues
|
|
37
34
|
|
|
38
35
|
`multipart/form-data` does not work, because `@rc-ex/core` is originally designed for [axios](https://github.com/axios/axios).
|
|
@@ -40,7 +37,6 @@ For such cases, please use `@ringcentral/sdk` directly, such as `await sdk.post(
|
|
|
40
37
|
|
|
41
38
|
Some extensions don't work with this extension. For example, the Retry Extension and RateLimit Extension because they rely on RestException object which `@ringcentral/sdk` doesn't throw.
|
|
42
39
|
|
|
43
|
-
|
|
44
40
|
## Switch between @ringcentral/sdk and axios
|
|
45
41
|
|
|
46
42
|
[axios][https://github.com/axios/axios] is the default HTTP engine.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
import SDK from '@ringcentral/sdk';
|
|
4
|
-
export
|
|
3
|
+
import type SDK from '@ringcentral/sdk';
|
|
4
|
+
export interface RcSdkOptions {
|
|
5
5
|
rcSdk: SDK;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
declare class RcSdkExtension extends SdkExtension {
|
|
8
8
|
options: RcSdkOptions;
|
|
9
9
|
constructor(options: RcSdkOptions);
|
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,gFAAwD;AACxD,kFAA0D;AAO1D,MAAM,cAAe,SAAQ,sBAAY;IAGvC,YAAmB,OAAqB;QACtC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,EAAe;QAClC,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE;YACjC,GAAG,EAAE,KAAK,IAAI,EA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,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/rcsdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "@ringcentral/sdk 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/rcsdk",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@rc-ex/core": "^1.3.
|
|
22
|
-
"@ringcentral/sdk": "^5.0.
|
|
21
|
+
"@rc-ex/core": "^1.3.5",
|
|
22
|
+
"@ringcentral/sdk": "^5.0.1"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "7b3b72e4d70ce3d45f21325d8bd31ded3d287626"
|
|
25
25
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
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 SdkExtension from '@rc-ex/core/lib/SdkExtension';
|
|
8
4
|
import RestException from '@rc-ex/core/lib/RestException';
|
|
9
|
-
import SDK from '@ringcentral/sdk';
|
|
5
|
+
import type SDK from '@ringcentral/sdk';
|
|
10
6
|
|
|
11
|
-
export
|
|
7
|
+
export interface RcSdkOptions {
|
|
12
8
|
rcSdk: SDK;
|
|
13
|
-
}
|
|
9
|
+
}
|
|
14
10
|
|
|
15
11
|
class RcSdkExtension extends SdkExtension {
|
|
16
|
-
options: RcSdkOptions;
|
|
12
|
+
public options: RcSdkOptions;
|
|
17
13
|
|
|
18
|
-
constructor(options: RcSdkOptions) {
|
|
14
|
+
public constructor(options: RcSdkOptions) {
|
|
19
15
|
super();
|
|
20
16
|
this.options = options;
|
|
21
17
|
}
|
|
22
18
|
|
|
23
|
-
async install(rc: RingCentral) {
|
|
19
|
+
public async install(rc: RingCentral) {
|
|
24
20
|
Object.defineProperty(rc, 'token', {
|
|
25
21
|
get: async () => this.options.rcSdk.platform().auth().data(),
|
|
26
22
|
});
|
|
@@ -31,9 +27,10 @@ class RcSdkExtension extends SdkExtension {
|
|
|
31
27
|
content?: {},
|
|
32
28
|
queryParams?: {},
|
|
33
29
|
config?: RestRequestConfig,
|
|
30
|
+
// eslint-disable-next-line max-params
|
|
34
31
|
): Promise<RestResponse<T>> => {
|
|
35
32
|
if (!this.enabled) {
|
|
36
|
-
return request
|
|
33
|
+
return request(method, endpoint, content, queryParams, config);
|
|
37
34
|
}
|
|
38
35
|
const r = await this.options.rcSdk.send({
|
|
39
36
|
method,
|
|
@@ -63,7 +60,7 @@ class RcSdkExtension extends SdkExtension {
|
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function
|
|
66
|
-
async revoke(): Promise<void> {
|
|
63
|
+
public async revoke(): Promise<void> {}
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
export default RcSdkExtension;
|