increase 0.3.0 → 0.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.
Files changed (286) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/.stats.yml +1 -1
  3. package/CHANGELOG.md +46 -0
  4. package/README.md +3 -4
  5. package/api.md +11 -0
  6. package/core.ts +4 -140
  7. package/dist/cjs/core.d.ts +3 -53
  8. package/dist/cjs/core.d.ts.map +1 -1
  9. package/dist/cjs/core.js +12 -179
  10. package/dist/cjs/core.js.map +1 -1
  11. package/dist/cjs/error.d.ts +72 -27
  12. package/dist/cjs/error.d.ts.map +1 -1
  13. package/dist/cjs/error.js +176 -54
  14. package/dist/cjs/error.js.map +1 -1
  15. package/dist/cjs/index.d.ts +25 -28
  16. package/dist/cjs/index.d.ts.map +1 -1
  17. package/dist/cjs/index.js +30 -77
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/cjs/resources/account-numbers.d.ts +1 -20
  20. package/dist/cjs/resources/account-numbers.d.ts.map +1 -1
  21. package/dist/cjs/resources/account-statements.d.ts +1 -20
  22. package/dist/cjs/resources/account-statements.d.ts.map +1 -1
  23. package/dist/cjs/resources/account-transfers.d.ts +1 -20
  24. package/dist/cjs/resources/account-transfers.d.ts.map +1 -1
  25. package/dist/cjs/resources/accounts.d.ts +17 -25
  26. package/dist/cjs/resources/accounts.d.ts.map +1 -1
  27. package/dist/cjs/resources/ach-prenotifications.d.ts +6 -25
  28. package/dist/cjs/resources/ach-prenotifications.d.ts.map +1 -1
  29. package/dist/cjs/resources/ach-transfers.d.ts +70 -37
  30. package/dist/cjs/resources/ach-transfers.d.ts.map +1 -1
  31. package/dist/cjs/resources/bookkeeping-accounts.d.ts +4 -4
  32. package/dist/cjs/resources/bookkeeping-accounts.d.ts.map +1 -1
  33. package/dist/cjs/resources/bookkeeping-entry-sets.d.ts +4 -16
  34. package/dist/cjs/resources/bookkeeping-entry-sets.d.ts.map +1 -1
  35. package/dist/cjs/resources/card-disputes.d.ts +2 -26
  36. package/dist/cjs/resources/card-disputes.d.ts.map +1 -1
  37. package/dist/cjs/resources/card-profiles.d.ts +1 -63
  38. package/dist/cjs/resources/card-profiles.d.ts.map +1 -1
  39. package/dist/cjs/resources/cards.d.ts +1 -116
  40. package/dist/cjs/resources/cards.d.ts.map +1 -1
  41. package/dist/cjs/resources/check-deposits.d.ts +3 -21
  42. package/dist/cjs/resources/check-deposits.d.ts.map +1 -1
  43. package/dist/cjs/resources/check-transfers.d.ts +10 -58
  44. package/dist/cjs/resources/check-transfers.d.ts.map +1 -1
  45. package/dist/cjs/resources/declined-transactions.d.ts +2 -48
  46. package/dist/cjs/resources/declined-transactions.d.ts.map +1 -1
  47. package/dist/cjs/resources/digital-wallet-tokens.d.ts +1 -20
  48. package/dist/cjs/resources/digital-wallet-tokens.d.ts.map +1 -1
  49. package/dist/cjs/resources/documents.d.ts +2 -76
  50. package/dist/cjs/resources/documents.d.ts.map +1 -1
  51. package/dist/cjs/resources/entities/entities.d.ts +81 -1021
  52. package/dist/cjs/resources/entities/entities.d.ts.map +1 -1
  53. package/dist/cjs/resources/entities/index.d.ts +6 -1
  54. package/dist/cjs/resources/entities/index.d.ts.map +1 -1
  55. package/dist/cjs/resources/entities/index.js +8 -1
  56. package/dist/cjs/resources/entities/index.js.map +1 -1
  57. package/dist/cjs/resources/entities/supplemental-documents.d.ts +35 -0
  58. package/dist/cjs/resources/entities/supplemental-documents.d.ts.map +1 -1
  59. package/dist/cjs/resources/entities/supplemental-documents.js +14 -1
  60. package/dist/cjs/resources/entities/supplemental-documents.js.map +1 -1
  61. package/dist/cjs/resources/event-subscriptions.d.ts +4 -4
  62. package/dist/cjs/resources/event-subscriptions.d.ts.map +1 -1
  63. package/dist/cjs/resources/events.d.ts +24 -99
  64. package/dist/cjs/resources/events.d.ts.map +1 -1
  65. package/dist/cjs/resources/exports.d.ts +4 -86
  66. package/dist/cjs/resources/exports.d.ts.map +1 -1
  67. package/dist/cjs/resources/external-accounts.d.ts +5 -10
  68. package/dist/cjs/resources/external-accounts.d.ts.map +1 -1
  69. package/dist/cjs/resources/files.d.ts +6 -43
  70. package/dist/cjs/resources/files.d.ts.map +1 -1
  71. package/dist/cjs/resources/limits.d.ts +4 -4
  72. package/dist/cjs/resources/limits.d.ts.map +1 -1
  73. package/dist/cjs/resources/pending-transactions.d.ts +11 -86
  74. package/dist/cjs/resources/pending-transactions.d.ts.map +1 -1
  75. package/dist/cjs/resources/real-time-decisions.d.ts +0 -69
  76. package/dist/cjs/resources/real-time-decisions.d.ts.map +1 -1
  77. package/dist/cjs/resources/real-time-payments-transfers.d.ts +9 -28
  78. package/dist/cjs/resources/real-time-payments-transfers.d.ts.map +1 -1
  79. package/dist/cjs/resources/simulations/ach-transfers.d.ts +108 -214
  80. package/dist/cjs/resources/simulations/ach-transfers.d.ts.map +1 -1
  81. package/dist/cjs/resources/simulations/card-disputes.d.ts +4 -4
  82. package/dist/cjs/resources/simulations/card-disputes.d.ts.map +1 -1
  83. package/dist/cjs/resources/simulations/cards.d.ts +6 -83
  84. package/dist/cjs/resources/simulations/cards.d.ts.map +1 -1
  85. package/dist/cjs/resources/simulations/inbound-wire-drawdown-requests.d.ts +25 -25
  86. package/dist/cjs/resources/simulations/inbound-wire-drawdown-requests.d.ts.map +1 -1
  87. package/dist/cjs/resources/simulations/index.d.ts +1 -0
  88. package/dist/cjs/resources/simulations/index.d.ts.map +1 -1
  89. package/dist/cjs/resources/simulations/interest-payments.d.ts +57 -184
  90. package/dist/cjs/resources/simulations/interest-payments.d.ts.map +1 -1
  91. package/dist/cjs/resources/simulations/programs.d.ts +21 -0
  92. package/dist/cjs/resources/simulations/programs.d.ts.map +1 -0
  93. package/dist/cjs/resources/simulations/programs.js +17 -0
  94. package/dist/cjs/resources/simulations/programs.js.map +1 -0
  95. package/dist/cjs/resources/simulations/real-time-payments-transfers.d.ts +58 -242
  96. package/dist/cjs/resources/simulations/real-time-payments-transfers.d.ts.map +1 -1
  97. package/dist/cjs/resources/simulations/simulations.d.ts +2 -0
  98. package/dist/cjs/resources/simulations/simulations.d.ts.map +1 -1
  99. package/dist/cjs/resources/simulations/simulations.js +2 -0
  100. package/dist/cjs/resources/simulations/simulations.js.map +1 -1
  101. package/dist/cjs/resources/simulations/wire-transfers.d.ts +57 -184
  102. package/dist/cjs/resources/simulations/wire-transfers.d.ts.map +1 -1
  103. package/dist/cjs/resources/transactions.d.ts +81 -281
  104. package/dist/cjs/resources/transactions.d.ts.map +1 -1
  105. package/dist/cjs/resources/wire-drawdown-requests.d.ts +8 -8
  106. package/dist/cjs/resources/wire-drawdown-requests.d.ts.map +1 -1
  107. package/dist/cjs/resources/wire-transfers.d.ts +13 -32
  108. package/dist/cjs/resources/wire-transfers.d.ts.map +1 -1
  109. package/dist/cjs/streaming.d.ts +13 -0
  110. package/dist/cjs/streaming.d.ts.map +1 -0
  111. package/dist/cjs/streaming.js +282 -0
  112. package/dist/cjs/streaming.js.map +1 -0
  113. package/dist/cjs/tests/api-resources/account-numbers.test.js +7 -8
  114. package/dist/cjs/tests/api-resources/account-numbers.test.js.map +1 -1
  115. package/dist/cjs/tests/api-resources/account-statements.test.js +6 -4
  116. package/dist/cjs/tests/api-resources/account-statements.test.js.map +1 -1
  117. package/dist/cjs/tests/api-resources/account-transfers.test.js +6 -5
  118. package/dist/cjs/tests/api-resources/account-transfers.test.js.map +1 -1
  119. package/dist/cjs/tests/api-resources/accounts.test.js +10 -12
  120. package/dist/cjs/tests/api-resources/accounts.test.js.map +1 -1
  121. package/dist/cjs/tests/api-resources/ach-prenotifications.test.js +7 -15
  122. package/dist/cjs/tests/api-resources/ach-prenotifications.test.js.map +1 -1
  123. package/dist/cjs/tests/api-resources/ach-transfers.test.js +8 -20
  124. package/dist/cjs/tests/api-resources/ach-transfers.test.js.map +1 -1
  125. package/dist/cjs/tests/api-resources/balance-lookups.test.js +1 -4
  126. package/dist/cjs/tests/api-resources/balance-lookups.test.js.map +1 -1
  127. package/dist/cjs/tests/api-resources/bookkeeping-accounts.test.js +2 -7
  128. package/dist/cjs/tests/api-resources/bookkeeping-accounts.test.js.map +1 -1
  129. package/dist/cjs/tests/api-resources/bookkeeping-entry-sets.test.js +1 -3
  130. package/dist/cjs/tests/api-resources/bookkeeping-entry-sets.test.js.map +1 -1
  131. package/dist/cjs/tests/api-resources/card-disputes.test.js +7 -5
  132. package/dist/cjs/tests/api-resources/card-disputes.test.js.map +1 -1
  133. package/dist/cjs/tests/api-resources/card-profiles.test.js +1 -1
  134. package/dist/cjs/tests/api-resources/card-profiles.test.js.map +1 -1
  135. package/dist/cjs/tests/api-resources/cards.test.js +8 -16
  136. package/dist/cjs/tests/api-resources/cards.test.js.map +1 -1
  137. package/dist/cjs/tests/api-resources/check-deposits.test.js +6 -4
  138. package/dist/cjs/tests/api-resources/check-deposits.test.js.map +1 -1
  139. package/dist/cjs/tests/api-resources/check-transfers.test.js +8 -10
  140. package/dist/cjs/tests/api-resources/check-transfers.test.js.map +1 -1
  141. package/dist/cjs/tests/api-resources/declined-transactions.test.js +6 -4
  142. package/dist/cjs/tests/api-resources/declined-transactions.test.js.map +1 -1
  143. package/dist/cjs/tests/api-resources/digital-wallet-tokens.test.js +6 -4
  144. package/dist/cjs/tests/api-resources/digital-wallet-tokens.test.js.map +1 -1
  145. package/dist/cjs/tests/api-resources/documents.test.js +13 -9
  146. package/dist/cjs/tests/api-resources/documents.test.js.map +1 -1
  147. package/dist/cjs/tests/api-resources/entities/entities.test.js +8 -76
  148. package/dist/cjs/tests/api-resources/entities/entities.test.js.map +1 -1
  149. package/dist/cjs/tests/api-resources/entities/supplemental-documents.test.js +12 -0
  150. package/dist/cjs/tests/api-resources/entities/supplemental-documents.test.js.map +1 -1
  151. package/dist/cjs/tests/api-resources/event-subscriptions.test.js +3 -7
  152. package/dist/cjs/tests/api-resources/event-subscriptions.test.js.map +1 -1
  153. package/dist/cjs/tests/api-resources/events.test.js +7 -5
  154. package/dist/cjs/tests/api-resources/events.test.js.map +1 -1
  155. package/dist/cjs/tests/api-resources/exports.test.js +2 -6
  156. package/dist/cjs/tests/api-resources/exports.test.js.map +1 -1
  157. package/dist/cjs/tests/api-resources/external-accounts.test.js +3 -7
  158. package/dist/cjs/tests/api-resources/external-accounts.test.js.map +1 -1
  159. package/dist/cjs/tests/api-resources/files.test.js +8 -7
  160. package/dist/cjs/tests/api-resources/files.test.js.map +1 -1
  161. package/dist/cjs/tests/api-resources/limits.test.js +2 -7
  162. package/dist/cjs/tests/api-resources/limits.test.js.map +1 -1
  163. package/dist/cjs/tests/api-resources/pending-transactions.test.js +7 -5
  164. package/dist/cjs/tests/api-resources/pending-transactions.test.js.map +1 -1
  165. package/dist/cjs/tests/api-resources/real-time-decisions.test.js +1 -5
  166. package/dist/cjs/tests/api-resources/real-time-decisions.test.js.map +1 -1
  167. package/dist/cjs/tests/api-resources/real-time-payments-transfers.test.js +8 -10
  168. package/dist/cjs/tests/api-resources/real-time-payments-transfers.test.js.map +1 -1
  169. package/dist/cjs/tests/api-resources/routing-numbers.test.js +2 -6
  170. package/dist/cjs/tests/api-resources/routing-numbers.test.js.map +1 -1
  171. package/dist/cjs/tests/api-resources/simulations/ach-transfers.test.js +4 -8
  172. package/dist/cjs/tests/api-resources/simulations/ach-transfers.test.js.map +1 -1
  173. package/dist/cjs/tests/api-resources/simulations/card-disputes.test.js +1 -2
  174. package/dist/cjs/tests/api-resources/simulations/card-disputes.test.js.map +1 -1
  175. package/dist/cjs/tests/api-resources/simulations/cards.test.js +2 -8
  176. package/dist/cjs/tests/api-resources/simulations/cards.test.js.map +1 -1
  177. package/dist/cjs/tests/api-resources/simulations/inbound-wire-drawdown-requests.test.js +6 -18
  178. package/dist/cjs/tests/api-resources/simulations/inbound-wire-drawdown-requests.test.js.map +1 -1
  179. package/dist/cjs/tests/api-resources/simulations/programs.test.d.ts +2 -0
  180. package/dist/cjs/tests/api-resources/simulations/programs.test.d.ts.map +1 -0
  181. package/dist/cjs/tests/api-resources/simulations/programs.test.js +52 -0
  182. package/dist/cjs/tests/api-resources/simulations/programs.test.js.map +1 -0
  183. package/dist/cjs/tests/api-resources/simulations/real-time-payments-transfers.test.js +1 -6
  184. package/dist/cjs/tests/api-resources/simulations/real-time-payments-transfers.test.js.map +1 -1
  185. package/dist/cjs/tests/api-resources/simulations/wire-transfers.test.js +0 -13
  186. package/dist/cjs/tests/api-resources/simulations/wire-transfers.test.js.map +1 -1
  187. package/dist/cjs/tests/api-resources/transactions.test.js +9 -9
  188. package/dist/cjs/tests/api-resources/transactions.test.js.map +1 -1
  189. package/dist/cjs/tests/api-resources/wire-drawdown-requests.test.js +2 -5
  190. package/dist/cjs/tests/api-resources/wire-drawdown-requests.test.js.map +1 -1
  191. package/dist/cjs/tests/api-resources/wire-transfers.test.js +9 -14
  192. package/dist/cjs/tests/api-resources/wire-transfers.test.js.map +1 -1
  193. package/dist/cjs/tests/index.test.js +9 -4
  194. package/dist/cjs/tests/index.test.js.map +1 -1
  195. package/dist/cjs/version.d.ts +1 -1
  196. package/dist/cjs/version.js +1 -1
  197. package/error.ts +195 -27
  198. package/index.ts +26 -94
  199. package/package.json +1 -1
  200. package/release-please-config.json +5 -8
  201. package/resources/account-numbers.ts +1 -23
  202. package/resources/account-statements.ts +1 -23
  203. package/resources/account-transfers.ts +1 -23
  204. package/resources/accounts.ts +19 -28
  205. package/resources/ach-prenotifications.ts +7 -29
  206. package/resources/ach-transfers.ts +73 -42
  207. package/resources/bookkeeping-accounts.ts +5 -5
  208. package/resources/bookkeeping-entry-sets.ts +5 -19
  209. package/resources/card-disputes.ts +2 -29
  210. package/resources/card-profiles.ts +1 -74
  211. package/resources/cards.ts +1 -135
  212. package/resources/check-deposits.ts +3 -24
  213. package/resources/check-transfers.ts +11 -68
  214. package/resources/declined-transactions.ts +2 -60
  215. package/resources/digital-wallet-tokens.ts +1 -23
  216. package/resources/documents.ts +2 -79
  217. package/resources/entities/entities.ts +112 -1210
  218. package/resources/entities/index.ts +6 -1
  219. package/resources/entities/supplemental-documents.ts +46 -0
  220. package/resources/event-subscriptions.ts +5 -5
  221. package/resources/events.ts +28 -106
  222. package/resources/exports.ts +5 -99
  223. package/resources/external-accounts.ts +6 -11
  224. package/resources/files.ts +6 -46
  225. package/resources/limits.ts +5 -5
  226. package/resources/pending-transactions.ts +12 -104
  227. package/resources/real-time-decisions.ts +0 -77
  228. package/resources/real-time-payments-transfers.ts +11 -33
  229. package/resources/simulations/ach-transfers.ts +109 -263
  230. package/resources/simulations/card-disputes.ts +4 -4
  231. package/resources/simulations/cards.ts +7 -107
  232. package/resources/simulations/inbound-wire-drawdown-requests.ts +28 -28
  233. package/resources/simulations/index.ts +1 -0
  234. package/resources/simulations/interest-payments.ts +58 -224
  235. package/resources/simulations/programs.ts +26 -0
  236. package/resources/simulations/real-time-payments-transfers.ts +59 -292
  237. package/resources/simulations/simulations.ts +2 -0
  238. package/resources/simulations/wire-transfers.ts +58 -224
  239. package/resources/transactions.ts +86 -328
  240. package/resources/wire-drawdown-requests.ts +10 -10
  241. package/resources/wire-transfers.ts +15 -37
  242. package/streaming.ts +199 -0
  243. package/tests/api-resources/account-numbers.test.ts +7 -8
  244. package/tests/api-resources/account-statements.test.ts +6 -4
  245. package/tests/api-resources/account-transfers.test.ts +6 -5
  246. package/tests/api-resources/accounts.test.ts +10 -12
  247. package/tests/api-resources/ach-prenotifications.test.ts +7 -15
  248. package/tests/api-resources/ach-transfers.test.ts +8 -20
  249. package/tests/api-resources/balance-lookups.test.ts +1 -4
  250. package/tests/api-resources/bookkeeping-accounts.test.ts +2 -7
  251. package/tests/api-resources/bookkeeping-entry-sets.test.ts +1 -3
  252. package/tests/api-resources/card-disputes.test.ts +7 -5
  253. package/tests/api-resources/card-profiles.test.ts +1 -1
  254. package/tests/api-resources/cards.test.ts +8 -16
  255. package/tests/api-resources/check-deposits.test.ts +6 -4
  256. package/tests/api-resources/check-transfers.test.ts +8 -10
  257. package/tests/api-resources/declined-transactions.test.ts +6 -4
  258. package/tests/api-resources/digital-wallet-tokens.test.ts +6 -4
  259. package/tests/api-resources/documents.test.ts +9 -9
  260. package/tests/api-resources/entities/entities.test.ts +9 -80
  261. package/tests/api-resources/entities/supplemental-documents.test.ts +12 -0
  262. package/tests/api-resources/event-subscriptions.test.ts +3 -7
  263. package/tests/api-resources/events.test.ts +7 -5
  264. package/tests/api-resources/exports.test.ts +2 -6
  265. package/tests/api-resources/external-accounts.test.ts +3 -7
  266. package/tests/api-resources/files.test.ts +8 -7
  267. package/tests/api-resources/limits.test.ts +2 -7
  268. package/tests/api-resources/pending-transactions.test.ts +7 -5
  269. package/tests/api-resources/real-time-decisions.test.ts +1 -5
  270. package/tests/api-resources/real-time-payments-transfers.test.ts +8 -10
  271. package/tests/api-resources/routing-numbers.test.ts +2 -6
  272. package/tests/api-resources/simulations/ach-transfers.test.ts +1 -8
  273. package/tests/api-resources/simulations/card-disputes.test.ts +1 -2
  274. package/tests/api-resources/simulations/cards.test.ts +2 -8
  275. package/tests/api-resources/simulations/inbound-wire-drawdown-requests.test.ts +6 -18
  276. package/tests/api-resources/simulations/programs.test.ts +15 -0
  277. package/tests/api-resources/simulations/real-time-payments-transfers.test.ts +1 -6
  278. package/tests/api-resources/simulations/wire-transfers.test.ts +0 -13
  279. package/tests/api-resources/transactions.test.ts +9 -9
  280. package/tests/api-resources/wire-drawdown-requests.test.ts +2 -5
  281. package/tests/api-resources/wire-transfers.test.ts +9 -14
  282. package/tests/index.test.ts +9 -4
  283. package/version.ts +1 -1
  284. package/.github/workflows/publish-npm.yml +0 -28
  285. package/.github/workflows/release-doctor.yml +0 -20
  286. package/.github/workflows/release.yml +0 -38
