@dalmore/api-contracts 1.0.6 → 1.0.7

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/dist/contracts/clients/index.d.ts +19 -0
  2. package/index.mjs +4 -1
  3. package/package.json +4 -4
  4. package/src/common/types/account-contact.types.ts +0 -98
  5. package/src/common/types/account-detail.types.ts +0 -27
  6. package/src/common/types/account-integration.types.ts +0 -143
  7. package/src/common/types/account-manager.types.ts +0 -124
  8. package/src/common/types/account.types.ts +0 -296
  9. package/src/common/types/activity.types.ts +0 -274
  10. package/src/common/types/address.spec.ts +0 -203
  11. package/src/common/types/address.types.ts +0 -41
  12. package/src/common/types/aic.types.ts +0 -246
  13. package/src/common/types/aml.types.ts +0 -18
  14. package/src/common/types/api-key-logs.types.ts +0 -66
  15. package/src/common/types/api-keys.types.ts +0 -69
  16. package/src/common/types/asset.types.ts +0 -338
  17. package/src/common/types/auth.types.ts +0 -370
  18. package/src/common/types/batch-jobs.types.ts +0 -151
  19. package/src/common/types/bonus-tier.types.ts +0 -147
  20. package/src/common/types/cart.types.ts +0 -18
  21. package/src/common/types/checklist-items.types.ts +0 -70
  22. package/src/common/types/checklist.types.ts +0 -97
  23. package/src/common/types/common.types.spec.ts +0 -336
  24. package/src/common/types/common.types.ts +0 -1520
  25. package/src/common/types/comply-advantage-api.types.ts +0 -316
  26. package/src/common/types/comply-advantage.types.ts +0 -25
  27. package/src/common/types/contact-us.types.ts +0 -107
  28. package/src/common/types/contract-helpers.ts +0 -205
  29. package/src/common/types/countries.types.ts +0 -375
  30. package/src/common/types/covered-person.types.ts +0 -274
  31. package/src/common/types/dashboard.types.ts +0 -799
  32. package/src/common/types/data-record.types.ts +0 -325
  33. package/src/common/types/data-room.types.ts +0 -242
  34. package/src/common/types/default-theme-config.types.ts +0 -87
  35. package/src/common/types/disbursement-adjustment.types.ts +0 -32
  36. package/src/common/types/disbursement-approval-user.types.ts +0 -100
  37. package/src/common/types/disbursement-review.types.ts +0 -110
  38. package/src/common/types/disbursement-transaction.types.ts +0 -72
  39. package/src/common/types/disbursements.types.ts +0 -310
  40. package/src/common/types/domain-filter.types.ts +0 -55
  41. package/src/common/types/email-theme.types.ts +0 -442
  42. package/src/common/types/entity.types.ts +0 -15
  43. package/src/common/types/error-responses.types.ts +0 -135
  44. package/src/common/types/escrow-account.types.ts +0 -104
  45. package/src/common/types/exchange-api-key.types.ts +0 -121
  46. package/src/common/types/exchange-import.types.ts +0 -36
  47. package/src/common/types/exchange-provider.types.ts +0 -329
  48. package/src/common/types/file.types.ts +0 -461
  49. package/src/common/types/files.types.spec.ts +0 -154
  50. package/src/common/types/health.types.ts +0 -29
  51. package/src/common/types/index.ts +0 -48
  52. package/src/common/types/individuals.types.ts +0 -554
  53. package/src/common/types/investor-account.types.ts +0 -1239
  54. package/src/common/types/investorAccountIdSchema.type.ts +0 -0
  55. package/src/common/types/investors-offering.types.ts +0 -65
  56. package/src/common/types/invite.types.ts +0 -133
  57. package/src/common/types/issuer-bank-account.types.ts +0 -107
  58. package/src/common/types/issuer-offering.types.ts +0 -306
  59. package/src/common/types/issuer-payment-method.types.spec.ts +0 -612
  60. package/src/common/types/issuer-payment-method.types.ts +0 -341
  61. package/src/common/types/issuer.types.ts +0 -312
  62. package/src/common/types/job-item.types.ts +0 -119
  63. package/src/common/types/jobs.types.ts +0 -171
  64. package/src/common/types/kyb.types.ts +0 -53
  65. package/src/common/types/kyc.types.ts +0 -188
  66. package/src/common/types/legal-entity.types.ts +0 -185
  67. package/src/common/types/login-history.types.ts +0 -46
  68. package/src/common/types/mail-template.types.ts +0 -436
  69. package/src/common/types/north-cap-integration.types.ts +0 -190
  70. package/src/common/types/note.types.ts +0 -109
  71. package/src/common/types/notification.types.ts +0 -58
  72. package/src/common/types/notion-api.types.ts +0 -374
  73. package/src/common/types/notion-database.types.ts +0 -125
  74. package/src/common/types/notion-page.types.ts +0 -267
  75. package/src/common/types/offering-reports.types.ts +0 -153
  76. package/src/common/types/offering-submission.types.ts +0 -314
  77. package/src/common/types/offering.types.spec.ts +0 -91
  78. package/src/common/types/offering.types.ts +0 -590
  79. package/src/common/types/page-revision.types.ts +0 -86
  80. package/src/common/types/page.types.ts +0 -436
  81. package/src/common/types/password.type.ts +0 -15
  82. package/src/common/types/payment-methods.types.ts +0 -298
  83. package/src/common/types/phone.spec.ts +0 -76
  84. package/src/common/types/phone.type.ts +0 -27
  85. package/src/common/types/portfolio.types.ts +0 -50
  86. package/src/common/types/privacy-policy-and-tos.types.ts +0 -231
  87. package/src/common/types/queue.types.ts +0 -112
  88. package/src/common/types/registered-reps.types.ts +0 -25
  89. package/src/common/types/rejection-reasons.types.ts +0 -56
  90. package/src/common/types/reminder-config.types.ts +0 -40
  91. package/src/common/types/review.types.ts +0 -133
  92. package/src/common/types/role.types.ts +0 -26
  93. package/src/common/types/secondary-customer.types.ts +0 -66
  94. package/src/common/types/secondary-issuer.types.ts +0 -50
  95. package/src/common/types/secondary-order.types.ts +0 -58
  96. package/src/common/types/secondary-security.types.ts +0 -60
  97. package/src/common/types/secondary-trade.entity.ts +0 -16
  98. package/src/common/types/secondary-trade.types.ts +0 -95
  99. package/src/common/types/secure-request.types.ts +0 -68
  100. package/src/common/types/signer.types.ts +0 -651
  101. package/src/common/types/site-link.types.spec.ts +0 -134
  102. package/src/common/types/site-link.types.ts +0 -166
  103. package/src/common/types/site-settings.types.ts +0 -726
  104. package/src/common/types/site.types.ts +0 -270
  105. package/src/common/types/sms.types.ts +0 -30
  106. package/src/common/types/state-machine.types.ts +0 -177
  107. package/src/common/types/states.types.ts +0 -163
  108. package/src/common/types/subdoc-preview.types.ts +0 -35
  109. package/src/common/types/task.types.ts +0 -258
  110. package/src/common/types/trade-adjustment.type.ts +0 -33
  111. package/src/common/types/trade-line-item.type.ts +0 -132
  112. package/src/common/types/trade.types.ts +0 -929
  113. package/src/common/types/transaction.types.ts +0 -198
  114. package/src/common/types/trusted-contact.types.ts +0 -122
  115. package/src/common/types/typography.types.ts +0 -75
  116. package/src/common/types/user-manual.types.ts +0 -290
  117. package/src/common/types/user-setting.types.ts +0 -133
  118. package/src/common/types/user.types.ts +0 -320
  119. package/src/common/types/webhook.types.ts +0 -588
  120. package/src/common/types/zip.type.ts +0 -36
  121. package/src/contracts/clients/accounts/index.ts +0 -61
  122. package/src/contracts/clients/aic/index.ts +0 -59
  123. package/src/contracts/clients/api-key-logs/index.ts +0 -53
  124. package/src/contracts/clients/api-keys/index.ts +0 -73
  125. package/src/contracts/clients/assets/index.ts +0 -102
  126. package/src/contracts/clients/auth/index.ts +0 -50
  127. package/src/contracts/clients/files/index.ts +0 -166
  128. package/src/contracts/clients/files-public/index.ts +0 -166
  129. package/src/contracts/clients/index.ts +0 -44
  130. package/src/contracts/clients/individuals/index.ts +0 -93
  131. package/src/contracts/clients/investor-accounts/index.ts +0 -93
  132. package/src/contracts/clients/issuers/index.ts +0 -94
  133. package/src/contracts/clients/legal-entities/index.ts +0 -93
  134. package/src/contracts/clients/offerings/index.ts +0 -117
  135. package/src/contracts/clients/secure-requests/index.ts +0 -34
  136. package/src/contracts/clients/sites/index.ts +0 -56
  137. package/src/contracts/clients/trades/index.ts +0 -122
