@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,341 @@
1
+ import { TypeID } from 'typeid-js';
2
+ import { z } from 'zod';
3
+ import {
4
+ PaymentMethodProvider,
5
+ PaymentMethodType,
6
+ } from './payment-methods.types';
7
+ import { issuerIdSchema, IIssuer } from './issuer.types';
8
+ import { IBaseEntity } from './entity.types';
9
+ import { IPaginationMeta, REDACTED } from './common.types';
10
+ import { StateCode } from './states.types';
11
+ import { CountryCode } from './countries.types';
12
+ import { accountIdSchema } from './account.types';
13
+ import { fileIdSchema } from './file.types';
14
+
15
+ export const issuerPaymentMethodIdSchema = z.string().refine(
16
+ (value) => {
17
+ try {
18
+ const tid = TypeID.fromString(value);
19
+ return tid.getType() === 'issuer_payment_method';
20
+ } catch {
21
+ return false;
22
+ }
23
+ },
24
+ {
25
+ message: `Invalid issuer_payment_method ID format. Must be a valid TypeID with "issuer_payment_method" prefix. Example: issuer_payment_method_01j5y5ghx5fg68d663j1fvy2x7`,
26
+ },
27
+ );
28
+
29
+ export const issuerPaymentMethodIntegrationIdSchema = z.string().refine(
30
+ (value) => {
31
+ try {
32
+ const tid = TypeID.fromString(value);
33
+ return tid.getType() === 'issuer_payment_method_integration';
34
+ } catch {
35
+ return false;
36
+ }
37
+ },
38
+ {
39
+ message: `Invalid issuer_payment_method_integration ID format. Must be a valid TypeID with "issuer_payment_method_integration" prefix. Example: issuer_payment_method_integration_01j5y5ghx5fg68d663j1fvy2x7`,
40
+ },
41
+ );
42
+
43
+ export enum IssuerPaymentMethodIntegrationStatus {
44
+ PENDING = 'PENDING',
45
+ CONNECTED = 'CONNECTED',
46
+ DISCONNECTED = 'DISCONNECTED',
47
+ }
48
+
49
+ export const IssuerPaymentMethodIntegration = IBaseEntity.extend({
50
+ id: issuerPaymentMethodIntegrationIdSchema,
51
+ integrationStatus: z
52
+ .nativeEnum(IssuerPaymentMethodIntegrationStatus)
53
+ .openapi({
54
+ example: IssuerPaymentMethodIntegrationStatus.PENDING,
55
+ }),
56
+ issuerPaymentMethodId: issuerPaymentMethodIdSchema,
57
+ integrationAccountId: z.string().nullable(),
58
+ integrationAccountEmail: z.string().nullable(),
59
+ integrationAccountLink: z.string().nullable(),
60
+ integrationAccountLinkExpiresAt: z
61
+ .union([z.number(), z.string().transform((val) => parseInt(val, 10))])
62
+ .nullable(), // the reason we need to do this is Unix timestamps stored as BIGINT in PostgreSQL. The value 1759727425634 is likely a Unix timestamp in milliseconds, which exceeds JavaScript's safe integer range, so TypeORM returns it as a string to prevent precision loss.
63
+ });
64
+ export type IssuerPaymentMethodIntegration = z.infer<
65
+ typeof IssuerPaymentMethodIntegration
66
+ >;
67
+
68
+ export const IPaginatedIssuerPaymentMethodIntegrations = z.object({
69
+ items: z.array(IssuerPaymentMethodIntegration),
70
+ meta: IPaginationMeta,
71
+ });
72
+ export type IPaginatedIssuerPaymentMethodIntegrations = z.infer<
73
+ typeof IPaginatedIssuerPaymentMethodIntegrations
74
+ >;
75
+
76
+ export const IIssuerPaymentMethod = IBaseEntity.extend({
77
+ paymentMethodType: z
78
+ .nativeEnum(PaymentMethodType)
79
+ .openapi({ example: PaymentMethodType.CREDIT_CARD }),
80
+ paymentMethodProvider: z.nativeEnum(PaymentMethodProvider).openapi({
81
+ example: PaymentMethodProvider.STRIPE,
82
+ }),
83
+ enabled: z.boolean().openapi({ example: true }),
84
+ issuerId: issuerIdSchema.openapi({
85
+ example: 'issuer_01jdq2crwke8xskjd840cj79pw',
86
+ }),
87
+ config: z
88
+ .any()
89
+ .transform((config) => {
90
+ if (!config) return null;
91
+ const configData =
92
+ typeof config === 'string' ? JSON.parse(config) : config;
93
+
94
+ if (configData.stripeSecretKey) {
95
+ configData.stripeSecretKey = REDACTED;
96
+ }
97
+
98
+ return configData;
99
+ })
100
+ .nullable()
101
+ .optional(),
102
+ issuer: IIssuer.optional().nullable(),
103
+ integration: IssuerPaymentMethodIntegration.nullable().optional(),
104
+ });
105
+ export type IIssuerPaymentMethod = z.infer<typeof IIssuerPaymentMethod>;
106
+
107
+ export const stripeConfigSchema = z.object({
108
+ stripeAccountId: z.string().nullable(),
109
+ });
110
+
111
+ export const wireConfigSchema = z.object({
112
+ usAccountHolderName: z.string().nullable(),
113
+ usBankName: z.string().nullable(),
114
+ usRoutingNumber: z
115
+ .string()
116
+ .length(9, { message: 'Routing number must be 9 digits' })
117
+ .regex(/^\d{9}$/, { message: 'Routing number must be numeric digits' })
118
+ .nullable(),
119
+ usAccountNumber: z
120
+ .string()
121
+ .min(8, { message: 'Account number must be at least 8 digits' })
122
+ .max(17, { message: 'Account number must be at most 17 digits' })
123
+ .regex(/^\d+$/, { message: 'Account number must be numeric digits' })
124
+ .nullable(),
125
+ reference: z
126
+ .string()
127
+ .min(1, { message: 'Reference must be at least 1 character' })
128
+ .max(255, { message: 'Reference must be at most 255 characters' })
129
+ .nullable()
130
+ .optional(),
131
+ swiftId: z
132
+ .string()
133
+ .min(8, { message: 'Swift ID must be at least 8 characters' })
134
+ .max(11, { message: 'Swift ID must be at most 11 characters' })
135
+ .nullable()
136
+ .optional(),
137
+ });
138
+ export type WireConfig = z.infer<typeof wireConfigSchema>;
139
+
140
+ export const checkConfigSchema = z.object({
141
+ companyName: z.string().nullable(),
142
+ address: z.string().nullable(),
143
+ address2: z.string().optional().nullable(),
144
+ city: z.string().nullable(),
145
+ state: z.nativeEnum(StateCode).nullable().openapi({ example: 'CA' }),
146
+ zip: z
147
+ .string()
148
+ .regex(/^\d{5}$/, {
149
+ message: 'Invalid ZIP code. It must be a 5-digit number.',
150
+ })
151
+ .nullable()
152
+ .openapi({ example: '90015' }),
153
+ country: z.nativeEnum(CountryCode).nullable().openapi({ example: 'US' }),
154
+ reference: z
155
+ .string()
156
+ .min(1, { message: 'Reference must be at least 1 character' })
157
+ .max(255, { message: 'Reference must be at most 255 characters' })
158
+ .nullable()
159
+ .optional(),
160
+ });
161
+
162
+ export type CheckConfig = z.infer<typeof checkConfigSchema>;
163
+
164
+ export const retirementConfigSchema = z.object({
165
+ custodianInstruction: z.string().min(1).max(1000).nullable().openapi({
166
+ example: 'This is a test custodian instruction',
167
+ }),
168
+ custodianDocument: z
169
+ .lazy(() => fileIdSchema)
170
+ .optional()
171
+ .nullable(),
172
+ });
173
+
174
+ export const PatchIssuerPaymentMethodZod = z.discriminatedUnion(
175
+ 'paymentMethodType',
176
+ [
177
+ z.object({
178
+ paymentMethodType: z.literal(PaymentMethodType.CREDIT_CARD),
179
+ config: stripeConfigSchema,
180
+ }),
181
+ z.object({
182
+ paymentMethodType: z.literal(PaymentMethodType.ACH),
183
+ config: stripeConfigSchema,
184
+ }),
185
+ z.object({
186
+ paymentMethodType: z.literal(PaymentMethodType.BANK_ACCOUNT),
187
+ config: stripeConfigSchema,
188
+ }),
189
+ z.object({
190
+ paymentMethodType: z.literal(PaymentMethodType.WIRE),
191
+ config: wireConfigSchema,
192
+ }),
193
+ z.object({
194
+ paymentMethodType: z.literal(PaymentMethodType.CHECK),
195
+ config: checkConfigSchema,
196
+ }),
197
+ z.object({
198
+ paymentMethodType: z.literal(PaymentMethodType.RETIREMENT),
199
+ config: retirementConfigSchema,
200
+ }),
201
+ ],
202
+ );
203
+
204
+ export type PatchIssuerPaymentMethodZod = z.infer<
205
+ typeof PatchIssuerPaymentMethodZod
206
+ >;
207
+ export const CompliancePatchIssuerPaymentMethodZod = z
208
+ .object({
209
+ accountId: accountIdSchema,
210
+ })
211
+ .and(PatchIssuerPaymentMethodZod);
212
+
213
+ export type CompliancePatchIssuerPaymentMethodZod = z.infer<
214
+ typeof CompliancePatchIssuerPaymentMethodZod
215
+ >;
216
+
217
+ export const IPaginatedIssuerPaymentMethod = z.object({
218
+ items: z.array(IIssuerPaymentMethod),
219
+ meta: IPaginationMeta,
220
+ });
221
+ export type IPaginatedIssuerPaymentMethod = z.infer<
222
+ typeof IPaginatedIssuerPaymentMethod
223
+ >;
224
+
225
+ export const GetIssuerPaymentMethodZod = z.object({
226
+ issuerId: issuerIdSchema.openapi({
227
+ example: 'issuer_01jdq2crwke8xskjd840cj79pw',
228
+ }),
229
+ });
230
+ export type GetIssuerPaymentMethodZod = z.infer<
231
+ typeof GetIssuerPaymentMethodZod
232
+ >;
233
+
234
+ export const ComplianceGetIssuerPaymentMethodZod =
235
+ GetIssuerPaymentMethodZod.extend({
236
+ accountId: accountIdSchema,
237
+ });
238
+ export type ComplianceGetIssuerPaymentMethodZod = z.infer<
239
+ typeof ComplianceGetIssuerPaymentMethodZod
240
+ >;
241
+
242
+ export const PaymentMethodConfig = z.discriminatedUnion('paymentMethodType', [
243
+ z.object({
244
+ paymentMethodType: z.literal(PaymentMethodType.CREDIT_CARD),
245
+ config: stripeConfigSchema,
246
+ }),
247
+ z.object({
248
+ paymentMethodType: z.literal(PaymentMethodType.ACH),
249
+ config: stripeConfigSchema,
250
+ }),
251
+ z.object({
252
+ paymentMethodType: z.literal(PaymentMethodType.WIRE),
253
+ config: wireConfigSchema,
254
+ }),
255
+ z.object({
256
+ paymentMethodType: z.literal(PaymentMethodType.CHECK),
257
+ config: checkConfigSchema,
258
+ }),
259
+ z.object({
260
+ paymentMethodType: z.literal(PaymentMethodType.RETIREMENT),
261
+ config: retirementConfigSchema,
262
+ }),
263
+ ]);
264
+
265
+ export type PaymentMethodConfig = z.infer<typeof PaymentMethodConfig>;
266
+
267
+ export const createDefaultIssuerPaymentMethods = (issuerId: string) => {
268
+ const paymentMethods = [
269
+ {
270
+ paymentMethod: PaymentMethodType.CREDIT_CARD,
271
+ paymentMethodProvider: PaymentMethodProvider.STRIPE,
272
+ config: stripeConfigSchema.parse({
273
+ stripeAccountId: null,
274
+ }),
275
+ },
276
+ {
277
+ paymentMethod: PaymentMethodType.ACH,
278
+ paymentMethodProvider: PaymentMethodProvider.STRIPE,
279
+ config: stripeConfigSchema.parse({
280
+ stripeAccountId: null,
281
+ }),
282
+ },
283
+ {
284
+ paymentMethod: PaymentMethodType.BANK_ACCOUNT,
285
+ paymentMethodProvider: PaymentMethodProvider.STRIPE,
286
+ config: stripeConfigSchema.parse({
287
+ stripeAccountId: null,
288
+ }),
289
+ },
290
+ {
291
+ paymentMethod: PaymentMethodType.WIRE,
292
+ paymentMethodProvider: PaymentMethodProvider.OTHER,
293
+ config: wireConfigSchema.parse({
294
+ usAccountHolderName: null,
295
+ usBankName: null,
296
+ usRoutingNumber: null,
297
+ usAccountNumber: null,
298
+ reference: null,
299
+ swiftId: null,
300
+ }),
301
+ },
302
+ {
303
+ paymentMethod: PaymentMethodType.CHECK,
304
+ paymentMethodProvider: PaymentMethodProvider.OTHER,
305
+ config: checkConfigSchema.parse({
306
+ companyName: null,
307
+ address: null,
308
+ address2: null,
309
+ city: null,
310
+ state: null,
311
+ zip: null,
312
+ country: null,
313
+ reference: null,
314
+ }),
315
+ },
316
+ {
317
+ paymentMethod: PaymentMethodType.RETIREMENT,
318
+ paymentMethodProvider: PaymentMethodProvider.OTHER,
319
+ config: retirementConfigSchema.parse({
320
+ custodianInstruction: null,
321
+ custodianDocument: null,
322
+ }),
323
+ },
324
+ ];
325
+
326
+ return paymentMethods.map((paymentMethod) => ({
327
+ issuerId,
328
+ paymentMethodType: paymentMethod.paymentMethod,
329
+ paymentMethodProvider: paymentMethod.paymentMethodProvider,
330
+ enabled: false,
331
+ config: JSON.stringify(paymentMethod.config),
332
+ }));
333
+ };
334
+
335
+ export const ConnectIssuerPaymentMethodZod = z.object({
336
+ email: z.string().email(),
337
+ paymentMethodProvider: z.enum([PaymentMethodProvider.STRIPE]), // Only Stripe is supported for now
338
+ });
339
+ export type ConnectIssuerPaymentMethodZod = z.infer<
340
+ typeof ConnectIssuerPaymentMethodZod
341
+ >;
@@ -0,0 +1,312 @@
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
+ dateSchema,
8
+ IPaginationMeta,
9
+ IssuerStatus,
10
+ SortBy,
11
+ SortOrder,
12
+ } from './common.types';
13
+ import { IBaseEntity } from './entity.types';
14
+ import { fileIdSchema, FileZod } from './file.types';
15
+ import { AddressSchema } from './address.types';
16
+
17
+ extendZodWithOpenApi(z);
18
+ export enum IssuerTypes {
19
+ LLC = 'LLC',
20
+ S_CORP = 'S_CORP',
21
+ C_CORP = 'C_CORP',
22
+ }
23
+ export const issuerIdSchema = z.string().refine(
24
+ (value) => {
25
+ try {
26
+ const tid = TypeID.fromString(value);
27
+ return tid.getType() === 'issuer';
28
+ } catch {
29
+ return false;
30
+ }
31
+ },
32
+ {
33
+ message:
34
+ 'Invalid issuer ID format. Must be a valid TypeID with "issuer" prefix.',
35
+ },
36
+ );
37
+
38
+ const issuersInclude = z.enum(['account', 'offerings', 'coveredPersons']);
39
+
40
+ /**
41
+ * @description Query parameters for including related entities
42
+ * @xample in contract us as -> query: z.object({}).merge(IssuerIncludeQuery),
43
+ */
44
+ export const IssuersIncludeQuery = z.object({
45
+ include: z
46
+ .string()
47
+ .optional()
48
+ .transform((str) => (str ? str.split(',') : []))
49
+ .refine(
50
+ (includes) =>
51
+ includes.every((include) =>
52
+ issuersInclude.options.includes(include as any),
53
+ ),
54
+ {
55
+ message: `Invalid include option provided. Valid options are: ${issuersInclude.options.join(',')}`,
56
+ },
57
+ )
58
+ .openapi({
59
+ example: `${issuersInclude.options.join(',')}`,
60
+ }),
61
+ });
62
+
63
+ export const PostIssuerZod = z
64
+ .object({
65
+ title: z
66
+ .string()
67
+ .min(1)
68
+ .max(150)
69
+ .nullable()
70
+ .optional()
71
+ .openapi({ example: 'Issuer Title' }),
72
+ description: z
73
+ .string()
74
+ .min(1)
75
+ .max(1000)
76
+ .nullable()
77
+ .optional()
78
+ .openapi({ example: 'Fund Consulting Services' }),
79
+ legalName: z.string().min(1).max(100).openapi({ example: 'Fund.co LLC' }),
80
+ dba: z
81
+ .string()
82
+ .min(1)
83
+ .max(100)
84
+ .nullable()
85
+ .optional()
86
+ .openapi({ example: 'Fund Consulting Services' }),
87
+ doi: dateSchema.nullable().optional().openapi({ example: 'MM/DD/YYYY' }),
88
+ ein: z
89
+ .string()
90
+ .regex(/^\d{9}$/, {
91
+ message: 'Invalid EIN format. Must be exactly 9 digits',
92
+ })
93
+ .nullable()
94
+ .optional()
95
+ .openapi({ example: '123456789' }),
96
+ type: z.nativeEnum(IssuerTypes).openapi({ example: 'LLC' }),
97
+ })
98
+ .and(AddressSchema);
99
+
100
+ export type PostIssuerZod = z.infer<typeof PostIssuerZod>;
101
+
102
+ export const CompliancePostIssuerZod = z
103
+ .object({
104
+ accountId: accountIdSchema.openapi({
105
+ accountId: 'account_00041061050r3gg28a1c60t3gf',
106
+ }),
107
+ })
108
+ .and(PostIssuerZod);
109
+
110
+ export type CompliancePostIssuerZod = z.infer<typeof CompliancePostIssuerZod>;
111
+
112
+ export const PutIssuerZod = z
113
+ .object({
114
+ title: z
115
+ .string()
116
+ .min(1)
117
+ .max(150)
118
+ .nullable()
119
+ .optional()
120
+ .openapi({ example: 'Issuer Title' }),
121
+ description: z
122
+ .string()
123
+ .min(1)
124
+ .max(1000)
125
+ .nullable()
126
+ .optional()
127
+ .openapi({ example: 'Fund Consulting Services' }),
128
+ legalName: z
129
+ .string()
130
+ .min(1)
131
+ .max(100)
132
+ .optional()
133
+ .openapi({ example: 'Fund.co LLC' }),
134
+ dba: z
135
+ .string()
136
+ .min(1)
137
+ .max(100)
138
+ .nullable()
139
+ .optional()
140
+ .openapi({ example: 'Fund Consulting Services' }),
141
+ doi: dateSchema.nullable().optional().openapi({ example: 'MM/DD/YYYY' }),
142
+ ein: z
143
+ .string()
144
+ .regex(/^\d{9}$/, {
145
+ message: 'Invalid EIN format. Must be exactly 9 digits',
146
+ })
147
+ .optional()
148
+ .nullable()
149
+ .openapi({ example: '123456789' }),
150
+ type: z.nativeEnum(IssuerTypes).optional().openapi({ example: 'LLC' }),
151
+ ss4LetterFileId: z
152
+ .lazy(() => fileIdSchema)
153
+ .optional()
154
+ .nullable(),
155
+ coverArtId: z
156
+ .lazy(() => fileIdSchema)
157
+ .optional()
158
+ .nullable(),
159
+ })
160
+ .and(AddressSchema);
161
+
162
+ export type PutIssuerZod = z.infer<typeof PutIssuerZod>;
163
+
164
+ export const IIssuer = IBaseEntity.extend({
165
+ id: issuerIdSchema,
166
+ legalName: z.string().nullable().openapi({ example: 'Fund.co LLC' }),
167
+ dba: z.string().nullable().openapi({ example: 'Fund Consulting Services' }),
168
+ title: z.string().nullable().openapi({ example: 'Issuer Title' }),
169
+ description: z
170
+ .string()
171
+ .nullable()
172
+ .openapi({ example: 'Fund Consulting Services' }),
173
+ ein: z
174
+ .string()
175
+ .regex(/^\d{9}$/, {
176
+ message: 'Invalid EIN format. Must be exactly 9 digits',
177
+ })
178
+ .transform((val) => val.replace(/(\d{2})(\d{7})/, '$1-$2'))
179
+ .nullable()
180
+ .openapi({ example: '123456789' }),
181
+ type: z.nativeEnum(IssuerTypes).openapi({ example: 'LLC' }),
182
+ address: z.string().nullable().openapi({ example: '1234 Main St, Apt 101' }),
183
+ address2: z.string().nullable().openapi({ example: 'Apt 202' }),
184
+ city: z.string().nullable().openapi({ example: 'Los Angeles' }),
185
+ state: z.string().nullable().openapi({ example: 'CA' }),
186
+ zip: z.string().nullable().openapi({ example: '90015' }),
187
+ country: z.string().nullable().openapi({ example: 'United States' }),
188
+ accountId: z.string(),
189
+ account: AccountZod.optional().nullable(),
190
+ ss4LetterFileId: z.string().nullable(),
191
+ status: z
192
+ .nativeEnum(IssuerStatus)
193
+ .openapi({ example: IssuerStatus.SUBMITTED }),
194
+ coverArtId: z.string().nullable(),
195
+ coverArt: z
196
+ .lazy(() => FileZod)
197
+ .nullable()
198
+ .optional(),
199
+ doi: z.date().nullable(),
200
+ });
201
+
202
+ export type IIssuer = z.infer<typeof IIssuer>;
203
+
204
+ export const IPaginatedIssuer = z.object({
205
+ items: z.array(IIssuer),
206
+ meta: IPaginationMeta,
207
+ });
208
+ export type IPaginatedIssuer = z.infer<typeof IPaginatedIssuer>;
209
+
210
+ export const GetIssuersZod = z.object({
211
+ accountId: accountIdSchema.optional(),
212
+ ein: z
213
+ .string()
214
+ .regex(/^\d{9}$/, {
215
+ message: 'Invalid EIN format. Must be exactly 9 digits',
216
+ })
217
+ .optional()
218
+ .openapi({ example: '123456789' }),
219
+ legalName: z.string().optional().openapi({ example: 'Fund.co LLC' }),
220
+ type: z
221
+ .nativeEnum(IssuerTypes)
222
+ .optional()
223
+ .openapi({ example: IssuerTypes.C_CORP }),
224
+ status: z
225
+ .nativeEnum(IssuerStatus)
226
+ .optional()
227
+ .openapi({ example: IssuerStatus.SUBMITTED }),
228
+ });
229
+
230
+ export type GetIssuersZod = z.infer<typeof GetIssuersZod>;
231
+
232
+ export enum CatalogMode {
233
+ CATALOG = 'CATALOG',
234
+ CATEGORY = 'CATEGORY',
235
+ PRODUCT = 'PRODUCT',
236
+ }
237
+
238
+ const CatalogModeSchema = z.object({
239
+ mode: z.nativeEnum(CatalogMode).optional(),
240
+ });
241
+
242
+ export const IPaginatedCatalog = z.object({
243
+ items: z.array(IIssuer),
244
+ meta: IPaginationMeta.merge(CatalogModeSchema),
245
+ });
246
+
247
+ export const GetIssuersSummaryZod = z.object({
248
+ accountId: accountIdSchema.optional(),
249
+ issuerId: issuerIdSchema.optional(),
250
+ coveredPersons: z.number(),
251
+ offerings: z.number(),
252
+ assets: z.number(),
253
+ });
254
+ export type GetIssuersSummaryZod = z.infer<typeof GetIssuersSummaryZod>;
255
+
256
+ export const IPaginatedIssersSummary = z.object({
257
+ items: z.array(GetIssuersSummaryZod),
258
+ meta: IPaginationMeta,
259
+ });
260
+ export type IPaginatedIssersSummary = z.infer<typeof IPaginatedIssersSummary>;
261
+
262
+ export const IssuersSummaryFilterZod = z.object({
263
+ accountId: accountIdSchema.optional(),
264
+ issuerId: issuerIdSchema.optional(),
265
+ search: z.string().optional(),
266
+ });
267
+ export type IssuersSummaryFilterZod = z.infer<typeof IssuersSummaryFilterZod>;
268
+
269
+ export const IssuersSortZod = z.object({
270
+ sort: z
271
+ .enum([SortBy.LEGAL_NAME, SortBy.CREATED_AT, SortBy.UPDATED_AT])
272
+ .optional(),
273
+ dir: z.nativeEnum(SortOrder).optional(),
274
+ });
275
+ export type IssuersSortZod = z.infer<typeof IssuersSortZod>;
276
+
277
+ /**
278
+ * Schema for transforming EIN (Employer Identification Number) formats.
279
+ *
280
+ * This schema validates and transforms a 9-digit EIN by inserting a hyphen after
281
+ * the first two digits (XX-XXXXXXX format). If the input doesn't match the expected
282
+ * 9-digit pattern, the original value is returned unchanged.
283
+ *
284
+ * The schema uses passthrough to allow additional fields in the object without validation,
285
+ * making it flexible for use with various data structures that include an EIN.
286
+ *
287
+ * @example
288
+ * // Transforms: { ein: '123456789' } -> { ein: '12-3456789' }
289
+ * // Keeps as-is: { ein: '12-3456789' } -> { ein: '12-3456789' }
290
+ */
291
+ export const EinTransformerSchema = z
292
+ .object({
293
+ ein: z
294
+ .string()
295
+ .nullable()
296
+ .optional()
297
+ .transform((val) => {
298
+ // Only apply transformation if it matches the regex pattern
299
+ if (val && /^\d{9}$/.test(val)) {
300
+ return val.replace(/(\d{2})(\d{7})/, '$1-$2');
301
+ }
302
+ // Otherwise return the original value
303
+ return val;
304
+ })
305
+ .openapi({ example: '123456789' }),
306
+ })
307
+ .passthrough(); // Allow additional fields without validation
308
+
309
+ export const PaginatedEinTransformerSchema = z.object({
310
+ items: z.array(EinTransformerSchema),
311
+ meta: IPaginationMeta,
312
+ });