@dalmore/api-contracts 0.0.0-dev.7c97041 → 0.0.0-dev.988f3c3

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 (34) hide show
  1. package/common/types/account-setting.types.ts +65 -0
  2. package/common/types/account.types.ts +1 -0
  3. package/common/types/bonus-tier.types.ts +33 -0
  4. package/common/types/cart.types.ts +4 -1
  5. package/common/types/common.types.ts +16 -6
  6. package/common/types/dashboard.types.ts +2 -9
  7. package/common/types/individuals.types.ts +2 -15
  8. package/common/types/issuer-offering.types.ts +11 -17
  9. package/common/types/notification.types.ts +515 -29
  10. package/common/types/offering.types.ts +2 -9
  11. package/common/types/site.types.ts +2 -9
  12. package/common/types/{trade-line-item.type.ts → trade-line-item.types.ts} +2 -9
  13. package/common/types/trade.types.ts +1 -1
  14. package/common/types/transaction.types.ts +12 -1
  15. package/common/types/user.types.ts +15 -28
  16. package/contracts/clients/cart/index.ts +21 -1
  17. package/contracts/clients/index.ts +2 -0
  18. package/contracts/clients/trade-line-items/index.ts +1 -1
  19. package/contracts/clients/trades/index.ts +1 -1
  20. package/contracts/clients/transactions/index.ts +37 -0
  21. package/contracts/compliance/account-settings/index.ts +59 -0
  22. package/contracts/compliance/bonus-tiers/index.ts +21 -2
  23. package/contracts/compliance/index.ts +4 -0
  24. package/contracts/compliance/notification-channels/index.ts +251 -0
  25. package/contracts/compliance/trade-line-items/index.ts +1 -1
  26. package/contracts/compliance/users/index.ts +21 -0
  27. package/contracts/investors/bonus-tiers/index.ts +18 -0
  28. package/contracts/investors/trade-line-items/index.ts +1 -1
  29. package/contracts/issuers/account-settings/index.ts +36 -0
  30. package/contracts/issuers/bonus-tiers/index.ts +18 -0
  31. package/contracts/issuers/disbursements/index.ts +17 -17
  32. package/contracts/issuers/index.ts +4 -0
  33. package/contracts/issuers/notification-channels/index.ts +251 -0
  34. package/package.json +1 -1
