@getjones/test-infra 1.0.14 → 1.1.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 +1 -1
- package/src/{exceptions → common/exceptions}/notFoundError.js +2 -1
- package/src/env.js +6 -1
- package/src/index.js +19 -17
- package/src/{internal-api/accounts → saas/internal-api/accounts/api}/core/accounts.core.api.js +2 -2
- package/src/{internal-api/accounts → saas/internal-api/accounts/api}/core/accounts.core.setup.js +14 -21
- package/src/{internal-api/accounts → saas/internal-api/accounts/api}/openapi/accounts.openapi.api.js +2 -2
- package/src/{internal-api/accounts → saas/internal-api/accounts/api}/openapi/accounts.openapi.setup.js +7 -1
- package/src/{internal-api/accounts → saas/internal-api/accounts/api}/settings/settings.api.js +5 -4
- package/src/saas/internal-api/accounts/api/settings/settings.setup.js +23 -0
- package/src/saas/internal-api/accounts/index.js +19 -0
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -0
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +8 -0
- package/src/{internal-api/auth → saas/internal-api/auth/api}/auth.api.js +2 -2
- package/src/{internal-api/auth → saas/internal-api/auth/api}/auth.setup.js +1 -6
- package/src/saas/internal-api/auth/index.js +3 -0
- package/src/{internal-api → saas/internal-api}/contractors/api/contractors.api.js +1 -1
- package/src/{internal-api → saas/internal-api}/contractors/api/contractors.setup.js +1 -1
- package/src/{internal-api → saas/internal-api}/contractors/index.js +2 -2
- package/src/{internal-api → saas/internal-api}/contractors/models/create.contractor.model.js +1 -1
- package/src/{internal-api/projects → saas/internal-api/projects/api}/projects.api.js +2 -2
- package/src/{internal-api/projects → saas/internal-api/projects/api}/projects.setup.js +7 -6
- package/src/saas/internal-api/projects/index.js +6 -0
- package/src/saas/internal-api/projects/models/create.project.model.js +26 -0
- package/src/{internal-api → saas/internal-api}/requirements/api/requirements.api.js +1 -1
- package/src/{internal-api → saas/internal-api}/requirements/api/requirements.setup.js +1 -1
- package/src/{internal-api → saas/internal-api}/requirements/index.js +2 -2
- package/src/{internal-api → saas/internal-api}/requirements/models/create.requirement.model.js +1 -1
- package/src/{internal-api/tabs → saas/internal-api/tabs/api}/tabs.api.js +2 -2
- package/src/saas/internal-api/tabs/api/tabs.setup.js +39 -0
- package/src/saas/internal-api/tabs/index.js +3 -0
- package/src/saas/openapi/common/requests.js +55 -0
- package/src/saas/openapi/tabs/tabs.api.js +13 -0
- package/src/saas/openapi/tabs/tabs.setup.js +7 -0
- package/tests/env.test.js +14 -12
- package/src/internal-api/accounts/settings/settings.setup.js +0 -22
- package/src/internal-api/tabs/tabs.setup.js +0 -16
- /package/src/{internal-api/common/validations.js → common/validations/typeValidations.js} +0 -0
- /package/src/{internal-api → saas/internal-api}/common/requests.js +0 -0
package/package.json
CHANGED
package/src/env.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let privateMembers = {
|
|
2
2
|
backendUrl: null,
|
|
3
|
+
openapiUrl: null,
|
|
3
4
|
credentials: null,
|
|
4
5
|
environment: null,
|
|
5
6
|
accountCreationSecret: null,
|
|
@@ -7,7 +8,11 @@ let privateMembers = {
|
|
|
7
8
|
|
|
8
9
|
const init = conf => {
|
|
9
10
|
privateMembers = Object.assign(privateMembers, conf);
|
|
10
|
-
requiredValidation({
|
|
11
|
+
requiredValidation({
|
|
12
|
+
backendUrl: privateMembers.backendUrl,
|
|
13
|
+
openapiUrl: privateMembers.openapiUrl,
|
|
14
|
+
environment: privateMembers.environment
|
|
15
|
+
});
|
|
11
16
|
};
|
|
12
17
|
|
|
13
18
|
const requiredValidation = object => {
|
package/src/index.js
CHANGED
|
@@ -2,26 +2,21 @@ const env = require('./env');
|
|
|
2
2
|
|
|
3
3
|
const init = conf => {
|
|
4
4
|
env.init(conf);
|
|
5
|
+
const internalAPI = getInternalAPI();
|
|
6
|
+
const openAPI = getOpenAPI();
|
|
7
|
+
return { internalAPI, openAPI };
|
|
8
|
+
};
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
const getInternalAPI = () => {
|
|
7
11
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const accountsOpenAPI = require('./internal-api/accounts/openapi/accounts.openapi.setup');
|
|
12
|
+
const auth = require('./saas/internal-api/auth');
|
|
13
|
+
const accounts = require('./saas/internal-api/accounts');
|
|
11
14
|
|
|
12
|
-
const projects = require('./internal-api/projects
|
|
13
|
-
const tabs = require('./internal-api/tabs
|
|
14
|
-
const requirements = require('./internal-api/requirements');
|
|
15
|
-
const contractors = require('./internal-api/contractors');
|
|
15
|
+
const projects = require('./saas/internal-api/projects');
|
|
16
|
+
const tabs = require('./saas/internal-api/tabs');
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
settings: accountsSettings,
|
|
20
|
-
openAPI: accountsOpenAPI,
|
|
21
|
-
accountsCore,
|
|
22
|
-
accountsSettings,
|
|
23
|
-
accountsOpenAPI
|
|
24
|
-
};
|
|
18
|
+
const requirements = require('./saas/internal-api/requirements');
|
|
19
|
+
const contractors = require('./saas/internal-api/contractors');
|
|
25
20
|
|
|
26
21
|
const internalAPI = {
|
|
27
22
|
auth,
|
|
@@ -31,7 +26,14 @@ const init = conf => {
|
|
|
31
26
|
requirements,
|
|
32
27
|
contractors
|
|
33
28
|
};
|
|
34
|
-
return
|
|
29
|
+
return internalAPI;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getOpenAPI = () => {
|
|
33
|
+
const tabs = require('./saas/openapi/tabs/tabs.setup');
|
|
34
|
+
const openAPI = { tabs };
|
|
35
|
+
return openAPI;
|
|
36
|
+
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
module.exports = init;
|
package/src/{internal-api/accounts → saas/internal-api/accounts/api}/core/accounts.core.api.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const requests = require('
|
|
2
|
-
const { backendUrl } = require('
|
|
1
|
+
const requests = require('../../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
getAccount: `${backendUrl}/saas/accounts`,
|
package/src/{internal-api/accounts → saas/internal-api/accounts/api}/core/accounts.core.setup.js
RENAMED
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
const env = require('
|
|
1
|
+
const env = require('../../../../../env');
|
|
2
2
|
const accountsAPI = require('./accounts.core.api');
|
|
3
|
+
const CreateAccountModel = require('../../models/core/create.account.model');
|
|
4
|
+
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
3
5
|
|
|
4
|
-
const {
|
|
5
|
-
const { NotFoundError } = require('
|
|
6
|
-
|
|
6
|
+
const { accountCreationSecret } = env.getEnv();
|
|
7
|
+
const { NotFoundError } = require('../../../../../common/exceptions/notFoundError');
|
|
8
|
+
|
|
9
|
+
const createAccount = async (createAccountModel, context) => {
|
|
10
|
+
validateType(createAccountModel, CreateAccountModel);
|
|
7
11
|
|
|
8
|
-
const createAccount = async (email, accountName, context,
|
|
9
|
-
password = credentials.strongPassword,
|
|
10
|
-
propertyType = PROPERTY_TYPE) => {
|
|
11
12
|
env.requiredValidation({
|
|
12
13
|
accountCreationSecret: accountCreationSecret,
|
|
13
|
-
'credentials.strongPassword': password
|
|
14
|
+
'credentials.strongPassword': createAccountModel.password
|
|
14
15
|
});
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
companyName: accountName,
|
|
18
|
-
email: email,
|
|
19
|
-
password: password,
|
|
20
|
-
verifyPassword: password,
|
|
21
|
-
secret: accountCreationSecret,
|
|
22
|
-
userType: propertyType
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return await accountsAPI.create(newAccount, context);
|
|
17
|
+
return await accountsAPI.create(createAccountModel, context);
|
|
26
18
|
};
|
|
27
19
|
|
|
28
20
|
const getAccount = async (accountName, context) => {
|
|
@@ -39,14 +31,15 @@ const getAccount = async (accountName, context) => {
|
|
|
39
31
|
return existingAccounts[0];
|
|
40
32
|
};
|
|
41
33
|
|
|
42
|
-
const getOrCreateAccount = async (
|
|
43
|
-
|
|
34
|
+
const getOrCreateAccount = async (createAccountModel, context) => {
|
|
35
|
+
validateType(createAccountModel, CreateAccountModel);
|
|
36
|
+
const existingAccount = await getAccount(createAccountModel.companyName, context);
|
|
44
37
|
|
|
45
38
|
if (existingAccount) {
|
|
46
39
|
return existingAccount;
|
|
47
40
|
}
|
|
48
41
|
|
|
49
|
-
return await createAccount(
|
|
42
|
+
return await createAccount(createAccountModel, context);
|
|
50
43
|
};
|
|
51
44
|
|
|
52
45
|
const getAccountId = async (accountName, context) => {
|
package/src/{internal-api/accounts → saas/internal-api/accounts/api}/openapi/accounts.openapi.api.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const requests = require('
|
|
2
|
-
const { backendUrl } = require('
|
|
1
|
+
const requests = require('../../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
createApiKey: `${backendUrl}/saas/api-keys`,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
const accountsAPI = require('./accounts.openapi.api');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
|
|
4
|
+
const generateApiKeyValue = accountName => {
|
|
5
|
+
return crypto.createHash('sha256').update(accountName).digest('base64');
|
|
6
|
+
};
|
|
2
7
|
|
|
3
8
|
const createApiKey = async (accountId, apiKeyValue, context) => {
|
|
4
9
|
const data = { apiKeyValue, accountId };
|
|
@@ -39,5 +44,6 @@ module.exports = {
|
|
|
39
44
|
getApiKeyDetails,
|
|
40
45
|
deleteApiKey,
|
|
41
46
|
getOrCreateApiKey,
|
|
42
|
-
initializeApiKeyOnAws
|
|
47
|
+
initializeApiKeyOnAws,
|
|
48
|
+
generateApiKeyValue
|
|
43
49
|
};
|
package/src/{internal-api/accounts → saas/internal-api/accounts/api}/settings/settings.api.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const requests = require('
|
|
2
|
-
const { backendUrl } = require('
|
|
1
|
+
const requests = require('../../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
get: accountId => `${backendUrl}/saas/account/${accountId}/settings`,
|
|
@@ -10,8 +10,9 @@ const getAccountSettings = async (accountId, context) => {
|
|
|
10
10
|
return requests.getRequestHandler(Endpoints.get(accountId), {}, context);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const updateAccountSettings = async (
|
|
14
|
-
|
|
13
|
+
const updateAccountSettings = async (updateAccountSettingsModel, context) => {
|
|
14
|
+
const { accountId } = updateAccountSettingsModel;
|
|
15
|
+
return requests.putRequestHandler(Endpoints.edit(accountId), updateAccountSettingsModel, context);
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
module.exports = {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const accountsAPI = require('./settings.api');
|
|
2
|
+
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
3
|
+
const UpdateAccountSettings = require('../../models/settings/update.settings.model');
|
|
4
|
+
|
|
5
|
+
const getAccountSettings = async (accountId, context) => {
|
|
6
|
+
return accountsAPI.getAccountSettings(accountId, context).then(res => res.data);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const updateAccountSettings = async (updateAccountSettingsModel, context) => {
|
|
10
|
+
validateType(updateAccountSettingsModel, UpdateAccountSettings);
|
|
11
|
+
return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const restoreAccountSettings = async (accountId, context) => {
|
|
15
|
+
const updateAccountSettingsModel = new UpdateAccountSettings(accountId, false, false);
|
|
16
|
+
return accountsAPI.updateAccountSettings(updateAccountSettingsModel, context);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
getAccountSettings,
|
|
21
|
+
updateAccountSettings,
|
|
22
|
+
restoreAccountSettings
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const CreateAccountModel = require('./models/core/create.account.model');
|
|
2
|
+
const coreModels = { CreateAccountModel };
|
|
3
|
+
|
|
4
|
+
const UpdateAccountSettings = require('./models/settings/update.settings.model');
|
|
5
|
+
const settingsModels = { UpdateAccountSettings };
|
|
6
|
+
|
|
7
|
+
const models = { core: coreModels, settings: settingsModels };
|
|
8
|
+
|
|
9
|
+
const coreService = require('./api/core/accounts.core.setup');
|
|
10
|
+
const openApiServices = require('./api/openapi/accounts.openapi.setup');
|
|
11
|
+
const settingsServices = require('./api/settings/settings.setup');
|
|
12
|
+
|
|
13
|
+
const services = {
|
|
14
|
+
core: coreService,
|
|
15
|
+
openApi: openApiServices,
|
|
16
|
+
settings: settingsServices
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = { services, models };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const env = require('../../../../../env');
|
|
2
|
+
const { credentials, accountCreationSecret } = env.getEnv();
|
|
3
|
+
const PROPERTY_TYPE = 'Property Management';
|
|
4
|
+
|
|
5
|
+
function CreateAccountModel(accountName, email, password = credentials.strongPassword,
|
|
6
|
+
secret = accountCreationSecret, propertyType = PROPERTY_TYPE) {
|
|
7
|
+
|
|
8
|
+
this.companyName = accountName;
|
|
9
|
+
this.email = email;
|
|
10
|
+
this.password = password;
|
|
11
|
+
this.verifyPassword = password;
|
|
12
|
+
this.secret = secret;
|
|
13
|
+
this.userType = propertyType;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = CreateAccountModel;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const requests = require('
|
|
2
|
-
const { backendUrl } = require('
|
|
1
|
+
const requests = require('../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
login: `${backendUrl}/logincontroller`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getEnv, requiredValidation } = require('
|
|
1
|
+
const { getEnv, requiredValidation } = require('../../../../env');
|
|
2
2
|
const { credentials } = getEnv();
|
|
3
3
|
const authApi = require('./auth.api');
|
|
4
4
|
|
|
@@ -21,11 +21,6 @@ const getIcsCookie = async () => {
|
|
|
21
21
|
return await getAuthCookie(credentials.superUser, credentials.superUserPassword);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const auth = {
|
|
25
|
-
getAuthCookie,
|
|
26
|
-
getIcsCookie
|
|
27
|
-
};
|
|
28
|
-
|
|
29
24
|
module.exports = {
|
|
30
25
|
getAuthCookie,
|
|
31
26
|
getIcsCookie
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const contractorsAPI = require('./contractors.api');
|
|
2
2
|
const { CreateContractorModel } = require('../models/create.contractor.model');
|
|
3
|
-
const { validateType } = require('
|
|
3
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
4
|
|
|
5
5
|
const createContractors = async (createContractorsModel, context) => {
|
|
6
6
|
validateType(createContractorsModel, CreateContractorModel);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const createModel = require('./models/create.contractor.model');
|
|
2
|
-
const
|
|
2
|
+
const services = require('./api/contractors.setup');
|
|
3
3
|
|
|
4
4
|
const models = { create: createModel };
|
|
5
5
|
|
|
6
|
-
module.exports = {
|
|
6
|
+
module.exports = { services, models };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const requests = require('
|
|
2
|
-
const { backendUrl } = require('
|
|
1
|
+
const requests = require('../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
create: `${backendUrl}/saas/project`,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const projectsApi = require('./projects.api');
|
|
2
|
-
const accounts = require('
|
|
2
|
+
const accounts = require('../../accounts/api/core/accounts.core.setup');
|
|
3
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
|
+
const CreateProjectModel = require('../models/create.project.model');
|
|
3
5
|
|
|
4
6
|
const getProjectsByAccountName = async (accountName, context) => {
|
|
5
7
|
const accountId = accounts.getAccountId(accountName, context);
|
|
@@ -18,13 +20,12 @@ const getProjectsByName = async (accountId, projectName, context) => {
|
|
|
18
20
|
|
|
19
21
|
const deleteProjectByName = async (accountId, projectName, context) => {
|
|
20
22
|
const projects = await getProjectsByName(accountId, projectName, context);
|
|
21
|
-
projects.map(async project => await projectsApi.deleteProjectById(project.projectId, context)
|
|
22
|
-
);
|
|
23
|
+
projects.map(async project => await projectsApi.deleteProjectById(project.projectId, context));
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const createProject = async (
|
|
26
|
-
|
|
27
|
-
return
|
|
26
|
+
const createProject = async (createProjectModel, context) => {
|
|
27
|
+
validateType(createProjectModel, CreateProjectModel);
|
|
28
|
+
return projectsApi.create(createProjectModel, context);
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
module.exports = {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function CreateProjectModel(accountId, name, description, address, number, startDate, endDate,
|
|
2
|
+
city, state, zipCode, companyNameForProject, certificateHolder = '', additionalInsured = '',
|
|
3
|
+
tenantSolutionEnabled = 0, onboardingEnabled = 0, automaticRenewalEnabled = 0) {
|
|
4
|
+
this.projectName = name;
|
|
5
|
+
this.userId = accountId;
|
|
6
|
+
this.projectDescription = description;
|
|
7
|
+
|
|
8
|
+
this.address = address;
|
|
9
|
+
this.projectNumber = number;
|
|
10
|
+
this.projectStartDate = startDate;
|
|
11
|
+
this.projectEndDate = endDate;
|
|
12
|
+
|
|
13
|
+
this.city = city;
|
|
14
|
+
this.state = state;
|
|
15
|
+
this.zipCode = zipCode;
|
|
16
|
+
this.companyNameForProject = companyNameForProject;
|
|
17
|
+
|
|
18
|
+
this.certificateHolder = certificateHolder;
|
|
19
|
+
this.additionalInsured = additionalInsured;
|
|
20
|
+
|
|
21
|
+
this.tenantSolutionEnabled = tenantSolutionEnabled;
|
|
22
|
+
this.onboardingEnabled = onboardingEnabled;
|
|
23
|
+
this.automaticRenewalEnabled = automaticRenewalEnabled;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = CreateProjectModel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const requirementsAPI = require('./requirements.api');
|
|
2
2
|
const { CreateRequirementModel } = require('../models/create.requirement.model');
|
|
3
|
-
const { validateType } = require('
|
|
3
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
4
|
|
|
5
5
|
const createRequirement = async (createRequirementModel, context) => {
|
|
6
6
|
validateType(createRequirementModel, CreateRequirementModel);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const createModel = require('./models/create.requirement.model');
|
|
2
|
-
const
|
|
2
|
+
const services = require('./api/requirements.setup');
|
|
3
3
|
|
|
4
4
|
const models = { create: createModel };
|
|
5
5
|
|
|
6
|
-
module.exports = {
|
|
6
|
+
module.exports = { services, models };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const requests = require('
|
|
2
|
-
const { backendUrl } = require('
|
|
1
|
+
const requests = require('../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
getTabsByProjectId: `${backendUrl}/saas/vendortab`,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const tabsAPI = require('./tabs.api');
|
|
2
|
+
|
|
3
|
+
const createTab = async (projectId, tabName, tabType, context) => {
|
|
4
|
+
const tabModel = { projectId, tabName, type: tabType };
|
|
5
|
+
return tabsAPI.createTab(tabModel, context);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const getTabsByProjectId = async (projectId, context) => {
|
|
9
|
+
return tabsAPI.getTabsByProjectId(projectId, context);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const getTabsByName = async (projectId, tabName, context) => {
|
|
13
|
+
const tabs = await tabsAPI.getTabsByProjectId(projectId, context);
|
|
14
|
+
const requestedTab = tabs.find(tab => tab.tabName === tabName);
|
|
15
|
+
return requestedTab;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const deleteTabById = async (tabId, context) => {
|
|
19
|
+
return tabsAPI.deleteTab(tabId, context);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getOrCreateTab = async (projectId, tabName, tabType, context) => {
|
|
23
|
+
const tabs = await getTabsByProjectId(projectId, context);
|
|
24
|
+
const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
|
|
25
|
+
|
|
26
|
+
if (existingTab) {
|
|
27
|
+
return existingTab;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return createTab(projectId, tabName, tabType, context);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
getTabsByProjectId,
|
|
35
|
+
createTab,
|
|
36
|
+
deleteTabById,
|
|
37
|
+
getOrCreateTab,
|
|
38
|
+
getTabsByName
|
|
39
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
const getRequestHandler = async (url, apiKey, params = {}, headers = {}) => {
|
|
4
|
+
enrichApiKey(headers, apiKey);
|
|
5
|
+
try {
|
|
6
|
+
const response = await axios.get(url, { params, headers });
|
|
7
|
+
return response;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
const message = error.response.data && JSON.stringify(error.response.data) || error.message;
|
|
10
|
+
throw Error(message);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const postRequestHandler = async (url, apiKey, body, headers = {}) => {
|
|
16
|
+
enrichApiKey(headers, apiKey);
|
|
17
|
+
try {
|
|
18
|
+
const response = await axios.post(url, body, { headers });
|
|
19
|
+
return response;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
const message = error.response.data && JSON.stringify(error.response.data) || error.message;
|
|
22
|
+
throw Error(message);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const putRequestHandler = async (url, apiKey, body, headers = {}) => {
|
|
28
|
+
enrichApiKey(headers, apiKey);
|
|
29
|
+
try {
|
|
30
|
+
const response = await axios.put(url, body, { headers });
|
|
31
|
+
return response;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
const message = error.response.data && JSON.stringify(error.response.data) || error.message;
|
|
34
|
+
throw Error(message);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const deleteRequestHandler = async (url, apiKey, headers = {}, params = {}, data = {}) => {
|
|
40
|
+
enrichApiKey(headers, apiKey);
|
|
41
|
+
try {
|
|
42
|
+
const response = await axios.delete(url, { params, headers, data });
|
|
43
|
+
return response;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const message = error.response.data && JSON.stringify(error.response.data) || error.message;
|
|
46
|
+
throw Error(message);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const enrichApiKey = (headers, apiKey) => {
|
|
52
|
+
headers['x-api-key'] = apiKey;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
module.exports = { getRequestHandler, postRequestHandler, putRequestHandler, deleteRequestHandler };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const requests = require('../common/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
|
+
};
|
|
8
|
+
|
|
9
|
+
const deleteTabById = async (tabId, apiKey) => {
|
|
10
|
+
return requests.deleteRequestHandler(Endpoints.delete(tabId), apiKey);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = { deleteTabById };
|
package/tests/env.test.js
CHANGED
|
@@ -5,19 +5,9 @@ const { expect } = chai;
|
|
|
5
5
|
const env = require('../src/env');
|
|
6
6
|
|
|
7
7
|
describe('Env | Test Core Logic', async function() {
|
|
8
|
-
const expectedSanityAssignVariables = {
|
|
9
|
-
'backendUrl': 'Test',
|
|
10
|
-
'credentials': {
|
|
11
|
-
'superUser': 'TestSuperUser',
|
|
12
|
-
'superUserPassword': 'TestSuperUserPassword'
|
|
13
|
-
},
|
|
14
|
-
'environment': 'dev',
|
|
15
|
-
'accountCreationSecret': null
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const expectedValidationError = 'Missing required configuration on your environment variables. The missing env-vars are "backendUrl,environment".';
|
|
19
|
-
|
|
20
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
|
+
|
|
21
11
|
const badInput = {
|
|
22
12
|
credentials: { superUser: 'TestSuperUser', superUserPassword: 'TestSuperUserPassword' }
|
|
23
13
|
};
|
|
@@ -26,8 +16,20 @@ describe('Env | Test Core Logic', async function() {
|
|
|
26
16
|
});
|
|
27
17
|
|
|
28
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
|
+
|
|
29
30
|
env.init({
|
|
30
31
|
backendUrl: 'Test',
|
|
32
|
+
openapiUrl: 'openapi',
|
|
31
33
|
environment: 'dev',
|
|
32
34
|
credentials: { superUser: 'TestSuperUser', superUserPassword: 'TestSuperUserPassword' }
|
|
33
35
|
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const accountsAPI = require('./settings.api');
|
|
2
|
-
|
|
3
|
-
const getAccountSettings = async (accountId, context) => {
|
|
4
|
-
return accountsAPI.getAccountSettings(accountId, context).then(res => res.data);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const updateAccountSettings = async (accountId, { isMultiPropertyTenants, isHighPriority }, context) => {
|
|
8
|
-
return accountsAPI.updateAccountSettings(accountId, { isMultiPropertyTenants, isHighPriority }, context);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const restoreAccountSettings = async (accountId, context) => {
|
|
12
|
-
return accountsAPI.updateAccountSettings(accountId, {
|
|
13
|
-
isMultiPropertyTenants: false,
|
|
14
|
-
isHighPriority: false
|
|
15
|
-
}, context);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
getAccountSettings,
|
|
20
|
-
updateAccountSettings,
|
|
21
|
-
restoreAccountSettings
|
|
22
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const tabsAPI = require('./tabs.api');
|
|
2
|
-
|
|
3
|
-
const createTab = async (projectId, tabName, tabType, context) => {
|
|
4
|
-
const tabModel = { projectId, tabName, type: tabType };
|
|
5
|
-
return tabsAPI.createTab(tabModel, context);
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const getTabsByProjectId = async (projectId, context) => {
|
|
9
|
-
return tabsAPI.getTabsByProjectId(projectId, context);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const deleteTabById = async (tabId, context) => {
|
|
13
|
-
return tabsAPI.deleteTab(tabId, context);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = { getTabsByProjectId, createTab, deleteTabById };
|
|
File without changes
|
|
File without changes
|