@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
|
@@ -3,6 +3,7 @@ const { AuditRequestModel, AuditListParametersModel, AuditDatesModel } = require
|
|
|
3
3
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
4
4
|
const util = require('../../utils/util');
|
|
5
5
|
const dataTypeUtils = require('../../../../../common/utils/dataTypeUtils');
|
|
6
|
+
const { cloneObject } = require('../../../../../common/utils/objectUtils');
|
|
6
7
|
|
|
7
8
|
const audit = (auditRequestModel, context) => {
|
|
8
9
|
validateType(auditRequestModel, AuditRequestModel);
|
|
@@ -128,7 +129,7 @@ const auditRecord = async function(
|
|
|
128
129
|
const auditMetadata = await getAuditMetadata(auditorContext, accountId, projectId, requirementId, recordId);
|
|
129
130
|
|
|
130
131
|
const auditApiConfig = dataTypeUtils.isObject(auditConfig) ?
|
|
131
|
-
util.
|
|
132
|
+
util.parseAuditConfig(cloneObject(auditConfig)) :
|
|
132
133
|
auditConfig;
|
|
133
134
|
|
|
134
135
|
const auditEntities = await getAuditEntities(recordId, auditApiConfig, auditorContext);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
const env = require('../../../../../env');
|
|
2
|
+
|
|
1
3
|
const waiveApi = require('./waive.api');
|
|
2
4
|
const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
|
|
3
5
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
6
|
+
const util = require('../../utils/util');
|
|
7
|
+
|
|
8
|
+
const { credentials } = env.getEnv();
|
|
9
|
+
const userTypes = require('../../../../../common/consts/userTypes');
|
|
4
10
|
|
|
5
11
|
const waive = (waiveRequestModel, context) => {
|
|
6
12
|
validateType(waiveRequestModel, WaiveRequestModel);
|
|
@@ -12,4 +18,83 @@ const retract = (retractRequestModel, context) => {
|
|
|
12
18
|
return waiveApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
|
|
13
19
|
};
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
const getWaiveModel = (
|
|
22
|
+
record,
|
|
23
|
+
policyName,
|
|
24
|
+
attributeName,
|
|
25
|
+
waiverReason,
|
|
26
|
+
remarks,
|
|
27
|
+
{
|
|
28
|
+
userId,
|
|
29
|
+
userRole
|
|
30
|
+
} = {}) => {
|
|
31
|
+
const auditId = getPolicyAuditIdFromRecord(record, policyName, util.getAttributeKey(attributeName));
|
|
32
|
+
userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
|
|
33
|
+
userRole = userRole || userTypes.ICS;
|
|
34
|
+
|
|
35
|
+
const waiveModel = new WaiveRequestModel({
|
|
36
|
+
contractorId: record.id,
|
|
37
|
+
auditId,
|
|
38
|
+
waiverReason,
|
|
39
|
+
remarks,
|
|
40
|
+
userId,
|
|
41
|
+
userRole
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return waiveModel;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const getWaiveModelByGap = (
|
|
48
|
+
record,
|
|
49
|
+
policyName,
|
|
50
|
+
gap,
|
|
51
|
+
reason,
|
|
52
|
+
note,
|
|
53
|
+
{
|
|
54
|
+
userId,
|
|
55
|
+
userRole
|
|
56
|
+
} = {}) => {
|
|
57
|
+
const attributeName = util.getAttributeNameByGap(record, policyName, gap);
|
|
58
|
+
|
|
59
|
+
return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole });
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const getRetractModel = (record, policyName, attributeName) => {
|
|
63
|
+
const auditId = getPolicyAuditIdFromRecord(record, policyName, util.getAttributeKey(attributeName));
|
|
64
|
+
const userId = env.getSystemUserIdentity(credentials.superUser).id;
|
|
65
|
+
const userRole = userTypes.ICS;
|
|
66
|
+
|
|
67
|
+
const retractModel = new RetractRequestModel({
|
|
68
|
+
contractorId: record.id,
|
|
69
|
+
auditId,
|
|
70
|
+
userId,
|
|
71
|
+
userRole
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return retractModel;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
|
|
78
|
+
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
79
|
+
contractorCoverage.insuranceName === policyName);
|
|
80
|
+
|
|
81
|
+
if (!policy) {
|
|
82
|
+
throw new Error(`Policy name: ${policyName} don't exist in record`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const attribute = policy.errorList.find(error => error.limitname === attributeName);
|
|
86
|
+
|
|
87
|
+
if (!attribute) {
|
|
88
|
+
throw new Error(`Attribute name: ${attributeName} don't exist in record`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return attribute.auditId;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
waive,
|
|
96
|
+
retract,
|
|
97
|
+
getWaiveModel,
|
|
98
|
+
getRetractModel,
|
|
99
|
+
getWaiveModelByGap
|
|
100
|
+
};
|
|
@@ -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;
|
|
@@ -2,6 +2,8 @@ const { AUDIT_ENTITY_STATUSES, DEFAULT_POLICY_ID, VALID_SCORES } = require('../c
|
|
|
2
2
|
const { isObject, isArray } = require('../../../../common/utils/dataTypeUtils');
|
|
3
3
|
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
4
4
|
const auditModels = require('../models/audit/audit.model');
|
|
5
|
+
const waiveModels = require('../models/waive/waive.model');
|
|
6
|
+
|
|
5
7
|
const { getEnv, getSystemUserIdentity } = require('../../../../env');
|
|
6
8
|
const { credentials } = getEnv();
|
|
7
9
|
|
|
@@ -23,6 +25,27 @@ const getAttributeKey = attribute => {
|
|
|
23
25
|
return specialAttributes[attribute] || attribute;
|
|
24
26
|
};
|
|
25
27
|
|
|
28
|
+
const getWaiveReason = reason => {
|
|
29
|
+
return waiveReasons[reason] || reason;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getAttributeNameByGap = function(record, policyName, gap) {
|
|
33
|
+
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
34
|
+
contractorCoverage.insuranceName === policyName);
|
|
35
|
+
|
|
36
|
+
if (!policy) {
|
|
37
|
+
throw new Error(`Policy name ${policyName} don't exist in record`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const attribute = policy.errorList.find(error => error.errorHeadline === gap);
|
|
41
|
+
|
|
42
|
+
if (!attribute) {
|
|
43
|
+
throw new Error(`Gap ${gap} don't exist in record`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return attribute.limitname;
|
|
47
|
+
};
|
|
48
|
+
|
|
26
49
|
const getPolicyId = (policyName, requirement) => {
|
|
27
50
|
if (!policyName || policyName === 'Certificate of Insurance') {
|
|
28
51
|
return DEFAULT_POLICY_ID;
|
|
@@ -40,7 +63,7 @@ const getPolicyId = (policyName, requirement) => {
|
|
|
40
63
|
return policy.id;
|
|
41
64
|
};
|
|
42
65
|
|
|
43
|
-
const
|
|
66
|
+
const parseAuditConfig = function(config) {
|
|
44
67
|
const auditDataArr = [];
|
|
45
68
|
for (const field in config) {
|
|
46
69
|
if (!config.hasOwnProperty(field)) {
|
|
@@ -68,7 +91,7 @@ const getParsedConfig = function(config) {
|
|
|
68
91
|
}
|
|
69
92
|
|
|
70
93
|
if (isArray(attributes[attributeName])) {
|
|
71
|
-
selection.status = AUDIT_ENTITY_STATUSES[
|
|
94
|
+
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName][0]).toUpperCase()];
|
|
72
95
|
selection.value = attributes[attributeName][1].replace('$', emptyValue);
|
|
73
96
|
} else {
|
|
74
97
|
// Special statuses switch
|
|
@@ -80,7 +103,7 @@ const getParsedConfig = function(config) {
|
|
|
80
103
|
selection.status = AUDIT_ENTITY_STATUSES.YES;
|
|
81
104
|
break;
|
|
82
105
|
default:
|
|
83
|
-
selection.status = AUDIT_ENTITY_STATUSES[
|
|
106
|
+
selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName]).toUpperCase()];
|
|
84
107
|
break;
|
|
85
108
|
}
|
|
86
109
|
|
|
@@ -98,10 +121,10 @@ const getParsedConfig = function(config) {
|
|
|
98
121
|
certificateEndorsmentsList.includes(field) && (selection.policyName = field);
|
|
99
122
|
|
|
100
123
|
if (isArray(config[field])) {
|
|
101
|
-
selection.status = AUDIT_ENTITY_STATUSES[
|
|
124
|
+
selection.status = AUDIT_ENTITY_STATUSES[(config[field][0]).toUpperCase()];
|
|
102
125
|
selection.value = config[field][1]; // Ok to be undefined
|
|
103
126
|
} else {
|
|
104
|
-
selection.status = AUDIT_ENTITY_STATUSES[
|
|
127
|
+
selection.status = AUDIT_ENTITY_STATUSES[(config[field]).toUpperCase()] || AUDIT_ENTITY_STATUSES.YES;
|
|
105
128
|
selection.value = getValueBySelection(config[field]);
|
|
106
129
|
}
|
|
107
130
|
|
|
@@ -133,10 +156,13 @@ const getAuditorId = () => {
|
|
|
133
156
|
};
|
|
134
157
|
|
|
135
158
|
module.exports = {
|
|
136
|
-
|
|
159
|
+
parseAuditConfig,
|
|
137
160
|
getPolicyId,
|
|
138
161
|
createAuditEntity,
|
|
139
|
-
getAuditorId
|
|
162
|
+
getAuditorId,
|
|
163
|
+
getAttributeKey,
|
|
164
|
+
getAttributeNameByGap,
|
|
165
|
+
getWaiveReason
|
|
140
166
|
};
|
|
141
167
|
|
|
142
168
|
const certificateEndorsmentsList = [
|
|
@@ -173,3 +199,9 @@ const specialAttributes = {
|
|
|
173
199
|
'Umbrella': 'UMoccur'
|
|
174
200
|
}
|
|
175
201
|
};
|
|
202
|
+
|
|
203
|
+
const waiveReasons = {
|
|
204
|
+
'No Exposure': waiveModels.WAIVER_REASONS.NO_EXPOSURE,
|
|
205
|
+
'Business Decision': waiveModels.WAIVER_REASONS.BUSINESS_DECISION,
|
|
206
|
+
'Executive Approval': waiveModels.WAIVER_REASONS.EXECUTIVE_APPROVAL
|
|
207
|
+
};
|
|
@@ -3,6 +3,7 @@ const { CreateContractorModel } = require('../models/create.contractor.model');
|
|
|
3
3
|
const { RequestModel } = require('../../requests/models/edit.request.model');
|
|
4
4
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
5
5
|
const { RecordModifyDateVerificationModel } = require('../models/verification.contractor.model');
|
|
6
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
6
7
|
|
|
7
8
|
const createContractor = async (createContractorModel, context) => {
|
|
8
9
|
validateType(createContractorModel, CreateContractorModel);
|
|
@@ -25,10 +26,6 @@ const getRecordHistory = (contractorId, context) => {
|
|
|
25
26
|
return contractorsAPI.getRecordHistory(contractorId, context);
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
const deleteByContractorId = (contractorId, context) => {
|
|
29
|
-
return contractorsAPI.deleteByContractorId(contractorId, context);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
29
|
const archiveByContractorId = (contractorId, context) => {
|
|
33
30
|
return contractorsAPI.archiveByContractorId(contractorId, context);
|
|
34
31
|
};
|
|
@@ -99,13 +96,38 @@ const unmuteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
|
99
96
|
return contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
100
97
|
};
|
|
101
98
|
|
|
99
|
+
const deleteByContractorId = (contractorId, context) => {
|
|
100
|
+
return contractorsAPI.deleteByContractorId(contractorId, context);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const deleteAllRecordsInAccount = async (accountId, context, { activationStatus } = {}) => {
|
|
104
|
+
const { data: existingRecords } = await getContractorsByAccountId(accountId, context, activationStatus);
|
|
105
|
+
|
|
106
|
+
if (!existingRecords.length) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const failed = [];
|
|
111
|
+
for (const record of existingRecords) {
|
|
112
|
+
const response = await deleteByContractorId(record.id, context);
|
|
113
|
+
|
|
114
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
115
|
+
console.error('Failed to delete record: ', record.company);
|
|
116
|
+
failed.push(response);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (failed.length) {
|
|
121
|
+
throw Error(`Failed to delete ${failed.length} of ${existingRecords.length} records in account. Failed with status: ${ failed[0].status }`);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
102
125
|
module.exports = {
|
|
103
126
|
createContractor,
|
|
104
127
|
changeRequirement,
|
|
105
128
|
getContractorsByAccountId,
|
|
106
129
|
getContractorById,
|
|
107
130
|
getRecordHistory,
|
|
108
|
-
deleteByContractorId,
|
|
109
131
|
archiveByContractorId,
|
|
110
132
|
restoreContractor,
|
|
111
133
|
editContractor,
|
|
@@ -119,5 +141,7 @@ module.exports = {
|
|
|
119
141
|
requestNewCoiExpired,
|
|
120
142
|
resendInvitation,
|
|
121
143
|
muteNotifications,
|
|
122
|
-
unmuteNotifications
|
|
144
|
+
unmuteNotifications,
|
|
145
|
+
deleteByContractorId,
|
|
146
|
+
deleteAllRecordsInAccount
|
|
123
147
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const requestsAPI = require('./requests.api');
|
|
2
|
-
const { CreateRequestModel } = require('../models/create.request.model');
|
|
2
|
+
const { CreateRequestModel, ContractorInfo } = require('../models/create.request.model');
|
|
3
3
|
const { RequestModel } = require('../models/edit.request.model');
|
|
4
4
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
5
5
|
|
|
@@ -36,6 +36,37 @@ const getRequestsByAccountId = (accountId, context, activationStatus) => {
|
|
|
36
36
|
return requestsAPI.getRequestsByAccountId(accountId, context, params);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
const getCreateRequestModel = (requirementId, contractor, { tabId, publicLink, sendMail } = {}) => {
|
|
40
|
+
const { recordType, email, companyName, additionalEmails } = contractor;
|
|
41
|
+
const contractorInfoModel = new ContractorInfo(recordType, email, companyName, additionalEmails);
|
|
42
|
+
|
|
43
|
+
return new CreateRequestModel(
|
|
44
|
+
requirementId,
|
|
45
|
+
contractor.inviterEmail,
|
|
46
|
+
contractorInfoModel,
|
|
47
|
+
{
|
|
48
|
+
tabId,
|
|
49
|
+
publicLink,
|
|
50
|
+
sendMail
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const getOrCreateRequest = async (context, tabId, requirementId, contractor, activationStatus, { sendMail } = {}) => {
|
|
56
|
+
const { data: existingRequests } = await getRequestsByTabId(tabId, context, activationStatus);
|
|
57
|
+
|
|
58
|
+
const filteredRequests = Array.isArray(existingRequests) ? existingRequests.filter(({ record }) =>
|
|
59
|
+
record.company === contractor.companyName) : [];
|
|
60
|
+
|
|
61
|
+
if (filteredRequests.length) {
|
|
62
|
+
return filteredRequests[0];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const createContractorModel = getCreateRequestModel(requirementId, contractor, { tabId, sendMail });
|
|
66
|
+
const createContractorResponse = await createRequest(createContractorModel, context);
|
|
67
|
+
return createContractorResponse.data;
|
|
68
|
+
};
|
|
69
|
+
|
|
39
70
|
const requestsGlobalSearch = (projectId, searchWord, context) => {
|
|
40
71
|
return requestsAPI.requestsGlobalSearch(projectId, searchWord, context);
|
|
41
72
|
};
|
|
@@ -47,5 +78,7 @@ module.exports = {
|
|
|
47
78
|
getRequestsByTabId,
|
|
48
79
|
getReqeustById,
|
|
49
80
|
getRequestsByAccountId,
|
|
81
|
+
getOrCreateRequest,
|
|
82
|
+
getCreateRequestModel,
|
|
50
83
|
requestsGlobalSearch
|
|
51
84
|
};
|