@@ -0,0 +1,65 @@
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 { IPaginationMeta } from './common.types';
6
+ import { accountIdSchema } from './account.types';
7
+
8
+ extendZodWithOpenApi(z);
9
+
10
+ export const accountSettingIdSchema = z.string().refine(
11
+ (value) => {
12
+ try {
13
+ const tid = TypeID.fromString(value);
14
+ return tid.getType() === 'account_setting';
15
+ } catch {
16
+ return false;
17
+ }
18
+ },
19
+ {
20
+ message:
21
+ 'Invalid account setting ID format. Must be a valid TypeID with "account_setting" prefix.',
22
+ },
23
+ );
24
+
25
+ export const IAccountSettingZod = IBaseEntity.extend({
26
+ id: accountSettingIdSchema.openapi({
27
+ example: 'account_setting_01j5y5ghx8fvc83dmx3pznq7hv',
28
+ }),
29
+ accountId: z.string().openapi({
30
+ example: 'account_01j5y5ghx8fvc83dmx3pznq7hv',
31
+ }),
32
+ });
33
+ export type IAccountSettingZod = z.infer<typeof IAccountSettingZod>;
34
+
35
+ export const IPaginatedAccountSetting = z.object({
36
+ items: z.array(IAccountSettingZod),
37
+ meta: IPaginationMeta,
38
+ });
39
+ export type IPaginatedAccountSetting = z.infer<typeof IPaginatedAccountSetting>;
40
+
41
+ export const AccountSettingsFilters = z.object({
42
+ accountId: accountIdSchema.optional(),
43
+ });
44
+ export type AccountSettingsFilters = z.infer<typeof AccountSettingsFilters>;
45
+
46
+ export const accountSettingsInclude = z.enum(['notificationChannels']);
47
+
48
+ export const AccountSettingsIncludeQuery = z.object({
49
+ include: z
50
+ .string()
51
+ .optional()
52
+ .transform((str) => (str ? str.split(',') : []))
53
+ .refine(
54
+ (includes) =>
55
+ includes.every((include) =>
56
+ accountSettingsInclude.options.includes(include as any),
57
+ ),
58
+ {
59
+ message: `Invalid include value. Valid values are: ${accountSettingsInclude.options.join(', ')}`,
60
+ },
61
+ ),
62
+ });
63
+ export type AccountSettingsIncludeQuery = z.infer<
64
+ typeof AccountSettingsIncludeQuery
65
+ >;
@@ -91,6 +91,7 @@ export const AccountFiltersZod = z.object({
91
91
  const accountsInclude = z.enum([
92
92
  'accountManager',
93
93
  'accountIntegrations',
94
+ 'accountSettings',
94
95
  'apiKeys',
95
96
  'assets',
96
97
  'dataRooms',
@@ -98,6 +98,15 @@ export type EstimateBonusTierCalculationZod = z.infer<
98
98
  typeof EstimateBonusTierCalculationZod
99
99
  >;
100
100
 
101
+ export const ComplianceEstimateBonusTierCalculationZod =
102
+ EstimateBonusTierCalculationZod.and(
103
+ z.object({
104
+ accountId: accountIdSchema,
105
+ }),
106
+ );
107
+ export type ComplianceEstimateBonusTierCalculationZod = z.infer<
108
+ typeof ComplianceEstimateBonusTierCalculationZod
109
+ >;
101
110
  export const EstimateBonusTierCalculationResponseZod = z.object({
102
111
  bonusTierId: bonusTierIdSchema
103
112
  .nullable()
@@ -145,3 +154,27 @@ export const CompliancePostBonusTierZod = PostBonusTierZod.extend({
145
154
  export type CompliancePostBonusTierZod = z.infer<
146
155
  typeof CompliancePostBonusTierZod
147
156
  >;
157
+ export const PurchaseCalculationZod = z.object({
158
+ assetId: assetIdSchema,
159
+ totalAmount: z.number().positive().openapi({ example: 1000 }),
160
+ purchasedShares: z.number().positive().int().openapi({ example: 100 }),
161
+ });
162
+ export type PurchaseCalculationZod = z.infer<typeof PurchaseCalculationZod>;
163
+
164
+ export const PurchaseCalculationResponseZod = z.object({
165
+ bonusTierId: bonusTierIdSchema
166
+ .nullable()
167
+ .openapi({ example: 'bonus_tier_01j5y5ghx5fg68d663j1fvy2x7' }),
168
+ assetId: assetIdSchema.openapi({
169
+ example: 'asset_00041061050r3gg28a1c60t3gf',
170
+ }),
171
+ type: z
172
+ .nativeEnum(BonusType)
173
+ .nullable()
174
+ .openapi({ example: BonusType.PERCENTAGE }),
175
+ bonusShares: z.number().int().openapi({ example: 100 }),
176
+ });
177
+
178
+ export type PurchaseCalculationResponseZod = z.infer<
179
+ typeof PurchaseCalculationResponseZod
180
+ >;
@@ -3,6 +3,7 @@ import { extendZodWithOpenApi } from '@anatine/zod-openapi';
3
3
  import { TradeStatus } from './common.types';
4
4
  import { investorAccountIdSchema } from './investor-account.types';
5
5
  import { paymentMethodIdSchema } from './payment-methods.types';
6
+ import { userIdSchema } from './user.types';
6
7
 
7
8
  extendZodWithOpenApi(z);
8
9
 
@@ -10,7 +11,9 @@ export const PlaceTradeResponse = z.object({
10
11
  tradeStatus: z.nativeEnum(TradeStatus).optional(),
11
12
  });
12
13
  export const PlaceTradeBody = z.object({});
13
-
14
+ export const ClientPlacetradeBody = z.object({
15
+ userId: userIdSchema,
16
+ });
14
17
  export const PatchCartBody = z.object({
15
18
  investorAccountId: investorAccountIdSchema.optional(),
16
19
  paymentMethodId: paymentMethodIdSchema.optional(),
@@ -111,6 +111,10 @@ export enum HttpMethod {
111
111
  OPTIONS = 'OPTIONS',
112
112
  }
113
113
 
114
+ export enum UserStatus {
115
+ ACTIVE = 'ACTIVE',
116
+ LOCKED = 'LOCKED',
117
+ }
114
118
  export const SENSITIVE_PATTERNS = [
115
119
  /password/i,
116
120
  /credit.*card/i,
@@ -200,11 +204,6 @@ export enum UserType {
200
204
  DEMO = 'DEMO',
201
205
  }
202
206
 
203
- export enum UserStatus {
204
- ACTIVE = 'ACTIVE',
205
- LOCKED = 'LOCKED',
206
- }
207
-
208
207
  export enum UserRole {
209
208
  API_KEY = 'API_KEY',
210
209
  IMPORT = 'IMPORT',
@@ -306,7 +305,7 @@ export const AuthUserReq = BaseAuthReq.extend({
306
305
  lastName: z.string(),
307
306
  email: z.string().email(),
308
307
  provider: z.string(),
309
- status: z.lazy(() => z.nativeEnum(UserStatus)),
308
+ locked: z.boolean(),
310
309
  lastLoginAt: z.date().nullable(),
311
310
  loginCount: z.number(),
312
311
  requiresTwoFactorSetup: z.boolean().optional(),
@@ -1518,3 +1517,14 @@ export const SUBJECT_TYPE_MAP: Record<BulkExportType, string> = {
1518
1517
  [BulkExportType.SECONDARY_CUSTOMERS]: 'Secondary Customers',
1519
1518
  [BulkExportType.SECONDARY_TRADES]: 'Secondary Trades',
1520
1519
  };
1520
+
1521
+ export const StringToBooleanSchema = z.preprocess(
1522
+ (val) =>
1523
+ val === 'true' || val === '1'
1524
+ ? true
1525
+ : val === 'false' || val === '0'
1526
+ ? false
1527
+ : val,
1528
+ z.boolean(),
1529
+ );
1530
+ export type StringToBooleanSchema = z.infer<typeof StringToBooleanSchema>;
@@ -7,6 +7,7 @@ import {
7
7
  FileLabels,
8
8
  IPaginationMeta,
9
9
  OfferingType,
10
+ StringToBooleanSchema,
10
11
  } from './common.types';
11
12
  import { accountIdSchema } from './account.types';
12
13
 
@@ -330,15 +331,7 @@ export const GetInvestmentDashboardQueryZod = z.object({
330
331
  offerings: OfferingsArrayQueryZod.optional(),
331
332
  offeringTypes: OfferingTypesQueryZod.optional(),
332
333
  timeFilteringType: z.nativeEnum(DashboardTimeFilteringType),
333
- debug: z.preprocess(
334
- (val) =>
335
- val === 'true' || val === '1'
336
- ? true
337
- : val === 'false' || val === '0'
338
- ? false
339
- : val,
340
- z.boolean().optional(),
341
- ),
334
+ debug: StringToBooleanSchema.optional(),
342
335
  });
343
336
  export type GetInvestmentDashboardQueryZod = z.infer<
344
337
  typeof GetInvestmentDashboardQueryZod
@@ -12,9 +12,7 @@ import {
12
12
  InvestorAccountType,
13
13
  SetupStatusType,
14
14
  SetupStepType,
15
- ComplianceReview,
16
15
  RetirementAccountType,
17
- TradeStatus,
18
16
  EmploymentStatus,
19
17
  SourceOfIncome,
20
18
  AMLProvider,
@@ -60,8 +58,8 @@ export enum aicQuestionnaireQuestionType {
60
58
  }
61
59
 
62
60
  export enum FilterBy {
63
- TRADE = 'TRADE',
64
- INVESTOR = 'INVESTOR',
61
+ ALL = 'ALL',
62
+ PENDING_TRADES = 'PENDING_TRADES',
65
63
  }
66
64
 
67
65
  export const aicQuestionnaireQuestion = z.object({
@@ -243,17 +241,6 @@ export const IndividualFiltersZod = z.object({
243
241
 
244
242
  export const ComplianceIndividualFiltersZod = IndividualFiltersZod.extend({
245
243
  filterBy: z.nativeEnum(FilterBy).optional(),
246
- tradeStatus: z.nativeEnum(TradeStatus).optional(),
247
- complianceReview: z.nativeEnum(ComplianceReview).optional(),
248
- hasPendingTrades: z.preprocess(
249
- (val) =>
250
- val === 'true' || val === '1'
251
- ? true
252
- : val === 'false' || val === '0'
253
- ? false
254
- : val,
255
- z.boolean().optional(),
256
- ),
257
244
  });
258
245
 
259
246
  /**
@@ -10,6 +10,7 @@ import {
10
10
  ComplianceReview,
11
11
  DurationType,
12
12
  AssetType,
13
+ StringToBooleanSchema,
13
14
  } from './common.types';
14
15
  import { IBaseEntity } from './entity.types';
15
16
  import { IIssuer, issuerIdSchema } from './issuer.types';
@@ -193,38 +194,39 @@ export const PatchIssuerOffering = z.object({
193
194
  .max(100)
194
195
  .optional()
195
196
  .openapi({ example: 'Airbnb IPO' }),
197
+ type: z
198
+ .nativeEnum(OfferingType)
199
+ .optional()
200
+ .openapi({ example: OfferingType.REG_D }),
196
201
  targetAmount: z
197
202
  .number()
198
203
  .min(0)
199
204
  .max(10000000000)
200
205
  .optional()
201
206
  .openapi({ example: 120000 }),
202
- raiseAmount: z
203
- .number()
204
- .min(0)
205
- .max(10000000000)
206
- .optional()
207
- .openapi({ example: 200000 }),
208
207
  minInvestment: z
209
208
  .number()
210
209
  .min(0)
211
210
  .max(10000000000)
211
+ .nullable()
212
212
  .optional()
213
213
  .openapi({ example: 1000 }),
214
214
  maxInvestment: z
215
215
  .number()
216
216
  .min(0)
217
217
  .max(10000000000)
218
+ .nullable()
218
219
  .optional()
219
220
  .openapi({ example: 20000 }),
220
221
  contingencyAmount: z
221
222
  .number()
222
223
  .min(0)
223
224
  .max(10000000000)
225
+ .nullable()
224
226
  .optional()
225
227
  .openapi({ example: 5000 }),
226
- startAt: dateSchema.optional().openapi({ example: '10/20/2024' }),
227
- endAt: dateSchema.optional().openapi({ example: '10/27/2024' }),
228
+ startAt: dateSchema.nullable().optional().openapi({ example: '10/20/2024' }),
229
+ endAt: dateSchema.nullable().optional().openapi({ example: '10/27/2024' }),
228
230
  cancellationPeriod: z
229
231
  .number()
230
232
  .min(1)
@@ -370,15 +372,7 @@ export const IssuerOfferingsFilterZod = z.object({
370
372
  issuerId: z.lazy(() => issuerIdSchema).optional(),
371
373
  type: z.nativeEnum(OfferingType).optional(),
372
374
  status: z.nativeEnum(ComplianceReview).optional(),
373
- enabled: z.preprocess(
374
- (val) =>
375
- val === 'true' || val === '1'
376
- ? true
377
- : val === 'false' || val === '0'
378
- ? false
379
- : val,
380
- z.boolean().optional(),
381
- ),
375
+ enabled: StringToBooleanSchema.optional(),
382
376
  managedBy: z.nativeEnum(ManagedByType).optional(),
383
377
  versioningType: z.nativeEnum(OfferingVersioningType).optional(),
384
378
  combinedStatus: z.nativeEnum(OfferingStatus).optional(),