@dalmore/api-contracts 1.0.0 → 1.0.2

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 (33) hide show
  1. package/common/helpers/index.ts +205 -0
  2. package/common/types/account-manager.types.ts +10 -0
  3. package/common/types/account.types.ts +59 -2
  4. package/common/types/activity.types.ts +38 -0
  5. package/common/types/asset.types.ts +3 -0
  6. package/common/types/auth.types.ts +37 -10
  7. package/common/types/batch-jobs.types.ts +0 -1
  8. package/common/types/bonus-tier.types.ts +32 -0
  9. package/common/types/common.types.ts +20 -1
  10. package/common/types/contract-helpers.ts +205 -0
  11. package/common/types/investor-account.types.ts +137 -66
  12. package/common/types/page.types.ts +1 -1
  13. package/common/types/phone.type.ts +1 -1
  14. package/common/types/queue.types.ts +0 -1
  15. package/common/types/secondary-trade.types.ts +8 -0
  16. package/common/types/trade.types.ts +83 -1
  17. package/common/types/user.types.ts +2 -0
  18. package/common/types/zip.type.ts +1 -1
  19. package/contracts/clients/accounts/index.ts +3 -0
  20. package/contracts/clients/auth/index.ts +18 -1
  21. package/contracts/clients/index.ts +2 -0
  22. package/contracts/clients/offerings/index.ts +4 -3
  23. package/contracts/clients/sites/index.ts +56 -0
  24. package/contracts/compliance/account-managers/index.ts +2 -0
  25. package/contracts/compliance/accounts/index.ts +4 -2
  26. package/contracts/compliance/bonus-tiers/index.ts +55 -0
  27. package/contracts/compliance/index.ts +2 -0
  28. package/contracts/compliance/investor-accounts/index.ts +4 -0
  29. package/contracts/issuers/accounts/index.ts +5 -0
  30. package/contracts/issuers/bonus-tiers/index.ts +18 -0
  31. package/contracts/issuers/investor-accounts/index.ts +22 -0
  32. package/package.json +12 -2
  33. package/common/types/reminder-config.types.ts +0 -40
@@ -1,8 +1,10 @@
1
1
  import { initContract } from '@ts-rest/core';
2
2
  import {
3
+ AccessTokenResponse,
3
4
  BadRequestError,
4
5
  ClientAuthSuccessResponse,
5
6
  InternalError,
7
+ IRegisterClientIssuerBodyZod,
6
8
  RegisterBodyInvestors,
7
9
  UnauthorizedError,
8
10
  } from '../../../common/types';
