@dalmore/api-contracts 0.0.0-dev.0c67bc1

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 (296) hide show
  1. package/README.md +79 -0
  2. package/common/helpers/index.ts +59 -0
  3. package/common/types/account-contact.types.ts +98 -0
  4. package/common/types/account-detail.types.ts +27 -0
  5. package/common/types/account-integration.types.ts +143 -0
  6. package/common/types/account-manager.types.ts +124 -0
  7. package/common/types/account.types.ts +296 -0
  8. package/common/types/activity.types.ts +274 -0
  9. package/common/types/address.types.ts +41 -0
  10. package/common/types/aic.types.ts +246 -0
  11. package/common/types/aml.types.ts +18 -0
  12. package/common/types/api-key-logs.types.ts +66 -0
  13. package/common/types/api-keys.types.ts +69 -0
  14. package/common/types/asset.types.ts +338 -0
  15. package/common/types/auth.types.ts +370 -0
  16. package/common/types/batch-jobs.types.ts +151 -0
  17. package/common/types/bonus-tier.types.ts +147 -0
  18. package/common/types/cart.types.ts +18 -0
  19. package/common/types/checklist-items.types.ts +70 -0
  20. package/common/types/checklist.types.ts +97 -0
  21. package/common/types/common.types.ts +1520 -0
  22. package/common/types/comply-advantage-api.types.ts +316 -0
  23. package/common/types/comply-advantage.types.ts +25 -0
  24. package/common/types/contact-us.types.ts +107 -0
  25. package/common/types/countries.types.ts +375 -0
  26. package/common/types/covered-person.types.ts +274 -0
  27. package/common/types/dashboard.types.ts +799 -0
  28. package/common/types/data-record.types.ts +325 -0
  29. package/common/types/data-room.types.ts +242 -0
  30. package/common/types/default-theme-config.types.ts +87 -0
  31. package/common/types/disbursement-adjustment.types.ts +32 -0
  32. package/common/types/disbursement-approval-user.types.ts +100 -0
  33. package/common/types/disbursement-review.types.ts +110 -0
  34. package/common/types/disbursement-transaction.types.ts +72 -0
  35. package/common/types/disbursements.types.ts +332 -0
  36. package/common/types/domain-filter.types.ts +55 -0
  37. package/common/types/email-theme.types.ts +442 -0
  38. package/common/types/entity.types.ts +15 -0
  39. package/common/types/error-responses.types.ts +135 -0
  40. package/common/types/escrow-account.types.ts +104 -0
  41. package/common/types/exchange-api-key.types.ts +121 -0
  42. package/common/types/exchange-import.types.ts +36 -0
  43. package/common/types/exchange-provider.types.ts +329 -0
  44. package/common/types/file.types.ts +461 -0
  45. package/common/types/health.types.ts +29 -0
  46. package/common/types/index.ts +49 -0
  47. package/common/types/individuals.types.ts +554 -0
  48. package/common/types/investor-account.types.ts +1239 -0
  49. package/common/types/investorAccountIdSchema.type.ts +0 -0
  50. package/common/types/investors-offering.types.ts +65 -0
  51. package/common/types/invite.types.ts +133 -0
  52. package/common/types/issuer-bank-account.types.ts +107 -0
  53. package/common/types/issuer-offering.types.ts +393 -0
  54. package/common/types/issuer-payment-method.types.ts +382 -0
  55. package/common/types/issuer.types.ts +321 -0
  56. package/common/types/job-item.types.ts +119 -0
  57. package/common/types/jobs.types.ts +171 -0
  58. package/common/types/kyb.types.ts +53 -0
  59. package/common/types/kyc.types.ts +188 -0
  60. package/common/types/legal-entity.types.ts +185 -0
  61. package/common/types/login-history.types.ts +46 -0
  62. package/common/types/mail-template.types.ts +436 -0
  63. package/common/types/north-cap-integration.types.ts +190 -0
  64. package/common/types/note.types.ts +109 -0
  65. package/common/types/notification.types.ts +58 -0
  66. package/common/types/notion-api.types.ts +374 -0
  67. package/common/types/notion-database.types.ts +125 -0
  68. package/common/types/notion-page.types.ts +267 -0
  69. package/common/types/offering-reports.types.ts +153 -0
  70. package/common/types/offering-submission.types.ts +314 -0
  71. package/common/types/offering.types.ts +681 -0
  72. package/common/types/page-revision.types.ts +86 -0
  73. package/common/types/page.types.ts +436 -0
  74. package/common/types/password.type.ts +15 -0
  75. package/common/types/payment-methods.types.ts +298 -0
  76. package/common/types/phone.type.ts +27 -0
  77. package/common/types/portfolio.types.ts +50 -0
  78. package/common/types/privacy-policy-and-tos.types.ts +231 -0
  79. package/common/types/queue.types.ts +112 -0
  80. package/common/types/registered-reps.types.ts +25 -0
  81. package/common/types/rejection-reasons.types.ts +56 -0
  82. package/common/types/reminder-config.types.ts +40 -0
  83. package/common/types/review.types.ts +133 -0
  84. package/common/types/role.types.ts +26 -0
  85. package/common/types/secondary-customer.types.ts +66 -0
  86. package/common/types/secondary-issuer.types.ts +50 -0
  87. package/common/types/secondary-order.types.ts +58 -0
  88. package/common/types/secondary-security.types.ts +60 -0
  89. package/common/types/secondary-trade.entity.ts +16 -0
  90. package/common/types/secondary-trade.types.ts +95 -0
  91. package/common/types/secure-request.types.ts +68 -0
  92. package/common/types/signer.types.ts +651 -0
  93. package/common/types/site-link.types.ts +166 -0
  94. package/common/types/site-settings.types.ts +726 -0
  95. package/common/types/site.types.ts +270 -0
  96. package/common/types/sms.types.ts +30 -0
  97. package/common/types/state-machine.types.ts +177 -0
  98. package/common/types/states.types.ts +163 -0
  99. package/common/types/subdoc-preview.types.ts +35 -0
  100. package/common/types/task.types.ts +258 -0
  101. package/common/types/trade-adjustment.type.ts +33 -0
  102. package/common/types/trade-line-item.type.ts +132 -0
  103. package/common/types/trade.types.ts +999 -0
  104. package/common/types/transaction.types.ts +198 -0
  105. package/common/types/trusted-contact.types.ts +122 -0
  106. package/common/types/typography.types.ts +75 -0
  107. package/common/types/user-manual.types.ts +290 -0
  108. package/common/types/user-setting.types.ts +133 -0
  109. package/common/types/user.types.ts +320 -0
  110. package/common/types/webhook.types.ts +588 -0
  111. package/common/types/zip.type.ts +36 -0
  112. package/contracts/clients/accounts/index.ts +61 -0
  113. package/contracts/clients/aic/index.ts +59 -0
  114. package/contracts/clients/api-key-logs/index.ts +53 -0
  115. package/contracts/clients/api-keys/index.ts +73 -0
  116. package/contracts/clients/assets/index.ts +102 -0
  117. package/contracts/clients/auth/index.ts +50 -0
  118. package/contracts/clients/cart/index.ts +60 -0
  119. package/contracts/clients/files/index.ts +166 -0
  120. package/contracts/clients/files-public/index.ts +166 -0
  121. package/contracts/clients/index.ts +52 -0
  122. package/contracts/clients/individuals/index.ts +93 -0
  123. package/contracts/clients/investor-accounts/index.ts +93 -0
  124. package/contracts/clients/issuer-payment-methods/index.ts +39 -0
  125. package/contracts/clients/issuers/index.ts +94 -0
  126. package/contracts/clients/legal-entities/index.ts +93 -0
  127. package/contracts/clients/offerings/index.ts +117 -0
  128. package/contracts/clients/payment-methods/index.ts +85 -0
  129. package/contracts/clients/secure-requests/index.ts +34 -0
  130. package/contracts/clients/sites/index.ts +56 -0
  131. package/contracts/clients/trade-line-items/index.ts +66 -0
  132. package/contracts/clients/trades/index.ts +186 -0
  133. package/contracts/compliance/account-contacts/index.ts +82 -0
  134. package/contracts/compliance/account-managers/index.ts +142 -0
  135. package/contracts/compliance/accounts/index.ts +187 -0
  136. package/contracts/compliance/activities/index.ts +55 -0
  137. package/contracts/compliance/aic/index.ts +60 -0
  138. package/contracts/compliance/api-keys/index.ts +91 -0
  139. package/contracts/compliance/assets/index.ts +122 -0
  140. package/contracts/compliance/auth/index.ts +134 -0
  141. package/contracts/compliance/batch-jobs/index.ts +62 -0
  142. package/contracts/compliance/bonus-tiers/index.ts +55 -0
  143. package/contracts/compliance/checklist/index.ts +87 -0
  144. package/contracts/compliance/checklist-items/index.ts +86 -0
  145. package/contracts/compliance/covered-persons/index.ts +97 -0
  146. package/contracts/compliance/dashboard/index.ts +111 -0
  147. package/contracts/compliance/data-records/index.ts +116 -0
  148. package/contracts/compliance/data-rooms/index.ts +113 -0
  149. package/contracts/compliance/default-theme-configs/index.ts +95 -0
  150. package/contracts/compliance/disbursement/index.ts +165 -0
  151. package/contracts/compliance/disbursement-approval-users/index.ts +84 -0
  152. package/contracts/compliance/disbursement-transactions/index.ts +37 -0
  153. package/contracts/compliance/domain-filters/index.ts +117 -0
  154. package/contracts/compliance/email-themes/index.ts +284 -0
  155. package/contracts/compliance/escrow-accounts/index.ts +85 -0
  156. package/contracts/compliance/exchange-api-keys/index.ts +129 -0
  157. package/contracts/compliance/exchange-imports/index.ts +137 -0
  158. package/contracts/compliance/files/index.ts +267 -0
  159. package/contracts/compliance/files-public/index.ts +188 -0
  160. package/contracts/compliance/health/index.ts +26 -0
  161. package/contracts/compliance/index.ts +147 -0
  162. package/contracts/compliance/individuals/index.ts +57 -0
  163. package/contracts/compliance/investor-accounts/index.ts +141 -0
  164. package/contracts/compliance/invites/index.ts +137 -0
  165. package/contracts/compliance/issuer-bank-accounts/index.ts +81 -0
  166. package/contracts/compliance/issuer-payment-methods/index.ts +81 -0
  167. package/contracts/compliance/issuers/index.ts +97 -0
  168. package/contracts/compliance/job-items/index.ts +58 -0
  169. package/contracts/compliance/jobs/index.ts +59 -0
  170. package/contracts/compliance/kyb/index.ts +54 -0
  171. package/contracts/compliance/kyc/index.ts +77 -0
  172. package/contracts/compliance/legal-entities/index.ts +57 -0
  173. package/contracts/compliance/login-histories/index.ts +37 -0
  174. package/contracts/compliance/notes/index.ts +69 -0
  175. package/contracts/compliance/notion-databases/index.ts +107 -0
  176. package/contracts/compliance/notion-pages/index.ts +105 -0
  177. package/contracts/compliance/offering-reports/index.ts +149 -0
  178. package/contracts/compliance/offerings/index.ts +233 -0
  179. package/contracts/compliance/pages/index.ts +178 -0
  180. package/contracts/compliance/payment-methods/index.ts +57 -0
  181. package/contracts/compliance/rejection-reasons/index.ts +32 -0
  182. package/contracts/compliance/review/index.ts +169 -0
  183. package/contracts/compliance/roles/index.ts +34 -0
  184. package/contracts/compliance/secondary-customers/index.ts +77 -0
  185. package/contracts/compliance/secondary-orders/index.ts +60 -0
  186. package/contracts/compliance/secondary-trades/index.ts +100 -0
  187. package/contracts/compliance/secure-requests/index.ts +54 -0
  188. package/contracts/compliance/signer/index.ts +369 -0
  189. package/contracts/compliance/site-links/index.ts +128 -0
  190. package/contracts/compliance/site-settings/index.ts +669 -0
  191. package/contracts/compliance/sites/index.ts +56 -0
  192. package/contracts/compliance/state-machine/index.ts +94 -0
  193. package/contracts/compliance/tasks/index.ts +91 -0
  194. package/contracts/compliance/third-parties/index.ts +52 -0
  195. package/contracts/compliance/trade-line-items/index.ts +59 -0
  196. package/contracts/compliance/trades/index.ts +230 -0
  197. package/contracts/compliance/transactions/index.ts +161 -0
  198. package/contracts/compliance/user-manuals/index.ts +271 -0
  199. package/contracts/compliance/user-settings/index.ts +189 -0
  200. package/contracts/compliance/users/index.ts +200 -0
  201. package/contracts/compliance/webhooks/index.ts +41 -0
  202. package/contracts/compliance-apikey/accounts/index.ts +58 -0
  203. package/contracts/compliance-apikey/index.ts +14 -0
  204. package/contracts/index.ts +6 -0
  205. package/contracts/investors/account-contacts/index.ts +58 -0
  206. package/contracts/investors/aic/index.ts +59 -0
  207. package/contracts/investors/assets/index.ts +61 -0
  208. package/contracts/investors/auth/index.ts +116 -0
  209. package/contracts/investors/bonus-tiers/index.ts +37 -0
  210. package/contracts/investors/cart/index.ts +75 -0
  211. package/contracts/investors/contact-us/index.ts +48 -0
  212. package/contracts/investors/data-records/index.ts +113 -0
  213. package/contracts/investors/data-rooms/index.ts +96 -0
  214. package/contracts/investors/files/index.ts +167 -0
  215. package/contracts/investors/files-public/index.ts +185 -0
  216. package/contracts/investors/index.ts +72 -0
  217. package/contracts/investors/individuals/index.ts +99 -0
  218. package/contracts/investors/investor-accounts/index.ts +110 -0
  219. package/contracts/investors/issuer-payment-methods/index.ts +36 -0
  220. package/contracts/investors/issuers/index.ts +30 -0
  221. package/contracts/investors/legal-entities/index.ts +93 -0
  222. package/contracts/investors/notes/index.ts +69 -0
  223. package/contracts/investors/offerings/index.ts +93 -0
  224. package/contracts/investors/pages/index.ts +88 -0
  225. package/contracts/investors/payment-methods/index.ts +149 -0
  226. package/contracts/investors/portfolios/index.ts +53 -0
  227. package/contracts/investors/sites/index.ts +96 -0
  228. package/contracts/investors/tasks/index.ts +111 -0
  229. package/contracts/investors/trade-line-items/index.ts +75 -0
  230. package/contracts/investors/trades/index.ts +114 -0
  231. package/contracts/investors/transactions/index.ts +37 -0
  232. package/contracts/investors/trusted-contacts/index.ts +93 -0
  233. package/contracts/investors/user-manuals/index.ts +62 -0
  234. package/contracts/investors/user-settings/index.ts +170 -0
  235. package/contracts/investors/users/index.ts +45 -0
  236. package/contracts/investors/webhooks/index.ts +30 -0
  237. package/contracts/issuers/account-contacts/index.ts +76 -0
  238. package/contracts/issuers/account-integrations/index.ts +97 -0
  239. package/contracts/issuers/accounts/index.ts +97 -0
  240. package/contracts/issuers/activities/index.ts +54 -0
  241. package/contracts/issuers/aic/index.ts +39 -0
  242. package/contracts/issuers/api-key-logs/index.ts +53 -0
  243. package/contracts/issuers/api-keys/index.ts +93 -0
  244. package/contracts/issuers/assets/index.ts +122 -0
  245. package/contracts/issuers/auth/index.ts +152 -0
  246. package/contracts/issuers/bonus-tiers/index.ts +55 -0
  247. package/contracts/issuers/contact-us/index.ts +48 -0
  248. package/contracts/issuers/covered-persons/index.ts +136 -0
  249. package/contracts/issuers/dashboard/index.ts +72 -0
  250. package/contracts/issuers/data-records/index.ts +257 -0
  251. package/contracts/issuers/data-rooms/index.ts +134 -0
  252. package/contracts/issuers/disbursement-approval-users/index.ts +82 -0
  253. package/contracts/issuers/disbursement-transactions/index.ts +53 -0
  254. package/contracts/issuers/disbursements/index.ts +171 -0
  255. package/contracts/issuers/email-themes/index.ts +242 -0
  256. package/contracts/issuers/escrow-accounts/index.ts +81 -0
  257. package/contracts/issuers/exchange-api-keys/index.ts +144 -0
  258. package/contracts/issuers/files/index.ts +166 -0
  259. package/contracts/issuers/files-public/index.ts +166 -0
  260. package/contracts/issuers/health/index.ts +24 -0
  261. package/contracts/issuers/index.ts +112 -0
  262. package/contracts/issuers/investor-accounts/index.ts +148 -0
  263. package/contracts/issuers/invites/index.ts +129 -0
  264. package/contracts/issuers/issuer/index.ts +94 -0
  265. package/contracts/issuers/issuer-bank-accounts/index.ts +81 -0
  266. package/contracts/issuers/issuer-payment-methods/index.ts +136 -0
  267. package/contracts/issuers/kyc/index.ts +38 -0
  268. package/contracts/issuers/login-histories/index.ts +51 -0
  269. package/contracts/issuers/notes/index.ts +69 -0
  270. package/contracts/issuers/offerings/index.ts +206 -0
  271. package/contracts/issuers/pages/index.ts +138 -0
  272. package/contracts/issuers/payment-methods/index.ts +61 -0
  273. package/contracts/issuers/portfolios/index.ts +36 -0
  274. package/contracts/issuers/rejection-reasons/index.ts +32 -0
  275. package/contracts/issuers/review/index.ts +63 -0
  276. package/contracts/issuers/secondary-customers/index.ts +55 -0
  277. package/contracts/issuers/secondary-orders/index.ts +57 -0
  278. package/contracts/issuers/secondary-trades/index.ts +57 -0
  279. package/contracts/issuers/secure-requests/index.ts +34 -0
  280. package/contracts/issuers/site-links/index.ts +116 -0
  281. package/contracts/issuers/site-settings/index.ts +585 -0
  282. package/contracts/issuers/sites/index.ts +32 -0
  283. package/contracts/issuers/tasks/index.ts +111 -0
  284. package/contracts/issuers/trades/index.ts +132 -0
  285. package/contracts/issuers/transactions/index.ts +158 -0
  286. package/contracts/issuers/user-manuals/index.ts +62 -0
  287. package/contracts/issuers/user-settings/index.ts +170 -0
  288. package/contracts/issuers/users/index.ts +126 -0
  289. package/contracts/secondaries/accounts/index.ts +58 -0
  290. package/contracts/secondaries/index.ts +23 -0
  291. package/contracts/secondaries/secondary-customers/index.ts +55 -0
  292. package/contracts/secondaries/secondary-issuers/index.ts +94 -0
  293. package/contracts/secondaries/secondary-orders/index.ts +56 -0
  294. package/contracts/secondaries/secondary-securities/index.ts +95 -0
  295. package/contracts/secondaries/secondary-trades/index.ts +56 -0
  296. package/package.json +77 -0