package/streaming.ts ADDED
@@ -0,0 +1,199 @@
1
+ import type { Response } from 'node-fetch';
2
+ import { APIResponse, Headers, createResponseHeaders } from '~/core';
3
+
4
+ type ServerSentEvent = {
5
+ event: string | null;
6
+ data: string;
7
+ raw: string[];
8
+ };
9
+
10
+ class SSEDecoder {
11
+ private data: string[];
12
+ private event: string | null;
13
+ private chunks: string[];
14
+
15
+ constructor() {
16
+ this.event = null;
17
+ this.data = [];
18
+ this.chunks = [];
19
+ }
20
+
21
+ decode(line: string) {
22
+ if (line.endsWith('\r')) {
23
+ line = line.substring(0, line.length - 1);
24
+ }
25
+
26
+ if (!line) {
27
+ // empty line and we didn't previously encounter any messages
28
+ if (!this.event && !this.data.length) return null;
29
+
30
+ const sse: ServerSentEvent = {
31
+ event: this.event,
32
+ data: this.data.join('\n'),
33
+ raw: this.chunks,
34
+ };
35
+
36
+ this.event = null;
37
+ this.data = [];
38
+ this.chunks = [];
39
+
40
+ return sse;
41
+ }
42
+
43
+ this.chunks.push(line);
44
+
45
+ if (line.startsWith(':')) {
46
+ return null;
47
+ }
48
+
49
+ let [fieldname, _, value] = partition(line, ':');
50
+
51
+ if (value.startsWith(' ')) {
52
+ value = value.substring(1);
53
+ }
54
+
55
+ if (fieldname === 'event') {
56
+ this.event = value;
57
+ } else if (fieldname === 'data') {
58
+ this.data.push(value);
59
+ }
60
+
61
+ return null;
62
+ }
63
+ }
64
+
65
+ export class Stream<Item> implements AsyncIterable<Item>, APIResponse<Stream<Item>> {
66
+ response: Response;
67
+ responseHeaders: Headers;
68
+ controller: AbortController;
69
+
70
+ private decoder: SSEDecoder;
71
+
72
+ constructor(response: Response, controller: AbortController) {
73
+ this.response = response;
74
+ this.controller = controller;
75
+ this.decoder = new SSEDecoder();
76
+ this.responseHeaders = createResponseHeaders(response.headers);
77
+ }
78
+
79
+ private async *iterMessages(): AsyncGenerator<ServerSentEvent, void, unknown> {
80
+ if (!this.response.body) {
81
+ this.controller.abort();
82
+ throw new Error(`Attempted to iterate over a response with no body`);
83
+ }
84
+
85
+ const lineDecoder = new LineDecoder();
86
+
87
+ for await (const chunk of this.response.body) {
88
+ let text;
89
+ if (chunk instanceof Buffer) {
90
+ text = chunk.toString();
91
+ } else {
92
+ text = chunk;
93
+ }
94
+
95
+ for (const line of lineDecoder.decode(text)) {
96
+ const sse = this.decoder.decode(line);
97
+ if (sse) yield sse;
98
+ }
99
+ }
100
+
101
+ for (const line of lineDecoder.flush()) {
102
+ const sse = this.decoder.decode(line);
103
+ if (sse) yield sse;
104
+ }
105
+ }
106
+
107
+ async *[Symbol.asyncIterator](): AsyncIterator<Item, any, undefined> {
108
+ try {
109
+ for await (const sse of this.iterMessages()) {
110
+ try {
111
+ yield JSON.parse(sse.data);
112
+ } catch (e) {
113
+ console.error(`Could not parse message into JSON:`, sse.data);
114
+ console.error(`From chunk:`, sse.raw);
115
+ throw e;
116
+ }
117
+ }
118
+ } catch (e) {
119
+ // If the user calls `stream.controller.abort()`, we should exit without throwing.
120
+ if (e instanceof Error && e.name === 'AbortError') return;
121
+ throw e;
122
+ } finally {
123
+ // If the user `break`s, abort the ongoing request.
124
+ this.controller.abort();
125
+ }
126
+ }
127
+ }
128
+
129
+ const NEWLINE_CHARS = '\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029';
130
+
131
+ /**
132
+ * A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
133
+ * reading lines from text.
134
+ *
135
+ * https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
136
+ */
137
+ class LineDecoder {
138
+ buffer: string[];
139
+ trailingCR: boolean;
140
+
141
+ constructor() {
142
+ this.buffer = [];
143
+ this.trailingCR = false;
144
+ }
145
+
146
+ decode(text: string): string[] {
147
+ if (this.trailingCR) {
148
+ text = '\r' + text;
149
+ this.trailingCR = false;
150
+ }
151
+ if (text.endsWith('\r')) {
152
+ this.trailingCR = true;
153
+ text = text.slice(0, -1);
154
+ }
155
+
156
+ if (!text) {
157
+ return [];
158
+ }
159
+
160
+ const trailing_newline = NEWLINE_CHARS.includes(text.slice(-1));
161
+ let lines = text.split(/\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g);
162
+
163
+ if (lines.length === 1 && !trailing_newline) {
164
+ this.buffer.push(lines[0]!);
165
+ return [];
166
+ }
167
+
168
+ if (this.buffer.length > 0) {
169
+ lines = [this.buffer.join('') + lines[0], ...lines.slice(1)];
170
+ this.buffer = [];
171
+ }
172
+
173
+ if (!trailing_newline) {
174
+ this.buffer = [lines.pop() || ''];
175
+ }
176
+
177
+ return lines;
178
+ }
179
+
180
+ flush(): string[] {
181
+ if (!this.buffer.length && !this.trailingCR) {
182
+ return [];
183
+ }
184
+
185
+ const lines = [this.buffer.join('')];
186
+ this.buffer = [];
187
+ this.trailingCR = false;
188
+ return lines;
189
+ }
190
+ }
191
+
192
+ function partition(str: string, delimiter: string): [string, string, string] {
193
+ const index = str.indexOf(delimiter);
194
+ if (index !== -1) {
195
+ return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
196
+ }
197
+
198
+ return [str, '', ''];
199
+ }
@@ -27,10 +27,7 @@ describe('resource accountNumbers', () => {
27
27
  });
