From e4a31c21daa4e039cad248160bcca778c4aca669 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Wed, 7 Sep 2022 10:26:19 -0700 Subject: [PATCH] Revert Typescript changes --- .eslintignore | 3 +- .eslintrc.js | 25 ----- .github/workflows/main.yml | 6 +- .gitignore | 1 - CHANGELOG.md | 6 -- OPENAPI_VERSION | 2 +- VERSION | 2 +- src/Error.ts => lib/Error.js | 92 ++++++------------- {src => lib}/ResourceNamespace.js | 0 {src => lib}/StripeMethod.basic.js | 0 src/StripeMethod.ts => lib/StripeMethod.js | 9 +- .../StripeResource.js | 35 +++---- {src => lib}/Webhooks.js | 0 {src => lib}/apiVersion.js | 0 .../autoPagination.js | 15 ++- {src => lib}/crypto/CryptoProvider.js | 0 {src => lib}/crypto/NodeCryptoProvider.js | 0 {src => lib}/crypto/SubtleCryptoProvider.js | 0 src/makeRequest.ts => lib/makeRequest.js | 4 +- {src => lib}/multipart.js | 0 {src => lib}/net/FetchHttpClient.js | 0 {src => lib}/net/HttpClient.js | 0 {src => lib}/net/NodeHttpClient.js | 0 {src => lib}/resources.js | 0 {src => lib}/resources/AccountLinks.js | 0 {src => lib}/resources/Accounts.js | 0 {src => lib}/resources/ApplePayDomains.js | 0 {src => lib}/resources/ApplicationFees.js | 0 {src => lib}/resources/Apps/Secrets.js | 0 {src => lib}/resources/Balance.js | 0 {src => lib}/resources/BalanceTransactions.js | 0 .../resources/BillingPortal/Configurations.js | 0 .../resources/BillingPortal/Sessions.js | 0 {src => lib}/resources/Charges.js | 0 {src => lib}/resources/Checkout/Sessions.js | 0 {src => lib}/resources/CountrySpecs.js | 0 {src => lib}/resources/Coupons.js | 0 {src => lib}/resources/CreditNotes.js | 0 {src => lib}/resources/Customers.js | 0 {src => lib}/resources/Disputes.js | 0 {src => lib}/resources/EphemeralKeys.js | 0 {src => lib}/resources/Events.js | 0 {src => lib}/resources/ExchangeRates.js | 0 {src => lib}/resources/FileLinks.js | 0 {src => lib}/resources/Files.js | 0 .../FinancialConnections/Accounts.js | 0 .../FinancialConnections/Sessions.js | 0 .../resources/Identity/VerificationReports.js | 0 .../Identity/VerificationSessions.js | 0 {src => lib}/resources/InvoiceItems.js | 0 {src => lib}/resources/Invoices.js | 0 .../resources/Issuing/Authorizations.js | 0 {src => lib}/resources/Issuing/Cardholders.js | 0 {src => lib}/resources/Issuing/Cards.js | 0 {src => lib}/resources/Issuing/Disputes.js | 0 .../resources/Issuing/Transactions.js | 0 {src => lib}/resources/Mandates.js | 0 {src => lib}/resources/OAuth.js | 0 {src => lib}/resources/Orders.js | 0 {src => lib}/resources/PaymentIntents.js | 0 {src => lib}/resources/PaymentLinks.js | 0 {src => lib}/resources/PaymentMethods.js | 0 {src => lib}/resources/Payouts.js | 0 {src => lib}/resources/Plans.js | 0 {src => lib}/resources/Prices.js | 0 {src => lib}/resources/Products.js | 0 {src => lib}/resources/PromotionCodes.js | 0 {src => lib}/resources/Quotes.js | 0 .../resources/Radar/EarlyFraudWarnings.js | 0 .../resources/Radar/ValueListItems.js | 0 {src => lib}/resources/Radar/ValueLists.js | 0 {src => lib}/resources/Refunds.js | 0 .../resources/Reporting/ReportRuns.js | 0 .../resources/Reporting/ReportTypes.js | 0 {src => lib}/resources/Reviews.js | 0 {src => lib}/resources/SKUs.js | 0 {src => lib}/resources/SetupAttempts.js | 0 {src => lib}/resources/SetupIntents.js | 0 {src => lib}/resources/ShippingRates.js | 0 .../resources/Sigma/ScheduledQueryRuns.js | 0 {src => lib}/resources/Sources.js | 0 {src => lib}/resources/SubscriptionItems.js | 0 .../resources/SubscriptionSchedules.js | 0 {src => lib}/resources/Subscriptions.js | 0 {src => lib}/resources/TaxCodes.js | 0 {src => lib}/resources/TaxRates.js | 0 .../resources/Terminal/Configurations.js | 0 .../resources/Terminal/ConnectionTokens.js | 0 {src => lib}/resources/Terminal/Locations.js | 0 {src => lib}/resources/Terminal/Readers.js | 0 .../resources/TestHelpers/Customers.js | 0 .../resources/TestHelpers/Issuing/Cards.js | 0 {src => lib}/resources/TestHelpers/Refunds.js | 0 .../resources/TestHelpers/Terminal/Readers.js | 0 .../resources/TestHelpers/TestClocks.js | 0 .../TestHelpers/Treasury/InboundTransfers.js | 0 .../TestHelpers/Treasury/OutboundPayments.js | 0 .../TestHelpers/Treasury/OutboundTransfers.js | 0 .../TestHelpers/Treasury/ReceivedCredits.js | 0 .../TestHelpers/Treasury/ReceivedDebits.js | 0 {src => lib}/resources/Tokens.js | 0 {src => lib}/resources/Topups.js | 0 {src => lib}/resources/Transfers.js | 0 .../resources/Treasury/CreditReversals.js | 0 .../resources/Treasury/DebitReversals.js | 0 .../resources/Treasury/FinancialAccounts.js | 0 .../resources/Treasury/InboundTransfers.js | 0 .../resources/Treasury/OutboundPayments.js | 0 .../resources/Treasury/OutboundTransfers.js | 0 .../resources/Treasury/ReceivedCredits.js | 0 .../resources/Treasury/ReceivedDebits.js | 0 .../resources/Treasury/TransactionEntries.js | 0 .../resources/Treasury/Transactions.js | 0 {src => lib}/resources/WebhookEndpoints.js | 0 src/stripe.ts => lib/stripe.js | 39 ++++---- {src => lib}/utils.js | 0 package.json | 9 +- tsconfig.json | 10 -- types/2022-08-01/Checkout/Sessions.d.ts | 2 +- types/2022-08-01/FileLinks.d.ts | 2 +- types/2022-08-01/Files.d.ts | 6 +- yarn.lock | 7 -- 122 files changed, 82 insertions(+), 193 deletions(-) rename src/Error.ts => lib/Error.js (64%) rename {src => lib}/ResourceNamespace.js (100%) rename {src => lib}/StripeMethod.basic.js (100%) rename src/StripeMethod.ts => lib/StripeMethod.js (90%) rename src/StripeResource.ts => lib/StripeResource.js (97%) rename {src => lib}/Webhooks.js (100%) rename {src => lib}/apiVersion.js (100%) rename src/autoPagination.ts => lib/autoPagination.js (96%) rename {src => lib}/crypto/CryptoProvider.js (100%) rename {src => lib}/crypto/NodeCryptoProvider.js (100%) rename {src => lib}/crypto/SubtleCryptoProvider.js (100%) rename src/makeRequest.ts => lib/makeRequest.js (98%) rename {src => lib}/multipart.js (100%) rename {src => lib}/net/FetchHttpClient.js (100%) rename {src => lib}/net/HttpClient.js (100%) rename {src => lib}/net/NodeHttpClient.js (100%) rename {src => lib}/resources.js (100%) rename {src => lib}/resources/AccountLinks.js (100%) rename {src => lib}/resources/Accounts.js (100%) rename {src => lib}/resources/ApplePayDomains.js (100%) rename {src => lib}/resources/ApplicationFees.js (100%) rename {src => lib}/resources/Apps/Secrets.js (100%) rename {src => lib}/resources/Balance.js (100%) rename {src => lib}/resources/BalanceTransactions.js (100%) rename {src => lib}/resources/BillingPortal/Configurations.js (100%) rename {src => lib}/resources/BillingPortal/Sessions.js (100%) rename {src => lib}/resources/Charges.js (100%) rename {src => lib}/resources/Checkout/Sessions.js (100%) rename {src => lib}/resources/CountrySpecs.js (100%) rename {src => lib}/resources/Coupons.js (100%) rename {src => lib}/resources/CreditNotes.js (100%) rename {src => lib}/resources/Customers.js (100%) rename {src => lib}/resources/Disputes.js (100%) rename {src => lib}/resources/EphemeralKeys.js (100%) rename {src => lib}/resources/Events.js (100%) rename {src => lib}/resources/ExchangeRates.js (100%) rename {src => lib}/resources/FileLinks.js (100%) rename {src => lib}/resources/Files.js (100%) rename {src => lib}/resources/FinancialConnections/Accounts.js (100%) rename {src => lib}/resources/FinancialConnections/Sessions.js (100%) rename {src => lib}/resources/Identity/VerificationReports.js (100%) rename {src => lib}/resources/Identity/VerificationSessions.js (100%) rename {src => lib}/resources/InvoiceItems.js (100%) rename {src => lib}/resources/Invoices.js (100%) rename {src => lib}/resources/Issuing/Authorizations.js (100%) rename {src => lib}/resources/Issuing/Cardholders.js (100%) rename {src => lib}/resources/Issuing/Cards.js (100%) rename {src => lib}/resources/Issuing/Disputes.js (100%) rename {src => lib}/resources/Issuing/Transactions.js (100%) rename {src => lib}/resources/Mandates.js (100%) rename {src => lib}/resources/OAuth.js (100%) rename {src => lib}/resources/Orders.js (100%) rename {src => lib}/resources/PaymentIntents.js (100%) rename {src => lib}/resources/PaymentLinks.js (100%) rename {src => lib}/resources/PaymentMethods.js (100%) rename {src => lib}/resources/Payouts.js (100%) rename {src => lib}/resources/Plans.js (100%) rename {src => lib}/resources/Prices.js (100%) rename {src => lib}/resources/Products.js (100%) rename {src => lib}/resources/PromotionCodes.js (100%) rename {src => lib}/resources/Quotes.js (100%) rename {src => lib}/resources/Radar/EarlyFraudWarnings.js (100%) rename {src => lib}/resources/Radar/ValueListItems.js (100%) rename {src => lib}/resources/Radar/ValueLists.js (100%) rename {src => lib}/resources/Refunds.js (100%) rename {src => lib}/resources/Reporting/ReportRuns.js (100%) rename {src => lib}/resources/Reporting/ReportTypes.js (100%) rename {src => lib}/resources/Reviews.js (100%) rename {src => lib}/resources/SKUs.js (100%) rename {src => lib}/resources/SetupAttempts.js (100%) rename {src => lib}/resources/SetupIntents.js (100%) rename {src => lib}/resources/ShippingRates.js (100%) rename {src => lib}/resources/Sigma/ScheduledQueryRuns.js (100%) rename {src => lib}/resources/Sources.js (100%) rename {src => lib}/resources/SubscriptionItems.js (100%) rename {src => lib}/resources/SubscriptionSchedules.js (100%) rename {src => lib}/resources/Subscriptions.js (100%) rename {src => lib}/resources/TaxCodes.js (100%) rename {src => lib}/resources/TaxRates.js (100%) rename {src => lib}/resources/Terminal/Configurations.js (100%) rename {src => lib}/resources/Terminal/ConnectionTokens.js (100%) rename {src => lib}/resources/Terminal/Locations.js (100%) rename {src => lib}/resources/Terminal/Readers.js (100%) rename {src => lib}/resources/TestHelpers/Customers.js (100%) rename {src => lib}/resources/TestHelpers/Issuing/Cards.js (100%) rename {src => lib}/resources/TestHelpers/Refunds.js (100%) rename {src => lib}/resources/TestHelpers/Terminal/Readers.js (100%) rename {src => lib}/resources/TestHelpers/TestClocks.js (100%) rename {src => lib}/resources/TestHelpers/Treasury/InboundTransfers.js (100%) rename {src => lib}/resources/TestHelpers/Treasury/OutboundPayments.js (100%) rename {src => lib}/resources/TestHelpers/Treasury/OutboundTransfers.js (100%) rename {src => lib}/resources/TestHelpers/Treasury/ReceivedCredits.js (100%) rename {src => lib}/resources/TestHelpers/Treasury/ReceivedDebits.js (100%) rename {src => lib}/resources/Tokens.js (100%) rename {src => lib}/resources/Topups.js (100%) rename {src => lib}/resources/Transfers.js (100%) rename {src => lib}/resources/Treasury/CreditReversals.js (100%) rename {src => lib}/resources/Treasury/DebitReversals.js (100%) rename {src => lib}/resources/Treasury/FinancialAccounts.js (100%) rename {src => lib}/resources/Treasury/InboundTransfers.js (100%) rename {src => lib}/resources/Treasury/OutboundPayments.js (100%) rename {src => lib}/resources/Treasury/OutboundTransfers.js (100%) rename {src => lib}/resources/Treasury/ReceivedCredits.js (100%) rename {src => lib}/resources/Treasury/ReceivedDebits.js (100%) rename {src => lib}/resources/Treasury/TransactionEntries.js (100%) rename {src => lib}/resources/Treasury/Transactions.js (100%) rename {src => lib}/resources/WebhookEndpoints.js (100%) rename src/stripe.ts => lib/stripe.js (94%) rename {src => lib}/utils.js (100%) delete mode 100644 tsconfig.json diff --git a/.eslintignore b/.eslintignore index aaaf6b9a4c..a6de844ce0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,2 @@ *.node*.js -node_modules -lib +node_modules \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 0f3c0a64f4..5111f4c6da 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -249,29 +249,4 @@ module.exports = { }, plugins: ['prettier'], extends: ['plugin:prettier/recommended'], - overrides: [ - { - files: ["**/*.ts"], - parser: "@typescript-eslint/parser", - plugins: ['@typescript-eslint', 'prettier'], - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - rules: { - '@typescript-eslint/no-use-before-define': 0, - '@typescript-eslint/no-empty-interface': 0, - '@typescript-eslint/no-unused-vars': 0, - '@typescript-eslint/triple-slash-reference': 0, - '@typescript-eslint/ban-ts-ignore': 0, - '@typescript-eslint/no-empty-function': 0, - '@typescript-eslint/camelcase': 0, - '@typescript-eslint/no-explicit-any': 0, - '@typescript-eslint/explicit-function-return-type': 0, - 'prefer-rest-params': 'off', - }, - }, - ], }; diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 07a9335515..61f9d08d3e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,11 +41,11 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - - name: Build Typescript - run: yarn && yarn build + - name: Node check + run: find . -name "*.js" -type f -not -path "./node_modules/*" -not -path "./\.*" -exec node --check {} \; - name: Lint - run: yarn lint + run: yarn && yarn lint test: name: Test (${{ matrix.node }}) diff --git a/.gitignore b/.gitignore index 9c0b948ea6..ee483f2f9d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ tags .nyc_output coverage .idea -lib diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d1a8a8020..e35d7713c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,5 @@ # Changelog -## 10.8.0 - 2022-09-06 -* [#1544](https://github.com/stripe/stripe-node/pull/1544) API Updates - * Add support for new value `terminal_reader_splashscreen` on enums `File.purpose` and `FileListParams.purpose` -* [#1543](https://github.com/stripe/stripe-node/pull/1543) Migrate Stripe infrastructure to Typescript -* [#1539](https://github.com/stripe/stripe-node/pull/1539) Build Typescript and migrate StripeResource - ## 10.7.0 - 2022-08-31 * [#1540](https://github.com/stripe/stripe-node/pull/1540) API Updates * Add support for new values `de-CH`, `en-CH`, `en-PL`, `en-PT`, `fr-CH`, `it-CH`, `pl-PL`, and `pt-PT` on enums `OrderCreateParams.payment.settings.payment_method_options.klarna.preferred_locale`, `OrderUpdateParams.payment.settings.payment_method_options.klarna.preferred_locale`, `PaymentIntentConfirmParams.payment_method_options.klarna.preferred_locale`, `PaymentIntentCreateParams.payment_method_options.klarna.preferred_locale`, and `PaymentIntentUpdateParams.payment_method_options.klarna.preferred_locale` diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index ffd0a4e351..169d5f2568 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v189 \ No newline at end of file +v188 \ No newline at end of file diff --git a/VERSION b/VERSION index 2a3262d8a9..1bcdaf5fec 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.8.0 +10.7.0 diff --git a/src/Error.ts b/lib/Error.js similarity index 64% rename from src/Error.ts rename to lib/Error.js index 5a2ebaa72e..2ad52c931a 100644 --- a/src/Error.ts +++ b/lib/Error.js @@ -1,63 +1,11 @@ 'use strict'; -type RawErrorType = - | 'card_error' - | 'invalid_request_error' - | 'api_error' - | 'idempotency_error' - | 'rate_limit_error' - | 'authentication_error' - | 'invalid_grant'; - -type StripeRawError = { - message?: string; - type?: RawErrorType; - - headers?: {[header: string]: string}; - statusCode?: number; - requestId?: string; - code?: string; - doc_url?: string; - decline_code?: string; - param?: string; - detail?: string; - charge?: string; - payment_method_type?: string; - - payment_intent?: any; - payment_method?: any; - setup_intent?: any; - source?: any; - exception?: any; -}; - /** * StripeError is the base error from which all other more specific Stripe errors derive. * Specifically for errors returned from Stripe's REST API. */ -export class StripeError extends Error { - readonly message: string; - readonly type: string; - readonly raw: unknown; - readonly rawType: RawErrorType; - readonly headers: {[header: string]: string}; - readonly requestId: string; - - readonly code?: string; - readonly doc_url?: string; - readonly param?: string; - readonly detail?: string; - readonly statusCode?: number; - readonly charge?: string; - readonly decline_code?: string; - readonly payment_method_type?: string; - - readonly payment_intent?: any; - readonly payment_method?: any; - readonly setup_intent?: any; - readonly source?: any; - - constructor(raw: StripeRawError) { +class StripeError extends Error { + constructor(raw = {}) { super(raw.message); this.type = this.constructor.name; @@ -112,13 +60,13 @@ export class StripeError extends Error { * CardError is raised when a user enters a card that can't be charged for * some reason. */ -export class StripeCardError extends StripeError {} +class StripeCardError extends StripeError {} /** * InvalidRequestError is raised when a request is initiated with invalid * parameters. */ -export class StripeInvalidRequestError extends StripeError {} +class StripeInvalidRequestError extends StripeError {} /** * APIError is a generic error that may be raised in cases where none of the @@ -126,45 +74,45 @@ export class StripeInvalidRequestError extends StripeError {} * that a new error has been introduced in the API, but this version of the * Node.JS SDK doesn't know how to handle it. */ -export class StripeAPIError extends StripeError {} +class StripeAPIError extends StripeError {} /** * AuthenticationError is raised when invalid credentials are used to connect * to Stripe's servers. */ -export class StripeAuthenticationError extends StripeError {} +class StripeAuthenticationError extends StripeError {} /** * PermissionError is raised in cases where access was attempted on a resource * that wasn't allowed. */ -export class StripePermissionError extends StripeError {} +class StripePermissionError extends StripeError {} /** * RateLimitError is raised in cases where an account is putting too much load * on Stripe's API servers (usually by performing too many requests). Please * back off on request rate. */ -export class StripeRateLimitError extends StripeError {} +class StripeRateLimitError extends StripeError {} /** * StripeConnectionError is raised in the event that the SDK can't connect to * Stripe's servers. That can be for a variety of different reasons from a * downed network to a bad TLS certificate. */ -export class StripeConnectionError extends StripeError {} +class StripeConnectionError extends StripeError {} /** * SignatureVerificationError is raised when the signature verification for a * webhook fails */ -export class StripeSignatureVerificationError extends StripeError {} +class StripeSignatureVerificationError extends StripeError {} /** * IdempotencyError is raised in cases where an idempotency key was used * improperly. */ -export class StripeIdempotencyError extends StripeError {} +class StripeIdempotencyError extends StripeError {} /** * InvalidGrantError is raised when a specified code doesn't exist, is @@ -172,9 +120,23 @@ export class StripeIdempotencyError extends StripeError {} * exist, or doesn't belong to you; or if an API key's mode (live or test) * doesn't match the mode of a code or refresh token. */ -export class StripeInvalidGrantError extends StripeError {} +class StripeInvalidGrantError extends StripeError {} /** * Any other error from Stripe not specifically captured above */ -export class StripeUnknownError extends StripeError {} +class StripeUnknownError extends StripeError {} + +module.exports.generate = StripeError.generate; +module.exports.StripeError = StripeError; +module.exports.StripeCardError = StripeCardError; +module.exports.StripeInvalidRequestError = StripeInvalidRequestError; +module.exports.StripeAPIError = StripeAPIError; +module.exports.StripeAuthenticationError = StripeAuthenticationError; +module.exports.StripePermissionError = StripePermissionError; +module.exports.StripeRateLimitError = StripeRateLimitError; +module.exports.StripeConnectionError = StripeConnectionError; +module.exports.StripeSignatureVerificationError = StripeSignatureVerificationError; +module.exports.StripeIdempotencyError = StripeIdempotencyError; +module.exports.StripeInvalidGrantError = StripeInvalidGrantError; +module.exports.StripeUnknownError = StripeUnknownError; diff --git a/src/ResourceNamespace.js b/lib/ResourceNamespace.js similarity index 100% rename from src/ResourceNamespace.js rename to lib/ResourceNamespace.js diff --git a/src/StripeMethod.basic.js b/lib/StripeMethod.basic.js similarity index 100% rename from src/StripeMethod.basic.js rename to lib/StripeMethod.basic.js diff --git a/src/StripeMethod.ts b/lib/StripeMethod.js similarity index 90% rename from src/StripeMethod.ts rename to lib/StripeMethod.js index 3102ff95a9..78018da23a 100644 --- a/src/StripeMethod.ts +++ b/lib/StripeMethod.js @@ -1,8 +1,9 @@ 'use strict'; -import utils = require('./utils'); -import makeRequest = require('./makeRequest'); -import {makeAutoPaginationMethods} from './autoPagination'; +const utils = require('./utils'); +const makeRequest = require('./makeRequest'); +const makeAutoPaginationMethods = require('./autoPagination') + .makeAutoPaginationMethods; /** * Create an API method from the declared spec. @@ -54,4 +55,4 @@ function stripeMethod(spec) { }; } -export = stripeMethod; +module.exports = stripeMethod; diff --git a/src/StripeResource.ts b/lib/StripeResource.js similarity index 97% rename from src/StripeResource.ts rename to lib/StripeResource.js index 1943251201..f56bb9bc72 100644 --- a/src/StripeResource.ts +++ b/lib/StripeResource.js @@ -1,26 +1,16 @@ 'use strict'; -import utils = require('./utils'); -import { - StripeAPIError, - StripeAuthenticationError, +const utils = require('./utils'); +const { StripeConnectionError, - StripeError, + StripeAuthenticationError, StripePermissionError, StripeRateLimitError, -} from './Error'; - -import {HttpClient} from './net/HttpClient'; - -type Settings = { - timeout?: number; -}; + StripeError, + StripeAPIError, +} = require('./Error'); -type Options = { - settings?: Settings; - streaming?: boolean; - headers?: Record; -}; +const {HttpClient} = require('./net/HttpClient'); // Provide extension mechanism for Stripe Resource Sub-Classes StripeResource.extend = utils.protoExtend; @@ -123,7 +113,7 @@ StripeResource.prototype = { _timeoutHandler(timeout, req, callback) { return () => { const timeoutErr = new TypeError('ETIMEDOUT'); - (timeoutErr as any).code = 'ETIMEDOUT'; + timeoutErr.code = 'ETIMEDOUT'; req.destroy(timeoutErr); }; @@ -293,7 +283,7 @@ StripeResource.prototype = { this, new StripeConnectionError({ message: this._generateConnectionErrorMessage(requestRetries), - detail, + detail: error, }), null ); @@ -374,7 +364,7 @@ StripeResource.prototype = { }, // Max retries can be set on a per request basis. Favor those over the global setting - _getMaxNetworkRetries(settings: {maxNetworkRetries?: number} = {}) { + _getMaxNetworkRetries(settings = {}) { return settings.maxNetworkRetries && Number.isInteger(settings.maxNetworkRetries) ? settings.maxNetworkRetries @@ -490,7 +480,7 @@ StripeResource.prototype = { } }, - _request(method, host, path, data, auth, options: Options = {}, callback) { + _request(method, host, path, data, auth, options = {}, callback) { let requestData; const retryRequest = ( @@ -513,7 +503,6 @@ StripeResource.prototype = { // timeout can be set on a per-request basis. Favor that over the global setting const timeout = options.settings && - options.settings.timeout && Number.isInteger(options.settings.timeout) && options.settings.timeout >= 0 ? options.settings.timeout @@ -610,7 +599,7 @@ StripeResource.prototype = { options.settings ); - makeRequest(apiVersion, headers, 0); + makeRequest(apiVersion, headers); }); }; diff --git a/src/Webhooks.js b/lib/Webhooks.js similarity index 100% rename from src/Webhooks.js rename to lib/Webhooks.js diff --git a/src/apiVersion.js b/lib/apiVersion.js similarity index 100% rename from src/apiVersion.js rename to lib/apiVersion.js diff --git a/src/autoPagination.ts b/lib/autoPagination.js similarity index 96% rename from src/autoPagination.ts rename to lib/autoPagination.js index e956bf0036..fe6f1f15b6 100644 --- a/src/autoPagination.ts +++ b/lib/autoPagination.js @@ -1,14 +1,9 @@ 'use strict'; -import utils = require('./utils'); -import makeRequest = require('./makeRequest'); +const makeRequest = require('./makeRequest'); +const utils = require('./utils'); -export function makeAutoPaginationMethods( - self, - requestArgs, - spec, - firstPagePromise -) { +function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { const promiseCache = {currentPromise: null}; const reverseIteration = isReverseIteration(requestArgs); let pagePromise = firstPagePromise; @@ -99,6 +94,8 @@ export function makeAutoPaginationMethods( return autoPaginationMethods; } +module.exports.makeAutoPaginationMethods = makeAutoPaginationMethods; + /** * ---------------- * Private Helpers: @@ -245,7 +242,7 @@ function makeAutoPagingToArray(autoPagingEach) { } function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { function handleIteration(iterResult) { if (iterResult.done) { resolve(); diff --git a/src/crypto/CryptoProvider.js b/lib/crypto/CryptoProvider.js similarity index 100% rename from src/crypto/CryptoProvider.js rename to lib/crypto/CryptoProvider.js diff --git a/src/crypto/NodeCryptoProvider.js b/lib/crypto/NodeCryptoProvider.js similarity index 100% rename from src/crypto/NodeCryptoProvider.js rename to lib/crypto/NodeCryptoProvider.js diff --git a/src/crypto/SubtleCryptoProvider.js b/lib/crypto/SubtleCryptoProvider.js similarity index 100% rename from src/crypto/SubtleCryptoProvider.js rename to lib/crypto/SubtleCryptoProvider.js diff --git a/src/makeRequest.ts b/lib/makeRequest.js similarity index 98% rename from src/makeRequest.ts rename to lib/makeRequest.js index b37d106ce5..7ea0737b73 100644 --- a/src/makeRequest.ts +++ b/lib/makeRequest.js @@ -1,6 +1,6 @@ 'use strict'; -import utils = require('./utils'); +const utils = require('./utils'); function getRequestOpts(self, requestArgs, spec, overrideData) { // Extract spec values with defaults. @@ -119,4 +119,4 @@ function makeRequest(self, requestArgs, spec, overrideData) { }); } -export = makeRequest; +module.exports = makeRequest; diff --git a/src/multipart.js b/lib/multipart.js similarity index 100% rename from src/multipart.js rename to lib/multipart.js diff --git a/src/net/FetchHttpClient.js b/lib/net/FetchHttpClient.js similarity index 100% rename from src/net/FetchHttpClient.js rename to lib/net/FetchHttpClient.js diff --git a/src/net/HttpClient.js b/lib/net/HttpClient.js similarity index 100% rename from src/net/HttpClient.js rename to lib/net/HttpClient.js diff --git a/src/net/NodeHttpClient.js b/lib/net/NodeHttpClient.js similarity index 100% rename from src/net/NodeHttpClient.js rename to lib/net/NodeHttpClient.js diff --git a/src/resources.js b/lib/resources.js similarity index 100% rename from src/resources.js rename to lib/resources.js diff --git a/src/resources/AccountLinks.js b/lib/resources/AccountLinks.js similarity index 100% rename from src/resources/AccountLinks.js rename to lib/resources/AccountLinks.js diff --git a/src/resources/Accounts.js b/lib/resources/Accounts.js similarity index 100% rename from src/resources/Accounts.js rename to lib/resources/Accounts.js diff --git a/src/resources/ApplePayDomains.js b/lib/resources/ApplePayDomains.js similarity index 100% rename from src/resources/ApplePayDomains.js rename to lib/resources/ApplePayDomains.js diff --git a/src/resources/ApplicationFees.js b/lib/resources/ApplicationFees.js similarity index 100% rename from src/resources/ApplicationFees.js rename to lib/resources/ApplicationFees.js diff --git a/src/resources/Apps/Secrets.js b/lib/resources/Apps/Secrets.js similarity index 100% rename from src/resources/Apps/Secrets.js rename to lib/resources/Apps/Secrets.js diff --git a/src/resources/Balance.js b/lib/resources/Balance.js similarity index 100% rename from src/resources/Balance.js rename to lib/resources/Balance.js diff --git a/src/resources/BalanceTransactions.js b/lib/resources/BalanceTransactions.js similarity index 100% rename from src/resources/BalanceTransactions.js rename to lib/resources/BalanceTransactions.js diff --git a/src/resources/BillingPortal/Configurations.js b/lib/resources/BillingPortal/Configurations.js similarity index 100% rename from src/resources/BillingPortal/Configurations.js rename to lib/resources/BillingPortal/Configurations.js diff --git a/src/resources/BillingPortal/Sessions.js b/lib/resources/BillingPortal/Sessions.js similarity index 100% rename from src/resources/BillingPortal/Sessions.js rename to lib/resources/BillingPortal/Sessions.js diff --git a/src/resources/Charges.js b/lib/resources/Charges.js similarity index 100% rename from src/resources/Charges.js rename to lib/resources/Charges.js diff --git a/src/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js similarity index 100% rename from src/resources/Checkout/Sessions.js rename to lib/resources/Checkout/Sessions.js diff --git a/src/resources/CountrySpecs.js b/lib/resources/CountrySpecs.js similarity index 100% rename from src/resources/CountrySpecs.js rename to lib/resources/CountrySpecs.js diff --git a/src/resources/Coupons.js b/lib/resources/Coupons.js similarity index 100% rename from src/resources/Coupons.js rename to lib/resources/Coupons.js diff --git a/src/resources/CreditNotes.js b/lib/resources/CreditNotes.js similarity index 100% rename from src/resources/CreditNotes.js rename to lib/resources/CreditNotes.js diff --git a/src/resources/Customers.js b/lib/resources/Customers.js similarity index 100% rename from src/resources/Customers.js rename to lib/resources/Customers.js diff --git a/src/resources/Disputes.js b/lib/resources/Disputes.js similarity index 100% rename from src/resources/Disputes.js rename to lib/resources/Disputes.js diff --git a/src/resources/EphemeralKeys.js b/lib/resources/EphemeralKeys.js similarity index 100% rename from src/resources/EphemeralKeys.js rename to lib/resources/EphemeralKeys.js diff --git a/src/resources/Events.js b/lib/resources/Events.js similarity index 100% rename from src/resources/Events.js rename to lib/resources/Events.js diff --git a/src/resources/ExchangeRates.js b/lib/resources/ExchangeRates.js similarity index 100% rename from src/resources/ExchangeRates.js rename to lib/resources/ExchangeRates.js diff --git a/src/resources/FileLinks.js b/lib/resources/FileLinks.js similarity index 100% rename from src/resources/FileLinks.js rename to lib/resources/FileLinks.js diff --git a/src/resources/Files.js b/lib/resources/Files.js similarity index 100% rename from src/resources/Files.js rename to lib/resources/Files.js diff --git a/src/resources/FinancialConnections/Accounts.js b/lib/resources/FinancialConnections/Accounts.js similarity index 100% rename from src/resources/FinancialConnections/Accounts.js rename to lib/resources/FinancialConnections/Accounts.js diff --git a/src/resources/FinancialConnections/Sessions.js b/lib/resources/FinancialConnections/Sessions.js similarity index 100% rename from src/resources/FinancialConnections/Sessions.js rename to lib/resources/FinancialConnections/Sessions.js diff --git a/src/resources/Identity/VerificationReports.js b/lib/resources/Identity/VerificationReports.js similarity index 100% rename from src/resources/Identity/VerificationReports.js rename to lib/resources/Identity/VerificationReports.js diff --git a/src/resources/Identity/VerificationSessions.js b/lib/resources/Identity/VerificationSessions.js similarity index 100% rename from src/resources/Identity/VerificationSessions.js rename to lib/resources/Identity/VerificationSessions.js diff --git a/src/resources/InvoiceItems.js b/lib/resources/InvoiceItems.js similarity index 100% rename from src/resources/InvoiceItems.js rename to lib/resources/InvoiceItems.js diff --git a/src/resources/Invoices.js b/lib/resources/Invoices.js similarity index 100% rename from src/resources/Invoices.js rename to lib/resources/Invoices.js diff --git a/src/resources/Issuing/Authorizations.js b/lib/resources/Issuing/Authorizations.js similarity index 100% rename from src/resources/Issuing/Authorizations.js rename to lib/resources/Issuing/Authorizations.js diff --git a/src/resources/Issuing/Cardholders.js b/lib/resources/Issuing/Cardholders.js similarity index 100% rename from src/resources/Issuing/Cardholders.js rename to lib/resources/Issuing/Cardholders.js diff --git a/src/resources/Issuing/Cards.js b/lib/resources/Issuing/Cards.js similarity index 100% rename from src/resources/Issuing/Cards.js rename to lib/resources/Issuing/Cards.js diff --git a/src/resources/Issuing/Disputes.js b/lib/resources/Issuing/Disputes.js similarity index 100% rename from src/resources/Issuing/Disputes.js rename to lib/resources/Issuing/Disputes.js diff --git a/src/resources/Issuing/Transactions.js b/lib/resources/Issuing/Transactions.js similarity index 100% rename from src/resources/Issuing/Transactions.js rename to lib/resources/Issuing/Transactions.js diff --git a/src/resources/Mandates.js b/lib/resources/Mandates.js similarity index 100% rename from src/resources/Mandates.js rename to lib/resources/Mandates.js diff --git a/src/resources/OAuth.js b/lib/resources/OAuth.js similarity index 100% rename from src/resources/OAuth.js rename to lib/resources/OAuth.js diff --git a/src/resources/Orders.js b/lib/resources/Orders.js similarity index 100% rename from src/resources/Orders.js rename to lib/resources/Orders.js diff --git a/src/resources/PaymentIntents.js b/lib/resources/PaymentIntents.js similarity index 100% rename from src/resources/PaymentIntents.js rename to lib/resources/PaymentIntents.js diff --git a/src/resources/PaymentLinks.js b/lib/resources/PaymentLinks.js similarity index 100% rename from src/resources/PaymentLinks.js rename to lib/resources/PaymentLinks.js diff --git a/src/resources/PaymentMethods.js b/lib/resources/PaymentMethods.js similarity index 100% rename from src/resources/PaymentMethods.js rename to lib/resources/PaymentMethods.js diff --git a/src/resources/Payouts.js b/lib/resources/Payouts.js similarity index 100% rename from src/resources/Payouts.js rename to lib/resources/Payouts.js diff --git a/src/resources/Plans.js b/lib/resources/Plans.js similarity index 100% rename from src/resources/Plans.js rename to lib/resources/Plans.js diff --git a/src/resources/Prices.js b/lib/resources/Prices.js similarity index 100% rename from src/resources/Prices.js rename to lib/resources/Prices.js diff --git a/src/resources/Products.js b/lib/resources/Products.js similarity index 100% rename from src/resources/Products.js rename to lib/resources/Products.js diff --git a/src/resources/PromotionCodes.js b/lib/resources/PromotionCodes.js similarity index 100% rename from src/resources/PromotionCodes.js rename to lib/resources/PromotionCodes.js diff --git a/src/resources/Quotes.js b/lib/resources/Quotes.js similarity index 100% rename from src/resources/Quotes.js rename to lib/resources/Quotes.js diff --git a/src/resources/Radar/EarlyFraudWarnings.js b/lib/resources/Radar/EarlyFraudWarnings.js similarity index 100% rename from src/resources/Radar/EarlyFraudWarnings.js rename to lib/resources/Radar/EarlyFraudWarnings.js diff --git a/src/resources/Radar/ValueListItems.js b/lib/resources/Radar/ValueListItems.js similarity index 100% rename from src/resources/Radar/ValueListItems.js rename to lib/resources/Radar/ValueListItems.js diff --git a/src/resources/Radar/ValueLists.js b/lib/resources/Radar/ValueLists.js similarity index 100% rename from src/resources/Radar/ValueLists.js rename to lib/resources/Radar/ValueLists.js diff --git a/src/resources/Refunds.js b/lib/resources/Refunds.js similarity index 100% rename from src/resources/Refunds.js rename to lib/resources/Refunds.js diff --git a/src/resources/Reporting/ReportRuns.js b/lib/resources/Reporting/ReportRuns.js similarity index 100% rename from src/resources/Reporting/ReportRuns.js rename to lib/resources/Reporting/ReportRuns.js diff --git a/src/resources/Reporting/ReportTypes.js b/lib/resources/Reporting/ReportTypes.js similarity index 100% rename from src/resources/Reporting/ReportTypes.js rename to lib/resources/Reporting/ReportTypes.js diff --git a/src/resources/Reviews.js b/lib/resources/Reviews.js similarity index 100% rename from src/resources/Reviews.js rename to lib/resources/Reviews.js diff --git a/src/resources/SKUs.js b/lib/resources/SKUs.js similarity index 100% rename from src/resources/SKUs.js rename to lib/resources/SKUs.js diff --git a/src/resources/SetupAttempts.js b/lib/resources/SetupAttempts.js similarity index 100% rename from src/resources/SetupAttempts.js rename to lib/resources/SetupAttempts.js diff --git a/src/resources/SetupIntents.js b/lib/resources/SetupIntents.js similarity index 100% rename from src/resources/SetupIntents.js rename to lib/resources/SetupIntents.js diff --git a/src/resources/ShippingRates.js b/lib/resources/ShippingRates.js similarity index 100% rename from src/resources/ShippingRates.js rename to lib/resources/ShippingRates.js diff --git a/src/resources/Sigma/ScheduledQueryRuns.js b/lib/resources/Sigma/ScheduledQueryRuns.js similarity index 100% rename from src/resources/Sigma/ScheduledQueryRuns.js rename to lib/resources/Sigma/ScheduledQueryRuns.js diff --git a/src/resources/Sources.js b/lib/resources/Sources.js similarity index 100% rename from src/resources/Sources.js rename to lib/resources/Sources.js diff --git a/src/resources/SubscriptionItems.js b/lib/resources/SubscriptionItems.js similarity index 100% rename from src/resources/SubscriptionItems.js rename to lib/resources/SubscriptionItems.js diff --git a/src/resources/SubscriptionSchedules.js b/lib/resources/SubscriptionSchedules.js similarity index 100% rename from src/resources/SubscriptionSchedules.js rename to lib/resources/SubscriptionSchedules.js diff --git a/src/resources/Subscriptions.js b/lib/resources/Subscriptions.js similarity index 100% rename from src/resources/Subscriptions.js rename to lib/resources/Subscriptions.js diff --git a/src/resources/TaxCodes.js b/lib/resources/TaxCodes.js similarity index 100% rename from src/resources/TaxCodes.js rename to lib/resources/TaxCodes.js diff --git a/src/resources/TaxRates.js b/lib/resources/TaxRates.js similarity index 100% rename from src/resources/TaxRates.js rename to lib/resources/TaxRates.js diff --git a/src/resources/Terminal/Configurations.js b/lib/resources/Terminal/Configurations.js similarity index 100% rename from src/resources/Terminal/Configurations.js rename to lib/resources/Terminal/Configurations.js diff --git a/src/resources/Terminal/ConnectionTokens.js b/lib/resources/Terminal/ConnectionTokens.js similarity index 100% rename from src/resources/Terminal/ConnectionTokens.js rename to lib/resources/Terminal/ConnectionTokens.js diff --git a/src/resources/Terminal/Locations.js b/lib/resources/Terminal/Locations.js similarity index 100% rename from src/resources/Terminal/Locations.js rename to lib/resources/Terminal/Locations.js diff --git a/src/resources/Terminal/Readers.js b/lib/resources/Terminal/Readers.js similarity index 100% rename from src/resources/Terminal/Readers.js rename to lib/resources/Terminal/Readers.js diff --git a/src/resources/TestHelpers/Customers.js b/lib/resources/TestHelpers/Customers.js similarity index 100% rename from src/resources/TestHelpers/Customers.js rename to lib/resources/TestHelpers/Customers.js diff --git a/src/resources/TestHelpers/Issuing/Cards.js b/lib/resources/TestHelpers/Issuing/Cards.js similarity index 100% rename from src/resources/TestHelpers/Issuing/Cards.js rename to lib/resources/TestHelpers/Issuing/Cards.js diff --git a/src/resources/TestHelpers/Refunds.js b/lib/resources/TestHelpers/Refunds.js similarity index 100% rename from src/resources/TestHelpers/Refunds.js rename to lib/resources/TestHelpers/Refunds.js diff --git a/src/resources/TestHelpers/Terminal/Readers.js b/lib/resources/TestHelpers/Terminal/Readers.js similarity index 100% rename from src/resources/TestHelpers/Terminal/Readers.js rename to lib/resources/TestHelpers/Terminal/Readers.js diff --git a/src/resources/TestHelpers/TestClocks.js b/lib/resources/TestHelpers/TestClocks.js similarity index 100% rename from src/resources/TestHelpers/TestClocks.js rename to lib/resources/TestHelpers/TestClocks.js diff --git a/src/resources/TestHelpers/Treasury/InboundTransfers.js b/lib/resources/TestHelpers/Treasury/InboundTransfers.js similarity index 100% rename from src/resources/TestHelpers/Treasury/InboundTransfers.js rename to lib/resources/TestHelpers/Treasury/InboundTransfers.js diff --git a/src/resources/TestHelpers/Treasury/OutboundPayments.js b/lib/resources/TestHelpers/Treasury/OutboundPayments.js similarity index 100% rename from src/resources/TestHelpers/Treasury/OutboundPayments.js rename to lib/resources/TestHelpers/Treasury/OutboundPayments.js diff --git a/src/resources/TestHelpers/Treasury/OutboundTransfers.js b/lib/resources/TestHelpers/Treasury/OutboundTransfers.js similarity index 100% rename from src/resources/TestHelpers/Treasury/OutboundTransfers.js rename to lib/resources/TestHelpers/Treasury/OutboundTransfers.js diff --git a/src/resources/TestHelpers/Treasury/ReceivedCredits.js b/lib/resources/TestHelpers/Treasury/ReceivedCredits.js similarity index 100% rename from src/resources/TestHelpers/Treasury/ReceivedCredits.js rename to lib/resources/TestHelpers/Treasury/ReceivedCredits.js diff --git a/src/resources/TestHelpers/Treasury/ReceivedDebits.js b/lib/resources/TestHelpers/Treasury/ReceivedDebits.js similarity index 100% rename from src/resources/TestHelpers/Treasury/ReceivedDebits.js rename to lib/resources/TestHelpers/Treasury/ReceivedDebits.js diff --git a/src/resources/Tokens.js b/lib/resources/Tokens.js similarity index 100% rename from src/resources/Tokens.js rename to lib/resources/Tokens.js diff --git a/src/resources/Topups.js b/lib/resources/Topups.js similarity index 100% rename from src/resources/Topups.js rename to lib/resources/Topups.js diff --git a/src/resources/Transfers.js b/lib/resources/Transfers.js similarity index 100% rename from src/resources/Transfers.js rename to lib/resources/Transfers.js diff --git a/src/resources/Treasury/CreditReversals.js b/lib/resources/Treasury/CreditReversals.js similarity index 100% rename from src/resources/Treasury/CreditReversals.js rename to lib/resources/Treasury/CreditReversals.js diff --git a/src/resources/Treasury/DebitReversals.js b/lib/resources/Treasury/DebitReversals.js similarity index 100% rename from src/resources/Treasury/DebitReversals.js rename to lib/resources/Treasury/DebitReversals.js diff --git a/src/resources/Treasury/FinancialAccounts.js b/lib/resources/Treasury/FinancialAccounts.js similarity index 100% rename from src/resources/Treasury/FinancialAccounts.js rename to lib/resources/Treasury/FinancialAccounts.js diff --git a/src/resources/Treasury/InboundTransfers.js b/lib/resources/Treasury/InboundTransfers.js similarity index 100% rename from src/resources/Treasury/InboundTransfers.js rename to lib/resources/Treasury/InboundTransfers.js diff --git a/src/resources/Treasury/OutboundPayments.js b/lib/resources/Treasury/OutboundPayments.js similarity index 100% rename from src/resources/Treasury/OutboundPayments.js rename to lib/resources/Treasury/OutboundPayments.js diff --git a/src/resources/Treasury/OutboundTransfers.js b/lib/resources/Treasury/OutboundTransfers.js similarity index 100% rename from src/resources/Treasury/OutboundTransfers.js rename to lib/resources/Treasury/OutboundTransfers.js diff --git a/src/resources/Treasury/ReceivedCredits.js b/lib/resources/Treasury/ReceivedCredits.js similarity index 100% rename from src/resources/Treasury/ReceivedCredits.js rename to lib/resources/Treasury/ReceivedCredits.js diff --git a/src/resources/Treasury/ReceivedDebits.js b/lib/resources/Treasury/ReceivedDebits.js similarity index 100% rename from src/resources/Treasury/ReceivedDebits.js rename to lib/resources/Treasury/ReceivedDebits.js diff --git a/src/resources/Treasury/TransactionEntries.js b/lib/resources/Treasury/TransactionEntries.js similarity index 100% rename from src/resources/Treasury/TransactionEntries.js rename to lib/resources/Treasury/TransactionEntries.js diff --git a/src/resources/Treasury/Transactions.js b/lib/resources/Treasury/Transactions.js similarity index 100% rename from src/resources/Treasury/Transactions.js rename to lib/resources/Treasury/Transactions.js diff --git a/src/resources/WebhookEndpoints.js b/lib/resources/WebhookEndpoints.js similarity index 100% rename from src/resources/WebhookEndpoints.js rename to lib/resources/WebhookEndpoints.js diff --git a/src/stripe.ts b/lib/stripe.js similarity index 94% rename from src/stripe.ts rename to lib/stripe.js index c0a6253c66..f928ee5a51 100644 --- a/src/stripe.ts +++ b/lib/stripe.js @@ -1,15 +1,6 @@ 'use strict'; -import resources = require('./resources'); -import utils = require('./utils'); - -import {HttpClient, HttpClientResponse} from './net/HttpClient'; -import {FetchHttpClient} from './net/FetchHttpClient'; -import {NodeHttpClient} from './net/NodeHttpClient'; - -import CryptoProvider = require('./crypto/CryptoProvider'); -import NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); -import SubtleCryptoProvider = require('./crypto/SubtleCryptoProvider'); +const resources = require('./resources'); const DEFAULT_HOST = 'api.stripe.com'; const DEFAULT_PORT = '443'; @@ -20,6 +11,7 @@ const DEFAULT_TIMEOUT = 80000; Stripe.PACKAGE_VERSION = require('../package.json').version; +const utils = require('./utils'); const {determineProcessUserAgentProperties, emitWarning} = utils; Stripe.USER_AGENT = { @@ -58,14 +50,16 @@ const EventEmitter = require('events').EventEmitter; Stripe.StripeResource = require('./StripeResource'); Stripe.resources = resources; +const {HttpClient, HttpClientResponse} = require('./net/HttpClient'); Stripe.HttpClient = HttpClient; Stripe.HttpClientResponse = HttpClientResponse; +const CryptoProvider = require('./crypto/CryptoProvider'); Stripe.CryptoProvider = CryptoProvider; function Stripe(key, config = {}) { if (!(this instanceof Stripe)) { - return new (Stripe as any)(key, config); + return new Stripe(key, config); } const props = this._getPropsFromConfig(config); @@ -144,6 +138,7 @@ Stripe.errors = require('./Error'); Stripe.webhooks = require('./Webhooks'); Stripe.createNodeHttpClient = (agent) => { + const {NodeHttpClient} = require('./net/NodeHttpClient'); return new NodeHttpClient(agent); }; @@ -155,6 +150,7 @@ Stripe.createNodeHttpClient = (agent) => { * passed, will default to the default `fetch` function in the global scope. */ Stripe.createFetchHttpClient = (fetchFn) => { + const {FetchHttpClient} = require('./net/FetchHttpClient'); return new FetchHttpClient(fetchFn); }; @@ -163,6 +159,7 @@ Stripe.createFetchHttpClient = (fetchFn) => { * its crypto operations. */ Stripe.createNodeCryptoProvider = () => { + const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); return new NodeCryptoProvider(); }; @@ -175,6 +172,7 @@ Stripe.createNodeCryptoProvider = () => { * scope. */ Stripe.createSubtleCryptoProvider = (subtleCrypto) => { + const SubtleCryptoProvider = require('./crypto/SubtleCryptoProvider'); return new SubtleCryptoProvider(subtleCrypto); }; @@ -328,18 +326,15 @@ Stripe.prototype = { info = info || {}; - const appInfo = APP_INFO_PROPERTIES.reduce( - (accum: Record, prop) => { - if (typeof info[prop] == 'string') { - accum = accum || {}; + const appInfo = APP_INFO_PROPERTIES.reduce((accum, prop) => { + if (typeof info[prop] == 'string') { + accum = accum || {}; - accum[prop] = info[prop]; - } + accum[prop] = info[prop]; + } - return accum; - }, - undefined - ); + return accum; + }, undefined); this._appInfo = appInfo; }, @@ -488,7 +483,7 @@ Stripe.prototype = { */ getClientUserAgentSeeded(seed, cb) { this.getUname((uname) => { - const userAgent: any = {}; + const userAgent = {}; for (const field in seed) { userAgent[field] = encodeURIComponent(seed[field]); } diff --git a/src/utils.js b/lib/utils.js similarity index 100% rename from src/utils.js rename to lib/utils.js diff --git a/package.json b/package.json index 184ca78368..5a495950da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stripe", - "version": "10.8.0", + "version": "10.7.0", "description": "Stripe API wrapper", "keywords": [ "stripe", @@ -27,7 +27,6 @@ "main": "lib/stripe.js", "types": "types/2022-08-01/index.d.ts", "devDependencies": { - "@istanbuljs/nyc-config-typescript": "^1.0.2", "@typescript-eslint/eslint-plugin": "^2.13.0", "@typescript-eslint/parser": "^2.13.0", "chai": "~4.2.0", @@ -56,12 +55,10 @@ }, "license": "MIT", "scripts": { - "build": "tsc -p tsconfig.json", - "clean": "rm -rf ./.nyc_output ./node_modules/.cache ./coverage ./lib", - "prepack": "yarn install && yarn build", + "clean": "rm -rf ./.nyc_output ./node_modules/.cache ./coverage", "mocha": "nyc mocha --config=test/.mocharc.js", "mocha-only": "mocha --config=test/.mocharc.js", - "test": "yarn build && yarn test-typescript && yarn mocha", + "test": "yarn test-typescript && yarn mocha", "test-typescript": "tsc --build types/test", "lint": "eslint --ext .js,.jsx,.ts .", "fix": "yarn lint --fix && ./scripts/updateAPIVersion.js", diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 96e742a5a0..0000000000 --- a/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./lib", - "allowJs": true, - "target": "es6", - "module": "commonjs", - "checkJs": false, - }, - "include": ["./src/**/*"] -} diff --git a/types/2022-08-01/Checkout/Sessions.d.ts b/types/2022-08-01/Checkout/Sessions.d.ts index 04b258e607..e3fd770a05 100644 --- a/types/2022-08-01/Checkout/Sessions.d.ts +++ b/types/2022-08-01/Checkout/Sessions.d.ts @@ -1746,7 +1746,7 @@ declare module 'stripe' { enabled: boolean; /** - * The maximum quantity the customer can purchase for the Checkout Session. By default this value is 99. You can specify a value up to 999999. + * The maximum quantity the customer can purchase for the Checkout Session. By default this value is 99. You can specify a value up to 999. */ maximum?: number; diff --git a/types/2022-08-01/FileLinks.d.ts b/types/2022-08-01/FileLinks.d.ts index 7ae6dc56bf..75efff0ba5 100644 --- a/types/2022-08-01/FileLinks.d.ts +++ b/types/2022-08-01/FileLinks.d.ts @@ -56,7 +56,7 @@ declare module 'stripe' { interface FileLinkCreateParams { /** - * The ID of the file. The file's `purpose` must be one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `finance_report_run`, `identity_document_downloadable`, `pci_document`, `selfie`, `sigma_scheduled_query`, `tax_document_user_upload`, or `terminal_reader_splashscreen`. + * The ID of the file. The file's `purpose` must be one of the following: `business_icon`, `business_logo`, `customer_signature`, `dispute_evidence`, `finance_report_run`, `identity_document_downloadable`, `pci_document`, `selfie`, `sigma_scheduled_query`, or `tax_document_user_upload`. */ file: string; diff --git a/types/2022-08-01/Files.d.ts b/types/2022-08-01/Files.d.ts index 8f1d6d8b49..5e1fa4da22 100644 --- a/types/2022-08-01/Files.d.ts +++ b/types/2022-08-01/Files.d.ts @@ -83,8 +83,7 @@ declare module 'stripe' { | 'pci_document' | 'selfie' | 'sigma_scheduled_query' - | 'tax_document_user_upload' - | 'terminal_reader_splashscreen'; + | 'tax_document_user_upload'; } interface FileCreateParams {} @@ -125,8 +124,7 @@ declare module 'stripe' { | 'pci_document' | 'selfie' | 'sigma_scheduled_query' - | 'tax_document_user_upload' - | 'terminal_reader_splashscreen'; + | 'tax_document_user_upload'; } class FilesResource { diff --git a/yarn.lock b/yarn.lock index 98be4cd4e4..7c7a6481f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -204,13 +204,6 @@ js-yaml "^3.13.1" resolve-from "^5.0.0" -"@istanbuljs/nyc-config-typescript@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@istanbuljs/nyc-config-typescript/-/nyc-config-typescript-1.0.2.tgz#1f5235b28540a07219ae0dd42014912a0b19cf89" - integrity sha512-iKGIyMoyJuFnJRSVTZ78POIRvNnwZaWIf8vG4ZS3rQq58MMDrqEX2nnzx0R28V2X8JvmKYiqY9FP2hlJsm8A0w== - dependencies: - "@istanbuljs/schema" "^0.1.2" - "@istanbuljs/schema@^0.1.2": version "0.1.3" resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"