@dalmore/api-contracts 1.0.3 → 1.0.5

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 (303) hide show
  1. package/README.md +34 -60
  2. package/index.d.mts +17 -0
  3. package/index.d.ts +17 -0
  4. package/index.mjs +1001 -18638
  5. package/package.json +7 -54
  6. package/clients/index.mjs +0 -10970
  7. package/compliance/index.mjs +0 -20016
  8. package/compliance-apikey/index.mjs +0 -9795
  9. package/helpers/index.mjs +0 -146
  10. package/investors/index.mjs +0 -12844
  11. package/issuers/index.mjs +0 -16168
  12. package/secondaries/index.mjs +0 -10282
  13. package/src/common/helpers/index.ts +0 -205
  14. package/src/common/types/account-contact.types.ts +0 -98
  15. package/src/common/types/account-detail.types.ts +0 -27
  16. package/src/common/types/account-integration.types.ts +0 -143
  17. package/src/common/types/account-manager.types.ts +0 -124
  18. package/src/common/types/account.types.ts +0 -296
  19. package/src/common/types/activity.types.ts +0 -274
  20. package/src/common/types/address.types.ts +0 -41
  21. package/src/common/types/aic.types.ts +0 -246
  22. package/src/common/types/aml.types.ts +0 -18
  23. package/src/common/types/api-key-logs.types.ts +0 -66
  24. package/src/common/types/api-keys.types.ts +0 -69
  25. package/src/common/types/asset.types.ts +0 -338
  26. package/src/common/types/auth.types.ts +0 -370
  27. package/src/common/types/batch-jobs.types.ts +0 -150
  28. package/src/common/types/bonus-tier.types.ts +0 -147
  29. package/src/common/types/cart.types.ts +0 -18
  30. package/src/common/types/checklist-items.types.ts +0 -70
  31. package/src/common/types/checklist.types.ts +0 -97
  32. package/src/common/types/common.types.ts +0 -1520
  33. package/src/common/types/comply-advantage-api.types.ts +0 -316
  34. package/src/common/types/comply-advantage.types.ts +0 -25
  35. package/src/common/types/contact-us.types.ts +0 -107
  36. package/src/common/types/contract-helpers.ts +0 -205
  37. package/src/common/types/countries.types.ts +0 -375
  38. package/src/common/types/covered-person.types.ts +0 -274
  39. package/src/common/types/dashboard.types.ts +0 -799
  40. package/src/common/types/data-record.types.ts +0 -325
  41. package/src/common/types/data-room.types.ts +0 -242
  42. package/src/common/types/default-theme-config.types.ts +0 -87
  43. package/src/common/types/disbursement-adjustment.types.ts +0 -32
  44. package/src/common/types/disbursement-approval-user.types.ts +0 -100
  45. package/src/common/types/disbursement-review.types.ts +0 -110
  46. package/src/common/types/disbursement-transaction.types.ts +0 -72
  47. package/src/common/types/disbursements.types.ts +0 -310
  48. package/src/common/types/domain-filter.types.ts +0 -55
  49. package/src/common/types/email-theme.types.ts +0 -442
  50. package/src/common/types/entity.types.ts +0 -15
  51. package/src/common/types/error-responses.types.ts +0 -135
  52. package/src/common/types/escrow-account.types.ts +0 -104
  53. package/src/common/types/exchange-api-key.types.ts +0 -121
  54. package/src/common/types/exchange-import.types.ts +0 -36
  55. package/src/common/types/exchange-provider.types.ts +0 -329
  56. package/src/common/types/file.types.ts +0 -461
  57. package/src/common/types/health.types.ts +0 -29
  58. package/src/common/types/index.ts +0 -48
  59. package/src/common/types/individuals.types.ts +0 -554
  60. package/src/common/types/investor-account.types.ts +0 -1239
  61. package/src/common/types/investorAccountIdSchema.type.ts +0 -0
  62. package/src/common/types/investors-offering.types.ts +0 -65
  63. package/src/common/types/invite.types.ts +0 -133
  64. package/src/common/types/issuer-bank-account.types.ts +0 -107
  65. package/src/common/types/issuer-offering.types.ts +0 -306
  66. package/src/common/types/issuer-payment-method.types.ts +0 -341
  67. package/src/common/types/issuer.types.ts +0 -312
  68. package/src/common/types/job-item.types.ts +0 -119
  69. package/src/common/types/jobs.types.ts +0 -171
  70. package/src/common/types/kyb.types.ts +0 -53
  71. package/src/common/types/kyc.types.ts +0 -188
  72. package/src/common/types/legal-entity.types.ts +0 -185
  73. package/src/common/types/login-history.types.ts +0 -46
  74. package/src/common/types/mail-template.types.ts +0 -436
  75. package/src/common/types/north-cap-integration.types.ts +0 -190
  76. package/src/common/types/note.types.ts +0 -109
  77. package/src/common/types/notification.types.ts +0 -58
  78. package/src/common/types/notion-api.types.ts +0 -374
  79. package/src/common/types/notion-database.types.ts +0 -125
  80. package/src/common/types/notion-page.types.ts +0 -267
  81. package/src/common/types/offering-reports.types.ts +0 -153
  82. package/src/common/types/offering-submission.types.ts +0 -314
  83. package/src/common/types/offering.types.ts +0 -590
  84. package/src/common/types/page-revision.types.ts +0 -86
  85. package/src/common/types/page.types.ts +0 -436
  86. package/src/common/types/password.type.ts +0 -15
  87. package/src/common/types/payment-methods.types.ts +0 -298
  88. package/src/common/types/phone.type.ts +0 -27
  89. package/src/common/types/portfolio.types.ts +0 -50
  90. package/src/common/types/privacy-policy-and-tos.types.ts +0 -231
  91. package/src/common/types/queue.types.ts +0 -111
  92. package/src/common/types/registered-reps.types.ts +0 -25
  93. package/src/common/types/rejection-reasons.types.ts +0 -56
  94. package/src/common/types/review.types.ts +0 -133
  95. package/src/common/types/role.types.ts +0 -26
  96. package/src/common/types/secondary-customer.types.ts +0 -66
  97. package/src/common/types/secondary-issuer.types.ts +0 -50
  98. package/src/common/types/secondary-order.types.ts +0 -58
  99. package/src/common/types/secondary-security.types.ts +0 -60
  100. package/src/common/types/secondary-trade.entity.ts +0 -16
  101. package/src/common/types/secondary-trade.types.ts +0 -95
  102. package/src/common/types/secure-request.types.ts +0 -68
  103. package/src/common/types/signer.types.ts +0 -651
  104. package/src/common/types/site-link.types.ts +0 -166
  105. package/src/common/types/site-settings.types.ts +0 -726
  106. package/src/common/types/site.types.ts +0 -270
  107. package/src/common/types/sms.types.ts +0 -30
  108. package/src/common/types/state-machine.types.ts +0 -177
  109. package/src/common/types/states.types.ts +0 -163
  110. package/src/common/types/subdoc-preview.types.ts +0 -35
  111. package/src/common/types/task.types.ts +0 -258
  112. package/src/common/types/trade-adjustment.type.ts +0 -33
  113. package/src/common/types/trade-line-item.type.ts +0 -132
  114. package/src/common/types/trade.types.ts +0 -931
  115. package/src/common/types/transaction.types.ts +0 -198
  116. package/src/common/types/trusted-contact.types.ts +0 -122
  117. package/src/common/types/typography.types.ts +0 -75
  118. package/src/common/types/user-manual.types.ts +0 -290
  119. package/src/common/types/user-setting.types.ts +0 -133
  120. package/src/common/types/user.types.ts +0 -320
  121. package/src/common/types/webhook.types.ts +0 -588
  122. package/src/common/types/zip.type.ts +0 -36
  123. package/src/contracts/clients/accounts/index.ts +0 -61
  124. package/src/contracts/clients/aic/index.ts +0 -59
  125. package/src/contracts/clients/api-key-logs/index.ts +0 -53
  126. package/src/contracts/clients/api-keys/index.ts +0 -73
  127. package/src/contracts/clients/assets/index.ts +0 -102
  128. package/src/contracts/clients/auth/index.ts +0 -50
  129. package/src/contracts/clients/files/index.ts +0 -166
  130. package/src/contracts/clients/files-public/index.ts +0 -166
  131. package/src/contracts/clients/index.ts +0 -44
  132. package/src/contracts/clients/individuals/index.ts +0 -93
  133. package/src/contracts/clients/investor-accounts/index.ts +0 -93
  134. package/src/contracts/clients/issuers/index.ts +0 -94
  135. package/src/contracts/clients/legal-entities/index.ts +0 -93
  136. package/src/contracts/clients/offerings/index.ts +0 -117
  137. package/src/contracts/clients/secure-requests/index.ts +0 -34
  138. package/src/contracts/clients/sites/index.ts +0 -56
  139. package/src/contracts/clients/trades/index.ts +0 -122
  140. package/src/contracts/compliance/account-contacts/index.ts +0 -82
  141. package/src/contracts/compliance/account-managers/index.ts +0 -142
  142. package/src/contracts/compliance/accounts/index.ts +0 -187
  143. package/src/contracts/compliance/activities/index.ts +0 -55
  144. package/src/contracts/compliance/aic/index.ts +0 -60
  145. package/src/contracts/compliance/api-keys/index.ts +0 -91
  146. package/src/contracts/compliance/assets/index.ts +0 -122
  147. package/src/contracts/compliance/auth/index.ts +0 -134
  148. package/src/contracts/compliance/batch-jobs/index.ts +0 -62
  149. package/src/contracts/compliance/bonus-tiers/index.ts +0 -55
  150. package/src/contracts/compliance/checklist/index.ts +0 -87
  151. package/src/contracts/compliance/checklist-items/index.ts +0 -86
  152. package/src/contracts/compliance/covered-persons/index.ts +0 -97
  153. package/src/contracts/compliance/dashboard/index.ts +0 -111
  154. package/src/contracts/compliance/data-records/index.ts +0 -116
  155. package/src/contracts/compliance/data-rooms/index.ts +0 -113
  156. package/src/contracts/compliance/default-theme-configs/index.ts +0 -95
  157. package/src/contracts/compliance/disbursement/index.ts +0 -165
  158. package/src/contracts/compliance/disbursement-approval-users/index.ts +0 -84
  159. package/src/contracts/compliance/disbursement-transactions/index.ts +0 -37
  160. package/src/contracts/compliance/domain-filters/index.ts +0 -117
  161. package/src/contracts/compliance/email-themes/index.ts +0 -284
  162. package/src/contracts/compliance/escrow-accounts/index.ts +0 -85
  163. package/src/contracts/compliance/exchange-api-keys/index.ts +0 -129
  164. package/src/contracts/compliance/exchange-imports/index.ts +0 -137
  165. package/src/contracts/compliance/files/index.ts +0 -267
  166. package/src/contracts/compliance/files-public/index.ts +0 -188
  167. package/src/contracts/compliance/health/index.ts +0 -26
  168. package/src/contracts/compliance/index.ts +0 -147
  169. package/src/contracts/compliance/individuals/index.ts +0 -57
  170. package/src/contracts/compliance/investor-accounts/index.ts +0 -141
  171. package/src/contracts/compliance/invites/index.ts +0 -137
  172. package/src/contracts/compliance/issuer-bank-accounts/index.ts +0 -81
  173. package/src/contracts/compliance/issuer-payment-methods/index.ts +0 -81
  174. package/src/contracts/compliance/issuers/index.ts +0 -97
  175. package/src/contracts/compliance/job-items/index.ts +0 -58
  176. package/src/contracts/compliance/jobs/index.ts +0 -59
  177. package/src/contracts/compliance/kyb/index.ts +0 -54
  178. package/src/contracts/compliance/kyc/index.ts +0 -77
  179. package/src/contracts/compliance/legal-entities/index.ts +0 -57
  180. package/src/contracts/compliance/login-histories/index.ts +0 -37
  181. package/src/contracts/compliance/notes/index.ts +0 -69
  182. package/src/contracts/compliance/notion-databases/index.ts +0 -107
  183. package/src/contracts/compliance/notion-pages/index.ts +0 -105
  184. package/src/contracts/compliance/offering-reports/index.ts +0 -149
  185. package/src/contracts/compliance/offerings/index.ts +0 -233
  186. package/src/contracts/compliance/pages/index.ts +0 -178
  187. package/src/contracts/compliance/payment-methods/index.ts +0 -57
  188. package/src/contracts/compliance/rejection-reasons/index.ts +0 -32
  189. package/src/contracts/compliance/review/index.ts +0 -169
  190. package/src/contracts/compliance/roles/index.ts +0 -34
  191. package/src/contracts/compliance/secondary-customers/index.ts +0 -77
  192. package/src/contracts/compliance/secondary-orders/index.ts +0 -60
  193. package/src/contracts/compliance/secondary-trades/index.ts +0 -100
  194. package/src/contracts/compliance/secure-requests/index.ts +0 -54
  195. package/src/contracts/compliance/signer/index.ts +0 -369
  196. package/src/contracts/compliance/site-links/index.ts +0 -128
  197. package/src/contracts/compliance/site-settings/index.ts +0 -669
  198. package/src/contracts/compliance/sites/index.ts +0 -56
  199. package/src/contracts/compliance/state-machine/index.ts +0 -94
  200. package/src/contracts/compliance/tasks/index.ts +0 -91
  201. package/src/contracts/compliance/third-parties/index.ts +0 -52
  202. package/src/contracts/compliance/trade-line-items/index.ts +0 -59
  203. package/src/contracts/compliance/trades/index.ts +0 -230
  204. package/src/contracts/compliance/transactions/index.ts +0 -161
  205. package/src/contracts/compliance/user-manuals/index.ts +0 -271
  206. package/src/contracts/compliance/user-settings/index.ts +0 -189
  207. package/src/contracts/compliance/users/index.ts +0 -200
  208. package/src/contracts/compliance/webhooks/index.ts +0 -41
  209. package/src/contracts/compliance-apikey/accounts/index.ts +0 -58
  210. package/src/contracts/compliance-apikey/index.ts +0 -14
  211. package/src/contracts/index.ts +0 -6
  212. package/src/contracts/investors/account-contacts/index.ts +0 -58
  213. package/src/contracts/investors/aic/index.ts +0 -59
  214. package/src/contracts/investors/assets/index.ts +0 -61
  215. package/src/contracts/investors/auth/index.ts +0 -116
  216. package/src/contracts/investors/bonus-tiers/index.ts +0 -37
  217. package/src/contracts/investors/cart/index.ts +0 -75
  218. package/src/contracts/investors/contact-us/index.ts +0 -48
  219. package/src/contracts/investors/data-records/index.ts +0 -113
  220. package/src/contracts/investors/data-rooms/index.ts +0 -96
  221. package/src/contracts/investors/files/index.ts +0 -167
  222. package/src/contracts/investors/files-public/index.ts +0 -185
  223. package/src/contracts/investors/index.ts +0 -72
  224. package/src/contracts/investors/individuals/index.ts +0 -99
  225. package/src/contracts/investors/investor-accounts/index.ts +0 -110
  226. package/src/contracts/investors/issuer-payment-methods/index.ts +0 -36
  227. package/src/contracts/investors/issuers/index.ts +0 -30
  228. package/src/contracts/investors/legal-entities/index.ts +0 -93
  229. package/src/contracts/investors/notes/index.ts +0 -69
  230. package/src/contracts/investors/offerings/index.ts +0 -93
  231. package/src/contracts/investors/pages/index.ts +0 -88
  232. package/src/contracts/investors/payment-methods/index.ts +0 -149
  233. package/src/contracts/investors/portfolios/index.ts +0 -53
  234. package/src/contracts/investors/sites/index.ts +0 -96
  235. package/src/contracts/investors/tasks/index.ts +0 -111
  236. package/src/contracts/investors/trade-line-items/index.ts +0 -75
  237. package/src/contracts/investors/trades/index.ts +0 -114
  238. package/src/contracts/investors/transactions/index.ts +0 -37
  239. package/src/contracts/investors/trusted-contacts/index.ts +0 -93
  240. package/src/contracts/investors/user-manuals/index.ts +0 -62
  241. package/src/contracts/investors/user-settings/index.ts +0 -170
  242. package/src/contracts/investors/users/index.ts +0 -45
  243. package/src/contracts/investors/webhooks/index.ts +0 -30
  244. package/src/contracts/issuers/account-contacts/index.ts +0 -76
  245. package/src/contracts/issuers/account-integrations/index.ts +0 -97
  246. package/src/contracts/issuers/accounts/index.ts +0 -97
  247. package/src/contracts/issuers/activities/index.ts +0 -54
  248. package/src/contracts/issuers/aic/index.ts +0 -39
  249. package/src/contracts/issuers/api-key-logs/index.ts +0 -53
  250. package/src/contracts/issuers/api-keys/index.ts +0 -93
  251. package/src/contracts/issuers/assets/index.ts +0 -122
  252. package/src/contracts/issuers/auth/index.ts +0 -152
  253. package/src/contracts/issuers/bonus-tiers/index.ts +0 -55
  254. package/src/contracts/issuers/contact-us/index.ts +0 -48
  255. package/src/contracts/issuers/covered-persons/index.ts +0 -136
  256. package/src/contracts/issuers/dashboard/index.ts +0 -72
  257. package/src/contracts/issuers/data-records/index.ts +0 -257
  258. package/src/contracts/issuers/data-rooms/index.ts +0 -134
  259. package/src/contracts/issuers/disbursement-approval-users/index.ts +0 -82
  260. package/src/contracts/issuers/disbursement-transactions/index.ts +0 -53
  261. package/src/contracts/issuers/disbursements/index.ts +0 -153
  262. package/src/contracts/issuers/email-themes/index.ts +0 -242
  263. package/src/contracts/issuers/escrow-accounts/index.ts +0 -81
  264. package/src/contracts/issuers/exchange-api-keys/index.ts +0 -144
  265. package/src/contracts/issuers/files/index.ts +0 -166
  266. package/src/contracts/issuers/files-public/index.ts +0 -166
  267. package/src/contracts/issuers/health/index.ts +0 -24
  268. package/src/contracts/issuers/index.ts +0 -112
  269. package/src/contracts/issuers/investor-accounts/index.ts +0 -148
  270. package/src/contracts/issuers/invites/index.ts +0 -129
  271. package/src/contracts/issuers/issuer/index.ts +0 -94
  272. package/src/contracts/issuers/issuer-bank-accounts/index.ts +0 -81
  273. package/src/contracts/issuers/issuer-payment-methods/index.ts +0 -136
  274. package/src/contracts/issuers/kyc/index.ts +0 -38
  275. package/src/contracts/issuers/login-histories/index.ts +0 -51
  276. package/src/contracts/issuers/notes/index.ts +0 -69
  277. package/src/contracts/issuers/offerings/index.ts +0 -206
  278. package/src/contracts/issuers/pages/index.ts +0 -138
  279. package/src/contracts/issuers/payment-methods/index.ts +0 -61
  280. package/src/contracts/issuers/portfolios/index.ts +0 -36
  281. package/src/contracts/issuers/rejection-reasons/index.ts +0 -32
  282. package/src/contracts/issuers/review/index.ts +0 -63
  283. package/src/contracts/issuers/secondary-customers/index.ts +0 -55
  284. package/src/contracts/issuers/secondary-orders/index.ts +0 -57
  285. package/src/contracts/issuers/secondary-trades/index.ts +0 -57
  286. package/src/contracts/issuers/secure-requests/index.ts +0 -34
  287. package/src/contracts/issuers/site-links/index.ts +0 -116
  288. package/src/contracts/issuers/site-settings/index.ts +0 -585
  289. package/src/contracts/issuers/sites/index.ts +0 -32
  290. package/src/contracts/issuers/tasks/index.ts +0 -111
  291. package/src/contracts/issuers/trades/index.ts +0 -132
  292. package/src/contracts/issuers/transactions/index.ts +0 -158
  293. package/src/contracts/issuers/user-manuals/index.ts +0 -62
  294. package/src/contracts/issuers/user-settings/index.ts +0 -170
  295. package/src/contracts/issuers/users/index.ts +0 -126
  296. package/src/contracts/secondaries/accounts/index.ts +0 -58
  297. package/src/contracts/secondaries/index.ts +0 -23
  298. package/src/contracts/secondaries/secondary-customers/index.ts +0 -55
  299. package/src/contracts/secondaries/secondary-issuers/index.ts +0 -94
  300. package/src/contracts/secondaries/secondary-orders/index.ts +0 -56
  301. package/src/contracts/secondaries/secondary-securities/index.ts +0 -95
  302. package/src/contracts/secondaries/secondary-trades/index.ts +0 -56
  303. package/types/index.mjs +0 -10320
