@getjones/test-infra 2.6.6 → 2.6.8
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/auth/auth.js +40 -0
- package/src/common/commonFlows/index.js +2 -1
- package/src/common/commonFlows/records/records.js +4 -4
- package/src/common/consts/recordTypes.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 +9 -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 +18 -7
- package/src/saas/internal-api/auth/api/auth.api.js +14 -5
- package/src/saas/internal-api/auth/api/auth.service.js +28 -5
- package/src/saas/internal-api/compliance/api/waive/waive.service.js +16 -1
- package/src/saas/internal-api/compliance/utils/util.js +25 -1
- package/src/saas/internal-api/contractors/consts/consts.js +6 -0
- 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 +14 -2
- package/src/saas/internal-api/requests/api/requests.service.js +18 -0
- package/src/saas/internal-api/requestsTable/api/requests.table.api.js +14 -0
- package/src/saas/internal-api/requestsTable/api/requests.table.service.js +9 -0
- package/src/saas/internal-api/requestsTable/index.js +3 -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/requirements/models/update.requirement.model.js +3 -1
- package/src/saas/internal-api/requirements/utils/utils.js +2 -2
- 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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { expect } = require('chai');
|
|
2
|
+
|
|
3
|
+
const env = require('../../../../../../src/env');
|
|
4
|
+
|
|
5
|
+
const { internalAPI } = require('../../../../src')(env);
|
|
6
|
+
const { dbEmails, auth } = internalAPI;
|
|
7
|
+
|
|
8
|
+
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
9
|
+
|
|
10
|
+
const textInSubject = 'One-Time Security Code';
|
|
11
|
+
const textInBody = 'Please use the one-time code below to confirm your identity';
|
|
12
|
+
const codeLength = 6;
|
|
13
|
+
|
|
14
|
+
const getVendorHubAuthCookie = async email => {
|
|
15
|
+
const createOneTimeSessionResponse = await auth.services.createOneTimeSession(email);
|
|
16
|
+
expect(createOneTimeSessionResponse.status, `Create one-time session for email ${email} has failed`).to.equal(httpResponseStatusCodes.OK);
|
|
17
|
+
|
|
18
|
+
const recipients = {
|
|
19
|
+
from: env.credentials.superUser,
|
|
20
|
+
to: [email]
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const userEmailBody = await dbEmails.services.getLastMessage({ recipients, textInSubject });
|
|
24
|
+
expect(userEmailBody, 'Fetching user one-time security code email has failed').to.be.a('string').that.includes(textInBody);
|
|
25
|
+
|
|
26
|
+
const oneTimeCode = await extractOneTimeCode(userEmailBody);
|
|
27
|
+
expect(oneTimeCode.length, 'One-time security code extraction from email body has failed').to.equal(codeLength);
|
|
28
|
+
|
|
29
|
+
return auth.services.getHubUserCookie(email, oneTimeCode);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
async function extractOneTimeCode(inputString) {
|
|
33
|
+
const regex = '\s*(\\d{6})\n\s*';
|
|
34
|
+
const match = inputString.match(regex);
|
|
35
|
+
|
|
36
|
+
return match ? match[1] : null;
|
|
37
|
+
}
|
|
38
|
+
module.exports = {
|
|
39
|
+
getVendorHubAuthCookie
|
|
40
|
+
};
|
|
@@ -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,12 +26,14 @@ 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');
|
|
33
33
|
const serviceArea = require('./saas/internal-api/serviceArea');
|
|
34
34
|
|
|
35
|
+
const requestsTable = require('./saas/internal-api/requestsTable');
|
|
36
|
+
|
|
35
37
|
const threadScheduler = require('./saas/internal-api/thread-scheduler/runner');
|
|
36
38
|
const dbEmails = require('./saas/internal-api/dbEmails/index');
|
|
37
39
|
|
|
@@ -49,10 +51,11 @@ const getInternalAPI = () => {
|
|
|
49
51
|
reports,
|
|
50
52
|
users,
|
|
51
53
|
charts,
|
|
52
|
-
|
|
54
|
+
dashboard,
|
|
53
55
|
globalRecord,
|
|
54
56
|
vendorProfile,
|
|
55
57
|
serviceArea,
|
|
58
|
+
requestsTable,
|
|
56
59
|
threadScheduler,
|
|
57
60
|
dbEmails,
|
|
58
61
|
factory
|
|
@@ -63,11 +66,12 @@ const getInternalAPI = () => {
|
|
|
63
66
|
|
|
64
67
|
const getOpenAPI = () => {
|
|
65
68
|
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
69
|
const projects = require('./saas/openapi/projects/projects.service');
|
|
70
|
+
const tabs = require('./saas/openapi/tabs/tabs.service');
|
|
69
71
|
const requirements = require('./saas/openapi/requirements');
|
|
70
|
-
const
|
|
72
|
+
const requests = require('./saas/openapi/requests');
|
|
73
|
+
const coi = require('./saas/openapi/coi/coi.service');
|
|
74
|
+
const openAPI = { accounts, projects, tabs, requirements, requests, coi };
|
|
71
75
|
return openAPI;
|
|
72
76
|
};
|
|
73
77
|
|
|
@@ -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,17 @@
|
|
|
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
|
+
isAccountRequirementsAutoRenewalsEnabled = false,
|
|
13
|
+
autoGaps = {}
|
|
14
|
+
} = {}
|
|
11
15
|
) {
|
|
12
16
|
this.accountId = accountId;
|
|
13
17
|
this.isHighPriority = isHighPriority;
|
|
@@ -17,7 +21,14 @@ class UpdateAccountSettingsModel {
|
|
|
17
21
|
this.isOcrEnabled = isOcrEnabled;
|
|
18
22
|
this.isCoverageAudit = isCoverageAudit;
|
|
19
23
|
this.isAccountRequirementsEnabled = isAccountRequirementsEnabled;
|
|
24
|
+
this.isAccountRequirementsAutoRenewalsEnabled = isAccountRequirementsAutoRenewalsEnabled;
|
|
25
|
+
this.autoGaps = { ... DEFAULT_AUTO_GAPS, ... autoGaps };
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
|
|
29
|
+
const DEFAULT_AUTO_GAPS = {
|
|
30
|
+
isAutoGapsEnabledForTenants: false,
|
|
31
|
+
isAutoGapsEnabledForVendors: false
|
|
32
|
+
};
|
|
33
|
+
|
|
23
34
|
module.exports = UpdateAccountSettingsModel;
|
|
@@ -3,16 +3,25 @@ const { backendUrl } = require('../../../../env').getEnv();
|
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
login: `${backendUrl}/logincontroller`,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
verifyEmail: `${backendUrl}/verify/email`,
|
|
7
|
+
createOneTimeSession: `${backendUrl}/vendor-app/one-time-session/create`,
|
|
8
|
+
verifyRecord: `${backendUrl}/vendor-app/one-time-session/verify/record/undefined`// Due to unused variable "recordId"
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
const login = (email, password) => {
|
|
11
12
|
return requests.postRequestHandler(Endpoints.login, { email, password });
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
-
return requests.postRequestHandler(Endpoints.
|
|
15
|
+
const verifyEmail = email => {
|
|
16
|
+
return requests.postRequestHandler(Endpoints.verifyEmail, { email });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const createOneTimeSession = email => {
|
|
20
|
+
return requests.postRequestHandler(Endpoints.createOneTimeSession, { email });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const verifyRecord = (email, oneTimeCode) => {
|
|
24
|
+
return requests.getRequestHandler(Endpoints.verifyRecord, { email, oneTimeCode });
|
|
16
25
|
};
|
|
17
26
|
|
|
18
|
-
module.exports = { login,
|
|
27
|
+
module.exports = { login, verifyEmail, createOneTimeSession, verifyRecord };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const { getEnv, requiredValidation, getSystemUserIdentity, addUserIdentity } = require('../../../../env');
|
|
2
2
|
const { credentials } = getEnv();
|
|
3
|
+
|
|
4
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
5
|
+
|
|
3
6
|
const authApi = require('./auth.api');
|
|
4
7
|
|
|
5
8
|
const getAuthCookie = async (email, password) => {
|
|
@@ -11,20 +14,38 @@ const getAuthCookie = async (email, password) => {
|
|
|
11
14
|
|
|
12
15
|
try {
|
|
13
16
|
const response = await authApi.login(email, password);
|
|
17
|
+
|
|
18
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
19
|
+
throw Error(`Error: ${JSON.stringify(response.data)}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
|
|
15
23
|
|
|
16
24
|
addUserIdentity(email, authCookie, response.data.id);
|
|
17
25
|
|
|
18
26
|
return authCookie;
|
|
19
27
|
} catch (error) {
|
|
20
|
-
throw new Error(`Failed to login
|
|
28
|
+
throw new Error(`Failed to login with email: ${email}\nError: ${error}`);
|
|
21
29
|
}
|
|
22
30
|
};
|
|
23
31
|
|
|
24
|
-
const
|
|
32
|
+
const verifyEmail = email => {
|
|
33
|
+
return authApi.verifyEmail(email);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const createOneTimeSession = email => {
|
|
37
|
+
return authApi.createOneTimeSession(email);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getHubUserCookie = async (email, oneTimeCode) => {
|
|
25
41
|
try {
|
|
26
|
-
const response = await authApi.
|
|
27
|
-
|
|
42
|
+
const response = await authApi.verifyRecord(email, oneTimeCode);
|
|
43
|
+
|
|
44
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
45
|
+
throw Error(`Error: ${JSON.stringify(response.data)}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken='));
|
|
28
49
|
|
|
29
50
|
return authCookie;
|
|
30
51
|
} catch (error) {
|
|
@@ -60,7 +81,9 @@ const getOperatorCookie = () => {
|
|
|
60
81
|
|
|
61
82
|
module.exports = {
|
|
62
83
|
getAuthCookie,
|
|
63
|
-
|
|
84
|
+
verifyEmail,
|
|
85
|
+
createOneTimeSession,
|
|
86
|
+
getHubUserCookie,
|
|
64
87
|
getIcsCookie,
|
|
65
88
|
getAuditorCookie,
|
|
66
89
|
getOperatorCookie
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const env = require('../../../../../env');
|
|
2
2
|
|
|
3
3
|
const waiveApi = require('./waive.api');
|
|
4
|
-
const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
|
|
4
|
+
const { WaiveRequestModel, RetractRequestModel, WAIVER_REASONS } = require('../../models/waive/waive.model');
|
|
5
5
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
6
6
|
const util = require('../../utils/util');
|
|
7
|
+
const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
|
|
7
8
|
|
|
8
9
|
const { credentials } = env.getEnv();
|
|
9
10
|
const userTypes = require('../../../../../common/consts/userTypes');
|
|
@@ -91,8 +92,22 @@ const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
|
|
|
91
92
|
return attribute.auditId;
|
|
92
93
|
};
|
|
93
94
|
|
|
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
|
+
|
|
94
108
|
module.exports = {
|
|
95
109
|
waive,
|
|
110
|
+
waiveAll,
|
|
96
111
|
retract,
|
|
97
112
|
getWaiveModel,
|
|
98
113
|
getRetractModel,
|
|
@@ -46,6 +46,29 @@ const getAttributeNameByGap = function(record, policyName, gap) {
|
|
|
46
46
|
return attribute.limitname;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
const getAllWaivablePolicies = function(record) {
|
|
50
|
+
const waivable = [];
|
|
51
|
+
|
|
52
|
+
const policies = record.reviewbyAuditor;
|
|
53
|
+
for (const policy of policies) {
|
|
54
|
+
const {
|
|
55
|
+
insuranceName: policyName,
|
|
56
|
+
errorList: errorList
|
|
57
|
+
} = policy;
|
|
58
|
+
|
|
59
|
+
for (const error of errorList) {
|
|
60
|
+
if (error.warningStatus === 'POLICYERROR' && error.errorStatus === 'notIgnored') {
|
|
61
|
+
waivable.push({
|
|
62
|
+
policyName: policyName,
|
|
63
|
+
attributeName: error.limitname
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return waivable;
|
|
70
|
+
};
|
|
71
|
+
|
|
49
72
|
const getPolicyId = (policyName, requirement) => {
|
|
50
73
|
if (!policyName || policyName === 'Certificate of Insurance') {
|
|
51
74
|
return DEFAULT_POLICY_ID;
|
|
@@ -162,7 +185,8 @@ module.exports = {
|
|
|
162
185
|
getAuditorId,
|
|
163
186
|
getAttributeKey,
|
|
164
187
|
getAttributeNameByGap,
|
|
165
|
-
getWaiveReason
|
|
188
|
+
getWaiveReason,
|
|
189
|
+
getAllWaivablePolicies
|
|
166
190
|
};
|
|
167
191
|
|
|
168
192
|
const certificateEndorsmentsList = [
|