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.
Files changed (118) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/LICENSE +1 -1
  3. package/README.md +90 -172
  4. package/cjs/RequestWrapper.js +81 -0
  5. package/cjs/asyncApiSupport.js +39 -0
  6. package/cjs/chargebee.cjs.js +13 -0
  7. package/cjs/chargebee.cjs.worker.js +9 -0
  8. package/cjs/chargebeeError.js +17 -0
  9. package/cjs/coreCommon.js +72 -0
  10. package/cjs/createChargebee.js +92 -0
  11. package/cjs/environment.js +18 -0
  12. package/cjs/filter.js +1 -0
  13. package/cjs/net/ClientInterface.js +40 -0
  14. package/cjs/net/FetchClient.js +86 -0
  15. package/cjs/net/NodeClient.js +61 -0
  16. package/cjs/package.json +1 -0
  17. package/cjs/resources/api_endpoints.js +1086 -0
  18. package/cjs/util.js +218 -0
  19. package/esm/RequestWrapper.js +77 -0
  20. package/esm/asyncApiSupport.js +35 -0
  21. package/esm/chargebee.esm.js +9 -0
  22. package/esm/chargebee.esm.worker.js +5 -0
  23. package/esm/chargebeeError.js +13 -0
  24. package/esm/coreCommon.js +67 -0
  25. package/esm/createChargebee.js +88 -0
  26. package/esm/environment.js +15 -0
  27. package/esm/filter.js +1 -0
  28. package/esm/net/ClientInterface.js +35 -0
  29. package/esm/net/FetchClient.js +81 -0
  30. package/esm/net/NodeClient.js +56 -0
  31. package/esm/package.json +1 -0
  32. package/esm/resources/api_endpoints.js +1083 -0
  33. package/esm/util.js +202 -0
  34. package/package.json +69 -38
  35. package/types/core.d.ts +558 -89
  36. package/types/index.d.ts +91 -54
  37. package/types/resources/Address.d.ts +57 -272
  38. package/types/resources/AdvanceInvoiceSchedule.d.ts +21 -94
  39. package/types/resources/AttachedItem.d.ts +91 -329
  40. package/types/resources/Attribute.d.ts +5 -5
  41. package/types/resources/BusinessEntity.d.ts +49 -69
  42. package/types/resources/BusinessEntityTransfer.d.ts +11 -17
  43. package/types/resources/Card.d.ts +146 -424
  44. package/types/resources/Comment.d.ts +72 -189
  45. package/types/resources/Contact.d.ts +12 -64
  46. package/types/resources/ContractTerm.d.ts +15 -96
  47. package/types/resources/Coupon.d.ts +282 -758
  48. package/types/resources/CouponCode.d.ts +56 -52
  49. package/types/resources/CouponSet.d.ts +92 -234
  50. package/types/resources/CreditNote.d.ts +588 -1758
  51. package/types/resources/CreditNoteEstimate.d.ts +131 -157
  52. package/types/resources/Currency.d.ts +75 -62
  53. package/types/resources/Customer.d.ts +892 -835
  54. package/types/resources/CustomerEntitlement.d.ts +36 -0
  55. package/types/resources/DifferentialPrice.d.ts +116 -314
  56. package/types/resources/Discount.d.ts +20 -125
  57. package/types/resources/Download.d.ts +6 -22
  58. package/types/resources/Entitlement.d.ts +51 -160
  59. package/types/resources/EntitlementOverride.d.ts +58 -139
  60. package/types/resources/Estimate.d.ts +1178 -527
  61. package/types/resources/Event.d.ts +67 -178
  62. package/types/resources/Export.d.ts +563 -723
  63. package/types/resources/Feature.d.ts +117 -433
  64. package/types/resources/GatewayErrorDetail.d.ts +16 -72
  65. package/types/resources/Gift.d.ts +265 -432
  66. package/types/resources/Hierarchy.d.ts +8 -36
  67. package/types/resources/HostedPage.d.ts +1017 -1153
  68. package/types/resources/ImpactedItem.d.ts +13 -50
  69. package/types/resources/ImpactedItemPrice.d.ts +13 -15
  70. package/types/resources/ImpactedSubscription.d.ts +13 -45
  71. package/types/resources/InAppSubscription.d.ts +93 -389
  72. package/types/resources/Installment.d.ts +35 -110
  73. package/types/resources/InstallmentConfig.d.ts +54 -155
  74. package/types/resources/InstallmentDetail.d.ts +19 -27
  75. package/types/resources/Invoice.d.ts +1574 -3157
  76. package/types/resources/InvoiceEstimate.d.ts +131 -161
  77. package/types/resources/Item.d.ts +133 -611
  78. package/types/resources/ItemEntitlement.d.ts +78 -215
  79. package/types/resources/ItemFamily.d.ts +69 -178
  80. package/types/resources/ItemPrice.d.ts +291 -1203
  81. package/types/resources/Metadata.d.ts +3 -5
  82. package/types/resources/Order.d.ts +538 -1471
  83. package/types/resources/PaymentIntent.d.ts +163 -347
  84. package/types/resources/PaymentReferenceNumber.d.ts +7 -29
  85. package/types/resources/PaymentSource.d.ts +476 -1272
  86. package/types/resources/PaymentVoucher.d.ts +87 -306
  87. package/types/resources/PortalSession.d.ts +71 -207
  88. package/types/resources/PriceVariant.d.ts +91 -279
  89. package/types/resources/PricingPageSession.d.ts +92 -41
  90. package/types/resources/PromotionalCredit.d.ts +90 -346
  91. package/types/resources/Purchase.d.ts +185 -315
  92. package/types/resources/Quote.d.ts +1406 -887
  93. package/types/resources/QuoteLineGroup.d.ts +125 -452
  94. package/types/resources/QuotedCharge.d.ts +45 -274
  95. package/types/resources/QuotedSubscription.d.ts +100 -488
  96. package/types/resources/Ramp.d.ts +233 -724
  97. package/types/resources/ResourceMigration.d.ts +25 -80
  98. package/types/resources/SiteMigrationDetail.d.ts +34 -112
  99. package/types/resources/Subscription.d.ts +2390 -4335
  100. package/types/resources/SubscriptionEntitlement.d.ts +59 -160
  101. package/types/resources/SubscriptionEstimate.d.ts +51 -75
  102. package/types/resources/TaxWithheld.d.ts +15 -40
  103. package/types/resources/ThirdPartyPaymentMethod.d.ts +7 -29
  104. package/types/resources/TimeMachine.d.ts +43 -97
  105. package/types/resources/Token.d.ts +15 -85
  106. package/types/resources/Transaction.d.ts +278 -900
  107. package/types/resources/UnbilledCharge.d.ts +189 -164
  108. package/types/resources/Usage.d.ts +89 -279
  109. package/types/resources/VirtualBankAccount.d.ts +103 -255
  110. package/types/resources/filter.d.ts +52 -0
  111. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -81
  112. package/.github/ISSUE_TEMPLATE/config.yml +0 -6
  113. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -34
  114. package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
  115. package/lib/chargebee.js +0 -512
  116. package/lib/resources/api_endpoints.js +0 -2912
  117. package/types/resources/NonSubscription.d.ts +0 -30
  118. 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
- "name":"chargebee",
3
- "version":"2.40.0",
4
- "description":"A library for integrating with ChargeBee.",
5
- "keywords":[
6
- "payments",
7
- "billing",
8
- "subscription",
9
- "chargebee"
10
- ],
11
- "homepage":"http://github.com/chargebee/chargebee-node",
12
- "author":"Ajit <ajit@chargebee.com> (https://www.chargebee.com)",
13
- "main":"lib/chargebee.js",
14
- "types": "types/index.d.ts",
15
- "dependencies":{
16
- "q" : ">=1.0.1",
17
- "safer-buffer": "2.1.2"
18
- },
19
- "directories":{
20
- "lib":"./lib"
21
- },
22
- "repository":{
23
- "type":"git",
24
- "url":"http://github.com/chargebee/chargebee-node.git"
25
- },
26
- "engines":{
27
- "node":">=0.6.0"
28
- },
29
- "bugs":{
30
- "url":"http://support.chargebee.com",
31
- "email":"support@chargebee.com"
32
- },
33
- "licenses":[
34
- {
35
- "type":"MIT",
36
- "url":"http://github.com/chargebee/chargebee-node/blob/master/LICENSE"
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
+ }