@getjones/test-infra 1.1.4 → 1.1.5
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 +2 -2
- package/src/env.js +2 -2
- package/src/index.js +2 -1
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.setup.js +11 -5
- package/src/saas/internal-api/contractors/api/contractors.setup.js +0 -1
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +46 -5
- package/src/saas/internal-api/projects/api/core/projects.api.js +13 -2
- package/src/saas/internal-api/projects/api/core/projects.setup.js +14 -1
- package/src/saas/internal-api/projects/index.js +2 -1
- package/src/saas/internal-api/projects/models/core/update.project.model.js +27 -0
- package/src/saas/openapi/accounts/accounts.api.js +12 -0
- package/src/saas/openapi/accounts/accounts.setup.js +7 -0
- package/src/saas/openapi/projects/projects.api.js +16 -2
- package/src/saas/openapi/projects/projects.setup.js +11 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getjones/test-infra",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Providing internal and openapi interface",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout
|
|
7
|
+
"test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout 30000 --exit --inlineDiffs --bail --parallel"
|
|
8
8
|
},
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
package/src/env.js
CHANGED
|
@@ -23,12 +23,12 @@ const requiredValidation = object => {
|
|
|
23
23
|
const invalidKeys = [];
|
|
24
24
|
Object.keys(object).forEach(key => {
|
|
25
25
|
if (!object[key]) {
|
|
26
|
-
invalidKeys.push(key);
|
|
26
|
+
invalidKeys.push(` '${key}'`);
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (invalidKeys.length > 0) {
|
|
31
|
-
throw `Missing required configuration on your environment variables
|
|
31
|
+
throw Error(`Missing required configuration on your environment variables.\nThe missing env-vars are:${invalidKeys}`);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
|
package/src/index.js
CHANGED
|
@@ -42,11 +42,12 @@ const getInternalAPI = () => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const getOpenAPI = () => {
|
|
45
|
+
const accounts = require('./saas/openapi/accounts/accounts.setup');
|
|
45
46
|
const tabs = require('./saas/openapi/tabs/tabs.setup');
|
|
46
47
|
const contractors = require('./saas/openapi/contractors/contractors.setup');
|
|
47
48
|
const projects = require('./saas/openapi/projects/projects.setup');
|
|
48
49
|
const requirements = require('./saas/openapi/requirements');
|
|
49
|
-
const openAPI = { tabs, contractors, projects, requirements };
|
|
50
|
+
const openAPI = { accounts, tabs, contractors, projects, requirements };
|
|
50
51
|
return openAPI;
|
|
51
52
|
|
|
52
53
|
};
|
|
@@ -5,8 +5,8 @@ const generateApiKeyValue = accountName => {
|
|
|
5
5
|
return crypto.createHash('sha256').update(accountName).digest('base64');
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
const createApiKey = async (accountId, apiKeyValue, context) => {
|
|
9
|
-
const data = { apiKeyValue, accountId };
|
|
8
|
+
const createApiKey = async (accountId, apiKeyValue, context, { apiKeyType = null, apiKeyName = null } = {}) => {
|
|
9
|
+
const data = { apiKeyValue, accountId, apiKeyName, apiKeyType };
|
|
10
10
|
return accountsAPI.createApiKey(data, context);
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -28,11 +28,17 @@ const deleteApiKey = async (apiKeyValue, context) => {
|
|
|
28
28
|
return accountsAPI.deleteApiKey(data, context);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const getOrCreateApiKey = async (accountId, apiKey, context) => {
|
|
32
|
-
|
|
31
|
+
const getOrCreateApiKey = async (accountId, apiKey, context, { apiKeyType = null, apiKeyName = null } = {}) => {
|
|
32
|
+
let existingApiKey = await getApiKeyByAccountId(accountId, context);
|
|
33
|
+
|
|
34
|
+
if (existingApiKey.apiKeyValue) {
|
|
35
|
+
return existingApiKey;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
existingApiKey = await getApiKeyDetails(apiKey, context);
|
|
33
39
|
|
|
34
40
|
if (!existingApiKey.apiKeyValue) {
|
|
35
|
-
return createApiKey(accountId, apiKey, context);
|
|
41
|
+
return createApiKey(accountId, apiKey, context, { apiKeyType, apiKeyName });
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
return existingApiKey;
|
|
@@ -2,7 +2,6 @@ const contractorsAPI = require('./contractors.api');
|
|
|
2
2
|
const { CreateContractorModel } = require('../models/create.contractor.model');
|
|
3
3
|
const { ContractorModel } = require('../models/edit.contractor.model');
|
|
4
4
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
5
|
-
const requests = require('../../common/requests');
|
|
6
5
|
|
|
7
6
|
const createContractors = async (createContractorsModel, context) => {
|
|
8
7
|
validateType(createContractorsModel, CreateContractorModel);
|
|
@@ -1,15 +1,56 @@
|
|
|
1
1
|
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
2
2
|
|
|
3
|
-
function ContractorModel(contractorId, company, emailAddress, tab,
|
|
3
|
+
function ContractorModel(contractorId, company, emailAddress, tab, additionalDetails ) {
|
|
4
|
+
validateType(tab, VendorTabModel);
|
|
5
|
+
validateType(additionalDetails, ContractorDetailsModel);
|
|
6
|
+
|
|
4
7
|
this.contractorId = contractorId;
|
|
5
8
|
this.company = company;
|
|
6
9
|
this.emailAddress = emailAddress;
|
|
7
10
|
this.tab = tab;
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
for (const detail in additionalDetails) {
|
|
13
|
+
if (additionalDetails[detail]){
|
|
14
|
+
this[detail] = additionalDetails[detail];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function ContractorDetailsModel({
|
|
21
|
+
additionalEmails = null,
|
|
22
|
+
dba = null,
|
|
23
|
+
firstName = null,
|
|
24
|
+
lastName = null,
|
|
25
|
+
address = null,
|
|
26
|
+
city = null,
|
|
27
|
+
state = null,
|
|
28
|
+
zipCode = null,
|
|
29
|
+
phoneNumber = null,
|
|
30
|
+
agreementNumber = null,
|
|
31
|
+
projectDescription = null,
|
|
32
|
+
startDate = null,
|
|
33
|
+
endDate = null,
|
|
34
|
+
tenantRecord = {}
|
|
35
|
+
} = {}){
|
|
9
36
|
this.additionalEmails = additionalEmails;
|
|
37
|
+
this.dba = dba;
|
|
38
|
+
this.fName = firstName;
|
|
39
|
+
this.lName = lastName;
|
|
40
|
+
this.location = address;
|
|
41
|
+
this.city = city;
|
|
42
|
+
this.state = state;
|
|
43
|
+
this.zipCode = zipCode;
|
|
44
|
+
this.phoneNumber = phoneNumber;
|
|
45
|
+
this.subContractNumber = agreementNumber;
|
|
46
|
+
this.descriptionOfOperations = projectDescription;
|
|
47
|
+
this.startDate = startDate;
|
|
48
|
+
this.endDate = endDate;
|
|
10
49
|
|
|
11
|
-
|
|
12
|
-
|
|
50
|
+
if (tenantRecord){
|
|
51
|
+
validateType(tenantRecord, TenantRecordModel);
|
|
52
|
+
this.tenantRecord = tenantRecord;
|
|
53
|
+
}
|
|
13
54
|
}
|
|
14
55
|
|
|
15
56
|
function TenantRecordModel(id, companyName, emailAddress) {
|
|
@@ -22,4 +63,4 @@ function VendorTabModel(type){
|
|
|
22
63
|
this.type = type;
|
|
23
64
|
}
|
|
24
65
|
|
|
25
|
-
module.exports = { ContractorModel, TenantRecordModel, VendorTabModel };
|
|
66
|
+
module.exports = { ContractorModel, TenantRecordModel, VendorTabModel, ContractorDetailsModel };
|
|
@@ -4,7 +4,9 @@ const { backendUrl } = require('../../../../../env').getEnv();
|
|
|
4
4
|
const Endpoints = {
|
|
5
5
|
create: `${backendUrl}/saas/project`,
|
|
6
6
|
delete: projectId => `${backendUrl}/saas/project/${projectId}`,
|
|
7
|
-
getByAccountId: `${backendUrl}/saas/project/list
|
|
7
|
+
getByAccountId: `${backendUrl}/saas/project/list`,
|
|
8
|
+
update: `${backendUrl}/saas/project`,
|
|
9
|
+
getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
const create = async (project, context) => {
|
|
@@ -16,8 +18,17 @@ const getProjectsByAccountId = async (accountId, context) => {
|
|
|
16
18
|
return requests.getRequestHandler(Endpoints.getByAccountId, params, context).then(res => res.data);
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
const getProjectByProjectId = async (projectId, context) => {
|
|
22
|
+
const params = { };
|
|
23
|
+
return requests.getRequestHandler(Endpoints.getProjectByProjectId(projectId), params, context).then(res => res.data);
|
|
24
|
+
};
|
|
25
|
+
|
|
19
26
|
const deleteProjectById = async (projectId, context) => {
|
|
20
27
|
return requests.deleteRequestHandler(Endpoints.delete(projectId), context);
|
|
21
28
|
};
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
const update = async (project, context) => {
|
|
31
|
+
return requests.postRequestHandler(Endpoints.update, project, context);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId };
|
|
@@ -2,6 +2,7 @@ const projectsApi = require('./projects.api');
|
|
|
2
2
|
const accounts = require('../../../accounts/api/core/accounts.core.setup');
|
|
3
3
|
const { validateType } = require('../../../../../common/validations/typeValidations');
|
|
4
4
|
const CreateProjectModel = require('../../models/core/create.project.model');
|
|
5
|
+
const UpdateProjectModel = require('../../models/core/update.project.model');
|
|
5
6
|
|
|
6
7
|
const getProjectsByAccountName = async (accountName, context) => {
|
|
7
8
|
const accountId = accounts.getAccountId(accountName, context);
|
|
@@ -12,6 +13,10 @@ const getProjectsByAccountId = async (accountId, context) => {
|
|
|
12
13
|
return projectsApi.getProjectsByAccountId(accountId, context);
|
|
13
14
|
};
|
|
14
15
|
|
|
16
|
+
const getProjectByProjectId = async (projectId, context) => {
|
|
17
|
+
return projectsApi.getProjectByProjectId(projectId, context);
|
|
18
|
+
};
|
|
19
|
+
|
|
15
20
|
const getProjectsByName = async (accountId, projectName, context) => {
|
|
16
21
|
const projects = await getProjectsByAccountId(accountId, context);
|
|
17
22
|
const filteredProjects = projects.filter(project => project.projectName === projectName);
|
|
@@ -38,10 +43,18 @@ const getOrCreateProject = async (createProjectModel, context) => {
|
|
|
38
43
|
return createProject(createProjectModel, context);
|
|
39
44
|
};
|
|
40
45
|
|
|
46
|
+
const updateProject = async (updateProjectModel, context) => {
|
|
47
|
+
validateType(updateProjectModel, UpdateProjectModel);
|
|
48
|
+
return projectsApi.update(updateProjectModel, context);
|
|
49
|
+
};
|
|
50
|
+
|
|
41
51
|
module.exports = {
|
|
42
52
|
getProjectsByAccountName,
|
|
43
53
|
getProjectsByAccountId,
|
|
44
54
|
createProject,
|
|
45
55
|
deleteProjectByName,
|
|
46
|
-
getOrCreateProject
|
|
56
|
+
getOrCreateProject,
|
|
57
|
+
updateProject,
|
|
58
|
+
getProjectsByName,
|
|
59
|
+
getProjectByProjectId
|
|
47
60
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const projectService = require('./api/core/projects.setup');
|
|
2
2
|
const projectSettingsService = require('./api/settings/project.settings.setup');
|
|
3
3
|
const CreateProjectModel = require('./models/core/create.project.model');
|
|
4
|
+
const UpdateProjectModel = require('./models/core/update.project.model');
|
|
4
5
|
const UpdateProjectSettingsModel = require('./models/settings/update.project.settings.model');
|
|
5
6
|
|
|
6
|
-
const coreModels = { CreateProjectModel };
|
|
7
|
+
const coreModels = { CreateProjectModel, UpdateProjectModel };
|
|
7
8
|
const settingsModels = { UpdateProjectSettingsModel };
|
|
8
9
|
|
|
9
10
|
const services = {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function UpdateProjectModel(accountId, projectId, name, description, address, number, startDate, endDate,
|
|
2
|
+
city, state, zipCode, companyNameForProject, certificateHolder = '', additionalInsured = '',
|
|
3
|
+
tenantSolutionEnabled = 0, onboardingEnabled = 0, automaticRenewalEnabled = 0) {
|
|
4
|
+
this.projectId = projectId;
|
|
5
|
+
this.projectName = name;
|
|
6
|
+
this.userId = accountId;
|
|
7
|
+
this.projectDescription = description;
|
|
8
|
+
|
|
9
|
+
this.address = address;
|
|
10
|
+
this.projectNumber = number;
|
|
11
|
+
this.projectStartDate = startDate;
|
|
12
|
+
this.projectEndDate = endDate;
|
|
13
|
+
|
|
14
|
+
this.city = city;
|
|
15
|
+
this.state = state;
|
|
16
|
+
this.zipCode = zipCode;
|
|
17
|
+
this.companyNameForProject = companyNameForProject;
|
|
18
|
+
|
|
19
|
+
this.certificateHolder = certificateHolder;
|
|
20
|
+
this.additionalInsured = additionalInsured;
|
|
21
|
+
|
|
22
|
+
this.tenantSolutionEnabled = tenantSolutionEnabled;
|
|
23
|
+
this.onboardingEnabled = onboardingEnabled;
|
|
24
|
+
this.automaticRenewalEnabled = automaticRenewalEnabled;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = UpdateProjectModel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const requests = require('../common/requests');
|
|
2
|
+
const { openapiUrl } = require('../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
getAccountList: `${openapiUrl}/accounts`
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const getAccountList = async apiKey => {
|
|
9
|
+
return requests.getRequestHandler(Endpoints.getAccountList, apiKey).then(res => res.data);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = { getAccountList };
|
|
@@ -6,7 +6,9 @@ const Endpoints = {
|
|
|
6
6
|
getAllProjects: `${openapiUrl}/properties/all`,
|
|
7
7
|
getModifiedProjects: `${openapiUrl}/properties/modified`,
|
|
8
8
|
createProject: `${openapiUrl}/properties`,
|
|
9
|
-
updateProject: projectId => `${openapiUrl}/properties/${projectId}
|
|
9
|
+
updateProject: projectId => `${openapiUrl}/properties/${projectId}`,
|
|
10
|
+
getProjectSettings: projectId => `${openapiUrl}/properties/${projectId}/settings`,
|
|
11
|
+
updateProjectSettings: projectId => `${openapiUrl}/properties/${projectId}/settings`
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
const getProjectsByName = async (apiKey, params) => {
|
|
@@ -29,10 +31,22 @@ const updateProject = async (apiKey, projectId, projectData) => {
|
|
|
29
31
|
return requests.patchRequestHandler(Endpoints.updateProject(projectId), apiKey, projectData).then(res => res.data);
|
|
30
32
|
};
|
|
31
33
|
|
|
34
|
+
const updateProjectSettings = async (apiKey, projectId, projectSettings) => {
|
|
35
|
+
return requests.patchRequestHandler(Endpoints.updateProjectSettings(projectId),
|
|
36
|
+
apiKey, projectSettings).then(res => res.data);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getProjectSettings = async (apiKey, projectId) => {
|
|
40
|
+
return requests.getRequestHandler(Endpoints.getProjectSettings(projectId),
|
|
41
|
+
apiKey).then(res => res.data);
|
|
42
|
+
};
|
|
43
|
+
|
|
32
44
|
module.exports = {
|
|
33
45
|
getProjectsByName,
|
|
34
46
|
getAllProjects,
|
|
35
47
|
getModifiedProjects,
|
|
36
48
|
createProject,
|
|
37
|
-
updateProject
|
|
49
|
+
updateProject,
|
|
50
|
+
updateProjectSettings,
|
|
51
|
+
getProjectSettings
|
|
38
52
|
};
|
|
@@ -20,10 +20,20 @@ const getModifiedProjects = async (apiKey, timestamp) => {
|
|
|
20
20
|
return projectsApi.getModifiedProjects(apiKey, { timestamp });
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
const updateProjectSettings = async (apiKey, projectId, projectSettings) => {
|
|
24
|
+
return projectsApi.updateProjectSettings(apiKey, projectId, projectSettings);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getProjectSettings = async (apiKey, projectId) => {
|
|
28
|
+
return projectsApi.getProjectSettings(apiKey, projectId);
|
|
29
|
+
};
|
|
30
|
+
|
|
23
31
|
module.exports = {
|
|
24
32
|
getProjectsByName,
|
|
25
33
|
createProject,
|
|
26
34
|
updateProject,
|
|
27
35
|
getAllProjects,
|
|
28
|
-
getModifiedProjects
|
|
36
|
+
getModifiedProjects,
|
|
37
|
+
updateProjectSettings,
|
|
38
|
+
getProjectSettings
|
|
29
39
|
};
|