@@ -1,296 +0,0 @@
1
- import { extendZodWithOpenApi } from '@anatine/zod-openapi';
2
- import { TypeID } from 'typeid-js';
3
- import { z } from 'zod';
4
- import {
5
- AccountZod,
6
- dateSchema,
7
- IPaginationMeta,
8
- IssuerOnboardingSetupType,
9
- ManagedByType,
10
- Platform,
11
- SortBy,
12
- SortOrder,
13
- AccountStatus,
14
- } from './common.types';
15
- import { notionPageIdSchema } from './notion-page.types';
16
-
17
- extendZodWithOpenApi(z);
18
-
19
- export const accountIdSchema = z.string().refine(
20
- (value) => {
21
- try {
22
- const tid = TypeID.fromString(value);
23
- return tid.getType() === 'account';
24
- } catch {
25
- return false;
26
- }
27
- },
28
- {
29
- message:
30
- 'Invalid account ID format. Must be a valid TypeID with "account" prefix.',
31
- },
32
- );
33
-
34
- export const UpdateAccountZod = z.object({
35
- name: z.string().min(1).max(100),
36
- status: z.nativeEnum(AccountStatus).optional(),
37
- platform: z
38
- .nativeEnum(Platform)
39
- .optional()
40
- .openapi({ example: Platform.INTEGRATION }),
41
- managedBy: z
42
- .nativeEnum(ManagedByType)
43
- .optional()
44
- .openapi({ example: ManagedByType.DALMORE }),
45
- approversCount: z.number().min(1).max(5).optional(),
46
- });
47
- export type UpdateAccountZod = z.infer<typeof UpdateAccountZod>;
48
-
49
- export const CreateAccountZod = z.object({
50
- name: z.string().min(1).max(100).openapi({ example: 'Name' }),
51
- platform: z
52
- .nativeEnum(Platform)
53
- .optional()
54
- .openapi({ example: Platform.INTEGRATION }),
55
- managedBy: z
56
- .nativeEnum(ManagedByType)
57
- .optional()
58
- .openapi({ example: ManagedByType.DALMORE }),
59
- approversCount: z.number().min(1).max(5).optional().openapi({ example: 2 }),
60
- hubspotCompany: z
61
- .string()
62
- .url()
63
- .max(2048)
64
- .nullable()
65
- .optional()
66
- .openapi({ example: 'https://www.google.com' }),
67
- });
68
- export type CreateAccountZod = z.infer<typeof CreateAccountZod>;
69
-
70
- export const IPaginatedAccount = z.object({
71
- items: z.array(AccountZod),
72
- meta: IPaginationMeta,
73
- });
74
- export type IPaginatedAccount = z.infer<typeof IPaginatedAccount>;
75
-
76
- export const AccountFiltersZod = z.object({
77
- search: z.string().max(50).optional(),
78
- status: z.nativeEnum(AccountStatus).optional(),
79
- platform: z
80
- .nativeEnum(Platform)
81
- .optional()
82
- .openapi({ example: Platform.INTEGRATION }),
83
- managedBy: z
84
- .nativeEnum(ManagedByType)
85
- .optional()
86
- .openapi({ example: ManagedByType.DALMORE }),
87
- from: dateSchema.optional().openapi({ example: 'MM/DD/YYYY' }),
88
- to: dateSchema.optional().openapi({ example: 'MM/DD/YYYY' }),
89
- });
90
-
91
- const accountsInclude = z.enum([
92
- 'accountManager',
93
- 'accountIntegrations',
94
- 'apiKeys',
95
- 'assets',
96
- 'dataRooms',
97
- 'individuals',
98
- 'investorAccounts',
99
- 'invites',
100
- 'issuers',
101
- 'legalEntities',
102
- 'offerings',
103
- 'sites',
104
- 'trades',
105
- 'users',
106
- ]);
107
-
108
- /**
109
- * @description Query parameters for including related entities
110
- * @xample in contract us as -> query: z.object({}).merge(AccountsIncludeQuery),
111
- */
112
- export const AccountsIncludeQuery = z.object({
113
- include: z
114
- .string()
115
- .optional()
116
- .transform((str) => (str ? str.split(',') : []))
117
- .refine(
118
- (includes) =>
119
- includes.every((include) =>
120
- accountsInclude.options.includes(include as any),
121
- ),
122
- {
123
- message: `Invalid include option provided. Valid options are: ${accountsInclude.options.join(',')}`,
124
- },
125
- )
126
- .openapi({
127
- example: `${accountsInclude.options.join(',')}`,
128
- }),
129
- });
130
- export interface AccountsIncludeQuery
131
- extends z.infer<typeof AccountsIncludeQuery> {}
132
-
133
- export const PatchAccountZod = z.object({
134
- name: z.string().min(1).max(100),
135
- approversCount: z.number().min(1).max(5).optional(),
136
- managedBy: z.nativeEnum(ManagedByType).optional(),
137
- platform: z.nativeEnum(Platform).optional(),
138
- integrationGuideId: notionPageIdSchema.nullable().optional(),
139
- productPrimaries: z.boolean().optional(),
140
- productSecondaries: z.boolean().optional(),
141
- featureDisbursements: z.boolean().optional(),
142
- });
143
- export type PatchAccountZod = z.infer<typeof PatchAccountZod>;
144
-
145
- export const CompliancePatchAccountZod = PatchAccountZod.extend({
146
- hubspotCompany: z
147
- .string()
148
- .url()
149
- .max(2048)
150
- .nullable()
151
- .optional()
152
- .openapi({ example: 'https://www.google.com' }),
153
- });
154
- export type CompliancePatchAccountZod = z.infer<
155
- typeof CompliancePatchAccountZod
156
- >;
157
-
158
- export const PostAccountResponse = z.object({
159
- id: z.string(),
160
- });
161
- export type PostAccountResponse = z.infer<typeof PostAccountResponse>;
162
-
163
- export const GetAccountIssuersZod = z.object({
164
- name: z.string().optional(),
165
- accountId: accountIdSchema.optional(),
166
- });
167
- export type GetAccountIssuersZod = z.infer<typeof GetAccountIssuersZod>;
168
-
169
- export const UpdateAccountIssuersStatusZod = z.object({
170
- status: z.nativeEnum(AccountStatus),
171
- });
172
- export type UpdateAccountIssuersStatusZod = z.infer<
173
- typeof UpdateAccountIssuersStatusZod
174
- >;
175
-
176
- export const UpdateAccountStatusReponse = z.object({
177
- id: accountIdSchema,
178
- status: z.nativeEnum(AccountStatus),
179
- });
180
- export type UpdateAccountStatusReponse = z.infer<
181
- typeof UpdateAccountStatusReponse
182
- >;
183
-
184
- export const AccountsSummaryFilterZod = z.object({
185
- search: z.string().trim().max(50).optional(),
186
- status: z.nativeEnum(AccountStatus).optional(),
187
- from: dateSchema.optional().openapi({ example: 'MM/DD/YYYY' }),
188
- to: dateSchema.optional().openapi({ example: 'MM/DD/YYYY' }),
189
- accountManagerIds: z
190
- .string()
191
- .optional()
192
- .transform((val) => {
193
- if (!val || typeof val !== 'string') return undefined;
194
-
195
- const ids = val
196
- .split(',')
197
- .map((id: string) => id.trim())
198
- .filter((id: string) => id.length > 0);
199
-
200
- // Remove duplicates using Set
201
- const uniqueIds = [...new Set(ids)];
202
-
203
- return uniqueIds.length > 0 ? uniqueIds : undefined;
204
- })
205
- .pipe(
206
- z
207
- .array(
208
- z.string().refine(
209
- (value) => {
210
- try {
211
- const tid = TypeID.fromString(value);
212
- return tid.getType() === 'account_manager';
213
- } catch {
214
- return false;
215
- }
216
- },
217
- {
218
- message: `Invalid account manager ID format. Must be a valid TypeID with "account_manager" prefix. Example: account_manager_01j5y5ghx5fg68d663j1fvy2x7`,
219
- },
220
- ),
221
- )
222
- .optional(),
223
- ),
224
- });
225
- export type AccountsSummaryFilterZod = z.infer<typeof AccountsSummaryFilterZod>;
226
-
227
- export const AccountSortZod = z.object({
228
- sort: z.enum([SortBy.NAME, SortBy.CREATED_AT, SortBy.UPDATED_AT]).optional(),
229
- dir: z.nativeEnum(SortOrder).optional(),
230
- });
231
- export type AccountSortZod = z.infer<typeof AccountSortZod>;
232
-
233
- export const AccountsSummaryZod = z.object({
234
- accountId: accountIdSchema,
235
- accountName: z.string(),
236
- issuers: z.number().int(),
237
- offerings: z.number().int(),
238
- assets: z.number().int(),
239
- users: z.number().int(),
240
- trades: z.number().int(),
241
- accountManagerName: z.string(),
242
- createdOn: z.string(),
243
- status: z.string(),
244
- });
245
- export type AccountsSummaryZod = z.infer<typeof AccountsSummaryZod>;
246
-
247
- export const IPaginatedAccountsSummaryResponse = z.object({
248
- items: z.array(AccountsSummaryZod),
249
- meta: IPaginationMeta,
250
- });
251
- export type IPaginatedAccountsSummaryResponse = z.infer<
252
- typeof IPaginatedAccountsSummaryResponse
253
- >;
254
- export const PatchIssuerOnboardingStep = z.object({
255
- step: z.nativeEnum(IssuerOnboardingSetupType),
256
- });
257
- export type PatchIssuerOnboardingStep = z.infer<
258
- typeof PatchIssuerOnboardingStep
259
- >;
260
-
261
- export const IssuerOnboardingStepZod = z.object({
262
- offeringSetup: z.boolean().default(false),
263
- investorPortalSetup: z.boolean().default(false),
264
- paymentMethodSetup: z.boolean().default(false),
265
- accountContactsSetup: z.boolean().default(false),
266
- });
267
- export type IssuerOnboardingStepZod = z.infer<typeof IssuerOnboardingStepZod>;
268
-
269
- export const OnboardingAccountSummaryZod = z.object({
270
- accountId: accountIdSchema,
271
- accountName: z.string(),
272
- siteId: z.string().nullable(),
273
- offeringId: z.string().nullable(),
274
- investorPortalSetup: z.boolean(),
275
- offeringSetup: z.boolean(),
276
- paymentMethodSetup: z.boolean(),
277
- accountContactsSetup: z.boolean(),
278
- });
279
- export type OnboardingAccountSummaryZod = z.infer<
280
- typeof OnboardingAccountSummaryZod
281
- >;
282
-
283
- export const IPaginatedOnboardingAccountSummaryResponse = z.object({
284
- items: z.array(OnboardingAccountSummaryZod),
285
- meta: IPaginationMeta,
286
- });
287
- export type IPaginatedOnboardingAccountSummaryResponse = z.infer<
288
- typeof IPaginatedOnboardingAccountSummaryResponse
289
- >;
290
-
291
- export const OnboardingAccountSummaryFilterZod = z.object({
292
- status: z.nativeEnum(AccountStatus).optional(),
293
- });
294
- export type OnboardingAccountSummaryFilterZod = z.infer<
295
- typeof OnboardingAccountSummaryFilterZod
296
- >;
@@ -1,274 +0,0 @@
1
- import { z } from 'zod';
2
- import {
3
- BaseAction,
4
- BaseStatus,
5
- IPaginationMeta,
6
- PortalType,
7
- TargetTableConfig,
8
- TargetTableEnum,
9
- } from './common.types';
10
- import { TypeID } from 'typeid-js';
11
- import { IBaseEntity } from './entity.types';
12
-
13
- /**
14
- * WARNING!!!
15
- * ANY CHANGES TO:
16
- * - ActivityTypeCategory
17
- * - ActivityTypeResource
18
- * - ActivityTypeAction
19
- * Will require a migration to add the new combinations to the database. See activity-type.entity.ts
20
- * Also, previous migrations will have to be updated to prevent the new combination from being seeded before the new migration introduces it.
21
- * see: SeedActivityActionTable1733789494520
22
- * This is required only for backwards compatibility when developing locally and e2e tests.
23
- */
24
- export enum ActivityTypeCategory {
25
- CLIENT = PortalType.CLIENT,
26
- INVESTOR = PortalType.INVESTOR,
27
- COMPLIANCE = PortalType.COMPLIANCE,
28
- ISSUER = PortalType.ISSUER,
29
- }
30
-
31
- export const CategoryMap: { [key: string]: ActivityTypeCategory } = {
32
- compliance: ActivityTypeCategory.COMPLIANCE,
33
- issuers: ActivityTypeCategory.ISSUER,
34
- clients: ActivityTypeCategory.CLIENT,
35
- investors: ActivityTypeCategory.INVESTOR,
36
- };
37
-
38
- export enum ActivityTypeResource {
39
- KYCS = 'KYCS',
40
- KYBS = 'KYBS',
41
- INDIVIDUALS = 'INDIVIDUALS',
42
- LEGAL_ENTITIES = 'LEGAL_ENTITIES',
43
- INVESTOR_ACCOUNTS = 'INVESTOR_ACCOUNTS',
44
- TRADES = 'TRADES',
45
- OFFERINGS = 'OFFERINGS',
46
- ISSUERS = 'ISSUERS',
47
- COVERED_PERSONS = 'COVERED_PERSONS',
48
- PAYMENT_METHODS = 'PAYMENT_METHODS',
49
- NOTES = 'NOTES',
50
- USERS = 'USERS',
51
- ACCOUNTS = 'ACCOUNTS',
52
- FILES = 'FILES',
53
- PAGES = 'PAGES',
54
- AMLS = 'AMLS',
55
- DISBURSEMENTS = 'DISBURSEMENTS',
56
- DISBURSEMENT_REVIEWS = 'DISBURSEMENT_REVIEWS',
57
- TRADE_LINE_ITEMS = 'TRADE_LINE_ITEMS',
58
- TRANSACTIONS = 'TRANSACTIONS',
59
- AICS = 'AICS',
60
- SITES = 'SITES',
61
- THEMES = 'THEMES',
62
- THEME_SETTINGS = 'THEME_SETTINGS',
63
- }
64
-
65
- export const ResourceMap: { [key: string]: ActivityTypeResource } = {
66
- trades: ActivityTypeResource.TRADES,
67
- 'trade-line-items': ActivityTypeResource.TRADE_LINE_ITEMS,
68
- transactions: ActivityTypeResource.TRANSACTIONS,
69
- users: ActivityTypeResource.USERS,
70
- offerings: ActivityTypeResource.OFFERINGS,
71
- 'investor-accounts': ActivityTypeResource.INVESTOR_ACCOUNTS,
72
- individuals: ActivityTypeResource.INDIVIDUALS,
73
- 'payment-methods': ActivityTypeResource.PAYMENT_METHODS,
74
- notes: ActivityTypeResource.NOTES,
75
- issuers: ActivityTypeResource.ISSUERS,
76
- 'covered-persons': ActivityTypeResource.COVERED_PERSONS,
77
- kyc: ActivityTypeResource.KYCS,
78
- aml: ActivityTypeResource.AMLS,
79
- aic: ActivityTypeResource.AICS,
80
- kyb: ActivityTypeResource.KYBS,
81
- 'legal-entities': ActivityTypeResource.LEGAL_ENTITIES,
82
- accounts: ActivityTypeResource.ACCOUNTS,
83
- files: ActivityTypeResource.FILES,
84
- 'files-public': ActivityTypeResource.FILES,
85
- pages: ActivityTypeResource.PAGES,
86
- disbursements: ActivityTypeResource.DISBURSEMENTS,
87
- 'disbursement-reviews': ActivityTypeResource.DISBURSEMENT_REVIEWS,
88
- sites: ActivityTypeResource.SITES,
89
- themes: ActivityTypeResource.THEMES,
90
- 'theme-settings': ActivityTypeResource.THEME_SETTINGS,
91
- };
92
-
93
- /**
94
- * WARNING!!!
95
- * ANY CHANGES TO:
96
- * - ActivityTypeAction
97
- * Will require a migration to add the new combinations to the database. See activity-type.entity.ts
98
- * Also, previous migrations will have to be updated to prevent the new combination from being seeded before the new migration introduces it.
99
- * see:
100
- * SeedActivityActionTable1733789494520
101
- * SeedActivityResourceTableFiles1735884938590
102
- * SeedAmlPagesInActivityTypes1740995815856
103
- * SeedActivityResourceTypeDisbursement1742689286845
104
- * SeedActivityResourceTradeLineItem1746449328700
105
- * SeedActivityReset2faAction1746791323564
106
- * SeedActivityResourceUserCombinations1747289941817
107
- * AddedResubmitActivityType1747999619404
108
- * AddedDeclinedAndSignedActivityAction1748011929459
109
- * SeedActivityResourceTypeDisbursementReview1753945998383
110
- * SeedActivityResourceTypeTransaction1754457409040
111
- * AddedAicTargetTable1756265520122
112
- * AddedReporcessActivityTypeAction1758023244400
113
- * AddedActivityActionSave1761715000038
114
- * AddedAcceptedActivityAction1762848949484
115
- */
116
- export enum ActivityTypeAction {
117
- CREATE = BaseAction.CREATE,
118
- UPDATE = BaseAction.UPDATE,
119
- DELETE = BaseAction.DELETE,
120
- IMPORT = BaseAction.IMPORT,
121
- APPROVED = BaseStatus.APPROVED,
122
- REJECTED = BaseStatus.REJECTED,
123
- SUBMITTED = BaseStatus.SUBMITTED,
124
- DECLINED = BaseStatus.DECLINED,
125
- SIGNED = BaseStatus.SIGNED,
126
- COMPLETED = BaseStatus.COMPLETED,
127
- RE_SIGN = BaseStatus.RE_SIGN,
128
- RESUBMIT = BaseStatus.RESUBMIT,
129
- RESET_2FA = BaseStatus.RESET_2FA,
130
- LOGIN = BaseStatus.LOGIN,
131
- RESET_PASSWORD = BaseStatus.RESET_PASSWORD,
132
- TWO_FACTOR_LOGIN = BaseStatus.TWO_FACTOR_LOGIN,
133
- FORGOT_PASSWORD = BaseStatus.FORGOT_PASSWORD,
134
- RE_PROCESS = BaseStatus.RE_PROCESS,
135
- SAVE = BaseStatus.SAVE,
136
- ACCEPTED = BaseStatus.ACCEPTED,
137
- JOIN = BaseStatus.JOIN,
138
- RESTORE = BaseStatus.RESTORE,
139
- }
140
-
141
- export const MethodMap: { [key: string]: ActivityTypeAction } = {
142
- POST: ActivityTypeAction.CREATE,
143
- PUT: ActivityTypeAction.UPDATE,
144
- PATCH: ActivityTypeAction.UPDATE,
145
- DELETE: ActivityTypeAction.DELETE,
146
- };
147
-
148
- export const activityIdSchema = z.string().refine(
149
- (value) => {
150
- try {
151
- const tid = TypeID.fromString(value);
152
- return tid.getType() === 'activity';
153
- } catch {
154
- return false;
155
- }
156
- },
157
- {
158
- message:
159
- 'Invalid activity ID format. Must be a valid TypeID with "activity" prefix. Example: activity_01j5y5ghx8fvc83dmx3pznq7hv',
160
- },
161
- );
162
-
163
- export const UserLoginForActivityZod = z.object({
164
- id: z.string().openapi({
165
- example: 'user_login_01jepymte1feb8a4j46gy6850k',
166
- }),
167
- firstName: z.string().openapi({
168
- example: 'Daniel',
169
- }),
170
- lastName: z.string().openapi({
171
- example: 'Ice',
172
- }),
173
- email: z.string().email().openapi({
174
- example: 'dice@dalmoregroup.com',
175
- }),
176
- __entity: z.string().optional(),
177
- });
178
-
179
- const UserForActivityZod = z.object({
180
- id: z.string(),
181
- roleId: z.string().nullable(),
182
- accountId: z.string().nullable(),
183
- userLogin: UserLoginForActivityZod,
184
- __entity: z.string().optional(),
185
- });
186
-
187
- const ActivityTypeZod = IBaseEntity.extend({
188
- category: z.nativeEnum(ActivityTypeCategory),
189
- resource: z.enum(TargetTableEnum),
190
- action: z.nativeEnum(ActivityTypeAction),
191
- __entity: z.string().optional(),
192
- });
193
-
194
- export const ActivityZod = IBaseEntity.extend({
195
- id: activityIdSchema,
196
- message: z.string(),
197
- targetTable: z.enum(TargetTableEnum),
198
- targetId: z.string(),
199
- userId: z.string().nullable(),
200
- activityTypeId: z.string(),
201
- accountId: z.string().nullable(),
202
- user: UserForActivityZod,
203
- activityType: ActivityTypeZod,
204
- targetObject: z.string().nullable().optional(),
205
- __entity: z.string().optional(),
206
- });
207
- export type ActivityZod = z.infer<typeof ActivityZod>;
208
-
209
- export const IPaginatedActivity = z.object({
210
- items: z.array(ActivityZod),
211
- meta: IPaginationMeta,
212
- });
213
- export type IPaginatedActivity = z.infer<typeof IPaginatedActivity>;
214
-
215
- export const ActivitiesFilters = z.object({
216
- targetTable: z.enum(TargetTableEnum).optional(),
217
- targetId: z
218
- .string()
219
- .optional()
220
- .openapi({
221
- example: 'disbursement_01j6aqmtfyfwy9spjdcnh7yqk7',
222
- })
223
- .refine(
224
- (value) => {
225
- try {
226
- if (!value) return true;
227
- const tid = TypeID.fromString(value);
228
- return Object.values(TargetTableConfig).some(
229
- (config) => config.idPrefix === tid.getType(),
230
- );
231
- } catch {
232
- return false;
233
- }
234
- },
235
- {
236
- message: `Invalid target ID format. Must match the corresponding table's ID prefix. Valid prefix: ${TargetTableEnum.toString().toLowerCase()}. Example: disbursement_01j6aqmtfyfwy9spjdcnh7yqk7`,
237
- },
238
- ),
239
- search: z.string().max(50).optional(),
240
- targetIds: z
241
- .string()
242
- .optional()
243
- .openapi({
244
- example:
245
- 'disbursement_01j6aqmtfyfwy9spjdcnh7yqk7,disbursement_01j6aqmtfyfwy9spjdcnh7yqk8',
246
- })
247
- .transform((str) => {
248
- if (!str) return [];
249
- // Split by comma, trim whitespace, and remove duplicates using Set
250
- const ids = str.split(',').map((id) => id.trim());
251
- return Array.from(new Set(ids));
252
- })
253
- .refine(
254
- (value) => {
255
- if (!value || value.length === 0) return true;
256
-
257
- // Validate each ID
258
- return value.every((id) => {
259
- try {
260
- const tid = TypeID.fromString(id);
261
- return Object.values(TargetTableConfig).some(
262
- (config) => config.idPrefix === tid.getType(),
263
- );
264
- } catch {
265
- return false;
266
- }
267
- });
268
- },
269
- {
270
- message: `Invalid target IDs. All IDs must match the corresponding table's ID prefix. Valid prefix: ${TargetTableEnum.toString().toLowerCase()}. Example: disbursement_01j6aqmtfyfwy9spjdcnh7yqk7`,
271
- },
272
- ),
273
- });
274
- export type ActivitiesFilters = z.infer<typeof ActivitiesFilters>;