@getjones/test-infra 2.14.0 → 3.0.1

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 (209) hide show
  1. package/.npmrc.bak +2 -0
  2. package/package.json +30 -30
  3. package/package.json.bak +30 -0
  4. package/src/common/commonFlows/auth/auth.js +40 -40
  5. package/src/common/commonFlows/index.js +4 -4
  6. package/src/common/commonFlows/records/records.js +102 -102
  7. package/src/common/consts/activationStatuses.js +6 -6
  8. package/src/common/consts/dashboardCharts.js +18 -18
  9. package/src/common/consts/projectSettings.js +6 -6
  10. package/src/common/consts/recordTypes.js +5 -5
  11. package/src/common/consts/s3FileTypes.js +12 -12
  12. package/src/common/consts/userTypes.js +8 -8
  13. package/src/common/errorCodes.js +3 -3
  14. package/src/common/httpResponseStatusCodes.json +11 -11
  15. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  16. package/src/common/requests/cookieAuth/requests.js +40 -40
  17. package/src/common/requests/internalAuth/requests.js +48 -38
  18. package/src/common/requests/requestHandlers.js +78 -78
  19. package/src/common/utils/complianceUtil.js +83 -83
  20. package/src/common/utils/configsUtil.js +22 -22
  21. package/src/common/utils/dataTypeUtils.js +41 -41
  22. package/src/common/utils/numberUtils.js +22 -22
  23. package/src/common/utils/objectUtils.js +7 -7
  24. package/src/common/utils/timeUtils.js +177 -177
  25. package/src/common/validations/errorValidation.js +16 -16
  26. package/src/common/validations/typeValidations.js +36 -36
  27. package/src/defaults/configs/auditConfigs.js +91 -91
  28. package/src/defaults/configs/coverage.js +227 -227
  29. package/src/defaults/configs/polices.js +64 -64
  30. package/src/defaults/configs/requirement.js +32 -32
  31. package/src/defaults/index.js +6 -6
  32. package/src/env.js +57 -57
  33. package/src/factory/globalRecord/globalRecord.js +70 -70
  34. package/src/factory/index.js +8 -8
  35. package/src/factory/records/records.js +183 -183
  36. package/src/factory/users/users.js +77 -77
  37. package/src/index.js +91 -91
  38. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
  39. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
  40. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
  41. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
  42. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  43. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  44. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  45. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  46. package/src/saas/internal-api/accounts/consts/consts.js +6 -6
  47. package/src/saas/internal-api/accounts/index.js +22 -22
  48. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  49. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +38 -38
  50. package/src/saas/internal-api/accounts/utils/utils.js +58 -58
  51. package/src/saas/internal-api/agreement/api/agreement.api.js +35 -35
  52. package/src/saas/internal-api/agreement/api/agreement.service.js +81 -81
  53. package/src/saas/internal-api/agreement/consts/consts.js +8 -8
  54. package/src/saas/internal-api/agreement/index.js +11 -11
  55. package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
  56. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
  57. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
  58. package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
  59. package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
  60. package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
  61. package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
  62. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  63. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  64. package/src/saas/internal-api/auditNotes/index.js +4 -4
  65. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  66. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  67. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  68. package/src/saas/internal-api/auth/index.js +3 -3
  69. package/src/saas/internal-api/coi/api/coi.api.js +40 -34
  70. package/src/saas/internal-api/coi/api/coi.service.js +26 -22
  71. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  72. package/src/saas/internal-api/coi/index.js +13 -13
  73. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  74. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  75. package/src/saas/internal-api/compliance/api/audit/audit.api.js +100 -100
  76. package/src/saas/internal-api/compliance/api/audit/audit.service.js +230 -230
  77. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  78. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  79. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  80. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +48 -48
  81. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +33 -33
  82. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +141 -141
  83. package/src/saas/internal-api/compliance/consts/audit.js +103 -103
  84. package/src/saas/internal-api/compliance/index.js +33 -33
  85. package/src/saas/internal-api/compliance/models/audit/audit.model.js +94 -94
  86. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  87. package/src/saas/internal-api/compliance/utils/auditUtil.js +222 -222
  88. package/src/saas/internal-api/compliance/utils/coverageUtil.js +40 -40
  89. package/src/saas/internal-api/contractors/api/contractors.api.js +179 -179
  90. package/src/saas/internal-api/contractors/api/contractors.service.js +247 -234
  91. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  92. package/src/saas/internal-api/contractors/index.js +8 -8
  93. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  94. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -60
  95. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  96. package/src/saas/internal-api/contractors/utils.js +25 -25
  97. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  98. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  99. package/src/saas/internal-api/dashboard/index.js +5 -5
  100. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  101. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  102. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +147 -147
  103. package/src/saas/internal-api/dbEmails/consts/consts.js +54 -54
  104. package/src/saas/internal-api/dbEmails/index.js +6 -6
  105. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
  106. package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
  107. package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
  108. package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
  109. package/src/saas/internal-api/emailCustomization/index.js +3 -3
  110. package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
  111. package/src/saas/internal-api/globalRecord/api/global.record.service.js +105 -106
  112. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  113. package/src/saas/internal-api/globalRecord/index.js +6 -6
  114. package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
  115. package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
  116. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  117. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  118. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  119. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  120. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  121. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  122. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  123. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  124. package/src/saas/internal-api/projects/index.js +24 -24
  125. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  126. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  127. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +41 -41
  128. package/src/saas/internal-api/projects/utils/utils.js +156 -156
  129. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  130. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +47 -47
  131. package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
  132. package/src/saas/internal-api/recordNotes/index.js +3 -3
  133. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  134. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  135. package/src/saas/internal-api/reports/consts/consts.js +64 -64
  136. package/src/saas/internal-api/reports/index.js +15 -15
  137. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  138. package/src/saas/internal-api/requests/api/requests.api.js +96 -90
  139. package/src/saas/internal-api/requests/api/requests.service.js +220 -208
  140. package/src/saas/internal-api/requests/index.js +18 -16
  141. package/src/saas/internal-api/requests/models/create.request.model.js +34 -34
  142. package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
  143. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  144. package/src/saas/internal-api/requests/models/{inner.page.request.criteria.model.js → requestListCriteriaModel.js} +17 -17
  145. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  146. package/src/saas/internal-api/requests/utils.js +8 -8
  147. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  148. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  149. package/src/saas/internal-api/requestsTable/index.js +3 -3
  150. package/src/saas/internal-api/requirements/api/requirements.api.js +51 -45
  151. package/src/saas/internal-api/requirements/api/requirements.service.js +153 -142
  152. package/src/saas/internal-api/requirements/consts/attributeTypes.json +6 -6
  153. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  154. package/src/saas/internal-api/requirements/index.js +10 -10
  155. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  156. package/src/saas/internal-api/requirements/models/policy.model.js +33 -33
  157. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  158. package/src/saas/internal-api/requirements/utils/utils.js +116 -116
  159. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  160. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  161. package/src/saas/internal-api/serviceArea/index.js +4 -4
  162. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  163. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  164. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  165. package/src/saas/internal-api/tabs/index.js +3 -3
  166. package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
  167. package/src/saas/internal-api/thread-scheduler/runner.js +39 -39
  168. package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +31 -31
  169. package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +42 -42
  170. package/src/saas/internal-api/uploadFiles/consts.js +12 -12
  171. package/src/saas/internal-api/uploadFiles/index.js +3 -3
  172. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +32 -32
  173. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +97 -97
  174. package/src/saas/internal-api/users/api/users.api.js +115 -115
  175. package/src/saas/internal-api/users/api/users.service.js +203 -203
  176. package/src/saas/internal-api/users/index.js +16 -16
  177. package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
  178. package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
  179. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  180. package/src/saas/internal-api/users/models/users.model.js +41 -41
  181. package/src/saas/internal-api/users/utils/util.js +39 -39
  182. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  183. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  184. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  185. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  186. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  187. package/src/saas/openapi/coi/coi.api.js +20 -20
  188. package/src/saas/openapi/coi/coi.service.js +13 -13
  189. package/src/saas/openapi/projects/projects.api.js +83 -83
  190. package/src/saas/openapi/projects/projects.service.js +64 -64
  191. package/src/saas/openapi/requests/index.js +7 -7
  192. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  193. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  194. package/src/saas/openapi/requests/requests.api.js +82 -82
  195. package/src/saas/openapi/requests/requests.service.js +70 -70
  196. package/src/saas/openapi/requirements/index.js +6 -6
  197. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  198. package/src/saas/openapi/requirements/requirements.api.js +32 -32
  199. package/src/saas/openapi/requirements/requirements.service.js +37 -37
  200. package/src/saas/openapi/tabs/index.js +6 -6
  201. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
  202. package/src/saas/openapi/tabs/tabs.api.js +27 -27
  203. package/src/saas/openapi/tabs/tabs.service.js +19 -19
  204. package/src/saas/openapi/users/user.model.js +10 -10
  205. package/src/saas/openapi/users/users.api.js +33 -33
  206. package/src/saas/openapi/users/users.service.js +41 -41
  207. package/tests/env.test.js +40 -40
  208. package/tests/validation.test.js +83 -83
  209. package/src/resources/virusFile.pdf +0 -0
