@getjones/test-infra 4.4.11 → 4.4.13
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/package.json +1 -1
- package/src/common/commonFlows/records/records.js +14 -0
- package/src/common/consts/autocomplete.js +2 -1
- package/src/common/consts/userRoles.js +6 -0
- package/src/factory/records/records.js +12 -12
- package/src/factory/users/users.js +22 -13
- package/src/index.js +3 -1
- package/src/saas/internal-api/compliance/consts/audit.js +2 -1
- package/src/saas/internal-api/contractors/api/contractors.service.js +7 -1
- package/src/saas/internal-api/policyFile/api/policy.file.api.js +25 -0
- package/src/saas/internal-api/policyFile/api/policy.file.service.js +39 -0
- package/src/saas/internal-api/policyFile/consts.js +21 -0
- package/src/saas/internal-api/policyFile/index.js +11 -0
- package/src/saas/internal-api/projects/api/core/projects.service.js +8 -1
- package/src/saas/internal-api/requests/api/requests.api.js +1 -1
- package/src/saas/internal-api/requests/api/requests.service.js +6 -4
- package/src/saas/internal-api/requests/models/create.request.model.js +3 -1
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +0 -6
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +2 -13
- package/src/saas/internal-api/uploadFiles/consts.js +1 -20
- package/src/saas/internal-api/uploadFiles/index.js +1 -7
- package/src/saas/internal-api/users/api/users.api.js +2 -2
- package/src/saas/internal-api/users/api/users.service.js +24 -6
- package/src/saas/internal-api/users/models/users.model.js +2 -1
- /package/src/saas/internal-api/{uploadFiles → policyFile}/models/create.policy.file.model.js +0 -0
package/package.json
CHANGED
|
@@ -24,6 +24,19 @@ const makeRecordNotResponsive = async function(recordId, context) {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
const resendInvitationByRecordId = async (recordId, tabId, context) => {
|
|
28
|
+
const { id: requestId } = await requests.services.getRequestFromTabByRecordId(recordId, tabId, context);
|
|
29
|
+
const recordModifyDateVerificationModel = await contractors.services.getRecordVerificationModel(recordId, context);
|
|
30
|
+
|
|
31
|
+
const resendInvitationResponse = await contractors.services.resendInvitation(requestId, recordModifyDateVerificationModel, context);
|
|
32
|
+
|
|
33
|
+
if (resendInvitationResponse.status !== httpResponseStatusCodes.OK) {
|
|
34
|
+
throw new Error(`Failed to resend invitation for record: ${resendInvitationResponse.statusText}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return resendInvitationResponse;
|
|
38
|
+
};
|
|
39
|
+
|
|
27
40
|
const editRequestAndRecordDetails = async function(request, recordConfig, context) {
|
|
28
41
|
const tabModel = new requests.models.TabModel(request.tab.type);
|
|
29
42
|
const recordDetailsModel = contractors.services.getContractorDetailsModel(recordConfig);
|
|
@@ -209,6 +222,7 @@ const waiveAllGaps = async (recordId, context) => {
|
|
|
209
222
|
|
|
210
223
|
module.exports = {
|
|
211
224
|
makeRecordNotResponsive,
|
|
225
|
+
resendInvitationByRecordId,
|
|
212
226
|
runOverAllRenewalDatesForRecord,
|
|
213
227
|
editRequestAndRecordDetails,
|
|
214
228
|
updateInviteDate,
|
|
@@ -85,8 +85,8 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
85
85
|
return recordId;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
const prepareCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
89
|
-
return prepareRecord(recordCompany, recordEmail, complianceStatuses.compliant, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber });
|
|
88
|
+
const prepareCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
89
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.compliant, tabId, requirementId, context, { inviterEmail, recordConfig, expiryStatus, glPolicyNumber });
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
const prepareNotCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, shouldSendNotificationToPM = false, recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
@@ -99,14 +99,14 @@ const prepareWaivedRecord = async (recordCompany, recordEmail, tabId, requiremen
|
|
|
99
99
|
return recordId;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const prepareAcceptedRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
103
|
-
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber });
|
|
102
|
+
const prepareAcceptedRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig, expiryStatus, glPolicyNumber } = {}) => {
|
|
103
|
+
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context, { inviterEmail, recordConfig, expiryStatus, glPolicyNumber });
|
|
104
104
|
await acceptAllGaps(recordId, context);
|
|
105
105
|
return recordId;
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
const prepareAwaitingNewCoiRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig, expiryStatus, isNotResponsive = false, glPolicyNumber } = {}) => {
|
|
109
|
-
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.awaitingNewCoi, tabId, requirementId, context, { recordConfig, expiryStatus, glPolicyNumber });
|
|
108
|
+
const prepareAwaitingNewCoiRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig, expiryStatus, isNotResponsive = false, glPolicyNumber } = {}) => {
|
|
109
|
+
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.awaitingNewCoi, tabId, requirementId, context, { inviterEmail, recordConfig, expiryStatus, glPolicyNumber });
|
|
110
110
|
|
|
111
111
|
await sendGaps(recordId, tabId, context);
|
|
112
112
|
|
|
@@ -117,8 +117,8 @@ const prepareAwaitingNewCoiRecord = async (recordCompany, recordEmail, tabId, re
|
|
|
117
117
|
return recordId;
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
const prepareAwaitingCoiRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig, isNotResponsive = false } = {}) => {
|
|
121
|
-
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.awaitingCoi, tabId, requirementId, context, { recordConfig });
|
|
120
|
+
const prepareAwaitingCoiRecord = async (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig, isNotResponsive = false } = {}) => {
|
|
121
|
+
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.awaitingCoi, tabId, requirementId, context, { inviterEmail, recordConfig });
|
|
122
122
|
|
|
123
123
|
if (isNotResponsive) {
|
|
124
124
|
await recordFlows.makeRecordNotResponsive(recordId, context);
|
|
@@ -127,12 +127,12 @@ const prepareAwaitingCoiRecord = async (recordCompany, recordEmail, tabId, requi
|
|
|
127
127
|
return recordId;
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
const prepareNoCoiRequireRecord = async (recordCompany, recordEmail, tabId, context, { recordConfig } = {}) => {
|
|
131
|
-
return prepareRecord(recordCompany, recordEmail, complianceStatuses.noCoiRequire, tabId, null, context, { recordConfig });
|
|
130
|
+
const prepareNoCoiRequireRecord = async (recordCompany, recordEmail, tabId, context, { inviterEmail, recordConfig } = {}) => {
|
|
131
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.noCoiRequire, tabId, null, context, { inviterEmail, recordConfig });
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirementId, context, { recordConfig } = {}) => {
|
|
135
|
-
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context, { recordConfig });
|
|
134
|
+
const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirementId, context, { inviterEmail, recordConfig } = {}) => {
|
|
135
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context, { inviterEmail, recordConfig });
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
const sendGaps = async (recordId, tabId, context) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { getEnv } = require('../../env');
|
|
2
|
+
const auth = require('../../saas/internal-api/auth/api/auth.service');
|
|
2
3
|
const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
|
|
3
4
|
|
|
4
5
|
const { credentials } = getEnv();
|
|
@@ -13,14 +14,21 @@ const roles = {
|
|
|
13
14
|
cm: 'Compliance Manager'
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const inviteSaasUser = async (username, role, projectIds, context) => {
|
|
17
|
+
const inviteSaasUser = async (username, role, projectIds, context, { hasCompleteAccessPermission } = {}) => {
|
|
17
18
|
const userResponse = await users.services.getUserByEmail(username, context);
|
|
18
19
|
|
|
19
20
|
if (userResponse.data && userResponse.data.subuserId) {
|
|
20
|
-
|
|
21
|
+
const { projectPermissions } = userResponse.data;
|
|
22
|
+
const projectPermissionsIds = projectPermissions.map(projectPermission => projectPermission.projectId);
|
|
23
|
+
|
|
24
|
+
projectIds = projectIds.filter(projectId => !projectPermissionsIds.includes(projectId));
|
|
25
|
+
|
|
26
|
+
if (!projectIds.length) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
const inviteUserModel = new InviteUserModel(username, role, projectIds,
|
|
31
|
+
const inviteUserModel = new InviteUserModel(username, role, projectIds, hasCompleteAccessPermission);
|
|
24
32
|
const inviteResponse = await users.services.inviteUser([inviteUserModel], context);
|
|
25
33
|
|
|
26
34
|
if (inviteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
@@ -44,12 +52,13 @@ const signupSaasUser = async (username, role, context) => {
|
|
|
44
52
|
}
|
|
45
53
|
};
|
|
46
54
|
|
|
47
|
-
const prepareUser = async (username, role, projectIds, context, { signup = true } = {}) => {
|
|
48
|
-
await inviteSaasUser(username, role, projectIds, context);
|
|
55
|
+
const prepareUser = async (username, role, projectIds, context, { signup = true, hasCompleteAccessPermission } = {}) => {
|
|
56
|
+
await inviteSaasUser(username, role, projectIds, context, { hasCompleteAccessPermission });
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
const icsContext = await auth.getIcsCookie();
|
|
59
|
+
signup && await signupSaasUser(username, role, icsContext); // Can not use other context than ics to use this function
|
|
51
60
|
|
|
52
|
-
const userResponse = await users.services.getUserByEmail(username,
|
|
61
|
+
const userResponse = await users.services.getUserByEmail(username, icsContext); // Can not use other context than ics to use this function
|
|
53
62
|
|
|
54
63
|
if (userResponse.status !== httpResponseStatusCodes.OK) {
|
|
55
64
|
throw new Error(`Failed to prepare ${role} user with email: ${username}\n${userResponse}`);
|
|
@@ -58,16 +67,16 @@ const prepareUser = async (username, role, projectIds, context, { signup = true
|
|
|
58
67
|
return userResponse.data;
|
|
59
68
|
};
|
|
60
69
|
|
|
61
|
-
const prepareComplianceManagerUser = (username, projectIds, context, { signup } = {}) => {
|
|
62
|
-
return prepareUser(username, roles.cm, projectIds, context, { signup });
|
|
70
|
+
const prepareComplianceManagerUser = (username, projectIds, context, { signup, hasCompleteAccessPermission } = {}) => {
|
|
71
|
+
return prepareUser(username, roles.cm, projectIds, context, { signup, hasCompleteAccessPermission });
|
|
63
72
|
};
|
|
64
73
|
|
|
65
|
-
const prepareInviterUser = (username, projectIds, context, { signup } = {}) => {
|
|
66
|
-
return prepareUser(username, roles.inviter, projectIds, context, { signup });
|
|
74
|
+
const prepareInviterUser = (username, projectIds, context, { signup, hasCompleteAccessPermission } = {}) => {
|
|
75
|
+
return prepareUser(username, roles.inviter, projectIds, context, { signup, hasCompleteAccessPermission });
|
|
67
76
|
};
|
|
68
77
|
|
|
69
|
-
const prepareReadOnlyUser = (username, projectIds, context, { signup } = {}) => {
|
|
70
|
-
return prepareUser(username, roles.readOnly, projectIds, context, { signup });
|
|
78
|
+
const prepareReadOnlyUser = (username, projectIds, context, { signup, hasCompleteAccessPermission } = {}) => {
|
|
79
|
+
return prepareUser(username, roles.readOnly, projectIds, context, { signup, hasCompleteAccessPermission });
|
|
71
80
|
};
|
|
72
81
|
|
|
73
82
|
module.exports = {
|
package/src/index.js
CHANGED
|
@@ -43,6 +43,7 @@ const getInternalAPI = () => {
|
|
|
43
43
|
const dbEmails = require('./saas/internal-api/dbEmails/index');
|
|
44
44
|
const agreement = require('./saas/internal-api/agreement/index');
|
|
45
45
|
const uploadFile = require('./saas/internal-api/uploadFiles/index');
|
|
46
|
+
const policyFile = require('./saas/internal-api/policyFile');
|
|
46
47
|
|
|
47
48
|
const emailCustomization = require('./saas/internal-api/emailCustomization');
|
|
48
49
|
|
|
@@ -74,7 +75,8 @@ const getInternalAPI = () => {
|
|
|
74
75
|
emailCustomization,
|
|
75
76
|
factory,
|
|
76
77
|
agreement,
|
|
77
|
-
uploadFile
|
|
78
|
+
uploadFile,
|
|
79
|
+
policyFile
|
|
78
80
|
};
|
|
79
81
|
|
|
80
82
|
return internalAPI;
|
|
@@ -308,6 +308,11 @@ const changeRequirementsDirectly = async (recordId, newRequirementId, context) =
|
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
+
const isRecordNotResponsive = async (recordId, context) => {
|
|
312
|
+
const record = await getContractorById(recordId, context);
|
|
313
|
+
return record.data.isNotResponsive;
|
|
314
|
+
};
|
|
315
|
+
|
|
311
316
|
module.exports = {
|
|
312
317
|
changeRequirement,
|
|
313
318
|
getContractorsByAccountId,
|
|
@@ -351,5 +356,6 @@ module.exports = {
|
|
|
351
356
|
getBasicDetailsById,
|
|
352
357
|
getRecordsFromInsuredName,
|
|
353
358
|
linkDraftRequestToAccountRecord,
|
|
354
|
-
changeRequirementsDirectly
|
|
359
|
+
changeRequirementsDirectly,
|
|
360
|
+
isRecordNotResponsive
|
|
355
361
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
getPolicyFilesForVendorReport: requestId => `${backendUrl}/saas/request/${requestId}/policy-files`,
|
|
6
|
+
getPreSignedUrlByPolicyId: policyFileId => `${backendUrl}/saas/policy-file/${policyFileId}`,
|
|
7
|
+
getAuditPolicyFilesByAuditId: (recordId, auditId) => `${backendUrl}/saas/integration-tests/record/${recordId}/audit/${auditId}/policy-files`
|
|
8
|
+
};
|
|
9
|
+
const getPolicyFilesForVendorReport = async (requestId, context) => {
|
|
10
|
+
return requests.getRequestHandler(Endpoints.getPolicyFilesForVendorReport(requestId), {}, context);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getPreSignedUrlByPolicyId = async (policyFileId, context) => {
|
|
14
|
+
return requests.getRequestHandler(Endpoints.getPreSignedUrlByPolicyId(policyFileId), {}, context);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getAuditPolicyFiles = async (recordId, auditId, context) => {
|
|
18
|
+
return requests.getRequestHandler(Endpoints.getAuditPolicyFilesByAuditId(recordId, auditId), {}, context);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
getPolicyFilesForVendorReport,
|
|
23
|
+
getPreSignedUrlByPolicyId,
|
|
24
|
+
getAuditPolicyFiles
|
|
25
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const policyFileApi = require('./policy.file.api');
|
|
2
|
+
|
|
3
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
4
|
+
|
|
5
|
+
const getPolicyFilesForVendorReport = async (requestId, context, { shouldExpectError } = {}) => {
|
|
6
|
+
const getPolicyResponse = await policyFileApi.getPolicyFilesForVendorReport(requestId, context);
|
|
7
|
+
|
|
8
|
+
if (getPolicyResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
9
|
+
throw new Error('Failed to get policy files for PM');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return getPolicyResponse;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getPreSignedUrlByPolicyId = async (policyFileId, context, { shouldExpectError } = {}) => {
|
|
16
|
+
const getPolicyLinkResponse = await policyFileApi.getPreSignedUrlByPolicyId(policyFileId, context);
|
|
17
|
+
|
|
18
|
+
if (getPolicyLinkResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
19
|
+
throw new Error('Failed to get policy view only link');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return getPolicyLinkResponse;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getAuditPolicyFiles = async (recordId, auditId, context) => {
|
|
26
|
+
const getAuditPolicyFilesResponse = await policyFileApi.getAuditPolicyFiles(recordId, auditId, context);
|
|
27
|
+
|
|
28
|
+
if (getAuditPolicyFilesResponse.status !== httpResponseStatusCodes.OK) {
|
|
29
|
+
throw new Error('Failed to get policy files by audit id');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return getAuditPolicyFilesResponse;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
getPolicyFilesForVendorReport,
|
|
37
|
+
getPreSignedUrlByPolicyId,
|
|
38
|
+
getAuditPolicyFiles
|
|
39
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const policyType = {
|
|
2
|
+
generalLiability: 'GENERAL_LIABILITY',
|
|
3
|
+
umbrella: 'UMBRELLA_EXCESS_LIABILITY',
|
|
4
|
+
workersCompensation: 'WORKERS_COMPENSATION',
|
|
5
|
+
automobileLiability: 'AUTOMOBILE_LIABILITY',
|
|
6
|
+
propertyInsurance: 'PROPERTY_INSURANCE',
|
|
7
|
+
professionalLiability: 'PROFESSIONAL_LIABILITY',
|
|
8
|
+
businessInterruptions: 'BUSINESS_INTERRUPTION_INCOME_INSURANCE',
|
|
9
|
+
environmentalLiability: 'POLLUTION_LIABILITY',
|
|
10
|
+
crimeLiability: 'CRIME_LIABILITY',
|
|
11
|
+
liquorLiability: 'LIQUOR_LIABILITY',
|
|
12
|
+
directorsAndOfficers: 'DIRECTORS_AND_OFFICERS_LIABILITY',
|
|
13
|
+
employmentPractice: 'EMPLOYMENT_PRACTICES_LIABILITY',
|
|
14
|
+
cyberLiability: 'CYBER_LIABILITY',
|
|
15
|
+
garageLiability: 'GARAGE_LIABILITY',
|
|
16
|
+
garageKeepers: 'GARAGE_KEEPERS_LIABILITY'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
policyType
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const services = require('./api/policy.file.service');
|
|
2
|
+
|
|
3
|
+
const { CreatePolicyFileModel } = require('../policyFile/models/create.policy.file.model');
|
|
4
|
+
|
|
5
|
+
const models = {
|
|
6
|
+
CreatePolicyFileModel
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const consts = require('./consts');
|
|
10
|
+
|
|
11
|
+
module.exports = { services, models, consts };
|
|
@@ -2,6 +2,7 @@ const projectsApi = require('./projects.api');
|
|
|
2
2
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
3
3
|
const CreateProjectModel = require('../../models/core/create.project.model');
|
|
4
4
|
const UpdateProjectModel = require('../../models/core/update.project.model');
|
|
5
|
+
const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
|
|
5
6
|
|
|
6
7
|
const getProjectsByAccountId = (accountId, context) => {
|
|
7
8
|
return projectsApi.getProjectsByAccountId(accountId, context);
|
|
@@ -33,7 +34,13 @@ const deleteProjectByName = async (accountId, projectName, context) => {
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const deleteProjectById = async (projectId, context) => {
|
|
36
|
-
|
|
37
|
+
const response = await projectsApi.deleteProjectById(projectId, context);
|
|
38
|
+
|
|
39
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
40
|
+
throw new Error(`Failed to delete project by id ${projectId}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return response;
|
|
37
44
|
};
|
|
38
45
|
|
|
39
46
|
const createProject = (createProjectModel, context) => {
|
|
@@ -17,7 +17,7 @@ const Endpoints = {
|
|
|
17
17
|
getAutocompleteAutoSelect: `${backendUrl}/saas/request/auto/selection`,
|
|
18
18
|
getTabTenantRequestsInProject: projectId => `${backendUrl}/saas/project/${projectId}/tenants/companies`,
|
|
19
19
|
innerPageRequests: `${backendUrl}/saas/requests/chart-filter`,
|
|
20
|
-
homePageRequests: `${backendUrl}/saas/requests/
|
|
20
|
+
homePageRequests: `${backendUrl}/saas/requests/homepage`,
|
|
21
21
|
draftFilterCounters: tabId => `${backendUrl}/saas/tab/${tabId}/requests/draft/filter/counter`,
|
|
22
22
|
activityStatusCounter: tabId => `${backendUrl}/saas/tab/${tabId}/requests/activity-status/count`,
|
|
23
23
|
requestsCounters: tabId => `${backendUrl}/saas/tab/${tabId}/requests/counters`
|
|
@@ -112,7 +112,7 @@ const getRequestsByAccountId = (accountId, context, activationStatus) => {
|
|
|
112
112
|
return requestsAPI.getRequestsByAccountId(accountId, context, params);
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
const getCreateRequestModel = (requirementId, contractor, { tabId, publicLink, requirementDateModified, isDraft } = {}) => {
|
|
115
|
+
const getCreateRequestModel = (requirementId, contractor, { tabId, publicLink, requirementDateModified, isDraft, existingCoiFileName, policyOwnerRecordId } = {}) => {
|
|
116
116
|
const { recordType, email, companyName, additionalEmails } = contractor;
|
|
117
117
|
const contractorInfoModel = new ContractorInfo(recordType, email, companyName, additionalEmails, isDraft);
|
|
118
118
|
|
|
@@ -123,12 +123,14 @@ const getCreateRequestModel = (requirementId, contractor, { tabId, publicLink, r
|
|
|
123
123
|
{
|
|
124
124
|
tabId,
|
|
125
125
|
publicLink,
|
|
126
|
-
requirementDateModified
|
|
126
|
+
requirementDateModified,
|
|
127
|
+
existingCoiFileName,
|
|
128
|
+
policyOwnerRecordId
|
|
127
129
|
}
|
|
128
130
|
);
|
|
129
131
|
};
|
|
130
132
|
|
|
131
|
-
const getOrCreateRequest = async (context, tabId, requirementId, contractor, activationStatus, { requirementDateModified } = {}) => {
|
|
133
|
+
const getOrCreateRequest = async (context, tabId, requirementId, contractor, activationStatus, { requirementDateModified, existingCoiFileName, policyOwnerRecordId } = {}) => {
|
|
132
134
|
const { data: existingRequests } = await getRequestsByTabId(tabId, context, activationStatus);
|
|
133
135
|
|
|
134
136
|
const filteredRequests = Array.isArray(existingRequests) ? existingRequests.filter(({ record }) =>
|
|
@@ -140,7 +142,7 @@ const getOrCreateRequest = async (context, tabId, requirementId, contractor, act
|
|
|
140
142
|
|
|
141
143
|
const isDraft = activationStatus === 'Draft' ? true : false;
|
|
142
144
|
|
|
143
|
-
const createContractorModel = getCreateRequestModel(requirementId, contractor, { tabId, requirementDateModified, isDraft });
|
|
145
|
+
const createContractorModel = getCreateRequestModel(requirementId, contractor, { tabId, requirementDateModified, isDraft, existingCoiFileName, policyOwnerRecordId });
|
|
144
146
|
const createContractorResponse = await createRequest(createContractorModel, context);
|
|
145
147
|
return createContractorResponse.data;
|
|
146
148
|
};
|
|
@@ -6,13 +6,15 @@ const { validateType, validateDateString } = require('../../../../common/validat
|
|
|
6
6
|
const superUserEmail = credentials.superUser;
|
|
7
7
|
|
|
8
8
|
class CreateRequestModel {
|
|
9
|
-
constructor(requirementId, inviterEmail, vendorInfo, { tabId = null, publicLink, requirementDateModified } = {}) {
|
|
9
|
+
constructor(requirementId, inviterEmail, vendorInfo, { tabId = null, publicLink, requirementDateModified, existingCoiFileName, policyOwnerRecordId } = {}) {
|
|
10
10
|
this.reqId = requirementId;
|
|
11
11
|
this.inviterEmail = inviterEmail || superUserEmail;
|
|
12
12
|
this.vendorInfo = vendorInfo;
|
|
13
13
|
this.tabId = tabId;
|
|
14
14
|
this.publicLink = publicLink;
|
|
15
15
|
this.dateModified = requirementDateModified;
|
|
16
|
+
this.existingCoiFileName = existingCoiFileName;
|
|
17
|
+
this.policyOwnerRecordId = policyOwnerRecordId;
|
|
16
18
|
|
|
17
19
|
vendorInfo && validateType(vendorInfo, ContractorInfo);
|
|
18
20
|
requirementDateModified && validateDateString(requirementDateModified);
|
|
@@ -4,7 +4,6 @@ const { backendUrl } = require('../../../../env').getEnv();
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
getRelatedDocPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/document`,
|
|
6
6
|
getCreatePolicyPreSignedUrl: `${backendUrl}/saas/pre-signed-url/upload/policy`,
|
|
7
|
-
getPolicyFilesForVendorReport: requestId => `${backendUrl}/saas/request/${requestId}/policy-files`,
|
|
8
7
|
createPolicyFiles: requestId => `${backendUrl}/saas/request/${requestId}/policy-files/create`,
|
|
9
8
|
uploadRelatedDoc: recordId => `${backendUrl}/saas/contractor/${recordId}/document`,
|
|
10
9
|
fileUpload: `${backendUrl}/file/finalize-upload`
|
|
@@ -18,10 +17,6 @@ const getCreatePolicyPreSignedUrl = (formData, context) => {
|
|
|
18
17
|
return requests.postRequestHandler(Endpoints.getCreatePolicyPreSignedUrl, formData, context, formData.getHeaders());
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
const getPolicyFilesForVendorReport = (requestId, context) => {
|
|
22
|
-
return requests.getRequestHandler(Endpoints.getPolicyFilesForVendorReport(requestId), {}, context);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
20
|
const createPolicyFiles = (requestId, policyFileList, context) => {
|
|
26
21
|
return requests.postRequestHandler(Endpoints.createPolicyFiles(requestId), policyFileList, context);
|
|
27
22
|
};
|
|
@@ -44,6 +39,5 @@ module.exports = {
|
|
|
44
39
|
uploadRelatedDoc,
|
|
45
40
|
uploadFileToS3,
|
|
46
41
|
uploadFile,
|
|
47
|
-
getPolicyFilesForVendorReport,
|
|
48
42
|
createPolicyFiles
|
|
49
43
|
};
|
|
@@ -4,7 +4,7 @@ const path = require('path');
|
|
|
4
4
|
const FormData = require('form-data');
|
|
5
5
|
const consts = require('../consts');
|
|
6
6
|
const { DOCUMENT, TEMP_DOCUMENTS, TEMP_POLICY } = require('../../../../common/consts/s3FileTypes');
|
|
7
|
-
const { CreatePolicyFileModel } = require('
|
|
7
|
+
const { CreatePolicyFileModel } = require('../../policyFile/models/create.policy.file.model');
|
|
8
8
|
const { validateArray } = require('../../../../common/validations/typeValidations');
|
|
9
9
|
|
|
10
10
|
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
@@ -96,22 +96,11 @@ const uploadAndCreatePolicyFile = async (policyTypeList, policyFilePath, request
|
|
|
96
96
|
return createPolicyFiles(requestId, uploadedPolicyModelsList, context);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
const getPolicyFilesForVendorReport = async (requestId, context, { shouldExpectError } = {}) => {
|
|
100
|
-
const policyPreSignedUrlResponse = await uploadFileApi.getPolicyFilesForVendorReport(requestId, context);
|
|
101
|
-
|
|
102
|
-
if (policyPreSignedUrlResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
103
|
-
throw new Error('Failed to get policy files for PM');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return policyPreSignedUrlResponse;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
99
|
module.exports = {
|
|
110
100
|
getCreatePolicyPreSignedUrl,
|
|
111
101
|
uploadRelatedDoc,
|
|
112
102
|
uploadFileToS3,
|
|
113
103
|
uploadPolicyFileAndGetPolicyModel,
|
|
114
104
|
createPolicyFiles,
|
|
115
|
-
uploadAndCreatePolicyFile
|
|
116
|
-
getPolicyFilesForVendorReport
|
|
105
|
+
uploadAndCreatePolicyFile
|
|
117
106
|
};
|
|
@@ -7,25 +7,6 @@ const RELATED_DOC_TYPES = {
|
|
|
7
7
|
OTHER: 'OTHER'
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const policyType = {
|
|
11
|
-
generalLiability: 'GENERAL_LIABILITY',
|
|
12
|
-
umbrella: 'UMBRELLA_EXCESS_LIABILITY',
|
|
13
|
-
workersCompensation: 'WORKERS_COMPENSATION',
|
|
14
|
-
automobileLiability: 'AUTOMOBILE_LIABILITY',
|
|
15
|
-
propertyInsurance: 'PROPERTY_INSURANCE',
|
|
16
|
-
professionalLiability: 'PROFESSIONAL_LIABILITY',
|
|
17
|
-
businessInterruptions: 'BUSINESS_INTERRUPTION_INCOME_INSURANCE',
|
|
18
|
-
environmentalLiability: 'POLLUTION_LIABILITY',
|
|
19
|
-
crimeLiability: 'CRIME_LIABILITY',
|
|
20
|
-
liquorLiability: 'LIQUOR_LIABILITY',
|
|
21
|
-
directorsAndOfficers: 'DIRECTORS_AND_OFFICERS_LIABILITY',
|
|
22
|
-
employmentPractice: 'EMPLOYMENT_PRACTICES_LIABILITY',
|
|
23
|
-
cyberLiability: 'CYBER_LIABILITY',
|
|
24
|
-
garageLiability: 'GARAGE_LIABILITY',
|
|
25
|
-
garageKeepers: 'GARAGE_KEEPERS_LIABILITY'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
10
|
module.exports = {
|
|
29
|
-
RELATED_DOC_TYPES
|
|
30
|
-
policyType
|
|
11
|
+
RELATED_DOC_TYPES
|
|
31
12
|
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
const services = require('./api/upload.file.service');
|
|
2
2
|
|
|
3
|
-
const { CreatePolicyFileModel } = require('./models/create.policy.file.model');
|
|
4
|
-
|
|
5
|
-
const models = {
|
|
6
|
-
CreatePolicyFileModel
|
|
7
|
-
};
|
|
8
|
-
|
|
9
3
|
const consts = require('./consts');
|
|
10
4
|
|
|
11
|
-
module.exports = { services,
|
|
5
|
+
module.exports = { services, consts };
|
|
@@ -65,7 +65,7 @@ const deleteUser = (userId, context) => {
|
|
|
65
65
|
return requests.deleteRequestHandler(Endpoints.delete(userId), context);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const deleteTeamMemberFromSingleProject = (userId, projectId, context) => {
|
|
69
69
|
return requests.deleteRequestHandler(Endpoints.deleteSingleProject(userId, projectId), context);
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -114,7 +114,7 @@ module.exports = {
|
|
|
114
114
|
getUserEncryptedData,
|
|
115
115
|
getUserListByRecordId,
|
|
116
116
|
deleteUser,
|
|
117
|
-
|
|
117
|
+
deleteTeamMemberFromSingleProject,
|
|
118
118
|
removeAllUserTraceFromDb,
|
|
119
119
|
editUserRole,
|
|
120
120
|
editUserProjects,
|
|
@@ -9,9 +9,10 @@ const { NotificationSettingsModel } = require('../models/notification.settings.m
|
|
|
9
9
|
const CreateInnerSystemAccountModel = require('../models/create.inner.system.user.model');
|
|
10
10
|
|
|
11
11
|
const userTypes = require('../../../../common/consts/userTypes');
|
|
12
|
+
const userRoles = require('../../../../common/consts/userRoles');
|
|
12
13
|
|
|
13
|
-
const inviteUser = async (
|
|
14
|
-
return userAPI.invite(
|
|
14
|
+
const inviteUser = async (invitedUserModels, context, { disableSendMail } = {}) => {
|
|
15
|
+
return userAPI.invite(invitedUserModels, context, { disableSendMail });
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const signupUser = (signupUserModel, context) => {
|
|
@@ -70,7 +71,7 @@ const getOrCreateUser = async (email, role, projectsIds, context, { fullName = r
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
const inviteUserModel = new InviteUserModel(email, role, projectsIds
|
|
74
|
+
const inviteUserModel = new InviteUserModel(email, role, projectsIds);
|
|
74
75
|
const inviteResponse = await inviteUser([inviteUserModel], context);
|
|
75
76
|
|
|
76
77
|
if (inviteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
@@ -99,8 +100,24 @@ const deleteUser = (userId, context) => {
|
|
|
99
100
|
return userAPI.deleteUser(userId, context);
|
|
100
101
|
};
|
|
101
102
|
|
|
102
|
-
const
|
|
103
|
-
return userAPI.
|
|
103
|
+
const deleteTeamMemberFromSingleProject = async (userId, projectId, context) => {
|
|
104
|
+
return userAPI.deleteTeamMemberFromSingleProject(userId, projectId, context);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const deleteAllTeamMembersFromProjects = async (projectsIds, context) => {
|
|
108
|
+
for (const projectId of projectsIds) {
|
|
109
|
+
await deleteAllTeamMembersFromProject(projectId, context);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const deleteAllTeamMembersFromProject = async (projectId, context) => {
|
|
114
|
+
let { data: users } = await getUsersByProjectId(projectId, context);
|
|
115
|
+
users = users.filter(user => user.role !== userRoles.admin);
|
|
116
|
+
|
|
117
|
+
for (const user of users) {
|
|
118
|
+
await deleteUser(user.id, context);
|
|
119
|
+
await removeAllUserTraceFromDb(user.id, context);
|
|
120
|
+
}
|
|
104
121
|
};
|
|
105
122
|
|
|
106
123
|
const removeAllUserTraceFromDb = (userId, context) => {
|
|
@@ -209,7 +226,8 @@ module.exports = {
|
|
|
209
226
|
getEnabledAndDisabledByEmail,
|
|
210
227
|
getOrCreateUser,
|
|
211
228
|
deleteUser,
|
|
212
|
-
|
|
229
|
+
deleteTeamMemberFromSingleProject,
|
|
230
|
+
deleteAllTeamMembersFromProjects,
|
|
213
231
|
deleteUserByEmail,
|
|
214
232
|
removeAllUserTraceFromDb,
|
|
215
233
|
editUserRole,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
class InviteUserModel {
|
|
2
|
-
constructor(email, role, projects = []) {
|
|
2
|
+
constructor(email, role, projects = [], hasCompleteAccessPermission) {
|
|
3
3
|
this.email = email;
|
|
4
4
|
this.role = role;
|
|
5
5
|
this.projects = projects;
|
|
6
|
+
this.hasCompleteAccessPermission = hasCompleteAccessPermission;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
|
/package/src/saas/internal-api/{uploadFiles → policyFile}/models/create.policy.file.model.js
RENAMED
|
File without changes
|