@@ -12,7 +14,7 @@ const c = initContract();
12
14
  export const authContract = c.router(
13
15
  {
14
16
  registerInvestor: {
15
- summary: 'Register investor with email',
17
+ summary: 'Register investor with email (API Key Auth)',
16
18
  method: 'POST',
17
19
  path: 'register/investor',
18
20
  metadata: {
@@ -26,6 +28,21 @@ export const authContract = c.router(
26
28
  500: InternalError,
27
29
  },
28
30
  },
31
+ registerIssuer: {
32
+ summary: 'Register issuer with email (API Key Auth)',
33
+ method: 'POST',
34
+ path: 'register/issuer',
35
+ metadata: {
36
+ auth: true,
37
+ },
38
+ body: IRegisterClientIssuerBodyZod,
39
+ responses: {
40
+ 201: AccessTokenResponse,
41
+ 400: BadRequestError,
42
+ 401: UnauthorizedError,
43
+ 500: InternalError,
44
+ },
45
+ },
29
46
  },
30
47
  {
31
48
  pathPrefix: 'auth/',
@@ -14,6 +14,7 @@ import { filesPublicContract } from './files-public';
14
14
  import { secureRequestContract } from './secure-requests';
15
15
  import { aicContract } from './aic';
16
16
  import { authContract } from './auth';
17
+ import { sitesContract } from './sites';
17
18
 
18
19
  const c = initContract();
19
20
 
@@ -34,6 +35,7 @@ export const clientsContract = c.router(
34
35
  legalEntities: legalEntityContract,
35
36
  offerings: offeringsContract,
36
37
  secureRequests: secureRequestContract,
38
+ sites: sitesContract,
37
39
  trades: tradesContract,
38
40
  },
39
41
  {
@@ -13,7 +13,8 @@ import {
13
13
  OfferingSummaryFiltersZod,
14
14
  PaginatedOfferingSummaryResponseZod,
15
15
  PaginationOptionsZod,
16
- PatchOffering,
16
+ PatchIssuerOffering,
17
+ PostIssuerOffering,
17
18
  UnauthorizedError,
18
19
  } from '../../../common/types';
19
20
 
@@ -83,7 +84,7 @@ export const offeringsContract = c.router(
83
84
  pathParams: z.object({
84
85
  id: offeringIdSchema,
85
86
  }),
86
- body: PatchOffering,
87
+ body: PatchIssuerOffering,
87
88
  responses: {
88
89
  201: IOffering,
89
90
  400: BadRequestError,
@@ -100,7 +101,7 @@ export const offeringsContract = c.router(
100
101
  metadata: {
101
102
  auth: true,
102
103
  },
103
- body: PatchOffering,
104
+ body: PostIssuerOffering,
104
105
  responses: {
105
106
  201: IOffering,
106
107
  400: BadRequestError,
@@ -0,0 +1,56 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import {
3
+ ForbiddenError,
4
+ NotFoundError,
5
+ PaginationOptionsZod,
6
+ UnauthorizedError,
7
+ } from '../../../common/types';
8
+ import {
9
+ SitesFiltersZod,
10
+ SitesIncludeQuery,
11
+ SitesPaginated,
12
+ SitesParamSchema,
13
+ SiteZod,
14
+ } from '../../../common/types/site.types';
15
+
16
+ const c = initContract();
17
+
18
+ export const sitesContract = c.router(
19
+ {
20
+ getSite: {
21
+ summary: 'get site by id',
22
+ method: 'GET',
23
+ path: '/:id',
24
+ pathParams: SitesParamSchema,
25
+ metadata: {
26
+ auth: true,
27
+ },
28
+ query: SitesIncludeQuery.merge(SitesFiltersZod),
29
+ responses: {
30
+ 200: SiteZod,
31
+ 401: UnauthorizedError,
32
+ 403: ForbiddenError,
33
+ 404: NotFoundError,
34
+ },
35
+ },
36
+ getSites: {
37
+ summary: 'query sites by url',
38
+ method: 'GET',
39
+ path: '/',
40
+ metadata: {
41
+ auth: true,
42
+ },
43
+ query:
44
+ PaginationOptionsZod.merge(SitesFiltersZod).merge(SitesIncludeQuery),
45
+ responses: {
46
+ 200: SitesPaginated,
47
+ 401: UnauthorizedError,
48
+ 403: ForbiddenError,
49
+ 404: NotFoundError,
50
+ },
51
+ },
52
+ },
53
+ {
54
+ pathPrefix: 'sites',
55
+ },
56
+ );
@@ -10,6 +10,7 @@ import {
10
10
  UnauthorizedError,
11
11
  } from '../../../common/types';
12
12
  import {
13
+ AccountManagerDeleteQuery,
13
14
  AccountManagerDeleteResponse,
14
15
  accountManagerIdSchema,
15
16
  AccountManagersIncludeQuery,
@@ -122,6 +123,7 @@ export const accountManagersContract = c.router(
122
123
  pathParams: z.object({
123
124
  id: accountManagerIdSchema,
124
125
  }),
126
+ query: AccountManagerDeleteQuery,
125
127
  responses: {
126
128
  201: AccountManagerDeleteResponse,
127
129
  400: BadRequestError,
@@ -15,7 +15,7 @@ import {
15
15
  IPaginatedAccountsSummaryResponse,
16
16
  UpdateAccountIssuersStatusZod,
17
17
  UpdateAccountStatusReponse,
18
- PatchAccountZod,
18
+ CompliancePatchAccountZod,
19
19
  AccountSortZod,
20
20
  BadRequestError,
21
21
  } from '../../../common/types';
@@ -63,6 +63,7 @@ export const accountsContract = c.router(
63
63
  401: UnauthorizedError,
64
64
  403: ForbiddenError,
65
65
  404: NotFoundError,
66
+ 500: InternalError,
66
67
  },
67
68
  },
68
69
  // Admin
@@ -81,6 +82,7 @@ export const accountsContract = c.router(
81
82
  200: IPaginatedAccount,
82
83
  401: UnauthorizedError,
83
84
  403: ForbiddenError,
85
+ 500: InternalError,
84
86
  },
85
87
  },
86
88
  updateAccountAdmin: {
@@ -93,7 +95,7 @@ export const accountsContract = c.router(
93
95
  pathParams: z.object({
94
96
  id: accountIdSchema,
95
97
  }),
96
- body: PatchAccountZod,
98
+ body: CompliancePatchAccountZod,
97
99
  responses: {
98
100
  200: AccountZod,
99
101
  404: NotFoundError,
@@ -0,0 +1,55 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import {
3
+ BadRequestError,
4
+ ForbiddenError,
5
+ InternalError,
6
+ UnauthorizedError,
7
+ } from '../../../common/types';
8
+ import {
9
+ CompliancePostBonusTierZod,
10
+ EstimateBonusTierCalculationResponseZod,
11
+ EstimateBonusTierCalculationZod,
12
+ IBonusTierList,
13
+ } from '../../../common/types/bonus-tier.types';
14
+
15
+ const c = initContract();
16
+
17
+ export const bonusTiersContract = c.router(
18
+ {
19
+ estimateCalculation: {
20
+ summary: 'Estimate bonus tier calculation',
21
+ method: 'POST',
22
+ path: '/estimate-calculation',
23
+ metadata: {
24
+ auth: true,
25
+ },
26
+ body: EstimateBonusTierCalculationZod,
27
+ responses: {
28
+ 200: EstimateBonusTierCalculationResponseZod,
29
+ 400: BadRequestError,
30
+ 401: UnauthorizedError,
31
+ 403: ForbiddenError,
32
+ 500: InternalError,
33
+ },
34
+ },
35
+ postBonusTier: {
36
+ summary: 'Create a new bonus tier',
37
+ method: 'POST',
38
+ path: '/',
39
+ metadata: {
40
+ auth: true,
41
+ },
42
+ body: CompliancePostBonusTierZod,
43
+ responses: {
44
+ 201: IBonusTierList,
45
+ 400: BadRequestError,
46
+ 401: UnauthorizedError,
47
+ 403: ForbiddenError,
48
+ 500: InternalError,
49
+ },
50
+ },
51
+ },
52
+ {
53
+ pathPrefix: 'bonus-tiers',
54
+ },
55
+ );
@@ -66,6 +66,7 @@ import { defaultThemeConfigsContract } from './default-theme-configs';
66
66
  import { aicContract } from './aic';
67
67
  import { stateMachineContract } from './state-machine';
68
68
  import { offeringReportsContract } from './offering-reports';
69
+ import { bonusTiersContract } from './bonus-tiers';
69
70
 
70
71
  const c = initContract();
71
72
 
@@ -80,6 +81,7 @@ export const complianceContract = c.router(
80
81
  auth: authContract,
81
82
  aic: aicContract,
82
83
  batchJobs: batchJobsContract,
84
+ bonusTiers: bonusTiersContract,
83
85
  checklist: checkListContract,
84
86
  checklistItems: checkListItemsContract,
85
87
  coveredPersons: coveredPersonsContract,
@@ -6,6 +6,7 @@ import {
6
6
  InternalError,
7
7
  NotFoundError,
8
8
  PaginationOptionsZod,
9
+ tradeIdSchema,
9
10
  UnauthorizedError,
10
11
  } from '../../../common/types';
11
12
  import { z } from 'zod';
@@ -89,6 +90,9 @@ export const investorAccountsContract = c.router(
89
90
  pathParams: z.object({
90
91
  id: investorAccountIdSchema,
91
92
  }),
93
+ query: z.object({
94
+ tradeId: tradeIdSchema.optional(),
95
+ }),
92
96
  responses: {
93
97
  200: IInvestorAccountSummary,
94
98
  401: UnauthorizedError,
@@ -13,6 +13,7 @@ import {
13
13
  PatchAccountZod,
14
14
  PatchIssuerOnboardingStep,
15
15
  IssuerOnboardingStepZod,
16
+ InternalError,
16
17
  } from '../../../common/types';
17
18
  import { z } from 'zod';
18
19
 
@@ -35,6 +36,7 @@ export const accountsContract = c.router(
35
36
  200: IPaginatedAccount,
36
37
  401: UnauthorizedError,
37
38
  403: ForbiddenError,
39
+ 500: InternalError,
38
40
  },
39
41
  },
40
42
  getAccount: {
@@ -53,6 +55,7 @@ export const accountsContract = c.router(
53
55
  401: UnauthorizedError,
54
56
  403: ForbiddenError,
55
57
  404: NotFoundError,
58
+ 500: InternalError,
56
59
  },
57
60
  },
58
61
  patchOnboardingStep: {
@@ -68,6 +71,7 @@ export const accountsContract = c.router(
68
71
  401: UnauthorizedError,
69
72
  403: ForbiddenError,
70
73
  404: NotFoundError,
74
+ 500: InternalError,
71
75
  },
72
76
  },
73
77
  patchAccount: {
@@ -83,6 +87,7 @@ export const accountsContract = c.router(
83
87
  401: UnauthorizedError,
84
88
  403: ForbiddenError,
85
89
  404: NotFoundError,
90
+ 500: InternalError,
86
91
  },
87
92
  },
88
93
  },
@@ -8,6 +8,8 @@ import {
8
8
  import {
9
9
  EstimateBonusTierCalculationResponseZod,
10
10
  EstimateBonusTierCalculationZod,
11
+ IBonusTierList,
12
+ PostBonusTierZod,
11
13
  } from '../../../common/types/bonus-tier.types';
12
14
 
13
15
  const c = initContract();
@@ -30,6 +32,22 @@ export const bonusTiersContract = c.router(
30
32
  500: InternalError,
31
33
  },
32
34
  },
35
+ postBonusTier: {
36
+ summary: 'Create a new bonus tier',
37
+ method: 'POST',
38
+ path: '/',
39
+ metadata: {
40
+ auth: true,
41
+ },
42
+ body: PostBonusTierZod,
43
+ responses: {
44
+ 201: IBonusTierList,
45
+ 400: BadRequestError,
46
+ 401: UnauthorizedError,
47
+ 403: ForbiddenError,
48
+ 500: InternalError,
49
+ },
50
+ },
33
51
  },
34
52
  {
35
53
  pathPrefix: 'bonus-tiers',
@@ -6,6 +6,7 @@ import {
6
6
  InternalError,
7
7
  NotFoundError,
8
8
  PaginationOptionsZod,
9
+ tradeIdSchema,
9
10
  UnauthorizedError,
10
11
  } from '../../../common/types';
11
12
  import { z } from 'zod';
@@ -19,6 +20,7 @@ import {
19
20
  GetInvestorAccountDetailsQuery,
20
21
  RegisteredInvestorUserFiltersZod,
21
22
  IPaginatedRegisteredInvestorUserZod,
23
+ IInvestorAccountSummary,
22
24
  } from '../../../common/types/investor-account.types';
23
25
 
24
26
  const c = initContract();
@@ -119,6 +121,26 @@ export const investorAccountsContract = c.router(
119
121
  404: NotFoundError,
120
122
  },
121
123
  },
124
+ getInvestorAccountSummary: {
125
+ summary: 'Get investor account summary',
126
+ method: 'GET',
127
+ path: '/:id/summary',
128
+ metadata: {
129
+ auth: true,
130
+ },
131
+ pathParams: z.object({
132
+ id: investorAccountIdSchema,
133
+ }),
134
+ query: z.object({
135
+ tradeId: tradeIdSchema.optional(),
136
+ }),
137
+ responses: {
138
+ 200: IInvestorAccountSummary,
139
+ 401: UnauthorizedError,
140
+ 403: ForbiddenError,
141
+ 404: NotFoundError,
142
+ },
143
+ },
122
144
  },
123
145
  {
124
146
  pathPrefix: 'investor-accounts',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalmore/api-contracts",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Type-safe API contracts for Dalmore Client Portal",
5
5
  "main": "./contracts/index.ts",
6
6
  "types": "./contracts/index.ts",
@@ -40,6 +40,10 @@
40
40
  "./types/*": {
41
41
  "types": "./common/types/*.ts",
42
42
  "default": "./common/types/*.ts"
43
+ },
44
+ "./helpers": {
45
+ "types": "./common/helpers/index.ts",
46
+ "default": "./common/helpers/index.ts"
43
47
  }
44
48
  },
45
49
  "files": [
@@ -55,13 +59,19 @@
55
59
  ],
56
60
  "author": "Dalmore Group",
57
61
  "license": "UNLICENSED",
62
+ "publishConfig": {
63
+ "access": "public"
64
+ },
58
65
  "repository": {
59
66
  "type": "git",
60
67
  "url": "https://github.com/OfficialDalmoreGroup/dalmore-client-portal-api.git"
61
68
  },
62
69
  "peerDependencies": {
63
70
  "@anatine/zod-openapi": "^1.14.2",
71
+ "@nestjs/common": "^11.0.0",
64
72
  "@ts-rest/core": "^3.52.1",
73
+ "libphonenumber-js": "^1.12.0",
74
+ "neverthrow": "^8.0.0",
65
75
  "typeid-js": "^1.2.0",
66
76
  "zod": "^3.24.4"
67
77
  },
@@ -69,6 +79,6 @@
69
79
  "typescript": "^5.8.3"
70
80
  },
71
81
  "engines": {
72
- "node": ">=22.15.0 <23.0.0"
82
+ "node": ">=24.0.0 <25.0.0"
73
83
  }
74
84
  }
@@ -1,40 +0,0 @@
1
- import { Job } from 'bullmq';
2
- import { QueryRunner } from 'typeorm';
3
- import { Site } from '../../sites/entities/site.entity';
4
- import { ProcessTradeCancellationReminderDto } from '../../workers/dto.worker';
5
-
6
- export enum ReminderType {
7
- DAILY = 'daily',
8
- CUMULATIVE = 'cumulative',
9
- WARNING = 'warning',
10
- CANCEL = 'cancel',
11
- SKIP = 'skip', // for days with no action
12
- }
13
-
14
- export interface ReminderConfig {
15
- day: number;
16
- type: ReminderType;
17
- daysLeft?: number; // for warning type
18
- createTask?: boolean; // for daily type
19
- priority?: 'low' | 'medium' | 'high' | 'urgent';
20
- }
21
-
22
- export interface ReminderTemplate {
23
- subject: (params: ReminderTemplateParams) => string;
24
- description: (params: ReminderTemplateParams) => string;
25
- }
26
-
27
- export interface ReminderTemplateParams {
28
- day: number;
29
- offeringName: string;
30
- daysLeft?: number;
31
- userName: string;
32
- tradeStatus: string;
33
- }
34
-
35
- export interface ReminderContext {
36
- queryRunner: QueryRunner;
37
- job: Job<ProcessTradeCancellationReminderDto>;
38
- site: Site;
39
- logContext: any;
40
- }