@getjones/test-infra 4.5.0 → 4.5.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 (238) 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 +260 -260
  5. package/src/common/consts/accountSettings.js +14 -14
  6. package/src/common/consts/activationStatuses.js +6 -6
  7. package/src/common/consts/autocomplete.js +10 -10
  8. package/src/common/consts/constantsForRecordsSortingAndFilters.js +48 -48
  9. package/src/common/consts/dashboardCharts.js +18 -18
  10. package/src/common/consts/homepage/AttentionTab.js +5 -5
  11. package/src/common/consts/homepage/sortOptions.js +14 -14
  12. package/src/common/consts/ocrStatuses.js +6 -6
  13. package/src/common/consts/projectSettings.js +21 -21
  14. package/src/common/consts/recordTypes.js +5 -5
  15. package/src/common/consts/requirementActions.js +10 -10
  16. package/src/common/consts/s3FileTypes.js +13 -13
  17. package/src/common/consts/userRoles.js +18 -18
  18. package/src/common/consts/userTypes.js +8 -8
  19. package/src/common/errorCodes.js +3 -3
  20. package/src/common/httpResponseStatusCodes.json +11 -11
  21. package/src/common/httpResponseTypes.json +2 -2
  22. package/src/common/requests/apiKeyAuth/requests.js +44 -44
  23. package/src/common/requests/cookieAuth/requests.js +40 -40
  24. package/src/common/requests/internalAuth/requests.js +48 -48
  25. package/src/common/requests/requestHandlers.js +80 -80
  26. package/src/common/utils/complianceUtil.js +114 -114
  27. package/src/common/utils/configsUtil.js +22 -22
  28. package/src/common/utils/dataTypeUtils.js +41 -41
  29. package/src/common/utils/numberUtils.js +22 -22
  30. package/src/common/utils/objectUtils.js +7 -7
  31. package/src/common/utils/timeUtils.js +177 -177
  32. package/src/common/validations/errorValidation.js +16 -16
  33. package/src/common/validations/typeValidations.js +36 -36
  34. package/src/defaults/configs/auditConfigs.js +146 -125
  35. package/src/defaults/configs/coverage.js +236 -227
  36. package/src/defaults/configs/polices.js +75 -75
  37. package/src/defaults/configs/requirement.js +32 -32
  38. package/src/defaults/index.js +6 -6
  39. package/src/env.js +57 -57
  40. package/src/factory/globalRecord/globalRecord.js +43 -43
  41. package/src/factory/index.js +8 -8
  42. package/src/factory/records/records.js +297 -229
  43. package/src/factory/users/users.js +86 -86
  44. package/src/index.js +97 -97
  45. package/src/saas/internal-api/accountDirectory/api/accountDirectory.api.js +50 -50
  46. package/src/saas/internal-api/accountDirectory/api/accountDirectory.service.js +182 -182
  47. package/src/saas/internal-api/accountDirectory/index.js +4 -4
  48. package/src/saas/internal-api/accountDirectory/models/accountDirectory.model.js +40 -40
  49. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +35 -35
  50. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +93 -93
  51. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
  52. package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +61 -61
  53. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  54. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  55. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  56. package/src/saas/internal-api/accounts/api/settings/settings.service.js +41 -41
  57. package/src/saas/internal-api/accounts/consts/consts.js +8 -8
  58. package/src/saas/internal-api/accounts/index.js +22 -22
  59. package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
  60. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +51 -51
  61. package/src/saas/internal-api/accounts/utils/utils.js +60 -60
  62. package/src/saas/internal-api/agreement/api/agreement.api.js +39 -39
  63. package/src/saas/internal-api/agreement/api/agreement.service.js +121 -121
  64. package/src/saas/internal-api/agreement/consts/consts.js +11 -11
  65. package/src/saas/internal-api/agreement/index.js +12 -12
  66. package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
  67. package/src/saas/internal-api/agreement/models/createAgreementByAuditorModel.js +11 -11
  68. package/src/saas/internal-api/agreement/models/createAgreementByPMModel.js +13 -13
  69. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +43 -43
  70. package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +105 -105
  71. package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +11 -11
  72. package/src/saas/internal-api/auditCustomerRules/index.js +6 -6
  73. package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +46 -46
  74. package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +19 -19
  75. package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
  76. package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +115 -115
  77. package/src/saas/internal-api/auditNotes/index.js +4 -4
  78. package/src/saas/internal-api/auditNotes/models/audit.note.model.js +30 -30
  79. package/src/saas/internal-api/auth/api/auth.api.js +27 -27
  80. package/src/saas/internal-api/auth/api/auth.service.js +90 -90
  81. package/src/saas/internal-api/auth/index.js +3 -3
  82. package/src/saas/internal-api/coi/api/coi.api.js +45 -45
  83. package/src/saas/internal-api/coi/api/coi.service.js +39 -39
  84. package/src/saas/internal-api/coi/consts/hashes.js +4 -4
  85. package/src/saas/internal-api/coi/consts/uploaderTypes.js +5 -5
  86. package/src/saas/internal-api/coi/index.js +14 -14
  87. package/src/saas/internal-api/coi/models/Combine.last.two.cois.model.js +25 -25
  88. package/src/saas/internal-api/coi/models/submit.coi.model.js +19 -19
  89. package/src/saas/internal-api/coi/utils/utils.js +117 -117
  90. package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.api.js +12 -12
  91. package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.service.js +14 -14
  92. package/src/saas/internal-api/compliance/api/audit/audit.api.js +115 -115
  93. package/src/saas/internal-api/compliance/api/audit/audit.service.js +300 -300
  94. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  95. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  96. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  97. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +50 -48
  98. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +38 -38
  99. package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +183 -183
  100. package/src/saas/internal-api/compliance/consts/audit.js +111 -111
  101. package/src/saas/internal-api/compliance/index.js +36 -36
  102. package/src/saas/internal-api/compliance/models/audit/audit.model.js +96 -96
  103. package/src/saas/internal-api/compliance/models/waive/waive.model.js +49 -49
  104. package/src/saas/internal-api/compliance/utils/auditUtil.js +254 -254
  105. package/src/saas/internal-api/compliance/utils/coverageUtil.js +55 -40
  106. package/src/saas/internal-api/contractors/api/contractors.api.js +209 -209
  107. package/src/saas/internal-api/contractors/api/contractors.service.js +361 -361
  108. package/src/saas/internal-api/contractors/consts/consts.js +6 -6
  109. package/src/saas/internal-api/contractors/index.js +8 -8
  110. package/src/saas/internal-api/contractors/models/assign.requirement.model.js +10 -10
  111. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +73 -73
  112. package/src/saas/internal-api/contractors/models/link.request.model.js +10 -10
  113. package/src/saas/internal-api/contractors/models/subscription.contractor.model.js +13 -13
  114. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  115. package/src/saas/internal-api/contractors/utils.js +25 -25
  116. package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
  117. package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
  118. package/src/saas/internal-api/dashboard/index.js +5 -5
  119. package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
  120. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  121. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +156 -156
  122. package/src/saas/internal-api/dbEmails/consts/consts.js +55 -55
  123. package/src/saas/internal-api/dbEmails/index.js +6 -6
  124. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
  125. package/src/saas/internal-api/dbEmails/utils/util.js +87 -87
  126. package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
  127. package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
  128. package/src/saas/internal-api/emailCustomization/index.js +3 -3
  129. package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
  130. package/src/saas/internal-api/globalRecord/api/global.record.service.js +112 -112
  131. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  132. package/src/saas/internal-api/globalRecord/index.js +6 -6
  133. package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
  134. package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
  135. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  136. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  137. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  138. package/src/saas/internal-api/policyFile/api/policy.file.api.js +43 -43
  139. package/src/saas/internal-api/policyFile/api/policy.file.service.js +117 -117
  140. package/src/saas/internal-api/policyFile/consts.js +21 -21
  141. package/src/saas/internal-api/policyFile/index.js +11 -11
  142. package/src/saas/internal-api/policyFile/models/create.policy.file.model.js +11 -11
  143. package/src/saas/internal-api/policyFile/models/set.publish.flag.to.policy.model.js +13 -13
  144. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  145. package/src/saas/internal-api/projects/api/core/projects.service.js +77 -77
  146. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  147. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
  148. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  149. package/src/saas/internal-api/projects/index.js +24 -24
  150. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  151. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  152. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +40 -40
  153. package/src/saas/internal-api/projects/utils/utils.js +155 -155
  154. package/src/saas/internal-api/recordHub/api/record.hub.api.js +14 -14
  155. package/src/saas/internal-api/recordHub/api/record.hub.service.js +21 -21
  156. package/src/saas/internal-api/recordHub/index.js +3 -3
  157. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  158. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +47 -47
  159. package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
  160. package/src/saas/internal-api/recordNotes/index.js +3 -3
  161. package/src/saas/internal-api/reports/api/reports.api.js +62 -62
  162. package/src/saas/internal-api/reports/api/reports.service.js +79 -79
  163. package/src/saas/internal-api/reports/consts/consts.js +74 -74
  164. package/src/saas/internal-api/reports/index.js +15 -15
  165. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  166. package/src/saas/internal-api/requests/api/requests.api.js +126 -126
  167. package/src/saas/internal-api/requests/api/requests.service.js +301 -301
  168. package/src/saas/internal-api/requests/index.js +21 -21
  169. package/src/saas/internal-api/requests/models/create.request.model.js +36 -36
  170. package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -18
  171. package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
  172. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
  173. package/src/saas/internal-api/requests/models/homepageRequestCriteriaModel.js +19 -19
  174. package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
  175. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  176. package/src/saas/internal-api/requests/utils.js +16 -16
  177. package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
  178. package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
  179. package/src/saas/internal-api/requestsTable/index.js +3 -3
  180. package/src/saas/internal-api/requirements/api/requirements.api.js +57 -57
  181. package/src/saas/internal-api/requirements/api/requirements.service.js +177 -177
  182. package/src/saas/internal-api/requirements/consts/attributeTypes.json +8 -8
  183. package/src/saas/internal-api/requirements/consts/consts.js +6 -6
  184. package/src/saas/internal-api/requirements/index.js +10 -10
  185. package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
  186. package/src/saas/internal-api/requirements/models/policy.model.js +35 -35
  187. package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
  188. package/src/saas/internal-api/requirements/utils/utils.js +129 -129
  189. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  190. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  191. package/src/saas/internal-api/serviceArea/index.js +4 -4
  192. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  193. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  194. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  195. package/src/saas/internal-api/tabs/index.js +3 -3
  196. package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
  197. package/src/saas/internal-api/thread-scheduler/runner.js +55 -55
  198. package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +43 -43
  199. package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +107 -107
  200. package/src/saas/internal-api/uploadFiles/consts.js +12 -12
  201. package/src/saas/internal-api/uploadFiles/index.js +5 -5
  202. package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +38 -38
  203. package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +108 -108
  204. package/src/saas/internal-api/users/api/users.api.js +127 -127
  205. package/src/saas/internal-api/users/api/users.service.js +258 -258
  206. package/src/saas/internal-api/users/index.js +16 -16
  207. package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
  208. package/src/saas/internal-api/users/models/notification.settings.model.js +12 -12
  209. package/src/saas/internal-api/users/models/tenent.user.model.js +11 -11
  210. package/src/saas/internal-api/users/models/users.model.js +43 -43
  211. package/src/saas/internal-api/users/utils/util.js +39 -39
  212. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +26 -26
  213. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +19 -19
  214. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  215. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  216. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  217. package/src/saas/openapi/coi/coi.api.js +30 -30
  218. package/src/saas/openapi/coi/coi.service.js +43 -43
  219. package/src/saas/openapi/projects/projects.api.js +83 -83
  220. package/src/saas/openapi/projects/projects.service.js +64 -64
  221. package/src/saas/openapi/requests/index.js +7 -7
  222. package/src/saas/openapi/requests/models/invite.request.model.js +40 -40
  223. package/src/saas/openapi/requests/models/update.request.model.js +35 -35
  224. package/src/saas/openapi/requests/requests.api.js +93 -93
  225. package/src/saas/openapi/requests/requests.service.js +94 -94
  226. package/src/saas/openapi/requirements/index.js +6 -6
  227. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  228. package/src/saas/openapi/requirements/requirements.api.js +41 -41
  229. package/src/saas/openapi/requirements/requirements.service.js +49 -49
  230. package/src/saas/openapi/tabs/index.js +6 -6
  231. package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
  232. package/src/saas/openapi/tabs/tabs.api.js +27 -27
  233. package/src/saas/openapi/tabs/tabs.service.js +19 -19
  234. package/src/saas/openapi/users/user.model.js +10 -10
  235. package/src/saas/openapi/users/users.api.js +33 -33
  236. package/src/saas/openapi/users/users.service.js +51 -51
  237. package/tests/env.test.js +40 -40
  238. package/tests/validation.test.js +83 -83
