@getjones/test-infra 2.7.12 → 2.7.14
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/factory/records/records.js +1 -1
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +1 -15
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +33 -29
- package/src/saas/internal-api/compliance/models/overrideGap/override.gap.model.js +2 -2
- package/src/saas/internal-api/compliance/utils/auditUtil.js +5 -16
package/package.json
CHANGED
|
@@ -113,7 +113,7 @@ const prepareWaivedRecord = async (recordCompany, recordEmail, tabId, requiremen
|
|
|
113
113
|
const recordId = await prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context);
|
|
114
114
|
|
|
115
115
|
const { data: record } = await contractors.services.getContractorById(recordId, context);
|
|
116
|
-
await compliance.services.overrideGap.
|
|
116
|
+
await compliance.services.overrideGap.waiveAllGaps(record, context);
|
|
117
117
|
|
|
118
118
|
return recordId;
|
|
119
119
|
};
|
|
@@ -2,24 +2,10 @@ const requests = require('../../../../../common/requests/cookieAuth/requests');
|
|
|
2
2
|
const { backendUrl } = require('../../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
|
-
waive: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
|
|
6
|
-
retract: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
|
|
7
5
|
overrideGap: `${backendUrl}/saas/record/override-gap`,
|
|
8
6
|
retractOverride: `${backendUrl}/saas/record/retract-override`
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
const waive = async (contractorId, waiveRequestModel, context) => {
|
|
12
|
-
const status = waiveRequestModel.status;
|
|
13
|
-
delete waiveRequestModel.status;
|
|
14
|
-
return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status });
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const retract = async (contractorId, retractRequestModel, context) => {
|
|
18
|
-
const status = retractRequestModel.status;
|
|
19
|
-
delete retractRequestModel.status;
|
|
20
|
-
return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status });
|
|
21
|
-
};
|
|
22
|
-
|
|
23
9
|
const overrideGap = ({ overrideGapModel, isTestingBackwardCompatibility = false, context }) => {
|
|
24
10
|
const headers = {};
|
|
25
11
|
const params = { isTestingBackwardCompatibility };
|
|
@@ -30,4 +16,4 @@ const retractOverride = (retractModel, context) => {
|
|
|
30
16
|
return requests.postRequestHandler(Endpoints.retractOverride, retractModel, context);
|
|
31
17
|
};
|
|
32
18
|
|
|
33
|
-
module.exports = {
|
|
19
|
+
module.exports = { overrideGap, retractOverride };
|
|
@@ -11,16 +11,6 @@ const httpResponseStatusCodes = require('../../../../../common/httpResponseStatu
|
|
|
11
11
|
const { credentials } = env.getEnv();
|
|
12
12
|
const userTypes = require('../../../../../common/consts/userTypes');
|
|
13
13
|
|
|
14
|
-
const waive = (waiveRequestModel, context) => {
|
|
15
|
-
validateType(waiveRequestModel, OverrideGapModel);
|
|
16
|
-
return overrideGapApi.waive(waiveRequestModel.contractorId, waiveRequestModel, context);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const retract = (retractRequestModel, context) => {
|
|
20
|
-
validateType(retractRequestModel, RetractOverrideGapModel);
|
|
21
|
-
return overrideGapApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
14
|
const overrideGap = ({ overrideGapModel, isTestingBackwardCompatibility = false, context }) => {
|
|
25
15
|
validateType(overrideGapModel, OverrideGapModel);
|
|
26
16
|
return overrideGapApi.overrideGap({ overrideGapModel, isTestingBackwardCompatibility, context });
|
|
@@ -31,11 +21,11 @@ const retractOverride = (retractModel, context) => {
|
|
|
31
21
|
return overrideGapApi.retractOverride(retractModel, context);
|
|
32
22
|
};
|
|
33
23
|
|
|
34
|
-
const
|
|
24
|
+
const getOverrideGapModel = (
|
|
35
25
|
record,
|
|
36
26
|
policyName,
|
|
37
27
|
attributeName,
|
|
38
|
-
|
|
28
|
+
reason,
|
|
39
29
|
remarks,
|
|
40
30
|
{
|
|
41
31
|
userId,
|
|
@@ -45,19 +35,19 @@ const getWaiveModel = (
|
|
|
45
35
|
userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
|
|
46
36
|
userRole = userRole || userTypes.ICS;
|
|
47
37
|
|
|
48
|
-
const
|
|
38
|
+
const overrideGapModel = new OverrideGapModel({
|
|
49
39
|
contractorId: record.id,
|
|
50
40
|
auditId,
|
|
51
|
-
|
|
41
|
+
reason,
|
|
52
42
|
remarks,
|
|
53
43
|
userId,
|
|
54
44
|
userRole
|
|
55
45
|
});
|
|
56
46
|
|
|
57
|
-
return
|
|
47
|
+
return overrideGapModel;
|
|
58
48
|
};
|
|
59
49
|
|
|
60
|
-
const
|
|
50
|
+
const getOverrideGapModelByGap = (
|
|
61
51
|
record,
|
|
62
52
|
policyName,
|
|
63
53
|
gap,
|
|
@@ -69,7 +59,7 @@ const getWaiveModelByGap = (
|
|
|
69
59
|
} = {}) => {
|
|
70
60
|
const attributeName = auditUtil.getAttributeNameByGap(record, policyName, gap);
|
|
71
61
|
|
|
72
|
-
return
|
|
62
|
+
return getOverrideGapModel(record, policyName, attributeName, reason, note, { userId, userRole });
|
|
73
63
|
};
|
|
74
64
|
|
|
75
65
|
const getRetractModel = (record, policyName, attributeName) => {
|
|
@@ -104,26 +94,40 @@ const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
|
|
|
104
94
|
return attribute.auditId;
|
|
105
95
|
};
|
|
106
96
|
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
// PRIVATE METHOD - please refer to waiveAllGaps / acceptAllGaps according to your needs
|
|
98
|
+
const overrideAllGaps = async (record, context, { reason = OVERRIDE_GAP_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
|
|
99
|
+
const allOverriddenPolicies = auditUtil.getAllOverriddenGapPolicies(record, context);
|
|
109
100
|
|
|
110
|
-
for (const
|
|
111
|
-
const
|
|
112
|
-
const
|
|
101
|
+
for (const policy of allOverriddenPolicies) {
|
|
102
|
+
const overrideGapModel = getOverrideGapModel(record, policy.policyName, policy.attributeName, reason, note);
|
|
103
|
+
const overrideGapResponse = await overrideGap({ overrideGapModel, context });
|
|
113
104
|
|
|
114
|
-
if (
|
|
115
|
-
throw Error(`Failed to
|
|
105
|
+
if (overrideGapResponse.status !== httpResponseStatusCodes.OK) {
|
|
106
|
+
throw Error(`Failed to override gap ${policy.policyName} - ${policy.attributeName} for ${record.company}`);
|
|
116
107
|
}
|
|
117
108
|
}
|
|
118
109
|
};
|
|
119
110
|
|
|
111
|
+
const waiveAllGaps = async (record, context, { reason = OVERRIDE_GAP_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
|
|
112
|
+
const waivedReasons = new Set([OVERRIDE_GAP_REASONS.BUSINESS_DECISION, OVERRIDE_GAP_REASONS.EXECUTIVE_APPROVAL, OVERRIDE_GAP_REASONS.NO_EXPOSURE]);
|
|
113
|
+
|
|
114
|
+
if (!waivedReasons.has(reason)) {
|
|
115
|
+
throw Error(`Invalid waive reason ${reason} provided when trying to waive all gaps to waive`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await overrideAllGaps(record, context, { reason, note });
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const acceptAllGaps = async (record, context, { note = 'ACCEPTED AUTOMATICALLY' } = {}) => {
|
|
122
|
+
overrideAllGaps(record, context, { reason: OVERRIDE_GAP_REASONS.ACCEPT_NO_EXPOSURE, note });
|
|
123
|
+
};
|
|
124
|
+
|
|
120
125
|
module.exports = {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
getWaiveModel,
|
|
126
|
+
acceptAllGaps,
|
|
127
|
+
waiveAllGaps,
|
|
128
|
+
getOverrideGapModel,
|
|
125
129
|
getRetractModel,
|
|
126
|
-
|
|
130
|
+
getOverrideGapModelByGap,
|
|
127
131
|
overrideGap,
|
|
128
132
|
retractOverride
|
|
129
133
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
class OverrideGapModel {
|
|
2
2
|
constructor({
|
|
3
|
-
contractorId, auditId,
|
|
3
|
+
contractorId, auditId, reason, remarks, userId, userRole
|
|
4
4
|
}) {
|
|
5
5
|
this.auditorContractorId = auditId;
|
|
6
6
|
this.contractorId = contractorId;
|
|
7
|
-
this.
|
|
7
|
+
this.reason = reason;
|
|
8
8
|
this.remarks = remarks || '';
|
|
9
9
|
this.userId = userId;
|
|
10
10
|
this.userRole = userRole;
|
|
@@ -22,10 +22,6 @@ const getAttributeKey = attribute => {
|
|
|
22
22
|
return specialAttributes[attribute] || attribute;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const getWaiveReason = reason => {
|
|
26
|
-
return waiveReasons[reason] || reason;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
25
|
const getAttributeNameByGap = function(record, policyName, gap) {
|
|
30
26
|
const policy = record.reviewbyAuditor.find(contractorCoverage =>
|
|
31
27
|
contractorCoverage.insuranceName === policyName);
|
|
@@ -43,8 +39,8 @@ const getAttributeNameByGap = function(record, policyName, gap) {
|
|
|
43
39
|
return attribute.limitname;
|
|
44
40
|
};
|
|
45
41
|
|
|
46
|
-
const
|
|
47
|
-
const
|
|
42
|
+
const getAllOverriddenGapPolicies = function(record) {
|
|
43
|
+
const overridden = [];
|
|
48
44
|
|
|
49
45
|
const policies = record.reviewbyAuditor;
|
|
50
46
|
for (const policy of policies) {
|
|
@@ -55,7 +51,7 @@ const getAllWaivablePolicies = function(record) {
|
|
|
55
51
|
|
|
56
52
|
for (const error of errorList) {
|
|
57
53
|
if (error.warningStatus === 'POLICYERROR' && error.errorStatus === 'notIgnored') {
|
|
58
|
-
|
|
54
|
+
overridden.push({
|
|
59
55
|
policyName: policyName,
|
|
60
56
|
attributeName: error.limitname
|
|
61
57
|
});
|
|
@@ -63,7 +59,7 @@ const getAllWaivablePolicies = function(record) {
|
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
return
|
|
62
|
+
return overridden;
|
|
67
63
|
};
|
|
68
64
|
|
|
69
65
|
const getPolicyId = (policyName, requirement) => {
|
|
@@ -176,8 +172,7 @@ module.exports = {
|
|
|
176
172
|
createAuditEntity,
|
|
177
173
|
getAttributeKey,
|
|
178
174
|
getAttributeNameByGap,
|
|
179
|
-
|
|
180
|
-
getAllWaivablePolicies
|
|
175
|
+
getAllOverriddenGapPolicies
|
|
181
176
|
};
|
|
182
177
|
|
|
183
178
|
const certificateEndorsmentsList = [
|
|
@@ -214,9 +209,3 @@ const specialAttributes = {
|
|
|
214
209
|
'Umbrella': 'UMoccur'
|
|
215
210
|
}
|
|
216
211
|
};
|
|
217
|
-
|
|
218
|
-
const waiveReasons = {
|
|
219
|
-
'No Exposure': OVERRIDE_GAP_REASONS.NO_EXPOSURE,
|
|
220
|
-
'Business Decision': OVERRIDE_GAP_REASONS.BUSINESS_DECISION,
|
|
221
|
-
'Executive Approval': OVERRIDE_GAP_REASONS.EXECUTIVE_APPROVAL
|
|
222
|
-
};
|