@dalmore/api-contracts 1.0.6 → 1.0.7

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 (137) hide show
  1. package/dist/contracts/clients/index.d.ts +19 -0
  2. package/index.mjs +4 -1
  3. package/package.json +4 -4
  4. package/src/common/types/account-contact.types.ts +0 -98
  5. package/src/common/types/account-detail.types.ts +0 -27
  6. package/src/common/types/account-integration.types.ts +0 -143
  7. package/src/common/types/account-manager.types.ts +0 -124
  8. package/src/common/types/account.types.ts +0 -296
  9. package/src/common/types/activity.types.ts +0 -274
  10. package/src/common/types/address.spec.ts +0 -203
  11. package/src/common/types/address.types.ts +0 -41
  12. package/src/common/types/aic.types.ts +0 -246
  13. package/src/common/types/aml.types.ts +0 -18
  14. package/src/common/types/api-key-logs.types.ts +0 -66
  15. package/src/common/types/api-keys.types.ts +0 -69
  16. package/src/common/types/asset.types.ts +0 -338
  17. package/src/common/types/auth.types.ts +0 -370
  18. package/src/common/types/batch-jobs.types.ts +0 -151
  19. package/src/common/types/bonus-tier.types.ts +0 -147
  20. package/src/common/types/cart.types.ts +0 -18
  21. package/src/common/types/checklist-items.types.ts +0 -70
  22. package/src/common/types/checklist.types.ts +0 -97
  23. package/src/common/types/common.types.spec.ts +0 -336
  24. package/src/common/types/common.types.ts +0 -1520
  25. package/src/common/types/comply-advantage-api.types.ts +0 -316
  26. package/src/common/types/comply-advantage.types.ts +0 -25
  27. package/src/common/types/contact-us.types.ts +0 -107
  28. package/src/common/types/contract-helpers.ts +0 -205
  29. package/src/common/types/countries.types.ts +0 -375
  30. package/src/common/types/covered-person.types.ts +0 -274
  31. package/src/common/types/dashboard.types.ts +0 -799
  32. package/src/common/types/data-record.types.ts +0 -325
  33. package/src/common/types/data-room.types.ts +0 -242
  34. package/src/common/types/default-theme-config.types.ts +0 -87
  35. package/src/common/types/disbursement-adjustment.types.ts +0 -32
  36. package/src/common/types/disbursement-approval-user.types.ts +0 -100
  37. package/src/common/types/disbursement-review.types.ts +0 -110
  38. package/src/common/types/disbursement-transaction.types.ts +0 -72
  39. package/src/common/types/disbursements.types.ts +0 -310
  40. package/src/common/types/domain-filter.types.ts +0 -55
  41. package/src/common/types/email-theme.types.ts +0 -442
  42. package/src/common/types/entity.types.ts +0 -15
  43. package/src/common/types/error-responses.types.ts +0 -135
  44. package/src/common/types/escrow-account.types.ts +0 -104
  45. package/src/common/types/exchange-api-key.types.ts +0 -121
  46. package/src/common/types/exchange-import.types.ts +0 -36
  47. package/src/common/types/exchange-provider.types.ts +0 -329
  48. package/src/common/types/file.types.ts +0 -461
  49. package/src/common/types/files.types.spec.ts +0 -154
  50. package/src/common/types/health.types.ts +0 -29
  51. package/src/common/types/index.ts +0 -48
  52. package/src/common/types/individuals.types.ts +0 -554
  53. package/src/common/types/investor-account.types.ts +0 -1239
  54. package/src/common/types/investorAccountIdSchema.type.ts +0 -0
  55. package/src/common/types/investors-offering.types.ts +0 -65
  56. package/src/common/types/invite.types.ts +0 -133
  57. package/src/common/types/issuer-bank-account.types.ts +0 -107
  58. package/src/common/types/issuer-offering.types.ts +0 -306
  59. package/src/common/types/issuer-payment-method.types.spec.ts +0 -612
  60. package/src/common/types/issuer-payment-method.types.ts +0 -341
  61. package/src/common/types/issuer.types.ts +0 -312
  62. package/src/common/types/job-item.types.ts +0 -119
  63. package/src/common/types/jobs.types.ts +0 -171
  64. package/src/common/types/kyb.types.ts +0 -53
  65. package/src/common/types/kyc.types.ts +0 -188
  66. package/src/common/types/legal-entity.types.ts +0 -185
  67. package/src/common/types/login-history.types.ts +0 -46
  68. package/src/common/types/mail-template.types.ts +0 -436
  69. package/src/common/types/north-cap-integration.types.ts +0 -190
  70. package/src/common/types/note.types.ts +0 -109
  71. package/src/common/types/notification.types.ts +0 -58
  72. package/src/common/types/notion-api.types.ts +0 -374
  73. package/src/common/types/notion-database.types.ts +0 -125
  74. package/src/common/types/notion-page.types.ts +0 -267
  75. package/src/common/types/offering-reports.types.ts +0 -153
  76. package/src/common/types/offering-submission.types.ts +0 -314
  77. package/src/common/types/offering.types.spec.ts +0 -91
  78. package/src/common/types/offering.types.ts +0 -590
  79. package/src/common/types/page-revision.types.ts +0 -86
  80. package/src/common/types/page.types.ts +0 -436
  81. package/src/common/types/password.type.ts +0 -15
  82. package/src/common/types/payment-methods.types.ts +0 -298
  83. package/src/common/types/phone.spec.ts +0 -76
  84. package/src/common/types/phone.type.ts +0 -27
  85. package/src/common/types/portfolio.types.ts +0 -50
  86. package/src/common/types/privacy-policy-and-tos.types.ts +0 -231
  87. package/src/common/types/queue.types.ts +0 -112
  88. package/src/common/types/registered-reps.types.ts +0 -25
  89. package/src/common/types/rejection-reasons.types.ts +0 -56
  90. package/src/common/types/reminder-config.types.ts +0 -40
  91. package/src/common/types/review.types.ts +0 -133
  92. package/src/common/types/role.types.ts +0 -26
  93. package/src/common/types/secondary-customer.types.ts +0 -66
  94. package/src/common/types/secondary-issuer.types.ts +0 -50
  95. package/src/common/types/secondary-order.types.ts +0 -58
  96. package/src/common/types/secondary-security.types.ts +0 -60
  97. package/src/common/types/secondary-trade.entity.ts +0 -16
  98. package/src/common/types/secondary-trade.types.ts +0 -95
  99. package/src/common/types/secure-request.types.ts +0 -68
  100. package/src/common/types/signer.types.ts +0 -651
  101. package/src/common/types/site-link.types.spec.ts +0 -134
  102. package/src/common/types/site-link.types.ts +0 -166
  103. package/src/common/types/site-settings.types.ts +0 -726
  104. package/src/common/types/site.types.ts +0 -270
  105. package/src/common/types/sms.types.ts +0 -30
  106. package/src/common/types/state-machine.types.ts +0 -177
  107. package/src/common/types/states.types.ts +0 -163
  108. package/src/common/types/subdoc-preview.types.ts +0 -35
  109. package/src/common/types/task.types.ts +0 -258
  110. package/src/common/types/trade-adjustment.type.ts +0 -33
  111. package/src/common/types/trade-line-item.type.ts +0 -132
  112. package/src/common/types/trade.types.ts +0 -929
  113. package/src/common/types/transaction.types.ts +0 -198
  114. package/src/common/types/trusted-contact.types.ts +0 -122
  115. package/src/common/types/typography.types.ts +0 -75
  116. package/src/common/types/user-manual.types.ts +0 -290
  117. package/src/common/types/user-setting.types.ts +0 -133
  118. package/src/common/types/user.types.ts +0 -320
  119. package/src/common/types/webhook.types.ts +0 -588
  120. package/src/common/types/zip.type.ts +0 -36
  121. package/src/contracts/clients/accounts/index.ts +0 -61
  122. package/src/contracts/clients/aic/index.ts +0 -59
  123. package/src/contracts/clients/api-key-logs/index.ts +0 -53
  124. package/src/contracts/clients/api-keys/index.ts +0 -73
  125. package/src/contracts/clients/assets/index.ts +0 -102
  126. package/src/contracts/clients/auth/index.ts +0 -50
  127. package/src/contracts/clients/files/index.ts +0 -166
  128. package/src/contracts/clients/files-public/index.ts +0 -166
  129. package/src/contracts/clients/index.ts +0 -44
  130. package/src/contracts/clients/individuals/index.ts +0 -93
  131. package/src/contracts/clients/investor-accounts/index.ts +0 -93
  132. package/src/contracts/clients/issuers/index.ts +0 -94
  133. package/src/contracts/clients/legal-entities/index.ts +0 -93
  134. package/src/contracts/clients/offerings/index.ts +0 -117
  135. package/src/contracts/clients/secure-requests/index.ts +0 -34
  136. package/src/contracts/clients/sites/index.ts +0 -56
  137. package/src/contracts/clients/trades/index.ts +0 -122
