@dalmore/api-contracts 1.0.5 → 1.0.6

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/package.json +4 -5
  2. package/src/common/types/account-contact.types.ts +98 -0
  3. package/src/common/types/account-detail.types.ts +27 -0
  4. package/src/common/types/account-integration.types.ts +143 -0
  5. package/src/common/types/account-manager.types.ts +124 -0
  6. package/src/common/types/account.types.ts +296 -0
  7. package/src/common/types/activity.types.ts +274 -0
  8. package/src/common/types/address.spec.ts +203 -0
  9. package/src/common/types/address.types.ts +41 -0
  10. package/src/common/types/aic.types.ts +246 -0
  11. package/src/common/types/aml.types.ts +18 -0
  12. package/src/common/types/api-key-logs.types.ts +66 -0
  13. package/src/common/types/api-keys.types.ts +69 -0
  14. package/src/common/types/asset.types.ts +338 -0
  15. package/src/common/types/auth.types.ts +370 -0
  16. package/src/common/types/batch-jobs.types.ts +151 -0
  17. package/src/common/types/bonus-tier.types.ts +147 -0
  18. package/src/common/types/cart.types.ts +18 -0
  19. package/src/common/types/checklist-items.types.ts +70 -0
  20. package/src/common/types/checklist.types.ts +97 -0
  21. package/src/common/types/common.types.spec.ts +336 -0
  22. package/src/common/types/common.types.ts +1520 -0
  23. package/src/common/types/comply-advantage-api.types.ts +316 -0
  24. package/src/common/types/comply-advantage.types.ts +25 -0
  25. package/src/common/types/contact-us.types.ts +107 -0
  26. package/src/common/types/contract-helpers.ts +205 -0
  27. package/src/common/types/countries.types.ts +375 -0
  28. package/src/common/types/covered-person.types.ts +274 -0
  29. package/src/common/types/dashboard.types.ts +799 -0
  30. package/src/common/types/data-record.types.ts +325 -0
  31. package/src/common/types/data-room.types.ts +242 -0
  32. package/src/common/types/default-theme-config.types.ts +87 -0
  33. package/src/common/types/disbursement-adjustment.types.ts +32 -0
  34. package/src/common/types/disbursement-approval-user.types.ts +100 -0
  35. package/src/common/types/disbursement-review.types.ts +110 -0
  36. package/src/common/types/disbursement-transaction.types.ts +72 -0
  37. package/src/common/types/disbursements.types.ts +310 -0
  38. package/src/common/types/domain-filter.types.ts +55 -0
  39. package/src/common/types/email-theme.types.ts +442 -0
  40. package/src/common/types/entity.types.ts +15 -0
  41. package/src/common/types/error-responses.types.ts +135 -0
  42. package/src/common/types/escrow-account.types.ts +104 -0
  43. package/src/common/types/exchange-api-key.types.ts +121 -0
  44. package/src/common/types/exchange-import.types.ts +36 -0
  45. package/src/common/types/exchange-provider.types.ts +329 -0
  46. package/src/common/types/file.types.ts +461 -0
  47. package/src/common/types/files.types.spec.ts +154 -0
  48. package/src/common/types/health.types.ts +29 -0
  49. package/src/common/types/index.ts +48 -0
  50. package/src/common/types/individuals.types.ts +554 -0
  51. package/src/common/types/investor-account.types.ts +1239 -0
  52. package/src/common/types/investorAccountIdSchema.type.ts +0 -0
  53. package/src/common/types/investors-offering.types.ts +65 -0
  54. package/src/common/types/invite.types.ts +133 -0
  55. package/src/common/types/issuer-bank-account.types.ts +107 -0
  56. package/src/common/types/issuer-offering.types.ts +306 -0
  57. package/src/common/types/issuer-payment-method.types.spec.ts +612 -0
  58. package/src/common/types/issuer-payment-method.types.ts +341 -0
  59. package/src/common/types/issuer.types.ts +312 -0
  60. package/src/common/types/job-item.types.ts +119 -0
  61. package/src/common/types/jobs.types.ts +171 -0
  62. package/src/common/types/kyb.types.ts +53 -0
  63. package/src/common/types/kyc.types.ts +188 -0
  64. package/src/common/types/legal-entity.types.ts +185 -0
  65. package/src/common/types/login-history.types.ts +46 -0
  66. package/src/common/types/mail-template.types.ts +436 -0
  67. package/src/common/types/north-cap-integration.types.ts +190 -0
  68. package/src/common/types/note.types.ts +109 -0
  69. package/src/common/types/notification.types.ts +58 -0
  70. package/src/common/types/notion-api.types.ts +374 -0
  71. package/src/common/types/notion-database.types.ts +125 -0
  72. package/src/common/types/notion-page.types.ts +267 -0
  73. package/src/common/types/offering-reports.types.ts +153 -0
  74. package/src/common/types/offering-submission.types.ts +314 -0
  75. package/src/common/types/offering.types.spec.ts +91 -0
  76. package/src/common/types/offering.types.ts +590 -0
  77. package/src/common/types/page-revision.types.ts +86 -0
  78. package/src/common/types/page.types.ts +436 -0
  79. package/src/common/types/password.type.ts +15 -0
  80. package/src/common/types/payment-methods.types.ts +298 -0
  81. package/src/common/types/phone.spec.ts +76 -0
  82. package/src/common/types/phone.type.ts +27 -0
  83. package/src/common/types/portfolio.types.ts +50 -0
  84. package/src/common/types/privacy-policy-and-tos.types.ts +231 -0
  85. package/src/common/types/queue.types.ts +112 -0
  86. package/src/common/types/registered-reps.types.ts +25 -0
  87. package/src/common/types/rejection-reasons.types.ts +56 -0
  88. package/src/common/types/reminder-config.types.ts +40 -0
  89. package/src/common/types/review.types.ts +133 -0
  90. package/src/common/types/role.types.ts +26 -0
  91. package/src/common/types/secondary-customer.types.ts +66 -0
  92. package/src/common/types/secondary-issuer.types.ts +50 -0
  93. package/src/common/types/secondary-order.types.ts +58 -0
  94. package/src/common/types/secondary-security.types.ts +60 -0
  95. package/src/common/types/secondary-trade.entity.ts +16 -0
  96. package/src/common/types/secondary-trade.types.ts +95 -0
  97. package/src/common/types/secure-request.types.ts +68 -0
  98. package/src/common/types/signer.types.ts +651 -0
  99. package/src/common/types/site-link.types.spec.ts +134 -0
  100. package/src/common/types/site-link.types.ts +166 -0
  101. package/src/common/types/site-settings.types.ts +726 -0
  102. package/src/common/types/site.types.ts +270 -0
  103. package/src/common/types/sms.types.ts +30 -0
  104. package/src/common/types/state-machine.types.ts +177 -0
  105. package/src/common/types/states.types.ts +163 -0
  106. package/src/common/types/subdoc-preview.types.ts +35 -0
  107. package/src/common/types/task.types.ts +258 -0
  108. package/src/common/types/trade-adjustment.type.ts +33 -0
  109. package/src/common/types/trade-line-item.type.ts +132 -0
  110. package/src/common/types/trade.types.ts +929 -0
  111. package/src/common/types/transaction.types.ts +198 -0
  112. package/src/common/types/trusted-contact.types.ts +122 -0
  113. package/src/common/types/typography.types.ts +75 -0
  114. package/src/common/types/user-manual.types.ts +290 -0
  115. package/src/common/types/user-setting.types.ts +133 -0
  116. package/src/common/types/user.types.ts +320 -0
  117. package/src/common/types/webhook.types.ts +588 -0
  118. package/src/common/types/zip.type.ts +36 -0
  119. package/src/contracts/clients/accounts/index.ts +61 -0
  120. package/src/contracts/clients/aic/index.ts +59 -0
  121. package/src/contracts/clients/api-key-logs/index.ts +53 -0
  122. package/src/contracts/clients/api-keys/index.ts +73 -0
  123. package/src/contracts/clients/assets/index.ts +102 -0
  124. package/src/contracts/clients/auth/index.ts +50 -0
  125. package/src/contracts/clients/files/index.ts +166 -0
  126. package/src/contracts/clients/files-public/index.ts +166 -0
  127. package/src/contracts/clients/index.ts +44 -0
  128. package/src/contracts/clients/individuals/index.ts +93 -0
  129. package/src/contracts/clients/investor-accounts/index.ts +93 -0
  130. package/src/contracts/clients/issuers/index.ts +94 -0
  131. package/src/contracts/clients/legal-entities/index.ts +93 -0
  132. package/src/contracts/clients/offerings/index.ts +117 -0
  133. package/src/contracts/clients/secure-requests/index.ts +34 -0
  134. package/src/contracts/clients/sites/index.ts +56 -0
  135. package/src/contracts/clients/trades/index.ts +122 -0
  136. package/index.d.mts +0 -17
  137. package/index.d.ts +0 -17
