modern-treasury 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +2 -0
- package/_shims/{ReadableStream.node.d.ts → ReadableStream-node.d.ts} +1 -1
- package/_shims/ReadableStream-node.d.ts.map +1 -0
- package/_shims/{ReadableStream.node.js → ReadableStream-node.js} +1 -1
- package/_shims/ReadableStream-node.js.map +1 -0
- package/_shims/{ReadableStream.node.mjs → ReadableStream-node.mjs} +1 -1
- package/_shims/ReadableStream-node.mjs.map +1 -0
- package/_shims/{agent.node.d.ts → agent-node.d.ts} +1 -1
- package/_shims/agent-node.d.ts.map +1 -0
- package/_shims/{agent.node.js → agent-node.js} +1 -1
- package/_shims/{agent.node.js.map → agent-node.js.map} +1 -1
- package/_shims/{agent.node.mjs → agent-node.mjs} +1 -1
- package/_shims/{agent.node.mjs.map → agent-node.mjs.map} +1 -1
- package/_shims/agent.d.ts +1 -1
- package/_shims/agent.js +1 -1
- package/_shims/agent.mjs +1 -1
- package/{src/_shims/fetch.node.d.ts → _shims/fetch-node.d.ts} +1 -0
- package/_shims/fetch.d.ts +1 -0
- package/_shims/{fileFromPath.node.d.ts → fileFromPath-node.d.ts} +2 -2
- package/_shims/{fileFromPath.node.d.ts.map → fileFromPath-node.d.ts.map} +1 -1
- package/_shims/{fileFromPath.node.js → fileFromPath-node.js} +1 -1
- package/_shims/{fileFromPath.node.js.map → fileFromPath-node.js.map} +1 -1
- package/_shims/{fileFromPath.node.mjs → fileFromPath-node.mjs} +1 -1
- package/_shims/{fileFromPath.node.mjs.map → fileFromPath-node.mjs.map} +1 -1
- package/_shims/fileFromPath.d.ts +2 -2
- package/_shims/fileFromPath.d.ts.map +1 -1
- package/_shims/fileFromPath.js +1 -1
- package/_shims/fileFromPath.mjs +1 -1
- package/_shims/form-data.js +17 -0
- package/_shims/form-data.mjs +20 -0
- package/_shims/{getMultipartRequestOptions.node.d.ts → getMultipartRequestOptions-node.d.ts} +2 -2
- package/_shims/getMultipartRequestOptions-node.d.ts.map +1 -0
- package/_shims/{getMultipartRequestOptions.node.js → getMultipartRequestOptions-node.js} +1 -1
- package/_shims/{getMultipartRequestOptions.node.js.map → getMultipartRequestOptions-node.js.map} +1 -1
- package/_shims/{getMultipartRequestOptions.node.mjs → getMultipartRequestOptions-node.mjs} +1 -1
- package/_shims/{getMultipartRequestOptions.node.mjs.map → getMultipartRequestOptions-node.mjs.map} +1 -1
- package/_shims/getMultipartRequestOptions.d.ts +1 -1
- package/_shims/getMultipartRequestOptions.d.ts.map +1 -1
- package/_shims/{node-readable.node.d.ts → node-readable-node.d.ts} +1 -1
- package/_shims/{node-readable.node.d.ts.map → node-readable-node.d.ts.map} +1 -1
- package/_shims/{node-readable.node.js → node-readable-node.js} +1 -1
- package/_shims/node-readable-node.js.map +1 -0
- package/_shims/{node-readable.node.mjs → node-readable-node.mjs} +1 -1
- package/_shims/node-readable-node.mjs.map +1 -0
- package/core.d.ts +13 -5
- package/core.d.ts.map +1 -1
- package/core.js +17 -10
- package/core.js.map +1 -1
- package/core.mjs +17 -10
- package/core.mjs.map +1 -1
- package/index.d.mts +18 -5
- package/index.d.ts +18 -5
- package/index.d.ts.map +1 -1
- package/index.js +21 -7
- package/index.js.map +1 -1
- package/index.mjs +21 -7
- package/index.mjs.map +1 -1
- package/package.json +32 -9
- package/resources/account-collection-flows.d.ts +3 -28
- package/resources/account-collection-flows.d.ts.map +1 -1
- package/resources/account-collection-flows.js +22 -17
- package/resources/account-collection-flows.js.map +1 -1
- package/resources/account-collection-flows.mjs +22 -17
- package/resources/account-collection-flows.mjs.map +1 -1
- package/resources/account-details.d.ts +3 -8
- package/resources/account-details.d.ts.map +1 -1
- package/resources/account-details.js +10 -4
- package/resources/account-details.js.map +1 -1
- package/resources/account-details.mjs +10 -4
- package/resources/account-details.mjs.map +1 -1
- package/resources/connections.js +3 -3
- package/resources/connections.mjs +3 -3
- package/resources/counterparties.d.ts +26 -40
- package/resources/counterparties.d.ts.map +1 -1
- package/resources/counterparties.js +17 -5
- package/resources/counterparties.js.map +1 -1
- package/resources/counterparties.mjs +17 -5
- package/resources/counterparties.mjs.map +1 -1
- package/resources/documents.d.ts +2 -13
- package/resources/documents.d.ts.map +1 -1
- package/resources/documents.js +11 -5
- package/resources/documents.js.map +1 -1
- package/resources/documents.mjs +11 -5
- package/resources/documents.mjs.map +1 -1
- package/resources/events.js +3 -3
- package/resources/events.mjs +3 -3
- package/resources/expected-payments.d.ts +23 -32
- package/resources/expected-payments.d.ts.map +1 -1
- package/resources/expected-payments.js +10 -4
- package/resources/expected-payments.js.map +1 -1
- package/resources/expected-payments.mjs +10 -4
- package/resources/expected-payments.mjs.map +1 -1
- package/resources/external-accounts.d.ts +17 -51
- package/resources/external-accounts.d.ts.map +1 -1
- package/resources/external-accounts.js +24 -6
- package/resources/external-accounts.js.map +1 -1
- package/resources/external-accounts.mjs +24 -6
- package/resources/external-accounts.mjs.map +1 -1
- package/resources/incoming-payment-details.d.ts +10 -15
- package/resources/incoming-payment-details.d.ts.map +1 -1
- package/resources/incoming-payment-details.js +10 -4
- package/resources/incoming-payment-details.js.map +1 -1
- package/resources/incoming-payment-details.mjs +10 -4
- package/resources/incoming-payment-details.mjs.map +1 -1
- package/resources/index.d.ts +0 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/internal-accounts/balance-reports.js +3 -3
- package/resources/internal-accounts/balance-reports.mjs +3 -3
- package/resources/internal-accounts/internal-accounts.d.ts +10 -15
- package/resources/internal-accounts/internal-accounts.d.ts.map +1 -1
- package/resources/internal-accounts/internal-accounts.js +10 -4
- package/resources/internal-accounts/internal-accounts.js.map +1 -1
- package/resources/internal-accounts/internal-accounts.mjs +10 -4
- package/resources/internal-accounts/internal-accounts.mjs.map +1 -1
- package/resources/invoices/invoices.d.ts +24 -32
- package/resources/invoices/invoices.d.ts.map +1 -1
- package/resources/invoices/invoices.js +10 -4
- package/resources/invoices/invoices.js.map +1 -1
- package/resources/invoices/invoices.mjs +10 -4
- package/resources/invoices/invoices.mjs.map +1 -1
- package/resources/invoices/line-items.d.ts +9 -14
- package/resources/invoices/line-items.d.ts.map +1 -1
- package/resources/invoices/line-items.js +10 -4
- package/resources/invoices/line-items.js.map +1 -1
- package/resources/invoices/line-items.mjs +10 -4
- package/resources/invoices/line-items.mjs.map +1 -1
- package/resources/ledger-account-categories.d.ts +8 -13
- package/resources/ledger-account-categories.d.ts.map +1 -1
- package/resources/ledger-account-categories.js +10 -4
- package/resources/ledger-account-categories.js.map +1 -1
- package/resources/ledger-account-categories.mjs +10 -4
- package/resources/ledger-account-categories.mjs.map +1 -1
- package/resources/ledger-account-payouts.d.ts +14 -19
- package/resources/ledger-account-payouts.d.ts.map +1 -1
- package/resources/ledger-account-payouts.js +10 -4
- package/resources/ledger-account-payouts.js.map +1 -1
- package/resources/ledger-account-payouts.mjs +10 -4
- package/resources/ledger-account-payouts.mjs.map +1 -1
- package/resources/ledger-account-statements.d.ts +9 -14
- package/resources/ledger-account-statements.d.ts.map +1 -1
- package/resources/ledger-account-statements.js +8 -2
- package/resources/ledger-account-statements.js.map +1 -1
- package/resources/ledger-account-statements.mjs +8 -2
- package/resources/ledger-account-statements.mjs.map +1 -1
- package/resources/ledger-accounts.d.ts +13 -18
- package/resources/ledger-accounts.d.ts.map +1 -1
- package/resources/ledger-accounts.js +10 -4
- package/resources/ledger-accounts.js.map +1 -1
- package/resources/ledger-accounts.mjs +10 -4
- package/resources/ledger-accounts.mjs.map +1 -1
- package/resources/ledger-entries.js +3 -3
- package/resources/ledger-entries.mjs +3 -3
- package/resources/ledger-event-handlers.d.ts +5 -16
- package/resources/ledger-event-handlers.d.ts.map +1 -1
- package/resources/ledger-event-handlers.js +10 -4
- package/resources/ledger-event-handlers.js.map +1 -1
- package/resources/ledger-event-handlers.mjs +10 -4
- package/resources/ledger-event-handlers.mjs.map +1 -1
- package/resources/ledger-transactions/ledger-transactions.d.ts +16 -22
- package/resources/ledger-transactions/ledger-transactions.d.ts.map +1 -1
- package/resources/ledger-transactions/ledger-transactions.js +10 -4
- package/resources/ledger-transactions/ledger-transactions.js.map +1 -1
- package/resources/ledger-transactions/ledger-transactions.mjs +10 -4
- package/resources/ledger-transactions/ledger-transactions.mjs.map +1 -1
- package/resources/ledger-transactions/versions.js +3 -3
- package/resources/ledger-transactions/versions.mjs +3 -3
- package/resources/ledgerable-events.d.ts +11 -16
- package/resources/ledgerable-events.d.ts.map +1 -1
- package/resources/ledgerable-events.js +8 -2
- package/resources/ledgerable-events.js.map +1 -1
- package/resources/ledgerable-events.mjs +8 -2
- package/resources/ledgerable-events.mjs.map +1 -1
- package/resources/ledgers.d.ts +4 -9
- package/resources/ledgers.d.ts.map +1 -1
- package/resources/ledgers.js +10 -4
- package/resources/ledgers.js.map +1 -1
- package/resources/ledgers.mjs +10 -4
- package/resources/ledgers.mjs.map +1 -1
- package/resources/line-items.js +3 -3
- package/resources/line-items.mjs +3 -3
- package/resources/paper-items.js +3 -3
- package/resources/paper-items.mjs +3 -3
- package/resources/payment-flows.d.ts +10 -34
- package/resources/payment-flows.d.ts.map +1 -1
- package/resources/payment-flows.js +22 -17
- package/resources/payment-flows.js.map +1 -1
- package/resources/payment-flows.mjs +22 -17
- package/resources/payment-flows.mjs.map +1 -1
- package/resources/payment-orders/payment-orders.d.ts +142 -167
- package/resources/payment-orders/payment-orders.d.ts.map +1 -1
- package/resources/payment-orders/payment-orders.js +18 -6
- package/resources/payment-orders/payment-orders.js.map +1 -1
- package/resources/payment-orders/payment-orders.mjs +18 -6
- package/resources/payment-orders/payment-orders.mjs.map +1 -1
- package/resources/payment-orders/reversals.d.ts +7 -13
- package/resources/payment-orders/reversals.d.ts.map +1 -1
- package/resources/payment-orders/reversals.js +10 -4
- package/resources/payment-orders/reversals.js.map +1 -1
- package/resources/payment-orders/reversals.mjs +10 -4
- package/resources/payment-orders/reversals.mjs.map +1 -1
- package/resources/payment-references.js +3 -3
- package/resources/payment-references.mjs +3 -3
- package/resources/returns.d.ts +9 -15
- package/resources/returns.d.ts.map +1 -1
- package/resources/returns.js +10 -4
- package/resources/returns.js.map +1 -1
- package/resources/returns.mjs +10 -4
- package/resources/returns.mjs.map +1 -1
- package/resources/routing-details.d.ts +4 -10
- package/resources/routing-details.d.ts.map +1 -1
- package/resources/routing-details.js +10 -4
- package/resources/routing-details.js.map +1 -1
- package/resources/routing-details.mjs +10 -4
- package/resources/routing-details.mjs.map +1 -1
- package/resources/transactions/line-items.js +3 -3
- package/resources/transactions/line-items.mjs +3 -3
- package/resources/transactions/transactions.js +3 -3
- package/resources/transactions/transactions.mjs +3 -3
- package/resources/validations.js +1 -1
- package/resources/validations.mjs +1 -1
- package/resources/virtual-accounts.d.ts +12 -18
- package/resources/virtual-accounts.d.ts.map +1 -1
- package/resources/virtual-accounts.js +10 -4
- package/resources/virtual-accounts.js.map +1 -1
- package/resources/virtual-accounts.mjs +10 -4
- package/resources/virtual-accounts.mjs.map +1 -1
- package/resources/webhooks.js +2 -2
- package/resources/webhooks.mjs +2 -2
- package/src/_shims/ReadableStream.d.ts +5 -5
- package/src/_shims/agent.ts +1 -1
- package/{_shims/fetch.node.d.ts → src/_shims/fetch-node.d.ts} +9 -8
- package/src/_shims/fetch.d.ts +11 -10
- package/src/_shims/{fileFromPath.node.ts → fileFromPath-node.ts} +1 -1
- package/src/_shims/fileFromPath.ts +2 -2
- package/src/_shims/{formdata.node.d.ts → form-data-node.d.ts} +4 -4
- package/src/_shims/{formdata.d.ts → form-data.d.ts} +4 -4
- package/src/_shims/form-data.js +17 -0
- package/src/_shims/form-data.mjs +20 -0
- package/src/_shims/{getMultipartRequestOptions.node.ts → getMultipartRequestOptions-node.ts} +3 -3
- package/src/_shims/getMultipartRequestOptions.ts +3 -3
- package/src/core.ts +35 -22
- package/src/error.ts +1 -1
- package/src/index.ts +27 -13
- package/src/pagination.ts +1 -1
- package/src/resource.ts +1 -1
- package/src/resources/account-collection-flows.ts +24 -52
- package/src/resources/account-details.ts +16 -16
- package/src/resources/connections.ts +5 -5
- package/src/resources/counterparties.ts +48 -52
- package/src/resources/documents.ts +15 -21
- package/src/resources/events.ts +5 -5
- package/src/resources/expected-payments.ts +36 -40
- package/src/resources/external-accounts.ts +46 -65
- package/src/resources/incoming-payment-details.ts +24 -24
- package/src/resources/index.ts +39 -35
- package/src/resources/internal-accounts/balance-reports.ts +6 -6
- package/src/resources/internal-accounts/index.ts +2 -2
- package/src/resources/internal-accounts/internal-accounts.ts +27 -27
- package/src/resources/invoices/index.ts +2 -2
- package/src/resources/invoices/invoices.ts +39 -42
- package/src/resources/invoices/line-items.ts +21 -21
- package/src/resources/ledger-account-categories.ts +20 -20
- package/src/resources/ledger-account-payouts.ts +26 -26
- package/src/resources/ledger-account-statements.ts +19 -19
- package/src/resources/ledger-accounts.ts +25 -25
- package/src/resources/ledger-entries.ts +5 -5
- package/src/resources/ledger-event-handlers.ts +17 -23
- package/src/resources/ledger-transactions/index.ts +2 -2
- package/src/resources/ledger-transactions/ledger-transactions.ts +30 -31
- package/src/resources/ledger-transactions/versions.ts +5 -5
- package/src/resources/ledgerable-events.ts +21 -21
- package/src/resources/ledgers.ts +16 -16
- package/src/resources/line-items.ts +5 -5
- package/src/resources/paper-items.ts +6 -6
- package/src/resources/payment-flows.ts +31 -58
- package/src/resources/payment-orders/index.ts +2 -2
- package/src/resources/payment-orders/payment-orders.ts +166 -181
- package/src/resources/payment-orders/reversals.ts +19 -20
- package/src/resources/payment-references.ts +5 -5
- package/src/resources/returns.ts +22 -23
- package/src/resources/routing-details.ts +17 -18
- package/src/resources/top-level.ts +1 -1
- package/src/resources/transactions/index.ts +7 -2
- package/src/resources/transactions/line-items.ts +5 -5
- package/src/resources/transactions/transactions.ts +7 -7
- package/src/resources/validations.ts +3 -3
- package/src/resources/virtual-accounts.ts +26 -27
- package/src/resources/webhooks.ts +3 -3
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +6 -6
- package/src/version.ts +1 -1
- package/uploads.d.ts +1 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js +7 -7
- package/uploads.js.map +1 -1
- package/uploads.mjs +4 -4
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/_shims/ReadableStream.node.d.ts.map +0 -1
- package/_shims/ReadableStream.node.js.map +0 -1
- package/_shims/ReadableStream.node.mjs.map +0 -1
- package/_shims/agent.node.d.ts.map +0 -1
- package/_shims/formdata.js +0 -9
- package/_shims/formdata.mjs +0 -11
- package/_shims/getMultipartRequestOptions.node.d.ts.map +0 -1
- package/_shims/node-readable.node.js.map +0 -1
- package/_shims/node-readable.node.mjs.map +0 -1
- package/src/_shims/fetch.deno.ts +0 -23
- package/src/_shims/formdata.deno.ts +0 -16
- package/src/_shims/formdata.js +0 -9
- package/src/_shims/formdata.mjs +0 -11
- /package/_shims/{fetch.node.js → fetch-node.js} +0 -0
- /package/_shims/{fetch.node.mjs → fetch-node.mjs} +0 -0
- /package/_shims/{formdata.node.d.ts → form-data-node.d.ts} +0 -0
- /package/_shims/{formdata.node.js → form-data-node.js} +0 -0
- /package/_shims/{formdata.node.mjs → form-data-node.mjs} +0 -0
- /package/_shims/{formdata.d.ts → form-data.d.ts} +0 -0
- /package/src/_shims/{ReadableStream.node.ts → ReadableStream-node.ts} +0 -0
- /package/src/_shims/{agent.node.ts → agent-node.ts} +0 -0
- /package/src/_shims/{fetch.node.js → fetch-node.js} +0 -0
- /package/src/_shims/{fetch.node.mjs → fetch-node.mjs} +0 -0
- /package/src/_shims/{formdata.node.js → form-data-node.js} +0 -0
- /package/src/_shims/{formdata.node.mjs → form-data-node.mjs} +0 -0
- /package/src/_shims/{node-readable.node.ts → node-readable-node.ts} +0 -0
package/src/core.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { VERSION } from './version';
|
|
2
|
-
import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error';
|
|
3
|
-
import type { Readable } from './_shims/node-readable';
|
|
4
|
-
import { getDefaultAgent, type Agent } from './_shims/agent';
|
|
1
|
+
import { VERSION } from './version.js';
|
|
2
|
+
import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error.js';
|
|
3
|
+
import type { Readable } from './_shims/node-readable.js';
|
|
4
|
+
import { getDefaultAgent, type Agent } from './_shims/agent.js';
|
|
5
5
|
import {
|
|
6
6
|
fetch,
|
|
7
7
|
isPolyfilled as fetchIsPolyfilled,
|
|
8
8
|
type RequestInfo,
|
|
9
9
|
type RequestInit,
|
|
10
10
|
type Response,
|
|
11
|
+
type HeadersInit,
|
|
11
12
|
} from './_shims/fetch.js';
|
|
12
13
|
export { type Response };
|
|
13
|
-
import { isMultipartBody } from './uploads';
|
|
14
|
+
import { isMultipartBody } from './uploads.js';
|
|
14
15
|
export {
|
|
15
16
|
maybeMultipartFormRequestOptions,
|
|
16
17
|
multipartFormRequestOptions,
|
|
17
18
|
createForm,
|
|
18
19
|
type Uploadable,
|
|
19
|
-
} from './uploads';
|
|
20
|
+
} from './uploads.js';
|
|
20
21
|
|
|
21
22
|
const MAX_RETRIES = 2;
|
|
22
23
|
|
|
@@ -44,7 +45,7 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
|
|
|
44
45
|
// TODO handle blob, arraybuffer, other content types, etc.
|
|
45
46
|
const text = await response.text();
|
|
46
47
|
debug('response', response.status, response.url, response.headers, text);
|
|
47
|
-
return text as T;
|
|
48
|
+
return text as any as T;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
/**
|
|
@@ -146,7 +147,7 @@ export abstract class APIClient {
|
|
|
146
147
|
this.fetch = overridenFetch ?? fetch;
|
|
147
148
|
}
|
|
148
149
|
|
|
149
|
-
protected authHeaders(): Headers {
|
|
150
|
+
protected authHeaders(opts: FinalRequestOptions): Headers {
|
|
150
151
|
return {};
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -158,13 +159,13 @@ export abstract class APIClient {
|
|
|
158
159
|
* Authorization: 'Bearer 123',
|
|
159
160
|
* }
|
|
160
161
|
*/
|
|
161
|
-
protected defaultHeaders(): Headers {
|
|
162
|
+
protected defaultHeaders(opts: FinalRequestOptions): Headers {
|
|
162
163
|
return {
|
|
163
164
|
Accept: 'application/json',
|
|
164
165
|
'Content-Type': 'application/json',
|
|
165
166
|
'User-Agent': this.getUserAgent(),
|
|
166
167
|
...getPlatformHeaders(),
|
|
167
|
-
...this.authHeaders(),
|
|
168
|
+
...this.authHeaders(opts),
|
|
168
169
|
};
|
|
169
170
|
}
|
|
170
171
|
|
|
@@ -265,7 +266,7 @@ export abstract class APIClient {
|
|
|
265
266
|
|
|
266
267
|
const reqHeaders: Record<string, string> = {
|
|
267
268
|
...(contentLength && { 'Content-Length': contentLength }),
|
|
268
|
-
...this.defaultHeaders(),
|
|
269
|
+
...this.defaultHeaders(options),
|
|
269
270
|
...headers,
|
|
270
271
|
};
|
|
271
272
|
// let builtin fetch set the Content-Type for multipart bodies
|
|
@@ -297,7 +298,19 @@ export abstract class APIClient {
|
|
|
297
298
|
* This is useful for cases where you want to add certain headers based off of
|
|
298
299
|
* the request properties, e.g. `method` or `url`.
|
|
299
300
|
*/
|
|
300
|
-
protected async prepareRequest(
|
|
301
|
+
protected async prepareRequest(
|
|
302
|
+
request: RequestInit,
|
|
303
|
+
{ url, options }: { url: string; options: FinalRequestOptions },
|
|
304
|
+
): Promise<void> {}
|
|
305
|
+
|
|
306
|
+
protected parseHeaders(headers: HeadersInit | null | undefined): Record<string, string> {
|
|
307
|
+
return (
|
|
308
|
+
!headers ? {}
|
|
309
|
+
: Symbol.iterator in headers ?
|
|
310
|
+
Object.fromEntries(Array.from(headers as Iterable<string[]>).map((header) => [...header]))
|
|
311
|
+
: { ...headers }
|
|
312
|
+
);
|
|
313
|
+
}
|
|
301
314
|
|
|
302
315
|
protected makeStatusError(
|
|
303
316
|
status: number | undefined,
|
|
@@ -315,10 +328,10 @@ export abstract class APIClient {
|
|
|
315
328
|
return new APIPromise(this.makeRequest(options, remainingRetries));
|
|
316
329
|
}
|
|
317
330
|
|
|
318
|
-
private async makeRequest
|
|
331
|
+
private async makeRequest(
|
|
319
332
|
optionsInput: PromiseOrValue<FinalRequestOptions>,
|
|
320
333
|
retriesRemaining: number | null,
|
|
321
|
-
): Promise<
|
|
334
|
+
): Promise<APIResponseProps> {
|
|
322
335
|
const options = await optionsInput;
|
|
323
336
|
if (retriesRemaining == null) {
|
|
324
337
|
retriesRemaining = options.maxRetries ?? this.maxRetries;
|
|
@@ -326,7 +339,7 @@ export abstract class APIClient {
|
|
|
326
339
|
|
|
327
340
|
const { req, url, timeout } = this.buildRequest(options);
|
|
328
341
|
|
|
329
|
-
await this.prepareRequest(req, { url });
|
|
342
|
+
await this.prepareRequest(req, { url, options });
|
|
330
343
|
|
|
331
344
|
debug('request', url, options, req.headers);
|
|
332
345
|
|
|
@@ -378,7 +391,7 @@ export abstract class APIClient {
|
|
|
378
391
|
return new PagePromise<PageClass, Item>(this, request, Page);
|
|
379
392
|
}
|
|
380
393
|
|
|
381
|
-
buildURL<Req
|
|
394
|
+
buildURL<Req extends Record<string, unknown>>(path: string, query: Req | null | undefined): string {
|
|
382
395
|
const url =
|
|
383
396
|
isAbsoluteURL(path) ?
|
|
384
397
|
new URL(path)
|
|
@@ -455,11 +468,11 @@ export abstract class APIClient {
|
|
|
455
468
|
return false;
|
|
456
469
|
}
|
|
457
470
|
|
|
458
|
-
private async retryRequest
|
|
459
|
-
options: FinalRequestOptions
|
|
471
|
+
private async retryRequest(
|
|
472
|
+
options: FinalRequestOptions,
|
|
460
473
|
retriesRemaining: number,
|
|
461
474
|
responseHeaders?: Headers | undefined,
|
|
462
|
-
): Promise<
|
|
475
|
+
): Promise<APIResponseProps> {
|
|
463
476
|
retriesRemaining -= 1;
|
|
464
477
|
|
|
465
478
|
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
@@ -472,7 +485,7 @@ export abstract class APIClient {
|
|
|
472
485
|
const timeout = this.calculateRetryTimeoutSeconds(retriesRemaining, retryAfter, maxRetries) * 1000;
|
|
473
486
|
await sleep(timeout);
|
|
474
487
|
|
|
475
|
-
return this.
|
|
488
|
+
return this.makeRequest(options, retriesRemaining);
|
|
476
489
|
}
|
|
477
490
|
|
|
478
491
|
private calculateRetryTimeoutSeconds(
|
|
@@ -556,7 +569,7 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
|
556
569
|
return this.nextPageInfo() != null;
|
|
557
570
|
}
|
|
558
571
|
|
|
559
|
-
async getNextPage(): Promise<
|
|
572
|
+
async getNextPage(): Promise<this> {
|
|
560
573
|
const nextInfo = this.nextPageInfo();
|
|
561
574
|
if (!nextInfo) {
|
|
562
575
|
throw new Error(
|
|
@@ -796,7 +809,7 @@ declare const navigator: { userAgent: string } | undefined;
|
|
|
796
809
|
|
|
797
810
|
// Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts
|
|
798
811
|
function getBrowserInfo(): BrowserInfo | null {
|
|
799
|
-
if (
|
|
812
|
+
if (typeof navigator === 'undefined' || !navigator) {
|
|
800
813
|
return null;
|
|
801
814
|
}
|
|
802
815
|
|
package/src/error.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from './core';
|
|
4
|
-
import * as Pagination from './pagination';
|
|
5
|
-
import * as API from './resources/index';
|
|
6
|
-
import * as Errors from './error';
|
|
7
|
-
import type { Agent } from './_shims/agent';
|
|
8
|
-
import * as Uploads from './uploads';
|
|
3
|
+
import * as Core from './core.js';
|
|
4
|
+
import * as Pagination from './pagination.js';
|
|
5
|
+
import * as API from './resources/index.js';
|
|
6
|
+
import * as Errors from './error.js';
|
|
7
|
+
import type { Agent } from './_shims/agent.js';
|
|
8
|
+
import * as Uploads from './uploads.js';
|
|
9
9
|
import * as qs from 'qs';
|
|
10
10
|
|
|
11
11
|
export interface ClientOptions {
|
|
@@ -73,7 +73,7 @@ export interface ClientOptions {
|
|
|
73
73
|
webhookKey?: string | null;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/**
|
|
76
|
+
/** API Client for interfacing with the Modern Treasury API. */
|
|
77
77
|
export class ModernTreasury extends Core.APIClient {
|
|
78
78
|
apiKey: string;
|
|
79
79
|
organizationId: string;
|
|
@@ -81,6 +81,20 @@ export class ModernTreasury extends Core.APIClient {
|
|
|
81
81
|
|
|
82
82
|
private _options: ClientOptions;
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* API Client for interfacing with the Modern Treasury API.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} [opts.apiKey=process.env['MODERN_TREASURY_API_KEY']] - The API Key to send to the API.
|
|
88
|
+
* @param {string} [opts.baseURL] - Override the default base URL for the API.
|
|
89
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
90
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
91
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
92
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
93
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
94
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
95
|
+
* @param {string} [opts.organizationId]
|
|
96
|
+
* @param {string | null} [opts.webhookKey]
|
|
97
|
+
*/
|
|
84
98
|
constructor({
|
|
85
99
|
apiKey = Core.readEnv('MODERN_TREASURY_API_KEY'),
|
|
86
100
|
organizationId = Core.readEnv('MODERN_TREASURY_ORGANIZATION_ID'),
|
|
@@ -102,8 +116,8 @@ export class ModernTreasury extends Core.APIClient {
|
|
|
102
116
|
apiKey,
|
|
103
117
|
organizationId,
|
|
104
118
|
webhookKey,
|
|
105
|
-
baseURL: `https://app.moderntreasury.com`,
|
|
106
119
|
...opts,
|
|
120
|
+
baseURL: opts.baseURL ?? `https://app.moderntreasury.com`,
|
|
107
121
|
};
|
|
108
122
|
|
|
109
123
|
super({
|
|
@@ -165,14 +179,14 @@ export class ModernTreasury extends Core.APIClient {
|
|
|
165
179
|
return this._options.defaultQuery;
|
|
166
180
|
}
|
|
167
181
|
|
|
168
|
-
protected override defaultHeaders(): Core.Headers {
|
|
182
|
+
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
169
183
|
return {
|
|
170
|
-
...super.defaultHeaders(),
|
|
184
|
+
...super.defaultHeaders(opts),
|
|
171
185
|
...this._options.defaultHeaders,
|
|
172
186
|
};
|
|
173
187
|
}
|
|
174
188
|
|
|
175
|
-
protected override authHeaders(): Core.Headers {
|
|
189
|
+
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
176
190
|
const credentials = `${this.organizationId}:${this.apiKey}`;
|
|
177
191
|
const Authorization = `Basic ${Core.toBase64(credentials)}`;
|
|
178
192
|
return { Authorization };
|
|
@@ -221,6 +235,8 @@ export namespace ModernTreasury {
|
|
|
221
235
|
export import toFile = Uploads.toFile;
|
|
222
236
|
export import fileFromPath = Uploads.fileFromPath;
|
|
223
237
|
|
|
238
|
+
export import RequestOptions = Core.RequestOptions;
|
|
239
|
+
|
|
224
240
|
export import Page = Pagination.Page;
|
|
225
241
|
export import PageParams = Pagination.PageParams;
|
|
226
242
|
export import PageResponse = Pagination.PageResponse;
|
|
@@ -288,7 +304,6 @@ export namespace ModernTreasury {
|
|
|
288
304
|
export import AccountCollectionFlow = API.AccountCollectionFlow;
|
|
289
305
|
export import AccountCollectionFlowsPage = API.AccountCollectionFlowsPage;
|
|
290
306
|
export import AccountCollectionFlowCreateParams = API.AccountCollectionFlowCreateParams;
|
|
291
|
-
export import AccountCollectionFlowRetrieveParams = API.AccountCollectionFlowRetrieveParams;
|
|
292
307
|
export import AccountCollectionFlowUpdateParams = API.AccountCollectionFlowUpdateParams;
|
|
293
308
|
export import AccountCollectionFlowListParams = API.AccountCollectionFlowListParams;
|
|
294
309
|
|
|
@@ -383,7 +398,6 @@ export namespace ModernTreasury {
|
|
|
383
398
|
export import PaymentFlow = API.PaymentFlow;
|
|
384
399
|
export import PaymentFlowsPage = API.PaymentFlowsPage;
|
|
385
400
|
export import PaymentFlowCreateParams = API.PaymentFlowCreateParams;
|
|
386
|
-
export import PaymentFlowRetrieveParams = API.PaymentFlowRetrieveParams;
|
|
387
401
|
export import PaymentFlowUpdateParams = API.PaymentFlowUpdateParams;
|
|
388
402
|
export import PaymentFlowListParams = API.PaymentFlowListParams;
|
|
389
403
|
|
package/src/pagination.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { AbstractPage, Response, APIClient, FinalRequestOptions, coerceInteger, PageInfo } from './core';
|
|
3
|
+
import { AbstractPage, Response, APIClient, FinalRequestOptions, coerceInteger, PageInfo } from './core.js';
|
|
4
4
|
|
|
5
5
|
export type PageResponse<Item> = Item[];
|
|
6
6
|
|
package/src/resource.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import { isRequestOptions } from '../core';
|
|
6
|
-
import * as API from './index';
|
|
7
|
-
import { Page, PageParams } from '../pagination';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import { isRequestOptions } from '../core.js';
|
|
6
|
+
import * as API from './index.js';
|
|
7
|
+
import { Page, PageParams } from '../pagination.js';
|
|
8
8
|
|
|
9
9
|
export class AccountCollectionFlows extends APIResource {
|
|
10
10
|
/**
|
|
@@ -14,36 +14,25 @@ export class AccountCollectionFlows extends APIResource {
|
|
|
14
14
|
params: AccountCollectionFlowCreateParams,
|
|
15
15
|
options?: Core.RequestOptions,
|
|
16
16
|
): Core.APIPromise<AccountCollectionFlow> {
|
|
17
|
+
// @ts-expect-error idempotency key header isn't defined anymore but is included here for back-compat
|
|
17
18
|
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
19
|
+
if (idempotencyKey) {
|
|
20
|
+
console.warn(
|
|
21
|
+
"The Idempotency-Key request param is deprecated, the 'idempotencyToken' option should be set instead",
|
|
22
|
+
);
|
|
23
|
+
}
|
|
18
24
|
return this.post('/api/account_collection_flows', {
|
|
19
25
|
body,
|
|
20
26
|
...options,
|
|
21
|
-
headers: { 'Idempotency-Key': idempotencyKey
|
|
27
|
+
headers: { 'Idempotency-Key': idempotencyKey, ...options?.headers },
|
|
22
28
|
});
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
/**
|
|
26
32
|
* get account_collection_flow
|
|
27
33
|
*/
|
|
28
|
-
retrieve(
|
|
29
|
-
id
|
|
30
|
-
query?: AccountCollectionFlowRetrieveParams,
|
|
31
|
-
options?: Core.RequestOptions,
|
|
32
|
-
): Core.APIPromise<AccountCollectionFlow>;
|
|
33
|
-
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<AccountCollectionFlow>;
|
|
34
|
-
retrieve(
|
|
35
|
-
id: string,
|
|
36
|
-
query: AccountCollectionFlowRetrieveParams | Core.RequestOptions = {},
|
|
37
|
-
options?: Core.RequestOptions,
|
|
38
|
-
): Core.APIPromise<AccountCollectionFlow> {
|
|
39
|
-
if (isRequestOptions(query)) {
|
|
40
|
-
return this.retrieve(id, {}, query);
|
|
41
|
-
}
|
|
42
|
-
const { 'Idempotency-Key': idempotencyKey } = query;
|
|
43
|
-
return this.get(`/api/account_collection_flows/${id}`, {
|
|
44
|
-
...options,
|
|
45
|
-
headers: { 'Idempotency-Key': idempotencyKey || '', ...options?.headers },
|
|
46
|
-
});
|
|
34
|
+
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<AccountCollectionFlow> {
|
|
35
|
+
return this.get(`/api/account_collection_flows/${id}`, options);
|
|
47
36
|
}
|
|
48
37
|
|
|
49
38
|
/**
|
|
@@ -54,11 +43,17 @@ export class AccountCollectionFlows extends APIResource {
|
|
|
54
43
|
params: AccountCollectionFlowUpdateParams,
|
|
55
44
|
options?: Core.RequestOptions,
|
|
56
45
|
): Core.APIPromise<AccountCollectionFlow> {
|
|
46
|
+
// @ts-expect-error idempotency key header isn't defined anymore but is included here for back-compat
|
|
57
47
|
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
48
|
+
if (idempotencyKey) {
|
|
49
|
+
console.warn(
|
|
50
|
+
"The Idempotency-Key request param is deprecated, the 'idempotencyToken' option should be set instead",
|
|
51
|
+
);
|
|
52
|
+
}
|
|
58
53
|
return this.patch(`/api/account_collection_flows/${id}`, {
|
|
59
54
|
body,
|
|
60
55
|
...options,
|
|
61
|
-
headers: { 'Idempotency-Key': idempotencyKey
|
|
56
|
+
headers: { 'Idempotency-Key': idempotencyKey, ...options?.headers },
|
|
62
57
|
});
|
|
63
58
|
}
|
|
64
59
|
|
|
@@ -131,41 +126,19 @@ export interface AccountCollectionFlow {
|
|
|
131
126
|
|
|
132
127
|
export interface AccountCollectionFlowCreateParams {
|
|
133
128
|
/**
|
|
134
|
-
*
|
|
129
|
+
* Required.
|
|
135
130
|
*/
|
|
136
131
|
counterparty_id: string;
|
|
137
132
|
|
|
138
|
-
/**
|
|
139
|
-
* Body param:
|
|
140
|
-
*/
|
|
141
133
|
payment_types: Array<string>;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Header param: This key should be something unique, preferably something like an
|
|
145
|
-
* UUID.
|
|
146
|
-
*/
|
|
147
|
-
'Idempotency-Key'?: string;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export interface AccountCollectionFlowRetrieveParams {
|
|
151
|
-
/**
|
|
152
|
-
* This key should be something unique, preferably something like an UUID.
|
|
153
|
-
*/
|
|
154
|
-
'Idempotency-Key'?: string;
|
|
155
134
|
}
|
|
156
135
|
|
|
157
136
|
export interface AccountCollectionFlowUpdateParams {
|
|
158
137
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
138
|
+
* Required. The updated status of the account collection flow. Can only be used to
|
|
139
|
+
* mark a flow as `cancelled`.
|
|
161
140
|
*/
|
|
162
141
|
status: 'cancelled';
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Header param: This key should be something unique, preferably something like an
|
|
166
|
-
* UUID.
|
|
167
|
-
*/
|
|
168
|
-
'Idempotency-Key'?: string;
|
|
169
142
|
}
|
|
170
143
|
|
|
171
144
|
export interface AccountCollectionFlowListParams extends PageParams {
|
|
@@ -182,7 +155,6 @@ export namespace AccountCollectionFlows {
|
|
|
182
155
|
export import AccountCollectionFlow = API.AccountCollectionFlow;
|
|
183
156
|
export type AccountCollectionFlowsPage = _AccountCollectionFlowsPage;
|
|
184
157
|
export import AccountCollectionFlowCreateParams = API.AccountCollectionFlowCreateParams;
|
|
185
|
-
export import AccountCollectionFlowRetrieveParams = API.AccountCollectionFlowRetrieveParams;
|
|
186
158
|
export import AccountCollectionFlowUpdateParams = API.AccountCollectionFlowUpdateParams;
|
|
187
159
|
export import AccountCollectionFlowListParams = API.AccountCollectionFlowListParams;
|
|
188
160
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import { isRequestOptions } from '../core';
|
|
6
|
-
import * as Shared from './shared';
|
|
7
|
-
import * as API from './index';
|
|
8
|
-
import { Page, PageParams } from '../pagination';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import { isRequestOptions } from '../core.js';
|
|
6
|
+
import * as Shared from './shared.js';
|
|
7
|
+
import * as API from './index.js';
|
|
8
|
+
import { Page, PageParams } from '../pagination.js';
|
|
9
9
|
|
|
10
10
|
export class AccountDetails extends APIResource {
|
|
11
11
|
/**
|
|
@@ -17,11 +17,17 @@ export class AccountDetails extends APIResource {
|
|
|
17
17
|
params: AccountDetailCreateParams,
|
|
18
18
|
options?: Core.RequestOptions,
|
|
19
19
|
): Core.APIPromise<AccountDetail> {
|
|
20
|
+
// @ts-expect-error idempotency key header isn't defined anymore but is included here for back-compat
|
|
20
21
|
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
|
|
22
|
+
if (idempotencyKey) {
|
|
23
|
+
console.warn(
|
|
24
|
+
"The Idempotency-Key request param is deprecated, the 'idempotencyToken' option should be set instead",
|
|
25
|
+
);
|
|
26
|
+
}
|
|
21
27
|
return this.post(`/api/${accountsType}/${accountId}/account_details`, {
|
|
22
28
|
body,
|
|
23
29
|
...options,
|
|
24
|
-
headers: { 'Idempotency-Key': idempotencyKey
|
|
30
|
+
headers: { 'Idempotency-Key': idempotencyKey, ...options?.headers },
|
|
25
31
|
});
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -122,21 +128,15 @@ export interface AccountDetail {
|
|
|
122
128
|
|
|
123
129
|
export interface AccountDetailCreateParams {
|
|
124
130
|
/**
|
|
125
|
-
*
|
|
131
|
+
* The account number for the bank account.
|
|
126
132
|
*/
|
|
127
133
|
account_number: string;
|
|
128
134
|
|
|
129
135
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
136
|
+
* One of `iban`, `clabe`, `wallet_address`, or `other`. Use `other` if the bank
|
|
137
|
+
* account number is in a generic format.
|
|
132
138
|
*/
|
|
133
139
|
account_number_type?: 'clabe' | 'iban' | 'other' | 'pan' | 'wallet_address';
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Header param: This key should be something unique, preferably something like an
|
|
137
|
-
* UUID.
|
|
138
|
-
*/
|
|
139
|
-
'Idempotency-Key'?: string;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
export interface AccountDetailListParams extends PageParams {}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import { isRequestOptions } from '../core';
|
|
6
|
-
import * as API from './index';
|
|
7
|
-
import { Page, PageParams } from '../pagination';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import { isRequestOptions } from '../core.js';
|
|
6
|
+
import * as API from './index.js';
|
|
7
|
+
import { Page, PageParams } from '../pagination.js';
|
|
8
8
|
|
|
9
9
|
export class Connections extends APIResource {
|
|
10
10
|
/**
|