@yosle/tropipayjs 0.1.21 → 0.1.23

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 (39) hide show
  1. package/.nvmrc +1 -1
  2. package/.vscode/launch.json +18 -0
  3. package/LICENSE +9 -9
  4. package/README.md +152 -152
  5. package/api/TropipayAPI.d.ts +18 -5
  6. package/depositAccount/depositAccounts.d.ts +1 -1
  7. package/docs/readme.md +3 -3
  8. package/globals.d.ts +75 -75
  9. package/hooks/TropipayHooks.d.ts +2 -2
  10. package/index.d.ts +50 -12
  11. package/index.js +99 -8
  12. package/interfaces/countries/index.d.ts +1 -1
  13. package/interfaces/index.d.ts +14 -9
  14. package/jest.config.js +5 -0
  15. package/mediationPaymentCard/MediationPaymentCard.d.ts +17 -0
  16. package/package.json +49 -46
  17. package/paymentcard/PaymentCard.d.ts +17 -1
  18. package/paymentcard/paymentcard.spec.d.ts +1 -1
  19. package/rollup.config.js +24 -24
  20. package/src/api/TropipayAPI.ts +370 -323
  21. package/src/config/TropipayConfig.ts +2 -2
  22. package/src/constants/TropipayConstants.ts +2 -2
  23. package/src/depositAccount/depositAccounts.ts +139 -139
  24. package/src/hooks/TropipayHooks.ts +154 -154
  25. package/src/index.ts +28 -27
  26. package/src/interfaces/depositaccounts/index.ts +70 -70
  27. package/src/interfaces/index.js +1 -1
  28. package/src/interfaces/index.ts +201 -195
  29. package/src/interfaces/mediation/index.ts +22 -22
  30. package/src/interfaces/paymentlink/index.d.ts +36 -36
  31. package/src/interfaces/paymentlink/index.js +2 -2
  32. package/src/interfaces/paymentlink/index.ts +91 -91
  33. package/src/mediationPaymentCard/MediationPaymentCard.ts +42 -0
  34. package/src/mocks/tropipay.ts +0 -0
  35. package/src/paymentcard/PaymentCard.ts +123 -84
  36. package/src/paymentcard/paymentcard.spec.ts +79 -10
  37. package/src/utils/TropipayUtils.ts +126 -126
  38. package/src/utils/errors.ts +92 -101
  39. package/tsconfig.json +96 -95
package/index.d.ts CHANGED
@@ -13,6 +13,7 @@ interface TropipayConfig {
13
13
  clientSecret: string;
14
14
  scopes?: string[];
15
15
  serverMode?: ServerMode$1;
16
+ customTropipayUrl?: string;
16
17
  }
