@getjones/test-infra 2.11.2 → 2.11.3

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 (193) hide show
  1. package/package.json +30 -30
  2. package/src/common/commonFlows/auth/auth.js +40 -40
  3. package/src/common/commonFlows/index.js +4 -4
  4. package/src/common/commonFlows/records/records.js +102 -102
  5. package/src/common/consts/dashboardCharts.js +18 -18
  6. package/src/common/consts/recordTypes.js +5 -5
  7. package/src/common/consts/s3FileTypes.js +11 -11
  8. package/src/common/consts/userTypes.js +8 -8
  9. package/src/common/httpResponseStatusCodes.json +11 -11
  10. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  11. package/src/common/requests/cookieAuth/requests.js +40 -40
  12. package/src/common/requests/requestHandlers.js +78 -78
  13. package/src/common/utils/complianceUtil.js +83 -83
  14. package/src/common/utils/configsUtil.js +22 -22
  15. package/src/common/utils/dataTypeUtils.js +41 -41
  16. package/src/common/utils/numberUtils.js +22 -22
  17. package/src/common/utils/objectUtils.js +7 -7
  18. package/src/common/utils/timeUtils.js +177 -177
  19. package/src/common/validations/errorValidation.js +16 -16
  20. package/src/common/validations/typeValidations.js +36 -36
  21. package/src/defaults/configs/auditConfigs.js +91 -91
  22. package/src/defaults/configs/coverage.js +227 -227
  23. package/src/defaults/configs/polices.js +54 -54
  24. package/src/defaults/configs/requirement.js +32 -32
  25. package/src/defaults/index.js +6 -6
  26. package/src/env.js +57 -57
  27. package/src/factory/globalRecord/globalRecord.js +70 -70
  28. package/src/factory/index.js +8 -8
  29. package/src/factory/records/records.js +128 -128
  30. package/src/factory/users/users.js +77 -77
  31. package/src/index.js +89 -89
  32. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
  33. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +82 -82
  34. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  35. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  36. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  37. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  38. package/src/saas/internal-api/accounts/consts/consts.js +6 -6
  39. package/src/saas/internal-api/accounts/index.js +20 -20
  40. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  41. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +38 -38
  42. package/src/saas/internal-api/accounts/utils/utils.js +58 -58
  43. package/src/saas/internal-api/agreement/api/agreement.api.js +35 -35
  44. package/src/saas/internal-api/agreement/api/agreement.service.js +67 -67
  45. package/src/saas/internal-api/agreement/consts/consts.js +8 -8
  46. package/src/saas/internal-api/agreement/index.js +11 -11
  47. package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
  48. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  49. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  50. package/src/saas/internal-api/auditNotes/index.js +4 -4
  51. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  52. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  53. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  54. package/src/saas/internal-api/auth/index.js +3 -3
  55. package/src/saas/internal-api/coi/api/coi.api.js +34 -34
  56. package/src/saas/internal-api/coi/api/coi.service.js +22 -22
  57. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  58. package/src/saas/internal-api/coi/index.js +13 -13
  59. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  60. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  61. package/src/saas/internal-api/compliance/api/audit/audit.api.js +96 -96
  62. package/src/saas/internal-api/compliance/api/audit/audit.service.js +219 -219
  63. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  64. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  65. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  66. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +48 -48
  67. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +33 -33
  68. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +141 -141
  69. package/src/saas/internal-api/compliance/consts/audit.js +102 -102
  70. package/src/saas/internal-api/compliance/index.js +33 -33
  71. package/src/saas/internal-api/compliance/models/audit/audit.model.js +94 -94
  72. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  73. package/src/saas/internal-api/compliance/utils/auditUtil.js +222 -222
  74. package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
  75. package/src/saas/internal-api/contractors/api/contractors.api.js +166 -166
  76. package/src/saas/internal-api/contractors/api/contractors.service.js +211 -199
  77. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  78. package/src/saas/internal-api/contractors/index.js +9 -9
  79. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  80. package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
  81. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
  82. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  83. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  84. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  85. package/src/saas/internal-api/dashboard/index.js +5 -5
  86. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  87. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  88. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +147 -147
  89. package/src/saas/internal-api/dbEmails/consts/consts.js +53 -53
  90. package/src/saas/internal-api/dbEmails/index.js +6 -6
  91. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
  92. package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
  93. package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
  94. package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
  95. package/src/saas/internal-api/emailCustomization/index.js +3 -3
  96. package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
  97. package/src/saas/internal-api/globalRecord/api/global.record.service.js +106 -106
  98. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  99. package/src/saas/internal-api/globalRecord/index.js +6 -6
  100. package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
  101. package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
  102. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  103. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  104. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  105. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  106. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  107. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  108. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  109. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  110. package/src/saas/internal-api/projects/index.js +24 -24
  111. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  112. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  113. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +41 -41
  114. package/src/saas/internal-api/projects/utils/utils.js +156 -156
  115. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  116. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
  117. package/src/saas/internal-api/recordNotes/index.js +3 -3
  118. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  119. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  120. package/src/saas/internal-api/reports/consts/consts.js +64 -64
  121. package/src/saas/internal-api/reports/index.js +15 -15
  122. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  123. package/src/saas/internal-api/requests/api/requests.api.js +78 -78
  124. package/src/saas/internal-api/requests/api/requests.service.js +151 -151
  125. package/src/saas/internal-api/requests/index.js +16 -16
  126. package/src/saas/internal-api/requests/models/create.request.model.js +33 -33
  127. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  128. package/src/saas/internal-api/requests/models/inner.page.request.criteria.model.js +17 -17
  129. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  130. package/src/saas/internal-api/requests/utils.js +8 -8
  131. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  132. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  133. package/src/saas/internal-api/requestsTable/index.js +3 -3
  134. package/src/saas/internal-api/requirements/api/requirements.api.js +45 -45
  135. package/src/saas/internal-api/requirements/api/requirements.service.js +134 -134
  136. package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -6
  137. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  138. package/src/saas/internal-api/requirements/index.js +10 -10
  139. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  140. package/src/saas/internal-api/requirements/models/policy.model.js +33 -33
  141. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  142. package/src/saas/internal-api/requirements/utils/utils.js +115 -115
  143. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  144. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  145. package/src/saas/internal-api/serviceArea/index.js +4 -4
  146. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  147. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  148. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  149. package/src/saas/internal-api/tabs/index.js +3 -3
  150. package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
  151. package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
  152. package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +25 -25
  153. package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +32 -32
  154. package/src/saas/internal-api/uploadFiles/consts.js +12 -12
  155. package/src/saas/internal-api/uploadFiles/index.js +3 -3
  156. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +32 -32
  157. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +78 -78
  158. package/src/saas/internal-api/users/api/users.api.js +109 -109
  159. package/src/saas/internal-api/users/api/users.service.js +198 -198
  160. package/src/saas/internal-api/users/index.js +16 -16
  161. package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
  162. package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
  163. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  164. package/src/saas/internal-api/users/models/users.model.js +41 -41
  165. package/src/saas/internal-api/users/utils/util.js +39 -39
  166. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  167. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  168. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  169. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  170. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  171. package/src/saas/openapi/coi/coi.api.js +20 -20
  172. package/src/saas/openapi/coi/coi.service.js +13 -13
  173. package/src/saas/openapi/projects/projects.api.js +83 -83
  174. package/src/saas/openapi/projects/projects.service.js +64 -64
  175. package/src/saas/openapi/requests/index.js +7 -7
  176. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  177. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  178. package/src/saas/openapi/requests/requests.api.js +76 -76
  179. package/src/saas/openapi/requests/requests.service.js +65 -65
  180. package/src/saas/openapi/requirements/index.js +6 -6
  181. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  182. package/src/saas/openapi/requirements/requirements.api.js +32 -32
  183. package/src/saas/openapi/requirements/requirements.service.js +37 -37
  184. package/src/saas/openapi/tabs/index.js +6 -6
  185. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
  186. package/src/saas/openapi/tabs/tabs.api.js +27 -27
  187. package/src/saas/openapi/tabs/tabs.service.js +19 -19
  188. package/src/saas/openapi/users/user.model.js +10 -10
  189. package/src/saas/openapi/users/users.api.js +33 -33
  190. package/src/saas/openapi/users/users.service.js +41 -41
  191. package/tests/env.test.js +40 -40
  192. package/tests/validation.test.js +83 -83
  193. package/src/resources/virusFile.pdf +0 -0
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "@getjones/test-infra",
3
- "version": "2.11.2",
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
- "form-data": "^4.0.0",
19
- "mocha": "^8.3.2"
20
- },
21
- "devDependencies": {
22
- "babel-eslint": "^10.0.3",
23
- "eslint": "^6.8.0",
24
- "eslint-plugin-import": "^2.19.1",
25
- "mocha-spec-json-output-reporter": "^1.1.7"
26
- },
27
- "directories": {
28
- "test": "tests"
29
- }
30
- }
1
+ {
2
+ "name": "@getjones/test-infra",
3
+ "version": "2.11.3",
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
+ "form-data": "^4.0.0",
19
+ "mocha": "^8.3.2"
20
+ },
21
+ "devDependencies": {
22
+ "babel-eslint": "^10.0.3",
23
+ "eslint": "^6.8.0",
24
+ "eslint-plugin-import": "^2.19.1",
25
+ "mocha-spec-json-output-reporter": "^1.1.7"
26
+ },
27
+ "directories": {
28
+ "test": "tests"
29
+ }
30
+ }
@@ -1,40 +1,40 @@
1
- const { expect } = require('chai');
2
-
3
- const env = require('../../../../../../src/env');
4
-
5
- const { internalAPI } = require('../../../../src')(env);
6
- const { dbEmails, auth } = internalAPI;
7
-
8
- const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
9
-
10
- const textInSubject = 'One-Time Security Code';
11
- const textInBody = 'Please use the one-time code below to confirm your identity';
12
- const codeLength = 6;
13
-
14
- const getVendorHubAuthCookie = async email => {
15
- const createOneTimeSessionResponse = await auth.services.createOneTimeSession(email);
16
- expect(createOneTimeSessionResponse.status, `Create one-time session for email ${email} has failed`).to.equal(httpResponseStatusCodes.OK);
17
-
18
- const recipients = {
19
- from: env.credentials.superUser,
20
- to: [email]
21
- };
22
-
23
- const userEmailBody = await dbEmails.services.getLastMessage({ recipients, textInSubject });
24
- expect(userEmailBody, 'Fetching user one-time security code email has failed').to.be.a('string').that.includes(textInBody);
25
-
26
- const oneTimeCode = await extractOneTimeCode(userEmailBody);
27
- expect(oneTimeCode.length, 'One-time security code extraction from email body has failed').to.equal(codeLength);
28
-
29
- return auth.services.getHubUserCookie(email, oneTimeCode);
30
- };
31
-
32
- async function extractOneTimeCode(inputString) {
33
- const regex = '\s*(\\d{6})\n\s*';
34
- const match = inputString.match(regex);
35
-
36
- return match ? match[1] : null;
37
- }
38
- module.exports = {
39
- getVendorHubAuthCookie
40
- };
1
+ const { expect } = require('chai');
2
+
3
+ const env = require('../../../../../../src/env');
4
+
5
+ const { internalAPI } = require('../../../../src')(env);
6
+ const { dbEmails, auth } = internalAPI;
7
+
8
+ const httpResponseStatusCodes = require('../../../common/httpResponseStatusCodes.json');
9
+
10
+ const textInSubject = 'One-Time Security Code';
11
+ const textInBody = 'Please use the one-time code below to confirm your identity';
12
+ const codeLength = 6;
13
+
14
+ const getVendorHubAuthCookie = async email => {
15
+ const createOneTimeSessionResponse = await auth.services.createOneTimeSession(email);
16
+ expect(createOneTimeSessionResponse.status, `Create one-time session for email ${email} has failed`).to.equal(httpResponseStatusCodes.OK);
17
+
18
+ const recipients = {
19
+ from: env.credentials.superUser,
20
+ to: [email]
21
+ };
22
+
23
+ const userEmailBody = await dbEmails.services.getLastMessage({ recipients, textInSubject });
24
+ expect(userEmailBody, 'Fetching user one-time security code email has failed').to.be.a('string').that.includes(textInBody);
25
+
26
+ const oneTimeCode = await extractOneTimeCode(userEmailBody);
27
+ expect(oneTimeCode.length, 'One-time security code extraction from email body has failed').to.equal(codeLength);
28
+
29
+ return auth.services.getHubUserCookie(email, oneTimeCode);
30
+ };
31
+
32
+ async function extractOneTimeCode(inputString) {
33
+ const regex = '\s*(\\d{6})\n\s*';
34
+ const match = inputString.match(regex);
35
+
36
+ return match ? match[1] : null;
37
+ }
38
+ module.exports = {
39
+ getVendorHubAuthCookie
40
+ };
@@ -1,4 +1,4 @@
1
- const records = require('./records/records');
2
- const auth = require('./auth/auth');
3
-
4
- module.exports = { records, auth };
1
+ const records = require('./records/records');
2
+ const auth = require('./auth/auth');
3
+
4
+ module.exports = { records, auth };
@@ -1,102 +1,102 @@
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
- const compliance = require('../../../saas/internal-api/compliance');
8
-
9
- const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
10
- const offsetInDaysList = isTenant ?
11
- timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
12
- timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
13
-
14
- for (const offsetInDays of offsetInDaysList) {
15
- await updateLastInviteActionDate(recordId, offsetInDays, context);
16
- }
17
- };
18
-
19
- const updateInviteDate = async function(recordId, inviteDate, context) {
20
- await timeUtils.waitFor(1).seconds;
21
- const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
22
-
23
- if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
24
- throw new Error(`Failed to update record invite date\n${updateResponse}`);
25
- }
26
-
27
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
28
-
29
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
30
- throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
31
- }
32
-
33
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
34
- };
35
-
36
- const updateLastInviteActionDate = async function(recordId, offsetInDays, context) {
37
- await timeUtils.waitFor(1).seconds;
38
- /*
39
- To run the reminders mails successfully we must first update the compliance audit actions date,
40
- Since the thread scheduler will trigger the logic of the reminders mails
41
- only if last invite action date will be equal or after compliance audit actions date
42
- */
43
- const updateComplianceAuditResponse = await compliance.services.audit.updateComplianceAuditActionsDate(recordId, offsetInDays, context);
44
-
45
- if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
46
- throw new Error(`Failed to update compliance audit date\n${updateComplianceAuditResponse}`);
47
- }
48
-
49
- const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, offsetInDays, context);
50
-
51
- if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
52
- throw new Error(`Failed to update record invite date\n${updateLastInviteActionResponse}`);
53
- }
54
-
55
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
56
-
57
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
58
- throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
59
- }
60
-
61
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
62
- };
63
-
64
- const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
65
- const dates = timeUtils.getAutomaticRenewalsExpirationDates();
66
-
67
- for (const date of dates) {
68
- await updatePolicyExpiryDateForRecord(recordId, date, policyName);
69
- }
70
- };
71
-
72
- const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
73
- const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
74
-
75
- if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
76
- throw new Error(`Record expiry date could not be updated\n${updateResponse}`);
77
- }
78
-
79
- const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
80
-
81
- if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
82
- throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
83
- }
84
-
85
- await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
86
- };
87
-
88
- const getHistoryEvents = async function(recordId, context) {
89
- const recordHistory = await contractors.services.getRecordHistory(recordId, context);
90
- expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
91
-
92
- return recordHistory.data.map(item => item.itemTitle).reverse();
93
- };
94
-
95
- module.exports = {
96
- makeRecordNotResponsive,
97
- runOverAllRenewalDatesForRecord,
98
- updateInviteDate,
99
- updatePolicyExpiryDateForRecord,
100
- getHistoryEvents,
101
- updateLastInviteActionDate
102
- };
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
+ const compliance = require('../../../saas/internal-api/compliance');
8
+
9
+ const makeRecordNotResponsive = async function(recordId, context, { isTenant } = {}) {
10
+ const offsetInDaysList = isTenant ?
11
+ timeUtils.getInviteActionOffsetInDaysForNotResponsiveTenant() :
12
+ timeUtils.getInviteActionOffsetInDaysForNotResponsiveVendor();
13
+
14
+ for (const offsetInDays of offsetInDaysList) {
15
+ await updateLastInviteActionDate(recordId, offsetInDays, context);
16
+ }
17
+ };
18
+
19
+ const updateInviteDate = async function(recordId, inviteDate, context) {
20
+ await timeUtils.waitFor(1).seconds;
21
+ const updateResponse = await contractors.services.updateInviteDate(recordId, inviteDate, context);
22
+
23
+ if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
24
+ throw new Error(`Failed to update record invite date\n${updateResponse}`);
25
+ }
26
+
27
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
28
+
29
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
30
+ throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
31
+ }
32
+
33
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
34
+ };
35
+
36
+ const updateLastInviteActionDate = async function(recordId, offsetInDays, context) {
37
+ await timeUtils.waitFor(1).seconds;
38
+ /*
39
+ To run the reminders mails successfully we must first update the compliance audit actions date,
40
+ Since the thread scheduler will trigger the logic of the reminders mails
41
+ only if last invite action date will be equal or after compliance audit actions date
42
+ */
43
+ const updateComplianceAuditResponse = await compliance.services.audit.updateComplianceAuditActionsDate(recordId, offsetInDays, context);
44
+
45
+ if (updateComplianceAuditResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
46
+ throw new Error(`Failed to update compliance audit date\n${updateComplianceAuditResponse}`);
47
+ }
48
+
49
+ const updateLastInviteActionResponse = await contractors.services.updateLastInviteActionDate(recordId, offsetInDays, context);
50
+
51
+ if (updateLastInviteActionResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
52
+ throw new Error(`Failed to update record invite date\n${updateLastInviteActionResponse}`);
53
+ }
54
+
55
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
56
+
57
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
58
+ throw new Error(`Failed to run thread scheduler\n${threadSchedulerResponse}`);
59
+ }
60
+
61
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
62
+ };
63
+
64
+ const runOverAllRenewalDatesForRecord = async function(recordId, policyName) {
65
+ const dates = timeUtils.getAutomaticRenewalsExpirationDates();
66
+
67
+ for (const date of dates) {
68
+ await updatePolicyExpiryDateForRecord(recordId, date, policyName);
69
+ }
70
+ };
71
+
72
+ const updatePolicyExpiryDateForRecord = async function(recordId, expiryDate, policyName) {
73
+ const updateResponse = await contractors.services.updateExpiryDate(recordId, expiryDate, policyName);
74
+
75
+ if (updateResponse.status !== httpResponseStatusCodes.NO_CONTENT) {
76
+ throw new Error(`Record expiry date could not be updated\n${updateResponse}`);
77
+ }
78
+
79
+ const threadSchedulerResponse = await threadScheduler.runForRecords([recordId]);
80
+
81
+ if (threadSchedulerResponse.status !== httpResponseStatusCodes.OK) {
82
+ throw new Error(`Thread scheduler has failed to run\n${threadSchedulerResponse}`);
83
+ }
84
+
85
+ await timeUtils.waitFor(2.5).seconds; // calls for the same records can override each other
86
+ };
87
+
88
+ const getHistoryEvents = async function(recordId, context) {
89
+ const recordHistory = await contractors.services.getRecordHistory(recordId, context);
90
+ expect(recordHistory.status, 'Expected record history response status to equal 200.').to.equal(httpResponseStatusCodes.OK);
91
+
92
+ return recordHistory.data.map(item => item.itemTitle).reverse();
93
+ };
94
+
95
+ module.exports = {
96
+ makeRecordNotResponsive,
97
+ runOverAllRenewalDatesForRecord,
98
+ updateInviteDate,
99
+ updatePolicyExpiryDateForRecord,
100
+ getHistoryEvents,
101
+ updateLastInviteActionDate
102
+ };
@@ -1,18 +1,18 @@
1
- const chartTypes = {
2
- requiringAttention: 'requiringAttention',
3
- expirationDatePerMonth: 'expirationDatePerMonth',
4
- waivedByRequirement: 'waivedByRequirement',
5
- notCompliantForRequirement: 'notCompliantForRequirement'
6
- };
7
- const sortBy = {
8
- companyName: 'SORT_BY_COMPANYNAME',
9
- projectName: 'SORT_BY_PROJECT_NAME',
10
- insuranceStatus: 'SORT_BY_INSURANCE_STATUS',
11
- minPolicyExpiration: 'SORT_BY_MIN_POLICY_EXP'
12
-
13
- };
14
-
15
- module.exports = {
16
- chartTypes,
17
- sortBy
18
- };
1
+ const chartTypes = {
2
+ requiringAttention: 'requiringAttention',
3
+ expirationDatePerMonth: 'expirationDatePerMonth',
4
+ waivedByRequirement: 'waivedByRequirement',
5
+ notCompliantForRequirement: 'notCompliantForRequirement'
6
+ };
7
+ const sortBy = {
8
+ companyName: 'SORT_BY_COMPANYNAME',
9
+ projectName: 'SORT_BY_PROJECT_NAME',
10
+ insuranceStatus: 'SORT_BY_INSURANCE_STATUS',
11
+ minPolicyExpiration: 'SORT_BY_MIN_POLICY_EXP'
12
+
13
+ };
14
+
15
+ module.exports = {
16
+ chartTypes,
17
+ sortBy
18
+ };
@@ -1,5 +1,5 @@
1
- module.exports = {
2
- VENDORS: 'Vendors',
3
- TENANTS: 'Tenants',
4
- GUESTS: 'Guests'
5
- };
1
+ module.exports = {
2
+ VENDORS: 'Vendors',
3
+ TENANTS: 'Tenants',
4
+ GUESTS: 'Guests'
5
+ };
@@ -1,11 +1,11 @@
1
- module.exports = {
2
- DOCUMENT: 'DOCUMENT',
3
- REPORTS: 'REPORTS',
4
- SNIPPET: 'SNIPPET',
5
- CONTRACT: 'CONTRACT',
6
- TEMPCOI: 'TEMPCOI',
7
- COI: 'COI',
8
- ATTACHMENT: 'ATTACHMENT',
9
- OCRDATA: 'OCRDATA',
10
- VENDORREPORT: 'VENDORREPORT'
11
- };
1
+ module.exports = {
2
+ DOCUMENT: 'DOCUMENT',
3
+ REPORTS: 'REPORTS',
4
+ SNIPPET: 'SNIPPET',
5
+ CONTRACT: 'CONTRACT',
6
+ TEMPCOI: 'TEMPCOI',
7
+ COI: 'COI',
8
+ ATTACHMENT: 'ATTACHMENT',
9
+ OCRDATA: 'OCRDATA',
10
+ VENDORREPORT: 'VENDORREPORT'
11
+ };
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- ICS: 'ICS',
3
- PM: 'PM',
4
- AUDITOR: 'Auditor',
5
- VENDOR: 'Vendor',
6
- auditor: 'Auditor',
7
- operator: 'Operator'
8
- };
1
+ module.exports = {
2
+ ICS: 'ICS',
3
+ PM: 'PM',
4
+ AUDITOR: 'Auditor',
5
+ VENDOR: 'Vendor',
6
+ auditor: 'Auditor',
7
+ operator: 'Operator'
8
+ };
@@ -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,44 +1,44 @@
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 putFileRequestHandler = (url, apiKey, fileData, headers = {}) => {
19
- enrichApiKey(headers, apiKey);
20
- return requestHandler.putFileRequestHandler(url, fileData, headers);
21
- };
22
-
23
- const patchRequestHandler = (url, apiKey, body, headers = {}) => {
24
- enrichApiKey(headers, apiKey);
25
- return requestHandler.patchRequestHandler(url, body, headers);
26
- };
27
-
28
- const deleteRequestHandler = (url, apiKey, headers = {}, params = {}, data = {}) => {
29
- enrichApiKey(headers, apiKey);
30
- return requestHandler.deleteRequestHandler(url, headers, params, data);
31
- };
32
-
33
- const enrichApiKey = (headers, apiKey) => {
34
- headers['x-api-key'] = apiKey;
35
- };
36
-
37
- module.exports = {
38
- getRequestHandler,
39
- postRequestHandler,
40
- putRequestHandler,
41
- putFileRequestHandler,
42
- patchRequestHandler,
43
- deleteRequestHandler
44
- };
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 putFileRequestHandler = (url, apiKey, fileData, headers = {}) => {
19
+ enrichApiKey(headers, apiKey);
20
+ return requestHandler.putFileRequestHandler(url, fileData, headers);
21
+ };
22
+
23
+ const patchRequestHandler = (url, apiKey, body, headers = {}) => {
24
+ enrichApiKey(headers, apiKey);
25
+ return requestHandler.patchRequestHandler(url, body, headers);
26
+ };
27
+
28
+ const deleteRequestHandler = (url, apiKey, headers = {}, params = {}, data = {}) => {
29
+ enrichApiKey(headers, apiKey);
30
+ return requestHandler.deleteRequestHandler(url, headers, params, data);
31
+ };
32
+
33
+ const enrichApiKey = (headers, apiKey) => {
34
+ headers['x-api-key'] = apiKey;
35
+ };
36
+
37
+ module.exports = {
38
+ getRequestHandler,
39
+ postRequestHandler,
40
+ putRequestHandler,
41
+ putFileRequestHandler,
42
+ patchRequestHandler,
43
+ deleteRequestHandler
44
+ };
@@ -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
+ };