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
package/esm/util.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
export const extend = (deep, target, copy) => {
|
|
2
|
+
_extendsFn(deep, target, copy);
|
|
3
|
+
};
|
|
4
|
+
const _extendsFn = (...args) => {
|
|
5
|
+
{
|
|
6
|
+
let options, name, src, copy, copyIsArray, clone, target = args[0] || {}, i = 1, length = args.length, deep = false;
|
|
7
|
+
if (typeof target === 'boolean') {
|
|
8
|
+
deep = target;
|
|
9
|
+
target = args[1] || {};
|
|
10
|
+
i = 2;
|
|
11
|
+
}
|
|
12
|
+
if (typeof target !== 'object' && typeof target !== 'function') {
|
|
13
|
+
target = {};
|
|
14
|
+
}
|
|
15
|
+
if (length === i) {
|
|
16
|
+
target = this;
|
|
17
|
+
--i;
|
|
18
|
+
}
|
|
19
|
+
for (; i < length; i++) {
|
|
20
|
+
if ((options = args[i]) !== null) {
|
|
21
|
+
for (name in options) {
|
|
22
|
+
src = target[name];
|
|
23
|
+
copy = options[name];
|
|
24
|
+
if (target === copy) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (deep &&
|
|
28
|
+
copy &&
|
|
29
|
+
(typeof copy === 'object' || (copyIsArray = isArray(copy)))) {
|
|
30
|
+
if (copyIsArray) {
|
|
31
|
+
copyIsArray = false;
|
|
32
|
+
clone = src && isArray(src) ? src : [];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
clone = src && typeof src === 'object' ? src : {};
|
|
36
|
+
}
|
|
37
|
+
target[name] = extend(deep, clone, copy);
|
|
38
|
+
}
|
|
39
|
+
else if (copy !== undefined) {
|
|
40
|
+
target[name] = copy;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export const isArray = (obj) => {
|
|
49
|
+
return (Array.isArray(obj) ||
|
|
50
|
+
Object.prototype.toString.call(obj) === '[object Array]');
|
|
51
|
+
};
|
|
52
|
+
export const isObject = (obj) => {
|
|
53
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
54
|
+
};
|
|
55
|
+
// const indexOf = (array, item) => {
|
|
56
|
+
// if (![].indexOf(undefined)) {
|
|
57
|
+
// for (let i = 0; i < array.length; i++) {
|
|
58
|
+
// if (array[i] === item) {
|
|
59
|
+
// return i;
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
// return -1;
|
|
63
|
+
// } else {
|
|
64
|
+
// return array.indexOf(item);
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
export const trim = (str) => {
|
|
68
|
+
return str !== '' ? str : str.replace(/^\s+|\s+$/g, '');
|
|
69
|
+
};
|
|
70
|
+
const isEmptyObject = (obj) => {
|
|
71
|
+
let name;
|
|
72
|
+
for (name in obj) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
export const isNotUndefinedNEmpty = (obj) => {
|
|
78
|
+
if (typeof obj !== 'undefined' && !isEmptyObject(obj)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
};
|
|
83
|
+
export const isFunction = (obj) => {
|
|
84
|
+
return typeof obj === 'function';
|
|
85
|
+
};
|
|
86
|
+
export const sleep = (milliseconds) => {
|
|
87
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
88
|
+
};
|
|
89
|
+
export function callbackifyPromise(promise, callback) {
|
|
90
|
+
if (callback) {
|
|
91
|
+
return promise.then((res) => {
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
callback(null, res);
|
|
94
|
+
}, 0);
|
|
95
|
+
}, (err) => {
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
callback(err, null);
|
|
98
|
+
}, 0);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return promise;
|
|
102
|
+
}
|
|
103
|
+
export function getApiURL(env, urlPrefix, urlSuffix, urlIdParam) {
|
|
104
|
+
if (typeof env.apiKey === 'undefined' || typeof env.site === 'undefined') {
|
|
105
|
+
throw new Error('Your site or api key is not configured.');
|
|
106
|
+
}
|
|
107
|
+
return (env.apiPath +
|
|
108
|
+
urlPrefix +
|
|
109
|
+
(urlIdParam !== null //
|
|
110
|
+
? '/' + encodeURIComponent(urlIdParam).replace(/%2F/g, '/')
|
|
111
|
+
: '') +
|
|
112
|
+
(urlSuffix !== null ? urlSuffix : ''));
|
|
113
|
+
}
|
|
114
|
+
export function serialize(paramObj) {
|
|
115
|
+
let key, value;
|
|
116
|
+
let array_ops = ['in', 'not_in', 'between'];
|
|
117
|
+
for (key in paramObj) {
|
|
118
|
+
value = paramObj[key];
|
|
119
|
+
if (typeof value === 'object' && isObject(value)) {
|
|
120
|
+
let old_key = key;
|
|
121
|
+
let child_key;
|
|
122
|
+
for (child_key in value) {
|
|
123
|
+
key = key + '[' + child_key + ']';
|
|
124
|
+
paramObj[key] = value[child_key];
|
|
125
|
+
if (array_ops.includes(child_key)) {
|
|
126
|
+
paramObj[key] = JSON.stringify(value[child_key]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
delete paramObj[old_key];
|
|
130
|
+
serialize(paramObj);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
paramObj[key] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return paramObj;
|
|
137
|
+
}
|
|
138
|
+
export function encodeListParams(paramObj) {
|
|
139
|
+
let key, value;
|
|
140
|
+
for (key in paramObj) {
|
|
141
|
+
value = paramObj[key];
|
|
142
|
+
if (typeof value !== 'undefined' && value !== null && isArray(value)) {
|
|
143
|
+
paramObj[key] = JSON.stringify(value);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
paramObj[key] = value;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return encodeParams(paramObj);
|
|
150
|
+
}
|
|
151
|
+
export function getHost(env) {
|
|
152
|
+
return env.site + env.hostSuffix;
|
|
153
|
+
}
|
|
154
|
+
export function encodeParams(paramObj, serialized, scope, index) {
|
|
155
|
+
let key, value;
|
|
156
|
+
if (typeof serialized === 'undefined' || serialized === null) {
|
|
157
|
+
serialized = [];
|
|
158
|
+
}
|
|
159
|
+
for (key in paramObj) {
|
|
160
|
+
value = paramObj[key];
|
|
161
|
+
if (scope) {
|
|
162
|
+
key = '' + scope + '[' + key + ']';
|
|
163
|
+
}
|
|
164
|
+
if (typeof index !== 'undefined' && index !== null) {
|
|
165
|
+
key = key + '[' + index + ']';
|
|
166
|
+
}
|
|
167
|
+
if (isArray(value)) {
|
|
168
|
+
for (let arrIdx = 0; arrIdx < value.length; arrIdx++) {
|
|
169
|
+
if (typeof value[arrIdx] === 'object' || isArray(value[arrIdx])) {
|
|
170
|
+
encodeParams(value[arrIdx], serialized, key, arrIdx);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (typeof value[arrIdx] !== 'undefined') {
|
|
174
|
+
serialized.push(encodeURIComponent(key + '[' + arrIdx + ']') +
|
|
175
|
+
'=' +
|
|
176
|
+
encodeURIComponent(trim(value[arrIdx]) !== '' ? value[arrIdx] : ''));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (key === 'meta_data') {
|
|
182
|
+
let attrVal = '';
|
|
183
|
+
if (value !== null) {
|
|
184
|
+
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === '[object String]'
|
|
185
|
+
? trim(value)
|
|
186
|
+
: JSON.stringify(value));
|
|
187
|
+
}
|
|
188
|
+
serialized.push(encodeURIComponent(key) + '=' + attrVal);
|
|
189
|
+
}
|
|
190
|
+
else if (typeof value === 'object' && !isArray(value)) {
|
|
191
|
+
encodeParams(value, serialized, key);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
if (typeof value !== 'undefined') {
|
|
195
|
+
serialized.push(encodeURIComponent(key) +
|
|
196
|
+
'=' +
|
|
197
|
+
encodeURIComponent(trim(value) !== '' ? value : ''));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return serialized.join('&').replace(/%20/g, '+');
|
|
202
|
+
}
|
package/package.json
CHANGED
|
@@ -1,39 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
2
|
+
"name": "chargebee",
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
|
+
"description": "A library for integrating with Chargebee.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"prepack": "npm install && npm run build",
|
|
7
|
+
"build": "npm run build-esm && npm run build-cjs",
|
|
8
|
+
"build-esm": "rm -rf esm && mkdir -p esm && tsc -p tsconfig.esm.json && echo '{\"type\":\"module\"}' > esm/package.json",
|
|
9
|
+
"build-cjs": "rm -rf cjs && mkdir -p cjs && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > cjs/package.json",
|
|
10
|
+
"prettier": "prettier --write \"src/**/*.ts\" \"types/**/*.d.ts\""
|
|
11
|
+
},
|
|
12
|
+
"types": "./types/index.d.ts",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"paymetns",
|
|
15
|
+
"billings",
|
|
16
|
+
"subscription",
|
|
17
|
+
"chargebee"
|
|
18
|
+
],
|
|
19
|
+
"homepage": "http://github.com/chargebee/chargebee-node",
|
|
20
|
+
"main": "./cjs/chargebee.cjs.js",
|
|
21
|
+
"author": "<api@chargeee.com> (https://www.chargebee.com)",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.*"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "http://support.chargebee.com",
|
|
27
|
+
"email": "support@chargebee.com"
|
|
28
|
+
},
|
|
29
|
+
"licenses": [
|
|
30
|
+
{
|
|
31
|
+
"type": "MIT",
|
|
32
|
+
"url": "http://github.com/chargebee/chargebee-node/blob/master/LICENSE"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@types/node": "20.0.0"
|
|
37
|
+
},
|
|
38
|
+
"exports": {
|
|
39
|
+
"types": "./types/index.d.ts",
|
|
40
|
+
"worker": {
|
|
41
|
+
"import": "./esm/chargebee.esm.worker.js",
|
|
42
|
+
"require": "./cjs/chargebee.cjs.worker.js"
|
|
43
|
+
},
|
|
44
|
+
"workerd": {
|
|
45
|
+
"import": "./esm/chargebee.esm.worker.js",
|
|
46
|
+
"require": "./cjs/chargebee.cjs.worker.js"
|
|
47
|
+
},
|
|
48
|
+
"deno": {
|
|
49
|
+
"import": "./esm/chargebee.esm.worker.js",
|
|
50
|
+
"require": "./cjs/chargebee.cjs.worker.js"
|
|
51
|
+
},
|
|
52
|
+
"bun": {
|
|
53
|
+
"import": "./esm/chargebee.esm.worker.js",
|
|
54
|
+
"require": "./cjs/chargebee.cjs.worker.js"
|
|
55
|
+
},
|
|
56
|
+
"default": {
|
|
57
|
+
"import": "./esm/chargebee.esm.js",
|
|
58
|
+
"require": "./cjs/chargebee.cjs.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"prettier": "^3.3.3",
|
|
63
|
+
"typescript": "^5.5.4"
|
|
64
|
+
},
|
|
65
|
+
"prettier": {
|
|
66
|
+
"semi": true,
|
|
67
|
+
"singleQuote": true,
|
|
68
|
+
"parser": "typescript"
|
|
69
|
+
}
|
|
70
|
+
}
|