@getjones/test-infra 2.8.7 → 2.8.8

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.8.7",
3
+ "version": "2.8.8",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,8 @@
1
1
  const chartTypes = {
2
2
  requiringAttention: 'requiringAttention',
3
3
  expirationDatePerMonth: 'expirationDatePerMonth',
4
- waivedByRequirement: 'waivedByRequirement'
4
+ waivedByRequirement: 'waivedByRequirement',
5
+ notCompliantForRequirement: 'notCompliantForRequirement'
5
6
  };
6
7
  const sortBy = {
7
8
  companyName: 'SORT_BY_COMPANYNAME',
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  ICS: 'ICS',
3
3
  PM: 'PM',
4
- AUDITOR: 'AUDITOR'
4
+ AUDITOR: 'AUDITOR',
5
+ VENDOR: 'Vendor'
5
6
  };
@@ -1,5 +1,5 @@
1
- const { ICS, PM, AUDITOR } = require('../../../../common/consts/userTypes');
1
+ const { ICS, PM, AUDITOR, VENDOR } = require('../../../../common/consts/userTypes');
2
2
 
3
- const UPLOADER_TYPES = { ICS, PM, AUDITOR };
3
+ const UPLOADER_TYPES = { ICS, PM, AUDITOR, VENDOR };
4
4
 
5
5
  module.exports = UPLOADER_TYPES;
@@ -8,7 +8,8 @@ const Endpoints = {
8
8
  contractorDetailsForAudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/master-audit`,
9
9
  requirementDetailsForAudit: contractorId => `${backendUrl}/saas/auditor/contractor/${contractorId}/requirement`,
10
10
  isReaudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/isreaudit`,
11
- revertCoi: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/coi/revert`
11
+ revertCoi: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/coi/revert`,
12
+ wrongCoi: `${backendUrl}/saas/coi/wrong-coi`
12
13
  };
13
14
 
