@getjones/test-infra 2.6.2 → 2.6.4

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": "2.6.2",
3
+ "version": "2.6.4",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  const requests = require('../../saas/internal-api/requests');
2
- const { credentials } = require('../../../../../src/env');
2
+ const { credentials } = require('../../../src/env');
3
3
  const coi = require('../../saas/internal-api/coi');
4
4
  const compliance = require('../../saas/internal-api/compliance');
5
5
  const auth = require('../../saas/internal-api/auth');
@@ -1,5 +1,7 @@
1
- const { ICS, PM, AUDITOR } = require('../../../../common/consts/userTypes');
2
-
3
- const UPLOADER_TYPES = { ICS, PM, AUDITOR };
1
+ const UPLOADER_TYPES = {
2
+ ICS: 'ICS',
3
+ PM: 'PM',
4
+ AUDITOR: 'AUDITOR'
5
+ };
4
6
 
5
7
  module.exports = UPLOADER_TYPES;
@@ -1,12 +1,6 @@
1
- const env = require('../../../../../env');
2
-
3
1
  const waiveApi = require('./waive.api');
4
2
  const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
5
3
  const { validateType } = require('../../../../../common/validations/typeValidations');
6
- const util = require('../../utils/util');
7
-
8
- const { credentials } = env.getEnv();
9
- const userTypes = require('../../../../../common/consts/userTypes');
10
4
 