@@ -0,0 +1,336 @@
1
+ import { PaginationOptionsZod, numberPrecisionSchema } from './common.types';
2
+ import { z } from 'zod';
3
+
4
+ describe('PaginationOptionsZod', () => {
5
+ it('should use default values when no values are provided', () => {
6
+ const result = PaginationOptionsZod.parse({});
7
+ expect(result).toEqual({ page: 1, limit: 10 });
8
+ });
9
+
10
+ it('should use provided values when they are valid', () => {
11
+ const result = PaginationOptionsZod.parse({ page: 2, limit: 20 });
12
+ expect(result).toEqual({ page: 2, limit: 20 });
13
+ });
14
+
15
+ it('should transform page 0 to page 1', () => {
16
+ const result = PaginationOptionsZod.parse({ page: 0 });
17
+ expect(result).toEqual({ page: 1, limit: 10 });
18
+ });
19
+
20
+ it('should transform limit 0 to limit 10', () => {
21
+ const result = PaginationOptionsZod.parse({ limit: 0 });
22
+ expect(result).toEqual({ page: 1, limit: 10 });
23
+ });
24
+
25
+ it('should coerce string values to numbers', () => {
26
+ const result = PaginationOptionsZod.parse({ page: '3', limit: '15' });
27
+ expect(result).toEqual({ page: 3, limit: 15 });
28
+ });
29
+
30
+ it('should handle negative values without transformation', () => {
31
+ const result = PaginationOptionsZod.parse({ page: -1, limit: -5 });
32
+ expect(result).toEqual({ page: -1, limit: -5 });
33
+ });
34
+
35
+ it('should handle decimal values', () => {
36
+ const result = PaginationOptionsZod.parse({ page: 2.5, limit: 15.7 });
37
+ expect(result).toEqual({ page: 2.5, limit: 15.7 });
38
+ });
39
+
40
+ it('should throw an error for non-numeric string values', () => {
41
+ expect(() => {
42
+ PaginationOptionsZod.parse({ page: 'abc' });
43
+ }).toThrow();
44
+ });
45
+
46
+ it('should accept empty string values and convert them to defaults', () => {
47
+ const result = PaginationOptionsZod.parse({ page: '' });
48
+ expect(result).toEqual({ page: 1, limit: 10 });
49
+ });
50
+
51
+ it('should accept undefined values and use defaults', () => {
52
+ const result = PaginationOptionsZod.parse({ page: undefined });
53
+ expect(result).toEqual({ page: 1, limit: 10 });
54
+ });
55
+
56
+ it('should handle null values by using defaults', () => {
57
+ const result = PaginationOptionsZod.parse({ page: null, limit: null });
58
+ expect(result).toEqual({ page: 1, limit: 10 });
59
+ });
60
+
61
+ it('should handle objects with extra properties', () => {
62
+ const result = PaginationOptionsZod.parse({
63
+ page: 5,
64
+ limit: 25,
65
+ sort: 'asc',
66
+ filter: 'active',
67
+ });
68
+ expect(result).toEqual({ page: 5, limit: 25 });
69
+ });
70
+
71
+ it('should handle string numbers with leading zeros', () => {
72
+ const result = PaginationOptionsZod.parse({ page: '01', limit: '05' });
73
+ expect(result).toEqual({ page: 1, limit: 5 });
74
+ });
75
+
76
+ it('should handle exponential notation', () => {
77
+ const result = PaginationOptionsZod.parse({ page: 1e2, limit: 1e1 });
78
+ expect(result).toEqual({ page: 100, limit: 10 });
79
+ });
80
+ });
81
+
82
+ describe('numberPrecisionSchema', () => {
83
+ describe('default precision (2 decimal places)', () => {
84
+ it('should transform numbers with more than 2 decimal places', () => {
85
+ const schema = numberPrecisionSchema();
86
+ expect(schema.parse(123.456)).toBe(123.46);
87
+ expect(schema.parse(123.456789)).toBe(123.46);
88
+ expect(schema.parse(0.999)).toBe(1.0);
89
+ });
90
+
91
+ it('should keep numbers with exactly 2 decimal places unchanged', () => {
92
+ const schema = numberPrecisionSchema();
93
+ expect(schema.parse(123.45)).toBe(123.45);
94
+ expect(schema.parse(0.99)).toBe(0.99);
95
+ expect(schema.parse(1000.0)).toBe(1000.0);
96
+ });
97
+
98
+ it('should pad numbers with fewer than 2 decimal places', () => {
99
+ const schema = numberPrecisionSchema();
100
+ expect(schema.parse(123.4)).toBe(123.4);
101
+ expect(schema.parse(123)).toBe(123.0);
102
+ expect(schema.parse(0.5)).toBe(0.5);
103
+ });
104
+
105
+ it('should handle whole numbers', () => {
106
+ const schema = numberPrecisionSchema();
107
+ expect(schema.parse(100)).toBe(100.0);
108
+ expect(schema.parse(0)).toBe(0.0);
109
+ expect(schema.parse(999)).toBe(999.0);
110
+ });
111
+
112
+ it('should handle negative numbers', () => {
113
+ const schema = numberPrecisionSchema();
114
+ expect(schema.parse(-123.456)).toBe(-123.46);
115
+ expect(schema.parse(-123.45)).toBe(-123.45);
116
+ expect(schema.parse(-100)).toBe(-100.0);
117
+ });
118
+
119
+ it('should handle zero', () => {
120
+ const schema = numberPrecisionSchema();
121
+ expect(schema.parse(0)).toBe(0.0);
122
+ expect(schema.parse(0.0)).toBe(0.0);
123
+ expect(schema.parse(0.001)).toBe(0.0);
124
+ });
125
+
126
+ it('should handle very small numbers', () => {
127
+ const schema = numberPrecisionSchema();
128
+ expect(schema.parse(0.001)).toBe(0.0);
129
+ expect(schema.parse(0.004)).toBe(0.0);
130
+ expect(schema.parse(0.005)).toBe(0.01);
131
+ expect(schema.parse(0.015)).toBe(0.02);
132
+ });
133
+
134
+ it('should handle very large numbers', () => {
135
+ const schema = numberPrecisionSchema();
136
+ expect(schema.parse(999999999.123456)).toBe(999999999.12);
137
+ expect(schema.parse(1234567890.99)).toBe(1234567890.99);
138
+ });
139
+
140
+ it('should handle numbers with floating point precision issues', () => {
141
+ const schema = numberPrecisionSchema();
142
+ // Common floating point issue: 0.1 + 0.2 = 0.30000000000000004
143
+ expect(schema.parse(0.1 + 0.2)).toBe(0.3);
144
+ expect(schema.parse(0.1 + 0.7)).toBe(0.8);
145
+ });
146
+ });
147
+
148
+ describe('custom precision values', () => {
149
+ it('should work with precision 0 (whole numbers)', () => {
150
+ const schema = numberPrecisionSchema(0);
151
+ expect(schema.parse(123.456)).toBe(123);
152
+ expect(schema.parse(123.5)).toBe(124);
153
+ expect(schema.parse(123.4)).toBe(123);
154
+ expect(schema.parse(0.9)).toBe(1);
155
+ });
156
+
157
+ it('should work with precision 1', () => {
158
+ const schema = numberPrecisionSchema(1);
159
+ expect(schema.parse(123.45)).toBe(123.5);
160
+ expect(schema.parse(123.44)).toBe(123.4);
161
+ expect(schema.parse(123.456)).toBe(123.5);
162
+ });
163
+
164
+ it('should work with precision 3', () => {
165
+ const schema = numberPrecisionSchema(3);
166
+ expect(schema.parse(123.4567)).toBe(123.457);
167
+ expect(schema.parse(123.456)).toBe(123.456);
168
+ expect(schema.parse(123.4)).toBe(123.4);
169
+ });
170
+
171
+ it('should work with precision 4', () => {
172
+ const schema = numberPrecisionSchema(4);
173
+ expect(schema.parse(123.45678)).toBe(123.4568);
174
+ expect(schema.parse(123.4567)).toBe(123.4567);
175
+ expect(schema.parse(123.4)).toBe(123.4);
176
+ });
177
+
178
+ it('should work with precision 6', () => {
179
+ const schema = numberPrecisionSchema(6);
180
+ expect(schema.parse(123.4567890123)).toBe(123.456789);
181
+ expect(schema.parse(123.456789)).toBe(123.456789);
182
+ });
183
+ });
184
+
185
+ describe('with base schema constraints', () => {
186
+ it('should apply positive constraint', () => {
187
+ const schema = numberPrecisionSchema(2, z.number().positive());
188
+ expect(schema.parse(123.456)).toBe(123.46);
189
+ expect(() => schema.parse(-123.456)).toThrow();
190
+ expect(() => schema.parse(0)).toThrow();
191
+ });
192
+
193
+ it('should apply max constraint', () => {
194
+ const schema = numberPrecisionSchema(2, z.number().max(1000));
195
+ expect(schema.parse(999.99)).toBe(999.99);
196
+ expect(schema.parse(1000.0)).toBe(1000.0);
197
+ expect(() => schema.parse(1000.01)).toThrow();
198
+ });
199
+
200
+ it('should apply min constraint', () => {
201
+ const schema = numberPrecisionSchema(2, z.number().min(0.01));
202
+ expect(schema.parse(0.01)).toBe(0.01);
203
+ expect(schema.parse(0.015)).toBe(0.02);
204
+ expect(() => schema.parse(0.005)).toThrow();
205
+ });
206
+
207
+ it('should apply multiple constraints', () => {
208
+ const schema = numberPrecisionSchema(
209
+ 2,
210
+ z.number().positive().min(0.01).max(999999999),
211
+ );
212
+ expect(schema.parse(500.99)).toBe(500.99);
213
+ expect(schema.parse(0.015)).toBe(0.02);
214
+ expect(() => schema.parse(-100)).toThrow();
215
+ expect(() => schema.parse(0.005)).toThrow();
216
+ expect(() => schema.parse(1000000000)).toThrow();
217
+ });
218
+ });
219
+
220
+ describe('rounding behavior', () => {
221
+ it('should round up correctly', () => {
222
+ const schema = numberPrecisionSchema(2);
223
+ expect(schema.parse(123.455)).toBe(123.46);
224
+ expect(schema.parse(123.445)).toBe(123.45);
225
+ expect(schema.parse(0.995)).toBe(1.0);
226
+ });
227
+
228
+ it('should round down correctly', () => {
229
+ const schema = numberPrecisionSchema(2);
230
+ expect(schema.parse(123.444)).toBe(123.44);
231
+ expect(schema.parse(123.441)).toBe(123.44);
232
+ });
233
+
234
+ it("should handle banker's rounding (round half to even)", () => {
235
+ const schema = numberPrecisionSchema(2);
236
+ // JavaScript's toFixed uses standard rounding, not banker's rounding
237
+ expect(schema.parse(123.445)).toBe(123.45);
238
+ expect(schema.parse(123.435)).toBe(123.44);
239
+ });
240
+
241
+ it('should handle edge cases in rounding', () => {
242
+ const schema = numberPrecisionSchema(2);
243
+ expect(schema.parse(0.004)).toBe(0.0);
244
+ expect(schema.parse(0.005)).toBe(0.01);
245
+ expect(schema.parse(0.015)).toBe(0.02);
246
+ expect(schema.parse(0.025)).toBe(0.03);
247
+ });
248
+ });
249
+
250
+ describe('edge cases', () => {
251
+ it('should handle very small positive numbers', () => {
252
+ const schema = numberPrecisionSchema(2);
253
+ expect(schema.parse(0.0001)).toBe(0.0);
254
+ expect(schema.parse(0.0005)).toBe(0.0);
255
+ expect(schema.parse(0.0006)).toBe(0.0);
256
+ });
257
+
258
+ it('should handle very large numbers', () => {
259
+ const schema = numberPrecisionSchema(2);
260
+ expect(schema.parse(Number.MAX_SAFE_INTEGER)).toBe(
261
+ Number(Number.MAX_SAFE_INTEGER.toFixed(2)),
262
+ );
263
+ });
264
+
265
+ it('should handle numbers at precision boundaries', () => {
266
+ const schema = numberPrecisionSchema(2);
267
+ expect(schema.parse(123.444)).toBe(123.44);
268
+ expect(schema.parse(123.445)).toBe(123.45);
269
+ expect(schema.parse(123.446)).toBe(123.45);
270
+ });
271
+
272
+ it('should handle scientific notation', () => {
273
+ const schema = numberPrecisionSchema(2);
274
+ expect(schema.parse(1.23e2)).toBe(123.0);
275
+ expect(schema.parse(1.234e2)).toBe(123.4);
276
+ expect(schema.parse(1.2345e2)).toBe(123.45);
277
+ });
278
+
279
+ it('should handle Infinity', () => {
280
+ const schema = numberPrecisionSchema(2);
281
+ expect(schema.parse(Infinity)).toBe(Infinity);
282
+ expect(schema.parse(-Infinity)).toBe(-Infinity);
283
+ });
284
+
285
+ it('should handle NaN', () => {
286
+ const schema = numberPrecisionSchema(2);
287
+ expect(() => schema.parse(NaN)).toThrow();
288
+ });
289
+ });
290
+
291
+ describe('real-world scenarios', () => {
292
+ it('should handle currency amounts', () => {
293
+ const schema = numberPrecisionSchema(2);
294
+ expect(schema.parse(122.4444)).toBe(122.44);
295
+ expect(schema.parse(99.995)).toBe(100.0);
296
+ expect(schema.parse(0.01)).toBe(0.01);
297
+ expect(schema.parse(1000.0)).toBe(1000.0);
298
+ });
299
+
300
+ it('should handle percentage values', () => {
301
+ const schema = numberPrecisionSchema(2);
302
+ expect(schema.parse(12.3456)).toBe(12.35);
303
+ expect(schema.parse(99.999)).toBe(100.0);
304
+ expect(schema.parse(0.123)).toBe(0.12);
305
+ });
306
+
307
+ it('should handle measurement values with different precision', () => {
308
+ const schema3 = numberPrecisionSchema(3);
309
+ expect(schema3.parse(12.34567)).toBe(12.346);
310
+ expect(schema3.parse(0.1234)).toBe(0.123);
311
+ });
312
+ });
313
+
314
+ describe('integration with Zod features', () => {
315
+ it('should work with safeParse', () => {
316
+ const schema = numberPrecisionSchema(2);
317
+ const result = schema.safeParse(123.456);
318
+ expect(result.success).toBe(true);
319
+ if (result.success) {
320
+ expect(result.data).toBe(123.46);
321
+ }
322
+ });
323
+
324
+ it('should work with safeParse for invalid input', () => {
325
+ const schema = numberPrecisionSchema(2, z.number().positive());
326
+ const result = schema.safeParse(-123.456);
327
+ expect(result.success).toBe(false);
328
+ });
329
+
330
+ it('should preserve type information', () => {
331
+ const schema = numberPrecisionSchema(2);
332
+ const result = schema.parse(123.456);
333
+ expect(typeof result).toBe('number');
334
+ });
335
+ });
336
+ });