@webiny/api-audit-logs 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.eb81deee7e
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/AuditLogsFeature.d.ts +8 -0
- package/AuditLogsFeature.js +32 -0
- package/AuditLogsFeature.js.map +1 -0
- package/abstractions.d.ts +14 -4
- package/abstractions.js +3 -3
- package/abstractions.js.map +1 -1
- package/config.js +2 -1
- package/config.js.map +1 -1
- package/domain/errors.d.ts +5 -0
- package/domain/errors.js +11 -0
- package/domain/errors.js.map +1 -0
- package/events/AuditLogAfterCreateEvent.js +8 -5
- package/events/AuditLogAfterCreateEvent.js.map +1 -1
- package/events/AuditLogAfterUpdateEvent.js +8 -5
- package/events/AuditLogAfterUpdateEvent.js.map +1 -1
- package/events/AuditLogBeforeCreateEvent.js +8 -5
- package/events/AuditLogBeforeCreateEvent.js.map +1 -1
- package/events/AuditLogBeforeUpdateEvent.js +8 -5
- package/events/AuditLogBeforeUpdateEvent.js.map +1 -1
- package/events/abstractions.d.ts +0 -5
- package/events/abstractions.js +5 -24
- package/events/abstractions.js.map +1 -1
- package/events/index.js +0 -2
- package/features/AuditLogPermissions/AuditLogPermissions.d.ts +15 -0
- package/features/AuditLogPermissions/AuditLogPermissions.js +24 -0
- package/features/AuditLogPermissions/AuditLogPermissions.js.map +1 -0
- package/features/AuditLogPermissions/abstractions.d.ts +11 -0
- package/features/AuditLogPermissions/abstractions.js +5 -0
- package/features/AuditLogPermissions/abstractions.js.map +1 -0
- package/features/AuditLogPermissions/feature.d.ts +4 -0
- package/features/AuditLogPermissions/feature.js +11 -0
- package/features/AuditLogPermissions/feature.js.map +1 -0
- package/features/CreateAuditLog/CreateAuditLogGateway.d.ts +12 -0
- package/features/CreateAuditLog/CreateAuditLogGateway.js +23 -0
- package/features/CreateAuditLog/CreateAuditLogGateway.js.map +1 -0
- package/features/CreateAuditLog/CreateAuditLogRepository.d.ts +14 -0
- package/features/CreateAuditLog/CreateAuditLogRepository.js +25 -0
- package/features/CreateAuditLog/CreateAuditLogRepository.js.map +1 -0
- package/features/CreateAuditLog/CreateAuditLogUseCase.d.ts +24 -0
- package/features/CreateAuditLog/CreateAuditLogUseCase.js +70 -0
- package/features/CreateAuditLog/CreateAuditLogUseCase.js.map +1 -0
- package/features/CreateAuditLog/abstractions.d.ts +42 -0
- package/features/CreateAuditLog/abstractions.js +7 -0
- package/features/CreateAuditLog/abstractions.js.map +1 -0
- package/features/CreateAuditLog/feature.d.ts +4 -0
- package/features/CreateAuditLog/feature.js +15 -0
- package/features/CreateAuditLog/feature.js.map +1 -0
- package/features/GetAuditLog/GetAuditLogGateway.d.ts +13 -0
- package/features/GetAuditLog/GetAuditLogGateway.js +21 -0
- package/features/GetAuditLog/GetAuditLogGateway.js.map +1 -0
- package/features/GetAuditLog/GetAuditLogRepository.d.ts +16 -0
- package/features/GetAuditLog/GetAuditLogRepository.js +32 -0
- package/features/GetAuditLog/GetAuditLogRepository.js.map +1 -0
- package/features/GetAuditLog/GetAuditLogUseCase.d.ts +15 -0
- package/features/GetAuditLog/GetAuditLogUseCase.js +29 -0
- package/features/GetAuditLog/GetAuditLogUseCase.js.map +1 -0
- package/features/GetAuditLog/abstractions.d.ts +42 -0
- package/features/GetAuditLog/abstractions.js +7 -0
- package/features/GetAuditLog/abstractions.js.map +1 -0
- package/features/GetAuditLog/feature.d.ts +4 -0
- package/features/GetAuditLog/feature.js +15 -0
- package/features/GetAuditLog/feature.js.map +1 -0
- package/features/ListAuditLogs/ListAuditLogsGateway.d.ts +12 -0
- package/features/ListAuditLogs/ListAuditLogsGateway.js +24 -0
- package/features/ListAuditLogs/ListAuditLogsGateway.js.map +1 -0
- package/features/ListAuditLogs/ListAuditLogsRepository.d.ts +17 -0
- package/features/ListAuditLogs/ListAuditLogsRepository.js +38 -0
- package/features/ListAuditLogs/ListAuditLogsRepository.js.map +1 -0
- package/features/ListAuditLogs/ListAuditLogsUseCase.d.ts +15 -0
- package/features/ListAuditLogs/ListAuditLogsUseCase.js +27 -0
- package/features/ListAuditLogs/ListAuditLogsUseCase.js.map +1 -0
- package/features/ListAuditLogs/abstractions.d.ts +55 -0
- package/features/ListAuditLogs/abstractions.js +7 -0
- package/features/ListAuditLogs/abstractions.js.map +1 -0
- package/features/ListAuditLogs/feature.d.ts +4 -0
- package/features/ListAuditLogs/feature.js +15 -0
- package/features/ListAuditLogs/feature.js.map +1 -0
- package/features/RecordAuditLog/RecordAuditLogUseCase.d.ts +30 -0
- package/features/RecordAuditLog/RecordAuditLogUseCase.js +108 -0
- package/features/RecordAuditLog/RecordAuditLogUseCase.js.map +1 -0
- package/features/RecordAuditLog/abstractions.d.ts +26 -0
- package/features/RecordAuditLog/abstractions.js +5 -0
- package/features/RecordAuditLog/abstractions.js.map +1 -0
- package/features/RecordAuditLog/feature.d.ts +4 -0
- package/features/RecordAuditLog/feature.js +11 -0
- package/features/RecordAuditLog/feature.js.map +1 -0
- package/features/UpdateAuditLog/UpdateAuditLogGateway.d.ts +12 -0
- package/features/UpdateAuditLog/UpdateAuditLogGateway.js +23 -0
- package/features/UpdateAuditLog/UpdateAuditLogGateway.js.map +1 -0
- package/features/UpdateAuditLog/UpdateAuditLogRepository.d.ts +14 -0
- package/features/UpdateAuditLog/UpdateAuditLogRepository.js +25 -0
- package/features/UpdateAuditLog/UpdateAuditLogRepository.js.map +1 -0
- package/features/UpdateAuditLog/UpdateAuditLogUseCase.d.ts +18 -0
- package/features/UpdateAuditLog/UpdateAuditLogUseCase.js +53 -0
- package/features/UpdateAuditLog/UpdateAuditLogUseCase.js.map +1 -0
- package/features/UpdateAuditLog/abstractions.d.ts +42 -0
- package/features/UpdateAuditLog/abstractions.js +7 -0
- package/features/UpdateAuditLog/abstractions.js.map +1 -0
- package/features/UpdateAuditLog/feature.d.ts +4 -0
- package/features/UpdateAuditLog/feature.js +15 -0
- package/features/UpdateAuditLog/feature.js.map +1 -0
- package/graphql/AuditLogsGraphQLSchema.d.ts +10 -0
- package/graphql/AuditLogsGraphQLSchema.js +139 -0
- package/graphql/AuditLogsGraphQLSchema.js.map +1 -0
- package/graphql/validation.js +26 -30
- package/graphql/validation.js.map +1 -1
- package/index.d.ts +2 -8
- package/index.js +1 -22
- package/package.json +28 -28
- package/storage/abstractions/Storage.js +0 -3
- package/storage/types.d.ts +0 -35
- package/storage/types.js +0 -3
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.d.ts +3 -3
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js +37 -27
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js.map +1 -1
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js +45 -30
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js.map +1 -1
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js +43 -34
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js.map +1 -1
- package/subscriptions/aco/index.d.ts +2 -2
- package/subscriptions/aco/index.js +5 -4
- package/subscriptions/aco/index.js.map +1 -1
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.d.ts +11 -0
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js +45 -0
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js.map +1 -0
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.d.ts +11 -0
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js +42 -0
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js.map +1 -0
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.d.ts +11 -0
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js +44 -0
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js.map +1 -0
- package/subscriptions/ai/index.d.ts +2 -0
- package/subscriptions/ai/index.js +11 -0
- package/subscriptions/ai/index.js.map +1 -0
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js +27 -22
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js +27 -22
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js +30 -26
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js +30 -26
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js.map +1 -1
- package/subscriptions/fileManager/index.d.ts +2 -2
- package/subscriptions/fileManager/index.js +6 -8
- package/subscriptions/fileManager/index.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js +37 -31
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js +30 -29
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js +30 -26
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js +30 -26
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/index.d.ts +2 -2
- package/subscriptions/headlessCms/index.js +16 -20
- package/subscriptions/headlessCms/index.js.map +1 -1
- package/subscriptions/index.d.ts +2 -2
- package/subscriptions/index.js +10 -7
- package/subscriptions/index.js.map +1 -1
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.d.ts +3 -3
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js +29 -24
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js.map +1 -1
- package/subscriptions/mailer/index.d.ts +2 -2
- package/subscriptions/mailer/index.js +3 -3
- package/subscriptions/mailer/index.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js +37 -39
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js +37 -39
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js +41 -44
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js +27 -22
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js +27 -22
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js +30 -26
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js +27 -22
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js +27 -22
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js +30 -26
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js +27 -22
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js +27 -22
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js +30 -26
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/cleanupApiKey.js +10 -16
- package/subscriptions/security/handlers/cleanupApiKey.js.map +1 -1
- package/subscriptions/security/index.d.ts +2 -2
- package/subscriptions/security/index.js +14 -20
- package/subscriptions/security/index.js.map +1 -1
- package/subscriptions/websiteBuilder/index.d.ts +2 -2
- package/subscriptions/websiteBuilder/index.js +14 -16
- package/subscriptions/websiteBuilder/index.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js +26 -21
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js +26 -21
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js +26 -21
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js +29 -25
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js +26 -21
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js +26 -21
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js +26 -21
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js +29 -25
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js +26 -21
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js +26 -21
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js +26 -21
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js +29 -25
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js.map +1 -1
- package/types.d.ts +0 -23
- package/types.js +0 -3
- package/utils/expiresAt.js +14 -19
- package/utils/expiresAt.js.map +1 -1
- package/utils/getAuditObject.js +14 -15
- package/utils/getAuditObject.js.map +1 -1
- package/context/AuditLogsContextValue.d.ts +0 -10
- package/context/AuditLogsContextValue.js +0 -139
- package/context/AuditLogsContextValue.js.map +0 -1
- package/context/index.d.ts +0 -9
- package/context/index.js +0 -37
- package/context/index.js.map +0 -1
- package/events/index.js.map +0 -1
- package/graphql/schema.d.ts +0 -3
- package/graphql/schema.js +0 -126
- package/graphql/schema.js.map +0 -1
- package/index.js.map +0 -1
- package/storage/AccessPatternHandler.d.ts +0 -14
- package/storage/AccessPatternHandler.js +0 -60
- package/storage/AccessPatternHandler.js.map +0 -1
- package/storage/Converter.d.ts +0 -16
- package/storage/Converter.js +0 -52
- package/storage/Converter.js.map +0 -1
- package/storage/Storage.d.ts +0 -18
- package/storage/Storage.js +0 -89
- package/storage/Storage.js.map +0 -1
- package/storage/abstractions/AccessPattern.d.ts +0 -24
- package/storage/abstractions/AccessPattern.js +0 -3
- package/storage/abstractions/AccessPattern.js.map +0 -1
- package/storage/abstractions/AccessPatternHandler.d.ts +0 -13
- package/storage/abstractions/AccessPatternHandler.js +0 -3
- package/storage/abstractions/AccessPatternHandler.js.map +0 -1
- package/storage/abstractions/Converter.d.ts +0 -6
- package/storage/abstractions/Converter.js +0 -3
- package/storage/abstractions/Converter.js.map +0 -1
- package/storage/abstractions/Storage.js.map +0 -1
- package/storage/accessPatterns/AppAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppAccessPattern.js +0 -29
- package/storage/accessPatterns/AppAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppCreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppCreatedByAccessPattern.js +0 -32
- package/storage/accessPatterns/AppCreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityAccessPattern.js +0 -29
- package/storage/accessPatterns/AppEntityAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityActionAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityActionAccessPattern.js +0 -29
- package/storage/accessPatterns/AppEntityActionAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js +0 -32
- package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityCreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityCreatedByAccessPattern.js +0 -32
- package/storage/accessPatterns/AppEntityCreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/BaseAccessPattern.d.ts +0 -32
- package/storage/accessPatterns/BaseAccessPattern.js +0 -83
- package/storage/accessPatterns/BaseAccessPattern.js.map +0 -1
- package/storage/accessPatterns/CreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/CreatedByAccessPattern.js +0 -32
- package/storage/accessPatterns/CreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/CreatedOnAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/CreatedOnAccessPattern.js +0 -30
- package/storage/accessPatterns/CreatedOnAccessPattern.js.map +0 -1
- package/storage/accessPatterns/DefaultAccessPattern.d.ts +0 -15
- package/storage/accessPatterns/DefaultAccessPattern.js +0 -36
- package/storage/accessPatterns/DefaultAccessPattern.js.map +0 -1
- package/storage/accessPatterns/EntityIdAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/EntityIdAccessPattern.js +0 -33
- package/storage/accessPatterns/EntityIdAccessPattern.js.map +0 -1
- package/storage/accessPatterns/index.d.ts +0 -6
- package/storage/accessPatterns/index.js +0 -47
- package/storage/accessPatterns/index.js.map +0 -1
- package/storage/cursorSchema.d.ts +0 -4
- package/storage/cursorSchema.js +0 -25
- package/storage/cursorSchema.js.map +0 -1
- package/storage/entity.d.ts +0 -36
- package/storage/entity.js +0 -127
- package/storage/entity.js.map +0 -1
- package/storage/results/ListErrorResult.d.ts +0 -10
- package/storage/results/ListErrorResult.js +0 -11
- package/storage/results/ListErrorResult.js.map +0 -1
- package/storage/results/ListSuccessResult.d.ts +0 -14
- package/storage/results/ListSuccessResult.js +0 -16
- package/storage/results/ListSuccessResult.js.map +0 -1
- package/storage/results/index.d.ts +0 -2
- package/storage/results/index.js +0 -4
- package/storage/results/index.js.map +0 -1
- package/storage/startKey.d.ts +0 -6
- package/storage/startKey.js +0 -9
- package/storage/startKey.js.map +0 -1
- package/storage/types.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/getAuditConfig.d.ts +0 -4
- package/utils/getAuditConfig.js +0 -105
- package/utils/getAuditConfig.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
|
|
3
|
+
import type { IListAuditLogsParams } from "../../types.js";
|
|
4
|
+
import type { IListAuditLogsResultMeta } from "../../types.js";
|
|
5
|
+
import type { IAuditLog } from "../../storage/types.js";
|
|
6
|
+
import type { IStorageListParams } from "../../storage/abstractions/Storage.js";
|
|
7
|
+
import type { IStorageListSuccessResultMeta } from "../../storage/abstractions/Storage.js";
|
|
8
|
+
import type { AuditLogPersistenceError } from "../../domain/errors.js";
|
|
9
|
+
export interface ListAuditLogsOutput {
|
|
10
|
+
items: IAuditLog[];
|
|
11
|
+
meta: IListAuditLogsResultMeta;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* ListAuditLogs Use Case - Lists audit logs of the current tenant. Needs access to all audit logs.
|
|
15
|
+
*/
|
|
16
|
+
export interface IListAuditLogsUseCase {
|
|
17
|
+
execute(params: IListAuditLogsParams): Promise<Result<ListAuditLogsOutput, UseCaseError>>;
|
|
18
|
+
}
|
|
19
|
+
export interface IListAuditLogsUseCaseErrors {
|
|
20
|
+
notAuthorized: NotAuthorizedError;
|
|
21
|
+
persistence: AuditLogPersistenceError;
|
|
22
|
+
}
|
|
23
|
+
type UseCaseError = IListAuditLogsUseCaseErrors[keyof IListAuditLogsUseCaseErrors];
|
|
24
|
+
export declare const ListAuditLogsUseCase: import("@webiny/di").Abstraction<IListAuditLogsUseCase>;
|
|
25
|
+
export declare namespace ListAuditLogsUseCase {
|
|
26
|
+
type Interface = IListAuditLogsUseCase;
|
|
27
|
+
type Output = ListAuditLogsOutput;
|
|
28
|
+
type Error = UseCaseError;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* ListAuditLogsRepository - Lists audit logs of the current tenant.
|
|
32
|
+
*/
|
|
33
|
+
export interface IListAuditLogsRepository {
|
|
34
|
+
list(params: IListAuditLogsParams): Promise<Result<ListAuditLogsOutput, AuditLogPersistenceError>>;
|
|
35
|
+
}
|
|
36
|
+
export declare const ListAuditLogsRepository: import("@webiny/di").Abstraction<IListAuditLogsRepository>;
|
|
37
|
+
export declare namespace ListAuditLogsRepository {
|
|
38
|
+
type Interface = IListAuditLogsRepository;
|
|
39
|
+
}
|
|
40
|
+
export interface ListAuditLogsGatewayOutput {
|
|
41
|
+
items: IAuditLog[];
|
|
42
|
+
meta: IStorageListSuccessResultMeta;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* ListAuditLogsGateway - Lists audit logs from the audit logs storage.
|
|
46
|
+
*/
|
|
47
|
+
export interface IListAuditLogsGateway {
|
|
48
|
+
list(params: IStorageListParams): Promise<ListAuditLogsGatewayOutput>;
|
|
49
|
+
}
|
|
50
|
+
export declare const ListAuditLogsGateway: import("@webiny/di").Abstraction<IListAuditLogsGateway>;
|
|
51
|
+
export declare namespace ListAuditLogsGateway {
|
|
52
|
+
type Interface = IListAuditLogsGateway;
|
|
53
|
+
type Output = ListAuditLogsGatewayOutput;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const ListAuditLogsUseCase = createAbstraction("ListAuditLogsUseCase");
|
|
3
|
+
const ListAuditLogsRepository = createAbstraction("ListAuditLogsRepository");
|
|
4
|
+
const ListAuditLogsGateway = createAbstraction("ListAuditLogsGateway");
|
|
5
|
+
export { ListAuditLogsGateway, ListAuditLogsRepository, ListAuditLogsUseCase };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ListAuditLogs/abstractions.js","sources":["../../../src/features/ListAuditLogs/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport type { IListAuditLogsParams } from \"~/types.js\";\nimport type { IListAuditLogsResultMeta } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListParams } from \"~/storage/abstractions/Storage.js\";\nimport type { IStorageListSuccessResultMeta } from \"~/storage/abstractions/Storage.js\";\nimport type { AuditLogPersistenceError } from \"~/domain/errors.js\";\n\nexport interface ListAuditLogsOutput {\n items: IAuditLog[];\n meta: IListAuditLogsResultMeta;\n}\n\n/**\n * ListAuditLogs Use Case - Lists audit logs of the current tenant. Needs access to all audit logs.\n */\nexport interface IListAuditLogsUseCase {\n execute(params: IListAuditLogsParams): Promise<Result<ListAuditLogsOutput, UseCaseError>>;\n}\n\nexport interface IListAuditLogsUseCaseErrors {\n notAuthorized: NotAuthorizedError;\n persistence: AuditLogPersistenceError;\n}\n\ntype UseCaseError = IListAuditLogsUseCaseErrors[keyof IListAuditLogsUseCaseErrors];\n\nexport const ListAuditLogsUseCase =\n createAbstraction<IListAuditLogsUseCase>(\"ListAuditLogsUseCase\");\n\nexport namespace ListAuditLogsUseCase {\n export type Interface = IListAuditLogsUseCase;\n export type Output = ListAuditLogsOutput;\n export type Error = UseCaseError;\n}\n\n/**\n * ListAuditLogsRepository - Lists audit logs of the current tenant.\n */\nexport interface IListAuditLogsRepository {\n list(\n params: IListAuditLogsParams\n ): Promise<Result<ListAuditLogsOutput, AuditLogPersistenceError>>;\n}\n\nexport const ListAuditLogsRepository =\n createAbstraction<IListAuditLogsRepository>(\"ListAuditLogsRepository\");\n\nexport namespace ListAuditLogsRepository {\n export type Interface = IListAuditLogsRepository;\n}\n\nexport interface ListAuditLogsGatewayOutput {\n items: IAuditLog[];\n meta: IStorageListSuccessResultMeta;\n}\n\n/**\n * ListAuditLogsGateway - Lists audit logs from the audit logs storage.\n */\nexport interface IListAuditLogsGateway {\n list(params: IStorageListParams): Promise<ListAuditLogsGatewayOutput>;\n}\n\nexport const ListAuditLogsGateway =\n createAbstraction<IListAuditLogsGateway>(\"ListAuditLogsGateway\");\n\nexport namespace ListAuditLogsGateway {\n export type Interface = IListAuditLogsGateway;\n export type Output = ListAuditLogsGatewayOutput;\n}\n"],"names":["ListAuditLogsUseCase","createAbstraction","ListAuditLogsRepository","ListAuditLogsGateway"],"mappings":";AA6BO,MAAMA,uBACTC,kBAAyC;AAiBtC,MAAMC,0BACTD,kBAA4C;AAkBzC,MAAME,uBACTF,kBAAyC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListAuditLogsUseCase } from "./ListAuditLogsUseCase.js";
|
|
3
|
+
import { ListAuditLogsRepository } from "./ListAuditLogsRepository.js";
|
|
4
|
+
import { ListAuditLogsGateway } from "./ListAuditLogsGateway.js";
|
|
5
|
+
const ListAuditLogsFeature = createFeature({
|
|
6
|
+
name: "AuditLogs/ListAuditLogs",
|
|
7
|
+
register (container) {
|
|
8
|
+
container.register(ListAuditLogsUseCase);
|
|
9
|
+
container.register(ListAuditLogsRepository).inSingletonScope();
|
|
10
|
+
container.register(ListAuditLogsGateway).inSingletonScope();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { ListAuditLogsFeature };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ListAuditLogs/feature.js","sources":["../../../src/features/ListAuditLogs/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListAuditLogsUseCase } from \"./ListAuditLogsUseCase.js\";\nimport { ListAuditLogsRepository } from \"./ListAuditLogsRepository.js\";\nimport { ListAuditLogsGateway } from \"./ListAuditLogsGateway.js\";\n\nexport const ListAuditLogsFeature = createFeature({\n name: \"AuditLogs/ListAuditLogs\",\n register(container) {\n container.register(ListAuditLogsUseCase);\n container.register(ListAuditLogsRepository).inSingletonScope();\n container.register(ListAuditLogsGateway).inSingletonScope();\n }\n});\n"],"names":["ListAuditLogsFeature","createFeature","container","ListAuditLogsUseCase","ListAuditLogsRepository","ListAuditLogsGateway"],"mappings":";;;;AAKO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,yBAAyB,gBAAgB;QAC5DF,UAAU,QAAQ,CAACG,sBAAsB,gBAAgB;IAC7D;AACJ"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
3
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
4
|
+
import { CreateAuditLogUseCase } from "../../features/CreateAuditLog/abstractions.js";
|
|
5
|
+
import { ListAuditLogsUseCase } from "../../features/ListAuditLogs/abstractions.js";
|
|
6
|
+
import { UpdateAuditLogUseCase } from "../../features/UpdateAuditLog/abstractions.js";
|
|
7
|
+
import type { IAuditLog } from "../../storage/types.js";
|
|
8
|
+
import { RecordAuditLogUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
9
|
+
/**
|
|
10
|
+
* Records audit logs for things the current identity did. Writes happen without authorization,
|
|
11
|
+
* because the identity doing the audited action doesn't need audit log permissions.
|
|
12
|
+
*
|
|
13
|
+
* An action with a `newEntryDelay` merges into the entity's latest audit log when that log is
|
|
14
|
+
* newer than the delay, instead of creating a new one. A failure on that path is logged and
|
|
15
|
+
* nothing is recorded.
|
|
16
|
+
*/
|
|
17
|
+
declare class RecordAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
18
|
+
private readonly createAuditLog;
|
|
19
|
+
private readonly listAuditLogs;
|
|
20
|
+
private readonly updateAuditLog;
|
|
21
|
+
private readonly identityContext;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
constructor(createAuditLog: CreateAuditLogUseCase.Interface, listAuditLogs: ListAuditLogsUseCase.Interface, updateAuditLog: UpdateAuditLogUseCase.Interface, identityContext: IdentityContext.Interface, logger: Logger.Interface);
|
|
24
|
+
execute(input: UseCaseAbstraction.Input): Promise<Result<IAuditLog | null, UseCaseAbstraction.Error>>;
|
|
25
|
+
private createOrMergeAuditLog;
|
|
26
|
+
}
|
|
27
|
+
export declare const RecordAuditLogUseCase: typeof RecordAuditLogUseCaseImpl & {
|
|
28
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRecordAuditLogUseCase>;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
3
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
4
|
+
import { CreateAuditLogUseCase } from "../CreateAuditLog/abstractions.js";
|
|
5
|
+
import { ListAuditLogsUseCase } from "../ListAuditLogs/abstractions.js";
|
|
6
|
+
import { UpdateAuditLogUseCase } from "../UpdateAuditLog/abstractions.js";
|
|
7
|
+
import { RecordAuditLogUseCase } from "./abstractions.js";
|
|
8
|
+
const createAuditLogDelayDate = (delay)=>{
|
|
9
|
+
const date = new Date();
|
|
10
|
+
date.setTime(date.getTime() - 1000 * delay);
|
|
11
|
+
return date;
|
|
12
|
+
};
|
|
13
|
+
class RecordAuditLogUseCaseImpl {
|
|
14
|
+
constructor(createAuditLog, listAuditLogs, updateAuditLog, identityContext, logger){
|
|
15
|
+
this.createAuditLog = createAuditLog;
|
|
16
|
+
this.listAuditLogs = listAuditLogs;
|
|
17
|
+
this.updateAuditLog = updateAuditLog;
|
|
18
|
+
this.identityContext = identityContext;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
}
|
|
21
|
+
async execute(input) {
|
|
22
|
+
const { audit, message, content, entityId } = input;
|
|
23
|
+
if (!this.identityContext.getIdentity()?.id) {
|
|
24
|
+
this.logger.debug("No identity, skipping audit log creation.");
|
|
25
|
+
return Result.ok(null);
|
|
26
|
+
}
|
|
27
|
+
const payload = {
|
|
28
|
+
message,
|
|
29
|
+
app: audit.app.app,
|
|
30
|
+
entityId,
|
|
31
|
+
entity: audit.entity.type,
|
|
32
|
+
action: audit.action.type,
|
|
33
|
+
content,
|
|
34
|
+
tags: []
|
|
35
|
+
};
|
|
36
|
+
const delay = audit.action.newEntryDelay || 0;
|
|
37
|
+
return await this.identityContext.withoutAuthorization(async ()=>{
|
|
38
|
+
if (delay > 0) try {
|
|
39
|
+
return await this.createOrMergeAuditLog(payload, delay);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
this.logger.warn({
|
|
42
|
+
error
|
|
43
|
+
}, "Could not create or merge an audit log.");
|
|
44
|
+
return Result.ok(null);
|
|
45
|
+
}
|
|
46
|
+
return await this.createAuditLog.execute(payload);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async createOrMergeAuditLog(payload, delay) {
|
|
50
|
+
const createdOnGte = createAuditLogDelayDate(delay);
|
|
51
|
+
const listResult = await this.listAuditLogs.execute({
|
|
52
|
+
app: payload.app,
|
|
53
|
+
entityId: payload.entityId,
|
|
54
|
+
limit: 1,
|
|
55
|
+
createdOn_gte: createdOnGte,
|
|
56
|
+
sort: "DESC"
|
|
57
|
+
});
|
|
58
|
+
if (listResult.isFail()) {
|
|
59
|
+
this.logger.warn({
|
|
60
|
+
error: listResult.error
|
|
61
|
+
}, "Could not list audit logs to merge into.");
|
|
62
|
+
return Result.ok(null);
|
|
63
|
+
}
|
|
64
|
+
const original = listResult.value.items[0];
|
|
65
|
+
if (!original) {
|
|
66
|
+
const createResult = await this.createAuditLog.execute(payload);
|
|
67
|
+
if (createResult.isFail()) {
|
|
68
|
+
this.logger.warn({
|
|
69
|
+
error: createResult.error
|
|
70
|
+
}, "Could not create an audit log.");
|
|
71
|
+
return Result.ok(null);
|
|
72
|
+
}
|
|
73
|
+
return Result.ok(createResult.value);
|
|
74
|
+
}
|
|
75
|
+
let content = payload.content;
|
|
76
|
+
if (original.content) {
|
|
77
|
+
const beforePayloadData = JSON.parse(original.content)?.before;
|
|
78
|
+
if (beforePayloadData) content = {
|
|
79
|
+
before: beforePayloadData,
|
|
80
|
+
after: payload.content?.after
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const updateResult = await this.updateAuditLog.execute(original, {
|
|
84
|
+
message: payload.message,
|
|
85
|
+
content
|
|
86
|
+
});
|
|
87
|
+
if (updateResult.isFail()) {
|
|
88
|
+
this.logger.warn({
|
|
89
|
+
error: updateResult.error
|
|
90
|
+
}, "Could not merge an audit log.");
|
|
91
|
+
return Result.ok(null);
|
|
92
|
+
}
|
|
93
|
+
return Result.ok(updateResult.value);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const RecordAuditLogUseCase_RecordAuditLogUseCase = RecordAuditLogUseCase.createImplementation({
|
|
97
|
+
implementation: RecordAuditLogUseCaseImpl,
|
|
98
|
+
dependencies: [
|
|
99
|
+
CreateAuditLogUseCase,
|
|
100
|
+
ListAuditLogsUseCase,
|
|
101
|
+
UpdateAuditLogUseCase,
|
|
102
|
+
IdentityContext,
|
|
103
|
+
Logger
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
export { RecordAuditLogUseCase_RecordAuditLogUseCase as RecordAuditLogUseCase };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=RecordAuditLogUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/RecordAuditLog/RecordAuditLogUseCase.js","sources":["../../../src/features/RecordAuditLog/RecordAuditLogUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { CreateAuditLogUseCase } from \"~/features/CreateAuditLog/abstractions.js\";\nimport { ListAuditLogsUseCase } from \"~/features/ListAuditLogs/abstractions.js\";\nimport { UpdateAuditLogUseCase } from \"~/features/UpdateAuditLog/abstractions.js\";\nimport type { AuditLogPayload } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { RecordAuditLogUseCase as UseCaseAbstraction } from \"./abstractions.js\";\n\nconst createAuditLogDelayDate = (delay: number): Date => {\n const date = new Date();\n date.setTime(date.getTime() - delay * 1000);\n return date;\n};\n\n/**\n * Records audit logs for things the current identity did. Writes happen without authorization,\n * because the identity doing the audited action doesn't need audit log permissions.\n *\n * An action with a `newEntryDelay` merges into the entity's latest audit log when that log is\n * newer than the delay, instead of creating a new one. A failure on that path is logged and\n * nothing is recorded.\n */\nclass RecordAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly createAuditLog: CreateAuditLogUseCase.Interface,\n private readonly listAuditLogs: ListAuditLogsUseCase.Interface,\n private readonly updateAuditLog: UpdateAuditLogUseCase.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly logger: Logger.Interface\n ) {}\n\n public async execute(\n input: UseCaseAbstraction.Input\n ): Promise<Result<IAuditLog | null, UseCaseAbstraction.Error>> {\n const { audit, message, content, entityId } = input;\n\n if (!this.identityContext.getIdentity()?.id) {\n this.logger.debug(\"No identity, skipping audit log creation.\");\n return Result.ok(null);\n }\n\n const payload: AuditLogPayload = {\n message,\n app: audit.app.app,\n entityId,\n entity: audit.entity.type,\n action: audit.action.type,\n content,\n tags: []\n };\n\n const delay = audit.action.newEntryDelay || 0;\n\n return await this.identityContext.withoutAuthorization(async () => {\n if (delay > 0) {\n try {\n return await this.createOrMergeAuditLog(payload, delay);\n } catch (error) {\n this.logger.warn({ error }, \"Could not create or merge an audit log.\");\n return Result.ok(null);\n }\n }\n return await this.createAuditLog.execute(payload);\n });\n }\n\n private async createOrMergeAuditLog(\n payload: AuditLogPayload,\n delay: number\n ): Promise<Result<IAuditLog | null, UseCaseAbstraction.Error>> {\n const createdOnGte = createAuditLogDelayDate(delay);\n const listResult = await this.listAuditLogs.execute({\n app: payload.app,\n entityId: payload.entityId,\n limit: 1,\n createdOn_gte: createdOnGte,\n sort: \"DESC\"\n });\n if (listResult.isFail()) {\n this.logger.warn(\n { error: listResult.error },\n \"Could not list audit logs to merge into.\"\n );\n return Result.ok(null);\n }\n\n const original = listResult.value.items[0];\n if (!original) {\n const createResult = await this.createAuditLog.execute(payload);\n if (createResult.isFail()) {\n this.logger.warn({ error: createResult.error }, \"Could not create an audit log.\");\n return Result.ok(null);\n }\n return Result.ok(createResult.value);\n }\n\n // Update the latest audit log with the new \"after\" payload, keeping its original \"before\".\n // Only the message and the content change: the original log keeps everything else,\n // including any tags it was created with.\n let content = payload.content;\n if (original.content) {\n const beforePayloadData = JSON.parse(original.content)?.before;\n if (beforePayloadData) {\n content = {\n before: beforePayloadData,\n after: payload.content?.after\n };\n }\n }\n\n const updateResult = await this.updateAuditLog.execute(original, {\n message: payload.message,\n content\n });\n if (updateResult.isFail()) {\n this.logger.warn({ error: updateResult.error }, \"Could not merge an audit log.\");\n return Result.ok(null);\n }\n\n return Result.ok(updateResult.value);\n }\n}\n\nexport const RecordAuditLogUseCase = UseCaseAbstraction.createImplementation({\n implementation: RecordAuditLogUseCaseImpl,\n dependencies: [\n CreateAuditLogUseCase,\n ListAuditLogsUseCase,\n UpdateAuditLogUseCase,\n IdentityContext,\n Logger\n ]\n});\n"],"names":["createAuditLogDelayDate","delay","date","Date","RecordAuditLogUseCaseImpl","createAuditLog","listAuditLogs","updateAuditLog","identityContext","logger","input","audit","message","content","entityId","Result","payload","error","createdOnGte","listResult","original","createResult","beforePayloadData","JSON","updateResult","RecordAuditLogUseCase","UseCaseAbstraction","CreateAuditLogUseCase","ListAuditLogsUseCase","UpdateAuditLogUseCase","IdentityContext","Logger"],"mappings":";;;;;;;AAUA,MAAMA,0BAA0B,CAACC;IAC7B,MAAMC,OAAO,IAAIC;IACjBD,KAAK,OAAO,CAACA,KAAK,OAAO,KAAKD,AAAQ,OAARA;IAC9B,OAAOC;AACX;AAUA,MAAME;IACF,YACqBC,cAA+C,EAC/CC,aAA6C,EAC7CC,cAA+C,EAC/CC,eAA0C,EAC1CC,MAAwB,CAC3C;aALmBJ,cAAc,GAAdA;aACAC,aAAa,GAAbA;aACAC,cAAc,GAAdA;aACAC,eAAe,GAAfA;aACAC,MAAM,GAANA;IAClB;IAEH,MAAa,QACTC,KAA+B,EAC4B;QAC3D,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGJ;QAE9C,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI,IAAI;YACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAClB,OAAOK,OAAO,EAAE,CAAC;QACrB;QAEA,MAAMC,UAA2B;YAC7BJ;YACA,KAAKD,MAAM,GAAG,CAAC,GAAG;YAClBG;YACA,QAAQH,MAAM,MAAM,CAAC,IAAI;YACzB,QAAQA,MAAM,MAAM,CAAC,IAAI;YACzBE;YACA,MAAM,EAAE;QACZ;QAEA,MAAMZ,QAAQU,MAAM,MAAM,CAAC,aAAa,IAAI;QAE5C,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC;YACnD,IAAIV,QAAQ,GACR,IAAI;gBACA,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAACe,SAASf;YACrD,EAAE,OAAOgB,OAAO;gBACZ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;oBAAEA;gBAAM,GAAG;gBAC5B,OAAOF,OAAO,EAAE,CAAC;YACrB;YAEJ,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACC;QAC7C;IACJ;IAEA,MAAc,sBACVA,OAAwB,EACxBf,KAAa,EAC8C;QAC3D,MAAMiB,eAAelB,wBAAwBC;QAC7C,MAAMkB,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YAChD,KAAKH,QAAQ,GAAG;YAChB,UAAUA,QAAQ,QAAQ;YAC1B,OAAO;YACP,eAAeE;YACf,MAAM;QACV;QACA,IAAIC,WAAW,MAAM,IAAI;YACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ;gBAAE,OAAOA,WAAW,KAAK;YAAC,GAC1B;YAEJ,OAAOJ,OAAO,EAAE,CAAC;QACrB;QAEA,MAAMK,WAAWD,WAAW,KAAK,CAAC,KAAK,CAAC,EAAE;QAC1C,IAAI,CAACC,UAAU;YACX,MAAMC,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACL;YACvD,IAAIK,aAAa,MAAM,IAAI;gBACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;oBAAE,OAAOA,aAAa,KAAK;gBAAC,GAAG;gBAChD,OAAON,OAAO,EAAE,CAAC;YACrB;YACA,OAAOA,OAAO,EAAE,CAACM,aAAa,KAAK;QACvC;QAKA,IAAIR,UAAUG,QAAQ,OAAO;QAC7B,IAAII,SAAS,OAAO,EAAE;YAClB,MAAME,oBAAoBC,KAAK,KAAK,CAACH,SAAS,OAAO,GAAG;YACxD,IAAIE,mBACAT,UAAU;gBACN,QAAQS;gBACR,OAAON,QAAQ,OAAO,EAAE;YAC5B;QAER;QAEA,MAAMQ,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACJ,UAAU;YAC7D,SAASJ,QAAQ,OAAO;YACxBH;QACJ;QACA,IAAIW,aAAa,MAAM,IAAI;YACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBAAE,OAAOA,aAAa,KAAK;YAAC,GAAG;YAChD,OAAOT,OAAO,EAAE,CAAC;QACrB;QAEA,OAAOA,OAAO,EAAE,CAACS,aAAa,KAAK;IACvC;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBtB;IAChB,cAAc;QACVuB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
+
import type { AuditAction } from "../../types.js";
|
|
4
|
+
import type { IAuditLog } from "../../storage/types.js";
|
|
5
|
+
import type { CreateAuditLogUseCase } from "../../features/CreateAuditLog/abstractions.js";
|
|
6
|
+
export interface RecordAuditLogInput {
|
|
7
|
+
audit: AuditAction;
|
|
8
|
+
message: string;
|
|
9
|
+
content: GenericRecord;
|
|
10
|
+
entityId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* RecordAuditLog Use Case - Records an audit log for something the current identity did. Returns
|
|
14
|
+
* null when nothing was recorded: there's no identity, or merging into an earlier log failed.
|
|
15
|
+
*/
|
|
16
|
+
export interface IRecordAuditLogUseCase {
|
|
17
|
+
execute(input: RecordAuditLogInput): Promise<Result<IAuditLog | null, UseCaseError>>;
|
|
18
|
+
}
|
|
19
|
+
type UseCaseError = CreateAuditLogUseCase.Error;
|
|
20
|
+
export declare const RecordAuditLogUseCase: import("@webiny/di").Abstraction<IRecordAuditLogUseCase>;
|
|
21
|
+
export declare namespace RecordAuditLogUseCase {
|
|
22
|
+
type Interface = IRecordAuditLogUseCase;
|
|
23
|
+
type Input = RecordAuditLogInput;
|
|
24
|
+
type Error = UseCaseError;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/RecordAuditLog/abstractions.js","sources":["../../../src/features/RecordAuditLog/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { AuditAction } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport type { CreateAuditLogUseCase } from \"~/features/CreateAuditLog/abstractions.js\";\n\nexport interface RecordAuditLogInput {\n audit: AuditAction;\n message: string;\n content: GenericRecord;\n entityId: string;\n}\n\n/**\n * RecordAuditLog Use Case - Records an audit log for something the current identity did. Returns\n * null when nothing was recorded: there's no identity, or merging into an earlier log failed.\n */\nexport interface IRecordAuditLogUseCase {\n execute(input: RecordAuditLogInput): Promise<Result<IAuditLog | null, UseCaseError>>;\n}\n\ntype UseCaseError = CreateAuditLogUseCase.Error;\n\nexport const RecordAuditLogUseCase =\n createAbstraction<IRecordAuditLogUseCase>(\"RecordAuditLogUseCase\");\n\nexport namespace RecordAuditLogUseCase {\n export type Interface = IRecordAuditLogUseCase;\n export type Input = RecordAuditLogInput;\n export type Error = UseCaseError;\n}\n"],"names":["RecordAuditLogUseCase","createAbstraction"],"mappings":";AAwBO,MAAMA,wBACTC,kBAA0C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { RecordAuditLogUseCase } from "./RecordAuditLogUseCase.js";
|
|
3
|
+
const RecordAuditLogFeature = createFeature({
|
|
4
|
+
name: "AuditLogs/RecordAuditLog",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(RecordAuditLogUseCase);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { RecordAuditLogFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/RecordAuditLog/feature.js","sources":["../../../src/features/RecordAuditLog/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { RecordAuditLogUseCase } from \"./RecordAuditLogUseCase.js\";\n\nexport const RecordAuditLogFeature = createFeature({\n name: \"AuditLogs/RecordAuditLog\",\n register(container) {\n container.register(RecordAuditLogUseCase);\n }\n});\n"],"names":["RecordAuditLogFeature","createFeature","container","RecordAuditLogUseCase"],"mappings":";;AAGO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuditLogsStorage } from "../../abstractions.js";
|
|
2
|
+
import type { IAuditLog } from "../../storage/types.js";
|
|
3
|
+
import { UpdateAuditLogGateway as Abstraction } from "./abstractions.js";
|
|
4
|
+
declare class UpdateAuditLogGatewayImpl implements Abstraction.Interface {
|
|
5
|
+
private readonly storage;
|
|
6
|
+
constructor(storage: AuditLogsStorage.Interface);
|
|
7
|
+
update(auditLog: IAuditLog): Promise<IAuditLog>;
|
|
8
|
+
}
|
|
9
|
+
export declare const UpdateAuditLogGateway: typeof UpdateAuditLogGatewayImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateAuditLogGateway>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AuditLogsStorage } from "../../abstractions.js";
|
|
2
|
+
import { UpdateAuditLogGateway } from "./abstractions.js";
|
|
3
|
+
class UpdateAuditLogGatewayImpl {
|
|
4
|
+
constructor(storage){
|
|
5
|
+
this.storage = storage;
|
|
6
|
+
}
|
|
7
|
+
async update(auditLog) {
|
|
8
|
+
const result = await this.storage.store({
|
|
9
|
+
data: auditLog
|
|
10
|
+
});
|
|
11
|
+
if (!result.success) throw result.error;
|
|
12
|
+
return result.data;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const UpdateAuditLogGateway_UpdateAuditLogGateway = UpdateAuditLogGateway.createImplementation({
|
|
16
|
+
implementation: UpdateAuditLogGatewayImpl,
|
|
17
|
+
dependencies: [
|
|
18
|
+
AuditLogsStorage
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
export { UpdateAuditLogGateway_UpdateAuditLogGateway as UpdateAuditLogGateway };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=UpdateAuditLogGateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateAuditLog/UpdateAuditLogGateway.js","sources":["../../../src/features/UpdateAuditLog/UpdateAuditLogGateway.ts"],"sourcesContent":["import { AuditLogsStorage } from \"~/abstractions.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { UpdateAuditLogGateway as Abstraction } from \"./abstractions.js\";\n\nclass UpdateAuditLogGatewayImpl implements Abstraction.Interface {\n public constructor(private readonly storage: AuditLogsStorage.Interface) {}\n\n public async update(auditLog: IAuditLog): Promise<IAuditLog> {\n const result = await this.storage.store({ data: auditLog });\n if (!result.success) {\n throw result.error;\n }\n return result.data;\n }\n}\n\nexport const UpdateAuditLogGateway = Abstraction.createImplementation({\n implementation: UpdateAuditLogGatewayImpl,\n dependencies: [AuditLogsStorage]\n});\n"],"names":["UpdateAuditLogGatewayImpl","storage","auditLog","result","UpdateAuditLogGateway","Abstraction","AuditLogsStorage"],"mappings":";;AAIA,MAAMA;IACF,YAAoCC,OAAmC,CAAE;aAArCA,OAAO,GAAPA;IAAsC;IAE1E,MAAa,OAAOC,QAAmB,EAAsB;QACzD,MAAMC,SAAS,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,MAAMD;QAAS;QACzD,IAAI,CAACC,OAAO,OAAO,EACf,MAAMA,OAAO,KAAK;QAEtB,OAAOA,OAAO,IAAI;IACtB;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBL;IAChB,cAAc;QAACM;KAAiB;AACpC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { AuditLogPersistenceError } from "../../domain/errors.js";
|
|
3
|
+
import type { IAuditLog } from "../../storage/types.js";
|
|
4
|
+
import { UpdateAuditLogRepository as Abstraction } from "./abstractions.js";
|
|
5
|
+
import { UpdateAuditLogGateway } from "./abstractions.js";
|
|
6
|
+
declare class UpdateAuditLogRepositoryImpl implements Abstraction.Interface {
|
|
7
|
+
private readonly gateway;
|
|
8
|
+
constructor(gateway: UpdateAuditLogGateway.Interface);
|
|
9
|
+
update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const UpdateAuditLogRepository: typeof UpdateAuditLogRepositoryImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateAuditLogRepository>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { AuditLogPersistenceError } from "../../domain/errors.js";
|
|
3
|
+
import { UpdateAuditLogGateway, UpdateAuditLogRepository } from "./abstractions.js";
|
|
4
|
+
class UpdateAuditLogRepositoryImpl {
|
|
5
|
+
constructor(gateway){
|
|
6
|
+
this.gateway = gateway;
|
|
7
|
+
}
|
|
8
|
+
async update(auditLog) {
|
|
9
|
+
try {
|
|
10
|
+
const updated = await this.gateway.update(auditLog);
|
|
11
|
+
return Result.ok(updated);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return Result.fail(new AuditLogPersistenceError(error));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const UpdateAuditLogRepository_UpdateAuditLogRepository = UpdateAuditLogRepository.createImplementation({
|
|
18
|
+
implementation: UpdateAuditLogRepositoryImpl,
|
|
19
|
+
dependencies: [
|
|
20
|
+
UpdateAuditLogGateway
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
export { UpdateAuditLogRepository_UpdateAuditLogRepository as UpdateAuditLogRepository };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=UpdateAuditLogRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateAuditLog/UpdateAuditLogRepository.js","sources":["../../../src/features/UpdateAuditLog/UpdateAuditLogRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { AuditLogPersistenceError } from \"~/domain/errors.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { UpdateAuditLogRepository as Abstraction } from \"./abstractions.js\";\nimport { UpdateAuditLogGateway } from \"./abstractions.js\";\n\nclass UpdateAuditLogRepositoryImpl implements Abstraction.Interface {\n public constructor(private readonly gateway: UpdateAuditLogGateway.Interface) {}\n\n public async update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>> {\n try {\n const updated = await this.gateway.update(auditLog);\n return Result.ok(updated);\n } catch (error) {\n return Result.fail(new AuditLogPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateAuditLogRepository = Abstraction.createImplementation({\n implementation: UpdateAuditLogRepositoryImpl,\n dependencies: [UpdateAuditLogGateway]\n});\n"],"names":["UpdateAuditLogRepositoryImpl","gateway","auditLog","updated","Result","error","AuditLogPersistenceError","UpdateAuditLogRepository","Abstraction","UpdateAuditLogGateway"],"mappings":";;;AAMA,MAAMA;IACF,YAAoCC,OAAwC,CAAE;aAA1CA,OAAO,GAAPA;IAA2C;IAE/E,MAAa,OAAOC,QAAmB,EAAwD;QAC3F,IAAI;YACA,MAAMC,UAAU,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAACD;YAC1C,OAAOE,OAAO,EAAE,CAACD;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOD,OAAO,IAAI,CAAC,IAAIE,yBAAyBD;QACpD;IACJ;AACJ;AAEO,MAAME,oDAA2BC,yBAAAA,oBAAgC,CAAC;IACrE,gBAAgBR;IAChB,cAAc;QAACS;KAAsB;AACzC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
import { AuditLogPermissions } from "../../features/AuditLogPermissions/abstractions.js";
|
|
4
|
+
import type { AuditLogPayload } from "../../types.js";
|
|
5
|
+
import type { IAuditLog } from "../../storage/types.js";
|
|
6
|
+
import { UpdateAuditLogUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
7
|
+
import { UpdateAuditLogRepository } from "./abstractions.js";
|
|
8
|
+
declare class UpdateAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
9
|
+
private readonly repository;
|
|
10
|
+
private readonly permissions;
|
|
11
|
+
private readonly eventPublisher;
|
|
12
|
+
constructor(repository: UpdateAuditLogRepository.Interface, permissions: AuditLogPermissions.Interface, eventPublisher: EventPublisher.Interface);
|
|
13
|
+
execute(original: IAuditLog, payload: Partial<AuditLogPayload>): Promise<Result<IAuditLog, UseCaseAbstraction.Error>>;
|
|
14
|
+
}
|
|
15
|
+
export declare const UpdateAuditLogUseCase: typeof UpdateAuditLogUseCaseImpl & {
|
|
16
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateAuditLogUseCase>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
|
|
3
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
4
|
+
import { AuditLogPermissions } from "../AuditLogPermissions/abstractions.js";
|
|
5
|
+
import { AuditLogAfterUpdateEvent, AuditLogBeforeUpdateEvent } from "../../events/index.js";
|
|
6
|
+
import { UpdateAuditLogRepository, UpdateAuditLogUseCase } from "./abstractions.js";
|
|
7
|
+
class UpdateAuditLogUseCaseImpl {
|
|
8
|
+
constructor(repository, permissions, eventPublisher){
|
|
9
|
+
this.repository = repository;
|
|
10
|
+
this.permissions = permissions;
|
|
11
|
+
this.eventPublisher = eventPublisher;
|
|
12
|
+
}
|
|
13
|
+
async execute(original, payload) {
|
|
14
|
+
let content = original.content;
|
|
15
|
+
if (payload.content) content = JSON.stringify(payload.content);
|
|
16
|
+
const auditLog = {
|
|
17
|
+
...original,
|
|
18
|
+
...payload,
|
|
19
|
+
content
|
|
20
|
+
};
|
|
21
|
+
const canAccess = await this.permissions.canAccess(auditLog.action);
|
|
22
|
+
if (!canAccess) return Result.fail(new NotAuthorizedError({
|
|
23
|
+
message: "You cannot access audit logs."
|
|
24
|
+
}));
|
|
25
|
+
const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({
|
|
26
|
+
original,
|
|
27
|
+
auditLog,
|
|
28
|
+
setAuditLog (input) {
|
|
29
|
+
Object.assign(auditLog, input);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
await this.eventPublisher.publish(beforeUpdateEvent);
|
|
33
|
+
const result = await this.repository.update(auditLog);
|
|
34
|
+
if (result.isFail()) return Result.fail(result.error);
|
|
35
|
+
const afterUpdateEvent = new AuditLogAfterUpdateEvent({
|
|
36
|
+
original,
|
|
37
|
+
auditLog
|
|
38
|
+
});
|
|
39
|
+
await this.eventPublisher.publish(afterUpdateEvent);
|
|
40
|
+
return Result.ok(result.value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const UpdateAuditLogUseCase_UpdateAuditLogUseCase = UpdateAuditLogUseCase.createImplementation({
|
|
44
|
+
implementation: UpdateAuditLogUseCaseImpl,
|
|
45
|
+
dependencies: [
|
|
46
|
+
UpdateAuditLogRepository,
|
|
47
|
+
AuditLogPermissions,
|
|
48
|
+
EventPublisher
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
export { UpdateAuditLogUseCase_UpdateAuditLogUseCase as UpdateAuditLogUseCase };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=UpdateAuditLogUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateAuditLog/UpdateAuditLogUseCase.js","sources":["../../../src/features/UpdateAuditLog/UpdateAuditLogUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { AuditLogPermissions } from \"~/features/AuditLogPermissions/abstractions.js\";\nimport { AuditLogBeforeUpdateEvent } from \"~/events/index.js\";\nimport { AuditLogAfterUpdateEvent } from \"~/events/index.js\";\nimport type { AuditLogPayload } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport { UpdateAuditLogUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { UpdateAuditLogRepository } from \"./abstractions.js\";\n\nclass UpdateAuditLogUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private readonly repository: UpdateAuditLogRepository.Interface,\n private readonly permissions: AuditLogPermissions.Interface,\n private readonly eventPublisher: EventPublisher.Interface\n ) {}\n\n public async execute(\n original: IAuditLog,\n payload: Partial<AuditLogPayload>\n ): Promise<Result<IAuditLog, UseCaseAbstraction.Error>> {\n let content = original.content;\n if (payload.content) {\n content = JSON.stringify(payload.content);\n }\n\n const auditLog: IAuditLog = {\n ...original,\n ...payload,\n content\n };\n\n const canAccess = await this.permissions.canAccess(auditLog.action);\n if (!canAccess) {\n return Result.fail(\n new NotAuthorizedError({ message: \"You cannot access audit logs.\" })\n );\n }\n\n const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({\n original,\n auditLog,\n setAuditLog(input) {\n Object.assign(auditLog, input);\n }\n });\n await this.eventPublisher.publish(beforeUpdateEvent);\n\n const result = await this.repository.update(auditLog);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n const afterUpdateEvent = new AuditLogAfterUpdateEvent({ original, auditLog });\n await this.eventPublisher.publish(afterUpdateEvent);\n\n return Result.ok(result.value);\n }\n}\n\nexport const UpdateAuditLogUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateAuditLogUseCaseImpl,\n dependencies: [UpdateAuditLogRepository, AuditLogPermissions, EventPublisher]\n});\n"],"names":["UpdateAuditLogUseCaseImpl","repository","permissions","eventPublisher","original","payload","content","JSON","auditLog","canAccess","Result","NotAuthorizedError","beforeUpdateEvent","AuditLogBeforeUpdateEvent","input","Object","result","afterUpdateEvent","AuditLogAfterUpdateEvent","UpdateAuditLogUseCase","UseCaseAbstraction","UpdateAuditLogRepository","AuditLogPermissions","EventPublisher"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACqBC,UAA8C,EAC9CC,WAA0C,EAC1CC,cAAwC,CAC3D;aAHmBF,UAAU,GAAVA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IAClB;IAEH,MAAa,QACTC,QAAmB,EACnBC,OAAiC,EACmB;QACpD,IAAIC,UAAUF,SAAS,OAAO;QAC9B,IAAIC,QAAQ,OAAO,EACfC,UAAUC,KAAK,SAAS,CAACF,QAAQ,OAAO;QAG5C,MAAMG,WAAsB;YACxB,GAAGJ,QAAQ;YACX,GAAGC,OAAO;YACVC;QACJ;QAEA,MAAMG,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAACD,SAAS,MAAM;QAClE,IAAI,CAACC,WACD,OAAOC,OAAO,IAAI,CACd,IAAIC,mBAAmB;YAAE,SAAS;QAAgC;QAI1E,MAAMC,oBAAoB,IAAIC,0BAA0B;YACpDT;YACAI;YACA,aAAYM,KAAK;gBACbC,OAAO,MAAM,CAACP,UAAUM;YAC5B;QACJ;QACA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACF;QAElC,MAAMI,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACR;QAC5C,IAAIQ,OAAO,MAAM,IACb,OAAON,OAAO,IAAI,CAACM,OAAO,KAAK;QAGnC,MAAMC,mBAAmB,IAAIC,yBAAyB;YAAEd;YAAUI;QAAS;QAC3E,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACS;QAElC,OAAOP,OAAO,EAAE,CAACM,OAAO,KAAK;IACjC;AACJ;AAEO,MAAMG,8CAAwBC,sBAAAA,oBAAuC,CAAC;IACzE,gBAAgBpB;IAChB,cAAc;QAACqB;QAA0BC;QAAqBC;KAAe;AACjF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { NotAuthorizedError } from "@webiny/api-core/features/security/shared/errors.js";
|
|
3
|
+
import type { AuditLogPayload } from "../../types.js";
|
|
4
|
+
import type { IAuditLog } from "../../storage/types.js";
|
|
5
|
+
import type { AuditLogPersistenceError } from "../../domain/errors.js";
|
|
6
|
+
/**
|
|
7
|
+
* UpdateAuditLog Use Case - Updates an existing audit log with new values.
|
|
8
|
+
*/
|
|
9
|
+
export interface IUpdateAuditLogUseCase {
|
|
10
|
+
execute(original: IAuditLog, payload: Partial<AuditLogPayload>): Promise<Result<IAuditLog, UseCaseError>>;
|
|
11
|
+
}
|
|
12
|
+
export interface IUpdateAuditLogUseCaseErrors {
|
|
13
|
+
notAuthorized: NotAuthorizedError;
|
|
14
|
+
persistence: AuditLogPersistenceError;
|
|
15
|
+
}
|
|
16
|
+
type UseCaseError = IUpdateAuditLogUseCaseErrors[keyof IUpdateAuditLogUseCaseErrors];
|
|
17
|
+
export declare const UpdateAuditLogUseCase: import("@webiny/di").Abstraction<IUpdateAuditLogUseCase>;
|
|
18
|
+
export declare namespace UpdateAuditLogUseCase {
|
|
19
|
+
type Interface = IUpdateAuditLogUseCase;
|
|
20
|
+
type Error = UseCaseError;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* UpdateAuditLogRepository - Stores an updated audit log.
|
|
24
|
+
*/
|
|
25
|
+
export interface IUpdateAuditLogRepository {
|
|
26
|
+
update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>>;
|
|
27
|
+
}
|
|
28
|
+
export declare const UpdateAuditLogRepository: import("@webiny/di").Abstraction<IUpdateAuditLogRepository>;
|
|
29
|
+
export declare namespace UpdateAuditLogRepository {
|
|
30
|
+
type Interface = IUpdateAuditLogRepository;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* UpdateAuditLogGateway - Writes an updated audit log to the audit logs storage.
|
|
34
|
+
*/
|
|
35
|
+
export interface IUpdateAuditLogGateway {
|
|
36
|
+
update(auditLog: IAuditLog): Promise<IAuditLog>;
|
|
37
|
+
}
|
|
38
|
+
export declare const UpdateAuditLogGateway: import("@webiny/di").Abstraction<IUpdateAuditLogGateway>;
|
|
39
|
+
export declare namespace UpdateAuditLogGateway {
|
|
40
|
+
type Interface = IUpdateAuditLogGateway;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const UpdateAuditLogUseCase = createAbstraction("UpdateAuditLogUseCase");
|
|
3
|
+
const UpdateAuditLogRepository = createAbstraction("UpdateAuditLogRepository");
|
|
4
|
+
const UpdateAuditLogGateway = createAbstraction("UpdateAuditLogGateway");
|
|
5
|
+
export { UpdateAuditLogGateway, UpdateAuditLogRepository, UpdateAuditLogUseCase };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateAuditLog/abstractions.js","sources":["../../../src/features/UpdateAuditLog/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/errors.js\";\nimport type { AuditLogPayload } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport type { AuditLogPersistenceError } from \"~/domain/errors.js\";\n\n/**\n * UpdateAuditLog Use Case - Updates an existing audit log with new values.\n */\nexport interface IUpdateAuditLogUseCase {\n execute(\n original: IAuditLog,\n payload: Partial<AuditLogPayload>\n ): Promise<Result<IAuditLog, UseCaseError>>;\n}\n\nexport interface IUpdateAuditLogUseCaseErrors {\n notAuthorized: NotAuthorizedError;\n persistence: AuditLogPersistenceError;\n}\n\ntype UseCaseError = IUpdateAuditLogUseCaseErrors[keyof IUpdateAuditLogUseCaseErrors];\n\nexport const UpdateAuditLogUseCase =\n createAbstraction<IUpdateAuditLogUseCase>(\"UpdateAuditLogUseCase\");\n\nexport namespace UpdateAuditLogUseCase {\n export type Interface = IUpdateAuditLogUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UpdateAuditLogRepository - Stores an updated audit log.\n */\nexport interface IUpdateAuditLogRepository {\n update(auditLog: IAuditLog): Promise<Result<IAuditLog, AuditLogPersistenceError>>;\n}\n\nexport const UpdateAuditLogRepository = createAbstraction<IUpdateAuditLogRepository>(\n \"UpdateAuditLogRepository\"\n);\n\nexport namespace UpdateAuditLogRepository {\n export type Interface = IUpdateAuditLogRepository;\n}\n\n/**\n * UpdateAuditLogGateway - Writes an updated audit log to the audit logs storage.\n */\nexport interface IUpdateAuditLogGateway {\n update(auditLog: IAuditLog): Promise<IAuditLog>;\n}\n\nexport const UpdateAuditLogGateway =\n createAbstraction<IUpdateAuditLogGateway>(\"UpdateAuditLogGateway\");\n\nexport namespace UpdateAuditLogGateway {\n export type Interface = IUpdateAuditLogGateway;\n}\n"],"names":["UpdateAuditLogUseCase","createAbstraction","UpdateAuditLogRepository","UpdateAuditLogGateway"],"mappings":";AAwBO,MAAMA,wBACTC,kBAA0C;AAcvC,MAAMC,2BAA2BD,kBACpC;AAcG,MAAME,wBACTF,kBAA0C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { UpdateAuditLogUseCase } from "./UpdateAuditLogUseCase.js";
|
|
3
|
+
import { UpdateAuditLogRepository } from "./UpdateAuditLogRepository.js";
|
|
4
|
+
import { UpdateAuditLogGateway } from "./UpdateAuditLogGateway.js";
|
|
5
|
+
const UpdateAuditLogFeature = createFeature({
|
|
6
|
+
name: "AuditLogs/UpdateAuditLog",
|
|
7
|
+
register (container) {
|
|
8
|
+
container.register(UpdateAuditLogUseCase);
|
|
9
|
+
container.register(UpdateAuditLogRepository).inSingletonScope();
|
|
10
|
+
container.register(UpdateAuditLogGateway).inSingletonScope();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { UpdateAuditLogFeature };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UpdateAuditLog/feature.js","sources":["../../../src/features/UpdateAuditLog/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UpdateAuditLogUseCase } from \"./UpdateAuditLogUseCase.js\";\nimport { UpdateAuditLogRepository } from \"./UpdateAuditLogRepository.js\";\nimport { UpdateAuditLogGateway } from \"./UpdateAuditLogGateway.js\";\n\nexport const UpdateAuditLogFeature = createFeature({\n name: \"AuditLogs/UpdateAuditLog\",\n register(container) {\n container.register(UpdateAuditLogUseCase);\n container.register(UpdateAuditLogRepository).inSingletonScope();\n container.register(UpdateAuditLogGateway).inSingletonScope();\n }\n});\n"],"names":["UpdateAuditLogFeature","createFeature","container","UpdateAuditLogUseCase","UpdateAuditLogRepository","UpdateAuditLogGateway"],"mappings":";;;;AAKO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,0BAA0B,gBAAgB;QAC7DF,UAAU,QAAQ,CAACG,uBAAuB,gBAAgB;IAC9D;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { GraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
declare class AuditLogsGraphQLSchemaImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
getSchemaKey: () => string;
|
|
5
|
+
execute(builder: GraphQLSchemaBuilder.Interface): CoreGraphQLSchemaFactory.Return;
|
|
6
|
+
}
|
|
7
|
+
export declare const AuditLogsGraphQLSchema: typeof AuditLogsGraphQLSchemaImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core.js").ICoreGraphQLSchemaFactory>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|