@getjones/test-infra 1.2.1 → 1.2.2
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 +5 -4
- package/src/common/validations/errorValidation.js +2 -2
- package/src/env.js +29 -29
- package/src/index.js +41 -42
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +3 -4
- package/src/saas/internal-api/common/requests.js +49 -54
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +18 -8
- package/src/saas/internal-api/compliance/api/coverage/coverage.setup.js +11 -3
- package/src/saas/internal-api/compliance/models/coverage/coverage.model.js +53 -0
- package/src/saas/internal-api/projects/api/settings/project.settings.setup.js +1 -1
- package/src/saas/internal-api/projects/models/core/update.project.model.js +2 -1
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +8 -2
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +40 -0
- package/src/saas/internal-api/recordNotes/api/record.notes.setup.js +29 -0
- package/src/saas/internal-api/tabs/api/tabs.api.js +9 -9
- package/src/saas/internal-api/tabs/api/tabs.setup.js +24 -24
- package/src/saas/internal-api/users/api/invite.api.js +11 -11
- package/src/saas/internal-api/users/api/invite.setup.js +5 -5
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +14 -0
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.setup.js +8 -0
- package/tests/env.test.js +32 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getjones/test-infra",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Providing internal and openapi interface",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
"mocha": "^8.3.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"eslint": "^
|
|
23
|
-
"eslint
|
|
24
|
-
"eslint-plugin-
|
|
22
|
+
"babel-eslint": "^10.0.3",
|
|
23
|
+
"eslint": "^6.8.0",
|
|
24
|
+
"eslint-plugin-import": "^2.19.1",
|
|
25
|
+
"mocha-spec-json-output-reporter": "^1.1.7"
|
|
25
26
|
},
|
|
26
27
|
"directories": {
|
|
27
28
|
"test": "tests"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const responseStatusCodes = require('../httpResponseStatusCodes.json');
|
|
2
2
|
|
|
3
|
-
const validateError = error=> {
|
|
3
|
+
const validateError = error => {
|
|
4
4
|
if (!error.response || !isClientErrorCode(error.response.status)) {
|
|
5
5
|
throw error;
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
const isClientErrorCode = httpStatusCode =>{
|
|
9
|
+
const isClientErrorCode = httpStatusCode => {
|
|
10
10
|
const minClientErrorCode = responseStatusCodes.BAD_REQUEST;
|
|
11
11
|
const maxClientErrorCode = responseStatusCodes.CLIENT_CLOSED_REQUEST;
|
|
12
12
|
|
package/src/env.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
let privateMembers = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
backendUrl: null,
|
|
3
|
+
openapiUrl: null,
|
|
4
|
+
nodeBackendUrl: null,
|
|
5
|
+
credentials: null,
|
|
6
|
+
environment: null,
|
|
7
|
+
accountCreationSecret: null,
|
|
8
|
+
threadSchedulerSecret: null,
|
|
9
|
+
nodeBackendSecret: null
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const init = conf => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
privateMembers = Object.assign(privateMembers, conf);
|
|
14
|
+
requiredValidation({
|
|
15
|
+
backendUrl: privateMembers.backendUrl,
|
|
16
|
+
openapiUrl: privateMembers.openapiUrl,
|
|
17
|
+
nodeBackendUrl: privateMembers.nodeBackendUrl,
|
|
18
|
+
environment: privateMembers.environment
|
|
19
|
+
});
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const requiredValidation = object => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const invalidKeys = [];
|
|
24
|
+
Object.keys(object).forEach(key => {
|
|
25
|
+
if (!object[key]) {
|
|
26
|
+
invalidKeys.push(` '${key}'`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if (invalidKeys.length > 0) {
|
|
31
|
+
throw Error(`Missing required configuration on your environment variables.\nThe missing env-vars are:${invalidKeys}`);
|
|
32
|
+
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const isLocalhost = () => {
|
|
36
|
-
|
|
36
|
+
return privateMembers.backendUrl.includes('localhost');
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
module.exports = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
init,
|
|
41
|
+
getEnv: () => privateMembers,
|
|
42
|
+
requiredValidation,
|
|
43
|
+
isLocalhost
|
|
44
44
|
};
|
package/src/index.js
CHANGED
|
@@ -1,55 +1,54 @@
|
|
|
1
1
|
const env = require('./env');
|
|
2
2
|
|
|
3
3
|
const init = conf => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
env.init(conf);
|
|
5
|
+
const internalAPI = getInternalAPI();
|
|
6
|
+
const openAPI = getOpenAPI();
|
|
7
|
+
const threadScheduler = require('./saas/thread-scheduler/runner');
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
return { internalAPI, openAPI, threadScheduler };
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const getInternalAPI = () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
13
|
+
const auth = require('./saas/internal-api/auth');
|
|
14
|
+
const accounts = require('./saas/internal-api/accounts');
|
|
15
|
+
|
|
16
|
+
const projects = require('./saas/internal-api/projects');
|
|
17
|
+
const tabs = require('./saas/internal-api/tabs');
|
|
18
|
+
|
|
19
|
+
const requirements = require('./saas/internal-api/requirements');
|
|
20
|
+
const contractors = require('./saas/internal-api/contractors');
|
|
21
|
+
|
|
22
|
+
const coi = require('./saas/internal-api/coi');
|
|
23
|
+
const compliance = require('./saas/internal-api/compliance');
|
|
24
|
+
const users = require('./saas/internal-api/users');
|
|
25
|
+
|
|
26
|
+
const reports = require('./saas/internal-api/reports');
|
|
27
|
+
|
|
28
|
+
const internalAPI = {
|
|
29
|
+
auth,
|
|
30
|
+
accounts,
|
|
31
|
+
projects,
|
|
32
|
+
tabs,
|
|
33
|
+
requirements,
|
|
34
|
+
contractors,
|
|
35
|
+
coi,
|
|
36
|
+
compliance,
|
|
37
|
+
reports,
|
|
38
|
+
users
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return internalAPI;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const getOpenAPI = () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
const accounts = require('./saas/openapi/accounts/accounts.setup');
|
|
46
|
+
const tabs = require('./saas/openapi/tabs/tabs.setup');
|
|
47
|
+
const contractors = require('./saas/openapi/contractors/contractors.setup');
|
|
48
|
+
const projects = require('./saas/openapi/projects/projects.setup');
|
|
49
|
+
const requirements = require('./saas/openapi/requirements');
|
|
50
|
+
const openAPI = { accounts, tabs, contractors, projects, requirements };
|
|
51
|
+
return openAPI;
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
module.exports = init;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
function UpdateAccountSettings(accountId, isMultiPropertyTenants, isHighPriority) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
this.accountId = accountId;
|
|
3
|
+
this.isMultiPropertyTenants = isMultiPropertyTenants;
|
|
4
|
+
this.isHighPriority = isHighPriority;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
module.exports = UpdateAccountSettings;
|
|
8
|
-
|
|
@@ -2,75 +2,70 @@ const axios = require('axios');
|
|
|
2
2
|
const errorValidation = require('../../../common/validations/errorValidation');
|
|
3
3
|
|
|
4
4
|
const getRequestHandler = async (url, params = {}, context = null, headers = {}) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
enrichCookie(headers, context);
|
|
6
|
+
try {
|
|
7
|
+
const response = await axios.get(url, { params, headers });
|
|
8
|
+
return response;
|
|
9
|
+
} catch (error) {
|
|
10
|
+
errorValidation.validateError(error);
|
|
11
|
+
return error.response;
|
|
12
|
+
}
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
const postRequestHandler = async (url, body, context = null, headers = {}, params = {}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
enrichCookie(headers, context);
|
|
17
|
+
try {
|
|
18
|
+
const response = await axios.post(url, body, { headers, params });
|
|
19
|
+
return response;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
errorValidation.validateError(error);
|
|
22
|
+
return error.response;
|
|
23
|
+
}
|
|
26
24
|
};
|
|
27
25
|
|
|
28
26
|
const putRequestHandler = async (url, body, context = null, headers = {}) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
enrichCookie(headers, context);
|
|
28
|
+
try {
|
|
29
|
+
const response = await axios.put(url, body, { headers });
|
|
30
|
+
return response;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
errorValidation.validateError(error);
|
|
33
|
+
return error.response;
|
|
34
|
+
}
|
|
38
35
|
};
|
|
39
36
|
|
|
40
37
|
const patchRequestHandler = async (url, context, body, headers = {}) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
enrichCookie(headers, context);
|
|
39
|
+
try {
|
|
40
|
+
const response = await axios.patch(url, body, { headers });
|
|
41
|
+
return response;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
errorValidation.validateError(error);
|
|
44
|
+
return error.response;
|
|
45
|
+
}
|
|
50
46
|
};
|
|
51
47
|
|
|
52
48
|
const deleteRequestHandler = async (url, context = null, headers = {}, params = {}, data = {}) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
enrichCookie(headers, context);
|
|
50
|
+
try {
|
|
51
|
+
const response = await axios.delete(url, { params, headers, data });
|
|
52
|
+
return response;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
errorValidation.validateError(error);
|
|
55
|
+
return error.response;
|
|
56
|
+
}
|
|
62
57
|
};
|
|
63
58
|
|
|
64
59
|
const enrichCookie = (headers, context) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
if (context) {
|
|
61
|
+
headers.Cookie = context;
|
|
62
|
+
}
|
|
68
63
|
};
|
|
69
64
|
|
|
70
65
|
module.exports = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
66
|
+
getRequestHandler,
|
|
67
|
+
postRequestHandler,
|
|
68
|
+
putRequestHandler,
|
|
69
|
+
patchRequestHandler,
|
|
70
|
+
deleteRequestHandler
|
|
71
|
+
};
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const openApiRequests = require('../../../../openapi/common/requests');
|
|
2
|
+
const internalApiRequests = require('../../../common/requests');
|
|
3
|
+
const { backendUrl, nodeBackendUrl } = require('../../../../../env').getEnv();
|
|
3
4
|
|
|
4
5
|
const Endpoints = {
|
|
5
|
-
|
|
6
|
+
saveCoverageNode: `${nodeBackendUrl}/coverage`,
|
|
7
|
+
saveCoverageJava: contractorId => `${backendUrl}/saas/contractors/${contractorId}/coverage`,
|
|
6
8
|
getCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`
|
|
7
9
|
};
|
|
8
10
|
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
+
const saveCoverageNode = (coverage, nodeBackendSecret) => {
|
|
12
|
+
return openApiRequests.postRequestHandler(Endpoints.saveCoverageNode, nodeBackendSecret, coverage);
|
|
11
13
|
};
|
|
12
14
|
|
|
13
|
-
const
|
|
14
|
-
return
|
|
15
|
+
const saveCoverageJava = (auditorContext, contractorId, coverage) => {
|
|
16
|
+
return internalApiRequests.postRequestHandler(Endpoints.saveCoverageJava(contractorId), coverage, auditorContext);
|
|
15
17
|
};
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
const getCoverageByCoiId = (coiId, nodeBackendSecret) => {
|
|
20
|
+
return openApiRequests.getRequestHandler(Endpoints.getCoverageByCoiId(coiId), nodeBackendSecret);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
saveCoverageNode,
|
|
25
|
+
saveCoverageJava,
|
|
26
|
+
getCoverageByCoiId
|
|
27
|
+
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
const coverageApi = require('./coverage.api');
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
return coverageApi.
|
|
3
|
+
const saveCoverageNode = async (coverage, nodeBackendSecret) => {
|
|
4
|
+
return coverageApi.saveCoverageNode(coverage, nodeBackendSecret);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const saveCoverageJava = async (auditorContext, contractorId, coverage) => {
|
|
8
|
+
return coverageApi.saveCoverageJava(auditorContext, contractorId, coverage);
|
|
5
9
|
};
|
|
6
10
|
|
|
7
11
|
const getCoverageByCoiId = async (coiId, nodeBackendSecret) => {
|
|
8
12
|
return coverageApi.getCoverageByCoiId(coiId, nodeBackendSecret).then(res => res && res.data);
|
|
9
13
|
};
|
|
10
14
|
|
|
11
|
-
module.exports = {
|
|
15
|
+
module.exports = {
|
|
16
|
+
saveCoverageNode,
|
|
17
|
+
saveCoverageJava,
|
|
18
|
+
getCoverageByCoiId
|
|
19
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
class coverageRequestModel {
|
|
2
|
+
constructor({
|
|
3
|
+
coiId,
|
|
4
|
+
documentsModel
|
|
5
|
+
}) {
|
|
6
|
+
this.coiId = coiId,
|
|
7
|
+
this.documents = documentsModel;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class coverageDocumentModel {
|
|
12
|
+
constructor({
|
|
13
|
+
documentType,
|
|
14
|
+
pagesModel
|
|
15
|
+
}) {
|
|
16
|
+
this.documentType = documentType,
|
|
17
|
+
this.pagesModel = pagesModel;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class coveragePageModel {
|
|
22
|
+
constructor({
|
|
23
|
+
pageNumber,
|
|
24
|
+
policies
|
|
25
|
+
}) {
|
|
26
|
+
this.pageNumber = pageNumber,
|
|
27
|
+
this.policies = policies;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class coveragePolicyModel {
|
|
32
|
+
constructor({
|
|
33
|
+
key,
|
|
34
|
+
policyEntities,
|
|
35
|
+
provisions,
|
|
36
|
+
limits
|
|
37
|
+
}) {
|
|
38
|
+
this.key = key,
|
|
39
|
+
this.policyEntities = policyEntities,
|
|
40
|
+
this.provisions = provisions,
|
|
41
|
+
this.limits = limits
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const documentTypesList = ['accord25']
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
coverageRequestModel,
|
|
49
|
+
coverageDocumentModel,
|
|
50
|
+
coveragePageModel,
|
|
51
|
+
coveragePolicyModel,
|
|
52
|
+
documentTypesList
|
|
53
|
+
};
|
|
@@ -7,7 +7,7 @@ const updateProjectSettings = async (updateProjectSettingsModel, context) => {
|
|
|
7
7
|
return updateProjectSettingsByProjectId(updateProjectSettingsModel, context);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const getProjectSettings = async (projectId, context)=>{
|
|
10
|
+
const getProjectSettings = async (projectId, context) => {
|
|
11
11
|
return getProjectSettingsByProjectId(projectId, context);
|
|
12
12
|
};
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function UpdateProjectModel(accountId, projectId, name, description, address, number, startDate, endDate,
|
|
2
2
|
city, state, zipCode, companyNameForProject, certificateHolder = '', additionalInsured = '',
|
|
3
|
-
tenantSolutionEnabled = 0, onboardingEnabled = 0, automaticRenewalEnabled = 0) {
|
|
3
|
+
tenantSolutionEnabled = 0, onboardingEnabled = 0, automaticRenewalEnabled = 0, onboardedVendors = 0) {
|
|
4
4
|
this.projectId = projectId;
|
|
5
5
|
this.projectName = name;
|
|
6
6
|
this.userId = accountId;
|
|
@@ -10,6 +10,7 @@ function UpdateProjectModel(accountId, projectId, name, description, address, nu
|
|
|
10
10
|
this.projectNumber = number;
|
|
11
11
|
this.projectStartDate = startDate;
|
|
12
12
|
this.projectEndDate = endDate;
|
|
13
|
+
this.onboardedVendors = onboardedVendors;
|
|
13
14
|
|
|
14
15
|
this.city = city;
|
|
15
16
|
this.state = state;
|
|
@@ -7,7 +7,8 @@ function UpdateProjectSettingsModel({
|
|
|
7
7
|
onboardingPhase = false,
|
|
8
8
|
projectId=null,
|
|
9
9
|
qrEnabled = false,
|
|
10
|
-
tenantSolution = false
|
|
10
|
+
tenantSolution = false,
|
|
11
|
+
autocompleteAddVendors = defaultAutocompleteAddVendors,
|
|
11
12
|
|
|
12
13
|
}) {
|
|
13
14
|
this.autoGaps = autoGaps;
|
|
@@ -18,6 +19,7 @@ function UpdateProjectSettingsModel({
|
|
|
18
19
|
this.projectId = projectId;
|
|
19
20
|
this.qrEnabled = qrEnabled;
|
|
20
21
|
this.tenantSolution = tenantSolution;
|
|
22
|
+
this.autocompleteAddVendors = autocompleteAddVendors;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
module.exports = UpdateProjectSettingsModel;
|
|
@@ -25,10 +27,14 @@ module.exports = UpdateProjectSettingsModel;
|
|
|
25
27
|
const defaultMarketplace = {
|
|
26
28
|
marketplaceEnabled: false,
|
|
27
29
|
marketplacePreApproved: false,
|
|
28
|
-
|
|
30
|
+
marketplaceOnboardedVendors:false
|
|
29
31
|
};
|
|
30
32
|
const defaultAutoGaps = {
|
|
31
33
|
Guests: false,
|
|
32
34
|
Tenants: false,
|
|
33
35
|
Vendors: false
|
|
36
|
+
};
|
|
37
|
+
const defaultAutocompleteAddVendors = {
|
|
38
|
+
autocompleteAddVendorsForPm: false,
|
|
39
|
+
autocompleteAddVendorsForTenants: false,
|
|
34
40
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const requests = require('../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
create: recordId => `${backendUrl}/saas/contractors/${recordId}/notes`,
|
|
6
|
+
getNotesByRecordId: recordId => `${backendUrl}/saas/contractors/${recordId}/notes`,
|
|
7
|
+
getNotesCountByRecordId: recordId => `${backendUrl}/saas/contractors/${recordId}/notes/count`,
|
|
8
|
+
deleteByNoteId: noteId => `${backendUrl}/saas/contractors/notes/${noteId}`,
|
|
9
|
+
updateByNoteId: noteId => `${backendUrl}/saas/contractors/notes/${noteId}`,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const createRecordNote = async (recordId, data, context) => {
|
|
13
|
+
return requests.postRequestHandler(Endpoints.create(recordId), data, context);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getNotesByRecordId = async (recordId, context) => {
|
|
17
|
+
return requests.getRequestHandler(Endpoints.getNotesByRecordId(recordId), {}, context);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getNotesCountByRecordId = async (recordId, context) => {
|
|
21
|
+
return requests.getRequestHandler(Endpoints.getNotesCountByRecordId(recordId), {}, context);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const deleteByNoteId = async (id, data, context) => {
|
|
25
|
+
const headers = {};
|
|
26
|
+
const params = {};
|
|
27
|
+
return requests.deleteRequestHandler(Endpoints.deleteByNoteId(id), context, headers, params, data);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const updateByNoteId = async (id, data, context) => {
|
|
31
|
+
return requests.putRequestHandler(Endpoints.updateByNoteId(id), data, context);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
createRecordNote,
|
|
36
|
+
getNotesByRecordId,
|
|
37
|
+
getNotesCountByRecordId,
|
|
38
|
+
deleteByNoteId,
|
|
39
|
+
updateByNoteId
|
|
40
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const recordNotesAPI = require('./record.notes.api');
|
|
2
|
+
|
|
3
|
+
const createRecordNote = async (recordId, data, context) => {
|
|
4
|
+
return recordNotesAPI.createRecordNote(recordId, data, context);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const getNotesByRecordId = async (recordId, context) => {
|
|
8
|
+
return recordNotesAPI.getNotesByRecordId(recordId, context);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getNotesCountByRecordId = async (recordId, context) => {
|
|
12
|
+
return recordNotesAPI.getNotesCountByRecordId(recordId, context);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const deleteByNoteId = async (noteId, data, context) => {
|
|
16
|
+
return recordNotesAPI.deleteByNoteId(noteId, data, context);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const updateByNoteId = async (noteId, data, context) => {
|
|
20
|
+
return recordNotesAPI.updateByNoteId(noteId, data, context);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
createRecordNote,
|
|
25
|
+
getNotesByRecordId,
|
|
26
|
+
getNotesCountByRecordId,
|
|
27
|
+
deleteByNoteId,
|
|
28
|
+
updateByNoteId
|
|
29
|
+
};
|
|
@@ -2,26 +2,26 @@ const requests = require('../../common/requests');
|
|
|
2
2
|
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
getTabsByProjectId: `${backendUrl}/saas/vendortab`,
|
|
6
|
+
create: `${backendUrl}/saas/vendortab`,
|
|
7
|
+
update: `${backendUrl}/saas/vendortab`,
|
|
8
|
+
delete: `${backendUrl}/saas/vendortab`
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const getTabsByProjectId = async (projectId, context) => {
|
|
12
|
-
|
|
12
|
+
return requests.getRequestHandler(Endpoints.getTabsByProjectId, { projectId }, context).then(res => res.data);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const createTab = async (tabModel, context) => {
|
|
16
|
-
|
|
16
|
+
return requests.postRequestHandler(Endpoints.create, tabModel, context);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const updateTab = async (tabModel, context) => {
|
|
20
|
-
|
|
20
|
+
return requests.postRequestHandler(Endpoints.update, tabModel, context);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const deleteTab = async (tabId, context) => {
|
|
24
|
-
|
|
24
|
+
return requests.deleteRequestHandler(Endpoints.delete, context, {}, { tabId });
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
module.exports = { getTabsByProjectId, createTab, updateTab, deleteTab };
|
|
27
|
+
module.exports = { getTabsByProjectId, createTab, updateTab, deleteTab };
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
const tabsAPI = require('./tabs.api');
|
|
2
2
|
|
|
3
3
|
const createTab = async (projectId, tabName, tabType, context) => {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const tabModel = { projectId, tabName, type: tabType };
|
|
5
|
+
return tabsAPI.createTab(tabModel, context);
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
const updateTab = async (projectId, tabName, tabType, tabId, context) => {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const tabModel = { projectId, tabName, type: tabType, tabId };
|
|
10
|
+
return tabsAPI.updateTab(tabModel, context);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const getTabsByProjectId = async (projectId, context) => {
|
|
14
|
-
|
|
14
|
+
return tabsAPI.getTabsByProjectId(projectId, context);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const tabs = await tabsAPI.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
23
|
};
|
|
24
24
|
|
|
25
25
|
const deleteTabById = async (tabId, context) => {
|
|
26
|
-
|
|
26
|
+
return tabsAPI.deleteTab(tabId, context);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const getOrCreateTab = async (projectId, tabName, tabType, context) => {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const tabs = await getTabsByProjectId(projectId, context);
|
|
31
|
+
const existingTab = tabs.find(tab => tab.tabName === tabName && tab.type === tabType);
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (existingTab) {
|
|
34
|
+
return existingTab;
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
return createTab(projectId, tabName, tabType, context);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
module.exports = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
41
|
+
getTabsByProjectId,
|
|
42
|
+
createTab,
|
|
43
|
+
updateTab,
|
|
44
|
+
deleteTabById,
|
|
45
|
+
getOrCreateTab,
|
|
46
|
+
getTabsByName
|
|
47
|
+
};
|
|
@@ -2,28 +2,28 @@ const requests = require('../../common/requests');
|
|
|
2
2
|
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
3
|
|
|
4
4
|
const Endpoints = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
invite: projectId => `${backendUrl}/saas/project/${projectId}/team-member`,
|
|
6
|
+
getByProjectId: projectId => `${backendUrl}/saas/project/${projectId}/team-members`,
|
|
7
|
+
getByEmail: email => `${backendUrl}/saas/team-member/by-email/${email}`,
|
|
8
|
+
delete: userId => `${backendUrl}/saas/users/${userId}`
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const invite = async (projectId, invitedUser, context) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
return requests.putRequestHandler(Endpoints.invite(projectId), invitedUser, context).then(
|
|
13
|
+
res => res.data
|
|
14
|
+
);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const getUsersByProjectId = async (projectId, context) => {
|
|
18
|
-
|
|
18
|
+
return requests.getRequestHandler(Endpoints.getByProjectId(projectId), null, context).then(res => res.data);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const getUserByEmail = async (email, context) => {
|
|
22
|
-
|
|
22
|
+
return requests.getRequestHandler(Endpoints.getByEmail(email), null, context).then(res => res.data);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const deleteUser = async (userId, context) => {
|
|
26
|
-
|
|
26
|
+
return requests.deleteRequestHandler(Endpoints.delete(userId), context);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };
|
|
29
|
+
module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const inviteUserAPI = require('./invite.api');
|
|
2
2
|
|
|
3
3
|
const invite = async (projectId, invitedUser, context) => {
|
|
4
|
-
|
|
4
|
+
return inviteUserAPI.invite(projectId, invitedUser, context);
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
const getUsersByProjectId = async (projectId, context) => {
|
|
8
|
-
|
|
8
|
+
return inviteUserAPI.getUsersByProjectId(projectId, context);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const getUserByEmail = async (email, context) => {
|
|
12
|
-
|
|
12
|
+
return inviteUserAPI.getUserByEmail(email, context);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const deleteUser = (userId, context) => {
|
|
16
|
-
|
|
16
|
+
return inviteUserAPI.deleteUser(userId, context);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };
|
|
19
|
+
module.exports = { invite, getUsersByProjectId, getUserByEmail, deleteUser };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const requests = require('../../common/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
getVendorProfileJson: (contractorId, requirementId) => `${backendUrl}/saas/vendorProfile/contractor/${contractorId}/requirement/${requirementId}/immediateComplianceReport`
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const createVendorProfileReport = async (contractorId, requirementId, context) => {
|
|
9
|
+
return requests.getRequestHandler(Endpoints.getVendorProfileJson(contractorId, requirementId), {}, context);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
createVendorProfileReport
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const vendorProfileApi = require('./vendor.profile.api');
|
|
2
|
+
|
|
3
|
+
const createVendorProfileReport = async (contractorId, requirementId, context) => {
|
|
4
|
+
return vendorProfileApi.createVendorProfileReport(contractorId, requirementId, context);
|
|
5
|
+
};
|
|
6
|
+
module.exports = {
|
|
7
|
+
createVendorProfileReport
|
|
8
|
+
};
|
package/tests/env.test.js
CHANGED
|
@@ -5,37 +5,36 @@ const { expect } = chai;
|
|
|
5
5
|
const env = require('../src/env');
|
|
6
6
|
|
|
7
7
|
describe('Env | Test Core Logic', async function() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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.deep.equal(expectedSanityAssignVariables, 'Assign configuration did not work properly');
|
|
39
|
+
});
|
|
41
40
|
});
|