@getjones/test-infra 2.8.8 → 2.8.9
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/consts/dashboardCharts.js +1 -2
- package/src/common/utils/complianceUtil.js +28 -1
- package/src/factory/globalRecord/globalRecord.js +70 -0
- package/src/factory/index.js +3 -2
- package/src/factory/records/records.js +16 -30
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +2 -20
- package/src/saas/internal-api/dbEmails/consts/consts.js +2 -0
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +33 -20
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +31 -20
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +18 -1
- package/src/saas/internal-api/globalRecord/utils/util.js +13 -0
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const chartTypes = {
|
|
2
2
|
requiringAttention: 'requiringAttention',
|
|
3
3
|
expirationDatePerMonth: 'expirationDatePerMonth',
|
|
4
|
-
waivedByRequirement: 'waivedByRequirement'
|
|
5
|
-
notCompliantForRequirement: 'notCompliantForRequirement'
|
|
4
|
+
waivedByRequirement: 'waivedByRequirement'
|
|
6
5
|
};
|
|
7
6
|
const sortBy = {
|
|
8
7
|
companyName: 'SORT_BY_COMPANYNAME',
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
const { getEnv, getSystemUserIdentity } = require('../../env');
|
|
2
|
+
const auditConfigs = require('../../defaults/configs/auditConfigs');
|
|
3
|
+
|
|
2
4
|
const { credentials } = getEnv();
|
|
3
5
|
|
|
4
6
|
const auditApi = require('../../saas/internal-api/compliance/api/audit/audit.api');
|
|
5
7
|
|
|
8
|
+
const complianceStatuses = {
|
|
9
|
+
complaint: 'complaint',
|
|
10
|
+
notCompliant: 'notCompliant',
|
|
11
|
+
expired: 'expired',
|
|
12
|
+
aboutToExpired: 'aboutToExpired',
|
|
13
|
+
awaitingNewCoi: 'awaitingNewCoi'
|
|
14
|
+
};
|
|
15
|
+
|
|
6
16
|
const isReaudit = (contractorId, context) => {
|
|
7
17
|
return auditApi.isReaudit(contractorId, context);
|
|
8
18
|
};
|
|
@@ -51,6 +61,23 @@ const getAuditMetadata = async (
|
|
|
51
61
|
return metadata;
|
|
52
62
|
};
|
|
53
63
|
|
|
64
|
+
const getAuditConfigByStatus = (status, { glPolicyNumber } = {}) => {
|
|
65
|
+
switch (status) {
|
|
66
|
+
case complianceStatuses.notCompliant:
|
|
67
|
+
case complianceStatuses.awaitingNewCoi:
|
|
68
|
+
return auditConfigs.getNotCompliantConfig({ glPolicyNumber });
|
|
69
|
+
case complianceStatuses.expired:
|
|
70
|
+
return auditConfigs.getExpiredConfig({ glPolicyNumber });
|
|
71
|
+
case complianceStatuses.aboutToExpired:
|
|
72
|
+
return auditConfigs.getAboutExpiredConfig({ glPolicyNumber });
|
|
73
|
+
default:
|
|
74
|
+
return auditConfigs.getCompliantAuditConfig({ glPolicyNumber });
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
54
78
|
module.exports = {
|
|
55
|
-
getAuditMetadata
|
|
79
|
+
getAuditMetadata,
|
|
80
|
+
isReaudit,
|
|
81
|
+
getAuditConfigByStatus,
|
|
82
|
+
complianceStatuses
|
|
56
83
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const auth = require('../../saas/internal-api/auth');
|
|
2
|
+
const compliance = require('../../saas/internal-api/compliance');
|
|
3
|
+
const requests = require('../../saas/internal-api/requests');
|
|
4
|
+
const globalRecord = require('../../saas/internal-api/globalRecord');
|
|
5
|
+
|
|
6
|
+
const { complianceStatuses, getAuditConfigByStatus } = require('../../common/utils/complianceUtil');
|
|
7
|
+
const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
|
|
8
|
+
const timeUtils = require('../../common/utils/timeUtils');
|
|
9
|
+
|
|
10
|
+
const preparePublishGlobalRecord = async (recordId, tabId, status, glPolicyNumber, threadName, primaryEmail, context) => {
|
|
11
|
+
const requestResponse = await requests.services.getRequestFromTabByRecordId(recordId, tabId, context);
|
|
12
|
+
|
|
13
|
+
if (!(requestResponse && requestResponse.id)) {
|
|
14
|
+
throw Error(`Failed to create record ${recordCompany}\n${requestData}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const accountId = requestResponse.record.userId;
|
|
18
|
+
const projectId = requestResponse.projectInfo.projectId;
|
|
19
|
+
const requirementId = requestResponse.record.requirementId;
|
|
20
|
+
|
|
21
|
+
const auditorContext = await auth.services.getAuditorCookie();
|
|
22
|
+
|
|
23
|
+
const auditConfig = getAuditConfigByStatus(status, { glPolicyNumber });
|
|
24
|
+
|
|
25
|
+
let auditResponse, retries = 5;
|
|
26
|
+
do {
|
|
27
|
+
await timeUtils.waitFor(1).seconds;
|
|
28
|
+
auditResponse = await compliance.services.audit.auditRecord(
|
|
29
|
+
auditorContext,
|
|
30
|
+
accountId,
|
|
31
|
+
projectId,
|
|
32
|
+
requirementId,
|
|
33
|
+
recordId,
|
|
34
|
+
auditConfig
|
|
35
|
+
);
|
|
36
|
+
} while (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT && retries--);
|
|
37
|
+
|
|
38
|
+
if (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
39
|
+
throw Error(`Failed to audit record ${recordCompany}\n${auditResponse}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const operatorContext = await auth.services.getOperatorCookie();
|
|
43
|
+
|
|
44
|
+
const { data: newGlobalByGlNumber } = await globalRecord.services.getGlobalRecordByPolicyNumber(glPolicyNumber);
|
|
45
|
+
const globalRecordId = newGlobalByGlNumber[0]._id;
|
|
46
|
+
|
|
47
|
+
const globalConfig = globalRecord.utils.createPublishGlobalConfig(threadName, globalRecordId, primaryEmail);
|
|
48
|
+
const publishGlobalRecordModel = globalRecord.utils.createGlobalRecordModel(globalConfig);
|
|
49
|
+
|
|
50
|
+
const { data: publishResponseDetails } = await globalRecord.services.publishGlobalRecord(publishGlobalRecordModel, operatorContext);
|
|
51
|
+
|
|
52
|
+
if (publishResponseDetails.status !== 'Published') {
|
|
53
|
+
throw Error(`Failed to publish global record with id ${globalRecordId}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return publishResponseDetails;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const prepareCompliantGlobalRecord = (recordId, tabId, glPolicyNumber, threadName, primaryEmail, context) => {
|
|
60
|
+
return preparePublishGlobalRecord(recordId, tabId, complianceStatuses.complaint, glPolicyNumber, threadName, primaryEmail, context);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const prepareNotCompliantGlobalRecord = (recordId, tabId, glPolicyNumber, threadName, primaryEmail, context) => {
|
|
64
|
+
return preparePublishGlobalRecord(recordId, tabId, complianceStatuses.notCompliant, glPolicyNumber, threadName, primaryEmail, context);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
prepareCompliantGlobalRecord,
|
|
69
|
+
prepareNotCompliantGlobalRecord
|
|
70
|
+
};
|
package/src/factory/index.js
CHANGED
|
@@ -9,21 +9,13 @@ const compliance = require('../../saas/internal-api/compliance');
|
|
|
9
9
|
const contractors = require('../../saas/internal-api/contractors');
|
|
10
10
|
const requests = require('../../saas/internal-api/requests');
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const { complianceStatuses, getAuditConfigByStatus } = require('../../common/utils/complianceUtil');
|
|
13
13
|
const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
|
|
14
14
|
const timeUtils = require('../../common/utils/timeUtils');
|
|
15
15
|
|
|
16
16
|
const filePath = path.join(__dirname, '../../resources/coi/coi.pdf');
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
complaint: 'complaint',
|
|
20
|
-
notCompliant: 'notCompliant',
|
|
21
|
-
expired: 'expired',
|
|
22
|
-
aboutToExpired: 'aboutToExpired',
|
|
23
|
-
awaitingNewCoi: 'awaitingNewCoi'
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context) => {
|
|
18
|
+
const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirementId, context, { shouldSendNotificationToPM = false } = {}) => {
|
|
27
19
|
const requestData = await requests.services.getOrCreateRequest(
|
|
28
20
|
context,
|
|
29
21
|
tabId,
|
|
@@ -54,24 +46,13 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
54
46
|
throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
|
|
55
47
|
}
|
|
56
48
|
|
|
49
|
+
if (complianceStatuses.underReview === status) {
|
|
50
|
+
return recordId;
|
|
51
|
+
}
|
|
52
|
+
|
|
57
53
|
const auditorContext = await auth.services.getAuditorCookie();
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
switch (status) {
|
|
61
|
-
case complianceStatuses.notCompliant:
|
|
62
|
-
case complianceStatuses.awaitingNewCoi:
|
|
63
|
-
auditConfig = auditConfigs.getNotCompliantConfig();
|
|
64
|
-
break;
|
|
65
|
-
case complianceStatuses.expired:
|
|
66
|
-
auditConfig = auditConfigs.getExpiredConfig();
|
|
67
|
-
break;
|
|
68
|
-
case complianceStatuses.aboutToExpired:
|
|
69
|
-
auditConfig = auditConfigs.getAboutExpiredConfig();
|
|
70
|
-
break;
|
|
71
|
-
default:
|
|
72
|
-
auditConfig = auditConfigs.getCompliantAuditConfig();
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
55
|
+
const auditConfig = getAuditConfigByStatus(status);
|
|
75
56
|
|
|
76
57
|
let auditResponse, retries = 5;
|
|
77
58
|
do {
|
|
@@ -82,7 +63,8 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
|
|
|
82
63
|
projectId,
|
|
83
64
|
requirementId,
|
|
84
65
|
recordId,
|
|
85
|
-
auditConfig
|
|
66
|
+
auditConfig,
|
|
67
|
+
{ shouldSendNotificationToPM }
|
|
86
68
|
);
|
|
87
69
|
} while (auditResponse.status !== httpResponseStatusCodes.NO_CONTENT && retries--);
|
|
88
70
|
|
|
@@ -97,8 +79,8 @@ const prepareCompliantRecord = (recordCompany, recordEmail, tabId, requirementId
|
|
|
97
79
|
return prepareRecord(recordCompany, recordEmail, complianceStatuses.complaint, tabId, requirementId, context);
|
|
98
80
|
};
|
|
99
81
|
|
|
100
|
-
const prepareNotCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
101
|
-
return prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context);
|
|
82
|
+
const prepareNotCompliantRecord = (recordCompany, recordEmail, tabId, requirementId, context, { shouldSendNotificationToPM = false } = {}) => {
|
|
83
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.notCompliant, tabId, requirementId, context, { shouldSendNotificationToPM });
|
|
102
84
|
};
|
|
103
85
|
|
|
104
86
|
const prepareExpiredRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
@@ -131,6 +113,9 @@ const prepareAwaitingNewCoiRecord = async (recordCompany, recordEmail, tabId, re
|
|
|
131
113
|
|
|
132
114
|
return recordId;
|
|
133
115
|
};
|
|
116
|
+
const prepareUnderReviewRecord = (recordCompany, recordEmail, tabId, requirementId, context) => {
|
|
117
|
+
return prepareRecord(recordCompany, recordEmail, complianceStatuses.underReview, tabId, requirementId, context);
|
|
118
|
+
};
|
|
134
119
|
|
|
135
120
|
module.exports = {
|
|
136
121
|
prepareCompliantRecord,
|
|
@@ -138,5 +123,6 @@ module.exports = {
|
|
|
138
123
|
prepareExpiredRecord,
|
|
139
124
|
prepareWaivedRecord,
|
|
140
125
|
prepareAboutToExpiredRecord,
|
|
141
|
-
prepareAwaitingNewCoiRecord
|
|
126
|
+
prepareAwaitingNewCoiRecord,
|
|
127
|
+
prepareUnderReviewRecord
|
|
142
128
|
};
|
|
@@ -102,13 +102,12 @@ const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
|
|
|
102
102
|
return attribute.auditId;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
const overrideAll = async (record, reason, context, { note = 'OVERRIDDEN AUTOMATICALLY' } = {}) => {
|
|
105
|
+
const waiveAll = async (record, context, { reason = WAIVER_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
|
|
107
106
|
const allWaivablePolicies = auditUtil.getAllWaivablePolicies(record, context);
|
|
108
107
|
|
|
109
108
|
for (const waivable of allWaivablePolicies) {
|
|
110
109
|
const waiveModel = getWaiveModel(record, waivable.policyName, waivable.attributeName, reason, note);
|
|
111
|
-
const waiveResponse = await
|
|
110
|
+
const waiveResponse = await waive(waiveModel, context);
|
|
112
111
|
|
|
113
112
|
if (waiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
114
113
|
throw Error(`Failed to waive ${waivable.policyName} - ${waivable.attributeName} for ${record.company}`);
|
|
@@ -116,26 +115,9 @@ const overrideAll = async (record, reason, context, { note = 'OVERRIDDEN AUTOMAT
|
|
|
116
115
|
}
|
|
117
116
|
};
|
|
118
117
|
|
|
119
|
-
const waiveAll = async (record, context, { reason = WAIVER_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
|
|
120
|
-
if (reason === WAIVER_REASONS.ACCEPT_NO_EXPOSURE) {
|
|
121
|
-
throw Error('Invalid override gap reason to waive');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
await overrideAll(record, reason, context, { note });
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const acceptAll = async (record, context, { reason = WAIVER_REASONS.ACCEPT_NO_EXPOSURE, note = 'ACCEPTED AUTOMATICALLY' } = {}) => {
|
|
128
|
-
if (reason !== WAIVER_REASONS.ACCEPT_NO_EXPOSURE) {
|
|
129
|
-
throw Error('Invalid override gap reason to accept');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
await overrideAll(record, reason, context, { note });
|
|
133
|
-
};
|
|
134
|
-
|
|
135
118
|
module.exports = {
|
|
136
119
|
waive,
|
|
137
120
|
waiveAll,
|
|
138
|
-
acceptAll,
|
|
139
121
|
retract,
|
|
140
122
|
getWaiveModel,
|
|
141
123
|
getRetractModel,
|
|
@@ -23,9 +23,11 @@ const EMAIL_SUBJECT = {
|
|
|
23
23
|
notCompliant: ({ recordCompanyName, requesterName }) => `Please Review COI Gaps - ${recordCompanyName} (${requesterName})`,
|
|
24
24
|
wrongCoi: ({ recordCompanyName, requesterName }) => `Incorrect File Submission - COI Still Required for ${recordCompanyName} - ${requesterName}`,
|
|
25
25
|
sendGaps: ({ requesterName }) => `New Insurance Docs Required for ${requesterName}`, //doesn't includes text for guest or tenant
|
|
26
|
+
sendGapsRecordFullName: ({ requesterName, recordFirstName, recordLastName }) => `New Insurance Docs Required for ${requesterName} - ${recordFirstName} ${recordLastName}`,
|
|
26
27
|
requestNewCoiExpired: ({ recordCompanyName }) => `${recordCompanyName}'s COI is`,
|
|
27
28
|
firstReminder: ({ requesterName }) => `We are still awaiting the Insurance Docs for ${requesterName}`,
|
|
28
29
|
secondReminder: ({ requesterName }) => `We are still awaiting the Insurance Docs for ${requesterName}`,
|
|
30
|
+
secondReminderAccountRequirement: ({ requesterName }) => `${requesterName} still needs your Insurance Docs`,
|
|
29
31
|
finalReminder: ({ recordCompanyName, requesterName }) => `Missing ${recordCompanyName}'s Insurance Docs for ${requesterName}`,
|
|
30
32
|
aboutToExpirePM: ({ recordCompanyName }) => `Insurance Policy of ${recordCompanyName} expires Soon`,
|
|
31
33
|
aboutToExpireMonthAutoRenewal: ({ requesterName }) => `Your COI for ${requesterName} expires in 30 days`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
2
|
const apiKeyAuthRequests = require('../../../../common/requests/apiKeyAuth/requests');
|
|
3
3
|
|
|
4
4
|
const { nodeBackendUrl, backendUrl } = require('../../../../env').getEnv();
|
|
@@ -15,55 +15,66 @@ const Endpoints = {
|
|
|
15
15
|
publishGlobalRecord: `${backendUrl}/saas/global-record/publish`,
|
|
16
16
|
getGlobalRecordLinkedRecords: id => `${backendUrl}/saas/global-record/${id}/linked-records`,
|
|
17
17
|
splitToNewGlobalRecord: `${backendUrl}/saas/global-record/split-to-new`,
|
|
18
|
-
|
|
18
|
+
splitToExistingRecord: `${backendUrl}/saas/global-record/split-to-existing`,
|
|
19
|
+
getGlobalByRecordId: recordId => `${backendUrl}/saas/global-record/${recordId}`,
|
|
20
|
+
dismiss: `${backendUrl}/saas/global-record/dismiss`
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
const getGlobalRecord =
|
|
23
|
+
const getGlobalRecord = (id, nodeBackendSecret) => {
|
|
22
24
|
return apiKeyAuthRequests.getRequestHandler(Endpoints.getGlobalRecordById(id), nodeBackendSecret);
|
|
23
25
|
};
|
|
24
26
|
|
|
25
|
-
const createGlobalRecord =
|
|
27
|
+
const createGlobalRecord = (globalRecord, nodeBackendSecret) => {
|
|
26
28
|
return apiKeyAuthRequests.postRequestHandler(Endpoints.createGlobalRecord, nodeBackendSecret, globalRecord);
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
const getAllGlobalRecords =
|
|
30
|
-
return
|
|
31
|
+
const getAllGlobalRecords = (data, pageNumber, itemsInPage, context) => {
|
|
32
|
+
return requests.postRequestHandler(Endpoints.getAllGlobalRecords(pageNumber, itemsInPage), data, context);
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
const deleteGlobalRecord =
|
|
35
|
+
const deleteGlobalRecord = (id, nodeBackendSecret, globalRecordModel) => {
|
|
34
36
|
return apiKeyAuthRequests.deleteRequestHandler(Endpoints.deleteGlobalRecord(id), nodeBackendSecret, {}, {}, globalRecordModel);
|
|
35
37
|
};
|
|
36
38
|
|
|
37
|
-
const updateGlobalRecord =
|
|
39
|
+
const updateGlobalRecord = (id, nodeBackendSecret, updatedGlobalRecord) => {
|
|
38
40
|
return apiKeyAuthRequests.putRequestHandler(Endpoints.updateGlobalRecord(id), nodeBackendSecret, updatedGlobalRecord);
|
|
39
41
|
};
|
|
40
42
|
|
|
41
|
-
const getGlobalRecordServiceAreas =
|
|
42
|
-
return
|
|
43
|
+
const getGlobalRecordServiceAreas = context => {
|
|
44
|
+
return requests.getRequestHandler(Endpoints.getGlobalRecordServiceAreas, {}, context);
|
|
43
45
|
};
|
|
44
46
|
|
|
45
|
-
const getRecordProfileDetails =
|
|
46
|
-
return
|
|
47
|
+
const getRecordProfileDetails = (id, context) => {
|
|
48
|
+
return requests.getRequestHandler(Endpoints.getRecordProfileDetails(id), {}, context);
|
|
47
49
|
};
|
|
48
50
|
|
|
49
|
-
const publishGlobalRecord =
|
|
50
|
-
return
|
|
51
|
+
const publishGlobalRecord = (globalRecordDetails, context) => {
|
|
52
|
+
return requests.putRequestHandler(Endpoints.publishGlobalRecord, globalRecordDetails, context);
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
const getGlobalRecordByPolicyNumber =
|
|
55
|
+
const getGlobalRecordByPolicyNumber = (policyNumber, nodeBackendSecret) => {
|
|
54
56
|
return apiKeyAuthRequests.getRequestHandler(Endpoints.getGlobalRecordByPolicyNumber(policyNumber), nodeBackendSecret);
|
|
55
57
|
};
|
|
56
58
|
|
|
57
|
-
const getGlobalRecordLinkedRecords =
|
|
58
|
-
return
|
|
59
|
+
const getGlobalRecordLinkedRecords = (id, context) => {
|
|
60
|
+
return requests.getRequestHandler(Endpoints.getGlobalRecordLinkedRecords(id), {}, context);
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
const splitToNewGlobalRecord = ({ recordId, glPolicyNumber }, context) => {
|
|
62
|
-
return
|
|
64
|
+
return requests.postRequestHandler(Endpoints.splitToNewGlobalRecord, { recordId, glPolicyNumber }, context);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const splitToExistGlobalRecord = ({ recordId, glPolicyNumber, newGlobalRecordId }, context) => {
|
|
68
|
+
return requests.putRequestHandler(Endpoints.splitToExistingRecord, { recordId, glPolicyNumber, newGlobalRecordId }, context);
|
|
63
69
|
};
|
|
64
70
|
|
|
65
71
|
const getGlobalRecordByRecordId = (recordId, context) => {
|
|
66
|
-
return
|
|
72
|
+
return requests.getRequestHandler(Endpoints.getGlobalByRecordId(recordId), {}, context);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const dismissGlobalChanges = (id, context) => {
|
|
76
|
+
const body = { id, userName: 'Main Operator' };
|
|
77
|
+
return requests.putRequestHandler(Endpoints.dismiss, body, context);
|
|
67
78
|
};
|
|
68
79
|
|
|
69
80
|
module.exports = {
|
|
@@ -78,5 +89,7 @@ module.exports = {
|
|
|
78
89
|
publishGlobalRecord,
|
|
79
90
|
getGlobalRecordLinkedRecords,
|
|
80
91
|
splitToNewGlobalRecord,
|
|
81
|
-
|
|
92
|
+
splitToExistGlobalRecord,
|
|
93
|
+
getGlobalRecordByRecordId,
|
|
94
|
+
dismissGlobalChanges
|
|
82
95
|
};
|
|
@@ -1,81 +1,90 @@
|
|
|
1
1
|
const globalRecordAPI = require('./global.record.api');
|
|
2
|
-
const { CreateGlobalRecordModel } = require('../models/global.record.model');
|
|
2
|
+
const { CreateGlobalRecordModel, CreateGlobalRecordSearchModel } = require('../models/global.record.model');
|
|
3
3
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
4
|
const { nodeBackendSecret } = require('../../../../env').getEnv();
|
|
5
5
|
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
6
6
|
|
|
7
|
-
const getGlobalRecordById =
|
|
7
|
+
const getGlobalRecordById = id => {
|
|
8
8
|
return globalRecordAPI.getGlobalRecord(id, nodeBackendSecret);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const getGlobalRecordByPolicyNumber =
|
|
11
|
+
const getGlobalRecordByPolicyNumber = policyNumber => {
|
|
12
12
|
return globalRecordAPI.getGlobalRecordByPolicyNumber(policyNumber, nodeBackendSecret);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const createGlobalRecord =
|
|
15
|
+
const createGlobalRecord = createGlobalRecordModel => {
|
|
16
16
|
validateType(createGlobalRecordModel, CreateGlobalRecordModel);
|
|
17
17
|
return globalRecordAPI.createGlobalRecord(createGlobalRecordModel, nodeBackendSecret);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const getAllGlobalRecordsInPage =
|
|
20
|
+
const getAllGlobalRecordsInPage = (pageNumber, context, itemsInPage = 10) => {
|
|
21
21
|
const param = {};
|
|
22
22
|
return globalRecordAPI.getAllGlobalRecords(param, pageNumber, itemsInPage, context);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const getAllGlobalRecordsInPageByServiceAreas =
|
|
25
|
+
const getAllGlobalRecordsInPageByServiceAreas = (serviceAreas, pageNumber, context, itemsInPage = 10) => {
|
|
26
26
|
const data = Array.isArray(serviceAreas) ? { serviceAreas } : { serviceAreas: new Array(serviceAreas) };
|
|
27
|
-
return globalRecordAPI.getAllGlobalRecords(data, pageNumber, itemsInPage,
|
|
27
|
+
return globalRecordAPI.getAllGlobalRecords(data, pageNumber, itemsInPage, context);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const getAllGlobalRecordsInPageBySearchTerm =
|
|
31
|
-
const
|
|
32
|
-
return globalRecordAPI.getAllGlobalRecords(
|
|
30
|
+
const getAllGlobalRecordsInPageBySearchTerm = (searchTerm, pageNumber, context, itemsInPage = 10) => {
|
|
31
|
+
const searchModel = new CreateGlobalRecordSearchModel(searchTerm);
|
|
32
|
+
return globalRecordAPI.getAllGlobalRecords(searchModel, pageNumber, itemsInPage, context);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const getAllGlobalRecordsInPageByCombinedSearch =
|
|
35
|
+
const getAllGlobalRecordsInPageByCombinedSearch = (combinedSearch, pageNumber, context, itemsInPage = 10) => {
|
|
36
36
|
const data = combinedSearch;
|
|
37
37
|
return globalRecordAPI.getAllGlobalRecords(data, pageNumber, itemsInPage, context);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const getGlobalRecordServiceAreas =
|
|
40
|
+
const getGlobalRecordServiceAreas = context => {
|
|
41
41
|
return globalRecordAPI.getGlobalRecordServiceAreas(context);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const deleteGlobalRecord =
|
|
44
|
+
const deleteGlobalRecord = (id, globalRecordModel) => {
|
|
45
45
|
return globalRecordAPI.deleteGlobalRecord(id, nodeBackendSecret, globalRecordModel);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const updateGlobalRecord =
|
|
48
|
+
const updateGlobalRecord = (id, updatedGlobalRecordModel) => {
|
|
49
49
|
return globalRecordAPI.updateGlobalRecord(id, nodeBackendSecret, updatedGlobalRecordModel);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const getRecordProfileDetails =
|
|
52
|
+
const getRecordProfileDetails = (id, context) => {
|
|
53
53
|
return globalRecordAPI.getRecordProfileDetails(id, context);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
const publishGlobalRecord =
|
|
56
|
+
const publishGlobalRecord = (globalRecordDetails, context) => {
|
|
57
57
|
return globalRecordAPI.publishGlobalRecord(globalRecordDetails, context);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
const getGlobalRecordLinkedRecords =
|
|
60
|
+
const getGlobalRecordLinkedRecords = (id, context) => {
|
|
61
61
|
return globalRecordAPI.getGlobalRecordLinkedRecords(id, context);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
const splitToNewGlobalRecord =
|
|
64
|
+
const splitToNewGlobalRecord = (recordId, glPolicyNumber, context) => {
|
|
65
65
|
const requestData = { recordId, glPolicyNumber };
|
|
66
66
|
return globalRecordAPI.splitToNewGlobalRecord(requestData, context);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
const splitToExistGlobalRecord = (recordId, glPolicyNumber, globalRecordId, context) => {
|
|
70
|
+
const requestData = { recordId, glPolicyNumber, newGlobalRecordId: globalRecordId };
|
|
71
|
+
return globalRecordAPI.splitToExistGlobalRecord(requestData, context);
|
|
72
|
+
};
|
|
73
|
+
|
|
69
74
|
const getGlobalRecordByRecordId = async (recordId, context) => {
|
|
70
75
|
const response = await globalRecordAPI.getGlobalRecordByRecordId(recordId, context);
|
|
71
76
|
|
|
72
77
|
if (response.status !== httpResponseStatusCodes.OK) {
|
|
73
|
-
throw Error(`Failed to get global record by recordId - ${recordId}
|
|
78
|
+
throw Error(`Failed to get global record by recordId - ${recordId}\n${response.data}`);
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
return response.data;
|
|
77
82
|
};
|
|
78
83
|
|
|
84
|
+
const dismissGlobalChanges = (id, context) => {
|
|
85
|
+
return globalRecordAPI.dismissGlobalChanges(id, context);
|
|
86
|
+
};
|
|
87
|
+
|
|
79
88
|
module.exports = {
|
|
80
89
|
createGlobalRecord,
|
|
81
90
|
getGlobalRecordById,
|
|
@@ -91,5 +100,7 @@ module.exports = {
|
|
|
91
100
|
publishGlobalRecord,
|
|
92
101
|
getGlobalRecordLinkedRecords,
|
|
93
102
|
splitToNewGlobalRecord,
|
|
94
|
-
getGlobalRecordByRecordId
|
|
103
|
+
getGlobalRecordByRecordId,
|
|
104
|
+
splitToExistGlobalRecord,
|
|
105
|
+
dismissGlobalChanges
|
|
95
106
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { isObject } = require('../../../../common/utils/dataTypeUtils');
|
|
2
|
+
|
|
1
3
|
class CreateGlobalRecordModel {
|
|
2
4
|
constructor(
|
|
3
5
|
header,
|
|
@@ -38,6 +40,21 @@ class CreateGlobalRecordModel {
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
class CreateGlobalRecordSearchModel {
|
|
44
|
+
constructor(
|
|
45
|
+
searchTerm,
|
|
46
|
+
{
|
|
47
|
+
sortBy = 'status',
|
|
48
|
+
sortOrderFlag = true
|
|
49
|
+
} = {}
|
|
50
|
+
) {
|
|
51
|
+
this.searchTerm = isObject(searchTerm) ? [searchTerm] : searchTerm,
|
|
52
|
+
this.sortBy = sortBy,
|
|
53
|
+
this.sortOrderFlag = sortOrderFlag;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
41
57
|
module.exports = {
|
|
42
|
-
CreateGlobalRecordModel
|
|
58
|
+
CreateGlobalRecordModel,
|
|
59
|
+
CreateGlobalRecordSearchModel
|
|
43
60
|
};
|
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
} = require('../../../../common/utils/numberUtils');
|
|
11
11
|
|
|
12
12
|
const { SERVICE_AREAS } = require('../consts');
|
|
13
|
+
const { cloneObject } = require('../../../../common/utils/objectUtils');
|
|
13
14
|
|
|
14
15
|
const createGlobalRecordConfig = (
|
|
15
16
|
name,
|
|
@@ -135,12 +136,24 @@ const getGlobalRecordsDefaultNameList = (nameBase, listLength) => {
|
|
|
135
136
|
);
|
|
136
137
|
};
|
|
137
138
|
|
|
139
|
+
const createPublishGlobalConfig = (recordName, id, primaryEmail, { additionalContacts, brokerEmails } = {}) => {
|
|
140
|
+
return cloneObject({
|
|
141
|
+
recordName,
|
|
142
|
+
id,
|
|
143
|
+
primaryEmail,
|
|
144
|
+
additionalContacts: additionalContacts || [],
|
|
145
|
+
brokerEmails: brokerEmails || []
|
|
146
|
+
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
138
150
|
module.exports = {
|
|
139
151
|
createGlobalRecords,
|
|
140
152
|
createGlobalRecordConfig,
|
|
141
153
|
createGlobalRecordConfigs,
|
|
142
154
|
createGlobalRecordModel,
|
|
143
155
|
createGlobalRecordModels,
|
|
156
|
+
createPublishGlobalConfig,
|
|
144
157
|
getCreateRandomGlobalRecordModels,
|
|
145
158
|
getGlobalRecordsDefaultNameList,
|
|
146
159
|
getGlobalRecordsByNumberOfPages,
|