@dalmore/api-contracts 1.0.3 → 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.
- package/README.md +34 -60
- package/index.mjs +1001 -18638
- package/package.json +5 -53
- package/src/common/types/address.spec.ts +203 -0
- package/src/common/types/batch-jobs.types.ts +1 -0
- package/src/common/types/common.types.spec.ts +336 -0
- package/src/common/types/files.types.spec.ts +154 -0
- package/src/common/types/issuer-payment-method.types.spec.ts +612 -0
- package/src/common/types/offering.types.spec.ts +91 -0
- package/src/common/types/phone.spec.ts +76 -0
- package/src/common/types/queue.types.ts +1 -0
- package/src/common/types/reminder-config.types.ts +40 -0
- package/src/common/types/site-link.types.spec.ts +134 -0
- package/src/common/types/trade.types.ts +2 -4
- package/clients/index.mjs +0 -10970
- package/compliance/index.mjs +0 -20016
- package/compliance-apikey/index.mjs +0 -9795
- package/helpers/index.mjs +0 -146
- package/investors/index.mjs +0 -12844
- package/issuers/index.mjs +0 -16168
- package/secondaries/index.mjs +0 -10282
- package/src/common/helpers/index.ts +0 -205
- package/src/contracts/compliance/account-contacts/index.ts +0 -82
- package/src/contracts/compliance/account-managers/index.ts +0 -142
- package/src/contracts/compliance/accounts/index.ts +0 -187
- package/src/contracts/compliance/activities/index.ts +0 -55
- package/src/contracts/compliance/aic/index.ts +0 -60
- package/src/contracts/compliance/api-keys/index.ts +0 -91
- package/src/contracts/compliance/assets/index.ts +0 -122
- package/src/contracts/compliance/auth/index.ts +0 -134
- package/src/contracts/compliance/batch-jobs/index.ts +0 -62
- package/src/contracts/compliance/bonus-tiers/index.ts +0 -55
- package/src/contracts/compliance/checklist/index.ts +0 -87
- package/src/contracts/compliance/checklist-items/index.ts +0 -86
- package/src/contracts/compliance/covered-persons/index.ts +0 -97
- package/src/contracts/compliance/dashboard/index.ts +0 -111
- package/src/contracts/compliance/data-records/index.ts +0 -116
- package/src/contracts/compliance/data-rooms/index.ts +0 -113
- package/src/contracts/compliance/default-theme-configs/index.ts +0 -95
- package/src/contracts/compliance/disbursement/index.ts +0 -165
- package/src/contracts/compliance/disbursement-approval-users/index.ts +0 -84
- package/src/contracts/compliance/disbursement-transactions/index.ts +0 -37
- package/src/contracts/compliance/domain-filters/index.ts +0 -117
- package/src/contracts/compliance/email-themes/index.ts +0 -284
- package/src/contracts/compliance/escrow-accounts/index.ts +0 -85
- package/src/contracts/compliance/exchange-api-keys/index.ts +0 -129
- package/src/contracts/compliance/exchange-imports/index.ts +0 -137
- package/src/contracts/compliance/files/index.ts +0 -267
- package/src/contracts/compliance/files-public/index.ts +0 -188
- package/src/contracts/compliance/health/index.ts +0 -26
- package/src/contracts/compliance/index.ts +0 -147
- package/src/contracts/compliance/individuals/index.ts +0 -57
- package/src/contracts/compliance/investor-accounts/index.ts +0 -141
- package/src/contracts/compliance/invites/index.ts +0 -137
- package/src/contracts/compliance/issuer-bank-accounts/index.ts +0 -81
- package/src/contracts/compliance/issuer-payment-methods/index.ts +0 -81
- package/src/contracts/compliance/issuers/index.ts +0 -97
- package/src/contracts/compliance/job-items/index.ts +0 -58
- package/src/contracts/compliance/jobs/index.ts +0 -59
- package/src/contracts/compliance/kyb/index.ts +0 -54
- package/src/contracts/compliance/kyc/index.ts +0 -77
- package/src/contracts/compliance/legal-entities/index.ts +0 -57
- package/src/contracts/compliance/login-histories/index.ts +0 -37
- package/src/contracts/compliance/notes/index.ts +0 -69
- package/src/contracts/compliance/notion-databases/index.ts +0 -107
- package/src/contracts/compliance/notion-pages/index.ts +0 -105
- package/src/contracts/compliance/offering-reports/index.ts +0 -149
- package/src/contracts/compliance/offerings/index.ts +0 -233
- package/src/contracts/compliance/pages/index.ts +0 -178
- package/src/contracts/compliance/payment-methods/index.ts +0 -57
- package/src/contracts/compliance/rejection-reasons/index.ts +0 -32
- package/src/contracts/compliance/review/index.ts +0 -169
- package/src/contracts/compliance/roles/index.ts +0 -34
- package/src/contracts/compliance/secondary-customers/index.ts +0 -77
- package/src/contracts/compliance/secondary-orders/index.ts +0 -60
- package/src/contracts/compliance/secondary-trades/index.ts +0 -100
- package/src/contracts/compliance/secure-requests/index.ts +0 -54
- package/src/contracts/compliance/signer/index.ts +0 -369
- package/src/contracts/compliance/site-links/index.ts +0 -128
- package/src/contracts/compliance/site-settings/index.ts +0 -669
- package/src/contracts/compliance/sites/index.ts +0 -56
- package/src/contracts/compliance/state-machine/index.ts +0 -94
- package/src/contracts/compliance/tasks/index.ts +0 -91
- package/src/contracts/compliance/third-parties/index.ts +0 -52
- package/src/contracts/compliance/trade-line-items/index.ts +0 -59
- package/src/contracts/compliance/trades/index.ts +0 -230
- package/src/contracts/compliance/transactions/index.ts +0 -161
- package/src/contracts/compliance/user-manuals/index.ts +0 -271
- package/src/contracts/compliance/user-settings/index.ts +0 -189
- package/src/contracts/compliance/users/index.ts +0 -200
- package/src/contracts/compliance/webhooks/index.ts +0 -41
- package/src/contracts/compliance-apikey/accounts/index.ts +0 -58
- package/src/contracts/compliance-apikey/index.ts +0 -14
- package/src/contracts/index.ts +0 -6
- package/src/contracts/investors/account-contacts/index.ts +0 -58
- package/src/contracts/investors/aic/index.ts +0 -59
- package/src/contracts/investors/assets/index.ts +0 -61
- package/src/contracts/investors/auth/index.ts +0 -116
- package/src/contracts/investors/bonus-tiers/index.ts +0 -37
- package/src/contracts/investors/cart/index.ts +0 -75
- package/src/contracts/investors/contact-us/index.ts +0 -48
- package/src/contracts/investors/data-records/index.ts +0 -113
- package/src/contracts/investors/data-rooms/index.ts +0 -96
- package/src/contracts/investors/files/index.ts +0 -167
- package/src/contracts/investors/files-public/index.ts +0 -185
- package/src/contracts/investors/index.ts +0 -72
- package/src/contracts/investors/individuals/index.ts +0 -99
- package/src/contracts/investors/investor-accounts/index.ts +0 -110
- package/src/contracts/investors/issuer-payment-methods/index.ts +0 -36
- package/src/contracts/investors/issuers/index.ts +0 -30
- package/src/contracts/investors/legal-entities/index.ts +0 -93
- package/src/contracts/investors/notes/index.ts +0 -69
- package/src/contracts/investors/offerings/index.ts +0 -93
- package/src/contracts/investors/pages/index.ts +0 -88
- package/src/contracts/investors/payment-methods/index.ts +0 -149
- package/src/contracts/investors/portfolios/index.ts +0 -53
- package/src/contracts/investors/sites/index.ts +0 -96
- package/src/contracts/investors/tasks/index.ts +0 -111
- package/src/contracts/investors/trade-line-items/index.ts +0 -75
- package/src/contracts/investors/trades/index.ts +0 -114
- package/src/contracts/investors/transactions/index.ts +0 -37
- package/src/contracts/investors/trusted-contacts/index.ts +0 -93
- package/src/contracts/investors/user-manuals/index.ts +0 -62
- package/src/contracts/investors/user-settings/index.ts +0 -170
- package/src/contracts/investors/users/index.ts +0 -45
- package/src/contracts/investors/webhooks/index.ts +0 -30
- package/src/contracts/issuers/account-contacts/index.ts +0 -76
- package/src/contracts/issuers/account-integrations/index.ts +0 -97
- package/src/contracts/issuers/accounts/index.ts +0 -97
- package/src/contracts/issuers/activities/index.ts +0 -54
- package/src/contracts/issuers/aic/index.ts +0 -39
- package/src/contracts/issuers/api-key-logs/index.ts +0 -53
- package/src/contracts/issuers/api-keys/index.ts +0 -93
- package/src/contracts/issuers/assets/index.ts +0 -122
- package/src/contracts/issuers/auth/index.ts +0 -152
- package/src/contracts/issuers/bonus-tiers/index.ts +0 -55
- package/src/contracts/issuers/contact-us/index.ts +0 -48
- package/src/contracts/issuers/covered-persons/index.ts +0 -136
- package/src/contracts/issuers/dashboard/index.ts +0 -72
- package/src/contracts/issuers/data-records/index.ts +0 -257
- package/src/contracts/issuers/data-rooms/index.ts +0 -134
- package/src/contracts/issuers/disbursement-approval-users/index.ts +0 -82
- package/src/contracts/issuers/disbursement-transactions/index.ts +0 -53
- package/src/contracts/issuers/disbursements/index.ts +0 -153
- package/src/contracts/issuers/email-themes/index.ts +0 -242
- package/src/contracts/issuers/escrow-accounts/index.ts +0 -81
- package/src/contracts/issuers/exchange-api-keys/index.ts +0 -144
- package/src/contracts/issuers/files/index.ts +0 -166
- package/src/contracts/issuers/files-public/index.ts +0 -166
- package/src/contracts/issuers/health/index.ts +0 -24
- package/src/contracts/issuers/index.ts +0 -112
- package/src/contracts/issuers/investor-accounts/index.ts +0 -148
- package/src/contracts/issuers/invites/index.ts +0 -129
- package/src/contracts/issuers/issuer/index.ts +0 -94
- package/src/contracts/issuers/issuer-bank-accounts/index.ts +0 -81
- package/src/contracts/issuers/issuer-payment-methods/index.ts +0 -136
- package/src/contracts/issuers/kyc/index.ts +0 -38
- package/src/contracts/issuers/login-histories/index.ts +0 -51
- package/src/contracts/issuers/notes/index.ts +0 -69
- package/src/contracts/issuers/offerings/index.ts +0 -206
- package/src/contracts/issuers/pages/index.ts +0 -138
- package/src/contracts/issuers/payment-methods/index.ts +0 -61
- package/src/contracts/issuers/portfolios/index.ts +0 -36
- package/src/contracts/issuers/rejection-reasons/index.ts +0 -32
- package/src/contracts/issuers/review/index.ts +0 -63
- package/src/contracts/issuers/secondary-customers/index.ts +0 -55
- package/src/contracts/issuers/secondary-orders/index.ts +0 -57
- package/src/contracts/issuers/secondary-trades/index.ts +0 -57
- package/src/contracts/issuers/secure-requests/index.ts +0 -34
- package/src/contracts/issuers/site-links/index.ts +0 -116
- package/src/contracts/issuers/site-settings/index.ts +0 -585
- package/src/contracts/issuers/sites/index.ts +0 -32
- package/src/contracts/issuers/tasks/index.ts +0 -111
- package/src/contracts/issuers/trades/index.ts +0 -132
- package/src/contracts/issuers/transactions/index.ts +0 -158
- package/src/contracts/issuers/user-manuals/index.ts +0 -62
- package/src/contracts/issuers/user-settings/index.ts +0 -170
- package/src/contracts/issuers/users/index.ts +0 -126
- package/src/contracts/secondaries/accounts/index.ts +0 -58
- package/src/contracts/secondaries/index.ts +0 -23
- package/src/contracts/secondaries/secondary-customers/index.ts +0 -55
- package/src/contracts/secondaries/secondary-issuers/index.ts +0 -94
- package/src/contracts/secondaries/secondary-orders/index.ts +0 -56
- package/src/contracts/secondaries/secondary-securities/index.ts +0 -95
- package/src/contracts/secondaries/secondary-trades/index.ts +0 -56
- package/types/index.mjs +0 -10320
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { typeid } from 'typeid-js';
|
|
2
|
+
import {
|
|
3
|
+
FileZod,
|
|
4
|
+
allowedFileExtension,
|
|
5
|
+
fileIdSchema,
|
|
6
|
+
PostFileQueryParams,
|
|
7
|
+
FileFilters,
|
|
8
|
+
ADFFileProcessingPipeline,
|
|
9
|
+
} from './file.types';
|
|
10
|
+
import { FileLabels, FileStatus } from './common.types';
|
|
11
|
+
|
|
12
|
+
describe('File Validation', () => {
|
|
13
|
+
describe('fileIdSchema', () => {
|
|
14
|
+
it('should validate correct file IDs', () => {
|
|
15
|
+
const validFileId = typeid('file').toString();
|
|
16
|
+
const result = fileIdSchema.safeParse(validFileId);
|
|
17
|
+
expect(result.success).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should reject invalid file IDs', () => {
|
|
21
|
+
const invalidFileIds = [
|
|
22
|
+
'user_01j5y5ghx8fvc83dmx3pznq7hv',
|
|
23
|
+
'file_invalid',
|
|
24
|
+
'',
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
invalidFileIds.forEach((id) => {
|
|
28
|
+
const result = fileIdSchema.safeParse(id);
|
|
29
|
+
expect(result.success).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('FileZod', () => {
|
|
35
|
+
it('should validate a correct file object', () => {
|
|
36
|
+
const validFile = {
|
|
37
|
+
id: typeid('file').toString(),
|
|
38
|
+
tid: 'some-tid',
|
|
39
|
+
url: 'https://example.com/file.pdf',
|
|
40
|
+
fileType: 'pdf',
|
|
41
|
+
fileName: 'test.pdf',
|
|
42
|
+
name: 'test',
|
|
43
|
+
category: 'application',
|
|
44
|
+
label: FileLabels.OTHER,
|
|
45
|
+
metadata: null,
|
|
46
|
+
private: false,
|
|
47
|
+
complianceReview: 'PENDING',
|
|
48
|
+
targetTable: 'TRADES',
|
|
49
|
+
targetId: null,
|
|
50
|
+
linkedFrom: null,
|
|
51
|
+
accountId: typeid('account').toString(),
|
|
52
|
+
userId: typeid('user').toString(),
|
|
53
|
+
status: FileStatus.PENDING,
|
|
54
|
+
pipeline: ADFFileProcessingPipeline.NONE,
|
|
55
|
+
errorMessage: null,
|
|
56
|
+
reviewLog: null,
|
|
57
|
+
createdAt: new Date(),
|
|
58
|
+
updatedAt: new Date(),
|
|
59
|
+
deletedAt: null,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const result = FileZod.safeParse(validFile);
|
|
63
|
+
expect(result.success).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should reject invalid file objects', () => {
|
|
67
|
+
const invalidFile = {
|
|
68
|
+
id: 'invalid_id',
|
|
69
|
+
url: 'not-a-url',
|
|
70
|
+
// missing required fields
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const result = FileZod.safeParse(invalidFile);
|
|
74
|
+
expect(result.success).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('PostFileQueryParams', () => {
|
|
79
|
+
it('should validate correct query parameters', () => {
|
|
80
|
+
const validQuery = {
|
|
81
|
+
name: 'test_file',
|
|
82
|
+
category: 'application',
|
|
83
|
+
label: FileLabels.OTHER,
|
|
84
|
+
targetId: typeid('trade').toString(),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const result = PostFileQueryParams.safeParse(validQuery);
|
|
88
|
+
expect(result.success).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should reject invalid target IDs', () => {
|
|
92
|
+
const invalidQuery = {
|
|
93
|
+
name: 'test_file',
|
|
94
|
+
category: 'application',
|
|
95
|
+
label: FileLabels.OTHER,
|
|
96
|
+
targetId: 'invalid_id',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const result = PostFileQueryParams.safeParse(invalidQuery);
|
|
100
|
+
expect(result.success).toBe(false);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('FileFilters', () => {
|
|
105
|
+
it('should handle optional includeLinkedFrom parameter', () => {
|
|
106
|
+
const validFilters = [
|
|
107
|
+
{ includeLinkedFrom: 'true' },
|
|
108
|
+
{ includeLinkedFrom: 'false' },
|
|
109
|
+
{ includeLinkedFrom: undefined },
|
|
110
|
+
{},
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
validFilters.forEach((filter) => {
|
|
114
|
+
const result = FileFilters.safeParse(filter);
|
|
115
|
+
expect(result.success).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should reject invalid includeLinkedFrom values', () => {
|
|
120
|
+
const invalidFilters = [
|
|
121
|
+
{ includeLinkedFrom: 'yes' },
|
|
122
|
+
{ includeLinkedFrom: '1' },
|
|
123
|
+
{ includeLinkedFrom: 'TRUE' },
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
invalidFilters.forEach((filter) => {
|
|
127
|
+
const result = FileFilters.safeParse(filter);
|
|
128
|
+
expect(result.success).toBe(false);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('allowedFileExtension', () => {
|
|
134
|
+
it('should contain all supported extensions', () => {
|
|
135
|
+
const expectedExtensions = [
|
|
136
|
+
'.pdf',
|
|
137
|
+
'.doc',
|
|
138
|
+
'.docx',
|
|
139
|
+
'.xls',
|
|
140
|
+
'.xlsx',
|
|
141
|
+
'.csv',
|
|
142
|
+
'.gif',
|
|
143
|
+
'.png',
|
|
144
|
+
'.jpg',
|
|
145
|
+
'.jpeg',
|
|
146
|
+
'.txt',
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
expectedExtensions.forEach((ext) => {
|
|
150
|
+
expect(allowedFileExtension).toContain(ext);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|