@getjones/test-infra 2.10.3 → 2.10.5
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/factory/users/users.js +1 -3
- package/src/index.js +3 -0
- package/src/saas/internal-api/agreement/api/agreement.api.js +2 -14
- package/src/saas/internal-api/agreement/api/agreement.service.js +1 -50
- package/src/saas/internal-api/agreement/models/create.agreement.model.js +1 -1
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +2 -2
- package/src/saas/internal-api/contractors/api/contractors.api.js +8 -2
- package/src/saas/internal-api/contractors/api/contractors.service.js +6 -1
- package/src/saas/internal-api/dbEmails/consts/consts.js +5 -1
- package/src/saas/internal-api/dbEmails/utils/util.js +12 -1
- package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -0
- package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -0
- package/src/saas/internal-api/emailCustomization/index.js +3 -0
- package/src/saas/internal-api/requirements/index.js +2 -1
- package/src/saas/internal-api/users/api/users.service.js +1 -2
- package/src/resources/virusFile.pdf +0 -0
package/package.json
CHANGED
|
@@ -13,8 +13,6 @@ const roles = {
|
|
|
13
13
|
cm: 'Compliance Manager'
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const generateFullName = role => `${role} User`;
|
|
17
|
-
|
|
18
16
|
const inviteSaasUser = async (username, role, projectIds, context) => {
|
|
19
17
|
const userResponse = await users.services.getUserByEmail(username, context);
|
|
20
18
|
|
|
@@ -38,7 +36,7 @@ const signupSaasUser = async (username, role, context) => {
|
|
|
38
36
|
return;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
const signupUserModel = await users.util.getSignupUserModel(username, role,
|
|
39
|
+
const signupUserModel = await users.util.getSignupUserModel(username, role, role, defaultsPassword, context);
|
|
42
40
|
const signupResponse = await users.services.signupUser(signupUserModel, context);
|
|
43
41
|
|
|
44
42
|
if (signupResponse.status !== httpResponseStatusCodes.OK) {
|
package/src/index.js
CHANGED
|
@@ -41,6 +41,8 @@ const getInternalAPI = () => {
|
|
|
41
41
|
const agreement = require('./saas/internal-api/agreement/index');
|
|
42
42
|
const uploadFile = require('./saas/internal-api/uploadFiles/index');
|
|
43
43
|
|
|
44
|
+
const emailCustomization = require('./saas/internal-api/emailCustomization');
|
|
45
|
+
|
|
44
46
|
const internalAPI = {
|
|
45
47
|
defaults,
|
|
46
48
|
auth,
|
|
@@ -63,6 +65,7 @@ const getInternalAPI = () => {
|
|
|
63
65
|
requestsTable,
|
|
64
66
|
threadScheduler,
|
|
65
67
|
dbEmails,
|
|
68
|
+
emailCustomization,
|
|
66
69
|
factory,
|
|
67
70
|
agreement,
|
|
68
71
|
uploadFile
|
|
@@ -5,17 +5,7 @@ const AGREEMENT_API_URL = `${backendUrl}/saas/contractor/agreement`;
|
|
|
5
5
|
|
|
6
6
|
const Endpoints = {
|
|
7
7
|
create: AGREEMENT_API_URL,
|
|
8
|
-
delete: AGREEMENT_API_URL
|
|
9
|
-
getAgreementPreSignedUrl: `${backendUrl}/pre-signed-url/upload/agreement`,
|
|
10
|
-
submitContract: `${backendUrl}/saas/contractor/agreement`
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const getAgreementPreSignedUrl = (formData, context) => {
|
|
14
|
-
return requests.postRequestHandler(Endpoints.getAgreementPreSignedUrl, formData, context, formData.getHeaders());
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const uploadAgreementToS3 = (preSignedUrl, file) => {
|
|
18
|
-
return requests.putRequestHandler(preSignedUrl, file);
|
|
8
|
+
delete: AGREEMENT_API_URL
|
|
19
9
|
};
|
|
20
10
|
|
|
21
11
|
const createAgreement = (createAgreementModel, context) => {
|
|
@@ -30,7 +20,5 @@ const deleteAgreement = (recordId, context) => {
|
|
|
30
20
|
|
|
31
21
|
module.exports = {
|
|
32
22
|
createAgreement,
|
|
33
|
-
deleteAgreement
|
|
34
|
-
uploadAgreementToS3,
|
|
35
|
-
getAgreementPreSignedUrl
|
|
23
|
+
deleteAgreement
|
|
36
24
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const FormData = require('form-data');
|
|
3
|
-
|
|
4
1
|
const agreementAPI = require('./agreement.api');
|
|
5
2
|
const { CreateAgreementModel } = require('../models/create.agreement.model');
|
|
6
3
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
7
|
-
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
8
4
|
|
|
9
5
|
const createAgreement = (createAgreementModel, context) => {
|
|
10
6
|
validateType(createAgreementModel, CreateAgreementModel);
|
|
@@ -15,52 +11,7 @@ const deleteAgreement = (recordId, context) => {
|
|
|
15
11
|
return agreementAPI.deleteAgreement(recordId, context);
|
|
16
12
|
};
|
|
17
13
|
|
|
18
|
-
const getAgreementPreSignedUrl = (recordId, context, { filePath }) => {
|
|
19
|
-
const formData = new FormData();
|
|
20
|
-
const file = fs.createReadStream(filePath);
|
|
21
|
-
formData.append('recordId', recordId);
|
|
22
|
-
formData.append('fileType', 'CONTRACT');
|
|
23
|
-
formData.append('file', file);
|
|
24
|
-
|
|
25
|
-
return agreementAPI.getAgreementPreSignedUrl(formData, context);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const uploadAgreementToS3 = (preSignedUrl, file) => {
|
|
29
|
-
return agreementAPI.uploadAgreementToS3(preSignedUrl, file);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const uploadAgreement = async (
|
|
33
|
-
recordId,
|
|
34
|
-
filePath,
|
|
35
|
-
uploaderId,
|
|
36
|
-
context,
|
|
37
|
-
{ contractorDateModified } = {}
|
|
38
|
-
) => {
|
|
39
|
-
const { data: { preSignedUrl, fileName: fullFilePath } } = await getAgreementPreSignedUrl(recordId, context, { filePath });
|
|
40
|
-
|
|
41
|
-
const uploadResults = await uploadAgreementToS3(preSignedUrl, filePath);
|
|
42
|
-
|
|
43
|
-
if (uploadResults.status !== httpResponseStatusCodes.OK) {
|
|
44
|
-
throw new Error(`Failed to upload agreement for to S3 for contractor ${recordId}`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const createAgreementModel = new CreateAgreementModel({
|
|
48
|
-
contractorId: recordId,
|
|
49
|
-
contractorDateModified,
|
|
50
|
-
uploaderId,
|
|
51
|
-
signedContractName: fullFilePath
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const createResponse = await createAgreement(createAgreementModel, context);
|
|
55
|
-
|
|
56
|
-
if (createResponse.status !== httpResponseStatusCodes.OK) {
|
|
57
|
-
throw new Error(`Failed to upload agreement for contractor ${recordId}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return createResponse;
|
|
61
|
-
};
|
|
62
14
|
module.exports = {
|
|
63
15
|
createAgreement,
|
|
64
|
-
deleteAgreement
|
|
65
|
-
uploadAgreement
|
|
16
|
+
deleteAgreement
|
|
66
17
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { UPLOADER_TYPE } = require('../consts/consts');
|
|
2
2
|
|
|
3
3
|
class CreateAgreementModel {
|
|
4
|
-
constructor({ contractorId, contractorDateModified
|
|
4
|
+
constructor({ contractorId, contractorDateModified, uploaderId, signedContractName, uploaderType = UPLOADER_TYPE.USER }) {
|
|
5
5
|
this.contractorId = contractorId;
|
|
6
6
|
this.contractorDateModified = contractorDateModified;
|
|
7
7
|
this.uploaderId = uploaderId;
|
|
@@ -167,7 +167,7 @@ const putAuditOnHold = async function(auditId, onHoldReason, context) {
|
|
|
167
167
|
const onHoldResponse = await auditApi.putAuditOnHold(onHoldModel, context);
|
|
168
168
|
|
|
169
169
|
if (onHoldResponse.status !== httpResponseStatusCodes.OK) {
|
|
170
|
-
throw Error(`Failed to put audit on hold\n${onHoldResponse}`);
|
|
170
|
+
throw Error(`Failed to put audit on hold\n${onHoldResponse.data.message}`);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
return onHoldResponse.data;
|
|
@@ -177,7 +177,7 @@ const resumeAudit = async function(onHoldId, context) {
|
|
|
177
177
|
const resumeAuditResponse = await auditApi.resumeAudit(onHoldId, context);
|
|
178
178
|
|
|
179
179
|
if (resumeAuditResponse.status !== httpResponseStatusCodes.OK) {
|
|
180
|
-
throw Error(`Failed to resume audit\n${resumeAuditResponse}`);
|
|
180
|
+
throw Error(`Failed to resume audit\n${resumeAuditResponse.data.message}`);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
return resumeAuditResponse.data;
|
|
@@ -25,7 +25,8 @@ const Endpoints = {
|
|
|
25
25
|
`${backendUrl}/saas/requests/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
|
|
26
26
|
automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`,
|
|
27
27
|
assignRequirement: requestId => `${backendUrl}/saas/contractor/${requestId}/assign-requirement`,
|
|
28
|
-
linkedProjectsCount: recordId => `${backendUrl}/saas/record/count/${recordId}/linked-projects
|
|
28
|
+
linkedProjectsCount: recordId => `${backendUrl}/saas/record/count/${recordId}/linked-projects`,
|
|
29
|
+
verifyInviteLink: encryptedData => `${backendUrl}/vendor-app/verify-link?data=${encryptedData}`
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
const createContractor = (createContractorModel, context) => {
|
|
@@ -133,6 +134,10 @@ const updateLastInviteActionDate = (recordId, offsetInDays, context) => {
|
|
|
133
134
|
return requests.putRequestHandler(url, {}, context);
|
|
134
135
|
};
|
|
135
136
|
|
|
137
|
+
const getInviteLinkStatus = (encryptedData, context) => {
|
|
138
|
+
return requests.getRequestHandler(Endpoints.verifyInviteLink(encryptedData), {}, context, {});
|
|
139
|
+
};
|
|
140
|
+
|
|
136
141
|
module.exports = {
|
|
137
142
|
createContractor,
|
|
138
143
|
changeRequirement,
|
|
@@ -156,5 +161,6 @@ module.exports = {
|
|
|
156
161
|
muteNotifications,
|
|
157
162
|
unmuteNotifications,
|
|
158
163
|
getLinkedProjectsCount,
|
|
159
|
-
updateLastInviteActionDate
|
|
164
|
+
updateLastInviteActionDate,
|
|
165
|
+
getInviteLinkStatus
|
|
160
166
|
};
|
|
@@ -162,6 +162,10 @@ const restoreByRecordId = async (recordId, context) => {
|
|
|
162
162
|
return restoreResponse;
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
+
const getInviteLinkStatus = (encryptedData, context) => {
|
|
166
|
+
return contractorsAPI.getInviteLinkStatus(encryptedData, context);
|
|
167
|
+
};
|
|
168
|
+
|
|
165
169
|
module.exports = {
|
|
166
170
|
createContractor,
|
|
167
171
|
changeRequirement,
|
|
@@ -189,5 +193,6 @@ module.exports = {
|
|
|
189
193
|
getAssignRequirementModel,
|
|
190
194
|
getLinkedProjectsCount,
|
|
191
195
|
restoreByRecordId,
|
|
192
|
-
updateLastInviteActionDate
|
|
196
|
+
updateLastInviteActionDate,
|
|
197
|
+
getInviteLinkStatus
|
|
193
198
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const DEFAULT_EMAIL_SENDER = 'hellogetjonestest@gmail.com';
|
|
2
2
|
|
|
3
|
+
const tenantUserExtension = externalCompanyName => ` and ${externalCompanyName}`;
|
|
4
|
+
|
|
3
5
|
const EMAIL_TYPES = {
|
|
6
|
+
INVITE: 'invite',
|
|
4
7
|
COMPLIANT: 'compliant',
|
|
5
8
|
NOT_COMPLIANT: 'notCompliant',
|
|
6
9
|
SEND_GAPS: 'sendGaps',
|
|
@@ -20,6 +23,7 @@ const EMAIL_TYPES = {
|
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
const EMAIL_SUBJECT = {
|
|
26
|
+
invite: 'Your Insurance Docs are needed for',
|
|
23
27
|
compliant: ({ recordCompanyName }) => `Compliant COI - ${recordCompanyName}`,
|
|
24
28
|
sendGaps: ({ requesterName }) => `New Insurance Docs Required for ${requesterName} - `, //For this email type, guest is the same as vendor
|
|
25
29
|
sendGapsForTenant: ({ requesterName }) => `New Insurance Docs Required for leased space at ${requesterName} - `,
|
|
@@ -46,4 +50,4 @@ const EMAIL_SUBJECT = {
|
|
|
46
50
|
thankYou: 'Thank you for submitting your COI'
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT };
|
|
53
|
+
module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT, tenantUserExtension };
|
|
@@ -62,10 +62,21 @@ const getEmailTextInSubject = (recordCompanyName, emailType, isAfterUpdateRequir
|
|
|
62
62
|
return isAfterUpdateRequirements ? `Updated Requirements - ${subject}` : subject;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
const getMailActionButtonUrlRegex = () => {
|
|
66
|
+
return /(https:\/\/[a-zA-Z0-9.].*[a-zA-Z.]+\/CheckCustomersInviteLinkJSON\?data=[^"]+)/g;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getEncryptedDataFromLink = link => {
|
|
70
|
+
const encryptedData = link.split('data=').pop();
|
|
71
|
+
return encryptedData.slice(0, -2);
|
|
72
|
+
};
|
|
73
|
+
|
|
65
74
|
module.exports = {
|
|
66
75
|
recipientsMatchVerification,
|
|
67
76
|
regexVerification,
|
|
68
77
|
extractEmailFromNameAndEmailFormat,
|
|
69
78
|
logRetrievedEmailInfo,
|
|
70
|
-
getEmailTextInSubject
|
|
79
|
+
getEmailTextInSubject,
|
|
80
|
+
getMailActionButtonUrlRegex,
|
|
81
|
+
getEncryptedDataFromLink
|
|
71
82
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
getCustomizationsByAccountId: accountId => `${backendUrl}/saas/email-customizations?accountId=${accountId}`,
|
|
6
|
+
restoreDefaultById: id => `${backendUrl}/saas/email-customization/${id}/restore?version=DEFAULT`,
|
|
7
|
+
deletePermanentlyById: id => `${backendUrl}/saas/email-customization/${id}/permanently`
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const getEmailCustomizationsByAccountId = (accountId, context) => {
|
|
11
|
+
return requests.getRequestHandler(Endpoints.getCustomizationsByAccountId(accountId), {}, context);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const restoreDefaultById = (id, context) => {
|
|
15
|
+
return requests.postRequestHandler(Endpoints.restoreDefaultById(id), {}, context);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const deleteEmailCustomizationPermanentlyById = (id, context) => {
|
|
19
|
+
return requests.deleteRequestHandler(Endpoints.deletePermanentlyById(id), context);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
getEmailCustomizationsByAccountId,
|
|
24
|
+
restoreDefaultById,
|
|
25
|
+
deleteEmailCustomizationPermanentlyById
|
|
26
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
2
|
+
|
|
3
|
+
const emailCustomizationApi = require('./email.customization.api');
|
|
4
|
+
|
|
5
|
+
const getEmailCustomizationsByAccountId = async (accountId, context) => {
|
|
6
|
+
const response = await emailCustomizationApi.getEmailCustomizationsByAccountId(accountId, context);
|
|
7
|
+
|
|
8
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
9
|
+
throw new Error(`Failed to get email customization by account id ${accountId}`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return response.data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const restoreDefaultById = async (id, context) => {
|
|
16
|
+
const response = await emailCustomizationApi.restoreDefaultById(id, context);
|
|
17
|
+
|
|
18
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
19
|
+
throw new Error('Failed to restore email customization to default');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return response;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const deleteEmailCustomizationPermanentlyById = async (id, context) => {
|
|
26
|
+
const response = await emailCustomizationApi.deleteEmailCustomizationPermanentlyById(id, context);
|
|
27
|
+
|
|
28
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
29
|
+
throw new Error(`Failed to delete email customization by id ${id}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return response;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const restoreAllEmailCustomizationsInAccount = async (accountId, context) => {
|
|
36
|
+
const customizationList = await getEmailCustomizationsByAccountId(accountId, context);
|
|
37
|
+
|
|
38
|
+
for (const customization of customizationList) {
|
|
39
|
+
if (customization.id) {
|
|
40
|
+
await restoreDefaultById(customization.id, context);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
getEmailCustomizationsByAccountId,
|
|
47
|
+
restoreDefaultById,
|
|
48
|
+
deleteEmailCustomizationPermanentlyById,
|
|
49
|
+
restoreAllEmailCustomizationsInAccount
|
|
50
|
+
};
|
|
@@ -3,7 +3,8 @@ const updateModel = require('./models/update.requirement.model');
|
|
|
3
3
|
const policyModel = require('./models/policy.model');
|
|
4
4
|
const services = require('./api/requirements.service');
|
|
5
5
|
const consts = require('./consts/consts');
|
|
6
|
+
const utils = require('./utils/utils');
|
|
6
7
|
|
|
7
8
|
const models = { create: createModel, update: updateModel, policy: policyModel };
|
|
8
9
|
|
|
9
|
-
module.exports = { services, models, consts };
|
|
10
|
+
module.exports = { services, models, consts, utils };
|
|
Binary file
|