@@ -1,117 +1,117 @@
1
- const policyFileApi = require('./policy.file.api');
2
- const timeUtils = require('../../../../common/utils/timeUtils');
3
- const { PolicyFileToSetPublishFlagRequestBodyModel } = require('../models/set.publish.flag.to.policy.model');
4
-
5
- const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
6
-
7
- const getPolicyFilesForVendorReport = async (requestId, context, { shouldExpectError } = {}) => {
8
- const getPolicyResponse = await policyFileApi.getPolicyFilesForVendorReport(requestId, context);
9
-
10
- if (getPolicyResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
11
- throw new Error('Failed to get policy files from record report');
12
- }
13
-
14
- return getPolicyResponse;
15
- };
16
-
17
- const getPreSignedUrlByPolicyId = async (policyFileId, context, { shouldExpectError } = {}) => {
18
- const getPolicyLinkResponse = await policyFileApi.getPreSignedUrlByPolicyId(policyFileId, context);
19
-
20
- if (getPolicyLinkResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
21
- throw new Error('Failed to get policy view only link');
22
- }
23
-
24
- return getPolicyLinkResponse;
25
- };
26
-
27
- const getAuditPolicyFiles = async (recordId, auditId, context) => {
28
- const getAuditPolicyFilesResponse = await policyFileApi.getAuditPolicyFiles(recordId, auditId, context);
29
-
30
- if (getAuditPolicyFilesResponse.status !== httpResponseStatusCodes.OK) {
31
- throw new Error('Failed to get policy files by audit id');
32
- }
33
-
34
- return getAuditPolicyFilesResponse;
35
- };
36
-
37
- const unpublishPolicyFile = async (unpublishPolicyFileModel, context, { shouldExpectError } = {}) => {
38
- const unpublishResponse = await policyFileApi.unpublishPolicyFile(unpublishPolicyFileModel, context);
39
-
40
- if (unpublishResponse.status !== httpResponseStatusCodes.NO_CONTENT && !shouldExpectError) {
41
- throw new Error(`Failed to unpublish policy file - ${unpublishPolicyFileModel.policyFileId}`);
42
- }
43
-
44
- return unpublishResponse;
45
- };
46
-
47
- const publishPolicyFile = async (publishPolicyFileModel, context, { shouldExpectError } = {}) => {
48
- const publishResponse = await policyFileApi.publishPolicyFile(publishPolicyFileModel, context);
49
-
50
- if (publishResponse.status !== httpResponseStatusCodes.NO_CONTENT && !shouldExpectError) {
51
- throw new Error(`Failed to unpublish policy file - ${publishPolicyFileModel.policyFileId}`);
52
- }
53
-
54
- return publishResponse;
55
- };
56
-
57
- const getSetPublishFlagToPolicyFileModel = async (requestId, policyFileId, context) => {
58
- const { isPublished, dateModified } = await getPolicyDetailsForPublishModel(requestId, policyFileId, context);
59
-
60
- return new PolicyFileToSetPublishFlagRequestBodyModel(policyFileId, isPublished, dateModified);
61
- };
62
-
63
- const getPolicyDetailsForPublishModel = async (requestId, policyFileId, context) => {
64
- const getPoliciesResponse = await getPolicyFilesForVendorReport(requestId, context);
65
-
66
- for (const policy of getPoliciesResponse.data) {
67
- if (policy.policyFileId === policyFileId) {
68
- return {
69
- isPublished: policy.isPublished,
70
- dateModified: policy.dateModified
71
- };
72
- }
73
- }
74
- throw new Error(`No match found for policy file id: ${policyFileId}`);
75
- };
76
-
77
- const getPolicyFilesIfExist = async (recordId, context) => {
78
- let retries = 10;
79
- let policiesToReviewResponse;
80
- let policyFiles = [];
81
-
82
- while (policyFiles.length === 0 && retries > 0) {
83
- //Busy wait for it takes time to get policy file to review
84
- await timeUtils.waitFor(1).seconds;
85
-
86
- policiesToReviewResponse = await policyFileApi.getPolicyFilesRequireAudit(recordId, context);
87
- policyFiles = policiesToReviewResponse.data;
88
-
89
- retries--;
90
- }
91
-
92
- if (policyFiles.length === 0) {
93
- throw new Error(`No policy files to review where found for record ${recordId}`);
94
- }
95
-
96
- return policiesToReviewResponse;
97
- };
98
-
99
- const getPolicyFilesRequireAudit = async (recordId, context) => {
100
- const getPolicyFilesResponse = await getPolicyFilesIfExist(recordId, context);
101
-
102
- if (getPolicyFilesResponse.status !== httpResponseStatusCodes.OK) {
103
- throw new Error('Failed to get policy files that require audit');
104
- }
105
-
106
- return getPolicyFilesResponse;
107
- };
108
-
109
- module.exports = {
110
- getPolicyFilesForVendorReport,
111
- getPreSignedUrlByPolicyId,
112
- getAuditPolicyFiles,
113
- getSetPublishFlagToPolicyFileModel,
114
- unpublishPolicyFile,
115
- publishPolicyFile,
116
- getPolicyFilesRequireAudit
117
- };
1
+ const policyFileApi = require('./policy.file.api');
2
+ const timeUtils = require('../../../../common/utils/timeUtils');
3
+ const { PolicyFileToSetPublishFlagRequestBodyModel } = require('../models/set.publish.flag.to.policy.model');
4
+
5
+ const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
6
+
7
+ const getPolicyFilesForVendorReport = async (requestId, context, { shouldExpectError } = {}) => {
8
+ const getPolicyResponse = await policyFileApi.getPolicyFilesForVendorReport(requestId, context);
9
+
10
+ if (getPolicyResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
11
+ throw new Error('Failed to get policy files from record report');
12
+ }
13
+
14
+ return getPolicyResponse;
15
+ };
16
+
17
+ const getPreSignedUrlByPolicyId = async (policyFileId, context, { shouldExpectError } = {}) => {
18
+ const getPolicyLinkResponse = await policyFileApi.getPreSignedUrlByPolicyId(policyFileId, context);
19
+
20
+ if (getPolicyLinkResponse.status !== httpResponseStatusCodes.OK && !shouldExpectError) {
21
+ throw new Error('Failed to get policy view only link');
22
+ }
23
+
24
+ return getPolicyLinkResponse;
25
+ };
26
+
27
+ const getAuditPolicyFiles = async (recordId, auditId, context) => {
28
+ const getAuditPolicyFilesResponse = await policyFileApi.getAuditPolicyFiles(recordId, auditId, context);
29
+
30
+ if (getAuditPolicyFilesResponse.status !== httpResponseStatusCodes.OK) {
31
+ throw new Error('Failed to get policy files by audit id');
32
+ }
33
+
34
+ return getAuditPolicyFilesResponse;
35
+ };
36
+
37
+ const unpublishPolicyFile = async (unpublishPolicyFileModel, context, { shouldExpectError } = {}) => {
38
+ const unpublishResponse = await policyFileApi.unpublishPolicyFile(unpublishPolicyFileModel, context);
39
+
40
+ if (unpublishResponse.status !== httpResponseStatusCodes.NO_CONTENT && !shouldExpectError) {
41
+ throw new Error(`Failed to unpublish policy file - ${unpublishPolicyFileModel.policyFileId}`);
42
+ }
43
+
44
+ return unpublishResponse;
45
+ };
46
+
47
+ const publishPolicyFile = async (publishPolicyFileModel, context, { shouldExpectError } = {}) => {
48
+ const publishResponse = await policyFileApi.publishPolicyFile(publishPolicyFileModel, context);
49
+
50
+ if (publishResponse.status !== httpResponseStatusCodes.NO_CONTENT && !shouldExpectError) {
51
+ throw new Error(`Failed to unpublish policy file - ${publishPolicyFileModel.policyFileId}`);
52
+ }
53
+
54
+ return publishResponse;
55
+ };
56
+
57
+ const getSetPublishFlagToPolicyFileModel = async (requestId, policyFileId, context) => {
58
+ const { isPublished, dateModified } = await getPolicyDetailsForPublishModel(requestId, policyFileId, context);
59
+
60
+ return new PolicyFileToSetPublishFlagRequestBodyModel(policyFileId, isPublished, dateModified);
61
+ };
62
+
63
+ const getPolicyDetailsForPublishModel = async (requestId, policyFileId, context) => {
64
+ const getPoliciesResponse = await getPolicyFilesForVendorReport(requestId, context);
65
+
66
+ for (const policy of getPoliciesResponse.data) {
67
+ if (policy.policyFileId === policyFileId) {
68
+ return {
69
+ isPublished: policy.isPublished,
70
+ dateModified: policy.dateModified
71
+ };
72
+ }
73
+ }
74
+ throw new Error(`No match found for policy file id: ${policyFileId}`);
75
+ };
76
+
77
+ const getPolicyFilesIfExist = async (recordId, context) => {
78
+ let retries = 10;
79
+ let policiesToReviewResponse;
80
+ let policyFiles = [];
81
+
82
+ while (policyFiles.length === 0 && retries > 0) {
83
+ //Busy wait for it takes time to get policy file to review
84
+ await timeUtils.waitFor(1).seconds;
85
+
86
+ policiesToReviewResponse = await policyFileApi.getPolicyFilesRequireAudit(recordId, context);
87
+ policyFiles = policiesToReviewResponse.data;
88
+
89
+ retries--;
90
+ }
91
+
92
+ if (policyFiles.length === 0) {
93
+ throw new Error(`No policy files to review where found for record ${recordId}`);
94
+ }
95
+
96
+ return policiesToReviewResponse;
97
+ };
98
+
99
+ const getPolicyFilesRequireAudit = async (recordId, context) => {
100
+ const getPolicyFilesResponse = await getPolicyFilesIfExist(recordId, context);
101
+
102
+ if (getPolicyFilesResponse.status !== httpResponseStatusCodes.OK) {
103
+ throw new Error('Failed to get policy files that require audit');
104
+ }
105
+
106
+ return getPolicyFilesResponse;
107
+ };
108
+
109
+ module.exports = {
110
+ getPolicyFilesForVendorReport,
111
+ getPreSignedUrlByPolicyId,
112
+ getAuditPolicyFiles,
113
+ getSetPublishFlagToPolicyFileModel,
114
+ unpublishPolicyFile,
115
+ publishPolicyFile,
116
+ getPolicyFilesRequireAudit
117
+ };
@@ -1,21 +1,21 @@
1
- const policyType = {
2
- generalLiability: 'GENERAL_LIABILITY',
3
- umbrella: 'UMBRELLA_EXCESS_LIABILITY',
4
- workersCompensation: 'WORKERS_COMPENSATION',
5
- automobileLiability: 'AUTOMOBILE_LIABILITY',
6
- propertyInsurance: 'PROPERTY_INSURANCE',
7
- professionalLiability: 'PROFESSIONAL_LIABILITY',
8
- businessInterruptions: 'BUSINESS_INTERRUPTION_INCOME_INSURANCE',
9
- environmentalLiability: 'POLLUTION_LIABILITY',
10
- crimeLiability: 'CRIME_LIABILITY',
11
- liquorLiability: 'LIQUOR_LIABILITY',
12
- directorsAndOfficers: 'DIRECTORS_AND_OFFICERS_LIABILITY',
13
- employmentPractice: 'EMPLOYMENT_PRACTICES_LIABILITY',
14
- cyberLiability: 'CYBER_LIABILITY',
15
- garageLiability: 'GARAGE_LIABILITY',
16
- garageKeepers: 'GARAGE_KEEPERS_LIABILITY'
17
- };
18
-
19
- module.exports = {
20
- policyType
21
- };
1
+ const policyType = {
2
+ generalLiability: 'GENERAL_LIABILITY',
3
+ umbrella: 'UMBRELLA_EXCESS_LIABILITY',
4
+ workersCompensation: 'WORKERS_COMPENSATION',
5
+ automobileLiability: 'AUTOMOBILE_LIABILITY',
6
+ propertyInsurance: 'PROPERTY_INSURANCE',
7
+ professionalLiability: 'PROFESSIONAL_LIABILITY',
8
+ businessInterruptions: 'BUSINESS_INTERRUPTION_INCOME_INSURANCE',
9
+ environmentalLiability: 'POLLUTION_LIABILITY',
10
+ crimeLiability: 'CRIME_LIABILITY',
11
+ liquorLiability: 'LIQUOR_LIABILITY',
12
+ directorsAndOfficers: 'DIRECTORS_AND_OFFICERS_LIABILITY',
13
+ employmentPractice: 'EMPLOYMENT_PRACTICES_LIABILITY',
14
+ cyberLiability: 'CYBER_LIABILITY',
15
+ garageLiability: 'GARAGE_LIABILITY',
16
+ garageKeepers: 'GARAGE_KEEPERS_LIABILITY'
17
+ };
18
+
19
+ module.exports = {
20
+ policyType
21
+ };
@@ -1,11 +1,11 @@
1
- const services = require('./api/policy.file.service');
2
-
3
- const { CreatePolicyFileModel } = require('../policyFile/models/create.policy.file.model');
4
-
5
- const models = {
6
- CreatePolicyFileModel
7
- };
8
-
9
- const consts = require('./consts');
10
-
11
- module.exports = { services, models, consts };
1
+ const services = require('./api/policy.file.service');
2
+
3
+ const { CreatePolicyFileModel } = require('../policyFile/models/create.policy.file.model');
4
+
5
+ const models = {
6
+ CreatePolicyFileModel
7
+ };
8
+
9
+ const consts = require('./consts');
10
+
11
+ module.exports = { services, models, consts };
@@ -1,11 +1,11 @@
1
- class CreatePolicyFileModel {
2
- constructor(
3
- policyFileName,
4
- policyType
5
- ) {
6
- this.policyFileName = policyFileName;
7
- this.policyType = policyType;
8
- }
9
- }
10
-
11
- module.exports = { CreatePolicyFileModel };
1
+ class CreatePolicyFileModel {
2
+ constructor(
3
+ policyFileName,
4
+ policyType
5
+ ) {
6
+ this.policyFileName = policyFileName;
7
+ this.policyType = policyType;
8
+ }
9
+ }
10
+
11
+ module.exports = { CreatePolicyFileModel };
@@ -1,13 +1,13 @@
1
- class PolicyFileToSetPublishFlagRequestBodyModel {
2
- constructor(
3
- policyFileId,
4
- isPublished,
5
- policyFileDateModified
6
- ) {
7
- this.policyFileId = policyFileId;
8
- this.isPublished = isPublished;
9
- this.policyFileDateModified = policyFileDateModified;
10
- }
11
- }
12
-
13
- module.exports = { PolicyFileToSetPublishFlagRequestBodyModel };
1
+ class PolicyFileToSetPublishFlagRequestBodyModel {
2
+ constructor(
3
+ policyFileId,
4
+ isPublished,
5
+ policyFileDateModified
6
+ ) {
7
+ this.policyFileId = policyFileId;
8
+ this.isPublished = isPublished;
9
+ this.policyFileDateModified = policyFileDateModified;
10
+ }
11
+ }
12
+
13
+ module.exports = { PolicyFileToSetPublishFlagRequestBodyModel };
@@ -1,39 +1,39 @@
1
- const requests = require('../../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- create: `${backendUrl}/saas/project`,
6
- delete: projectId => `${backendUrl}/saas/project/${projectId}`,
7
- getByAccountId: `${backendUrl}/saas/project/list`,
8
- update: `${backendUrl}/saas/project`,
9
- getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`,
10
- getProjectServiceAreaByProjectId: projectId => `${backendUrl}/saas/integration-tests/project/${projectId}/service-area`
11
- };
12
-
13
- const create = (project, context) => {
14
- return requests.putRequestHandler(Endpoints.create, project, context);
15
- };
16
-
17
- const getProjectsByAccountId = (accountId, context) => {
18
- const params = { userId: accountId };
19
- return requests.getRequestHandler(Endpoints.getByAccountId, params, context);
20
- };
21
-
22
- const getProjectByProjectId = (projectId, context) => {
23
- const params = { };
24
- return requests.getRequestHandler(Endpoints.getProjectByProjectId(projectId), params, context);
25
- };
26
-
27
- const deleteProjectById = (projectId, context) => {
28
- return requests.deleteRequestHandler(Endpoints.delete(projectId), context);
29
- };
30
-
31
- const update = (project, context) => {
32
- return requests.postRequestHandler(Endpoints.update, project, context);
33
- };
34
-
35
- const getProjectServiceAreaByProjectId = (projectId, context) => {
36
- return requests.getRequestHandler(Endpoints.getProjectServiceAreaByProjectId(projectId), {}, context);
37
- };
38
-
39
- module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId, getProjectServiceAreaByProjectId };
1
+ const requests = require('../../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ create: `${backendUrl}/saas/project`,
6
+ delete: projectId => `${backendUrl}/saas/project/${projectId}`,
7
+ getByAccountId: `${backendUrl}/saas/project/list`,
8
+ update: `${backendUrl}/saas/project`,
9
+ getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`,
10
+ getProjectServiceAreaByProjectId: projectId => `${backendUrl}/saas/integration-tests/project/${projectId}/service-area`
11
+ };
12
+
13
+ const create = (project, context) => {
14
+ return requests.putRequestHandler(Endpoints.create, project, context);
15
+ };
16
+
17
+ const getProjectsByAccountId = (accountId, context) => {
18
+ const params = { userId: accountId };
19
+ return requests.getRequestHandler(Endpoints.getByAccountId, params, context);
20
+ };
21
+
22
+ const getProjectByProjectId = (projectId, context) => {
23
+ const params = { };
24
+ return requests.getRequestHandler(Endpoints.getProjectByProjectId(projectId), params, context);
25
+ };
26
+
27
+ const deleteProjectById = (projectId, context) => {
28
+ return requests.deleteRequestHandler(Endpoints.delete(projectId), context);
29
+ };
30
+
31
+ const update = (project, context) => {
32
+ return requests.postRequestHandler(Endpoints.update, project, context);
33
+ };
34
+
35
+ const getProjectServiceAreaByProjectId = (projectId, context) => {
36
+ return requests.getRequestHandler(Endpoints.getProjectServiceAreaByProjectId(projectId), {}, context);
37
+ };
38
+
39
+ module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId, getProjectServiceAreaByProjectId };
@@ -1,77 +1,77 @@
1
- const projectsApi = require('./projects.api');
2
- const { validateType } = require('../../../../../common/validations/typeValidations');
3
- const CreateProjectModel = require('../../models/core/create.project.model');
4
- const UpdateProjectModel = require('../../models/core/update.project.model');
5
- const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
6
-
7
- const getProjectsByAccountId = (accountId, context) => {
8
- return projectsApi.getProjectsByAccountId(accountId, context);
9
- };
10
-
11
- const getProjectByProjectId = (projectId, context) => {
12
- return projectsApi.getProjectByProjectId(projectId, context);
13
- };
14
-
15
- const getProjectByName = async (accountId, projectName, context) => {
16
- const { data: projects } = await getProjectsByAccountId(accountId, context);
17
- const requestedProject = projects.find(project => project.projectName === projectName);
18
- return requestedProject ? requestedProject : null;
19
- };
20
-
21
- const getProjectServiceArea = (projectId, context) => {
22
- return projectsApi.getProjectServiceAreaByProjectId(projectId, context);
23
- };
24
-
25
- const deleteProjectByName = async (accountId, projectName, context) => {
26
- const { data: projects } = await getProjectsByAccountId(accountId, context);
27
- const filteredProjects = projects.filter(project => project.projectName === projectName);
28
-
29
- return await Promise.all(
30
- filteredProjects.map(
31
- async project => await projectsApi.deleteProjectById(project.projectId, context)
32
- )
33
- );
34
- };
35
-
36
- const deleteProjectById = async (projectId, context) => {
37
- const response = await projectsApi.deleteProjectById(projectId, context);
38
-
39
- if (response.status !== httpResponseStatusCodes.OK) {
40
- throw new Error(`Failed to delete project by id ${projectId}`);
41
- }
42
-
43
- return response;
44
- };
45
-
46
- const createProject = (createProjectModel, context) => {
47
- validateType(createProjectModel, CreateProjectModel);
48
- return projectsApi.create(createProjectModel, context);
49
- };
50
-
51
- const getOrCreateProject = async (createProjectModel, context) => {
52
- let project = await getProjectByName(createProjectModel.userId, createProjectModel.projectName, context);
53
-
54
- if (!project) {
55
- await createProject(createProjectModel, context);
56
- project = await getProjectByName(createProjectModel.userId, createProjectModel.projectName, context);
57
- }
58
-
59
- return project;
60
- };
61
-
62
- const updateProject = (updateProjectModel, context) => {
63
- validateType(updateProjectModel, UpdateProjectModel);
64
- return projectsApi.update(updateProjectModel, context);
65
- };
66
-
67
- module.exports = {
68
- getOrCreateProject,
69
- getProjectsByAccountId,
70
- getProjectByProjectId,
71
- getProjectByName,
72
- createProject,
73
- deleteProjectByName,
74
- updateProject,
75
- getProjectServiceArea,
76
- deleteProjectById
77
- };
1
+ const projectsApi = require('./projects.api');
2
+ const { validateType } = require('../../../../../common/validations/typeValidations');
3
+ const CreateProjectModel = require('../../models/core/create.project.model');
4
+ const UpdateProjectModel = require('../../models/core/update.project.model');
5
+ const httpResponseStatusCodes = require('../../../../../common/httpResponseStatusCodes.json');
6
+
7
+ const getProjectsByAccountId = (accountId, context) => {
8
+ return projectsApi.getProjectsByAccountId(accountId, context);
9
+ };
10
+
11
+ const getProjectByProjectId = (projectId, context) => {
12
+ return projectsApi.getProjectByProjectId(projectId, context);
13
+ };
14
+
15
+ const getProjectByName = async (accountId, projectName, context) => {
16
+ const { data: projects } = await getProjectsByAccountId(accountId, context);
17
+ const requestedProject = projects.find(project => project.projectName === projectName);
18
+ return requestedProject ? requestedProject : null;
19
+ };
20
+
21
+ const getProjectServiceArea = (projectId, context) => {
22
+ return projectsApi.getProjectServiceAreaByProjectId(projectId, context);
23
+ };
24
+
25
+ const deleteProjectByName = async (accountId, projectName, context) => {
26
+ const { data: projects } = await getProjectsByAccountId(accountId, context);
27
+ const filteredProjects = projects.filter(project => project.projectName === projectName);
28
+
29
+ return await Promise.all(
30
+ filteredProjects.map(
31
+ async project => await projectsApi.deleteProjectById(project.projectId, context)
32
+ )
33
+ );
34
+ };
35
+
36
+ const deleteProjectById = async (projectId, context) => {
37
+ const response = await projectsApi.deleteProjectById(projectId, context);
38
+
39
+ if (response.status !== httpResponseStatusCodes.OK) {
40
+ throw new Error(`Failed to delete project by id ${projectId}`);
41
+ }
42
+
43
+ return response;
44
+ };
45
+
46
+ const createProject = (createProjectModel, context) => {
47
+ validateType(createProjectModel, CreateProjectModel);
48
+ return projectsApi.create(createProjectModel, context);
49
+ };
50
+
51
+ const getOrCreateProject = async (createProjectModel, context) => {
52
+ let project = await getProjectByName(createProjectModel.userId, createProjectModel.projectName, context);
53
+
54
+ if (!project) {
55
+ await createProject(createProjectModel, context);
56
+ project = await getProjectByName(createProjectModel.userId, createProjectModel.projectName, context);
57
+ }
58
+
59
+ return project;
60
+ };
61
+
62
+ const updateProject = (updateProjectModel, context) => {
63
+ validateType(updateProjectModel, UpdateProjectModel);
64
+ return projectsApi.update(updateProjectModel, context);
65
+ };
66
+
67
+ module.exports = {
68
+ getOrCreateProject,
69
+ getProjectsByAccountId,
70
+ getProjectByProjectId,
71
+ getProjectByName,
72
+ createProject,
73
+ deleteProjectByName,
74
+ updateProject,
75
+ getProjectServiceArea,
76
+ deleteProjectById
77
+ };
@@ -1,18 +1,18 @@
1
- const requests = require('../../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- getByProjectId: projectId => `${backendUrl}/saas/project/${projectId}/settings`,
6
- updateByProjectId: projectId => `${backendUrl}/saas/project/${projectId}/settings`
7
- };
8
-
9
- const getProjectSettingsByProjectId = (projectId, context) => {
10
- const params = { projectId };
11
- return requests.getRequestHandler(Endpoints.getByProjectId(projectId), params, context);
12
- };
13
-
14
- const updateProjectSettingsByProjectId = (settings, context) => {
15
- return requests.putRequestHandler(Endpoints.updateByProjectId(settings.projectId), settings, context);
16
- };
17
-
18
- module.exports = { getProjectSettingsByProjectId, updateProjectSettingsByProjectId };
1
+ const requests = require('../../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ getByProjectId: projectId => `${backendUrl}/saas/project/${projectId}/settings`,
6
+ updateByProjectId: projectId => `${backendUrl}/saas/project/${projectId}/settings`
7
+ };
8
+
9
+ const getProjectSettingsByProjectId = (projectId, context) => {
10
+ const params = { projectId };
11
+ return requests.getRequestHandler(Endpoints.getByProjectId(projectId), params, context);
12
+ };
13
+
14
+ const updateProjectSettingsByProjectId = (settings, context) => {
15
+ return requests.putRequestHandler(Endpoints.updateByProjectId(settings.projectId), settings, context);
16
+ };
17
+
18
+ module.exports = { getProjectSettingsByProjectId, updateProjectSettingsByProjectId };