@@ -0,0 +1,681 @@
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
+ ComplianceReview,
8
+ dateSchema,
9
+ IPaginationMeta,
10
+ OfferingType,
11
+ ManagedByType,
12
+ PaginationOptionsZod,
13
+ UrlSchema,
14
+ SortOrder,
15
+ SortBy,
16
+ OfferingVersioningType,
17
+ OfferingOnboardingStatus,
18
+ AssetType,
19
+ DurationType,
20
+ } from './common.types';
21
+ import { IBaseEntity } from './entity.types';
22
+ import { fileIdSchema, FileZod } from './file.types';
23
+ import { IIssuer, issuerIdSchema } from './issuer.types';
24
+ import {
25
+ InvestorsOfferingFiltersZod,
26
+ InvestorsOfferingsIncludeQuery,
27
+ } from './investors-offering.types';
28
+ import { OfferingStatus } from './issuer-offering.types';
29
+ import { postAssetRefinement, AssetTemplateType } from './asset.types';
30
+
31
+ export enum OfferingFeeType {
32
+ FIXED = 'FIXED',
33
+ PERCENTAGE = 'PERCENTAGE',
34
+ }
35
+
36
+ extendZodWithOpenApi(z);
37
+
38
+ export const offeringIdSchema = z.string().refine(
39
+ (value) => {
40
+ try {
41
+ const tid = TypeID.fromString(value);
42
+ return tid.getType() === 'offering';
43
+ } catch {
44
+ return false;
45
+ }
46
+ },
47
+ {
48
+ message: `Invalid offering ID format. Must be a valid TypeID with "offering" prefix. Example: offering_01j5y5ghx5fg68d663j1fvy2x7`,
49
+ },
50
+ );
51
+ export const offeringRevisionIdSchema = z.string().refine(
52
+ (value) => {
53
+ try {
54
+ const tid = TypeID.fromString(value);
55
+ return tid.getType() === 'offering_revision';
56
+ } catch {
57
+ return false;
58
+ }
59
+ },
60
+ {
61
+ message: `Invalid offering revision ID format. Must be a valid TypeID with "offering_revision" prefix. Example: offering_revision_01j5y5ghx5fg68d663j1fvy2x7`,
62
+ },
63
+ );
64
+
65
+ export const OfferingPlatformSettings = z.object({
66
+ backOfficePortal: z.string(),
67
+ username: z.string().nullable(),
68
+ password: z.string().nullable(),
69
+ apiKey: z.string().nullable(),
70
+ });
71
+ export type OfferingPlatformSettings = z.infer<typeof OfferingPlatformSettings>;
72
+
73
+ export const IOffering = IBaseEntity.extend({
74
+ name: z.string(),
75
+ tid: z.string().nullable(),
76
+ type: z.nativeEnum(OfferingType).nullable(),
77
+ description: z.string().nullable(),
78
+ raiseAmount: z.number().nullable(),
79
+ targetAmount: z.number().nullable(),
80
+ minInvestment: z.number().nullable(),
81
+ maxInvestment: z.number().nullable(),
82
+ contingencyAmount: z.number().nullable(),
83
+ startAt: z.date().nullable(),
84
+ endAt: z.date().nullable(),
85
+ platform: z.string(),
86
+ platformSettings: z.string().nullable(),
87
+ enabled: z.boolean(),
88
+ accountId: z.string().nullable(),
89
+ account: AccountZod.optional().nullable(),
90
+ issuer: z
91
+ .lazy(() => IIssuer)
92
+ .optional()
93
+ .nullable(), // Use z.lazy here
94
+ issuerId: z.string().nullable(),
95
+ coverArtId: z
96
+ .lazy(() => fileIdSchema)
97
+ .nullable()
98
+ .optional(),
99
+ coverArt: z.lazy(() => FileZod).nullable(),
100
+ cancellationPeriod: z.number().nullable(),
101
+ memorandumId: z
102
+ .lazy(() => fileIdSchema)
103
+ .nullable()
104
+ .optional(),
105
+ subscriptionAgreementId: z
106
+ .lazy(() => fileIdSchema)
107
+ .nullable()
108
+ .optional(),
109
+ managedBy: z.nativeEnum(ManagedByType).nullable(),
110
+ valuationCap: z.number().nullable(),
111
+ showTotalRaised: z.boolean().optional(),
112
+ });
113
+ export type IOffering = z.infer<typeof IOffering>;
114
+
115
+ export const IPaginatedOffering = z.object({
116
+ items: z.array(IOffering),
117
+ meta: IPaginationMeta,
118
+ });
119
+ export type IPaginatedOffering = z.infer<typeof IPaginatedOffering>;
120
+
121
+ export const PatchOfferingBase = z.object({
122
+ name: z.string().optional(),
123
+ description: z.string().nullable().optional(),
124
+ tid: z.string().optional(),
125
+ type: z.nativeEnum(OfferingType).optional(),
126
+ targetAmount: z.number().min(0.01).max(10000000000).optional(),
127
+ raiseAmount: z
128
+ .number()
129
+ .min(0.01)
130
+ .max(10000000000)
131
+ .openapi({ example: 5000 })
132
+ .optional(),
133
+ minInvestment: z
134
+ .number()
135
+ .min(0.01)
136
+ .max(10000000000)
137
+ .openapi({ example: 5000 })
138
+ .optional()
139
+ .nullable(),
140
+ maxInvestment: z
141
+ .number()
142
+ .min(0.01)
143
+ .max(10000000000)
144
+ .openapi({ example: 5000 })
145
+ .optional()
146
+ .nullable(),
147
+ contingencyAmount: z
148
+ .number()
149
+ .min(0.0)
150
+ .max(10000000000)
151
+ .openapi({ example: 5000 })
152
+ .optional()
153
+ .nullable(),
154
+ startAt: dateSchema.optional().openapi({ example: '10/20/2024' }),
155
+ endAt: dateSchema.optional().openapi({ example: '10/27/2024' }),
156
+ platform: z.string().optional(),
157
+ coverArtId: z
158
+ .lazy(() => fileIdSchema)
159
+ .nullable()
160
+ .optional(),
161
+ platformSettings: OfferingPlatformSettings.optional().transform((val) =>
162
+ val ? JSON.stringify(val) : null,
163
+ ),
164
+ enabled: z.boolean().optional(),
165
+ entitySubscriptionAgreementTemplateId: z.string().optional().nullable(),
166
+ managedBy: z.nativeEnum(ManagedByType).optional(),
167
+ subscriptionAgreementTemplateId: z.string().optional().nullable(),
168
+ memorandumId: z
169
+ .lazy(() => fileIdSchema)
170
+ .nullable()
171
+ .optional(),
172
+ subscriptionAgreementId: z
173
+ .lazy(() => fileIdSchema)
174
+ .nullable()
175
+ .optional(),
176
+ jointSubscriptionAgreementTemplateId: z.string().optional().nullable(),
177
+ cancellationPeriod: z.number().min(2).max(5).optional().nullable(),
178
+ showTotalRaised: z.boolean().optional(),
179
+ issuerId: issuerIdSchema.optional(),
180
+ });
181
+ export const PatchOffering = PatchOfferingBase.merge(
182
+ z.object({
183
+ assetName: z
184
+ .string()
185
+ .min(2)
186
+ .max(50)
187
+ .optional()
188
+ .openapi({ example: 'Asset name' }),
189
+ assetType: z
190
+ .nativeEnum(AssetType)
191
+ .optional()
192
+ .openapi({ example: AssetType.STOCK }),
193
+ pricePerUnit: z
194
+ .number()
195
+ .min(0.01)
196
+ .max(10000000000)
197
+ .nullable()
198
+ .optional()
199
+ .openapi({ example: 2000 }),
200
+ totalUnits: z
201
+ .number()
202
+ .min(1)
203
+ .max(10000000000)
204
+ .nullable()
205
+ .optional()
206
+ .openapi({ example: 5200 }),
207
+ yield: z
208
+ .number()
209
+ .min(0.01)
210
+ .max(10000000000)
211
+ .nullable()
212
+ .optional()
213
+ .openapi({ example: 1200 }),
214
+ duration: z
215
+ .number()
216
+ .min(1)
217
+ .max(1000)
218
+ .nullable()
219
+ .optional()
220
+ .openapi({ example: 1 }),
221
+ durationType: z
222
+ .nativeEnum(DurationType)
223
+ .nullable()
224
+ .optional()
225
+ .openapi({ example: DurationType.DAY }),
226
+ template: z
227
+ .nativeEnum(AssetTemplateType)
228
+ .default(AssetTemplateType.STANDARD)
229
+ .openapi({ example: AssetTemplateType.STANDARD })
230
+ .nullable()
231
+ .optional(),
232
+ tiers: z.array(z.number().positive()).nullable().optional(),
233
+ }),
234
+ );
235
+ export type PatchOffering = z.infer<typeof PatchOffering>;
236
+
237
+ export const PostComplianceOffering = PatchOfferingBase.merge(
238
+ z.object({
239
+ accountId: accountIdSchema,
240
+ managedBy: z.nativeEnum(ManagedByType).optional(),
241
+ assetName: z.string().min(2).max(50).openapi({ example: 'Asset name' }),
242
+ assetType: z.nativeEnum(AssetType).openapi({ example: AssetType.STOCK }),
243
+ pricePerUnit: z
244
+ .number()
245
+ .min(0.01)
246
+ .max(10000000000)
247
+ .nullable()
248
+ .openapi({ example: 2000 }),
249
+ totalUnits: z
250
+ .number()
251
+ .min(1)
252
+ .max(10000000000)
253
+ .nullable()
254
+ .openapi({ example: 5200 }),
255
+ yield: z
256
+ .number()
257
+ .min(0.01)
258
+ .max(10000000000)
259
+ .nullable()
260
+ .optional()
261
+ .openapi({ example: 1200 }),
262
+ duration: z
263
+ .number()
264
+ .min(1)
265
+ .max(1000)
266
+ .nullable()
267
+ .optional()
268
+ .openapi({ example: 1 }),
269
+ durationType: z
270
+ .nativeEnum(DurationType)
271
+ .nullable()
272
+ .optional()
273
+ .openapi({ example: DurationType.DAY }),
274
+ template: z
275
+ .nativeEnum(AssetTemplateType)
276
+ .default(AssetTemplateType.STANDARD)
277
+ .openapi({ example: AssetTemplateType.STANDARD }),
278
+ tiers: z.array(z.number().positive()).nullable().optional(),
279
+ }),
280
+ ).superRefine(postAssetRefinement);
281
+ export type PostComplianceOffering = z.infer<typeof PostComplianceOffering>;
282
+
283
+ export const offeringsInclude = z.enum([
284
+ 'account',
285
+ 'issuer',
286
+ 'trades',
287
+ 'assets',
288
+ 'disbursements',
289
+ 'draftVersion',
290
+ 'publishedVersion',
291
+ 'revisions',
292
+ 'onboardingReviewedBy',
293
+ ]);
294
+
295
+ /**
296
+ * @description Query parameters for including related entities
297
+ * @xample in contract us as -> query: z.object({}).merge(UsersIncludeQuery),
298
+ */
299
+ export const OfferingsIncludeQuery = z.object({
300
+ include: z
301
+ .string()
302
+ .optional()
303
+ .transform((str) => (str ? str.split(',') : []))
304
+ .refine(
305
+ (includes) =>
306
+ includes.every((include) =>
307
+ offeringsInclude.options.includes(include as any),
308
+ ),
309
+ {
310
+ message: `Invalid include option provided. Valid options are: ${offeringsInclude.options.join(',')}`,
311
+ },
312
+ )
313
+ .openapi({
314
+ example: `${offeringsInclude.options.join(',')}`,
315
+ }),
316
+ });
317
+
318
+ export interface OfferingsIncludeQuery
319
+ extends z.infer<typeof OfferingsIncludeQuery> {}
320
+
321
+ /**
322
+ * @description
323
+ * Filters for querying offerings.
324
+ *
325
+ * The "combinedStatus" filter provides a unified status that combines three separate fields:
326
+ * - complianceReview: The compliance review status of the offering
327
+ * - onboardingStatus: The onboarding completion status
328
+ * - enabled: Whether the offering is currently enabled/active
329
+ *
330
+ * The combinedStatus is calculated using the following priority rules:
331
+ * 1. If onboardingStatus is "IN_REVIEW" → combinedStatus = "ONBOARDING"
332
+ * 2. Else if complianceReview is not "APPROVED" → combinedStatus = "IN_COMPLIANCE_REVIEW"
333
+ * 3. Else if onboardingStatus is "COMPLETE" and complianceReview is "APPROVED" →
334
+ * - If enabled is true → combinedStatus = "ACTIVE"
335
+ * - If enabled is false → combinedStatus = "PAUSED"
336
+ *
337
+ * This allows for filtering offerings by a single summary state that reflects the overall user-facing status,
338
+ * rather than requiring separate filters for each individual field.
339
+ */
340
+ export const OfferingFiltersZod = z.object({
341
+ issuerName: z.string().optional(),
342
+ name: z.string().optional(),
343
+ accountId: accountIdSchema.optional(),
344
+ issuerId: z.lazy(() => issuerIdSchema).optional(),
345
+ type: z.nativeEnum(OfferingType).optional(),
346
+ status: z.nativeEnum(ComplianceReview).optional(),
347
+ enabled: z.preprocess(
348
+ (val) =>
349
+ val === 'true' || val === '1'
350
+ ? true
351
+ : val === 'false' || val === '0'
352
+ ? false
353
+ : val,
354
+ z.boolean().optional(),
355
+ ),
356
+ managedBy: z.nativeEnum(ManagedByType).optional(),
357
+ versioningType: z.nativeEnum(OfferingVersioningType).optional(),
358
+ combinedStatus: z.nativeEnum(OfferingStatus).optional(),
359
+ onboardingStatus: z.nativeEnum(OfferingOnboardingStatus).optional(),
360
+ });
361
+ export type OfferingFiltersZod = z.infer<typeof OfferingFiltersZod>;
362
+
363
+ export const OfferingSortZod = z.object({
364
+ sort: z.enum([SortBy.NAME, SortBy.CREATED_AT, SortBy.UPDATED_AT]).optional(),
365
+ dir: z.nativeEnum(SortOrder).optional(),
366
+ });
367
+ export type OfferingSortZod = z.infer<typeof OfferingSortZod>;
368
+
369
+ export const OfferingSummaryFiltersZod = z.object({
370
+ accountId: accountIdSchema.optional(),
371
+ hasPendingTrades: z.coerce.boolean().optional(),
372
+ });
373
+ export type OfferingSummaryFiltersZod = z.infer<
374
+ typeof OfferingSummaryFiltersZod
375
+ >;
376
+
377
+ export const OfferingSummaryResponseZod = z.object({
378
+ id: offeringIdSchema,
379
+ name: z.string(),
380
+ account: z.object({ id: accountIdSchema, name: z.string() }),
381
+ trades: z.object({
382
+ total: z.number(),
383
+ tradeReview: z.number(),
384
+ readyForDisbursement: z.number(),
385
+ }),
386
+ });
387
+ export type OfferingSummaryResponse = z.infer<
388
+ typeof OfferingSummaryResponseZod
389
+ >;
390
+
391
+ export const PaginatedOfferingSummaryResponseZod = z.object({
392
+ items: z.array(OfferingSummaryResponseZod),
393
+ meta: IPaginationMeta,
394
+ });
395
+ export type PaginatedOfferingSummaryResponse = z.infer<
396
+ typeof PaginatedOfferingSummaryResponseZod
397
+ >;
398
+
399
+ const BaseOfferingSettings = z.object({
400
+ settingsBrokerageFeeValue: z.number().nonnegative().nullable().optional(),
401
+ settingsBrokerageFeeType: z.nativeEnum(OfferingFeeType).nullable().optional(),
402
+ settingsCardFeeValue: z.number().nonnegative().nullable().optional(),
403
+ settingsCardFeeType: z.nativeEnum(OfferingFeeType).nullable().optional(),
404
+ settingsDisbursementFeeValue: z.number().nonnegative().nullable().optional(),
405
+ settingsDisbursementFeeType: z
406
+ .nativeEnum(OfferingFeeType)
407
+ .nullable()
408
+ .optional(),
409
+ settingsRefundPoolFeeValue: z.number().nonnegative().nullable().optional(),
410
+ settingsRefundPoolFeeType: z
411
+ .nativeEnum(OfferingFeeType)
412
+ .nullable()
413
+ .optional(),
414
+ serviceChargesType: z.nativeEnum(OfferingFeeType).nullable().optional(),
415
+ serviceCharges: z.number().nonnegative().nullable().optional(),
416
+ });
417
+
418
+ export const OfferingSettings = BaseOfferingSettings.refine(
419
+ (data) =>
420
+ (data.settingsBrokerageFeeType === null &&
421
+ data.settingsBrokerageFeeValue === null) ||
422
+ (data.settingsBrokerageFeeType !== null &&
423
+ data.settingsBrokerageFeeValue !== null),
424
+ {
425
+ message:
426
+ 'settingsBrokerageFeeType and settingsBrokerageFeeValue must both be either null or not-null',
427
+ },
428
+ )
429
+ .refine(
430
+ (data) =>
431
+ (data.serviceChargesType === null && data.serviceCharges === null) ||
432
+ (data.serviceChargesType !== null && data.serviceCharges !== null),
433
+ {
434
+ message:
435
+ 'serviceChargesType and serviceCharges must both be either null or not-null',
436
+ },
437
+ )
438
+ .refine(
439
+ (data) =>
440
+ (data.settingsCardFeeType === null &&
441
+ data.settingsCardFeeValue === null) ||
442
+ (data.settingsCardFeeType !== null && data.settingsCardFeeValue !== null),
443
+ {
444
+ message:
445
+ 'settingsCardFeeType and settingsCardFeeValue must both be either null or not-null',
446
+ },
447
+ )
448
+ .refine(
449
+ (data) =>
450
+ (data.settingsDisbursementFeeType === null &&
451
+ data.settingsDisbursementFeeValue === null) ||
452
+ (data.settingsDisbursementFeeType !== null &&
453
+ data.settingsDisbursementFeeValue !== null),
454
+ {
455
+ message:
456
+ 'settingsDisbursementFeeType and settingsDisbursementFeeValue must both be either null or not-null',
457
+ },
458
+ )
459
+ .refine(
460
+ (data) =>
461
+ (data.settingsRefundPoolFeeType === null &&
462
+ data.settingsRefundPoolFeeValue === null) ||
463
+ (data.settingsRefundPoolFeeType !== null &&
464
+ data.settingsRefundPoolFeeValue !== null),
465
+ {
466
+ message:
467
+ 'settingsRefundPoolFeeType and settingsRefundPoolFeeValue must both be either null or not-null',
468
+ },
469
+ )
470
+ .refine(
471
+ (data) =>
472
+ data.settingsBrokerageFeeType !== OfferingFeeType.PERCENTAGE ||
473
+ (data.settingsBrokerageFeeValue !== null &&
474
+ data.settingsBrokerageFeeValue! <= 100),
475
+ {
476
+ message: 'settingsBrokerageFeeValue must be less than or equal to 100',
477
+ },
478
+ )
479
+ .refine(
480
+ (data) =>
481
+ data.settingsRefundPoolFeeType !== OfferingFeeType.PERCENTAGE ||
482
+ (data.settingsRefundPoolFeeValue !== null &&
483
+ data.settingsRefundPoolFeeValue! <= 100),
484
+ {
485
+ message: 'settingsRefundPoolFeeValue must be less than or equal to 100',
486
+ },
487
+ )
488
+ .refine(
489
+ (data) =>
490
+ data.settingsCardFeeType !== OfferingFeeType.PERCENTAGE ||
491
+ (data.settingsCardFeeValue !== null && data.settingsCardFeeValue! <= 100),
492
+ {
493
+ message: 'settingsCardFeeValue must be less than or equal to 100',
494
+ },
495
+ )
496
+ .refine(
497
+ (data) =>
498
+ data.settingsDisbursementFeeType !== OfferingFeeType.PERCENTAGE ||
499
+ (data.settingsDisbursementFeeValue !== null &&
500
+ data.settingsDisbursementFeeValue! <= 100),
501
+ {
502
+ message: 'settingsDisbursementFeeValue must be less than 100',
503
+ },
504
+ );
505
+
506
+ export type OfferingSettings = z.infer<typeof OfferingSettings>;
507
+
508
+ export const PatchComplianceOffering = z
509
+ .intersection(PatchOffering, OfferingSettings)
510
+ .refine(
511
+ (data) => {
512
+ // Check if both values are present, and if so, ensure minInvestment is less than maxInvestment
513
+ if (data.minInvestment && data.maxInvestment) {
514
+ return data.minInvestment < data.maxInvestment;
515
+ }
516
+ return true; // If one or both values are undefined, skip this check
517
+ },
518
+ {
519
+ message: 'Minimum investment must be less than maximum investment.',
520
+ path: ['minInvestment'],
521
+ },
522
+ );
523
+ export type PatchComplianceOffering = z.infer<typeof PatchComplianceOffering>;
524
+
525
+ export const IComplianceOffering = z.intersection(IOffering, OfferingSettings);
526
+ export type IComplianceOffering = z.infer<typeof IComplianceOffering>;
527
+
528
+ export const IPaginatedComplianceOffering = z.object({
529
+ items: z.array(IComplianceOffering),
530
+ meta: IPaginationMeta,
531
+ });
532
+ export type IPaginatedComplianceOffering = z.infer<
533
+ typeof IPaginatedComplianceOffering
534
+ >;
535
+
536
+ export const ReviewOfferings = z.object({
537
+ complianceReview: z.enum([
538
+ ComplianceReview.APPROVED,
539
+ ComplianceReview.REJECTED,
540
+ ]),
541
+ offerings: z
542
+ .array(offeringIdSchema)
543
+ .min(1, 'At least one offering is required')
544
+ .max(50, 'Maximum of 50 offerings allowed')
545
+ .openapi({
546
+ example: [
547
+ 'offering_01jjsdrx1seqfse7z4z47sgdp5',
548
+ 'offering_01jjsdrx27enkszq5cnc3hdhrf',
549
+ ],
550
+ }),
551
+ });
552
+ export type ReviewOfferings = z.infer<typeof ReviewOfferings>;
553
+
554
+ export const OfferingDetailsResponseZod = z.object({
555
+ raisedAmount: z.number(),
556
+ investors: z.number().int(),
557
+ minInvestment: z.number(),
558
+ maxInvestment: z.number(),
559
+ valuationCap: z.number(),
560
+ targetAmount: z.number(),
561
+ });
562
+
563
+ export type OfferingDetailsResponseZod = z.infer<
564
+ typeof OfferingDetailsResponseZod
565
+ >;
566
+
567
+ export const OfferingsArrayQueryZod = z.object({
568
+ offerings: z
569
+ .string()
570
+ .optional()
571
+ .transform((val) => {
572
+ if (!val) return undefined;
573
+ return val.split(',').map((id) => id.trim());
574
+ })
575
+ .pipe(
576
+ z
577
+ .array(z.string())
578
+ .optional()
579
+ .refine(
580
+ (val) => {
581
+ if (!val) return true;
582
+ return val.every((id) => {
583
+ try {
584
+ const tid = TypeID.fromString(id);
585
+ return tid.getType() === 'offering';
586
+ } catch {
587
+ return false;
588
+ }
589
+ });
590
+ },
591
+ {
592
+ message:
593
+ 'Invalid offering IDs format. Must be a valid TypeID with "offering" prefix.',
594
+ },
595
+ ),
596
+ ),
597
+ });
598
+
599
+ export const OfferingRaiseAmountResponseZod = z.object({
600
+ offeringId: offeringIdSchema,
601
+ totalRaisedAmount: z.number(),
602
+ });
603
+ export type OfferingRaiseAmountResponseZod = z.infer<
604
+ typeof OfferingRaiseAmountResponseZod
605
+ >;
606
+
607
+ export const PublicOfferingFiltersZod = PaginationOptionsZod.merge(
608
+ InvestorsOfferingsIncludeQuery,
609
+ )
610
+ .merge(InvestorsOfferingFiltersZod)
611
+ .extend({
612
+ url: UrlSchema,
613
+ });
614
+
615
+ export type PublicOfferingFiltersZod = z.infer<typeof PublicOfferingFiltersZod>;
616
+
617
+ export const PendingOfferingSummaryResponseZod = z.object({
618
+ id: offeringIdSchema,
619
+ name: z.string(),
620
+ assets: z.number(),
621
+ issuerName: z.string(),
622
+ issuerId: z.string(),
623
+ accountName: z.string(),
624
+ accountId: z.string(),
625
+ targetAmount: z.number().nullable(),
626
+ startAt: z.date().nullable(),
627
+ offeringType: z.nativeEnum(OfferingType),
628
+ });
629
+ export type PendingOfferingSummaryResponse = z.infer<
630
+ typeof PendingOfferingSummaryResponseZod
631
+ >;
632
+
633
+ export const PaginatedPendingOfferingSummaryResponseZod = z.object({
634
+ items: z.array(PendingOfferingSummaryResponseZod),
635
+ meta: IPaginationMeta,
636
+ });
637
+ export type PaginatedPendingOfferingSummaryResponse = z.infer<
638
+ typeof PaginatedPendingOfferingSummaryResponseZod
639
+ >;
640
+
641
+ export type OfferingUpdateFields = {
642
+ managedBy?: ManagedByType | null;
643
+ showTotalRaised?: boolean;
644
+ enabled?: boolean;
645
+ };
646
+
647
+ export const ReviewOfferingOnboarding = z.object({
648
+ onboardingStatus: z.nativeEnum(OfferingOnboardingStatus),
649
+ });
650
+ export type ReviewOfferingOnboarding = z.infer<typeof ReviewOfferingOnboarding>;
651
+
652
+ export const OnboardingOfferingSummaryZod = z.object({
653
+ accountId: accountIdSchema,
654
+ accountName: z.string(),
655
+ offeringName: z.string(),
656
+ offeringId: z.string(),
657
+ memorandumId: z.string().nullable(),
658
+ subscriptionAgreementId: z.string().nullable(),
659
+ subscriptionAgreementTemplateId: z.string().nullable(),
660
+ jointSubscriptionAgreementTemplateId: z.string().nullable(),
661
+ entitySubscriptionAgreementTemplateId: z.string().nullable(),
662
+ });
663
+ export type OnboardingOfferingSummaryZod = z.infer<
664
+ typeof OnboardingOfferingSummaryZod
665
+ >;
666
+
667
+ export const OnboardingOfferingSummaryFilterZod = z.object({
668
+ search: z.string().optional(),
669
+ offeringId: offeringIdSchema.optional(),
670
+ });
671
+ export type OnboardingOfferingSummaryFilterZod = z.infer<
672
+ typeof OnboardingOfferingSummaryFilterZod
673
+ >;
674
+
675
+ export const IPaginatedOnboardingOfferingSummaryResponse = z.object({
676
+ items: z.array(OnboardingOfferingSummaryZod),
677
+ meta: IPaginationMeta,
678
+ });
679
+ export type IPaginatedOnboardingOfferingSummaryResponse = z.infer<
680
+ typeof IPaginatedOnboardingOfferingSummaryResponse
681
+ >;