@dalmore/api-contracts 1.0.2 → 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 (295) hide show
  1. package/README.md +34 -55
  2. package/index.d.mts +17 -0
  3. package/index.d.ts +17 -0
  4. package/index.mjs +10970 -0
  5. package/package.json +10 -46
  6. package/common/helpers/index.ts +0 -205
  7. package/common/types/account-contact.types.ts +0 -98
  8. package/common/types/account-detail.types.ts +0 -27
  9. package/common/types/account-integration.types.ts +0 -143
  10. package/common/types/account-manager.types.ts +0 -124
  11. package/common/types/account.types.ts +0 -296
  12. package/common/types/activity.types.ts +0 -274
  13. package/common/types/address.types.ts +0 -41
  14. package/common/types/aic.types.ts +0 -246
  15. package/common/types/aml.types.ts +0 -18
  16. package/common/types/api-key-logs.types.ts +0 -66
  17. package/common/types/api-keys.types.ts +0 -69
  18. package/common/types/asset.types.ts +0 -338
  19. package/common/types/auth.types.ts +0 -370
  20. package/common/types/batch-jobs.types.ts +0 -150
  21. package/common/types/bonus-tier.types.ts +0 -147
  22. package/common/types/cart.types.ts +0 -18
  23. package/common/types/checklist-items.types.ts +0 -70
  24. package/common/types/checklist.types.ts +0 -97
  25. package/common/types/common.types.ts +0 -1520
  26. package/common/types/comply-advantage-api.types.ts +0 -316
  27. package/common/types/comply-advantage.types.ts +0 -25
  28. package/common/types/contact-us.types.ts +0 -107
  29. package/common/types/contract-helpers.ts +0 -205
  30. package/common/types/countries.types.ts +0 -375
  31. package/common/types/covered-person.types.ts +0 -274
  32. package/common/types/dashboard.types.ts +0 -799
  33. package/common/types/data-record.types.ts +0 -325
  34. package/common/types/data-room.types.ts +0 -242
  35. package/common/types/default-theme-config.types.ts +0 -87
  36. package/common/types/disbursement-adjustment.types.ts +0 -32
  37. package/common/types/disbursement-approval-user.types.ts +0 -100
  38. package/common/types/disbursement-review.types.ts +0 -110
  39. package/common/types/disbursement-transaction.types.ts +0 -72
  40. package/common/types/disbursements.types.ts +0 -310
  41. package/common/types/domain-filter.types.ts +0 -55
  42. package/common/types/email-theme.types.ts +0 -442
  43. package/common/types/entity.types.ts +0 -15
  44. package/common/types/error-responses.types.ts +0 -135
  45. package/common/types/escrow-account.types.ts +0 -104
  46. package/common/types/exchange-api-key.types.ts +0 -121
  47. package/common/types/exchange-import.types.ts +0 -36
  48. package/common/types/exchange-provider.types.ts +0 -329
  49. package/common/types/file.types.ts +0 -461
  50. package/common/types/health.types.ts +0 -29
  51. package/common/types/index.ts +0 -48
  52. package/common/types/individuals.types.ts +0 -554
  53. package/common/types/investor-account.types.ts +0 -1239
  54. package/common/types/investorAccountIdSchema.type.ts +0 -0
  55. package/common/types/investors-offering.types.ts +0 -65
  56. package/common/types/invite.types.ts +0 -133
  57. package/common/types/issuer-bank-account.types.ts +0 -107
  58. package/common/types/issuer-offering.types.ts +0 -306
  59. package/common/types/issuer-payment-method.types.ts +0 -341
  60. package/common/types/issuer.types.ts +0 -312
  61. package/common/types/job-item.types.ts +0 -119
  62. package/common/types/jobs.types.ts +0 -171
  63. package/common/types/kyb.types.ts +0 -53
  64. package/common/types/kyc.types.ts +0 -188
  65. package/common/types/legal-entity.types.ts +0 -185
  66. package/common/types/login-history.types.ts +0 -46
  67. package/common/types/mail-template.types.ts +0 -436
  68. package/common/types/north-cap-integration.types.ts +0 -190
  69. package/common/types/note.types.ts +0 -109
  70. package/common/types/notification.types.ts +0 -58
  71. package/common/types/notion-api.types.ts +0 -374
  72. package/common/types/notion-database.types.ts +0 -125
  73. package/common/types/notion-page.types.ts +0 -267
  74. package/common/types/offering-reports.types.ts +0 -153
  75. package/common/types/offering-submission.types.ts +0 -314
  76. package/common/types/offering.types.ts +0 -590
  77. package/common/types/page-revision.types.ts +0 -86
  78. package/common/types/page.types.ts +0 -436
  79. package/common/types/password.type.ts +0 -15
  80. package/common/types/payment-methods.types.ts +0 -298
  81. package/common/types/phone.type.ts +0 -27
  82. package/common/types/portfolio.types.ts +0 -50
  83. package/common/types/privacy-policy-and-tos.types.ts +0 -231
  84. package/common/types/queue.types.ts +0 -111
  85. package/common/types/registered-reps.types.ts +0 -25
  86. package/common/types/rejection-reasons.types.ts +0 -56
  87. package/common/types/review.types.ts +0 -133
  88. package/common/types/role.types.ts +0 -26
  89. package/common/types/secondary-customer.types.ts +0 -66
  90. package/common/types/secondary-issuer.types.ts +0 -50
  91. package/common/types/secondary-order.types.ts +0 -58
  92. package/common/types/secondary-security.types.ts +0 -60
  93. package/common/types/secondary-trade.entity.ts +0 -16
  94. package/common/types/secondary-trade.types.ts +0 -95
  95. package/common/types/secure-request.types.ts +0 -68
  96. package/common/types/signer.types.ts +0 -651
  97. package/common/types/site-link.types.ts +0 -166
  98. package/common/types/site-settings.types.ts +0 -726
  99. package/common/types/site.types.ts +0 -270
  100. package/common/types/sms.types.ts +0 -30
  101. package/common/types/state-machine.types.ts +0 -177
  102. package/common/types/states.types.ts +0 -163
  103. package/common/types/subdoc-preview.types.ts +0 -35
  104. package/common/types/task.types.ts +0 -258
  105. package/common/types/trade-adjustment.type.ts +0 -33
  106. package/common/types/trade-line-item.type.ts +0 -132
  107. package/common/types/trade.types.ts +0 -931
  108. package/common/types/transaction.types.ts +0 -198
  109. package/common/types/trusted-contact.types.ts +0 -122
  110. package/common/types/typography.types.ts +0 -75
  111. package/common/types/user-manual.types.ts +0 -290
  112. package/common/types/user-setting.types.ts +0 -133
  113. package/common/types/user.types.ts +0 -320
  114. package/common/types/webhook.types.ts +0 -588
  115. package/common/types/zip.type.ts +0 -36
  116. package/contracts/clients/accounts/index.ts +0 -61
  117. package/contracts/clients/aic/index.ts +0 -59
  118. package/contracts/clients/api-key-logs/index.ts +0 -53
  119. package/contracts/clients/api-keys/index.ts +0 -73
  120. package/contracts/clients/assets/index.ts +0 -102
  121. package/contracts/clients/auth/index.ts +0 -50
  122. package/contracts/clients/files/index.ts +0 -166
  123. package/contracts/clients/files-public/index.ts +0 -166
  124. package/contracts/clients/index.ts +0 -44
  125. package/contracts/clients/individuals/index.ts +0 -93
  126. package/contracts/clients/investor-accounts/index.ts +0 -93
  127. package/contracts/clients/issuers/index.ts +0 -94
  128. package/contracts/clients/legal-entities/index.ts +0 -93
  129. package/contracts/clients/offerings/index.ts +0 -117
  130. package/contracts/clients/secure-requests/index.ts +0 -34
  131. package/contracts/clients/sites/index.ts +0 -56
  132. package/contracts/clients/trades/index.ts +0 -122
  133. package/contracts/compliance/account-contacts/index.ts +0 -82
  134. package/contracts/compliance/account-managers/index.ts +0 -142
  135. package/contracts/compliance/accounts/index.ts +0 -187
  136. package/contracts/compliance/activities/index.ts +0 -55
  137. package/contracts/compliance/aic/index.ts +0 -60
  138. package/contracts/compliance/api-keys/index.ts +0 -91
  139. package/contracts/compliance/assets/index.ts +0 -122
  140. package/contracts/compliance/auth/index.ts +0 -134
  141. package/contracts/compliance/batch-jobs/index.ts +0 -62
  142. package/contracts/compliance/bonus-tiers/index.ts +0 -55
  143. package/contracts/compliance/checklist/index.ts +0 -87
  144. package/contracts/compliance/checklist-items/index.ts +0 -86
  145. package/contracts/compliance/covered-persons/index.ts +0 -97
  146. package/contracts/compliance/dashboard/index.ts +0 -111
  147. package/contracts/compliance/data-records/index.ts +0 -116
  148. package/contracts/compliance/data-rooms/index.ts +0 -113
  149. package/contracts/compliance/default-theme-configs/index.ts +0 -95
  150. package/contracts/compliance/disbursement/index.ts +0 -165
  151. package/contracts/compliance/disbursement-approval-users/index.ts +0 -84
  152. package/contracts/compliance/disbursement-transactions/index.ts +0 -37
  153. package/contracts/compliance/domain-filters/index.ts +0 -117
  154. package/contracts/compliance/email-themes/index.ts +0 -284
  155. package/contracts/compliance/escrow-accounts/index.ts +0 -85
  156. package/contracts/compliance/exchange-api-keys/index.ts +0 -129
  157. package/contracts/compliance/exchange-imports/index.ts +0 -137
  158. package/contracts/compliance/files/index.ts +0 -267
  159. package/contracts/compliance/files-public/index.ts +0 -188
  160. package/contracts/compliance/health/index.ts +0 -26
  161. package/contracts/compliance/index.ts +0 -147
  162. package/contracts/compliance/individuals/index.ts +0 -57
  163. package/contracts/compliance/investor-accounts/index.ts +0 -141
  164. package/contracts/compliance/invites/index.ts +0 -137
  165. package/contracts/compliance/issuer-bank-accounts/index.ts +0 -81
  166. package/contracts/compliance/issuer-payment-methods/index.ts +0 -81
  167. package/contracts/compliance/issuers/index.ts +0 -97
  168. package/contracts/compliance/job-items/index.ts +0 -58
  169. package/contracts/compliance/jobs/index.ts +0 -59
  170. package/contracts/compliance/kyb/index.ts +0 -54
  171. package/contracts/compliance/kyc/index.ts +0 -77
  172. package/contracts/compliance/legal-entities/index.ts +0 -57
  173. package/contracts/compliance/login-histories/index.ts +0 -37
  174. package/contracts/compliance/notes/index.ts +0 -69
  175. package/contracts/compliance/notion-databases/index.ts +0 -107
  176. package/contracts/compliance/notion-pages/index.ts +0 -105
  177. package/contracts/compliance/offering-reports/index.ts +0 -149
  178. package/contracts/compliance/offerings/index.ts +0 -233
  179. package/contracts/compliance/pages/index.ts +0 -178
  180. package/contracts/compliance/payment-methods/index.ts +0 -57
  181. package/contracts/compliance/rejection-reasons/index.ts +0 -32
  182. package/contracts/compliance/review/index.ts +0 -169
  183. package/contracts/compliance/roles/index.ts +0 -34
  184. package/contracts/compliance/secondary-customers/index.ts +0 -77
  185. package/contracts/compliance/secondary-orders/index.ts +0 -60
  186. package/contracts/compliance/secondary-trades/index.ts +0 -100
  187. package/contracts/compliance/secure-requests/index.ts +0 -54
  188. package/contracts/compliance/signer/index.ts +0 -369
  189. package/contracts/compliance/site-links/index.ts +0 -128
  190. package/contracts/compliance/site-settings/index.ts +0 -669
  191. package/contracts/compliance/sites/index.ts +0 -56
  192. package/contracts/compliance/state-machine/index.ts +0 -94
  193. package/contracts/compliance/tasks/index.ts +0 -91
  194. package/contracts/compliance/third-parties/index.ts +0 -52
  195. package/contracts/compliance/trade-line-items/index.ts +0 -59
  196. package/contracts/compliance/trades/index.ts +0 -230
  197. package/contracts/compliance/transactions/index.ts +0 -161
  198. package/contracts/compliance/user-manuals/index.ts +0 -271
  199. package/contracts/compliance/user-settings/index.ts +0 -189
  200. package/contracts/compliance/users/index.ts +0 -200
  201. package/contracts/compliance/webhooks/index.ts +0 -41
  202. package/contracts/compliance-apikey/accounts/index.ts +0 -58
  203. package/contracts/compliance-apikey/index.ts +0 -14
  204. package/contracts/index.ts +0 -6
  205. package/contracts/investors/account-contacts/index.ts +0 -58
  206. package/contracts/investors/aic/index.ts +0 -59
  207. package/contracts/investors/assets/index.ts +0 -61
  208. package/contracts/investors/auth/index.ts +0 -116
  209. package/contracts/investors/bonus-tiers/index.ts +0 -37
  210. package/contracts/investors/cart/index.ts +0 -75
  211. package/contracts/investors/contact-us/index.ts +0 -48
  212. package/contracts/investors/data-records/index.ts +0 -113
  213. package/contracts/investors/data-rooms/index.ts +0 -96
  214. package/contracts/investors/files/index.ts +0 -167
  215. package/contracts/investors/files-public/index.ts +0 -185
  216. package/contracts/investors/index.ts +0 -72
  217. package/contracts/investors/individuals/index.ts +0 -99
  218. package/contracts/investors/investor-accounts/index.ts +0 -110
  219. package/contracts/investors/issuer-payment-methods/index.ts +0 -36
  220. package/contracts/investors/issuers/index.ts +0 -30
  221. package/contracts/investors/legal-entities/index.ts +0 -93
  222. package/contracts/investors/notes/index.ts +0 -69
  223. package/contracts/investors/offerings/index.ts +0 -93
  224. package/contracts/investors/pages/index.ts +0 -88
  225. package/contracts/investors/payment-methods/index.ts +0 -149
  226. package/contracts/investors/portfolios/index.ts +0 -53
  227. package/contracts/investors/sites/index.ts +0 -96
  228. package/contracts/investors/tasks/index.ts +0 -111
  229. package/contracts/investors/trade-line-items/index.ts +0 -75
  230. package/contracts/investors/trades/index.ts +0 -114
  231. package/contracts/investors/transactions/index.ts +0 -37
  232. package/contracts/investors/trusted-contacts/index.ts +0 -93
  233. package/contracts/investors/user-manuals/index.ts +0 -62
  234. package/contracts/investors/user-settings/index.ts +0 -170
  235. package/contracts/investors/users/index.ts +0 -45
  236. package/contracts/investors/webhooks/index.ts +0 -30
  237. package/contracts/issuers/account-contacts/index.ts +0 -76
  238. package/contracts/issuers/account-integrations/index.ts +0 -97
  239. package/contracts/issuers/accounts/index.ts +0 -97
  240. package/contracts/issuers/activities/index.ts +0 -54
  241. package/contracts/issuers/aic/index.ts +0 -39
  242. package/contracts/issuers/api-key-logs/index.ts +0 -53
  243. package/contracts/issuers/api-keys/index.ts +0 -93
  244. package/contracts/issuers/assets/index.ts +0 -122
  245. package/contracts/issuers/auth/index.ts +0 -152
  246. package/contracts/issuers/bonus-tiers/index.ts +0 -55
  247. package/contracts/issuers/contact-us/index.ts +0 -48
  248. package/contracts/issuers/covered-persons/index.ts +0 -136
  249. package/contracts/issuers/dashboard/index.ts +0 -72
  250. package/contracts/issuers/data-records/index.ts +0 -257
  251. package/contracts/issuers/data-rooms/index.ts +0 -134
  252. package/contracts/issuers/disbursement-approval-users/index.ts +0 -82
  253. package/contracts/issuers/disbursement-transactions/index.ts +0 -53
  254. package/contracts/issuers/disbursements/index.ts +0 -153
  255. package/contracts/issuers/email-themes/index.ts +0 -242
  256. package/contracts/issuers/escrow-accounts/index.ts +0 -81
  257. package/contracts/issuers/exchange-api-keys/index.ts +0 -144
  258. package/contracts/issuers/files/index.ts +0 -166
  259. package/contracts/issuers/files-public/index.ts +0 -166
  260. package/contracts/issuers/health/index.ts +0 -24
  261. package/contracts/issuers/index.ts +0 -112
  262. package/contracts/issuers/investor-accounts/index.ts +0 -148
  263. package/contracts/issuers/invites/index.ts +0 -129
  264. package/contracts/issuers/issuer/index.ts +0 -94
  265. package/contracts/issuers/issuer-bank-accounts/index.ts +0 -81
  266. package/contracts/issuers/issuer-payment-methods/index.ts +0 -136
  267. package/contracts/issuers/kyc/index.ts +0 -38
  268. package/contracts/issuers/login-histories/index.ts +0 -51
  269. package/contracts/issuers/notes/index.ts +0 -69
  270. package/contracts/issuers/offerings/index.ts +0 -206
  271. package/contracts/issuers/pages/index.ts +0 -138
  272. package/contracts/issuers/payment-methods/index.ts +0 -61
  273. package/contracts/issuers/portfolios/index.ts +0 -36
  274. package/contracts/issuers/rejection-reasons/index.ts +0 -32
  275. package/contracts/issuers/review/index.ts +0 -63
  276. package/contracts/issuers/secondary-customers/index.ts +0 -55
  277. package/contracts/issuers/secondary-orders/index.ts +0 -57
  278. package/contracts/issuers/secondary-trades/index.ts +0 -57
  279. package/contracts/issuers/secure-requests/index.ts +0 -34
  280. package/contracts/issuers/site-links/index.ts +0 -116
  281. package/contracts/issuers/site-settings/index.ts +0 -585
  282. package/contracts/issuers/sites/index.ts +0 -32
  283. package/contracts/issuers/tasks/index.ts +0 -111
  284. package/contracts/issuers/trades/index.ts +0 -132
  285. package/contracts/issuers/transactions/index.ts +0 -158
  286. package/contracts/issuers/user-manuals/index.ts +0 -62
  287. package/contracts/issuers/user-settings/index.ts +0 -170
  288. package/contracts/issuers/users/index.ts +0 -126
  289. package/contracts/secondaries/accounts/index.ts +0 -58
  290. package/contracts/secondaries/index.ts +0 -23
  291. package/contracts/secondaries/secondary-customers/index.ts +0 -55
  292. package/contracts/secondaries/secondary-issuers/index.ts +0 -94
  293. package/contracts/secondaries/secondary-orders/index.ts +0 -56
  294. package/contracts/secondaries/secondary-securities/index.ts +0 -95
  295. package/contracts/secondaries/secondary-trades/index.ts +0 -56
@@ -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
- ];