modern-treasury 0.0.1

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 (169) hide show
  1. package/.eslintrc.js +10 -0
  2. package/.prettierrc +6 -0
  3. package/LICENSE +7 -0
  4. package/README.md +198 -0
  5. package/build +10 -0
  6. package/core.ts +746 -0
  7. package/dist/cjs/core.d.ts +215 -0
  8. package/dist/cjs/core.js +815 -0
  9. package/dist/cjs/core.js.map +1 -0
  10. package/dist/cjs/index.d.ts +118 -0
  11. package/dist/cjs/index.js +128 -0
  12. package/dist/cjs/index.js.map +1 -0
  13. package/dist/cjs/pagination.d.ts +14 -0
  14. package/dist/cjs/pagination.js +22 -0
  15. package/dist/cjs/pagination.js.map +1 -0
  16. package/dist/cjs/resource.d.ts +11 -0
  17. package/dist/cjs/resource.js +16 -0
  18. package/dist/cjs/resource.js.map +1 -0
  19. package/dist/cjs/resources/counterparties.d.ts +500 -0
  20. package/dist/cjs/resources/counterparties.js +57 -0
  21. package/dist/cjs/resources/counterparties.js.map +1 -0
  22. package/dist/cjs/resources/documents.d.ts +66 -0
  23. package/dist/cjs/resources/documents.js +23 -0
  24. package/dist/cjs/resources/documents.js.map +1 -0
  25. package/dist/cjs/resources/events.d.ts +53 -0
  26. package/dist/cjs/resources/events.js +22 -0
  27. package/dist/cjs/resources/events.js.map +1 -0
  28. package/dist/cjs/resources/expected-payments.d.ts +928 -0
  29. package/dist/cjs/resources/expected-payments.js +31 -0
  30. package/dist/cjs/resources/expected-payments.js.map +1 -0
  31. package/dist/cjs/resources/external-accounts.d.ts +597 -0
  32. package/dist/cjs/resources/external-accounts.js +51 -0
  33. package/dist/cjs/resources/external-accounts.js.map +1 -0
  34. package/dist/cjs/resources/incoming-payment-details.d.ts +487 -0
  35. package/dist/cjs/resources/incoming-payment-details.js +35 -0
  36. package/dist/cjs/resources/incoming-payment-details.js.map +1 -0
  37. package/dist/cjs/resources/index.d.ts +15 -0
  38. package/dist/cjs/resources/index.js +46 -0
  39. package/dist/cjs/resources/index.js.map +1 -0
  40. package/dist/cjs/resources/internal-accounts.d.ts +666 -0
  41. package/dist/cjs/resources/internal-accounts.js +31 -0
  42. package/dist/cjs/resources/internal-accounts.js.map +1 -0
  43. package/dist/cjs/resources/line-items.d.ts +90 -0
  44. package/dist/cjs/resources/line-items.js +38 -0
  45. package/dist/cjs/resources/line-items.js.map +1 -0
  46. package/dist/cjs/resources/paper-items.d.ts +279 -0
  47. package/dist/cjs/resources/paper-items.js +25 -0
  48. package/dist/cjs/resources/paper-items.js.map +1 -0
  49. package/dist/cjs/resources/payment-orders/index.d.ts +2 -0
  50. package/dist/cjs/resources/payment-orders/index.js +33 -0
  51. package/dist/cjs/resources/payment-orders/index.js.map +1 -0
  52. package/dist/cjs/resources/payment-orders/payment-orders.d.ts +2180 -0
  53. package/dist/cjs/resources/payment-orders/payment-orders.js +56 -0
  54. package/dist/cjs/resources/payment-orders/payment-orders.js.map +1 -0
  55. package/dist/cjs/resources/payment-orders/reversals.d.ts +46 -0
  56. package/dist/cjs/resources/payment-orders/reversals.js +23 -0
  57. package/dist/cjs/resources/payment-orders/reversals.js.map +1 -0
  58. package/dist/cjs/resources/returns.d.ts +487 -0
  59. package/dist/cjs/resources/returns.js +31 -0
  60. package/dist/cjs/resources/returns.js.map +1 -0
  61. package/dist/cjs/resources/top-level.d.ts +3 -0
  62. package/dist/cjs/resources/top-level.js +4 -0
  63. package/dist/cjs/resources/top-level.js.map +1 -0
  64. package/dist/cjs/resources/transactions.d.ts +377 -0
  65. package/dist/cjs/resources/transactions.js +31 -0
  66. package/dist/cjs/resources/transactions.js.map +1 -0
  67. package/dist/cjs/resources/validations.d.ts +97 -0
  68. package/dist/cjs/resources/validations.js +16 -0
  69. package/dist/cjs/resources/validations.js.map +1 -0
  70. package/dist/cjs/resources/webhooks.d.ts +31 -0
  71. package/dist/cjs/resources/webhooks.js +44 -0
  72. package/dist/cjs/resources/webhooks.js.map +1 -0
  73. package/dist/cjs/tests/api-resources/counterparties.test.d.ts +1 -0
  74. package/dist/cjs/tests/api-resources/counterparties.test.js +275 -0
  75. package/dist/cjs/tests/api-resources/counterparties.test.js.map +1 -0
  76. package/dist/cjs/tests/api-resources/documents.test.d.ts +1 -0
  77. package/dist/cjs/tests/api-resources/documents.test.js +78 -0
  78. package/dist/cjs/tests/api-resources/documents.test.js.map +1 -0
  79. package/dist/cjs/tests/api-resources/events.test.d.ts +1 -0
  80. package/dist/cjs/tests/api-resources/events.test.js +100 -0
  81. package/dist/cjs/tests/api-resources/events.test.js.map +1 -0
  82. package/dist/cjs/tests/api-resources/expected-payments.test.d.ts +1 -0
  83. package/dist/cjs/tests/api-resources/expected-payments.test.js +176 -0
  84. package/dist/cjs/tests/api-resources/expected-payments.test.js.map +1 -0
  85. package/dist/cjs/tests/api-resources/external-accounts.test.d.ts +1 -0
  86. package/dist/cjs/tests/api-resources/external-accounts.test.js +248 -0
  87. package/dist/cjs/tests/api-resources/external-accounts.test.js.map +1 -0
  88. package/dist/cjs/tests/api-resources/incoming-payment-details.test.d.ts +1 -0
  89. package/dist/cjs/tests/api-resources/incoming-payment-details.test.js +130 -0
  90. package/dist/cjs/tests/api-resources/incoming-payment-details.test.js.map +1 -0
  91. package/dist/cjs/tests/api-resources/internal-accounts.test.d.ts +1 -0
  92. package/dist/cjs/tests/api-resources/internal-accounts.test.js +144 -0
  93. package/dist/cjs/tests/api-resources/internal-accounts.test.js.map +1 -0
  94. package/dist/cjs/tests/api-resources/line-items.test.d.ts +1 -0
  95. package/dist/cjs/tests/api-resources/line-items.test.js +123 -0
  96. package/dist/cjs/tests/api-resources/line-items.test.js.map +1 -0
  97. package/dist/cjs/tests/api-resources/paper-items.test.d.ts +1 -0
  98. package/dist/cjs/tests/api-resources/paper-items.test.js +96 -0
  99. package/dist/cjs/tests/api-resources/paper-items.test.js.map +1 -0
  100. package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.d.ts +1 -0
  101. package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.js +77 -0
  102. package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.js.map +1 -0
  103. package/dist/cjs/tests/api-resources/returns.test.d.ts +1 -0
  104. package/dist/cjs/tests/api-resources/returns.test.js +116 -0
  105. package/dist/cjs/tests/api-resources/returns.test.js.map +1 -0
  106. package/dist/cjs/tests/api-resources/top-level.test.d.ts +1 -0
  107. package/dist/cjs/tests/api-resources/top-level.test.js +59 -0
  108. package/dist/cjs/tests/api-resources/top-level.test.js.map +1 -0
  109. package/dist/cjs/tests/api-resources/transactions.test.d.ts +1 -0
  110. package/dist/cjs/tests/api-resources/transactions.test.js +134 -0
  111. package/dist/cjs/tests/api-resources/transactions.test.js.map +1 -0
  112. package/dist/cjs/tests/api-resources/validations.test.d.ts +1 -0
  113. package/dist/cjs/tests/api-resources/validations.test.js +62 -0
  114. package/dist/cjs/tests/api-resources/validations.test.js.map +1 -0
  115. package/dist/cjs/tests/api-resources/webhooks.test.d.ts +1 -0
  116. package/dist/cjs/tests/api-resources/webhooks.test.js +100 -0
  117. package/dist/cjs/tests/api-resources/webhooks.test.js.map +1 -0
  118. package/dist/cjs/tests/form.test.d.ts +1 -0
  119. package/dist/cjs/tests/form.test.js +61 -0
  120. package/dist/cjs/tests/form.test.js.map +1 -0
  121. package/dist/cjs/tests/index.test.d.ts +1 -0
  122. package/dist/cjs/tests/index.test.js +57 -0
  123. package/dist/cjs/tests/index.test.js.map +1 -0
  124. package/dist/cjs/tests/responses.test.d.ts +1 -0
  125. package/dist/cjs/tests/responses.test.js +60 -0
  126. package/dist/cjs/tests/responses.test.js.map +1 -0
  127. package/index.ts +175 -0
  128. package/jest.config.js +8 -0
  129. package/package.json +47 -0
  130. package/pagination.ts +36 -0
  131. package/resource.ts +22 -0
  132. package/resources/counterparties.ts +666 -0
  133. package/resources/documents.ts +97 -0
  134. package/resources/events.ts +86 -0
  135. package/resources/expected-payments.ts +1016 -0
  136. package/resources/external-accounts.ts +762 -0
  137. package/resources/incoming-payment-details.ts +592 -0
  138. package/resources/index.ts +16 -0
  139. package/resources/internal-accounts.ts +774 -0
  140. package/resources/line-items.ts +138 -0
  141. package/resources/paper-items.ts +317 -0
  142. package/resources/payment-orders/index.ts +3 -0
  143. package/resources/payment-orders/payment-orders.ts +2486 -0
  144. package/resources/payment-orders/reversals.ts +72 -0
  145. package/resources/returns.ts +545 -0
  146. package/resources/top-level.ts +5 -0
  147. package/resources/transactions.ts +441 -0
  148. package/resources/validations.ts +115 -0
  149. package/resources/webhooks.ts +48 -0
  150. package/tests/api-resources/counterparties.test.ts +237 -0
  151. package/tests/api-resources/documents.test.ts +40 -0
  152. package/tests/api-resources/events.test.ts +62 -0
  153. package/tests/api-resources/expected-payments.test.ts +138 -0
  154. package/tests/api-resources/external-accounts.test.ts +210 -0
  155. package/tests/api-resources/incoming-payment-details.test.ts +92 -0
  156. package/tests/api-resources/internal-accounts.test.ts +103 -0
  157. package/tests/api-resources/line-items.test.ts +85 -0
  158. package/tests/api-resources/paper-items.test.ts +58 -0
  159. package/tests/api-resources/payment-orders/payment-orders.test.ts +39 -0
  160. package/tests/api-resources/returns.test.ts +78 -0
  161. package/tests/api-resources/top-level.test.ts +21 -0
  162. package/tests/api-resources/transactions.test.ts +96 -0
  163. package/tests/api-resources/validations.test.ts +24 -0
  164. package/tests/api-resources/webhooks.test.ts +102 -0
  165. package/tests/form.test.ts +27 -0
  166. package/tests/index.test.ts +62 -0
  167. package/tests/responses.test.ts +25 -0
  168. package/tsconfig.cjs.json +8 -0
  169. package/tsconfig.json +36 -0
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ var __awaiter =
4
+ (this && this.__awaiter) ||
5
+ function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) {
7
+ return value instanceof P
8
+ ? value
9
+ : new P(function (resolve) {
10
+ resolve(value);
11
+ });
12
+ }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) {
15
+ try {
16
+ step(generator.next(value));
17
+ } catch (e) {
18
+ reject(e);
19
+ }
20
+ }
21
+ function rejected(value) {
22
+ try {
23
+ step(generator['throw'](value));
24
+ } catch (e) {
25
+ reject(e);
26
+ }
27
+ }
28
+ function step(result) {
29
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
30
+ }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault =
35
+ (this && this.__importDefault) ||
36
+ function (mod) {
37
+ return mod && mod.__esModule ? mod : { default: mod };
38
+ };
39
+ Object.defineProperty(exports, '__esModule', { value: true });
40
+ const index_1 = __importDefault(require('../../index'));
41
+ const modernTreasury = new index_1.default({
42
+ apiKey: 'something1234',
43
+ baseURL: 'http://127.0.0.1:4010',
44
+ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa',
45
+ });
46
+ describe('resource validations', () => {
47
+ test('validate_routing_number: only required params', () =>
48
+ __awaiter(void 0, void 0, void 0, function* () {
49
+ const response = yield modernTreasury.validations.validateRoutingNumber({
50
+ routing_number: 'string',
51
+ routing_number_type: 'aba',
52
+ });
53
+ }));
54
+ test('validate_routing_number: required and optional params', () =>
55
+ __awaiter(void 0, void 0, void 0, function* () {
56
+ const response = yield modernTreasury.validations.validateRoutingNumber({
57
+ routing_number: 'string',
58
+ routing_number_type: 'aba',
59
+ });
60
+ }));
61
+ });
62
+ //# sourceMappingURL=validations.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.test.js","sourceRoot":"","sources":["../../../../tests/api-resources/validations.test.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;AAErD,oDAAqC;AACrC,MAAM,cAAc,GAAG,IAAI,eAAc,CAAC;IACxC,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,uBAAuB;IAChC,cAAc,EAAE,sCAAsC;CACvD,CAAC,CAAC;AAEH,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,CAAC,+CAA+C,EAAE,GAAS,EAAE;QAC/D,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,qBAAqB,CAAC;YACtE,cAAc,EAAE,QAAQ;YACxB,mBAAmB,EAAE,KAAK;SAC3B,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,uDAAuD,EAAE,GAAS,EAAE;QACvE,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,qBAAqB,CAAC;YACtE,cAAc,EAAE,QAAQ;YACxB,mBAAmB,EAAE,KAAK;SAC3B,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,100 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ var __importDefault =
4
+ (this && this.__importDefault) ||
5
+ function (mod) {
6
+ return mod && mod.__esModule ? mod : { default: mod };
7
+ };
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+ const index_1 = __importDefault(require('../../index'));
10
+ const modernTreasury = new index_1.default({
11
+ apiKey: 'something1234',
12
+ baseURL: 'http://127.0.0.1:4010',
13
+ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa',
14
+ });
15
+ describe('resource webhooks', () => {
16
+ it.each([
17
+ ['foo', '08ba357e274f528065766c770a639abf6809b39ccfd37c2a3157c7f51954da0a'],
18
+ ['{"foo":"bar"}', '57e14f6f354543f0101fb06ea24df7731d90087b76651e3497345e22a3622940'],
19
+ [
20
+ '{"foo":"bar","bar":"baz","a": true}',
21
+ 'ec1c86d16075e6937fc26d55b7dc60bac9b1178a2f714312f7c5cb13a319b0ac',
22
+ ],
23
+ [
24
+ '{"a":{"b":{"c":{"d":[null,1,true,false,["foo",{"bar":[true, false]}]]}}}}',
25
+ '39b6fc0f5b02a5aefbdd7fb337245b4209036334e837d8c5b6a4092965ebc0a5',
26
+ ],
27
+ ])('getSignature', (payload, expected) => {
28
+ const signature = modernTreasury.webhooks.getSignature(payload, { key: 'foo' });
29
+ expect(signature).toEqual(expected);
30
+ });
31
+ it('getSignature: Throws an error when the key has not been set', () => {
32
+ const client = new index_1.default({
33
+ apiKey: 'something1234',
34
+ baseURL: 'http://127.0.0.1:4010',
35
+ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa',
36
+ });
37
+ expect(() => client.webhooks.getSignature('bar')).toThrowError(/webhook key/);
38
+ });
39
+ it('getSignature: Uses the webhook key set at the client level', () => {
40
+ const client = new index_1.default({
41
+ apiKey: 'something1234',
42
+ baseURL: 'http://127.0.0.1:4010',
43
+ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa',
44
+ webhookKey: 'hello, world',
45
+ });
46
+ const payload = '{"foo":"bar"}';
47
+ const signature = client.webhooks.getSignature(payload);
48
+ expect(signature).toEqual('07e118b4a9818c9242baf9009e76a78c29aeb015da93f600d514b77185247069');
49
+ const otherSignature = modernTreasury.webhooks.getSignature(payload, { key: 'foo' });
50
+ expect(otherSignature).not.toEqual(signature);
51
+ });
52
+ it('validateSignature: Throws an error when the X-Signature header is not present', () => {
53
+ expect(() =>
54
+ modernTreasury.webhooks.validateSignature('bar', /* headers */ {}, { key: 'foo' }),
55
+ ).toThrowError('Could not find an X-Signature header');
56
+ });
57
+ it('validateSignature: Correctly verifies against the expected signature', () => {
58
+ const payload = '{"foo":"bar"}';
59
+ expect(
60
+ modernTreasury.webhooks.validateSignature(
61
+ payload,
62
+ /* headers */ { 'X-Signature': '57e14f6f354543f0101fb06ea24df7731d90087b76651e3497345e22a3622940' },
63
+ {
64
+ key: 'foo',
65
+ },
66
+ ),
67
+ ).toBe(true);
68
+ // lowercased header
69
+ expect(
70
+ modernTreasury.webhooks.validateSignature(
71
+ payload,
72
+ /* headers */ { 'x-signature': '57e14f6f354543f0101fb06ea24df7731d90087b76651e3497345e22a3622940' },
73
+ {
74
+ key: 'foo',
75
+ },
76
+ ),
77
+ ).toBe(true);
78
+ // modified payload
79
+ expect(
80
+ modernTreasury.webhooks.validateSignature(
81
+ payload + 'foo',
82
+ /* headers */ { 'X-Signature': '57e14f6f354543f0101fb06ea24df7731d90087b76651e3497345e22a3622940' },
83
+ {
84
+ key: 'foo',
85
+ },
86
+ ),
87
+ ).toBe(false);
88
+ // modified signature
89
+ expect(
90
+ modernTreasury.webhooks.validateSignature(
91
+ payload,
92
+ /* headers */ { 'X-Signature': 'hello' },
93
+ {
94
+ key: 'foo',
95
+ },
96
+ ),
97
+ ).toBe(false);
98
+ });
99
+ });
100
+ //# sourceMappingURL=webhooks.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.test.js","sourceRoot":"","sources":["../../../../tests/api-resources/webhooks.test.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+ var __awaiter =
3
+ (this && this.__awaiter) ||
4
+ function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) {
6
+ return value instanceof P
7
+ ? value
8
+ : new P(function (resolve) {
9
+ resolve(value);
10
+ });
11
+ }
12
+ return new (P || (P = Promise))(function (resolve, reject) {
13
+ function fulfilled(value) {
14
+ try {
15
+ step(generator.next(value));
16
+ } catch (e) {
17
+ reject(e);
18
+ }
19
+ }
20
+ function rejected(value) {
21
+ try {
22
+ step(generator['throw'](value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ }
27
+ function step(result) {
28
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
+ }
30
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31
+ });
32
+ };
33
+ Object.defineProperty(exports, '__esModule', { value: true });
34
+ const core_1 = require('../core');
35
+ const formdata_node_1 = require('formdata-node');
36
+ const file_from_path_1 = require('formdata-node/file-from-path');
37
+ describe('form data validation', () => {
38
+ test('valid values do not error', () =>
39
+ __awaiter(void 0, void 0, void 0, function* () {
40
+ (0, core_1.multipartFormRequestOptions)({
41
+ body: {
42
+ foo: 'foo',
43
+ string: 1,
44
+ bool: true,
45
+ file: yield (0, file_from_path_1.fileFromPath)('README.md'),
46
+ blob: new formdata_node_1.Blob(['Some content'], { type: 'text/plain' }),
47
+ },
48
+ });
49
+ }));
50
+ test('null', () =>
51
+ __awaiter(void 0, void 0, void 0, function* () {
52
+ expect(() =>
53
+ (0, core_1.multipartFormRequestOptions)({
54
+ body: {
55
+ null: null,
56
+ },
57
+ }),
58
+ ).toThrow(TypeError);
59
+ }));
60
+ });
61
+ //# sourceMappingURL=form.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.test.js","sourceRoot":"","sources":["../../../tests/form.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAqD;AACrD,iDAAqC;AACrC,iEAA4D;AAE5D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,CAAC,2BAA2B,EAAE,GAAS,EAAE;QAC3C,IAAA,kCAA2B,EAAC;YAC1B,IAAI,EAAE;gBACJ,GAAG,EAAE,KAAK;gBACV,MAAM,EAAE,CAAC;gBACT,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,MAAM,IAAA,6BAAY,EAAC,WAAW,CAAC;gBACrC,IAAI,EAAE,IAAI,oBAAI,CAAC,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;aACzD;SACF,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,GAAS,EAAE;QACtB,MAAM,CAAC,GAAG,EAAE,CACV,IAAA,kCAA2B,EAAC;YAC1B,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI;aACX;SACF,CAAC,CACH,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ var __importDefault =
4
+ (this && this.__importDefault) ||
5
+ function (mod) {
6
+ return mod && mod.__esModule ? mod : { default: mod };
7
+ };
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+ const index_1 = __importDefault(require('../index'));
10
+ describe('instantiate client', () => {
11
+ const env = process.env;
12
+ beforeEach(() => {
13
+ jest.resetModules();
14
+ process.env = Object.assign({}, env);
15
+ console.warn = jest.fn();
16
+ });
17
+ afterEach(() => {
18
+ process.env = env;
19
+ });
20
+ test('with minimal arguments', () => {
21
+ // fails if no api key provided
22
+ expect(() => {
23
+ new index_1.default({ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa' });
24
+ }).toThrow();
25
+ // set api key via env var
26
+ process.env['MODERN_TREASURY_API_KEY'] = 'env var api key';
27
+ const client = new index_1.default({ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa' });
28
+ expect(client.apiKey).toBe('env var api key');
29
+ expect(client.organizationId).toBe('c40c0b40-11d3-42ee-8f2e-18ee8b8239aa');
30
+ });
31
+ test('with apiKey argument', () => {
32
+ process.env['MODERN_TREASURY_API_KEY'] = 'env var api key';
33
+ const client = new index_1.default({
34
+ apiKey: 'another api key',
35
+ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa',
36
+ });
37
+ expect(client.apiKey).toBe('another api key');
38
+ });
39
+ test('with options argument', () => {
40
+ process.env['MODERN_TREASURY_API_KEY'] = 'env var api key';
41
+ // apiKey and custom options
42
+ const client = new index_1.default({
43
+ apiKey: 'my api key',
44
+ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa',
45
+ });
46
+ expect(client.apiKey).toBe('my api key');
47
+ });
48
+ test('with disabled authentication', () => {
49
+ process.env['MODERN_TREASURY_API_KEY'] = 'env var api key';
50
+ const client = new index_1.default({
51
+ apiKey: null,
52
+ organizationId: 'c40c0b40-11d3-42ee-8f2e-18ee8b8239aa',
53
+ });
54
+ expect(client.apiKey).toBeNull();
55
+ });
56
+ });
57
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../tests/index.test.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;AAErD,qDAAsC;AAEtC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAExB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,qBAAQ,GAAG,CAAE,CAAC;QAEzB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAClC,+BAA+B;QAC/B,MAAM,CAAC,GAAG,EAAE;YACV,IAAI,eAAc,CAAC,EAAE,cAAc,EAAE,sCAAsC,EAAE,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,0BAA0B;QAC1B,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,GAAG,iBAAiB,CAAC;QAC3D,MAAM,MAAM,GAAG,IAAI,eAAc,CAAC,EAAE,cAAc,EAAE,sCAAsC,EAAE,CAAC,CAAC;QAC9F,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAChC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,GAAG,iBAAiB,CAAC;QAE3D,MAAM,MAAM,GAAG,IAAI,eAAc,CAAC;YAChC,MAAM,EAAE,iBAAiB;YACzB,cAAc,EAAE,sCAAsC;SACvD,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE;QACjC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,GAAG,iBAAiB,CAAC;QAE3D,4BAA4B;QAC5B,MAAM,MAAM,GAAG,IAAI,eAAc,CAAC;YAChC,MAAM,EAAE,YAAY;YACpB,cAAc,EAAE,sCAAsC;SACvD,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,GAAG,iBAAiB,CAAC;QAE3D,MAAM,MAAM,GAAG,IAAI,eAAc,CAAC;YAChC,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,sCAAsC;SACvD,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+ var __awaiter =
3
+ (this && this.__awaiter) ||
4
+ function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) {
6
+ return value instanceof P
7
+ ? value
8
+ : new P(function (resolve) {
9
+ resolve(value);
10
+ });
11
+ }
12
+ return new (P || (P = Promise))(function (resolve, reject) {
13
+ function fulfilled(value) {
14
+ try {
15
+ step(generator.next(value));
16
+ } catch (e) {
17
+ reject(e);
18
+ }
19
+ }
20
+ function rejected(value) {
21
+ try {
22
+ step(generator['throw'](value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ }
27
+ function step(result) {
28
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
+ }
30
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31
+ });
32
+ };
33
+ Object.defineProperty(exports, '__esModule', { value: true });
34
+ const core_1 = require('../core');
35
+ const node_fetch_1 = require('node-fetch');
36
+ describe('response parsing', () => {
37
+ // TODO: test unicode characters
38
+ test('headers are case agnostic', () =>
39
+ __awaiter(void 0, void 0, void 0, function* () {
40
+ const headers = (0, core_1.createResponseHeaders)(
41
+ new node_fetch_1.Headers({ 'Content-Type': 'foo', Accept: 'text/plain' }),
42
+ );
43
+ expect(headers['content-type']).toEqual('foo');
44
+ expect(headers['Content-type']).toEqual('foo');
45
+ expect(headers['Content-Type']).toEqual('foo');
46
+ expect(headers['accept']).toEqual('text/plain');
47
+ expect(headers['Accept']).toEqual('text/plain');
48
+ expect(headers['Hello-World']).toBeUndefined();
49
+ }));
50
+ test('duplicate headers are concatenated', () => {
51
+ const headers = (0, core_1.createResponseHeaders)(
52
+ new node_fetch_1.Headers([
53
+ ['Content-Type', 'text/xml'],
54
+ ['Content-Type', 'application/json'],
55
+ ]),
56
+ );
57
+ expect(headers['content-type']).toBe('text/xml, application/json');
58
+ });
59
+ });
60
+ //# sourceMappingURL=responses.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.test.js","sourceRoot":"","sources":["../../../tests/responses.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAA+C;AAC/C,2CAAqC;AAErC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,gCAAgC;IAChC,IAAI,CAAC,2BAA2B,EAAE,GAAS,EAAE;QAC3C,MAAM,OAAO,GAAG,IAAA,4BAAqB,EAAC,IAAI,oBAAO,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;QACpG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACjD,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC9C,MAAM,OAAO,GAAG,IAAA,4BAAqB,EACnC,IAAI,oBAAO,CAAC;YACV,CAAC,cAAc,EAAE,UAAU,CAAC;YAC5B,CAAC,cAAc,EAAE,kBAAkB,CAAC;SACrC,CAAC,CACH,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/index.ts ADDED
@@ -0,0 +1,175 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+ import * as Core from './core';
3
+ import * as Pagination from './pagination';
4
+ import * as API from './resources';
5
+ import type { Agent } from 'http';
6
+
7
+ type Config = {
8
+ /**
9
+ * Defaults to to process.env["MODERN_TREASURY_API_KEY"]. Set it to null if you want to send unauthenticated requests.
10
+ */
11
+ apiKey?: string | null;
12
+ baseURL?: string;
13
+ timeout?: number;
14
+ httpAgent?: Agent;
15
+ organizationId: string;
16
+ webhookKey?: string | null;
17
+ };
18
+
19
+ export class ModernTreasury extends Core.APIClient {
20
+ organizationId: string;
21
+ webhookKey?: string | null;
22
+
23
+ constructor(config: Config) {
24
+ const options: Config = {
25
+ apiKey: process.env['MODERN_TREASURY_API_KEY'] || '',
26
+ baseURL: 'https://app.moderntreasury.com',
27
+ ...config,
28
+ };
29
+
30
+ if (!options.apiKey && options.apiKey !== null) {
31
+ throw new Error(
32
+ "The MODERN_TREASURY_API_KEY environment variable is missing or empty; either provide it, or instantiate the ModernTreasury client with an apiKey option, like new ModernTreasury({apiKey: 'my api key'}).",
33
+ );
34
+ }
35
+
36
+ super({
37
+ apiKey: options.apiKey,
38
+ baseURL: options.baseURL!,
39
+ timeout: options.timeout,
40
+ httpAgent: options.httpAgent,
41
+ });
42
+ this.idempotencyHeader = 'Idempotency-Key';
43
+
44
+ this.organizationId = config.organizationId;
45
+ this.webhookKey = config.webhookKey || process.env['MODERN_TREASURY_WEBHOOK_KEY'] || null;
46
+ }
47
+
48
+ counterparties: API.Counterparties = new API.Counterparties(this);
49
+ events: API.Events = new API.Events(this);
50
+ expectedPayments: API.ExpectedPayments = new API.ExpectedPayments(this);
51
+ externalAccounts: API.ExternalAccounts = new API.ExternalAccounts(this);
52
+ incomingPaymentDetails: API.IncomingPaymentDetails = new API.IncomingPaymentDetails(this);
53
+ documents: API.Documents = new API.Documents(this);
54
+ internalAccounts: API.InternalAccounts = new API.InternalAccounts(this);
55
+ lineItems: API.LineItems = new API.LineItems(this);
56
+ paymentOrders: API.PaymentOrders = new API.PaymentOrders(this);
57
+ returns: API.Returns = new API.Returns(this);
58
+ transactions: API.Transactions = new API.Transactions(this);
59
+ validations: API.Validations = new API.Validations(this);
60
+ paperItems: API.PaperItems = new API.PaperItems(this);
61
+ webhooks: API.Webhooks = new API.Webhooks(this);
62
+
63
+ /**
64
+ * A test endpoint often used to confirm credentials and headers are being passed
65
+ * in correctly.
66
+ */
67
+ ping(options?: Core.RequestOptions): Promise<Core.APIResponse<ModernTreasury.PingResponse>> {
68
+ return this.get('/api/ping', options);
69
+ }
70
+
71
+ protected override authHeaders(): Core.Headers {
72
+ const creds = `${this.organizationId}:${this.apiKey}`;
73
+ const Authorization = `Basic ${Buffer.from(creds).toString('base64')}`;
74
+ return { Authorization };
75
+ }
76
+
77
+ protected override qsOptions(): qs.IStringifyOptions {
78
+ return { arrayFormat: 'repeat' };
79
+ }
80
+
81
+ static APIError = Core.APIError;
82
+
83
+ static APIConnectionError = Core.APIConnectionError;
84
+ static APIConnectionTimeoutError = Core.APIConnectionTimeoutError;
85
+
86
+ static BadRequestError = Core.BadRequestError;
87
+ static AuthenticationError = Core.AuthenticationError;
88
+ static PermissionDeniedError = Core.PermissionDeniedError;
89
+ static NotFoundError = Core.NotFoundError;
90
+ static ConflictError = Core.ConflictError;
91
+ static UnprocessableEntityError = Core.UnprocessableEntityError;
92
+ static RateLimitError = Core.RateLimitError;
93
+ static InternalServerError = Core.InternalServerError;
94
+ }
95
+
96
+ export namespace ModernTreasury {
97
+ export import Page = Pagination.Page;
98
+ export import PageParams = Pagination.PageParams;
99
+ export import PageResponse = Pagination.PageResponse;
100
+
101
+ export import PingResponse = API.PingResponse;
102
+
103
+ export import Counterparty = API.Counterparty;
104
+ export import CounterpartyCollectAccountResponse = API.CounterpartyCollectAccountResponse;
105
+ export import CounterpartiesPage = API.CounterpartiesPage;
106
+ export import CounterpartyCreateParams = API.CounterpartyCreateParams;
107
+ export import CounterpartyUpdateParams = API.CounterpartyUpdateParams;
108
+ export import CounterpartyListParams = API.CounterpartyListParams;
109
+ export import CounterpartyCollectAccountParams = API.CounterpartyCollectAccountParams;
110
+
111
+ export import Event = API.Event;
112
+ export import EventsPage = API.EventsPage;
113
+ export import EventListParams = API.EventListParams;
114
+
115
+ export import ExpectedPayment = API.ExpectedPayment;
116
+ export import ExpectedPaymentsPage = API.ExpectedPaymentsPage;
117
+ export import ExpectedPaymentCreateParams = API.ExpectedPaymentCreateParams;
118
+ export import ExpectedPaymentUpdateParams = API.ExpectedPaymentUpdateParams;
119
+ export import ExpectedPaymentListParams = API.ExpectedPaymentListParams;
120
+
121
+ export import ExternalAccount = API.ExternalAccount;
122
+ export import ExternalAccountsPage = API.ExternalAccountsPage;
123
+ export import ExternalAccountCreateParams = API.ExternalAccountCreateParams;
124
+ export import ExternalAccountUpdateParams = API.ExternalAccountUpdateParams;
125
+ export import ExternalAccountListParams = API.ExternalAccountListParams;
126
+ export import ExternalAccountCompleteVerificationParams = API.ExternalAccountCompleteVerificationParams;
127
+ export import ExternalAccountVerifyParams = API.ExternalAccountVerifyParams;
128
+
129
+ export import IncomingPaymentDetail = API.IncomingPaymentDetail;
130
+ export import IncomingPaymentDetailsPage = API.IncomingPaymentDetailsPage;
131
+ export import IncomingPaymentDetailUpdateParams = API.IncomingPaymentDetailUpdateParams;
132
+ export import IncomingPaymentDetailListParams = API.IncomingPaymentDetailListParams;
133
+
134
+ export import Document = API.Document;
135
+ export import DocumentsPage = API.DocumentsPage;
136
+ export import DocumentListParams = API.DocumentListParams;
137
+
138
+ export import InternalAccount = API.InternalAccount;
139
+ export import InternalAccountsPage = API.InternalAccountsPage;
140
+ export import InternalAccountCreateParams = API.InternalAccountCreateParams;
141
+ export import InternalAccountUpdateParams = API.InternalAccountUpdateParams;
142
+ export import InternalAccountListParams = API.InternalAccountListParams;
143
+
144
+ export import LineItem = API.LineItem;
145
+ export import LineItemsPage = API.LineItemsPage;
146
+ export import LineItemUpdateParams = API.LineItemUpdateParams;
147
+ export import LineItemListParams = API.LineItemListParams;
148
+
149
+ export import PaymentOrder = API.PaymentOrder;
150
+ export import PaymentOrdersPage = API.PaymentOrdersPage;
151
+ export import PaymentOrderCreateParams = API.PaymentOrderCreateParams;
152
+ export import PaymentOrderUpdateParams = API.PaymentOrderUpdateParams;
153
+ export import PaymentOrderListParams = API.PaymentOrderListParams;
154
+ export import PaymentOrderCreateAsyncParams = API.PaymentOrderCreateAsyncParams;
155
+
156
+ export import ReturnObject = API.ReturnObject;
157
+ export import ReturnObjectsPage = API.ReturnObjectsPage;
158
+ export import ReturnCreateParams = API.ReturnCreateParams;
159
+ export import ReturnListParams = API.ReturnListParams;
160
+
161
+ export import Transaction = API.Transaction;
162
+ export import TransactionsPage = API.TransactionsPage;
163
+ export import TransactionUpdateParams = API.TransactionUpdateParams;
164
+ export import TransactionListParams = API.TransactionListParams;
165
+
166
+ export import RoutingNumberLookupRequest = API.RoutingNumberLookupRequest;
167
+ export import ValidationValidateRoutingNumberParams = API.ValidationValidateRoutingNumberParams;
168
+
169
+ export import PaperItem = API.PaperItem;
170
+ export import PaperItemsPage = API.PaperItemsPage;
171
+ export import PaperItemListParams = API.PaperItemListParams;
172
+ }
173
+
174
+ exports = module.exports = ModernTreasury;
175
+ export default ModernTreasury;
package/jest.config.js ADDED
@@ -0,0 +1,8 @@
1
+ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ moduleNameMapper: {
6
+ '^~/(.*)$': '<rootDir>/$1',
7
+ },
8
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "modern-treasury",
3
+ "version": "0.0.1",
4
+ "description": "Client library for the ModernTreasury API",
5
+ "author": "Modern Treasury <dev-feedback@moderntreasury.com>",
6
+ "types": "dist/cjs/index.d.ts",
7
+ "main": "dist/cjs/index.js",
8
+ "type": "commonjs",
9
+ "repository": "github:Modern-Treasury/modern-treasury-node",
10
+ "license": "MIT",
11
+ "private": false,
12
+ "scripts": {
13
+ "test": "yarn jest",
14
+ "build": "bash ./build",
15
+ "prepack": "yarn build",
16
+ "format": "prettier --write .",
17
+ "tsn": "ts-node -r tsconfig-paths/register",
18
+ "fix": "eslint --fix --ext ts,js ."
19
+ },
20
+ "dependencies": {
21
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
22
+ "abort-controller": "^3.0.0",
23
+ "agentkeepalive": "^4.2.1",
24
+ "form-data-encoder": "1.7.2",
25
+ "formdata-node": "^4.3.2",
26
+ "node-fetch": "^2.6.7",
27
+ "pkg-up": "^3.1.0",
28
+ "qs": "^6.10.3"
29
+ },
30
+ "devDependencies": {
31
+ "@types/jest": "^27.5.0",
32
+ "@types/node": "^17.0.21",
33
+ "@types/node-fetch": "^2.6.1",
34
+ "@types/qs": "^6.9.7",
35
+ "@types/web": "^0.0.53",
36
+ "@typescript-eslint/parser": "^5.33.0",
37
+ "eslint": "^8.22.0",
38
+ "eslint-plugin-unused-imports": "^2.0.0",
39
+ "jest": "^28.1.0",
40
+ "prettier": "^2.5.1",
41
+ "ts-jest": "^28.0.2",
42
+ "ts-node": "^10.5.0",
43
+ "tsc-alias": "^1.6.9",
44
+ "tsconfig-paths": "^3.12.0",
45
+ "typescript": "^4.7.4"
46
+ }
47
+ }
package/pagination.ts ADDED
@@ -0,0 +1,36 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+ import { AbstractPage, APIResponse, APIClient, FinalRequestOptions, coerceInteger } from './core';
3
+
4
+ export type PageResponse<Item> = Item[];
5
+
6
+ export interface PageParams {
7
+ after_cursor?: string;
8
+
9
+ per_page?: number;
10
+ }
11
+
12
+ export class Page<Item> extends AbstractPage<Item> {
13
+ items: Array<Item>;
14
+
15
+ per_page: number | null;
16
+
17
+ after_cursor: string | null;
18
+
19
+ constructor(client: APIClient, response: APIResponse<PageResponse<Item>>, options: FinalRequestOptions) {
20
+ super(client, response, options);
21
+
22
+ this.items = response;
23
+ this.per_page = coerceInteger(response.responseHeaders['x-per-page'] || null);
24
+ this.after_cursor = response.responseHeaders['x-after-cursor'] || null;
25
+ }
26
+
27
+ getPaginatedItems(): Item[] {
28
+ return this.items;
29
+ }
30
+
31
+ nextPageParams(): Partial<PageParams> | null {
32
+ if (!this.after_cursor) return null;
33
+
34
+ return { after_cursor: this.after_cursor };
35
+ }
36
+ }