chargebee 3.2.0 → 3.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### v3.2.1 (2024-12-04)
2
+ * * *
3
+
4
+ #### Bug Fixes
5
+ * unable to access content of HostedPage & Event (#57).
6
+ * uncaught promise in case of fetch failure (#58).
7
+
1
8
  ### v3.2.0 (2024-11-27)
2
9
  * * *
3
10
  #### New Resource:
@@ -41,42 +41,47 @@ class RequestWrapper {
41
41
  resolve(response);
42
42
  }
43
43
  }
44
- let path = (0, util_js_1.getApiURL)(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
45
- if (typeof params === 'undefined' || params === null) {
46
- params = {};
47
- }
48
- if (this.apiCall.httpMethod === 'GET') {
49
- params = (0, util_js_1.serialize)(params);
50
- let queryParam = this.apiCall.isListReq
51
- ? (0, util_js_1.encodeListParams)(params)
52
- : (0, util_js_1.encodeParams)(params);
53
- path += '?' + queryParam;
54
- params = {};
55
- }
56
- let data = (0, util_js_1.encodeParams)(params);
57
- if (data.length) {
44
+ try {
45
+ let path = (0, util_js_1.getApiURL)(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
46
+ if (typeof params === 'undefined' || params === null) {
47
+ params = {};
48
+ }
49
+ if (this.apiCall.httpMethod === 'GET') {
50
+ params = (0, util_js_1.serialize)(params);
51
+ let queryParam = this.apiCall.isListReq
52
+ ? (0, util_js_1.encodeListParams)(params)
53
+ : (0, util_js_1.encodeParams)(params);
54
+ path += '?' + queryParam;
55
+ params = {};
56
+ }
57
+ let data = (0, util_js_1.encodeParams)(params);
58
+ if (data.length) {
59
+ (0, util_js_1.extend)(true, this.httpHeaders, {
60
+ 'Content-Length': data.length,
61
+ });
62
+ }
58
63
  (0, util_js_1.extend)(true, this.httpHeaders, {
59
- 'Content-Length': data.length,
64
+ Authorization: 'Basic ' + node_buffer_1.Buffer.from(env.apiKey + ':').toString('base64'),
65
+ Accept: 'application/json',
66
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
67
+ 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
68
+ 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
69
+ });
70
+ const resp = await this.envArg.httpClient.makeApiRequest({
71
+ host: (0, util_js_1.getHost)(env),
72
+ port: env.port,
73
+ path,
74
+ method: this.apiCall.httpMethod,
75
+ protocol: env.protocol,
76
+ headers: this.httpHeaders,
77
+ data: data,
78
+ timeout: env.timeout,
60
79
  });
80
+ (0, coreCommon_js_1.handleResponse)(callBackWrapper, resp);
81
+ }
82
+ catch (err) {
83
+ callBackWrapper(err, null);
61
84
  }
62
- (0, util_js_1.extend)(true, this.httpHeaders, {
63
- Authorization: 'Basic ' + node_buffer_1.Buffer.from(env.apiKey + ':').toString('base64'),
64
- Accept: 'application/json',
65
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
66
- 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
67
- 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
68
- });
69
- const resp = await this.envArg.httpClient.makeApiRequest({
70
- host: (0, util_js_1.getHost)(env),
71
- port: env.port,
72
- path,
73
- method: this.apiCall.httpMethod,
74
- protocol: env.protocol,
75
- headers: this.httpHeaders,
76
- data: data,
77
- timeout: env.timeout,
78
- });
79
- (0, coreCommon_js_1.handleResponse)(callBackWrapper, resp);
80
85
  });
81
86
  return (0, util_js_1.callbackifyPromise)(promise);
82
87
  }
@@ -11,7 +11,7 @@ exports.Environment = {
11
11
  hostSuffix: '.chargebee.com',
12
12
  apiPath: '/api/v2',
13
13
  timeout: DEFAULT_TIME_OUT,
14
- clientVersion: 'v3.2.0',
14
+ clientVersion: 'v3.2.1',
15
15
  port: DEFAULT_PORT,
16
16
  timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
17
17
  exportWaitInMillis: DEFAULT_EXPORT_WAIT,
@@ -11,10 +11,15 @@ class FetchHttpClient extends ClientInterface_js_1.HttpClient {
11
11
  headers: headers,
12
12
  body: props.data ? props.data : undefined,
13
13
  };
14
- const response = globalThis.AbortController
15
- ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
16
- : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
17
- return new FetchHttpClientResponse(response);
14
+ try {
15
+ const response = globalThis.AbortController
16
+ ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
17
+ : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
18
+ return new FetchHttpClientResponse(response);
19
+ }
20
+ catch (err) {
21
+ return Promise.reject(err);
22
+ }
18
23
  }
19
24
  _createHeaders(httpHeaders) {
20
25
  const headers = new Headers();
@@ -44,20 +49,22 @@ class FetchHttpClient extends ClientInterface_js_1.HttpClient {
44
49
  timeoutId = null;
45
50
  abort.abort(ClientInterface_js_1.HttpClient.timeOutError());
46
51
  }, timeout);
47
- const fetchPromise = fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
48
- fetchPromise.finally(() => {
49
- if (timeoutId) {
50
- clearTimeout(timeoutId);
51
- }
52
- });
53
- return fetchPromise.catch((err) => {
52
+ try {
53
+ return await fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
54
+ }
55
+ catch (err) {
54
56
  if (err.name === 'AbortError') {
55
- throw ClientInterface_js_1.HttpClient.timeOutError();
57
+ return Promise.reject(ClientInterface_js_1.HttpClient.timeOutError());
56
58
  }
57
59
  else {
58
- throw err;
60
+ return Promise.reject(err);
59
61
  }
60
- });
62
+ }
63
+ finally {
64
+ if (timeoutId) {
65
+ clearTimeout(timeoutId);
66
+ }
67
+ }
61
68
  }
