@getjones/test-infra 2.10.1 → 2.10.2

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.10.1",
3
+ "version": "2.10.2",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -13,8 +13,6 @@ const roles = {
13
13
  cm: 'Compliance Manager'
14
14
  };
15
15
 
16
- const generateFullName = role => `${role} User`;
17
-
18
16
  const inviteSaasUser = async (username, role, projectIds, context) => {
19
17
  const userResponse = await users.services.getUserByEmail(username, context);
20
18
 
@@ -38,7 +36,7 @@ const signupSaasUser = async (username, role, context) => {
38
36
  return;
39
37
  }
40
38
 
41
- const signupUserModel = await users.util.getSignupUserModel(username, role, generateFullName(role), defaultsPassword, context);
39
+ const signupUserModel = await users.util.getSignupUserModel(username, role, role, defaultsPassword, context);
42
40
  const signupResponse = await users.services.signupUser(signupUserModel, context);
43
41
 
44
42
  if (signupResponse.status !== httpResponseStatusCodes.OK) {
@@ -167,7 +167,7 @@ const putAuditOnHold = async function(auditId, onHoldReason, context) {
167
167
  const onHoldResponse = await auditApi.putAuditOnHold(onHoldModel, context);
168
168
 
169
169
  if (onHoldResponse.status !== httpResponseStatusCodes.OK) {
170
- throw Error(`Failed to put audit on hold\n${onHoldResponse}`);
170
+ throw Error(`Failed to put audit on hold\n${onHoldResponse.data.message}`);
171
171
  }
172
172
 
173
173
  return onHoldResponse.data;
@@ -177,7 +177,7 @@ const resumeAudit = async function(onHoldId, context) {
177
177
  const resumeAuditResponse = await auditApi.resumeAudit(onHoldId, context);
178
178
 
179
179
  if (resumeAuditResponse.status !== httpResponseStatusCodes.OK) {
180
- throw Error(`Failed to resume audit\n${resumeAuditResponse}`);
180
+ throw Error(`Failed to resume audit\n${resumeAuditResponse.data.message}`);
181
181
  }
182
182
 
183
183
  return resumeAuditResponse.data;
@@ -25,7 +25,8 @@ const Endpoints = {
25
25
  `${backendUrl}/saas/requests/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
26
26
  automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`,
27
27
  assignRequirement: requestId => `${backendUrl}/saas/contractor/${requestId}/assign-requirement`,
28
- linkedProjectsCount: recordId => `${backendUrl}/saas/record/count/${recordId}/linked-projects`
28
+ linkedProjectsCount: recordId => `${backendUrl}/saas/record/count/${recordId}/linked-projects`,
29
+ verifyInviteLink: encryptedData => `${backendUrl}/vendor-app/verify-link?data=${encryptedData}`
29
30
  };
30
31
 
31
32
  const createContractor = (createContractorModel, context) => {
@@ -133,6 +134,10 @@ const updateLastInviteActionDate = (recordId, offsetInDays, context) => {
133
134
  return requests.putRequestHandler(url, {}, context);
134
135
  };
135
136
 
137
+ const getInviteLinkStatus = (encryptedData, context) => {
138
+ return requests.getRequestHandler(Endpoints.verifyInviteLink(encryptedData), {}, context, {});
139
+ };
140
+
136
141
  module.exports = {
137
142
  createContractor,
138
143
  changeRequirement,
@@ -156,5 +161,6 @@ module.exports = {
156
161
  muteNotifications,
157
162
  unmuteNotifications,
158
163
  getLinkedProjectsCount,
159
- updateLastInviteActionDate
164
+ updateLastInviteActionDate,
165
+ getInviteLinkStatus
160
166
  };
@@ -162,6 +162,10 @@ const restoreByRecordId = async (recordId, context) => {
162
162
  return restoreResponse;
163
163
  };
164
164
 
165
+ const getInviteLinkStatus = (encryptedData, context) => {
166
+ return contractorsAPI.getInviteLinkStatus(encryptedData, context);
167
+ };
168
+
165
169
  module.exports = {
166
170
  createContractor,
167
171
  changeRequirement,
@@ -189,5 +193,6 @@ module.exports = {
189
193
  getAssignRequirementModel,
190
194
  getLinkedProjectsCount,
191
195
  restoreByRecordId,
192
- updateLastInviteActionDate
196
+ updateLastInviteActionDate,
197
+ getInviteLinkStatus
193
198
  };
@@ -1,6 +1,9 @@
1
1
  const DEFAULT_EMAIL_SENDER = 'hellogetjonestest@gmail.com';
2
2
 
3
+ const tenantUserExtension = externalCompanyName => ` and ${externalCompanyName}`;
4
+
3
5
  const EMAIL_TYPES = {
6
+ INVITE: 'invite',
4
7
  COMPLIANT: 'compliant',
5
8
  NOT_COMPLIANT: 'notCompliant',
6
9
  SEND_GAPS: 'sendGaps',
@@ -20,6 +23,7 @@ const EMAIL_TYPES = {
20
23
  };
21
24
 
22
25
  const EMAIL_SUBJECT = {
26
+ invite: 'Your Insurance Docs are needed for',
23
27
  compliant: ({ recordCompanyName }) => `Compliant COI - ${recordCompanyName}`,
24
28
  sendGaps: ({ requesterName }) => `New Insurance Docs Required for ${requesterName} - `, //For this email type, guest is the same as vendor
25
29
  sendGapsForTenant: ({ requesterName }) => `New Insurance Docs Required for leased space at ${requesterName} - `,
@@ -46,4 +50,4 @@ const EMAIL_SUBJECT = {
46
50
  thankYou: 'Thank you for submitting your COI'
47
51
  };
48
52
 
49
- module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT };
53
+ module.exports = { DEFAULT_EMAIL_SENDER, EMAIL_TYPES, EMAIL_SUBJECT, tenantUserExtension };
@@ -62,10 +62,21 @@ const getEmailTextInSubject = (recordCompanyName, emailType, isAfterUpdateRequir
62
62
  return isAfterUpdateRequirements ? `Updated Requirements - ${subject}` : subject;
63
63
  };
64
64
 
65
+ const getMailActionButtonUrlRegex = () => {
66
+ return /(https:\/\/[a-zA-Z0-9.].*[a-zA-Z.]+\/CheckCustomersInviteLinkJSON\?data=[^"]+)/g;
67
+ };
68
+
69
+ const getEncryptedDataFromLink = link => {
70
+ const encryptedData = link.split('data=').pop();
71
+ return encryptedData.slice(0, -2);
72
+ };
73
+
65
74
  module.exports = {
66
75
  recipientsMatchVerification,
67
76
  regexVerification,
68
77
  extractEmailFromNameAndEmailFormat,
69
78
  logRetrievedEmailInfo,
70
- getEmailTextInSubject
79
+ getEmailTextInSubject,
80
+ getMailActionButtonUrlRegex,
81
+ getEncryptedDataFromLink
71
82
  };
@@ -3,18 +3,24 @@ const { backendUrl } = require('../../../../env').getEnv();
3
3
 
4
4
  const Endpoints = {
5
5
  getCustomizationsByAccountId: accountId => `${backendUrl}/saas/email-customizations?accountId=${accountId}`,
6
- deleteById: id => `${backendUrl}/saas/email-customization/${id}/permanently`
6
+ restoreDefaultById: id => `${backendUrl}/saas/email-customization/${id}/restore?version=DEFAULT`,
7
+ deletePermanentlyById: id => `${backendUrl}/saas/email-customization/${id}/permanently`
7
8
  };
8
9
 
9
10
  const getEmailCustomizationsByAccountId = (accountId, context) => {
10
11
  return requests.getRequestHandler(Endpoints.getCustomizationsByAccountId(accountId), {}, context);
11
12
  };
12
13
 
13
- const deleteEmailCustomizationById = (id, context) => {
14
- return requests.deleteRequestHandler(Endpoints.deleteById(id), context);
14
+ const restoreDefaultById = (id, context) => {
15
+ return requests.postRequestHandler(Endpoints.restoreDefaultById(id), {}, context);
16
+ };
17
+
18
+ const deleteEmailCustomizationPermanentlyById = (id, context) => {
19
+ return requests.deleteRequestHandler(Endpoints.deletePermanentlyById(id), context);
15
20
  };
16
21
 
17
22
  module.exports = {
18
23
  getEmailCustomizationsByAccountId,
19
- deleteEmailCustomizationById
24
+ restoreDefaultById,
25
+ deleteEmailCustomizationPermanentlyById
20
26
  };
@@ -3,37 +3,48 @@ const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCo
3
3
  const emailCustomizationApi = require('./email.customization.api');
4
4
 
5
5
  const getEmailCustomizationsByAccountId = async (accountId, context) => {
6
- const resp = await emailCustomizationApi.getEmailCustomizationsByAccountId(accountId, context);
6
+ const response = await emailCustomizationApi.getEmailCustomizationsByAccountId(accountId, context);
7
7
 
8
- if (resp.status !== httpResponseStatusCodes.OK) {
8
+ if (response.status !== httpResponseStatusCodes.OK) {
9
9
  throw new Error(`Failed to get email customization by account id ${accountId}`);
10
10
  }
11
11
 
12
- return resp.data;
12
+ return response.data;
13
13
  };
14
14
 
15
- const deleteEmailCustomizationById = async (id, context) => {
16
- const resp = await emailCustomizationApi.deleteEmailCustomizationById(id, context);
15
+ const restoreDefaultById = async (id, context) => {
16
+ const response = await emailCustomizationApi.restoreDefaultById(id, context);
17
17
 
18
- if (resp.status !== httpResponseStatusCodes.OK) {
18
+ if (response.status !== httpResponseStatusCodes.OK) {
19
19
  throw new Error(`Failed to delete email customization by id ${id}`);
20
20
  }
21
21
 
22
- return resp;
22
+ return response;
23
23
  };
24
24
 
25
- const deleteAllEmailCustomizationsInAccount = async (accountId, context) => {
25
+ const deleteEmailCustomizationPermanentlyById = async (id, context) => {
26
+ const response = await emailCustomizationApi.deleteEmailCustomizationPermanentlyById(id, context);
27
+
28
+ if (response.status !== httpResponseStatusCodes.OK) {
29
+ throw new Error(`Failed to delete email customization by id ${id}`);
30
+ }
31
+
32
+ return response;
33
+ };
34
+
35
+ const restoreAllEmailCustomizationsInAccount = async (accountId, context) => {
26
36
  const customizationList = await getEmailCustomizationsByAccountId(accountId, context);
27
37
 
28
38
  for (const customization of customizationList) {
29
39
  if (customization.id) {
30
- await deleteEmailCustomizationById(customization.id, context);
40
+ await restoreDefaultById(customization.id, context);
31
41
  }
32
42
  }
33
43
  };
34
44
 
35
45
  module.exports = {
36
46
  getEmailCustomizationsByAccountId,
37
- deleteEmailCustomizationById,
38
- deleteAllEmailCustomizationsInAccount
47
+ restoreDefaultById,
48
+ deleteEmailCustomizationPermanentlyById,
49
+ restoreAllEmailCustomizationsInAccount
39
50
  };
@@ -3,7 +3,8 @@ const updateModel = require('./models/update.requirement.model');
3
3
  const policyModel = require('./models/policy.model');
4
4
  const services = require('./api/requirements.service');
5
5
  const consts = require('./consts/consts');
6
+ const utils = require('./utils/utils');
6
7
 
7
8
  const models = { create: createModel, update: updateModel, policy: policyModel };
8
9
 
9
- module.exports = { services, models, consts };
10
+ module.exports = { services, models, consts, utils };
Binary file