@getjones/test-infra 2.1.2 → 2.1.4
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 +29 -29
- package/src/common/commonFlows/index.js +3 -3
- package/src/common/commonFlows/records/records.js +71 -71
- package/src/common/httpResponseStatusCodes.json +11 -11
- package/src/common/requests/apiKeyAuth/requests.js +38 -38
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/requestHandlers.js +60 -60
- package/src/common/utils/dataTypeUtils.js +41 -0
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/timeUtils.js +167 -162
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/env.js +45 -45
- package/src/index.js +71 -69
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
- package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
- package/src/saas/internal-api/accounts/index.js +20 -20
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +15 -15
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +23 -21
- package/src/saas/internal-api/accounts/utils/utils.js +32 -32
- package/src/saas/internal-api/auth/api/auth.api.js +18 -12
- package/src/saas/internal-api/auth/api/auth.service.js +75 -47
- package/src/saas/internal-api/auth/index.js +3 -3
- package/src/saas/internal-api/coi/api/coi.api.js +34 -34
- package/src/saas/internal-api/coi/api/coi.service.js +22 -22
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +7 -7
- package/src/saas/internal-api/coi/index.js +13 -13
- package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
- package/src/saas/internal-api/coi/utils/utils.js +48 -48
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +41 -40
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +151 -33
- package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
- package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
- package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
- package/src/saas/internal-api/compliance/api/waive/waive.service.js +15 -15
- package/src/saas/internal-api/compliance/consts/audit.js +81 -81
- package/src/saas/internal-api/compliance/index.js +28 -28
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +84 -84
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
- package/src/saas/internal-api/compliance/utils/util.js +173 -218
- package/src/saas/internal-api/contractors/api/contractors.api.js +141 -141
- package/src/saas/internal-api/contractors/api/contractors.service.js +123 -123
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.api.js +12 -0
- package/src/saas/internal-api/dashboardInnerPage/api/recordList.service.js +7 -0
- package/src/saas/internal-api/dashboardInnerPage/index.js +5 -0
- package/src/saas/internal-api/dashboardInnerPage/models/dashboard.filter.criteria.model.js +38 -0
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
- package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
- package/src/saas/internal-api/dbEmails/index.js +4 -4
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
- package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
- package/src/saas/internal-api/globalRecord/consts.js +20 -20
- package/src/saas/internal-api/globalRecord/index.js +6 -6
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
- package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
- package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
- package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
- package/src/saas/internal-api/homepageCharts/index.js +3 -3
- package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
- package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
- package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
- package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
- package/src/saas/internal-api/projects/index.js +24 -24
- package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
- package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
- package/src/saas/internal-api/projects/utils/utils.js +82 -82
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
- package/src/saas/internal-api/recordNotes/index.js +3 -3
- package/src/saas/internal-api/reports/api/reports.api.js +39 -39
- package/src/saas/internal-api/reports/api/reports.service.js +34 -34
- package/src/saas/internal-api/reports/consts/consts.js +63 -63
- package/src/saas/internal-api/reports/index.js +15 -15
- package/src/saas/internal-api/reports/models/report.model.js +27 -27
- package/src/saas/internal-api/requests/api/requests.api.js +54 -54
- package/src/saas/internal-api/requests/api/requests.service.js +51 -51
- package/src/saas/internal-api/requests/index.js +14 -14
- package/src/saas/internal-api/requests/models/create.request.model.js +22 -22
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requests/utils.js +8 -8
- package/src/saas/internal-api/requirements/api/requirements.api.js +27 -27
- package/src/saas/internal-api/requirements/api/requirements.service.js +23 -23
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -0
- package/src/saas/internal-api/requirements/index.js +6 -6
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +45 -45
- package/src/saas/internal-api/requirements/utils/utils.js +88 -0
- package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
- package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
- package/src/saas/internal-api/serviceArea/index.js +4 -4
- package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
- package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
- package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
- package/src/saas/internal-api/tabs/index.js +3 -3
- package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
- package/src/saas/internal-api/thread-scheduler/runner.js +13 -13
- package/src/saas/internal-api/users/api/users.api.js +77 -77
- package/src/saas/internal-api/users/api/users.service.js +101 -101
- package/src/saas/internal-api/users/index.js +4 -4
- package/src/saas/internal-api/users/models/users.model.js +31 -31
- package/src/saas/internal-api/users/utils/util.js +14 -14
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
- package/src/saas/internal-api/vendorProfile/index.js +3 -3
- package/src/saas/openapi/accounts/accounts.api.js +17 -17
- package/src/saas/openapi/accounts/accounts.service.js +11 -11
- package/src/saas/openapi/projects/projects.api.js +59 -59
- package/src/saas/openapi/projects/projects.service.js +44 -44
- package/src/saas/openapi/requests/index.js +6 -6
- package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
- package/src/saas/openapi/requests/requests.api.js +20 -20
- package/src/saas/openapi/requests/requests.service.js +18 -18
- package/src/saas/openapi/requirements/index.js +6 -6
- package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
- package/src/saas/openapi/requirements/requirements.api.js +12 -12
- package/src/saas/openapi/requirements/requirements.service.js +20 -20
- package/src/saas/openapi/tabs/tabs.api.js +13 -13
- package/src/saas/openapi/tabs/tabs.service.js +7 -7
- package/tests/env.test.js +40 -40
- package/tests/validation.test.js +83 -83
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@getjones/test-infra",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "Providing internal and openapi interface",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout 10000 --exit --inlineDiffs --bail",
|
|
8
|
-
"eslint-fix": "eslint \"./src/**/*.js\" --fix"
|
|
9
|
-
},
|
|
10
|
-
"author": "",
|
|
11
|
-
"license": "ISC",
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"axios": "^0.21.1",
|
|
14
|
-
"axios-file": "^1.0.17",
|
|
15
|
-
"chai": "^4.3.4",
|
|
16
|
-
"dotenv": "^8.2.0",
|
|
17
|
-
"enum": "^3.0.4",
|
|
18
|
-
"mocha": "^8.3.2"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"babel-eslint": "^10.0.3",
|
|
22
|
-
"eslint": "^6.8.0",
|
|
23
|
-
"eslint-plugin-import": "^2.19.1",
|
|
24
|
-
"mocha-spec-json-output-reporter": "^1.1.7"
|
|
25
|
-
},
|
|
26
|
-
"directories": {
|
|
27
|
-
"test": "tests"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@getjones/test-infra",
|
|
3
|
+
"version": "2.1.4",
|
|
4
|
+
"description": "Providing internal and openapi interface",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout 10000 --exit --inlineDiffs --bail",
|
|
8
|
+
"eslint-fix": "eslint \"./src/**/*.js\" --fix"
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "^0.21.1",
|
|
14
|
+
"axios-file": "^1.0.17",
|
|
15
|
+
"chai": "^4.3.4",
|
|
16
|
+
"dotenv": "^8.2.0",
|
|
17
|
+
"enum": "^3.0.4",
|
|
18
|
+
"mocha": "^8.3.2"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"babel-eslint": "^10.0.3",
|
|
22
|
+
"eslint": "^6.8.0",
|
|
23
|
+
"eslint-plugin-import": "^2.19.1",
|
|
24
|
+
"mocha-spec-json-output-reporter": "^1.1.7"
|
|
25
|
+
},
|
|
26
|
+
"directories": {
|
|
27
|
+
"test": "tests"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const records = require('./records/records');
|
|
2
|
-
|
|
3
|
-
module.exports = { records };
|
|
1
|
+
const records = require('./records/records');
|
|
2
|
+
|
|
3
|
+
module.exports = { records };
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
const { expect } = require('chai');
|
|
2
|
-
|
|
3
|
-
const threadScheduler = require('../../../saas/internal-api/thread-scheduler/runner');
|
|
4
|
-
const timeUtils = require('../../utils/timeUtils');
|
|
5
|
-
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
6
|
-
const contractors = require('../../../saas/internal-api/contractors');
|
|
7
|
-
|
|
8
|
-
const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
|
|
9
|
-
const dates = isTenant ?
|
|
10
|
-
timeUtils.getInvitationDatesForNotResponsiveTenant() :
|
|
11
|
-
timeUtils.getInvitationDatesForNotResponsiveVendor();
|
|
12
|
-
|
|
13
|
-
for (const date of dates) {
|
|
14
|
-
await updateInviteDate(recordId, date, context);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const updateInviteDate = async function(recordId, inviteDate, context) {
|
|
19
|
-
const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
|
|
20
|
-
|
|
21
|
-
if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
22
|
-
throw new Error('Record invite date could not be updated', updateResponse);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const threadSchedulerResponse = await threadScheduler.runThreadScheduler({ contractorIds: [recordId] });
|
|
26
|
-
|
|
27
|
-
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
28
|
-
throw new Error('Thread scheduler has failed to run', threadSchedulerResponse);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
|
|
35
|
-
const dates = timeUtils.getAutomaticRenewalsExpirationDates();
|
|
36
|
-
|
|
37
|
-
for (const date of dates) {
|
|
38
|
-
await updatePolicyExpiryDateForRecord(recordId, date, policyName);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
|
|
43
|
-
const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
|
|
44
|
-
|
|
45
|
-
if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
46
|
-
throw new Error('Record expiry date could not be updated', updateResponse);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const threadSchedulerResponse = await threadScheduler.runThreadScheduler({ contractorIds: [recordId] });
|
|
50
|
-
|
|
51
|
-
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
52
|
-
throw new Error('Thread scheduler has failed to run', threadSchedulerResponse);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getHistoryEvents = async function(recordId, context) {
|
|
59
|
-
const recordHistory = await contractors.services.getRecordHistory(recordId, context);
|
|
60
|
-
expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
|
|
61
|
-
|
|
62
|
-
return recordHistory.data.map(item => item.itemTitle).reverse();
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
module.exports = {
|
|
66
|
-
makeRecordNotResponsive,
|
|
67
|
-
runOverAllRenewalDatesForRecord,
|
|
68
|
-
updateInviteDate,
|
|
69
|
-
updatePolicyExpiryDateForRecord,
|
|
70
|
-
getHistoryEvents
|
|
71
|
-
};
|
|
1
|
+
const { expect } = require('chai');
|
|
2
|
+
|
|
3
|
+
const threadScheduler = require('../../../saas/internal-api/thread-scheduler/runner');
|
|
4
|
+
const timeUtils = require('../../utils/timeUtils');
|
|
5
|
+
const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
|
|
6
|
+
const contractors = require('../../../saas/internal-api/contractors');
|
|
7
|
+
|
|
8
|
+
const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
|
|
9
|
+
const dates = isTenant ?
|
|
10
|
+
timeUtils.getInvitationDatesForNotResponsiveTenant() :
|
|
11
|
+
timeUtils.getInvitationDatesForNotResponsiveVendor();
|
|
12
|
+
|
|
13
|
+
for (const date of dates) {
|
|
14
|
+
await updateInviteDate(recordId, date, context);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const updateInviteDate = async function(recordId, inviteDate, context) {
|
|
19
|
+
const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
|
|
20
|
+
|
|
21
|
+
if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
22
|
+
throw new Error('Record invite date could not be updated', updateResponse);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const threadSchedulerResponse = await threadScheduler.runThreadScheduler({ contractorIds: [recordId] });
|
|
26
|
+
|
|
27
|
+
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
28
|
+
throw new Error('Thread scheduler has failed to run', threadSchedulerResponse);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
|
|
35
|
+
const dates = timeUtils.getAutomaticRenewalsExpirationDates();
|
|
36
|
+
|
|
37
|
+
for (const date of dates) {
|
|
38
|
+
await updatePolicyExpiryDateForRecord(recordId, date, policyName);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
|
|
43
|
+
const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
|
|
44
|
+
|
|
45
|
+
if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
46
|
+
throw new Error('Record expiry date could not be updated', updateResponse);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const threadSchedulerResponse = await threadScheduler.runThreadScheduler({ contractorIds: [recordId] });
|
|
50
|
+
|
|
51
|
+
if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
|
|
52
|
+
throw new Error('Thread scheduler has failed to run', threadSchedulerResponse);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getHistoryEvents = async function(recordId, context) {
|
|
59
|
+
const recordHistory = await contractors.services.getRecordHistory(recordId, context);
|
|
60
|
+
expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
|
|
61
|
+
|
|
62
|
+
return recordHistory.data.map(item => item.itemTitle).reverse();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
module.exports = {
|
|
66
|
+
makeRecordNotResponsive,
|
|
67
|
+
runOverAllRenewalDatesForRecord,
|
|
68
|
+
updateInviteDate,
|
|
69
|
+
updatePolicyExpiryDateForRecord,
|
|
70
|
+
getHistoryEvents
|
|
71
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"OK": 200,
|
|
3
|
-
"NO_CONTENT": 204,
|
|
4
|
-
"IM_USED": 226,
|
|
5
|
-
"BAD_REQUEST": 400,
|
|
6
|
-
"UNAUTHORIZED": 401,
|
|
7
|
-
"FORBIDDEN": 403,
|
|
8
|
-
"NOT_FOUND": 404,
|
|
9
|
-
"CONFLICT": 409,
|
|
10
|
-
"TOO_MANY_REQUESTS": 429,
|
|
11
|
-
"CLIENT_CLOSED_REQUEST": 499
|
|
1
|
+
{
|
|
2
|
+
"OK": 200,
|
|
3
|
+
"NO_CONTENT": 204,
|
|
4
|
+
"IM_USED": 226,
|
|
5
|
+
"BAD_REQUEST": 400,
|
|
6
|
+
"UNAUTHORIZED": 401,
|
|
7
|
+
"FORBIDDEN": 403,
|
|
8
|
+
"NOT_FOUND": 404,
|
|
9
|
+
"CONFLICT": 409,
|
|
10
|
+
"TOO_MANY_REQUESTS": 429,
|
|
11
|
+
"CLIENT_CLOSED_REQUEST": 499
|
|
12
12
|
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const requestHandler = require('./../requestHandlers');
|
|
2
|
-
|
|
3
|
-
const getRequestHandler = (url, apiKey, params = {}, headers = {}) => {
|
|
4
|
-
enrichApiKey(headers, apiKey);
|
|
5
|
-
return requestHandler.getRequestHandler(url, headers, params);
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const postRequestHandler = (url, apiKey, body, headers = {}, params = {}) => {
|
|
9
|
-
enrichApiKey(headers, apiKey);
|
|
10
|
-
return requestHandler.postRequestHandler(url, body, headers, params);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const putRequestHandler = (url, apiKey, body, headers = {}, params = {}) => {
|
|
14
|
-
enrichApiKey(headers, apiKey);
|
|
15
|
-
return requestHandler.putRequestHandler(url, body, headers, params);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const patchRequestHandler = (url, apiKey, body, headers = {}) => {
|
|
19
|
-
enrichApiKey(headers, apiKey);
|
|
20
|
-
return requestHandler.patchRequestHandler(url, body, headers);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const deleteRequestHandler = (url, apiKey, headers = {}, params = {}, data = {}) => {
|
|
24
|
-
enrichApiKey(headers, apiKey);
|
|
25
|
-
return requestHandler.deleteRequestHandler(url, headers, params, data);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const enrichApiKey = (headers, apiKey) => {
|
|
29
|
-
headers['x-api-key'] = apiKey;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
module.exports = {
|
|
33
|
-
getRequestHandler,
|
|
34
|
-
postRequestHandler,
|
|
35
|
-
putRequestHandler,
|
|
36
|
-
patchRequestHandler,
|
|
37
|
-
deleteRequestHandler
|
|
38
|
-
};
|
|
1
|
+
const requestHandler = require('./../requestHandlers');
|
|
2
|
+
|
|
3
|
+
const getRequestHandler = (url, apiKey, params = {}, headers = {}) => {
|
|
4
|
+
enrichApiKey(headers, apiKey);
|
|
5
|
+
return requestHandler.getRequestHandler(url, headers, params);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const postRequestHandler = (url, apiKey, body, headers = {}, params = {}) => {
|
|
9
|
+
enrichApiKey(headers, apiKey);
|
|
10
|
+
return requestHandler.postRequestHandler(url, body, headers, params);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const putRequestHandler = (url, apiKey, body, headers = {}, params = {}) => {
|
|
14
|
+
enrichApiKey(headers, apiKey);
|
|
15
|
+
return requestHandler.putRequestHandler(url, body, headers, params);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const patchRequestHandler = (url, apiKey, body, headers = {}) => {
|
|
19
|
+
enrichApiKey(headers, apiKey);
|
|
20
|
+
return requestHandler.patchRequestHandler(url, body, headers);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const deleteRequestHandler = (url, apiKey, headers = {}, params = {}, data = {}) => {
|
|
24
|
+
enrichApiKey(headers, apiKey);
|
|
25
|
+
return requestHandler.deleteRequestHandler(url, headers, params, data);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const enrichApiKey = (headers, apiKey) => {
|
|
29
|
+
headers['x-api-key'] = apiKey;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
getRequestHandler,
|
|
34
|
+
postRequestHandler,
|
|
35
|
+
putRequestHandler,
|
|
36
|
+
patchRequestHandler,
|
|
37
|
+
deleteRequestHandler
|
|
38
|
+
};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
const requestHandler = require('./../requestHandlers');
|
|
2
|
-
|
|
3
|
-
const getRequestHandler = (url, params = {}, context = null, headers = {}) => {
|
|
4
|
-
enrichCookie(headers, context);
|
|
5
|
-
return requestHandler.getRequestHandler(url, headers, params);
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const postRequestHandler = (url, body, context = null, headers = {}, params = {}) => {
|
|
9
|
-
enrichCookie(headers, context);
|
|
10
|
-
return requestHandler.postRequestHandler(url, body, headers, params);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const putRequestHandler = (url, body, context = null, headers = {}, params = {}) => {
|
|
14
|
-
enrichCookie(headers, context);
|
|
15
|
-
return requestHandler.putRequestHandler(url, body, headers, params);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const patchRequestHandler = (url, context, body, headers = {}) => {
|
|
19
|
-
enrichCookie(headers, context);
|
|
20
|
-
return requestHandler.patchRequestHandler(url, body, headers);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const deleteRequestHandler = (url, context = null, headers = {}, params = {}, data = {}) => {
|
|
24
|
-
enrichCookie(headers, context);
|
|
25
|
-
return requestHandler.deleteRequestHandler(url, headers, params, data);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const enrichCookie = (headers, context) => {
|
|
29
|
-
if (context) {
|
|
30
|
-
headers.Cookie = context;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
getRequestHandler,
|
|
36
|
-
postRequestHandler,
|
|
37
|
-
putRequestHandler,
|
|
38
|
-
patchRequestHandler,
|
|
39
|
-
deleteRequestHandler
|
|
40
|
-
};
|
|
1
|
+
const requestHandler = require('./../requestHandlers');
|
|
2
|
+
|
|
3
|
+
const getRequestHandler = (url, params = {}, context = null, headers = {}) => {
|
|
4
|
+
enrichCookie(headers, context);
|
|
5
|
+
return requestHandler.getRequestHandler(url, headers, params);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const postRequestHandler = (url, body, context = null, headers = {}, params = {}) => {
|
|
9
|
+
enrichCookie(headers, context);
|
|
10
|
+
return requestHandler.postRequestHandler(url, body, headers, params);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const putRequestHandler = (url, body, context = null, headers = {}, params = {}) => {
|
|
14
|
+
enrichCookie(headers, context);
|
|
15
|
+
return requestHandler.putRequestHandler(url, body, headers, params);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const patchRequestHandler = (url, context, body, headers = {}) => {
|
|
19
|
+
enrichCookie(headers, context);
|
|
20
|
+
return requestHandler.patchRequestHandler(url, body, headers);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const deleteRequestHandler = (url, context = null, headers = {}, params = {}, data = {}) => {
|
|
24
|
+
enrichCookie(headers, context);
|
|
25
|
+
return requestHandler.deleteRequestHandler(url, headers, params, data);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const enrichCookie = (headers, context) => {
|
|
29
|
+
if (context) {
|
|
30
|
+
headers.Cookie = context;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
getRequestHandler,
|
|
36
|
+
postRequestHandler,
|
|
37
|
+
putRequestHandler,
|
|
38
|
+
patchRequestHandler,
|
|
39
|
+
deleteRequestHandler
|
|
40
|
+
};
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
const errorValidation = require('../validations/errorValidation');
|
|
3
|
-
|
|
4
|
-
const getRequestHandler = async (url, headers = {}, params = {}) => {
|
|
5
|
-
try {
|
|
6
|
-
const response = await axios.get(url, { params, headers });
|
|
7
|
-
return response;
|
|
8
|
-
} catch (error) {
|
|
9
|
-
errorValidation.validateClientErrorResponseStatus(error);
|
|
10
|
-
return error.response;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const postRequestHandler = async (url, body, headers = {}, params = {}) => {
|
|
15
|
-
try {
|
|
16
|
-
const response = await axios.post(url, body, { headers, params });
|
|
17
|
-
return response;
|
|
18
|
-
} catch (error) {
|
|
19
|
-
errorValidation.validateClientErrorResponseStatus(error);
|
|
20
|
-
return error.response;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const putRequestHandler = async (url, body, headers = {}, params = {}) => {
|
|
25
|
-
try {
|
|
26
|
-
const response = await axios.put(url, body, { headers, params });
|
|
27
|
-
return response;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
errorValidation.validateClientErrorResponseStatus(error);
|
|
30
|
-
return error.response;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const patchRequestHandler = async (url, body, headers = {}) => {
|
|
35
|
-
try {
|
|
36
|
-
const response = await axios.patch(url, body, { headers });
|
|
37
|
-
return response;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
errorValidation.validateClientErrorResponseStatus(error);
|
|
40
|
-
return error.response;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const deleteRequestHandler = async (url, headers = {}, params = {}, data = {}) => {
|
|
45
|
-
try {
|
|
46
|
-
const response = await axios.delete(url, { params, headers, data });
|
|
47
|
-
return response;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
errorValidation.validateClientErrorResponseStatus(error);
|
|
50
|
-
return error.response;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
module.exports = {
|
|
55
|
-
getRequestHandler,
|
|
56
|
-
postRequestHandler,
|
|
57
|
-
putRequestHandler,
|
|
58
|
-
patchRequestHandler,
|
|
59
|
-
deleteRequestHandler
|
|
60
|
-
};
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const errorValidation = require('../validations/errorValidation');
|
|
3
|
+
|
|
4
|
+
const getRequestHandler = async (url, headers = {}, params = {}) => {
|
|
5
|
+
try {
|
|
6
|
+
const response = await axios.get(url, { params, headers });
|
|
7
|
+
return response;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
errorValidation.validateClientErrorResponseStatus(error);
|
|
10
|
+
return error.response;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const postRequestHandler = async (url, body, headers = {}, params = {}) => {
|
|
15
|
+
try {
|
|
16
|
+
const response = await axios.post(url, body, { headers, params });
|
|
17
|
+
return response;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
errorValidation.validateClientErrorResponseStatus(error);
|
|
20
|
+
return error.response;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const putRequestHandler = async (url, body, headers = {}, params = {}) => {
|
|
25
|
+
try {
|
|
26
|
+
const response = await axios.put(url, body, { headers, params });
|
|
27
|
+
return response;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
errorValidation.validateClientErrorResponseStatus(error);
|
|
30
|
+
return error.response;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const patchRequestHandler = async (url, body, headers = {}) => {
|
|
35
|
+
try {
|
|
36
|
+
const response = await axios.patch(url, body, { headers });
|
|
37
|
+
return response;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
errorValidation.validateClientErrorResponseStatus(error);
|
|
40
|
+
return error.response;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const deleteRequestHandler = async (url, headers = {}, params = {}, data = {}) => {
|
|
45
|
+
try {
|
|
46
|
+
const response = await axios.delete(url, { params, headers, data });
|
|
47
|
+
return response;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
errorValidation.validateClientErrorResponseStatus(error);
|
|
50
|
+
return error.response;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
getRequestHandler,
|
|
56
|
+
postRequestHandler,
|
|
57
|
+
putRequestHandler,
|
|
58
|
+
patchRequestHandler,
|
|
59
|
+
deleteRequestHandler
|
|
60
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const dataTypes = Object.freeze({
|
|
2
|
+
object: 'object',
|
|
3
|
+
boolean: 'boolean',
|
|
4
|
+
string: 'string',
|
|
5
|
+
number: 'number'
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const validateValueDataType = (value, type) => {
|
|
9
|
+
return value !== null
|
|
10
|
+
&& value !== undefined
|
|
11
|
+
&& typeof value === type;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const isObject = value => {
|
|
15
|
+
return validateValueDataType(value, dataTypes.object)
|
|
16
|
+
&& !isArray(value);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const isArray = value => {
|
|
20
|
+
return Array.isArray(value);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const isBoolean = value => {
|
|
24
|
+
return validateValueDataType(value, dataTypes.boolean);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const isString = value => {
|
|
28
|
+
return validateValueDataType(value, dataTypes.string) || value instanceof String;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const isNumber = value => {
|
|
32
|
+
return validateValueDataType(value, dataTypes.number) && Number.isFinite(value);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
isObject,
|
|
37
|
+
isArray,
|
|
38
|
+
isBoolean,
|
|
39
|
+
isString,
|
|
40
|
+
isNumber
|
|
41
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const { v4: uuidv4 } = require('uuid');
|
|
2
|
-
|
|
3
|
-
const getRandomNumberInRange = (min, max) => {
|
|
4
|
-
min = Math.ceil(min);
|
|
5
|
-
max = Math.floor(max);
|
|
6
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const getCapitalLetterUnicodeValueList = ({ listLength = 26 }) => {
|
|
10
|
-
//This code number represent the letter A
|
|
11
|
-
const firstLetterUnicodeValue = 65;
|
|
12
|
-
//Return list of unicodes values for all alphabet letters.
|
|
13
|
-
//The index value will be in the ranges between 1-26 (The English alphabet has 26 letters)
|
|
14
|
-
//In case listLength will be bigger then 26, index will start the cycle again respectively to the ranges
|
|
15
|
-
return Array.from(Array(listLength)).map((_, index) => (index % 26) + firstLetterUnicodeValue);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const getUniqueNumber = () => {
|
|
19
|
-
return uuidv4();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
module.exports = { getRandomNumberInRange, getCapitalLetterUnicodeValueList, getUniqueNumber };
|
|
1
|
+
const { v4: uuidv4 } = require('uuid');
|
|
2
|
+
|
|
3
|
+
const getRandomNumberInRange = (min, max) => {
|
|
4
|
+
min = Math.ceil(min);
|
|
5
|
+
max = Math.floor(max);
|
|
6
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const getCapitalLetterUnicodeValueList = ({ listLength = 26 }) => {
|
|
10
|
+
//This code number represent the letter A
|
|
11
|
+
const firstLetterUnicodeValue = 65;
|
|
12
|
+
//Return list of unicodes values for all alphabet letters.
|
|
13
|
+
//The index value will be in the ranges between 1-26 (The English alphabet has 26 letters)
|
|
14
|
+
//In case listLength will be bigger then 26, index will start the cycle again respectively to the ranges
|
|
15
|
+
return Array.from(Array(listLength)).map((_, index) => (index % 26) + firstLetterUnicodeValue);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getUniqueNumber = () => {
|
|
19
|
+
return uuidv4();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = { getRandomNumberInRange, getCapitalLetterUnicodeValueList, getUniqueNumber };
|