@dalmore/api-contracts 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/package.json +4 -5
  2. package/src/common/types/account-contact.types.ts +98 -0
  3. package/src/common/types/account-detail.types.ts +27 -0
  4. package/src/common/types/account-integration.types.ts +143 -0
  5. package/src/common/types/account-manager.types.ts +124 -0
  6. package/src/common/types/account.types.ts +296 -0
  7. package/src/common/types/activity.types.ts +274 -0
  8. package/src/common/types/address.spec.ts +203 -0
  9. package/src/common/types/address.types.ts +41 -0
  10. package/src/common/types/aic.types.ts +246 -0
  11. package/src/common/types/aml.types.ts +18 -0
  12. package/src/common/types/api-key-logs.types.ts +66 -0
  13. package/src/common/types/api-keys.types.ts +69 -0
  14. package/src/common/types/asset.types.ts +338 -0
  15. package/src/common/types/auth.types.ts +370 -0
  16. package/src/common/types/batch-jobs.types.ts +151 -0
  17. package/src/common/types/bonus-tier.types.ts +147 -0
  18. package/src/common/types/cart.types.ts +18 -0
  19. package/src/common/types/checklist-items.types.ts +70 -0
  20. package/src/common/types/checklist.types.ts +97 -0
  21. package/src/common/types/common.types.spec.ts +336 -0
  22. package/src/common/types/common.types.ts +1520 -0
  23. package/src/common/types/comply-advantage-api.types.ts +316 -0
  24. package/src/common/types/comply-advantage.types.ts +25 -0
  25. package/src/common/types/contact-us.types.ts +107 -0
  26. package/src/common/types/contract-helpers.ts +205 -0
  27. package/src/common/types/countries.types.ts +375 -0
  28. package/src/common/types/covered-person.types.ts +274 -0
  29. package/src/common/types/dashboard.types.ts +799 -0
  30. package/src/common/types/data-record.types.ts +325 -0
  31. package/src/common/types/data-room.types.ts +242 -0
  32. package/src/common/types/default-theme-config.types.ts +87 -0
  33. package/src/common/types/disbursement-adjustment.types.ts +32 -0
  34. package/src/common/types/disbursement-approval-user.types.ts +100 -0
  35. package/src/common/types/disbursement-review.types.ts +110 -0
  36. package/src/common/types/disbursement-transaction.types.ts +72 -0
  37. package/src/common/types/disbursements.types.ts +310 -0
  38. package/src/common/types/domain-filter.types.ts +55 -0
  39. package/src/common/types/email-theme.types.ts +442 -0
  40. package/src/common/types/entity.types.ts +15 -0
  41. package/src/common/types/error-responses.types.ts +135 -0
  42. package/src/common/types/escrow-account.types.ts +104 -0
  43. package/src/common/types/exchange-api-key.types.ts +121 -0
  44. package/src/common/types/exchange-import.types.ts +36 -0
  45. package/src/common/types/exchange-provider.types.ts +329 -0
  46. package/src/common/types/file.types.ts +461 -0
  47. package/src/common/types/files.types.spec.ts +154 -0
  48. package/src/common/types/health.types.ts +29 -0
  49. package/src/common/types/index.ts +48 -0
  50. package/src/common/types/individuals.types.ts +554 -0
  51. package/src/common/types/investor-account.types.ts +1239 -0
  52. package/src/common/types/investorAccountIdSchema.type.ts +0 -0
  53. package/src/common/types/investors-offering.types.ts +65 -0
  54. package/src/common/types/invite.types.ts +133 -0
  55. package/src/common/types/issuer-bank-account.types.ts +107 -0
  56. package/src/common/types/issuer-offering.types.ts +306 -0
  57. package/src/common/types/issuer-payment-method.types.spec.ts +612 -0
  58. package/src/common/types/issuer-payment-method.types.ts +341 -0
  59. package/src/common/types/issuer.types.ts +312 -0
  60. package/src/common/types/job-item.types.ts +119 -0
  61. package/src/common/types/jobs.types.ts +171 -0
  62. package/src/common/types/kyb.types.ts +53 -0
  63. package/src/common/types/kyc.types.ts +188 -0
  64. package/src/common/types/legal-entity.types.ts +185 -0
  65. package/src/common/types/login-history.types.ts +46 -0
  66. package/src/common/types/mail-template.types.ts +436 -0
  67. package/src/common/types/north-cap-integration.types.ts +190 -0
  68. package/src/common/types/note.types.ts +109 -0
  69. package/src/common/types/notification.types.ts +58 -0
  70. package/src/common/types/notion-api.types.ts +374 -0
  71. package/src/common/types/notion-database.types.ts +125 -0
  72. package/src/common/types/notion-page.types.ts +267 -0
  73. package/src/common/types/offering-reports.types.ts +153 -0
  74. package/src/common/types/offering-submission.types.ts +314 -0
  75. package/src/common/types/offering.types.spec.ts +91 -0
  76. package/src/common/types/offering.types.ts +590 -0
  77. package/src/common/types/page-revision.types.ts +86 -0
  78. package/src/common/types/page.types.ts +436 -0
  79. package/src/common/types/password.type.ts +15 -0
  80. package/src/common/types/payment-methods.types.ts +298 -0
  81. package/src/common/types/phone.spec.ts +76 -0
  82. package/src/common/types/phone.type.ts +27 -0
  83. package/src/common/types/portfolio.types.ts +50 -0
  84. package/src/common/types/privacy-policy-and-tos.types.ts +231 -0
  85. package/src/common/types/queue.types.ts +112 -0
  86. package/src/common/types/registered-reps.types.ts +25 -0
  87. package/src/common/types/rejection-reasons.types.ts +56 -0
  88. package/src/common/types/reminder-config.types.ts +40 -0
  89. package/src/common/types/review.types.ts +133 -0
  90. package/src/common/types/role.types.ts +26 -0
  91. package/src/common/types/secondary-customer.types.ts +66 -0
  92. package/src/common/types/secondary-issuer.types.ts +50 -0
  93. package/src/common/types/secondary-order.types.ts +58 -0
  94. package/src/common/types/secondary-security.types.ts +60 -0
  95. package/src/common/types/secondary-trade.entity.ts +16 -0
  96. package/src/common/types/secondary-trade.types.ts +95 -0
  97. package/src/common/types/secure-request.types.ts +68 -0
  98. package/src/common/types/signer.types.ts +651 -0
  99. package/src/common/types/site-link.types.spec.ts +134 -0
  100. package/src/common/types/site-link.types.ts +166 -0
  101. package/src/common/types/site-settings.types.ts +726 -0
  102. package/src/common/types/site.types.ts +270 -0
  103. package/src/common/types/sms.types.ts +30 -0
  104. package/src/common/types/state-machine.types.ts +177 -0
  105. package/src/common/types/states.types.ts +163 -0
  106. package/src/common/types/subdoc-preview.types.ts +35 -0
  107. package/src/common/types/task.types.ts +258 -0
  108. package/src/common/types/trade-adjustment.type.ts +33 -0
  109. package/src/common/types/trade-line-item.type.ts +132 -0
  110. package/src/common/types/trade.types.ts +929 -0
  111. package/src/common/types/transaction.types.ts +198 -0
  112. package/src/common/types/trusted-contact.types.ts +122 -0
  113. package/src/common/types/typography.types.ts +75 -0
  114. package/src/common/types/user-manual.types.ts +290 -0
  115. package/src/common/types/user-setting.types.ts +133 -0
  116. package/src/common/types/user.types.ts +320 -0
  117. package/src/common/types/webhook.types.ts +588 -0
  118. package/src/common/types/zip.type.ts +36 -0
  119. package/src/contracts/clients/accounts/index.ts +61 -0
  120. package/src/contracts/clients/aic/index.ts +59 -0
  121. package/src/contracts/clients/api-key-logs/index.ts +53 -0
  122. package/src/contracts/clients/api-keys/index.ts +73 -0
  123. package/src/contracts/clients/assets/index.ts +102 -0
  124. package/src/contracts/clients/auth/index.ts +50 -0
  125. package/src/contracts/clients/files/index.ts +166 -0
  126. package/src/contracts/clients/files-public/index.ts +166 -0
  127. package/src/contracts/clients/index.ts +44 -0
  128. package/src/contracts/clients/individuals/index.ts +93 -0
  129. package/src/contracts/clients/investor-accounts/index.ts +93 -0
  130. package/src/contracts/clients/issuers/index.ts +94 -0
  131. package/src/contracts/clients/legal-entities/index.ts +93 -0
  132. package/src/contracts/clients/offerings/index.ts +117 -0
  133. package/src/contracts/clients/secure-requests/index.ts +34 -0
  134. package/src/contracts/clients/sites/index.ts +56 -0
  135. package/src/contracts/clients/trades/index.ts +122 -0
  136. package/index.d.mts +0 -17
  137. package/index.d.ts +0 -17