11
5
  const waive = (waiveRequestModel, context) => {
12
6
  validateType(waiveRequestModel, WaiveRequestModel);
@@ -18,63 +12,39 @@ const retract = (retractRequestModel, context) => {
18
12
  return waiveApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
19
13
  };
20
14
 
21
- const getWaiveModel = (
15
+ const getWaiveModel = async (
22
16
  record,
23
17
  policyName,
24
18
  attributeName,
25
19
  waiverReason,
26
- remarks,
27
- {
28
- userId,
29
- userRole
30
- } = {}) => {
31
- const auditId = getPolicyAuditIdFromRecord(record, policyName, util.getAttributeKey(attributeName));
32
- userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
33
- userRole = userRole || userTypes.ICS;
20
+ remarks
21
+ ) => {
22
+ const auditId = await getPolicyAuditIdFromRecord(record, policyName, attributeName);
34
23
 
35
24
  const waiveModel = new WaiveRequestModel({
25
+ userId: record.userId,
36
26
  contractorId: record.id,
37
27
  auditId,
38
28
  waiverReason,
39
- remarks,
40
- userId,
41
- userRole
29
+ remarks
42
30
  });
43
31
 
44
32
  return waiveModel;
45
33
  };
46
34
 
47
- const getWaiveModelByGap = (
48
- record,
49
- policyName,
50
- gap,
51
- reason,
52
- note,
53
- {
54
- userId,
55
- userRole
56
- } = {}) => {
57
- const attributeName = util.getAttributeNameByGap(record, policyName, gap);
58
-
59
- return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole });
60
- };
61
-
62
- const getRetractModel = (record, policyName, attributeName) => {
63
- const auditId = getPolicyAuditIdFromRecord(record, policyName, util.getAttributeKey(attributeName));
64
- const userId = env.getSystemUserIdentity(credentials.superUser).id;
65
- const userRole = userTypes.ICS;
35
+ const getRetractModel = async (record, policyName, attributeName) => {
36
+ const auditId = await getPolicyAuditIdFromRecord(record, policyName, attributeName);
66
37
 
67
38
  const retractModel = new RetractRequestModel({
39
+ userId: record.userId,
68
40
  contractorId: record.id,
69
- auditId,
70
- userId,
71
- userRole
41
+ auditId
72
42
  });
73
43
 
74
44
  return retractModel;
75
45
  };
76
46
 
77
- const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
47
+ const getPolicyAuditIdFromRecord = async (record, policyName, attributeName) => {
78
48
  const policy = record.reviewbyAuditor.find(contractorCoverage =>
79
49
  contractorCoverage.insuranceName === policyName);
80
50
 
@@ -91,10 +61,4 @@ const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
91
61
  return attribute.auditId;
92
62
  };
93
63
 
94
- module.exports = {
95
- waive,
96
- retract,
97
- getWaiveModel,
98
- getRetractModel,
99
- getWaiveModelByGap
100
- };
64
+ module.exports = { waive, retract, getWaiveModel, getRetractModel };
@@ -11,6 +11,14 @@ const AUDIT_ENTITY_STATUSES = {
11
11
  CLAIMS: 'Claims'
12
12
  };
13
13
 
14
+ const AUDIT_ATTRIBUTE_NAMES = {
15
+ CERTIFICATE_ISSUE_DATE: 'certIssueDate'
16
+ };
17
+
18
+ const AUDIT_POLICY_NAMES = {
19
+ GENERAL_LIABILITY: ''
20
+ };
21
+
14
22
  const VALID_SCORES = ['A+', 'A'];
15
23
 
16
24
  const AUDITOR_ROLE = 'Auditor';
@@ -66,6 +74,8 @@ module.exports = {
66
74
  ATTRIBUTE_NAMES_MAP,
67
75
  COI_AUDIT_STATUSES,
68
76
  AUDITOR_ROLE,
77
+ AUDIT_POLICY_NAMES,
78
+ AUDIT_ATTRIBUTE_NAMES,
69
79
  AUDIT_ENTITY_STATUSES,
70
80
  VALID_SCORES
71
81
  };
@@ -1,3 +1,5 @@
1
+ const DEFAULT_USER_ROLE = 'ICS';
2
+
1
3
  const WAIVE_ACTIONS = {
2
4
  WAIVE: 'ignored',
3
5
  RETRACT: 'notIgnored'
@@ -10,29 +12,24 @@ const WAIVER_REASONS = {
10
12
  };
11
13
 
12
14
  function WaiveRequestModel({
15
+ userId,
13
16
  contractorId,
14
17
  auditId,
15
18
  waiverReason,
16
- remarks,
17
- userId,
18
- userRole
19
+ remarks = '',
20
+ userRole = DEFAULT_USER_ROLE
19
21
  }) {
20
22
  this.auditorContractorId = auditId;
21
23
  this.contractorId = contractorId;
24
+ this.userId = userId;
22
25
  this.waiverReason = waiverReason;
23
- this.remarks = remarks || '';
26
+ this.remarks = remarks;
24
27
 
25
- this.userId = userId,
26
- this.userRole = userRole,
28
+ this.userRole = userRole;
27
29
  this.status = WAIVE_ACTIONS.WAIVE;
28
30
  }
29
31
 
30
- function RetractRequestModel({
31
- contractorId,
32
- auditId,
33
- userId,
34
- userRole
35
- }) {
32
+ function RetractRequestModel({ userId, contractorId, auditId, userRole = DEFAULT_USER_ROLE }) {
36
33
  this.auditorContractorId = auditId;
37
34
  this.contractorId = contractorId;
38
35
  this.userId = userId;
@@ -2,8 +2,6 @@ const { AUDIT_ENTITY_STATUSES, DEFAULT_POLICY_ID, VALID_SCORES } = require('../c
2
2
  const { isObject, isArray } = require('../../../../common/utils/dataTypeUtils');
3
3
  const timeUtils = require('../../../../common/utils/timeUtils');
4
4
  const auditModels = require('../models/audit/audit.model');
5
- const waiveModels = require('../models/waive/waive.model');
6
-
7
5
  const { getEnv, getSystemUserIdentity } = require('../../../../env');
8
6
  const { credentials } = getEnv();
9
7
 
@@ -25,27 +23,6 @@ const getAttributeKey = attribute => {
25
23
  return specialAttributes[attribute] || attribute;
26
24
  };
27
25
 
28
- const getWaiveReason = reason => {
29
- return waiveReasons[reason] || reason;
30
- };
31
-
32
- const getAttributeNameByGap = function(record, policyName, gap) {
33
- const policy = record.reviewbyAuditor.find(contractorCoverage =>
34
- contractorCoverage.insuranceName === policyName);
35
-
36
- if (!policy) {
37
- throw new Error(`Policy name ${policyName} don't exist in record`);
38
- }
39
-
40
- const attribute = policy.errorList.find(error => error.errorHeadline === gap);
41
-
42
- if (!attribute) {
43
- throw new Error(`Gap ${gap} don't exist in record`);
44
- }
45
-
46
- return attribute.limitname;
47
- };
48
-
49
26
  const getPolicyId = (policyName, requirement) => {
50
27
  if (!policyName || policyName === 'Certificate of Insurance') {
51
28
  return DEFAULT_POLICY_ID;
@@ -91,7 +68,7 @@ const parseAuditConfig = function(config) {
91
68
  }
92
69
 
93
70
  if (isArray(attributes[attributeName])) {
94
- selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName][0]).toUpperCase()];
71
+ selection.status = AUDIT_ENTITY_STATUSES[ (attributes[attributeName][0]).toUpperCase() ];
95
72
  selection.value = attributes[attributeName][1].replace('$', emptyValue);
96
73
  } else {
97
74
  // Special statuses switch
@@ -103,7 +80,7 @@ const parseAuditConfig = function(config) {
103
80
  selection.status = AUDIT_ENTITY_STATUSES.YES;
104
81
  break;
105
82
  default:
106
- selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName]).toUpperCase()];
83
+ selection.status = AUDIT_ENTITY_STATUSES[ (attributes[attributeName]).toUpperCase() ];
107
84
  break;
108
85
  }
109
86
 
@@ -121,10 +98,10 @@ const parseAuditConfig = function(config) {
121
98
  certificateEndorsmentsList.includes(field) && (selection.policyName = field);
122
99
 
123
100
  if (isArray(config[field])) {
124
- selection.status = AUDIT_ENTITY_STATUSES[(config[field][0]).toUpperCase()];
101
+ selection.status = AUDIT_ENTITY_STATUSES[ (config[field][0]).toUpperCase() ];
125
102
  selection.value = config[field][1]; // Ok to be undefined
126
103
  } else {
127
- selection.status = AUDIT_ENTITY_STATUSES[(config[field]).toUpperCase()] || AUDIT_ENTITY_STATUSES.YES;
104
+ selection.status = AUDIT_ENTITY_STATUSES[ (config[field]).toUpperCase() ] || AUDIT_ENTITY_STATUSES.YES;
128
105
  selection.value = getValueBySelection(config[field]);
129
106
  }
130
107
 
@@ -159,10 +136,7 @@ module.exports = {
159
136
  parseAuditConfig,
160
137
  getPolicyId,
161
138
  createAuditEntity,
162
- getAuditorId,
163
- getAttributeKey,
164
- getAttributeNameByGap,
165
- getWaiveReason
139
+ getAuditorId
166
140
  };
167
141
 
168
142
  const certificateEndorsmentsList = [
@@ -199,9 +173,3 @@ const specialAttributes = {
199
173
  'Umbrella': 'UMoccur'
200
174
  }
201
175
  };
202
-
203
- const waiveReasons = {
204
- 'No Exposure': waiveModels.WAIVER_REASONS.NO_EXPOSURE,
205
- 'Business Decision': waiveModels.WAIVER_REASONS.BUSINESS_DECISION,
206
- 'Executive Approval': waiveModels.WAIVER_REASONS.EXECUTIVE_APPROVAL
207
- };
@@ -20,7 +20,7 @@ const Endpoints = {
20
20
  updateVendorExpiryDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/expiry-date`,
21
21
  updateContractorInviteDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/invite-date`,
22
22
  searchInAutocomplete: ({ tabId, searchWord }) =>
23
- `${backendUrl}/saas/contractors/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
23
+ `${backendUrl}/saas/requests/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
24
24
  automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`
25
25
  };
26
26
 
@@ -2,7 +2,7 @@ const requests = require('../../../../common/requests/cookieAuth/requests');
2
2
  const { backendUrl } = require('../../../../env').getEnv();
3
3
 
4
4
  const Endpoints = {
5
- innerPageRecordsApi: `${backendUrl}/saas/analytics/dashboard/records`
5
+ innerPageRecordsApi: `${backendUrl}/saas/analytics/dashboard/requests`
6
6
  };
7
7
 
8
8
  const getSortedRecordsForDashboardInnerPage = (dashboardCriteriaModel, context) => {
@@ -2,14 +2,14 @@ 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
+ create: `${backendUrl}/saas/requests/invite`,
6
+ publicLinkInvite: `${backendUrl}/_saas/requests/publicinvite`,
7
+ edit: contractorId => `${backendUrl}/saas/requests/${contractorId}/update`,
8
8
  getById: requestId => `${backendUrl}/saas/request/${requestId}`,
9
9
  getAccountRequests: accountId => `${backendUrl}/saas/requests/${accountId}`,
10
- getByTabId: `${backendUrl}/saas/contractors`,
10
+ getByTabId: `${backendUrl}/saas/requests`,
11
11
  requestsGlobalSearch: (projectId, searchWord) =>
12
- `${backendUrl}/saas/contractors/search?&projectId=${projectId}&searchWord=${searchWord}`
12
+ `${backendUrl}/saas/requests/search?&projectId=${projectId}&searchWord=${searchWord}`
13
13
  };
14
14
 
15
15
  const createRequest = (createRequestModel, context) => {
@@ -27,8 +27,8 @@ const updateRequirement = (updateRequirementModel, tabId, context) => {
27
27
  return requests.postRequestHandler(Endpoints.update, updateRequirementModel, context, {}, { tabId });
28
28
  };
29
29
 
30
- const updateRequirementWithNotification = (updateRequirementModel, context) => {
31
- return requests.postRequestHandler(Endpoints.updateWithNotification, updateRequirementModel, context);
30
+ const updateRequirementWithNotification = (updateRequirementModel, tabId, context) => {
31
+ return requests.postRequestHandler(Endpoints.updateWithNotification, updateRequirementModel, context, {}, { tabId });
32
32
  };
33
33
 
34
34
  const deleteByRequirementId = (requirementId, context) => {
@@ -53,9 +53,9 @@ const updateRequirement = (updateRequirementModel, tabId, context) => {
53
53
  return requirementsAPI.updateRequirement(updateRequirementModel, tabId, context);
54
54
  };
55
55
 
56
- const updateRequirementWithNotification = (updateRequirementModel, context) => {
56
+ const updateRequirementWithNotification = (updateRequirementModel, tabId, context) => {
57
57
  validateType(updateRequirementModel, UpdateRequirementModel);
58
- return requirementsAPI.updateRequirementWithNotification(updateRequirementModel, context);
58
+ return requirementsAPI.updateRequirementWithNotification(updateRequirementModel, tabId, context);
59
59
  };
60
60
 
61
61
  const deleteByRequirementId = (requirementId, context) => {
@@ -1,6 +1,6 @@
1
1
  const { validateType } = require('../../../../common/validations/typeValidations');
2
+ const { REQUIREMENT_SHARING_LEVELS } = require('../consts/consts');
2
3
  const { PolicyModel } = require('./policy.model');
3
- const DEFAULT_REQUIREMENT_TYPE = 'REQUIREMENT';
4
4
 
5
5
  class UpdateRequirementModel {
6
6
  constructor(id, accountId, projectId, tabId, name, policies, dateModified) {
@@ -10,7 +10,7 @@ class UpdateRequirementModel {
10
10
  this.tabId = tabId;
11
11
  this.name = name;
12
12
  this.policies = policies;
13
- this.requirementType = DEFAULT_REQUIREMENT_TYPE;
13
+ this.sharingLevel = REQUIREMENT_SHARING_LEVELS.TAB;
14
14
  this.dateModified = dateModified;
15
15
 
16
16
  validateType(policies, Array);
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- ICS: 'ICS',
3
- PM: 'PM',
4
- AUDITOR: 'AUDITOR'
5
- };