@dalmore/api-contracts 0.0.0-dev.2dc8e92

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 (292) 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 +310 -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 +48 -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 +306 -0
  54. package/common/types/issuer-payment-method.types.ts +341 -0
  55. package/common/types/issuer.types.ts +312 -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 +590 -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 +929 -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/files/index.ts +166 -0
  119. package/contracts/clients/files-public/index.ts +166 -0
  120. package/contracts/clients/index.ts +44 -0
  121. package/contracts/clients/individuals/index.ts +93 -0
  122. package/contracts/clients/investor-accounts/index.ts +93 -0
  123. package/contracts/clients/issuers/index.ts +94 -0
  124. package/contracts/clients/legal-entities/index.ts +93 -0
  125. package/contracts/clients/offerings/index.ts +117 -0
  126. package/contracts/clients/secure-requests/index.ts +34 -0
  127. package/contracts/clients/sites/index.ts +56 -0
  128. package/contracts/clients/trades/index.ts +122 -0
  129. package/contracts/compliance/account-contacts/index.ts +82 -0
  130. package/contracts/compliance/account-managers/index.ts +142 -0
  131. package/contracts/compliance/accounts/index.ts +187 -0
  132. package/contracts/compliance/activities/index.ts +55 -0
  133. package/contracts/compliance/aic/index.ts +60 -0
  134. package/contracts/compliance/api-keys/index.ts +91 -0
  135. package/contracts/compliance/assets/index.ts +122 -0
  136. package/contracts/compliance/auth/index.ts +134 -0
  137. package/contracts/compliance/batch-jobs/index.ts +62 -0
  138. package/contracts/compliance/bonus-tiers/index.ts +55 -0
  139. package/contracts/compliance/checklist/index.ts +87 -0
  140. package/contracts/compliance/checklist-items/index.ts +86 -0
  141. package/contracts/compliance/covered-persons/index.ts +97 -0
  142. package/contracts/compliance/dashboard/index.ts +111 -0
  143. package/contracts/compliance/data-records/index.ts +116 -0
  144. package/contracts/compliance/data-rooms/index.ts +113 -0
  145. package/contracts/compliance/default-theme-configs/index.ts +95 -0
  146. package/contracts/compliance/disbursement/index.ts +165 -0
  147. package/contracts/compliance/disbursement-approval-users/index.ts +84 -0
  148. package/contracts/compliance/disbursement-transactions/index.ts +37 -0
  149. package/contracts/compliance/domain-filters/index.ts +117 -0
  150. package/contracts/compliance/email-themes/index.ts +284 -0
  151. package/contracts/compliance/escrow-accounts/index.ts +85 -0
  152. package/contracts/compliance/exchange-api-keys/index.ts +129 -0
  153. package/contracts/compliance/exchange-imports/index.ts +137 -0
  154. package/contracts/compliance/files/index.ts +267 -0
  155. package/contracts/compliance/files-public/index.ts +188 -0
  156. package/contracts/compliance/health/index.ts +26 -0
  157. package/contracts/compliance/index.ts +147 -0
  158. package/contracts/compliance/individuals/index.ts +57 -0
  159. package/contracts/compliance/investor-accounts/index.ts +141 -0
  160. package/contracts/compliance/invites/index.ts +137 -0
  161. package/contracts/compliance/issuer-bank-accounts/index.ts +81 -0
  162. package/contracts/compliance/issuer-payment-methods/index.ts +81 -0
  163. package/contracts/compliance/issuers/index.ts +97 -0
  164. package/contracts/compliance/job-items/index.ts +58 -0
  165. package/contracts/compliance/jobs/index.ts +59 -0
  166. package/contracts/compliance/kyb/index.ts +54 -0
  167. package/contracts/compliance/kyc/index.ts +77 -0
  168. package/contracts/compliance/legal-entities/index.ts +57 -0
  169. package/contracts/compliance/login-histories/index.ts +37 -0
  170. package/contracts/compliance/notes/index.ts +69 -0
  171. package/contracts/compliance/notion-databases/index.ts +107 -0
  172. package/contracts/compliance/notion-pages/index.ts +105 -0
  173. package/contracts/compliance/offering-reports/index.ts +149 -0
  174. package/contracts/compliance/offerings/index.ts +233 -0
  175. package/contracts/compliance/pages/index.ts +178 -0
  176. package/contracts/compliance/payment-methods/index.ts +57 -0
  177. package/contracts/compliance/rejection-reasons/index.ts +32 -0
  178. package/contracts/compliance/review/index.ts +169 -0
  179. package/contracts/compliance/roles/index.ts +34 -0
  180. package/contracts/compliance/secondary-customers/index.ts +77 -0
  181. package/contracts/compliance/secondary-orders/index.ts +60 -0
  182. package/contracts/compliance/secondary-trades/index.ts +100 -0
  183. package/contracts/compliance/secure-requests/index.ts +54 -0
  184. package/contracts/compliance/signer/index.ts +369 -0
  185. package/contracts/compliance/site-links/index.ts +128 -0
  186. package/contracts/compliance/site-settings/index.ts +669 -0
  187. package/contracts/compliance/sites/index.ts +56 -0
  188. package/contracts/compliance/state-machine/index.ts +94 -0
  189. package/contracts/compliance/tasks/index.ts +91 -0
  190. package/contracts/compliance/third-parties/index.ts +52 -0
  191. package/contracts/compliance/trade-line-items/index.ts +59 -0
  192. package/contracts/compliance/trades/index.ts +230 -0
  193. package/contracts/compliance/transactions/index.ts +161 -0
  194. package/contracts/compliance/user-manuals/index.ts +271 -0
  195. package/contracts/compliance/user-settings/index.ts +189 -0
  196. package/contracts/compliance/users/index.ts +200 -0
  197. package/contracts/compliance/webhooks/index.ts +41 -0
  198. package/contracts/compliance-apikey/accounts/index.ts +58 -0
  199. package/contracts/compliance-apikey/index.ts +14 -0
  200. package/contracts/index.ts +6 -0
  201. package/contracts/investors/account-contacts/index.ts +58 -0
  202. package/contracts/investors/aic/index.ts +59 -0
  203. package/contracts/investors/assets/index.ts +61 -0
  204. package/contracts/investors/auth/index.ts +116 -0
  205. package/contracts/investors/bonus-tiers/index.ts +37 -0
  206. package/contracts/investors/cart/index.ts +75 -0
  207. package/contracts/investors/contact-us/index.ts +48 -0
  208. package/contracts/investors/data-records/index.ts +113 -0
  209. package/contracts/investors/data-rooms/index.ts +96 -0
  210. package/contracts/investors/files/index.ts +167 -0
  211. package/contracts/investors/files-public/index.ts +185 -0
  212. package/contracts/investors/index.ts +72 -0
  213. package/contracts/investors/individuals/index.ts +99 -0
  214. package/contracts/investors/investor-accounts/index.ts +110 -0
  215. package/contracts/investors/issuer-payment-methods/index.ts +36 -0
  216. package/contracts/investors/issuers/index.ts +30 -0
  217. package/contracts/investors/legal-entities/index.ts +93 -0
  218. package/contracts/investors/notes/index.ts +69 -0
  219. package/contracts/investors/offerings/index.ts +93 -0
  220. package/contracts/investors/pages/index.ts +88 -0
  221. package/contracts/investors/payment-methods/index.ts +149 -0
  222. package/contracts/investors/portfolios/index.ts +53 -0
  223. package/contracts/investors/sites/index.ts +96 -0
  224. package/contracts/investors/tasks/index.ts +111 -0
  225. package/contracts/investors/trade-line-items/index.ts +75 -0
  226. package/contracts/investors/trades/index.ts +114 -0
  227. package/contracts/investors/transactions/index.ts +37 -0
  228. package/contracts/investors/trusted-contacts/index.ts +93 -0
  229. package/contracts/investors/user-manuals/index.ts +62 -0
  230. package/contracts/investors/user-settings/index.ts +170 -0
  231. package/contracts/investors/users/index.ts +45 -0
  232. package/contracts/investors/webhooks/index.ts +30 -0
  233. package/contracts/issuers/account-contacts/index.ts +76 -0
  234. package/contracts/issuers/account-integrations/index.ts +97 -0
  235. package/contracts/issuers/accounts/index.ts +97 -0
  236. package/contracts/issuers/activities/index.ts +54 -0
  237. package/contracts/issuers/aic/index.ts +39 -0
  238. package/contracts/issuers/api-key-logs/index.ts +53 -0
  239. package/contracts/issuers/api-keys/index.ts +93 -0
  240. package/contracts/issuers/assets/index.ts +122 -0
  241. package/contracts/issuers/auth/index.ts +152 -0
  242. package/contracts/issuers/bonus-tiers/index.ts +55 -0
  243. package/contracts/issuers/contact-us/index.ts +48 -0
  244. package/contracts/issuers/covered-persons/index.ts +136 -0
  245. package/contracts/issuers/dashboard/index.ts +72 -0
  246. package/contracts/issuers/data-records/index.ts +257 -0
  247. package/contracts/issuers/data-rooms/index.ts +134 -0
  248. package/contracts/issuers/disbursement-approval-users/index.ts +82 -0
  249. package/contracts/issuers/disbursement-transactions/index.ts +53 -0
  250. package/contracts/issuers/disbursements/index.ts +153 -0
  251. package/contracts/issuers/email-themes/index.ts +242 -0
  252. package/contracts/issuers/escrow-accounts/index.ts +81 -0
  253. package/contracts/issuers/exchange-api-keys/index.ts +144 -0
  254. package/contracts/issuers/files/index.ts +166 -0
  255. package/contracts/issuers/files-public/index.ts +166 -0
  256. package/contracts/issuers/health/index.ts +24 -0
  257. package/contracts/issuers/index.ts +112 -0
  258. package/contracts/issuers/investor-accounts/index.ts +148 -0
  259. package/contracts/issuers/invites/index.ts +129 -0
  260. package/contracts/issuers/issuer/index.ts +94 -0
  261. package/contracts/issuers/issuer-bank-accounts/index.ts +81 -0
  262. package/contracts/issuers/issuer-payment-methods/index.ts +136 -0
  263. package/contracts/issuers/kyc/index.ts +38 -0
  264. package/contracts/issuers/login-histories/index.ts +51 -0
  265. package/contracts/issuers/notes/index.ts +69 -0
  266. package/contracts/issuers/offerings/index.ts +206 -0
  267. package/contracts/issuers/pages/index.ts +138 -0
  268. package/contracts/issuers/payment-methods/index.ts +61 -0
  269. package/contracts/issuers/portfolios/index.ts +36 -0
  270. package/contracts/issuers/rejection-reasons/index.ts +32 -0
  271. package/contracts/issuers/review/index.ts +63 -0
  272. package/contracts/issuers/secondary-customers/index.ts +55 -0
  273. package/contracts/issuers/secondary-orders/index.ts +57 -0
  274. package/contracts/issuers/secondary-trades/index.ts +57 -0
  275. package/contracts/issuers/secure-requests/index.ts +34 -0
  276. package/contracts/issuers/site-links/index.ts +116 -0
  277. package/contracts/issuers/site-settings/index.ts +585 -0
  278. package/contracts/issuers/sites/index.ts +32 -0
  279. package/contracts/issuers/tasks/index.ts +111 -0
  280. package/contracts/issuers/trades/index.ts +132 -0
  281. package/contracts/issuers/transactions/index.ts +158 -0
  282. package/contracts/issuers/user-manuals/index.ts +62 -0
  283. package/contracts/issuers/user-settings/index.ts +170 -0
  284. package/contracts/issuers/users/index.ts +126 -0
  285. package/contracts/secondaries/accounts/index.ts +58 -0
  286. package/contracts/secondaries/index.ts +23 -0
  287. package/contracts/secondaries/secondary-customers/index.ts +55 -0
  288. package/contracts/secondaries/secondary-issuers/index.ts +94 -0
  289. package/contracts/secondaries/secondary-orders/index.ts +56 -0
  290. package/contracts/secondaries/secondary-securities/index.ts +95 -0
  291. package/contracts/secondaries/secondary-trades/index.ts +56 -0
  292. package/package.json +77 -0
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @dalmore/api-contracts
2
+
3
+ Type-safe API contracts for Dalmore Client Portal, powered by [ts-rest](https://ts-rest.com/).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Production (stable releases from main branch)
9
+ npm install @dalmore/api-contracts
10
+
11
+ # Development (latest from dev branch)
12
+ npm install @dalmore/api-contracts@dev
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Import specific contracts (recommended for tree-shaking)
18
+
19
+ ```typescript
20
+ import { complianceContract } from '@dalmore/api-contracts/compliance';
21
+ import { investorsContract } from '@dalmore/api-contracts/investors';
22
+ import { issuersContract } from '@dalmore/api-contracts/issuers';
23
+ import { clientsContract } from '@dalmore/api-contracts/clients';
24
+ ```
25
+
26
+ ### Import types
27
+
28
+ ```typescript
29
+ import type { IInvestorAccount } from '@dalmore/api-contracts/types/investor-account.types';
30
+ import type { ITrade } from '@dalmore/api-contracts/types/trade.types';
31
+ ```
32
+
33
+ ### Create a typed client
34
+
35
+ ```typescript
36
+ import { complianceContract } from '@dalmore/api-contracts/compliance';
37
+ import { initClient } from '@ts-rest/core';
38
+
39
+ const client = initClient(complianceContract, {
40
+ baseUrl: 'https://platform.dalmoregroup.com',
41
+ baseHeaders: {
42
+ Authorization: `Bearer ${token}`,
43
+ },
44
+ });
45
+
46
+ // Fully typed API calls
47
+ const { status, body } = await client.accounts.getAccounts({
48
+ query: { page: 1, limit: 10 },
49
+ });
50
+ ```
51
+
52
+ ## Peer Dependencies
53
+
54
+ This package requires the following peer dependencies:
55
+
56
+ - `@ts-rest/core` ^3.0.0
57
+ - `zod` ^3.0.0
58
+
59
+ ## Available Contracts
60
+
61
+ - `complianceContract` - Compliance portal API
62
+ - `investorsContract` - Investor portal API
63
+ - `issuersContract` - Issuer portal API
64
+ - `clientsContract` - Client API (API key auth)
65
+ - `secondariesContract` - Secondaries API
66
+ - `complianceApiKeyContract` - Compliance API (API key auth)
67
+
68
+ ## TypeScript Configuration
69
+
70
+ This package ships TypeScript source files for maximum type safety. Your `tsconfig.json` should include:
71
+
72
+ ```json
73
+ {
74
+ "compilerOptions": {
75
+ "moduleResolution": "node",
76
+ "esModuleInterop": true
77
+ }
78
+ }
79
+ ```
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Contract helpers - minimal subset for API documentation generation
3
+ */
4
+
5
+ type CurlOptions = {
6
+ query?: Record<string, string>;
7
+ headers?: Record<string, string>;
8
+ body?: Record<string, unknown>;
9
+ formData?: Record<string, string>;
10
+ };
11
+
12
+ export const authHeader: CurlOptions['headers'] = {
13
+ Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
14
+ };
15
+
16
+ const generateCurlExample = (
17
+ method: string,
18
+ path: string,
19
+ options: CurlOptions,
20
+ ) => {
21
+ const baseUrl = 'https://dalmore-client-portal-api-prod.onrender.com/api/v1';
22
+ let curl = `curl -X ${method.toUpperCase()} '${baseUrl}${path}`;
23
+ if (options.query) {
24
+ const queryString = new URLSearchParams(options.query).toString();
25
+ curl += `?${queryString}`;
26
+ }
27
+ curl += "'";
28
+ if (options.headers) {
29
+ Object.entries(options.headers).forEach(([key, value]) => {
30
+ curl += ` \\\n --header '${key}: ${value}'`;
31
+ });
32
+ }
33
+ if (options.body) {
34
+ curl += ` \\\n --header 'Content-Type: application/json'`;
35
+ curl += ` \\\n --data '${JSON.stringify(options.body)}'`;
36
+ }
37
+ if (options.formData) {
38
+ Object.entries(options.formData).forEach(([key, value]) => {
39
+ curl += ` \\\n --form '${key}=${value}'`;
40
+ });
41
+ }
42
+ return curl;
43
+ };
44
+
45
+ export const generateApiDescription = (
46
+ summary: string,
47
+ method: string,
48
+ path: string,
49
+ options: CurlOptions,
50
+ ) => {
51
+ const curlExample = generateCurlExample(method, path, options);
52
+ return `${summary}
53
+
54
+ ### Example curl request
55
+
56
+ \`\`\`bash
57
+ ${curlExample}
58
+ \`\`\``;
59
+ };
@@ -0,0 +1,98 @@
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 { PhoneZodSchema } from './phone.type';
6
+ import {
7
+ AccountContactType,
8
+ AccountZod,
9
+ IPaginationMeta,
10
+ } from './common.types';
11
+ import { IBaseEntity } from './entity.types';
12
+ import { PhoneNumberData } from './sms.types';
13
+
14
+ extendZodWithOpenApi(z);
15
+
16
+ export const accountContactIdSchema = z.string().refine(
17
+ (value) => {
18
+ try {
19
+ const tid = TypeID.fromString(value);
20
+ return tid.getType() === 'account_contact';
21
+ } catch {
22
+ return false;
23
+ }
24
+ },
25
+ {
26
+ message:
27
+ 'Invalid account contact ID format. Must be a valid TypeID with "account_contact" prefix.',
28
+ },
29
+ );
30
+
31
+ export const IAccountContact = IBaseEntity.extend({
32
+ id: accountContactIdSchema,
33
+ title: z.string().nullable().openapi({ example: 'Mr' }),
34
+ firstName: z.string().nullable().openapi({ example: 'John' }),
35
+ lastName: z.string().nullable().openapi({ example: 'Doe' }),
36
+ email: z
37
+ .string()
38
+ .email()
39
+ .nullable()
40
+ .openapi({ example: 'john.doe@example.com' }),
41
+ phone: PhoneNumberData.nullable().optional().openapi({ example: null }),
42
+ type: z
43
+ .nativeEnum(AccountContactType)
44
+ .openapi({ example: AccountContactType.GENERAL }),
45
+ accountId: accountIdSchema.openapi({
46
+ example: 'account_01je6ht4b8fbmttkzh2hs82xqp',
47
+ }),
48
+ account: AccountZod.optional().nullable(),
49
+ referenceLink: z.string().nullable().optional(),
50
+ });
51
+ export type IAccountContact = z.infer<typeof IAccountContact>;
52
+
53
+ export const PatchAccountContactZod = z.object({
54
+ title: z
55
+ .string()
56
+ .min(1)
57
+ .max(50)
58
+ .nullable()
59
+ .optional()
60
+ .openapi({ example: 'Mr' }),
61
+ firstName: z.string().min(1).max(150).openapi({ example: 'John' }),
62
+ lastName: z.string().min(1).max(150).openapi({ example: 'Doe' }),
63
+ email: z.string().email().openapi({ example: 'john.doe@example.com' }),
64
+ phone: PhoneZodSchema.nullable()
65
+ .optional()
66
+ .openapi({ example: '+12124567890' }),
67
+ });
68
+
69
+ export type PatchAccountContactZod = z.infer<typeof PatchAccountContactZod>;
70
+
71
+ export const CompliancePatchAccountContactZod = PatchAccountContactZod.extend({
72
+ accountId: accountIdSchema.openapi({
73
+ example: 'account_01je6ht4b8fbmttkzh2hs82xqp',
74
+ }),
75
+ referenceLink: z
76
+ .string()
77
+ .url()
78
+ .max(2048)
79
+ .nullable()
80
+ .optional()
81
+ .openapi({ example: 'https://www.google.com' }),
82
+ });
83
+ export type CompliancePatchAccountContactZod = z.infer<
84
+ typeof CompliancePatchAccountContactZod
85
+ >;
86
+
87
+ export const IPaginatedAccountContact = z.object({
88
+ items: z.array(IAccountContact),
89
+ meta: IPaginationMeta,
90
+ });
91
+ export type IPaginatedAccountContact = z.infer<typeof IPaginatedAccountContact>;
92
+
93
+ export const AccountContactDeleteResponse = z.object({
94
+ status: z.enum(['pass', 'fail']),
95
+ });
96
+ export type AccountContactDeleteResponse = z.infer<
97
+ typeof AccountContactDeleteResponse
98
+ >;
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ import { IAsset } from './asset.types';
3
+ import { IIssuer } from './issuer.types';
4
+ import { IOffering } from './offering.types';
5
+ import { IIssuerPaymentMethod } from './issuer-payment-method.types';
6
+ import { SiteZod } from './site.types';
7
+ import { IPage } from './page.types';
8
+
9
+ export const AccountDetailSummaryZod = z.object({
10
+ id: z.string(),
11
+ name: z.string(),
12
+ issuers: z.array(
13
+ IIssuer.extend({
14
+ offerings: z.lazy(() =>
15
+ z.array(
16
+ IOffering.extend({
17
+ assets: z.lazy(() => z.array(IAsset)),
18
+ }),
19
+ ),
20
+ ),
21
+ paymentMethods: z.lazy(() => z.array(IIssuerPaymentMethod)),
22
+ }),
23
+ ),
24
+ sites: z.lazy(() => z.array(SiteZod)),
25
+ pages: z.lazy(() => z.array(IPage)),
26
+ });
27
+ export type AccountDetailSummaryZod = z.infer<typeof AccountDetailSummaryZod>;
@@ -0,0 +1,143 @@
1
+ import { extendZodWithOpenApi } from '@anatine/zod-openapi';
2
+ import { TypeID } from 'typeid-js';
3
+ import { z } from 'zod';
4
+ import { IBaseEntity } from './entity.types';
5
+ import { accountIdSchema } from './account.types';
6
+ import { IPaginationMeta } from './common.types';
7
+
8
+ extendZodWithOpenApi(z);
9
+
10
+ export enum IntegrationType {
11
+ RAISI = 'RAISI',
12
+ }
13
+
14
+ export const accountIntegrationIdSchema = z.string().refine(
15
+ (value) => {
16
+ try {
17
+ const tid = TypeID.fromString(value);
18
+ return tid.getType() === 'account_integration';
19
+ } catch {
20
+ return false;
21
+ }
22
+ },
23
+ {
24
+ message:
25
+ 'Invalid account integration ID format. Must be a valid TypeID with "account_integration" prefix.',
26
+ },
27
+ );
28
+
29
+ export const AccountIntegrationZod = IBaseEntity.extend({
30
+ id: accountIntegrationIdSchema,
31
+ name: z.string(),
32
+ integration: z.nativeEnum(IntegrationType),
33
+ description: z.string().nullable(),
34
+ partnerId: z.string().nullable(),
35
+ url: z.string().nullable(),
36
+ webhook: z.string().nullable(),
37
+ active: z.boolean(),
38
+ metadata: z.record(z.string(), z.unknown()).nullable(),
39
+ accountId: z.lazy(() => accountIdSchema),
40
+ });
41
+ export type AccountIntegrationZod = z.infer<typeof AccountIntegrationZod>;
42
+
43
+ export const IPaginatedAccountIntegration = z.object({
44
+ items: z.array(AccountIntegrationZod),
45
+ meta: IPaginationMeta,
46
+ });
47
+ export type IPaginatedAccountIntegration = z.infer<
48
+ typeof IPaginatedAccountIntegration
49
+ >;
50
+
51
+ export const PostAccountIntegrationZod = z.object({
52
+ name: z.string().min(1).max(100).openapi({ example: 'Raisi' }),
53
+ integration: z
54
+ .nativeEnum(IntegrationType)
55
+ .openapi({ example: IntegrationType.RAISI }),
56
+ description: z
57
+ .string()
58
+ .min(1)
59
+ .max(1000)
60
+ .nullable()
61
+ .optional()
62
+ .openapi({ example: 'Raisi integration' }),
63
+ partnerId: z
64
+ .string()
65
+ .min(1)
66
+ .max(100)
67
+ .nullable()
68
+ .optional()
69
+ .openapi({ example: '1234567890' }),
70
+ url: z
71
+ .string()
72
+ .url()
73
+ .nullable()
74
+ .optional()
75
+ .openapi({ example: 'https://www.raisi.com' }),
76
+ webhook: z
77
+ .string()
78
+ .url()
79
+ .nullable()
80
+ .optional()
81
+ .openapi({ example: 'https://www.raisi.com/webhook' }),
82
+ active: z.boolean().default(true).openapi({ example: true }),
83
+ metadata: z
84
+ .record(z.string(), z.unknown())
85
+ .nullable()
86
+ .optional()
87
+ .openapi({ example: { key: 'value' } }),
88
+ });
89
+ export type PostAccountIntegrationZod = z.infer<
90
+ typeof PostAccountIntegrationZod
91
+ >;
92
+
93
+ export const PatchAccountIntegrationZod = z.object({
94
+ name: z
95
+ .string()
96
+ .min(1)
97
+ .max(100)
98
+ .nullable()
99
+ .optional()
100
+ .openapi({ example: 'Raisi' }),
101
+ integration: z
102
+ .nativeEnum(IntegrationType)
103
+ .optional()
104
+ .openapi({ example: IntegrationType.RAISI }),
105
+ description: z
106
+ .string()
107
+ .min(1)
108
+ .max(1000)
109
+ .nullable()
110
+ .optional()
111
+ .openapi({ example: 'Raisi integration' }),
112
+ partnerId: z.string().min(1).max(100).nullable().optional(),
113
+ url: z
114
+ .string()
115
+ .url()
116
+ .nullable()
117
+ .optional()
118
+ .openapi({ example: 'https://www.raisi.com' }),
119
+ webhook: z
120
+ .string()
121
+ .url()
122
+ .nullable()
123
+ .optional()
124
+ .openapi({ example: 'https://www.raisi.com/webhook' }),
125
+ active: z.boolean().nullable().optional(),
126
+ metadata: z
127
+ .record(z.string(), z.unknown())
128
+ .nullable()
129
+ .optional()
130
+ .openapi({ example: { key: 'value' } }),
131
+ });
132
+ export type PatchAccountIntegrationZod = z.infer<
133
+ typeof PatchAccountIntegrationZod
134
+ >;
135
+
136
+ export const AccountIntegrationFiltersZod = z.object({
137
+ search: z.string().max(50).optional(),
138
+ integration: z.nativeEnum(IntegrationType).optional(),
139
+ active: z.boolean().optional(),
140
+ });
141
+ export type AccountIntegrationFiltersZod = z.infer<
142
+ typeof AccountIntegrationFiltersZod
143
+ >;
@@ -0,0 +1,124 @@
1
+ import { extendZodWithOpenApi } from '@anatine/zod-openapi';
2
+ import { z } from 'zod';
3
+ import { TypeID } from 'typeid-js';
4
+ import { IBaseEntity } from './entity.types';
5
+ import { PhoneNumberData } from './sms.types';
6
+ import { userIdSchema, UserZod } from './user.types';
7
+ import { IPaginationMeta } from './common.types';
8
+ import { PhoneZodSchema } from './phone.type';
9
+
10
+ extendZodWithOpenApi(z);
11
+ export const accountManagerIdSchema = z.string().refine(
12
+ (value) => {
13
+ try {
14
+ const tid = TypeID.fromString(value);
15
+ return tid.getType() === 'account_manager';
16
+ } catch {
17
+ return false;
18
+ }
19
+ },
20
+ {
21
+ message: `Invalid account manager ID format. Must be a valid TypeID with "account_manager" prefix. Example: account_manager_01j5y5ghx5fg68d663j1fvy2x7`,
22
+ },
23
+ );
24
+
25
+ export const accountManagersInclude = z.enum(['accounts', 'user']);
26
+
27
+ /**
28
+ * @description Query parameters for including related entities
29
+ * @xample in contract us as -> query: z.object({}).merge(AccountManagersIncludeQuery),
30
+ */
31
+ export const AccountManagersIncludeQuery = z.object({
32
+ include: z
33
+ .string()
34
+ .optional()
35
+ .transform((str) => (str ? str.split(',') : []))
36
+ .refine(
37
+ (includes) =>
38
+ includes.every((include) =>
39
+ accountManagersInclude.options.includes(include as any),
40
+ ),
41
+ {
42
+ message: `Invalid include option provided. Valid options are: ${accountManagersInclude.options.join(',')}`,
43
+ },
44
+ )
45
+ .openapi({
46
+ example: `${accountManagersInclude.options.join(',')}`,
47
+ }),
48
+ });
49
+
50
+ export const IAccountManagerZod = IBaseEntity.extend({
51
+ firstName: z.string().openapi({ example: 'John' }),
52
+ lastName: z.string().openapi({ example: 'Doe' }),
53
+ email: z.string().email().openapi({ example: 'john.doe@example.com' }),
54
+ phone: PhoneNumberData.nullable().openapi({ example: '+12124567890' }),
55
+ isDefault: z.boolean().openapi({ example: false }),
56
+ userId: z
57
+ .lazy(() => userIdSchema)
58
+ .nullable()
59
+ .openapi({ example: 'user_01je6ht4b8fbmttkzh2hs82xqp' }),
60
+ user: z
61
+ .lazy(() => UserZod)
62
+ .optional()
63
+ .nullable(),
64
+ });
65
+
66
+ export type IAccountManagerZod = z.infer<typeof IAccountManagerZod>;
67
+
68
+ export const PostAccountManagerZod = z.object({
69
+ firstName: z.string().min(1).max(255).openapi({ example: 'John' }),
70
+ lastName: z.string().min(1).max(255).openapi({ example: 'Doe' }),
71
+ email: z.string().email().openapi({ example: 'john.doe@example.com' }),
72
+ phone: PhoneZodSchema.nullable()
73
+ .optional()
74
+ .openapi({ example: '+12124567890' }),
75
+ isDefault: z.boolean().openapi({ example: false }),
76
+ });
77
+
78
+ export type PostAccountManagerZod = z.infer<typeof PostAccountManagerZod>;
79
+
80
+ export const PatchAccountManagerZod = z.object({
81
+ firstName: z.string().min(1).max(255).optional().openapi({ example: 'John' }),
82
+ lastName: z.string().min(1).max(255).optional().openapi({ example: 'Doe' }),
83
+ email: z
84
+ .string()
85
+ .email()
86
+ .optional()
87
+ .openapi({ example: 'john.doe@example.com' }),
88
+ phone: PhoneZodSchema.nullable()
89
+ .optional()
90
+ .openapi({ example: '+12124567890' }),
91
+ isDefault: z.boolean().optional().openapi({ example: false }),
92
+ });
93
+ export type PatchAccountManagerZod = z.infer<typeof PatchAccountManagerZod>;
94
+
95
+ export const IPaginatedAccountManager = z.object({
96
+ items: z.array(IAccountManagerZod),
97
+ meta: IPaginationMeta,
98
+ });
99
+ export type IPaginatedAccountManager = z.infer<typeof IPaginatedAccountManager>;
100
+
101
+ export const AccountManagerDeleteResponse = z.object({
102
+ status: z.boolean().openapi({ example: true }),
103
+ });
104
+ export type AccountManagerDeleteResponse = z.infer<
105
+ typeof AccountManagerDeleteResponse
106
+ >;
107
+ export const SetDefaultAccountManagerForAllAccountsResponse = z.object({
108
+ message: z
109
+ .string()
110
+ .openapi({ example: 'Default account manager set for all accounts' }),
111
+ });
112
+ export type SetDefaultAccountManagerForAllAccountsResponse = z.infer<
113
+ typeof SetDefaultAccountManagerForAllAccountsResponse
114
+ >;
115
+
116
+ export const AccountManagerDeleteQuery = z.object({
117
+ reassignTo: accountManagerIdSchema
118
+ .nullable()
119
+ .optional()
120
+ .openapi({ example: 'account_manager_01j5y5ghx5fg68d663j1fvy2x7' }),
121
+ });
122
+ export type AccountManagerDeleteQuery = z.infer<
123
+ typeof AccountManagerDeleteQuery
124
+ >;