From 866f10690834e4c23f67245b654e9b2d21768281 Mon Sep 17 00:00:00 2001 From: "gocardless-ci-robot[bot]" <123969075+gocardless-ci-robot[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 12:38:43 +0000 Subject: [PATCH] Changes generated by fcd6867b0946bff9e9995013241d0100af0bb285 This commit was automatically created from gocardless/gocardless-nodejs-template@fcd6867b0946bff9e9995013241d0100af0bb285 by the `push-files` action. Workflow run: https://github.com/gocardless/gocardless-nodejs-template/actions/runs/22098729423 --- .gitignore | 3 + README.md | 41 ++++++-- dist-cjs-package.json | 3 + dist-esm-package.json | 3 + jest.config.js | 17 +++- package-lock.json | 16 ++-- package.json | 68 +++++++++++++- src/api/api.test.ts | 4 +- src/api/api.ts | 16 ++-- src/apiRequestSigning.test.ts | 2 +- src/client.ts | 94 +++++++++---------- src/constants.ts | 4 +- src/errors.ts | 2 - src/index.ts | 29 ++++-- src/services/balanceService.ts | 6 +- src/services/bankAccountDetailService.ts | 6 +- .../bankAccountHolderVerificationService.ts | 6 +- src/services/bankAuthorisationService.ts | 6 +- src/services/bankDetailsLookupService.ts | 6 +- src/services/billingRequestFlowService.ts | 6 +- src/services/billingRequestService.ts | 6 +- src/services/billingRequestTemplateService.ts | 6 +- .../billingRequestWithActionService.ts | 6 +- src/services/blockService.ts | 6 +- src/services/creditorBankAccountService.ts | 6 +- src/services/creditorService.ts | 6 +- src/services/currencyExchangeRateService.ts | 6 +- src/services/customerBankAccountService.ts | 6 +- src/services/customerNotificationService.ts | 6 +- src/services/customerService.ts | 6 +- src/services/eventService.ts | 6 +- src/services/exportService.ts | 6 +- src/services/fundsAvailabilityService.ts | 6 +- src/services/instalmentScheduleService.ts | 6 +- src/services/institutionService.ts | 6 +- src/services/logoService.ts | 6 +- src/services/mandateImportEntryService.ts | 6 +- src/services/mandateImportService.ts | 6 +- src/services/mandatePdfService.ts | 6 +- src/services/mandateService.ts | 6 +- src/services/negativeBalanceLimitService.ts | 6 +- src/services/outboundPaymentService.ts | 6 +- src/services/payerAuthorisationService.ts | 6 +- src/services/payerThemeService.ts | 6 +- src/services/paymentAccountService.ts | 6 +- .../paymentAccountTransactionService.ts | 6 +- src/services/paymentService.ts | 6 +- src/services/payoutItemService.ts | 6 +- src/services/payoutService.ts | 6 +- src/services/redirectFlowService.ts | 6 +- src/services/refundService.ts | 6 +- src/services/scenarioSimulatorService.ts | 6 +- src/services/schemeIdentifierService.ts | 6 +- src/services/subscriptionService.ts | 6 +- src/services/taxRateService.ts | 6 +- src/services/transferredMandateService.ts | 6 +- src/services/verificationDetailService.ts | 6 +- src/services/webhookService.ts | 6 +- src/webhooks.ts | 2 +- tsconfig.base.json | 24 +++++ tsconfig.cjs.json | 9 ++ tsconfig.json | 27 +----- 62 files changed, 337 insertions(+), 291 deletions(-) create mode 100644 dist-cjs-package.json create mode 100644 dist-esm-package.json create mode 100644 tsconfig.base.json create mode 100644 tsconfig.cjs.json diff --git a/.gitignore b/.gitignore index f711aadf..5a19aca3 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ typings/ # Stores VSCode versions used for testing VSCode extensions .vscode-test + +# Build outputs +dist/ diff --git a/README.md b/README.md index 18886746..fe91ce67 100644 --- a/README.md +++ b/README.md @@ -20,18 +20,31 @@ To initialise the client, you must provide: - The environment that this token is for (see [here](https://github.com/gocardless/gocardless-nodejs/blob/master/src/constants.ts) for a list of available environments). - Any additional options (see [here](#available-client-options) for a list of supported options). - ```js -const gocardless = require('gocardless-nodejs/client'); -const constants = require('gocardless-nodejs/constants'); - +import gocardless from 'gocardless-nodejs'; +import { Environments } from 'gocardless-nodejs/constants'; -// Initialise the client. +// Initialize the client const client = gocardless( process.env.GC_ACCESS_TOKEN, - constants.Environments.Sandbox, - { raiseOnIdempotencyConflict: true }, + Environments.Sandbox, + { raiseOnIdempotencyConflict: true } +); +``` + +TypeScript: + +```typescript +import gocardless, { GoCardlessClient } from 'gocardless-nodejs'; +import { Environments } from 'gocardless-nodejs/constants'; +import type { Payment } from 'gocardless-nodejs/types'; + +const client: GoCardlessClient = gocardless( + process.env.GC_ACCESS_TOKEN, + Environments.Sandbox ); + +const payment: Payment = await client.payments.find('PM123'); ``` ### The Basics @@ -42,7 +55,7 @@ For a full list of available resources, visit the [GoCardless API reference](htt ```js -const uuidv4 = require('uuid/v4'); +import { v4 as uuidv4 } from 'uuid'; // Create a new payment. const payment = await client.payments.create( @@ -51,7 +64,7 @@ const payment = await client.payments.create( currency: "GBP", links: { mandate: "MD123" }, }, - { uuidv4() }, + uuidv4(), ); // List the first three payments past a certain date. @@ -86,3 +99,13 @@ for await (const payment of client.payments.all()) { ### Available client options - `raiseOnIdempotencyConflict`: set to `true` to raise exceptions on [idempotency](https://developer.gocardless.com/api-reference/#making-requests-idempotency-keys) conflicts. Defaults to `false`. + + +### CommonJS backwards compatibility + +We provide a CommonJS implementation for backwards compatibility. For CommonJS, change the imports to: + +```js +const gocardless = require('gocardless-nodejs'); +const { Environments } = require('gocardless-nodejs/constants'); +``` \ No newline at end of file diff --git a/dist-cjs-package.json b/dist-cjs-package.json new file mode 100644 index 00000000..5bbefffb --- /dev/null +++ b/dist-cjs-package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/dist-esm-package.json b/dist-esm-package.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/dist-esm-package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/jest.config.js b/jest.config.js index 91a2d2c0..14bfb585 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,19 @@ -module.exports = { +export default { preset: 'ts-jest', testEnvironment: 'node', + extensionsToTreatAsEsm: ['.ts'], + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + transform: { + '^.+\\.ts$': [ + 'ts-jest', + { + useESM: true, + tsconfig: { + esModuleInterop: false, + }, + }, + ], + }, }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 621dd2b3..50d41027 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gocardless-nodejs", - "version": "7.1.0", + "version": "7.2.0-beta1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gocardless-nodejs", - "version": "7.1.0", + "version": "7.2.0-beta1", "license": "MIT", "dependencies": { "buffer-equal-constant-time": "1.0.1", @@ -2658,9 +2658,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001769", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001769.tgz", - "integrity": "sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==", + "version": "1.0.30001770", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001770.tgz", + "integrity": "sha512-x/2CLQ1jHENRbHg5PSId2sXq1CIO1CISvwWAj027ltMVG2UNgW+w9oH2+HzgEIRFembL8bUlXtfbBHR1fCg2xw==", "dev": true, "funding": [ { @@ -6187,9 +6187,9 @@ "license": "MIT" }, "node_modules/qs": { - "version": "6.14.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", - "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.0.tgz", + "integrity": "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==", "license": "BSD-3-Clause", "dependencies": { "side-channel": "^1.1.0" diff --git a/package.json b/package.json index 68bf43b0..e41159e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gocardless-nodejs", - "version": "7.1.0", + "version": "7.2.0-beta1", "description": "Node.js client for the GoCardless API - a powerful, simple solution for the collection of recurring bank-to-bank payments", "author": "GoCardless Ltd ", "repository": { @@ -19,6 +19,65 @@ "api", "direct debit" ], + "type": "module", + "main": "./dist/esm/index.js", + "types": "./dist/types/index.d.ts", + "exports": { + ".": { + "import": { + "types": "./dist/types/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/types/index.d.ts", + "default": "./dist/cjs/index.js" + } + }, + "./client": { + "import": { + "types": "./dist/types/client.d.ts", + "default": "./dist/esm/client.js" + }, + "require": { + "types": "./dist/types/client.d.ts", + "default": "./dist/cjs/client.js" + } + }, + "./constants": { + "import": { + "types": "./dist/types/constants.d.ts", + "default": "./dist/esm/constants.js" + }, + "require": { + "types": "./dist/types/constants.d.ts", + "default": "./dist/cjs/constants.js" + } + }, + "./webhooks": { + "import": { + "types": "./dist/types/webhooks.d.ts", + "default": "./dist/esm/webhooks.js" + }, + "require": { + "types": "./dist/types/webhooks.d.ts", + "default": "./dist/cjs/webhooks.js" + } + }, + "./errors": { + "import": { + "types": "./dist/types/errors.d.ts", + "default": "./dist/esm/errors.js" + }, + "require": { + "types": "./dist/types/errors.d.ts", + "default": "./dist/cjs/errors.js" + } + }, + "./types": { + "types": "./dist/types/types/Types.d.ts" + }, + "./package.json": "./package.json" + }, "scripts": { "test": "jest", "lint": "eslint src/**/*.ts", @@ -47,8 +106,11 @@ "ts-jest": "29.4.1", "typescript": "^5.0.2" }, - "main": "index.js", - "types": "types/Types.d.ts", + "files": [ + "dist/", + "LICENSE.txt", + "README.md" + ], "engines": { "node": ">=18.0" } diff --git a/src/api/api.test.ts b/src/api/api.test.ts index 5fc19fd3..528d3bdc 100644 --- a/src/api/api.test.ts +++ b/src/api/api.test.ts @@ -1,5 +1,5 @@ -import fs from 'node:fs'; -import nock from 'nock'; +import * as fs from 'node:fs'; +import * as nock from 'nock'; import { Api } from './api'; import { Environments } from '../constants'; import * as GoCardlessErrors from '../errors'; diff --git a/src/api/api.ts b/src/api/api.ts index b8c09751..7b2e31e4 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,20 +1,18 @@ -'use strict'; - -import os = require('os'); -import process = require('process'); -import _ = require('lodash'); +import * as os from 'os'; +import * as process from 'process'; +import * as _ from 'lodash'; import { v4 as uuidv4 } from 'uuid'; import * as url from 'url'; import got, { Agents, OptionsOfJSONResponseBody } from 'got'; -import qs from 'qs'; +import * as qs from 'qs'; -import { Environments, CLIENT_VERSION, API_VERSION } from '../constants'; -import * as GoCardlessErrors from '../errors'; +import { Environments, CLIENT_VERSION, API_VERSION } from '../constants.js'; +import * as GoCardlessErrors from '../errors.js'; import { ApiRequestSignatureHelper, ApiRequestSigningOptions, ApiRequestSigningOptionsInternal, -} from '../apiRequestSigning'; +} from '../apiRequestSigning.js'; export interface APIOptions { proxy?: Agents; diff --git a/src/apiRequestSigning.test.ts b/src/apiRequestSigning.test.ts index bd6d5af5..11fdb708 100644 --- a/src/apiRequestSigning.test.ts +++ b/src/apiRequestSigning.test.ts @@ -1,4 +1,4 @@ -import fs from 'node:fs'; +import * as fs from 'node:fs'; import { ApiRequestSignatureHelper, ApiRequestSigningOptionsInternal } from './apiRequestSigning'; const privateKeyPem = fs.readFileSync('src/fixtures/private_key.pem', 'utf8'); diff --git a/src/client.ts b/src/client.ts index ed1868cc..5f41aee3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,51 +1,49 @@ -'use strict'; - -import { Environments } from './constants'; -import { Api, APIOptions } from './api/api'; -import { BalanceService } from './services/balanceService'; -import { BankAccountDetailService } from './services/bankAccountDetailService'; -import { BankAccountHolderVerificationService } from './services/bankAccountHolderVerificationService'; -import { BankAuthorisationService } from './services/bankAuthorisationService'; -import { BankDetailsLookupService } from './services/bankDetailsLookupService'; -import { BillingRequestService } from './services/billingRequestService'; -import { BillingRequestFlowService } from './services/billingRequestFlowService'; -import { BillingRequestTemplateService } from './services/billingRequestTemplateService'; -import { BillingRequestWithActionService } from './services/billingRequestWithActionService'; -import { BlockService } from './services/blockService'; -import { CreditorService } from './services/creditorService'; -import { CreditorBankAccountService } from './services/creditorBankAccountService'; -import { CurrencyExchangeRateService } from './services/currencyExchangeRateService'; -import { CustomerService } from './services/customerService'; -import { CustomerBankAccountService } from './services/customerBankAccountService'; -import { CustomerNotificationService } from './services/customerNotificationService'; -import { EventService } from './services/eventService'; -import { ExportService } from './services/exportService'; -import { FundsAvailabilityService } from './services/fundsAvailabilityService'; -import { InstalmentScheduleService } from './services/instalmentScheduleService'; -import { InstitutionService } from './services/institutionService'; -import { LogoService } from './services/logoService'; -import { MandateService } from './services/mandateService'; -import { MandateImportService } from './services/mandateImportService'; -import { MandateImportEntryService } from './services/mandateImportEntryService'; -import { MandatePdfService } from './services/mandatePdfService'; -import { NegativeBalanceLimitService } from './services/negativeBalanceLimitService'; -import { OutboundPaymentService } from './services/outboundPaymentService'; -import { PayerAuthorisationService } from './services/payerAuthorisationService'; -import { PayerThemeService } from './services/payerThemeService'; -import { PaymentService } from './services/paymentService'; -import { PaymentAccountService } from './services/paymentAccountService'; -import { PaymentAccountTransactionService } from './services/paymentAccountTransactionService'; -import { PayoutService } from './services/payoutService'; -import { PayoutItemService } from './services/payoutItemService'; -import { RedirectFlowService } from './services/redirectFlowService'; -import { RefundService } from './services/refundService'; -import { ScenarioSimulatorService } from './services/scenarioSimulatorService'; -import { SchemeIdentifierService } from './services/schemeIdentifierService'; -import { SubscriptionService } from './services/subscriptionService'; -import { TaxRateService } from './services/taxRateService'; -import { TransferredMandateService } from './services/transferredMandateService'; -import { VerificationDetailService } from './services/verificationDetailService'; -import { WebhookService } from './services/webhookService'; +import { Environments } from './constants.js'; +import { Api, APIOptions } from './api/api.js'; +import { BalanceService } from './services/balanceService.js'; +import { BankAccountDetailService } from './services/bankAccountDetailService.js'; +import { BankAccountHolderVerificationService } from './services/bankAccountHolderVerificationService.js'; +import { BankAuthorisationService } from './services/bankAuthorisationService.js'; +import { BankDetailsLookupService } from './services/bankDetailsLookupService.js'; +import { BillingRequestService } from './services/billingRequestService.js'; +import { BillingRequestFlowService } from './services/billingRequestFlowService.js'; +import { BillingRequestTemplateService } from './services/billingRequestTemplateService.js'; +import { BillingRequestWithActionService } from './services/billingRequestWithActionService.js'; +import { BlockService } from './services/blockService.js'; +import { CreditorService } from './services/creditorService.js'; +import { CreditorBankAccountService } from './services/creditorBankAccountService.js'; +import { CurrencyExchangeRateService } from './services/currencyExchangeRateService.js'; +import { CustomerService } from './services/customerService.js'; +import { CustomerBankAccountService } from './services/customerBankAccountService.js'; +import { CustomerNotificationService } from './services/customerNotificationService.js'; +import { EventService } from './services/eventService.js'; +import { ExportService } from './services/exportService.js'; +import { FundsAvailabilityService } from './services/fundsAvailabilityService.js'; +import { InstalmentScheduleService } from './services/instalmentScheduleService.js'; +import { InstitutionService } from './services/institutionService.js'; +import { LogoService } from './services/logoService.js'; +import { MandateService } from './services/mandateService.js'; +import { MandateImportService } from './services/mandateImportService.js'; +import { MandateImportEntryService } from './services/mandateImportEntryService.js'; +import { MandatePdfService } from './services/mandatePdfService.js'; +import { NegativeBalanceLimitService } from './services/negativeBalanceLimitService.js'; +import { OutboundPaymentService } from './services/outboundPaymentService.js'; +import { PayerAuthorisationService } from './services/payerAuthorisationService.js'; +import { PayerThemeService } from './services/payerThemeService.js'; +import { PaymentService } from './services/paymentService.js'; +import { PaymentAccountService } from './services/paymentAccountService.js'; +import { PaymentAccountTransactionService } from './services/paymentAccountTransactionService.js'; +import { PayoutService } from './services/payoutService.js'; +import { PayoutItemService } from './services/payoutItemService.js'; +import { RedirectFlowService } from './services/redirectFlowService.js'; +import { RefundService } from './services/refundService.js'; +import { ScenarioSimulatorService } from './services/scenarioSimulatorService.js'; +import { SchemeIdentifierService } from './services/schemeIdentifierService.js'; +import { SubscriptionService } from './services/subscriptionService.js'; +import { TaxRateService } from './services/taxRateService.js'; +import { TransferredMandateService } from './services/transferredMandateService.js'; +import { VerificationDetailService } from './services/verificationDetailService.js'; +import { WebhookService } from './services/webhookService.js'; export class GoCardlessClient { private _api: Api; diff --git a/src/constants.ts b/src/constants.ts index fbc1f545..267d9824 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,11 +1,9 @@ -'use strict'; - enum Environments { Live = 'LIVE', Sandbox = 'SANDBOX', } -const CLIENT_VERSION = '7.1.0'; +const CLIENT_VERSION = '7.2.0-beta1'; const API_VERSION = '2015-07-06'; export { Environments, CLIENT_VERSION, API_VERSION }; diff --git a/src/errors.ts b/src/errors.ts index 80e4aaf0..a4802519 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,5 +1,3 @@ -'use strict'; - class GoCardlessException extends Error {} class MalformedResponseError extends GoCardlessException { diff --git a/src/index.ts b/src/index.ts index ae6ad045..3e31f0a5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,26 @@ -'use strict'; +import { GoCardlessClient } from './client.js'; +import { Environments } from './constants.js'; +import type { APIOptions } from './api/api.js'; -import { GoCardlessClient } from './client'; +/** + * Initialize a GoCardless client + * @param token - API token + * @param environment - Live or Sandbox environment + * @param options - Additional API options + */ +export default function gocardless( + token: string, + environment = Environments.Live, + options: APIOptions = {}, +): GoCardlessClient { + return new GoCardlessClient(token, environment, options); +} -const initialiser = function (token, envrionment, options = {}) { - return new GoCardlessClient(token, envrionment, options); -}; +// Named export for destructuring +export { gocardless }; -module.exports = initialiser; +// Re-export main exports for convenience +export { GoCardlessClient } from './client.js'; +export { Environments, CLIENT_VERSION, API_VERSION } from './constants.js'; +export { parse, verifySignature, InvalidSignatureError } from './webhooks.js'; +export type { APIOptions } from './api/api.js'; diff --git a/src/services/balanceService.ts b/src/services/balanceService.ts index 2c87c607..aa3a8225 100644 --- a/src/services/balanceService.ts +++ b/src/services/balanceService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BalanceResponse extends Types.Balance, Types.APIResponse {} diff --git a/src/services/bankAccountDetailService.ts b/src/services/bankAccountDetailService.ts index 95d8bb8d..f799a1c2 100644 --- a/src/services/bankAccountDetailService.ts +++ b/src/services/bankAccountDetailService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BankAccountDetailResponse extends Types.BankAccountDetail, Types.APIResponse {} diff --git a/src/services/bankAccountHolderVerificationService.ts b/src/services/bankAccountHolderVerificationService.ts index 32c1dd4e..0233bbf7 100644 --- a/src/services/bankAccountHolderVerificationService.ts +++ b/src/services/bankAccountHolderVerificationService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BankAccountHolderVerificationResponse extends Types.BankAccountHolderVerification, Types.APIResponse {} diff --git a/src/services/bankAuthorisationService.ts b/src/services/bankAuthorisationService.ts index d4bbc836..78040b42 100644 --- a/src/services/bankAuthorisationService.ts +++ b/src/services/bankAuthorisationService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BankAuthorisationResponse extends Types.BankAuthorisation, Types.APIResponse {} diff --git a/src/services/bankDetailsLookupService.ts b/src/services/bankDetailsLookupService.ts index c47c998b..74ad8f18 100644 --- a/src/services/bankDetailsLookupService.ts +++ b/src/services/bankDetailsLookupService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BankDetailsLookupResponse extends Types.BankDetailsLookup, Types.APIResponse {} diff --git a/src/services/billingRequestFlowService.ts b/src/services/billingRequestFlowService.ts index 834e2711..87fdf83f 100644 --- a/src/services/billingRequestFlowService.ts +++ b/src/services/billingRequestFlowService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BillingRequestFlowResponse extends Types.BillingRequestFlow, Types.APIResponse {} diff --git a/src/services/billingRequestService.ts b/src/services/billingRequestService.ts index c125549f..6aaefc39 100644 --- a/src/services/billingRequestService.ts +++ b/src/services/billingRequestService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BillingRequestResponse extends Types.BillingRequest, Types.APIResponse {} diff --git a/src/services/billingRequestTemplateService.ts b/src/services/billingRequestTemplateService.ts index 2dde7ac4..881baef0 100644 --- a/src/services/billingRequestTemplateService.ts +++ b/src/services/billingRequestTemplateService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BillingRequestTemplateResponse extends Types.BillingRequestTemplate, Types.APIResponse {} diff --git a/src/services/billingRequestWithActionService.ts b/src/services/billingRequestWithActionService.ts index 94bce47e..0a7e84a5 100644 --- a/src/services/billingRequestWithActionService.ts +++ b/src/services/billingRequestWithActionService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BillingRequestWithActionResponse extends Types.BillingRequestWithAction, Types.APIResponse {} diff --git a/src/services/blockService.ts b/src/services/blockService.ts index aad4dd21..5ea752ec 100644 --- a/src/services/blockService.ts +++ b/src/services/blockService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface BlockResponse extends Types.Block, Types.APIResponse {} diff --git a/src/services/creditorBankAccountService.ts b/src/services/creditorBankAccountService.ts index a8315042..cc4c2e32 100644 --- a/src/services/creditorBankAccountService.ts +++ b/src/services/creditorBankAccountService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface CreditorBankAccountResponse extends Types.CreditorBankAccount, Types.APIResponse {} diff --git a/src/services/creditorService.ts b/src/services/creditorService.ts index 97a35135..ea7d8d27 100644 --- a/src/services/creditorService.ts +++ b/src/services/creditorService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface CreditorResponse extends Types.Creditor, Types.APIResponse {} diff --git a/src/services/currencyExchangeRateService.ts b/src/services/currencyExchangeRateService.ts index a0f3d57c..059b371b 100644 --- a/src/services/currencyExchangeRateService.ts +++ b/src/services/currencyExchangeRateService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface CurrencyExchangeRateResponse extends Types.CurrencyExchangeRate, Types.APIResponse {} diff --git a/src/services/customerBankAccountService.ts b/src/services/customerBankAccountService.ts index cf542e7d..fd4349b0 100644 --- a/src/services/customerBankAccountService.ts +++ b/src/services/customerBankAccountService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface CustomerBankAccountResponse extends Types.CustomerBankAccount, Types.APIResponse {} diff --git a/src/services/customerNotificationService.ts b/src/services/customerNotificationService.ts index 74b43222..a4934f13 100644 --- a/src/services/customerNotificationService.ts +++ b/src/services/customerNotificationService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface CustomerNotificationResponse extends Types.CustomerNotification, Types.APIResponse {} diff --git a/src/services/customerService.ts b/src/services/customerService.ts index c8f74dbd..8716a540 100644 --- a/src/services/customerService.ts +++ b/src/services/customerService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface CustomerResponse extends Types.Customer, Types.APIResponse {} diff --git a/src/services/eventService.ts b/src/services/eventService.ts index 39e16b89..8bd2e54b 100644 --- a/src/services/eventService.ts +++ b/src/services/eventService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface EventResponse extends Types.Event, Types.APIResponse {} diff --git a/src/services/exportService.ts b/src/services/exportService.ts index 99cb2dbe..55c95363 100644 --- a/src/services/exportService.ts +++ b/src/services/exportService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface ExportResponse extends Types.Export, Types.APIResponse {} diff --git a/src/services/fundsAvailabilityService.ts b/src/services/fundsAvailabilityService.ts index 339ad5e1..2a58c0b7 100644 --- a/src/services/fundsAvailabilityService.ts +++ b/src/services/fundsAvailabilityService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface FundsAvailabilityResponse extends Types.FundsAvailability, Types.APIResponse {} diff --git a/src/services/instalmentScheduleService.ts b/src/services/instalmentScheduleService.ts index 6762153f..6103bc88 100644 --- a/src/services/instalmentScheduleService.ts +++ b/src/services/instalmentScheduleService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface InstalmentScheduleResponse extends Types.InstalmentSchedule, Types.APIResponse {} diff --git a/src/services/institutionService.ts b/src/services/institutionService.ts index 83e76c67..b8b90df7 100644 --- a/src/services/institutionService.ts +++ b/src/services/institutionService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface InstitutionResponse extends Types.Institution, Types.APIResponse {} diff --git a/src/services/logoService.ts b/src/services/logoService.ts index 52e7930a..810cced9 100644 --- a/src/services/logoService.ts +++ b/src/services/logoService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface LogoResponse extends Types.Logo, Types.APIResponse {} diff --git a/src/services/mandateImportEntryService.ts b/src/services/mandateImportEntryService.ts index 540f2e70..3a1fe194 100644 --- a/src/services/mandateImportEntryService.ts +++ b/src/services/mandateImportEntryService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface MandateImportEntryResponse extends Types.MandateImportEntry, Types.APIResponse {} diff --git a/src/services/mandateImportService.ts b/src/services/mandateImportService.ts index 77c75cbf..3c738df6 100644 --- a/src/services/mandateImportService.ts +++ b/src/services/mandateImportService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface MandateImportResponse extends Types.MandateImport, Types.APIResponse {} diff --git a/src/services/mandatePdfService.ts b/src/services/mandatePdfService.ts index 64cdf2ff..076295f2 100644 --- a/src/services/mandatePdfService.ts +++ b/src/services/mandatePdfService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface MandatePdfResponse extends Types.MandatePdf, Types.APIResponse {} diff --git a/src/services/mandateService.ts b/src/services/mandateService.ts index f7f0795b..6b93e85b 100644 --- a/src/services/mandateService.ts +++ b/src/services/mandateService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface MandateResponse extends Types.Mandate, Types.APIResponse {} diff --git a/src/services/negativeBalanceLimitService.ts b/src/services/negativeBalanceLimitService.ts index 7b1c48a4..644bcc7b 100644 --- a/src/services/negativeBalanceLimitService.ts +++ b/src/services/negativeBalanceLimitService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface NegativeBalanceLimitResponse extends Types.NegativeBalanceLimit, Types.APIResponse {} diff --git a/src/services/outboundPaymentService.ts b/src/services/outboundPaymentService.ts index 758b9f16..a623d9bc 100644 --- a/src/services/outboundPaymentService.ts +++ b/src/services/outboundPaymentService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface OutboundPaymentResponse extends Types.OutboundPayment, Types.APIResponse {} diff --git a/src/services/payerAuthorisationService.ts b/src/services/payerAuthorisationService.ts index a59badb0..bd8a3a0a 100644 --- a/src/services/payerAuthorisationService.ts +++ b/src/services/payerAuthorisationService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface PayerAuthorisationResponse extends Types.PayerAuthorisation, Types.APIResponse {} diff --git a/src/services/payerThemeService.ts b/src/services/payerThemeService.ts index 486c00da..61bd868b 100644 --- a/src/services/payerThemeService.ts +++ b/src/services/payerThemeService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface PayerThemeResponse extends Types.PayerTheme, Types.APIResponse {} diff --git a/src/services/paymentAccountService.ts b/src/services/paymentAccountService.ts index 66f35616..bb1733c8 100644 --- a/src/services/paymentAccountService.ts +++ b/src/services/paymentAccountService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface PaymentAccountResponse extends Types.PaymentAccount, Types.APIResponse {} diff --git a/src/services/paymentAccountTransactionService.ts b/src/services/paymentAccountTransactionService.ts index 0124e3cb..5eb27ba3 100644 --- a/src/services/paymentAccountTransactionService.ts +++ b/src/services/paymentAccountTransactionService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface PaymentAccountTransactionResponse extends Types.PaymentAccountTransaction, Types.APIResponse {} diff --git a/src/services/paymentService.ts b/src/services/paymentService.ts index 14ae99c8..88625a6d 100644 --- a/src/services/paymentService.ts +++ b/src/services/paymentService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface PaymentResponse extends Types.Payment, Types.APIResponse {} diff --git a/src/services/payoutItemService.ts b/src/services/payoutItemService.ts index 92f0b811..3576801a 100644 --- a/src/services/payoutItemService.ts +++ b/src/services/payoutItemService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface PayoutItemResponse extends Types.PayoutItem, Types.APIResponse {} diff --git a/src/services/payoutService.ts b/src/services/payoutService.ts index 0a69303b..c5dc2dc4 100644 --- a/src/services/payoutService.ts +++ b/src/services/payoutService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface PayoutResponse extends Types.Payout, Types.APIResponse {} diff --git a/src/services/redirectFlowService.ts b/src/services/redirectFlowService.ts index 9de0db63..c916f4e0 100644 --- a/src/services/redirectFlowService.ts +++ b/src/services/redirectFlowService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface RedirectFlowResponse extends Types.RedirectFlow, Types.APIResponse {} diff --git a/src/services/refundService.ts b/src/services/refundService.ts index c228d45d..6eb03f3c 100644 --- a/src/services/refundService.ts +++ b/src/services/refundService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface RefundResponse extends Types.Refund, Types.APIResponse {} diff --git a/src/services/scenarioSimulatorService.ts b/src/services/scenarioSimulatorService.ts index 9d7cf981..026dea6f 100644 --- a/src/services/scenarioSimulatorService.ts +++ b/src/services/scenarioSimulatorService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface ScenarioSimulatorResponse extends Types.ScenarioSimulator, Types.APIResponse {} diff --git a/src/services/schemeIdentifierService.ts b/src/services/schemeIdentifierService.ts index 48282640..2fa8d403 100644 --- a/src/services/schemeIdentifierService.ts +++ b/src/services/schemeIdentifierService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface SchemeIdentifierResponse extends Types.SchemeIdentifier, Types.APIResponse {} diff --git a/src/services/subscriptionService.ts b/src/services/subscriptionService.ts index 6c671306..ee12ed52 100644 --- a/src/services/subscriptionService.ts +++ b/src/services/subscriptionService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface SubscriptionResponse extends Types.Subscription, Types.APIResponse {} diff --git a/src/services/taxRateService.ts b/src/services/taxRateService.ts index d259106c..2e496709 100644 --- a/src/services/taxRateService.ts +++ b/src/services/taxRateService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface TaxRateResponse extends Types.TaxRate, Types.APIResponse {} diff --git a/src/services/transferredMandateService.ts b/src/services/transferredMandateService.ts index 12208735..aa0b9baf 100644 --- a/src/services/transferredMandateService.ts +++ b/src/services/transferredMandateService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface TransferredMandateResponse extends Types.TransferredMandate, Types.APIResponse {} diff --git a/src/services/verificationDetailService.ts b/src/services/verificationDetailService.ts index 86049394..74cfd9d3 100644 --- a/src/services/verificationDetailService.ts +++ b/src/services/verificationDetailService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface VerificationDetailResponse extends Types.VerificationDetail, Types.APIResponse {} diff --git a/src/services/webhookService.ts b/src/services/webhookService.ts index 22b3fac9..e7d4d7bc 100644 --- a/src/services/webhookService.ts +++ b/src/services/webhookService.ts @@ -1,7 +1,5 @@ -'use strict'; - -import { Api } from '../api/api'; -import * as Types from '../types/Types'; +import { Api } from '../api/api.js'; +import * as Types from '../types/Types.js'; interface WebhookResponse extends Types.Webhook, Types.APIResponse {} diff --git a/src/webhooks.ts b/src/webhooks.ts index 2f200966..1d48a38b 100644 --- a/src/webhooks.ts +++ b/src/webhooks.ts @@ -10,7 +10,7 @@ * JSON object into an `GoCardless.Event` class. */ -import crypto from 'crypto'; +import * as crypto from 'crypto'; import { Event } from './types/Types'; function InvalidSignatureError() { diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..99fd93f9 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "newLine": "lf", + "allowJs": true, + "target": "es2018", + "pretty": true, + "moduleResolution": "node", + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "baseUrl": ".", + "noImplicitAny": false, + "noImplicitReturns": false, + "skipLibCheck": true, + "paths": { + "*": ["node_modules/*", "src/types/*"] + } + }, + "files": ["src/api/api.ts"], + "include": ["src/**/*.ts"], + "exclude": ["node_modules", "**/*.test.ts", "dist"] +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 00000000..a6f107f7 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "dist/cjs", + "declaration": false, + "declarationMap": false + } +} diff --git a/tsconfig.json b/tsconfig.json index d14a1ed9..c44d103e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,8 @@ { + "extends": "./tsconfig.base.json", "compilerOptions": { - "module": "commonjs", - "newLine": "lf", - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "allowJs": true, - "target": "es2018", - "pretty": true, - "moduleResolution": "node", - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "baseUrl": ".", - "noImplicitAny": false, - "noImplicitReturns": false, - "skipLibCheck": true, - "paths": { - "*": ["node_modules/*", "src/types/*"] - } - }, - "files": ["src/api/api.ts"], - "include": ["src/**/*.ts"], - "exclude": ["node_modules"] + "module": "esnext", + "outDir": "dist/esm", + "declarationDir": "dist/types" + } }