@getjones/test-infra 4.5.5 → 4.5.7

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": "4.5.5",
3
+ "version": "4.5.7",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,5 +10,9 @@ module.exports = {
10
10
  isPolicyVerificationEnabled: {
11
11
  on: { hasPolicyVerification: true },
12
12
  off: { hasPolicyVerification: false }
13
+ },
14
+ isAuditingAiEnabled: {
15
+ on: { isAuditingAiEnabled: true },
16
+ off: { isAuditingAiEnabled: false }
13
17
  }
14
18
  };
@@ -10,10 +10,12 @@ const recordComplianceStatuses = {
10
10
  compliant: 'COMPLIANT_STATUS',
11
11
  notCompliant: 'NOT_COMPLIANT_STATUS',
12
12
  noCOIRequired: 'NO_COI_REQUIRED',
13
+ awaitingCOI: 'EMPTY_STATUS',
13
14
  awaitingNewCOI: 'WAITING_NEW_COI_STATUS',
14
15
  waived: 'WAIVED_STATUS',
15
16
  underReview: 'UNDER_REVIEW',
16
17
  expired: 'Expired',
18
+ expiringSoon: 'ExpiringSoon',
17
19
  notResponsive: 'NotResponsive'
18
20
  };
19
21
 
@@ -8,26 +8,9 @@ const users = require('../../saas/internal-api/users');
8
8
  const { InviteUserModel } = users.models;
9
9
 
10
10
  const defaultsPassword = credentials.strongPassword;
11
- const roles = {
12
- readOnly: 'Read-only User',
13
- inviter: 'Inviter',
14
- cm: 'Compliance Manager'
15
- };
11
+ const { internalApiUserRoles: roles } = require('../../../src/common/consts/userRoles');
16
12
 
