@getjones/test-infra 1.2.2 → 1.2.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": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -24,6 +24,8 @@ const getInternalAPI = () => {
24
24
  const users = require('./saas/internal-api/users');
25
25
 
26
26
  const reports = require('./saas/internal-api/reports');
27
+ const charts = require('./saas/internal-api/homepageCharts');
28
+
27
29
 
28
30
  const internalAPI = {
29
31
  auth,
@@ -35,7 +37,8 @@ const getInternalAPI = () => {
35
37
  coi,
36
38
  compliance,
37
39
  reports,
38
- users
40
+ users,
41
+ charts
39
42
  };
40
43
 
41
44
  return internalAPI;
@@ -1,18 +1,18 @@
1
1
  const accountsAPI = require('./settings.api');
2
2
  const { validateType } = require('../../../../../common/validations/typeValidations');
3
- const UpdateAccountSettings = require('../../models/settings/update.settings.model');
3
+ const UpdateAccountSettingsModel = require('../../models/settings/update.settings.model');
4
4
 
5
5
  const getAccountSettings = async (accountId, context) => {
6
6
  return accountsAPI.getAccountSettings(accountId, context).then(res => res.data);
7
7
  };
8
8
 
9
9
  const updateAccountSettings = async (updateAccountSettingsModel, context) => {
10
- validateType(updateAccountSettingsModel, UpdateAccountSettings);
10
+ validateType(updateAccountSettingsModel, UpdateAccountSettingsModel);
11
11
  return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
12
12
  };
13
13
 
14
14
  const restoreAccountSettings = async (accountId, context) => {
15
- const updateAccountSettingsModel = new UpdateAccountSettings(accountId, false, false);
15
+ const updateAccountSettingsModel = new UpdateAccountSettingsModel(accountId, false, false , false);
16
16
  return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
17
17
  };
18
18
 
@@ -1,8 +1,8 @@
1
1
  const CreateAccountModel = require('./models/core/create.account.model');
2
2
  const coreModels = { CreateAccountModel };
3
3
 
4
- const UpdateAccountSettings = require('./models/settings/update.settings.model');
5
- const settingsModels = { UpdateAccountSettings };
4
+ const UpdateAccountSettingsModel = require('./models/settings/update.settings.model');
5
+ const settingsModels = { UpdateAccountSettingsModel };
6
6
 
7
7
  const models = { core: coreModels, settings: settingsModels };
8
8
 
@@ -1,7 +1,15 @@
1
- function UpdateAccountSettings(accountId, isMultiPropertyTenants, isHighPriority) {
2
- this.accountId = accountId;
3
- this.isMultiPropertyTenants = isMultiPropertyTenants;
4
- this.isHighPriority = isHighPriority;
1
+ class UpdateAccountSettingsModel {
2
+ constructor(
3
+ accountId,
4
+ isMultiPropertyTenants,
5
+ isHighPriority,
6
+ hasAnalyticsDashboard
7
+ ) {
8
+ this.accountId = accountId;
9
+ this.isMultiPropertyTenants = isMultiPropertyTenants;
10
+ this.isHighPriority = isHighPriority;
11
+ this.hasAnalyticsDashboard = hasAnalyticsDashboard;
12
+ }
5
13
  }
6
14
 
7
- module.exports = UpdateAccountSettings;
15
+ module.exports = UpdateAccountSettingsModel;
@@ -23,10 +23,10 @@ const postRequestHandler = async (url, body, context = null, headers = {}, param
23
23
  }
24
24
  };
25
25
 
26
- const putRequestHandler = async (url, body, context = null, headers = {}) => {
26
+ const putRequestHandler = async (url, body, context = null, headers = {}, params = {}) => {
27
27
  enrichCookie(headers, context);
28
28
  try {
29
- const response = await axios.put(url, body, { headers });
29
+ const response = await axios.put(url, body, { headers, params });
30
30
  return response;
31
31
  } catch (error) {
32
32
  errorValidation.validateError(error);
@@ -4,7 +4,7 @@ const { backendUrl } = require('../../../../../env').getEnv();
4
4
  const Endpoints = {
5
5
  auditorContractorList: `${backendUrl}/saas/auditor/contractors`,
6
6
  preAudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/master-audit`,
7
- audit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/audits`,
7
+ audit: `${backendUrl}/saas/auditor/contractors/submit/audits`,
8
8
  contractorDetailsForAudit: contractorId => `${backendUrl}/saas/auditor/contractors/${contractorId}/master-audit`,
9
9
  requirementDetailsForAudit: contractorId => `${backendUrl}/saas/auditor/contractor/${contractorId}/requirement`
10
10
  };
@@ -15,7 +15,7 @@ const getAuditorContractorList = (page, accountId, context) => {
15
15
 
16
16
  const audit = async (contractorId, auditRequestModel, context) => {
17
17
  const response = await requests.getRequestHandler(Endpoints.preAudit(contractorId), {}, context);
18
- return requests.postRequestHandler(Endpoints.audit(contractorId), auditRequestModel, context).then(res => res.data);
18
+ return requests.postRequestHandler(Endpoints.audit, auditRequestModel, context).then(res => res.data);
19
19
  };
20
20
 
21
21
  const getContractorDetailsForAudit = (contractorId, context) => {
@@ -4,24 +4,30 @@ const { backendUrl, nodeBackendUrl } = require('../../../../../env').getEnv();
4
4
 
5
5
  const Endpoints = {
6
6
  saveCoverageNode: `${nodeBackendUrl}/coverage`,
7
- saveCoverageJava: contractorId => `${backendUrl}/saas/contractors/${contractorId}/coverage`,
8
- getCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`
7
+ saveCoverageJava: `${backendUrl}/saas/contractors/coverage`,
8
+ getCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`,
9
+ deleteCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`
9
10
  };
10
11
 
11
12
  const saveCoverageNode = (coverage, nodeBackendSecret) => {
12
13
  return openApiRequests.postRequestHandler(Endpoints.saveCoverageNode, nodeBackendSecret, coverage);
13
14
  };
14
15
 
15
- const saveCoverageJava = (auditorContext, contractorId, coverage) => {
16
- return internalApiRequests.postRequestHandler(Endpoints.saveCoverageJava(contractorId), coverage, auditorContext);
16
+ const saveCoverageJava = (auditorContext, auditDates, coverage) => {
17
+ return internalApiRequests.postRequestHandler(Endpoints.saveCoverageJava, { auditDates, coverage }, auditorContext);
17
18
  };
18
19
 
19
20
  const getCoverageByCoiId = (coiId, nodeBackendSecret) => {
20
21
  return openApiRequests.getRequestHandler(Endpoints.getCoverageByCoiId(coiId), nodeBackendSecret);
21
22
  };
22
23
 
24
+ const deleteCoverageByCoiId = (coiId, nodeBackendSecret) => {
25
+ return openApiRequests.deleteRequestHandler(Endpoints.deleteCoverageByCoiId(coiId), nodeBackendSecret);
26
+ };
27
+
23
28
  module.exports = {
24
29
  saveCoverageNode,
25
30
  saveCoverageJava,
26
- getCoverageByCoiId
31
+ getCoverageByCoiId,
32
+ deleteCoverageByCoiId
27
33
  };
@@ -4,16 +4,21 @@ const saveCoverageNode = async (coverage, nodeBackendSecret) => {
4
4
  return coverageApi.saveCoverageNode(coverage, nodeBackendSecret);
5
5
  };
6
6
 
7
- const saveCoverageJava = async (auditorContext, contractorId, coverage) => {
8
- return coverageApi.saveCoverageJava(auditorContext, contractorId, coverage);
7
+ const saveCoverageJava = async (auditorContext, auditDates, coverage) => {
8
+ return coverageApi.saveCoverageJava(auditorContext, auditDates, coverage);
9
9
  };
10
10
 
11
11
  const getCoverageByCoiId = async (coiId, nodeBackendSecret) => {
12
12
  return coverageApi.getCoverageByCoiId(coiId, nodeBackendSecret).then(res => res && res.data);
13
13
  };
14
14
 
15
+ const deleteCoverageByCoiId = async (coiId, nodeBackendSecret) => {
16
+ return coverageApi.deleteCoverageByCoiId(coiId, nodeBackendSecret).then(res => res && res.data);
17
+ };
18
+
15
19
  module.exports = {
16
20
  saveCoverageNode,
17
21
  saveCoverageJava,
18
- getCoverageByCoiId
22
+ getCoverageByCoiId,
23
+ deleteCoverageByCoiId
19
24
  };
@@ -1,3 +1,5 @@
1
+ const { validateType } = require('../../../../../common/validations/typeValidations');
2
+
1
3
  const COI_AUDIT_STATUSES = {
2
4
  NOT_AUDITED: '0',
3
5
  REAUDIT: '3'
@@ -21,50 +23,67 @@ const AUDIT_POLICY_NAMES = {
21
23
 
22
24
  const AUDITOR_ROLE = 'Auditor';
23
25
 
24
- function AuditRequestModel({
25
- accountId = null,
26
- projectId = null,
27
- requirementId = null,
28
- contractorId = null,
29
- certificateId = null,
30
- auditorId = null,
31
- auditEntities = null,
32
- dateModified = null,
33
- isReaudit = null,
34
- isProjectOnboarding = false,
35
- auditorRole = AUDITOR_ROLE,
36
- shouldSendNotificationToPM = true
37
- }) {
38
- const auditData = {
39
- userId: accountId,
40
- projectId: projectId,
41
- requirementId: requirementId,
42
- contractorId: contractorId,
43
- certificateId: certificateId,
44
- auditorId: auditorId,
45
- policyDetails: auditEntities,
46
- auditorStatus: COI_AUDIT_STATUSES.NOT_AUDITED,
47
- dateModified: dateModified,
48
- isReaudit: isReaudit,
49
- projectOnboarding: isProjectOnboarding,
50
- role: auditorRole,
51
- sendNotificationToPM: shouldSendNotificationToPM
52
- };
26
+ class AuditRequestModel{
27
+ constructor(
28
+ accountId = null,
29
+ projectId = null,
30
+ requirementId = null,
31
+ contractorId = null,
32
+ certificateId = null,
33
+ auditorId = null,
34
+ auditEntities = null,
35
+ isReaudit = null,
36
+ isProjectOnboarding = false,
37
+ shouldSendNotificationToPM = true,
38
+ auditDates = {},
39
+ auditStatus = null,
40
+ auditorRole = AUDITOR_ROLE,
41
+ ){
42
+ const auditData = {
43
+ userId: accountId,
44
+ projectId: projectId,
45
+ requirementId: requirementId,
46
+ contractorId: contractorId,
47
+ certificateId: certificateId,
48
+ auditorId: auditorId,
49
+ policyDetails: auditEntities,
50
+ auditorStatus: COI_AUDIT_STATUSES.NOT_AUDITED,
51
+ isReaudit: isReaudit,
52
+ projectOnboarding: isProjectOnboarding,
53
+ role: auditorRole,
54
+ sendNotificationToPM: shouldSendNotificationToPM,
55
+ auditStatus
56
+ };
53
57
 
54
- this.auditData = auditData;
55
- this.dateModified = dateModified;
58
+ validateType(auditDates,AuditDatesModel)
59
+ this.auditData = auditData;
60
+ this.auditDates = auditDates
61
+ }
56
62
  }
57
63
 
58
- function AuditEntityModel(policyId, attributeName, status, value) {
64
+ class AuditEntityModel {
65
+ constructor(policyId, attributeName, status, value){
59
66
  this.contractorInsuranceId = policyId;
60
67
  this.limitname = attributeName;
61
68
  this.status = status;
62
69
  this.value = value;
70
+ }
71
+ }
72
+
73
+ class AuditDatesModel{
74
+ constructor(contractorId ,contractorDateModified, dateStartedAudit, contractorOverrideDateModified, contractCreateDate){
75
+ this.contractorId = contractorId;
76
+ this.contractorDateModified = contractorDateModified;
77
+ this.dateStartedAudit = dateStartedAudit;
78
+ this.contractorOverrideDateModified = contractorOverrideDateModified;
79
+ this.contractCreateDate = contractCreateDate;
80
+ }
63
81
  }
64
82
 
65
83
  module.exports = {
66
84
  AuditRequestModel,
67
85
  AuditEntityModel,
86
+ AuditDatesModel,
68
87
  COI_AUDIT_STATUSES,
69
88
  AUDIT_ENTITY_STATUSES,
70
89
  AUDIT_ATTRIBUTE_NAMES,
@@ -0,0 +1,12 @@
1
+ const requests = require('../../common/requests');
2
+ const { backendUrl } = require('../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ getHomePageChartsDataApi: () => `${backendUrl}/saas/user/properties/compliance-summary`,
6
+ };
7
+
8
+ const getHomePageChartsData = context => {
9
+ return requests.getRequestHandler(Endpoints.getHomePageChartsDataApi(), {}, context).then(res => res.data);
10
+ };
11
+
12
+ module.exports = { getHomePageChartsData };
@@ -0,0 +1,7 @@
1
+ const chartsAPI = require('./charts.api');
2
+
3
+ const getHomePageChartsData = async context => {
4
+ return chartsAPI.getHomePageChartsData(context);
5
+ };
6
+
7
+ module.exports = { getHomePageChartsData };
@@ -0,0 +1,3 @@
1
+ const services = require('./api/charts.setup');
2
+
3
+ module.exports = { services };
@@ -0,0 +1,55 @@
1
+ const requests = require("../../common/requests");
2
+ const { backendUrl } = require("../../../../env").getEnv();
3
+
4
+ const Endpoints = {
5
+ invite: `${backendUrl}/saas/project/team-member`,
6
+ editUserProjects: `${backendUrl}/saas/project/team-member`,
7
+ editUserRole: userId => `${backendUrl}/secured/users/${userId}/change-role`,
8
+ getByProjectId: projectId =>
9
+ `${backendUrl}/saas/project/${projectId}/team-members`,
10
+ getByEmail: email => `${backendUrl}/saas/team-member/by-email/${email}`,
11
+ delete: userId => `${backendUrl}/saas/users/${userId}`,
12
+ deleteSingleProject: (userId, projectId) => `${backendUrl}/saas/project/${projectId}/sub-account/${userId}`,
13
+ reinvite: `${backendUrl}/saas/project/team-member/reinvite`
14
+ };
15
+
16
+ const invite = async (invitedUser, context) => {
17
+ const headers = {}
18
+ const params = { disableSendMail: true }
19
+ return requests.putRequestHandler(Endpoints.invite, invitedUser, context, headers, params).then(res => res.data);
20
+ };
21
+
22
+ const editUserRole = async (userId, data, context) => {
23
+ return requests.patchRequestHandler(Endpoints.editUserRole(userId), context, data);
24
+ };
25
+
26
+ const editUserProjects = async (data, context) => {
27
+ const headers = {}
28
+ const params = { disableSendMail: true }
29
+ return requests.putRequestHandler(Endpoints.editUserProjects, data, context, headers, params);
30
+ };
31
+
32
+ const getUsersByProjectId = async (projectId, context) => {
33
+ return requests.getRequestHandler(Endpoints.getByProjectId(projectId), null, context).then(res => res.data);
34
+ };
35
+
36
+ const getUserByEmail = async (email, context) => {
37
+ return requests.getRequestHandler(Endpoints.getByEmail(email), null, context).then(res => res.data);
38
+ };
39
+
40
+ const deleteUser = async (userId, context) => {
41
+ return requests.deleteRequestHandler(Endpoints.delete(userId), context);
42
+ };
43
+
44
+ const deleteUserFromSingleProject = async (userId, projectId, context) => {
45
+ return requests.deleteRequestHandler(Endpoints.deleteSingleProject(userId, projectId), context);
46
+ };
47
+
48
+ const reinviteUser = async (userId, context) => {
49
+ const body = {}
50
+ const headers = {}
51
+ const params = { id: userId }
52
+ return requests.postRequestHandler(Endpoints.reinvite, body, context, headers, params);
53
+ };
54
+
55
+ module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser, deleteUserFromSingleProject, editUserRole, editUserProjects, reinviteUser };
@@ -0,0 +1,38 @@
1
+ const EditUserModel = require('../models/edit.user.model');
2
+ const userAPI = require('./users.api');
3
+ const { validateType } = require('../../../../common/validations/typeValidations');
4
+
5
+ const inviteUser = async (invitedUser, context) => {
6
+ return userAPI.invite(invitedUser, context);
7
+ };
8
+
9
+ const editUserRole = async (userId, data, context) => {
10
+ return userAPI.editUserRole(userId, data, context);
11
+ };
12
+
13
+ const editUserProjects = async (editUserModel, context) => {
14
+ validateType(editUserModel, EditUserModel);
15
+ return userAPI.editUserProjects([editUserModel], context);
16
+ };
17
+
18
+ const getUsersByProjectId = async (projectId, context) => {
19
+ return userAPI.getUsersByProjectId(projectId, context);
20
+ };
21
+
22
+ const getUserByEmail = async (email, context) => {
23
+ return userAPI.getUserByEmail(email, context);
24
+ };
25
+
26
+ const deleteUser = (userId, context) => {
27
+ return userAPI.deleteUser(userId, context);
28
+ };
29
+
30
+ const deleteUserFromSingleProject = (userId, projectId, context) => {
31
+ return userAPI.deleteUserFromSingleProject(userId, projectId, context);
32
+ };
33
+
34
+ const reinviteUser = (userId, context) => {
35
+ return userAPI.reinviteUser(userId, context);
36
+ };
37
+
38
+ module.exports = { inviteUser, getUsersByProjectId, getUserByEmail, deleteUser, deleteUserFromSingleProject, editUserRole, editUserProjects, reinviteUser };
@@ -1,3 +1,8 @@
1
- const services = require('./api/invite.setup');
1
+ const EditUserModel = require('./models/edit.user.model');
2
+ const coreModels = { EditUserModel };
2
3
 
3
- module.exports = { services };
4
+ const models = { core: coreModels };
5
+
6
+ const services = require('./api/users.setup');
7
+
8
+ module.exports = { services, models };
@@ -0,0 +1,10 @@
1
+ class EditUserModel {
2
+ constructor(subUserId, email, role, projects = []) {
3
+ this.subUserId = subUserId;
4
+ this.email = email;
5
+ this.role = role;
6
+ this.projects = projects;
7
+ }
8
+ }
9
+
10
+ module.exports = EditUserModel;
@@ -1,53 +0,0 @@
1
- class coverageRequestModel {
2
- constructor({
3
- coiId,
4
- documentsModel
5
- }) {
6
- this.coiId = coiId,
7
- this.documents = documentsModel;
8
- }
9
- }
10
-
11
- class coverageDocumentModel {
12
- constructor({
13
- documentType,
14
- pagesModel
15
- }) {
16
- this.documentType = documentType,
17
- this.pagesModel = pagesModel;
18
- }
19
- }
20
-
21
- class coveragePageModel {
22
- constructor({
23
- pageNumber,
24
- policies
25
- }) {
26
- this.pageNumber = pageNumber,
27
- this.policies = policies;
28
- }
29
- }
30
-
31
- class coveragePolicyModel {
32
- constructor({
33
- key,
34
- policyEntities,
35
- provisions,
36
- limits
37
- }) {
38
- this.key = key,
39
- this.policyEntities = policyEntities,
40
- this.provisions = provisions,
41
- this.limits = limits
42
- }
43
- }
44
-
45
- const documentTypesList = ['accord25']
46
-
47
- module.exports = {
48
- coverageRequestModel,
49
- coverageDocumentModel,
50
- coveragePageModel,
51
- coveragePolicyModel,
52
- documentTypesList
53
- };
@@ -1,29 +0,0 @@
1
- const requests = require('../../common/requests');
2
- const { backendUrl } = require('../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- invite: projectId => `${backendUrl}/saas/project/${projectId}/team-member`,
6
- getByProjectId: projectId => `${backendUrl}/saas/project/${projectId}/team-members`,
7
- getByEmail: email => `${backendUrl}/saas/team-member/by-email/${email}`,
8
- delete: userId => `${backendUrl}/saas/users/${userId}`
9
- };
10
-
11
- const invite = async (projectId, invitedUser, context) => {
12
- return requests.putRequestHandler(Endpoints.invite(projectId), invitedUser, context).then(
13
- res => res.data
14
- );
15
- };
16
-
17
- const getUsersByProjectId = async (projectId, context) => {
18
- return requests.getRequestHandler(Endpoints.getByProjectId(projectId), null, context).then(res => res.data);
19
- };
20
-
21
- const getUserByEmail = async (email, context) => {
22
- return requests.getRequestHandler(Endpoints.getByEmail(email), null, context).then(res => res.data);
23
- };
24
-
25
- const deleteUser = async (userId, context) => {
26
- return requests.deleteRequestHandler(Endpoints.delete(userId), context);
27
- };
28
-
29
- module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };
@@ -1,19 +0,0 @@
1
- const inviteUserAPI = require('./invite.api');
2
-
3
- const invite = async (projectId, invitedUser, context) => {
4
- return inviteUserAPI.invite(projectId, invitedUser, context);
5
- };
6
-
7
- const getUsersByProjectId = async (projectId, context) => {
8
- return inviteUserAPI.getUsersByProjectId(projectId, context);
9
- };
10
-
11
- const getUserByEmail = async (email, context) => {
12
- return inviteUserAPI.getUserByEmail(email, context);
13
- };
14
-
15
- const deleteUser = (userId, context) => {
16
- return inviteUserAPI.deleteUser(userId, context);
17
- };
18
-
19
- module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };