@getjones/test-infra 2.9.7 → 2.9.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/commonFlows/records/records.js +38 -8
- package/src/common/utils/timeUtils.js +27 -1
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +11 -2
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +6 -1
- package/src/saas/internal-api/contractors/api/contractors.api.js +9 -1
- package/src/saas/internal-api/contractors/api/contractors.service.js +6 -1
- package/src/resources/virusFile.pdf +0 -0
package/package.json
CHANGED
|
@@ -4,14 +4,15 @@ const threadScheduler = require('../../../saas/internal-api/thread-scheduler/run
|
|
|
4
4
|
const timeUtils = require('../../utils/timeUtils');
|
|
5
5
|
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
6
6
|
const contractors = require('../../../saas/internal-api/contractors');
|
|
7
|
+
const compliance = require('../../../saas/internal-api/compliance');
|
|
7
8
|
|
|
8
9
|
const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
|
|
9
|
-
const
|
|
10
|
-
timeUtils.
|
|
11
|
-
timeUtils.
|
|
10
|
+
const offsetInDaysList = isTenant ?
|
|
11
|
+
timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
|
|
12
|
+
timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
|
|
12
13
|
|
|
13
|
-
for (const
|
|
14
|
-
await
|
|
14
|
+
for (const offsetInDays of offsetInDaysList) {
|
|
15
|
+
await updateLastInviteActionDate(recordId, offsetInDays, context);
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -20,13 +21,41 @@ const updateInviteDate = async function(recordId, inviteDate, context) {
|
|
|
20
21
|
const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
|
|
21
22
|
|
|
22
23
|
if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
23
|
-
throw new Error(`
|
|
24
|
+
throw new Error(`Failed to update record invite date\n${updateResponse}`);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
|
|
27
28
|
|
|
28
29
|
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
29
|
-
throw new Error(`
|
|
30
|
+
throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const updateLastInviteActionDate = async function(recordId, offsetInDays, context) {
|
|
37
|
+
await timeUtils.waitFor(1).seconds;
|
|
38
|
+
/*
|
|
39
|
+
To run the reminders mails successfully we must first update the compliance audit actions date,
|
|
40
|
+
Since the thread scheduler will trigger the logic of the reminders mails
|
|
41
|
+
only if last invite action date will be equal or after compliance audit actions date
|
|
42
|
+
*/
|
|
43
|
+
const updateComplianceAuditResponse = await compliance.services.audit.updateComplianceAuditActionsDate(recordId, offsetInDays, context);
|
|
44
|
+
|
|
45
|
+
if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
46
|
+
throw new Error(`Failed to update compliance audit date\n${updateComplianceAuditResponse}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, offsetInDays, context);
|
|
50
|
+
|
|
51
|
+
if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
52
|
+
throw new Error(`Failed to update record invite date\n${updateLastInviteActionResponse}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
|
|
56
|
+
|
|
57
|
+
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
58
|
+
throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
|
|
30
59
|
}
|
|
31
60
|
|
|
32
61
|
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
@@ -68,5 +97,6 @@ module.exports = {
|
|
|
68
97
|
runOverAllRenewalDatesForRecord,
|
|
69
98
|
updateInviteDate,
|
|
70
99
|
updatePolicyExpiryDateForRecord,
|
|
71
|
-
getHistoryEvents
|
|
100
|
+
getHistoryEvents,
|
|
101
|
+
updateLastInviteActionDate
|
|
72
102
|
};
|
|
@@ -24,6 +24,16 @@ const peroids = {
|
|
|
24
24
|
years: 'years'
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
const inviteActionDateOffset = {
|
|
28
|
+
oneDay: 1,
|
|
29
|
+
twoDays: 2,
|
|
30
|
+
threeDays: 3,
|
|
31
|
+
fourDays: 4,
|
|
32
|
+
fiveDays: 5,
|
|
33
|
+
tenDays: 10,
|
|
34
|
+
fifteenDays: 15
|
|
35
|
+
};
|
|
36
|
+
|
|
27
37
|
const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
|
|
28
38
|
const getTwoHundredDaysAgoDate = format => moment().utc().subtract(200, peroids.days).format(format || formats.threadScheduler);
|
|
29
39
|
const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
|
|
@@ -86,6 +96,10 @@ const getInvitationDatesForNotResponsiveVendor = function() {
|
|
|
86
96
|
return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
|
|
87
97
|
};
|
|
88
98
|
|
|
99
|
+
const getInviteActionOffsetInDaysForNotResponsiveVendor = function() {
|
|
100
|
+
return [inviteActionDateOffset.twoDays, inviteActionDateOffset.threeDays, inviteActionDateOffset.threeDays];
|
|
101
|
+
};
|
|
102
|
+
|
|
89
103
|
const getInvitationDatesForNotResponsiveTenant = function() {
|
|
90
104
|
const fiveDaysAgoUtc = getFiveDaysAgoDate();
|
|
91
105
|
const tenDaysAgoUtc = getTenDaysAgoDate();
|
|
@@ -94,6 +108,10 @@ const getInvitationDatesForNotResponsiveTenant = function() {
|
|
|
94
108
|
return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
|
|
95
109
|
};
|
|
96
110
|
|
|
111
|
+
const getInviteActionOffsetInDaysForNotResponsiveTenant = function() {
|
|
112
|
+
return [inviteActionDateOffset.fiveDays, inviteActionDateOffset.fiveDays, inviteActionDateOffset.fiveDays];
|
|
113
|
+
};
|
|
114
|
+
|
|
97
115
|
const isDateAfterOther = (date, other) => {
|
|
98
116
|
return moment(date).isAfter(other);
|
|
99
117
|
};
|
|
@@ -115,6 +133,10 @@ const convertDateToLongInt = value => {
|
|
|
115
133
|
return Date.parse(value);
|
|
116
134
|
};
|
|
117
135
|
|
|
136
|
+
const convertDateStringFormatToISOString = dateStringFormat => {
|
|
137
|
+
return new Date(dateStringFormat).toISOString();
|
|
138
|
+
};
|
|
139
|
+
|
|
118
140
|
module.exports = {
|
|
119
141
|
formats,
|
|
120
142
|
getOneYearAgoDate,
|
|
@@ -136,7 +158,9 @@ module.exports = {
|
|
|
136
158
|
getDateinTwentyNineDays,
|
|
137
159
|
getDateInTwoMonths,
|
|
138
160
|
getInvitationDatesForNotResponsiveVendor,
|
|
161
|
+
getInviteActionOffsetInDaysForNotResponsiveVendor,
|
|
139
162
|
getInvitationDatesForNotResponsiveTenant,
|
|
163
|
+
getInviteActionOffsetInDaysForNotResponsiveTenant,
|
|
140
164
|
getAutomaticRenewalsExpirationDates,
|
|
141
165
|
getLogTimestamp,
|
|
142
166
|
getDayInMilliseconds,
|
|
@@ -147,5 +171,7 @@ module.exports = {
|
|
|
147
171
|
convertDateToNewFormat,
|
|
148
172
|
getOneWeekAgoDate,
|
|
149
173
|
getOneWeekAheadDate,
|
|
150
|
-
convertDateToLongInt
|
|
174
|
+
convertDateToLongInt,
|
|
175
|
+
convertDateStringFormatToISOString,
|
|
176
|
+
inviteActionDateOffset
|
|
151
177
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const requests = require('../../../../../common/requests/cookieAuth/requests');
|
|
2
2
|
const { backendUrl } = require('../../../../../env').getEnv();
|
|
3
3
|
|
|
4
|
+
const { convertDateStringFormatToISOString } = require('../../../../../common/utils/timeUtils');
|
|
5
|
+
|
|
4
6
|
const Endpoints = {
|
|
5
7
|
auditorContractorList: `${backendUrl}/saas/auditor/contractors`,
|
|
6
8
|
audit: `${backendUrl}/saas/auditor/contractors/submit/audits`,
|
|
@@ -10,7 +12,8 @@ const Endpoints = {
|
|
|
10
12
|
isReaudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/isreaudit`,
|
|
11
13
|
revertCoi: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/coi/revert`,
|
|
12
14
|
wrongCoi: `${backendUrl}/saas/coi/wrong-coi`,
|
|
13
|
-
getAudit: recordId => `${backendUrl}/saas/audit/${recordId}
|
|
15
|
+
getAudit: recordId => `${backendUrl}/saas/audit/${recordId}`,
|
|
16
|
+
updateComplianceAuditActionsDate: recordId => `${backendUrl}/saas/automation/record/${recordId}/update-audit-actions-date`
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
const audit = async (contractorId, auditRequestModel, context) => {
|
|
@@ -55,6 +58,11 @@ const wrongCoi = (recordId, context) => {
|
|
|
55
58
|
return requests.getRequestHandler(Endpoints.wrongCoi, params, context);
|
|
56
59
|
};
|
|
57
60
|
|
|
61
|
+
const updateComplianceAuditActionsDate = (recordId, dateOffset, context) => {
|
|
62
|
+
const url = `${Endpoints.updateComplianceAuditActionsDate(recordId)}?offsetInDays=${dateOffset}`;
|
|
63
|
+
return requests.putRequestHandler(url, {}, context);
|
|
64
|
+
};
|
|
65
|
+
|
|
58
66
|
module.exports = {
|
|
59
67
|
audit,
|
|
60
68
|
submitAudit,
|
|
@@ -65,5 +73,6 @@ module.exports = {
|
|
|
65
73
|
enterAudit,
|
|
66
74
|
getAuditRecordModel,
|
|
67
75
|
getRequirementDetailsForAudit,
|
|
68
|
-
getAuditByRecordId
|
|
76
|
+
getAuditByRecordId,
|
|
77
|
+
updateComplianceAuditActionsDate
|
|
69
78
|
};
|
|
@@ -157,6 +157,10 @@ const auditRecord = async function(
|
|
|
157
157
|
return auditResponse;
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
+
const updateComplianceAuditActionsDate = (recordId, dateOffset, context) => {
|
|
161
|
+
return auditApi.updateComplianceAuditActionsDate(recordId, dateOffset, context);
|
|
162
|
+
};
|
|
163
|
+
|
|
160
164
|
module.exports = {
|
|
161
165
|
audit,
|
|
162
166
|
submitAudit,
|
|
@@ -171,5 +175,6 @@ module.exports = {
|
|
|
171
175
|
getAuditMetadata,
|
|
172
176
|
getAuditByRecordId,
|
|
173
177
|
getAuditRequestModel,
|
|
174
|
-
auditRecord
|
|
178
|
+
auditRecord,
|
|
179
|
+
updateComplianceAuditActionsDate
|
|
175
180
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
2
|
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
const { convertDateStringFormatToISOString } = require('../../../../common/utils/timeUtils');
|
|
3
4
|
|
|
4
5
|
const Endpoints = {
|
|
5
6
|
create: `${backendUrl}/saas/contractors/invite`,
|
|
@@ -19,6 +20,7 @@ const Endpoints = {
|
|
|
19
20
|
changeRequirement: `${backendUrl}/saas/contractor/requirement`,
|
|
20
21
|
updateVendorExpiryDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/expiry-date`,
|
|
21
22
|
updateContractorInviteDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/invite-date`,
|
|
23
|
+
updateLastInviteActionDate: recordId => `${backendUrl}/saas/automation/record/${recordId}/update-emails-date`,
|
|
22
24
|
searchInAutocomplete: ({ tabId, searchWord }) =>
|
|
23
25
|
`${backendUrl}/saas/requests/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
|
|
24
26
|
automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`,
|
|
@@ -126,6 +128,11 @@ const getLinkedProjectsCount = async (recordId, context) => {
|
|
|
126
128
|
return await requests.getRequestHandler(Endpoints.linkedProjectsCount(recordId), {}, context);
|
|
127
129
|
};
|
|
128
130
|
|
|
131
|
+
const updateLastInviteActionDate = (recordId, offsetInDays, context) => {
|
|
132
|
+
const url = `${Endpoints.updateLastInviteActionDate(recordId)}?offsetInDays=${offsetInDays}`;
|
|
133
|
+
return requests.putRequestHandler(url, {}, context);
|
|
134
|
+
};
|
|
135
|
+
|
|
129
136
|
module.exports = {
|
|
130
137
|
createContractor,
|
|
131
138
|
changeRequirement,
|
|
@@ -148,5 +155,6 @@ module.exports = {
|
|
|
148
155
|
resendInvitation,
|
|
149
156
|
muteNotifications,
|
|
150
157
|
unmuteNotifications,
|
|
151
|
-
getLinkedProjectsCount
|
|
158
|
+
getLinkedProjectsCount,
|
|
159
|
+
updateLastInviteActionDate
|
|
152
160
|
};
|
|
@@ -54,6 +54,10 @@ const updateInviteDate = (contractorId, inviteDate, context) => {
|
|
|
54
54
|
return contractorsAPI.updateInviteDate(contractorId, inviteDate, context);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
const updateLastInviteActionDate = (recordId, dateOffset, context) => {
|
|
58
|
+
return contractorsAPI.updateLastInviteActionDate(recordId, dateOffset, context);
|
|
59
|
+
};
|
|
60
|
+
|
|
57
61
|
const getContractorsByTabId = (tabId, context, activityStatus = 'Active') => {
|
|
58
62
|
return contractorsAPI.getContractorsByTabId(tabId, context, activityStatus);
|
|
59
63
|
};
|
|
@@ -184,5 +188,6 @@ module.exports = {
|
|
|
184
188
|
assignRequirement,
|
|
185
189
|
getAssignRequirementModel,
|
|
186
190
|
getLinkedProjectsCount,
|
|
187
|
-
restoreByRecordId
|
|
191
|
+
restoreByRecordId,
|
|
192
|
+
updateLastInviteActionDate
|
|
188
193
|
};
|
|
Binary file
|