@dalmore/api-contracts 0.0.0-dev.785b227 → 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 (44) 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/activity.types.ts +1 -1
  4. package/common/types/bonus-tier.types.ts +33 -0
  5. package/common/types/cart.types.ts +4 -1
  6. package/common/types/common.types.ts +16 -6
  7. package/common/types/dashboard.types.ts +2 -9
  8. package/common/types/disbursements.types.ts +119 -3
  9. package/common/types/file.types.ts +20 -4
  10. package/common/types/i-will-do-it-later.types.ts +68 -0
  11. package/common/types/index.ts +2 -0
  12. package/common/types/individuals.types.ts +2 -15
  13. package/common/types/issuer-offering.types.ts +13 -17
  14. package/common/types/issuer-payment-method.types.ts +41 -0
  15. package/common/types/issuer.types.ts +9 -0
  16. package/common/types/notification.types.ts +515 -29
  17. package/common/types/offering.types.ts +4 -9
  18. package/common/types/site.types.ts +2 -9
  19. package/common/types/{trade-line-item.type.ts → trade-line-item.types.ts} +2 -9
  20. package/common/types/trade.types.ts +1 -1
  21. package/common/types/transaction.types.ts +12 -1
  22. package/common/types/user.types.ts +15 -28
  23. package/contracts/clients/cart/index.ts +21 -1
  24. package/contracts/clients/index.ts +6 -0
  25. package/contracts/clients/issuer-payment-methods/index.ts +39 -0
  26. package/contracts/clients/payment-methods/index.ts +85 -0
  27. package/contracts/clients/trade-line-items/index.ts +1 -1
  28. package/contracts/clients/trades/index.ts +1 -1
  29. package/contracts/clients/transactions/index.ts +37 -0
  30. package/contracts/compliance/account-settings/index.ts +59 -0
  31. package/contracts/compliance/bonus-tiers/index.ts +21 -2
  32. package/contracts/compliance/index.ts +4 -0
  33. package/contracts/compliance/notification-channels/index.ts +251 -0
  34. package/contracts/compliance/trade-line-items/index.ts +1 -1
  35. package/contracts/compliance/users/index.ts +21 -0
  36. package/contracts/investors/bonus-tiers/index.ts +18 -0
  37. package/contracts/investors/individuals/index.ts +22 -0
  38. package/contracts/investors/trade-line-items/index.ts +1 -1
  39. package/contracts/issuers/account-settings/index.ts +36 -0
  40. package/contracts/issuers/bonus-tiers/index.ts +18 -0
  41. package/contracts/issuers/disbursements/index.ts +48 -12
  42. package/contracts/issuers/index.ts +4 -0
  43. package/contracts/issuers/notification-channels/index.ts +251 -0
  44. package/package.json +1 -1
@@ -1,10 +1,11 @@
1
+ import { z } from 'zod';
2
+ import { extendZodWithOpenApi } from '@anatine/zod-openapi';
1
3
  import { TypeID } from 'typeid-js';
2
4
  import {
3
5
  dateSchema,
4
6
  InvestorAccountType,
5
7
  numberPrecisionSchema,
6
8
  } from './common.types';
7
- import { z } from 'zod';
8
9
  import { IBaseEntity } from './entity.types';
9
10
  import { accountIdSchema } from './account.types';
