@getjones/test-infra 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +2 -0
- package/src/saas/internal-api/compliance/consts/audit.js +81 -0
- package/src/saas/internal-api/compliance/index.js +7 -1
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +2 -28
- package/src/saas/internal-api/compliance/utils/util.js +218 -0
- package/src/saas/internal-api/contractors/api/contractors.api.js +1 -7
- package/src/saas/internal-api/contractors/api/contractors.service.js +0 -6
- package/src/saas/internal-api/requests/api/requests.api.js +20 -0
- package/src/saas/internal-api/requests/api/requests.service.js +21 -0
- package/src/saas/internal-api/requests/index.js +4 -1
- package/src/saas/internal-api/requests/models/create.request.model.js +22 -0
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ class UpdateAccountSettingsModel {
|
|
|
3
3
|
accountId,
|
|
4
4
|
isHighPriority,
|
|
5
5
|
hasAnalyticsDashboard,
|
|
6
|
+
isEmailOnWelcomePageVA,
|
|
6
7
|
isExcludedFromNetwork,
|
|
7
8
|
isOcrEnabled,
|
|
8
9
|
isCoverageAudit
|
|
@@ -10,6 +11,7 @@ class UpdateAccountSettingsModel {
|
|
|
10
11
|
this.accountId = accountId;
|
|
11
12
|
this.isHighPriority = isHighPriority;
|
|
12
13
|
this.hasAnalyticsDashboard = hasAnalyticsDashboard;
|
|
14
|
+
this.isEmailOnWelcomePageVA = isEmailOnWelcomePageVA;
|
|
13
15
|
this.isExcludedFromNetwork = isExcludedFromNetwork;
|
|
14
16
|
this.isOcrEnabled = isOcrEnabled;
|
|
15
17
|
this.isCoverageAudit = isCoverageAudit;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const COI_AUDIT_STATUSES = {
|
|
2
|
+
NOT_AUDITED: '0',
|
|
3
|
+
REAUDIT: '3'
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
const AUDIT_ENTITY_STATUSES = {
|
|
7
|
+
YES: 'Yes',
|
|
8
|
+
NO: 'No',
|
|
9
|
+
EMPTY: 'empty',
|
|
10
|
+
OTHER: 'other',
|
|
11
|
+
CLAIMS: 'Claims'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const AUDIT_ATTRIBUTE_NAMES = {
|
|
15
|
+
CERTIFICATE_ISSUE_DATE: 'certIssueDate'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const AUDIT_POLICY_NAMES = {
|
|
19
|
+
GENERAL_LIABILITY: ''
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const VALID_SCORES = ['A+', 'A'];
|
|
23
|
+
|
|
24
|
+
const AUDITOR_ROLE = 'Auditor';
|
|
25
|
+
|
|
26
|
+
const DEFAULT_POLICY_ID = '-3';
|
|
27
|
+
|
|
28
|
+
const POLICY_NAMES_MAP = {
|
|
29
|
+
certificateOfInsurance: 'Certificate of Insurance',
|
|
30
|
+
generalLiability: 'General Liability',
|
|
31
|
+
excessLiability: 'Excess Liability',
|
|
32
|
+
umbrella: 'Umbrella',
|
|
33
|
+
professionalLiability: 'Professional Liability',
|
|
34
|
+
environmentalLiability: 'Environmental Liability',
|
|
35
|
+
liquorLiability: 'Liquor Liability',
|
|
36
|
+
garageLiability: 'Garage Liability',
|
|
37
|
+
garageKeepersLiability: 'Garage Keepers Liability',
|
|
38
|
+
workersCompensation: 'Workers’ Compensation',
|
|
39
|
+
automobileLiability: 'Automobile Liability',
|
|
40
|
+
propertyInsurance: 'Property Insurance',
|
|
41
|
+
rentedLeasedEquipment: 'Rented/Leased Equipment',
|
|
42
|
+
fidelityCrime: 'Fidelity / Crime',
|
|
43
|
+
employmentPracticesLiability: 'Employment Practices Liability',
|
|
44
|
+
directorsAndOfficersLiability: 'Directors and Officers Liability',
|
|
45
|
+
cyberLiability: 'Cyber Liability',
|
|
46
|
+
waiverOfSubrogation: 'Waiver Of Subrogation',
|
|
47
|
+
agreement: 'Agreement',
|
|
48
|
+
certificateHolder: 'Certificate Holder',
|
|
49
|
+
additionalInformation: 'Additional Information',
|
|
50
|
+
additionalInsured: 'Additional Insured'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const ATTRIBUTE_NAMES_MAP = {
|
|
54
|
+
isPolicyExist: 'coverageexists',
|
|
55
|
+
eachOccurrence: 'Each Occurrence',
|
|
56
|
+
expiryDate: 'expirydate',
|
|
57
|
+
policyNumber: 'policyNumber',
|
|
58
|
+
perOccurrence: 'PerOccur',
|
|
59
|
+
perPolicy: 'Per Policy',
|
|
60
|
+
perProject: 'Per Project',
|
|
61
|
+
perLocation: 'Per Location',
|
|
62
|
+
certificateIssueDate: 'certIssueDate',
|
|
63
|
+
insuredAddress: 'Insured Address',
|
|
64
|
+
insuredName: 'Insured Name',
|
|
65
|
+
amRating: 'AMBestRating',
|
|
66
|
+
cancellationTerms: 'cancellationTerms',
|
|
67
|
+
coiAuthentication: 'COIauthentication',
|
|
68
|
+
signature: 'signature'
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
DEFAULT_POLICY_ID,
|
|
73
|
+
POLICY_NAMES_MAP,
|
|
74
|
+
ATTRIBUTE_NAMES_MAP,
|
|
75
|
+
COI_AUDIT_STATUSES,
|
|
76
|
+
AUDITOR_ROLE,
|
|
77
|
+
AUDIT_POLICY_NAMES,
|
|
78
|
+
AUDIT_ATTRIBUTE_NAMES,
|
|
79
|
+
AUDIT_ENTITY_STATUSES,
|
|
80
|
+
VALID_SCORES
|
|
81
|
+
};
|
|
@@ -7,11 +7,17 @@ const waiveServices = require('./api/waive/waive.service');
|
|
|
7
7
|
const convertServices = require('./api/convert/convert.service');
|
|
8
8
|
const coverageServices = require('./api/coverage/coverage.service');
|
|
9
9
|
|
|
10
|
+
const auditConsts = require('./consts/audit');
|
|
11
|
+
|
|
10
12
|
const models = {
|
|
11
13
|
audit: auditModels,
|
|
12
14
|
waive: waiveModels
|
|
13
15
|
};
|
|
14
16
|
|
|
17
|
+
const consts = {
|
|
18
|
+
audit: auditConsts
|
|
19
|
+
};
|
|
20
|
+
|
|
15
21
|
const services = {
|
|
16
22
|
audit: auditServices,
|
|
17
23
|
waive: waiveServices,
|
|
@@ -19,4 +25,4 @@ const services = {
|
|
|
19
25
|
coverage: coverageServices
|
|
20
26
|
};
|
|
21
27
|
|
|
22
|
-
module.exports = { services, models };
|
|
28
|
+
module.exports = { services, models, consts };
|
|
@@ -1,27 +1,5 @@
|
|
|
1
1
|
const { validateType, validateInteger, validateArray, validateDateString } = require('../../../../../common/validations/typeValidations');
|
|
2
|
-
|
|
3
|
-
const COI_AUDIT_STATUSES = {
|
|
4
|
-
NOT_AUDITED: '0',
|
|
5
|
-
REAUDIT: '3'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const AUDIT_ENTITY_STATUSES = {
|
|
9
|
-
YES: 'Yes',
|
|
10
|
-
NO: 'No',
|
|
11
|
-
EMPTY: 'empty',
|
|
12
|
-
OTHER: 'other',
|
|
13
|
-
CLAIMS: 'Claims'
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const AUDIT_ATTRIBUTE_NAMES = {
|
|
17
|
-
CERTIFICATE_ISSUE_DATE: 'certIssueDate'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const AUDIT_POLICY_NAMES = {
|
|
21
|
-
GENERAL_LIABILITY: ''
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const AUDITOR_ROLE = 'Auditor';
|
|
2
|
+
const { AUDITOR_ROLE, COI_AUDIT_STATUSES } = require('../../consts/audit');
|
|
25
3
|
|
|
26
4
|
class AuditRequestModel {
|
|
27
5
|
constructor(
|
|
@@ -102,9 +80,5 @@ module.exports = {
|
|
|
102
80
|
AuditRequestModel,
|
|
103
81
|
AuditEntityModel,
|
|
104
82
|
AuditDatesModel,
|
|
105
|
-
AuditListParametersModel
|
|
106
|
-
COI_AUDIT_STATUSES,
|
|
107
|
-
AUDIT_ENTITY_STATUSES,
|
|
108
|
-
AUDIT_ATTRIBUTE_NAMES,
|
|
109
|
-
AUDIT_POLICY_NAMES
|
|
83
|
+
AuditListParametersModel
|
|
110
84
|
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
const { AUDIT_ENTITY_STATUSES, DEFAULT_POLICY_ID, VALID_SCORES } = require('../consts/audit');
|
|
2
|
+
|
|
3
|
+
const emptyValue = '';
|
|
4
|
+
|
|
5
|
+
const getValueBySelection = selection => {
|
|
6
|
+
return ['Yes', 'No', 'Empty', 'Claims'].includes(selection) ? emptyValue : selection;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const getDateInApiFormat = date => {
|
|
10
|
+
return dateTimeModule.convertDateToNewFormat(
|
|
11
|
+
date,
|
|
12
|
+
dateTimeModule.formats.dayMonthYear,
|
|
13
|
+
dateTimeModule.formats.numericMonthDayYear
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getAttributeKey = attribute => {
|
|
18
|
+
return specialAttributes[attribute] || attribute;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getAuditEntities = async (recordId, auditData, auditorContext) => {
|
|
22
|
+
const requirementDetailsForAuditResponse = await auditServices.getRequirementDetailsForAudit(recordId, auditorContext);
|
|
23
|
+
const requirement = requirementDetailsForAuditResponse.data;
|
|
24
|
+
|
|
25
|
+
const auditEntities = [];
|
|
26
|
+
auditData.forEach(auditEntity => auditEntities.push(
|
|
27
|
+
createAuditEntity(requirement, { ... auditEntity }))
|
|
28
|
+
);
|
|
29
|
+
return auditEntities;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const createAuditEntity = (
|
|
33
|
+
requirement, {
|
|
34
|
+
policyName = null,
|
|
35
|
+
attributeName = null,
|
|
36
|
+
value = emptyValue,
|
|
37
|
+
status = emptyValue
|
|
38
|
+
}) => {
|
|
39
|
+
const policyId = getPolicyId(policyName, requirement);
|
|
40
|
+
const auditEntityModel = new auditModels.AuditEntityModel(policyId, attributeName, status, value);
|
|
41
|
+
return auditEntityModel;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getPolicyId = (policyName, requirement) => {
|
|
45
|
+
if (!policyName || policyName === 'Certificate of Insurance') {
|
|
46
|
+
return DEFAULT_POLICY_ID;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const policy = requirement.policies.find(policy => policy.name === policyName);
|
|
50
|
+
|
|
51
|
+
if (!policy) {
|
|
52
|
+
let policiesList = emptyValue;
|
|
53
|
+
requirement.policies.forEach(policy => policiesList += `${policy.name},`);
|
|
54
|
+
|
|
55
|
+
throw Error(`Policy '${policyName}' not found in the Requirement. List: ${policiesList.slice(0, -1)}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return policy.id;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const getAuditRequestModel = (metaData, auditEntities) => {
|
|
62
|
+
const {
|
|
63
|
+
accountId = null,
|
|
64
|
+
projectId = null,
|
|
65
|
+
requirementId = null,
|
|
66
|
+
contractorId = null,
|
|
67
|
+
certificateId = null,
|
|
68
|
+
auditorId = null,
|
|
69
|
+
auditStatus = null,
|
|
70
|
+
isReaudit = false,
|
|
71
|
+
isProjectOnboarding = false,
|
|
72
|
+
shouldSendNotificationToPM = false,
|
|
73
|
+
auditDates = {}
|
|
74
|
+
} = metaData;
|
|
75
|
+
|
|
76
|
+
const auditDatesModel = new auditModels.AuditDatesModel(
|
|
77
|
+
auditDates.contractorId,
|
|
78
|
+
auditDates.contractorDateModified,
|
|
79
|
+
auditDates.dateStartedAudit,
|
|
80
|
+
auditDates.contractorOverrideDateModified,
|
|
81
|
+
auditDates.contractCreateDate
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const auditRequestModel = new auditModels.AuditRequestModel(
|
|
85
|
+
accountId,
|
|
86
|
+
projectId,
|
|
87
|
+
requirementId,
|
|
88
|
+
contractorId,
|
|
89
|
+
certificateId,
|
|
90
|
+
auditorId,
|
|
91
|
+
auditEntities,
|
|
92
|
+
isReaudit,
|
|
93
|
+
isProjectOnboarding,
|
|
94
|
+
shouldSendNotificationToPM,
|
|
95
|
+
auditDatesModel,
|
|
96
|
+
auditStatus
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return auditRequestModel;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const getParsedConfig = function(config) {
|
|
103
|
+
const automationInfra = require('../../../infrastructure/automation/automationInfra');
|
|
104
|
+
config = automationInfra.cloneObject(config);
|
|
105
|
+
const auditDataArr = [];
|
|
106
|
+
for (const field in config) {
|
|
107
|
+
if (!config.hasOwnProperty(field)) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (typeof config[field] === 'object' && !Array.isArray(config[field])) {
|
|
112
|
+
const attributes = config[field];
|
|
113
|
+
for (const attributeName in attributes) {
|
|
114
|
+
if (attributeName === 'Policy Expiry') {
|
|
115
|
+
attributes[attributeName] = getDateInApiFormat(attributes[attributeName]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const selection = { policyName: field };
|
|
119
|
+
|
|
120
|
+
// Special attribute names switch
|
|
121
|
+
switch (attributeName) {
|
|
122
|
+
case 'Occur':
|
|
123
|
+
const occurKeys = getAttributeKey(attributeName);
|
|
124
|
+
selection.attributeName = occurKeys[field];
|
|
125
|
+
break;
|
|
126
|
+
default:
|
|
127
|
+
selection.attributeName = getAttributeKey(attributeName);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (Array.isArray(attributes[attributeName])) {
|
|
132
|
+
selection.status = AUDIT_ENTITY_STATUSES[ attributes[attributeName][0] ];
|
|
133
|
+
selection.value = attributes[attributeName][1].replace('$', emptyValue);
|
|
134
|
+
} else {
|
|
135
|
+
// Special statuses switch
|
|
136
|
+
switch (selection.attributeName) {
|
|
137
|
+
case getAttributeKey('Policy Number'):
|
|
138
|
+
selection.status = emptyValue;
|
|
139
|
+
break;
|
|
140
|
+
case getAttributeKey('Policy Expiry'):
|
|
141
|
+
selection.status = AUDIT_ENTITY_STATUSES.YES;
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
selection.status = AUDIT_ENTITY_STATUSES[ attributes[attributeName] ];
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
selection.value = getValueBySelection(attributes[attributeName]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
auditDataArr.push(selection);
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
if (field === 'Certificate issue date') {
|
|
155
|
+
config[field] = getDateInApiFormat(config[field]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const selection = { attributeName: getAttributeKey(field) };
|
|
159
|
+
certificateEndorsmentsList.includes(field) && (selection.policyName = field);
|
|
160
|
+
|
|
161
|
+
if (Array.isArray(config[field])) {
|
|
162
|
+
selection.status = AUDIT_ENTITY_STATUSES[ config[field][0] ];
|
|
163
|
+
selection.value = config[field][1]; // Ok to be undefined
|
|
164
|
+
} else {
|
|
165
|
+
selection.status = AUDIT_ENTITY_STATUSES[ config[field] ] || AUDIT_ENTITY_STATUSES.YES;
|
|
166
|
+
selection.value = getValueBySelection(config[field]);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (field === 'AM Score') {
|
|
170
|
+
selection.status = VALID_SCORES.includes(selection.value) ? AUDIT_ENTITY_STATUSES.YES : AUDIT_ENTITY_STATUSES.NO;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
auditDataArr.push(selection);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return auditDataArr;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
module.exports = {
|
|
180
|
+
getAuditEntities,
|
|
181
|
+
getAuditRequestModel,
|
|
182
|
+
getParsedConfig
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const certificateEndorsmentsList = [
|
|
186
|
+
'Waiver Of Subrogation',
|
|
187
|
+
'Certificate Holder',
|
|
188
|
+
'Additional Information',
|
|
189
|
+
'Additional Insured',
|
|
190
|
+
'Agreement'
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
const specialAttributes = {
|
|
194
|
+
'Certificate issue date': 'certIssueDate',
|
|
195
|
+
'Cancellation Terms': 'cancellationTerms',
|
|
196
|
+
'COI authentication': 'COIauthentication',
|
|
197
|
+
'AM Score': 'AMBestRating',
|
|
198
|
+
'Signature': 'signature',
|
|
199
|
+
|
|
200
|
+
'Insured Address': 'Insured Address',
|
|
201
|
+
'Insured Name': 'Insured Name',
|
|
202
|
+
|
|
203
|
+
'Additional Information': 'additionalInformation',
|
|
204
|
+
'Waiver Of Subrogation': 'waiverofsubrogation',
|
|
205
|
+
'Additional Insured': 'additionalInsured',
|
|
206
|
+
'Certificate Holder': 'certificateHolder',
|
|
207
|
+
|
|
208
|
+
'Coverage Exists': 'coverageexists',
|
|
209
|
+
'Coverage exists': 'coverageexists',
|
|
210
|
+
'Policy Number': 'policynumber',
|
|
211
|
+
'Policy Expiry': 'expirydate',
|
|
212
|
+
'Per Occur': 'PerOccur',
|
|
213
|
+
|
|
214
|
+
'Occur': {
|
|
215
|
+
'Excess Liability': 'EXoccur',
|
|
216
|
+
'Umbrella': 'UMoccur'
|
|
217
|
+
}
|
|
218
|
+
};
|
|
@@ -21,8 +21,7 @@ const Endpoints = {
|
|
|
21
21
|
updateContractorInviteDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/invite-date`,
|
|
22
22
|
searchInAutocomplete: ({ tabId, searchWord }) =>
|
|
23
23
|
`${backendUrl}/saas/contractors/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
|
|
24
|
-
automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date
|
|
25
|
-
publicLinkInvite: `${backendUrl}/_saas/contractors/publicinvite`
|
|
24
|
+
automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
const createContractor = (createContractorModel, context) => {
|
|
@@ -118,10 +117,6 @@ const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
|
118
117
|
return requests.patchRequestHandler(url, context);
|
|
119
118
|
};
|
|
120
119
|
|
|
121
|
-
const inviteContractorViaPublicLink = (createContractorModel, context) => {
|
|
122
|
-
return requests.postRequestHandler(Endpoints.publicLinkInvite, createContractorModel, context);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
120
|
module.exports = {
|
|
126
121
|
createContractor,
|
|
127
122
|
changeRequirement,
|
|
@@ -137,7 +132,6 @@ module.exports = {
|
|
|
137
132
|
getContractorsByTabId,
|
|
138
133
|
searchInAutocomplete,
|
|
139
134
|
updateContractorUploadDate,
|
|
140
|
-
inviteContractorViaPublicLink,
|
|
141
135
|
sendGaps,
|
|
142
136
|
requestNewCoiAboutToExpire,
|
|
143
137
|
requestNewCoiExpired,
|
|
@@ -64,11 +64,6 @@ const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
|
64
64
|
return contractorsAPI.updateContractorUploadDate(contractorId, uploadDate, context);
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const inviteContractorViaPublicLink = async (createContractorModel, context) => {
|
|
68
|
-
validateType(createContractorModel, CreateContractorModel);
|
|
69
|
-
return contractorsAPI.inviteContractorViaPublicLink(createContractorModel, context);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
67
|
const changeRequirement = (recordModifyDateVerificationModel, context) => {
|
|
73
68
|
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
74
69
|
return contractorsAPI.changeRequirement(recordModifyDateVerificationModel, context);
|
|
@@ -119,7 +114,6 @@ module.exports = {
|
|
|
119
114
|
getContractorsByTabId,
|
|
120
115
|
searchInAutoComplete,
|
|
121
116
|
updateContractorUploadDate,
|
|
122
|
-
inviteContractorViaPublicLink,
|
|
123
117
|
sendGaps,
|
|
124
118
|
requestNewCoiAboutToExpire,
|
|
125
119
|
requestNewCoiExpired,
|
|
@@ -2,6 +2,9 @@ const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
|
2
2
|
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
|
+
create: `${backendUrl}/saas/contractors/invite`,
|
|
6
|
+
publicLinkInvite: `${backendUrl}/_saas/contractors/publicinvite`,
|
|
7
|
+
edit: contractorId => `${backendUrl}/saas/contractors/${contractorId}/update`,
|
|
5
8
|
getById: requestId => `${backendUrl}/saas/request/${requestId}`,
|
|
6
9
|
getAccountRequests: accountId => `${backendUrl}/saas/requests/${accountId}`,
|
|
7
10
|
getByTabId: `${backendUrl}/saas/contractors`,
|
|
@@ -9,6 +12,20 @@ const Endpoints = {
|
|
|
9
12
|
`${backendUrl}/saas/contractors/search?&projectId=${projectId}&searchWord=${searchWord}`
|
|
10
13
|
};
|
|
11
14
|
|
|
15
|
+
const createRequest = (createRequestModel, context) => {
|
|
16
|
+
return requests.postRequestHandler(Endpoints.create, createRequestModel, context);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const inviteRequestViaPublicLink = (createRequestModel, context) => {
|
|
20
|
+
return requests.postRequestHandler(Endpoints.publicLinkInvite, createRequestModel, context);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const editRequestAndRecordDetails = (editRequestModel, context) => {
|
|
24
|
+
const params = { updateInfoUser: 'EditVendor' };
|
|
25
|
+
const { record: { contractorId } } = editRequestModel;
|
|
26
|
+
return requests.postRequestHandler(Endpoints.edit(contractorId), editRequestModel, context, {}, params);
|
|
27
|
+
};
|
|
28
|
+
|
|
12
29
|
const getReqeustById = (requestId, context) => {
|
|
13
30
|
return requests.getRequestHandler(Endpoints.getById(requestId), {}, context);
|
|
14
31
|
};
|
|
@@ -27,6 +44,9 @@ const requestsGlobalSearch = (projectId, searchWord, context) => {
|
|
|
27
44
|
};
|
|
28
45
|
|
|
29
46
|
module.exports = {
|
|
47
|
+
createRequest,
|
|
48
|
+
inviteRequestViaPublicLink,
|
|
49
|
+
editRequestAndRecordDetails,
|
|
30
50
|
getReqeustById,
|
|
31
51
|
getRequestsByAccountId,
|
|
32
52
|
getRequestsByTabId,
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
const requestsAPI = require('./requests.api');
|
|
2
|
+
const { CreateRequestModel } = require('../models/create.request.model');
|
|
3
|
+
const { RequestModel } = require('../models/edit.request.model');
|
|
4
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
5
|
+
|
|
6
|
+
const createRequest = async (createRequestModel, context) => {
|
|
7
|
+
validateType(createRequestModel, CreateRequestModel);
|
|
8
|
+
return requestsAPI.createRequest(createRequestModel, context);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const inviteRequestViaPublicLink = async (createRequestModel, context) => {
|
|
12
|
+
validateType(createRequestModel, CreateRequestModel);
|
|
13
|
+
return requestsAPI.inviteRequestViaPublicLink(createRequestModel, context);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const editRequestAndRecordDetails = (editRequestModel, context) => {
|
|
17
|
+
validateType(editRequestModel, RequestModel);
|
|
18
|
+
return requestsAPI.editRequestAndRecordDetails(editRequestModel, context);
|
|
19
|
+
};
|
|
2
20
|
|
|
3
21
|
const getRequestsByTabId = (tabId, context, activityStatus = 'Active') => {
|
|
4
22
|
return requestsAPI.getRequestsByTabId(tabId, context, activityStatus);
|
|
@@ -23,6 +41,9 @@ const requestsGlobalSearch = (projectId, searchWord, context) => {
|
|
|
23
41
|
};
|
|
24
42
|
|
|
25
43
|
module.exports = {
|
|
44
|
+
createRequest,
|
|
45
|
+
inviteRequestViaPublicLink,
|
|
46
|
+
editRequestAndRecordDetails,
|
|
26
47
|
getRequestsByTabId,
|
|
27
48
|
getReqeustById,
|
|
28
49
|
getRequestsByAccountId,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
const services = require('./api/requests.service');
|
|
2
2
|
|
|
3
3
|
const { TenantRequestModel, RequestModel, TabModel } = require('./models/edit.request.model');
|
|
4
|
+
const { CreateRequestModel, ContractorInfo } = require('./models/create.request.model');
|
|
4
5
|
|
|
5
6
|
const models = {
|
|
6
7
|
TenantRequestModel,
|
|
7
8
|
RequestModel,
|
|
8
|
-
TabModel
|
|
9
|
+
TabModel,
|
|
10
|
+
CreateRequestModel,
|
|
11
|
+
ContractorInfo
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
module.exports = { services, models };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
|
+
|
|
3
|
+
function CreateRequestModel(requirementId, inviterEmail, vendorInfo, { tabId = null, sendMail = false, publicLink } = {}) {
|
|
4
|
+
this.reqId = requirementId;
|
|
5
|
+
this.inviterEmail = inviterEmail;
|
|
6
|
+
this.vendorInfo = vendorInfo;
|
|
7
|
+
this.disableMail = !sendMail;
|
|
8
|
+
this.tabId = tabId;
|
|
9
|
+
this.publicLink = publicLink;
|
|
10
|
+
|
|
11
|
+
vendorInfo && validateType(vendorInfo, ContractorInfo);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function ContractorInfo(recordType, email, companyName, additionalEmails) {
|
|
15
|
+
this.recordType = recordType;
|
|
16
|
+
this.email = email;
|
|
17
|
+
this.companyName = companyName;
|
|
18
|
+
this.title = email;
|
|
19
|
+
this.additionalEmails = additionalEmails;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { CreateRequestModel, ContractorInfo };
|