@getjones/test-infra 2.13.1 → 3.0.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 +30 -30
- package/src/common/commonFlows/auth/auth.js +40 -40
- package/src/common/commonFlows/index.js +4 -4
- package/src/common/commonFlows/records/records.js +102 -102
- package/src/common/consts/dashboardCharts.js +18 -18
- package/src/common/consts/recordTypes.js +5 -5
- package/src/common/consts/s3FileTypes.js +12 -12
- package/src/common/consts/userTypes.js +8 -8
- package/src/common/httpResponseStatusCodes.json +11 -11
- package/src/common/requests/apiKeyAuth/requests.js +44 -44
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/internalAuth/requests.js +48 -38
- package/src/common/requests/requestHandlers.js +78 -78
- package/src/common/utils/complianceUtil.js +83 -83
- package/src/common/utils/configsUtil.js +22 -22
- package/src/common/utils/dataTypeUtils.js +41 -41
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/objectUtils.js +7 -7
- package/src/common/utils/timeUtils.js +177 -177
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/defaults/configs/auditConfigs.js +91 -91
- package/src/defaults/configs/coverage.js +227 -227
- package/src/defaults/configs/polices.js +64 -60
- package/src/defaults/configs/requirement.js +32 -32
- package/src/defaults/index.js +6 -6
- package/src/env.js +57 -57
- package/src/factory/globalRecord/globalRecord.js +70 -70
- package/src/factory/index.js +8 -8
- package/src/factory/records/records.js +147 -147
- package/src/factory/users/users.js +77 -77
- package/src/index.js +91 -91
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
- 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 +41 -41
- package/src/saas/internal-api/accounts/consts/consts.js +6 -6
- package/src/saas/internal-api/accounts/index.js +20 -20
- 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 +38 -38
- package/src/saas/internal-api/accounts/utils/utils.js +58 -58
- package/src/saas/internal-api/agreement/api/agreement.api.js +35 -35
- package/src/saas/internal-api/agreement/api/agreement.service.js +81 -81
- package/src/saas/internal-api/agreement/consts/consts.js +8 -8
- package/src/saas/internal-api/agreement/index.js +11 -11
- package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
- package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
- package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
- package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
- package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
- package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
- package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
- package/src/saas/internal-api/auditNotes/index.js +4 -4
- package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
- package/src/saas/internal-api/auth/api/auth.api.js +27 -27
- package/src/saas/internal-api/auth/api/auth.service.js +90 -90
- 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 -5
- 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 +100 -100
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +230 -230
- 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 +48 -48
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +33 -33
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +141 -141
- package/src/saas/internal-api/compliance/consts/audit.js +103 -103
- package/src/saas/internal-api/compliance/index.js +33 -33
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +94 -94
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
- package/src/saas/internal-api/compliance/utils/auditUtil.js +222 -222
- package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
- package/src/saas/internal-api/contractors/api/contractors.api.js +179 -179
- package/src/saas/internal-api/contractors/api/contractors.service.js +234 -234
- package/src/saas/internal-api/contractors/consts/consts.js +6 -6
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
- 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/contractors/utils.js +25 -25
- package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
- package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
- package/src/saas/internal-api/dashboard/index.js +5 -5
- package/src/saas/internal-api/dashboard/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 +147 -147
- package/src/saas/internal-api/dbEmails/consts/consts.js +54 -54
- package/src/saas/internal-api/dbEmails/index.js +6 -6
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
- package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
- package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
- package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
- package/src/saas/internal-api/emailCustomization/index.js +3 -3
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +105 -106
- 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 +60 -60
- package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
- 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 +35 -35
- 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 +41 -41
- package/src/saas/internal-api/projects/utils/utils.js +156 -156
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +47 -47
- package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
- 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 +64 -64
- 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 +78 -78
- package/src/saas/internal-api/requests/api/requests.service.js +153 -153
- package/src/saas/internal-api/requests/index.js +16 -16
- package/src/saas/internal-api/requests/models/create.request.model.js +34 -34
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/inner.page.request.criteria.model.js +17 -17
- 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/requestsTable/api/requests.table.api.js +20 -20
- package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
- package/src/saas/internal-api/requestsTable/index.js +3 -3
- package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
- package/src/saas/internal-api/requirements/api/requirements.service.js +142 -142
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -6
- package/src/saas/internal-api/requirements/consts/consts.js +6 -6
- package/src/saas/internal-api/requirements/index.js +10 -10
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
- package/src/saas/internal-api/requirements/models/policy.model.js +33 -33
- package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
- package/src/saas/internal-api/requirements/utils/utils.js +116 -116
- 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 +19 -19
- package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +31 -31
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +42 -42
- package/src/saas/internal-api/uploadFiles/consts.js +12 -12
- package/src/saas/internal-api/uploadFiles/index.js +3 -3
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +32 -32
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +93 -93
- package/src/saas/internal-api/users/api/users.api.js +115 -115
- package/src/saas/internal-api/users/api/users.service.js +203 -203
- package/src/saas/internal-api/users/index.js +16 -16
- package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
- package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
- package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
- package/src/saas/internal-api/users/models/users.model.js +41 -41
- package/src/saas/internal-api/users/utils/util.js +39 -39
- 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/coi/coi.api.js +20 -20
- package/src/saas/openapi/coi/coi.service.js +13 -13
- package/src/saas/openapi/projects/projects.api.js +83 -83
- package/src/saas/openapi/projects/projects.service.js +64 -64
- package/src/saas/openapi/requests/index.js +7 -7
- package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
- package/src/saas/openapi/requests/models/update.request.model.js +35 -35
- package/src/saas/openapi/requests/requests.api.js +82 -82
- package/src/saas/openapi/requests/requests.service.js +70 -70
- 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 +32 -32
- package/src/saas/openapi/requirements/requirements.service.js +37 -37
- package/src/saas/openapi/tabs/index.js +6 -6
- package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
- package/src/saas/openapi/tabs/tabs.api.js +27 -27
- package/src/saas/openapi/tabs/tabs.service.js +19 -19
- package/src/saas/openapi/users/user.model.js +10 -10
- package/src/saas/openapi/users/users.api.js +33 -33
- package/src/saas/openapi/users/users.service.js +41 -41
- package/tests/env.test.js +40 -40
- package/tests/validation.test.js +83 -83
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
const contractorsAPI = require('./contractors.api');
|
|
2
|
-
const { RequestModel } = require('../../requests/models/edit.request.model');
|
|
3
|
-
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
|
-
const { RecordModifyDateVerificationModel } = require('../models/verification.contractor.model');
|
|
5
|
-
const { AssignRequirementModel } = require('../models/assign.requirement.model');
|
|
6
|
-
const { ContractorDetailsModel } = require('../models/edit.contractor.model');
|
|
7
|
-
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
8
|
-
const { waitFor } = require('../../../../common/utils/timeUtils');
|
|
9
|
-
const utils = require('../utils');
|
|
10
|
-
|
|
11
|
-
const getContractorsByAccountId = async (accountId, context, activationStatus = null) => {
|
|
12
|
-
if (activationStatus) {
|
|
13
|
-
activationStatus = activationStatus.reduce((f, s) => `${f},${s}`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return contractorsAPI.getContractorsByAccountId({ accountId, activationStatus }, context);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const getContractorById = (contractorId, context) => {
|
|
20
|
-
return contractorsAPI.getContractorById(contractorId, context);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const getRecordHistory = (contractorId, context) => {
|
|
24
|
-
return contractorsAPI.getRecordHistory(contractorId, context);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const archiveRecord = (recordVerificationModel, context) => {
|
|
28
|
-
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
29
|
-
return contractorsAPI.archiveRecord(recordVerificationModel, context);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const restoreRecord = (recordVerificationModel, context) => {
|
|
33
|
-
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
34
|
-
return contractorsAPI.restoreRecord(recordVerificationModel, context);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const editContractor = (editRequestModel, context) => {
|
|
38
|
-
validateType(editRequestModel, RequestModel);
|
|
39
|
-
return contractorsAPI.editContractor(editRequestModel, context);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const updateExpiryDate = (contractorId, expiryDate, policyName) => {
|
|
43
|
-
return contractorsAPI.updateExpiryDate(contractorId, expiryDate, policyName);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const assignRequirement = (requestId, assignRequirementModel, context) => {
|
|
47
|
-
return contractorsAPI.assignRequirement(requestId, assignRequirementModel, context);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const updateInviteDate = (contractorId, inviteDate, context) => {
|
|
51
|
-
return contractorsAPI.updateInviteDate(contractorId, inviteDate, context);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const updateLastInviteActionDate = (recordId, dateOffset, context) => {
|
|
55
|
-
return contractorsAPI.updateLastInviteActionDate(recordId, dateOffset, context);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getContractorsByTabId = (tabId, context, activityStatus = 'Active') => {
|
|
59
|
-
return contractorsAPI.getContractorsByTabId(tabId, context, activityStatus);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const searchInAutoComplete = ({ tabId, searchWord }, context) => {
|
|
63
|
-
return contractorsAPI.searchInAutocomplete({ tabId, searchWord }, context);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
67
|
-
validateType(uploadDate, Date);
|
|
68
|
-
return contractorsAPI.updateContractorUploadDate(contractorId, uploadDate, context);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const changeRequirement = (recordModifyDateVerificationModel, context) => {
|
|
72
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
73
|
-
return contractorsAPI.changeRequirement(recordModifyDateVerificationModel, context);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const sendGaps = (requestId, recordModifyDateVerificationModel, context) => {
|
|
77
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
78
|
-
return contractorsAPI.sendGaps(requestId, recordModifyDateVerificationModel, context);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const requestNewCoiAboutToExpire = (requestId, recordModifyDateVerificationModel, context) => {
|
|
82
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
83
|
-
return contractorsAPI.requestNewCoiAboutToExpire(requestId, recordModifyDateVerificationModel, context);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const requestNewCoiExpired = (requestId, recordModifyDateVerificationModel, context) => {
|
|
87
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
88
|
-
return contractorsAPI.requestNewCoiExpired(requestId, recordModifyDateVerificationModel, context);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const resendInvitation = (requestId, recordModifyDateVerificationModel, context) => {
|
|
92
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
93
|
-
return contractorsAPI.resendInvitation(requestId, recordModifyDateVerificationModel, context);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const muteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
97
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
98
|
-
return contractorsAPI.muteNotifications(recordModifyDateVerificationModel, context);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const unmuteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
102
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
103
|
-
return contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const deleteByContractorId = (contractorId, context) => {
|
|
107
|
-
return contractorsAPI.deleteByContractorId(contractorId, context);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const deleteAllRecordsInAccount = async (accountId, context, { activationStatus } = {}) => {
|
|
111
|
-
const { data: existingRecords } = await getContractorsByAccountId(accountId, context, activationStatus);
|
|
112
|
-
|
|
113
|
-
if (!existingRecords.length) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const failed = [];
|
|
118
|
-
for (const record of existingRecords) {
|
|
119
|
-
const response = await deleteByContractorId(record.id, context);
|
|
120
|
-
|
|
121
|
-
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
122
|
-
console.error(`Failed to delete record: ${record.company}, retrying...`);
|
|
123
|
-
waitFor(1000);
|
|
124
|
-
const try2response = await deleteByContractorId(record.id, context);
|
|
125
|
-
|
|
126
|
-
if (try2response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
127
|
-
console.error(`Failed to delete record: ${record.company} second time.`);
|
|
128
|
-
failed.push(response);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (failed.length) {
|
|
134
|
-
throw Error(`Failed to delete ${failed.length} of ${existingRecords.length} records in account. Failed with status: ${ failed[0].status }`);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const getRecordVerificationModel = async (recordId, context, { requirementId, requirementDateModified } = {}) => {
|
|
139
|
-
const { data: recordData } = await getContractorById(recordId, context);
|
|
140
|
-
return new RecordModifyDateVerificationModel(recordData.id, { contractorDateModified: recordData.dateModified, requirementId, requirementDateModified });
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const getAssignRequirementModel = (requirementId, companyName, emailAddress) => {
|
|
144
|
-
return new AssignRequirementModel(requirementId, companyName, emailAddress);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const getLinkedProjectsCount = (recordId, context) => {
|
|
148
|
-
return contractorsAPI.getLinkedProjectsCount(recordId, context);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const restoreByRecordId = async (recordId, context) => {
|
|
152
|
-
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
153
|
-
const restoreResponse = await restoreRecord(recordModifyModel, context);
|
|
154
|
-
|
|
155
|
-
if (restoreResponse.status !== httpResponseStatusCodes.OK) {
|
|
156
|
-
throw new Error(`Failed to restore record "${recordId}"\n${restoreResponse.statusText}`);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return restoreResponse;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const archiveByRecordId = async (recordId, context) => {
|
|
163
|
-
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
164
|
-
const archiveResponse = await archiveRecord(recordModifyModel, context);
|
|
165
|
-
|
|
166
|
-
if (archiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
167
|
-
throw new Error(`Failed to archive record "${recordId}"\n${archiveResponse.statusText}`);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return archiveResponse;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const getInviteLinkStatus = (encryptedData, context) => {
|
|
174
|
-
return contractorsAPI.getInviteLinkStatus(encryptedData, context);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const getContractorDetailsModel = recordConfig => {
|
|
178
|
-
const apiDetailsConfig = utils.getRecordDetailsConfigInApiFormat(recordConfig);
|
|
179
|
-
return new ContractorDetailsModel(apiDetailsConfig);
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const getBasicDetailsById = async recordId => {
|
|
183
|
-
const response = await contractorsAPI.getBasicDetailsById(recordId);
|
|
184
|
-
|
|
185
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
186
|
-
throw Error(`Failed to get basic record details by record id: ${recordId} - Response: ${response.status}`);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return response.data;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const getRecordsFromInsuredName = async (insuredName, accountIds) => {
|
|
193
|
-
const response = await contractorsAPI.getRecordsFromInsuredName(insuredName, accountIds);
|
|
194
|
-
|
|
195
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
196
|
-
throw Error(`Failed to get records from insured name: ${insuredName} and accountIds: ${accountIds} - Response: ${response.status}`);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return response.data;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
module.exports = {
|
|
203
|
-
changeRequirement,
|
|
204
|
-
getContractorsByAccountId,
|
|
205
|
-
getContractorById,
|
|
206
|
-
getRecordHistory,
|
|
207
|
-
archiveRecord,
|
|
208
|
-
restoreRecord,
|
|
209
|
-
editContractor,
|
|
210
|
-
updateInviteDate,
|
|
211
|
-
updateExpiryDate,
|
|
212
|
-
getContractorsByTabId,
|
|
213
|
-
searchInAutoComplete,
|
|
214
|
-
updateContractorUploadDate,
|
|
215
|
-
sendGaps,
|
|
216
|
-
requestNewCoiAboutToExpire,
|
|
217
|
-
requestNewCoiExpired,
|
|
218
|
-
resendInvitation,
|
|
219
|
-
muteNotifications,
|
|
220
|
-
unmuteNotifications,
|
|
221
|
-
deleteByContractorId,
|
|
222
|
-
deleteAllRecordsInAccount,
|
|
223
|
-
getRecordVerificationModel,
|
|
224
|
-
assignRequirement,
|
|
225
|
-
getAssignRequirementModel,
|
|
226
|
-
getLinkedProjectsCount,
|
|
227
|
-
archiveByRecordId,
|
|
228
|
-
restoreByRecordId,
|
|
229
|
-
updateLastInviteActionDate,
|
|
230
|
-
getInviteLinkStatus,
|
|
231
|
-
getContractorDetailsModel,
|
|
232
|
-
getBasicDetailsById,
|
|
233
|
-
getRecordsFromInsuredName
|
|
234
|
-
};
|
|
1
|
+
const contractorsAPI = require('./contractors.api');
|
|
2
|
+
const { RequestModel } = require('../../requests/models/edit.request.model');
|
|
3
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
|
+
const { RecordModifyDateVerificationModel } = require('../models/verification.contractor.model');
|
|
5
|
+
const { AssignRequirementModel } = require('../models/assign.requirement.model');
|
|
6
|
+
const { ContractorDetailsModel } = require('../models/edit.contractor.model');
|
|
7
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
8
|
+
const { waitFor } = require('../../../../common/utils/timeUtils');
|
|
9
|
+
const utils = require('../utils');
|
|
10
|
+
|
|
11
|
+
const getContractorsByAccountId = async (accountId, context, activationStatus = null) => {
|
|
12
|
+
if (activationStatus) {
|
|
13
|
+
activationStatus = activationStatus.reduce((f, s) => `${f},${s}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return contractorsAPI.getContractorsByAccountId({ accountId, activationStatus }, context);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getContractorById = (contractorId, context) => {
|
|
20
|
+
return contractorsAPI.getContractorById(contractorId, context);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getRecordHistory = (contractorId, context) => {
|
|
24
|
+
return contractorsAPI.getRecordHistory(contractorId, context);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const archiveRecord = (recordVerificationModel, context) => {
|
|
28
|
+
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
29
|
+
return contractorsAPI.archiveRecord(recordVerificationModel, context);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const restoreRecord = (recordVerificationModel, context) => {
|
|
33
|
+
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
34
|
+
return contractorsAPI.restoreRecord(recordVerificationModel, context);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const editContractor = (editRequestModel, context) => {
|
|
38
|
+
validateType(editRequestModel, RequestModel);
|
|
39
|
+
return contractorsAPI.editContractor(editRequestModel, context);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const updateExpiryDate = (contractorId, expiryDate, policyName) => {
|
|
43
|
+
return contractorsAPI.updateExpiryDate(contractorId, expiryDate, policyName);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const assignRequirement = (requestId, assignRequirementModel, context) => {
|
|
47
|
+
return contractorsAPI.assignRequirement(requestId, assignRequirementModel, context);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const updateInviteDate = (contractorId, inviteDate, context) => {
|
|
51
|
+
return contractorsAPI.updateInviteDate(contractorId, inviteDate, context);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const updateLastInviteActionDate = (recordId, dateOffset, context) => {
|
|
55
|
+
return contractorsAPI.updateLastInviteActionDate(recordId, dateOffset, context);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getContractorsByTabId = (tabId, context, activityStatus = 'Active') => {
|
|
59
|
+
return contractorsAPI.getContractorsByTabId(tabId, context, activityStatus);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const searchInAutoComplete = ({ tabId, searchWord }, context) => {
|
|
63
|
+
return contractorsAPI.searchInAutocomplete({ tabId, searchWord }, context);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
67
|
+
validateType(uploadDate, Date);
|
|
68
|
+
return contractorsAPI.updateContractorUploadDate(contractorId, uploadDate, context);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const changeRequirement = (recordModifyDateVerificationModel, context) => {
|
|
72
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
73
|
+
return contractorsAPI.changeRequirement(recordModifyDateVerificationModel, context);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const sendGaps = (requestId, recordModifyDateVerificationModel, context) => {
|
|
77
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
78
|
+
return contractorsAPI.sendGaps(requestId, recordModifyDateVerificationModel, context);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const requestNewCoiAboutToExpire = (requestId, recordModifyDateVerificationModel, context) => {
|
|
82
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
83
|
+
return contractorsAPI.requestNewCoiAboutToExpire(requestId, recordModifyDateVerificationModel, context);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const requestNewCoiExpired = (requestId, recordModifyDateVerificationModel, context) => {
|
|
87
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
88
|
+
return contractorsAPI.requestNewCoiExpired(requestId, recordModifyDateVerificationModel, context);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const resendInvitation = (requestId, recordModifyDateVerificationModel, context) => {
|
|
92
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
93
|
+
return contractorsAPI.resendInvitation(requestId, recordModifyDateVerificationModel, context);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const muteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
97
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
98
|
+
return contractorsAPI.muteNotifications(recordModifyDateVerificationModel, context);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const unmuteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
102
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
103
|
+
return contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const deleteByContractorId = (contractorId, context) => {
|
|
107
|
+
return contractorsAPI.deleteByContractorId(contractorId, context);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const deleteAllRecordsInAccount = async (accountId, context, { activationStatus } = {}) => {
|
|
111
|
+
const { data: existingRecords } = await getContractorsByAccountId(accountId, context, activationStatus);
|
|
112
|
+
|
|
113
|
+
if (!existingRecords.length) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const failed = [];
|
|
118
|
+
for (const record of existingRecords) {
|
|
119
|
+
const response = await deleteByContractorId(record.id, context);
|
|
120
|
+
|
|
121
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
122
|
+
console.error(`Failed to delete record: ${record.company}, retrying...`);
|
|
123
|
+
waitFor(1000);
|
|
124
|
+
const try2response = await deleteByContractorId(record.id, context);
|
|
125
|
+
|
|
126
|
+
if (try2response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
127
|
+
console.error(`Failed to delete record: ${record.company} second time.`);
|
|
128
|
+
failed.push(response);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (failed.length) {
|
|
134
|
+
throw Error(`Failed to delete ${failed.length} of ${existingRecords.length} records in account. Failed with status: ${ failed[0].status }`);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const getRecordVerificationModel = async (recordId, context, { requirementId, requirementDateModified } = {}) => {
|
|
139
|
+
const { data: recordData } = await getContractorById(recordId, context);
|
|
140
|
+
return new RecordModifyDateVerificationModel(recordData.id, { contractorDateModified: recordData.dateModified, requirementId, requirementDateModified });
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const getAssignRequirementModel = (requirementId, companyName, emailAddress) => {
|
|
144
|
+
return new AssignRequirementModel(requirementId, companyName, emailAddress);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const getLinkedProjectsCount = (recordId, context) => {
|
|
148
|
+
return contractorsAPI.getLinkedProjectsCount(recordId, context);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const restoreByRecordId = async (recordId, context) => {
|
|
152
|
+
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
153
|
+
const restoreResponse = await restoreRecord(recordModifyModel, context);
|
|
154
|
+
|
|
155
|
+
if (restoreResponse.status !== httpResponseStatusCodes.OK) {
|
|
156
|
+
throw new Error(`Failed to restore record "${recordId}"\n${restoreResponse.statusText}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return restoreResponse;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const archiveByRecordId = async (recordId, context) => {
|
|
163
|
+
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
164
|
+
const archiveResponse = await archiveRecord(recordModifyModel, context);
|
|
165
|
+
|
|
166
|
+
if (archiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
167
|
+
throw new Error(`Failed to archive record "${recordId}"\n${archiveResponse.statusText}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return archiveResponse;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const getInviteLinkStatus = (encryptedData, context) => {
|
|
174
|
+
return contractorsAPI.getInviteLinkStatus(encryptedData, context);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const getContractorDetailsModel = recordConfig => {
|
|
178
|
+
const apiDetailsConfig = utils.getRecordDetailsConfigInApiFormat(recordConfig);
|
|
179
|
+
return new ContractorDetailsModel(apiDetailsConfig);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const getBasicDetailsById = async recordId => {
|
|
183
|
+
const response = await contractorsAPI.getBasicDetailsById(recordId);
|
|
184
|
+
|
|
185
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
186
|
+
throw Error(`Failed to get basic record details by record id: ${recordId} - Response: ${response.status}`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return response.data;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const getRecordsFromInsuredName = async (insuredName, accountIds) => {
|
|
193
|
+
const response = await contractorsAPI.getRecordsFromInsuredName(insuredName, accountIds);
|
|
194
|
+
|
|
195
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
196
|
+
throw Error(`Failed to get records from insured name: ${insuredName} and accountIds: ${accountIds} - Response: ${response.status}`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return response.data;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
module.exports = {
|
|
203
|
+
changeRequirement,
|
|
204
|
+
getContractorsByAccountId,
|
|
205
|
+
getContractorById,
|
|
206
|
+
getRecordHistory,
|
|
207
|
+
archiveRecord,
|
|
208
|
+
restoreRecord,
|
|
209
|
+
editContractor,
|
|
210
|
+
updateInviteDate,
|
|
211
|
+
updateExpiryDate,
|
|
212
|
+
getContractorsByTabId,
|
|
213
|
+
searchInAutoComplete,
|
|
214
|
+
updateContractorUploadDate,
|
|
215
|
+
sendGaps,
|
|
216
|
+
requestNewCoiAboutToExpire,
|
|
217
|
+
requestNewCoiExpired,
|
|
218
|
+
resendInvitation,
|
|
219
|
+
muteNotifications,
|
|
220
|
+
unmuteNotifications,
|
|
221
|
+
deleteByContractorId,
|
|
222
|
+
deleteAllRecordsInAccount,
|
|
223
|
+
getRecordVerificationModel,
|
|
224
|
+
assignRequirement,
|
|
225
|
+
getAssignRequirementModel,
|
|
226
|
+
getLinkedProjectsCount,
|
|
227
|
+
archiveByRecordId,
|
|
228
|
+
restoreByRecordId,
|
|
229
|
+
updateLastInviteActionDate,
|
|
230
|
+
getInviteLinkStatus,
|
|
231
|
+
getContractorDetailsModel,
|
|
232
|
+
getBasicDetailsById,
|
|
233
|
+
getRecordsFromInsuredName
|
|
234
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const RECORD_SHARING_LEVEL = {
|
|
2
|
-
account: 'Account',
|
|
3
|
-
tab: 'Tab'
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
module.exports = { RECORD_SHARING_LEVEL };
|
|
1
|
+
const RECORD_SHARING_LEVEL = {
|
|
2
|
+
account: 'Account',
|
|
3
|
+
tab: 'Tab'
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
module.exports = { RECORD_SHARING_LEVEL };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const editModel = require('./models/edit.contractor.model');
|
|
2
|
-
const verificationModel = require('./models/verification.contractor.model');
|
|
3
|
-
const assignRequirementModel = require('./models/assign.requirement.model');
|
|
4
|
-
const services = require('./api/contractors.service');
|
|
5
|
-
|
|
6
|
-
const models = { edit: editModel, verification: verificationModel, assignRequirementModel };
|
|
7
|
-
|
|
8
|
-
module.exports = { services, models };
|
|
1
|
+
const editModel = require('./models/edit.contractor.model');
|
|
2
|
+
const verificationModel = require('./models/verification.contractor.model');
|
|
3
|
+
const assignRequirementModel = require('./models/assign.requirement.model');
|
|
4
|
+
const services = require('./api/contractors.service');
|
|
5
|
+
|
|
6
|
+
const models = { edit: editModel, verification: verificationModel, assignRequirementModel };
|
|
7
|
+
|
|
8
|
+
module.exports = { services, models };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
class AssignRequirementModel {
|
|
2
|
-
constructor(requirementId, companyName, emailAddress, { fileName = null, disableMail = false } = {}) {
|
|
3
|
-
this.requirementId = requirementId;
|
|
4
|
-
this.companyName = companyName;
|
|
5
|
-
this.emailAddress = emailAddress;
|
|
6
|
-
this.fileName = fileName;
|
|
7
|
-
this.disableMail = disableMail;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
module.exports = { AssignRequirementModel };
|
|
1
|
+
class AssignRequirementModel {
|
|
2
|
+
constructor(requirementId, companyName, emailAddress, { fileName = null, disableMail = false } = {}) {
|
|
3
|
+
this.requirementId = requirementId;
|
|
4
|
+
this.companyName = companyName;
|
|
5
|
+
this.emailAddress = emailAddress;
|
|
6
|
+
this.fileName = fileName;
|
|
7
|
+
this.disableMail = disableMail;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
module.exports = { AssignRequirementModel };
|
|
@@ -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
|
-
externalRecordId = 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 = externalRecordId;
|
|
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
|
+
externalRecordId = 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 = externalRecordId;
|
|
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
|
+
};
|