package/.npmrc.bak ADDED
@@ -0,0 +1,2 @@
1
+ @getjones:registry=https://registry.npmjs.org/
2
+ //registry.npmjs.org/:_authToken=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
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
- {
2
- "name": "@getjones/test-infra",
3
- "version": "2.14.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
- "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": "3.0.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
+ "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
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@getjones/test-infra",
3
+ "version": "3.0.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
+ "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,6 +1,6 @@
1
- module.exports = {
2
- ACTIVE: 'Active',
3
- ARCHIVED: 'Archived',
4
- DRAFT: 'Draft',
5
- DELETED: 'Deleted'
6
- };
1
+ module.exports = {
2
+ ACTIVE: 'Active',
3
+ ARCHIVED: 'Archived',
4
+ DRAFT: 'Draft',
5
+ DELETED: 'Deleted'
6
+ };
@@ -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,6 +1,6 @@
1
- module.exports = {
2
- tenantSolution: {
3
- on: { tenantSolution: true },
4
- off: { tenantSolution: false }
5
- }
6
- };
1
+ module.exports = {
2
+ tenantSolution: {
3
+ on: { tenantSolution: true },
4
+ off: { tenantSolution: false }
5
+ }
6
+ };
@@ -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,12 +1,12 @@
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
- TEMP_DOCUMENTS: 'TEMP_DOCUMENTS'
12
- };
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
+ TEMP_DOCUMENTS: 'TEMP_DOCUMENTS'
12
+ };
@@ -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,3 +1,3 @@
1
- module.exports = {
2
- UNKNOWN: 'UNKNOWN'
3
- };
1
+ module.exports = {
2
+ UNKNOWN: 'UNKNOWN'
3
+ };
@@ -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
+ };