14
15
  const audit = async (contractorId, auditRequestModel, context) => {
@@ -36,9 +37,15 @@ const getRequirementDetailsForAudit = (contractorId, context) => {
36
37
  return requests.getRequestHandler(Endpoints.requirementDetailsForAudit(contractorId), {}, context);
37
38
  };
38
39
 
40
+ const wrongCoi = (recordId, context) => {
41
+ const params = { contractorId: recordId };
42
+ return requests.getRequestHandler(Endpoints.wrongCoi, params, context);
43
+ };
44
+
39
45
  module.exports = {
40
46
  audit,
41
47
  revertCoi,
48
+ wrongCoi,
42
49
  isReaudit,
43
50
  getAuditorContractorList,
44
51
  getContractorDetailsForAudit,
@@ -12,7 +12,12 @@ const audit = (auditRequestModel, context) => {
12
12
  };
13
13
 
14
14
  const revertCoi = (contractorId, dateModified, context) => {
15
- return auditApi.revertCoi(contractorId, dateModified, context);
15
+ const dateModifiedObj = { dateModified };
16
+ return auditApi.revertCoi(contractorId, dateModifiedObj, context);
17
+ };
18
+
19
+ const wrongCoi = (recordId, context) => {
20
+ return auditApi.wrongCoi(recordId, context);
16
21
  };
17
22
 
18
23
  const isReaudit = (contractorId, context) => {
@@ -114,9 +119,10 @@ const auditRecord = async function(
114
119
  projectId,
115
120
  requirementId,
116
121
  recordId,
117
- auditConfig
122
+ auditConfig,
123
+ { shouldSendNotificationToPM = false } = {}
118
124
  ) {
119
- const auditMetadata = await getAuditMetadata(auditorContext, accountId, projectId, requirementId, recordId);
125
+ const auditMetadata = await getAuditMetadata(auditorContext, accountId, projectId, requirementId, recordId, { shouldSendNotificationToPM });
120
126
 
121
127
  const auditApiConfig = dataTypeUtils.isObject(auditConfig) ?
122
128
  auditUtil.parseAuditConfig(cloneObject(auditConfig)) :
@@ -133,6 +139,7 @@ module.exports = {
133
139
  audit,
134
140
  revertCoi,
135
141
  isReaudit,
142
+ wrongCoi,
136
143
  getAuditorContractorList,
137
144
  getContractorDetailsForAudit,
138
145
  getRequirementDetailsForAudit,
@@ -102,12 +102,13 @@ const getPolicyAuditIdFromRecord = (record, policyName, attributeName) => {
102
102
  return attribute.auditId;
103
103
  };
104
104
 
105
- const waiveAll = async (record, context, { reason = WAIVER_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
105
+ // private method - please refer to waiveAll / acceptAll
106
+ const overrideAll = async (record, reason, context, { note = 'OVERRIDDEN AUTOMATICALLY' } = {}) => {
106
107
  const allWaivablePolicies = auditUtil.getAllWaivablePolicies(record, context);
107
108
 
108
109
  for (const waivable of allWaivablePolicies) {
109
110
  const waiveModel = getWaiveModel(record, waivable.policyName, waivable.attributeName, reason, note);
110
- const waiveResponse = await waive(waiveModel, context);
111
+ const waiveResponse = await overrideGap({ waiveRequestModel: waiveModel, context });
111
112
 
112
113
  if (waiveResponse.status !== httpResponseStatusCodes.OK) {
113
114
  throw Error(`Failed to waive ${waivable.policyName} - ${waivable.attributeName} for ${record.company}`);
@@ -115,9 +116,26 @@ const waiveAll = async (record, context, { reason = WAIVER_REASONS.BUSINESS_DECI
115
116
  }
116
117
  };
117
118
 
119
+ const waiveAll = async (record, context, { reason = WAIVER_REASONS.BUSINESS_DECISION, note = 'WAIVED AUTOMATICALLY' } = {}) => {
120
+ if (reason === WAIVER_REASONS.ACCEPT_NO_EXPOSURE) {
121
+ throw Error('Invalid override gap reason to waive');
122
+ }
123
+
124
+ await overrideAll(record, reason, context, { note });
125
+ };
126
+
127
+ const acceptAll = async (record, context, { reason = WAIVER_REASONS.ACCEPT_NO_EXPOSURE, note = 'ACCEPTED AUTOMATICALLY' } = {}) => {
128
+ if (reason !== WAIVER_REASONS.ACCEPT_NO_EXPOSURE) {
129
+ throw Error('Invalid override gap reason to accept');
130
+ }
131
+
132
+ await overrideAll(record, reason, context, { note });
133
+ };
134
+
118
135
  module.exports = {
119
136
  waive,
120
137
  waiveAll,
138
+ acceptAll,
121
139
  retract,
122
140
  getWaiveModel,
123
141
  getRetractModel,
@@ -87,13 +87,15 @@ const getLastMessage = async (
87
87
 
88
88
  // In case the format is 'First Last <username@domain.com>' we need the email part only
89
89
  const emailModel = new EmailModel(
90
- util.extractEmailFromNameAndEmailFormat(recipients.from),
91
- recipientsTo,
92
- includesOneOfRecipientsTo,
93
- recipients.cc,
94
- textInSubject,
95
- textInBody,
96
- excludingPhrasesInBody
90
+ {
91
+ from: util.extractEmailFromNameAndEmailFormat(recipients.from),
92
+ recipientsTo,
93
+ includesOneOfRecipientsTo,
94
+ recipientsCc: recipients.cc,
95
+ textInSubject,
96
+ textInBody,
97
+ excludingPhrasesInBody
98
+ }
97
99
  );
98
100
 
99
101
  const response = await getAllMessages(emailModel);
@@ -2,6 +2,7 @@ const DEFAULT_EMAIL_SENDER = 'hellogetjonestest@gmail.com';
2
2
 
3
3
  const EMAIL_TYPES = {
4
4
  COMPLIANT: 'compliant',
5
+ NOT_COMPLIANT: 'notCompliant',
5
6
  SEND_GAPS: 'sendGaps',
6
7
  REQUEST_NEW_COI_EXPIRED: 'requestNewCoiExpired',
7
8
  FIRST_REMINDER: 'firstReminder',
@@ -19,6 +20,8 @@ const EMAIL_TYPES = {
19
20
 
20
21
  const EMAIL_SUBJECT = {
21
22
  compliant: ({ recordCompanyName }) => `Compliant COI - ${recordCompanyName}`,
23
+ notCompliant: ({ recordCompanyName, requesterName }) => `Please Review COI Gaps - ${recordCompanyName} (${requesterName})`,
24
+ wrongCoi: ({ recordCompanyName, requesterName }) => `Incorrect File Submission - COI Still Required for ${recordCompanyName} - ${requesterName}`,
22
25
  sendGaps: ({ requesterName }) => `New Insurance Docs Required for ${requesterName}`, //doesn't includes text for guest or tenant
23
26
  requestNewCoiExpired: ({ recordCompanyName }) => `${recordCompanyName}'s COI is`,
24
27
  firstReminder: ({ requesterName }) => `We are still awaiting the Insurance Docs for ${requesterName}`,
@@ -31,7 +34,8 @@ const EMAIL_SUBJECT = {
31
34
  sameDayExpirationRecordAutoRenewal: ({ requesterName }) => `Your COI for ${requesterName} expires TODAY`,
32
35
  sameDayExpirationPMAutoRenewal: ({ recordCompanyName }) => `COI expired for ${recordCompanyName} at`,
33
36
  requirementsUpdatedNotification: ({ requesterName }) => `Updated Requirements - Your Insurance Docs are needed for ${requesterName}`,
34
- updatedRequirementsSubjectPrefix: () => 'Updated Requirements - '
37
+ updatedRequirementsSubjectPrefix: () => 'Updated Requirements - ',
38
+ thankYou: 'Thank you for submitting your COI'
35
39
  };
36
40
 
37
41
  module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT };
@@ -1,5 +1,6 @@
1
1
  const services = require('./api/db.emails.service');
2
2
  const consts = require('./consts/consts');
3
3
  const utils = require('./utils/util');
4
+ const { EmailModel } = require('./models/db.emails.model');
4
5
 
5
- module.exports = { services, consts, utils };
6
+ module.exports = { services, consts, utils, models: { EmailModel } };
@@ -1,5 +1,5 @@
1
1
  class EmailModel {
2
- constructor(
2
+ constructor({
3
3
  from,
4
4
  recipientsTo,
5
5
  includesOneOfRecipientsTo,
@@ -7,6 +7,7 @@ class EmailModel {
7
7
  textInSubject,
8
8
  textInBody,
9
9
  excludingPhrasesInBody
10
+ } = {}
10
11
  ) {
11
12
  this.from = from;
12
13
  this.recipientsTo = recipientsTo;
@@ -1,11 +1,14 @@
1
1
  const { EMAIL_SUBJECT } = require('../consts/consts');
2
2
 
3
+ //compare method for sorting with ignore caseSensitive
4
+ const compareFn = (a, b) => a.toLowerCase().localeCompare(b.toLowerCase());
5
+
3
6
  const compareUnorderedArrays = (arr, other, { caseSensitive = true } = {}) => {
4
- const isEachElementEqual = arr.sort().every((mail, i) => {
7
+ const isEachElementEqual = arr.sort(compareFn).every((mail, i) => {
5
8
  if (caseSensitive) {
6
- return mail === other.sort()[i];
9
+ return mail === other.sort((compareFn))[i];
7
10
  } else {
8
- return mail.toLowerCase() === other.sort()[i].toLowerCase();
11
+ return mail.toLowerCase() === other.sort(compareFn)[i].toLowerCase();
9
12
  }
10
13
  });
11
14
  return arr.length === other.length && isEachElementEqual;
@@ -13,7 +13,8 @@ const Endpoints = {
13
13
  reinvite: `${backendUrl}/saas/project/team-member/reinvite`,
14
14
  getUserEncryptedData: (email, userRole) => `${backendUrl}/saas/team-member/email/${email}/role/${userRole}/signup-data`,
15
15
  signupUser: `${backendUrl}/_saas/guests/signup`,
16
- removeAllUserTraceFromDb: userId => `${backendUrl}/saas/user/automation/${userId}`
16
+ removeAllUserTraceFromDb: userId => `${backendUrl}/saas/user/automation/${userId}`,
17
+ userEmailNotificationsSettings: `${backendUrl}/saas/account/notification/set`
17
18
  };
18
19
 
19
20
  const invite = (invitedUser, context, { disableSendMail = true } = {}) => {
@@ -62,6 +63,11 @@ const reinviteUser = (userId, context) => {
62
63
  return requests.postRequestHandler(Endpoints.reinvite, {}, context, {}, params);
63
64
  };
64
65
 
66
+ const editUserEmailNotificationsSettings = (userId, notificationSettingsModel, context) => {
67
+ const params = { userId };
68
+ return requests.postRequestHandler(Endpoints.userEmailNotificationsSettings, notificationSettingsModel, context, {}, params);
69
+ };
70
+
65
71
  module.exports = {
66
72
  invite,
67
73
  signupUser,
@@ -73,5 +79,6 @@ module.exports = {
73
79
  removeAllUserTraceFromDb,
74
80
  editUserRole,
75
81
  editUserProjects,
76
- reinviteUser
82
+ reinviteUser,
83
+ editUserEmailNotificationsSettings
77
84
  };
@@ -5,6 +5,7 @@ const { credentials } = getEnv();
5
5
  const userAPI = require('./users.api');
6
6
  const util = require('../utils/util');
7
7
  const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
8
+ const { NotificationSettingsModel } = require('../models/notification.settings.model');
8
9
 
9
10
  const inviteUser = async (invitedUser, context, { disableSendMail } = {}) => {
10
11
  return userAPI.invite(invitedUser, context, { disableSendMail });
@@ -85,6 +86,11 @@ const reinviteUser = (userId, context) => {
85
86
  return userAPI.reinviteUser(userId, context);
86
87
  };
87
88
 
89
+ const editUserEmailNotificationsSettings = (userId, notificationSettingsModel, context) => {
90
+ validateType(notificationSettingsModel, NotificationSettingsModel);
91
+ return userAPI.editUserEmailNotificationsSettings(userId, notificationSettingsModel, context);
92
+ };
93
+
88
94
  module.exports = {
89
95
  inviteUser,
90
96
  signupUser,
@@ -97,5 +103,6 @@ module.exports = {
97
103
  removeAllUserTraceFromDb,
98
104
  editUserRole,
99
105
  editUserProjects,
100
- reinviteUser
106
+ reinviteUser,
107
+ editUserEmailNotificationsSettings
101
108
  };
@@ -1,4 +1,5 @@
1
- const models = require('./models/users.model');
1
+ const userModels = require('./models/users.model');
2
+ const { NotificationSettingsModel } = require('./models/notification.settings.model');
2
3
  const services = require('./api/users.service');
3
4
  const util = require('./utils/util');
4
5
 
@@ -8,4 +9,6 @@ const tenants = {
8
9
  services: tenantUserService
9
10
  };
10
11
 
12
+ const models = { ... userModels, NotificationSettingsModel };
13
+
11
14
  module.exports = { services, models, util, tenants };
@@ -0,0 +1,12 @@
1
+ class NotificationSettingsModel {
2
+ constructor({ aboutToExpire = true, auditCompliant = true, auditNotCompliant = true, missingCoi = true } = {}) {
3
+ this.aboutToExpire = aboutToExpire;
4
+ this.auditCompliant = auditCompliant;
5
+ this.auditNotCompliant = auditNotCompliant;
6
+ this.missingCoi = missingCoi;
7
+ }
8
+ }
9
+
10
+ module.exports = {
11
+ NotificationSettingsModel
12
+ };