@getjones/test-infra 2.10.14 → 2.11.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 +30 -30
- package/src/common/commonFlows/auth/auth.js +40 -40
- package/src/common/commonFlows/index.js +4 -4
- package/src/common/commonFlows/records/records.js +102 -102
- package/src/common/consts/dashboardCharts.js +18 -18
- package/src/common/consts/recordTypes.js +5 -5
- package/src/common/consts/s3FileTypes.js +11 -11
- package/src/common/consts/userTypes.js +8 -8
- package/src/common/httpResponseStatusCodes.json +11 -11
- package/src/common/requests/apiKeyAuth/requests.js +44 -44
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/requestHandlers.js +78 -78
- package/src/common/utils/complianceUtil.js +83 -83
- package/src/common/utils/configsUtil.js +22 -22
- package/src/common/utils/dataTypeUtils.js +41 -41
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/objectUtils.js +7 -7
- package/src/common/utils/timeUtils.js +177 -177
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/defaults/configs/auditConfigs.js +91 -91
- package/src/defaults/configs/coverage.js +227 -227
- package/src/defaults/configs/polices.js +54 -54
- package/src/defaults/configs/requirement.js +32 -32
- package/src/defaults/index.js +6 -6
- package/src/env.js +57 -57
- package/src/factory/globalRecord/globalRecord.js +70 -70
- package/src/factory/index.js +8 -8
- package/src/factory/records/records.js +128 -128
- package/src/factory/users/users.js +77 -77
- package/src/index.js +89 -89
- package/src/resources/virusFile.pdf +0 -0
- 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 +82 -82
- 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 +41 -41
- package/src/saas/internal-api/accounts/consts/consts.js +6 -6
- package/src/saas/internal-api/accounts/index.js +20 -20
- 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 +38 -38
- package/src/saas/internal-api/accounts/utils/utils.js +58 -58
- package/src/saas/internal-api/agreement/api/agreement.api.js +35 -35
- package/src/saas/internal-api/agreement/api/agreement.service.js +67 -67
- package/src/saas/internal-api/agreement/consts/consts.js +8 -8
- package/src/saas/internal-api/agreement/index.js +11 -11
- package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
- package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
- package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
- package/src/saas/internal-api/auditNotes/index.js +4 -4
- package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
- package/src/saas/internal-api/auth/api/auth.api.js +27 -27
- package/src/saas/internal-api/auth/api/auth.service.js +90 -90
- 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 +5 -5
- 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 +96 -96
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +219 -219
- 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 +48 -48
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +33 -33
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +141 -141
- package/src/saas/internal-api/compliance/consts/audit.js +102 -102
- package/src/saas/internal-api/compliance/index.js +33 -33
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +94 -94
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
- package/src/saas/internal-api/compliance/utils/auditUtil.js +222 -222
- package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
- package/src/saas/internal-api/contractors/api/contractors.api.js +166 -166
- package/src/saas/internal-api/contractors/api/contractors.service.js +198 -198
- package/src/saas/internal-api/contractors/consts/consts.js +6 -6
- package/src/saas/internal-api/contractors/index.js +9 -9
- package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
- 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/dashboard/api/recordList.api.js +38 -38
- package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
- package/src/saas/internal-api/dashboard/index.js +5 -5
- package/src/saas/internal-api/dashboard/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 +147 -147
- package/src/saas/internal-api/dbEmails/consts/consts.js +53 -53
- package/src/saas/internal-api/dbEmails/index.js +6 -6
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
- package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
- package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
- package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
- package/src/saas/internal-api/emailCustomization/index.js +3 -3
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +106 -106
- 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 +60 -60
- package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
- 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 +35 -35
- 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 +41 -41
- package/src/saas/internal-api/projects/utils/utils.js +156 -156
- 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 +64 -64
- 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 +78 -78
- package/src/saas/internal-api/requests/api/requests.service.js +151 -151
- package/src/saas/internal-api/requests/index.js +16 -16
- package/src/saas/internal-api/requests/models/create.request.model.js +33 -33
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/inner.page.request.criteria.model.js +17 -17
- 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/requestsTable/api/requests.table.api.js +20 -20
- package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
- package/src/saas/internal-api/requestsTable/index.js +3 -3
- package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
- package/src/saas/internal-api/requirements/api/requirements.service.js +134 -134
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +5 -6
- package/src/saas/internal-api/requirements/consts/consts.js +6 -6
- package/src/saas/internal-api/requirements/index.js +10 -10
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
- package/src/saas/internal-api/requirements/models/policy.model.js +33 -33
- package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
- package/src/saas/internal-api/requirements/utils/utils.js +102 -115
- 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 -19
- package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +25 -25
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +32 -32
- package/src/saas/internal-api/uploadFiles/consts.js +12 -12
- package/src/saas/internal-api/uploadFiles/index.js +3 -3
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +32 -32
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +78 -78
- package/src/saas/internal-api/users/api/users.api.js +109 -109
- package/src/saas/internal-api/users/api/users.service.js +198 -198
- package/src/saas/internal-api/users/index.js +16 -16
- package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
- package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
- package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
- package/src/saas/internal-api/users/models/users.model.js +41 -41
- package/src/saas/internal-api/users/utils/util.js +39 -39
- 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/coi/coi.api.js +20 -20
- package/src/saas/openapi/coi/coi.service.js +13 -13
- package/src/saas/openapi/projects/projects.api.js +83 -83
- package/src/saas/openapi/projects/projects.service.js +64 -64
- package/src/saas/openapi/requests/index.js +7 -7
- package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
- package/src/saas/openapi/requests/models/update.request.model.js +35 -35
- package/src/saas/openapi/requests/requests.api.js +76 -76
- package/src/saas/openapi/requests/requests.service.js +65 -65
- 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 +32 -32
- package/src/saas/openapi/requirements/requirements.service.js +37 -37
- package/src/saas/openapi/tabs/index.js +6 -6
- package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
- package/src/saas/openapi/tabs/tabs.api.js +27 -27
- package/src/saas/openapi/tabs/tabs.service.js +19 -19
- package/src/saas/openapi/users/user.model.js +10 -10
- package/src/saas/openapi/users/users.api.js +33 -33
- package/src/saas/openapi/users/users.service.js +41 -41
- package/tests/env.test.js +40 -40
- package/tests/validation.test.js +83 -83
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const requests = require('../../../common/requests/apiKeyAuth/requests');
|
|
2
|
-
const { openapiUrl, backendUrl } = require('../../../env').getEnv();
|
|
3
|
-
|
|
4
|
-
const Endpoints = {
|
|
5
|
-
delete: tabId => `${openapiUrl}/tabs/${tabId}`,
|
|
6
|
-
get: tabId => `${backendUrl}/tabs/${tabId}`,
|
|
7
|
-
create: projectId => `${openapiUrl}/properties/${projectId}/tab`,
|
|
8
|
-
getAll: `${openapiUrl}/tabs/all`,
|
|
9
|
-
getProjectTabs: projectId => `${openapiUrl}/properties/${projectId}/tabs`
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const deleteTabById = (tabId, apiKey) => {
|
|
13
|
-
return requests.deleteRequestHandler(Endpoints.delete(tabId), apiKey);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const createTab = (projectId, createTabModel, apiKey) => {
|
|
17
|
-
return requests.postRequestHandler(Endpoints.create(projectId), apiKey, createTabModel);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getAllTabs = (apiKey, params) => {
|
|
21
|
-
return requests.getRequestHandler(Endpoints.getAll, apiKey, params);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const getProjectTabs = (projectId, apiKey) => {
|
|
25
|
-
return requests.getRequestHandler(Endpoints.getProjectTabs(projectId), apiKey);
|
|
26
|
-
};
|
|
27
|
-
module.exports = { deleteTabById, createTab, getAllTabs, getProjectTabs };
|
|
1
|
+
const requests = require('../../../common/requests/apiKeyAuth/requests');
|
|
2
|
+
const { openapiUrl, backendUrl } = require('../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
delete: tabId => `${openapiUrl}/tabs/${tabId}`,
|
|
6
|
+
get: tabId => `${backendUrl}/tabs/${tabId}`,
|
|
7
|
+
create: projectId => `${openapiUrl}/properties/${projectId}/tab`,
|
|
8
|
+
getAll: `${openapiUrl}/tabs/all`,
|
|
9
|
+
getProjectTabs: projectId => `${openapiUrl}/properties/${projectId}/tabs`
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const deleteTabById = (tabId, apiKey) => {
|
|
13
|
+
return requests.deleteRequestHandler(Endpoints.delete(tabId), apiKey);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const createTab = (projectId, createTabModel, apiKey) => {
|
|
17
|
+
return requests.postRequestHandler(Endpoints.create(projectId), apiKey, createTabModel);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getAllTabs = (apiKey, params) => {
|
|
21
|
+
return requests.getRequestHandler(Endpoints.getAll, apiKey, params);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const getProjectTabs = (projectId, apiKey) => {
|
|
25
|
+
return requests.getRequestHandler(Endpoints.getProjectTabs(projectId), apiKey);
|
|
26
|
+
};
|
|
27
|
+
module.exports = { deleteTabById, createTab, getAllTabs, getProjectTabs };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const tabsApi = require('./tabs.api');
|
|
2
|
-
|
|
3
|
-
const deleteTabById = (tabId, apiKey) => {
|
|
4
|
-
return tabsApi.deleteTabById(tabId, apiKey);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const createTab = (projectId, createTabModel, apiKey) => {
|
|
8
|
-
return tabsApi.createTab(projectId, createTabModel, apiKey);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const getAllTabs = (apiKey, params) => {
|
|
12
|
-
return tabsApi.getAllTabs(apiKey, params);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const getProjectTabs = (projectId, apiKey) => {
|
|
16
|
-
return tabsApi.getProjectTabs(projectId, apiKey);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
module.exports = { deleteTabById, createTab, getAllTabs, getProjectTabs };
|
|
1
|
+
const tabsApi = require('./tabs.api');
|
|
2
|
+
|
|
3
|
+
const deleteTabById = (tabId, apiKey) => {
|
|
4
|
+
return tabsApi.deleteTabById(tabId, apiKey);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const createTab = (projectId, createTabModel, apiKey) => {
|
|
8
|
+
return tabsApi.createTab(projectId, createTabModel, apiKey);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getAllTabs = (apiKey, params) => {
|
|
12
|
+
return tabsApi.getAllTabs(apiKey, params);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getProjectTabs = (projectId, apiKey) => {
|
|
16
|
+
return tabsApi.getProjectTabs(projectId, apiKey);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = { deleteTabById, createTab, getAllTabs, getProjectTabs };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
class ApiUserModel {
|
|
2
|
-
constructor(user = {}) {
|
|
3
|
-
this.fullName = user.fullName;
|
|
4
|
-
this.email = user.email;
|
|
5
|
-
this.role = user.role;
|
|
6
|
-
this.properties = user.properties;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = { ApiUserModel };
|
|
1
|
+
class ApiUserModel {
|
|
2
|
+
constructor(user = {}) {
|
|
3
|
+
this.fullName = user.fullName;
|
|
4
|
+
this.email = user.email;
|
|
5
|
+
this.role = user.role;
|
|
6
|
+
this.properties = user.properties;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { ApiUserModel };
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const requests = require('../../../common/requests/apiKeyAuth/requests');
|
|
2
|
-
const { openapiUrl } = require('../../../env').getEnv();
|
|
3
|
-
|
|
4
|
-
const Endpoints = {
|
|
5
|
-
createUser: `${openapiUrl}/users`,
|
|
6
|
-
updateUser: userId => `${openapiUrl}/users/${userId}`,
|
|
7
|
-
deleteUser: userId => `${openapiUrl}/users/${userId}`,
|
|
8
|
-
getUser: `${openapiUrl}/users`,
|
|
9
|
-
getAllUsers: `${openapiUrl}/users/all`
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const createUser = async (apiKey, user) => {
|
|
14
|
-
return requests.postRequestHandler(Endpoints.createUser, apiKey, user).then(res => res);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const updateUser = async (apiKey, user, userId) => {
|
|
18
|
-
return requests.patchRequestHandler(Endpoints.updateUser(userId), apiKey, user).then(res => res);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const deleteUser = async (apiKey, userId) => {
|
|
22
|
-
return requests.deleteRequestHandler(Endpoints.deleteUser(userId), apiKey).then(res => res);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getUser = async (apiKey, params) => {
|
|
26
|
-
return requests.getRequestHandler(Endpoints.getUser, apiKey, params).then(res => res);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const getAllUsers = async (apiKey, params) => {
|
|
30
|
-
return requests.getRequestHandler(Endpoints.getAllUsers, apiKey, params).then(res => res);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
module.exports = { createUser, updateUser, deleteUser, getUser, getAllUsers };
|
|
1
|
+
const requests = require('../../../common/requests/apiKeyAuth/requests');
|
|
2
|
+
const { openapiUrl } = require('../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
createUser: `${openapiUrl}/users`,
|
|
6
|
+
updateUser: userId => `${openapiUrl}/users/${userId}`,
|
|
7
|
+
deleteUser: userId => `${openapiUrl}/users/${userId}`,
|
|
8
|
+
getUser: `${openapiUrl}/users`,
|
|
9
|
+
getAllUsers: `${openapiUrl}/users/all`
|
|
10
|
+
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const createUser = async (apiKey, user) => {
|
|
14
|
+
return requests.postRequestHandler(Endpoints.createUser, apiKey, user).then(res => res);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const updateUser = async (apiKey, user, userId) => {
|
|
18
|
+
return requests.patchRequestHandler(Endpoints.updateUser(userId), apiKey, user).then(res => res);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const deleteUser = async (apiKey, userId) => {
|
|
22
|
+
return requests.deleteRequestHandler(Endpoints.deleteUser(userId), apiKey).then(res => res);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getUser = async (apiKey, params) => {
|
|
26
|
+
return requests.getRequestHandler(Endpoints.getUser, apiKey, params).then(res => res);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getAllUsers = async (apiKey, params) => {
|
|
30
|
+
return requests.getRequestHandler(Endpoints.getAllUsers, apiKey, params).then(res => res);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = { createUser, updateUser, deleteUser, getUser, getAllUsers };
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
const { validateType } = require('../../../common/validations/typeValidations');
|
|
2
|
-
const { ApiUserModel } = require('./user.model');
|
|
3
|
-
const usersApi = require('./users.api');
|
|
4
|
-
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
5
|
-
|
|
6
|
-
const createUser = async (apiKey, user) => {
|
|
7
|
-
validateType(user, ApiUserModel);
|
|
8
|
-
const response = await usersApi.createUser(apiKey, user);
|
|
9
|
-
validateResponse(response, httpResponseStatusCodes.OK, 'Create user has failed');
|
|
10
|
-
return response.data;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const updateUser = async (apiKey, user, userId) => {
|
|
14
|
-
const response = await usersApi.updateUser(apiKey, user, userId);
|
|
15
|
-
validateResponse(response, httpResponseStatusCodes.OK, 'Update user has failed');
|
|
16
|
-
return response.data;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const deleteUser = async (apiKey, userId) => {
|
|
20
|
-
const response = await usersApi.deleteUser(apiKey, userId);
|
|
21
|
-
validateResponse(response, httpResponseStatusCodes.OK, 'Delete user has failed');
|
|
22
|
-
return response.data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getUserByEmailId = async (apiKey, email) => {
|
|
26
|
-
const response = await usersApi.getUser(apiKey, { email });
|
|
27
|
-
return response;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const getAllUsers = async (apiKey, { before, after, propertyId } = {}) => {
|
|
31
|
-
const response = await usersApi.getAllUsers(apiKey, { before, after, propertyId });
|
|
32
|
-
return response;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const validateResponse = (response, expectedStatus, errorMessage) => {
|
|
36
|
-
if (response.status !== expectedStatus) {
|
|
37
|
-
throw new Error(`${errorMessage}\n${JSON.stringify(response.status)}`);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
module.exports = { createUser, updateUser, deleteUser, getUserByEmailId, getAllUsers };
|
|
1
|
+
const { validateType } = require('../../../common/validations/typeValidations');
|
|
2
|
+
const { ApiUserModel } = require('./user.model');
|
|
3
|
+
const usersApi = require('./users.api');
|
|
4
|
+
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
5
|
+
|
|
6
|
+
const createUser = async (apiKey, user) => {
|
|
7
|
+
validateType(user, ApiUserModel);
|
|
8
|
+
const response = await usersApi.createUser(apiKey, user);
|
|
9
|
+
validateResponse(response, httpResponseStatusCodes.OK, 'Create user has failed');
|
|
10
|
+
return response.data;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const updateUser = async (apiKey, user, userId) => {
|
|
14
|
+
const response = await usersApi.updateUser(apiKey, user, userId);
|
|
15
|
+
validateResponse(response, httpResponseStatusCodes.OK, 'Update user has failed');
|
|
16
|
+
return response.data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const deleteUser = async (apiKey, userId) => {
|
|
20
|
+
const response = await usersApi.deleteUser(apiKey, userId);
|
|
21
|
+
validateResponse(response, httpResponseStatusCodes.OK, 'Delete user has failed');
|
|
22
|
+
return response.data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getUserByEmailId = async (apiKey, email) => {
|
|
26
|
+
const response = await usersApi.getUser(apiKey, { email });
|
|
27
|
+
return response;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getAllUsers = async (apiKey, { before, after, propertyId } = {}) => {
|
|
31
|
+
const response = await usersApi.getAllUsers(apiKey, { before, after, propertyId });
|
|
32
|
+
return response;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const validateResponse = (response, expectedStatus, errorMessage) => {
|
|
36
|
+
if (response.status !== expectedStatus) {
|
|
37
|
+
throw new Error(`${errorMessage}\n${JSON.stringify(response.status)}`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
module.exports = { createUser, updateUser, deleteUser, getUserByEmailId, getAllUsers };
|
package/tests/env.test.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
const chai = require('chai');
|
|
2
|
-
|
|
3
|
-
const { expect } = chai;
|
|
4
|
-
|
|
5
|
-
const env = require('../src/env');
|
|
6
|
-
|
|
7
|
-
describe('Env | Test Core Logic', async function() {
|
|
8
|
-
it('Missing Configuration', async function() {
|
|
9
|
-
const expectedValidationError = 'Missing required configuration on your environment variables. The missing env-vars are "backendUrl,openapiUrl,environment".';
|
|
10
|
-
|
|
11
|
-
const badInput = {
|
|
12
|
-
credentials: { superUser: 'TestSuperUser', superUserPassword: 'TestSuperUserPassword' }
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
expect(() => env.init(badInput)).to.throw(expectedValidationError);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Assign Configuration', async function() {
|
|
19
|
-
const expectedSanityAssignVariables = {
|
|
20
|
-
'backendUrl': 'Test',
|
|
21
|
-
'openapiUrl': 'openapi',
|
|
22
|
-
'credentials': {
|
|
23
|
-
'superUser': 'TestSuperUser',
|
|
24
|
-
'superUserPassword': 'TestSuperUserPassword'
|
|
25
|
-
},
|
|
26
|
-
'environment': 'dev',
|
|
27
|
-
'accountCreationSecret': null
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
env.init({
|
|
31
|
-
backendUrl: 'Test',
|
|
32
|
-
openapiUrl: 'openapi',
|
|
33
|
-
environment: 'dev',
|
|
34
|
-
credentials: { superUser: 'TestSuperUser', superUserPassword: 'TestSuperUserPassword' }
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const envVariables = env.getEnv();
|
|
38
|
-
expect(envVariables).to.eql(expectedSanityAssignVariables, 'Assign configuration did not work properly');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
1
|
+
const chai = require('chai');
|
|
2
|
+
|
|
3
|
+
const { expect } = chai;
|
|
4
|
+
|
|
5
|
+
const env = require('../src/env');
|
|
6
|
+
|
|
7
|
+
describe('Env | Test Core Logic', async function() {
|
|
8
|
+
it('Missing Configuration', async function() {
|
|
9
|
+
const expectedValidationError = 'Missing required configuration on your environment variables. The missing env-vars are "backendUrl,openapiUrl,environment".';
|
|
10
|
+
|
|
11
|
+
const badInput = {
|
|
12
|
+
credentials: { superUser: 'TestSuperUser', superUserPassword: 'TestSuperUserPassword' }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
expect(() => env.init(badInput)).to.throw(expectedValidationError);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('Assign Configuration', async function() {
|
|
19
|
+
const expectedSanityAssignVariables = {
|
|
20
|
+
'backendUrl': 'Test',
|
|
21
|
+
'openapiUrl': 'openapi',
|
|
22
|
+
'credentials': {
|
|
23
|
+
'superUser': 'TestSuperUser',
|
|
24
|
+
'superUserPassword': 'TestSuperUserPassword'
|
|
25
|
+
},
|
|
26
|
+
'environment': 'dev',
|
|
27
|
+
'accountCreationSecret': null
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
env.init({
|
|
31
|
+
backendUrl: 'Test',
|
|
32
|
+
openapiUrl: 'openapi',
|
|
33
|
+
environment: 'dev',
|
|
34
|
+
credentials: { superUser: 'TestSuperUser', superUserPassword: 'TestSuperUserPassword' }
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const envVariables = env.getEnv();
|
|
38
|
+
expect(envVariables).to.eql(expectedSanityAssignVariables, 'Assign configuration did not work properly');
|
|
39
|
+
});
|
|
40
|
+
});
|
package/tests/validation.test.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
const { expect } = require('chai');
|
|
2
|
-
|
|
3
|
-
const { validateDateString, validateInteger, validateArray } = require('../src/common/validations/typeValidations');
|
|
4
|
-
const VALID_DATE_STRINGS = Object.freeze([
|
|
5
|
-
'2022-08-03T11:47:07.499Z',
|
|
6
|
-
'2022-08-03T14:16:27.000+0000'
|
|
7
|
-
|
|
8
|
-
]);
|
|
9
|
-
const INVALID_DATE_STRINGS = Object.freeze([
|
|
10
|
-
'2022-08-03T11:47:07.',
|
|
11
|
-
'2022-08-03T11:47:07.499Z1',
|
|
12
|
-
'2022-08-03T11:47:07.Z',
|
|
13
|
-
'2022-08-03T11:47:07.499Za',
|
|
14
|
-
'2022-0803T11:47:07.499Z',
|
|
15
|
-
'2022-08-03T100:47:07.499Z',
|
|
16
|
-
'2022-08-03T11:4:07.499Z',
|
|
17
|
-
'2022-08-03T11:47:7z.499Z',
|
|
18
|
-
'2022-08-03T11:47:07.a499Z',
|
|
19
|
-
'2022-0803T14:16:27.000+0000',
|
|
20
|
-
'2022-08-03T14:16:27.000+000a',
|
|
21
|
-
'2022-08-03T14:16:27.000+0000c',
|
|
22
|
-
'2022-08-0314:16:27.000+0000',
|
|
23
|
-
'2022-08-03x14:16:27.000+0000',
|
|
24
|
-
'2022-08-03a14:16:27.000+0000',
|
|
25
|
-
'2022-08-03T14:16:2.000+0000',
|
|
26
|
-
'asd1q2123'
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
describe('Validation | Test Validation functions', function() {
|
|
30
|
-
it('Should validate date strings', () => {
|
|
31
|
-
for (const dateString of VALID_DATE_STRINGS) {
|
|
32
|
-
expect(() => validateDateString(dateString), `Expect string: '${dateString}' to pass date validation.`).to.not.throw(TypeError);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('Should throw error for invalid date strings', () => {
|
|
37
|
-
for (const dateString of INVALID_DATE_STRINGS) {
|
|
38
|
-
expect(() => validateDateString(dateString), `Expect string: '${dateString}' to fail date validation.`).to.throw(TypeError);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('Should throw error for invalid integers', () => {
|
|
43
|
-
for (let i = -1; i < 3 ; i++) {
|
|
44
|
-
const number = i.toString();
|
|
45
|
-
expect(() => validateInteger(number)).to.throw(TypeError);
|
|
46
|
-
expect(() => validateInteger(number, { min: 4 })).to.throw(TypeError);
|
|
47
|
-
expect(() => validateInteger(number, { max: -11 })).to.throw(TypeError);
|
|
48
|
-
expect(() => validateInteger(number, { min: -100, max: -5 })).to.throw(TypeError);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('Should throw error for out of range integers', () => {
|
|
53
|
-
for (let i = -1; i < 3 ; i++) {
|
|
54
|
-
expect(() => validateInteger(i, { min: 4 })).to.throw(RangeError);
|
|
55
|
-
expect(() => validateInteger(i, { max: -11 })).to.throw(RangeError);
|
|
56
|
-
expect(() => validateInteger(i, { min: -100, max: -5 })).to.throw(RangeError);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('Should throw error for invalid arrays', () => {
|
|
61
|
-
expect(() => validateArray(undefined)).to.throw(TypeError);
|
|
62
|
-
expect(() => validateArray(null)).to.throw(TypeError);
|
|
63
|
-
expect(() => validateArray()).to.throw(TypeError);
|
|
64
|
-
expect(() => validateArray({})).to.throw(TypeError);
|
|
65
|
-
expect(() => validateArray({ 1: 2 })).to.throw(TypeError);
|
|
66
|
-
expect(() => validateArray(new Set())).to.throw(TypeError);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('Should not throw error for valid integers', () => {
|
|
70
|
-
for (let i = -1; i < 3 ; i++) {
|
|
71
|
-
expect(() => validateInteger(i)).to.not.throw();
|
|
72
|
-
expect(() => validateInteger(i, { min: -4 })).to.not.throw();
|
|
73
|
-
expect(() => validateInteger(i, { max: 5 })).to.not.throw();
|
|
74
|
-
expect(() => validateInteger(i, { min: -100, max: 4 })).to.not.throw();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('Should not throw error for valid arrays', () => {
|
|
79
|
-
expect(() => validateArray([])).to.not.throw(TypeError);
|
|
80
|
-
expect(() => validateArray([1, 2, 3])).to.not.throw(TypeError);
|
|
81
|
-
expect(() => validateArray(['a'])).to.not.throw(TypeError);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
1
|
+
const { expect } = require('chai');
|
|
2
|
+
|
|
3
|
+
const { validateDateString, validateInteger, validateArray } = require('../src/common/validations/typeValidations');
|
|
4
|
+
const VALID_DATE_STRINGS = Object.freeze([
|
|
5
|
+
'2022-08-03T11:47:07.499Z',
|
|
6
|
+
'2022-08-03T14:16:27.000+0000'
|
|
7
|
+
|
|
8
|
+
]);
|
|
9
|
+
const INVALID_DATE_STRINGS = Object.freeze([
|
|
10
|
+
'2022-08-03T11:47:07.',
|
|
11
|
+
'2022-08-03T11:47:07.499Z1',
|
|
12
|
+
'2022-08-03T11:47:07.Z',
|
|
13
|
+
'2022-08-03T11:47:07.499Za',
|
|
14
|
+
'2022-0803T11:47:07.499Z',
|
|
15
|
+
'2022-08-03T100:47:07.499Z',
|
|
16
|
+
'2022-08-03T11:4:07.499Z',
|
|
17
|
+
'2022-08-03T11:47:7z.499Z',
|
|
18
|
+
'2022-08-03T11:47:07.a499Z',
|
|
19
|
+
'2022-0803T14:16:27.000+0000',
|
|
20
|
+
'2022-08-03T14:16:27.000+000a',
|
|
21
|
+
'2022-08-03T14:16:27.000+0000c',
|
|
22
|
+
'2022-08-0314:16:27.000+0000',
|
|
23
|
+
'2022-08-03x14:16:27.000+0000',
|
|
24
|
+
'2022-08-03a14:16:27.000+0000',
|
|
25
|
+
'2022-08-03T14:16:2.000+0000',
|
|
26
|
+
'asd1q2123'
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
describe('Validation | Test Validation functions', function() {
|
|
30
|
+
it('Should validate date strings', () => {
|
|
31
|
+
for (const dateString of VALID_DATE_STRINGS) {
|
|
32
|
+
expect(() => validateDateString(dateString), `Expect string: '${dateString}' to pass date validation.`).to.not.throw(TypeError);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('Should throw error for invalid date strings', () => {
|
|
37
|
+
for (const dateString of INVALID_DATE_STRINGS) {
|
|
38
|
+
expect(() => validateDateString(dateString), `Expect string: '${dateString}' to fail date validation.`).to.throw(TypeError);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('Should throw error for invalid integers', () => {
|
|
43
|
+
for (let i = -1; i < 3 ; i++) {
|
|
44
|
+
const number = i.toString();
|
|
45
|
+
expect(() => validateInteger(number)).to.throw(TypeError);
|
|
46
|
+
expect(() => validateInteger(number, { min: 4 })).to.throw(TypeError);
|
|
47
|
+
expect(() => validateInteger(number, { max: -11 })).to.throw(TypeError);
|
|
48
|
+
expect(() => validateInteger(number, { min: -100, max: -5 })).to.throw(TypeError);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('Should throw error for out of range integers', () => {
|
|
53
|
+
for (let i = -1; i < 3 ; i++) {
|
|
54
|
+
expect(() => validateInteger(i, { min: 4 })).to.throw(RangeError);
|
|
55
|
+
expect(() => validateInteger(i, { max: -11 })).to.throw(RangeError);
|
|
56
|
+
expect(() => validateInteger(i, { min: -100, max: -5 })).to.throw(RangeError);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('Should throw error for invalid arrays', () => {
|
|
61
|
+
expect(() => validateArray(undefined)).to.throw(TypeError);
|
|
62
|
+
expect(() => validateArray(null)).to.throw(TypeError);
|
|
63
|
+
expect(() => validateArray()).to.throw(TypeError);
|
|
64
|
+
expect(() => validateArray({})).to.throw(TypeError);
|
|
65
|
+
expect(() => validateArray({ 1: 2 })).to.throw(TypeError);
|
|
66
|
+
expect(() => validateArray(new Set())).to.throw(TypeError);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('Should not throw error for valid integers', () => {
|
|
70
|
+
for (let i = -1; i < 3 ; i++) {
|
|
71
|
+
expect(() => validateInteger(i)).to.not.throw();
|
|
72
|
+
expect(() => validateInteger(i, { min: -4 })).to.not.throw();
|
|
73
|
+
expect(() => validateInteger(i, { max: 5 })).to.not.throw();
|
|
74
|
+
expect(() => validateInteger(i, { min: -100, max: 4 })).to.not.throw();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('Should not throw error for valid arrays', () => {
|
|
79
|
+
expect(() => validateArray([])).to.not.throw(TypeError);
|
|
80
|
+
expect(() => validateArray([1, 2, 3])).to.not.throw(TypeError);
|
|
81
|
+
expect(() => validateArray(['a'])).to.not.throw(TypeError);
|
|
82
|
+
});
|
|
83
|
+
});
|