@getjones/test-infra 1.12.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/package.json +29 -29
  2. package/src/common/{factory → commonFlows}/index.js +3 -3
  3. package/src/common/{factory → commonFlows}/records/records.js +71 -71
  4. package/src/common/httpResponseStatusCodes.json +11 -11
  5. package/src/common/requests/apiKeyAuth/requests.js +38 -38
  6. package/src/common/requests/cookieAuth/requests.js +40 -40
  7. package/src/common/requests/requestHandlers.js +60 -60
  8. package/src/common/utils/numberUtils.js +22 -22
  9. package/src/common/utils/timeUtils.js +162 -162
  10. package/src/common/validations/errorValidation.js +16 -16
  11. package/src/common/validations/typeValidations.js +36 -36
  12. package/src/env.js +45 -45
  13. package/src/index.js +69 -69
  14. package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +28 -28
  15. package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +77 -77
  16. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +48 -48
  17. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +74 -74
  18. package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
  19. package/src/saas/internal-api/accounts/api/settings/settings.service.js +24 -24
  20. package/src/saas/internal-api/accounts/index.js +20 -20
  21. package/src/saas/internal-api/accounts/models/core/create.account.model.js +15 -15
  22. package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +19 -19
  23. package/src/saas/internal-api/accounts/utils/utils.js +32 -32
  24. package/src/saas/internal-api/auth/api/auth.api.js +12 -12
  25. package/src/saas/internal-api/auth/api/auth.service.js +47 -47
  26. package/src/saas/internal-api/auth/index.js +3 -3
  27. package/src/saas/internal-api/coi/api/coi.api.js +34 -34
  28. package/src/saas/internal-api/coi/api/coi.service.js +22 -22
  29. package/src/saas/internal-api/coi/consts/uploaderTypes.js +7 -7
  30. package/src/saas/internal-api/coi/index.js +13 -13
  31. package/src/saas/internal-api/coi/models/submit.coi.model.js +9 -9
  32. package/src/saas/internal-api/coi/utils/utils.js +48 -48
  33. package/src/saas/internal-api/compliance/api/audit/audit.api.js +40 -40
  34. package/src/saas/internal-api/compliance/api/audit/audit.service.js +33 -33
  35. package/src/saas/internal-api/compliance/api/convert/convert.api.js +17 -17
  36. package/src/saas/internal-api/compliance/api/convert/convert.service.js +11 -11
  37. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
  38. package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +24 -24
  39. package/src/saas/internal-api/compliance/api/waive/waive.api.js +21 -21
  40. package/src/saas/internal-api/compliance/api/waive/waive.service.js +15 -15
  41. package/src/saas/internal-api/compliance/index.js +22 -22
  42. package/src/saas/internal-api/compliance/models/audit/audit.model.js +110 -110
  43. package/src/saas/internal-api/compliance/models/waive/waive.model.js +45 -45
  44. package/src/saas/internal-api/contractors/api/contractors.api.js +147 -146
  45. package/src/saas/internal-api/contractors/api/contractors.service.js +130 -129
  46. package/src/saas/internal-api/contractors/index.js +8 -8
  47. package/src/saas/internal-api/contractors/models/create.contractor.model.js +22 -22
  48. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -74
  49. package/src/saas/internal-api/contractors/models/verification.contractor.model.js +27 -27
  50. package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
  51. package/src/saas/internal-api/dbEmails/api/db.emails.service.js +127 -127
  52. package/src/saas/internal-api/dbEmails/consts/consts.js +3 -3
  53. package/src/saas/internal-api/dbEmails/index.js +4 -4
  54. package/src/saas/internal-api/dbEmails/models/db.emails.model.js +21 -21
  55. package/src/saas/internal-api/dbEmails/utils/util.js +59 -59
  56. package/src/saas/internal-api/globalRecord/api/global.record.api.js +76 -76
  57. package/src/saas/internal-api/globalRecord/api/global.record.service.js +83 -83
  58. package/src/saas/internal-api/globalRecord/consts.js +20 -20
  59. package/src/saas/internal-api/globalRecord/index.js +6 -6
  60. package/src/saas/internal-api/globalRecord/models/global.record.model.js +43 -43
  61. package/src/saas/internal-api/globalRecord/utils/util.js +148 -148
  62. package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
  63. package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
  64. package/src/saas/internal-api/homepageCharts/index.js +3 -3
  65. package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
  66. package/src/saas/internal-api/projects/api/core/projects.service.js +65 -65
  67. package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
  68. package/src/saas/internal-api/projects/api/settings/project.settings.service.js +17 -17
  69. package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
  70. package/src/saas/internal-api/projects/index.js +24 -24
  71. package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
  72. package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
  73. package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +39 -39
  74. package/src/saas/internal-api/projects/utils/utils.js +82 -82
  75. package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
  76. package/src/saas/internal-api/recordNotes/api/record.notes.service.js +29 -29
  77. package/src/saas/internal-api/recordNotes/index.js +3 -3
  78. package/src/saas/internal-api/reports/api/reports.api.js +39 -39
  79. package/src/saas/internal-api/reports/api/reports.service.js +34 -34
  80. package/src/saas/internal-api/reports/consts/consts.js +63 -63
  81. package/src/saas/internal-api/reports/index.js +15 -15
  82. package/src/saas/internal-api/reports/models/report.model.js +27 -27
  83. package/src/saas/internal-api/requests/api/requests.api.js +34 -28
  84. package/src/saas/internal-api/requests/api/requests.service.js +31 -19
  85. package/src/saas/internal-api/requests/index.js +11 -9
  86. package/src/saas/internal-api/requests/models/edit.request.model.js +31 -0
  87. package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
  88. package/src/saas/internal-api/requests/utils.js +8 -0
  89. package/src/saas/internal-api/requirements/api/requirements.api.js +27 -27
  90. package/src/saas/internal-api/requirements/api/requirements.service.js +23 -23
  91. package/src/saas/internal-api/requirements/index.js +6 -6
  92. package/src/saas/internal-api/requirements/models/create.requirement.model.js +45 -45
  93. package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
  94. package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
  95. package/src/saas/internal-api/serviceArea/index.js +4 -4
  96. package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
  97. package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
  98. package/src/saas/internal-api/tabs/api/tabs.service.js +54 -54
  99. package/src/saas/internal-api/tabs/index.js +3 -3
  100. package/src/saas/internal-api/tabs/models/tabs.model.js +18 -18
  101. package/src/saas/internal-api/thread-scheduler/runner.js +13 -13
  102. package/src/saas/internal-api/users/api/users.api.js +77 -77
  103. package/src/saas/internal-api/users/api/users.service.js +101 -101
  104. package/src/saas/internal-api/users/index.js +4 -4
  105. package/src/saas/internal-api/users/models/users.model.js +31 -31
  106. package/src/saas/internal-api/users/utils/util.js +14 -14
  107. package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +20 -20
  108. package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +14 -14
  109. package/src/saas/internal-api/vendorProfile/index.js +3 -3
  110. package/src/saas/openapi/accounts/accounts.api.js +17 -17
  111. package/src/saas/openapi/accounts/accounts.service.js +11 -11
  112. package/src/saas/openapi/projects/projects.api.js +59 -59
  113. package/src/saas/openapi/projects/projects.service.js +44 -44
  114. package/src/saas/openapi/requests/index.js +6 -6
  115. package/src/saas/openapi/requests/models/invite.request.model.js +37 -37
  116. package/src/saas/openapi/requests/requests.api.js +20 -20
  117. package/src/saas/openapi/requests/requests.service.js +18 -18
  118. package/src/saas/openapi/requirements/index.js +6 -6
  119. package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
  120. package/src/saas/openapi/requirements/requirements.api.js +12 -12
  121. package/src/saas/openapi/requirements/requirements.service.js +20 -20
  122. package/src/saas/openapi/tabs/tabs.api.js +13 -13
  123. package/src/saas/openapi/tabs/tabs.service.js +7 -7
  124. package/tests/env.test.js +40 -40
  125. package/tests/validation.test.js +83 -83
