@getjones/test-infra 2.8.14 → 2.9.0
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 +32 -2
- package/src/common/utils/timeUtils.js +11 -30
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +23 -4
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +19 -2
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +15 -1
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +12 -0
- package/src/saas/internal-api/contractors/api/contractors.api.js +9 -1
- package/src/saas/internal-api/contractors/api/contractors.service.js +17 -4
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +8 -7
- package/src/resources/virusFile.pdf +0 -0
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ 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
10
|
const dates = isTenant ?
|
|
@@ -11,7 +12,7 @@ const makeRecordNotResponsive = async function(recordId, context, { isTenant } =
|
|
|
11
12
|
timeUtils.getInvitationDatesForNotResponsiveVendor();
|
|
12
13
|
|
|
13
14
|
for (const date of dates) {
|
|
14
|
-
await
|
|
15
|
+
await updateLastInviteActionDate(recordId, date, context);
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -32,6 +33,34 @@ const updateInviteDate = async function(recordId, inviteDate, context) {
|
|
|
32
33
|
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
const updateLastInviteActionDate = async function(recordId, customDate, 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, customDate, context);
|
|
44
|
+
|
|
45
|
+
if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
46
|
+
throw new Error(`Compliance audit date could not be updated\n${updateComplianceAuditResponse}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, customDate, context);
|
|
50
|
+
|
|
51
|
+
if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
52
|
+
throw new Error(`Record invite date could not be updated\n${updateLastInviteActionResponse}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
|
|
56
|
+
|
|
57
|
+
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
58
|
+
throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
62
|
+
};
|
|
63
|
+
|
|
35
64
|
const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
|
|
36
65
|
const dates = timeUtils.getAutomaticRenewalsExpirationDates();
|
|
37
66
|
|
|
@@ -68,5 +97,6 @@ module.exports = {
|
|
|
68
97
|
runOverAllRenewalDatesForRecord,
|
|
69
98
|
updateInviteDate,
|
|
70
99
|
updatePolicyExpiryDateForRecord,
|
|
71
|
-
getHistoryEvents
|
|
100
|
+
getHistoryEvents,
|
|
101
|
+
updateLastInviteActionDate
|
|
72
102
|
};
|
|
@@ -7,6 +7,7 @@ const formats = {
|
|
|
7
7
|
dayMonthYear: 'DD/MM/YYYY',
|
|
8
8
|
numericMonthDayYear: 'MM/DD/YYYY',
|
|
9
9
|
monthDayYear: 'MMM DD, YYYY',
|
|
10
|
+
monthDYear: 'MMM D, YYYY',
|
|
10
11
|
monthDayYear_noZeroPrefix: 'MMM D, YYYY',
|
|
11
12
|
dateTime: 'YYYY/MM/DD-hh:mm:ss',
|
|
12
13
|
fullMonthDayYear: 'MMMM DD, YYYY',
|
|
@@ -24,7 +25,9 @@ const peroids = {
|
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
|
|
28
|
+
const getTwoHundredDaysAgoDate = format => moment().utc().subtract(200, peroids.days).format(format || formats.threadScheduler);
|
|
27
29
|
const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
|
|
30
|
+
const getFortyFiveDaysAgoDate = format => moment().utc().subtract(45, peroids.days).format(format || formats.threadScheduler);
|
|
28
31
|
const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
|
|
29
32
|
const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
|
|
30
33
|
const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
|
|
@@ -46,31 +49,6 @@ const getLogTimestamp = () => {
|
|
|
46
49
|
return moment().format(formats.logTimeStampFormat);
|
|
47
50
|
};
|
|
48
51
|
|
|
49
|
-
const getCurrentFormattedDate = () => {
|
|
50
|
-
return new Date().toISOString();
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const getDateWithOffset = (date, offsetInDays) => {
|
|
54
|
-
date.setDate(date.getDate() + offsetInDays);
|
|
55
|
-
return date;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getAuditDateFormat = date => {
|
|
59
|
-
const year = date.getUTCFullYear();
|
|
60
|
-
const month = date.getUTCMonth() + 1; //getMonth is zero-based
|
|
61
|
-
const day = date.getUTCDate();
|
|
62
|
-
|
|
63
|
-
return `${month}/${day}/${year}`;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const getYearMonthDayFormat = date => {
|
|
67
|
-
const year = date.getUTCFullYear();
|
|
68
|
-
const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
|
|
69
|
-
const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
|
|
70
|
-
|
|
71
|
-
return `${year}-${month}-${day}`;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
52
|
const extractDateFromDateTime = date => {
|
|
75
53
|
let extractedDate = date;
|
|
76
54
|
|
|
@@ -137,10 +115,16 @@ const convertDateToLongInt = value => {
|
|
|
137
115
|
return Date.parse(value);
|
|
138
116
|
};
|
|
139
117
|
|
|
118
|
+
const convertDateStringFormatToISOString = dateStringFormat => {
|
|
119
|
+
return new Date(dateStringFormat).toISOString();
|
|
120
|
+
};
|
|
121
|
+
|
|
140
122
|
module.exports = {
|
|
141
123
|
formats,
|
|
142
124
|
getOneYearAgoDate,
|
|
125
|
+
getTwoHundredDaysAgoDate,
|
|
143
126
|
getSixMonthAgoDate,
|
|
127
|
+
getFortyFiveDaysAgoDate,
|
|
144
128
|
getOneMonthAgoDate,
|
|
145
129
|
getFifteenDaysAgoDate,
|
|
146
130
|
getTenDaysAgoDate,
|
|
@@ -159,10 +143,6 @@ module.exports = {
|
|
|
159
143
|
getInvitationDatesForNotResponsiveTenant,
|
|
160
144
|
getAutomaticRenewalsExpirationDates,
|
|
161
145
|
getLogTimestamp,
|
|
162
|
-
getCurrentFormattedDate,
|
|
163
|
-
getAuditDateFormat,
|
|
164
|
-
getDateWithOffset,
|
|
165
|
-
getYearMonthDayFormat,
|
|
166
146
|
getDayInMilliseconds,
|
|
167
147
|
extractDateFromDateTime,
|
|
168
148
|
getPreviousDateByDays,
|
|
@@ -171,5 +151,6 @@ module.exports = {
|
|
|
171
151
|
convertDateToNewFormat,
|
|
172
152
|
getOneWeekAgoDate,
|
|
173
153
|
getOneWeekAheadDate,
|
|
174
|
-
convertDateToLongInt
|
|
154
|
+
convertDateToLongInt,
|
|
155
|
+
convertDateStringFormatToISOString
|
|
175
156
|
};
|
|
@@ -1,19 +1,26 @@
|
|
|
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
|
-
preAudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/master-audit`,
|
|
7
8
|
audit: `${backendUrl}/saas/auditor/contractors/submit/audits`,
|
|
8
9
|
contractorDetailsForAudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/master-audit`,
|
|
9
10
|
requirementDetailsForAudit: contractorId => `${backendUrl}/saas/auditor/contractor/${contractorId}/requirement`,
|
|
10
11
|
isReaudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/isreaudit`,
|
|
11
12
|
revertCoi: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/coi/revert`,
|
|
12
|
-
wrongCoi: `${backendUrl}/saas/coi/wrong-coi
|
|
13
|
+
wrongCoi: `${backendUrl}/saas/coi/wrong-coi`,
|
|
14
|
+
getAudit: recordId => `${backendUrl}/saas/audit/${recordId}`,
|
|
15
|
+
updateComplianceAuditActionsDate: recordId => `${backendUrl}/saas/automation/audit/record/${recordId}/compliance-audit-actions/date`
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
const audit = async (contractorId, auditRequestModel, context) => {
|
|
16
|
-
await
|
|
19
|
+
await getContractorDetailsForAudit(contractorId, {}, context);
|
|
20
|
+
return submitAudit(auditRequestModel, context);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const submitAudit = async (auditRequestModel, context) => {
|
|
17
24
|
return requests.postRequestHandler(Endpoints.audit, auditRequestModel, context);
|
|
18
25
|
};
|
|
19
26
|
|
|
@@ -37,17 +44,29 @@ const getRequirementDetailsForAudit = (contractorId, context) => {
|
|
|
37
44
|
return requests.getRequestHandler(Endpoints.requirementDetailsForAudit(contractorId), {}, context);
|
|
38
45
|
};
|
|
39
46
|
|
|
47
|
+
const getAuditByRecordId = (recordId, context, { isRecordDeleted } = {}) => {
|
|
48
|
+
return requests.getRequestHandler(Endpoints.getAudit(recordId), { isRecordDeleted }, context);
|
|
49
|
+
};
|
|
50
|
+
|
|
40
51
|
const wrongCoi = (recordId, context) => {
|
|
41
52
|
const params = { contractorId: recordId };
|
|
42
53
|
return requests.getRequestHandler(Endpoints.wrongCoi, params, context);
|
|
43
54
|
};
|
|
44
55
|
|
|
56
|
+
const updateComplianceAuditActionsDate = (recordId, customComplianceAuditActionsDate, context) => {
|
|
57
|
+
const url = `${Endpoints.updateComplianceAuditActionsDate(recordId)}?customComplianceAuditActionsDate=${convertDateStringFormatToISOString(customComplianceAuditActionsDate)}`;
|
|
58
|
+
return requests.putRequestHandler(url, {}, context);
|
|
59
|
+
};
|
|
60
|
+
|
|
45
61
|
module.exports = {
|
|
46
62
|
audit,
|
|
63
|
+
submitAudit,
|
|
47
64
|
revertCoi,
|
|
48
65
|
wrongCoi,
|
|
49
66
|
isReaudit,
|
|
50
67
|
getAuditorContractorList,
|
|
51
68
|
getContractorDetailsForAudit,
|
|
52
|
-
getRequirementDetailsForAudit
|
|
69
|
+
getRequirementDetailsForAudit,
|
|
70
|
+
getAuditByRecordId,
|
|
71
|
+
updateComplianceAuditActionsDate
|
|
53
72
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const auditApi = require('./audit.api');
|
|
2
2
|
const { AuditRequestModel, AuditListParametersModel, AuditDatesModel } = require('../../models/audit/audit.model');
|
|
3
|
-
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
3
|
+
const { validateType, validateDateString } = require('../../../../../common/validations/typeValidations');
|
|
4
4
|
const auditUtil = require('../../utils/auditUtil');
|
|
5
5
|
const dataTypeUtils = require('../../../../../common/utils/dataTypeUtils');
|
|
6
6
|
const { cloneObject } = require('../../../../../common/utils/objectUtils');
|
|
@@ -11,6 +11,11 @@ const audit = (auditRequestModel, context) => {
|
|
|
11
11
|
return auditApi.audit(auditRequestModel.auditData.contractorId, auditRequestModel, context);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
const submitAudit = (auditRequestModel, context) => {
|
|
15
|
+
validateType(auditRequestModel, AuditRequestModel);
|
|
16
|
+
return auditApi.submitAudit(auditRequestModel, context);
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
const revertCoi = (contractorId, dateModified, context) => {
|
|
15
20
|
const dateModifiedObj = { dateModified };
|
|
16
21
|
return auditApi.revertCoi(contractorId, dateModifiedObj, context);
|
|
@@ -61,6 +66,10 @@ const getAuditMetadata = async (
|
|
|
61
66
|
);
|
|
62
67
|
};
|
|
63
68
|
|
|
69
|
+
const getAuditByRecordId = async (recordId, context, { isRecordDeleted } = {}) => {
|
|
70
|
+
return auditApi.getAuditByRecordId(recordId, context, { isRecordDeleted });
|
|
71
|
+
};
|
|
72
|
+
|
|
64
73
|
const getAuditEntities = async (recordId, auditData, auditorContext) => {
|
|
65
74
|
const requirementDetailsForAuditResponse = await getRequirementDetailsForAudit(recordId, auditorContext);
|
|
66
75
|
const requirement = requirementDetailsForAuditResponse.data;
|
|
@@ -135,8 +144,14 @@ const auditRecord = async function(
|
|
|
135
144
|
return auditResponse;
|
|
136
145
|
};
|
|
137
146
|
|
|
147
|
+
const updateComplianceAuditActionsDate = (recordId, customLastInviteActionDate, context) => {
|
|
148
|
+
validateDateString(customLastInviteActionDate, Date);
|
|
149
|
+
return auditApi.updateComplianceAuditActionsDate(recordId, customLastInviteActionDate, context);
|
|
150
|
+
};
|
|
151
|
+
|
|
138
152
|
module.exports = {
|
|
139
153
|
audit,
|
|
154
|
+
submitAudit,
|
|
140
155
|
revertCoi,
|
|
141
156
|
isReaudit,
|
|
142
157
|
wrongCoi,
|
|
@@ -145,6 +160,8 @@ module.exports = {
|
|
|
145
160
|
getRequirementDetailsForAudit,
|
|
146
161
|
getAuditEntities,
|
|
147
162
|
getAuditMetadata,
|
|
163
|
+
getAuditByRecordId,
|
|
148
164
|
getAuditRequestModel,
|
|
149
|
-
auditRecord
|
|
165
|
+
auditRecord,
|
|
166
|
+
updateComplianceAuditActionsDate
|
|
150
167
|
};
|
|
@@ -2,10 +2,24 @@ 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`,
|
|
5
7
|
overrideGap: `${backendUrl}/saas/record/override-gap`,
|
|
6
8
|
retractOverride: `${backendUrl}/saas/record/retract-override`
|
|
7
9
|
};
|
|
8
10
|
|
|
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
|
+
|
|
9
23
|
const overrideGap = ({ waiveRequestModel, isTestingBackwardCompatibility = false, context }) => {
|
|
10
24
|
const headers = {};
|
|
11
25
|
const params = { isTestingBackwardCompatibility };
|
|
@@ -16,4 +30,4 @@ const retractOverride = (retractRequestModel, context) => {
|
|
|
16
30
|
return requests.postRequestHandler(Endpoints.retractOverride, retractRequestModel, context);
|
|
17
31
|
};
|
|
18
32
|
|
|
19
|
-
module.exports = { overrideGap, retractOverride };
|
|
33
|
+
module.exports = { waive, retract, overrideGap, retractOverride };
|
|
@@ -9,6 +9,16 @@ const httpResponseStatusCodes = require('../../../../../common/httpResponseStatu
|
|
|
9
9
|
const { credentials } = env.getEnv();
|
|
10
10
|
const userTypes = require('../../../../../common/consts/userTypes');
|
|
11
11
|
|
|
12
|
+
const waive = (waiveRequestModel, context) => {
|
|
13
|
+
validateType(waiveRequestModel, WaiveRequestModel);
|
|
14
|
+
return overrideGapApi.waive(waiveRequestModel.contractorId, waiveRequestModel, context);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const retract = (retractRequestModel, context) => {
|
|
18
|
+
validateType(retractRequestModel, RetractRequestModel);
|
|
19
|
+
return overrideGapApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
|
|
20
|
+
};
|
|
21
|
+
|
|
12
22
|
const overrideGap = ({ waiveRequestModel, isTestingBackwardCompatibility = false, context }) => {
|
|
13
23
|
validateType(waiveRequestModel, WaiveRequestModel);
|
|
14
24
|
return overrideGapApi.overrideGap({ waiveRequestModel, isTestingBackwardCompatibility, context });
|
|
@@ -119,8 +129,10 @@ const acceptAll = async (record, context, { note = 'ACCEPTED AUTOMATICALLY' } =
|
|
|
119
129
|
};
|
|
120
130
|
|
|
121
131
|
module.exports = {
|
|
132
|
+
waive,
|
|
122
133
|
waiveAll,
|
|
123
134
|
acceptAll,
|
|
135
|
+
retract,
|
|
124
136
|
getWaiveModel,
|
|
125
137
|
getRetractModel,
|
|
126
138
|
getWaiveModelByGap,
|
|
@@ -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/invite/record/${recordId}/last-invite-action/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, customLastInviteActionDate, context) => {
|
|
132
|
+
const url = `${Endpoints.updateLastInviteActionDate(recordId)}?customLastInviteActionDate=${convertDateStringFormatToISOString(customLastInviteActionDate)}`;
|
|
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
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const contractorsAPI = require('./contractors.api');
|
|
2
2
|
const { CreateContractorModel } = require('../models/create.contractor.model');
|
|
3
3
|
const { RequestModel } = require('../../requests/models/edit.request.model');
|
|
4
|
-
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
|
+
const { validateType, validateDateString } = require('../../../../common/validations/typeValidations');
|
|
5
5
|
const { RecordModifyDateVerificationModel } = require('../models/verification.contractor.model');
|
|
6
6
|
const { AssignRequirementModel } = require('../models/assign.requirement.model');
|
|
7
7
|
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
8
|
+
const { waitFor } = require('../../../../common/utils/timeUtils');
|
|
8
9
|
|
|
9
10
|
const createContractor = async (createContractorModel, context) => {
|
|
10
11
|
validateType(createContractorModel, CreateContractorModel);
|
|
@@ -53,6 +54,11 @@ const updateInviteDate = (contractorId, inviteDate, context) => {
|
|
|
53
54
|
return contractorsAPI.updateInviteDate(contractorId, inviteDate, context);
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
const updateLastInviteActionDate = (recordId, customLastInviteActionDate, context) => {
|
|
58
|
+
validateDateString(customLastInviteActionDate, Date);
|
|
59
|
+
return contractorsAPI.updateLastInviteActionDate(recordId, customLastInviteActionDate, context);
|
|
60
|
+
};
|
|
61
|
+
|
|
56
62
|
const getContractorsByTabId = (tabId, context, activityStatus = 'Active') => {
|
|
57
63
|
return contractorsAPI.getContractorsByTabId(tabId, context, activityStatus);
|
|
58
64
|
};
|
|
@@ -117,8 +123,14 @@ const deleteAllRecordsInAccount = async (accountId, context, { activationStatus
|
|
|
117
123
|
const response = await deleteByContractorId(record.id, context);
|
|
118
124
|
|
|
119
125
|
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
120
|
-
console.error(
|
|
121
|
-
|
|
126
|
+
console.error(`Failed to delete record: ${record.company}, retrying...`);
|
|
127
|
+
waitFor(1000);
|
|
128
|
+
const try2response = await deleteByContractorId(record.id, context);
|
|
129
|
+
|
|
130
|
+
if (try2response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
131
|
+
console.error(`Failed to delete record: ${record.company} second time.`);
|
|
132
|
+
failed.push(response);
|
|
133
|
+
}
|
|
122
134
|
}
|
|
123
135
|
}
|
|
124
136
|
|
|
@@ -177,5 +189,6 @@ module.exports = {
|
|
|
177
189
|
assignRequirement,
|
|
178
190
|
getAssignRequirementModel,
|
|
179
191
|
getLinkedProjectsCount,
|
|
180
|
-
restoreByRecordId
|
|
192
|
+
restoreByRecordId,
|
|
193
|
+
updateLastInviteActionDate
|
|
181
194
|
};
|
|
@@ -119,21 +119,22 @@ const getLastMessage = async (
|
|
|
119
119
|
return newestResult;
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
const waitForMail = async (emailModel, maxSecondToWait) => {
|
|
123
|
-
let
|
|
122
|
+
const waitForMail = async (emailModel, { maxSecondToWait = 30 } = {}) => {
|
|
123
|
+
let isFound = false;
|
|
124
124
|
const oneSecondInMilliseconds = 1000;
|
|
125
125
|
let timeFromTheStart = 0;
|
|
126
126
|
const started = new Date();
|
|
127
|
-
let
|
|
127
|
+
let foundMails;
|
|
128
128
|
|
|
129
|
-
while (
|
|
130
|
-
({ data:
|
|
131
|
-
|
|
129
|
+
while (!isFound && timeFromTheStart < maxSecondToWait) {
|
|
130
|
+
({ data: foundMails } = await getAllMessages(emailModel));
|
|
131
|
+
isFound = foundMails.length > 0;
|
|
132
132
|
const now = new Date();
|
|
133
133
|
timeFromTheStart = (now - started) / oneSecondInMilliseconds;
|
|
134
|
+
await timeUtils.waitFor(3).seconds;
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
return
|
|
137
|
+
return foundMails;
|
|
137
138
|
};
|
|
138
139
|
|
|
139
140
|
module.exports = {
|
|
Binary file
|