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 +7 -0
- package/cjs/RequestWrapper.js +38 -33
- package/cjs/environment.js +1 -1
- package/cjs/net/FetchClient.js +21 -14
- package/esm/RequestWrapper.js +38 -33
- package/esm/environment.js +1 -1
- package/esm/net/FetchClient.js +21 -14
- package/package.json +1 -1
- package/types/resources/Event.d.ts +1 -0
- package/types/resources/HostedPage.d.ts +1 -0
package/CHANGELOG.md
CHANGED
package/cjs/RequestWrapper.js
CHANGED
|
@@ -41,42 +41,47 @@ class RequestWrapper {
|
|
|
41
41
|
resolve(response);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
params
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
'
|
|
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
|
}
|
package/cjs/environment.js
CHANGED
|
@@ -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.
|
|
14
|
+
clientVersion: 'v3.2.1',
|
|
15
15
|
port: DEFAULT_PORT,
|
|
16
16
|
timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
|
|
17
17
|
exportWaitInMillis: DEFAULT_EXPORT_WAIT,
|
package/cjs/net/FetchClient.js
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
57
|
+
return Promise.reject(ClientInterface_js_1.HttpClient.timeOutError());
|
|
56
58
|
}
|
|
57
59
|
else {
|
|
58
|
-
|
|
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;
|
package/esm/RequestWrapper.js
CHANGED
|
@@ -38,42 +38,47 @@ export class RequestWrapper {
|
|
|
38
38
|
resolve(response);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
params
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
'
|
|
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
|
}
|
package/esm/environment.js
CHANGED
|
@@ -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.
|
|
11
|
+
clientVersion: 'v3.2.1',
|
|
12
12
|
port: DEFAULT_PORT,
|
|
13
13
|
timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
|
|
14
14
|
exportWaitInMillis: DEFAULT_EXPORT_WAIT,
|
package/esm/net/FetchClient.js
CHANGED
|
@@ -8,10 +8,15 @@ export class FetchHttpClient extends HttpClient {
|
|
|
8
8
|
headers: headers,
|
|
9
9
|
body: props.data ? props.data : undefined,
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
54
|
+
return Promise.reject(HttpClient.timeOutError());
|
|
53
55
|
}
|
|
54
56
|
else {
|
|
55
|
-
|
|
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