62
69
  }
63
70
  exports.FetchHttpClient = FetchHttpClient;
@@ -38,42 +38,47 @@ export class RequestWrapper {
38
38
  resolve(response);
39
39
  }
40
40
  }
41
- let path = getApiURL(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
42
- if (typeof params === 'undefined' || params === null) {
43
- params = {};
44
- }
45
- if (this.apiCall.httpMethod === 'GET') {
46
- params = serialize(params);
47
- let queryParam = this.apiCall.isListReq
48
- ? encodeListParams(params)
49
- : encodeParams(params);
50
- path += '?' + queryParam;
51
- params = {};
52
- }
53
- let data = encodeParams(params);
54
- if (data.length) {
41
+ try {
42
+ let path = getApiURL(env, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam);
43
+ if (typeof params === 'undefined' || params === null) {
44
+ params = {};
45
+ }
46
+ if (this.apiCall.httpMethod === 'GET') {
47
+ params = serialize(params);
48
+ let queryParam = this.apiCall.isListReq
49
+ ? encodeListParams(params)
50
+ : encodeParams(params);
51
+ path += '?' + queryParam;
52
+ params = {};
53
+ }
54
+ let data = encodeParams(params);
55
+ if (data.length) {
56
+ extend(true, this.httpHeaders, {
57
+ 'Content-Length': data.length,
58
+ });
59
+ }
55
60
  extend(true, this.httpHeaders, {
56
- 'Content-Length': data.length,
61
+ Authorization: 'Basic ' + Buffer.from(env.apiKey + ':').toString('base64'),
62
+ Accept: 'application/json',
63
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
64
+ 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
65
+ 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
66
+ });
67
+ const resp = await this.envArg.httpClient.makeApiRequest({
68
+ host: getHost(env),
69
+ port: env.port,
70
+ path,
71
+ method: this.apiCall.httpMethod,
72
+ protocol: env.protocol,
73
+ headers: this.httpHeaders,
74
+ data: data,
75
+ timeout: env.timeout,
57
76
  });
77
+ handleResponse(callBackWrapper, resp);
78
+ }
79
+ catch (err) {
80
+ callBackWrapper(err, null);
58
81
  }
59
- extend(true, this.httpHeaders, {
60
- Authorization: 'Basic ' + Buffer.from(env.apiKey + ':').toString('base64'),
61
- Accept: 'application/json',
62
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
63
- 'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
64
- 'Lang-Version': typeof process === 'undefined' ? '' : process.version,
65
- });
66
- const resp = await this.envArg.httpClient.makeApiRequest({
67
- host: getHost(env),
68
- port: env.port,
69
- path,
70
- method: this.apiCall.httpMethod,
71
- protocol: env.protocol,
72
- headers: this.httpHeaders,
73
- data: data,
74
- timeout: env.timeout,
75
- });
76
- handleResponse(callBackWrapper, resp);
77
82
  });
