modern-treasury 2.0.0 → 2.2.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.
Files changed (172) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/LICENSE +7 -0
  3. package/README.md +273 -0
  4. package/_shims/fetch.js +1 -1
  5. package/_shims/formdata.node.d.ts +1 -0
  6. package/core.d.ts +19 -11
  7. package/core.d.ts.map +1 -1
  8. package/core.js +122 -72
  9. package/core.js.map +1 -1
  10. package/core.mjs +112 -32
  11. package/core.mjs.map +1 -1
  12. package/error.d.ts +5 -0
  13. package/error.d.ts.map +1 -1
  14. package/error.js +20 -3
  15. package/error.js.map +1 -1
  16. package/error.mjs +18 -3
  17. package/error.mjs.map +1 -1
  18. package/index.d.mts +17 -8
  19. package/index.d.ts +17 -8
  20. package/index.d.ts.map +1 -1
  21. package/index.js +36 -20
  22. package/index.js.map +1 -1
  23. package/index.mjs +35 -20
  24. package/index.mjs.map +1 -1
  25. package/package.json +5 -5
  26. package/resources/account-collection-flows.d.ts +11 -11
  27. package/resources/account-collection-flows.d.ts.map +1 -1
  28. package/resources/account-collection-flows.js +4 -4
  29. package/resources/account-collection-flows.mjs +2 -2
  30. package/resources/account-details.d.ts.map +1 -1
  31. package/resources/connections.d.ts.map +1 -1
  32. package/resources/counterparties.d.ts.map +1 -1
  33. package/resources/documents.d.ts +2 -5
  34. package/resources/documents.d.ts.map +1 -1
  35. package/resources/documents.js +1 -7
  36. package/resources/documents.js.map +1 -1
  37. package/resources/documents.mjs +1 -7
  38. package/resources/documents.mjs.map +1 -1
  39. package/resources/events.d.ts.map +1 -1
  40. package/resources/expected-payments.d.ts.map +1 -1
  41. package/resources/external-accounts.d.ts.map +1 -1
  42. package/resources/incoming-payment-details.d.ts.map +1 -1
  43. package/resources/index.d.ts +2 -2
  44. package/resources/index.js +3 -3
  45. package/resources/index.mjs +1 -1
  46. package/resources/internal-accounts/balance-reports.d.ts.map +1 -1
  47. package/resources/internal-accounts/internal-accounts.d.ts +5 -4
  48. package/resources/internal-accounts/internal-accounts.d.ts.map +1 -1
  49. package/resources/internal-accounts/internal-accounts.js.map +1 -1
  50. package/resources/internal-accounts/internal-accounts.mjs.map +1 -1
  51. package/resources/invoices/invoices.d.ts +102 -5
  52. package/resources/invoices/invoices.d.ts.map +1 -1
  53. package/resources/invoices/invoices.js.map +1 -1
  54. package/resources/invoices/invoices.mjs.map +1 -1
  55. package/resources/invoices/line-items.d.ts +41 -0
  56. package/resources/invoices/line-items.d.ts.map +1 -1
  57. package/resources/invoices/line-items.js.map +1 -1
  58. package/resources/invoices/line-items.mjs.map +1 -1
  59. package/resources/ledger-account-categories.d.ts.map +1 -1
  60. package/resources/ledger-account-payouts.d.ts.map +1 -1
  61. package/resources/ledger-account-statements.d.ts.map +1 -1
  62. package/resources/ledger-accounts.d.ts +23 -16
  63. package/resources/ledger-accounts.d.ts.map +1 -1
  64. package/resources/ledger-accounts.js.map +1 -1
  65. package/resources/ledger-accounts.mjs.map +1 -1
  66. package/resources/ledger-entries.d.ts.map +1 -1
  67. package/resources/ledger-event-handlers.d.ts +4 -0
  68. package/resources/ledger-event-handlers.d.ts.map +1 -1
  69. package/resources/ledger-event-handlers.js.map +1 -1
  70. package/resources/ledger-event-handlers.mjs.map +1 -1
  71. package/resources/ledger-transactions/ledger-transactions.d.ts +8 -3
  72. package/resources/ledger-transactions/ledger-transactions.d.ts.map +1 -1
  73. package/resources/ledger-transactions/ledger-transactions.js.map +1 -1
  74. package/resources/ledger-transactions/ledger-transactions.mjs.map +1 -1
  75. package/resources/ledger-transactions/versions.d.ts.map +1 -1
  76. package/resources/ledgerable-events.d.ts +0 -16
  77. package/resources/ledgerable-events.d.ts.map +1 -1
  78. package/resources/ledgerable-events.js.map +1 -1
  79. package/resources/ledgerable-events.mjs.map +1 -1
  80. package/resources/ledgers.d.ts.map +1 -1
  81. package/resources/line-items.d.ts.map +1 -1
  82. package/resources/paper-items.d.ts.map +1 -1
  83. package/resources/payment-flows.d.ts.map +1 -1
  84. package/resources/payment-orders/payment-orders.d.ts +32 -6
  85. package/resources/payment-orders/payment-orders.d.ts.map +1 -1
  86. package/resources/payment-orders/payment-orders.js.map +1 -1
  87. package/resources/payment-orders/payment-orders.mjs.map +1 -1
  88. package/resources/payment-orders/reversals.d.ts +8 -3
  89. package/resources/payment-orders/reversals.d.ts.map +1 -1
  90. package/resources/payment-orders/reversals.js.map +1 -1
  91. package/resources/payment-orders/reversals.mjs.map +1 -1
  92. package/resources/payment-references.d.ts.map +1 -1
  93. package/resources/returns.d.ts.map +1 -1
  94. package/resources/routing-details.d.ts.map +1 -1
  95. package/resources/top-level.d.ts.map +1 -1
  96. package/resources/transactions/line-items.d.ts.map +1 -1
  97. package/resources/transactions/transactions.d.ts.map +1 -1
  98. package/resources/transactions/transactions.js.map +1 -1
  99. package/resources/validations.d.ts.map +1 -1
  100. package/resources/virtual-accounts.d.ts +59 -3
  101. package/resources/virtual-accounts.d.ts.map +1 -1
  102. package/resources/virtual-accounts.js +1 -4
  103. package/resources/virtual-accounts.js.map +1 -1
  104. package/resources/virtual-accounts.mjs +1 -4
  105. package/resources/virtual-accounts.mjs.map +1 -1
  106. package/src/_shims/fetch.deno.ts +23 -0
  107. package/src/_shims/fetch.js +1 -1
  108. package/src/_shims/fileFromPath.node.ts +1 -1
  109. package/src/_shims/fileFromPath.ts +1 -1
  110. package/src/_shims/formdata.deno.ts +16 -0
  111. package/src/_shims/formdata.node.d.ts +1 -0
  112. package/src/_shims/getMultipartRequestOptions.node.ts +1 -1
  113. package/src/_shims/getMultipartRequestOptions.ts +1 -1
  114. package/src/core.ts +123 -34
  115. package/src/error.ts +19 -1
  116. package/src/index.ts +47 -28
  117. package/src/resources/account-collection-flows.ts +19 -19
  118. package/src/resources/account-details.ts +6 -6
  119. package/src/resources/connections.ts +5 -5
  120. package/src/resources/counterparties.ts +8 -8
  121. package/src/resources/documents.ts +9 -18
  122. package/src/resources/events.ts +5 -5
  123. package/src/resources/expected-payments.ts +6 -6
  124. package/src/resources/external-accounts.ts +8 -8
  125. package/src/resources/incoming-payment-details.ts +7 -7
  126. package/src/resources/index.ts +2 -2
  127. package/src/resources/internal-accounts/balance-reports.ts +6 -6
  128. package/src/resources/internal-accounts/internal-accounts.ts +15 -14
  129. package/src/resources/invoices/invoices.ts +121 -13
  130. package/src/resources/invoices/line-items.ts +51 -6
  131. package/src/resources/ledger-account-categories.ts +5 -5
  132. package/src/resources/ledger-account-payouts.ts +5 -5
  133. package/src/resources/ledger-account-statements.ts +3 -3
  134. package/src/resources/ledger-accounts.ts +29 -21
  135. package/src/resources/ledger-entries.ts +5 -5
  136. package/src/resources/ledger-event-handlers.ts +10 -5
  137. package/src/resources/ledger-transactions/ledger-transactions.ts +15 -9
  138. package/src/resources/ledger-transactions/versions.ts +5 -5
  139. package/src/resources/ledgerable-events.ts +3 -23
  140. package/src/resources/ledgers.ts +5 -5
  141. package/src/resources/line-items.ts +5 -5
  142. package/src/resources/paper-items.ts +6 -6
  143. package/src/resources/payment-flows.ts +5 -5
  144. package/src/resources/payment-orders/payment-orders.ts +45 -15
  145. package/src/resources/payment-orders/reversals.ts +14 -8
  146. package/src/resources/payment-references.ts +5 -5
  147. package/src/resources/returns.ts +6 -6
  148. package/src/resources/routing-details.ts +6 -6
  149. package/src/resources/top-level.ts +1 -1
  150. package/src/resources/transactions/line-items.ts +5 -5
  151. package/src/resources/transactions/transactions.ts +6 -6
  152. package/src/resources/validations.ts +3 -3
  153. package/src/resources/virtual-accounts.ts +72 -14
  154. package/src/resources/webhooks.ts +3 -3
  155. package/src/uploads.ts +16 -14
  156. package/src/version.ts +1 -1
  157. package/uploads.d.ts +6 -5
  158. package/uploads.d.ts.map +1 -1
  159. package/uploads.js +4 -3
  160. package/uploads.js.map +1 -1
  161. package/uploads.mjs +4 -3
  162. package/uploads.mjs.map +1 -1
  163. package/version.d.ts +1 -1
  164. package/version.js +1 -1
  165. package/version.mjs +1 -1
  166. package/src/streaming.ts +0 -204
  167. package/streaming.d.ts +0 -14
  168. package/streaming.d.ts.map +0 -1
  169. package/streaming.js +0 -155
  170. package/streaming.js.map +0 -1
  171. package/streaming.mjs +0 -151
  172. package/streaming.mjs.map +0 -1
