@getjones/test-infra 1.11.0 → 1.12.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 +29 -29
- package/src/common/factory/index.js +3 -3
- package/src/common/factory/records/records.js +71 -45
- package/src/common/httpResponseStatusCodes.json +11 -11
- package/src/common/requests/apiKeyAuth/requests.js +38 -38
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/requestHandlers.js +60 -60
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/timeUtils.js +162 -147
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/env.js +45 -45
- package/src/index.js +69 -67
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
- package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
- package/src/saas/internal-api/accounts/index.js +20 -20
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +15 -15
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +19 -19
- package/src/saas/internal-api/accounts/utils/utils.js +32 -32
- package/src/saas/internal-api/auth/api/auth.api.js +12 -12
- package/src/saas/internal-api/auth/api/auth.service.js +47 -47
- package/src/saas/internal-api/auth/index.js +3 -3
- package/src/saas/internal-api/coi/api/coi.api.js +34 -34
- package/src/saas/internal-api/coi/api/coi.service.js +22 -22
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +7 -7
- package/src/saas/internal-api/coi/index.js +13 -13
- package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
- package/src/saas/internal-api/coi/utils/utils.js +48 -48
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +40 -40
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +33 -33
- package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
- package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
- package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
- package/src/saas/internal-api/compliance/api/waive/waive.service.js +15 -15
- package/src/saas/internal-api/compliance/index.js +22 -22
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +110 -110
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
- package/src/saas/internal-api/contractors/api/contractors.api.js +146 -159
- package/src/saas/internal-api/contractors/api/contractors.service.js +129 -136
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +74 -69
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -19
- package/src/saas/internal-api/dbEmails/consts/consts.js +3 -0
- package/src/saas/internal-api/dbEmails/index.js +4 -3
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
- package/src/saas/internal-api/dbEmails/utils/util.js +59 -0
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
- package/src/saas/internal-api/globalRecord/consts.js +20 -20
- package/src/saas/internal-api/globalRecord/index.js +6 -6
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
- package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
- package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
- package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
- package/src/saas/internal-api/homepageCharts/index.js +3 -3
- package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
- package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
- package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
- package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
- package/src/saas/internal-api/projects/index.js +24 -24
- package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
- package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
- package/src/saas/internal-api/projects/utils/utils.js +82 -82
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
- package/src/saas/internal-api/recordNotes/index.js +3 -3
- package/src/saas/internal-api/reports/api/reports.api.js +39 -39
- package/src/saas/internal-api/reports/api/reports.service.js +34 -34
- package/src/saas/internal-api/reports/consts/consts.js +63 -63
- package/src/saas/internal-api/reports/index.js +15 -15
- package/src/saas/internal-api/reports/models/report.model.js +27 -27
- package/src/saas/internal-api/requests/api/requests.api.js +28 -28
- package/src/saas/internal-api/requests/api/requests.service.js +19 -19
- package/src/saas/internal-api/requests/index.js +9 -11
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requirements/api/requirements.api.js +27 -27
- package/src/saas/internal-api/requirements/api/requirements.service.js +23 -23
- package/src/saas/internal-api/requirements/index.js +6 -6
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +45 -45
- package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
- package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
- package/src/saas/internal-api/serviceArea/index.js +4 -4
- package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
- package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
- package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
- package/src/saas/internal-api/tabs/index.js +3 -3
- package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
- package/src/saas/internal-api/thread-scheduler/runner.js +13 -13
- package/src/saas/internal-api/users/api/users.api.js +77 -78
- package/src/saas/internal-api/users/api/users.service.js +101 -101
- package/src/saas/internal-api/users/index.js +4 -4
- package/src/saas/internal-api/users/models/users.model.js +31 -31
- package/src/saas/internal-api/users/utils/util.js +14 -14
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
- package/src/saas/internal-api/vendorProfile/index.js +3 -3
- package/src/saas/openapi/accounts/accounts.api.js +17 -17
- package/src/saas/openapi/accounts/accounts.service.js +11 -11
- package/src/saas/openapi/projects/projects.api.js +59 -59
- package/src/saas/openapi/projects/projects.service.js +44 -44
- package/src/saas/openapi/requests/index.js +6 -0
- package/src/saas/openapi/{contractors/models/invite.contractor.model.js → requests/models/invite.request.model.js} +37 -37
- package/src/saas/openapi/requests/requests.api.js +20 -0
- package/src/saas/openapi/requests/requests.service.js +18 -0
- package/src/saas/openapi/requirements/index.js +6 -6
- package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
- package/src/saas/openapi/requirements/requirements.api.js +12 -12
- package/src/saas/openapi/requirements/requirements.service.js +20 -20
- package/src/saas/openapi/tabs/tabs.api.js +13 -13
- package/src/saas/openapi/tabs/tabs.service.js +7 -7
- package/tests/env.test.js +40 -40
- package/tests/validation.test.js +83 -83
- package/src/saas/internal-api/requests/models/edit.request.model.js +0 -31
- package/src/saas/internal-api/requests/models/validation.models.js +0 -8
- package/src/saas/openapi/contractors/contractors.api.js +0 -20
- package/src/saas/openapi/contractors/contractors.service.js +0 -18
- package/src/saas/openapi/contractors/index.js +0 -6
|
@@ -1,69 +1,74 @@
|
|
|
1
|
-
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
|
+
const TenantRequestModel = require('../../requests/models/tenant.request.model');
|
|
3
|
+
|
|
4
|
+
class ContractorModel {
|
|
5
|
+
constructor(contractorId, recordType, company, emailAddress, tab, additionalDetails) {
|
|
6
|
+
validateType(tab, VendorTabModel);
|
|
7
|
+
validateType(additionalDetails, ContractorDetailsModel);
|
|
8
|
+
|
|
9
|
+
this.contractorId = contractorId;
|
|
10
|
+
this.recordType = recordType;
|
|
11
|
+
this.company = company;
|
|
12
|
+
this.emailAddress = emailAddress;
|
|
13
|
+
this.tab = tab;
|
|
14
|
+
|
|
15
|
+
for (const detail in additionalDetails) {
|
|
16
|
+
if (additionalDetails[detail]) {
|
|
17
|
+
this[detail] = additionalDetails[detail];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class ContractorDetailsModel {
|
|
24
|
+
constructor({
|
|
25
|
+
additionalEmails = [],
|
|
26
|
+
dba = null,
|
|
27
|
+
firstName = null,
|
|
28
|
+
lastName = null,
|
|
29
|
+
address = null,
|
|
30
|
+
city = null,
|
|
31
|
+
state = null,
|
|
32
|
+
zipCode = null,
|
|
33
|
+
phoneNumber = null,
|
|
34
|
+
recordId = null,
|
|
35
|
+
projectDescription = null,
|
|
36
|
+
startDate = null,
|
|
37
|
+
endDate = null,
|
|
38
|
+
tenantRequest = {}
|
|
39
|
+
} = {}) {
|
|
40
|
+
this.dba = dba;
|
|
41
|
+
this.fName = firstName;
|
|
42
|
+
this.lName = lastName;
|
|
43
|
+
this.location = address;
|
|
44
|
+
this.city = city;
|
|
45
|
+
this.state = state;
|
|
46
|
+
this.zipCode = zipCode;
|
|
47
|
+
this.phoneNumber = phoneNumber;
|
|
48
|
+
this.externalRecordId = recordId;
|
|
49
|
+
this.descriptionOfOperations = projectDescription;
|
|
50
|
+
this.startDate = startDate;
|
|
51
|
+
this.endDate = endDate;
|
|
52
|
+
|
|
53
|
+
Object.keys(tenantRequest).length && validateType(tenantRequest, TenantRequestModel);
|
|
54
|
+
this.tenantRequest = tenantRequest;
|
|
55
|
+
|
|
56
|
+
this.additionalEmails = [];
|
|
57
|
+
|
|
58
|
+
for (const email of additionalEmails) {
|
|
59
|
+
this.additionalEmails.push(typeof email === 'string' ? { email: email } : email);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class VendorTabModel {
|
|
65
|
+
constructor(type) {
|
|
66
|
+
this.type = type;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = {
|
|
71
|
+
ContractorModel,
|
|
72
|
+
VendorTabModel,
|
|
73
|
+
ContractorDetailsModel
|
|
74
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const { validateDateString } = require('../../../../common/validations/typeValidations');
|
|
2
|
-
|
|
3
|
-
class RecordModifyDateVerificationModel {
|
|
4
|
-
constructor(
|
|
5
|
-
contractorId,
|
|
6
|
-
{
|
|
7
|
-
contractorDateModified,
|
|
8
|
-
contractorOverrideDateModified,
|
|
9
|
-
requirementId,
|
|
10
|
-
requirementDateModified
|
|
11
|
-
} = {}
|
|
12
|
-
) {
|
|
13
|
-
contractorDateModified && validateDateString(contractorDateModified);
|
|
14
|
-
contractorOverrideDateModified && validateDateString(contractorOverrideDateModified);
|
|
15
|
-
requirementId && validateDateString(requirementDateModified);
|
|
16
|
-
|
|
17
|
-
this.contractorId = contractorId;
|
|
18
|
-
this.contractorDateModified = contractorDateModified;
|
|
19
|
-
this.contractorOverrideDateModified = contractorOverrideDateModified;
|
|
20
|
-
this.requirementId = requirementId;
|
|
21
|
-
this.requirementDateModified = requirementDateModified;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
RecordModifyDateVerificationModel
|
|
27
|
-
};
|
|
1
|
+
const { validateDateString } = require('../../../../common/validations/typeValidations');
|
|
2
|
+
|
|
3
|
+
class RecordModifyDateVerificationModel {
|
|
4
|
+
constructor(
|
|
5
|
+
contractorId,
|
|
6
|
+
{
|
|
7
|
+
contractorDateModified,
|
|
8
|
+
contractorOverrideDateModified,
|
|
9
|
+
requirementId,
|
|
10
|
+
requirementDateModified
|
|
11
|
+
} = {}
|
|
12
|
+
) {
|
|
13
|
+
contractorDateModified && validateDateString(contractorDateModified);
|
|
14
|
+
contractorOverrideDateModified && validateDateString(contractorOverrideDateModified);
|
|
15
|
+
requirementId && validateDateString(requirementDateModified);
|
|
16
|
+
|
|
17
|
+
this.contractorId = contractorId;
|
|
18
|
+
this.contractorDateModified = contractorDateModified;
|
|
19
|
+
this.contractorOverrideDateModified = contractorOverrideDateModified;
|
|
20
|
+
this.requirementId = requirementId;
|
|
21
|
+
this.requirementDateModified = requirementDateModified;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
RecordModifyDateVerificationModel
|
|
27
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
const requests = require('../../../../common/requests/requestHandlers');
|
|
2
|
-
const { backendUrl, dbEmailsSecrets } = require('../../../../env').getEnv();
|
|
3
|
-
|
|
4
|
-
const Endpoints = {
|
|
5
|
-
dbEmails: `${backendUrl}/_saas/automation/emails/${dbEmailsSecrets}`,
|
|
6
|
-
deleteAllDbEmails: `${backendUrl}/_saas/automation/emails/all/${dbEmailsSecrets}`
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const getAllMessages = emailModel => {
|
|
10
|
-
return requests.postRequestHandler(Endpoints.dbEmails, emailModel);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const deleteMultipleMessages = emailIds => {
|
|
14
|
-
return requests.deleteRequestHandler(Endpoints.dbEmails, {
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const deleteAllMessages = () => {
|
|
18
|
-
return requests.deleteRequestHandler(Endpoints.deleteAllDbEmails);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
getAllMessages,
|
|
23
|
-
deleteMultipleMessages,
|
|
24
|
-
deleteAllMessages
|
|
25
|
-
};
|
|
1
|
+
const requests = require('../../../../common/requests/requestHandlers');
|
|
2
|
+
const { backendUrl, dbEmailsSecrets } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
dbEmails: `${backendUrl}/_saas/automation/emails/${dbEmailsSecrets}`,
|
|
6
|
+
deleteAllDbEmails: `${backendUrl}/_saas/automation/emails/all/${dbEmailsSecrets}`
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const getAllMessages = emailModel => {
|
|
10
|
+
return requests.postRequestHandler(Endpoints.dbEmails, emailModel);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const deleteMultipleMessages = emailIds => {
|
|
14
|
+
return requests.deleteRequestHandler(Endpoints.dbEmails, {}, {}, emailIds);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const deleteAllMessages = () => {
|
|
18
|
+
return requests.deleteRequestHandler(Endpoints.deleteAllDbEmails);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
getAllMessages,
|
|
23
|
+
deleteMultipleMessages,
|
|
24
|
+
deleteAllMessages
|
|
25
|
+
};
|
|
@@ -1,19 +1,127 @@
|
|
|
1
|
-
const dbEmailsApi = require('./db.emails.api');
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
deleteAllMessages
|
|
19
|
-
};
|
|
1
|
+
const dbEmailsApi = require('./db.emails.api');
|
|
2
|
+
const util = require('../utils/util');
|
|
3
|
+
const timeUtils = require('../../../../common/utils/timeUtils');
|
|
4
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
5
|
+
const { EmailModel } = require('../models/db.emails.model');
|
|
6
|
+
|
|
7
|
+
const strict = 'strict';
|
|
8
|
+
|
|
9
|
+
const getAllMessages = emailModel => {
|
|
10
|
+
return dbEmailsApi.getAllMessages(emailModel);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const deleteMultipleMessages = emailIds => {
|
|
14
|
+
return dbEmailsApi.deleteMultipleMessages(emailIds);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const deleteAllMessages = () => {
|
|
18
|
+
return dbEmailsApi.deleteAllMessages();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getLastMessage = async (
|
|
22
|
+
{
|
|
23
|
+
recipients,
|
|
24
|
+
recipientsVerification = strict,
|
|
25
|
+
textInSubject,
|
|
26
|
+
textInBody,
|
|
27
|
+
excludingPhrasesInBody,
|
|
28
|
+
regex,
|
|
29
|
+
returnType
|
|
30
|
+
} = {}
|
|
31
|
+
) => {
|
|
32
|
+
async function getLatestMessage(messages) {
|
|
33
|
+
for (const message of messages) {
|
|
34
|
+
/* The query we use to search for messages guarantees the recipients are included,
|
|
35
|
+
but it doesn't guarantee other emails aren't in to, cc or bcc */
|
|
36
|
+
let emailsMatch = true;
|
|
37
|
+
|
|
38
|
+
if (recipientsVerification === strict) {
|
|
39
|
+
const emptyArray = [''];
|
|
40
|
+
|
|
41
|
+
const expectedRecipients = {
|
|
42
|
+
from: util.extractEmailFromNameAndEmailFormat(recipients.from),
|
|
43
|
+
to: recipients.to || emptyArray,
|
|
44
|
+
cc: recipients.cc || emptyArray
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const actualRecipients = {
|
|
48
|
+
from: util.extractEmailFromNameAndEmailFormat(message.from),
|
|
49
|
+
to: message.recipientsTo || emptyArray,
|
|
50
|
+
cc: message.recipientsCc || emptyArray
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
emailsMatch = util.recipientsMatchVerification(expectedRecipients, actualRecipients);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!emailsMatch) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const result = regex ? util.regexVerification(message.body, regex, { returnType }) : message.body;
|
|
61
|
+
|
|
62
|
+
const isMessageNewest = timeUtils.isDateAfterOther(message.insertedTime, newestDateTime);
|
|
63
|
+
|
|
64
|
+
if (result && (!newestResult || !newestId || isMessageNewest)) {
|
|
65
|
+
newestResult = result;
|
|
66
|
+
newestId = message.id;
|
|
67
|
+
newestDateTime = message.insertedTime;
|
|
68
|
+
|
|
69
|
+
// Used for logging purposes only
|
|
70
|
+
newestTo = message.recipientsTo;
|
|
71
|
+
newestCc = message.recipientsCc;
|
|
72
|
+
newestSubject = message.subject;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let newestDateTime = '2020-01-01T01:01:01.000+0000';
|
|
78
|
+
let newestId, newestResult, newestTo, newestCc, newestSubject;
|
|
79
|
+
|
|
80
|
+
let recipientsTo = recipients.to;
|
|
81
|
+
let includesOneOfRecipientsTo;
|
|
82
|
+
|
|
83
|
+
if (recipientsVerification !== strict) {
|
|
84
|
+
recipientsTo = null;
|
|
85
|
+
includesOneOfRecipientsTo = recipients.to;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// In case the format is 'First Last <username@domain.com>' we need the email part only
|
|
89
|
+
const emailModel = new EmailModel(
|
|
90
|
+
util.extractEmailFromNameAndEmailFormat(recipients.from),
|
|
91
|
+
recipientsTo,
|
|
92
|
+
includesOneOfRecipientsTo,
|
|
93
|
+
recipients.cc,
|
|
94
|
+
textInSubject,
|
|
95
|
+
textInBody,
|
|
96
|
+
excludingPhrasesInBody
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const response = await getAllMessages(emailModel);
|
|
100
|
+
|
|
101
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
102
|
+
throw new Error('Inbox messages could not be retrieved', response);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
await getLatestMessage(response.data);
|
|
106
|
+
|
|
107
|
+
if (newestId) {
|
|
108
|
+
util.logRetrievedEmailInfo(newestTo, newestSubject, { cc: newestCc });
|
|
109
|
+
|
|
110
|
+
const response = await deleteMultipleMessages([newestId]);
|
|
111
|
+
|
|
112
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
113
|
+
throw new Error(`Failed to delete email with ID : ${newestId}`, response);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return newestResult;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
module.exports = {
|
|
121
|
+
util,
|
|
122
|
+
|
|
123
|
+
getAllMessages,
|
|
124
|
+
getLastMessage,
|
|
125
|
+
deleteMultipleMessages,
|
|
126
|
+
deleteAllMessages
|
|
127
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
const services = require('./api/db.emails.service');
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const services = require('./api/db.emails.service');
|
|
2
|
+
const consts = require('./consts/consts');
|
|
3
|
+
|
|
4
|
+
module.exports = { services, consts };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
class EmailModel {
|
|
2
|
-
constructor(
|
|
3
|
-
from,
|
|
4
|
-
recipientsTo,
|
|
5
|
-
includesOneOfRecipientsTo,
|
|
6
|
-
recipientsCc,
|
|
7
|
-
textInSubject,
|
|
8
|
-
textInBody,
|
|
9
|
-
excludingPhrasesInBody
|
|
10
|
-
) {
|
|
11
|
-
this.from = from;
|
|
12
|
-
this.recipientsTo = recipientsTo;
|
|
13
|
-
this.includesOneOfRecipientsTo = includesOneOfRecipientsTo;
|
|
14
|
-
this.recipientsCc = recipientsCc;
|
|
15
|
-
this.textInSubject = textInSubject;
|
|
16
|
-
this.textInBody = textInBody;
|
|
17
|
-
this.excludingPhrasesInBody = excludingPhrasesInBody;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = EmailModel;
|
|
1
|
+
class EmailModel {
|
|
2
|
+
constructor(
|
|
3
|
+
from,
|
|
4
|
+
recipientsTo,
|
|
5
|
+
includesOneOfRecipientsTo,
|
|
6
|
+
recipientsCc,
|
|
7
|
+
textInSubject,
|
|
8
|
+
textInBody,
|
|
9
|
+
excludingPhrasesInBody
|
|
10
|
+
) {
|
|
11
|
+
this.from = from;
|
|
12
|
+
this.recipientsTo = recipientsTo;
|
|
13
|
+
this.includesOneOfRecipientsTo = includesOneOfRecipientsTo;
|
|
14
|
+
this.recipientsCc = recipientsCc;
|
|
15
|
+
this.textInSubject = textInSubject;
|
|
16
|
+
this.textInBody = textInBody;
|
|
17
|
+
this.excludingPhrasesInBody = excludingPhrasesInBody;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { EmailModel };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const compareUnorderedArrays = (arr, other, { caseSensitive = true } = {}) => {
|
|
2
|
+
const isEachElementEqual = arr.sort().every((mail, i) => {
|
|
3
|
+
if (caseSensitive) {
|
|
4
|
+
return mail === other.sort()[i];
|
|
5
|
+
} else {
|
|
6
|
+
return mail.toLowerCase() === other.sort()[i].toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
return arr.length === other.length && isEachElementEqual;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const recipientsMatchVerification = (expectedRecipients, actualRecipients) => {
|
|
13
|
+
const caseSensitive = false;
|
|
14
|
+
|
|
15
|
+
return expectedRecipients.from.includes(actualRecipients.from) && // For some emails can be few sendor options (ex: branded emails)
|
|
16
|
+
compareUnorderedArrays(actualRecipients.to, expectedRecipients.to, { caseSensitive }) &&
|
|
17
|
+
compareUnorderedArrays(actualRecipients.cc, expectedRecipients.cc, { caseSensitive });
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const regexVerification = (message, regex, { returnType } = {}) => {
|
|
21
|
+
const capturingGroupsArr = message.match(regex);
|
|
22
|
+
|
|
23
|
+
if (!capturingGroupsArr || capturingGroupsArr.length < 1) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const capturingGroups = capturingGroupsArr[capturingGroupsArr.length - 1];
|
|
28
|
+
|
|
29
|
+
if (!capturingGroups || capturingGroups.length < 2) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
switch (returnType) {
|
|
34
|
+
case 'url':
|
|
35
|
+
return typeof capturingGroups === 'string' ? capturingGroups : capturingGroups[capturingGroups.length - 1];
|
|
36
|
+
case 'body':
|
|
37
|
+
return message;
|
|
38
|
+
default:
|
|
39
|
+
return 'Bad "returnType" argument';
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const extractEmailFromNameAndEmailFormat = str => {
|
|
44
|
+
// In case the format is 'First Last <username@domain.com>' we will return username@domain.com only
|
|
45
|
+
return str.split('<').pop().split('>')[0];
|
|
46
|
+
};
|
|
47
|
+
const logRetrievedEmailInfo = (to, subject, { cc } = {}) => {
|
|
48
|
+
let log = 'The following email retrieved and will be sent to trash:';
|
|
49
|
+
log += `\n| To: ${to}`;
|
|
50
|
+
cc ? log += `\n| Cc: ${cc}` : '';
|
|
51
|
+
log += `\n| Subject: ${subject}`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
recipientsMatchVerification,
|
|
56
|
+
regexVerification,
|
|
57
|
+
extractEmailFromNameAndEmailFormat,
|
|
58
|
+
logRetrievedEmailInfo
|
|
59
|
+
};
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
const cookieAuthRequests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
-
const apiKeyAuthRequests = require('../../../../common/requests/apiKeyAuth/requests');
|
|
3
|
-
|
|
4
|
-
const { nodeBackendUrl, backendUrl } = require('../../../../env').getEnv();
|
|
5
|
-
|
|
6
|
-
const Endpoints = {
|
|
7
|
-
createGlobalRecord: `${nodeBackendUrl}/global-record`,
|
|
8
|
-
getGlobalRecordById: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
9
|
-
getAllGlobalRecords: (pageNumber, itemsInPage) => `${nodeBackendUrl}/global-record/all-global-records/${pageNumber}/items/${itemsInPage}`,
|
|
10
|
-
getGlobalRecordServiceAreas: `${backendUrl}/saas/global-record/service-areas`,
|
|
11
|
-
deleteGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
12
|
-
updateGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
13
|
-
getRecordProfileDetails: id => `${nodeBackendUrl}/global-record/record-profile/id/${id}`,
|
|
14
|
-
getGlobalRecordByPolicyNumber: policyNumber => `${nodeBackendUrl}/global-record/policyNumber/${policyNumber}`,
|
|
15
|
-
publishGlobalRecord: `${backendUrl}/saas/global-record/publish`,
|
|
16
|
-
getGlobalRecordLinkedRecords: id => `${backendUrl}/saas/global-record/${id}/linked-records`,
|
|
17
|
-
splitToNewGlobalRecord: `${backendUrl}/saas/global-record/split-to-new`
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getGlobalRecord = async (id, nodeBackendSecret) => {
|
|
21
|
-
return apiKeyAuthRequests.getRequestHandler(Endpoints.getGlobalRecordById(id), nodeBackendSecret);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const createGlobalRecord = async (globalRecord, nodeBackendSecret) => {
|
|
25
|
-
return apiKeyAuthRequests.postRequestHandler(Endpoints.createGlobalRecord, nodeBackendSecret, globalRecord);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getAllGlobalRecords = async (data, pageNumber, itemsInPage, context) => {
|
|
29
|
-
return cookieAuthRequests.postRequestHandler(Endpoints.getAllGlobalRecords(pageNumber, itemsInPage), data, context);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const deleteGlobalRecord = async (id, nodeBackendSecret, globalRecordModel) => {
|
|
33
|
-
return apiKeyAuthRequests.deleteRequestHandler(Endpoints.deleteGlobalRecord(id), nodeBackendSecret, {}, {}, globalRecordModel);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const updateGlobalRecord = async (id, nodeBackendSecret, updatedGlobalRecord) => {
|
|
37
|
-
return apiKeyAuthRequests.putRequestHandler(Endpoints.updateGlobalRecord(id), nodeBackendSecret, updatedGlobalRecord);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const getGlobalRecordServiceAreas = async context => {
|
|
41
|
-
return cookieAuthRequests.getRequestHandler(Endpoints.getGlobalRecordServiceAreas, {}, context);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const getRecordProfileDetails = async (id, context) => {
|
|
45
|
-
return cookieAuthRequests.getRequestHandler(Endpoints.getRecordProfileDetails(id), {}, context);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const publishGlobalRecord = async (globalRecordDetails, context) => {
|
|
49
|
-
return cookieAuthRequests.putRequestHandler(Endpoints.publishGlobalRecord, globalRecordDetails, context);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const getGlobalRecordByPolicyNumber = async (policyNumber, nodeBackendSecret) => {
|
|
53
|
-
return apiKeyAuthRequests.getRequestHandler(Endpoints.getGlobalRecordByPolicyNumber(policyNumber), nodeBackendSecret);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const getGlobalRecordLinkedRecords = async (id, context) => {
|
|
57
|
-
return cookieAuthRequests.getRequestHandler(Endpoints.getGlobalRecordLinkedRecords(id), {}, context);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const splitToNewGlobalRecord = ({ recordId, glPolicyNumber }, context) => {
|
|
61
|
-
return cookieAuthRequests.postRequestHandler(Endpoints.splitToNewGlobalRecord, { recordId, glPolicyNumber }, context);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
module.exports = {
|
|
65
|
-
createGlobalRecord,
|
|
66
|
-
getGlobalRecord,
|
|
67
|
-
getAllGlobalRecords,
|
|
68
|
-
getGlobalRecordServiceAreas,
|
|
69
|
-
deleteGlobalRecord,
|
|
70
|
-
updateGlobalRecord,
|
|
71
|
-
getRecordProfileDetails,
|
|
72
|
-
getGlobalRecordByPolicyNumber,
|
|
73
|
-
publishGlobalRecord,
|
|
74
|
-
getGlobalRecordLinkedRecords,
|
|
75
|
-
splitToNewGlobalRecord
|
|
76
|
-
};
|
|
1
|
+
const cookieAuthRequests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const apiKeyAuthRequests = require('../../../../common/requests/apiKeyAuth/requests');
|
|
3
|
+
|
|
4
|
+
const { nodeBackendUrl, backendUrl } = require('../../../../env').getEnv();
|
|
5
|
+
|
|
6
|
+
const Endpoints = {
|
|
7
|
+
createGlobalRecord: `${nodeBackendUrl}/global-record`,
|
|
8
|
+
getGlobalRecordById: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
9
|
+
getAllGlobalRecords: (pageNumber, itemsInPage) => `${nodeBackendUrl}/global-record/all-global-records/${pageNumber}/items/${itemsInPage}`,
|
|
10
|
+
getGlobalRecordServiceAreas: `${backendUrl}/saas/global-record/service-areas`,
|
|
11
|
+
deleteGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
12
|
+
updateGlobalRecord: id => `${nodeBackendUrl}/global-record/id/${id}`,
|
|
13
|
+
getRecordProfileDetails: id => `${nodeBackendUrl}/global-record/record-profile/id/${id}`,
|
|
14
|
+
getGlobalRecordByPolicyNumber: policyNumber => `${nodeBackendUrl}/global-record/policyNumber/${policyNumber}`,
|
|
15
|
+
publishGlobalRecord: `${backendUrl}/saas/global-record/publish`,
|
|
16
|
+
getGlobalRecordLinkedRecords: id => `${backendUrl}/saas/global-record/${id}/linked-records`,
|
|
17
|
+
splitToNewGlobalRecord: `${backendUrl}/saas/global-record/split-to-new`
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getGlobalRecord = async (id, nodeBackendSecret) => {
|
|
21
|
+
return apiKeyAuthRequests.getRequestHandler(Endpoints.getGlobalRecordById(id), nodeBackendSecret);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const createGlobalRecord = async (globalRecord, nodeBackendSecret) => {
|
|
25
|
+
return apiKeyAuthRequests.postRequestHandler(Endpoints.createGlobalRecord, nodeBackendSecret, globalRecord);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getAllGlobalRecords = async (data, pageNumber, itemsInPage, context) => {
|
|
29
|
+
return cookieAuthRequests.postRequestHandler(Endpoints.getAllGlobalRecords(pageNumber, itemsInPage), data, context);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const deleteGlobalRecord = async (id, nodeBackendSecret, globalRecordModel) => {
|
|
33
|
+
return apiKeyAuthRequests.deleteRequestHandler(Endpoints.deleteGlobalRecord(id), nodeBackendSecret, {}, {}, globalRecordModel);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const updateGlobalRecord = async (id, nodeBackendSecret, updatedGlobalRecord) => {
|
|
37
|
+
return apiKeyAuthRequests.putRequestHandler(Endpoints.updateGlobalRecord(id), nodeBackendSecret, updatedGlobalRecord);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getGlobalRecordServiceAreas = async context => {
|
|
41
|
+
return cookieAuthRequests.getRequestHandler(Endpoints.getGlobalRecordServiceAreas, {}, context);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getRecordProfileDetails = async (id, context) => {
|
|
45
|
+
return cookieAuthRequests.getRequestHandler(Endpoints.getRecordProfileDetails(id), {}, context);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const publishGlobalRecord = async (globalRecordDetails, context) => {
|
|
49
|
+
return cookieAuthRequests.putRequestHandler(Endpoints.publishGlobalRecord, globalRecordDetails, context);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const getGlobalRecordByPolicyNumber = async (policyNumber, nodeBackendSecret) => {
|
|
53
|
+
return apiKeyAuthRequests.getRequestHandler(Endpoints.getGlobalRecordByPolicyNumber(policyNumber), nodeBackendSecret);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getGlobalRecordLinkedRecords = async (id, context) => {
|
|
57
|
+
return cookieAuthRequests.getRequestHandler(Endpoints.getGlobalRecordLinkedRecords(id), {}, context);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const splitToNewGlobalRecord = ({ recordId, glPolicyNumber }, context) => {
|
|
61
|
+
return cookieAuthRequests.postRequestHandler(Endpoints.splitToNewGlobalRecord, { recordId, glPolicyNumber }, context);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
createGlobalRecord,
|
|
66
|
+
getGlobalRecord,
|
|
67
|
+
getAllGlobalRecords,
|
|
68
|
+
getGlobalRecordServiceAreas,
|
|
69
|
+
deleteGlobalRecord,
|
|
70
|
+
updateGlobalRecord,
|
|
71
|
+
getRecordProfileDetails,
|
|
72
|
+
getGlobalRecordByPolicyNumber,
|
|
73
|
+
publishGlobalRecord,
|
|
74
|
+
getGlobalRecordLinkedRecords,
|
|
75
|
+
splitToNewGlobalRecord
|
|
76
|
+
};
|