@getjones/test-infra 2.10.2 → 2.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/factory/users/users.js +3 -1
- package/src/index.js +0 -3
- package/src/resources/virusFile.pdf +0 -0
- package/src/saas/internal-api/agreement/api/agreement.api.js +14 -2
- package/src/saas/internal-api/agreement/api/agreement.service.js +50 -1
- 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 +2 -8
- package/src/saas/internal-api/contractors/api/contractors.service.js +1 -6
- package/src/saas/internal-api/dbEmails/consts/consts.js +1 -5
- package/src/saas/internal-api/dbEmails/utils/util.js +1 -12
- package/src/saas/internal-api/requirements/index.js +1 -2
- package/src/saas/internal-api/users/api/users.service.js +2 -1
- package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +0 -26
- package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +0 -50
- package/src/saas/internal-api/emailCustomization/index.js +0 -3
package/package.json
CHANGED
|
@@ -13,6 +13,8 @@ const roles = {
|
|
|
13
13
|
cm: 'Compliance Manager'
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
const generateFullName = role => `${role} User`;
|
|
17
|
+
|
|
16
18
|
const inviteSaasUser = async (username, role, projectIds, context) => {
|
|
17
19
|
const userResponse = await users.services.getUserByEmail(username, context);
|
|
18
20
|
|
|
@@ -36,7 +38,7 @@ const signupSaasUser = async (username, role, context) => {
|
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
const signupUserModel = await users.util.getSignupUserModel(username, role, role, defaultsPassword, context);
|
|
41
|
+
const signupUserModel = await users.util.getSignupUserModel(username, role, generateFullName(role), defaultsPassword, context);
|
|
40
42
|
const signupResponse = await users.services.signupUser(signupUserModel, context);
|
|
41
43
|
|
|
42
44
|
if (signupResponse.status !== httpResponseStatusCodes.OK) {
|
package/src/index.js
CHANGED
|
@@ -41,8 +41,6 @@ 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
|
-
|
|
46
44
|
const internalAPI = {
|
|
47
45
|
defaults,
|
|
48
46
|
auth,
|
|
@@ -65,7 +63,6 @@ const getInternalAPI = () => {
|
|
|
65
63
|
requestsTable,
|
|
66
64
|
threadScheduler,
|
|
67
65
|
dbEmails,
|
|
68
|
-
emailCustomization,
|
|
69
66
|
factory,
|
|
70
67
|
agreement,
|
|
71
68
|
uploadFile
|
|
Binary file
|
|
@@ -5,7 +5,17 @@ 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
|
|
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);
|
|
9
19
|
};
|
|
10
20
|
|
|
11
21
|
const createAgreement = (createAgreementModel, context) => {
|
|
@@ -20,5 +30,7 @@ const deleteAgreement = (recordId, context) => {
|
|
|
20
30
|
|
|
21
31
|
module.exports = {
|
|
22
32
|
createAgreement,
|
|
23
|
-
deleteAgreement
|
|
33
|
+
deleteAgreement,
|
|
34
|
+
uploadAgreementToS3,
|
|
35
|
+
getAgreementPreSignedUrl
|
|
24
36
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const FormData = require('form-data');
|
|
3
|
+
|
|
1
4
|
const agreementAPI = require('./agreement.api');
|
|
2
5
|
const { CreateAgreementModel } = require('../models/create.agreement.model');
|
|
3
6
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
7
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
4
8
|
|
|
5
9
|
const createAgreement = (createAgreementModel, context) => {
|
|
6
10
|
validateType(createAgreementModel, CreateAgreementModel);
|
|
@@ -11,7 +15,52 @@ const deleteAgreement = (recordId, context) => {
|
|
|
11
15
|
return agreementAPI.deleteAgreement(recordId, context);
|
|
12
16
|
};
|
|
13
17
|
|
|
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
|
+
};
|
|
14
62
|
module.exports = {
|
|
15
63
|
createAgreement,
|
|
16
|
-
deleteAgreement
|
|
64
|
+
deleteAgreement,
|
|
65
|
+
uploadAgreement
|
|
17
66
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { UPLOADER_TYPE } = require('../consts/consts');
|
|
2
2
|
|
|
3
3
|
class CreateAgreementModel {
|
|
4
|
-
constructor({ contractorId, contractorDateModified, uploaderId, signedContractName, uploaderType = UPLOADER_TYPE.USER }) {
|
|
4
|
+
constructor({ contractorId, contractorDateModified = null, 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}`);
|
|
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}`);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
return resumeAuditResponse.data;
|
|
@@ -25,8 +25,7 @@ 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
|
|
29
|
-
verifyInviteLink: encryptedData => `${backendUrl}/vendor-app/verify-link?data=${encryptedData}`
|
|
28
|
+
linkedProjectsCount: recordId => `${backendUrl}/saas/record/count/${recordId}/linked-projects`
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
const createContractor = (createContractorModel, context) => {
|
|
@@ -134,10 +133,6 @@ const updateLastInviteActionDate = (recordId, offsetInDays, context) => {
|
|
|
134
133
|
return requests.putRequestHandler(url, {}, context);
|
|
135
134
|
};
|
|
136
135
|
|
|
137
|
-
const getInviteLinkStatus = (encryptedData, context) => {
|
|
138
|
-
return requests.getRequestHandler(Endpoints.verifyInviteLink(encryptedData), {}, context, {});
|
|
139
|
-
};
|
|
140
|
-
|
|
141
136
|
module.exports = {
|
|
142
137
|
createContractor,
|
|
143
138
|
changeRequirement,
|
|
@@ -161,6 +156,5 @@ module.exports = {
|
|
|
161
156
|
muteNotifications,
|
|
162
157
|
unmuteNotifications,
|
|
163
158
|
getLinkedProjectsCount,
|
|
164
|
-
updateLastInviteActionDate
|
|
165
|
-
getInviteLinkStatus
|
|
159
|
+
updateLastInviteActionDate
|
|
166
160
|
};
|
|
@@ -162,10 +162,6 @@ 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
|
-
|
|
169
165
|
module.exports = {
|
|
170
166
|
createContractor,
|
|
171
167
|
changeRequirement,
|
|
@@ -193,6 +189,5 @@ module.exports = {
|
|
|
193
189
|
getAssignRequirementModel,
|
|
194
190
|
getLinkedProjectsCount,
|
|
195
191
|
restoreByRecordId,
|
|
196
|
-
updateLastInviteActionDate
|
|
197
|
-
getInviteLinkStatus
|
|
192
|
+
updateLastInviteActionDate
|
|
198
193
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const DEFAULT_EMAIL_SENDER = 'hellogetjonestest@gmail.com';
|
|
2
2
|
|
|
3
|
-
const tenantUserExtension = externalCompanyName => ` and ${externalCompanyName}`;
|
|
4
|
-
|
|
5
3
|
const EMAIL_TYPES = {
|
|
6
|
-
INVITE: 'invite',
|
|
7
4
|
COMPLIANT: 'compliant',
|
|
8
5
|
NOT_COMPLIANT: 'notCompliant',
|
|
9
6
|
SEND_GAPS: 'sendGaps',
|
|
@@ -23,7 +20,6 @@ const EMAIL_TYPES = {
|
|
|
23
20
|
};
|
|
24
21
|
|
|
25
22
|
const EMAIL_SUBJECT = {
|
|
26
|
-
invite: 'Your Insurance Docs are needed for',
|
|
27
23
|
compliant: ({ recordCompanyName }) => `Compliant COI - ${recordCompanyName}`,
|
|
28
24
|
sendGaps: ({ requesterName }) => `New Insurance Docs Required for ${requesterName} - `, //For this email type, guest is the same as vendor
|
|
29
25
|
sendGapsForTenant: ({ requesterName }) => `New Insurance Docs Required for leased space at ${requesterName} - `,
|
|
@@ -50,4 +46,4 @@ const EMAIL_SUBJECT = {
|
|
|
50
46
|
thankYou: 'Thank you for submitting your COI'
|
|
51
47
|
};
|
|
52
48
|
|
|
53
|
-
module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT
|
|
49
|
+
module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT };
|
|
@@ -62,21 +62,10 @@ 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
|
-
|
|
74
65
|
module.exports = {
|
|
75
66
|
recipientsMatchVerification,
|
|
76
67
|
regexVerification,
|
|
77
68
|
extractEmailFromNameAndEmailFormat,
|
|
78
69
|
logRetrievedEmailInfo,
|
|
79
|
-
getEmailTextInSubject
|
|
80
|
-
getMailActionButtonUrlRegex,
|
|
81
|
-
getEncryptedDataFromLink
|
|
70
|
+
getEmailTextInSubject
|
|
82
71
|
};
|
|
@@ -3,8 +3,7 @@ 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');
|
|
7
6
|
|
|
8
7
|
const models = { create: createModel, update: updateModel, policy: policyModel };
|
|
9
8
|
|
|
10
|
-
module.exports = { services, models, consts
|
|
9
|
+
module.exports = { services, models, consts };
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
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 delete email customization by id ${id}`);
|
|
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
|
-
};
|