@@ -1,15 +1,15 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as Returns from 'modern-treasury/resources/returns';
7
- import * as ExternalAccounts from 'modern-treasury/resources/external-accounts';
8
- import * as Shared from 'modern-treasury/resources/shared';
3
+ import * as Core from '../../core';
4
+ import { APIResource } from '../../resource';
5
+ import { isRequestOptions } from '../../core';
6
+ import * as Returns from '../returns';
7
+ import * as ExternalAccounts from '../external-accounts';
8
+ import * as Shared from '../shared';
9
9
  import { Reversals } from './reversals';
10
- import * as API from './';
11
- import { type Uploadable, maybeMultipartFormRequestOptions } from 'modern-treasury/core';
12
- import { Page, PageParams } from 'modern-treasury/pagination';
10
+ import * as API from './index';
11
+ import { type Uploadable, maybeMultipartFormRequestOptions } from '../../core';
12
+ import { Page, PageParams } from '../../pagination';
13
13
 
14
14
  export class PaymentOrders extends APIResource {
15
15
  reversals: Reversals = new Reversals(this.client);
@@ -740,6 +740,24 @@ export namespace PaymentOrderCreateParams {
740
740
  }
741
741
 
742
742
  export interface Document {
743
+ /**
744
+ * The unique identifier for the associated object.
745
+ */
746
+ documentable_id: string;
747
+
748
+ documentable_type:
749
+ | 'cases'
750
+ | 'counterparties'
751
+ | 'expected_payments'
752
+ | 'external_accounts'
753
+ | 'internal_accounts'
754
+ | 'organizations'
755
+ | 'paper_items'
756
+ | 'payment_orders'
757
+ | 'transactions'
758
+ | 'decisions'
759
+ | 'connections';
760
+
743
761
  file: Uploadable;
744
762
 
745
763
  /**
@@ -756,10 +774,10 @@ export namespace PaymentOrderCreateParams {
756
774
  */
757
775
  export interface LedgerTransaction {
758
776
  /**
759
- * The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
760
- * purposes.
777
+ * The timestamp (ISO8601 format) at which the ledger transaction happened for
778
+ * reporting purposes.
761
779
  */
762
- effective_date: string;
780
+ effective_at: string;
763
781
 
764
782
  /**
765
783
  * An array of ledger entry objects.
@@ -771,6 +789,12 @@ export namespace PaymentOrderCreateParams {
771
789
  */
772
790
  description?: string | null;
773
791
 
792
+ /**
793
+ * The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
794
+ * purposes.
795
+ */
796
+ effective_date?: string;
797
+
774
798
  /**
775
799
  * A unique string to represent the ledger transaction. Only one pending or posted
776
800
  * ledger transaction may have this ID in the ledger.
@@ -1880,10 +1904,10 @@ export namespace PaymentOrderCreateAsyncParams {
1880
1904
  */
1881
1905
  export interface LedgerTransaction {
1882
1906
  /**
1883
- * The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
1884
- * purposes.
1907
+ * The timestamp (ISO8601 format) at which the ledger transaction happened for
1908
+ * reporting purposes.
1885
1909
  */
1886
- effective_date: string;
1910
+ effective_at: string;
1887
1911
 
1888
1912
  /**
1889
1913
  * An array of ledger entry objects.
@@ -1895,6 +1919,12 @@ export namespace PaymentOrderCreateAsyncParams {
1895
1919
  */
1896
1920
  description?: string | null;
1897
1921
 
1922
+ /**
1923
+ * The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
1924
+ * purposes.
1925
+ */
1926
+ effective_date?: string;
1927
+
1898
1928
  /**
1899
1929
  * A unique string to represent the ledger transaction. Only one pending or posted
1900
1930
  * ledger transaction may have this ID in the ledger.
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as API from './';
7
- import { Page, PageParams } from 'modern-treasury/pagination';
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';
8
8
 
9
9
  export class Reversals extends APIResource {
10
10
  /**
@@ -146,10 +146,10 @@ export namespace ReversalCreateParams {
146
146
  */
147
147
  export interface LedgerTransaction {
148
148
  /**
149
- * The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
150
- * purposes.
149
+ * The timestamp (ISO8601 format) at which the ledger transaction happened for
150
+ * reporting purposes.
151
151
  */
152
- effective_date: string;
152
+ effective_at: string;
153
153
 
154
154
  /**
155
155
  * An array of ledger entry objects.
@@ -161,6 +161,12 @@ export namespace ReversalCreateParams {
161
161
  */
162
162
  description?: string | null;
163
163
 
164
+ /**
165
+ * The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
166
+ * purposes.
167
+ */
168
+ effective_date?: string;
169
+
164
170
  /**
165
171
  * A unique string to represent the ledger transaction. Only one pending or posted
166
172
  * ledger transaction may have this ID in the ledger.
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as API from './';
7
- import { Page, PageParams } from 'modern-treasury/pagination';
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';
8
8
 
9
9
  export class PaymentReferences extends APIResource {
10
10
  /**
@@ -1,11 +1,11 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as Shared from 'modern-treasury/resources/shared';
7
- import * as API from './';
8
- import { Page, PageParams } from 'modern-treasury/pagination';
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';
9
9
 
10
10
  export class Returns extends APIResource {
11
11
  /**
@@ -1,11 +1,11 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as Shared from 'modern-treasury/resources/shared';
7
- import * as API from './';
8
- import { Page, PageParams } from 'modern-treasury/pagination';
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';
9
9
 
10
10
  export class RoutingDetails extends APIResource {
11
11
  /**
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as API from './';
3
+ import * as API from './index';
4
4
 
5
5
  export interface PingResponse {
6
6
  ping: string;
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as API from './';
7
- import { Page, PageParams } from 'modern-treasury/pagination';
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';
8
8
 
9
9
  export class LineItems extends APIResource {
10
10
  /**
@@ -1,12 +1,12 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as Shared from 'modern-treasury/resources/shared';
3
+ import * as Core from '../../core';
4
+ import { APIResource } from '../../resource';
5
+ import { isRequestOptions } from '../../core';
6
+ import * as Shared from '../shared';
7
7
  import { LineItems } from './line-items';
8
- import * as API from './';
9
- import { Page, PageParams } from 'modern-treasury/pagination';
8
+ import * as API from './index';
9
+ import { Page, PageParams } from '../../pagination';
10
10
 
11
11
  export class Transactions extends APIResource {
12
12
  lineItems: LineItems = new LineItems(this.client);
@@ -1,8 +1,8 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import * as API from './';
3
+ import * as Core from '../core';
4
+ import { APIResource } from '../resource';
5
+ import * as API from './index';
6
6
 
7
7
  export class Validations extends APIResource {
8
8
  /**
@@ -1,12 +1,12 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from 'modern-treasury/core';
4
- import { APIResource } from 'modern-treasury/resource';
5
- import { isRequestOptions } from 'modern-treasury/core';
6
- import * as AccountDetails from 'modern-treasury/resources/account-details';
7
- import * as RoutingDetails from 'modern-treasury/resources/routing-details';
8
- import * as API from './';
9
- import { Page, PageParams } from 'modern-treasury/pagination';
3
+ import * as Core from '../core';
4
+ import { APIResource } from '../resource';
5
+ import { isRequestOptions } from '../core';
6
+ import * as AccountDetails from './account-details';
7
+ import * as RoutingDetails from './routing-details';
8
+ import * as API from './index';
9
+ import { Page, PageParams } from '../pagination';
10
10
 
11
11
  export class VirtualAccounts extends APIResource {
12
12
  /**
@@ -27,11 +27,8 @@ export class VirtualAccounts extends APIResource {
27
27
  /**
28
28
  * get virtual_account
29
29
  */
30
- retrieve(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<void>> {
31
- return this.get(`/api/virtual_accounts/${id}`, {
32
- ...options,
33
- headers: { Accept: '', ...options?.headers },
34
- });
30
+ retrieve(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<VirtualAccount>> {
31
+ return this.get(`/api/virtual_accounts/${id}`, options);
35
32
  }
36
33
 
37
34
  /**
@@ -168,7 +165,7 @@ export interface VirtualAccountCreateParams {
168
165
  /**
169
166
  * Body param: An array of account detail objects.
170
167
  */
171
- account_details?: Array<AccountDetails.AccountDetail>;
168
+ account_details?: Array<VirtualAccountCreateParams.AccountDetail>;
172
169
 
173
170
  /**
174
171
  * Body param: The ID of the counterparty that the virtual account belongs to.
@@ -203,7 +200,7 @@ export interface VirtualAccountCreateParams {
203
200
  /**
204
201
  * Body param: An array of routing detail objects.
205
202
  */
206
- routing_details?: Array<RoutingDetails.RoutingDetail>;
203
+ routing_details?: Array<VirtualAccountCreateParams.RoutingDetail>;
207
204
 
208
205
  /**
209
206
  * Header param: This key should be something unique, preferably something like an
@@ -212,6 +209,67 @@ export interface VirtualAccountCreateParams {
212
209
  'Idempotency-Key'?: string;
213
210
  }
214
211
 
212
+ export namespace VirtualAccountCreateParams {
213
+ export interface AccountDetail {
214
+ /**
215
+ * The account number for the bank account.
216
+ */
217
+ account_number: string;
218
+
219
+ /**
220
+ * One of `iban`, `clabe`, `wallet_address`, or `other`. Use `other` if the bank
221
+ * account number is in a generic format.
222
+ */
223
+ account_number_type?: 'clabe' | 'iban' | 'other' | 'pan' | 'wallet_address';
224
+ }
225
+
226
+ export interface RoutingDetail {
227
+ /**
228
+ * The routing number of the bank.
229
+ */
230
+ routing_number: string;
231
+
232
+ /**
233
+ * One of `aba`, `swift`, `ca_cpa`, `au_bsb`, `gb_sort_code`, `in_ifsc`, `cnaps`.
234
+ */
235
+ routing_number_type:
236
+ | 'aba'
237
+ | 'au_bsb'
238
+ | 'br_codigo'
239
+ | 'ca_cpa'
240
+ | 'chips'
241
+ | 'cnaps'
242
+ | 'gb_sort_code'
243
+ | 'in_ifsc'
244
+ | 'my_branch_code'
245
+ | 'swift';
246
+
247
+ /**
248
+ * If the routing detail is to be used for a specific payment type this field will
249
+ * be populated, otherwise null.
250
+ */
251
+ payment_type?:
252
+ | 'ach'
253
+ | 'au_becs'
254
+ | 'bacs'
255
+ | 'book'
256
+ | 'card'
257
+ | 'check'
258
+ | 'cross_border'
259
+ | 'eft'
260
+ | 'interac'
261
+ | 'masav'
262
+ | 'neft'
263
+ | 'provxchange'
264
+ | 'rtp'
265
+ | 'sen'
266
+ | 'sepa'
267
+ | 'signet'
268
+ | 'wire'
269
+ | null;
270
+ }
271
+ }
272
+
215
273
  export interface VirtualAccountUpdateParams {
216
274
  counterparty_id?: string;
217
275
 
@@ -1,9 +1,9 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import { APIResource } from 'modern-treasury/resource';
3
+ import { APIResource } from '../resource';
4
4
  import { createHmac } from 'crypto';
5
- import type { HeadersLike } from 'modern-treasury/core';
6
- import { getHeader } from 'modern-treasury/core';
5
+ import type { HeadersLike } from '../core';
6
+ import { getHeader } from '../core';
7
7
 
8
8
  export class Webhooks extends APIResource {
9
9
  /**
package/src/uploads.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { type RequestOptions } from './core';
2
- import { type Readable } from 'modern-treasury/_shims/node-readable';
3
- import { type BodyInit } from 'modern-treasury/_shims/fetch';
4
- import { FormData, File, type FilePropertyBag } from 'modern-treasury/_shims/formdata';
5
- import { getMultipartRequestOptions } from 'modern-treasury/_shims/getMultipartRequestOptions';
6
- import { fileFromPath } from 'modern-treasury/_shims/fileFromPath';
7
- import { type FsReadStream, isFsReadStream } from 'modern-treasury/_shims/node-readable';
2
+ import { type Readable } from './_shims/node-readable';
3
+ import { type BodyInit } from './_shims/fetch.js';
4
+ import { FormData, File, type Blob, type FilePropertyBag } from './_shims/formdata.js';
5
+ import { getMultipartRequestOptions } from './_shims/getMultipartRequestOptions';
6
+ import { fileFromPath } from './_shims/fileFromPath';
7
+ import { type FsReadStream, isFsReadStream } from './_shims/node-readable';
8
8
 
9
9
  export { fileFromPath };
10
10
 
11
- export type BlobPart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
11
+ type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
12
+ export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
12
13
 
13
14
  /**
14
15
  * Typically, this is a native "File" class.
@@ -84,11 +85,11 @@ export const isUploadable = (value: any): value is Uploadable => {
84
85
  return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
85
86
  };
86
87
 
87
- export type ToFileInput = Uploadable | Exclude<BlobPart, string> | AsyncIterable<BlobPart>;
88
+ export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIterable<BlobLikePart>;
88
89
 
89
90
  /**
90
91
  * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
91
- * @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s
92
+ * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
92
93
  * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
93
94
  * @param {Object=} options additional properties
94
95
  * @param {string=} options.type the MIME type of the content
@@ -96,10 +97,13 @@ export type ToFileInput = Uploadable | Exclude<BlobPart, string> | AsyncIterable
96
97
  * @returns a {@link File} with the given properties
97
98
  */
98
99
  export async function toFile(
99
- value: ToFileInput,
100
+ value: ToFileInput | PromiseLike<ToFileInput>,
100
101
  name?: string | null | undefined,
101
102
  options: FilePropertyBag | undefined = {},
102
103
  ): Promise<FileLike> {
104
+ // If it's a promise, resolve it.
105
+ value = await value;
106
+
103
107
  if (isResponseLike(value)) {
104
108
  const blob = await value.blob();
105
109
  name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';
@@ -122,8 +126,6 @@ export async function toFile(
122
126
  }
123
127
 
124
128
  async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
125
- if (value instanceof Promise) return getBytes(await (value as any));
126
-
127
129
  let parts: Array<BlobPart> = [];
128
130
  if (
129
131
  typeof value === 'string' ||
@@ -230,10 +232,10 @@ const addFormValue = async (form: FormData, key: string, value: unknown): Promis
230
232
 
231
233
  // TODO: make nested formats configurable
232
234
  if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
233
- form.append(key, value);
235
+ form.append(key, String(value));
234
236
  } else if (isUploadable(value)) {
235
237
  const file = await toFile(value);
236
- form.append(key, file);
238
+ form.append(key, file as File);
237
239
  } else if (Array.isArray(value)) {
238
240
  await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
239
241
  } else if (typeof value === 'object') {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.0.0'; // x-release-please-version
1
+ export const VERSION = '2.2.0'; // x-release-please-version
package/uploads.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { type RequestOptions } from './core.js';
2
2
  import { type Readable } from 'modern-treasury/_shims/node-readable';
3
3
  import { type BodyInit } from 'modern-treasury/_shims/fetch';
4
- import { FormData, type FilePropertyBag } from 'modern-treasury/_shims/formdata';
4
+ import { FormData, type Blob, type FilePropertyBag } from 'modern-treasury/_shims/formdata';
5
5
  import { fileFromPath } from 'modern-treasury/_shims/fileFromPath';
6
6
  import { type FsReadStream } from 'modern-treasury/_shims/node-readable';
7
7
  export { fileFromPath };
8
- export type BlobPart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
8
+ type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
9
+ export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
9
10
  /**
10
11
  * Typically, this is a native "File" class.
11
12
  *
@@ -55,10 +56,10 @@ export declare const isBlobLike: (value: any) => value is BlobLike & {
55
56
  arrayBuffer(): Promise<ArrayBuffer>;
56
57
  };
57
58
  export declare const isUploadable: (value: any) => value is Uploadable;
58
- export type ToFileInput = Uploadable | Exclude<BlobPart, string> | AsyncIterable<BlobPart>;
59
+ export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIterable<BlobLikePart>;
59
60
  /**
60
61
  * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
61
- * @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s
62
+ * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
62
63
  * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
63
64
  * @param {Object=} options additional properties
64
65
  * @param {string=} options.type the MIME type of the content
@@ -66,7 +67,7 @@ export type ToFileInput = Uploadable | Exclude<BlobPart, string> | AsyncIterable
66
67
  * @returns a {@link File} with the given properties
67
68
  */
68
69
  export declare function toFile(
69
- value: ToFileInput,
70
+ value: ToFileInput | PromiseLike<ToFileInput>,
70
71
  name?: string | null | undefined,
71
72
  options?: FilePropertyBag | undefined,
72
73
  ): Promise<FileLike>;
package/uploads.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAQ,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,sCAAsC,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E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CAAC;AAEF,eAAO,MAAM,2BAA2B,iHAKvC,CAAC;AAEF,eAAO,MAAM,UAAU,wDAA6D,QAAQ,QAAQ,CAInG,CAAC"}
package/uploads.js CHANGED
@@ -58,7 +58,7 @@ const isUploadable = (value) => {
58
58
  exports.isUploadable = isUploadable;
59
59
  /**
60
60
  * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
61
- * @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s
61
+ * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
62
62
  * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
63
63
  * @param {Object=} options additional properties
64
64
  * @param {string=} options.type the MIME type of the content
@@ -67,6 +67,8 @@ exports.isUploadable = isUploadable;
67
67
  */
68
68
  async function toFile(value, name, options = {}) {
69
69
  var _a, _b, _c;
70
+ // If it's a promise, resolve it.
71
+ value = await value;
70
72
  if ((0, exports.isResponseLike)(value)) {
71
73
  const blob = await value.blob();
72
74
  name ||
@@ -89,7 +91,6 @@ async function toFile(value, name, options = {}) {
89
91
  exports.toFile = toFile;
90
92
  async function getBytes(value) {
91
93
  var _a;
92
- if (value instanceof Promise) return getBytes(await value);
93
94
  let parts = [];
94
95
  if (
95
96
  typeof value === 'string' ||
@@ -188,7 +189,7 @@ const addFormValue = async (form, key, value) => {
188
189
  }
189
190
  // TODO: make nested formats configurable
190
191
  if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
191
- form.append(key, value);
192
+ form.append(key, String(value));
192
193
  } else if ((0, exports.isUploadable)(value)) {
193
194
  const file = await toFile(value);
194
195
  form.append(key, file);
package/uploads.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"uploads.js","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":";;;AAGA,8DAAuF;AACvF,kGAA+F;AAC/F,sEAAmE;AAG1D,6FAHA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AAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,GAAG,EAAE,IAAI,CAAC,CAAC,CACzF,CAAC;KACH;SAAM;QACL,MAAM,IAAI,SAAS,CACjB,wGAAwG,KAAK,UAAU,CACxH,CAAC;KACH;AACH,CAAC,CAAC"}
package/uploads.mjs CHANGED
@@ -31,7 +31,7 @@ export const isUploadable = (value) => {
31
31
  };
32
32
  /**
33
33
  * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
34
- * @param bits the raw content of the file. Can be an {@link Uploadable}, {@link BlobPart}, or {@link AsyncIterable} of {@link BlobPart}s
34
+ * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
35
35
  * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
36
36
  * @param {Object=} options additional properties
37
37
  * @param {string=} options.type the MIME type of the content
@@ -40,6 +40,8 @@ export const isUploadable = (value) => {
40
40
  */
41
41
  export async function toFile(value, name, options = {}) {
42
42
  var _a, _b, _c;
43
+ // If it's a promise, resolve it.
44
+ value = await value;
43
45
  if (isResponseLike(value)) {
44
46
  const blob = await value.blob();
45
47
  name ||
@@ -61,7 +63,6 @@ export async function toFile(value, name, options = {}) {
61
63
  }
62
64
  async function getBytes(value) {
63
65
  var _a;
64
- if (value instanceof Promise) return getBytes(await value);
65
66
  let parts = [];
66
67
  if (
67
68
  typeof value === 'string' ||
@@ -155,7 +156,7 @@ const addFormValue = async (form, key, value) => {
155
156
  }
156
157
  // TODO: make nested formats configurable
157
158
  if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
158
- form.append(key, value);
159
+ form.append(key, String(value));
159
160
  } else if (isUploadable(value)) {
160
161
  const file = await toFile(value);
161
162
  form.append(key, file);