@getjones/test-infra 1.11.0 → 1.12.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.
Files changed (128) hide show
  1. package/package.json +29 -29
  2. package/src/common/factory/index.js +3 -3
  3. package/src/common/factory/records/records.js +71 -45
  4. package/src/common/httpResponseStatusCodes.json +11 -11
  5. package/src/common/requests/apiKeyAuth/requests.js +38 -38
  6. package/src/common/requests/cookieAuth/requests.js +40 -40
  7. package/src/common/requests/requestHandlers.js +60 -60
  8. package/src/common/utils/numberUtils.js +22 -22
  9. package/src/common/utils/timeUtils.js +162 -147
  10. package/src/common/validations/errorValidation.js +16 -16
  11. package/src/common/validations/typeValidations.js +36 -36
  12. package/src/env.js +45 -45
  13. package/src/index.js +69 -67
  14. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
  15. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
  16. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  17. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  18. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  19. package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
  20. package/src/saas/internal-api/accounts/index.js +20 -20
  21. package/src/saas/internal-api/accounts/models/core/create.account.model.js +15 -15
  22. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +19 -19
  23. package/src/saas/internal-api/accounts/utils/utils.js +32 -32
  24. package/src/saas/internal-api/auth/api/auth.api.js +12 -12
  25. package/src/saas/internal-api/auth/api/auth.service.js +47 -47
  26. package/src/saas/internal-api/auth/index.js +3 -3
  27. package/src/saas/internal-api/coi/api/coi.api.js +34 -34
  28. package/src/saas/internal-api/coi/api/coi.service.js +22 -22
  29. package/src/saas/internal-api/coi/consts/uploaderTypes.js +7 -7
  30. package/src/saas/internal-api/coi/index.js +13 -13
  31. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  32. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  33. package/src/saas/internal-api/compliance/api/audit/audit.api.js +40 -40
  34. package/src/saas/internal-api/compliance/api/audit/audit.service.js +33 -33
  35. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  36. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  37. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  38. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
  39. package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
  40. package/src/saas/internal-api/compliance/api/waive/waive.service.js +15 -15
  41. package/src/saas/internal-api/compliance/index.js +22 -22
  42. package/src/saas/internal-api/compliance/models/audit/audit.model.js +110 -110
  43. package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
  44. package/src/saas/internal-api/contractors/api/contractors.api.js +146 -159
  45. package/src/saas/internal-api/contractors/api/contractors.service.js +129 -136
  46. package/src/saas/internal-api/contractors/index.js +8 -8
  47. package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
  48. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +74 -69
  49. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  50. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  51. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -19
  52. package/src/saas/internal-api/dbEmails/consts/consts.js +3 -0
  53. package/src/saas/internal-api/dbEmails/index.js +4 -3
  54. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
  55. package/src/saas/internal-api/dbEmails/utils/util.js +59 -0
  56. package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
  57. package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
  58. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  59. package/src/saas/internal-api/globalRecord/index.js +6 -6
  60. package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
  61. package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
  62. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  63. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  64. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  65. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  66. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  67. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  68. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
  69. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  70. package/src/saas/internal-api/projects/index.js +24 -24
  71. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  72. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  73. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
  74. package/src/saas/internal-api/projects/utils/utils.js +82 -82
  75. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  76. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
  77. package/src/saas/internal-api/recordNotes/index.js +3 -3
  78. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  79. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  80. package/src/saas/internal-api/reports/consts/consts.js +63 -63
  81. package/src/saas/internal-api/reports/index.js +15 -15
  82. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  83. package/src/saas/internal-api/requests/api/requests.api.js +28 -28
  84. package/src/saas/internal-api/requests/api/requests.service.js +19 -19
  85. package/src/saas/internal-api/requests/index.js +9 -11
  86. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  87. package/src/saas/internal-api/requirements/api/requirements.api.js +27 -27
  88. package/src/saas/internal-api/requirements/api/requirements.service.js +23 -23
  89. package/src/saas/internal-api/requirements/index.js +6 -6
  90. package/src/saas/internal-api/requirements/models/create.requirement.model.js +45 -45
  91. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  92. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  93. package/src/saas/internal-api/serviceArea/index.js +4 -4
  94. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  95. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  96. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  97. package/src/saas/internal-api/tabs/index.js +3 -3
  98. package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
  99. package/src/saas/internal-api/thread-scheduler/runner.js +13 -13
  100. package/src/saas/internal-api/users/api/users.api.js +77 -78
  101. package/src/saas/internal-api/users/api/users.service.js +101 -101
  102. package/src/saas/internal-api/users/index.js +4 -4
  103. package/src/saas/internal-api/users/models/users.model.js +31 -31
  104. package/src/saas/internal-api/users/utils/util.js +14 -14
  105. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  106. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  107. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  108. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  109. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  110. package/src/saas/openapi/projects/projects.api.js +59 -59
  111. package/src/saas/openapi/projects/projects.service.js +44 -44
  112. package/src/saas/openapi/requests/index.js +6 -0
  113. package/src/saas/openapi/{contractors/models/invite.contractor.model.js → requests/models/invite.request.model.js} +37 -37
  114. package/src/saas/openapi/requests/requests.api.js +20 -0
  115. package/src/saas/openapi/requests/requests.service.js +18 -0
  116. package/src/saas/openapi/requirements/index.js +6 -6
  117. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  118. package/src/saas/openapi/requirements/requirements.api.js +12 -12
  119. package/src/saas/openapi/requirements/requirements.service.js +20 -20
  120. package/src/saas/openapi/tabs/tabs.api.js +13 -13
  121. package/src/saas/openapi/tabs/tabs.service.js +7 -7
  122. package/tests/env.test.js +40 -40
  123. package/tests/validation.test.js +83 -83
  124. package/src/saas/internal-api/requests/models/edit.request.model.js +0 -31
  125. package/src/saas/internal-api/requests/models/validation.models.js +0 -8
  126. package/src/saas/openapi/contractors/contractors.api.js +0 -20
  127. package/src/saas/openapi/contractors/contractors.service.js +0 -18
  128. package/src/saas/openapi/contractors/index.js +0 -6
package/package.json CHANGED
@@ -1,29 +1,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
- }
1
+ {
2
+ "name": "@getjones/test-infra",
3
+ "version": "1.12.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
+ }
@@ -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,45 +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 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
+ 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
+ };
@@ -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 };