@getjones/test-infra 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +29 -29
- package/src/common/factory/index.js +3 -0
- package/src/common/factory/records/records.js +45 -0
- 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/numberUtils.js +22 -22
- package/src/common/utils/timeUtils.js +147 -0
- package/src/common/validations/errorValidation.js +16 -16
- package/src/common/validations/typeValidations.js +36 -36
- package/src/env.js +45 -44
- package/src/index.js +67 -67
- 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 +19 -19
- package/src/saas/internal-api/accounts/utils/utils.js +32 -32
- package/src/saas/internal-api/auth/api/auth.api.js +12 -12
- package/src/saas/internal-api/auth/api/auth.service.js +47 -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 +40 -40
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +33 -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/index.js +22 -22
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +110 -110
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
- package/src/saas/internal-api/contractors/api/contractors.api.js +159 -165
- package/src/saas/internal-api/contractors/api/contractors.service.js +136 -141
- 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 +69 -91
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -33
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -0
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +19 -0
- package/src/saas/internal-api/dbEmails/index.js +3 -0
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -0
- 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 +28 -21
- package/src/saas/internal-api/requests/api/requests.service.js +19 -14
- package/src/saas/internal-api/requests/index.js +11 -3
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -0
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -0
- package/src/saas/internal-api/requests/models/validation.models.js +8 -0
- 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/index.js +6 -6
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +45 -45
- 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 +78 -78
- 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/contractors/contractors.api.js +20 -20
- package/src/saas/openapi/contractors/contractors.service.js +18 -18
- package/src/saas/openapi/contractors/index.js +6 -6
- package/src/saas/openapi/contractors/models/invite.contractor.model.js +37 -37
- package/src/saas/openapi/projects/projects.api.js +59 -59
- package/src/saas/openapi/projects/projects.service.js +44 -44
- 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/src/common/utils/dateUtils.js +0 -6
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@getjones/test-infra",
|
|
3
|
-
"version": "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": "1.11.0",
|
|
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
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 getHistoryEvents = async function(recordId, context) {
|
|
35
|
+
const recordHistory = await contractors.services.getRecordHistory(recordId, context);
|
|
36
|
+
expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
|
|
37
|
+
|
|
38
|
+
return recordHistory.data.map(item => item.itemTitle).reverse();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
makeRecordNotResponsive,
|
|
43
|
+
updateInviteDate,
|
|
44
|
+
getHistoryEvents
|
|
45
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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 };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
const moment = require('moment');
|
|
2
|
+
|
|
3
|
+
const secondsInDay = 86400;
|
|
4
|
+
const millisecondsToSeconds = 1000;
|
|
5
|
+
const formats = {
|
|
6
|
+
logTimeStampFormat: 'YYYY-MM-DD hh:mm:ss',
|
|
7
|
+
dayMonthYear: 'DD/MM/YYYY',
|
|
8
|
+
numericMonthDayYear: 'MM/DD/YYYY',
|
|
9
|
+
monthDayYear: 'MMM DD, YYYY',
|
|
10
|
+
monthDayYear_noZeroPrefix: 'MMM D, YYYY',
|
|
11
|
+
dateTime: 'YYYY/MM/DD-hh:mm:ss',
|
|
12
|
+
fullMonthDayYear: 'MMMM DD, YYYY',
|
|
13
|
+
threadScheduler: '', // Passing empty string resolves moment.js format to ISO8601 standard like 2020-04-12T09:49:59Z;
|
|
14
|
+
monthDayYear12hTime: 'MMM D, YYYY h:mm A',
|
|
15
|
+
amPmTime: 'h:mm A'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const peroids = {
|
|
19
|
+
days: 'days',
|
|
20
|
+
months: 'months',
|
|
21
|
+
years: 'years'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const getOneYearAgoDate = format => moment().utc().subtract(1, peroids.years).format(format || formats.threadScheduler);
|
|
25
|
+
const getSixMonthAgoDate = format => moment().utc().subtract(6, peroids.months).format(format || formats.threadScheduler);
|
|
26
|
+
const getOneMonthAgoDate = format => moment().utc().subtract(1, peroids.months).format(format || formats.threadScheduler);
|
|
27
|
+
const getFifteenDaysAgoDate = format => moment().utc().subtract(15, peroids.days).format(format || formats.threadScheduler);
|
|
28
|
+
const getTenDaysAgoDate = format => moment().utc().subtract(10, peroids.days).format(format || formats.threadScheduler);
|
|
29
|
+
const getEightDaysAgoDate = format => moment().utc().subtract(8, peroids.days).format(format || formats.threadScheduler);
|
|
30
|
+
const getFiveDaysAgoDate = format => moment().utc().subtract(5, peroids.days).format(format || formats.threadScheduler);
|
|
31
|
+
const getTwoDaysAgoDate = format => moment().utc().subtract(2, peroids.days).format(format || formats.threadScheduler);
|
|
32
|
+
const getOneDayAgoDate = format => moment().utc().subtract(1, peroids.days).format(format || formats.threadScheduler);
|
|
33
|
+
const getThirtyFiveDaysAgoDate = format => moment().utc().subtract(35, peroids.days).format(format || formats.threadScheduler);
|
|
34
|
+
const getCurrentDate = format => moment().utc().format(format || formats.threadScheduler);
|
|
35
|
+
const getDateInOneDay = format => moment().utc().add(1, peroids.days).format(format || formats.threadScheduler);
|
|
36
|
+
const getDateinSixDays = format => moment().utc().add(6, peroids.days).format(format || formats.threadScheduler);
|
|
37
|
+
const getDateinThirteenDays = format => moment().utc().add(13, peroids.days).format(format || formats.threadScheduler);
|
|
38
|
+
const getDateinTwentyNineDays = format => moment().utc().add(29, peroids.days).format(format || formats.threadScheduler);
|
|
39
|
+
|
|
40
|
+
const getLogTimestamp = () => {
|
|
41
|
+
return moment().format(formats.logTimeStampFormat);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getCurrentFormattedDate = () => {
|
|
45
|
+
return new Date().toISOString();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const getDateWithOffset = (date, offsetInDays) => {
|
|
49
|
+
date.setDate(date.getDate() + offsetInDays);
|
|
50
|
+
return date;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getAuditDateFormat = date => {
|
|
54
|
+
const year = date.getUTCFullYear();
|
|
55
|
+
const month = date.getUTCMonth() + 1; //getMonth is zero-based
|
|
56
|
+
const day = date.getUTCDate();
|
|
57
|
+
|
|
58
|
+
return `${month}/${day}/${year}`;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const getYearMonthDayFormat = date => {
|
|
62
|
+
const year = date.getUTCFullYear();
|
|
63
|
+
const month = String(date.getUTCMonth() + 1).length === 1 ? `0${(date.getUTCMonth() + 1)}` : (date.getUTCMonth() + 1);
|
|
64
|
+
const day = String(date.getUTCDate()).length === 1 ? `0${date.getUTCDate()}` : date.getUTCDate();
|
|
65
|
+
|
|
66
|
+
return `${year}-${month}-${day}`;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const dateToIsoFormat = date => {
|
|
70
|
+
return new Date(date).toISOString();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const extractDateFromDateTime = date => {
|
|
74
|
+
let extractedDate = date;
|
|
75
|
+
|
|
76
|
+
if (date != null && date.length > 10) {
|
|
77
|
+
extractedDate = date.substr(0, 10);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return extractedDate;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
function waitFor(num) {
|
|
84
|
+
return {
|
|
85
|
+
mSeconds: new Promise(resolve => {
|
|
86
|
+
setTimeout(resolve, num);
|
|
87
|
+
}),
|
|
88
|
+
seconds: new Promise(resolve => {
|
|
89
|
+
setTimeout(resolve, num * 1000);
|
|
90
|
+
})
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getDayInMilliseconds() {
|
|
95
|
+
return secondsInDay * millisecondsToSeconds;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getPreviousDateByDays(days) {
|
|
99
|
+
return new Date(new Date().getTime() - getDayInMilliseconds() * days);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const getInvitationDatesForNotResponsiveVendor = function() {
|
|
103
|
+
const twoDaysAgoUtc = getTwoDaysAgoDate();
|
|
104
|
+
const fiveDaysAgoUtc = getFiveDaysAgoDate();
|
|
105
|
+
const eightDaysAgoUtc = getEightDaysAgoDate();
|
|
106
|
+
|
|
107
|
+
return [twoDaysAgoUtc, fiveDaysAgoUtc, eightDaysAgoUtc];
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const getInvitationDatesForNotResponsiveTenant = function() {
|
|
111
|
+
const fiveDaysAgoUtc = getFiveDaysAgoDate();
|
|
112
|
+
const tenDaysAgoUtc = getTenDaysAgoDate();
|
|
113
|
+
const fifteenDaysAgoUtc = getFifteenDaysAgoDate();
|
|
114
|
+
|
|
115
|
+
return [fiveDaysAgoUtc, tenDaysAgoUtc, fifteenDaysAgoUtc];
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
module.exports = {
|
|
119
|
+
formats,
|
|
120
|
+
getOneYearAgoDate,
|
|
121
|
+
getSixMonthAgoDate,
|
|
122
|
+
getOneMonthAgoDate,
|
|
123
|
+
getFifteenDaysAgoDate,
|
|
124
|
+
getTenDaysAgoDate,
|
|
125
|
+
getEightDaysAgoDate,
|
|
126
|
+
getFiveDaysAgoDate,
|
|
127
|
+
getTwoDaysAgoDate,
|
|
128
|
+
getOneDayAgoDate,
|
|
129
|
+
getThirtyFiveDaysAgoDate,
|
|
130
|
+
getCurrentDate,
|
|
131
|
+
getDateInOneDay,
|
|
132
|
+
getDateinSixDays,
|
|
133
|
+
getDateinThirteenDays,
|
|
134
|
+
getDateinTwentyNineDays,
|
|
135
|
+
getInvitationDatesForNotResponsiveVendor,
|
|
136
|
+
getInvitationDatesForNotResponsiveTenant,
|
|
137
|
+
getLogTimestamp,
|
|
138
|
+
getCurrentFormattedDate,
|
|
139
|
+
getAuditDateFormat,
|
|
140
|
+
getDateWithOffset,
|
|
141
|
+
getYearMonthDayFormat,
|
|
142
|
+
dateToIsoFormat,
|
|
143
|
+
getDayInMilliseconds,
|
|
144
|
+
extractDateFromDateTime,
|
|
145
|
+
getPreviousDateByDays,
|
|
146
|
+
waitFor
|
|
147
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const httpResponseStatusCodes = require('../httpResponseStatusCodes.json');
|
|
2
|
-
|
|
3
|
-
const validateClientErrorResponseStatus = error => {
|
|
4
|
-
if (!error.response || !isResponseStatusClientErrorCode(error.response.status)) {
|
|
5
|
-
throw error;
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const isResponseStatusClientErrorCode = httpResponseStatusCode => {
|
|
10
|
-
const minClientErrorCode = httpResponseStatusCodes.BAD_REQUEST;
|
|
11
|
-
const maxClientErrorCode = httpResponseStatusCodes.CLIENT_CLOSED_REQUEST;
|
|
12
|
-
|
|
13
|
-
return httpResponseStatusCode >= minClientErrorCode && httpResponseStatusCode <= maxClientErrorCode;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = { validateClientErrorResponseStatus };
|
|
1
|
+
const httpResponseStatusCodes = require('../httpResponseStatusCodes.json');
|
|
2
|
+
|
|
3
|
+
const validateClientErrorResponseStatus = error => {
|
|
4
|
+
if (!error.response || !isResponseStatusClientErrorCode(error.response.status)) {
|
|
5
|
+
throw error;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const isResponseStatusClientErrorCode = httpResponseStatusCode => {
|
|
10
|
+
const minClientErrorCode = httpResponseStatusCodes.BAD_REQUEST;
|
|
11
|
+
const maxClientErrorCode = httpResponseStatusCodes.CLIENT_CLOSED_REQUEST;
|
|
12
|
+
|
|
13
|
+
return httpResponseStatusCode >= minClientErrorCode && httpResponseStatusCode <= maxClientErrorCode;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = { validateClientErrorResponseStatus };
|