@getjones/test-infra 1.7.2 → 1.8.0
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 +1 -1
- package/src/index.js +0 -1
- package/src/saas/internal-api/contractors/api/contractors.api.js +26 -2
- package/src/saas/internal-api/contractors/api/contractors.service.js +25 -1
- package/src/saas/internal-api/contractors/models/create.contractor.model.js +2 -2
- package/src/saas/internal-api/projects/api/core/projects.api.js +7 -2
- package/src/saas/internal-api/projects/api/core/projects.service.js +6 -1
- package/src/saas/internal-api/reports/consts/consts.js +8 -1
- package/src/saas/internal-api/tabs/api/tabs.service.js +18 -17
- package/src/saas/internal-api/tabs/models/tabs.model.js +18 -0
- package/src/saas/internal-api/users/api/users.api.js +23 -2
- package/src/saas/internal-api/users/api/users.service.js +55 -3
- package/src/saas/internal-api/users/index.js +1 -1
- package/src/saas/internal-api/users/models/users.model.js +31 -0
- package/src/saas/internal-api/users/utils/util.js +14 -0
- package/src/saas/openapi/projects/projects.api.js +8 -2
- package/src/saas/openapi/projects/projects.service.js +6 -1
- package/README.md +0 -329
- package/src/saas/internal-api/users/models/edit.user.model.js +0 -10
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -9,11 +9,15 @@ const Endpoints = {
|
|
|
9
9
|
archive: contractorId => `${backendUrl}/saas/contractor/${contractorId}/archive`,
|
|
10
10
|
restore: contractorId => `${backendUrl}/saas/contractor/${contractorId}/restore`,
|
|
11
11
|
edit: contractorId => `${backendUrl}/saas/contractors/${contractorId}/update`,
|
|
12
|
+
muteNotifications: `${backendUrl}/saas/record/notifications/mute`,
|
|
13
|
+
unmuteNotifications: `${backendUrl}/saas/record/notifications/unmute`,
|
|
14
|
+
changeRequirement: `${backendUrl}/saas/contractor/requirement`,
|
|
12
15
|
updateVendorExpiryDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/expiry-date`,
|
|
13
16
|
assignMptToProperties: (accountId, tenantId) => `${backendUrl}/saas/account/${accountId}/multi-properties/${tenantId}`,
|
|
14
17
|
searchInAutocomplete: ({ tabId, searchWord }) =>
|
|
15
18
|
`${backendUrl}/saas/contractors/search/audited?&tabId=${tabId}&searchWord=${searchWord}`,
|
|
16
|
-
automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date
|
|
19
|
+
automationUpdateContractorUploadDate: contractorId => `${backendUrl}/saas/automation/contractor/${contractorId}/upload-date`,
|
|
20
|
+
publicLinkInvite: `${backendUrl}/_saas/contractors/publicinvite`
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
const createContractor = (createContractorModel, context) => {
|
|
@@ -45,6 +49,18 @@ const editContractor = (editContractorModel, context) => {
|
|
|
45
49
|
return requests.postRequestHandler(Endpoints.edit(editContractorModel.contractorId), editContractorModel, context, {}, params);
|
|
46
50
|
};
|
|
47
51
|
|
|
52
|
+
const muteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
53
|
+
return requests.postRequestHandler(Endpoints.muteNotifications, recordModifyDateVerificationModel, context);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const unmuteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
57
|
+
return requests.postRequestHandler(Endpoints.unmuteNotifications, recordModifyDateVerificationModel, context);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const changeRequirement = (recordModifyDateVerificationModel, context) => {
|
|
61
|
+
return requests.putRequestHandler(Endpoints.changeRequirement, recordModifyDateVerificationModel, context);
|
|
62
|
+
};
|
|
63
|
+
|
|
48
64
|
const updateExpiryDate = (contractorId, expiryDate, policyName) => {
|
|
49
65
|
const data = { [policyName]: expiryDate };
|
|
50
66
|
return requests.postRequestHandler(Endpoints.updateVendorExpiryDate(contractorId), data);
|
|
@@ -81,8 +97,13 @@ const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
|
81
97
|
return requests.patchRequestHandler(url, context);
|
|
82
98
|
};
|
|
83
99
|
|
|
100
|
+
const inviteContractorViaPublicLink = (createContractorModel, context) => {
|
|
101
|
+
return requests.postRequestHandler(Endpoints.publicLinkInvite, createContractorModel, context);
|
|
102
|
+
};
|
|
103
|
+
|
|
84
104
|
module.exports = {
|
|
85
105
|
createContractor,
|
|
106
|
+
changeRequirement,
|
|
86
107
|
getContractorsByAccountId,
|
|
87
108
|
getContractorById,
|
|
88
109
|
deleteByContractorId,
|
|
@@ -93,5 +114,8 @@ module.exports = {
|
|
|
93
114
|
assignMptToProperties,
|
|
94
115
|
getContractorsByTabId,
|
|
95
116
|
searchInAutocomplete,
|
|
96
|
-
updateContractorUploadDate
|
|
117
|
+
updateContractorUploadDate,
|
|
118
|
+
inviteContractorViaPublicLink,
|
|
119
|
+
muteNotifications,
|
|
120
|
+
unmuteNotifications
|
|
97
121
|
};
|
|
@@ -61,8 +61,29 @@ const updateContractorUploadDate = (contractorId, uploadDate, context) => {
|
|
|
61
61
|
return contractorsAPI.updateContractorUploadDate(contractorId, uploadDate, context);
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
const inviteContractorViaPublicLink = async (createContractorModel, context) => {
|
|
65
|
+
validateType(createContractorModel, CreateContractorModel);
|
|
66
|
+
return contractorsAPI.inviteContractorViaPublicLink(createContractorModel, context);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const changeRequirement = (recordModifyDateVerificationModel, context) => {
|
|
70
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
71
|
+
return contractorsAPI.changeRequirement(recordModifyDateVerificationModel, context);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const muteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
75
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
76
|
+
return contractorsAPI.muteNotifications(recordModifyDateVerificationModel, context);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const unmuteNotifications = (recordModifyDateVerificationModel, context) => {
|
|
80
|
+
validateType(recordModifyDateVerificationModel, RecordModifyDateVerificationModel);
|
|
81
|
+
return contractorsAPI.unmuteNotifications(recordModifyDateVerificationModel, context);
|
|
82
|
+
};
|
|
83
|
+
|
|
64
84
|
module.exports = {
|
|
65
85
|
createContractor,
|
|
86
|
+
changeRequirement,
|
|
66
87
|
getContractorsByAccountId,
|
|
67
88
|
getContractorById,
|
|
68
89
|
deleteByContractorId,
|
|
@@ -73,5 +94,8 @@ module.exports = {
|
|
|
73
94
|
getContractorsByTabId,
|
|
74
95
|
assignMptToProperties,
|
|
75
96
|
searchInAutoComplete,
|
|
76
|
-
updateContractorUploadDate
|
|
97
|
+
updateContractorUploadDate,
|
|
98
|
+
inviteContractorViaPublicLink,
|
|
99
|
+
muteNotifications,
|
|
100
|
+
unmuteNotifications
|
|
77
101
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
2
|
|
|
3
|
-
function CreateContractorModel(requirementId, inviterEmail, vendorInfo, { tabId = null, disableMail = true,
|
|
3
|
+
function CreateContractorModel(requirementId, inviterEmail, vendorInfo, { tabId = null, disableMail = true, publicLink } = {}) {
|
|
4
4
|
this.reqId = requirementId;
|
|
5
5
|
this.inviterEmail = inviterEmail;
|
|
6
6
|
this.vendorInfo = vendorInfo;
|
|
7
7
|
this.disableMail = disableMail;
|
|
8
|
-
this.sendCovid19Form = sendCovid19Form;
|
|
9
8
|
this.tabId = tabId;
|
|
9
|
+
this.publicLink = publicLink;
|
|
10
10
|
|
|
11
11
|
vendorInfo && validateType(vendorInfo, ContractorInfo);
|
|
12
12
|
}
|
|
@@ -6,7 +6,8 @@ const Endpoints = {
|
|
|
6
6
|
delete: projectId => `${backendUrl}/saas/project/${projectId}`,
|
|
7
7
|
getByAccountId: `${backendUrl}/saas/project/list`,
|
|
8
8
|
update: `${backendUrl}/saas/project`,
|
|
9
|
-
getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}
|
|
9
|
+
getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`,
|
|
10
|
+
getProjectServiceAreaByProjectId: projectId => `${backendUrl}/saas/integration-tests/project/${projectId}/service-area`
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
const create = (project, context) => {
|
|
@@ -31,4 +32,8 @@ const update = (project, context) => {
|
|
|
31
32
|
return requests.postRequestHandler(Endpoints.update, project, context);
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
const getProjectServiceAreaByProjectId = (projectId, context) => {
|
|
36
|
+
return requests.getRequestHandler(Endpoints.getProjectServiceAreaByProjectId(projectId), {}, context);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId, getProjectServiceAreaByProjectId };
|
|
@@ -17,6 +17,10 @@ const getProjectByName = async (accountId, projectName, context) => {
|
|
|
17
17
|
return requestedProject ? requestedProject : null;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
const getProjectServiceArea = (projectId, context) => {
|
|
21
|
+
return projectsApi.getProjectServiceAreaByProjectId(projectId, context);
|
|
22
|
+
};
|
|
23
|
+
|
|
20
24
|
const deleteProjectByName = async (accountId, projectName, context) => {
|
|
21
25
|
const { data: projects } = await getProjectsByAccountId(accountId, context);
|
|
22
26
|
const filteredProjects = projects.filter(project => project.projectName === projectName);
|
|
@@ -56,5 +60,6 @@ module.exports = {
|
|
|
56
60
|
getProjectByName,
|
|
57
61
|
createProject,
|
|
58
62
|
deleteProjectByName,
|
|
59
|
-
updateProject
|
|
63
|
+
updateProject,
|
|
64
|
+
getProjectServiceArea
|
|
60
65
|
};
|
|
@@ -6,6 +6,10 @@ const REPORT_COMPLIANCE_STATUSES = {
|
|
|
6
6
|
EXPIRED: 'EXPIRED'
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
const EXPIRING_RECORDS_REPORT_COMPLIANCE_STATUSES = {
|
|
10
|
+
EXPIRING_SOON: 'EXPIRING_SOON'
|
|
11
|
+
};
|
|
12
|
+
|
|
9
13
|
const REPORT_CONTRACTOR_TYPES = {
|
|
10
14
|
VENDORS: 'Vendors',
|
|
11
15
|
TENANTS: 'Tenants',
|
|
@@ -30,7 +34,9 @@ const XlsxReportTypes = {
|
|
|
30
34
|
HIGH_LEVEL_PROPERTY_METRICS: 'HighLevelPropertyMetrics',
|
|
31
35
|
MASTER_COMPLIANCE_REPORT: 'MasterComplianceReport',
|
|
32
36
|
WAIVERS_REPORT: 'WaiversReport',
|
|
33
|
-
USER_MANAGEMENT_REPORT: 'UserManagementReport'
|
|
37
|
+
USER_MANAGEMENT_REPORT: 'UserManagementReport',
|
|
38
|
+
COVERAGE_GAPS_REPORT: 'CoverageGapsReport',
|
|
39
|
+
EXPIRING_RECORDS_REPORT: 'ExpiringRecordsReport'
|
|
34
40
|
};
|
|
35
41
|
|
|
36
42
|
const ScheduledReportFrequency = {
|
|
@@ -49,6 +55,7 @@ module.exports = {
|
|
|
49
55
|
REPORT_COMPLIANCE_STATUSES,
|
|
50
56
|
REPORT_CONTRACTOR_TYPES,
|
|
51
57
|
ALL_REPORT_COMPLIANCE_STATUSES,
|
|
58
|
+
EXPIRING_RECORDS_REPORT_COMPLIANCE_STATUSES,
|
|
52
59
|
ALL_REPORT_CONTRACTOR_TYPES,
|
|
53
60
|
XlsxReportTypes,
|
|
54
61
|
ScheduledReportFrequency,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const tabsAPI = require('./tabs.api');
|
|
2
|
+
const { CreateTabModel, UpdateTabModel } = require('../models/tabs.model');
|
|
2
3
|
|
|
3
4
|
const createTab = async (projectId, tabName, tabType, context) => {
|
|
4
|
-
const tabModel =
|
|
5
|
+
const tabModel = new CreateTabModel(projectId, tabName, tabType);
|
|
5
6
|
return tabsAPI.createTab(tabModel, context);
|
|
6
7
|
};
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
return tabsAPI.updateTab(tabModel, context);
|
|
9
|
+
const getTabById = async (tabId, context) => {
|
|
10
|
+
return tabsAPI.getTabByTabId(tabId, context);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const getTabsByProjectId = async (projectId, context) => {
|
|
@@ -15,21 +15,13 @@ const getTabsByProjectId = async (projectId, context) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
|
|
18
|
-
const { data: tabs } = await
|
|
18
|
+
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
19
19
|
const requestedTab = tabType ?
|
|
20
20
|
tabs.find(tab => tab.tabName === tabName && tab.type === tabType) :
|
|
21
21
|
tabs.find(tab => tab.tabName === tabName);
|
|
22
22
|
return requestedTab;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const getTabById = async (tabId, context) => {
|
|
26
|
-
return tabsAPI.getTabByTabId(tabId, context);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const deleteTabById = async (tabId, context) => {
|
|
30
|
-
return tabsAPI.deleteTab(tabId, context);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
25
|
const getOrCreateTab = async (projectId, tabName, tabType, context) => {
|
|
34
26
|
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
35
27
|
const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
|
|
@@ -42,12 +34,21 @@ const getOrCreateTab = async (projectId, tabName, tabType, context) => {
|
|
|
42
34
|
return createResponse.data;
|
|
43
35
|
};
|
|
44
36
|
|
|
37
|
+
const updateTab = async (projectId, tabName, tabType, tabId, context) => {
|
|
38
|
+
const tabModel = new UpdateTabModel(projectId, tabName, tabType, tabId);
|
|
39
|
+
return tabsAPI.updateTab(tabModel, context);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const deleteTabById = async (tabId, context) => {
|
|
43
|
+
return tabsAPI.deleteTab(tabId, context);
|
|
44
|
+
};
|
|
45
|
+
|
|
45
46
|
module.exports = {
|
|
47
|
+
createTab,
|
|
46
48
|
getTabById,
|
|
47
49
|
getTabsByProjectId,
|
|
48
|
-
|
|
49
|
-
updateTab,
|
|
50
|
-
deleteTabById,
|
|
50
|
+
getTabsByName,
|
|
51
51
|
getOrCreateTab,
|
|
52
|
-
|
|
52
|
+
updateTab,
|
|
53
|
+
deleteTabById
|
|
53
54
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateTabModel {
|
|
2
|
+
constructor(projectId, tabName, tabType) {
|
|
3
|
+
this.projectId = projectId;
|
|
4
|
+
this.tabName = tabName;
|
|
5
|
+
this.type = tabType;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class UpdateTabModel {
|
|
10
|
+
constructor(projectId, tabName, tabType, tabId) {
|
|
11
|
+
this.projectId = projectId;
|
|
12
|
+
this.tabName = tabName;
|
|
13
|
+
this.type = tabType;
|
|
14
|
+
this.tabId = tabId;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = { CreateTabModel, UpdateTabModel };
|
|
@@ -10,7 +10,9 @@ const Endpoints = {
|
|
|
10
10
|
getByEmail: email => `${backendUrl}/saas/team-member/by-email/${email}`,
|
|
11
11
|
delete: userId => `${backendUrl}/saas/users/${userId}`,
|
|
12
12
|
deleteSingleProject: (userId, projectId) => `${backendUrl}/saas/project/${projectId}/sub-account/${userId}`,
|
|
13
|
-
reinvite: `${backendUrl}/saas/project/team-member/reinvite
|
|
13
|
+
reinvite: `${backendUrl}/saas/project/team-member/reinvite`,
|
|
14
|
+
getUserEncryptedData: (email, userRole) => `${backendUrl}/saas/team-member/email/${email}/role/${userRole}/signup-data`,
|
|
15
|
+
signupUser: `${backendUrl}/_saas/guests/signup`
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
const invite = (invitedUser, context) => {
|
|
@@ -18,6 +20,10 @@ const invite = (invitedUser, context) => {
|
|
|
18
20
|
return requests.putRequestHandler(Endpoints.invite, invitedUser, context, {}, params);
|
|
19
21
|
};
|
|
20
22
|
|
|
23
|
+
const signupUser = (signupUserModel, context) => {
|
|
24
|
+
return requests.postRequestHandler(Endpoints.signupUser, signupUserModel, context, {}, {});
|
|
25
|
+
};
|
|
26
|
+
|
|
21
27
|
const editUserRole = (userId, data, context) => {
|
|
22
28
|
return requests.patchRequestHandler(Endpoints.editUserRole(userId), context, data);
|
|
23
29
|
};
|
|
@@ -35,6 +41,10 @@ const getUserByEmail = (email, context) => {
|
|
|
35
41
|
return requests.getRequestHandler(Endpoints.getByEmail(email), null, context);
|
|
36
42
|
};
|
|
37
43
|
|
|
44
|
+
const getUserEncryptedData = (email, role, context) => {
|
|
45
|
+
return requests.getRequestHandler(Endpoints.getUserEncryptedData(email, role), null, context);
|
|
46
|
+
};
|
|
47
|
+
|
|
38
48
|
const deleteUser = (userId, context) => {
|
|
39
49
|
return requests.deleteRequestHandler(Endpoints.delete(userId), context);
|
|
40
50
|
};
|
|
@@ -48,4 +58,15 @@ const reinviteUser = (userId, context) => {
|
|
|
48
58
|
return requests.postRequestHandler(Endpoints.reinvite, {}, context, {}, params);
|
|
49
59
|
};
|
|
50
60
|
|
|
51
|
-
module.exports = {
|
|
61
|
+
module.exports = {
|
|
62
|
+
invite,
|
|
63
|
+
signupUser,
|
|
64
|
+
getUsersByProjectId,
|
|
65
|
+
getUserByEmail,
|
|
66
|
+
getUserEncryptedData,
|
|
67
|
+
deleteUser,
|
|
68
|
+
deleteUserFromSingleProject,
|
|
69
|
+
editUserRole,
|
|
70
|
+
editUserProjects,
|
|
71
|
+
reinviteUser
|
|
72
|
+
};
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
const EditUserModel = require('../models/
|
|
2
|
-
const userAPI = require('./users.api');
|
|
1
|
+
const { InviteUserModel, SignupUserModel, EditUserModel } = require('../models/users.model');
|
|
3
2
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
3
|
+
const { getEnv } = require('../../../../env');
|
|
4
|
+
const { credentials } = getEnv();
|
|
5
|
+
const userAPI = require('./users.api');
|
|
6
|
+
const util = require('../utils/util');
|
|
7
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
4
8
|
|
|
5
9
|
const inviteUser = async (invitedUser, context) => {
|
|
6
10
|
return userAPI.invite(invitedUser, context);
|
|
7
11
|
};
|
|
8
12
|
|
|
13
|
+
const signupUser = (signupUserModel, context) => {
|
|
14
|
+
validateType(signupUserModel, SignupUserModel);
|
|
15
|
+
return userAPI.signupUser(signupUserModel, context);
|
|
16
|
+
};
|
|
17
|
+
|
|
9
18
|
const editUserRole = async (userId, data, context) => {
|
|
10
19
|
return userAPI.editUserRole(userId, data, context);
|
|
11
20
|
};
|
|
@@ -23,6 +32,38 @@ const getUserByEmail = async (email, context) => {
|
|
|
23
32
|
return userAPI.getUserByEmail(email, context);
|
|
24
33
|
};
|
|
25
34
|
|
|
35
|
+
const getOrCreateUser = async (email, role, projectsIds, context, { fullName = role, password = credentials.strongPassword } = {}) => {
|
|
36
|
+
let userResponse = await getUserByEmail(email, context);
|
|
37
|
+
|
|
38
|
+
if (userResponse.data.subuserId) {
|
|
39
|
+
return userResponse.data;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const inviteUserModel = new InviteUserModel(email, role, projectsIds, context);
|
|
43
|
+
const inviteResponse = await inviteUser([inviteUserModel], context);
|
|
44
|
+
|
|
45
|
+
if (inviteResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
46
|
+
throw new Error(`Failed to invite user with email: ${email}`, inviteResponse);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
userResponse = await getUserByEmail(email, context);
|
|
50
|
+
|
|
51
|
+
//Already signup user
|
|
52
|
+
if (userResponse.data.isVerified) {
|
|
53
|
+
return userResponse.data;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const signupUserModel = await util.getSignupUserModel(email, role, fullName, password, context);
|
|
57
|
+
const signupResponse = await signupUser(signupUserModel, context);
|
|
58
|
+
|
|
59
|
+
if (signupResponse.status !== httpResponseStatusCodes.OK) {
|
|
60
|
+
throw new Error(`Failed to signup user with email: ${email}`, signupResponse);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
userResponse = await getUserByEmail(email, context);
|
|
64
|
+
return userResponse.data;
|
|
65
|
+
};
|
|
66
|
+
|
|
26
67
|
const deleteUser = (userId, context) => {
|
|
27
68
|
return userAPI.deleteUser(userId, context);
|
|
28
69
|
};
|
|
@@ -35,4 +76,15 @@ const reinviteUser = (userId, context) => {
|
|
|
35
76
|
return userAPI.reinviteUser(userId, context);
|
|
36
77
|
};
|
|
37
78
|
|
|
38
|
-
module.exports = {
|
|
79
|
+
module.exports = {
|
|
80
|
+
inviteUser,
|
|
81
|
+
signupUser,
|
|
82
|
+
getUsersByProjectId,
|
|
83
|
+
getUserByEmail,
|
|
84
|
+
getOrCreateUser,
|
|
85
|
+
deleteUser,
|
|
86
|
+
deleteUserFromSingleProject,
|
|
87
|
+
editUserRole,
|
|
88
|
+
editUserProjects,
|
|
89
|
+
reinviteUser
|
|
90
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class InviteUserModel {
|
|
2
|
+
constructor(email, role, projects = []) {
|
|
3
|
+
this.email = email;
|
|
4
|
+
this.role = role;
|
|
5
|
+
this.projects = projects;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class SignupUserModel {
|
|
10
|
+
constructor(fullName, role, password, encryptedData) {
|
|
11
|
+
this.fullName = fullName;
|
|
12
|
+
this.role = role;
|
|
13
|
+
this.password = password;
|
|
14
|
+
this.encryptedData = encryptedData;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class EditUserModel {
|
|
19
|
+
constructor(subUserId, email, role, projects = []) {
|
|
20
|
+
this.subUserId = subUserId;
|
|
21
|
+
this.email = email;
|
|
22
|
+
this.role = role;
|
|
23
|
+
this.projects = projects;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
InviteUserModel,
|
|
29
|
+
SignupUserModel,
|
|
30
|
+
EditUserModel
|
|
31
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { SignupUserModel } = require('../models/users.model');
|
|
2
|
+
const usersApi = require('../api/users.api');
|
|
3
|
+
|
|
4
|
+
const getUserEncryptedData = async (email, role, context) => {
|
|
5
|
+
const response = await usersApi.getUserEncryptedData(email, role, context);
|
|
6
|
+
return response.data;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const getSignupUserModel = async (email, role, fullName, password, context) => {
|
|
10
|
+
const userEncryptedData = await getUserEncryptedData(email, role, context);
|
|
11
|
+
return new SignupUserModel(fullName, role, password, userEncryptedData);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = { getSignupUserModel };
|
|
@@ -8,7 +8,8 @@ const Endpoints = {
|
|
|
8
8
|
createProject: `${openapiUrl}/properties`,
|
|
9
9
|
updateProject: projectId => `${openapiUrl}/properties/${projectId}`,
|
|
10
10
|
getProjectSettings: projectId => `${openapiUrl}/properties/${projectId}/settings`,
|
|
11
|
-
updateProjectSettings: projectId => `${openapiUrl}/properties/${projectId}/settings
|
|
11
|
+
updateProjectSettings: projectId => `${openapiUrl}/properties/${projectId}/settings`,
|
|
12
|
+
getProjectServiceArea: (city, state) => `${openapiUrl}/properties/service-area?city=${city}&state=${state}`
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const getProjectsByName = async (apiKey, params) => {
|
|
@@ -42,6 +43,10 @@ const getProjectSettings = async (apiKey, projectId) => {
|
|
|
42
43
|
apiKey).then(res => res.data);
|
|
43
44
|
};
|
|
44
45
|
|
|
46
|
+
const getProjectServiceArea = async (apiKey, city, state) => {
|
|
47
|
+
return requests.getRequestHandler(Endpoints.getProjectServiceArea(city, state), apiKey);
|
|
48
|
+
};
|
|
49
|
+
|
|
45
50
|
module.exports = {
|
|
46
51
|
getProjectsByName,
|
|
47
52
|
getAllProjects,
|
|
@@ -49,5 +54,6 @@ module.exports = {
|
|
|
49
54
|
createProject,
|
|
50
55
|
updateProject,
|
|
51
56
|
updateProjectSettings,
|
|
52
|
-
getProjectSettings
|
|
57
|
+
getProjectSettings,
|
|
58
|
+
getProjectServiceArea
|
|
53
59
|
};
|
|
@@ -28,6 +28,10 @@ const getProjectSettings = async (apiKey, projectId) => {
|
|
|
28
28
|
return projectsApi.getProjectSettings(apiKey, projectId);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
const getProjectServiceArea = async (apiKey, city, state) => {
|
|
32
|
+
return projectsApi.getProjectServiceArea(apiKey, city, state);
|
|
33
|
+
};
|
|
34
|
+
|
|
31
35
|
module.exports = {
|
|
32
36
|
getProjectsByName,
|
|
33
37
|
createProject,
|
|
@@ -35,5 +39,6 @@ module.exports = {
|
|
|
35
39
|
getAllProjects,
|
|
36
40
|
getModifiedProjects,
|
|
37
41
|
updateProjectSettings,
|
|
38
|
-
getProjectSettings
|
|
42
|
+
getProjectSettings,
|
|
43
|
+
getProjectServiceArea
|
|
39
44
|
};
|
package/README.md
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
# Package Name: @getjones/test-infra
|
|
2
|
-
|
|
3
|
-
## Package Goal
|
|
4
|
-
|
|
5
|
-
- Providing an easy and reusable interface for the backend system. Means, both by the OpenAPI, and the internal API.
|
|
6
|
-
|
|
7
|
-
## Interface
|
|
8
|
-
|
|
9
|
-
### init
|
|
10
|
-
|
|
11
|
-
- require the package with settled up configuration json
|
|
12
|
-
|
|
13
|
-
```node
|
|
14
|
-
const { internalAPI } = require("@getjones/test-infra")(conf);
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
- configuration example
|
|
18
|
-
|
|
19
|
-
```node
|
|
20
|
-
const dotenv = require("dotenv");
|
|
21
|
-
|
|
22
|
-
dotenv.config();
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
backendUrl: process.env.BACKEND_URL,
|
|
26
|
-
credentials: {
|
|
27
|
-
superUser: process.env.CREDENTIALS_SUPER_USER,
|
|
28
|
-
superUserPassword: process.env.CREDENTIALS_SUPER_USER_PASSWORD,
|
|
29
|
-
strongPassword: process.env.CREDENTIALS_STRONG_PASSWORD,
|
|
30
|
-
},
|
|
31
|
-
accountCreationSecret: process.env.ACCOUNT_CREATION_SECRET,
|
|
32
|
-
environment: process.env.ENVIRONMENT,
|
|
33
|
-
email: process.env.EMAIL,
|
|
34
|
-
};
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### internalAPI
|
|
38
|
-
|
|
39
|
-
- internalAPI contains the next services:
|
|
40
|
-
- auth
|
|
41
|
-
- accounts
|
|
42
|
-
- accountSettings
|
|
43
|
-
- projects
|
|
44
|
-
- projectSettings
|
|
45
|
-
|
|
46
|
-
```node
|
|
47
|
-
const { auth, accounts, accountSettings, projects } = internalAPI;
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### auth
|
|
51
|
-
|
|
52
|
-
```node
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @param email (string)
|
|
56
|
-
* @param password (string)
|
|
57
|
-
* @return Auth cookie (string) with given email privileges.
|
|
58
|
-
*/
|
|
59
|
-
const getAuthCookie = async (email, password) => {};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
* Required Configuration: {
|
|
64
|
-
* credentials.superUser,
|
|
65
|
-
* credentials.superUserPassword
|
|
66
|
-
* }
|
|
67
|
-
* @return ICS cookie (String)
|
|
68
|
-
*/
|
|
69
|
-
const getIcsCookie = async () => {};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* Required Configuration: {
|
|
74
|
-
* credentials.auditorUser,
|
|
75
|
-
* credentials.auditorPassword
|
|
76
|
-
* }
|
|
77
|
-
* @return Auditor cookie (String)
|
|
78
|
-
*/
|
|
79
|
-
const getAuditorCookie = async () => {};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
* Required Configuration: {
|
|
84
|
-
* credentials.operatorUser,
|
|
85
|
-
* credentials.operatorPassword
|
|
86
|
-
* }
|
|
87
|
-
* @return Operator cookie (String)
|
|
88
|
-
*/
|
|
89
|
-
const getOperatorCookie = async () => {};
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### accounts
|
|
93
|
-
|
|
94
|
-
```node
|
|
95
|
-
/**
|
|
96
|
-
*
|
|
97
|
-
* Required Configuration: {
|
|
98
|
-
* accountCreationSecret: accountCreationSecret,
|
|
99
|
-
* }
|
|
100
|
-
*
|
|
101
|
-
* If you want to use default password so
|
|
102
|
-
* 'credentials.strongPassword' is needed
|
|
103
|
-
* to be a part of the configuration.
|
|
104
|
-
*
|
|
105
|
-
* @param email (string)
|
|
106
|
-
* @param accountName (string)
|
|
107
|
-
* @param context (string): Should contain ICS cookie
|
|
108
|
-
* @return Account (object)
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
const createAccount = async (
|
|
112
|
-
email,
|
|
113
|
-
accountName,
|
|
114
|
-
context,
|
|
115
|
-
password = credentials.strongPassword,
|
|
116
|
-
propertyType = PROPERTY_TYPE
|
|
117
|
-
) => {};
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
*
|
|
121
|
-
* @param accountName (string)
|
|
122
|
-
* @param context (string): Should contains ICS cookie
|
|
123
|
-
* @return Account (object)
|
|
124
|
-
*/
|
|
125
|
-
const getAccount = async (accountName, context) => {};
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* @param email (string)
|
|
130
|
-
* @param accountName (string)
|
|
131
|
-
* @param context (string): Should contain ICS cookie
|
|
132
|
-
* @param password (string)
|
|
133
|
-
* @return Account (object)
|
|
134
|
-
*/
|
|
135
|
-
const getOrCreateAccount = async (
|
|
136
|
-
email,
|
|
137
|
-
accountName,
|
|
138
|
-
context,
|
|
139
|
-
password = credentials.strongPassword
|
|
140
|
-
) => {};
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
*
|
|
144
|
-
* @param accountName (string)
|
|
145
|
-
* @param context (string): Should contain ICS cookie
|
|
146
|
-
* @return Account ID (String)
|
|
147
|
-
*/
|
|
148
|
-
const getAccountId = async (accountName, context) => {};
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
*
|
|
152
|
-
* @param accountName (string)
|
|
153
|
-
* @param context (string): Should contains ICS cookie
|
|
154
|
-
* @return Http Response
|
|
155
|
-
*/
|
|
156
|
-
const deleteAccountByName = async (accountName, context) => {};
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
*
|
|
160
|
-
* @param accountId (string)
|
|
161
|
-
* @param context (string): Should contain ICS cookie
|
|
162
|
-
* @return Http Response
|
|
163
|
-
*/
|
|
164
|
-
const deleteAccountById = async (accountId, context) => {};
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### accountSettings
|
|
168
|
-
|
|
169
|
-
```node
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
* @param accountId (string)
|
|
173
|
-
* @param context (string): Should contain ICS cookie
|
|
174
|
-
* @return Account Settings (object)
|
|
175
|
-
*/
|
|
176
|
-
const getAccountSettings = async (accountId, context) => {};
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
*
|
|
180
|
-
* @param accountId (string)
|
|
181
|
-
* @param AccountSettings (object) Should Contain:
|
|
182
|
-
* isMultiPropertyTenants (boolean)
|
|
183
|
-
* isHighPriority (boolean)
|
|
184
|
-
* @param context (string): Should contain ICS cookie
|
|
185
|
-
* @return Http Response
|
|
186
|
-
*/
|
|
187
|
-
const updateAccountSettings = async (
|
|
188
|
-
accountId,
|
|
189
|
-
isMultiPropertyTenants,
|
|
190
|
-
isHighPriority,
|
|
191
|
-
context
|
|
192
|
-
) => {};
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Summary: Change account settings to default
|
|
196
|
-
* Description:
|
|
197
|
-
* Update The Next Account Settings:
|
|
198
|
-
* isMultiPropertyTenants: false
|
|
199
|
-
* isHighPriority: false
|
|
200
|
-
* @param accountId (string)
|
|
201
|
-
* @param context (string): Should Contain ICS cookie
|
|
202
|
-
* @return Http Response
|
|
203
|
-
*/
|
|
204
|
-
const restoreAccountSettings = async (accountId, context) => {};
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### projects
|
|
208
|
-
|
|
209
|
-
```node
|
|
210
|
-
/**
|
|
211
|
-
*
|
|
212
|
-
* @param accountName (string)
|
|
213
|
-
* @param context (string): Should contain cookie
|
|
214
|
-
* User's cookie that is related to this account or ICS cookie
|
|
215
|
-
* @return List of projects ([objects])
|
|
216
|
-
*/
|
|
217
|
-
const getProjectsByAccountName = async (accountName, context) => {};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
*
|
|
221
|
-
* @param accountId (String)
|
|
222
|
-
* @param context (string): Should contain cookie
|
|
223
|
-
* User's cookie that is related to this account or ICS cookie
|
|
224
|
-
* @return List of projects ([objects])
|
|
225
|
-
*/
|
|
226
|
-
const getProjectsByAccountId = async (accountId, context) => {};
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
*
|
|
230
|
-
* @param accountId (string)
|
|
231
|
-
* @param projectName (string)
|
|
232
|
-
* @param context (string): Should contain cookie
|
|
233
|
-
* User's cookie that is related to this account or ICS cookie
|
|
234
|
-
* @return List of projects ([objects])
|
|
235
|
-
*/
|
|
236
|
-
const getProjectsByName = async (accountId, projectName, context) => {};
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Summary: Delete project by given details
|
|
240
|
-
* @param accountId (string)
|
|
241
|
-
* @param projectName (string)
|
|
242
|
-
* @param context (string): Should contain cookie
|
|
243
|
-
* User's cookie that is related to this account or ICS cookie
|
|
244
|
-
* @return List of projects ([objects])
|
|
245
|
-
*/
|
|
246
|
-
const deleteProjectByName = async (accountId, projectName, context) => {};
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
*
|
|
250
|
-
* @param project (object)
|
|
251
|
-
* @param accountName (string)
|
|
252
|
-
* @param context (string): Should contain cookie
|
|
253
|
-
* User's cookie that is related to this account or ICS cookie
|
|
254
|
-
* @return object contains generated projectId
|
|
255
|
-
*/
|
|
256
|
-
|
|
257
|
-
// Example for project input (Not all of them are required):
|
|
258
|
-
const createProjectInput = {
|
|
259
|
-
projectName: project.name,
|
|
260
|
-
userId: "",
|
|
261
|
-
regionOrDivision: project.description,
|
|
262
|
-
address: project.address,
|
|
263
|
-
projectNumber: project.number,
|
|
264
|
-
projectStartDate: project.startDate,
|
|
265
|
-
projectEndDate: project.endDate,
|
|
266
|
-
city: project.city,
|
|
267
|
-
state: project.state,
|
|
268
|
-
zipCode: project.zipCode,
|
|
269
|
-
companyNameForProject: project.companyNameForProject,
|
|
270
|
-
certificateHolder: "",
|
|
271
|
-
additionalInsured: "",
|
|
272
|
-
tenantSolutionEnabled: "",
|
|
273
|
-
onboardingEnabled: "",
|
|
274
|
-
automaticRenewalEnabled: "",
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
const createProject = async (project, accountName, context) => {};
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### projectSettings
|
|
281
|
-
|
|
282
|
-
```node
|
|
283
|
-
/**
|
|
284
|
-
*
|
|
285
|
-
* @param accountName (string)
|
|
286
|
-
* @param context (string): Should contain cookie
|
|
287
|
-
*/
|
|
288
|
-
|
|
289
|
-
const getProjectsByAccountName = async (accountName, context) => {};
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
*
|
|
293
|
-
* @param settings (object)
|
|
294
|
-
* @param context (string): Should contain cookie
|
|
295
|
-
*/
|
|
296
|
-
|
|
297
|
-
const updateProjectSettingsByProjectId = async (settings, context) => {};
|
|
298
|
-
|
|
299
|
-
// Example for settings input (Not all of them are required):
|
|
300
|
-
const updateProjectSettingsInput = {
|
|
301
|
-
autoGaps: {
|
|
302
|
-
Guests: false,
|
|
303
|
-
Tenants: false,
|
|
304
|
-
Vendors: false,
|
|
305
|
-
},
|
|
306
|
-
autoRenewals: false,
|
|
307
|
-
marketplace: {
|
|
308
|
-
marketplaceEnabled: false,
|
|
309
|
-
marketplacePreApproved: false,
|
|
310
|
-
marketplacePublicLink: false,
|
|
311
|
-
},
|
|
312
|
-
ocrEnabled: false,
|
|
313
|
-
onboardingPhase: false,
|
|
314
|
-
projectId: null,
|
|
315
|
-
qrEnabled: false,
|
|
316
|
-
tenantSolution: false,
|
|
317
|
-
};
|
|
318
|
-
```
|
|
319
|
-
### serviceArea
|
|
320
|
-
|
|
321
|
-
```node
|
|
322
|
-
/**
|
|
323
|
-
* @param city (string)
|
|
324
|
-
* @param state (string)
|
|
325
|
-
* @param context (string): Should contain cookie
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
const getCoordinatesByAddress = (city, state, context) => {}
|
|
329
|
-
```
|