chargebee 2.40.0 → 3.0.0-beta.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 +10 -1
- package/LICENSE +1 -1
- package/README.md +90 -172
- package/cjs/RequestWrapper.js +81 -0
- package/cjs/asyncApiSupport.js +39 -0
- package/cjs/chargebee.cjs.js +13 -0
- package/cjs/chargebee.cjs.worker.js +9 -0
- package/cjs/chargebeeError.js +17 -0
- package/cjs/coreCommon.js +72 -0
- package/cjs/createChargebee.js +92 -0
- package/cjs/environment.js +18 -0
- package/cjs/filter.js +1 -0
- package/cjs/net/ClientInterface.js +40 -0
- package/cjs/net/FetchClient.js +86 -0
- package/cjs/net/NodeClient.js +61 -0
- package/cjs/package.json +1 -0
- package/cjs/resources/api_endpoints.js +1086 -0
- package/cjs/util.js +218 -0
- package/esm/RequestWrapper.js +77 -0
- package/esm/asyncApiSupport.js +35 -0
- package/esm/chargebee.esm.js +9 -0
- package/esm/chargebee.esm.worker.js +5 -0
- package/esm/chargebeeError.js +13 -0
- package/esm/coreCommon.js +67 -0
- package/esm/createChargebee.js +88 -0
- package/esm/environment.js +15 -0
- package/esm/filter.js +1 -0
- package/esm/net/ClientInterface.js +35 -0
- package/esm/net/FetchClient.js +81 -0
- package/esm/net/NodeClient.js +56 -0
- package/esm/package.json +1 -0
- package/esm/resources/api_endpoints.js +1083 -0
- package/esm/util.js +202 -0
- package/package.json +69 -38
- package/types/core.d.ts +558 -89
- package/types/index.d.ts +91 -54
- package/types/resources/Address.d.ts +57 -272
- package/types/resources/AdvanceInvoiceSchedule.d.ts +21 -94
- package/types/resources/AttachedItem.d.ts +91 -329
- package/types/resources/Attribute.d.ts +5 -5
- package/types/resources/BusinessEntity.d.ts +49 -69
- package/types/resources/BusinessEntityTransfer.d.ts +11 -17
- package/types/resources/Card.d.ts +146 -424
- package/types/resources/Comment.d.ts +72 -189
- package/types/resources/Contact.d.ts +12 -64
- package/types/resources/ContractTerm.d.ts +15 -96
- package/types/resources/Coupon.d.ts +282 -758
- package/types/resources/CouponCode.d.ts +56 -52
- package/types/resources/CouponSet.d.ts +92 -234
- package/types/resources/CreditNote.d.ts +588 -1758
- package/types/resources/CreditNoteEstimate.d.ts +131 -157
- package/types/resources/Currency.d.ts +75 -62
- package/types/resources/Customer.d.ts +892 -835
- package/types/resources/CustomerEntitlement.d.ts +36 -0
- package/types/resources/DifferentialPrice.d.ts +116 -314
- package/types/resources/Discount.d.ts +20 -125
- package/types/resources/Download.d.ts +6 -22
- package/types/resources/Entitlement.d.ts +51 -160
- package/types/resources/EntitlementOverride.d.ts +58 -139
- package/types/resources/Estimate.d.ts +1178 -527
- package/types/resources/Event.d.ts +67 -178
- package/types/resources/Export.d.ts +563 -723
- package/types/resources/Feature.d.ts +117 -433
- package/types/resources/GatewayErrorDetail.d.ts +16 -72
- package/types/resources/Gift.d.ts +265 -432
- package/types/resources/Hierarchy.d.ts +8 -36
- package/types/resources/HostedPage.d.ts +1017 -1153
- package/types/resources/ImpactedItem.d.ts +13 -50
- package/types/resources/ImpactedItemPrice.d.ts +13 -15
- package/types/resources/ImpactedSubscription.d.ts +13 -45
- package/types/resources/InAppSubscription.d.ts +93 -389
- package/types/resources/Installment.d.ts +35 -110
- package/types/resources/InstallmentConfig.d.ts +54 -155
- package/types/resources/InstallmentDetail.d.ts +19 -27
- package/types/resources/Invoice.d.ts +1574 -3157
- package/types/resources/InvoiceEstimate.d.ts +131 -161
- package/types/resources/Item.d.ts +133 -611
- package/types/resources/ItemEntitlement.d.ts +78 -215
- package/types/resources/ItemFamily.d.ts +69 -178
- package/types/resources/ItemPrice.d.ts +291 -1203
- package/types/resources/Metadata.d.ts +3 -5
- package/types/resources/Order.d.ts +538 -1471
- package/types/resources/PaymentIntent.d.ts +163 -347
- package/types/resources/PaymentReferenceNumber.d.ts +7 -29
- package/types/resources/PaymentSource.d.ts +476 -1272
- package/types/resources/PaymentVoucher.d.ts +87 -306
- package/types/resources/PortalSession.d.ts +71 -207
- package/types/resources/PriceVariant.d.ts +91 -279
- package/types/resources/PricingPageSession.d.ts +92 -41
- package/types/resources/PromotionalCredit.d.ts +90 -346
- package/types/resources/Purchase.d.ts +185 -315
- package/types/resources/Quote.d.ts +1406 -887
- package/types/resources/QuoteLineGroup.d.ts +125 -452
- package/types/resources/QuotedCharge.d.ts +45 -274
- package/types/resources/QuotedSubscription.d.ts +100 -488
- package/types/resources/Ramp.d.ts +233 -724
- package/types/resources/ResourceMigration.d.ts +25 -80
- package/types/resources/SiteMigrationDetail.d.ts +34 -112
- package/types/resources/Subscription.d.ts +2390 -4335
- package/types/resources/SubscriptionEntitlement.d.ts +59 -160
- package/types/resources/SubscriptionEstimate.d.ts +51 -75
- package/types/resources/TaxWithheld.d.ts +15 -40
- package/types/resources/ThirdPartyPaymentMethod.d.ts +7 -29
- package/types/resources/TimeMachine.d.ts +43 -97
- package/types/resources/Token.d.ts +15 -85
- package/types/resources/Transaction.d.ts +278 -900
- package/types/resources/UnbilledCharge.d.ts +189 -164
- package/types/resources/Usage.d.ts +89 -279
- package/types/resources/VirtualBankAccount.d.ts +103 -255
- package/types/resources/filter.d.ts +52 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -81
- package/.github/ISSUE_TEMPLATE/config.yml +0 -6
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -34
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
- package/lib/chargebee.js +0 -512
- package/lib/resources/api_endpoints.js +0 -2912
- package/types/resources/NonSubscription.d.ts +0 -30
- package/types/resources/Session.d.ts +0 -41
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Environment = void 0;
|
|
4
|
+
const DEFAULT_PROTOCOL = 'https';
|
|
5
|
+
const DEFAULT_TIME_OUT = 80000;
|
|
6
|
+
const DEFAULT_PORT = 443;
|
|
7
|
+
const DEFAULT_TIME_MACHINE_WAIT = 3000;
|
|
8
|
+
const DEFAULT_EXPORT_WAIT = 3000;
|
|
9
|
+
exports.Environment = {
|
|
10
|
+
protocol: DEFAULT_PROTOCOL,
|
|
11
|
+
hostSuffix: '.chargebee.com',
|
|
12
|
+
apiPath: '/api/v2',
|
|
13
|
+
timeout: DEFAULT_TIME_OUT,
|
|
14
|
+
clientVersion: 'v3.0.0-beta.1',
|
|
15
|
+
port: DEFAULT_PORT,
|
|
16
|
+
timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
|
|
17
|
+
exportWaitInMillis: DEFAULT_EXPORT_WAIT,
|
|
18
|
+
};
|
package/cjs/filter.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClientResponse = exports.HttpClient = void 0;
|
|
4
|
+
const chargebeeError_js_1 = require("../chargebeeError.js");
|
|
5
|
+
class HttpClient {
|
|
6
|
+
async makeApiRequest(props) {
|
|
7
|
+
throw new Error('makeApiRequest is not implemented');
|
|
8
|
+
}
|
|
9
|
+
static timeOutError() {
|
|
10
|
+
const error = new chargebeeError_js_1.ChargebeeError({
|
|
11
|
+
message: 'io_error',
|
|
12
|
+
type: 'timeout',
|
|
13
|
+
api_error_code: 'request aborted due to timeout.',
|
|
14
|
+
http_status_code: 504,
|
|
15
|
+
http_code: 504,
|
|
16
|
+
error_code: 'request aborted due to timeout.',
|
|
17
|
+
}, null);
|
|
18
|
+
return error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.HttpClient = HttpClient;
|
|
22
|
+
class HttpClientResponse {
|
|
23
|
+
constructor(statusCode, headers) {
|
|
24
|
+
this._statusCode = statusCode;
|
|
25
|
+
this._headers = headers;
|
|
26
|
+
}
|
|
27
|
+
getStatusCode() {
|
|
28
|
+
return this._statusCode;
|
|
29
|
+
}
|
|
30
|
+
getHeaders() {
|
|
31
|
+
return this._headers;
|
|
32
|
+
}
|
|
33
|
+
getRawResponse() {
|
|
34
|
+
throw new Error('getRawResponse not implemented.');
|
|
35
|
+
}
|
|
36
|
+
toJson() {
|
|
37
|
+
throw new Error('toJSON not implemented.');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.HttpClientResponse = HttpClientResponse;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FetchHttpClientResponse = exports.FetchHttpClient = void 0;
|
|
4
|
+
const ClientInterface_js_1 = require("./ClientInterface.js");
|
|
5
|
+
class FetchHttpClient extends ClientInterface_js_1.HttpClient {
|
|
6
|
+
async makeApiRequest(props) {
|
|
7
|
+
const headers = this._createHeaders(props.headers);
|
|
8
|
+
let url = `${props.protocol}://${props.host}:${props.port}${props.path}`;
|
|
9
|
+
let fetchOptions = {
|
|
10
|
+
method: props.method,
|
|
11
|
+
headers: headers,
|
|
12
|
+
body: props.data ? props.data : undefined,
|
|
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);
|
|
18
|
+
}
|
|
19
|
+
_createHeaders(httpHeaders) {
|
|
20
|
+
const headers = new Headers();
|
|
21
|
+
Object.entries(httpHeaders).forEach(([key, value]) => {
|
|
22
|
+
headers.append(key, String(value));
|
|
23
|
+
});
|
|
24
|
+
return headers;
|
|
25
|
+
}
|
|
26
|
+
async fetchWithTimeout(url, fetchOptions, timeout) {
|
|
27
|
+
let pendingTimeoutId;
|
|
28
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
29
|
+
pendingTimeoutId = setTimeout(() => {
|
|
30
|
+
pendingTimeoutId = null;
|
|
31
|
+
reject(ClientInterface_js_1.HttpClient.timeOutError());
|
|
32
|
+
}, timeout);
|
|
33
|
+
});
|
|
34
|
+
const fetchPromise = fetch(url, fetchOptions);
|
|
35
|
+
return Promise.race([fetchPromise, timeoutPromise]).finally(() => {
|
|
36
|
+
if (pendingTimeoutId) {
|
|
37
|
+
clearTimeout(pendingTimeoutId);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async fetchWithAbortTimeout(url, fetchOptions, timeout) {
|
|
42
|
+
const abort = new AbortController();
|
|
43
|
+
let timeoutId = setTimeout(() => {
|
|
44
|
+
timeoutId = null;
|
|
45
|
+
abort.abort(ClientInterface_js_1.HttpClient.timeOutError());
|
|
46
|
+
}, 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) => {
|
|
54
|
+
if (err.name === 'AbortError') {
|
|
55
|
+
throw ClientInterface_js_1.HttpClient.timeOutError();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.FetchHttpClient = FetchHttpClient;
|
|
64
|
+
class FetchHttpClientResponse extends ClientInterface_js_1.HttpClientResponse {
|
|
65
|
+
constructor(response) {
|
|
66
|
+
super(response.status, FetchHttpClientResponse._transformHeadersToObject(response.headers));
|
|
67
|
+
this._res = response;
|
|
68
|
+
}
|
|
69
|
+
getRawResponse() {
|
|
70
|
+
return this._res;
|
|
71
|
+
}
|
|
72
|
+
toJson() {
|
|
73
|
+
return this._res.json();
|
|
74
|
+
}
|
|
75
|
+
static _transformHeadersToObject(headers) {
|
|
76
|
+
const headersObj = {};
|
|
77
|
+
for (const entry of headers) {
|
|
78
|
+
if (!Array.isArray(entry) || entry.length != 2) {
|
|
79
|
+
throw new Error('Headers should be an iterable object.');
|
|
80
|
+
}
|
|
81
|
+
headersObj[entry[0]] = entry[1];
|
|
82
|
+
}
|
|
83
|
+
return headersObj;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.FetchHttpClientResponse = FetchHttpClientResponse;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeHttpClientResponse = exports.NodeHttpClient = void 0;
|
|
4
|
+
const ClientInterface_js_1 = require("./ClientInterface.js");
|
|
5
|
+
const http = require("http");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
class NodeHttpClient extends ClientInterface_js_1.HttpClient {
|
|
8
|
+
async makeApiRequest(props) {
|
|
9
|
+
const protocol = props.protocol === 'http' ? http : https;
|
|
10
|
+
const requestPromise = new Promise((resolve, reject) => {
|
|
11
|
+
const req = protocol.request({
|
|
12
|
+
hostname: props.host,
|
|
13
|
+
path: props.path,
|
|
14
|
+
method: props.method,
|
|
15
|
+
port: props.port,
|
|
16
|
+
headers: props.headers,
|
|
17
|
+
});
|
|
18
|
+
req.setTimeout(props.timeout, () => {
|
|
19
|
+
throw ClientInterface_js_1.HttpClient.timeOutError();
|
|
20
|
+
});
|
|
21
|
+
req.on('response', (res) => {
|
|
22
|
+
resolve(new NodeHttpClientResponse(res));
|
|
23
|
+
});
|
|
24
|
+
req.on('error', (error) => {
|
|
25
|
+
reject(error);
|
|
26
|
+
});
|
|
27
|
+
req.write(props.data);
|
|
28
|
+
req.end();
|
|
29
|
+
});
|
|
30
|
+
return requestPromise;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.NodeHttpClient = NodeHttpClient;
|
|
34
|
+
class NodeHttpClientResponse extends ClientInterface_js_1.HttpClientResponse {
|
|
35
|
+
constructor(res) {
|
|
36
|
+
//@ts-ignore
|
|
37
|
+
super(res.statusCode, res.headers);
|
|
38
|
+
this._res = res;
|
|
39
|
+
}
|
|
40
|
+
getRawResponse() {
|
|
41
|
+
return this._res;
|
|
42
|
+
}
|
|
43
|
+
toJson() {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
let response = '';
|
|
46
|
+
this._res.setEncoding('utf8');
|
|
47
|
+
this._res.on('data', (chunk) => {
|
|
48
|
+
response += chunk;
|
|
49
|
+
});
|
|
50
|
+
this._res.once('end', () => {
|
|
51
|
+
try {
|
|
52
|
+
resolve(JSON.parse(response));
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
reject(e);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.NodeHttpClientResponse = NodeHttpClientResponse;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|