@getjones/test-infra 3.1.3 → 3.1.4
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 +146 -146
- package/src/common/consts/accountSettings.js +10 -10
- package/src/common/consts/activationStatuses.js +6 -6
- package/src/common/consts/constantsForRecordsSortingAndFilters.js +40 -40
- package/src/common/consts/dashboardCharts.js +18 -18
- package/src/common/consts/ocrStatuses.js +6 -6
- package/src/common/consts/projectSettings.js +6 -6
- 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/errorCodes.js +3 -3
- 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 -48
- package/src/common/requests/requestHandlers.js +78 -78
- package/src/common/utils/complianceUtil.js +106 -106
- 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 +99 -99
- package/src/defaults/configs/coverage.js +227 -227
- package/src/defaults/configs/polices.js +67 -67
- 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 +221 -225
- 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/emailCustomization/accounts.email.customizations.api.js +29 -29
- package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
- 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 +22 -22
- 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 +40 -40
- package/src/saas/internal-api/coi/api/coi.service.js +26 -26
- package/src/saas/internal-api/coi/consts/hashes.js +4 -4
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
- package/src/saas/internal-api/coi/index.js +14 -14
- package/src/saas/internal-api/coi/models/submit.coi.model.js +19 -9
- package/src/saas/internal-api/coi/utils/utils.js +70 -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 +242 -242
- 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 +203 -203
- package/src/saas/internal-api/contractors/api/contractors.service.js +318 -318
- 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 +62 -62
- package/src/saas/internal-api/contractors/models/link.request.model.js +10 -10
- package/src/saas/internal-api/contractors/models/subscription.contractor.model.js +13 -13
- 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 +156 -156
- 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 +87 -87
- 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 -105
- 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 +65 -65
- 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 +120 -120
- package/src/saas/internal-api/requests/api/requests.service.js +272 -272
- package/src/saas/internal-api/requests/index.js +20 -20
- package/src/saas/internal-api/requests/models/create.request.model.js +33 -33
- package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -18
- package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/requestListCriteriaModel.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 +51 -51
- package/src/saas/internal-api/requirements/api/requirements.service.js +153 -153
- 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 +97 -97
- 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
- package/src/resources/virusFile.pdf +0 -0
|
@@ -1,318 +1,318 @@
|
|
|
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 { LinkRequestModel } = require('../models/link.request.model');
|
|
8
|
-
const { SubscriptionModel } = require('../models/subscription.contractor.model');
|
|
9
|
-
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
10
|
-
const { waitFor } = require('../../../../common/utils/timeUtils');
|
|
11
|
-
const activationStatuses = require('../../../../common/consts/activationStatuses');
|
|
12
|
-
const utils = require('../utils');
|
|
13
|
-
|
|
14
|
-
const getContractorsByAccountId = async (accountId, context, activationStatus = null) => {
|
|
15
|
-
if (activationStatus) {
|
|
16
|
-
activationStatus = activationStatus.reduce((f, s) => `${f},${s}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return contractorsAPI.getContractorsByAccountId({ accountId, activationStatus }, context);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const getContractorById = (contractorId, context) => {
|
|
23
|
-
return contractorsAPI.getContractorById(contractorId, context);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const getRecordHistory = (contractorId, context) => {
|
|
27
|
-
return contractorsAPI.getRecordHistory(contractorId, context);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const getRecordOcrStatus = (recordId, context) => {
|
|
31
|
-
return contractorsAPI.getRecordOcrStatus(recordId, context);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const archiveRecord = (recordVerificationModel, context) => {
|
|
35
|
-
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
36
|
-
return contractorsAPI.archiveRecord(recordVerificationModel, context);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const restoreRecord = (recordVerificationModel, context) => {
|
|
40
|
-
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
41
|
-
return contractorsAPI.restoreRecord(recordVerificationModel, context);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const editContractor = (editRequestModel, context) => {
|
|
45
|
-
validateType(editRequestModel, RequestModel);
|
|
46
|
-
return contractorsAPI.editContractor(editRequestModel, context);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const updateExpiryDate = (contractorId, expiryDate, policyName) => {
|
|
50
|
-
return contractorsAPI.updateExpiryDate(contractorId, expiryDate, policyName);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const assignRequirement = (requestId, assignRequirementModel, context) => {
|
|
54
|
-
return contractorsAPI.assignRequirement(requestId, assignRequirementModel, context);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const updateInviteDate = (contractorId, inviteDate, context) => {
|
|
58
|
-
return contractorsAPI.updateInviteDate(contractorId, inviteDate, context);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const updateLastInviteActionDate = (recordId, dateOffset, context) => {
|
|
62
|
-
return contractorsAPI.updateLastInviteActionDate(recordId, dateOffset, context);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const getContractorsByTabId = (tabId, context, activityStatus = 'Active') => {
|
|
66
|
-
return contractorsAPI.getContractorsByTabId(tabId, context, activityStatus);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const searchInAutoComplete = ({ tabId, searchWord }, context) => {
|
|
70
|
-
return contractorsAPI.searchInAutocomplete({ tabId, searchWord }, context);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
74
|
-
validateType(uploadDate, Date);
|
|
75
|
-
return contractorsAPI.updateContractorUploadDate(contractorId, uploadDate, context);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const changeRequirement = (recordModifyDateVerificationModel, context) => {
|
|
79
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
80
|
-
return contractorsAPI.changeRequirement(recordModifyDateVerificationModel, context);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const sendGaps = (requestId, recordModifyDateVerificationModel, context) => {
|
|
84
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
85
|
-
return contractorsAPI.sendGaps(requestId, recordModifyDateVerificationModel, context);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const requestNewCoiAboutToExpire = (requestId, recordModifyDateVerificationModel, context) => {
|
|
89
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
90
|
-
return contractorsAPI.requestNewCoiAboutToExpire(requestId, recordModifyDateVerificationModel, context);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const requestNewCoiExpired = (requestId, recordModifyDateVerificationModel, context) => {
|
|
94
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
95
|
-
return contractorsAPI.requestNewCoiExpired(requestId, recordModifyDateVerificationModel, context);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const resendInvitation = (requestId, recordModifyDateVerificationModel, context) => {
|
|
99
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
100
|
-
return contractorsAPI.resendInvitation(requestId, recordModifyDateVerificationModel, context);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const muteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
104
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
105
|
-
return contractorsAPI.muteNotifications(recordModifyDateVerificationModel, context);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const muteNotificationsByRecordId = async (recordId, context) => {
|
|
109
|
-
const recordModifyDateVerificationModel = await getRecordVerificationModel(recordId, context);
|
|
110
|
-
const muteResponse = await contractorsAPI.muteNotifications(recordModifyDateVerificationModel, context);
|
|
111
|
-
|
|
112
|
-
if (muteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
113
|
-
throw new Error(`Failed to mute record: ${muteResponse.statusText}`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return muteResponse;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const unmuteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
120
|
-
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
121
|
-
return contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const unmuteNotificationsByRecordId = async (recordId, context) => {
|
|
125
|
-
const recordModifyDateVerificationModel = await getRecordVerificationModel(recordId, context);
|
|
126
|
-
const unmuteResponse = await contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
127
|
-
|
|
128
|
-
if (unmuteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
129
|
-
throw new Error(`Failed to unmute record: ${unmuteResponse.statusText}`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return unmuteResponse;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const unsubscribe = async (subscriptionModel, { expectError } = {}) => {
|
|
136
|
-
validateType(subscriptionModel, SubscriptionModel);
|
|
137
|
-
const unsubscribeResponse = await contractorsAPI.unsubscribe(subscriptionModel);
|
|
138
|
-
|
|
139
|
-
if (unsubscribeResponse.status !== httpResponseStatusCodes.OK && !expectError) {
|
|
140
|
-
throw new Error(`Failed to unsubscribe record: ${unsubscribeResponse.statusText}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return unsubscribeResponse;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const subscribe = async (subscriptionModel, { expectError } = {}) => {
|
|
147
|
-
validateType(subscriptionModel, SubscriptionModel);
|
|
148
|
-
const subscribeResponse = await contractorsAPI.subscribe(subscriptionModel);
|
|
149
|
-
|
|
150
|
-
if (subscribeResponse.status !== httpResponseStatusCodes.OK && !expectError) {
|
|
151
|
-
throw new Error(`Failed to subscribe record: ${subscribeResponse.statusText}`);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return subscribeResponse;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const getSubscriptionModel = (data, { recaptchaResponse = 'recaptchaResponse' } = {}) => {
|
|
158
|
-
return new SubscriptionModel(data, recaptchaResponse);
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const deleteByContractorId = (contractorId, context) => {
|
|
162
|
-
return contractorsAPI.deleteByContractorId(contractorId, context);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const deleteAllRecordsInAccount = async (accountId, context, { activationStatus = [activationStatuses.ACTIVE, activationStatuses.ARCHIVED, activationStatuses.DRAFT] } = {}) => {
|
|
166
|
-
const { data: existingRecords } = await getContractorsByAccountId(accountId, context, activationStatus);
|
|
167
|
-
|
|
168
|
-
if (!existingRecords.length) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const failed = [];
|
|
173
|
-
for (const record of existingRecords) {
|
|
174
|
-
const response = await deleteByContractorId(record.id, context);
|
|
175
|
-
|
|
176
|
-
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
177
|
-
console.error(`Failed to delete record: ${record.company}, retrying...`);
|
|
178
|
-
waitFor(1000);
|
|
179
|
-
const try2response = await deleteByContractorId(record.id, context);
|
|
180
|
-
|
|
181
|
-
if (try2response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
182
|
-
console.error(`Failed to delete record: ${record.company} second time.`);
|
|
183
|
-
failed.push(response);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (failed.length) {
|
|
189
|
-
throw Error(`Failed to delete ${failed.length} of ${existingRecords.length} records in account. Failed with status: ${ failed[0].status }`);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const deleteAllActiveRecordsInAccount = async (accountId, context) => {
|
|
194
|
-
return deleteAllRecordsInAccount(accountId, context, { activationStatus: [activationStatuses.ACTIVE] });
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const getRecordVerificationModel = async (recordId, context, { requirementId, requirementDateModified } = {}) => {
|
|
198
|
-
const { data: recordData } = await getContractorById(recordId, context);
|
|
199
|
-
return new RecordModifyDateVerificationModel(recordData.id, { contractorDateModified: recordData.dateModified, requirementId, requirementDateModified });
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const getRecordVerificationModelForDraftRecord = (request, { requirementId, requirementDateModified } = {}) => {
|
|
203
|
-
const { record } = request;
|
|
204
|
-
return new RecordModifyDateVerificationModel(record.id, { contractorDateModified: record.dateModified, requirementId, requirementDateModified });
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const getAssignRequirementModel = (requirementId, companyName, emailAddress) => {
|
|
208
|
-
return new AssignRequirementModel(requirementId, companyName, emailAddress);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const getLinkedProjectsCount = (recordId, context) => {
|
|
212
|
-
return contractorsAPI.getLinkedProjectsCount(recordId, context);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const restoreByRecordId = async (recordId, context) => {
|
|
216
|
-
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
217
|
-
const restoreResponse = await restoreRecord(recordModifyModel, context);
|
|
218
|
-
|
|
219
|
-
if (restoreResponse.status !== httpResponseStatusCodes.OK) {
|
|
220
|
-
throw new Error(`Failed to restore record "${recordId}"\n${restoreResponse.statusText}`);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return restoreResponse;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const archiveByRecordId = async (recordId, context) => {
|
|
227
|
-
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
228
|
-
const archiveResponse = await archiveRecord(recordModifyModel, context);
|
|
229
|
-
|
|
230
|
-
if (archiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
231
|
-
throw new Error(`Failed to archive record "${recordId}"\n${archiveResponse.statusText}`);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return archiveResponse;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
const getInviteLinkStatus = (encryptedData, context) => {
|
|
238
|
-
return contractorsAPI.getInviteLinkStatus(encryptedData, context);
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const getContractorDetailsModel = recordConfig => {
|
|
242
|
-
const apiDetailsConfig = utils.getRecordDetailsConfigInApiFormat(recordConfig);
|
|
243
|
-
return new ContractorDetailsModel(apiDetailsConfig);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const getBasicDetailsById = async recordId => {
|
|
247
|
-
const response = await contractorsAPI.getBasicDetailsById(recordId);
|
|
248
|
-
|
|
249
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
250
|
-
throw Error(`Failed to get basic record details by record id: ${recordId} - Response: ${response.status}`);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return response.data;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
const getRecordsFromInsuredName = async (insuredName, accountIds) => {
|
|
257
|
-
const response = await contractorsAPI.getRecordsFromInsuredName(insuredName, accountIds);
|
|
258
|
-
|
|
259
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
260
|
-
throw Error(`Failed to get records from insured name: ${insuredName} and accountIds: ${accountIds} - Response: ${response.status}`);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return response.data;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const linkDraftRequestToAccountRecord = async (requestToLink, targetAccountRecord, context, { shouldExpectError } = {}) => {
|
|
267
|
-
const linkRequestModel = new LinkRequestModel(requestToLink, targetAccountRecord);
|
|
268
|
-
const linkRequestResponse = await contractorsAPI.linkDraftRequestToAccountRecord(linkRequestModel, context);
|
|
269
|
-
|
|
270
|
-
if (linkRequestResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
271
|
-
throw Error(`Failed to link request - ${requestToLink.id} to accountRecord ${targetAccountRecord.id}\n${linkRequestResponse}`);
|
|
272
|
-
} else {
|
|
273
|
-
return linkRequestResponse;
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
module.exports = {
|
|
278
|
-
changeRequirement,
|
|
279
|
-
getContractorsByAccountId,
|
|
280
|
-
getContractorById,
|
|
281
|
-
getRecordHistory,
|
|
282
|
-
getRecordOcrStatus,
|
|
283
|
-
archiveRecord,
|
|
284
|
-
restoreRecord,
|
|
285
|
-
editContractor,
|
|
286
|
-
updateInviteDate,
|
|
287
|
-
updateExpiryDate,
|
|
288
|
-
getContractorsByTabId,
|
|
289
|
-
searchInAutoComplete,
|
|
290
|
-
updateContractorUploadDate,
|
|
291
|
-
sendGaps,
|
|
292
|
-
requestNewCoiAboutToExpire,
|
|
293
|
-
requestNewCoiExpired,
|
|
294
|
-
resendInvitation,
|
|
295
|
-
muteNotifications,
|
|
296
|
-
muteNotificationsByRecordId,
|
|
297
|
-
unmuteNotifications,
|
|
298
|
-
unmuteNotificationsByRecordId,
|
|
299
|
-
unsubscribe,
|
|
300
|
-
subscribe,
|
|
301
|
-
getSubscriptionModel,
|
|
302
|
-
deleteByContractorId,
|
|
303
|
-
deleteAllRecordsInAccount,
|
|
304
|
-
deleteAllActiveRecordsInAccount,
|
|
305
|
-
getRecordVerificationModel,
|
|
306
|
-
getRecordVerificationModelForDraftRecord,
|
|
307
|
-
assignRequirement,
|
|
308
|
-
getAssignRequirementModel,
|
|
309
|
-
getLinkedProjectsCount,
|
|
310
|
-
archiveByRecordId,
|
|
311
|
-
restoreByRecordId,
|
|
312
|
-
updateLastInviteActionDate,
|
|
313
|
-
getInviteLinkStatus,
|
|
314
|
-
getContractorDetailsModel,
|
|
315
|
-
getBasicDetailsById,
|
|
316
|
-
getRecordsFromInsuredName,
|
|
317
|
-
linkDraftRequestToAccountRecord
|
|
318
|
-
};
|
|
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 { LinkRequestModel } = require('../models/link.request.model');
|
|
8
|
+
const { SubscriptionModel } = require('../models/subscription.contractor.model');
|
|
9
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
10
|
+
const { waitFor } = require('../../../../common/utils/timeUtils');
|
|
11
|
+
const activationStatuses = require('../../../../common/consts/activationStatuses');
|
|
12
|
+
const utils = require('../utils');
|
|
13
|
+
|
|
14
|
+
const getContractorsByAccountId = async (accountId, context, activationStatus = null) => {
|
|
15
|
+
if (activationStatus) {
|
|
16
|
+
activationStatus = activationStatus.reduce((f, s) => `${f},${s}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return contractorsAPI.getContractorsByAccountId({ accountId, activationStatus }, context);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getContractorById = (contractorId, context) => {
|
|
23
|
+
return contractorsAPI.getContractorById(contractorId, context);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const getRecordHistory = (contractorId, context) => {
|
|
27
|
+
return contractorsAPI.getRecordHistory(contractorId, context);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getRecordOcrStatus = (recordId, context) => {
|
|
31
|
+
return contractorsAPI.getRecordOcrStatus(recordId, context);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const archiveRecord = (recordVerificationModel, context) => {
|
|
35
|
+
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
36
|
+
return contractorsAPI.archiveRecord(recordVerificationModel, context);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const restoreRecord = (recordVerificationModel, context) => {
|
|
40
|
+
validateType(recordVerificationModel, RecordModifyDateVerificationModel);
|
|
41
|
+
return contractorsAPI.restoreRecord(recordVerificationModel, context);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const editContractor = (editRequestModel, context) => {
|
|
45
|
+
validateType(editRequestModel, RequestModel);
|
|
46
|
+
return contractorsAPI.editContractor(editRequestModel, context);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const updateExpiryDate = (contractorId, expiryDate, policyName) => {
|
|
50
|
+
return contractorsAPI.updateExpiryDate(contractorId, expiryDate, policyName);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const assignRequirement = (requestId, assignRequirementModel, context) => {
|
|
54
|
+
return contractorsAPI.assignRequirement(requestId, assignRequirementModel, context);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const updateInviteDate = (contractorId, inviteDate, context) => {
|
|
58
|
+
return contractorsAPI.updateInviteDate(contractorId, inviteDate, context);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const updateLastInviteActionDate = (recordId, dateOffset, context) => {
|
|
62
|
+
return contractorsAPI.updateLastInviteActionDate(recordId, dateOffset, context);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const getContractorsByTabId = (tabId, context, activityStatus = 'Active') => {
|
|
66
|
+
return contractorsAPI.getContractorsByTabId(tabId, context, activityStatus);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const searchInAutoComplete = ({ tabId, searchWord }, context) => {
|
|
70
|
+
return contractorsAPI.searchInAutocomplete({ tabId, searchWord }, context);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
74
|
+
validateType(uploadDate, Date);
|
|
75
|
+
return contractorsAPI.updateContractorUploadDate(contractorId, uploadDate, context);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const changeRequirement = (recordModifyDateVerificationModel, context) => {
|
|
79
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
80
|
+
return contractorsAPI.changeRequirement(recordModifyDateVerificationModel, context);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const sendGaps = (requestId, recordModifyDateVerificationModel, context) => {
|
|
84
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
85
|
+
return contractorsAPI.sendGaps(requestId, recordModifyDateVerificationModel, context);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const requestNewCoiAboutToExpire = (requestId, recordModifyDateVerificationModel, context) => {
|
|
89
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
90
|
+
return contractorsAPI.requestNewCoiAboutToExpire(requestId, recordModifyDateVerificationModel, context);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const requestNewCoiExpired = (requestId, recordModifyDateVerificationModel, context) => {
|
|
94
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
95
|
+
return contractorsAPI.requestNewCoiExpired(requestId, recordModifyDateVerificationModel, context);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const resendInvitation = (requestId, recordModifyDateVerificationModel, context) => {
|
|
99
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
100
|
+
return contractorsAPI.resendInvitation(requestId, recordModifyDateVerificationModel, context);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const muteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
104
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
105
|
+
return contractorsAPI.muteNotifications(recordModifyDateVerificationModel, context);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const muteNotificationsByRecordId = async (recordId, context) => {
|
|
109
|
+
const recordModifyDateVerificationModel = await getRecordVerificationModel(recordId, context);
|
|
110
|
+
const muteResponse = await contractorsAPI.muteNotifications(recordModifyDateVerificationModel, context);
|
|
111
|
+
|
|
112
|
+
if (muteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
113
|
+
throw new Error(`Failed to mute record: ${muteResponse.statusText}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return muteResponse;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const unmuteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
120
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
121
|
+
return contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const unmuteNotificationsByRecordId = async (recordId, context) => {
|
|
125
|
+
const recordModifyDateVerificationModel = await getRecordVerificationModel(recordId, context);
|
|
126
|
+
const unmuteResponse = await contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
127
|
+
|
|
128
|
+
if (unmuteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
129
|
+
throw new Error(`Failed to unmute record: ${unmuteResponse.statusText}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return unmuteResponse;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const unsubscribe = async (subscriptionModel, { expectError } = {}) => {
|
|
136
|
+
validateType(subscriptionModel, SubscriptionModel);
|
|
137
|
+
const unsubscribeResponse = await contractorsAPI.unsubscribe(subscriptionModel);
|
|
138
|
+
|
|
139
|
+
if (unsubscribeResponse.status !== httpResponseStatusCodes.OK && !expectError) {
|
|
140
|
+
throw new Error(`Failed to unsubscribe record: ${unsubscribeResponse.statusText}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return unsubscribeResponse;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const subscribe = async (subscriptionModel, { expectError } = {}) => {
|
|
147
|
+
validateType(subscriptionModel, SubscriptionModel);
|
|
148
|
+
const subscribeResponse = await contractorsAPI.subscribe(subscriptionModel);
|
|
149
|
+
|
|
150
|
+
if (subscribeResponse.status !== httpResponseStatusCodes.OK && !expectError) {
|
|
151
|
+
throw new Error(`Failed to subscribe record: ${subscribeResponse.statusText}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return subscribeResponse;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const getSubscriptionModel = (data, { recaptchaResponse = 'recaptchaResponse' } = {}) => {
|
|
158
|
+
return new SubscriptionModel(data, recaptchaResponse);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const deleteByContractorId = (contractorId, context) => {
|
|
162
|
+
return contractorsAPI.deleteByContractorId(contractorId, context);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const deleteAllRecordsInAccount = async (accountId, context, { activationStatus = [activationStatuses.ACTIVE, activationStatuses.ARCHIVED, activationStatuses.DRAFT] } = {}) => {
|
|
166
|
+
const { data: existingRecords } = await getContractorsByAccountId(accountId, context, activationStatus);
|
|
167
|
+
|
|
168
|
+
if (!existingRecords.length) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const failed = [];
|
|
173
|
+
for (const record of existingRecords) {
|
|
174
|
+
const response = await deleteByContractorId(record.id, context);
|
|
175
|
+
|
|
176
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
177
|
+
console.error(`Failed to delete record: ${record.company}, retrying...`);
|
|
178
|
+
waitFor(1000);
|
|
179
|
+
const try2response = await deleteByContractorId(record.id, context);
|
|
180
|
+
|
|
181
|
+
if (try2response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
182
|
+
console.error(`Failed to delete record: ${record.company} second time.`);
|
|
183
|
+
failed.push(response);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (failed.length) {
|
|
189
|
+
throw Error(`Failed to delete ${failed.length} of ${existingRecords.length} records in account. Failed with status: ${ failed[0].status }`);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const deleteAllActiveRecordsInAccount = async (accountId, context) => {
|
|
194
|
+
return deleteAllRecordsInAccount(accountId, context, { activationStatus: [activationStatuses.ACTIVE] });
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const getRecordVerificationModel = async (recordId, context, { requirementId, requirementDateModified } = {}) => {
|
|
198
|
+
const { data: recordData } = await getContractorById(recordId, context);
|
|
199
|
+
return new RecordModifyDateVerificationModel(recordData.id, { contractorDateModified: recordData.dateModified, requirementId, requirementDateModified });
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const getRecordVerificationModelForDraftRecord = (request, { requirementId, requirementDateModified } = {}) => {
|
|
203
|
+
const { record } = request;
|
|
204
|
+
return new RecordModifyDateVerificationModel(record.id, { contractorDateModified: record.dateModified, requirementId, requirementDateModified });
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const getAssignRequirementModel = (requirementId, companyName, emailAddress) => {
|
|
208
|
+
return new AssignRequirementModel(requirementId, companyName, emailAddress);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const getLinkedProjectsCount = (recordId, context) => {
|
|
212
|
+
return contractorsAPI.getLinkedProjectsCount(recordId, context);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const restoreByRecordId = async (recordId, context) => {
|
|
216
|
+
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
217
|
+
const restoreResponse = await restoreRecord(recordModifyModel, context);
|
|
218
|
+
|
|
219
|
+
if (restoreResponse.status !== httpResponseStatusCodes.OK) {
|
|
220
|
+
throw new Error(`Failed to restore record "${recordId}"\n${restoreResponse.statusText}`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return restoreResponse;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const archiveByRecordId = async (recordId, context) => {
|
|
227
|
+
const recordModifyModel = await getRecordVerificationModel(recordId, context);
|
|
228
|
+
const archiveResponse = await archiveRecord(recordModifyModel, context);
|
|
229
|
+
|
|
230
|
+
if (archiveResponse.status !== httpResponseStatusCodes.OK) {
|
|
231
|
+
throw new Error(`Failed to archive record "${recordId}"\n${archiveResponse.statusText}`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return archiveResponse;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const getInviteLinkStatus = (encryptedData, context) => {
|
|
238
|
+
return contractorsAPI.getInviteLinkStatus(encryptedData, context);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const getContractorDetailsModel = recordConfig => {
|
|
242
|
+
const apiDetailsConfig = utils.getRecordDetailsConfigInApiFormat(recordConfig);
|
|
243
|
+
return new ContractorDetailsModel(apiDetailsConfig);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const getBasicDetailsById = async recordId => {
|
|
247
|
+
const response = await contractorsAPI.getBasicDetailsById(recordId);
|
|
248
|
+
|
|
249
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
250
|
+
throw Error(`Failed to get basic record details by record id: ${recordId} - Response: ${response.status}`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return response.data;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const getRecordsFromInsuredName = async (insuredName, accountIds) => {
|
|
257
|
+
const response = await contractorsAPI.getRecordsFromInsuredName(insuredName, accountIds);
|
|
258
|
+
|
|
259
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
260
|
+
throw Error(`Failed to get records from insured name: ${insuredName} and accountIds: ${accountIds} - Response: ${response.status}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return response.data;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const linkDraftRequestToAccountRecord = async (requestToLink, targetAccountRecord, context, { shouldExpectError } = {}) => {
|
|
267
|
+
const linkRequestModel = new LinkRequestModel(requestToLink, targetAccountRecord);
|
|
268
|
+
const linkRequestResponse = await contractorsAPI.linkDraftRequestToAccountRecord(linkRequestModel, context);
|
|
269
|
+
|
|
270
|
+
if (linkRequestResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
|
|
271
|
+
throw Error(`Failed to link request - ${requestToLink.id} to accountRecord ${targetAccountRecord.id}\n${linkRequestResponse}`);
|
|
272
|
+
} else {
|
|
273
|
+
return linkRequestResponse;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
module.exports = {
|
|
278
|
+
changeRequirement,
|
|
279
|
+
getContractorsByAccountId,
|
|
280
|
+
getContractorById,
|
|
281
|
+
getRecordHistory,
|
|
282
|
+
getRecordOcrStatus,
|
|
283
|
+
archiveRecord,
|
|
284
|
+
restoreRecord,
|
|
285
|
+
editContractor,
|
|
286
|
+
updateInviteDate,
|
|
287
|
+
updateExpiryDate,
|
|
288
|
+
getContractorsByTabId,
|
|
289
|
+
searchInAutoComplete,
|
|
290
|
+
updateContractorUploadDate,
|
|
291
|
+
sendGaps,
|
|
292
|
+
requestNewCoiAboutToExpire,
|
|
293
|
+
requestNewCoiExpired,
|
|
294
|
+
resendInvitation,
|
|
295
|
+
muteNotifications,
|
|
296
|
+
muteNotificationsByRecordId,
|
|
297
|
+
unmuteNotifications,
|
|
298
|
+
unmuteNotificationsByRecordId,
|
|
299
|
+
unsubscribe,
|
|
300
|
+
subscribe,
|
|
301
|
+
getSubscriptionModel,
|
|
302
|
+
deleteByContractorId,
|
|
303
|
+
deleteAllRecordsInAccount,
|
|
304
|
+
deleteAllActiveRecordsInAccount,
|
|
305
|
+
getRecordVerificationModel,
|
|
306
|
+
getRecordVerificationModelForDraftRecord,
|
|
307
|
+
assignRequirement,
|
|
308
|
+
getAssignRequirementModel,
|
|
309
|
+
getLinkedProjectsCount,
|
|
310
|
+
archiveByRecordId,
|
|
311
|
+
restoreByRecordId,
|
|
312
|
+
updateLastInviteActionDate,
|
|
313
|
+
getInviteLinkStatus,
|
|
314
|
+
getContractorDetailsModel,
|
|
315
|
+
getBasicDetailsById,
|
|
316
|
+
getRecordsFromInsuredName,
|
|
317
|
+
linkDraftRequestToAccountRecord
|
|
318
|
+
};
|
|
@@ -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 };
|