28
28
 
29
29
  test('update', async () => {
30
- const response = await increase.accountNumbers.update('account_number_v18nkfqm6afpsrvy82b2', {
31
- name: 'x',
32
- status: 'active',
33
- });
30
+ const response = await increase.accountNumbers.update('account_number_v18nkfqm6afpsrvy82b2', {});
34
31
  });
35
32
 
36
33
  test('list', async () => {
@@ -50,10 +47,12 @@ describe('resource accountNumbers', () => {
50
47
  increase.accountNumbers.list(
51
48
  {
52
49
  account_id: 'string',
53
- 'created_at.after': '2019-12-27T18:11:19.117Z',
54
- 'created_at.before': '2019-12-27T18:11:19.117Z',
55
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
56
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
50
+ created_at: {
51
+ after: '2019-12-27T18:11:19.117Z',
52
+ before: '2019-12-27T18:11:19.117Z',
53
+ on_or_after: '2019-12-27T18:11:19.117Z',
54
+ on_or_before: '2019-12-27T18:11:19.117Z',
55
+ },
57
56
  cursor: 'string',
58
57
  limit: 0,
59
58
  status: 'active',
@@ -37,10 +37,12 @@ describe('resource accountStatements', () => {
37
37
  account_id: 'string',
38
38
  cursor: 'string',
39
39
  limit: 0,
40
- 'statement_period_start.after': '2019-12-27T18:11:19.117Z',
41
- 'statement_period_start.before': '2019-12-27T18:11:19.117Z',
42
- 'statement_period_start.on_or_after': '2019-12-27T18:11:19.117Z',
43
- 'statement_period_start.on_or_before': '2019-12-27T18:11:19.117Z',
40
+ statement_period_start: {
41
+ after: '2019-12-27T18:11:19.117Z',
42
+ before: '2019-12-27T18:11:19.117Z',
43
+ on_or_after: '2019-12-27T18:11:19.117Z',
44
+ on_or_before: '2019-12-27T18:11:19.117Z',
45
+ },
44
46
  },
45
47
  { path: '/_stainless_unknown_path' },
46
48
  ),
@@ -11,7 +11,6 @@ describe('resource accountTransfers', () => {
11
11
  amount: 1,
12
12
  description: 'x',
13
13
  destination_account_id: 'string',
14
- require_approval: true,
15
14
  });
16
15
  });
17
16
 
@@ -55,10 +54,12 @@ describe('resource accountTransfers', () => {
55
54
  increase.accountTransfers.list(
56
55
  {
57
56
  account_id: 'string',
58
- 'created_at.after': '2019-12-27T18:11:19.117Z',
59
- 'created_at.before': '2019-12-27T18:11:19.117Z',
60
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
61
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
57
+ created_at: {
58
+ after: '2019-12-27T18:11:19.117Z',
59
+ before: '2019-12-27T18:11:19.117Z',
60
+ on_or_after: '2019-12-27T18:11:19.117Z',
61
+ on_or_before: '2019-12-27T18:11:19.117Z',
62
+ },
62
63
  cursor: 'string',
63
64
  limit: 0,
64
65
  },
@@ -6,19 +6,14 @@ const increase = new Increase({ apiKey: 'something1234', baseURL: 'http://127.0.
6
6
 
7
7
  describe('resource accounts', () => {
8
8
  test('create: only required params', async () => {
9
- const response = await increase.accounts.create({
10
- entity_id: 'string',
11
- informational_entity_id: 'string',
12
- name: 'x',
13
- program_id: 'string',
14
- });
9
+ const response = await increase.accounts.create({ name: 'x' });
15
10
  });
16
11
 
17
12
  test('create: required and optional params', async () => {
18
13
  const response = await increase.accounts.create({
14
+ name: 'x',
19
15
  entity_id: 'string',
20
16
  informational_entity_id: 'string',
21
- name: 'x',
22
17
  program_id: 'string',
23
18
  });
24
19
  });
@@ -35,7 +30,7 @@ describe('resource accounts', () => {
35
30
  });
36
31
 
37
32
  test('update', async () => {
38
- const response = await increase.accounts.update('account_in71c4amph0vgo2qllky', { name: 'x' });
33
+ const response = await increase.accounts.update('account_in71c4amph0vgo2qllky', {});
39
34
  });
40
35
 
41
36
  test('list', async () => {
@@ -54,12 +49,15 @@ describe('resource accounts', () => {
54
49
  await expect(
55
50
  increase.accounts.list(
56
51
  {
57
- 'created_at.after': '2019-12-27T18:11:19.117Z',
58
- 'created_at.before': '2019-12-27T18:11:19.117Z',
59
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
60
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
52
+ created_at: {
53
+ after: '2019-12-27T18:11:19.117Z',
54
+ before: '2019-12-27T18:11:19.117Z',
55
+ on_or_after: '2019-12-27T18:11:19.117Z',
56
+ on_or_before: '2019-12-27T18:11:19.117Z',
57
+ },
61
58
  cursor: 'string',
62
59
  entity_id: 'string',
60
+ informational_entity_id: 'string',
63
61
  limit: 0,
64
62
  status: 'open',
65
63
  },
@@ -8,23 +8,14 @@ describe('resource achPrenotifications', () => {
8
8
  test('create: only required params', async () => {
9
9
  const response = await increase.achPrenotifications.create({
10
10
  account_number: 'x',
11
- addendum: 'x',
12
- company_descriptive_date: 'x',
13
- company_discretionary_data: 'x',
14
- company_entry_description: 'x',
15
- company_name: 'x',
16
- credit_debit_indicator: 'credit',
17
- effective_date: '2019-12-27',
18
- individual_id: 'x',
19
- individual_name: 'x',
20
11
  routing_number: 'xxxxxxxxx',
21
- standard_entry_class_code: 'corporate_credit_or_debit',
22
12
  });
23
13
  });
24
14
 
25
15
  test('create: required and optional params', async () => {
26
16
  const response = await increase.achPrenotifications.create({
27
17
  account_number: 'x',
18
+ routing_number: 'xxxxxxxxx',
28
19
  addendum: 'x',
29
20
  company_descriptive_date: 'x',
30
21
  company_discretionary_data: 'x',
@@ -34,7 +25,6 @@ describe('resource achPrenotifications', () => {
34
25
  effective_date: '2019-12-27',
35
26
  individual_id: 'x',
36
27
  individual_name: 'x',
37
- routing_number: 'xxxxxxxxx',
38
28
  standard_entry_class_code: 'corporate_credit_or_debit',
39
29
  });
40
30
  });
@@ -68,10 +58,12 @@ describe('resource achPrenotifications', () => {
68
58
  await expect(
69
59
  increase.achPrenotifications.list(
70
60
  {
71
- 'created_at.after': '2019-12-27T18:11:19.117Z',
72
- 'created_at.before': '2019-12-27T18:11:19.117Z',
73
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
74
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
61
+ created_at: {
62
+ after: '2019-12-27T18:11:19.117Z',
63
+ before: '2019-12-27T18:11:19.117Z',
64
+ on_or_after: '2019-12-27T18:11:19.117Z',
65
+ on_or_before: '2019-12-27T18:11:19.117Z',
66
+ },
75
67
  cursor: 'string',
76
68
  limit: 0,
77
69
  },
@@ -8,21 +8,7 @@ describe('resource achTransfers', () => {
8
8
  test('create: only required params', async () => {
9
9
  const response = await increase.achTransfers.create({
10
10
  account_id: 'string',
11
- account_number: 'x',
12
- addendum: 'x',
13
11
  amount: 0,
14
- company_descriptive_date: 'x',
15
- company_discretionary_data: 'x',
16
- company_entry_description: 'x',
17
- company_name: 'x',
18
- effective_date: '2019-12-27',
19
- external_account_id: 'string',
20
- funding: 'checking',
21
- individual_id: 'x',
22
- individual_name: 'x',
23
- require_approval: true,
24
- routing_number: 'xxxxxxxxx',
25
- standard_entry_class_code: 'corporate_credit_or_debit',
26
12
  statement_descriptor: 'x',
27
13
  });
28
14
  });
@@ -30,9 +16,10 @@ describe('resource achTransfers', () => {
30
16
  test('create: required and optional params', async () => {
31
17
  const response = await increase.achTransfers.create({
32
18
  account_id: 'string',
19
+ amount: 0,
20
+ statement_descriptor: 'x',
33
21
  account_number: 'x',
34
22
  addendum: 'x',
35
- amount: 0,
36
23
  company_descriptive_date: 'x',
37
24
  company_discretionary_data: 'x',
38
25
  company_entry_description: 'x',
@@ -45,7 +32,6 @@ describe('resource achTransfers', () => {
45
32
  require_approval: true,
46
33
  routing_number: 'xxxxxxxxx',
47
34
  standard_entry_class_code: 'corporate_credit_or_debit',
48
- statement_descriptor: 'x',
49
35
  });
50
36
  });
51
37
 
@@ -79,10 +65,12 @@ describe('resource achTransfers', () => {
79
65
  increase.achTransfers.list(
80
66
  {
81
67
  account_id: 'string',
82
- 'created_at.after': '2019-12-27T18:11:19.117Z',
83
- 'created_at.before': '2019-12-27T18:11:19.117Z',
84
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
85
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
68
+ created_at: {
69
+ after: '2019-12-27T18:11:19.117Z',
70
+ before: '2019-12-27T18:11:19.117Z',
71
+ on_or_after: '2019-12-27T18:11:19.117Z',
72
+ on_or_before: '2019-12-27T18:11:19.117Z',
73
+ },
86
74
  cursor: 'string',
87
75
  external_account_id: 'string',
88
76
  limit: 0,
@@ -6,10 +6,7 @@ const increase = new Increase({ apiKey: 'something1234', baseURL: 'http://127.0.
6
6
 
7
7
  describe('resource balanceLookups', () => {
8
8
  test('lookup: only required params', async () => {
9
- const response = await increase.balanceLookups.lookup({
10
- account_id: 'string',
11
- at_time: '2019-12-27T18:11:19.117Z',
12
- });
9
+ const response = await increase.balanceLookups.lookup({ account_id: 'string' });
13
10
  });
14
11
 
15
12
  test('lookup: required and optional params', async () => {
@@ -6,20 +6,15 @@ const increase = new Increase({ apiKey: 'something1234', baseURL: 'http://127.0.
6
6
 
7
7
  describe('resource bookkeepingAccounts', () => {
8
8
  test('create: only required params', async () => {
9
- const response = await increase.bookkeepingAccounts.create({
10
- account_id: 'string',
11
- compliance_category: 'commingled_cash',
12
- entity_id: 'string',
13
- name: 'x',
14
- });
9
+ const response = await increase.bookkeepingAccounts.create({ name: 'x' });
15
10
  });
16
11
 
17
12
  test('create: required and optional params', async () => {
18
13
  const response = await increase.bookkeepingAccounts.create({
14
+ name: 'x',
19
15
  account_id: 'string',
20
16
  compliance_category: 'commingled_cash',
21
17
  entity_id: 'string',
22
- name: 'x',
23
18
  });
24
19
  });
25
20
 
@@ -7,24 +7,22 @@ const increase = new Increase({ apiKey: 'something1234', baseURL: 'http://127.0.
7
7
  describe('resource bookkeepingEntrySets', () => {
8
8
  test('create: only required params', async () => {
9
9
  const response = await increase.bookkeepingEntrySets.create({
10
- date: '2019-12-27T18:11:19.117Z',
11
10
  entries: [
12
11
  { account_id: 'string', amount: 0 },
13
12
  { account_id: 'string', amount: 0 },
14
13
  { account_id: 'string', amount: 0 },
15
14
  ],
16
- transaction_id: 'string',
17
15
  });
18
16
  });
19
17
 
20
18
  test('create: required and optional params', async () => {
21
19
  const response = await increase.bookkeepingEntrySets.create({
22
- date: '2019-12-27T18:11:19.117Z',
23
20
  entries: [
24
21
  { account_id: 'string', amount: 0 },
25
22
  { account_id: 'string', amount: 0 },
26
23
  { account_id: 'string', amount: 0 },
27
24
  ],
25
+ date: '2019-12-27T18:11:19.117Z',
28
26
  transaction_id: 'string',
29
27
  });
30
28
  });
@@ -48,13 +48,15 @@ describe('resource cardDisputes', () => {
48
48
  await expect(
49
49
  increase.cardDisputes.list(
50
50
  {
51
- 'created_at.after': '2019-12-27T18:11:19.117Z',
52
- 'created_at.before': '2019-12-27T18:11:19.117Z',
53
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
54
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
51
+ created_at: {
52
+ after: '2019-12-27T18:11:19.117Z',
53
+ before: '2019-12-27T18:11:19.117Z',
54
+ on_or_after: '2019-12-27T18:11:19.117Z',
55
+ on_or_before: '2019-12-27T18:11:19.117Z',
56
+ },
55
57
  cursor: 'string',
56
58
  limit: 0,
57
- 'status.in': ['pending_reviewing', 'pending_reviewing', 'pending_reviewing'],
59
+ status: { in: ['pending_reviewing', 'pending_reviewing', 'pending_reviewing'] },
58
60
  },
59
61
  { path: '/_stainless_unknown_path' },
60
62
  ),
@@ -61,7 +61,7 @@ describe('resource cardProfiles', () => {
61
61
  // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
62
62
  await expect(
63
63
  increase.cardProfiles.list(
64
- { cursor: 'string', limit: 0, 'status.in': ['pending', 'pending', 'pending'] },
64
+ { cursor: 'string', limit: 0, status: { in: ['pending', 'pending', 'pending'] } },
65
65
  { path: '/_stainless_unknown_path' },
66
66
  ),
67
67
  ).rejects.toThrow(Increase.NotFoundError);
@@ -6,12 +6,7 @@ const increase = new Increase({ apiKey: 'something1234', baseURL: 'http://127.0.
6
6
 
7
7
  describe('resource cards', () => {
8
8
  test('create: only required params', async () => {
9
- const response = await increase.cards.create({
10
- account_id: 'string',
11
- billing_address: { line1: 'x', city: 'x', state: 'x', postal_code: 'x' },
12
- description: 'x',
13
- digital_wallet: {},
14
- });
9
+ const response = await increase.cards.create({ account_id: 'string' });
15
10
  });
16
11
 
17
12
  test('create: required and optional params', async () => {
@@ -35,12 +30,7 @@ describe('resource cards', () => {
35
30
  });
36
31
 
37
32
  test('update', async () => {
38
- const response = await increase.cards.update('card_oubs0hwk5rn6knuecxg2', {
39
- billing_address: { line1: 'x', city: 'x', state: 'x', postal_code: 'x' },
40
- description: 'x',
41
- digital_wallet: {},
42
- status: 'active',
43
- });
33
+ const response = await increase.cards.update('card_oubs0hwk5rn6knuecxg2', {});
44
34
  });
45
35
 
46
36
  test('list', async () => {
@@ -60,10 +50,12 @@ describe('resource cards', () => {
60
50
  increase.cards.list(
61
51
  {
62
52
  account_id: 'string',
63
- 'created_at.after': '2019-12-27T18:11:19.117Z',
64
- 'created_at.before': '2019-12-27T18:11:19.117Z',
65
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
66
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
53
+ created_at: {
54
+ after: '2019-12-27T18:11:19.117Z',
55
+ before: '2019-12-27T18:11:19.117Z',
56
+ on_or_after: '2019-12-27T18:11:19.117Z',
57
+ on_or_before: '2019-12-27T18:11:19.117Z',
58
+ },
67
59
  cursor: 'string',
68
60
  limit: 0,
69
61
  },
@@ -55,10 +55,12 @@ describe('resource checkDeposits', () => {
55
55
  increase.checkDeposits.list(
56
56
  {
57
57
  account_id: 'string',
58
- 'created_at.after': '2019-12-27T18:11:19.117Z',
59
- 'created_at.before': '2019-12-27T18:11:19.117Z',
60
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
61
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
58
+ created_at: {
59
+ after: '2019-12-27T18:11:19.117Z',
60
+ before: '2019-12-27T18:11:19.117Z',
61
+ on_or_after: '2019-12-27T18:11:19.117Z',
62
+ on_or_before: '2019-12-27T18:11:19.117Z',
63
+ },
62
64
  cursor: 'string',
63
65
  limit: 0,
64
66
  },
@@ -10,15 +10,11 @@ describe('resource checkTransfers', () => {
10
10
  account_id: 'string',
11
11
  address_city: 'x',
12
12
  address_line1: 'x',
13
- address_line2: 'x',
14
13
  address_state: 'x',
15
14
  address_zip: 'x',
16
15
  amount: 1,
17
16
  message: 'x',
18
- note: 'x',
19
17
  recipient_name: 'x',
20
- require_approval: true,
21
- return_address: { name: 'x', line1: 'x', city: 'x', state: 'x', zip: 'x' },
22
18
  });
23
19
  });
24
20
 
@@ -27,13 +23,13 @@ describe('resource checkTransfers', () => {
27
23
  account_id: 'string',
28
24
  address_city: 'x',
29
25
  address_line1: 'x',
30
- address_line2: 'x',
31
26
  address_state: 'x',
32
27
  address_zip: 'x',
33
28
  amount: 1,
34
29
  message: 'x',
35
- note: 'x',
36
30
  recipient_name: 'x',
31
+ address_line2: 'x',
32
+ note: 'x',
37
33
  require_approval: true,
38
34
  return_address: { name: 'x', line1: 'x', line2: 'x', city: 'x', state: 'x', zip: 'x' },
39
35
  });
@@ -69,10 +65,12 @@ describe('resource checkTransfers', () => {
69
65
  increase.checkTransfers.list(
70
66
  {
71
67
  account_id: 'string',
72
- 'created_at.after': '2019-12-27T18:11:19.117Z',
73
- 'created_at.before': '2019-12-27T18:11:19.117Z',
74
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
75
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
68
+ created_at: {
69
+ after: '2019-12-27T18:11:19.117Z',
70
+ before: '2019-12-27T18:11:19.117Z',
71
+ on_or_after: '2019-12-27T18:11:19.117Z',
72
+ on_or_before: '2019-12-27T18:11:19.117Z',
73
+ },
76
74
  cursor: 'string',
77
75
  limit: 0,
78
76
  },
@@ -37,10 +37,12 @@ describe('resource declinedTransactions', () => {
37
37
  increase.declinedTransactions.list(
38
38
  {
39
39
  account_id: 'string',
40
- 'created_at.after': '2019-12-27T18:11:19.117Z',
41
- 'created_at.before': '2019-12-27T18:11:19.117Z',
42
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
43
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
40
+ created_at: {
41
+ after: '2019-12-27T18:11:19.117Z',
42
+ before: '2019-12-27T18:11:19.117Z',
43
+ on_or_after: '2019-12-27T18:11:19.117Z',
44
+ on_or_before: '2019-12-27T18:11:19.117Z',
45
+ },
44
46
  cursor: 'string',
45
47
  limit: 0,
46
48
  route_id: 'string',
@@ -35,10 +35,12 @@ describe('resource digitalWalletTokens', () => {
35
35
  increase.digitalWalletTokens.list(
36
36
  {
37
37
  card_id: 'string',
38
- 'created_at.after': '2019-12-27T18:11:19.117Z',
39
- 'created_at.before': '2019-12-27T18:11:19.117Z',
40
- 'created_at.on_or_after': '2019-12-27T18:11:19.117Z',
41
- 'created_at.on_or_before': '2019-12-27T18:11:19.117Z',
38
+ created_at: {
39
+ after: '2019-12-27T18:11:19.117Z',
40
+ before: '2019-12-27T18:11:19.117Z',
41
+ on_or_after: '2019-12-27T18:11:19.117Z',
42
+ on_or_before: '2019-12-27T18:11:19.117Z',
43
+ },
42
44
  cursor: 'string',
43
45
  limit: 0,
44
46
  },