@@ -1,612 +0,0 @@
1
- import { PaymentMethodType } from './payment-methods.types';
2
- import {
3
- PatchIssuerPaymentMethodZod,
4
- PaymentMethodConfig,
5
- createDefaultIssuerPaymentMethods,
6
- stripeConfigSchema,
7
- wireConfigSchema,
8
- checkConfigSchema,
9
- retirementConfigSchema,
10
- } from './issuer-payment-method.types';
11
- import { StateCode } from './states.types';
12
- import { CountryCode } from './countries.types';
13
- import { typeid } from 'typeid-js';
14
- import {
15
- getRandomName,
16
- getRandomCompanyName,
17
- getRandomAddress,
18
- getRandomCity,
19
- getRandomState,
20
- getRandomZip,
21
- getRandomNumber,
22
- getRandomStripeAccountId,
23
- } from '../../tests/factory/random.factory';
24
-
25
- describe('PatchIssuerPaymentMethodZod Schema', () => {
26
- it('should validate CREDIT_CARD payment method', () => {
27
- const input = {
28
- paymentMethodType: PaymentMethodType.CREDIT_CARD,
29
- config: {
30
- stripeAccountId: getRandomStripeAccountId(),
31
- },
32
- };
33
-
34
- const result = PatchIssuerPaymentMethodZod.safeParse(input);
35
- expect(result.success).toBe(true);
36
- });
37
-
38
- it('should validate WIRE payment method', () => {
39
- const input = {
40
- paymentMethodType: PaymentMethodType.WIRE,
41
- config: {
42
- usAccountHolderName: getRandomName(),
43
- usBankName: `${getRandomName()} Bank`,
44
- usRoutingNumber: getRandomNumber(100000000, 999999999, 0)
45
- .toString()
46
- .padStart(9, '0'),
47
- usAccountNumber: getRandomNumber(
48
- 10000000,
49
- Number.MAX_SAFE_INTEGER,
50
- 0,
51
- ).toString(),
52
- reference: null,
53
- swiftId: null,
54
- },
55
- };
56
-
57
- const result = PatchIssuerPaymentMethodZod.safeParse(input);
58
- expect(result.success).toBe(true);
59
- });
60
-
61
- it('should validate CHECK payment method', () => {
62
- const input = {
63
- paymentMethodType: PaymentMethodType.CHECK,
64
- config: {
65
- companyName: getRandomCompanyName(),
66
- address: getRandomAddress(),
67
- address2: `Suite ${getRandomNumber(1, 999, 0)}`,
68
- city: getRandomCity(),
69
- state: StateCode[getRandomState() as keyof typeof StateCode],
70
- zip: getRandomZip(),
71
- country: CountryCode['US'],
72
- },
73
- };
74
-
75
- const result = PatchIssuerPaymentMethodZod.safeParse(input);
76
- expect(result.success).toBe(true);
77
- });
78
-
79
- it('should reject mismatched payment method type and config', () => {
80
- const input = {
81
- paymentMethodType: PaymentMethodType.CREDIT_CARD,
82
- config: {
83
- usAccountHolderName: getRandomName(),
84
- usBankName: `${getRandomName()} Bank`,
85
- usRoutingNumber: getRandomNumber(100000000, 999999999, 0)
86
- .toString()
87
- .padStart(9, '0'),
88
- usAccountNumber: getRandomNumber(
89
- 10000000,
90
- Number.MAX_SAFE_INTEGER,
91
- 0,
92
- ).toString(),
93
- },
94
- };
95
-
96
- const result = PatchIssuerPaymentMethodZod.safeParse(input);
97
- expect(result.success).toBe(false);
98
- });
99
-
100
- it('should reject invalid Stripe account id', () => {
101
- const input = {
102
- paymentMethodType: PaymentMethodType.CREDIT_CARD,
103
- config: {
104
- stripeAccountId: 123,
105
- },
106
- };
107
-
108
- const result = PatchIssuerPaymentMethodZod.safeParse(input);
109
- expect(result.success).toBe(false);
110
- });
111
-
112
- it('should reject missing required fields', () => {
113
- const input = {
114
- paymentMethodType: PaymentMethodType.WIRE,
115
- config: {
116
- usAccountHolderName: getRandomName(),
117
- // missing other required fields
118
- },
119
- };
120
-
121
- const result = PatchIssuerPaymentMethodZod.safeParse(input);
122
- expect(result.success).toBe(false);
123
- });
124
- });
125
-
126
- describe('Issuer Payment Method Schema Consistency', () => {
127
- describe('PatchIssuerPaymentMethodZod and PaymentMethodConfig consistency', () => {
128
- it('should use the same stripeConfigSchema for CREDIT_CARD in both schemas', () => {
129
- const stripeAccountId = getRandomStripeAccountId();
130
- const patchInput = {
131
- paymentMethodType: PaymentMethodType.CREDIT_CARD,
132
- config: {
133
- stripeAccountId,
134
- },
135
- };
136
-
137
- const configInput = {
138
- paymentMethodType: PaymentMethodType.CREDIT_CARD,
139
- config: {
140
- stripeAccountId,
141
- },
142
- };
143
-
144
- const patchResult = PatchIssuerPaymentMethodZod.safeParse(patchInput);
145
- const configResult = PaymentMethodConfig.safeParse(configInput);
146
-
147
- expect(patchResult.success).toBe(true);
148
- expect(configResult.success).toBe(true);
149
- });
150
-
151
- it('should use the same stripeConfigSchema for ACH in both schemas', () => {
152
- const stripeAccountId = getRandomStripeAccountId();
153
- const patchInput = {
154
- paymentMethodType: PaymentMethodType.ACH,
155
- config: {
156
- stripeAccountId,
157
- },
158
- };
159
-
160
- const configInput = {
161
- paymentMethodType: PaymentMethodType.ACH,
162
- config: {
163
- stripeAccountId,
164
- },
165
- };
166
-
167
- const patchResult = PatchIssuerPaymentMethodZod.safeParse(patchInput);
168
- const configResult = PaymentMethodConfig.safeParse(configInput);
169
-
170
- expect(patchResult.success).toBe(true);
171
- expect(configResult.success).toBe(true);
172
- });
173
-
174
- it('should use the same wireConfigSchema for WIRE in both schemas', () => {
175
- // Generate a valid swiftId (8-11 characters)
176
- const bankCode = getRandomName()
177
- .substring(0, 4)
178
- .toUpperCase()
179
- .padEnd(4, 'A');
180
- const swiftId = `${bankCode}US33XXX`.substring(0, 11); // Ensure 8-11 chars
181
-
182
- const wireConfig = {
183
- usAccountHolderName: getRandomName(),
184
- usBankName: `${getRandomName()} Bank`,
185
- usRoutingNumber: getRandomNumber(100000000, 999999999, 0)
186
- .toString()
187
- .padStart(9, '0'),
188
- usAccountNumber: getRandomNumber(
189
- 10000000,
190
- Number.MAX_SAFE_INTEGER,
191
- 0,
192
- ).toString(),
193
- reference: `REF${getRandomNumber(100, 999, 0)}`,
194
- swiftId:
195
- swiftId.length >= 8 ? swiftId : `${bankCode}US33XXX`.substring(0, 11),
196
- };
197
-
198
- const patchInput = {
199
- paymentMethodType: PaymentMethodType.WIRE,
200
- config: wireConfig,
201
- };
202
-
203
- const configInput = {
204
- paymentMethodType: PaymentMethodType.WIRE,
205
- config: wireConfig,
206
- };
207
-
208
- const patchResult = PatchIssuerPaymentMethodZod.safeParse(patchInput);
209
- const configResult = PaymentMethodConfig.safeParse(configInput);
210
-
211
- expect(patchResult.success).toBe(true);
212
- expect(configResult.success).toBe(true);
213
- });
214
-
215
- it('should use the same checkConfigSchema for CHECK in both schemas', () => {
216
- const checkConfig = {
217
- companyName: getRandomCompanyName(),
218
- address: getRandomAddress(),
219
- address2: `Suite ${getRandomNumber(1, 999, 0)}`,
220
- city: getRandomCity(),
221
- state: StateCode[getRandomState() as keyof typeof StateCode],
222
- zip: getRandomZip(),
223
- country: CountryCode['US'],
224
- reference: `REF${getRandomNumber(100, 999, 0)}`,
225
- };
226
-
227
- const patchInput = {
228
- paymentMethodType: PaymentMethodType.CHECK,
229
- config: checkConfig,
230
- };
231
-
232
- const configInput = {
233
- paymentMethodType: PaymentMethodType.CHECK,
234
- config: checkConfig,
235
- };
236
-
237
- const patchResult = PatchIssuerPaymentMethodZod.safeParse(patchInput);
238
- const configResult = PaymentMethodConfig.safeParse(configInput);
239
-
240
- expect(patchResult.success).toBe(true);
241
- expect(configResult.success).toBe(true);
242
- });
243
-
244
- it('should use the same retirementConfigSchema for RETIREMENT in both schemas', () => {
245
- const retirementConfig = {
246
- custodianInstruction: `Custodian instruction for ${getRandomCompanyName()}`,
247
- custodianDocument: null,
248
- };
249
-
250
- const patchInput = {
251
- paymentMethodType: PaymentMethodType.RETIREMENT,
252
- config: retirementConfig,
253
- };
254
-
255
- const configInput = {
256
- paymentMethodType: PaymentMethodType.RETIREMENT,
257
- config: retirementConfig,
258
- };
259
-
260
- const patchResult = PatchIssuerPaymentMethodZod.safeParse(patchInput);
261
- const configResult = PaymentMethodConfig.safeParse(configInput);
262
-
263
- expect(patchResult.success).toBe(true);
264
- expect(configResult.success).toBe(true);
265
- });
266
-
267
- it('should reject the same invalid configs in both schemas', () => {
268
- const invalidWireConfig = {
269
- usAccountHolderName: getRandomName(),
270
- // Missing required fields
271
- };
272
-
273
- const patchInput = {
274
- paymentMethodType: PaymentMethodType.WIRE,
275
- config: invalidWireConfig,
276
- };
277
-
278
- const configInput = {
279
- paymentMethodType: PaymentMethodType.WIRE,
280
- config: invalidWireConfig,
281
- };
282
-
283
- const patchResult = PatchIssuerPaymentMethodZod.safeParse(patchInput);
284
- const configResult = PaymentMethodConfig.safeParse(configInput);
285
-
286
- expect(patchResult.success).toBe(false);
287
- expect(configResult.success).toBe(false);
288
- });
289
- });
290
-
291
- describe('Payment method type coverage', () => {
292
- it('should cover all payment method types in PatchIssuerPaymentMethodZod', () => {
293
- const paymentMethodTypes = Object.values(PaymentMethodType);
294
- const coveredTypes = new Set<string>();
295
-
296
- // Test each payment method type
297
- paymentMethodTypes.forEach((type) => {
298
- let config: any;
299
- switch (type) {
300
- case PaymentMethodType.CREDIT_CARD:
301
- case PaymentMethodType.ACH:
302
- case PaymentMethodType.BANK_ACCOUNT:
303
- config = { stripeAccountId: getRandomStripeAccountId() };
304
- break;
305
- case PaymentMethodType.WIRE:
306
- config = {
307
- usAccountHolderName: getRandomName(),
308
- usBankName: `${getRandomName()} Bank`,
309
- usRoutingNumber: getRandomNumber(100000000, 999999999, 0)
310
- .toString()
311
- .padStart(9, '0'),
312
- usAccountNumber: getRandomNumber(
313
- 10000000,
314
- Number.MAX_SAFE_INTEGER,
315
- 0,
316
- ).toString(),
317
- };
318
- break;
319
- case PaymentMethodType.CHECK:
320
- config = {
321
- companyName: getRandomCompanyName(),
322
- address: getRandomAddress(),
323
- city: getRandomCity(),
324
- state: StateCode[getRandomState() as keyof typeof StateCode],
325
- zip: getRandomZip(),
326
- country: CountryCode['US'],
327
- };
328
- break;
329
- case PaymentMethodType.RETIREMENT:
330
- config = {
331
- custodianInstruction: `Custodian instruction for ${getRandomCompanyName()}`,
332
- };
333
- break;
334
- }
335
-
336
- const result = PatchIssuerPaymentMethodZod.safeParse({
337
- paymentMethodType: type,
338
- config,
339
- });
340
-
341
- if (result.success) {
342
- coveredTypes.add(type);
343
- }
344
- });
345
-
346
- // BANK_ACCOUNT is in PatchIssuerPaymentMethodZod but not in PaymentMethodConfig
347
- // This is expected behavior, so we check that all types that should be covered are covered
348
- expect(coveredTypes.has(PaymentMethodType.CREDIT_CARD)).toBe(true);
349
- expect(coveredTypes.has(PaymentMethodType.ACH)).toBe(true);
350
- expect(coveredTypes.has(PaymentMethodType.BANK_ACCOUNT)).toBe(true);
351
- expect(coveredTypes.has(PaymentMethodType.WIRE)).toBe(true);
352
- expect(coveredTypes.has(PaymentMethodType.CHECK)).toBe(true);
353
- expect(coveredTypes.has(PaymentMethodType.RETIREMENT)).toBe(true);
354
- });
355
-
356
- it('should cover all payment method types in PaymentMethodConfig', () => {
357
- const paymentMethodTypes = Object.values(PaymentMethodType);
358
- const coveredTypes = new Set<string>();
359
-
360
- // Test each payment method type
361
- paymentMethodTypes.forEach((type) => {
362
- let config: any;
363
- switch (type) {
364
- case PaymentMethodType.CREDIT_CARD:
365
- case PaymentMethodType.ACH:
366
- config = { stripeAccountId: getRandomStripeAccountId() };
367
- break;
368
- case PaymentMethodType.WIRE:
369
- config = {
370
- usAccountHolderName: getRandomName(),
371
- usBankName: `${getRandomName()} Bank`,
372
- usRoutingNumber: getRandomNumber(100000000, 999999999, 0)
373
- .toString()
374
- .padStart(9, '0'),
375
- usAccountNumber: getRandomNumber(
376
- 10000000,
377
- Number.MAX_SAFE_INTEGER,
378
- 0,
379
- ).toString(),
380
- };
381
- break;
382
- case PaymentMethodType.CHECK:
383
- config = {
384
- companyName: getRandomCompanyName(),
385
- address: getRandomAddress(),
386
- city: getRandomCity(),
387
- state: StateCode[getRandomState() as keyof typeof StateCode],
388
- zip: getRandomZip(),
389
- country: CountryCode['US'],
390
- };
391
- break;
392
- case PaymentMethodType.RETIREMENT:
393
- config = {
394
- custodianInstruction: `Custodian instruction for ${getRandomCompanyName()}`,
395
- };
396
- break;
397
- case PaymentMethodType.BANK_ACCOUNT:
398
- // BANK_ACCOUNT is not in PaymentMethodConfig, skip it
399
- return;
400
- }
401
-
402
- const result = PaymentMethodConfig.safeParse({
403
- paymentMethodType: type,
404
- config,
405
- });
406
-
407
- if (result.success) {
408
- coveredTypes.add(type);
409
- }
410
- });
411
-
412
- // PaymentMethodConfig doesn't include BANK_ACCOUNT, which is expected
413
- expect(coveredTypes.has(PaymentMethodType.CREDIT_CARD)).toBe(true);
414
- expect(coveredTypes.has(PaymentMethodType.ACH)).toBe(true);
415
- expect(coveredTypes.has(PaymentMethodType.WIRE)).toBe(true);
416
- expect(coveredTypes.has(PaymentMethodType.CHECK)).toBe(true);
417
- expect(coveredTypes.has(PaymentMethodType.RETIREMENT)).toBe(true);
418
- });
419
- });
420
-
421
- describe('createDefaultIssuerPaymentMethods schema consistency', () => {
422
- it('should create payment methods with valid configs that match their schemas', () => {
423
- const issuerId = typeid('issuer').toString();
424
- const defaultMethods = createDefaultIssuerPaymentMethods(issuerId);
425
-
426
- defaultMethods.forEach((method) => {
427
- let configSchema: any;
428
- switch (method.paymentMethodType) {
429
- case PaymentMethodType.CREDIT_CARD:
430
- case PaymentMethodType.ACH:
431
- case PaymentMethodType.BANK_ACCOUNT:
432
- configSchema = stripeConfigSchema;
433
- break;
434
- case PaymentMethodType.WIRE:
435
- configSchema = wireConfigSchema;
436
- break;
437
- case PaymentMethodType.CHECK:
438
- configSchema = checkConfigSchema;
439
- break;
440
- case PaymentMethodType.RETIREMENT:
441
- configSchema = retirementConfigSchema;
442
- break;
443
- default:
444
- throw new Error(
445
- `Unknown payment method type: ${method.paymentMethodType}`,
446
- );
447
- }
448
-
449
- // Parse the config string back to object
450
- const configObj =
451
- typeof method.config === 'string'
452
- ? JSON.parse(method.config)
453
- : method.config;
454
-
455
- // Validate the config against its schema
456
- const result = configSchema.safeParse(configObj);
457
- expect(result.success).toBe(true);
458
- });
459
- });
460
-
461
- it('should create all expected payment method types', () => {
462
- const issuerId = typeid('issuer').toString();
463
- const defaultMethods = createDefaultIssuerPaymentMethods(issuerId);
464
-
465
- const createdTypes = defaultMethods.map((m) => m.paymentMethodType);
466
- const expectedTypes = [
467
- PaymentMethodType.CREDIT_CARD,
468
- PaymentMethodType.ACH,
469
- PaymentMethodType.BANK_ACCOUNT,
470
- PaymentMethodType.WIRE,
471
- PaymentMethodType.CHECK,
472
- PaymentMethodType.RETIREMENT,
473
- ];
474
-
475
- expectedTypes.forEach((expectedType) => {
476
- expect(createdTypes).toContain(expectedType);
477
- });
478
-
479
- expect(defaultMethods.length).toBe(expectedTypes.length);
480
- });
481
-
482
- it('should create payment methods that can be validated by PatchIssuerPaymentMethodZod', () => {
483
- const issuerId = typeid('issuer').toString();
484
- const defaultMethods = createDefaultIssuerPaymentMethods(issuerId);
485
-
486
- defaultMethods.forEach((method) => {
487
- const configObj =
488
- typeof method.config === 'string'
489
- ? JSON.parse(method.config)
490
- : method.config;
491
-
492
- const input = {
493
- paymentMethodType: method.paymentMethodType,
494
- config: configObj,
495
- };
496
-
497
- const result = PatchIssuerPaymentMethodZod.safeParse(input);
498
-
499
- // BANK_ACCOUNT might not be in PaymentMethodConfig but should be in PatchIssuerPaymentMethodZod
500
- expect(result.success).toBe(true);
501
- });
502
- });
503
- });
504
-
505
- describe('Config schema field consistency', () => {
506
- it('should have consistent field definitions in wireConfigSchema', () => {
507
- // Generate a valid swiftId (8-11 characters, alphanumeric)
508
- // SWIFT IDs are typically 8 or 11 characters: 4 letters (bank code) + 2 letters (country) + 2 chars (location) + optional 3 chars (branch)
509
- const bankCode = getRandomName()
510
- .substring(0, 4)
511
- .toUpperCase()
512
- .padEnd(4, 'A');
513
- const countryCode = 'US';
514
- const locationCode = '33';
515
- const branchCode = 'XXX'; // Optional 3-character branch code
516
- const swiftId =
517
- `${bankCode}${countryCode}${locationCode}${branchCode}`.substring(
518
- 0,
519
- 11,
520
- ); // Ensure max 11 chars
521
-
522
- const validConfig = {
523
- usAccountHolderName: getRandomName(),
524
- usBankName: `${getRandomName()} Bank`,
525
- usRoutingNumber: getRandomNumber(100000000, 999999999, 0)
526
- .toString()
527
- .padStart(9, '0'),
528
- usAccountNumber: getRandomNumber(
529
- 10000000,
530
- Number.MAX_SAFE_INTEGER,
531
- 0,
532
- ).toString(),
533
- reference: `REF${getRandomNumber(100, 999, 0)}`,
534
- swiftId:
535
- swiftId.length >= 8
536
- ? swiftId
537
- : `${bankCode}${countryCode}${locationCode}XXX`.substring(0, 11),
538
- };
539
-
540
- const result = wireConfigSchema.safeParse(validConfig);
541
- expect(result.success).toBe(true);
542
-
543
- // Verify all expected fields are present
544
- if (result.success) {
545
- expect(result.data).toHaveProperty('usAccountHolderName');
546
- expect(result.data).toHaveProperty('usBankName');
547
- expect(result.data).toHaveProperty('usRoutingNumber');
548
- expect(result.data).toHaveProperty('usAccountNumber');
549
- expect(result.data).toHaveProperty('reference');
550
- expect(result.data).toHaveProperty('swiftId');
551
- }
552
- });
553
-
554
- it('should have consistent field definitions in checkConfigSchema', () => {
555
- const validConfig = {
556
- companyName: getRandomCompanyName(),
557
- address: getRandomAddress(),
558
- address2: `Suite ${getRandomNumber(1, 999, 0)}`,
559
- city: getRandomCity(),
560
- state: StateCode[getRandomState() as keyof typeof StateCode],
561
- zip: getRandomZip(),
562
- country: CountryCode['US'],
563
- reference: `REF${getRandomNumber(100, 999, 0)}`,
564
- };
565
-
566
- const result = checkConfigSchema.safeParse(validConfig);
567
- expect(result.success).toBe(true);
568
-
569
- // Verify all expected fields are present
570
- if (result.success) {
571
- expect(result.data).toHaveProperty('companyName');
572
- expect(result.data).toHaveProperty('address');
573
- expect(result.data).toHaveProperty('address2');
574
- expect(result.data).toHaveProperty('city');
575
- expect(result.data).toHaveProperty('state');
576
- expect(result.data).toHaveProperty('zip');
577
- expect(result.data).toHaveProperty('country');
578
- expect(result.data).toHaveProperty('reference');
579
- }
580
- });
581
-
582
- it('should have consistent field definitions in retirementConfigSchema', () => {
583
- const validConfig = {
584
- custodianInstruction: `Custodian instruction for ${getRandomCompanyName()}`,
585
- custodianDocument: null,
586
- };
587
-
588
- const result = retirementConfigSchema.safeParse(validConfig);
589
- expect(result.success).toBe(true);
590
-
591
- // Verify all expected fields are present
592
- if (result.success) {
593
- expect(result.data).toHaveProperty('custodianInstruction');
594
- expect(result.data).toHaveProperty('custodianDocument');
595
- }
596
- });
597
-
598
- it('should have consistent field definitions in stripeConfigSchema', () => {
599
- const validConfig = {
600
- stripeAccountId: getRandomStripeAccountId(),
601
- };
602
-
603
- const result = stripeConfigSchema.safeParse(validConfig);
604
- expect(result.success).toBe(true);
605
-
606
- // Verify all expected fields are present
607
- if (result.success) {
608
- expect(result.data).toHaveProperty('stripeAccountId');
609
- }
610
- });
611
- });
612
- });