@getjones/test-infra 5.2.10 → 5.2.12
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.
- package/eslint.config.mjs +156 -156
- package/package.json +43 -42
- package/src/common/commonFlows/auth/auth.js +95 -95
- package/src/common/commonFlows/index.js +5 -5
- package/src/common/commonFlows/records/records.js +457 -423
- package/src/common/commonFlows/users/users.js +15 -15
- package/src/common/consts/accountSettings.js +112 -112
- package/src/common/consts/activationStatuses.js +6 -6
- package/src/common/consts/analysisStatuses.js +7 -7
- package/src/common/consts/autocomplete.js +10 -10
- package/src/common/consts/constantsForRecordsSortingAndFilters.js +49 -49
- package/src/common/consts/dashboardCharts.js +18 -18
- package/src/common/consts/homepage/AttentionTab.js +6 -6
- package/src/common/consts/homepage/sortOptions.js +19 -19
- package/src/common/consts/projectSettings.js +28 -28
- package/src/common/consts/recordTypes.js +5 -5
- package/src/common/consts/requirementActions.js +10 -10
- package/src/common/consts/s3FileTypes.js +12 -12
- package/src/common/consts/userRoles.js +21 -21
- package/src/common/consts/userTypes.js +16 -16
- package/src/common/errorCodes.js +12 -11
- package/src/common/httpResponseStatusCodes.json +19 -19
- package/src/common/httpResponseTypes.json +2 -2
- package/src/common/requests/apiKeyAuth/requests.js +45 -45
- package/src/common/requests/cookieAuth/requests.js +40 -40
- package/src/common/requests/internalAuth/requests.js +48 -48
- package/src/common/requests/requestHandlers.js +112 -112
- package/src/common/utils/arrayUtils.js +19 -19
- package/src/common/utils/complianceUtil.js +114 -114
- package/src/common/utils/configsUtil.js +22 -22
- package/src/common/utils/dataTypeUtils.js +41 -41
- package/src/common/utils/numberUtils.js +22 -22
- package/src/common/utils/objectUtils.js +102 -102
- package/src/common/utils/timeUtils.js +195 -195
- package/src/common/validations/typeValidations.js +36 -36
- package/src/defaults/configs/attributes.js +170 -170
- package/src/defaults/configs/auditConfigs.js +129 -129
- package/src/defaults/configs/coverage.js +144 -144
- package/src/defaults/configs/polices.js +28 -28
- package/src/defaults/configs/requirement.js +218 -218
- package/src/defaults/index.js +7 -7
- package/src/env.js +58 -58
- package/src/factory/globalRecord/globalRecord.js +43 -43
- package/src/factory/index.js +8 -8
- package/src/factory/records/records.js +295 -295
- package/src/factory/users/users.js +70 -70
- package/src/index.js +114 -114
- package/src/reporters/mochaReporter.js +273 -273
- package/src/resources/agreements/agreement.pdf +0 -0
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.api.js +152 -152
- package/src/saas/internal-api/accountDirectory/api/accountDirectory.service.js +576 -576
- package/src/saas/internal-api/accountDirectory/consts/accountDirectory.consts.js +75 -75
- package/src/saas/internal-api/accountDirectory/index.js +5 -5
- package/src/saas/internal-api/accountDirectory/models/accountDirectory.models.js +172 -172
- package/src/saas/internal-api/accounts/api/core/accounts.core.api.js +48 -48
- package/src/saas/internal-api/accounts/api/core/accounts.core.service.js +104 -104
- package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.api.js +29 -29
- package/src/saas/internal-api/accounts/api/emailCustomization/accounts.email.customizations.service.js +60 -60
- package/src/saas/internal-api/accounts/api/emailCustomization/consts.js +8 -8
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +54 -54
- package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.service.js +67 -67
- package/src/saas/internal-api/accounts/api/settings/settings.api.js +21 -21
- package/src/saas/internal-api/accounts/api/settings/settings.service.js +58 -58
- package/src/saas/internal-api/accounts/consts/consts.js +8 -8
- package/src/saas/internal-api/accounts/index.js +22 -22
- package/src/saas/internal-api/accounts/models/core/create.account.model.js +16 -16
- package/src/saas/internal-api/accounts/models/settings/update.settings.model.js +110 -110
- package/src/saas/internal-api/accounts/utils/utils.js +60 -60
- package/src/saas/internal-api/agreement/api/agreement.api.js +39 -39
- package/src/saas/internal-api/agreement/api/agreement.service.js +121 -121
- package/src/saas/internal-api/agreement/consts/consts.js +11 -11
- package/src/saas/internal-api/agreement/index.js +12 -12
- package/src/saas/internal-api/agreement/models/create.agreement.model.js +12 -12
- package/src/saas/internal-api/agreement/models/createAgreementByAuditorModel.js +11 -11
- package/src/saas/internal-api/agreement/models/createAgreementByPMModel.js +13 -13
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.api.js +49 -49
- package/src/saas/internal-api/auditCustomerRules/api/customer.rules.service.js +121 -121
- package/src/saas/internal-api/auditCustomerRules/consts/customer.rule.js +40 -40
- package/src/saas/internal-api/auditCustomerRules/index.js +7 -7
- package/src/saas/internal-api/auditCustomerRules/models/customer.rule.model.js +55 -55
- package/src/saas/internal-api/auditCustomerRules/utils/customer.rule.util.js +70 -70
- package/src/saas/internal-api/auditNotes/api/audit.notes.api.js +40 -40
- package/src/saas/internal-api/auditNotes/api/audit.notes.service.js +116 -116
- package/src/saas/internal-api/auditNotes/index.js +4 -4
- package/src/saas/internal-api/auditNotes/models/audit.note.model.js +32 -32
- package/src/saas/internal-api/auditorComments/api/auditor.comments.api.js +20 -20
- package/src/saas/internal-api/auditorComments/api/auditor.comments.service.js +27 -27
- package/src/saas/internal-api/auditorComments/consts/auditor.comment.js +16 -16
- package/src/saas/internal-api/auditorComments/index.js +5 -5
- package/src/saas/internal-api/auditorComments/models/auditor.comment.model.js +40 -40
- package/src/saas/internal-api/auth/api/auth.api.js +78 -78
- package/src/saas/internal-api/auth/api/auth.service.js +206 -172
- package/src/saas/internal-api/auth/index.js +3 -3
- package/src/saas/internal-api/coi/api/coi.api.js +76 -76
- package/src/saas/internal-api/coi/api/coi.service.js +104 -104
- package/src/saas/internal-api/coi/consts/duplicateHandling.js +7 -7
- package/src/saas/internal-api/coi/consts/hashes.js +5 -5
- package/src/saas/internal-api/coi/consts/uploaderTypes.js +3 -3
- package/src/saas/internal-api/coi/index.js +16 -16
- package/src/saas/internal-api/coi/models/Combine.last.two.cois.model.js +25 -25
- package/src/saas/internal-api/coi/models/submit.coi.batch.model.js +23 -23
- package/src/saas/internal-api/coi/models/submit.coi.model.js +23 -23
- package/src/saas/internal-api/coi/utils/utils.js +185 -185
- package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.api.js +12 -12
- package/src/saas/internal-api/compliance/api/amBestRating/am.best.rating.service.js +14 -14
- package/src/saas/internal-api/compliance/api/audit/aiAudit/aiAudit.api.js +63 -63
- package/src/saas/internal-api/compliance/api/audit/aiAudit/aiAudit.service.js +99 -99
- package/src/saas/internal-api/compliance/api/audit/audit.api.js +124 -124
- package/src/saas/internal-api/compliance/api/audit/audit.service.js +390 -390
- package/src/saas/internal-api/compliance/api/complianceSnapshot/compliance.snapshot.api.js +32 -32
- package/src/saas/internal-api/compliance/api/complianceSnapshot/compliance.snapshot.service.js +73 -73
- package/src/saas/internal-api/compliance/api/convert/convert.api.js +12 -12
- package/src/saas/internal-api/compliance/api/convert/convert.service.js +7 -7
- package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +33 -33
- package/src/saas/internal-api/compliance/api/coverage/coverage.service.js +46 -46
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.api.js +86 -86
- package/src/saas/internal-api/compliance/api/overrideGap/override.gap.service.js +300 -300
- package/src/saas/internal-api/compliance/consts/audit.js +130 -130
- package/src/saas/internal-api/compliance/consts/overrideGapRequest/override.gap.request.js +7 -7
- package/src/saas/internal-api/compliance/index.js +41 -41
- package/src/saas/internal-api/compliance/models/audit/audit.model.js +109 -109
- package/src/saas/internal-api/compliance/models/overrideGapRequest/override.gap.request.model.js +16 -16
- package/src/saas/internal-api/compliance/models/waive/waive.model.js +112 -112
- package/src/saas/internal-api/compliance/utils/auditUtil.js +308 -308
- package/src/saas/internal-api/compliance/utils/coverageUtil.js +45 -45
- package/src/saas/internal-api/contractors/api/contractors.service.js +482 -482
- package/src/saas/internal-api/contractors/consts/consts.js +6 -6
- package/src/saas/internal-api/contractors/index.js +8 -8
- package/src/saas/internal-api/contractors/models/assign.requirement.model.js +11 -11
- package/src/saas/internal-api/contractors/models/edit.contractor.model.js +73 -73
- package/src/saas/internal-api/contractors/models/link.request.model.js +10 -10
- package/src/saas/internal-api/contractors/models/verification.contractor.model.js +29 -29
- package/src/saas/internal-api/contractors/utils.js +25 -25
- package/src/saas/internal-api/customTags/api/customTags.api.js +47 -47
- package/src/saas/internal-api/customTags/api/customTags.service.js +96 -96
- package/src/saas/internal-api/customTags/index.js +4 -4
- package/src/saas/internal-api/customTags/models/customTagsModels.js +17 -17
- package/src/saas/internal-api/dashboard/api/recordList.api.js +38 -38
- package/src/saas/internal-api/dashboard/api/recordList.service.js +60 -60
- package/src/saas/internal-api/dashboard/index.js +5 -5
- package/src/saas/internal-api/dashboard/models/dashboard.filter.criteria.model.js +38 -38
- package/src/saas/internal-api/dbEmails/api/db.emails.api.js +25 -25
- package/src/saas/internal-api/dbEmails/api/db.emails.service.js +178 -178
- package/src/saas/internal-api/dbEmails/consts/consts.js +66 -66
- package/src/saas/internal-api/dbEmails/index.js +6 -6
- package/src/saas/internal-api/dbEmails/models/db.emails.model.js +22 -22
- package/src/saas/internal-api/dbEmails/utils/util.js +82 -82
- package/src/saas/internal-api/emailCustomization/api/email.customization.api.js +26 -26
- package/src/saas/internal-api/emailCustomization/api/email.customization.service.js +50 -50
- package/src/saas/internal-api/emailCustomization/index.js +3 -3
- package/src/saas/internal-api/fileScan/api/file.scan.api.js +14 -14
- package/src/saas/internal-api/fileScan/api/file.scan.service.js +35 -35
- package/src/saas/internal-api/fileScan/index.js +3 -3
- package/src/saas/internal-api/fileScan/models/update.scan.status.model.js +13 -13
- package/src/saas/internal-api/globalRecord/api/global.record.api.js +95 -95
- package/src/saas/internal-api/globalRecord/api/global.record.service.js +112 -112
- package/src/saas/internal-api/globalRecord/consts.js +20 -20
- package/src/saas/internal-api/globalRecord/index.js +6 -6
- package/src/saas/internal-api/globalRecord/models/global.record.model.js +60 -60
- package/src/saas/internal-api/globalRecord/utils/util.js +161 -161
- package/src/saas/internal-api/homepageCharts/api/charts.api.js +12 -12
- package/src/saas/internal-api/homepageCharts/api/charts.service.js +7 -7
- package/src/saas/internal-api/homepageCharts/index.js +3 -3
- package/src/saas/internal-api/notificationCenter/api/notification.center.api.js +32 -32
- package/src/saas/internal-api/notificationCenter/api/notification.center.service.js +49 -49
- package/src/saas/internal-api/notificationCenter/consts.js +9 -9
- package/src/saas/internal-api/notificationCenter/index.js +4 -4
- package/src/saas/internal-api/outlook/api/outlook.api.js +14 -14
- package/src/saas/internal-api/outlook/api/outlook.service.js +14 -14
- package/src/saas/internal-api/outlook/index.js +3 -3
- package/src/saas/internal-api/policyFile/api/policy.file.api.js +43 -43
- package/src/saas/internal-api/policyFile/api/policy.file.service.js +117 -117
- package/src/saas/internal-api/policyFile/consts.js +21 -21
- package/src/saas/internal-api/policyFile/index.js +11 -11
- package/src/saas/internal-api/policyFile/models/create.policy.file.model.js +11 -11
- package/src/saas/internal-api/policyFile/models/set.publish.flag.to.policy.model.js +13 -13
- package/src/saas/internal-api/projects/api/core/projects.api.js +39 -39
- package/src/saas/internal-api/projects/api/core/projects.service.js +77 -77
- package/src/saas/internal-api/projects/api/settings/project.settings.api.js +18 -18
- package/src/saas/internal-api/projects/api/settings/project.settings.service.js +35 -35
- package/src/saas/internal-api/projects/consts/defaultProject.js +3 -3
- package/src/saas/internal-api/projects/index.js +24 -24
- package/src/saas/internal-api/projects/models/core/create.project.model.js +41 -41
- package/src/saas/internal-api/projects/models/core/update.project.model.js +47 -47
- package/src/saas/internal-api/projects/models/settings/update.project.settings.model.js +48 -48
- package/src/saas/internal-api/projects/utils/utils.js +159 -159
- package/src/saas/internal-api/recordHub/api/record.hub.api.js +20 -20
- package/src/saas/internal-api/recordHub/api/record.hub.service.js +86 -86
- package/src/saas/internal-api/recordHub/index.js +3 -3
- package/src/saas/internal-api/recordNotes/api/record.notes.api.js +38 -38
- package/src/saas/internal-api/recordNotes/api/record.notes.service.js +56 -56
- package/src/saas/internal-api/recordNotes/api/record.notes.utils.js +12 -12
- package/src/saas/internal-api/recordNotes/index.js +3 -3
- package/src/saas/internal-api/relatedDocs/api/related.docs.api.js +98 -98
- package/src/saas/internal-api/relatedDocs/api/related.docs.service.js +180 -180
- package/src/saas/internal-api/relatedDocs/index.js +4 -4
- package/src/saas/internal-api/relatedDocs/models/related.doc.model.js +36 -36
- package/src/saas/internal-api/reports/api/reports.api.js +56 -56
- package/src/saas/internal-api/reports/api/reports.service.js +68 -68
- package/src/saas/internal-api/reports/consts/consts.js +71 -71
- package/src/saas/internal-api/reports/index.js +15 -15
- package/src/saas/internal-api/reports/models/report.model.js +27 -27
- package/src/saas/internal-api/requests/api/requests.api.js +132 -132
- package/src/saas/internal-api/requests/api/requests.service.js +315 -315
- package/src/saas/internal-api/requests/index.js +21 -21
- package/src/saas/internal-api/requests/models/create.request.model.js +39 -39
- package/src/saas/internal-api/requests/models/draft.request.criteria.model.js +18 -18
- package/src/saas/internal-api/requests/models/draft.request.report.model.js +14 -14
- package/src/saas/internal-api/requests/models/edit.request.model.js +31 -31
- package/src/saas/internal-api/requests/models/homepageRequestCriteriaModel.js +19 -19
- package/src/saas/internal-api/requests/models/requestListCriteriaModel.js +17 -17
- package/src/saas/internal-api/requests/models/tenant.request.model.js +9 -9
- package/src/saas/internal-api/requests/utils.js +16 -16
- package/src/saas/internal-api/requestsTable/api/requests.table.api.js +20 -20
- package/src/saas/internal-api/requestsTable/api/requests.table.service.js +14 -14
- package/src/saas/internal-api/requestsTable/index.js +3 -3
- package/src/saas/internal-api/requirements/api/lease/lease.api.js +74 -56
- package/src/saas/internal-api/requirements/api/lease/lease.service.js +167 -123
- package/src/saas/internal-api/requirements/api/requirements.api.js +65 -65
- package/src/saas/internal-api/requirements/api/requirements.service.js +198 -198
- package/src/saas/internal-api/requirements/consts/attributeTypes.json +8 -8
- package/src/saas/internal-api/requirements/consts/consts.js +22 -15
- package/src/saas/internal-api/requirements/index.js +22 -21
- package/src/saas/internal-api/requirements/models/create.requirement.model.js +17 -17
- package/src/saas/internal-api/requirements/models/extraction.request.model.js +16 -16
- package/src/saas/internal-api/requirements/models/policy.model.js +35 -35
- package/src/saas/internal-api/requirements/models/tab.extraction.request.model.js +14 -0
- package/src/saas/internal-api/requirements/models/update.requirement.model.js +19 -19
- package/src/saas/internal-api/requirements/utils/utils.js +129 -129
- package/src/saas/internal-api/sampleCoi/api/sample.coi.api.js +15 -15
- package/src/saas/internal-api/sampleCoi/api/sample.coi.service.js +48 -48
- package/src/saas/internal-api/sampleCoi/consts/consts.js +22 -22
- package/src/saas/internal-api/sampleCoi/index.js +4 -4
- package/src/saas/internal-api/serviceArea/api/coordinates.api.js +12 -12
- package/src/saas/internal-api/serviceArea/api/coordinates.service.js +7 -7
- package/src/saas/internal-api/serviceArea/index.js +4 -4
- package/src/saas/internal-api/serviceArea/utils/utils.js +8 -8
- package/src/saas/internal-api/tableOfContents/api/table.of.contents.api.js +37 -37
- package/src/saas/internal-api/tableOfContents/api/table.of.contents.service.js +19 -19
- package/src/saas/internal-api/tableOfContents/index.js +3 -3
- package/src/saas/internal-api/tabs/api/tabs.api.js +32 -32
- package/src/saas/internal-api/tabs/api/tabs.service.js +60 -60
- package/src/saas/internal-api/tabs/index.js +3 -3
- package/src/saas/internal-api/tabs/models/tabs.model.js +19 -19
- package/src/saas/internal-api/thread-scheduler/runner.js +69 -69
- package/src/saas/internal-api/thread-scheduler/schedulerJobs.js +8 -8
- package/src/saas/internal-api/uploadFiles/api/upload.file.api.js +49 -49
- package/src/saas/internal-api/uploadFiles/api/upload.file.service.js +162 -162
- package/src/saas/internal-api/uploadFiles/consts.js +36 -36
- package/src/saas/internal-api/uploadFiles/index.js +5 -5
- package/src/saas/internal-api/uploadFiles/utils.js +34 -34
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.api.js +38 -38
- package/src/saas/internal-api/users/api/tenantApp/tenant.app.service.js +109 -109
- package/src/saas/internal-api/users/api/users.api.js +158 -158
- package/src/saas/internal-api/users/api/users.service.js +363 -363
- package/src/saas/internal-api/users/index.js +17 -17
- package/src/saas/internal-api/users/models/create.inner.system.user.model.js +18 -18
- package/src/saas/internal-api/users/models/notification.settings.model.js +15 -14
- package/src/saas/internal-api/users/models/tenant.user.model.js +11 -11
- package/src/saas/internal-api/users/models/users.model.js +43 -43
- package/src/saas/internal-api/users/utils/util.js +50 -49
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.api.js +26 -26
- package/src/saas/internal-api/vendorProfile/api/vendor.profile.service.js +19 -19
- package/src/saas/internal-api/vendorProfile/index.js +3 -3
- package/src/saas/openapi/accounts/accounts.api.js +17 -17
- package/src/saas/openapi/accounts/accounts.service.js +11 -11
- package/src/saas/openapi/coi/coi.api.js +35 -35
- package/src/saas/openapi/coi/coi.service.js +53 -53
- package/src/saas/openapi/projects/projects.api.js +83 -83
- package/src/saas/openapi/projects/projects.service.js +71 -71
- package/src/saas/openapi/relatedDocs/related.docs.api.js +30 -30
- package/src/saas/openapi/relatedDocs/related.docs.service.js +55 -55
- package/src/saas/openapi/requests/index.js +7 -7
- package/src/saas/openapi/requests/models/invite.request.model.js +42 -42
- package/src/saas/openapi/requests/models/update.request.model.js +37 -37
- package/src/saas/openapi/requests/requests.api.js +93 -93
- package/src/saas/openapi/requests/requests.service.js +94 -94
- package/src/saas/openapi/requirements/index.js +6 -6
- package/src/saas/openapi/requirements/models/copy.requirement.model.js +10 -10
- package/src/saas/openapi/requirements/requirements.api.js +41 -41
- package/src/saas/openapi/requirements/requirements.service.js +55 -55
- package/src/saas/openapi/tabs/index.js +6 -6
- package/src/saas/openapi/tabs/models/create.tab.model.js +6 -6
- package/src/saas/openapi/tabs/tabs.api.js +27 -27
- package/src/saas/openapi/tabs/tabs.service.js +19 -19
- package/src/saas/openapi/users/user.model.js +10 -10
- package/src/saas/openapi/users/users.api.js +33 -33
- package/src/saas/openapi/users/users.service.js +51 -51
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
const auditApi = require('./audit.notes.api');
|
|
2
|
-
const { AuditNoteModel } = require('../models/audit.note.model');
|
|
3
|
-
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
|
-
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
5
|
-
|
|
6
|
-
const createAuditNote = async (auditNoteModel, context) => {
|
|
7
|
-
validateType(auditNoteModel, AuditNoteModel);
|
|
8
|
-
const response = await auditApi.createAuditNote(auditNoteModel, context);
|
|
9
|
-
|
|
10
|
-
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
11
|
-
const errorCode = response.data && response.data.errorCode;
|
|
12
|
-
throw Error(`Failed to create audit note - Response: ${response.status}${errorCode ? ` Error Code: ${errorCode}` : ''}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return response;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const getAuditNotesByProjectId = async (projectId, context) => {
|
|
19
|
-
const response = await auditApi.getAuditNotesByProjectId(projectId, context);
|
|
20
|
-
|
|
21
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
22
|
-
throw Error(`Failed to get audit notes by project id: ${projectId} - Response: ${response.status}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return response.data;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getAuditNotesByRecordId = async (recordId, context) => {
|
|
29
|
-
const response = await auditApi.getAuditNotesByRecordId(recordId, context);
|
|
30
|
-
|
|
31
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
32
|
-
throw Error(`Failed to get audit notes by record id: ${recordId} - Response: ${response.status}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return response.data;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const updateAuditNote = async (auditNoteModel, context) => {
|
|
39
|
-
validateType(auditNoteModel, AuditNoteModel);
|
|
40
|
-
const response = await auditApi.updateAuditNote(auditNoteModel, context);
|
|
41
|
-
|
|
42
|
-
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
43
|
-
throw Error(`Failed to update audit note - Response: ${response.status}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return response;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const deleteAuditNoteById = (noteId, context) => {
|
|
50
|
-
return auditApi.deleteAuditNoteById(noteId, context);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const deleteAllAuditNotesInProject = async (projectId, context) => {
|
|
54
|
-
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
55
|
-
|
|
56
|
-
for (const auditNotesType in existingAuditNotes) {
|
|
57
|
-
if (existingAuditNotes[auditNotesType] && existingAuditNotes[auditNotesType].length) {
|
|
58
|
-
await deleteAuditNotesByIds(existingAuditNotes[auditNotesType], context);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const deleteAllAccountLevelNotes = async (projectId, context) => { //does not delete all notes in account, only account level notes!
|
|
64
|
-
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
65
|
-
const accountLevelNotesArr = existingAuditNotes.Account;
|
|
66
|
-
|
|
67
|
-
if (accountLevelNotesArr.length) {
|
|
68
|
-
await deleteAuditNotesByIds(accountLevelNotesArr, context);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const deleteAllProjectLevelNotes = async (projectId, context) => { //does not delete all notes in project, only project level notes!
|
|
73
|
-
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
74
|
-
const projectLevelNotesArr = existingAuditNotes.Project;
|
|
75
|
-
|
|
76
|
-
if (projectLevelNotesArr.length) {
|
|
77
|
-
await deleteAuditNotesByIds(projectLevelNotesArr, context);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const deleteAllRequirementLevelNotes = async (projectId, context) => {
|
|
82
|
-
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
83
|
-
const requirementLevelNotesArr = existingAuditNotes.Requirement;
|
|
84
|
-
|
|
85
|
-
if (requirementLevelNotesArr.length) {
|
|
86
|
-
await deleteAuditNotesByIds(requirementLevelNotesArr, context);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
module.exports = {
|
|
91
|
-
createAuditNote,
|
|
92
|
-
getAuditNotesByProjectId,
|
|
93
|
-
getAuditNotesByRecordId,
|
|
94
|
-
updateAuditNote,
|
|
95
|
-
deleteAuditNoteById,
|
|
96
|
-
deleteAllAccountLevelNotes,
|
|
97
|
-
deleteAllProjectLevelNotes,
|
|
98
|
-
deleteAllRequirementLevelNotes,
|
|
99
|
-
deleteAllAuditNotesInProject
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
async function deleteAuditNotesByIds(notes, context) {
|
|
103
|
-
const failed = [];
|
|
104
|
-
for (const note of notes) {
|
|
105
|
-
const deleteNoteResponse = await deleteAuditNoteById(note.id, context);
|
|
106
|
-
|
|
107
|
-
if (deleteNoteResponse.status !== httpResponseStatusCodes.NO_CONTENT) { //see what EP of delete is returning when all goes well - maybe need to change !status
|
|
108
|
-
console.error('Failed to delete note: ', note.id);
|
|
109
|
-
failed.push(deleteNoteResponse);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (failed.length) {
|
|
114
|
-
throw Error(`Failed to delete ${failed.length} of ${notes.length} notes in account. Failed with status: ${ failed[0].status }`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
1
|
+
const auditApi = require('./audit.notes.api');
|
|
2
|
+
const { AuditNoteModel } = require('../models/audit.note.model');
|
|
3
|
+
const { validateType } = require('../../../../common/validations/typeValidations');
|
|
4
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
5
|
+
|
|
6
|
+
const createAuditNote = async (auditNoteModel, context) => {
|
|
7
|
+
validateType(auditNoteModel, AuditNoteModel);
|
|
8
|
+
const response = await auditApi.createAuditNote(auditNoteModel, context);
|
|
9
|
+
|
|
10
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
11
|
+
const errorCode = response.data && response.data.errorCode;
|
|
12
|
+
throw Error(`Failed to create audit note - Response: ${response.status}${errorCode ? ` Error Code: ${errorCode}` : ''}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return response;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getAuditNotesByProjectId = async (projectId, context) => {
|
|
19
|
+
const response = await auditApi.getAuditNotesByProjectId(projectId, context);
|
|
20
|
+
|
|
21
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
22
|
+
throw Error(`Failed to get audit notes by project id: ${projectId} - Response: ${response.status}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return response.data;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getAuditNotesByRecordId = async (recordId, context) => {
|
|
29
|
+
const response = await auditApi.getAuditNotesByRecordId(recordId, context);
|
|
30
|
+
|
|
31
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
32
|
+
throw Error(`Failed to get audit notes by record id: ${recordId} - Response: ${response.status}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return response.data;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const updateAuditNote = async (auditNoteModel, context) => {
|
|
39
|
+
validateType(auditNoteModel, AuditNoteModel);
|
|
40
|
+
const response = await auditApi.updateAuditNote(auditNoteModel, context);
|
|
41
|
+
|
|
42
|
+
if (response.status !== httpResponseStatusCodes.NO_CONTENT) {
|
|
43
|
+
throw Error(`Failed to update audit note - Response: ${response.status}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return response;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const deleteAuditNoteById = (noteId, context) => {
|
|
50
|
+
return auditApi.deleteAuditNoteById(noteId, context);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const deleteAllAuditNotesInProject = async (projectId, context) => {
|
|
54
|
+
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
55
|
+
|
|
56
|
+
for (const auditNotesType in existingAuditNotes) {
|
|
57
|
+
if (existingAuditNotes[auditNotesType] && existingAuditNotes[auditNotesType].length) {
|
|
58
|
+
await deleteAuditNotesByIds(existingAuditNotes[auditNotesType], context);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const deleteAllAccountLevelNotes = async (projectId, context) => { //does not delete all notes in account, only account level notes!
|
|
64
|
+
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
65
|
+
const accountLevelNotesArr = existingAuditNotes.Account;
|
|
66
|
+
|
|
67
|
+
if (accountLevelNotesArr.length) {
|
|
68
|
+
await deleteAuditNotesByIds(accountLevelNotesArr, context);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const deleteAllProjectLevelNotes = async (projectId, context) => { //does not delete all notes in project, only project level notes!
|
|
73
|
+
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
74
|
+
const projectLevelNotesArr = existingAuditNotes.Project;
|
|
75
|
+
|
|
76
|
+
if (projectLevelNotesArr.length) {
|
|
77
|
+
await deleteAuditNotesByIds(projectLevelNotesArr, context);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const deleteAllRequirementLevelNotes = async (projectId, context) => {
|
|
82
|
+
const existingAuditNotes = await getAuditNotesByProjectId(projectId, context);
|
|
83
|
+
const requirementLevelNotesArr = existingAuditNotes.Requirement;
|
|
84
|
+
|
|
85
|
+
if (requirementLevelNotesArr.length) {
|
|
86
|
+
await deleteAuditNotesByIds(requirementLevelNotesArr, context);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
module.exports = {
|
|
91
|
+
createAuditNote,
|
|
92
|
+
getAuditNotesByProjectId,
|
|
93
|
+
getAuditNotesByRecordId,
|
|
94
|
+
updateAuditNote,
|
|
95
|
+
deleteAuditNoteById,
|
|
96
|
+
deleteAllAccountLevelNotes,
|
|
97
|
+
deleteAllProjectLevelNotes,
|
|
98
|
+
deleteAllRequirementLevelNotes,
|
|
99
|
+
deleteAllAuditNotesInProject
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
async function deleteAuditNotesByIds(notes, context) {
|
|
103
|
+
const failed = [];
|
|
104
|
+
for (const note of notes) {
|
|
105
|
+
const deleteNoteResponse = await deleteAuditNoteById(note.id, context);
|
|
106
|
+
|
|
107
|
+
if (deleteNoteResponse.status !== httpResponseStatusCodes.NO_CONTENT) { //see what EP of delete is returning when all goes well - maybe need to change !status
|
|
108
|
+
console.error('Failed to delete note: ', note.id);
|
|
109
|
+
failed.push(deleteNoteResponse);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (failed.length) {
|
|
114
|
+
throw Error(`Failed to delete ${failed.length} of ${notes.length} notes in account. Failed with status: ${ failed[0].status }`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const services = require('./api/audit.notes.service');
|
|
2
|
-
const models = require('./models/audit.note.model');
|
|
3
|
-
|
|
4
|
-
module.exports = { services, models };
|
|
1
|
+
const services = require('./api/audit.notes.service');
|
|
2
|
+
const models = require('./models/audit.note.model');
|
|
3
|
+
|
|
4
|
+
module.exports = { services, models };
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
class AuditNoteModel {
|
|
2
|
-
constructor(noteEntityType, entityId, note, { id, gapQuote, requirementName, policyKey, attributeKey } = {}) {
|
|
3
|
-
validateNoteEntityType(noteEntityType);
|
|
4
|
-
|
|
5
|
-
this.noteEntityType = noteEntityType;
|
|
6
|
-
this.entityId = entityId;
|
|
7
|
-
this.note = note;
|
|
8
|
-
|
|
9
|
-
this.id = id;
|
|
10
|
-
this.gapQuote = gapQuote;
|
|
11
|
-
this.requirementName = requirementName;
|
|
12
|
-
this.policyKey = policyKey;
|
|
13
|
-
this.attributeKey = attributeKey;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const auditNoteTypes = {
|
|
18
|
-
account: 'Account',
|
|
19
|
-
project: 'Project',
|
|
20
|
-
requirement: 'Requirement'
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
AuditNoteModel,
|
|
25
|
-
auditNoteTypes
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const validateNoteEntityType = noteEntityType => {
|
|
29
|
-
if (![auditNoteTypes.account, auditNoteTypes.project, auditNoteTypes.requirement].includes(noteEntityType)) {
|
|
30
|
-
throw new Error(`Invalid noteEntityType: ${noteEntityType}`);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
1
|
+
class AuditNoteModel {
|
|
2
|
+
constructor(noteEntityType, entityId, note, { id, gapQuote, requirementName, policyKey, attributeKey } = {}) {
|
|
3
|
+
validateNoteEntityType(noteEntityType);
|
|
4
|
+
|
|
5
|
+
this.noteEntityType = noteEntityType;
|
|
6
|
+
this.entityId = entityId;
|
|
7
|
+
this.note = note;
|
|
8
|
+
|
|
9
|
+
this.id = id;
|
|
10
|
+
this.gapQuote = gapQuote;
|
|
11
|
+
this.requirementName = requirementName;
|
|
12
|
+
this.policyKey = policyKey;
|
|
13
|
+
this.attributeKey = attributeKey;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const auditNoteTypes = {
|
|
18
|
+
account: 'Account',
|
|
19
|
+
project: 'Project',
|
|
20
|
+
requirement: 'Requirement'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
AuditNoteModel,
|
|
25
|
+
auditNoteTypes
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const validateNoteEntityType = noteEntityType => {
|
|
29
|
+
if (![auditNoteTypes.account, auditNoteTypes.project, auditNoteTypes.requirement].includes(noteEntityType)) {
|
|
30
|
+
throw new Error(`Invalid noteEntityType: ${noteEntityType}`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
-
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
-
|
|
4
|
-
const Endpoints = {
|
|
5
|
-
getCommentsByRecordId: recordId => `${backendUrl}/saas/auditor/records/${recordId}/comments`,
|
|
6
|
-
getCommentHistory: commentId => `${backendUrl}/saas/integration-tests/comments/${commentId}/history`
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const getCommentsByRecordId = (recordId, context) => {
|
|
10
|
-
return requests.getRequestHandler(Endpoints.getCommentsByRecordId(recordId), {}, context);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const getCommentHistory = (commentId, context) => {
|
|
14
|
-
return requests.getRequestHandler(Endpoints.getCommentHistory(commentId), {}, context);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
getCommentsByRecordId,
|
|
19
|
-
getCommentHistory
|
|
20
|
-
};
|
|
1
|
+
const requests = require('../../../../common/requests/cookieAuth/requests');
|
|
2
|
+
const { backendUrl } = require('../../../../env').getEnv();
|
|
3
|
+
|
|
4
|
+
const Endpoints = {
|
|
5
|
+
getCommentsByRecordId: recordId => `${backendUrl}/saas/auditor/records/${recordId}/comments`,
|
|
6
|
+
getCommentHistory: commentId => `${backendUrl}/saas/integration-tests/comments/${commentId}/history`
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const getCommentsByRecordId = (recordId, context) => {
|
|
10
|
+
return requests.getRequestHandler(Endpoints.getCommentsByRecordId(recordId), {}, context);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const getCommentHistory = (commentId, context) => {
|
|
14
|
+
return requests.getRequestHandler(Endpoints.getCommentHistory(commentId), {}, context);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
getCommentsByRecordId,
|
|
19
|
+
getCommentHistory
|
|
20
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const auditorCommentsApi = require('./auditor.comments.api');
|
|
2
|
-
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
3
|
-
|
|
4
|
-
const getCommentsByRecordId = async (recordId, context) => {
|
|
5
|
-
const response = await auditorCommentsApi.getCommentsByRecordId(recordId, context);
|
|
6
|
-
|
|
7
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
8
|
-
throw Error(`Failed to get audit comments by record id: ${recordId} - Response: ${response.status}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return response.data;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const getCommentHistory = async (commentId, context) => {
|
|
15
|
-
const response = await auditorCommentsApi.getCommentHistory(commentId, context);
|
|
16
|
-
|
|
17
|
-
if (response.status !== httpResponseStatusCodes.OK) {
|
|
18
|
-
throw Error(`Failed to get comment history for comment id: ${commentId}`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return response.data;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
getCommentsByRecordId,
|
|
26
|
-
getCommentHistory
|
|
27
|
-
};
|
|
1
|
+
const auditorCommentsApi = require('./auditor.comments.api');
|
|
2
|
+
const httpResponseStatusCodes = require('../../../../common/httpResponseStatusCodes.json');
|
|
3
|
+
|
|
4
|
+
const getCommentsByRecordId = async (recordId, context) => {
|
|
5
|
+
const response = await auditorCommentsApi.getCommentsByRecordId(recordId, context);
|
|
6
|
+
|
|
7
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
8
|
+
throw Error(`Failed to get audit comments by record id: ${recordId} - Response: ${response.status}`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getCommentHistory = async (commentId, context) => {
|
|
15
|
+
const response = await auditorCommentsApi.getCommentHistory(commentId, context);
|
|
16
|
+
|
|
17
|
+
if (response.status !== httpResponseStatusCodes.OK) {
|
|
18
|
+
throw Error(`Failed to get comment history for comment id: ${commentId}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return response.data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
getCommentsByRecordId,
|
|
26
|
+
getCommentHistory
|
|
27
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const CommentAction = {
|
|
2
|
-
CREATE: 'CREATE',
|
|
3
|
-
MUTE: 'MUTE',
|
|
4
|
-
UNMUTE: 'UNMUTE',
|
|
5
|
-
DELETE: 'DELETE'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const CommentActionReason = {
|
|
9
|
-
MANUAL_MUTE: 'MANUAL_MUTE',
|
|
10
|
-
MANUAL_UNMUTE: 'MANUAL_UNMUTE',
|
|
11
|
-
RESOLUTION_CHANGED: 'RESOLUTION_CHANGED',
|
|
12
|
-
EXPIRATION_CHANGED: 'EXPIRATION_CHANGED',
|
|
13
|
-
AUTO_REMOVE_MUTED_COMMENT: 'AUTO_REMOVE_MUTED_COMMENT'
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = { CommentAction, CommentActionReason };
|
|
1
|
+
const CommentAction = {
|
|
2
|
+
CREATE: 'CREATE',
|
|
3
|
+
MUTE: 'MUTE',
|
|
4
|
+
UNMUTE: 'UNMUTE',
|
|
5
|
+
DELETE: 'DELETE'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const CommentActionReason = {
|
|
9
|
+
MANUAL_MUTE: 'MANUAL_MUTE',
|
|
10
|
+
MANUAL_UNMUTE: 'MANUAL_UNMUTE',
|
|
11
|
+
RESOLUTION_CHANGED: 'RESOLUTION_CHANGED',
|
|
12
|
+
EXPIRATION_CHANGED: 'EXPIRATION_CHANGED',
|
|
13
|
+
AUTO_REMOVE_MUTED_COMMENT: 'AUTO_REMOVE_MUTED_COMMENT'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = { CommentAction, CommentActionReason };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const services = require('./api/auditor.comments.service');
|
|
2
|
-
const models = require('./models/auditor.comment.model');
|
|
3
|
-
const consts = require('./consts/auditor.comment');
|
|
4
|
-
|
|
5
|
-
module.exports = { services, models, consts };
|
|
1
|
+
const services = require('./api/auditor.comments.service');
|
|
2
|
+
const models = require('./models/auditor.comment.model');
|
|
3
|
+
const consts = require('./consts/auditor.comment');
|
|
4
|
+
|
|
5
|
+
module.exports = { services, models, consts };
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
const { CommentAction, CommentActionReason } = require('../consts/auditor.comment');
|
|
2
|
-
|
|
3
|
-
class CreateCommentModel {
|
|
4
|
-
constructor(policy, attribute, resolution, content, isMuted = false) {
|
|
5
|
-
this.policy = policy;
|
|
6
|
-
this.attribute = attribute;
|
|
7
|
-
this.resolution = resolution;
|
|
8
|
-
this.content = content;
|
|
9
|
-
this.isMuted = isMuted;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class ModifyCommentModel {
|
|
14
|
-
constructor(id, action, actionReason, isMuted = false) {
|
|
15
|
-
validateCommentAction(action);
|
|
16
|
-
validateCommentActionReason(actionReason);
|
|
17
|
-
|
|
18
|
-
this.id = id;
|
|
19
|
-
this.action = action;
|
|
20
|
-
this.actionReason = actionReason;
|
|
21
|
-
this.isMuted = isMuted;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
CreateCommentModel,
|
|
27
|
-
ModifyCommentModel
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const validateCommentAction = action => {
|
|
31
|
-
if (!Object.values(CommentAction).includes(action)) {
|
|
32
|
-
throw new Error(`Invalid comment action: ${action}`);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const validateCommentActionReason = actionReason => {
|
|
37
|
-
if (!Object.values(CommentActionReason).includes(actionReason)) {
|
|
38
|
-
throw new Error(`Invalid comment action reason: ${actionReason}`);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
1
|
+
const { CommentAction, CommentActionReason } = require('../consts/auditor.comment');
|
|
2
|
+
|
|
3
|
+
class CreateCommentModel {
|
|
4
|
+
constructor(policy, attribute, resolution, content, isMuted = false) {
|
|
5
|
+
this.policy = policy;
|
|
6
|
+
this.attribute = attribute;
|
|
7
|
+
this.resolution = resolution;
|
|
8
|
+
this.content = content;
|
|
9
|
+
this.isMuted = isMuted;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class ModifyCommentModel {
|
|
14
|
+
constructor(id, action, actionReason, isMuted = false) {
|
|
15
|
+
validateCommentAction(action);
|
|
16
|
+
validateCommentActionReason(actionReason);
|
|
17
|
+
|
|
18
|
+
this.id = id;
|
|
19
|
+
this.action = action;
|
|
20
|
+
this.actionReason = actionReason;
|
|
21
|
+
this.isMuted = isMuted;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
CreateCommentModel,
|
|
27
|
+
ModifyCommentModel
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const validateCommentAction = action => {
|
|
31
|
+
if (!Object.values(CommentAction).includes(action)) {
|
|
32
|
+
throw new Error(`Invalid comment action: ${action}`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const validateCommentActionReason = actionReason => {
|
|
37
|
+
if (!Object.values(CommentActionReason).includes(actionReason)) {
|
|
38
|
+
throw new Error(`Invalid comment action reason: ${actionReason}`);
|
|
39
|
+
}
|
|
40
|
+
};
|