@getjones/test-infra 2.6.0 → 2.6.2
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 -2
- package/src/common/consts/userTypes.js +5 -0
- package/src/common/utils/objectUtils.js +1 -3
- package/src/common/utils/timeUtils.js +2 -2
- package/src/defaults/configs/auditConfigs.js +6 -6
- package/src/factory/index.js +5 -0
- package/src/factory/records/records.js +105 -0
- package/src/index.js +3 -2
- package/src/resources/coi/coi.pdf +0 -0
- package/src/resources/coi/realCoi.pdf +5617 -20
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +3 -5
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +2 -1
- package/src/saas/internal-api/compliance/api/waive/waive.service.js +86 -1
- 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 +39 -7
- package/src/saas/internal-api/contractors/api/contractors.service.js +30 -6
- package/src/saas/internal-api/requests/api/requests.service.js +34 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getjones/test-infra",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Providing internal and openapi interface",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"chai": "^4.3.4",
|
|
16
16
|
"dotenv": "^8.2.0",
|
|
17
17
|
"enum": "^3.0.4",
|
|
18
|
-
"lodash": "^4.17.21",
|
|
19
18
|
"mocha": "^8.3.2"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
@@ -36,8 +36,8 @@ const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(for
|
|
|
36
36
|
const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
|
|
37
37
|
const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
|
|
38
38
|
const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
|
|
39
|
-
const getOneWeekAgoDate =
|
|
40
|
-
const getOneWeekAheadDate =
|
|
39
|
+
const getOneWeekAgoDate = () => moment().utc().subtract(7, peroids.days).format(formats.dayMonthYear);
|
|
40
|
+
const getOneWeekAheadDate = () => moment().utc().add(7, peroids.days).format(formats.dayMonthYear);
|
|
41
41
|
|
|
42
42
|
const getLogTimestamp = () => {
|
|
43
43
|
return moment().format(formats.logTimeStampFormat);
|
|
@@ -35,15 +35,15 @@ const policySelections = {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const getCompliantAuditConfig = ({ glPolicyNumber = DEFAULT_POLICY_NUMBER } = {}) => {
|
|
38
|
-
|
|
39
|
-
[certificateIssueDate]: DEFAULT_POLICY_DATE
|
|
38
|
+
const config = cloneObject({
|
|
39
|
+
[certificateIssueDate]: `${DEFAULT_POLICY_DATE}`,
|
|
40
40
|
[insuredAddress]: policySelections.YES,
|
|
41
41
|
[insuredName]: policySelections.YES,
|
|
42
42
|
[amScore]: DEFAULT_AM_SCORE,
|
|
43
43
|
[generalLiability]: {
|
|
44
44
|
[coverageExists]: policySelections.YES,
|
|
45
45
|
[policyNumber]: glPolicyNumber,
|
|
46
|
-
[policyExpired]: DEFAULT_POLICY_DATE
|
|
46
|
+
[policyExpired]: `${DEFAULT_POLICY_DATE}`,
|
|
47
47
|
[perOccurrence]: policySelections.YES,
|
|
48
48
|
[perPolicy]: policySelections.YES,
|
|
49
49
|
[perProject]: policySelections.YES,
|
|
@@ -54,6 +54,7 @@ const getCompliantAuditConfig = ({ glPolicyNumber = DEFAULT_POLICY_NUMBER } = {}
|
|
|
54
54
|
[coiAuthentication]: policySelections.YES,
|
|
55
55
|
[signature]: policySelections.YES
|
|
56
56
|
});
|
|
57
|
+
return config;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
const getNotCompliantConfig = ({ glPolicyNumber } = {}) => {
|
|
@@ -65,14 +66,13 @@ const getNotCompliantConfig = ({ glPolicyNumber } = {}) => {
|
|
|
65
66
|
|
|
66
67
|
const getAboutExpiredConfig = ({ glPolicyNumber } = {}) => {
|
|
67
68
|
const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
|
|
68
|
-
compliantConfig[generalLiability][policyExpired] = getOneWeekAheadDate()
|
|
69
|
-
|
|
69
|
+
compliantConfig[generalLiability][policyExpired] = `${getOneWeekAheadDate()}`;
|
|
70
70
|
return compliantConfig;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
const getExpiredConfig = ({ glPolicyNumber } = {}) => {
|
|
74
74
|
const compliantConfig = getCompliantAuditConfig({ glPolicyNumber });
|
|
75
|
-
compliantConfig[generalLiability][policyExpired] = getOneWeekAgoDate()
|
|
75
|
+
compliantConfig[generalLiability][policyExpired] = `${getOneWeekAgoDate()}`;
|
|
76
76
|
|
|
77
77
|
return compliantConfig;
|
|
78
78
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const requests = require('../../saas/internal-api/requests');
|
|
2
|
+
const { credentials } = require('../../../../../src/env');
|
|
3
|
+
const coi = require('../../saas/internal-api/coi');
|
|
4
|
+
const compliance = require('../../saas/internal-api/compliance');
|
|
5
|
+
const auth = require('../../saas/internal-api/auth');
|
|
6
|
+
const auditConfigs = require('../../defaults/configs/auditConfigs');
|
|
7
|
+
const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
|
|
8
|
+
const timeUtils = require('../../common/utils/timeUtils');
|
|
9
|
+
|
|
10
|
+
const filePath = 'src/resources/coi/coi.pdf';
|
|
11
|
+
const complianceStatuses = {
|
|
12
|
+
complaint: 'complaint',
|
|
13
|
+
notCompliant: 'notCompliant',
|
|
14
|
+
expired: 'expired',
|
|
15
|
+
aboutToExpired: 'aboutToExpired'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context) => {
|
|
19
|
+
const requestData = await requests.services.getOrCreateRequest(
|
|
20
|
+
context,
|
|
21
|
+
tabId,
|
|
22
|
+
requirementId,
|
|
23
|
+
{
|
|
24
|
+
inviterEmail: credentials.superUser,
|
|
25
|
+
email: recordEmail,
|
|
26
|
+
companyName: recordCompany
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (!(requestData && requestData.id)) {
|
|
31
|
+
throw Error(`Failed to create record ${record.company}\n`, requestData);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const accountId = requestData.record.userId;
|
|
35
|
+
const projectId = requestData.projectInfo.projectId;
|
|
36
|
+
|
|
37
|
+
const coiUpload = await coi.utils.uploadCoi(
|
|
38
|
+
requestData.id,
|
|
39
|
+
filePath,
|
|
40
|
+
uploaderType = coi.consts.UPLOADER_TYPES.ICS,
|
|
41
|
+
uploaderEmail = credentials.superUser
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (!(coiUpload && coiUpload.name)) {
|
|
45
|
+
throw Error(`Failed to upload COI for record ${record.company}\n`, coiUpload);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const auditorContext = await auth.services.getAuditorCookie();
|
|
49
|
+
|
|
50
|
+
let auditConfig;
|
|
51
|
+
switch (status) {
|
|
52
|
+
case complianceStatuses.notCompliant:
|
|
53
|
+
auditConfig = auditConfigs.getNotCompliantConfig();
|
|
54
|
+
break;
|
|
55
|
+
case complianceStatuses.expired:
|
|
56
|
+
auditConfig = auditConfigs.getExpiredConfig();
|
|
57
|
+
break;
|
|
58
|
+
case complianceStatuses.aboutToExpired:
|
|
59
|
+
auditConfig = auditConfigs.getAboutExpiredConfig();
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
auditConfig = auditConfigs.getCompliantAuditConfig();
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let auditResponse, retries = 5;
|
|
67
|
+
do {
|
|
68
|
+
await timeUtils.waitFor(1).seconds;
|
|
69
|
+
auditResponse = await compliance.services.audit.auditRecord(
|
|
70
|
+
auditorContext,
|
|
71
|
+
accountId,
|
|
72
|
+
projectId,
|
|
73
|
+
record.requirementId,
|
|
74
|
+
requestData.id,
|
|
75
|
+
auditConfig
|
|
76
|
+
);
|
|
77
|
+
} while (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT && retries--);
|
|
78
|
+
|
|
79
|
+
if (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
80
|
+
throw Error(`Failed to audit record ${record.company}\n`, auditResponse);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const prepareCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
85
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.complaint, tabId, requirementId, context);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const prepareNotCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
89
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const prepareExpiredRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
93
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.expired, tabId, requirementId, context);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const prepareAboutToExpiredRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
97
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.aboutToExpired, tabId, requirementId, context);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
module.exports = {
|
|
101
|
+
prepareCompliantRecord,
|
|
102
|
+
prepareNotCompliantRecord,
|
|
103
|
+
prepareExpiredRecord,
|
|
104
|
+
prepareAboutToExpiredRecord
|
|
105
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const env = require('./env');
|
|
2
|
-
|
|
3
2
|
const init = conf => {
|
|
4
3
|
env.init(conf);
|
|
5
4
|
const internalAPI = getInternalAPI();
|
|
@@ -9,6 +8,7 @@ const init = conf => {
|
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
const getInternalAPI = () => {
|
|
11
|
+
const factory = require('./factory');
|
|
12
12
|
const defaults = require('./defaults');
|
|
13
13
|
const auth = require('./saas/internal-api/auth');
|
|
14
14
|
const accounts = require('./saas/internal-api/accounts');
|
|
@@ -54,7 +54,8 @@ const getInternalAPI = () => {
|
|
|
54
54
|
vendorProfile,
|
|
55
55
|
serviceArea,
|
|
56
56
|
threadScheduler,
|
|
57
|
-
dbEmails
|
|
57
|
+
dbEmails,
|
|
58
|
+
factory
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
return internalAPI;
|
|
Binary file
|