@getjones/test-infra 3.1.5 → 3.1.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -2,5 +2,16 @@ module.exports = {
2
2
  tenantSolution: {
3
3
  on: { tenantSolution: true },
4
4
  off: { tenantSolution: false }
5
+ },
6
+ autoRenewals: {
7
+ on: { autoRenewals: true },
8
+ off: { autoRenewals: false }
9
+ },
10
+ autoGaps: {
11
+ onForAll: { autoGaps: { isAutoGapsEnabledForTenants: true, isAutoGapsEnabledForGuests: true, isAutoGapsEnabledForVendors: true } },
12
+ offForAll: { autoGaps: { isAutoGapsEnabledForTenants: false, isAutoGapsEnabledForGuests: false, isAutoGapsEnabledForVendors: false } },
13
+ onForVendors: { autoGaps: { isAutoGapsEnabledForTenants: false, isAutoGapsEnabledForGuests: false, isAutoGapsEnabledForVendors: true } },
14
+ onForTenants: { autoGaps: { isAutoGapsEnabledForTenants: true, isAutoGapsEnabledForGuests: false, isAutoGapsEnabledForVendors: false } },
15
+ onForGuests: { autoGaps: { isAutoGapsEnabledForTenants: false, isAutoGapsEnabledForGuests: true, isAutoGapsEnabledForVendors: false } }
5
16
  }
6
17
  };