78
83
  return callbackifyPromise(promise);
79
84
  }
@@ -8,7 +8,7 @@ export const Environment = {
8
8
  hostSuffix: '.chargebee.com',
9
9
  apiPath: '/api/v2',
10
10
  timeout: DEFAULT_TIME_OUT,
11
- clientVersion: 'v3.2.0',
11
+ clientVersion: 'v3.2.1',
12
12
  port: DEFAULT_PORT,
13
13
  timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
14
14
  exportWaitInMillis: DEFAULT_EXPORT_WAIT,
@@ -8,10 +8,15 @@ export class FetchHttpClient extends HttpClient {
8
8
  headers: headers,
9
9
  body: props.data ? props.data : undefined,
10
10
  };
11
- const response = globalThis.AbortController
12
- ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
13
- : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
14
- return new FetchHttpClientResponse(response);
11
+ try {
12
+ const response = globalThis.AbortController
13
+ ? await this.fetchWithAbortTimeout(url, fetchOptions, props.timeout)
14
+ : await this.fetchWithTimeout(url, fetchOptions, props.timeout);
15
+ return new FetchHttpClientResponse(response);
16
+ }
17
+ catch (err) {
18
+ return Promise.reject(err);
19
+ }
15
20
  }
16
21
  _createHeaders(httpHeaders) {
17
22
  const headers = new Headers();
@@ -41,20 +46,22 @@ export class FetchHttpClient extends HttpClient {
41
46
  timeoutId = null;
42
47
  abort.abort(HttpClient.timeOutError());
43
48
  }, timeout);
44
- const fetchPromise = fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
45
- fetchPromise.finally(() => {
46
- if (timeoutId) {
47
- clearTimeout(timeoutId);
48
- }
49
- });
50
- return fetchPromise.catch((err) => {
49
+ try {
50
+ return await fetch(url, Object.assign(Object.assign({}, fetchOptions), { signal: abort.signal }));
51
+ }
52
+ catch (err) {
51
53
  if (err.name === 'AbortError') {
52
- throw HttpClient.timeOutError();
54
+ return Promise.reject(HttpClient.timeOutError());
53
55
  }
54
56
  else {
55
- throw err;
57
+ return Promise.reject(err);
56
58
  }
57
- });
59
+ }
60
+ finally {
61
+ if (timeoutId) {
62
+ clearTimeout(timeoutId);
63
+ }
64
+ }
58
65
  }
59
66
  }
60
67
  export class FetchHttpClientResponse extends HttpClientResponse {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chargebee",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "A library for integrating with Chargebee.",
5
5
  "scripts": {
6
6
  "prepack": "npm install && npm run build",
@@ -19,6 +19,7 @@ declare module 'chargebee' {
19
19
  webhooks?: Event.Webhook[];
20
20
  event_type?: EventTypeEnum;
21
21
  api_version?: ApiVersionEnum;
22
+ content: any;
22
23
  origin_user?: string;
23
24
  }
24
25
 
@@ -28,6 +28,7 @@ declare module 'chargebee' {
28
28
  embed: boolean;
29
29
  created_at?: number;
30
30
  expires_at?: number;
31
+ content: any;
31
32
  updated_at?: number;
32
33
  resource_version?: number;
33
34
  checkout_info?: any;