@@ -1,338 +0,0 @@
1
- import { extendZodWithOpenApi } from '@anatine/zod-openapi';
2
- import { TypeID } from 'typeid-js';
3
- import { z } from 'zod';
4
- import { accountIdSchema } from './account.types';
5
- import {
6
- AccountZod,
7
- AssetType,
8
- DurationType,
9
- IPaginationMeta,
10
- SortBy,
11
- SortOrder,
12
- } from './common.types';
13
- import { IBaseEntity } from './entity.types';
14
- import { IOffering, offeringIdSchema } from './offering.types';
15
- import { issuerIdSchema } from './issuer.types';
16
-
17
- extendZodWithOpenApi(z);
18
-
19
- export const assetIdSchema = z.string().refine(
20
- (value) => {
21
- try {
22
- const tid = TypeID.fromString(value);
23
- return tid.getType() === 'asset';
24
- } catch {
25
- return false;
26
- }
27
- },
28
- {
29
- message: `Invalid asset ID format. Must be a valid TypeID with "asset" prefix. Example: asset_01j5y5ghx5fg68d663j1fvy2x7`,
30
- },
31
- );
32
- export enum TemplateType {
33
- STANDARD = 'STANDARD',
34
- TIERED = 'TIERED',
35
- }
36
-
37
- export const IAsset = IBaseEntity.extend({
38
- id: assetIdSchema,
39
- name: z.string(),
40
- type: z.nativeEnum(AssetType).nullable(),
41
- pricePerUnit: z.number().nullable(),
42
- totalUnits: z.number().nullable(),
43
- totalAmount: z.number().nullable(),
44
- yield: z.number().nullable(),
45
- duration: z.number().nullable(),
46
- durationType: z.nativeEnum(DurationType).nullable(),
47
- accountId: z.string(),
48
- account: AccountZod.optional().nullable(),
49
- offeringId: z.string(),
50
- offering: z
51
- .lazy(() => IOffering)
52
- .optional()
53
- .nullable(), // Use z.lazy here
54
- template: z.nativeEnum(TemplateType),
55
- tiers: z.array(z.number().positive()).nullable(),
56
- enableBonus: z.boolean(),
57
- });
58
-
59
- export type IAsset = z.infer<typeof IAsset>;
60
-
61
- export const IPaginatedAsset = z.object({
62
- items: z.array(IAsset),
63
- meta: IPaginationMeta,
64
- });
65
- export type IPaginatedAsset = z.infer<typeof IPaginatedAsset>;
66
-
67
- const PostAssetBase = z.object({
68
- offeringId: z
69
- .lazy(() => offeringIdSchema)
70
- .openapi({ example: 'offering_01jayn2qkpeebav9gjpqx7xm8j' }),
71
- name: z.string().min(2).max(50).openapi({ example: 'Asset name' }),
72
- type: z.nativeEnum(AssetType).openapi({ example: AssetType.STOCK }),
73
- pricePerUnit: z
74
- .number()
75
- .min(0.01)
76
- .max(10000000000)
77
- .nullable()
78
- .openapi({ example: 2000 }),
79
- totalUnits: z
80
- .number()
81
- .min(1)
82
- .max(10000000000)
83
- .nullable()
84
- .openapi({ example: 5200 }),
85
- yield: z
86
- .number()
87
- .min(0.01)
88
- .max(10000000000)
89
- .nullable()
90
- .optional()
91
- .openapi({ example: 1200 }),
92
- duration: z
93
- .number()
94
- .min(1)
95
- .max(1000)
96
- .nullable()
97
- .optional()
98
- .openapi({ example: 1 }),
99
- durationType: z
100
- .nativeEnum(DurationType)
101
- .nullable()
102
- .optional()
103
- .openapi({ example: DurationType.DAY }),
104
- template: z
105
- .nativeEnum(TemplateType)
106
- .default(TemplateType.STANDARD)
107
- .openapi({ example: TemplateType.STANDARD }),
108
- tiers: z.array(z.number().positive()).nullable().optional(),
109
- enableBonus: z.boolean().default(false).openapi({ example: false }),
110
- });
111
-
112
- const postAssetRefinement = (data: any, ctx: any) => {
113
- // If type is bond, yield and duration must be provided (cannot be null or undefined)
114
- if (data.type === AssetType.BOND) {
115
- if (data.yield === null || data.yield === undefined) {
116
- ctx.addIssue({
117
- path: ['yield'],
118
- message:
119
- 'Yield is required for bond type and cannot be null or undefined',
120
- code: z.ZodIssueCode.custom,
121
- });
122
- }
123
- if (data.duration === null || data.duration === undefined) {
124
- ctx.addIssue({
125
- path: ['duration'],
126
- message:
127
- 'Duration is required for bond type and cannot be null or undefined',
128
- code: z.ZodIssueCode.custom,
129
- });
130
- }
131
- if (data.durationType === null || data.durationType === undefined) {
132
- ctx.addIssue({
133
- path: ['durationType'],
134
- message:
135
- 'Duration type is required for bond type and cannot be null or undefined',
136
- code: z.ZodIssueCode.custom,
137
- });
138
- }
139
- }
140
-
141
- // If type is stock, yield and duration must be either null or undefined
142
- if (data.type === AssetType.STOCK) {
143
- if (data.yield !== null && data.yield !== undefined) {
144
- ctx.addIssue({
145
- path: ['yield'],
146
- message: 'Yield must not be provided for stock type',
147
- code: z.ZodIssueCode.custom,
148
- });
149
- }
150
- if (data.duration !== null && data.duration !== undefined) {
151
- ctx.addIssue({
152
- path: ['duration'],
153
- message: 'Duration must not be provided for stock type',
154
- code: z.ZodIssueCode.custom,
155
- });
156
- }
157
- if (data.durationType !== null && data.durationType !== undefined) {
158
- ctx.addIssue({
159
- path: ['durationType'],
160
- message: 'Duration type must not be provided for stock type',
161
- code: z.ZodIssueCode.custom,
162
- });
163
- }
164
- }
165
- if (data.template === TemplateType.TIERED) {
166
- if (data.tiers === null || data.tiers === undefined) {
167
- ctx.addIssue({
168
- path: ['tiers'],
169
- message: 'Tiers must be provided for TIERED template',
170
- code: z.ZodIssueCode.custom,
171
- });
172
- }
173
- }
174
- // If template is STANDARD, tiers must be null or undefined
175
- if (data.template === TemplateType.STANDARD) {
176
- if (data.tiers !== null && data.tiers !== undefined) {
177
- ctx.addIssue({
178
- path: ['tiers'],
179
- message: 'Tiers must not be provided for STANDARD template',
180
- code: z.ZodIssueCode.custom,
181
- });
182
- }
183
- }
184
- };
185
-
186
- export const PostAsset = PostAssetBase.superRefine(postAssetRefinement);
187
-
188
- export type PostAsset = z.infer<typeof PostAsset>;
189
-
190
- export const CompliancePostAsset = PostAssetBase.extend({
191
- accountId: accountIdSchema,
192
- }).superRefine(postAssetRefinement);
193
-
194
- export type CompliancePostAsset = z.infer<typeof CompliancePostAsset>;
195
-
196
- export const PutAsset = z.object({
197
- name: z.string().min(2).max(50).optional().openapi({ example: 'Z' }),
198
- type: z
199
- .nativeEnum(AssetType)
200
- .optional()
201
- .openapi({ example: AssetType.STOCK }),
202
- pricePerUnit: z
203
- .number()
204
- .min(0.01)
205
- .max(10000000000)
206
- .nullable()
207
- .optional()
208
- .openapi({ example: 2000 }),
209
- totalUnits: z
210
- .number()
211
- .min(1)
212
- .max(10000000000)
213
- .nullable()
214
- .optional()
215
- .openapi({ example: 5200 }),
216
- yield: z
217
- .number()
218
- .min(0.01)
219
- .max(10000000000)
220
- .nullable()
221
- .optional()
222
- .openapi({ example: 1200 }),
223
- duration: z
224
- .number()
225
- .min(1)
226
- .max(1000)
227
- .nullable()
228
- .optional()
229
- .openapi({ example: 1 }),
230
- durationType: z
231
- .nativeEnum(DurationType)
232
- .nullable()
233
- .optional()
234
- .openapi({ example: DurationType.DAY }),
235
- template: z
236
- .nativeEnum(TemplateType)
237
- .default(TemplateType.STANDARD)
238
- .openapi({ example: TemplateType.STANDARD })
239
- .nullable()
240
- .optional(),
241
- tiers: z.array(z.number().positive()).nullable().optional(),
242
- enableBonus: z.boolean().optional().openapi({ example: false }),
243
- });
244
-
245
- export type PutAsset = z.infer<typeof PutAsset>;
246
-
247
- export const CompliancePutAsset = PutAsset.merge(
248
- z.object({ accountId: accountIdSchema }),
249
- );
250
- export type CompliancePutAsset = z.infer<typeof CompliancePutAsset>;
251
-
252
- const assetsInclude = z.enum(['account', 'offering', 'bonusTiers']);
253
-
254
- export const AssetsIncludeQuery = z.object({
255
- include: z
256
- .string()
257
- .optional()
258
- .transform((str) => (str ? str.split(',') : []))
259
- .refine(
260
- (includes) =>
261
- includes.every((include) =>
262
- assetsInclude.options.includes(include as any),
263
- ),
264
- {
265
- message: `Invalid include option provided. Valid options are: ${assetsInclude.options.join(', ')}`,
266
- },
267
- )
268
- .openapi({
269
- example: `${assetsInclude.options.join(', ')}`,
270
- }),
271
- });
272
- export interface AssetsIncludeQuery
273
- extends z.infer<typeof AssetsIncludeQuery> {}
274
-
275
- export const AssetFiltersZod = z.object({
276
- name: z.string().optional(),
277
- accountId: accountIdSchema.optional(),
278
- offeringId: z
279
- .lazy(() => offeringIdSchema)
280
- .openapi({ example: 'offering_01jayn2qkpeebav9gjpqx7xm8j' })
281
- .optional(),
282
- issuerId: z.lazy(() => issuerIdSchema).optional(),
283
- type: z.nativeEnum(AssetType).optional(),
284
- });
285
- export type AssetFiltersZod = z.infer<typeof AssetFiltersZod>;
286
-
287
- export const AssetSortZod = z.object({
288
- sort: z.enum([SortBy.NAME, SortBy.CREATED_AT, SortBy.UPDATED_AT]).optional(),
289
- dir: z.nativeEnum(SortOrder).optional(),
290
- });
291
- export type AssetSortZod = z.infer<typeof AssetSortZod>;
292
-
293
- const BaseAssetSummarySchema = z.object({
294
- id: z.string(),
295
- name: z.string(),
296
- accountId: accountIdSchema,
297
- offeringId: offeringIdSchema,
298
- issuerId: z.lazy(() => issuerIdSchema).nullable(),
299
- pricePerUnit: z.number().nullable(),
300
- totalUnits: z.number().nullable(),
301
- });
302
-
303
- export const StockAssetSchema = BaseAssetSummarySchema.extend({
304
- type: z.literal(AssetType.STOCK),
305
- });
306
- export type StockAssetSchema = z.infer<typeof StockAssetSchema>;
307
-
308
- const BondAssetSchema = BaseAssetSummarySchema.extend({
309
- type: z.literal(AssetType.BOND).nullable(),
310
- yield: z.number().nullable(),
311
- duration: z.number().nullable(),
312
- durationType: z.nativeEnum(DurationType).nullable(),
313
- });
314
-
315
- export const AssetSummarySchema = z.discriminatedUnion('type', [
316
- StockAssetSchema,
317
- BondAssetSchema,
318
- ]);
319
- export type AssetSummarySchema = z.infer<typeof AssetSummarySchema>;
320
-
321
- export const IPaginatedAssetSummary = z.object({
322
- items: z.array(AssetSummarySchema),
323
- meta: IPaginationMeta,
324
- });
325
-
326
- export type IPaginatedAssetSummary = z.infer<typeof IPaginatedAssetSummary>;
327
-
328
- export const AssetSummaryFiltersZod = z.object({
329
- accountId: accountIdSchema.optional(),
330
- issuerId: z.lazy(() => issuerIdSchema).optional(),
331
- offeringId: z
332
- .lazy(() => offeringIdSchema)
333
- .openapi({ example: 'offering_01jayn2qkpeebav9gjpqx7xm8j' })
334
- .optional(),
335
- type: z.nativeEnum(AssetType),
336
- name: z.string().optional(),
337
- });
338
- export type AssetSummaryFiltersZod = z.infer<typeof AssetSummaryFiltersZod>;
@@ -1,370 +0,0 @@
1
- import { z } from 'zod';
2
- import { extendZodWithOpenApi } from '@anatine/zod-openapi';
3
- import { accountIdSchema } from './account.types';
4
- import { PasswordSchema } from './password.type';
5
- import { inviteIdSchema } from './invite.types';
6
- import {
7
- PortalType,
8
- ManagedByType,
9
- UserRole,
10
- createUrlSchema,
11
- } from './common.types';
12
- import { TypeID } from 'typeid-js';
13
- import { TwoFactorMethod } from './sms.types';
14
- import { PhoneZodSchema } from './phone.type';
15
-
16
- extendZodWithOpenApi(z);
17
-
18
- export const userLoginIdSchema = z.string().refine(
19
- (value) => {
20
- try {
21
- const tid = TypeID.fromString(value);
22
- return tid.getType() === 'user_login';
23
- } catch {
24
- return false;
25
- }
26
- },
27
- {
28
- message:
29
- 'Invalid user ID format. Must be a valid TypeID with "user_login" prefix.',
30
- },
31
- );
32
-
33
- export enum AuthProvider {
34
- EMAIL = 'email',
35
- }
36
-
37
- const isBase64 = (v: string) => {
38
- if (v.length % 4 !== 0) {
39
- return false;
40
- }
41
- try {
42
- return btoa(atob(v)) === v;
43
- } catch (err) {
44
- return false;
45
- }
46
- };
47
-
48
- const BaseAuthBody = z.object({
49
- firstName: z
50
- .string()
51
- .min(2, 'firstName is less than 2 characters')
52
- .max(20, 'firstName is more than 20 characters')
53
- .openapi({
54
- example: 'Neil',
55
- }),
56
- lastName: z
57
- .string()
58
- .min(2, 'lastName is less than 2 characters')
59
- .max(20, 'lastName is more than 20 characters')
60
- .openapi({
61
- example: 'Armstrong',
62
- }),
63
- email: z
64
- .string()
65
- .email()
66
- .transform((val) => val.toLowerCase())
67
- .openapi({
68
- example: 'neil@dalmoregroup.com',
69
- }),
70
- password: PasswordSchema,
71
- });
72
-
73
- export const IRegisterBodyZod = BaseAuthBody.extend({
74
- code: z
75
- .string()
76
- .refine(isBase64, {
77
- message: 'Must be a valid base64 encoded string',
78
- })
79
- .openapi({
80
- example: 'eyJpdiI6InhhTFIyVG9ETnhnUzQ1QzUyNzRJenc9PSIsI',
81
- }),
82
- });
83
-
84
- export const IChangePasswordBodyZod = z
85
- .object({
86
- currentPassword: z.string().min(6).openapi({
87
- example: 'Secretpassword6#',
88
- }),
89
- newPassword: PasswordSchema,
90
- newPasswordConfirm: PasswordSchema,
91
- })
92
- .refine((data) => data.currentPassword !== data.newPassword, {
93
- message: 'New password must be different from current password',
94
- path: ['newPassword'],
95
- })
96
- .refine((data) => data.newPassword === data.newPasswordConfirm, {
97
- message: 'Password confirmation does not match new password',
98
- path: ['newPasswordConfirm'],
99
- });
100
-
101
- export const LoginBody = z.object({
102
- email: z
103
- .string()
104
- .email()
105
- .transform((val) => val.toLowerCase())
106
- .openapi({
107
- example: 'neil@dalmoregroup.com',
108
- }),
109
- password: z.string().openapi({
110
- example: 'Secretpassword6#',
111
- }),
112
- rememberMe: z.boolean().optional().default(false).openapi({
113
- example: true,
114
- }),
115
- twoFactorMethod: z.nativeEnum(TwoFactorMethod).optional().openapi({
116
- example: 'SMS',
117
- }),
118
- });
119
- export type LoginBody = z.infer<typeof LoginBody>;
120
-
121
- export const LoginBody2FA = z.object({
122
- token: z.string().min(6).max(14).openapi({
123
- example: 'neil@dalmoregroup.com',
124
- }),
125
- temporaryToken: z.string().min(1).openapi({
126
- example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
127
- }),
128
- rememberMe: z.boolean().optional().default(false).openapi({
129
- example: true,
130
- }),
131
- });
132
- export type LoginBody2FA = z.infer<typeof LoginBody>;
133
-
134
- export const LoginBodyInvestors = LoginBody.extend({
135
- site: z.string().openapi({ site: 'example.com' }),
136
- });
137
- export type LoginBodyInvestors = z.infer<typeof LoginBodyInvestors>;
138
-
139
- export const LoginBodyIssuers = LoginBody.extend({
140
- accountId: accountIdSchema.openapi({
141
- accountId: 'account_00041061050r3gg28a1c60t3gf',
142
- }),
143
- });
144
- export type LoginBodyIssuers = z.infer<typeof LoginBodyIssuers>;
145
-
146
- export const SelectAccountIssuers = LoginBody;
147
- export type SelectAccountIssuers = z.infer<typeof SelectAccountIssuers>;
148
-
149
- export const SelectAccountIssuersResponse = z.object({
150
- invites: z.array(
151
- z.object({
152
- id: inviteIdSchema.openapi({
153
- example: 'invite_00041061050r3gg28a1c60t3gf',
154
- }),
155
- name: z.string().openapi({ example: 'Example Account' }),
156
- accountId: accountIdSchema.nullable().openapi({
157
- example: 'account_00041061050r3gg28a1c60t3gf',
158
- }),
159
- role: z
160
- .nativeEnum(UserRole)
161
- .nullable()
162
- .openapi({ example: UserRole.MARKETER }),
163
- }),
164
- ),
165
- accounts: z.array(
166
- z.object({
167
- id: accountIdSchema.openapi({
168
- example: 'account_00041061050r3gg28a1c60t3gf',
169
- }),
170
- name: z.string().openapi({ example: 'Example Account' }),
171
- firstName: z.string().openapi({ example: 'John' }),
172
- lastName: z.string().openapi({ example: 'Doe' }),
173
- }),
174
- ),
175
- });
176
- export type SelectAccountIssuersResponse = z.infer<
177
- typeof SelectAccountIssuersResponse
178
- >;
179
-
180
- export const SwitchAccountIssuersBody = z.object({
181
- accountId: accountIdSchema,
182
- });
183
- export type SwitchAccountIssuersBody = z.infer<typeof SwitchAccountIssuersBody>;
184
-
185
- export const AccessTokenResponse = z.object({
186
- accessToken: z.string().optional().openapi({
187
- example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
188
- }),
189
- requiresTwoFactor: z.boolean().optional().openapi({
190
- example: true,
191
- }),
192
- temporaryToken: z.string().optional().openapi({
193
- example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
194
- }),
195
- requiresTwoFactorSetup: z.boolean().optional().openapi({
196
- example: true,
197
- }),
198
- twoFactorMethod: z.nativeEnum(TwoFactorMethod).optional().openapi({
199
- example: 'SMS',
200
- }),
201
- });
202
- export type AccessTokenResponse = z.infer<typeof AccessTokenResponse>;
203
-
204
- // Base schema for issuer registration (shared fields without refinements)
205
- const BaseRegisterIssuerFields = BaseAuthBody.extend({
206
- confirmPassword: PasswordSchema,
207
- accountName: z
208
- .string()
209
- .min(1)
210
- .max(150)
211
- .openapi({
212
- example: 'Example Account',
213
- })
214
- .nullable()
215
- .optional(),
216
- accountType: z
217
- .nativeEnum(ManagedByType)
218
- .optional()
219
- .default(ManagedByType.DALMORE)
220
- .openapi({
221
- example: ManagedByType.DALMORE,
222
- }),
223
- });
224
-
225
- // Full issuer registration schema with code (for invite-based registration)
226
- export const IRegisterIssuerBodyZod = BaseRegisterIssuerFields.extend({
227
- code: z
228
- .string()
229
- .refine(isBase64, {
230
- message: 'Must be a valid base64 encoded string',
231
- })
232
- .optional()
233
- .openapi({
234
- example: 'eyJpdiI6InhhTFIyVG9ETnhnUzQ1QzUyNzRJenc9PSIsI',
235
- }),
236
- })
237
- .refine((data) => data.password === data.confirmPassword, {
238
- message: 'Passwords do not match',
239
- path: ['confirmPassword'],
240
- })
241
- .refine(
242
- (data) => {
243
- // If code is not provided, accountName must be present and not empty/null
244
- if (!data.code || data.code.length === 0) {
245
- return (
246
- data.accountName !== null &&
247
- data.accountName !== undefined &&
248
- data.accountName !== ''
249
- );
250
- }
251
- // If code is provided, accountName is not required
252
- return true;
253
- },
254
- {
255
- message: 'Account name is required if code is not provided',
256
- path: ['accountName'],
257
- },
258
- );
259
-
260
- // Client issuer registration schema without code (for API key registration)
261
- export const IRegisterClientIssuerBodyZod = BaseRegisterIssuerFields.refine(
262
- (data) => data.password === data.confirmPassword,
263
- {
264
- message: 'Passwords do not match',
265
- path: ['confirmPassword'],
266
- },
267
- ).refine(
268
- (data) => {
269
- // For client registration, accountName is always required
270
- return (
271
- data.accountName !== null &&
272
- data.accountName !== undefined &&
273
- data.accountName !== ''
274
- );
275
- },
276
- {
277
- message: 'Account name is required',
278
- path: ['accountName'],
279
- },
280
- );
281
-
282
- // Investors are a special case in which they require phone number at the time of registration
283
- // The phone number provided here is NOT validated and will still need to go thru the regular 2FA setup process
284
- export const RegisterBodyInvestors = BaseAuthBody.extend({
285
- confirmPassword: PasswordSchema,
286
- phoneNumber: PhoneZodSchema.openapi({ example: '+12124567890' }).optional(),
287
- site: z
288
- .string()
289
- .min(2, 'site is less than 2 characters')
290
- .max(253, 'site is more than 253 characters')
291
- .openapi({
292
- example: 'func.co',
293
- }),
294
- }).refine((data) => data.password === data.confirmPassword, {
295
- message: 'Passwords do not match',
296
- path: ['confirmPassword'],
297
- });
298
-
299
- export const ResetPasswordVerifyBody = z.object({
300
- email: z.string().email(),
301
- code: z.string().length(6, 'code is not 6 characters').openapi({
302
- example: '123456',
303
- }),
304
- });
305
-
306
- export type ResetPasswordVerifyBodyType = z.infer<
307
- typeof ResetPasswordVerifyBody
308
- >;
309
- export const ResetPasswordVerifyResponse = z.object({
310
- valid: z.boolean(),
311
- });
312
-
313
- export type ResetPasswordVerifyResponseType = z.infer<
314
- typeof ResetPasswordVerifyResponse
315
- >;
316
-
317
- export const ResetPasswordBody = z.object({
318
- email: z.string().email(),
319
- code: z.string().length(6, 'code is not 6 characters').openapi({
320
- example: '123456',
321
- }),
322
- password: PasswordSchema,
323
- });
324
- export type ResetPasswordBodyType = z.infer<typeof ResetPasswordBody>;
325
-
326
- export const AuthSuccessResponse = z.object({
327
- success: z.boolean(),
328
- });
329
- export type AuthSuccessResponseType = z.infer<typeof AuthSuccessResponse>;
330
-
331
- export const ClientAuthSuccessResponse = z.object({
332
- userId: z.string().openapi({ example: 'user_01je6ht4b8fbmttkzh2hs82xqp' }),
333
- });
334
-
335
- export type ClientAuthSuccessResponse = z.infer<
336
- typeof ClientAuthSuccessResponse
337
- >;
338
-
339
- export const AdminForgotPasswordRequestZod = z.object({
340
- email: z.string().email(),
341
- portal: z.nativeEnum(PortalType),
342
- });
343
- export type AdminForgotPasswordRequestZod = z.infer<
344
- typeof AdminForgotPasswordRequestZod
345
- >;
346
-
347
- export const InvestorForgotPasswordRequestZod = z.object({
348
- email: z.string().email(),
349
- url: createUrlSchema({ strict: true }),
350
- });
351
- export type InvestorForgotPasswordRequestZod = z.infer<
352
- typeof InvestorForgotPasswordRequestZod
353
- >;
354
-
355
- // Define paths that should be accessible EVEN with twoFactorPending
356
- export const twoFactorPendingAllowedPaths = [
357
- '/auth/login',
358
- '/auth/register',
359
- '/user-settings/valid-phone-number',
360
- '/user-settings/setup-phone-number',
361
- '/user-settings/verify-phone-number',
362
- '/user-settings/send-verification-code',
363
- '/user-settings/setup-authenticator',
364
- '/user-settings/verify-authenticator',
365
- ];
366
-
367
- export const lockedUserAllowedPathsAndMethods = [
368
- { path: '/users/me', method: 'GET' },
369
- { path: '/auth/login', method: 'POST' },
370
- ];