17
18
  type TropipayCredentials = {
18
19
  clientId: string;
@@ -53,18 +54,22 @@ interface PaymentLinkPayload {
53
54
  urlFailed: string;
54
55
  urlNotification: string;
55
56
  serviceDate: string;
56
- client: {
57
- name: string;
58
- lastName: string;
59
- address: string;
60
- phone: string;
61
- email: string;
62
- countryId: number;
57
+ client?: {
58
+ name?: string;
59
+ lastName?: string;
60
+ address?: string;
61
+ phone?: string;
62
+ email?: string;
63
+ countryId?: number;
64
+ countryIso?: string;
65
+ city: string;
66
+ postCode: string;
63
67
  termsAndConditions: boolean;
64
- };
68
+ } | null;
65
69
  directPayment: boolean;
66
70
  paymentMethods?: string[];
67
71
  imageBase?: string;
72
+ saveToken?: boolean;
68
73
  }
69
74
  interface PaymentLink extends PaymentLinkPayload {
70
75
  expirationDate: string;
@@ -75,7 +80,7 @@ interface PaymentLink extends PaymentLinkPayload {
75
80
  shortUrl: string;
76
81
  paymentUrl: string;
77
82
  }
78
- interface mediationPaymentCardConfig {
83
+ interface MediationPaymentCardConfig {
79
84
  amount: number;
80
85
  currency: "EUR" | "USD";
81
86
  concept: string;
@@ -196,7 +201,7 @@ declare class TropipayHooks {
196
201
  * @returns All subscribed hooks or empty Array if none exist.
197
202
  */
198
203
  list(eventType?: HookEventType): Promise<UserHookSubscribed[]>;
199
- update(eventType: string, target: "web" | "email", value: string): Promise<any>;
204
+ update(eventType: HookEventType, target: "web" | "email", value: string): Promise<any>;
200
205
  delete(eventType: HookEventType, target: string): Promise<any>;
201
206
  events(): Promise<any>;
202
207
  }
@@ -217,7 +222,38 @@ declare class PaymentCard {
217
222
  * @returns Array of paymentlinks
218
223
  */
219
224
  list(): Promise<any>;
225
+ /**
226
+ * Retrieves a payment card with the specified ID.
227
+ *
228
+ * @param {string} id - The ID of the payment card to retrieve.
229
+ * @return {Promise<any>} A Promise that resolves to the payment card data.
230
+ * @throws {Error} If an error occurs while retrieving the payment card.
231
+ */
220
232
  get(id: string): Promise<any>;
233
+ /**
234
+ * Deletes a payment card with the specified ID. Its a LOGIC delete
235
+ * so this will delete the paymentcard from paymentcard list and
236
+ * disable shortUrl but not paymentUrl
237
+ * @param {string} id - The ID of the payment card to delete.
238
+ * @return {Promise<any>} A Promise that resolves to the deleted payment card data.
239
+ * @throws {Error} If an error occurs while deleting the payment card.
240
+ */
241
+ delete(id: string): Promise<any>;
242
+ }
243
+
244
+ declare class MediationPaymentCard {
245
+ private tropipay;
246
+ constructor(tropipayInstance: Tropipay);
247
+ /**
248
+ * (ONLY FOR BUSINESS ACCOUNTS) Create a mediation paymentcard (an escrow payment link) with the specified options.
249
+ * This allows a payment to be made to persons belonging or not to the TropiPay platform with the
250
+ * particularity that the payment will be held in custody or retained until it is released with
251
+ * the approval of the payer.
252
+ * @param payload PaymentLinkPayload Object.
253
+ * @returns Promise<PaymentLink> or throws an Exception.
254
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
255
+ */
256
+ create(payload: MediationPaymentCardConfig): Promise<PaymentLink>;
221
257
  }
222
258
 
223
259
  interface DepositAccountConfig {
@@ -299,10 +335,12 @@ declare class Tropipay {
299
335
  request: Axios;
300
336
  static accessToken: string | null;
301
337
  static refreshToken: string | null;
338
+ static expiresIn: number | null;
302
339
  serverMode: ServerMode;
303
340
  hooks: TropipayHooks;
304
341
  paymentCards: PaymentCard;
305
342
  depositAccounts: DepositAccounts;
343
+ mediationPaymentCard: MediationPaymentCard;
306
344
  /**
307
345
  * Initializes a new instance of the Tropipay class.
308
346
  *
@@ -364,7 +402,7 @@ declare class Tropipay {
364
402
  * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
365
403
  * @param config Payload with the payment details
366
404
  */
367
- createMediationPaymentCard(config: mediationPaymentCardConfig): Promise<PaymentLink>;
405
+ createMediationPaymentCard(config: MediationPaymentCardConfig): Promise<PaymentLink>;
368
406
  }
369
407
  declare class ClientSideUtils {
370
408
  constructor(tropipayInstance: Tropipay);
@@ -417,4 +455,4 @@ declare class ServerSideUtils {
417
455
 
418
456
  declare const SERVER_MODE: ServerMode$1;
419
457
 
420
- export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, DepositAccounts, HookEventType, HookTargetType, LoginError, LoginResponse, MAX_IMAGE_SIZE_MB, PaymentCard, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, TropipayHooks, UserHook, UserHookSubscribed, mediationPaymentCardConfig };
458
+ export { AccountBalance, AccountDeposits, ClientSideUtils, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, MAX_IMAGE_SIZE_MB, MediationPaymentCardConfig, PaymentLink, PaymentLinkPayload, SERVER_MODE, ServerMode$1 as ServerMode, ServerSideUtils, Tropipay, TropipayConfig, TropipayCredentials, UserHook, UserHookSubscribed };
package/index.js CHANGED
@@ -36,10 +36,9 @@ function handleExceptions(error) {
36
36
  const axiosResponse = error.response;
37
37
  const errorMessage = axiosResponse.data?.error?.message || "An error occurred";
38
38
  switch (axiosResponse.status) {
39
+ case 400:
39
40
  case 401:
40
- return new TropipayJSException(errorMessage, axiosResponse.status, axiosResponse.data.error);
41
41
  case 403:
42
- return new TropipayJSException(errorMessage, axiosResponse.status, axiosResponse.data.error);
43
42
  case 404:
44
43
  return new TropipayJSException(errorMessage, axiosResponse.status, axiosResponse.data.error);
45
44
  case 429:
@@ -257,6 +256,13 @@ class PaymentCard {
257
256
  throw new Error(`Could not retrieve PaymenCards list`);
258
257
  }
259
258
  }
259
+ /**
260
+ * Retrieves a payment card with the specified ID.
261
+ *
262
+ * @param {string} id - The ID of the payment card to retrieve.
263
+ * @return {Promise<any>} A Promise that resolves to the payment card data.
264
+ * @throws {Error} If an error occurs while retrieving the payment card.
265
+ */
260
266
  async get(id) {
261
267
  if (!Tropipay.accessToken) {
262
268
  await this.tropipay.login();
@@ -275,6 +281,69 @@ class PaymentCard {
275
281
  throw handleExceptions(error);
276
282
  }
277
283
  }
284
+ /**
285
+ * Deletes a payment card with the specified ID. Its a LOGIC delete
286
+ * so this will delete the paymentcard from paymentcard list and
287
+ * disable shortUrl but not paymentUrl
288
+ * @param {string} id - The ID of the payment card to delete.
289
+ * @return {Promise<any>} A Promise that resolves to the deleted payment card data.
290
+ * @throws {Error} If an error occurs while deleting the payment card.
291
+ */
292
+ async delete(id) {
293
+ if (!Tropipay.accessToken) {
294
+ await this.tropipay.login();
295
+ }
296
+ try {
297
+ const paymentcard = await this.tropipay.request.delete(`/api/v2/paymentcards/`, {
298
+ headers: {
299
+ "Content-Type": "application/json",
300
+ Authorization: `Bearer ${Tropipay.accessToken}`,
301
+ Accept: "application/json",
302
+ },
303
+ data: {
304
+ cardId: id,
305
+ },
306
+ });
307
+ return paymentcard.data;
308
+ }
309
+ catch (error) {
310
+ throw handleExceptions(error);
311
+ }
312
+ }
313
+ }
314
+
315
+ class MediationPaymentCard {
316
+ tropipay;
317
+ constructor(tropipayInstance) {
318
+ this.tropipay = tropipayInstance;
319
+ }
320
+ /**
321
+ * (ONLY FOR BUSINESS ACCOUNTS) Create a mediation paymentcard (an escrow payment link) with the specified options.
322
+ * This allows a payment to be made to persons belonging or not to the TropiPay platform with the
323
+ * particularity that the payment will be held in custody or retained until it is released with
324
+ * the approval of the payer.
325
+ * @param payload PaymentLinkPayload Object.
326
+ * @returns Promise<PaymentLink> or throws an Exception.
327
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
328
+ */
329
+ async create(payload) {
330
+ if (!Tropipay.accessToken) {
331
+ await this.tropipay.login();
332
+ }
333
+ try {
334
+ const paylink = await this.tropipay.request.post("/api/v2/paymentcards/mediation", payload, {
335
+ headers: {
336
+ "Content-Type": "application/json",
337
+ Authorization: `Bearer ${Tropipay.accessToken}`,
338
+ Accept: "application/json",
339
+ },
340
+ });
341
+ return paylink.data;
342
+ }
343
+ catch (error) {
344
+ throw handleExceptions(error);
345
+ }
346
+ }
278
347
  }
279
348
 
280
349
  class DepositAccounts {
@@ -412,10 +481,12 @@ class Tropipay {
412
481
  request;
413
482
  static accessToken;
414
483
  static refreshToken;
484
+ static expiresIn;
415
485
  serverMode;
416
486
  hooks;
417
487
  paymentCards;
418
488
  depositAccounts;
489
+ mediationPaymentCard;
419
490
  /**
420
491
  * Initializes a new instance of the Tropipay class.
421
492
  *
@@ -445,18 +516,39 @@ class Tropipay {
445
516
  this.clientId = config.clientId;
446
517
  this.clientSecret = config.clientSecret;
447
518
  this.serverMode = config.serverMode || "Development";
519
+ const tpp_env = this.serverMode === "Production"
520
+ ? "https://www.tropipay.com"
521
+ : "https://tropipay-dev.herokuapp.com";
448
522
  this.request = axios__default["default"].create({
449
- baseURL: this.serverMode === "Production"
450
- ? "https://www.tropipay.com"
451
- : "https://tropipay-dev.herokuapp.com",
523
+ baseURL: config.customTropipayUrl || tpp_env,
452
524
  headers: {
453
525
  "Content-Type": "application/json",
454
526
  Accept: "application/json",
455
527
  Authorization: `Bearer ${Tropipay.accessToken}`,
456
528
  },
457
529
  });
530
+ // Add request interceptor for Token expired
531
+ this.request.interceptors.request.use(async (config) => {
532
+ const currentTimestamp = Math.floor(Date.now() / 1000); // Current time in seconds
533
+ if (Tropipay.expiresIn && Tropipay.expiresIn < currentTimestamp) {
534
+ // Token has expired, attempt to refresh it
535
+ try {
536
+ await this.login();
537
+ }
538
+ catch (error) {
539
+ // Handle token refresh error
540
+ Tropipay.accessToken = null;
541
+ Tropipay.refreshToken = null;
542
+ throw handleExceptions(error);
543
+ }
544
+ }
545
+ return config;
546
+ }, (error) => {
547
+ return Promise.reject(error);
548
+ });
458
549
  this.hooks = new TropipayHooks(this);
459
550
  this.paymentCards = new PaymentCard(this);
551
+ this.mediationPaymentCard = new MediationPaymentCard(this);
460
552
  this.depositAccounts = new DepositAccounts(this);
461
553
  }
462
554
  async login() {
@@ -489,11 +581,13 @@ class Tropipay {
489
581
  });
490
582
  Tropipay.accessToken = data.access_token;
491
583
  Tropipay.refreshToken = data.refresh_token;
584
+ Tropipay.expiresIn = data.expires_in;
492
585
  return data;
493
586
  }
494
587
  catch (error) {
495
588
  Tropipay.accessToken = null;
496
589
  Tropipay.refreshToken = null;
590
+ Tropipay.expiresIn = null;
497
591
  throw handleExceptions(error);
498
592
  }
499
593
  }
@@ -792,11 +886,8 @@ if (typeof window !== "undefined") {
792
886
  }
793
887
 
794
888
  exports.ClientSideUtils = ClientSideUtils;
795
- exports.DepositAccounts = DepositAccounts;
796
889
  exports.MAX_IMAGE_SIZE_MB = MAX_IMAGE_SIZE_MB;
797
- exports.PaymentCard = PaymentCard;
798
890
  exports.SERVER_MODE = SERVER_MODE;
799
891
  exports.ServerSideUtils = ServerSideUtils;
800
892
  exports.Tropipay = Tropipay;
801
- exports.TropipayHooks = TropipayHooks;
802
893
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export type TropipayCountry = {};
1
+ export type TropipayCountry = {};
@@ -9,6 +9,7 @@ export interface TropipayConfig {
9
9
  clientSecret: string;
10
10
  scopes?: string[];
11
11
  serverMode?: ServerMode;
12
+ customTropipayUrl?: string;
12
13
  }
13
14
  export type TropipayCredentials = {
14
15
  clientId: string;
@@ -49,18 +50,22 @@ export interface PaymentLinkPayload {
49
50
  urlFailed: string;
50
51
  urlNotification: string;
51
52
  serviceDate: string;
52
- client: {
53
- name: string;
54
- lastName: string;
55
- address: string;
56
- phone: string;
57
- email: string;
58
- countryId: number;
53
+ client?: {
54
+ name?: string;
55
+ lastName?: string;
56
+ address?: string;
57
+ phone?: string;
58
+ email?: string;
59
+ countryId?: number;
60
+ countryIso?: string;
61
+ city: string;
62
+ postCode: string;
59
63
  termsAndConditions: boolean;
60
- };
64
+ } | null;
61
65
  directPayment: boolean;
62
66
  paymentMethods?: string[];
63
67
  imageBase?: string;
68
+ saveToken?: boolean;
64
69
  }
65
70
  export interface PaymentLink extends PaymentLinkPayload {
66
71
  expirationDate: string;
@@ -71,7 +76,7 @@ export interface PaymentLink extends PaymentLinkPayload {
71
76
  shortUrl: string;
72
77
  paymentUrl: string;
73
78
  }
74
- export interface mediationPaymentCardConfig {
79
+ export interface MediationPaymentCardConfig {
75
80
  amount: number;
76
81
  currency: "EUR" | "USD";
77
82
  concept: string;
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: "ts-jest",
4
+ testEnvironment: "node",
5
+ };
@@ -0,0 +1,17 @@
1
+ import { Tropipay } from "../api/TropipayAPI";
2
+ import { PaymentLink } from "../interfaces";
3
+ import { MediationPaymentCardConfig } from "../interfaces";
4
+ export default class MediationPaymentCard {
5
+ private tropipay;
6
+ constructor(tropipayInstance: Tropipay);
7
+ /**
8
+ * (ONLY FOR BUSINESS ACCOUNTS) Create a mediation paymentcard (an escrow payment link) with the specified options.
9
+ * This allows a payment to be made to persons belonging or not to the TropiPay platform with the
10
+ * particularity that the payment will be held in custody or retained until it is released with
11
+ * the approval of the payer.
12
+ * @param payload PaymentLinkPayload Object.
13
+ * @returns Promise<PaymentLink> or throws an Exception.
14
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
15
+ */
16
+ create(payload: MediationPaymentCardConfig): Promise<PaymentLink>;
17
+ }
package/package.json CHANGED
@@ -1,46 +1,49 @@
1
- {
2
- "name": "@yosle/tropipayjs",
3
- "version": "0.1.21",
4
- "description": "Javascript / Typescript SDK for the Tropipay API",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "vitest run",
8
- "_clear": "rimraf src/dist/*",
9
- "_tsc": "tsc",
10
- "_make-bundle": "rollup --config",
11
- "build": "yarn _clear && yarn _tsc && yarn _make-bundle"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/yosle/tropipayjs"
16
- },
17
- "keywords": [
18
- "Javascript",
19
- "Typescript",
20
- "Tropipay",
21
- "payments",
22
- "gateway",
23
- "API"
24
- ],
25
- "author": "Yosleivy Baez Acosta <yosle007@gmail.com>",
26
- "license": "MIT",
27
- "dependencies": {
28
- "axios": "^1.6.0",
29
- "tslib": "^2.4.0"
30
- },
31
- "devDependencies": {
32
- "@rollup/plugin-typescript": "^8.5.0",
33
- "@types/tough-cookie": "^4.0.5",
34
- "rimraf": "^3.0.2",
35
- "rollup": "^2.79.1",
36
- "rollup-plugin-dts": "^4.2.2",
37
- "run-s": "^0.0.0",
38
- "typescript": "^5.0.4",
39
- "vitest": "^1.2.2",
40
- "@types/node": "^20.12.7"
41
- },
42
- "funding": {
43
- "type": "individual",
44
- "url": "https://tppay.me/l94qaa3h"
45
- }
46
- }
1
+ {
2
+ "name": "@yosle/tropipayjs",
3
+ "version": "0.1.23",
4
+ "description": "Javascript / Typescript SDK for the Tropipay API",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "jest --passWithNoTests --updateSnapshot --coverage",
8
+ "_clear": "rimraf src/dist/*",
9
+ "_tsc": "tsc",
10
+ "_make-bundle": "rollup --config",
11
+ "build": "npm run _clear && npm run _tsc && npm run _make-bundle"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/yosle/tropipayjs"
16
+ },
17
+ "keywords": [
18
+ "Javascript",
19
+ "Typescript",
20
+ "Tropipay",
21
+ "payments",
22
+ "gateway",
23
+ "API"
24
+ ],
25
+ "author": "Yosleivy Baez Acosta <yosle007@gmail.com>",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "axios": "^1.6.0",
29
+ "tslib": "^2.4.0"
30
+ },
31
+ "devDependencies": {
32
+ "@rollup/plugin-typescript": "^8.5.0",
33
+ "@types/jest": "^29.5.12",
34
+ "@types/node": "^20.12.7",
35
+ "@types/tough-cookie": "^4.0.5",
36
+ "babel-jest": "^29.7.0",
37
+ "jest": "^29.7.0",
38
+ "rimraf": "^3.0.2",
39
+ "rollup": "^2.79.1",
40
+ "rollup-plugin-dts": "^4.2.2",
41
+ "run-s": "^0.0.0",
42
+ "ts-jest": "^29.1.2",
43
+ "typescript": "^5.4.5"
44
+ },
45
+ "funding": {
46
+ "type": "individual",
47
+ "url": "https://tppay.me/l94qaa3h"
48
+ }
49
+ }
@@ -1,7 +1,7 @@
1
1
  import { Tropipay } from "../api/TropipayAPI";
2
2
  import { PaymentLink } from "../interfaces";
3
3
  import { PaymentLinkPayload } from "../interfaces";
4
- export declare class PaymentCard {
4
+ export default class PaymentCard {
5
5
  private tropipay;
6
6
  constructor(tropipayInstance: Tropipay);
7
7
  /**
@@ -17,5 +17,21 @@ export declare class PaymentCard {
17
17
  * @returns Array of paymentlinks
18
18
  */
19
19
  list(): Promise<any>;
20
+ /**
21
+ * Retrieves a payment card with the specified ID.
22
+ *
23
+ * @param {string} id - The ID of the payment card to retrieve.
24
+ * @return {Promise<any>} A Promise that resolves to the payment card data.
25
+ * @throws {Error} If an error occurs while retrieving the payment card.
26
+ */
20
27
  get(id: string): Promise<any>;
28
+ /**
29
+ * Deletes a payment card with the specified ID. Its a LOGIC delete
30
+ * so this will delete the paymentcard from paymentcard list and
31
+ * disable shortUrl but not paymentUrl
32
+ * @param {string} id - The ID of the payment card to delete.
33
+ * @return {Promise<any>} A Promise that resolves to the deleted payment card data.
34
+ * @throws {Error} If an error occurs while deleting the payment card.
35
+ */
36
+ delete(id: string): Promise<any>;
21
37
  }
@@ -1 +1 @@
1
- export {};
1
+ declare function sum(a: number, b: number): number;
package/rollup.config.js CHANGED
@@ -1,24 +1,24 @@
1
- // Contents of the file /rollup.config.js
2
- import typescript from "@rollup/plugin-typescript";
3
- import dts from "rollup-plugin-dts";
4
- const config = [
5
- {
6
- input: "dist/index.js",
7
- output: {
8
- file: "index.js",
9
- format: "cjs",
10
- sourcemap: true,
11
- },
12
- external: ["axios", "crypto", "fs/promises"],
13
- plugins: [typescript()],
14
- },
15
- {
16
- input: "dist/index.d.ts",
17
- output: {
18
- file: "index.d.ts",
19
- format: "es",
20
- },
21
- plugins: [dts()],
22
- },
23
- ];
24
- export default config;
1
+ // Contents of the file /rollup.config.js
2
+ import typescript from "@rollup/plugin-typescript";
3
+ import dts from "rollup-plugin-dts";
4
+ const config = [
5
+ {
6
+ input: "dist/index.js",
7
+ output: {
8
+ file: "index.js",
9
+ format: "cjs",
10
+ sourcemap: true,
11
+ },
12
+ external: ["axios", "crypto", "fs/promises"],
13
+ plugins: [typescript()],
14
+ },
15
+ {
16
+ input: "dist/index.d.ts",
17
+ output: {
18
+ file: "index.d.ts",
19
+ format: "es",
20
+ },
21
+ plugins: [dts()],
22
+ },
23
+ ];
24
+ export default config;