@rc-ex/rcsdk 1.2.0 → 1.2.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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # RingCentral SDK extension
2
2
 
3
- This extension makes [@ringcentral/sdk](https://www.npmjs.com/package/@ringcentral/sdk) the HTTP engine.
3
+ This extension makes
4
+ [@ringcentral/sdk](https://www.npmjs.com/package/@ringcentral/sdk) the HTTP
5
+ engine.
4
6
 
5
7
  ## Install
6
8
 
@@ -11,9 +13,9 @@ yarn add @rc-ex/rcsdk
11
13
  ## Usage
12
14
 
13
15
  ```ts
14
- import SDK from '@ringcentral/sdk';
15
- import RingCentral from '@rc-ex/core';
16
- import RcSdkExtension from '@rc-ex/rcsdk';
16
+ import SDK from "@ringcentral/sdk";
17
+ import RingCentral from "@rc-ex/core";
18
+ import RcSdkExtension from "@rc-ex/rcsdk";
17
19
 
18
20
  // @ringcentral/sdk
19
21
  const sdk = new SDK({ clientId, clientSecret, server });
@@ -28,19 +30,25 @@ await rc.installExtension(rcSdkExtension);
28
30
  const extensionInfo = await rc.restapi().account().extension().get();
29
31
  ```
30
32
 
31
- For a working sample, please check this [test case](../../../test/rcsdk-extension.spec.ts).
33
+ For a working sample, please check this
34
+ [test case](../../../test/rcsdk-extension.spec.ts).
32
35
 
33
36
  ## Known issues
34
37
 
35
- `multipart/form-data` does not work, because `@rc-ex/core` is originally designed for [axios](https://github.com/axios/axios).
36
- For such cases, please use `@ringcentral/sdk` directly, such as `await sdk.post('/restapi/v1.0/account/~/extension/~/fax', ...);`
38
+ `multipart/form-data` does not work, because `@rc-ex/core` is originally
39
+ designed for [axios](https://github.com/axios/axios). For such cases, please use
40
+ `@ringcentral/sdk` directly, such as
41
+ `await sdk.post('/restapi/v1.0/account/~/extension/~/fax', ...);`
37
42
 
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.
43
+ Some extensions don't work with this extension. For example, the Retry Extension
44
+ and RateLimit Extension because they rely on RestException object which
45
+ `@ringcentral/sdk` doesn't throw.
39
46
 
40
47
  ## Switch between @ringcentral/sdk and axios
41
48
 
42
- [axios][https://github.com/axios/axios] is the default HTTP engine.
43
- This extension makes `@ringcentral/sdk` as HTTP engine. to switch back to `axios`, just disable this extension:
49
+ [axios][https://github.com/axios/axios] is the default HTTP engine. This
50
+ extension makes `@ringcentral/sdk` as HTTP engine. to switch back to `axios`,
51
+ just disable this extension:
44
52
 
45
53
  ```ts
46
54
  // ringcentral-extensible + rcsdk extension
@@ -56,5 +64,6 @@ rcSdkExtension.disable();
56
64
  const extensionInfo2 = await rc.restapi().account().extension().get();
57
65
  ```
58
66
 
59
- Please note that by default `@ringcentral/sdk` and `axios` doesn't share tokens. You may need to manage tokens separately.
60
- Or you can make them share tokens explicitly by getting token from one and setting to the other.
67
+ Please note that by default `@ringcentral/sdk` and `axios` doesn't share tokens.
68
+ You may need to manage tokens separately. Or you can make them share tokens
69
+ explicitly by getting token from one and setting to the other.
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type RingCentral from '@rc-ex/core';
2
- import SdkExtension from '@rc-ex/core/lib/SdkExtension';
3
- import type SDK from '@ringcentral/sdk';
1
+ import type RingCentral from "@rc-ex/core";
2
+ import SdkExtension from "@rc-ex/core/lib/SdkExtension";
3
+ import type SDK from "@ringcentral/sdk";
4
4
  export interface RcSdkOptions {
5
5
  rcSdk: SDK;
6
6
  }
package/lib/index.js CHANGED
@@ -11,7 +11,7 @@ class RcSdkExtension extends SdkExtension_1.default {
11
11
  this.options = options;
12
12
  }
13
13
  async install(rc) {
14
- Object.defineProperty(rc, 'token', {
14
+ Object.defineProperty(rc, "token", {
15
15
  get: async () => this.options.rcSdk.platform().auth().data(),
16
16
  });
17
17
  const request = rc.request.bind(rc);
@@ -45,7 +45,6 @@ class RcSdkExtension extends SdkExtension_1.default {
45
45
  throw new RestException_1.default(response);
46
46
  };
47
47
  }
48
- // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function
49
48
  async revoke() { }
50
49
  }
51
50
  exports.default = RcSdkExtension;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
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,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE;SAC7D,CAAC,CAAC;QACH,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,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;gBACtC,MAAM;gBACN,GAAG,EAAE,QAAQ;gBACb,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,WAAW;gBAClB,OAAO,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO;aACzB,CAAC,CAAC;YACH,MAAM,QAAQ,GAAiB;gBAC7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gB,EAChB,MAA0B,EACA,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,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;gBACtC,MAAM;gBACN,GAAG,EAAE,QAAQ;gBACb,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,WAAW;gBAClB,OAAO,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO;aACzB,CAAC,CAAC;YACH,MAAM,QAAQ,GAAiB;gBAC7B,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE;gBACpB,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,OAAO,EAAE,CAAC,CAAC,OAA4C;gBACvD,MAAM,EAAE;oBACN,MAAM;oBACN,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACjC,GAAG,EAAE,QAAQ;oBACb,IAAI,EAAE,OAAO;oBACb,MAAM,EAAE,WAAW;iBACb;aACT,CAAC;YACF,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;gBACT,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,uBAAa,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC,CAAC;IACJ,CAAC;IAEM,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.2.0",
3
+ "version": "1.2.1",
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.5.0",
21
+ "@rc-ex/core": "^1.5.1",
22
22
  "@ringcentral/sdk": "^5.0.3"
23
23
  },
24
- "gitHead": "03fab0f9fc3d924054df16abd6854a5063e19829"
24
+ "gitHead": "1a8a5becc832b92af73f1ad1f58b87f38fee3650"
25
25
  }
package/src/index.ts CHANGED
@@ -1,8 +1,12 @@
1
- import type RingCentral from '@rc-ex/core';
2
- import type { RestRequestConfig, RestResponse, RestMethod } from '@rc-ex/core/lib/types';
3
- import SdkExtension from '@rc-ex/core/lib/SdkExtension';
4
- import RestException from '@rc-ex/core/lib/RestException';
5
- import type SDK from '@ringcentral/sdk';
1
+ import type RingCentral from "@rc-ex/core";
2
+ import type {
3
+ RestMethod,
4
+ RestRequestConfig,
5
+ RestResponse,
6
+ } from "@rc-ex/core/lib/types";
7
+ import SdkExtension from "@rc-ex/core/lib/SdkExtension";
8
+ import RestException from "@rc-ex/core/lib/RestException";
9
+ import type SDK from "@ringcentral/sdk";
6
10
 
7
11
  export interface RcSdkOptions {
8
12
  rcSdk: SDK;
@@ -17,7 +21,7 @@ class RcSdkExtension extends SdkExtension {
17
21
  }
18
22
 
19
23
  public async install(rc: RingCentral) {
20
- Object.defineProperty(rc, 'token', {
24
+ Object.defineProperty(rc, "token", {
21
25
  get: async () => this.options.rcSdk.platform().auth().data(),
22
26
  });
23
27
  const request = rc.request.bind(rc);
@@ -27,7 +31,6 @@ class RcSdkExtension extends SdkExtension {
27
31
  content?: {},
28
32
  queryParams?: {},
29
33
  config?: RestRequestConfig,
30
- // eslint-disable-next-line max-params
31
34
  ): Promise<RestResponse<T>> => {
32
35
  if (!this.enabled) {
33
36
  return request(method, endpoint, content, queryParams, config);
@@ -59,7 +62,6 @@ class RcSdkExtension extends SdkExtension {
59
62
  };
60
63
  }
61
64
 
62
- // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-empty-function
63
65
  public async revoke(): Promise<void> {}
64
66
  }
65
67