@getjones/test-infra 2.5.0 → 2.6.1
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 +30 -30
- package/src/common/commonFlows/index.js +3 -3
- package/src/common/commonFlows/records/records.js +71 -71
- package/src/common/httpResponseStatusCodes.json +11 -11
- package/src/common/requests/apiKeyAuth/requests.js +38 -38
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/requestHandlers.js +60 -60
- package/src/common/utils/dataTypeUtils.js +41 -41
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/objectUtils.js +9 -9
- package/src/common/utils/timeUtils.js +171 -171
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/defaults/configs/auditConfigs.js +85 -85
- package/src/defaults/configs/polices.js +47 -47
- package/src/defaults/configs/requirement.js +29 -29
- package/src/defaults/index.js +5 -5
- package/src/env.js +57 -57
- package/src/index.js +73 -73
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
- package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
- package/src/saas/internal-api/accounts/consts/consts.js +6 -6
- package/src/saas/internal-api/accounts/index.js +21 -21
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +23 -23
- package/src/saas/internal-api/accounts/utils/utils.js +32 -32
- package/src/saas/internal-api/auth/api/auth.api.js +18 -18
- package/src/saas/internal-api/auth/api/auth.service.js +67 -67
- package/src/saas/internal-api/auth/index.js +3 -3
- package/src/saas/internal-api/coi/api/coi.api.js +34 -34
- package/src/saas/internal-api/coi/api/coi.service.js +22 -22
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +7 -7
- package/src/saas/internal-api/coi/index.js +13 -13
- package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
- package/src/saas/internal-api/coi/utils/utils.js +48 -48
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +40 -40
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +151 -151
- package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
- package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
- package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
- package/src/saas/internal-api/compliance/api/waive/waive.service.js +15 -15
- package/src/saas/internal-api/compliance/consts/audit.js +81 -81
- package/src/saas/internal-api/compliance/index.js +28 -28
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -84
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
- package/src/saas/internal-api/compliance/utils/util.js +175 -175
- package/src/saas/internal-api/contractors/api/contractors.api.js +141 -141
- package/src/saas/internal-api/contractors/api/contractors.service.js +147 -123
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +12 -12
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +7 -7
- package/src/saas/internal-api/dashboardInnerPage/index.js +5 -5
- package/src/saas/internal-api/dashboardInnerPage/models/dashboard.filter.criteria.model.js +38 -38
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
- package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
- package/src/saas/internal-api/dbEmails/index.js +4 -4
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
- package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
- package/src/saas/internal-api/globalRecord/consts.js +20 -20
- package/src/saas/internal-api/globalRecord/index.js +6 -6
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
- package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
- package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
- package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
- package/src/saas/internal-api/homepageCharts/index.js +3 -3
- package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
- package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
- package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
- package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
- package/src/saas/internal-api/projects/index.js +24 -24
- package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
- package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
- package/src/saas/internal-api/projects/utils/utils.js +82 -82
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
- package/src/saas/internal-api/recordNotes/index.js +3 -3
- package/src/saas/internal-api/reports/api/reports.api.js +39 -39
- package/src/saas/internal-api/reports/api/reports.service.js +34 -34
- package/src/saas/internal-api/reports/consts/consts.js +63 -63
- package/src/saas/internal-api/reports/index.js +15 -15
- package/src/saas/internal-api/reports/models/report.model.js +27 -27
- package/src/saas/internal-api/requests/api/requests.api.js +54 -54
- package/src/saas/internal-api/requests/api/requests.service.js +51 -51
- package/src/saas/internal-api/requests/index.js +14 -14
- package/src/saas/internal-api/requests/models/create.request.model.js +22 -22
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requests/utils.js +8 -8
- package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
- package/src/saas/internal-api/requirements/api/requirements.service.js +94 -94
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +5 -5
- package/src/saas/internal-api/requirements/consts/consts.js +6 -6
- package/src/saas/internal-api/requirements/index.js +8 -8
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
- package/src/saas/internal-api/requirements/models/policy.model.js +32 -32
- package/src/saas/internal-api/requirements/models/update.requirement.model.js +21 -21
- package/src/saas/internal-api/requirements/utils/utils.js +101 -101
- package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
- package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
- package/src/saas/internal-api/serviceArea/index.js +4 -4
- package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
- package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
- package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
- package/src/saas/internal-api/tabs/index.js +3 -3
- package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
- package/src/saas/internal-api/thread-scheduler/runner.js +39 -13
- package/src/saas/internal-api/users/api/users.api.js +77 -77
- package/src/saas/internal-api/users/api/users.service.js +101 -101
- package/src/saas/internal-api/users/index.js +4 -4
- package/src/saas/internal-api/users/models/users.model.js +31 -31
- package/src/saas/internal-api/users/utils/util.js +14 -14
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
- package/src/saas/internal-api/vendorProfile/index.js +3 -3
- package/src/saas/openapi/accounts/accounts.api.js +17 -17
- package/src/saas/openapi/accounts/accounts.service.js +11 -11
- package/src/saas/openapi/projects/projects.api.js +59 -59
- package/src/saas/openapi/projects/projects.service.js +44 -44
- package/src/saas/openapi/requests/index.js +6 -6
- package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
- package/src/saas/openapi/requests/requests.api.js +20 -20
- package/src/saas/openapi/requests/requests.service.js +18 -18
- package/src/saas/openapi/requirements/index.js +6 -6
- package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
- package/src/saas/openapi/requirements/requirements.api.js +12 -12
- package/src/saas/openapi/requirements/requirements.service.js +20 -20
- package/src/saas/openapi/tabs/tabs.api.js +13 -13
- package/src/saas/openapi/tabs/tabs.service.js +7 -7
- package/tests/env.test.js +40 -40
- package/tests/validation.test.js +83 -83
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
-
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
-
|
|
4
|
-
const Endpoints = {
|
|
5
|
-
getTabsByProjectId: `${backendUrl}/saas/vendortab`,
|
|
6
|
-
getTabsByTabId: `${backendUrl}/saas/vendortab`,
|
|
7
|
-
create: `${backendUrl}/saas/vendortab`,
|
|
8
|
-
update: `${backendUrl}/saas/vendortab`,
|
|
9
|
-
delete: `${backendUrl}/saas/vendortab`
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const getTabByTabId = (tabId, context) => {
|
|
13
|
-
return requests.getRequestHandler(Endpoints.getTabsByTabId, { tabId }, context);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const getTabsByProjectId = (projectId, context) => {
|
|
17
|
-
return requests.getRequestHandler(Endpoints.getTabsByProjectId, { projectId }, context);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const createTab = (tabModel, context) => {
|
|
21
|
-
return requests.postRequestHandler(Endpoints.create, tabModel, context);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const updateTab = (tabModel, context) => {
|
|
25
|
-
return requests.putRequestHandler(Endpoints.update, tabModel, context);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const deleteTab = (tabId, context) => {
|
|
29
|
-
return requests.deleteRequestHandler(Endpoints.delete, context, {}, { tabId });
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
module.exports = { getTabByTabId, getTabsByProjectId, createTab, updateTab, deleteTab };
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
getTabsByProjectId: `${backendUrl}/saas/vendortab`,
|
|
6
|
+
getTabsByTabId: `${backendUrl}/saas/vendortab`,
|
|
7
|
+
create: `${backendUrl}/saas/vendortab`,
|
|
8
|
+
update: `${backendUrl}/saas/vendortab`,
|
|
9
|
+
delete: `${backendUrl}/saas/vendortab`
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const getTabByTabId = (tabId, context) => {
|
|
13
|
+
return requests.getRequestHandler(Endpoints.getTabsByTabId, { tabId }, context);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getTabsByProjectId = (projectId, context) => {
|
|
17
|
+
return requests.getRequestHandler(Endpoints.getTabsByProjectId, { projectId }, context);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const createTab = (tabModel, context) => {
|
|
21
|
+
return requests.postRequestHandler(Endpoints.create, tabModel, context);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const updateTab = (tabModel, context) => {
|
|
25
|
+
return requests.putRequestHandler(Endpoints.update, tabModel, context);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const deleteTab = (tabId, context) => {
|
|
29
|
+
return requests.deleteRequestHandler(Endpoints.delete, context, {}, { tabId });
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = { getTabByTabId, getTabsByProjectId, createTab, updateTab, deleteTab };
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
const tabsAPI = require('./tabs.api');
|
|
2
|
-
const { CreateTabModel, UpdateTabModel } = require('../models/tabs.model');
|
|
3
|
-
|
|
4
|
-
const createTab = async (projectId, tabName, tabType, context) => {
|
|
5
|
-
const tabModel = new CreateTabModel(projectId, tabName, tabType);
|
|
6
|
-
return tabsAPI.createTab(tabModel, context);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const getTabById = async (tabId, context) => {
|
|
10
|
-
return tabsAPI.getTabByTabId(tabId, context);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const getTabsByProjectId = async (projectId, context) => {
|
|
14
|
-
return tabsAPI.getTabsByProjectId(projectId, context);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
|
|
18
|
-
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
19
|
-
const requestedTab = tabType ?
|
|
20
|
-
tabs.find(tab => tab.tabName === tabName && tab.type === tabType) :
|
|
21
|
-
tabs.find(tab => tab.tabName === tabName);
|
|
22
|
-
return requestedTab;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getOrCreateTab = async (projectId, tabName, tabType, context) => {
|
|
26
|
-
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
27
|
-
const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
|
|
28
|
-
|
|
29
|
-
if (existingTab) {
|
|
30
|
-
return existingTab;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const createResponse = await createTab(projectId, tabName, tabType, context);
|
|
34
|
-
return createResponse.data;
|
|
35
|
-
};
|
|
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
|
-
|
|
46
|
-
module.exports = {
|
|
47
|
-
createTab,
|
|
48
|
-
getTabById,
|
|
49
|
-
getTabsByProjectId,
|
|
50
|
-
getTabsByName,
|
|
51
|
-
getOrCreateTab,
|
|
52
|
-
updateTab,
|
|
53
|
-
deleteTabById
|
|
54
|
-
};
|
|
1
|
+
const tabsAPI = require('./tabs.api');
|
|
2
|
+
const { CreateTabModel, UpdateTabModel } = require('../models/tabs.model');
|
|
3
|
+
|
|
4
|
+
const createTab = async (projectId, tabName, tabType, context) => {
|
|
5
|
+
const tabModel = new CreateTabModel(projectId, tabName, tabType);
|
|
6
|
+
return tabsAPI.createTab(tabModel, context);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const getTabById = async (tabId, context) => {
|
|
10
|
+
return tabsAPI.getTabByTabId(tabId, context);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getTabsByProjectId = async (projectId, context) => {
|
|
14
|
+
return tabsAPI.getTabsByProjectId(projectId, context);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
|
|
18
|
+
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
19
|
+
const requestedTab = tabType ?
|
|
20
|
+
tabs.find(tab => tab.tabName === tabName && tab.type === tabType) :
|
|
21
|
+
tabs.find(tab => tab.tabName === tabName);
|
|
22
|
+
return requestedTab;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getOrCreateTab = async (projectId, tabName, tabType, context) => {
|
|
26
|
+
const { data: tabs } = await getTabsByProjectId(projectId, context);
|
|
27
|
+
const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
|
|
28
|
+
|
|
29
|
+
if (existingTab) {
|
|
30
|
+
return existingTab;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const createResponse = await createTab(projectId, tabName, tabType, context);
|
|
34
|
+
return createResponse.data;
|
|
35
|
+
};
|
|
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
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
createTab,
|
|
48
|
+
getTabById,
|
|
49
|
+
getTabsByProjectId,
|
|
50
|
+
getTabsByName,
|
|
51
|
+
getOrCreateTab,
|
|
52
|
+
updateTab,
|
|
53
|
+
deleteTabById
|
|
54
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const services = require('./api/tabs.service');
|
|
2
|
-
|
|
3
|
-
module.exports = { services };
|
|
1
|
+
const services = require('./api/tabs.service');
|
|
2
|
+
|
|
3
|
+
module.exports = { services };
|
|
@@ -1,18 +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 };
|
|
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 };
|
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
const requests = require('../../internal-api/../../common/requests/cookieAuth/requests');
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
const requests = require('../../internal-api/../../common/requests/cookieAuth/requests');
|
|
2
|
+
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
3
|
+
const timeUtils = require('../../../common/utils/timeUtils');
|
|
4
|
+
|
|
5
|
+
const { backendUrl, threadSchedulerSecret } = require('../../../env').getEnv();
|
|
6
|
+
|
|
7
|
+
const Endpoints = {
|
|
8
|
+
run: `${backendUrl}/threadSchedular/${threadSchedulerSecret}`
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const runThreadScheduler = async ({ contractorIds = [], scheduledReportsIds = [], retries = 10 } = {}) => {
|
|
12
|
+
const params = { contractorIdsList: contractorIds.toString(), scheduledReportsIds: scheduledReportsIds.toString() };
|
|
13
|
+
|
|
14
|
+
let response;
|
|
15
|
+
while (!response || isOverloadError(response.status) && retries--) {
|
|
16
|
+
response = await requests.getRequestHandler(Endpoints.run, params);
|
|
17
|
+
await timeUtils.waitFor(1.5).seconds;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
21
|
+
throw new Error('Thread scheduler has failed to run', response);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return response;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
runForRecords: function(contractorIds) {
|
|
29
|
+
return runThreadScheduler({ contractorIds });
|
|
30
|
+
},
|
|
31
|
+
runForReports: function(scheduledReportsIds) {
|
|
32
|
+
return runThreadScheduler({ scheduledReportsIds });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function isOverloadError(errorCode) {
|
|
37
|
+
const overloadResponseErrors = [httpResponseStatusCodes.TOO_MANY_REQUESTS, httpResponseStatusCodes.CONFLICT];
|
|
38
|
+
return overloadResponseErrors.includes(errorCode);
|
|
39
|
+
}
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
const requests = require('../../../../common/requests/cookieAuth/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
|
-
getUserEncryptedData: (email, userRole) => `${backendUrl}/saas/team-member/email/${email}/role/${userRole}/signup-data`,
|
|
15
|
-
signupUser: `${backendUrl}/_saas/guests/signup`,
|
|
16
|
-
removeAllUserTraceFromDb: userId => `${backendUrl}/saas/user/automation/${userId}`
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const invite = (invitedUser, context, { disableSendMail = true } = {}) => {
|
|
20
|
-
return requests.putRequestHandler(Endpoints.invite, invitedUser, context, {}, { disableSendMail });
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const signupUser = (signupUserModel, context) => {
|
|
24
|
-
return requests.postRequestHandler(Endpoints.signupUser, signupUserModel, context, {}, {});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const editUserRole = (userId, data, context) => {
|
|
28
|
-
return requests.patchRequestHandler(Endpoints.editUserRole(userId), context, data);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const editUserProjects = (data, context) => {
|
|
32
|
-
const params = { disableSendMail: true };
|
|
33
|
-
return requests.putRequestHandler(Endpoints.editUserProjects, data, context, {}, params);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const getUsersByProjectId = (projectId, context) => {
|
|
37
|
-
return requests.getRequestHandler(Endpoints.getByProjectId(projectId), null, context);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const getUserByEmail = (email, context) => {
|
|
41
|
-
return requests.getRequestHandler(Endpoints.getByEmail(email), null, context);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const getUserEncryptedData = (email, role, context) => {
|
|
45
|
-
return requests.getRequestHandler(Endpoints.getUserEncryptedData(email, role), null, context);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const deleteUser = (userId, context) => {
|
|
49
|
-
return requests.deleteRequestHandler(Endpoints.delete(userId), context);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const deleteUserFromSingleProject = (userId, projectId, context) => {
|
|
53
|
-
return requests.deleteRequestHandler(Endpoints.deleteSingleProject(userId, projectId), context);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const removeAllUserTraceFromDb = (userId, context) => {
|
|
57
|
-
return requests.deleteRequestHandler(Endpoints.removeAllUserTraceFromDb(userId), context);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const reinviteUser = (userId, context) => {
|
|
61
|
-
const params = { id: userId };
|
|
62
|
-
return requests.postRequestHandler(Endpoints.reinvite, {}, context, {}, params);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
module.exports = {
|
|
66
|
-
invite,
|
|
67
|
-
signupUser,
|
|
68
|
-
getUsersByProjectId,
|
|
69
|
-
getUserByEmail,
|
|
70
|
-
getUserEncryptedData,
|
|
71
|
-
deleteUser,
|
|
72
|
-
deleteUserFromSingleProject,
|
|
73
|
-
removeAllUserTraceFromDb,
|
|
74
|
-
editUserRole,
|
|
75
|
-
editUserProjects,
|
|
76
|
-
reinviteUser
|
|
77
|
-
};
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/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
|
+
getUserEncryptedData: (email, userRole) => `${backendUrl}/saas/team-member/email/${email}/role/${userRole}/signup-data`,
|
|
15
|
+
signupUser: `${backendUrl}/_saas/guests/signup`,
|
|
16
|
+
removeAllUserTraceFromDb: userId => `${backendUrl}/saas/user/automation/${userId}`
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const invite = (invitedUser, context, { disableSendMail = true } = {}) => {
|
|
20
|
+
return requests.putRequestHandler(Endpoints.invite, invitedUser, context, {}, { disableSendMail });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const signupUser = (signupUserModel, context) => {
|
|
24
|
+
return requests.postRequestHandler(Endpoints.signupUser, signupUserModel, context, {}, {});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const editUserRole = (userId, data, context) => {
|
|
28
|
+
return requests.patchRequestHandler(Endpoints.editUserRole(userId), context, data);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const editUserProjects = (data, context) => {
|
|
32
|
+
const params = { disableSendMail: true };
|
|
33
|
+
return requests.putRequestHandler(Endpoints.editUserProjects, data, context, {}, params);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getUsersByProjectId = (projectId, context) => {
|
|
37
|
+
return requests.getRequestHandler(Endpoints.getByProjectId(projectId), null, context);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getUserByEmail = (email, context) => {
|
|
41
|
+
return requests.getRequestHandler(Endpoints.getByEmail(email), null, context);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getUserEncryptedData = (email, role, context) => {
|
|
45
|
+
return requests.getRequestHandler(Endpoints.getUserEncryptedData(email, role), null, context);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const deleteUser = (userId, context) => {
|
|
49
|
+
return requests.deleteRequestHandler(Endpoints.delete(userId), context);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const deleteUserFromSingleProject = (userId, projectId, context) => {
|
|
53
|
+
return requests.deleteRequestHandler(Endpoints.deleteSingleProject(userId, projectId), context);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const removeAllUserTraceFromDb = (userId, context) => {
|
|
57
|
+
return requests.deleteRequestHandler(Endpoints.removeAllUserTraceFromDb(userId), context);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const reinviteUser = (userId, context) => {
|
|
61
|
+
const params = { id: userId };
|
|
62
|
+
return requests.postRequestHandler(Endpoints.reinvite, {}, context, {}, params);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
module.exports = {
|
|
66
|
+
invite,
|
|
67
|
+
signupUser,
|
|
68
|
+
getUsersByProjectId,
|
|
69
|
+
getUserByEmail,
|
|
70
|
+
getUserEncryptedData,
|
|
71
|
+
deleteUser,
|
|
72
|
+
deleteUserFromSingleProject,
|
|
73
|
+
removeAllUserTraceFromDb,
|
|
74
|
+
editUserRole,
|
|
75
|
+
editUserProjects,
|
|
76
|
+
reinviteUser
|
|
77
|
+
};
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
const { InviteUserModel, SignupUserModel, EditUserModel } = require('../models/users.model');
|
|
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');
|
|
8
|
-
|
|
9
|
-
const inviteUser = async (invitedUser, context, { disableSendMail } = {}) => {
|
|
10
|
-
return userAPI.invite(invitedUser, context, { disableSendMail });
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const signupUser = (signupUserModel, context) => {
|
|
14
|
-
validateType(signupUserModel, SignupUserModel);
|
|
15
|
-
return userAPI.signupUser(signupUserModel, context);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const editUserRole = async (userId, data, context) => {
|
|
19
|
-
return userAPI.editUserRole(userId, data, context);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const editUserProjects = async (editUserModel, context) => {
|
|
23
|
-
validateType(editUserModel, EditUserModel);
|
|
24
|
-
return userAPI.editUserProjects([editUserModel], context);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const getUsersByProjectId = async (projectId, context) => {
|
|
28
|
-
return userAPI.getUsersByProjectId(projectId, context);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const getUserByEmail = async (email, context) => {
|
|
32
|
-
return userAPI.getUserByEmail(email, context);
|
|
33
|
-
};
|
|
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 && userResponse.data.subuserId && userResponse.data.isVerified) {
|
|
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
|
-
|
|
67
|
-
const deleteUser = (userId, context) => {
|
|
68
|
-
return userAPI.deleteUser(userId, context);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const deleteUserFromSingleProject = (userId, projectId, context) => {
|
|
72
|
-
return userAPI.deleteUserFromSingleProject(userId, projectId, context);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const removeAllUserTraceFromDb = (userId, context) => {
|
|
76
|
-
return userAPI.removeAllUserTraceFromDb(userId, context);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const deleteUserByEmail = async (userEmail, context) => {
|
|
80
|
-
const { data: user } = await getUserByEmail(userEmail, context);
|
|
81
|
-
return deleteUser(user.subuserId, context);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const reinviteUser = (userId, context) => {
|
|
85
|
-
return userAPI.reinviteUser(userId, context);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
module.exports = {
|
|
89
|
-
inviteUser,
|
|
90
|
-
signupUser,
|
|
91
|
-
getUsersByProjectId,
|
|
92
|
-
getUserByEmail,
|
|
93
|
-
getOrCreateUser,
|
|
94
|
-
deleteUser,
|
|
95
|
-
deleteUserFromSingleProject,
|
|
96
|
-
deleteUserByEmail,
|
|
97
|
-
removeAllUserTraceFromDb,
|
|
98
|
-
editUserRole,
|
|
99
|
-
editUserProjects,
|
|
100
|
-
reinviteUser
|
|
101
|
-
};
|
|
1
|
+
const { InviteUserModel, SignupUserModel, EditUserModel } = require('../models/users.model');
|
|
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');
|
|
8
|
+
|
|
9
|
+
const inviteUser = async (invitedUser, context, { disableSendMail } = {}) => {
|
|
10
|
+
return userAPI.invite(invitedUser, context, { disableSendMail });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const signupUser = (signupUserModel, context) => {
|
|
14
|
+
validateType(signupUserModel, SignupUserModel);
|
|
15
|
+
return userAPI.signupUser(signupUserModel, context);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const editUserRole = async (userId, data, context) => {
|
|
19
|
+
return userAPI.editUserRole(userId, data, context);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const editUserProjects = async (editUserModel, context) => {
|
|
23
|
+
validateType(editUserModel, EditUserModel);
|
|
24
|
+
return userAPI.editUserProjects([editUserModel], context);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getUsersByProjectId = async (projectId, context) => {
|
|
28
|
+
return userAPI.getUsersByProjectId(projectId, context);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const getUserByEmail = async (email, context) => {
|
|
32
|
+
return userAPI.getUserByEmail(email, context);
|
|
33
|
+
};
|
|
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 && userResponse.data.subuserId && userResponse.data.isVerified) {
|
|
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
|
+
|
|
67
|
+
const deleteUser = (userId, context) => {
|
|
68
|
+
return userAPI.deleteUser(userId, context);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const deleteUserFromSingleProject = (userId, projectId, context) => {
|
|
72
|
+
return userAPI.deleteUserFromSingleProject(userId, projectId, context);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const removeAllUserTraceFromDb = (userId, context) => {
|
|
76
|
+
return userAPI.removeAllUserTraceFromDb(userId, context);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const deleteUserByEmail = async (userEmail, context) => {
|
|
80
|
+
const { data: user } = await getUserByEmail(userEmail, context);
|
|
81
|
+
return deleteUser(user.subuserId, context);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const reinviteUser = (userId, context) => {
|
|
85
|
+
return userAPI.reinviteUser(userId, context);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
inviteUser,
|
|
90
|
+
signupUser,
|
|
91
|
+
getUsersByProjectId,
|
|
92
|
+
getUserByEmail,
|
|
93
|
+
getOrCreateUser,
|
|
94
|
+
deleteUser,
|
|
95
|
+
deleteUserFromSingleProject,
|
|
96
|
+
deleteUserByEmail,
|
|
97
|
+
removeAllUserTraceFromDb,
|
|
98
|
+
editUserRole,
|
|
99
|
+
editUserProjects,
|
|
100
|
+
reinviteUser
|
|
101
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const models = require('./models/users.model');
|
|
2
|
-
const services = require('./api/users.service');
|
|
3
|
-
|
|
4
|
-
module.exports = { services, models };
|
|
1
|
+
const models = require('./models/users.model');
|
|
2
|
+
const services = require('./api/users.service');
|
|
3
|
+
|
|
4
|
+
module.exports = { services, models };
|