@@ -1,9 +1,19 @@
1
- function SubmitCoiModel(contractorId, fileIds, uploadedBy, uploaderEmail, isContractorExist = true) {
2
- this.contractorId = contractorId;
3
- this.chosenIds = fileIds;
4
- this.uploadedBy = uploadedBy;
5
- this.uploaderEmail = uploaderEmail;
6
- this.isContractorExist = isContractorExist;
1
+ class SubmitCoiModel {
2
+ constructor({
3
+ recordId: contractorId,
4
+ fileIds,
5
+ uploadedBy,
6
+ uploaderEmail,
7
+ recordDateModified,
8
+ isContractorExist = true
9
+ }) {
10
+ this.contractorId = contractorId;
11
+ this.chosenIds = fileIds;
12
+ this.uploadedBy = uploadedBy;
13
+ this.uploaderEmail = uploaderEmail;
14
+ this.isContractorExist = isContractorExist;
15
+ this.recordDateModified = recordDateModified;
16
+ }
7
17
  }
8
18
 
9
19
  module.exports = { SubmitCoiModel };
@@ -2,36 +2,58 @@ const fs = require('fs');
2
2
 
3
3
  const services = require('../api/coi.service');
4
4
  const { SubmitCoiModel } = require('../models/submit.coi.model');
5
+ const { getContractorById } = require('../../contractors/api/contractors.service');
6
+ const { getIcsCookie } = require('../../auth/api/auth.service');
5
7
 
6
8
  const uploadFileToStorage = (recordId, filePath) => {
7
9
  const fileData = fs.createReadStream(filePath);
8
10
  return services.uploadToS3(recordId, fileData);
9
11
  };
10
12
 
11
- const submitCoiFilesUpload = (recordId, fileIds, uploaderType, uploaderEmail) => {
12
- const submitCoiModel = new SubmitCoiModel(
13
+ const submitCoiFilesUpload = ({
14
+ recordId,
15
+ fileIds,
16
+ uploadedBy,
17
+ uploaderEmail,
18
+ recordDateModified
19
+ }) => {
20
+ const submitCoiModel = new SubmitCoiModel({
13
21
  recordId,
14
22
  fileIds,
15
- uploaderType,
16
- uploaderEmail
17
- );
23
+ uploadedBy,
24
+ uploaderEmail,
25
+ recordDateModified
26
+ });
18
27
  return services.submitCoi(submitCoiModel);
19
28
  };
20
29
 
21
30
  const uploadCoi = async (
22
31
  recordId,
23
32
  filePath,
24
- uploaderType,
33
+ uploadedBy,
25
34
  uploaderEmail,
26
35
  {
27
36
  markAsScaned, // Should be passed with context
28
37
  context
29
38
  } = {}
30
39
  ) => {
40
+ if (!context) {
41
+ context = await getIcsCookie();
42
+ }
43
+
44
+ const recordResponse = await getContractorById(recordId, context);
45
+ const recordDateModified = recordResponse.data.dateModified;
31
46
  const uploadResponse = await uploadFileToStorage(recordId, filePath);
32
47
  const fileId = uploadResponse.data.fileId;
33
48
 
34
- const submitResponse = fileId && await submitCoiFilesUpload(recordId, [fileId], uploaderType, uploaderEmail);
49
+ const submitResponse = fileId && await submitCoiFilesUpload({
50
+ recordId,
51
+ fileIds: [fileId],
52
+ uploadedBy,
53
+ uploaderEmail,
54
+ recordDateModified
55
+ });
56
+
35
57
  const uploadedCoi = !!submitResponse.data.fileName && { id: fileId, name: submitResponse.data.fileName };
36
58
 
37
59
  if (uploadedCoi.name && markAsScaned && context) {
@@ -48,7 +48,8 @@ const EMAIL_SUBJECT = {
48
48
  requestNewCoi: ({ recordCompanyName, requesterName, isExpired }) => `${recordCompanyName}'s COI is ${isExpired ? 'expired' : 'about to expire'} - ${requesterName}`,
49
49
  malwareCoiFound: 'COI upload failed to pass security scan',
50
50
  thankYou: 'Thank you for submitting your COI',
51
- teamNoteMention: ({ taggingUserFullName, recordCompanyName }) => `${taggingUserFullName} mentioned you in a team note for ${recordCompanyName}`
51
+ teamNoteMention: ({ taggingUserFullName, recordCompanyName }) => `${taggingUserFullName} mentioned you in a team note for ${recordCompanyName}`,
52
+ reportSentSingleProject: ({ accountName, projectName }) => `Jones - Report for ${accountName}: ${projectName}`
52
53
  };
53
54
 
54
55
  module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT, tenantUserExtension };
@@ -32,6 +32,10 @@ const deleteProjectByName = async (accountId, projectName, context) => {
32
32
  );
33
33
  };
34
34
 
35
+ const deleteProjectById = async (projectId, context) => {
36
+ return projectsApi.deleteProjectById(projectId, context);
37
+ };
38
+
35
39
  const createProject = (createProjectModel, context) => {
36
40
  validateType(createProjectModel, CreateProjectModel);
37
41
  return projectsApi.create(createProjectModel, context);
@@ -61,5 +65,6 @@ module.exports = {
61
65
  createProject,
62
66
  deleteProjectByName,
63
67
  updateProject,
64
- getProjectServiceArea
68
+ getProjectServiceArea,
69
+ deleteProjectById
65
70
  };
@@ -9,6 +9,7 @@ const Endpoints = {
9
9
  getByProjectId: projectId =>
10
10
  `${backendUrl}/saas/project/${projectId}/team-members`,
11
11
  getByEmail: email => `${backendUrl}/saas/team-member/by-email/${email}`,
12
+ getEnabledAndDisabledByEmail: email => `${backendUrl}/saas/user/automation/email/${email}`,
12
13
  delete: userId => `${backendUrl}/saas/users/${userId}`,
13
14
  getUserListByRecordId: recordId => `${backendUrl}/saas/users/record/${recordId}`,
14
15
  deleteSingleProject: (userId, projectId) => `${backendUrl}/saas/project/${projectId}/sub-account/${userId}`,
@@ -47,6 +48,10 @@ const getUserByEmail = (email, context) => {
47
48
  return requests.getRequestHandler(Endpoints.getByEmail(email), null, context);
48
49
  };
49
50
 
51
+ const getEnabledAndDisabledByEmail = (email, context) => {
52
+ return requests.getRequestHandler(Endpoints.getEnabledAndDisabledByEmail(email), null, context);
53
+ };
54
+
50
55
  const getUserEncryptedData = (email, role, context) => {
51
56
  return requests.getRequestHandler(Endpoints.getUserEncryptedData(email, role), null, context);
52
57
  };
@@ -98,6 +103,7 @@ module.exports = {
98
103
  invite,
99
104
  signupUser,
100
105
  getUsersByProjectId,
106
+ getEnabledAndDisabledByEmail,
101
107
  getUserByEmail,
102
108
  getUserEncryptedData,
103
109
  getUserListByRecordId,
@@ -36,6 +36,16 @@ const getUserByEmail = async (email, context) => {
36
36
  return userAPI.getUserByEmail(email, context);
37
37
  };
38
38
 
39
+ const getEnabledAndDisabledByEmail = async (email, context) => {
40
+ const response = await userAPI.getEnabledAndDisabledByEmail(email, context);
41
+
42
+ if (response.status !== httpResponseStatusCodes.OK) {
43
+ throw new Error(`Failed to get user by email ${email}`);
44
+ }
45
+
46
+ return response.data;
47
+ };
48
+
39
49
  const getOrCreateUser = async (email, role, projectsIds, context, { fullName = role, password = credentials.strongPassword } = {}) => {
40
50
  let userResponse = await getUserByEmail(email, context);
41
51
 
@@ -185,6 +195,7 @@ module.exports = {
185
195
  signupUser,
186
196
  getUsersByProjectId,
187
197
  getUserByEmail,
198
+ getEnabledAndDisabledByEmail,
188
199
  getOrCreateUser,
189
200
  deleteUser,
190
201
  deleteUserFromSingleProject,
Binary file