@getjones/test-infra 2.8.8 → 2.8.10
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/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/resources/virusFile.pdf +0 -0
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +2 -6
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +18 -1
- package/src/saas/internal-api/dbEmails/consts/consts.js +4 -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/src/saas/internal-api/requests/api/requests.api.js +8 -2
- package/src/saas/internal-api/requests/api/requests.service.js +14 -1
- package/src/saas/internal-api/requests/index.js +3 -1
- package/src/saas/internal-api/requests/models/inner.page.request.criteria.model.js +17 -0
package/package.json
CHANGED
|
@@ -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
|
};
|
|
Binary file
|
|
@@ -124,12 +124,8 @@ const waiveAll = async (record, context, { reason = WAIVER_REASONS.BUSINESS_DECI
|
|
|
124
124
|
await overrideAll(record, reason, context, { note });
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
const acceptAll = async (record, context, {
|
|
128
|
-
|
|
129
|
-
throw Error('Invalid override gap reason to accept');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
await overrideAll(record, reason, context, { note });
|
|
127
|
+
const acceptAll = async (record, context, { note = 'ACCEPTED AUTOMATICALLY' } = {}) => {
|
|
128
|
+
await overrideAll(record, WAIVER_REASONS.ACCEPT_NO_EXPOSURE, context, { note });
|
|
133
129
|
};
|
|
134
130
|
|
|
135
131
|
module.exports = {
|
|
@@ -119,9 +119,26 @@ const getLastMessage = async (
|
|
|
119
119
|
return newestResult;
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
+
const waitForMail = async (emailModel, maxSecondToWait) => {
|
|
123
|
+
let isNotSend = true;
|
|
124
|
+
const oneSecondInMilliseconds = 1000;
|
|
125
|
+
let timeFromTheStart = 0;
|
|
126
|
+
const started = new Date();
|
|
127
|
+
let sendMails;
|
|
128
|
+
|
|
129
|
+
while (isNotSend && timeFromTheStart < maxSecondToWait) {
|
|
130
|
+
({ data: sendMails } = await getAllMessages(emailModel));
|
|
131
|
+
isNotSend = sendMails.length === 0;
|
|
132
|
+
const now = new Date();
|
|
133
|
+
timeFromTheStart = (now - started) / oneSecondInMilliseconds;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return sendMails;
|
|
137
|
+
};
|
|
138
|
+
|
|
122
139
|
module.exports = {
|
|
123
140
|
util,
|
|
124
|
-
|
|
141
|
+
waitForMail,
|
|
125
142
|
getAllMessages,
|
|
126
143
|
getLastMessage,
|
|
127
144
|
deleteMultipleMessages,
|
|
@@ -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`,
|
|
@@ -35,6 +37,8 @@ const EMAIL_SUBJECT = {
|
|
|
35
37
|
sameDayExpirationPMAutoRenewal: ({ recordCompanyName }) => `COI expired for ${recordCompanyName} at`,
|
|
36
38
|
requirementsUpdatedNotification: ({ requesterName }) => `Updated Requirements - Your Insurance Docs are needed for ${requesterName}`,
|
|
37
39
|
updatedRequirementsSubjectPrefix: () => 'Updated Requirements - ',
|
|
40
|
+
requestNewCoi: ({ recordCompanyName, requesterName, isExpired }) => `${recordCompanyName}'s COI is ${isExpired ? 'expired' : 'about to expire'} - ${requesterName}`,
|
|
41
|
+
malwareCoiFound: 'COI upload failed to pass security scan',
|
|
38
42
|
thankYou: 'Thank you for submitting your COI'
|
|
39
43
|
};
|
|
40
44
|
|
|
@@ -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,
|
|
@@ -12,7 +12,8 @@ const Endpoints = {
|
|
|
12
12
|
requestsGlobalSearch: (projectId, searchWord) =>
|
|
13
13
|
`${backendUrl}/saas/requests/search?&projectId=${projectId}&searchWord=${searchWord}`,
|
|
14
14
|
getAutocompleteAutoSelect: `${backendUrl}/saas/request/auto/selection`,
|
|
15
|
-
getTabTenantRequestsInProject: projectId => `${backendUrl}/saas/project/${projectId}/tenants/companies
|
|
15
|
+
getTabTenantRequestsInProject: projectId => `${backendUrl}/saas/project/${projectId}/tenants/companies`,
|
|
16
|
+
innerPageRequests: `${backendUrl}/saas/requests/chart-filter`
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const createRequest = (createRequestModel, context) => {
|
|
@@ -58,6 +59,10 @@ const getTabTenantRequestsInProject = (projectId, context) => {
|
|
|
58
59
|
return requests.getRequestHandler(Endpoints.getTabTenantRequestsInProject(projectId), {}, context);
|
|
59
60
|
};
|
|
60
61
|
|
|
62
|
+
const getInnerPageRequests = (innerPageRequestCriteriaModel, context) => {
|
|
63
|
+
return requests.postRequestHandler(Endpoints.innerPageRequests, innerPageRequestCriteriaModel, context);
|
|
64
|
+
};
|
|
65
|
+
|
|
61
66
|
module.exports = {
|
|
62
67
|
createRequest,
|
|
63
68
|
addRequestToRecord,
|
|
@@ -68,5 +73,6 @@ module.exports = {
|
|
|
68
73
|
getRequestsByTabId,
|
|
69
74
|
requestsGlobalSearch,
|
|
70
75
|
getAutocompleteAutoSelect,
|
|
71
|
-
getTabTenantRequestsInProject
|
|
76
|
+
getTabTenantRequestsInProject,
|
|
77
|
+
getInnerPageRequests
|
|
72
78
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const requestsAPI = require('./requests.api');
|
|
2
2
|
const { CreateRequestModel, ContractorInfo } = require('../models/create.request.model');
|
|
3
|
+
const { InnerPageRequestCriteriaModel } = require('../models/inner.page.request.criteria.model');
|
|
3
4
|
const { RequestModel } = require('../models/edit.request.model');
|
|
4
5
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
5
6
|
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
@@ -105,6 +106,17 @@ const getRequestFromTabByRecordId = async (recordId, tabId, context) => {
|
|
|
105
106
|
return request;
|
|
106
107
|
};
|
|
107
108
|
|
|
109
|
+
const getInnerPageRequests = async (innerPageRequestCriteriaModel, context) => {
|
|
110
|
+
validateType(innerPageRequestCriteriaModel, InnerPageRequestCriteriaModel);
|
|
111
|
+
const response = await requestsAPI.getInnerPageRequests(innerPageRequestCriteriaModel, context);
|
|
112
|
+
|
|
113
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
114
|
+
throw Error(`Get requests inner page has fail\n${response}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return response.data;
|
|
118
|
+
};
|
|
119
|
+
|
|
108
120
|
module.exports = {
|
|
109
121
|
createRequest,
|
|
110
122
|
getAutocompleteAutoSelect,
|
|
@@ -118,5 +130,6 @@ module.exports = {
|
|
|
118
130
|
getCreateRequestModel,
|
|
119
131
|
requestsGlobalSearch,
|
|
120
132
|
getTabTenantRequestsInProject,
|
|
121
|
-
getRequestFromTabByRecordId
|
|
133
|
+
getRequestFromTabByRecordId,
|
|
134
|
+
getInnerPageRequests
|
|
122
135
|
};
|
|
@@ -2,13 +2,15 @@ const services = require('./api/requests.service');
|
|
|
2
2
|
|
|
3
3
|
const { TenantRequestModel, RequestModel, TabModel } = require('./models/edit.request.model');
|
|
4
4
|
const { CreateRequestModel, ContractorInfo } = require('./models/create.request.model');
|
|
5
|
+
const { InnerPageRequestCriteriaModel } = require('./models/inner.page.request.criteria.model');
|
|
5
6
|
|
|
6
7
|
const models = {
|
|
7
8
|
TenantRequestModel,
|
|
8
9
|
RequestModel,
|
|
9
10
|
TabModel,
|
|
10
11
|
CreateRequestModel,
|
|
11
|
-
ContractorInfo
|
|
12
|
+
ContractorInfo,
|
|
13
|
+
InnerPageRequestCriteriaModel
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
module.exports = { services, models };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class InnerPageRequestCriteriaModel {
|
|
2
|
+
constructor({
|
|
3
|
+
projectIds = [],
|
|
4
|
+
recordTypes = [],
|
|
5
|
+
sortBy = '',
|
|
6
|
+
pageNo = 1
|
|
7
|
+
} = {}) {
|
|
8
|
+
this.projectIds = projectIds,
|
|
9
|
+
this.recordTypes = recordTypes,
|
|
10
|
+
this.sortBy = sortBy,
|
|
11
|
+
this.pageNo = pageNo;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
InnerPageRequestCriteriaModel
|
|
17
|
+
};
|