10
11
  import {
@@ -18,7 +19,9 @@ import {
18
19
  investorAccountIdSchema,
19
20
  } from './investor-account.types';
20
21
  import { TransactionStatus, TransactionType } from './common.types';
22
+ import { userIdSchema } from './user.types';
21
23
  export { TransactionStatus, TransactionType };
24
+ extendZodWithOpenApi(z);
22
25
 
23
26
  export enum RefundPaymentMethod {
24
27
  CHECK = 'CHECK',
@@ -115,6 +118,14 @@ export type InvestorPostTransactionZod = z.infer<
115
118
  typeof InvestorPostTransactionZod
116
119
  >;
117
120
 
121
+ export const ClientPostTransactionZod = InvestorPostTransactionZod.extend({
122
+ userId: z
123
+ .lazy(() => userIdSchema)
124
+ .openapi({ example: 'user_01j5y5ghx5fg68d663j1fvy2x7' }),
125
+ });
126
+
127
+ export type ClientPostTransactionZod = z.infer<typeof ClientPostTransactionZod>;
128
+
118
129
  export const refundTransactionIdSchema = z.string().refine(
119
130
  (value) => {
120
131
  try {
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { extendZodWithOpenApi } from '@anatine/zod-openapi';
2
3
  import {
3
4
  AccountStatus,
4
5
  AccountWithoutUsersZod,
@@ -7,12 +8,11 @@ import {
7
8
  ManagedByType,
8
9
  OfferingType,
9
10
  PortalType,
11
+ StringToBooleanSchema,
10
12
  UserRole,
11
- UserStatus,
12
13
  UserType,
13
14
  } from './common.types';
14
15
  import { dateOrString, IBaseEntity } from './entity.types';
15
- import { extendZodWithOpenApi } from '@anatine/zod-openapi';
16
16
  import { PhoneZodSchema } from './phone.type';
17
17
  import { IInvestorAccount } from './investor-account.types';
18
18
  import { TradeZod } from './trade.types';
@@ -51,6 +51,11 @@ export const UserDeleteResponse = z.object({
51
51
  });
52
52
  export type UserDeleteResponse = z.infer<typeof UserDeleteResponse>;
53
53
 
54
+ export const UserRestoreResponse = z.object({
55
+ message: z.string(),
56
+ });
57
+ export type UserRestoreResponse = z.infer<typeof UserRestoreResponse>;
58
+
54
59
  export const GetMeResponse = IBaseEntity.extend({
55
60
  accountId: z.string().nullable(),
56
61
  accountName: z.string().nullable(),
@@ -59,7 +64,7 @@ export const GetMeResponse = IBaseEntity.extend({
59
64
  email: z.string().email(),
60
65
  provider: z.string(),
61
66
  active: z.boolean(),
62
- status: z.lazy(() => z.nativeEnum(UserStatus)),
67
+ locked: z.boolean(),
63
68
  lastLoginAt: dateOrString.nullable(),
64
69
  loginCount: z.number(),
65
70
  role: z.string(),
@@ -157,7 +162,7 @@ export const UserZod = IBaseEntity.extend({
157
162
  onboarding: z.string().nullable(),
158
163
  account: AccountWithoutUsersZod.optional(),
159
164
  active: z.boolean(),
160
- status: z.nativeEnum(UserStatus),
165
+ locked: z.boolean(),
161
166
  userLogin: IBaseEntity.extend({
162
167
  firstName: z.string(),
163
168
  lastName: z.string(),
@@ -179,27 +184,9 @@ export const UserFiltersZod = z.object({
179
184
  search: z.string().max(50).optional(),
180
185
  role: z.nativeEnum(UserRole).optional(),
181
186
  portal: z.string().optional(),
182
- status: z.nativeEnum(UserStatus).optional(),
183
- active: z
184
- .string()
185
- .optional()
186
- .refine((v) => !v || v === 'true' || v === 'false', {
187
- message: 'active must be a boolean string',
188
- })
189
- .transform((v) => {
190
- if (!v) return undefined;
191
- return v === 'true';
192
- }),
193
- twoFactorEnabled: z
194
- .string()
195
- .optional()
196
- .refine((v) => !v || v === 'true' || v === 'false', {
197
- message: 'twoFactorEnabled must be a boolean string',
198
- })
199
- .transform((v) => {
200
- if (!v) return undefined;
201
- return v === 'true';
202
- }),
187
+ locked: StringToBooleanSchema.optional(),
188
+ active: StringToBooleanSchema.optional(),
189
+ twoFactorEnabled: StringToBooleanSchema.optional(),
203
190
  });
204
191
 
205
192
  const usersInclude = z.enum(['account', 'role']);
@@ -274,7 +261,7 @@ export type IssuerUsersStatusUpdateResponse = z.infer<
274
261
  >;
275
262
 
276
263
  export const UpdateLockedStatus = z.object({
277
- status: z.nativeEnum(UserStatus),
264
+ locked: z.boolean(),
278
265
  });
279
266
 
280
267
  export type UpdateLockedStatus = z.infer<typeof UpdateLockedStatus>;
@@ -285,7 +272,7 @@ export const UsersSummaryFilterZod = z.object({
285
272
  portalType: z.nativeEnum(PortalType).optional(),
286
273
  search: z.string().trim().max(50).optional(),
287
274
  selectRole: z.nativeEnum(UserRole).optional(),
288
- status: z.nativeEnum(UserStatus).optional(),
275
+ locked: StringToBooleanSchema.optional(),
289
276
  });
290
277
  export type UsersSummaryFilterZod = z.infer<typeof UsersSummaryFilterZod>;
291
278
 
@@ -299,7 +286,7 @@ export const UsersSummaryZod = z.object({
299
286
  portalType: z.string(),
300
287
  loginCount: z.number().int(),
301
288
  lastLogin: z.date(),
302
- status: z.nativeEnum(UserStatus),
289
+ locked: z.boolean(),
303
290
  });
304
291
  export type UsersSummaryZod = z.infer<typeof UsersSummaryZod>;
305
292
 
@@ -10,7 +10,11 @@ import {
10
10
  userIdSchema,
11
11
  tradeIdSchema,
12
12
  } from '../../../common/types';
13
- import { PatchCartBody } from '../../../common/types/cart.types';
13
+ import {
14
+ PatchCartBody,
15
+ ClientPlacetradeBody,
16
+ PlaceTradeResponse,
17
+ } from '../../../common/types/cart.types';
14
18
 
15
19
  const c = initContract();
16
20
 
@@ -34,6 +38,22 @@ export const cartContract = c.router(
34
38
  500: InternalError,
35
39
  },
36
40
  },
41
+ postCheckout: {
42
+ summary: 'Place a trade (checkout button)',
43
+ method: 'POST',
44
+ path: '/checkout',
45
+ metadata: {
46
+ auth: true,
47
+ },
48
+ body: ClientPlacetradeBody,
49
+ responses: {
50
+ 200: PlaceTradeResponse,
51
+ 400: BadRequestError,
52
+ 401: UnauthorizedError,
53
+ 403: ForbiddenError,
54
+ 500: InternalError,
55
+ },
56
+ },
37
57
  patchCart: {
38
58
  summary: 'Patch a cart',
39
59
  method: 'PATCH',
@@ -16,7 +16,10 @@ import { secureRequestContract } from './secure-requests';
16
16
  import { aicContract } from './aic';
17
17
  import { authContract } from './auth';
18
18
  import { sitesContract } from './sites';
19
+ import { paymentMethodsContract } from './payment-methods';
20
+ import { issuerPaymentMethodsContract } from './issuer-payment-methods';
19
21
  import { tradeLineItemsContract } from './trade-line-items';
22
+ import { clientsTransactionsContract } from './transactions';
20
23
 
21
24
  const c = initContract();
22
25
 
@@ -34,13 +37,16 @@ export const clientsContract = c.router(
34
37
  filesPublic: filesPublicContract,
35
38
  individuals: individualsContract,
36
39
  investorAccounts: investorAccountsContract,
40
+ issuerPaymentMethods: issuerPaymentMethodsContract,
37
41
  issuers: issuersContract,
38
42
  legalEntities: legalEntityContract,
39
43
  offerings: offeringsContract,
44
+ paymentMethods: paymentMethodsContract,
40
45
  secureRequests: secureRequestContract,
41
46
  sites: sitesContract,
42
47
  tradeLineItems: tradeLineItemsContract,
43
48
  trades: tradesContract,
49
+ transactions: clientsTransactionsContract,
44
50
  },
45
51
  {
46
52
  pathPrefix: '/clients/api/v1/',
@@ -0,0 +1,39 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import {
3
+ ForbiddenError,
4
+ InternalError,
5
+ NotFoundError,
6
+ UnauthorizedError,
7
+ GetIssuerPaymentMethodZod,
8
+ IPaginatedIssuerPaymentMethod,
9
+ IssuerPaymentMethodsIncludeQuery,
10
+ PaginationOptionsZod,
11
+ } from '../../../common/types';
12
+
13
+ const c = initContract();
14
+
15
+ export const issuerPaymentMethodsContract = c.router(
16
+ {
17
+ getIssuerPaymentMethods: {
18
+ summary: 'Get issuer payment methods',
19
+ method: 'GET',
20
+ path: '',
21
+ metadata: {
22
+ auth: true,
23
+ },
24
+ query: PaginationOptionsZod.merge(GetIssuerPaymentMethodZod).merge(
25
+ IssuerPaymentMethodsIncludeQuery,
26
+ ),
27
+ responses: {
28
+ 200: IPaginatedIssuerPaymentMethod,
29
+ 401: UnauthorizedError,
30
+ 403: ForbiddenError,
31
+ 404: NotFoundError,
32
+ 500: InternalError,
33
+ },
34
+ },
35
+ },
36
+ {
37
+ pathPrefix: 'issuer-payment-methods',
38
+ },
39
+ );
@@ -0,0 +1,85 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import { z } from 'zod';
3
+ import {
4
+ UnauthorizedError,
5
+ ForbiddenError,
6
+ NotFoundError,
7
+ userIdSchema,
8
+ BadRequestError,
9
+ InternalError,
10
+ } from '../../../common/types';
11
+ import {
12
+ PaymentMethodResponseArray,
13
+ PaymentMethodResponse,
14
+ PostPaymentMethod,
15
+ PostSetupIntentBody,
16
+ SetupIntentResponse,
17
+ } from '../../../common/types/payment-methods.types';
18
+
19
+ const c = initContract();
20
+
21
+ export const paymentMethodsContract = c.router(
22
+ {
23
+ getPaymentMethods: {
24
+ summary: 'Get payment methods for a user',
25
+ method: 'GET',
26
+ path: '',
27
+ metadata: {
28
+ auth: true,
29
+ },
30
+ query: z.object({
31
+ userId: userIdSchema,
32
+ }),
33
+ responses: {
34
+ 200: PaymentMethodResponseArray,
35
+ 401: UnauthorizedError,
36
+ 403: ForbiddenError,
37
+ 404: NotFoundError,
38
+ 500: InternalError,
39
+ },
40
+ },
41
+ createPaymentMethod: {
42
+ summary: 'Create payment method for a user',
43
+ method: 'POST',
44
+ path: '',
45
+ metadata: {
46
+ auth: true,
47
+ },
48
+ query: z.object({
49
+ userId: userIdSchema,
50
+ }),
51
+ body: PostPaymentMethod,
52
+ responses: {
53
+ 201: PaymentMethodResponse,
54
+ 400: BadRequestError,
55
+ 401: UnauthorizedError,
56
+ 403: ForbiddenError,
57
+ 404: NotFoundError,
58
+ 500: InternalError,
59
+ },
60
+ },
61
+ createSetupIntent: {
62
+ summary: 'Create payment method setup intent for a user',
63
+ method: 'POST',
64
+ path: '/intent',
65
+ metadata: {
66
+ auth: true,
67
+ },
68
+ query: z.object({
69
+ userId: userIdSchema,
70
+ }),
71
+ body: PostSetupIntentBody,
72
+ responses: {
73
+ 201: SetupIntentResponse,
74
+ 400: BadRequestError,
75
+ 401: UnauthorizedError,
76
+ 403: ForbiddenError,
77
+ 404: NotFoundError,
78
+ 500: InternalError,
79
+ },
80
+ },
81
+ },
82
+ {
83
+ pathPrefix: 'payment-methods',
84
+ },
85
+ );
@@ -14,7 +14,7 @@ import {
14
14
  TradeLineItemQuery,
15
15
  TradeLineItemResponse,
16
16
  TradeLineItemUpdate,
17
- } from '../../../common/types/trade-line-item.type';
17
+ } from '../../../common/types/trade-line-item.types';
18
18
 
19
19
  const c = initContract();
20
20
 
@@ -26,7 +26,7 @@ import {
26
26
  PostTradeLineItem,
27
27
  TradeLineItemQuery,
28
28
  TradeLineItemResponse,
29
- } from '../../../common/types/trade-line-item.type';
29
+ } from '../../../common/types/trade-line-item.types';
30
30
 
31
31
  const c = initContract();
32
32
 
@@ -0,0 +1,37 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import {
3
+ BadRequestError,
4
+ InternalError,
5
+ NotFoundError,
6
+ UnauthorizedError,
7
+ } from '../../../common/types';
8
+ import {
9
+ ClientPostTransactionZod,
10
+ TransactionZod,
11
+ } from '../../../common/types/transaction.types';
12
+
13
+ const c = initContract();
14
+
15
+ export const clientsTransactionsContract = c.router(
16
+ {
17
+ postTransaction: {
18
+ summary: 'Create a transaction',
19
+ method: 'POST',
20
+ path: '',
21
+ metadata: {
22
+ auth: true,
23
+ },
24
+ body: ClientPostTransactionZod,
25
+ responses: {
26
+ 201: TransactionZod,
27
+ 400: BadRequestError,
28
+ 401: UnauthorizedError,
29
+ 404: NotFoundError,
30
+ 500: InternalError,
31
+ },
32
+ },
33
+ },
34
+ {
35
+ pathPrefix: 'transactions',
36
+ },
37
+ );
@@ -0,0 +1,59 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import { z } from 'zod';
3
+ import {
4
+ accountSettingIdSchema,
5
+ AccountSettingsFilters,
6
+ AccountSettingsIncludeQuery,
7
+ IAccountSettingZod,
8
+ IPaginatedAccountSetting,
9
+ } from '../../../common/types/account-setting.types';
10
+ import {
11
+ InternalError,
12
+ NotFoundError,
13
+ PaginationOptionsZod,
14
+ UnauthorizedError,
15
+ } from '../../../common/types';
16
+
17
+ const c = initContract();
18
+
19
+ export const accountSettingsContract = c.router(
20
+ {
21
+ getAccountSettings: {
22
+ summary: 'Get account settings',
23
+ method: 'GET',
24
+ path: '',
25
+ metadata: {
26
+ auth: true,
27
+ },
28
+ query: PaginationOptionsZod.merge(AccountSettingsFilters).merge(
29
+ AccountSettingsIncludeQuery,
30
+ ),
31
+ responses: {
32
+ 200: IPaginatedAccountSetting,
33
+ 401: UnauthorizedError,
34
+ 500: InternalError,
35
+ },
36
+ },
37
+ getAccountSetting: {
38
+ summary: 'Get account setting by id',
39
+ method: 'GET',
40
+ path: '/:id',
41
+ metadata: {
42
+ auth: true,
43
+ },
44
+ pathParams: z.object({
45
+ id: accountSettingIdSchema,
46
+ }),
47
+ query: z.object({}).merge(AccountSettingsIncludeQuery),
48
+ responses: {
49
+ 200: IAccountSettingZod,
50
+ 401: UnauthorizedError,
51
+ 404: NotFoundError,
52
+ 500: InternalError,
53
+ },
54
+ },
55
+ },
56
+ {
57
+ pathPrefix: 'account-settings',
58
+ },
59
+ );
@@ -6,10 +6,12 @@ import {
6
6
  UnauthorizedError,
7
7
  } from '../../../common/types';
8
8
  import {
9
+ ComplianceEstimateBonusTierCalculationZod,
9
10
  CompliancePostBonusTierZod,
10
11
  EstimateBonusTierCalculationResponseZod,
11
- EstimateBonusTierCalculationZod,
12
12
  IBonusTierList,
13
+ PurchaseCalculationResponseZod,
14
+ PurchaseCalculationZod,
13
15
  } from '../../../common/types/bonus-tier.types';
14
16
 
15
17
  const c = initContract();
@@ -23,7 +25,7 @@ export const bonusTiersContract = c.router(
23
25
  metadata: {
24
26
  auth: true,
25
27
  },
26
- body: EstimateBonusTierCalculationZod,
28
+ body: ComplianceEstimateBonusTierCalculationZod,
27
29
  responses: {
28
30
  200: EstimateBonusTierCalculationResponseZod,
29
31
  400: BadRequestError,
@@ -32,6 +34,23 @@ export const bonusTiersContract = c.router(
32
34
  500: InternalError,
33
35
  },
34
36
  },
37
+ purchaseCalculation: {
38
+ summary:
39
+ '[ADMIN] Calculate the bonus shares that would be awarded for a trade',
40
+ method: 'POST',
41
+ path: '/purchase-calculation',
42
+ metadata: {
43
+ auth: true,
44
+ },
45
+ body: PurchaseCalculationZod,
46
+ responses: {
47
+ 200: PurchaseCalculationResponseZod,
48
+ 400: BadRequestError,
49
+ 401: UnauthorizedError,
50
+ 403: ForbiddenError,
51
+ 500: InternalError,
52
+ },
53
+ },
35
54
  postBonusTier: {
36
55
  summary: 'Create a new bonus tier',
37
56
  method: 'POST',
@@ -1,6 +1,7 @@
1
1
  import { accountsContract } from './accounts';
2
2
  import { accountContactsContract } from './account-contacts';
3
3
  import { accountManagersContract } from './account-managers';
4
+ import { accountSettingsContract } from './account-settings';
4
5
  import { activitiesContract } from './activities';
5
6
  import { apiKeysContract } from './api-keys';
6
7
  import { assetsContract } from './assets';
@@ -31,6 +32,7 @@ import { kycsContract } from './kyc';
31
32
  import { legalEntitiesContract } from './legal-entities';
32
33
  import { loginHistoriesContract } from './login-histories';
33
34
  import { notesContract } from './notes';
35
+ import { notificationChannelsContract } from './notification-channels';
34
36
  import { offeringsContract } from './offerings';
35
37
  import { pagesContract } from './pages';
36
38
  import { paymentMethodsContract } from './payment-methods';
@@ -75,6 +77,7 @@ export const complianceContract = c.router(
75
77
  accounts: accountsContract,
76
78
  accountContacts: accountContactsContract,
77
79
  accountManagers: accountManagersContract,
80
+ accountSettings: accountSettingsContract,
78
81
  activities: activitiesContract,
79
82
  apiKeys: apiKeysContract,
80
83
  assets: assetsContract,
@@ -112,6 +115,7 @@ export const complianceContract = c.router(
112
115
  legalEntities: legalEntitiesContract,
113
116
  loginHistories: loginHistoriesContract,
114
117
  notes: notesContract,
118
+ notificationChannels: notificationChannelsContract,
115
119
  offerings: offeringsContract,
116
120
  pages: pagesContract,
117
121
  paymentMethods: paymentMethodsContract,