17
13
  const inviteSaasUser = async (username, role, projectIds, context, { hasCompleteAccessPermission } = {}) => {
18
- const userResponse = await users.services.getUserByEmail(username, context);
19
-
20
- if (userResponse.data && userResponse.data.id) {
21
- const { projectPermissions } = userResponse.data;
22
- const projectPermissionsIds = projectPermissions.map(projectPermission => projectPermission.projectId);
23
-
24
- projectIds = projectIds.filter(projectId => !projectPermissionsIds.includes(projectId));
25
-
26
- if (!projectIds.length) {
27
- return;
28
- }
29
- }
30
-
31
14
  const inviteUserModel = new InviteUserModel(username, role, projectIds, hasCompleteAccessPermission);
32
15
  const inviteResponse = await users.services.inviteUser([inviteUserModel], context);
33
16
 
package/src/index.js CHANGED
@@ -33,6 +33,7 @@ const getInternalAPI = () => {
33
33
  const dashboard = require('./saas/internal-api/dashboard');
34
34
  const accountDirectory = require('./saas/internal-api/accountDirectory');
35
35
  const notificationCenter = require('./saas/internal-api/notificationCenter');
36
+ const jonesNetworkTab = require('./saas/internal-api/jonesNetworkTab');
36
37
 
37
38
  const globalRecord = require('./saas/internal-api/globalRecord');
38
39
  const vendorProfile = require('./saas/internal-api/vendorProfile');
@@ -69,6 +70,7 @@ const getInternalAPI = () => {
69
70
  dashboard,
70
71
  accountDirectory,
71
72
  notificationCenter,
73
+ jonesNetworkTab,
72
74
  globalRecord,
73
75
  vendorProfile,
74
76
  serviceArea,
@@ -16,7 +16,8 @@ class UpdateAccountSettingsModel {
16
16
  integrations = {},
17
17
  auditSlaHours = 24,
18
18
  shouldReachOutVendors = true,
19
- isWithoutAutocompleteDistanceLimitation = false
19
+ isWithoutAutocompleteDistanceLimitation = false,
20
+ isJonesNetworkTabEnabled = false
20
21
  } = {}
21
22
  ) {
22
23
  this.accountId = accountId;
@@ -35,6 +36,7 @@ class UpdateAccountSettingsModel {
35
36
  this.auditSlaHours = auditSlaHours;
36
37
  this.shouldReachOutVendors = shouldReachOutVendors;
37
38
  this.isWithoutAutocompleteDistanceLimitation = isWithoutAutocompleteDistanceLimitation;
39
+ this.isJonesNetworkTabEnabled = isJonesNetworkTabEnabled;
38
40
  }
39
41
  }
40
42
 
@@ -56,5 +56,6 @@ const attributesConvertor = {
56
56
  'Coverage Auditing': 'isCoverageAudit',
57
57
  'Account Requirements': 'isAccountRequirementsEnabled',
58
58
  'Skip 50 miles autocomplete limitation': 'isWithoutAutocompleteDistanceLimitation',
59
- 'Policy Verification': 'hasPolicyVerification'
59
+ 'Policy Verification': 'hasPolicyVerification',
60
+ 'Auditing AI Enabled': 'isAuditingAiEnabled'
60
61
  };
@@ -9,6 +9,7 @@ const Endpoints = {
9
9
  submitCoi: `${backendUrl}/coi/merge`,
10
10
  completeScan: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/coi/complete-scan`,
11
11
  getCoiPresignedUrl: fileName => `${backendUrl}/saas/coi/${fileName}`,
12
+ getCoiPresignedUrlBeforeMerge: fileId => `${backendUrl}/saas/coi-file-before-merge/presigned-url/${fileId}`,
12
13
  getCoiHashes: recordId => `${backendUrl}/jcsc/record/${recordId}/coi/hashes`,
13
14
  combineLastTwoCOIs: `${backendUrl}/saas/auditor/record/coi/merge-last-two`
14
15
  };
@@ -34,6 +35,10 @@ const getCoiPreSignedUrl = (coiFileName, context) => {
34
35
  return requests.getRequestHandler(Endpoints.getCoiPresignedUrl(coiFileName), {}, context);
35
36
  };
36
37
 
38
+ const getCoiPresignedUrlBeforeMerge = (fileId, context) => {
39
+ return requests.getRequestHandler(Endpoints.getCoiPresignedUrlBeforeMerge(fileId), {}, context);
40
+ };
41
+
37
42
  const getCoiHashes = recordId => {
38
43
  return internalRequests.getRequestHandler(Endpoints.getCoiHashes(recordId));
39
44
  };
@@ -42,4 +47,12 @@ const combineLastTwoCOIs = (combineLastTwoCOIsModel, context) => {
42
47
  return requests.postRequestHandler(Endpoints.combineLastTwoCOIs, combineLastTwoCOIsModel, context);
43
48
  };
44
49
 
45
- module.exports = { uploadToS3, submitCoi, completeScan, getCoiPreSignedUrl, getCoiHashes, combineLastTwoCOIs };
50
+ module.exports = {
51
+ uploadToS3,
52
+ submitCoi,
53
+ completeScan,
54
+ getCoiPreSignedUrl,
55
+ getCoiPresignedUrlBeforeMerge,
56
+ getCoiHashes,
57
+ combineLastTwoCOIs
58
+ };
@@ -21,6 +21,20 @@ const getCoiPreSignedUrl = (coiFileName, context) => {
21
21
  return coiApi.getCoiPreSignedUrl(coiFileName, context);
22
22
  };
23
23
 
24
+ const getCoiPresignedUrlBeforeMerge = async (fileId, context, { expectError } = {}) => {
25
+ const response = await coiApi.getCoiPresignedUrlBeforeMerge(fileId, context);
26
+
27
+ if (expectError) {
28
+ return response;
29
+ }
30
+
31
+ if (response.status !== httpResponseStatusCodes.OK) {
32
+ throw new Error(`Failed to get presigned url for file before merge with fileId: ${fileId}`);
33
+ }
34
+
35
+ return response.data.preSignedUrl;
36
+ };
37
+
24
38
  const getCoiHashes = recordId => {
25
39
  return coiApi.getCoiHashes(recordId);
26
40
  };
@@ -36,4 +50,12 @@ const combineLastTwoCOIs = async (combineLastTwoCOIsModel, auditorContext) => {
36
50
  return response;
37
51
  };
38
52
 
39
- module.exports = { uploadToS3, submitCoi, getCoiPreSignedUrl, completeScan, getCoiHashes, combineLastTwoCOIs };
53
+ module.exports = {
54
+ uploadToS3,
55
+ submitCoi,
56
+ getCoiPreSignedUrl,
57
+ getCoiPresignedUrlBeforeMerge,
58
+ completeScan,
59
+ getCoiHashes,
60
+ combineLastTwoCOIs
61
+ };
@@ -1,4 +1,5 @@
1
1
  const defaultCoiHashValue = '79c8e018c43de2d8f4c6b489dde08cc3e21abe30f3e5f3a26ee4a0bca1ca6226';
2
2
  const realCoiHashValue = '71de8e0b212168cb513c9f38af63f6b4f6186f950412b9e1e0ea84e1e54e47ce';
3
+ const secondCoiHashValue = '01d359a1d4ec9336526723e6533b92569515be1dd57115d0d73da7b45b48a827';
3
4
 
4
- module.exports = { defaultCoiHashValue, realCoiHashValue };
5
+ module.exports = { defaultCoiHashValue, realCoiHashValue, secondCoiHashValue };
@@ -93,7 +93,7 @@ const getWaiveModelByGap = (
93
93
  return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole, auditId });
94
94
  };
95
95
 
96
- const getRetractModel = (record, policyName, attributeName, { isAttributeMultipleComments } = {}) => {
96
+ const getRetractModel = (record, policyName, attributeName) => {
97
97
  const auditIds = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
98
98
  const userId = env.getSystemUserIdentity(credentials.superUser).id;
99
99
  const userRole = userTypes.ICS;
@@ -108,7 +108,7 @@ const getRetractModel = (record, policyName, attributeName, { isAttributeMultipl
108
108
  });
109
109
  retractModels.push(model);
110
110
  }
111
- return isAttributeMultipleComments ? retractModels : retractModels[0];
111
+ return retractModels.length > 1 ? retractModels : retractModels[0];
112
112
  };
113
113
 
114
114
  const getPolicyAuditIdsFromRecord = (record, policyName, attributeName) => {
@@ -0,0 +1,14 @@
1
+ const requests = require('../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ isNetworkTabEnabledForUser: `${backendUrl}/saas/account/user/jones-network-enabled/setting`
6
+ };
7
+
8
+ const isNetworkTabEnabledForUser = async context => {
9
+ return requests.getRequestHandler(Endpoints.isNetworkTabEnabledForUser, { }, context);
10
+ };
11
+
12
+ module.exports = {
13
+ isNetworkTabEnabledForUser
14
+ };
@@ -0,0 +1,16 @@
1
+ const networkTabApi = require('./jones.network.tab.api');
2
+ const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
3
+
4
+ const isNetworkTabEnabledForUser = async context => {
5
+ const notificationPageResponse = await networkTabApi.isNetworkTabEnabledForUser(context);
6
+
7
+ if (notificationPageResponse.status !== httpResponseStatusCodes.OK) {
8
+ throw new Error(`Failed to get network tab enable settings status, cause by: ${notificationPageResponse.message}`);
9
+ }
10
+
11
+ return notificationPageResponse.data;
12
+ };
13
+
14
+ module.exports = {
15
+ isNetworkTabEnabledForUser
16
+ };
@@ -0,0 +1,3 @@
1
+ const services = require('./api/jones.network.tab.service');
2
+
3
+ module.exports = { services };
@@ -9,13 +9,24 @@ const doesRecordHaveAgreementStep = async (recordId, context) => {
9
9
  const recordDataResponse = await getRecordHubDataByRecordId(recordId, context);
10
10
 
11
11
  if (recordDataResponse.status !== httpResponseStatusCodes.OK) {
12
- throw new Error(`Failed to get record hub data\n${recordDataResponse.status}`);
12
+ throw new Error(`Failed to get record hub data, response status - ${recordDataResponse.status}`);
13
13
  }
14
14
 
15
15
  return recordDataResponse?.data?.isVendorsAgreementSignNeeded;
16
16
  };
17
17
 
18
+ const isFullPolicyCopyInRequirementByRecordId = async (recordId, context) => {
19
+ const recordDataResponse = await getRecordHubDataByRecordId(recordId, context);
20
+
21
+ if (recordDataResponse.status !== httpResponseStatusCodes.OK) {
22
+ throw new Error(`Failed to get record hub data, response status - ${recordDataResponse.status}`);
23
+ }
24
+
25
+ return recordDataResponse?.data?.isFullPolicyCopyInRequirement;
26
+ };
27
+
18
28
  module.exports = {
19
29
  getRecordHubDataByRecordId,
20
- doesRecordHaveAgreementStep
30
+ doesRecordHaveAgreementStep,
31
+ isFullPolicyCopyInRequirementByRecordId
21
32
  };
@@ -98,9 +98,11 @@ const deleteRequirementByName = async (requirementName, tabId, context) => {
98
98
  const deleteAllRequirementsInTabs = async (tabIds, context) => {
99
99
  const failedToDeleteRequirements = [];
100
100
  const successfulDeleteRes = [];
101
+ let requirementsToDelete = [];
101
102
 
102
103
  for (const tabId of tabIds) {
103
104
  const { data: existingRequirements } = await getRequirementsByTabId(tabId, context);
105
+ requirementsToDelete = existingRequirements || [];
104
106
 
105
107
  for (const requirement of existingRequirements) {
106
108
  const response = await deleteByRequirementId(requirement.id, context);
@@ -110,6 +112,11 @@ const deleteAllRequirementsInTabs = async (tabIds, context) => {
110
112
  failedToDeleteRequirements.push(response);
111
113
  }
112
114
 
115
+ if (response.data.result === 'linked') {
116
+ console.error('Requirement is linked to a record and cannot be deleted', requirement.id);
117
+ failedToDeleteRequirements.push(response);
118
+ }
119
+
113
120
  if (response.status === httpResponseStatusCodes.OK) {
114
121
  successfulDeleteRes.push(response.data.result);
115
122
  }
@@ -117,7 +124,7 @@ const deleteAllRequirementsInTabs = async (tabIds, context) => {
117
124
  }
118
125
 
119
126
  if (failedToDeleteRequirements.length) {
120
- throw Error(`Failed to delete ${failedToDeleteRequirements.length} of ${existingRequirements.length} requirements in account. Failed with status: ${ failedToDeleteRequirements[0].status }`);
127
+ throw Error(`Failed to delete ${failedToDeleteRequirements.length} of ${requirementsToDelete.length} requirements in account. Failed with status: ${ failedToDeleteRequirements[0].status }`);
121
128
  }
122
129
 
123
130
  return successfulDeleteRes;
Binary file