@getjones/test-infra 4.5.2 → 4.5.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": "4.5.2",
3
+ "version": "4.5.4",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -10,6 +10,7 @@ const requests = require('../../../saas/internal-api/requests');
10
10
  const dbEmails = require('../../../saas/internal-api/dbEmails');
11
11
  const activationStatuses = require('../../../common/consts/activationStatuses');
12
12
  const recordTypes = require('../../../common/consts/recordTypes');
13
+ const { policyNames } = require('../../../defaults/index').polices;
13
14
 
14
15
  const makeRecordNotResponsive = async function(recordId, context) {
15
16
  const { data: record } = await contractors.services.getContractorById(recordId, context);
@@ -24,6 +25,13 @@ const makeRecordNotResponsive = async function(recordId, context) {
24
25
  }
25
26
  };
26
27
 
28
+ const makeRecordAboutToExpire = async (recordId, policyExpiryDate, { policyName = policyNames.generalLiability } = {}) => {
29
+ await contractors.services.updateExpiryDate(recordId, policyExpiryDate, policyName);
30
+
31
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
32
+ expect(threadSchedulerResponse.status, 'Run thread scheduler has failed.').to.equal(httpResponseStatusCodes.OK);
33
+ };
34
+
27
35
  const resendInvitationByRecordId = async (recordId, tabId, context) => {
28
36
  const { id: requestId } = await requests.services.getRequestFromTabByRecordId(recordId, tabId, context);
29
37
  const recordModifyDateVerificationModel = await contractors.services.getRecordVerificationModel(recordId, context);
@@ -239,6 +247,7 @@ const waiveAllGaps = async (recordId, context) => {
239
247
 
240
248
  module.exports = {
241
249
  makeRecordNotResponsive,
250
+ makeRecordAboutToExpire,
242
251
  resendInvitationByRecordId,
243
252
  runOverAllRenewalDatesForRecord,
244
253
  editRequestAndRecordDetails,
@@ -26,7 +26,6 @@ const draftRecordSortBy = {
26
26
 
27
27
  const draftCompletionStatus = {
28
28
  missingContact: 'missingContact',
29
- missingRequirements: 'missingRequirements',
30
29
  missingCoi: 'missingCoi',
31
30
  readyForCoiRequest: 'readyForCoiRequest',
32
31
  readyForReview: 'readyForReview',
@@ -13,7 +13,6 @@ const DEFAULT_POLICY_NUMBER = 'ABC-12345-XYZ';
13
13
  const {
14
14
  certificateIssueDate,
15
15
  generalLiability
16
- // umbrella
17
16
  } = policyNames;
18
17
 
19
18
  const {
@@ -109,25 +108,6 @@ const setAboutExpiredConfig = config =>
109
108
  const setExpiredConfig = config =>
110
109
  config[generalLiability][policyExpired] = `${getOneWeekAgoDate()}`;
111
110
 
112
- // const getMinimumRequiredCompliantConfigForAutocomplete = () => { //maybe no need, just use regular one? which req?
113
- // const baseAuditConfig = getCompliantAuditConfigWithoutPolicies();
114
- // return {
115
- // ... baseAuditConfig,
116
- // [generalLiability]: {
117
- // [coverageExists]: policySelections.YES,
118
- // [policyNumber]: DEFAULT_POLICY_NUMBER,
119
- // [policyExpired]: `${DEFAULT_POLICY_DATE}`,
120
- // [eachOccurrence]: policySelections.YES
121
- // },
122
- // [umbrella]: {
123
- // [coverageExists]: policySelections.YES,
124
- // [policyNumber]: DEFAULT_POLICY_NUMBER,
125
- // [policyExpired]: `${DEFAULT_POLICY_DATE}`,
126
- // [eachOccurrence]: policySelections.YES
127
- // }
128
- // };
129
- // };
130
-
131
111
  module.exports = {
132
112
  getCompliantAuditConfig,
133
113
  getCompliantAuditConfigWithoutPolicies,
@@ -137,7 +117,6 @@ module.exports = {
137
117
  getExpiredConfig,
138
118
  setExpiredConfig,
139
119
  setAboutExpiredConfig,
140
- // getMinimumRequiredCompliantConfigForAutocomplete,
141
120
  policySelections,
142
121
  defaultPolicyDate: DEFAULT_POLICY_DATE,
143
122
  defaultExpiredPolicyDate: DEFAULT_EXPIRED_POLICY_DATE,
@@ -1,10 +1,9 @@
1
1
  const policies = require('../configs/polices');
2
- // const { cloneObject } = require('../../common/utils/objectUtils');
3
2
 
4
3
  const defaultExpiryDate = '2030-10-10T00:00:00.000Z';
5
4
  const defaultEffectiveDate = '2020-10-10T00:00:00.000Z';
6
5
 
7
- const policiesCoverageConfig = { //rename - coverage policies config
6
+ const policiesCoverageConfig = {
8
7
  [policies.policyNames.generalLiability]: {
9
8
  key: 'generalLiability',
10
9
  policyEntities: [
@@ -19,57 +18,8 @@ const policiesCoverageConfig = { //rename - coverage policies config
19
18
  key: 'eachOccurrence',
20
19
  value: 1000000
21
20
  }
22
- // {
23
- // key: 'productsCompletedOperationsAggregate',
24
- // value: 3000000
25
- // },
26
- // {
27
- // key: 'personalAdvertisingInjury',
28
- // value: 1000000
29
- // },
30
- // {
31
- // key: 'medicalExpenses',
32
- // value: 5000
33
- // },
34
- // {
35
- // key: 'damageToRentedPremises',
36
- // value: 50000
37
- // },
38
- // {
39
- // key: 'generalAggregate',
40
- // value: 2000000
41
- // }
42
21
  ],
43
- provisions: [
44
- // {
45
- // key: 'primaryNonContributoryProvision',
46
- // value: true
47
- // },
48
- // {
49
- // key: 'primaryNonContributoryForAdditionalInsured',
50
- // value: true
51
- // },
52
- // {
53
- // key: '10DaysNoticeOfCancellation',
54
- // value: true
55
- // },
56
- // {
57
- // key: 'contractualLiability',
58
- // value: true
59
- // },
60
- // {
61
- // key: 'perOccur',
62
- // value: true
63
- // },
64
- // {
65
- // key: 'perPolicy',
66
- // value: true
67
- // },
68
- // {
69
- // key: 'perProject',
70
- // value: true
71
- // }
72
- ]
22
+ provisions: []
73
23
  },
74
24
  [policies.policyNames.automobileLiability]: {
75
25
  key: 'automobileLiability',
@@ -86,20 +36,7 @@ const policiesCoverageConfig = { //rename - coverage policies config
86
36
  value: 1000000
87
37
  }
88
38
  ],
89
- provisions: [
90
- // {
91
- // key: 'anyAuto',
92
- // value: true
93
- // },
94
- // {
95
- // key: 'waiverOfSubrogation',
96
- // value: true
97
- // },
98
- // {
99
- // key: 'hired',
100
- // value: true
101
- // }
102
- ]
39
+ provisions: []
103
40
  },
104
41
  [policies.policyNames.excessLiability]: {
105
42
  key: 'excessLiability',
@@ -110,18 +47,8 @@ const policiesCoverageConfig = { //rename - coverage policies config
110
47
  policyNumber: 'EL-12345'
111
48
  }
112
49
  ],
113
- limits: [
114
- // {
115
- // key: 'eachOccurrence',
116
- // value: 1000000
117
- // }
118
- ],
119
- provisions: [
120
- // {
121
- // key: 'occur',
122
- // value: true
123
- // }
124
- ]
50
+ limits: [],
51
+ provisions: []
125
52
  },
126
53
  [policies.policyNames.umbrella]: {
127
54
  key: 'umbrellaLiability',
@@ -137,17 +64,8 @@ const policiesCoverageConfig = { //rename - coverage policies config
137
64
  key: 'eachOccurrence',
138
65
  value: 5000000
139
66
  }
140
- // {
141
- // key: 'aggregate',
142
- // value: 5000000
143
- // }
144
67
  ],
145
- provisions: [
146
- // {
147
- // key: 'occur',
148
- // value: true
149
- // }
150
- ]
68
+ provisions: []
151
69
  },
152
70
  [policies.policyNames.workersCompensation]: {
153
71
  key: 'workersCompensation',
@@ -163,17 +81,8 @@ const policiesCoverageConfig = { //rename - coverage policies config
163
81
  key: 'employersLiabilityEachAccident',
164
82
  value: 1000000
165
83
  }
166
- // {
167
- // key: 'employersLiabilityDiseaseEachEmployee',
168
- // value: 1000000
169
- // }
170
84
  ],
171
- provisions: [
172
- // {
173
- // key: 'statutoryLimitsRequired',
174
- // value: true
175
- // }
176
- ]
85
+ provisions: []
177
86
  },
178
87
  [policies.policyNames.fidelityCrime]: {
179
88
  key: 'fidelityCrime',
@@ -213,24 +122,23 @@ const policiesCoverageConfig = { //rename - coverage policies config
213
122
  }
214
123
  };
215
124
 
216
- const getAllAvailablePolicies = () => Object.keys(policiesCoverageConfig); //getting all available policy names! change the naming ["General Liability", "Automobile Liability", "Excess Liability", "Umbrella", "Workers’ Compensation", "Fidelity / Crime", "Cyber Liability", ]
125
+ const getAllAvailablePolicyNamesForCoverage = () => Object.keys(policiesCoverageConfig);
217
126
 
218
- const getRequiredPoliciesMinimumForAutocomplete = () => { //is being used in automation!
219
- const policies = getAllAvailablePolicies();
127
+ const getRequiredPoliciesMinimumForAutocomplete = () => { //is being used in automation
128
+ const policies = getAllAvailablePolicyNamesForCoverage();
220
129
  policies.length = 2;
221
130
  return policies;
222
131
  };
223
132
 
224
- const getMinimumPoliciesCoverageForAutocomplete = () => { //new that takes getRequiredPoliciesMinimumForAutocomplete and return the entire coverage policy config
225
- const policiesNames = getAllAvailablePolicies();
133
+ const getMinimumPoliciesCoverageConfigForAutocomplete = () => {
134
+ const policiesNames = getAllAvailablePolicyNamesForCoverage();
226
135
  policiesNames.length = 2;
227
136
  const minimumPoliciesCoverageConfig = policiesNames.map(policyName => policiesCoverageConfig[policyName]);
228
137
  return minimumPoliciesCoverageConfig;
229
138
  };
230
139
 
231
140
  module.exports = {
232
- getAllAvailablePolicies,
233
141
  getRequiredPoliciesMinimumForAutocomplete,
234
- getMinimumPoliciesCoverageForAutocomplete,
142
+ getMinimumPoliciesCoverageConfigForAutocomplete,
235
143
  policiesCoverageConfig
236
144
  };
@@ -66,7 +66,8 @@ const attributeNames = {
66
66
  anyAuto: 'Any Auto',
67
67
  scheduled: 'Scheduled',
68
68
  multiple: 'multiple',
69
- other: 'Other'
69
+ other: 'Other',
70
+ fullPolicyCopy: 'Full Policy Copy'
70
71
  };
71
72
 
72
73
  module.exports = {
@@ -2,18 +2,11 @@ const path = require('path');
2
2
 
3
3
  const env = require('../../../src/env');
4
4
  const { getEnv } = env;
5
- // const { getEnv } = require('../../env');
6
5
  const { credentials } = getEnv();
7
6
 
8
7
  const { internalAPI } = require('../../../src')(env);
9
8
  const { auth, requests, contractors, compliance, coi, defaults } = internalAPI;
10
9
 
11
- // const auth = require('../../saas/internal-api/auth');
12
- // const coi = require('../../saas/internal-api/coi');
13
- // const compliance = require('../../saas/internal-api/compliance');
14
- // const contractors = require('../../saas/internal-api/contractors');
15
- // const requests = require('../../saas/internal-api/requests');
16
-
17
10
  const { complianceStatuses, getAuditConfigByStatus, expiryStatuses } = require('../../common/utils/complianceUtil');
18
11
  const httpResponseStatusCodes = require('../../common/httpResponseStatusCodes.json');
19
12
  const activationStatuses = require('../../common/consts/activationStatuses');
@@ -55,17 +48,7 @@ const prepareRecord = async (recordCompany, recordEmail, status, tabId, requirem
55
48
  return recordId;
56
49
  }
57
50
 
58
- await uploadCoiToRecord(recordId);
59
- // const coiUpload = await coi.utils.uploadCoi(
60
- // recordId,
61
- // filePath,
62
- // uploaderType = coi.consts.UPLOADER_TYPES.ICS,
63
- // uploaderEmail = credentials.superUser
64
- // );
65
-
66
- // if (!(coiUpload && coiUpload.name)) {
67
- // throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
68
- // }
51
+ await uploadCoiByRecordId(recordId);
69
52
 
70
53
  if (complianceStatuses.underReview === status) {
71
54
  return recordId;
@@ -211,25 +194,26 @@ const prepareDraftRecord = async (recordCompany, tabId, context, { recordEmail,
211
194
 
212
195
  if (uploadCoi) {
213
196
  const recordId = requestData.record.contractorId;
214
- await uploadCoiToRecord(recordId);
215
-
216
- // const coiUpload = await coi.utils.uploadCoi(
217
- // recordId,
218
- // filePath,
219
- // uploaderType = coi.consts.UPLOADER_TYPES.ICS,
220
- // uploaderEmail = credentials.superUser
221
- // );
222
-
223
- // if (!(coiUpload && coiUpload.name)) {
224
- // throw Error(`Failed to upload COI for record ${recordCompany}\n${coiUpload}`);
225
- // }
197
+ await uploadCoiByRecordId(recordId);
226
198
  }
227
199
 
228
200
  return requestData;
229
201
  };
230
202
 
231
- const prepareRecordThatFitsAutocomplete = async (accountId, projectId, tabId, requirementId, recordCompany, recordEmail, context, { policyOwnerRecordId, inviterEmail, recordConfig, glPolicyNumber } = {}) => {
232
- //Requirements should include "General Liability"
203
+ const prepareRecordForAutocomplete = async (
204
+ accountId,
205
+ projectId,
206
+ tabId,
207
+ requirementId, //Requirements should include "General Liability"
208
+ recordCompany,
209
+ recordEmail,
210
+ context,
211
+ {
212
+ policyOwnerRecordId,
213
+ inviterEmail,
214
+ recordConfig,
215
+ glPolicyNumber
216
+ } = {}) => {
233
217
  const auditorContext = await auth.services.getAuditorCookie();
234
218
 
235
219
  const recordId = await prepareUnderReviewRecord(recordCompany, recordEmail, tabId, requirementId, context, { policyOwnerRecordId, inviterEmail, recordConfig, glPolicyNumber });
@@ -240,7 +224,7 @@ const prepareRecordThatFitsAutocomplete = async (accountId, projectId, tabId, re
240
224
  throw new Error(`Failed to get record by id: ${recordId}`);
241
225
  }
242
226
 
243
- const coveragePoliciesConfig = defaults.coverage.getMinimumPoliciesCoverageForAutocomplete();
227
+ const coveragePoliciesConfig = defaults.coverage.getMinimumPoliciesCoverageConfigForAutocomplete();
244
228
  const coverageResponse = await compliance.services.coverage.addCoverage(auditorContext, accountId, projectId, requirementId, recordDetails.data, coveragePoliciesConfig);
245
229
 
246
230
  if (coverageResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
@@ -270,7 +254,7 @@ const prepareRecordThatFitsAutocomplete = async (accountId, projectId, tabId, re
270
254
  return updatedRequest;
271
255
  };
272
256
 
273
- const uploadCoiToRecord = async recordId => {
257
+ const uploadCoiByRecordId = async recordId => {
274
258
  const coiUpload = await coi.utils.uploadCoi(
275
259
  recordId,
276
260
  filePath,
@@ -293,5 +277,5 @@ module.exports = {
293
277
  prepareAwaitingCoiRecord,
294
278
  prepareNoCoiRequireRecord,
295
279
  prepareDraftRecord,
296
- prepareRecordThatFitsAutocomplete
280
+ prepareRecordForAutocomplete
297
281
  };
package/src/index.js CHANGED
@@ -19,6 +19,7 @@ const getInternalAPI = () => {
19
19
  const requirements = require('./saas/internal-api/requirements');
20
20
  const contractors = require('./saas/internal-api/contractors');
21
21
  const requests = require('./saas/internal-api/requests');
22
+ const recordTeamNotes = require('./saas/internal-api/recordNotes');
22
23
 
23
24
  const coi = require('./saas/internal-api/coi');
24
25
  const compliance = require('./saas/internal-api/compliance');
@@ -31,6 +32,7 @@ const getInternalAPI = () => {
31
32
  const charts = require('./saas/internal-api/homepageCharts');
32
33
  const dashboard = require('./saas/internal-api/dashboard');
33
34
  const accountDirectory = require('./saas/internal-api/accountDirectory');
35
+ const notificationCenter = require('./saas/internal-api/notificationCenter');
34
36
 
35
37
  const globalRecord = require('./saas/internal-api/globalRecord');
36
38
  const vendorProfile = require('./saas/internal-api/vendorProfile');
@@ -56,6 +58,7 @@ const getInternalAPI = () => {
56
58
  requirements,
57
59
  contractors,
58
60
  requests,
61
+ recordTeamNotes,
59
62
  coi,
60
63
  compliance,
61
64
  auditNotes,
@@ -65,6 +68,7 @@ const getInternalAPI = () => {
65
68
  charts,
66
69
  dashboard,
67
70
  accountDirectory,
71
+ notificationCenter,
68
72
  globalRecord,
69
73
  vendorProfile,
70
74
  serviceArea,
@@ -1,6 +1,6 @@
1
1
  const coverageApi = require('./coverage.api');
2
2
  const { prepareMetadataForAudit } = require('../../../../../common/utils/complianceUtil');
3
- const { getCoverageConfig, getAllAvailablePolicies } = require('../../utils/coverageUtil');
3
+ const { getCoverageConfig } = require('../../utils/coverageUtil');
4
4
 
5
5
  const saveCoverageNode = coverage => {
6
6
  return coverageApi.saveCoverageNode(coverage);
@@ -18,24 +18,20 @@ const deleteCoverageByCoiId = (coiId, icsContext) => {
18
18
  return coverageApi.deleteCoverageByCoiId(coiId, icsContext);
19
19
  };
20
20
 
21
- const addCoverage = async function( //function that fits only automation (fits or is being used? maybe because of the coveragePolicesList which is only a list of policy names) - testFlowsInternalApi.auditRecord is using internalApi.compliance.addCoverage and passes array by default. //persistRecordStatus when passing coverage=true doesn't pass an array (for 28.10.24 i see only tests passing "true" are in setup that doesn't run again so can't see what happens here)
21
+ const addCoverage = async function(
22
22
  auditorContext,
23
23
  accountId,
24
24
  projectId,
25
25
  requirementId,
26
26
  record,
27
- policiesCoverageConfig //change naming, not only list now
27
+ policiesCoverageConfig //If automation is passing "true" - will no longer work, can pass an array of policy names instead
28
28
  ) {
29
29
  const coiId = record.certificatePdf.split('contractor').shift();
30
30
  const recordId = record.contractorId;
31
31
 
32
32
  const { auditDates } = await prepareMetadataForAudit(auditorContext, accountId, projectId, requirementId, recordId);
33
33
 
34
- const coverageConfig = getCoverageConfig(coiId, policiesCoverageConfig); //takes all coverage and not just 2 policies!
35
-
36
- // const coverageConfig = Array.isArray(policiesCoverageConfig) && typeof policiesCoverageConfig[0] !== 'object' ?
37
- // getCoverageConfig(coiId, policiesCoverageConfig) : //gets from automation only policy names, no limits and so on.. no use in integration
38
- // getCoverageConfig(coiId, getAllAvailablePolicies()); //getAllAvailablePolicies is not located in current file and gets a format that doesn't fit the function getCoverageConfig - in automation this can happen only via persis
34
+ const coverageConfig = getCoverageConfig(coiId, policiesCoverageConfig);
39
35
 
40
36
  const coverageResponse = await saveCoverageJava(auditorContext, auditDates, coverageConfig);
41
37
  return coverageResponse;
@@ -37,9 +37,10 @@ const getAllWaiveModels = (
37
37
  remarks,
38
38
  {
39
39
  userId,
40
- userRole
40
+ userRole,
41
+ auditId
41
42
  } = {}) => {
42
- const auditIds = getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
43
+ const auditIds = [auditId] || getPolicyAuditIdsFromRecord(record, policyName, auditUtil.getAttributeKey(attributeName));
43
44
  userId = userId || env.getSystemUserIdentity(credentials.superUser).id;
44
45
  userRole = userRole || userTypes.ICS;
45
46
 
@@ -70,9 +71,10 @@ const getWaiveModel = (
70
71
  remarks,
71
72
  {
72
73
  userId,
73
- userRole
74
+ userRole,
75
+ auditId
74
76
  } = {}) => {
75
- return getAllWaiveModels(record, policyName, attributeName, waiverReason, remarks, { userId, userRole })[0];
77
+ return getAllWaiveModels(record, policyName, attributeName, waiverReason, remarks, { userId, userRole, auditId })[0];
76
78
  };
77
79
 
78
80
  const getWaiveModelByGap = (
@@ -86,8 +88,9 @@ const getWaiveModelByGap = (
86
88
  userRole
87
89
  } = {}) => {
88
90
  const attributeName = auditUtil.getAttributeNameByGap(record, policyName, gap);
91
+ const auditorContractorId = auditUtil.getAuditorContractorIdByGap(record, policyName, gap);
89
92
 
90
- return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole });
93
+ return getWaiveModel(record, policyName, attributeName, reason, note, { userId, userRole, auditId: auditorContractorId });
91
94
  };
92
95
 
93
96
  const getRetractModel = (record, policyName, attributeName) => {
@@ -93,7 +93,9 @@ const auditOnHoldReason = {
93
93
  ESCALATION_TO_PM: 'Escalation to PM',
94
94
  ISSUE_WITH_REQUIREMENTS: 'Issue with Requirements',
95
95
  REQUIREMENTS_UPDATE: 'Requirements Update',
96
- INTERNAL_DISCUSSION: 'Internal Discussion'
96
+ INTERNAL_DISCUSSION: 'Internal Discussion',
97
+ POLICY_VERIFICATION: 'Policy Verification',
98
+ COI_REVIEW: 'COI Review (For Policy Analysts\' Use Only)'
97
99
  };
98
100
 
99
101
  module.exports = {
@@ -43,6 +43,23 @@ const getAttributeNameByGap = function(record, policyName, gap) {
43
43
  return attribute.limitname;
44
44
  };
45
45
 
46
+ const getAuditorContractorIdByGap = function(record, policyName, gap) {
47
+ const policy = record.reviewbyAuditor.find(contractorCoverage =>
48
+ contractorCoverage.insuranceName === policyName);
49
+
50
+ if (!policy) {
51
+ throw new Error(`Policy name ${policyName} don't exist in record`);
52
+ }
53
+
54
+ const attribute = policy.errorList.find(error => error.errorHeadline === gap);
55
+
56
+ if (!attribute) {
57
+ throw new Error(`Gap ${gap} don't exist in record`);
58
+ }
59
+
60
+ return attribute.auditId;
61
+ };
62
+
46
63
  const getAllWaivablePolicies = function(record) {
47
64
  const waivable = [];
48
65
 
@@ -97,6 +114,7 @@ const parseAuditConfig = function(config) {
97
114
  continue;
98
115
  }
99
116
 
117
+ //for "regular" policies (passes as an object)
100
118
  if (isObject(config[field])) {
101
119
  const attributes = config[field];
102
120
  for (const attributeName in attributes) {
@@ -119,7 +137,19 @@ const parseAuditConfig = function(config) {
119
137
 
120
138
  if (isArray(attributes[attributeName])) {
121
139
  selection.status = AUDIT_ENTITY_STATUSES[(attributes[attributeName][0]).toUpperCase()];
122
- selection.value = attributes[attributeName][1].replace('$', emptyValue);
140
+
141
+ const auditValue = attributes[attributeName][1]; //must be passed as an array of comments -> ['Other', ['comment1', 'comment2']]. when one comment can also be passed as ['Other', 'comment1']
142
+
143
+ if (multipleErrorsEndorsementAndAttributesList.includes(attributeName) && isArray(auditValue)) {
144
+ // in case of multiple comments when selecting "Other" in "regular" policies attributes like 'Full Policy copy'
145
+ for (const value of auditValue) {
146
+ const copiedSelection = { ... selection, value };
147
+ auditDataArr.push(copiedSelection);
148
+ }
149
+ continue;
150
+ } else {
151
+ selection.value = attributes[attributeName][1].replace('$', emptyValue);
152
+ }
123
153
  } else {
124
154
  // Special statuses switch
125
155
  switch (selection.attributeName) {
@@ -147,6 +177,7 @@ const parseAuditConfig = function(config) {
147
177
  const selection = { attributeName: getAttributeKey(field) };
148
178
  certificateEndorsementsList.includes(field) && (selection.policyName = field);
149
179
 
180
+ //For endorsements / certificate of insurance fields
150
181
  if (isArray(config[field])) {
151
182
  selection.status = AUDIT_ENTITY_STATUSES[(config[field][0]).toUpperCase()];
152
183
 
@@ -201,7 +232,8 @@ module.exports = {
201
232
  getAttributeKey,
202
233
  getAttributeNameByGap,
203
234
  getWaiveReason,
204
- getAllWaivablePolicies
235
+ getAllWaivablePolicies,
236
+ getAuditorContractorIdByGap
205
237
  };
206
238
 
207
239
  const certificateEndorsementsList = [
@@ -217,7 +249,8 @@ const multipleErrorsEndorsementAndAttributesList = [
217
249
  'Additional Information',
218
250
  'Additional Insured',
219
251
  'Agreement',
220
- 'Other'
252
+ 'Other',
253
+ 'Full Policy Copy'
221
254
  ];
222
255
 
223
256
  const specialAttributes = {
@@ -1,12 +1,12 @@
1
1
  const { cloneObject } = require('../../../../common/utils/objectUtils');
2
2
  const { policiesCoverageConfig } = require('../../../../defaults/configs/coverage');
3
3
 
4
- const getCoverageConfig = function(coiId, policiesForCoverage) { //rename policiesArr because it will no longer be only array
5
- const coverageConfig = cloneObject(baseCoverageConfig); //rename to coverageConfig
4
+ const getCoverageConfig = function(coiId, policiesForCoverage) {
5
+ const coverageConfig = cloneObject(baseCoverageConfig);
6
6
 
7
7
  coverageConfig.coiId = coiId;
8
8
 
9
- if (Array.isArray(policiesForCoverage) && typeof policiesForCoverage[0] !== 'object') { //when a few policies are passed as policy config and as list of names, then the object condition is necessary
9
+ if (Array.isArray(policiesForCoverage) && typeof policiesForCoverage[0] !== 'object') { //when getting a list of policy names (from automation)
10
10
  const coveragePolicies = coverageConfig.documents[0].pages[0].policies;
11
11
 
12
12
  for (const policyName of policiesForCoverage) {
@@ -19,21 +19,12 @@ const getCoverageConfig = function(coiId, policiesForCoverage) { //rename polici
19
19
  coveragePolicies.push(cloneObject(policy));
20
20
  }
21
21
  } else {
22
- coverageConfig.documents[0].pages[0].policies = policiesForCoverage;
22
+ coverageConfig.documents[0].pages[0].policies = policiesForCoverage; //when getting the policies coverage config prepared
23
23
  }
24
24
 
25
25
  return coverageConfig;
26
26
  };
27
27
 
28
- // const getCoverageConfigByPolicies = function(coiId, policiesConfig) { //I added this?
29
- // const config = cloneObject(configBase);
30
-
31
- // config.coiId = coiId;
32
- // config.documents[0].pages[0].policies = policiesConfig;
33
-
34
- // return config;
35
- // };
36
-
37
28
  const baseCoverageConfig = {
38
29
  'coiId': 'REPLACE_WITH_REAL_VALUE',
39
30
  'documents': [
@@ -51,5 +42,4 @@ const baseCoverageConfig = {
51
42
 
52
43
  module.exports = {
53
44
  getCoverageConfig
54
- // getCoverageConfigByPolicies
55
45
  };
@@ -0,0 +1,32 @@
1
+ const requests = require('../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ getNotificationsPage: `${backendUrl}/saas/notifications`,
6
+ getLatestNotifications: `${backendUrl}/saas/notifications/newest`,
7
+ markNotificationAsRead: notificationId => `${backendUrl}/saas/notifications/${notificationId}/read`,
8
+ markNotificationsAsSeen: latestSeenNotificationId => `${backendUrl}/saas/notifications/${latestSeenNotificationId}/seen`
9
+ };
10
+
11
+ const getNotificationsPage = async (lastNotificationId, context) => {
12
+ return requests.getRequestHandler(Endpoints.getNotificationsPage, { lastNotificationId }, context);
13
+ };
14
+
15
+ const getLatestNotifications = async context => {
16
+ return requests.getRequestHandler(Endpoints.getLatestNotifications, {}, context);
17
+ };
18
+
19
+ const markNotificationAsRead = async (notificationId, context) => {
20
+ return requests.postRequestHandler(Endpoints.markNotificationAsRead(notificationId), {}, context);
21
+ };
22
+
23
+ const markNotificationsAsSeen = async (latestSeenNotificationId, context) => {
24
+ return requests.postRequestHandler(Endpoints.markNotificationsAsSeen(latestSeenNotificationId), {}, context);
25
+ };
26
+
27
+ module.exports = {
28
+ getNotificationsPage,
29
+ getLatestNotifications,
30
+ markNotificationAsRead,
31
+ markNotificationsAsSeen
32
+ };
@@ -0,0 +1,49 @@
1
+ const notificationCenterApi = require('./notification.center.api');
2
+ const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
3
+
4
+ const getNotificationsPage = async (lastNotificationId, context, { shouldExpectError } = {}) => {
5
+ const notificationPageResponse = await notificationCenterApi.getNotificationsPage(lastNotificationId, context);
6
+
7
+ if (notificationPageResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
8
+ throw new Error(`Failed to get notifications page, cause by : ${notificationPageResponse.message}`);
9
+ }
10
+
11
+ return shouldExpectError ? notificationPageResponse : notificationPageResponse.data;
12
+ };
13
+
14
+ const getLatestNotifications = async (context, { shouldExpectError } = {}) => {
15
+ const latestNotificationResponse = await notificationCenterApi.getLatestNotifications(context);
16
+
17
+ if (latestNotificationResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
18
+ throw new Error(`Failed to get latest notifications, cause by : ${latestNotificationResponse.message}`);
19
+ }
20
+
21
+ return shouldExpectError ? latestNotificationResponse : latestNotificationResponse.data;
22
+ };
23
+
24
+ const markNotificationAsRead = async (notificationId, context, { shouldExpectError } = {}) => {
25
+ const response = await notificationCenterApi.markNotificationAsRead(notificationId, context);
26
+
27
+ if (response.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
28
+ throw new Error(`Failed to mark notifications as read, cause by : ${response.message}`);
29
+ }
30
+
31
+ return response;
32
+ };
33
+
34
+ const markNotificationsAsSeen = async (latestSeenNotificationId, context, { shouldExpectError } = {}) => {
35
+ const response = await notificationCenterApi.markNotificationsAsSeen(latestSeenNotificationId, context);
36
+
37
+ if (response.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
38
+ throw new Error(`Failed to mark notifications as seen, cause by : ${response.message}`);
39
+ }
40
+
41
+ return response;
42
+ };
43
+
44
+ module.exports = {
45
+ getNotificationsPage,
46
+ getLatestNotifications,
47
+ markNotificationAsRead,
48
+ markNotificationsAsSeen
49
+ };
@@ -0,0 +1,3 @@
1
+ const services = require('./api/notification.center.service');
2
+
3
+ module.exports = { services };
@@ -75,13 +75,13 @@ const getPolicyDetailsForPublishModel = async (requestId, policyFileId, context)
75
75
  };
76
76
 
77
77
  const getPolicyFilesIfExist = async (recordId, context) => {
78
- let retries = 10;
78
+ let retries = 15;
79
79
  let policiesToReviewResponse;
80
80
  let policyFiles = [];
81
81
 
82
82
  while (policyFiles.length === 0 && retries > 0) {
83
83
  //Busy wait for it takes time to get policy file to review
84
- await timeUtils.waitFor(1).seconds;
84
+ await timeUtils.waitFor(1.5).seconds;
85
85
 
86
86
  policiesToReviewResponse = await policyFileApi.getPolicyFilesRequireAudit(recordId, context);
87
87
  policyFiles = policiesToReviewResponse.data;
@@ -1,8 +1,10 @@
1
1
  const recordNotesAPI = require('./record.notes.api');
2
2
  const utils = require('./record.notes.utils');
3
+ const httpStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
3
4
 
4
- const createRecordNote = (data, context, { tagUsers, multipleParagraphs } = {}) => {
5
- tagUsers && (data.content = utils.getMentionedNoteContent(tagUsers, data.content, { multipleParagraphs }));
5
+ const createRecordNote = ({ requestId, content, notificationCenterContent, dateModified }, context, { tagUsers, multipleParagraphs } = {}) => {
6
+ const contentToSend = tagUsers ? utils.getMentionedNoteContent(tagUsers, content, { multipleParagraphs }) : content;
7
+ const data = { requestId, content: contentToSend, notificationCenterContent: notificationCenterContent || contentToSend, dateModified };
6
8
 
7
9
  return recordNotesAPI.createRecordNote(data, context);
8
10
  };
@@ -31,10 +33,17 @@ const deleteByNoteId = (noteId, data, context) => {
31
33
  return recordNotesAPI.deleteByNoteId(noteId, data, context);
32
34
  };
33
35
 
34
- const updateByNoteId = (noteId, data, context, { tagUsers, multipleParagraphs } = {}) => {
35
- tagUsers && (data.content = utils.getMentionedNoteContent(tagUsers, data.content, { multipleParagraphs }));
36
+ const updateByNoteId = async (noteId, { requestId, content, notificationCenterContent, dateModified }, context, { tagUsers, multipleParagraphs, expectError } = {}) => {
37
+ const contentToSend = tagUsers ? utils.getMentionedNoteContent(tagUsers, content, { multipleParagraphs }) : content;
38
+ const data = { requestId, content: contentToSend, notificationCenterContent: notificationCenterContent || contentToSend, dateModified };
36
39
 
37
- return recordNotesAPI.updateByNoteId(noteId, data, context);
40
+ const updateResponse = await recordNotesAPI.updateByNoteId(noteId, data, context);
41
+
42
+ if (updateResponse.status != httpStatusCodes.OK && !expectError) {
43
+ throw new Error(`Failed to update note with id: ${noteId}`);
44
+ }
45
+
46
+ return updateResponse;
38
47
  };
39
48
 
40
49
  module.exports = {
@@ -14,6 +14,11 @@ const getTabsByProjectId = async (projectId, context) => {
14
14
  return tabsAPI.getTabsByProjectId(projectId, context);
15
15
  };
16
16
 
17
+ const getFirstTabIdByProjectId = async (projectId, context) => {
18
+ const { data: tabs } = await getTabsByProjectId(projectId, context);
19
+ return tabs[0].tabId;
20
+ };
21
+
17
22
  const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
18
23
  const { data: tabs } = await getTabsByProjectId(projectId, context);
19
24
  const requestedTab = tabType ?
@@ -47,6 +52,7 @@ module.exports = {
47
52
  createTab,
48
53
  getTabById,
49
54
  getTabsByProjectId,
55
+ getFirstTabIdByProjectId,
50
56
  getTabsByName,
51
57
  getOrCreateTab,
52
58
  updateTab,
File without changes