@@ -0,0 +1,100 @@
1
+ import { TypeID } from 'typeid-js';
2
+ import { z } from 'zod';
3
+ import { IBaseEntity } from './entity.types';
4
+ import { accountIdSchema } from './account.types';
5
+ import { AccountZod, IPaginationMeta } from './common.types';
6
+ import { userIdSchema, UserZod } from './user.types';
7
+
8
+ export const disbursementApprovalUserIdSchema = z.string().refine(
9
+ (value) => {
10
+ try {
11
+ const tid = TypeID.fromString(value);
12
+ return tid.getType() === 'disbursement_approval_user';
13
+ } catch {
14
+ return false;
15
+ }
16
+ },
17
+ {
18
+ message:
19
+ 'Invalid disbursement approval user ID format. Must be a valid TypeID with "disbursement_approval_user" prefix.',
20
+ },
21
+ );
22
+
23
+ export enum DisbursementApprovalUsersRole {
24
+ CREATOR = 'CREATOR',
25
+ APPROVER = 'APPROVER',
26
+ }
27
+
28
+ export const DisbursementApprovalUserZod = IBaseEntity.extend({
29
+ role: z.nativeEnum(DisbursementApprovalUsersRole),
30
+ accountId: accountIdSchema,
31
+ account: z
32
+ .lazy(() => AccountZod)
33
+ .optional()
34
+ .nullable(),
35
+ userId: userIdSchema,
36
+ user: UserZod.optional().nullable(),
37
+ });
38
+
39
+ export type DisbursementApprovalUserZod = z.infer<
40
+ typeof DisbursementApprovalUserZod
41
+ >;
42
+
43
+ export const PostDisbursementApprovalUser = z.object({
44
+ role: z.nativeEnum(DisbursementApprovalUsersRole),
45
+ userId: userIdSchema,
46
+ });
47
+ export type PostDisbursementApprovalUser = z.infer<
48
+ typeof PostDisbursementApprovalUser
49
+ >;
50
+
51
+ export const PostComplianceDisbursementApprovalUser =
52
+ PostDisbursementApprovalUser.extend({
53
+ accountId: accountIdSchema.optional().openapi({
54
+ example: 'account_00041061050r3gg28a1c60t3gf',
55
+ }),
56
+ });
57
+ export type PostComplianceDisbursementApprovalUser = z.infer<
58
+ typeof PostComplianceDisbursementApprovalUser
59
+ >;
60
+
61
+ export const DisbursementApprovalUserFiltersZod = z.object({
62
+ userId: userIdSchema.optional(),
63
+ role: z.nativeEnum(DisbursementApprovalUsersRole).optional(),
64
+ accountId: accountIdSchema.optional(),
65
+ });
66
+
67
+ export const IPaginatedDisbursementApprovalUser = z.object({
68
+ items: z.array(DisbursementApprovalUserZod),
69
+ meta: IPaginationMeta,
70
+ });
71
+ export type IPaginatedDisbursementApprovalUser = z.infer<
72
+ typeof IPaginatedDisbursementApprovalUser
73
+ >;
74
+
75
+ const disbursementApprovalUsersInclude = z.enum(['user', 'account']);
76
+
77
+ /**
78
+ * @description Query parameters for including related entities
79
+ * @xample in contract us as -> query: z.object({}).merge(DisbursementApprovalUsersIncludeQuery),
80
+ */
81
+ export const DisbursementApprovalUsersIncludeQuery = z.object({
82
+ include: z
83
+ .string()
84
+ .optional()
85
+ .transform((str) => (str ? str.split(',') : []))
86
+ .refine(
87
+ (includes) =>
88
+ includes.every((include) =>
89
+ disbursementApprovalUsersInclude.options.includes(include as any),
90
+ ),
91
+ {
92
+ message: `Invalid include option provided. Valid options are: ${disbursementApprovalUsersInclude.options.join(',')}`,
93
+ },
94
+ )
95
+ .openapi({
96
+ example: `${disbursementApprovalUsersInclude.options.join(',')}`,
97
+ }),
98
+ });
99
+ export interface DisbursementApprovalUsersIncludeQuery
100
+ extends z.infer<typeof DisbursementApprovalUsersIncludeQuery> {}
@@ -0,0 +1,110 @@
1
+ import { TypeID } from 'typeid-js';
2
+ import { z } from 'zod';
3
+ import { userIdSchema, UserZod } from './user.types';
4
+ import {
5
+ disbursementIdSchema,
6
+ DisbursementStatus,
7
+ } from './disbursements.types';
8
+ import { IBaseEntity } from './entity.types';
9
+ import { accountIdSchema } from './account.types';
10
+ import { AccountZod, ComplianceReview, IPaginationMeta } from './common.types';
11
+
12
+ export const disbursementReviewIdSchema = z.string().refine(
13
+ (value) => {
14
+ try {
15
+ const tid = TypeID.fromString(value);
16
+ return tid.getType() === 'disbursement_review';
17
+ } catch {
18
+ return false;
19
+ }
20
+ },
21
+ {
22
+ message:
23
+ 'Invalid disbursement review ID format. Must be a valid TypeID with "disbursement_review" prefix.',
24
+ },
25
+ );
26
+
27
+ export const PostDisbursementReviewZod = z.object({
28
+ disbursementReview: z.enum(['APPROVED', 'REJECTED']),
29
+ disbursements: z
30
+ .array(disbursementIdSchema)
31
+ .min(1, 'disbursement is required')
32
+ .max(1, 'Maximum of 1 disbursement allowed')
33
+ .openapi({
34
+ example: ['disbursement_01jjsdrx1seqfse7z4z47sgdp5'],
35
+ }),
36
+ });
37
+
38
+ export type PostDisbursementReviewZod = z.infer<
39
+ typeof PostDisbursementReviewZod
40
+ >;
41
+
42
+ export const DisbursementReviewZod = IBaseEntity.extend({
43
+ accountId: accountIdSchema,
44
+ account: AccountZod.optional().nullable(),
45
+ userId: userIdSchema,
46
+ user: UserZod.optional().nullable(),
47
+ status: z.nativeEnum(DisbursementStatus),
48
+ });
49
+
50
+ export type DisbursementReviewZod = z.infer<typeof DisbursementReviewZod>;
51
+
52
+ export const IPaginatedDisbursementReviews = z.object({
53
+ items: z.array(DisbursementReviewZod),
54
+ meta: IPaginationMeta,
55
+ });
56
+ export type IPaginatedDisbursementReviews = z.infer<
57
+ typeof IPaginatedDisbursementReviews
58
+ >;
59
+
60
+ const disbursementReviewsInclude = z.enum(['user', 'account', 'disbursement']);
61
+
62
+ /**
63
+ * @description Query parameters for including related entities
64
+ * @xample in contract us as -> query: z.object({}).merge(DisbursementReviewsIncludeQuery),
65
+ */
66
+ export const DisbursementReviewsIncludeQuery = z.object({
67
+ include: z
68
+ .string()
69
+ .optional()
70
+ .transform((str) => (str ? str.split(',') : []))
71
+ .refine(
72
+ (includes) =>
73
+ includes.every((include) =>
74
+ disbursementReviewsInclude.options.includes(include as any),
75
+ ),
76
+ {
77
+ message: `Invalid include option provided. Valid options are: ${disbursementReviewsInclude.options.join(',')}`,
78
+ },
79
+ )
80
+ .openapi({
81
+ example: `${disbursementReviewsInclude.options.join(',')}`,
82
+ }),
83
+ });
84
+ export interface DisbursementReviewsIncludeQuery
85
+ extends z.infer<typeof DisbursementReviewsIncludeQuery> {}
86
+
87
+ export const DisbursementReviewFiltersZod = z.object({
88
+ disbursementId: disbursementIdSchema,
89
+ });
90
+
91
+ export const PostComplianceReviewDisbursementZod = z.object({
92
+ complianceReview: z.enum([
93
+ ComplianceReview.APPROVED,
94
+ ComplianceReview.REJECTED,
95
+ ]),
96
+ disbursements: z
97
+ .array(disbursementIdSchema)
98
+ .min(1, 'At least one disbursement is required')
99
+ .max(50, 'Maximum of 50 disbursements allowed')
100
+ .openapi({
101
+ example: [
102
+ 'disbursement_01jjsdrx1seqfse7z4z47sgdp5',
103
+ 'disbursement_01jjsdrx27enkszq5cnc3hdhrf',
104
+ ],
105
+ }),
106
+ });
107
+
108
+ export type PostComplianceReviewDisbursementZod = z.infer<
109
+ typeof PostComplianceReviewDisbursementZod
110
+ >;
@@ -0,0 +1,72 @@
1
+ import { TypeID } from 'typeid-js';
2
+ import { z } from 'zod';
3
+
4
+ import { accountIdSchema } from './account.types';
5
+ import { IBaseEntity } from './entity.types';
6
+ import { dateSchema } from './common.types';
7
+ import { TransactionStatus, TransactionType } from './transaction.types';
8
+ import { disbursementIdSchema, DisbursementZod } from './disbursements.types';
9
+
10
+ export const disbursementTransactionIdSchema = z.string().refine(
11
+ (value) => {
12
+ try {
13
+ const tid = TypeID.fromString(value);
14
+ return tid.getType() === 'disbursement_transaction';
15
+ } catch {
16
+ return false;
17
+ }
18
+ },
19
+ {
20
+ message: `Invalid disbursement transaction ID format. Must be a valid TypeID with "disbursement_transaction" prefix.`,
21
+ },
22
+ );
23
+
24
+ export const DisbursementTransactionZod = IBaseEntity.extend({
25
+ id: disbursementTransactionIdSchema,
26
+ accountId: accountIdSchema,
27
+ type: z.nativeEnum(TransactionType),
28
+ status: z.nativeEnum(TransactionStatus),
29
+ tid: z.string().nullable(),
30
+ amount: z.number(),
31
+ currencyCode: z.string(),
32
+ chargedAt: z.date().nullable(),
33
+ cancelledAt: z.date().nullable(),
34
+ disbursementId: z.lazy(() => disbursementIdSchema).nullable(),
35
+ disbursement: z
36
+ .lazy(() => DisbursementZod)
37
+ .optional()
38
+ .nullable(),
39
+ });
40
+ export type DisbursementTransactionZod = z.infer<
41
+ typeof DisbursementTransactionZod
42
+ >;
43
+
44
+ export const PostDisbursementTransactionZod = z.object({
45
+ tid: z.string().min(6).max(64).openapi({ example: 'TXN8A7B6C5' }),
46
+ type: z
47
+ .nativeEnum(TransactionType)
48
+ .openapi({ example: TransactionType.CHARGE }),
49
+ amount: z.number().min(0.01).max(10000000000).openapi({ example: 2000 }),
50
+ disbursementId: z
51
+ .lazy(() => disbursementIdSchema)
52
+ .openapi({
53
+ example: 'disbursement_01j5y5ghx5fg68d663j1fvy2x7',
54
+ }),
55
+ });
56
+ export type PostDisbursementTransactionZod = z.infer<
57
+ typeof PostDisbursementTransactionZod
58
+ >;
59
+
60
+ export const CompliancePostDisbursementTransactionZod =
61
+ PostDisbursementTransactionZod.merge(
62
+ z.object({
63
+ chargedAt: dateSchema.refine(
64
+ (date) => date instanceof Date && date <= new Date(),
65
+ { message: 'date cannot be in the future' },
66
+ ),
67
+ accountId: accountIdSchema,
68
+ }),
69
+ );
70
+ export type CompliancePostDisbursementTransactionZod = z.infer<
71
+ typeof CompliancePostDisbursementTransactionZod
72
+ >;
@@ -0,0 +1,310 @@
1
+ import { z } from 'zod';
2
+ import { IBaseEntity } from './entity.types';
3
+ import { IOffering, offeringIdSchema } from './offering.types';
4
+ import {
5
+ AccountZod,
6
+ BaseStatus,
7
+ ComplianceReview,
8
+ dateSchema,
9
+ IPaginationMeta,
10
+ } from './common.types';
11
+ import { tradeIdSchema } from './trade.types';
12
+ import { accountIdSchema } from './account.types';
13
+ import { TypeID } from 'typeid-js';
14
+ import { issuerIdSchema } from './issuer.types';
15
+ import { issuerBankAccountIdSchema } from './issuer-bank-account.types';
16
+ import { userIdSchema, UserZod } from './user.types';
17
+ import {
18
+ PostDisbursementAdjustmentZod,
19
+ DisbursementAdjustmentType,
20
+ } from './disbursement-adjustment.types';
21
+ import { escrowAccountIdSchema } from './escrow-account.types';
22
+
23
+ export const disbursementIdSchema = z.string().refine(
24
+ (value) => {
25
+ try {
26
+ const tid = TypeID.fromString(value);
27
+ return tid.getType() === 'disbursement';
28
+ } catch {
29
+ return false;
30
+ }
31
+ },
32
+ {
33
+ message:
34
+ 'Invalid disbursement ID format. Must be a valid TypeID with "disbursement" prefix.',
35
+ },
36
+ );
37
+
38
+ export enum DisbursementStatus {
39
+ PENDING = BaseStatus.PENDING,
40
+ APPROVED = BaseStatus.APPROVED,
41
+ REJECTED = BaseStatus.REJECTED,
42
+ SETTLED = BaseStatus.SETTLED,
43
+ COMPLETED = BaseStatus.COMPLETED,
44
+ }
45
+
46
+ export const DisbursementZod = IBaseEntity.extend({
47
+ name: z.string().openapi({ example: 'Dalmore' }),
48
+ status: z
49
+ .nativeEnum(DisbursementStatus)
50
+ .openapi({ example: DisbursementStatus.PENDING }),
51
+ requestedAmount: z.number().openapi({ example: 100 }),
52
+ netAmount: z.number().openapi({ example: 1000 }),
53
+ complianceReview: z.nativeEnum(ComplianceReview),
54
+ approversCount: z.number(),
55
+ disbursedAt: z.date().nullable(),
56
+ accountId: accountIdSchema,
57
+ account: z
58
+ .lazy(() => AccountZod)
59
+ .optional()
60
+ .nullable(),
61
+ offeringId: offeringIdSchema,
62
+ offering: z
63
+ .lazy(() => IOffering)
64
+ .optional()
65
+ .nullable(),
66
+ createdById: userIdSchema,
67
+ createdBy: UserZod.optional().nullable(),
68
+ reviewedById: z
69
+ .string()
70
+ .nullable()
71
+ .openapi({ example: 'user_00041061050r3gg28a1c60t3gf' }),
72
+ });
73
+
74
+ export type DisbursementZod = z.infer<typeof DisbursementZod>;
75
+
76
+ export const PostDisbursementTrades = z.object({
77
+ accountId: accountIdSchema.openapi({
78
+ example: 'account_00041061050r3gg28a1c60t3gf',
79
+ }),
80
+ name: z.string().openapi({ example: 'Dalmore' }),
81
+ offeringId: z
82
+ .lazy(() => offeringIdSchema)
83
+ .openapi({
84
+ example: 'offering_00041061050r3gg28a1c60t3gf',
85
+ }),
86
+ trades: z
87
+ .array(tradeIdSchema)
88
+ .min(1, 'At least one trade is required')
89
+ .max(500, 'Maximum of 500 trades allowed')
90
+ .openapi({
91
+ example: [
92
+ 'trade_00041061050r3gg28a1c60t3gf',
93
+ 'trade_00041061050r3gg28a1c60t3g',
94
+ ],
95
+ }),
96
+ });
97
+ export type PostDisbursementTrades = z.infer<typeof PostDisbursementTrades>;
98
+
99
+ export const PostDisbursementOfferings = z.object({
100
+ accountId: accountIdSchema.openapi({
101
+ example: 'account_00041061050r3gg28a1c60t3gf',
102
+ }),
103
+ name: z.string().openapi({ example: 'Dalmore' }),
104
+ offeringId: z
105
+ .lazy(() => offeringIdSchema)
106
+ .openapi({
107
+ example: 'offering_00041061050r3gg28a1c60t3gf',
108
+ }),
109
+ });
110
+ export type PostDisbursementOfferings = z.infer<
111
+ typeof PostDisbursementOfferings
112
+ >;
113
+
114
+ export const DisbursementFiltersZod = z.object({
115
+ name: z.string().optional(),
116
+ offeringId: z.lazy(() => offeringIdSchema).optional(),
117
+ issuerId: z.lazy(() => issuerIdSchema).optional(),
118
+ search: z.string().optional(),
119
+ status: z
120
+ .nativeEnum(DisbursementStatus)
121
+ .optional()
122
+ .openapi({ example: 'PENDING' }),
123
+ from: dateSchema.optional().openapi({ example: 'MM/DD/YYYY' }),
124
+ to: dateSchema.optional().openapi({ example: 'MM/DD/YYYY' }),
125
+ accountId: accountIdSchema.optional(),
126
+ });
127
+
128
+ export const IPaginatedDisbursement = z.object({
129
+ items: z.array(DisbursementZod),
130
+ meta: IPaginationMeta,
131
+ });
132
+ export type IPaginatedDisbursement = z.infer<typeof IPaginatedDisbursement>;
133
+
134
+ export const disbursementsInclude = z.enum([
135
+ 'createdBy',
136
+ 'reviewedBy',
137
+ 'offering',
138
+ 'account',
139
+ 'issuerBankAccount',
140
+ 'escrowAccount',
141
+ 'disbursementAdjustments',
142
+ 'tradeDisbursements',
143
+ 'disbursementReviews',
144
+ 'disbursementTransactions',
145
+ 'issuer',
146
+ ]);
147
+
148
+ /**
149
+ * @description Query parameters for including related entities
150
+ * @xample in contract us as -> query: z.object({}).merge(DisbursementsIncludeQuery),
151
+ */
152
+ export const DisbursementsIncludeQuery = z.object({
153
+ include: z
154
+ .string()
155
+ .optional()
156
+ .transform((str) => (str ? str.split(',') : []))
157
+ .refine(
158
+ (includes) =>
159
+ includes.every((include) =>
160
+ disbursementsInclude.options.includes(include as any),
161
+ ),
162
+ {
163
+ message: `Invalid include option provided. Valid options are: ${disbursementsInclude.options.join(',')}`,
164
+ },
165
+ )
166
+ .openapi({
167
+ example: `${disbursementsInclude.options.join(',')}`,
168
+ }),
169
+ });
170
+ export interface DisbursementsIncludeQuery
171
+ extends z.infer<typeof DisbursementsIncludeQuery> {}
172
+
173
+ export const PostDisbursementZod = z.object({
174
+ name: z.string().max(50).openapi({ example: 'Dalmore' }),
175
+ offeringId: z
176
+ .lazy(() => offeringIdSchema)
177
+ .openapi({
178
+ example: 'offering_00041061050r3gg28a1c60t3gf',
179
+ }),
180
+ issuerId: z
181
+ .lazy(() => issuerIdSchema)
182
+ .openapi({
183
+ example: 'issuer_00041061050r3gg28a1c60t3gf',
184
+ }),
185
+ issuerBankAccountId: z
186
+ .lazy(() => issuerBankAccountIdSchema)
187
+ .openapi({
188
+ example: 'issuer_bank_account_00041061050r3gg28a1c60t3gf',
189
+ }),
190
+ requestedAmount: z
191
+ .number()
192
+ .min(0.01)
193
+ .max(10000000000)
194
+ .openapi({ example: 2000 }),
195
+ netAmount: z.number().min(0.01).max(10000000000).openapi({ example: 5000 }),
196
+ disbursedAt: dateSchema.optional().nullable(),
197
+ tradeIds: z.array(tradeIdSchema).min(1).max(100),
198
+ disbursementAdjustments: z.array(PostDisbursementAdjustmentZod).refine(
199
+ (adjustments) => {
200
+ const adjustmentTypes = adjustments.map((adj) => adj.type);
201
+ const requiredTypes = Object.values(DisbursementAdjustmentType);
202
+ return requiredTypes.every((type) => adjustmentTypes.includes(type));
203
+ },
204
+ {
205
+ message: `All disbursement adjustments are required: ${Object.values(DisbursementAdjustmentType).join(', ')}`,
206
+ },
207
+ ),
208
+ escrowAccountId: z.lazy(() => escrowAccountIdSchema),
209
+ });
210
+ export type PostDisbursementZod = z.infer<typeof PostDisbursementZod>;
211
+
212
+ export const CompliancePostDisbursementZod = PostDisbursementZod.extend({
213
+ accountId: accountIdSchema,
214
+ });
215
+ export type CompliancePostDisbursementZod = z.infer<
216
+ typeof CompliancePostDisbursementZod
217
+ >;
218
+
219
+ export const DisbursementsMissingConfigQuery = z.object({
220
+ accountId: accountIdSchema.optional(),
221
+ });
222
+ export interface DisbursementsMissingConfigQuery
223
+ extends z.infer<typeof DisbursementsMissingConfigQuery> {}
224
+
225
+ export const DisbursementMissingConfigZod = z.object({
226
+ missingConfigurations: z.array(z.string()),
227
+ });
228
+
229
+ export type DisbursementMissingConfigZod = z.infer<
230
+ typeof DisbursementMissingConfigZod
231
+ >;
232
+
233
+ export const DisbursementSigningLinkZod = z.string().nullable();
234
+
235
+ export type DisbursementSigningLinkZod = z.infer<
236
+ typeof DisbursementSigningLinkZod
237
+ >;
238
+
239
+ export const ComplianceReviewDisbursements = z.object({
240
+ complianceReview: z.enum([
241
+ ComplianceReview.APPROVED,
242
+ ComplianceReview.REJECTED,
243
+ ]),
244
+ disbursements: z
245
+ .array(disbursementIdSchema)
246
+ .min(1, 'At least one disbursement is required')
247
+ .max(50, 'Maximum of 50 disbursements allowed')
248
+ .openapi({
249
+ example: [
250
+ 'disbursement_01jjsdrx1seqfse7z4z47sgdp5',
251
+ 'disbursement_01jjsdrx27enkszq5cnc3hdhrf',
252
+ ],
253
+ }),
254
+ });
255
+ export type ComplianceReviewDisbursements = z.infer<
256
+ typeof ComplianceReviewDisbursements
257
+ >;
258
+
259
+ export const TradeDisbursementZod = z.object({
260
+ id: z
261
+ .lazy(() => disbursementIdSchema)
262
+ .openapi({
263
+ example: 'disbursement_00041061050r3gg28a1c60t3gf',
264
+ }),
265
+ name: z.string().openapi({ example: 'Disbursement Name' }),
266
+ status: z
267
+ .nativeEnum(DisbursementStatus)
268
+ .openapi({ example: DisbursementStatus.PENDING }),
269
+ date: z.date().nullable().openapi({ example: 'MM/DD/YYYY' }),
270
+ });
271
+ export type TradeDisbursementZod = z.infer<typeof TradeDisbursementZod>;
272
+
273
+ export const TradeDisbursementsZod = z.array(TradeDisbursementZod);
274
+ export type TradeDisbursementsZod = z.infer<typeof TradeDisbursementsZod>;
275
+
276
+ export const PostDisbursementBalanceZod = z.object({
277
+ offeringId: offeringIdSchema,
278
+ });
279
+ export type PostDisbursementBalanceZod = z.infer<
280
+ typeof PostDisbursementBalanceZod
281
+ >;
282
+
283
+ export const PostDisbursementSummaryZod = z.object({
284
+ offeringId: offeringIdSchema,
285
+ tradeIds: z.array(tradeIdSchema).min(1).max(1000),
286
+ });
287
+ export type PostDisbursementSummaryZod = z.infer<
288
+ typeof PostDisbursementSummaryZod
289
+ >;
290
+
291
+ export const DisbursementBalanceZod = z.object({
292
+ contingencyAmount: z.number(),
293
+ contingencyStatus: z.string(),
294
+ totalRaised: z.number(),
295
+ totalDisbursed: z.number(),
296
+ totalPending: z.number(),
297
+ totalFees: z.number(),
298
+ refundPool: z.number(),
299
+ availableForDisbursements: z.number(),
300
+ });
301
+ export type DisbursementBalanceZod = z.infer<typeof DisbursementBalanceZod>;
302
+
303
+ export const DisbursementSummaryZod = z.object({
304
+ amountRequested: z.number(),
305
+ brokerageFee: z.number(),
306
+ disbursementFee: z.number(),
307
+ refundPool: z.number(),
308
+ amountToBeTransferred: z.number(),
309
+ });
310
+ export type DisbursementSummaryZod = z.infer<typeof DisbursementSummaryZod>;
@@ -0,0 +1,55 @@
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 { DomainSchema, IPaginationMeta } from './common.types';
6
+ extendZodWithOpenApi(z);
7
+ export const domainFilterIdSchema = z.string().refine(
8
+ (value) => {
9
+ try {
10
+ const tid = TypeID.fromString(value);
11
+ return tid.getType() === 'domain_filter';
12
+ } catch {
13
+ return false;
14
+ }
15
+ },
16
+ {
17
+ message:
18
+ 'Invalid domain filter ID format. Must be a valid TypeID with "domain_filter" prefix. Example: domain_filter_01j5y5ghx5fg68d663j1fvy2x7',
19
+ },
20
+ );
21
+ export const DomainFilterZod = IBaseEntity.extend({
22
+ id: domainFilterIdSchema,
23
+ domain: z.string(),
24
+ });
25
+ export type DomainFilterZod = z.infer<typeof DomainFilterZod>;
26
+
27
+ export const IPaginatedDomainFilter = z.object({
28
+ items: z.array(DomainFilterZod),
29
+ meta: IPaginationMeta,
30
+ });
31
+ export type IPaginatedDomainFilter = z.infer<typeof IPaginatedDomainFilter>;
32
+
33
+ export const PostDomainFilterZod = z.object({
34
+ domain: DomainSchema.openapi({ example: 'dalmoregroup.com' }),
35
+ });
36
+ export type PostDomainFilterZod = z.infer<typeof PostDomainFilterZod>;
37
+
38
+ export const PatchDomainFilterZod = PostDomainFilterZod.extend({});
39
+ export type PatchDomainFilterZod = z.infer<typeof PatchDomainFilterZod>;
40
+
41
+ export const DomainFilterFiltersZod = z.object({
42
+ domain: z
43
+ .string()
44
+ .max(30)
45
+ .optional()
46
+ .openapi({ example: 'dalmoregroup.com' }),
47
+ });
48
+ export type DomainFilterFiltersZod = z.infer<typeof DomainFilterFiltersZod>;
49
+
50
+ export const DomainFilterDeleteResponseZod = z.object({
51
+ message: z.string(),
52
+ });
53
+ export type DomainFilterDeleteResponseZod = z.infer<
54
+ typeof DomainFilterDeleteResponseZod
55
+ >;