@getjones/test-infra 2.6.5 → 2.6.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.
- package/package.json +1 -1
- package/src/common/commonFlows/records/records.js +4 -4
- package/src/common/consts/recordTypes.js +5 -0
- package/src/common/consts/userTypes.js +5 -0
- package/src/common/requests/apiKeyAuth/requests.js +6 -0
- package/src/common/requests/requestHandlers.js +18 -0
- package/src/common/utils/timeUtils.js +10 -7
- package/src/defaults/configs/auditConfigs.js +5 -1
- package/src/defaults/configs/polices.js +2 -1
- package/src/defaults/configs/requirement.js +6 -3
- package/src/factory/records/records.js +33 -16
- package/src/index.js +6 -5
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +1 -1
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +1 -2
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +9 -7
- package/src/saas/internal-api/auth/api/auth.service.js +8 -1
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +3 -5
- package/src/saas/internal-api/compliance/api/waive/waive.service.js +64 -13
- package/src/saas/internal-api/compliance/consts/audit.js +0 -10
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +12 -9
- package/src/saas/internal-api/compliance/utils/util.js +61 -5
- package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -0
- package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -0
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +2 -2
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +8 -2
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +13 -1
- package/src/saas/internal-api/requests/api/requests.api.js +6 -0
- package/src/saas/internal-api/requests/api/requests.service.js +5 -0
- package/src/saas/internal-api/requirements/api/requirements.service.js +22 -1
- package/src/saas/internal-api/requirements/index.js +2 -1
- package/src/saas/internal-api/thread-scheduler/runner.js +1 -1
- package/src/saas/internal-api/users/api/users.service.js +2 -2
- package/src/saas/openapi/coi/coi.api.js +20 -0
- package/src/saas/openapi/coi/coi.service.js +13 -0
- package/src/saas/openapi/requests/index.js +2 -1
- package/src/saas/openapi/requests/models/invite.request.model.js +11 -11
- package/src/saas/openapi/requests/models/update.request.model.js +35 -0
- package/src/saas/openapi/requests/requests.api.js +64 -8
- package/src/saas/openapi/requests/requests.service.js +52 -5
- package/src/saas/openapi/requirements/requirements.api.js +18 -4
- package/src/saas/openapi/requirements/requirements.service.js +14 -2
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +0 -12
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +0 -7
- /package/src/saas/internal-api/{dashboardInnerPage → dashboard}/index.js +0 -0
- /package/src/saas/internal-api/{dashboardInnerPage → dashboard}/models/dashboard.filter.criteria.model.js +0 -0
package/package.json
CHANGED
|
@@ -19,13 +19,13 @@ const updateInviteDate = async function(recordId, inviteDate, context) {
|
|
|
19
19
|
const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
|
|
20
20
|
|
|
21
21
|
if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
22
|
-
throw new Error(
|
|
22
|
+
throw new Error(`Record invite date could not be updated\n${updateResponse}`);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
|
|
26
26
|
|
|
27
27
|
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
28
|
-
throw new Error(
|
|
28
|
+
throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
@@ -43,13 +43,13 @@ const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, pol
|
|
|
43
43
|
const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
|
|
44
44
|
|
|
45
45
|
if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
46
|
-
throw new Error(
|
|
46
|
+
throw new Error(`Record expiry date could not be updated\n${updateResponse}`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
|
|
50
50
|
|
|
51
51
|
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
52
|
-
throw new Error(
|
|
52
|
+
throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
@@ -15,6 +15,11 @@ const putRequestHandler = (url, apiKey, body, headers = {}, params = {}) => {
|
|
|
15
15
|
return requestHandler.putRequestHandler(url, body, headers, params);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
const putFileRequestHandler = (url, apiKey, fileData, headers = {}) => {
|
|
19
|
+
enrichApiKey(headers, apiKey);
|
|
20
|
+
return requestHandler.putFileRequestHandler(url, fileData, headers);
|
|
21
|
+
};
|
|
22
|
+
|
|
18
23
|
const patchRequestHandler = (url, apiKey, body, headers = {}) => {
|
|
19
24
|
enrichApiKey(headers, apiKey);
|
|
20
25
|
return requestHandler.patchRequestHandler(url, body, headers);
|
|
@@ -33,6 +38,7 @@ module.exports = {
|
|
|
33
38
|
getRequestHandler,
|
|
34
39
|
postRequestHandler,
|
|
35
40
|
putRequestHandler,
|
|
41
|
+
putFileRequestHandler,
|
|
36
42
|
patchRequestHandler,
|
|
37
43
|
deleteRequestHandler
|
|
38
44
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
|
+
const axiosFile = require('axios-file');
|
|
3
|
+
|
|
2
4
|
const errorValidation = require('../validations/errorValidation');
|
|
3
5
|
|
|
4
6
|
const getRequestHandler = async (url, headers = {}, params = {}) => {
|
|
@@ -31,6 +33,21 @@ const putRequestHandler = async (url, body, headers = {}, params = {}) => {
|
|
|
31
33
|
}
|
|
32
34
|
};
|
|
33
35
|
|
|
36
|
+
const putFileRequestHandler = async (url, fileData, headers = {}) => {
|
|
37
|
+
try {
|
|
38
|
+
const response = await axiosFile({
|
|
39
|
+
url,
|
|
40
|
+
method: 'put',
|
|
41
|
+
headers,
|
|
42
|
+
data: { file: fileData }
|
|
43
|
+
});
|
|
44
|
+
return response;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
errorValidation.validateClientErrorResponseStatus(error);
|
|
47
|
+
return error.response;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
34
51
|
const patchRequestHandler = async (url, body, headers = {}) => {
|
|
35
52
|
try {
|
|
36
53
|
const response = await axios.patch(url, body, { headers });
|
|
@@ -55,6 +72,7 @@ module.exports = {
|
|
|
55
72
|
getRequestHandler,
|
|
56
73
|
postRequestHandler,
|
|
57
74
|
putRequestHandler,
|
|
75
|
+
putFileRequestHandler,
|
|
58
76
|
patchRequestHandler,
|
|
59
77
|
deleteRequestHandler
|
|
60
78
|
};
|
|
@@ -12,7 +12,8 @@ const formats = {
|
|
|
12
12
|
fullMonthDayYear: 'MMMM DD, YYYY',
|
|
13
13
|
threadScheduler: '', // Passing empty string resolves moment.js format to ISO8601 standard like 2020-04-12T09:49:59Z;
|
|
14
14
|
monthDayYear12hTime: 'MMM D, YYYY h:mm A',
|
|
15
|
-
amPmTime: 'h:mm A'
|
|
15
|
+
amPmTime: 'h:mm A',
|
|
16
|
+
yearMonthDay: 'YYYY-MM-DD'
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const peroids = {
|
|
@@ -34,6 +35,7 @@ const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.d
|
|
|
34
35
|
const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
|
|
35
36
|
const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
|
|
36
37
|
const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
|
|
38
|
+
const getDateInTwoMonths = format => moment().utc().add(2, peroids.months).format(format || formats.dayMonthYear);
|
|
37
39
|
const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
|
|
38
40
|
const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
|
|
39
41
|
const getOneWeekAgoDate = () => moment().utc().subtract(7, peroids.days).format(formats.dayMonthYear);
|
|
@@ -68,10 +70,6 @@ const getYearMonthDayFormat = date => {
|
|
|
68
70
|
return `${year}-${month}-${day}`;
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
const dateToIsoFormat = date => {
|
|
72
|
-
return new Date(date).toISOString();
|
|
73
|
-
};
|
|
74
|
-
|
|
75
73
|
const extractDateFromDateTime = date => {
|
|
76
74
|
let extractedDate = date;
|
|
77
75
|
|
|
@@ -134,6 +132,10 @@ const convertDateToNewFormat = (value, currentFormat, newFormat = formats.dayMon
|
|
|
134
132
|
return moment(value, currentFormat).format(newFormat);
|
|
135
133
|
};
|
|
136
134
|
|
|
135
|
+
const convertDateToLongInt = value => {
|
|
136
|
+
return Date.parse(value);
|
|
137
|
+
};
|
|
138
|
+
|
|
137
139
|
module.exports = {
|
|
138
140
|
formats,
|
|
139
141
|
getOneYearAgoDate,
|
|
@@ -151,6 +153,7 @@ module.exports = {
|
|
|
151
153
|
getDateinSixDays,
|
|
152
154
|
getDateinThirteenDays,
|
|
153
155
|
getDateinTwentyNineDays,
|
|
156
|
+
getDateInTwoMonths,
|
|
154
157
|
getInvitationDatesForNotResponsiveVendor,
|
|
155
158
|
getInvitationDatesForNotResponsiveTenant,
|
|
156
159
|
getAutomaticRenewalsExpirationDates,
|
|
@@ -159,7 +162,6 @@ module.exports = {
|
|
|
159
162
|
getAuditDateFormat,
|
|
160
163
|
getDateWithOffset,
|
|
161
164
|
getYearMonthDayFormat,
|
|
162
|
-
dateToIsoFormat,
|
|
163
165
|
getDayInMilliseconds,
|
|
164
166
|
extractDateFromDateTime,
|
|
165
167
|
getPreviousDateByDays,
|
|
@@ -167,5 +169,6 @@ module.exports = {
|
|
|
167
169
|
isDateAfterOther,
|
|
168
170
|
convertDateToNewFormat,
|
|
169
171
|
getOneWeekAgoDate,
|
|
170
|
-
getOneWeekAheadDate
|
|
172
|
+
getOneWeekAheadDate,
|
|
173
|
+
convertDateToLongInt
|
|
171
174
|
};
|
|
@@ -81,5 +81,9 @@ module.exports = {
|
|
|
81
81
|
getCompliantAuditConfig,
|
|
82
82
|
getNotCompliantConfig,
|
|
83
83
|
getAboutExpiredConfig,
|
|
84
|
-
getExpiredConfig
|
|
84
|
+
getExpiredConfig,
|
|
85
|
+
policySelections,
|
|
86
|
+
defaultPolicyDate: DEFAULT_POLICY_DATE,
|
|
87
|
+
defaultAMScore: DEFAULT_AM_SCORE,
|
|
88
|
+
defaultPolicyNumber: DEFAULT_POLICY_NUMBER
|
|
85
89
|
};
|
|
@@ -4,6 +4,7 @@ const { cloneObject } = require('../../common/utils/objectUtils');
|
|
|
4
4
|
const { eachOccurrence } = attributeNames;
|
|
5
5
|
const { generalLiability } = policyNames;
|
|
6
6
|
|
|
7
|
+
const { REQUIREMENT_SHARING_LEVELS } = require('../../saas/internal-api/requirements/consts/consts');
|
|
7
8
|
const DEFAULT_REQUIREMENT_NAME = 'Integration Requirement';
|
|
8
9
|
const DEFAULT_COVERAGE_VALUE = 1000000;
|
|
9
10
|
|
|
@@ -15,15 +16,17 @@ const getDefaultRequirementPolices = () => {
|
|
|
15
16
|
});
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const defaultRequirementConfig = () => {
|
|
19
|
+
const defaultRequirementConfig = ({ name = DEFAULT_REQUIREMENT_NAME, sharingLevel = REQUIREMENT_SHARING_LEVELS.TAB } = {}) => {
|
|
19
20
|
return {
|
|
20
|
-
name
|
|
21
|
-
policies: getDefaultRequirementPolices()
|
|
21
|
+
name,
|
|
22
|
+
policies: getDefaultRequirementPolices(),
|
|
23
|
+
sharingLevel
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
module.exports = {
|
|
26
28
|
name: DEFAULT_REQUIREMENT_NAME,
|
|
29
|
+
value: DEFAULT_COVERAGE_VALUE,
|
|
27
30
|
getDefaultRequirementPolices,
|
|
28
31
|
defaultRequirementConfig
|
|
29
32
|
};
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
const { getEnv } = require('../../env');
|
|
4
|
+
const { credentials } = getEnv();
|
|
5
|
+
|
|
6
|
+
const auth = require('../../saas/internal-api/auth');
|
|
3
7
|
const coi = require('../../saas/internal-api/coi');
|
|
4
8
|
const compliance = require('../../saas/internal-api/compliance');
|
|
5
|
-
const auth = require('../../saas/internal-api/auth');
|
|
6
9
|
const contractors = require('../../saas/internal-api/contractors');
|
|
10
|
+
const requests = require('../../saas/internal-api/requests');
|
|
11
|
+
|
|
7
12
|
const auditConfigs = require('../../defaults/configs/auditConfigs');
|
|
8
13
|
const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
|
|
9
14
|
const timeUtils = require('../../common/utils/timeUtils');
|
|
10
15
|
|
|
11
|
-
const filePath = '
|
|
16
|
+
const filePath = path.join(__dirname, '../../resources/coi/coi.pdf');
|
|
17
|
+
|
|
12
18
|
const complianceStatuses = {
|
|
13
19
|
complaint: 'complaint',
|
|
14
20
|
notCompliant: 'notCompliant',
|
|
@@ -22,7 +28,7 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
22
28
|
context,
|
|
23
29
|
tabId,
|
|
24
30
|
requirementId,
|
|
25
|
-
{
|
|
31
|
+
{ // record
|
|
26
32
|
inviterEmail: credentials.superUser,
|
|
27
33
|
email: recordEmail,
|
|
28
34
|
companyName: recordCompany
|
|
@@ -30,21 +36,22 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
30
36
|
);
|
|
31
37
|
|
|
32
38
|
if (!(requestData && requestData.id)) {
|
|
33
|
-
throw Error(`Failed to create record ${
|
|
39
|
+
throw Error(`Failed to create record ${recordCompany}\n${requestData}`);
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
const accountId = requestData.record.userId;
|
|
37
43
|
const projectId = requestData.projectInfo.projectId;
|
|
44
|
+
const recordId = requestData.record.contractorId;
|
|
38
45
|
|
|
39
46
|
const coiUpload = await coi.utils.uploadCoi(
|
|
40
|
-
|
|
47
|
+
recordId,
|
|
41
48
|
filePath,
|
|
42
49
|
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
43
50
|
uploaderEmail = credentials.superUser
|
|
44
51
|
);
|
|
45
52
|
|
|
46
53
|
if (!(coiUpload && coiUpload.name)) {
|
|
47
|
-
throw Error(`Failed to upload COI for record ${
|
|
54
|
+
throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
const auditorContext = await auth.services.getAuditorCookie();
|
|
@@ -73,17 +80,17 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
73
80
|
auditorContext,
|
|
74
81
|
accountId,
|
|
75
82
|
projectId,
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
requirementId,
|
|
84
|
+
recordId,
|
|
78
85
|
auditConfig
|
|
79
86
|
);
|
|
80
87
|
} while (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT && retries--);
|
|
81
88
|
|
|
82
89
|
if (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
83
|
-
throw Error(`Failed to audit record ${record.company}\n
|
|
90
|
+
throw Error(`Failed to audit record ${record.company}\n${auditResponse}`);
|
|
84
91
|
}
|
|
85
92
|
|
|
86
|
-
return
|
|
93
|
+
return recordId;
|
|
87
94
|
};
|
|
88
95
|
|
|
89
96
|
const prepareCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
@@ -102,23 +109,33 @@ const prepareAboutToExpiredRecord = (recordCompany, recordEmail, tabId, requirem
|
|
|
102
109
|
return prepareRecord(recordCompany, recordEmail, complianceStatuses.aboutToExpired, tabId, requirementId, context);
|
|
103
110
|
};
|
|
104
111
|
|
|
112
|
+
const prepareWaivedRecord = async (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
113
|
+
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context);
|
|
114
|
+
|
|
115
|
+
const record = await contractors.services.getContractorById(recordId, context);
|
|
116
|
+
await compliance.services.waive.waiveAll(record, context);
|
|
117
|
+
|
|
118
|
+
return recordId;
|
|
119
|
+
};
|
|
120
|
+
|
|
105
121
|
const prepareAwaitingNewCoiRecord = async (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
106
|
-
const
|
|
122
|
+
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.awaitingNewCoi, tabId, requirementId, context);
|
|
107
123
|
|
|
108
|
-
const recordVerificationModel = await contractors.services.getRecordVerificationModel(
|
|
124
|
+
const recordVerificationModel = await contractors.services.getRecordVerificationModel(recordId, context);
|
|
109
125
|
const sendGapsResponse = await contractors.services.sendGaps(recordVerificationModel, context);
|
|
110
126
|
|
|
111
127
|
if (sendGapsResponse.status !== httpResponseStatusCodes.OK) {
|
|
112
|
-
throw Error(`Failed to send gaps to ${recordCompany}\n
|
|
128
|
+
throw Error(`Failed to send gaps to ${recordCompany}\n${sendGapsResponse}`);
|
|
113
129
|
}
|
|
114
130
|
|
|
115
|
-
return
|
|
131
|
+
return recordId;
|
|
116
132
|
};
|
|
117
133
|
|
|
118
134
|
module.exports = {
|
|
119
135
|
prepareCompliantRecord,
|
|
120
136
|
prepareNotCompliantRecord,
|
|
121
137
|
prepareExpiredRecord,
|
|
138
|
+
prepareWaivedRecord,
|
|
122
139
|
prepareAboutToExpiredRecord,
|
|
123
140
|
prepareAwaitingNewCoiRecord
|
|
124
141
|
};
|
package/src/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const getInternalAPI = () => {
|
|
|
26
26
|
|
|
27
27
|
const reports = require('./saas/internal-api/reports');
|
|
28
28
|
const charts = require('./saas/internal-api/homepageCharts');
|
|
29
|
-
const
|
|
29
|
+
const dashboard = require('./saas/internal-api/dashboard');
|
|
30
30
|
|
|
31
31
|
const globalRecord = require('./saas/internal-api/globalRecord');
|
|
32
32
|
const vendorProfile = require('./saas/internal-api/vendorProfile');
|
|
@@ -49,7 +49,7 @@ const getInternalAPI = () => {
|
|
|
49
49
|
reports,
|
|
50
50
|
users,
|
|
51
51
|
charts,
|
|
52
|
-
|
|
52
|
+
dashboard,
|
|
53
53
|
globalRecord,
|
|
54
54
|
vendorProfile,
|
|
55
55
|
serviceArea,
|
|
@@ -63,11 +63,12 @@ const getInternalAPI = () => {
|
|
|
63
63
|
|
|
64
64
|
const getOpenAPI = () => {
|
|
65
65
|
const accounts = require('./saas/openapi/accounts/accounts.service');
|
|
66
|
-
const tabs = require('./saas/openapi/tabs/tabs.service');
|
|
67
|
-
const requests = require('./saas/openapi/requests');
|
|
68
66
|
const projects = require('./saas/openapi/projects/projects.service');
|
|
67
|
+
const tabs = require('./saas/openapi/tabs/tabs.service');
|
|
69
68
|
const requirements = require('./saas/openapi/requirements');
|
|
70
|
-
const
|
|
69
|
+
const requests = require('./saas/openapi/requests');
|
|
70
|
+
const coi = require('./saas/openapi/coi/coi.service');
|
|
71
|
+
const openAPI = { accounts, projects, tabs, requirements, requests, coi };
|
|
71
72
|
return openAPI;
|
|
72
73
|
};
|
|
73
74
|
|
|
@@ -41,7 +41,7 @@ const getOrCreateAccount = async (createAccountModel, context) => {
|
|
|
41
41
|
const response = await accountsAPI.create(createAccountModel, context);
|
|
42
42
|
|
|
43
43
|
if (!response.data) {
|
|
44
|
-
throw new Error(`Account by the name ${createAccountModel.companyName} was not created`);
|
|
44
|
+
throw new Error(`Account by the name ${createAccountModel.companyName} was not created\n${response}`);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
return response.data;
|
|
@@ -12,8 +12,7 @@ const updateAccountSettings = (updateAccountSettingsModel, context) => {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const restoreAccountSettings = (accountId, context) => {
|
|
15
|
-
const
|
|
16
|
-
const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, isHighPriority, hasAnalyticsDashboard, isExcludedFromNetwork, isOcrEnabled, isCoverageAudit, isAccountRequirementsEnabled);
|
|
15
|
+
const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId);
|
|
17
16
|
return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
|
|
18
17
|
};
|
|
19
18
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
class UpdateAccountSettingsModel {
|
|
2
2
|
constructor(
|
|
3
3
|
accountId,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
{
|
|
5
|
+
isHighPriority = false,
|
|
6
|
+
hasAnalyticsDashboard = false,
|
|
7
|
+
isEmailOnWelcomePageVA = false,
|
|
8
|
+
isExcludedFromNetwork = false,
|
|
9
|
+
isOcrEnabled = false,
|
|
10
|
+
isCoverageAudit = false,
|
|
11
|
+
isAccountRequirementsEnabled = false
|
|
12
|
+
} = {}
|
|
11
13
|
) {
|
|
12
14
|
this.accountId = accountId;
|
|
13
15
|
this.isHighPriority = isHighPriority;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const { getEnv, requiredValidation, getSystemUserIdentity, addUserIdentity } = require('../../../../env');
|
|
2
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
3
|
+
|
|
2
4
|
const { credentials } = getEnv();
|
|
3
5
|
const authApi = require('./auth.api');
|
|
4
6
|
|
|
@@ -11,13 +13,18 @@ const getAuthCookie = async (email, password) => {
|
|
|
11
13
|
|
|
12
14
|
try {
|
|
13
15
|
const response = await authApi.login(email, password);
|
|
16
|
+
|
|
17
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
18
|
+
throw Error(`Error: ${JSON.stringify(response.data)}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
|
|
15
22
|
|
|
16
23
|
addUserIdentity(email, authCookie, response.data.id);
|
|
17
24
|
|
|
18
25
|
return authCookie;
|
|
19
26
|
} catch (error) {
|
|
20
|
-
throw new Error(`Failed to login
|
|
27
|
+
throw new Error(`Failed to login with email: ${email}\nError: ${error}`);
|
|
21
28
|
}
|
|
22
29
|
};
|
|
23
30
|
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
const env = require('../../../../../env');
|
|
2
|
+
|
|
1
3
|
const waiveApi = require('./waive.api');
|
|
2
|
-
const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
|
|
4
|
+
const { WaiveRequestModel, RetractRequestModel, WAIVER_REASONS } = require('../../models/waive/waive.model');
|
|
3
5
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
6
|
+
const util = require('../../utils/util');
|
|
7
|
+
const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
|
|
8
|
+
|
|
9
|
+
const { credentials } = env.getEnv();
|
|
10
|
+
const userTypes = require('../../../../../common/consts/userTypes');
|
|
4
11
|
|
|
5
12
|
const waive = (waiveRequestModel, context) => {
|
|
6
13
|
validateType(waiveRequestModel, WaiveRequestModel);
|
|
@@ -12,39 +19,63 @@ const retract = (retractRequestModel, context) => {
|
|
|
12
19
|
return waiveApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
|
|
13
20
|
};
|
|
14
21
|
|
|
15
|
-
const getWaiveModel =
|
|
22
|
+
const getWaiveModel = (
|
|
16
23
|
record,
|
|
17
24
|
policyName,
|
|
18
25
|
attributeName,
|
|
19
26
|
waiverReason,
|
|
20
|
-
remarks
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
remarks,
|
|
28
|
+
{
|
|
29
|
+
userId,
|
|
30
|
+
userRole
|
|
31
|
+
} = {}) => {
|
|
32
|
+
const auditId = getPolicyAuditIdFromRecord(record, policyName, util.getAttributeKey(attributeName));
|
|
33
|
+
userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
|
|
34
|
+
userRole = userRole || userTypes.ICS;
|
|
23
35
|
|
|
24
36
|
const waiveModel = new WaiveRequestModel({
|
|
25
|
-
userId: record.userId,
|
|
26
37
|
contractorId: record.id,
|
|
27
38
|
auditId,
|
|
28
39
|
waiverReason,
|
|
29
|
-
remarks
|
|
40
|
+
remarks,
|
|
41
|
+
userId,
|
|
42
|
+
userRole
|
|
30
43
|
});
|
|
31
44
|
|
|
32
45
|
return waiveModel;
|
|
33
46
|
};
|
|
34
47
|
|
|
35
|
-
const
|
|
36
|
-
|
|
48
|
+
const getWaiveModelByGap = (
|
|
49
|
+
record,
|
|
50
|
+
policyName,
|
|
51
|
+
gap,
|
|
52
|
+
reason,
|
|
53
|
+
note,
|
|
54
|
+
{
|
|
55
|
+
userId,
|
|
56
|
+
userRole
|
|
57
|
+
} = {}) => {
|
|
58
|
+
const attributeName = util.getAttributeNameByGap(record, policyName, gap);
|
|
59
|
+
|
|
60
|
+
return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole });
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getRetractModel = (record, policyName, attributeName) => {
|
|
64
|
+
const auditId = getPolicyAuditIdFromRecord(record, policyName, util.getAttributeKey(attributeName));
|
|
65
|
+
const userId = env.getSystemUserIdentity(credentials.superUser).id;
|
|
66
|
+
const userRole = userTypes.ICS;
|
|
37
67
|
|
|
38
68
|
const retractModel = new RetractRequestModel({
|
|
39
|
-
userId: record.userId,
|
|
40
69
|
contractorId: record.id,
|
|
41
|
-
auditId
|
|
70
|
+
auditId,
|
|
71
|
+
userId,
|
|
72
|
+
userRole
|
|
42
73
|
});
|
|
43
74
|
|
|
44
75
|
return retractModel;
|
|
45
76
|
};
|
|
46
77
|
|
|
47
|
-
const getPolicyAuditIdFromRecord =
|
|
78
|
+
const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
|
|
48
79
|
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
49
80
|
contractorCoverage.insuranceName === policyName);
|
|
50
81
|
|
|
@@ -61,4 +92,24 @@ const getPolicyAuditIdFromRecord = async (record, policyName, attributeName) =>
|
|
|
61
92
|
return attribute.auditId;
|
|
62
93
|
};
|
|
63
94
|
|
|
64
|
-
|
|
95
|
+
const waiveAll = async (record, context, { reason = WAIVER_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
|
|
96
|
+
const allWaivablePolicies = util.getAllWaivablePolicies(record, context);
|
|
97
|
+
|
|
98
|
+
for (const waivable of allWaivablePolicies) {
|
|
99
|
+
const waiveModel = getWaiveModel(record, waivable.policyName, waivable.attributeName, reason, note);
|
|
100
|
+
const waiveResponse = await waive(waiveModel, context);
|
|
101
|
+
|
|
102
|
+
if (waiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
103
|
+
throw Error(`Failed to waive ${waivable.policyName} - ${waivable.attributeName} for ${record.company}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
module.exports = {
|
|
109
|
+
waive,
|
|
110
|
+
waiveAll,
|
|
111
|
+
retract,
|
|
112
|
+
getWaiveModel,
|
|
113
|
+
getRetractModel,
|
|
114
|
+
getWaiveModelByGap
|
|
115
|
+
};
|
|
@@ -11,14 +11,6 @@ const AUDIT_ENTITY_STATUSES = {
|
|
|
11
11
|
CLAIMS: 'Claims'
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const AUDIT_ATTRIBUTE_NAMES = {
|
|
15
|
-
CERTIFICATE_ISSUE_DATE: 'certIssueDate'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const AUDIT_POLICY_NAMES = {
|
|
19
|
-
GENERAL_LIABILITY: ''
|
|
20
|
-
};
|
|
21
|
-
|
|
22
14
|
const VALID_SCORES = ['A+', 'A'];
|
|
23
15
|
|
|
24
16
|
const AUDITOR_ROLE = 'Auditor';
|
|
@@ -74,8 +66,6 @@ module.exports = {
|
|
|
74
66
|
ATTRIBUTE_NAMES_MAP,
|
|
75
67
|
COI_AUDIT_STATUSES,
|
|
76
68
|
AUDITOR_ROLE,
|
|
77
|
-
AUDIT_POLICY_NAMES,
|
|
78
|
-
AUDIT_ATTRIBUTE_NAMES,
|
|
79
69
|
AUDIT_ENTITY_STATUSES,
|
|
80
70
|
VALID_SCORES
|
|
81
71
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const DEFAULT_USER_ROLE = 'ICS';
|
|
2
|
-
|
|
3
1
|
const WAIVE_ACTIONS = {
|
|
4
2
|
WAIVE: 'ignored',
|
|
5
3
|
RETRACT: 'notIgnored'
|
|
@@ -12,24 +10,29 @@ const WAIVER_REASONS = {
|
|
|
12
10
|
};
|
|
13
11
|
|
|
14
12
|
function WaiveRequestModel({
|
|
15
|
-
userId,
|
|
16
13
|
contractorId,
|
|
17
14
|
auditId,
|
|
18
15
|
waiverReason,
|
|
19
|
-
remarks
|
|
20
|
-
|
|
16
|
+
remarks,
|
|
17
|
+
userId,
|
|
18
|
+
userRole
|
|
21
19
|
}) {
|
|
22
20
|
this.auditorContractorId = auditId;
|
|
23
21
|
this.contractorId = contractorId;
|
|
24
|
-
this.userId = userId;
|
|
25
22
|
this.waiverReason = waiverReason;
|
|
26
|
-
this.remarks = remarks;
|
|
23
|
+
this.remarks = remarks || '';
|
|
27
24
|
|
|
28
|
-
this.
|
|
25
|
+
this.userId = userId,
|
|
26
|
+
this.userRole = userRole,
|
|
29
27
|
this.status = WAIVE_ACTIONS.WAIVE;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
function RetractRequestModel({
|
|
30
|
+
function RetractRequestModel({
|
|
31
|
+
contractorId,
|
|
32
|
+
auditId,
|
|
33
|
+
userId,
|
|
34
|
+
userRole
|
|
35
|
+
}) {
|
|
33
36
|
this.auditorContractorId = auditId;
|
|
34
37
|
this.contractorId = contractorId;
|
|
35
38
|
this.userId = userId;
|