@@ -1,11 +1,11 @@
1
- const convertApi = require('./convert.api');
2
-
3
- const convertOcrToCoverage = async ocrData => {
4
- return convertApi.convertOcrToCoverage(ocrData).then(res => res && res.data);
5
- };
6
-
7
- const convertRequirement = async requirement => {
8
- return convertApi.convertRequirement(requirement).then(res => res && res.data);
9
- };
10
-
11
- module.exports = { convertOcrToCoverage, convertRequirement };
1
+ const convertApi = require('./convert.api');
2
+
3
+ const convertOcrToCoverage = async ocrData => {
4
+ return convertApi.convertOcrToCoverage(ocrData).then(res => res && res.data);
5
+ };
6
+
7
+ const convertRequirement = async requirement => {
8
+ return convertApi.convertRequirement(requirement).then(res => res && res.data);
9
+ };
10
+
11
+ module.exports = { convertOcrToCoverage, convertRequirement };
@@ -1,33 +1,33 @@
1
- const apiKeyAuthRequests = require('../../../../../common/requests/apiKeyAuth/requests');
2
- const cookieAuthRequests = require('../../../../../common/requests/cookieAuth/requests');
3
- const { backendUrl, nodeBackendUrl } = require('../../../../../env').getEnv();
4
-
5
- const Endpoints = {
6
- saveCoverageNode: `${nodeBackendUrl}/coverage`,
7
- saveCoverageJava: `${backendUrl}/saas/contractors/coverage`,
8
- getCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`,
9
- deleteCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`
10
- };
11
-
12
- const saveCoverageNode = (coverage, nodeBackendSecret) => {
13
- return apiKeyAuthRequests.postRequestHandler(Endpoints.saveCoverageNode, nodeBackendSecret, coverage);
14
- };
15
-
16
- const saveCoverageJava = (auditorContext, auditDates, coverage) => {
17
- return cookieAuthRequests.postRequestHandler(Endpoints.saveCoverageJava, { auditDates, coverage }, auditorContext);
18
- };
19
-
20
- const getCoverageByCoiId = (coiId, nodeBackendSecret) => {
21
- return apiKeyAuthRequests.getRequestHandler(Endpoints.getCoverageByCoiId(coiId), nodeBackendSecret);
22
- };
23
-
24
- const deleteCoverageByCoiId = (coiId, icsContext) => {
25
- return cookieAuthRequests.deleteRequestHandler(Endpoints.deleteCoverageByCoiId(coiId), icsContext);
26
- };
27
-
28
- module.exports = {
29
- saveCoverageNode,
30
- saveCoverageJava,
31
- getCoverageByCoiId,
32
- deleteCoverageByCoiId
33
- };
1
+ const apiKeyAuthRequests = require('../../../../../common/requests/apiKeyAuth/requests');
2
+ const cookieAuthRequests = require('../../../../../common/requests/cookieAuth/requests');
3
+ const { backendUrl, nodeBackendUrl } = require('../../../../../env').getEnv();
4
+
5
+ const Endpoints = {
6
+ saveCoverageNode: `${nodeBackendUrl}/coverage`,
7
+ saveCoverageJava: `${backendUrl}/saas/contractors/coverage`,
8
+ getCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`,
9
+ deleteCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`
10
+ };
11
+
12
+ const saveCoverageNode = (coverage, nodeBackendSecret) => {
13
+ return apiKeyAuthRequests.postRequestHandler(Endpoints.saveCoverageNode, nodeBackendSecret, coverage);
14
+ };
15
+
16
+ const saveCoverageJava = (auditorContext, auditDates, coverage) => {
17
+ return cookieAuthRequests.postRequestHandler(Endpoints.saveCoverageJava, { auditDates, coverage }, auditorContext);
18
+ };
19
+
20
+ const getCoverageByCoiId = (coiId, nodeBackendSecret) => {
21
+ return apiKeyAuthRequests.getRequestHandler(Endpoints.getCoverageByCoiId(coiId), nodeBackendSecret);
22
+ };
23
+
24
+ const deleteCoverageByCoiId = (coiId, icsContext) => {
25
+ return cookieAuthRequests.deleteRequestHandler(Endpoints.deleteCoverageByCoiId(coiId), icsContext);
26
+ };
27
+
28
+ module.exports = {
29
+ saveCoverageNode,
30
+ saveCoverageJava,
31
+ getCoverageByCoiId,
32
+ deleteCoverageByCoiId
33
+ };
@@ -1,24 +1,24 @@
1
- const coverageApi = require('./coverage.api');
2
-
3
- const saveCoverageNode = (coverage, nodeBackendSecret) => {
4
- return coverageApi.saveCoverageNode(coverage, nodeBackendSecret);
5
- };
6
-
7
- const saveCoverageJava = (auditorContext, auditDates, coverage) => {
8
- return coverageApi.saveCoverageJava(auditorContext, auditDates, coverage);
9
- };
10
-
11
- const getCoverageByCoiId = (coiId, nodeBackendSecret) => {
12
- return coverageApi.getCoverageByCoiId(coiId, nodeBackendSecret).then(res => res && res.data);
13
- };
14
-
15
- const deleteCoverageByCoiId = (coiId, icsContext) => {
16
- return coverageApi.deleteCoverageByCoiId(coiId, icsContext);
17
- };
18
-
19
- module.exports = {
20
- saveCoverageNode,
21
- saveCoverageJava,
22
- getCoverageByCoiId,
23
- deleteCoverageByCoiId
24
- };
1
+ const coverageApi = require('./coverage.api');
2
+
3
+ const saveCoverageNode = (coverage, nodeBackendSecret) => {
4
+ return coverageApi.saveCoverageNode(coverage, nodeBackendSecret);
5
+ };
6
+
7
+ const saveCoverageJava = (auditorContext, auditDates, coverage) => {
8
+ return coverageApi.saveCoverageJava(auditorContext, auditDates, coverage);
9
+ };
10
+
11
+ const getCoverageByCoiId = (coiId, nodeBackendSecret) => {
12
+ return coverageApi.getCoverageByCoiId(coiId, nodeBackendSecret).then(res => res && res.data);
13
+ };
14
+
15
+ const deleteCoverageByCoiId = (coiId, icsContext) => {
16
+ return coverageApi.deleteCoverageByCoiId(coiId, icsContext);
17
+ };
18
+
19
+ module.exports = {
20
+ saveCoverageNode,
21
+ saveCoverageJava,
22
+ getCoverageByCoiId,
23
+ deleteCoverageByCoiId
24
+ };
@@ -1,21 +1,21 @@
1
- const requests = require('../../../../../common/requests/cookieAuth/requests');
2
- const { backendUrl } = require('../../../../../env').getEnv();
3
-
4
- const Endpoints = {
5
- waive: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
6
- retract: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`
7
- };
8
-
9
- const waive = async (contractorId, waiveRequestModel, context) => {
10
- const status = waiveRequestModel.status;
11
- delete waiveRequestModel.status;
12
- return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status });
13
- };
14
-
15
- const retract = async (contractorId, retractRequestModel, context) => {
16
- const status = retractRequestModel.status;
17
- delete retractRequestModel.status;
18
- return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status });
19
- };
20
-
21
- module.exports = { waive, retract };
1
+ const requests = require('../../../../../common/requests/cookieAuth/requests');
2
+ const { backendUrl } = require('../../../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ waive: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`,
6
+ retract: contractorId => `${backendUrl}/saas/contractors/${contractorId}/waiver`
7
+ };
8
+
9
+ const waive = async (contractorId, waiveRequestModel, context) => {
10
+ const status = waiveRequestModel.status;
11
+ delete waiveRequestModel.status;
12
+ return requests.postRequestHandler(Endpoints.waive(contractorId), waiveRequestModel, context, {}, { status });
13
+ };
14
+
15
+ const retract = async (contractorId, retractRequestModel, context) => {
16
+ const status = retractRequestModel.status;
17
+ delete retractRequestModel.status;
18
+ return requests.postRequestHandler(Endpoints.retract(contractorId), retractRequestModel, context, {}, { status });
19
+ };
20
+
21
+ module.exports = { waive, retract };
@@ -1,15 +1,15 @@
1
- const waiveApi = require('./waive.api');
2
- const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
3
- const { validateType } = require('../../../../../common/validations/typeValidations');
4
-
5
- const waive = (waiveRequestModel, context) => {
6
- validateType(waiveRequestModel, WaiveRequestModel);
7
- return waiveApi.waive(waiveRequestModel.contractorId, waiveRequestModel, context);
8
- };
9
-
10
- const retract = (retractRequestModel, context) => {
11
- validateType(retractRequestModel, RetractRequestModel);
12
- return waiveApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
13
- };
14
-
15
- module.exports = { waive, retract };
1
+ const waiveApi = require('./waive.api');
2
+ const { WaiveRequestModel, RetractRequestModel } = require('../../models/waive/waive.model');
3
+ const { validateType } = require('../../../../../common/validations/typeValidations');
4
+
5
+ const waive = (waiveRequestModel, context) => {
6
+ validateType(waiveRequestModel, WaiveRequestModel);
7
+ return waiveApi.waive(waiveRequestModel.contractorId, waiveRequestModel, context);
8
+ };
9
+
10
+ const retract = (retractRequestModel, context) => {
11
+ validateType(retractRequestModel, RetractRequestModel);
12
+ return waiveApi.retract(retractRequestModel.contractorId, retractRequestModel, context);
13
+ };
14
+
15
+ module.exports = { waive, retract };
@@ -1,22 +1,22 @@
1
- const auditModels = require('./models/audit/audit.model');
2
- const auditServices = require('./api/audit/audit.service');
3
-
4
- const waiveModels = require('./models/waive/waive.model');
5
- const waiveServices = require('./api/waive/waive.service');
6
-
7
- const convertServices = require('./api/convert/convert.service');
8
- const coverageServices = require('./api/coverage/coverage.service');
9
-
10
- const models = {
11
- audit: auditModels,
12
- waive: waiveModels
13
- };
14
-
15
- const services = {
16
- audit: auditServices,
17
- waive: waiveServices,
18
- convert: convertServices,
19
- coverage: coverageServices
20
- };
21
-
22
- module.exports = { services, models };
1
+ const auditModels = require('./models/audit/audit.model');
2
+ const auditServices = require('./api/audit/audit.service');
3
+
4
+ const waiveModels = require('./models/waive/waive.model');
5
+ const waiveServices = require('./api/waive/waive.service');
6
+
7
+ const convertServices = require('./api/convert/convert.service');
8
+ const coverageServices = require('./api/coverage/coverage.service');
9
+
10
+ const models = {
11
+ audit: auditModels,
12
+ waive: waiveModels
13
+ };
14
+
15
+ const services = {
16
+ audit: auditServices,
17
+ waive: waiveServices,
18
+ convert: convertServices,
19
+ coverage: coverageServices
20
+ };
21
+
22
+ module.exports = { services, models };
@@ -1,110 +1,110 @@
1
- const { validateType, validateInteger, validateArray, validateDateString } = require('../../../../../common/validations/typeValidations');
2
-
3
- const COI_AUDIT_STATUSES = {
4
- NOT_AUDITED: '0',
5
- REAUDIT: '3'
6
- };
7
-
8
- const AUDIT_ENTITY_STATUSES = {
9
- YES: 'Yes',
10
- NO: 'No',
11
- EMPTY: 'empty',
12
- OTHER: 'other',
13
- CLAIMS: 'Claims'
14
- };
15
-
16
- const AUDIT_ATTRIBUTE_NAMES = {
17
- CERTIFICATE_ISSUE_DATE: 'certIssueDate'
18
- };
19
-
20
- const AUDIT_POLICY_NAMES = {
21
- GENERAL_LIABILITY: ''
22
- };
23
-
24
- const AUDITOR_ROLE = 'Auditor';
25
-
26
- class AuditRequestModel {
27
- constructor(
28
- accountId = null,
29
- projectId = null,
30
- requirementId = null,
31
- contractorId = null,
32
- certificateId = null,
33
- auditorId = null,
34
- auditEntities = null,
35
- isReaudit = null,
36
- isProjectOnboarding = false,
37
- shouldSendNotificationToPM = true,
38
- auditDates = {},
39
- auditStatus = null,
40
- auditorRole = AUDITOR_ROLE
41
- ) {
42
- const auditData = {
43
- userId: accountId,
44
- projectId: projectId,
45
- requirementId: requirementId,
46
- contractorId: contractorId,
47
- certificateId: certificateId,
48
- auditorId: auditorId,
49
- policyDetails: auditEntities,
50
- auditorStatus: COI_AUDIT_STATUSES.NOT_AUDITED,
51
- isReaudit: isReaudit,
52
- projectOnboarding: isProjectOnboarding,
53
- role: auditorRole,
54
- sendNotificationToPM: shouldSendNotificationToPM,
55
- auditStatus
56
- };
57
-
58
- validateType(auditDates, AuditDatesModel);
59
- this.auditData = auditData;
60
- this.auditDates = auditDates;
61
- }
62
- }
63
-
64
- class AuditEntityModel {
65
- constructor(policyId, attributeName, status, value) {
66
- this.contractorInsuranceId = policyId;
67
- this.limitname = attributeName;
68
- this.status = status;
69
- this.value = value;
70
- }
71
- }
72
-
73
- class AuditDatesModel {
74
- constructor(contractorId, contractorDateModified, dateStartedAudit, contractorOverrideDateModified, contractCreateDate) {
75
- this.contractorId = contractorId;
76
- this.contractorDateModified = contractorDateModified;
77
- this.dateStartedAudit = dateStartedAudit;
78
- this.contractorOverrideDateModified = contractorOverrideDateModified;
79
- this.contractCreateDate = contractCreateDate;
80
- }
81
- }
82
-
83
- class AuditListParametersModel {
84
- constructor(page, accountIds, { fromDate, toDate } = {}) {
85
- validateInteger(page, { min: 1 });
86
- validateArray(accountIds);
87
-
88
- if (fromDate) {
89
- validateDateString(fromDate);
90
- }
91
-
92
- if (toDate) {
93
- validateDateString(toDate);
94
- }
95
-
96
- this.page = page;
97
- this.filters = { accountIds, fromDate, toDate };
98
- }
99
- }
100
-
101
- module.exports = {
102
- AuditRequestModel,
103
- AuditEntityModel,
104
- AuditDatesModel,
105
- AuditListParametersModel,
106
- COI_AUDIT_STATUSES,
107
- AUDIT_ENTITY_STATUSES,
108
- AUDIT_ATTRIBUTE_NAMES,
109
- AUDIT_POLICY_NAMES
110
- };
1
+ const { validateType, validateInteger, validateArray, validateDateString } = require('../../../../../common/validations/typeValidations');
2
+
3
+ const COI_AUDIT_STATUSES = {
4
+ NOT_AUDITED: '0',
5
+ REAUDIT: '3'
6
+ };
7
+
8
+ const AUDIT_ENTITY_STATUSES = {
9
+ YES: 'Yes',
10
+ NO: 'No',
11
+ EMPTY: 'empty',
12
+ OTHER: 'other',
13
+ CLAIMS: 'Claims'
14
+ };
15
+
16
+ const AUDIT_ATTRIBUTE_NAMES = {
17
+ CERTIFICATE_ISSUE_DATE: 'certIssueDate'
18
+ };
19
+
20
+ const AUDIT_POLICY_NAMES = {
21
+ GENERAL_LIABILITY: ''
22
+ };
23
+
24
+ const AUDITOR_ROLE = 'Auditor';
25
+
26
+ class AuditRequestModel {
27
+ constructor(
28
+ accountId = null,
29
+ projectId = null,
30
+ requirementId = null,
31
+ contractorId = null,
32
+ certificateId = null,
33
+ auditorId = null,
34
+ auditEntities = null,
35
+ isReaudit = null,
36
+ isProjectOnboarding = false,
37
+ shouldSendNotificationToPM = true,
38
+ auditDates = {},
39
+ auditStatus = null,
40
+ auditorRole = AUDITOR_ROLE
41
+ ) {
42
+ const auditData = {
43
+ userId: accountId,
44
+ projectId: projectId,
45
+ requirementId: requirementId,
46
+ contractorId: contractorId,
47
+ certificateId: certificateId,
48
+ auditorId: auditorId,
49
+ policyDetails: auditEntities,
50
+ auditorStatus: COI_AUDIT_STATUSES.NOT_AUDITED,
51
+ isReaudit: isReaudit,
52
+ projectOnboarding: isProjectOnboarding,
53
+ role: auditorRole,
54
+ sendNotificationToPM: shouldSendNotificationToPM,
55
+ auditStatus
56
+ };
57
+
58
+ validateType(auditDates, AuditDatesModel);
59
+ this.auditData = auditData;
60
+ this.auditDates = auditDates;
61
+ }
62
+ }
63
+
64
+ class AuditEntityModel {
65
+ constructor(policyId, attributeName, status, value) {
66
+ this.contractorInsuranceId = policyId;
67
+ this.limitname = attributeName;
68
+ this.status = status;
69
+ this.value = value;
70
+ }
71
+ }
72
+
73
+ class AuditDatesModel {
74
+ constructor(contractorId, contractorDateModified, dateStartedAudit, contractorOverrideDateModified, contractCreateDate) {
75
+ this.contractorId = contractorId;
76
+ this.contractorDateModified = contractorDateModified;
77
+ this.dateStartedAudit = dateStartedAudit;
78
+ this.contractorOverrideDateModified = contractorOverrideDateModified;
79
+ this.contractCreateDate = contractCreateDate;
80
+ }
81
+ }
82
+
83
+ class AuditListParametersModel {
84
+ constructor(page, accountIds, { fromDate, toDate } = {}) {
85
+ validateInteger(page, { min: 1 });
86
+ validateArray(accountIds);
87
+
88
+ if (fromDate) {
89
+ validateDateString(fromDate);
90
+ }
91
+
92
+ if (toDate) {
93
+ validateDateString(toDate);
94
+ }
95
+
96
+ this.page = page;
97
+ this.filters = { accountIds, fromDate, toDate };
98
+ }
99
+ }
100
+
101
+ module.exports = {
102
+ AuditRequestModel,
103
+ AuditEntityModel,
104
+ AuditDatesModel,
105
+ AuditListParametersModel,
106
+ COI_AUDIT_STATUSES,
107
+ AUDIT_ENTITY_STATUSES,
108
+ AUDIT_ATTRIBUTE_NAMES,
109
+ AUDIT_POLICY_NAMES
110
+ };
@@ -1,45 +1,45 @@
1
- const DEFAULT_USER_ROLE = 'ICS';
2
-
3
- const WAIVE_ACTIONS = {
4
- WAIVE: 'ignored',
5
- RETRACT: 'notIgnored'
6
- };
7
-
8
- const WAIVER_REASONS = {
9
- BUSINESS_DECISION: 'Business_Decision',
10
- NO_EXPOSURE: 'No_Exposure',
11
- EXECUTIVE_APPROVAL: 'Executive_Approval'
12
- };
13
-
14
- function WaiveRequestModel({
15
- userId,
16
- contractorId,
17
- auditId,
18
- waiverReason,
19
- remarks = '',
20
- userRole = DEFAULT_USER_ROLE
21
- }) {
22
- this.auditorContractorId = auditId;
23
- this.contractorId = contractorId;
24
- this.userId = userId;
25
- this.waiverReason = waiverReason;
26
- this.remarks = remarks;
27
-
28
- this.userRole = userRole;
29
- this.status = WAIVE_ACTIONS.WAIVE;
30
- }
31
-
32
- function RetractRequestModel({ userId, contractorId, auditId, userRole = DEFAULT_USER_ROLE }) {
33
- this.auditorContractorId = auditId;
34
- this.contractorId = contractorId;
35
- this.userId = userId;
36
- this.userRole = userRole;
37
- this.status = WAIVE_ACTIONS.RETRACT;
38
- }
39
-
40
- module.exports = {
41
- WaiveRequestModel,
42
- RetractRequestModel,
43
- WAIVE_ACTIONS,
44
- WAIVER_REASONS
45
- };
1
+ const DEFAULT_USER_ROLE = 'ICS';
2
+
3
+ const WAIVE_ACTIONS = {
4
+ WAIVE: 'ignored',
5
+ RETRACT: 'notIgnored'
6
+ };
7
+
8
+ const WAIVER_REASONS = {
9
+ BUSINESS_DECISION: 'Business_Decision',
10
+ NO_EXPOSURE: 'No_Exposure',
11
+ EXECUTIVE_APPROVAL: 'Executive_Approval'
12
+ };
13
+
14
+ function WaiveRequestModel({
15
+ userId,
16
+ contractorId,
17
+ auditId,
18
+ waiverReason,
19
+ remarks = '',
20
+ userRole = DEFAULT_USER_ROLE
21
+ }) {
22
+ this.auditorContractorId = auditId;
23
+ this.contractorId = contractorId;
24
+ this.userId = userId;
25
+ this.waiverReason = waiverReason;
26
+ this.remarks = remarks;
27
+
28
+ this.userRole = userRole;
29
+ this.status = WAIVE_ACTIONS.WAIVE;
30
+ }
31
+
32
+ function RetractRequestModel({ userId, contractorId, auditId, userRole = DEFAULT_USER_ROLE }) {
33
+ this.auditorContractorId = auditId;
34
+ this.contractorId = contractorId;
35
+ this.userId = userId;
36
+ this.userRole = userRole;
37
+ this.status = WAIVE_ACTIONS.RETRACT;
38
+ }
39
+
40
+ module.exports = {
41
+ WaiveRequestModel,
42
+ RetractRequestModel,
43
+ WAIVE_ACTIONS,
44
+ WAIVER_REASONS
45
+ };