@getjones/test-infra 2.6.1 → 2.6.3
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 -30
- package/src/common/commonFlows/index.js +3 -3
- package/src/common/commonFlows/records/records.js +71 -71
- package/src/common/consts/userTypes.js +5 -0
- 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/dataTypeUtils.js +41 -41
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/objectUtils.js +7 -9
- package/src/common/utils/timeUtils.js +171 -171
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/defaults/configs/auditConfigs.js +85 -85
- package/src/defaults/configs/polices.js +47 -47
- package/src/defaults/configs/requirement.js +29 -29
- package/src/defaults/index.js +5 -5
- package/src/env.js +57 -57
- package/src/factory/index.js +5 -0
- package/src/factory/records/records.js +105 -0
- package/src/index.js +74 -73
- package/src/resources/coi/coi.pdf +0 -0
- package/src/resources/coi/realCoi.pdf +5617 -20
- 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/consts/consts.js +6 -6
- package/src/saas/internal-api/accounts/index.js +21 -21
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +23 -23
- package/src/saas/internal-api/accounts/utils/utils.js +32 -32
- package/src/saas/internal-api/auth/api/auth.api.js +18 -18
- package/src/saas/internal-api/auth/api/auth.service.js +67 -67
- 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 +5 -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 +152 -151
- 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 +100 -15
- package/src/saas/internal-api/compliance/consts/audit.js +71 -81
- package/src/saas/internal-api/compliance/index.js +28 -28
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -84
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +48 -45
- package/src/saas/internal-api/compliance/utils/util.js +207 -175
- package/src/saas/internal-api/contractors/api/contractors.api.js +141 -141
- package/src/saas/internal-api/contractors/api/contractors.service.js +147 -147
- 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 +60 -60
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +12 -12
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +7 -7
- package/src/saas/internal-api/dashboardInnerPage/index.js +5 -5
- package/src/saas/internal-api/dashboardInnerPage/models/dashboard.filter.criteria.model.js +38 -38
- 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 -127
- package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
- package/src/saas/internal-api/dbEmails/index.js +4 -4
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
- package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
- 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 +54 -54
- package/src/saas/internal-api/requests/api/requests.service.js +84 -51
- package/src/saas/internal-api/requests/index.js +14 -14
- package/src/saas/internal-api/requests/models/create.request.model.js +22 -22
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requests/utils.js +8 -8
- package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
- package/src/saas/internal-api/requirements/api/requirements.service.js +94 -94
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +5 -5
- package/src/saas/internal-api/requirements/consts/consts.js +6 -6
- package/src/saas/internal-api/requirements/index.js +8 -8
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
- package/src/saas/internal-api/requirements/models/policy.model.js +32 -32
- package/src/saas/internal-api/requirements/models/update.requirement.model.js +21 -21
- package/src/saas/internal-api/requirements/utils/utils.js +101 -101
- 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 +39 -39
- package/src/saas/internal-api/users/api/users.api.js +77 -77
- 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 -6
- package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
- package/src/saas/openapi/requests/requests.api.js +20 -20
- package/src/saas/openapi/requests/requests.service.js +18 -18
- 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
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
|
-
|
|
3
|
-
class ContractorModel {
|
|
4
|
-
constructor(contractorId, recordType, company, emailAddress, additionalDetails) {
|
|
5
|
-
validateType(additionalDetails, ContractorDetailsModel);
|
|
6
|
-
|
|
7
|
-
this.contractorId = contractorId;
|
|
8
|
-
this.recordType = recordType;
|
|
9
|
-
this.company = company;
|
|
10
|
-
this.emailAddress = emailAddress;
|
|
11
|
-
|
|
12
|
-
for (const detail in additionalDetails) {
|
|
13
|
-
if (additionalDetails[detail]) {
|
|
14
|
-
this[detail] = additionalDetails[detail];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
class ContractorDetailsModel {
|
|
21
|
-
constructor({
|
|
22
|
-
additionalEmails = [],
|
|
23
|
-
dba = null,
|
|
24
|
-
firstName = null,
|
|
25
|
-
lastName = null,
|
|
26
|
-
address = null,
|
|
27
|
-
city = null,
|
|
28
|
-
state = null,
|
|
29
|
-
zipCode = null,
|
|
30
|
-
phoneNumber = null,
|
|
31
|
-
recordId = null,
|
|
32
|
-
projectDescription = null,
|
|
33
|
-
startDate = null,
|
|
34
|
-
endDate = null
|
|
35
|
-
} = {}) {
|
|
36
|
-
this.dba = dba;
|
|
37
|
-
this.fName = firstName;
|
|
38
|
-
this.lName = lastName;
|
|
39
|
-
this.location = address;
|
|
40
|
-
this.city = city;
|
|
41
|
-
this.state = state;
|
|
42
|
-
this.zipCode = zipCode;
|
|
43
|
-
this.phoneNumber = phoneNumber;
|
|
44
|
-
this.externalRecordId = recordId;
|
|
45
|
-
this.descriptionOfOperations = projectDescription;
|
|
46
|
-
this.startDate = startDate;
|
|
47
|
-
this.endDate = endDate;
|
|
48
|
-
|
|
49
|
-
this.additionalEmails = [];
|
|
50
|
-
|
|
51
|
-
for (const email of additionalEmails) {
|
|
52
|
-
this.additionalEmails.push(typeof email === 'string' ? { email: email } : email);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = {
|
|
58
|
-
ContractorModel,
|
|
59
|
-
ContractorDetailsModel
|
|
60
|
-
};
|
|
1
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
|
+
|
|
3
|
+
class ContractorModel {
|
|
4
|
+
constructor(contractorId, recordType, company, emailAddress, additionalDetails) {
|
|
5
|
+
validateType(additionalDetails, ContractorDetailsModel);
|
|
6
|
+
|
|
7
|
+
this.contractorId = contractorId;
|
|
8
|
+
this.recordType = recordType;
|
|
9
|
+
this.company = company;
|
|
10
|
+
this.emailAddress = emailAddress;
|
|
11
|
+
|
|
12
|
+
for (const detail in additionalDetails) {
|
|
13
|
+
if (additionalDetails[detail]) {
|
|
14
|
+
this[detail] = additionalDetails[detail];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class ContractorDetailsModel {
|
|
21
|
+
constructor({
|
|
22
|
+
additionalEmails = [],
|
|
23
|
+
dba = null,
|
|
24
|
+
firstName = null,
|
|
25
|
+
lastName = null,
|
|
26
|
+
address = null,
|
|
27
|
+
city = null,
|
|
28
|
+
state = null,
|
|
29
|
+
zipCode = null,
|
|
30
|
+
phoneNumber = null,
|
|
31
|
+
recordId = null,
|
|
32
|
+
projectDescription = null,
|
|
33
|
+
startDate = null,
|
|
34
|
+
endDate = null
|
|
35
|
+
} = {}) {
|
|
36
|
+
this.dba = dba;
|
|
37
|
+
this.fName = firstName;
|
|
38
|
+
this.lName = lastName;
|
|
39
|
+
this.location = address;
|
|
40
|
+
this.city = city;
|
|
41
|
+
this.state = state;
|
|
42
|
+
this.zipCode = zipCode;
|
|
43
|
+
this.phoneNumber = phoneNumber;
|
|
44
|
+
this.externalRecordId = recordId;
|
|
45
|
+
this.descriptionOfOperations = projectDescription;
|
|
46
|
+
this.startDate = startDate;
|
|
47
|
+
this.endDate = endDate;
|
|
48
|
+
|
|
49
|
+
this.additionalEmails = [];
|
|
50
|
+
|
|
51
|
+
for (const email of additionalEmails) {
|
|
52
|
+
this.additionalEmails.push(typeof email === 'string' ? { email: email } : email);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
ContractorModel,
|
|
59
|
+
ContractorDetailsModel
|
|
60
|
+
};
|
|
@@ -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,12 +1,12 @@
|
|
|
1
|
-
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
-
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
-
|
|
4
|
-
const Endpoints = {
|
|
5
|
-
innerPageRecordsApi: `${backendUrl}/saas/analytics/dashboard/requests`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const getSortedRecordsForDashboardInnerPage = (dashboardCriteriaModel, context) => {
|
|
9
|
-
return requests.postRequestHandler(Endpoints.innerPageRecordsApi, dashboardCriteriaModel, context);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
module.exports = { getSortedRecordsForDashboardInnerPage };
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
innerPageRecordsApi: `${backendUrl}/saas/analytics/dashboard/requests`
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const getSortedRecordsForDashboardInnerPage = (dashboardCriteriaModel, context) => {
|
|
9
|
+
return requests.postRequestHandler(Endpoints.innerPageRecordsApi, dashboardCriteriaModel, context);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = { getSortedRecordsForDashboardInnerPage };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const recordListAPI = require('./recordList.api');
|
|
2
|
-
|
|
3
|
-
const getSortedRecordsForDashboardInnerPage = (dashboardCriteriaModel, context) => {
|
|
4
|
-
return recordListAPI.getSortedRecordsForDashboardInnerPage(dashboardCriteriaModel, context);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
module.exports = { getSortedRecordsForDashboardInnerPage };
|
|
1
|
+
const recordListAPI = require('./recordList.api');
|
|
2
|
+
|
|
3
|
+
const getSortedRecordsForDashboardInnerPage = (dashboardCriteriaModel, context) => {
|
|
4
|
+
return recordListAPI.getSortedRecordsForDashboardInnerPage(dashboardCriteriaModel, context);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
module.exports = { getSortedRecordsForDashboardInnerPage };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const criteria = require('./models/dashboard.filter.criteria.model');
|
|
2
|
-
const services = require('./api/recordList.service');
|
|
3
|
-
|
|
4
|
-
const models = { filterCriteria: criteria };
|
|
5
|
-
module.exports = { services, models };
|
|
1
|
+
const criteria = require('./models/dashboard.filter.criteria.model');
|
|
2
|
+
const services = require('./api/recordList.service');
|
|
3
|
+
|
|
4
|
+
const models = { filterCriteria: criteria };
|
|
5
|
+
module.exports = { services, models };
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
|
-
|
|
3
|
-
class DashboardInnerPageRecordListCriteriaModel {
|
|
4
|
-
constructor({
|
|
5
|
-
appliedFilters = [],
|
|
6
|
-
criteria = null,
|
|
7
|
-
chartType = null,
|
|
8
|
-
sortBy = null,
|
|
9
|
-
sortOrder = null,
|
|
10
|
-
pageNo = 1
|
|
11
|
-
} = {}) {
|
|
12
|
-
appliedFilters && validateType(appliedFilters, AnalyticsDashboardRequestModel);
|
|
13
|
-
|
|
14
|
-
this.appliedFilters = appliedFilters,
|
|
15
|
-
this.criteria = criteria,
|
|
16
|
-
this.chartType = chartType,
|
|
17
|
-
this.sortBy = sortBy,
|
|
18
|
-
this.sortOrder = sortOrder,
|
|
19
|
-
this.pageNo = pageNo;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class AnalyticsDashboardRequestModel {
|
|
24
|
-
constructor({
|
|
25
|
-
propertiesIds = [],
|
|
26
|
-
recordTypes = [],
|
|
27
|
-
accountId = null
|
|
28
|
-
} = {}) {
|
|
29
|
-
this.propertiesIds = propertiesIds;
|
|
30
|
-
this.recordTypes = recordTypes;
|
|
31
|
-
this.accountId = accountId;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = {
|
|
36
|
-
DashboardInnerPageRecordListCriteriaModel,
|
|
37
|
-
AnalyticsDashboardRequestModel
|
|
38
|
-
};
|
|
1
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
|
+
|
|
3
|
+
class DashboardInnerPageRecordListCriteriaModel {
|
|
4
|
+
constructor({
|
|
5
|
+
appliedFilters = [],
|
|
6
|
+
criteria = null,
|
|
7
|
+
chartType = null,
|
|
8
|
+
sortBy = null,
|
|
9
|
+
sortOrder = null,
|
|
10
|
+
pageNo = 1
|
|
11
|
+
} = {}) {
|
|
12
|
+
appliedFilters && validateType(appliedFilters, AnalyticsDashboardRequestModel);
|
|
13
|
+
|
|
14
|
+
this.appliedFilters = appliedFilters,
|
|
15
|
+
this.criteria = criteria,
|
|
16
|
+
this.chartType = chartType,
|
|
17
|
+
this.sortBy = sortBy,
|
|
18
|
+
this.sortOrder = sortOrder,
|
|
19
|
+
this.pageNo = pageNo;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class AnalyticsDashboardRequestModel {
|
|
24
|
+
constructor({
|
|
25
|
+
propertiesIds = [],
|
|
26
|
+
recordTypes = [],
|
|
27
|
+
accountId = null
|
|
28
|
+
} = {}) {
|
|
29
|
+
this.propertiesIds = propertiesIds;
|
|
30
|
+
this.recordTypes = recordTypes;
|
|
31
|
+
this.accountId = accountId;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
DashboardInnerPageRecordListCriteriaModel,
|
|
37
|
+
AnalyticsDashboardRequestModel
|
|
38
|
+
};
|
|
@@ -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, {}, {}, 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
|
+
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,127 +1,127 @@
|
|
|
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
|
+
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,3 @@
|
|
|
1
|
-
const DEFAULT_EMAIL_SENDER = 'hellogetjonestest@gmail.com';
|
|
2
|
-
|
|
3
|
-
module.exports = { DEFAULT_EMAIL_SENDER };
|
|
1
|
+
const DEFAULT_EMAIL_SENDER = 'hellogetjonestest@gmail.com';
|
|
2
|
+
|
|
3
|
+
module.exports = { DEFAULT_EMAIL_SENDER };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const services = require('./api/db.emails.service');
|
|
2
|
-
const consts = require('./consts/consts');
|
|
3
|
-
|
|
4
|
-
module.exports = { services, consts };
|
|
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 };
|