@webiny/api-audit-logs 0.0.0-unstable.df7a8bb475 → 0.0.0-unstable.e1999482d0
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.d.ts +2 -2
- package/events/AuditLogAfterCreateEvent.js +9 -6
- package/events/AuditLogAfterCreateEvent.js.map +1 -1
- package/events/AuditLogAfterUpdateEvent.d.ts +2 -2
- package/events/AuditLogAfterUpdateEvent.js +9 -6
- package/events/AuditLogAfterUpdateEvent.js.map +1 -1
- package/events/AuditLogBeforeCreateEvent.d.ts +2 -2
- package/events/AuditLogBeforeCreateEvent.js +9 -6
- package/events/AuditLogBeforeCreateEvent.js.map +1 -1
- package/events/AuditLogBeforeUpdateEvent.d.ts +2 -2
- package/events/AuditLogBeforeUpdateEvent.js +9 -6
- package/events/AuditLogBeforeUpdateEvent.js.map +1 -1
- package/events/abstractions.d.ts +1 -6
- 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 +32 -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 +104 -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.d.ts +10 -53
- 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 +34 -30
- 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 +7 -7
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js +38 -28
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js.map +1 -1
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js +54 -31
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js.map +1 -1
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js +44 -35
- 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 +7 -7
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js +28 -23
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js +28 -23
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js +31 -27
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js +31 -27
- 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 +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js +37 -31
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js +30 -29
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js +27 -25
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js +30 -26
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.d.ts +4 -4
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js +27 -22
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.d.ts +4 -4
- 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 +7 -7
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js +33 -25
- 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 +7 -7
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js +38 -40
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js +38 -40
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js +42 -45
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js +28 -23
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js +28 -23
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js +31 -27
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js +28 -23
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js +28 -23
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js +31 -27
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js +28 -23
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js +28 -23
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js +31 -27
- 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/globalComponents/SaveGlobalComponentWithAuditLog.d.ts +21 -0
- package/subscriptions/websiteBuilder/globalComponents/SaveGlobalComponentWithAuditLog.js +63 -0
- package/subscriptions/websiteBuilder/globalComponents/SaveGlobalComponentWithAuditLog.js.map +1 -0
- package/subscriptions/websiteBuilder/index.d.ts +2 -2
- package/subscriptions/websiteBuilder/index.js +16 -16
- package/subscriptions/websiteBuilder/index.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js +27 -22
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js +27 -22
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js +27 -22
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js +30 -26
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js +27 -22
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js +27 -22
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js +27 -22
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js +30 -26
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js +27 -22
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js +27 -22
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js +27 -22
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.d.ts +7 -7
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js +30 -26
- 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 -35
- 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 -82
- 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
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getAuditConfig } from "../../../utils/getAuditConfig.js";
|
|
2
|
+
import { RedirectAfterDeleteEventHandler } from "@webiny/api-website-builder/features/redirects/DeleteRedirect/index.js";
|
|
3
|
+
import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
|
|
5
4
|
import { AUDIT } from "../../../config.js";
|
|
6
5
|
class RedirectAfterDeleteHandlerImpl {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
constructor(recordAuditLog){
|
|
7
|
+
this.recordAuditLog = recordAuditLog;
|
|
8
|
+
}
|
|
9
|
+
async handle(event) {
|
|
10
|
+
try {
|
|
11
|
+
const { redirect } = event.payload;
|
|
12
|
+
const recordResult = await this.recordAuditLog.execute({
|
|
13
|
+
audit: AUDIT.WEBSITE_BUILDER.REDIRECT.DELETE,
|
|
14
|
+
message: "Website Redirect Deleted",
|
|
15
|
+
content: redirect,
|
|
16
|
+
entityId: redirect.id
|
|
17
|
+
});
|
|
18
|
+
if (recordResult.isFail()) throw recordResult.error;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw WebinyError.from(error, {
|
|
21
|
+
message: "Error while executing RedirectAfterDeleteEventHandler",
|
|
22
|
+
code: "AUDIT_LOGS_AFTER_REDIRECT_DELETE_HANDLER"
|
|
23
|
+
});
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
|
-
}
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const RedirectAfterDeleteAuditHandler = RedirectAfterDeleteEventHandler.createImplementation({
|
|
28
|
+
implementation: RedirectAfterDeleteHandlerImpl,
|
|
29
|
+
dependencies: [
|
|
30
|
+
RecordAuditLogUseCase
|
|
31
|
+
]
|
|
28
32
|
});
|
|
33
|
+
export { RedirectAfterDeleteAuditHandler };
|
|
29
34
|
|
|
30
35
|
//# sourceMappingURL=RedirectAfterDeleteHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js","sources":["../../../../src/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { RedirectAfterDeleteEventHandler } from \"@webiny/api-website-builder/features/redirects/DeleteRedirect/index.js\";\nimport { RecordAuditLogUseCase } from \"~/features/RecordAuditLog/abstractions.js\";\nimport { AUDIT } from \"~/config.js\";\n\nclass RedirectAfterDeleteHandlerImpl implements RedirectAfterDeleteEventHandler.Interface {\n constructor(private recordAuditLog: RecordAuditLogUseCase.Interface) {}\n\n async handle(event: RedirectAfterDeleteEventHandler.Event): Promise<void> {\n try {\n const { redirect } = event.payload;\n const recordResult = await this.recordAuditLog.execute({\n audit: AUDIT.WEBSITE_BUILDER.REDIRECT.DELETE,\n message: \"Website Redirect Deleted\",\n content: redirect,\n entityId: redirect.id\n });\n if (recordResult.isFail()) {\n throw recordResult.error;\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing RedirectAfterDeleteEventHandler\",\n code: \"AUDIT_LOGS_AFTER_REDIRECT_DELETE_HANDLER\"\n });\n }\n }\n}\n\nexport const RedirectAfterDeleteAuditHandler = RedirectAfterDeleteEventHandler.createImplementation(\n {\n implementation: RedirectAfterDeleteHandlerImpl,\n dependencies: [RecordAuditLogUseCase]\n }\n);\n"],"names":["RedirectAfterDeleteHandlerImpl","recordAuditLog","event","redirect","recordResult","AUDIT","error","WebinyError","RedirectAfterDeleteAuditHandler","RedirectAfterDeleteEventHandler","RecordAuditLogUseCase"],"mappings":";;;;AAKA,MAAMA;IACF,YAAoBC,cAA+C,CAAE;aAAjDA,cAAc,GAAdA;IAAkD;IAEtE,MAAM,OAAOC,KAA4C,EAAiB;QACtE,IAAI;YACA,MAAM,EAAEC,QAAQ,EAAE,GAAGD,MAAM,OAAO;YAClC,MAAME,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBACnD,OAAOC,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM;gBAC5C,SAAS;gBACT,SAASF;gBACT,UAAUA,SAAS,EAAE;YACzB;YACA,IAAIC,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAEhC,EAAE,OAAOE,OAAO;YACZ,MAAMC,YAAY,IAAI,CAACD,OAAO;gBAC1B,SAAS;gBACT,MAAM;YACV;QACJ;IACJ;AACJ;AAEO,MAAME,kCAAkCC,gCAAgC,oBAAoB,CAC/F;IACI,gBAAgBT;IAChB,cAAc;QAACU;KAAsB;AACzC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
declare class RedirectAfterMoveHandlerImpl implements
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
6
|
-
handle(event:
|
|
1
|
+
import { RedirectAfterMoveEventHandler } from "@webiny/api-website-builder/features/redirects/MoveRedirect/index.js";
|
|
2
|
+
import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
|
|
3
|
+
declare class RedirectAfterMoveHandlerImpl implements RedirectAfterMoveEventHandler.Interface {
|
|
4
|
+
private recordAuditLog;
|
|
5
|
+
constructor(recordAuditLog: RecordAuditLogUseCase.Interface);
|
|
6
|
+
handle(event: RedirectAfterMoveEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const RedirectAfterMoveAuditHandler: typeof RedirectAfterMoveHandlerImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-core/features/eventPublisher").DomainEvent<import("@webiny/api-website-builder/features/redirects/MoveRedirect/abstractions").RedirectAfterMovePayload>>>;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getAuditConfig } from "../../../utils/getAuditConfig.js";
|
|
2
|
+
import { RedirectAfterMoveEventHandler } from "@webiny/api-website-builder/features/redirects/MoveRedirect/index.js";
|
|
3
|
+
import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
|
|
5
4
|
import { AUDIT } from "../../../config.js";
|
|
6
5
|
class RedirectAfterMoveHandlerImpl {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
constructor(recordAuditLog){
|
|
7
|
+
this.recordAuditLog = recordAuditLog;
|
|
8
|
+
}
|
|
9
|
+
async handle(event) {
|
|
10
|
+
try {
|
|
11
|
+
const { redirect } = event.payload;
|
|
12
|
+
const recordResult = await this.recordAuditLog.execute({
|
|
13
|
+
audit: AUDIT.WEBSITE_BUILDER.REDIRECT.MOVE,
|
|
14
|
+
message: "Website Redirect Moved",
|
|
15
|
+
content: redirect,
|
|
16
|
+
entityId: redirect.id
|
|
17
|
+
});
|
|
18
|
+
if (recordResult.isFail()) throw recordResult.error;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw WebinyError.from(error, {
|
|
21
|
+
message: "Error while executing RedirectAfterMoveEventHandler",
|
|
22
|
+
code: "AUDIT_LOGS_AFTER_REDIRECT_MOVE_HANDLER"
|
|
23
|
+
});
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
|
-
}
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const RedirectAfterMoveAuditHandler = RedirectAfterMoveEventHandler.createImplementation({
|
|
28
|
+
implementation: RedirectAfterMoveHandlerImpl,
|
|
29
|
+
dependencies: [
|
|
30
|
+
RecordAuditLogUseCase
|
|
31
|
+
]
|
|
28
32
|
});
|
|
33
|
+
export { RedirectAfterMoveAuditHandler };
|
|
29
34
|
|
|
30
35
|
//# sourceMappingURL=RedirectAfterMoveHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js","sources":["../../../../src/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { RedirectAfterMoveEventHandler } from \"@webiny/api-website-builder/features/redirects/MoveRedirect/index.js\";\nimport { RecordAuditLogUseCase } from \"~/features/RecordAuditLog/abstractions.js\";\nimport { AUDIT } from \"~/config.js\";\n\nclass RedirectAfterMoveHandlerImpl implements RedirectAfterMoveEventHandler.Interface {\n constructor(private recordAuditLog: RecordAuditLogUseCase.Interface) {}\n\n async handle(event: RedirectAfterMoveEventHandler.Event): Promise<void> {\n try {\n const { redirect } = event.payload;\n const recordResult = await this.recordAuditLog.execute({\n audit: AUDIT.WEBSITE_BUILDER.REDIRECT.MOVE,\n message: \"Website Redirect Moved\",\n content: redirect,\n entityId: redirect.id\n });\n if (recordResult.isFail()) {\n throw recordResult.error;\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing RedirectAfterMoveEventHandler\",\n code: \"AUDIT_LOGS_AFTER_REDIRECT_MOVE_HANDLER\"\n });\n }\n }\n}\n\nexport const RedirectAfterMoveAuditHandler = RedirectAfterMoveEventHandler.createImplementation({\n implementation: RedirectAfterMoveHandlerImpl,\n dependencies: [RecordAuditLogUseCase]\n});\n"],"names":["RedirectAfterMoveHandlerImpl","recordAuditLog","event","redirect","recordResult","AUDIT","error","WebinyError","RedirectAfterMoveAuditHandler","RedirectAfterMoveEventHandler","RecordAuditLogUseCase"],"mappings":";;;;AAKA,MAAMA;IACF,YAAoBC,cAA+C,CAAE;aAAjDA,cAAc,GAAdA;IAAkD;IAEtE,MAAM,OAAOC,KAA0C,EAAiB;QACpE,IAAI;YACA,MAAM,EAAEC,QAAQ,EAAE,GAAGD,MAAM,OAAO;YAClC,MAAME,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBACnD,OAAOC,MAAM,eAAe,CAAC,QAAQ,CAAC,IAAI;gBAC1C,SAAS;gBACT,SAASF;gBACT,UAAUA,SAAS,EAAE;YACzB;YACA,IAAIC,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAEhC,EAAE,OAAOE,OAAO;YACZ,MAAMC,YAAY,IAAI,CAACD,OAAO;gBAC1B,SAAS;gBACT,MAAM;YACV;QACJ;IACJ;AACJ;AAEO,MAAME,gCAAgCC,8BAA8B,oBAAoB,CAAC;IAC5F,gBAAgBT;IAChB,cAAc;QAACU;KAAsB;AACzC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
declare class RedirectAfterUpdateHandlerImpl implements
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
6
|
-
handle(event:
|
|
1
|
+
import { RedirectAfterUpdateEventHandler } from "@webiny/api-website-builder/features/redirects/UpdateRedirect/index.js";
|
|
2
|
+
import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
|
|
3
|
+
declare class RedirectAfterUpdateHandlerImpl implements RedirectAfterUpdateEventHandler.Interface {
|
|
4
|
+
private recordAuditLog;
|
|
5
|
+
constructor(recordAuditLog: RecordAuditLogUseCase.Interface);
|
|
6
|
+
handle(event: RedirectAfterUpdateEventHandler.Event): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export declare const RedirectAfterUpdateAuditHandler: typeof RedirectAfterUpdateHandlerImpl & {
|
|
9
|
-
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-core/features/eventPublisher").DomainEvent<import("@webiny/api-website-builder/features/redirects/UpdateRedirect/abstractions").RedirectAfterUpdatePayload>>>;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -1,34 +1,38 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getAuditConfig } from "../../../utils/getAuditConfig.js";
|
|
2
|
+
import { RedirectAfterUpdateEventHandler } from "@webiny/api-website-builder/features/redirects/UpdateRedirect/index.js";
|
|
3
|
+
import { RecordAuditLogUseCase } from "../../../features/RecordAuditLog/abstractions.js";
|
|
5
4
|
import { AUDIT } from "../../../config.js";
|
|
6
5
|
class RedirectAfterUpdateHandlerImpl {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
constructor(recordAuditLog){
|
|
7
|
+
this.recordAuditLog = recordAuditLog;
|
|
8
|
+
}
|
|
9
|
+
async handle(event) {
|
|
10
|
+
try {
|
|
11
|
+
const { redirect, original } = event.payload;
|
|
12
|
+
const recordResult = await this.recordAuditLog.execute({
|
|
13
|
+
audit: AUDIT.WEBSITE_BUILDER.REDIRECT.UPDATE,
|
|
14
|
+
message: "Website Redirect Updated",
|
|
15
|
+
content: {
|
|
16
|
+
before: original,
|
|
17
|
+
after: redirect
|
|
18
|
+
},
|
|
19
|
+
entityId: redirect.id
|
|
20
|
+
});
|
|
21
|
+
if (recordResult.isFail()) throw recordResult.error;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw WebinyError.from(error, {
|
|
24
|
+
message: "Error while executing RedirectAfterUpdateEventHandler",
|
|
25
|
+
code: "AUDIT_LOGS_AFTER_REDIRECT_UPDATE_HANDLER"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
|
-
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const RedirectAfterUpdateAuditHandler = RedirectAfterUpdateEventHandler.createImplementation({
|
|
31
|
+
implementation: RedirectAfterUpdateHandlerImpl,
|
|
32
|
+
dependencies: [
|
|
33
|
+
RecordAuditLogUseCase
|
|
34
|
+
]
|
|
32
35
|
});
|
|
36
|
+
export { RedirectAfterUpdateAuditHandler };
|
|
33
37
|
|
|
34
38
|
//# sourceMappingURL=RedirectAfterUpdateHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js","sources":["../../../../src/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { RedirectAfterUpdateEventHandler } from \"@webiny/api-website-builder/features/redirects/UpdateRedirect/index.js\";\nimport { RecordAuditLogUseCase } from \"~/features/RecordAuditLog/abstractions.js\";\nimport { AUDIT } from \"~/config.js\";\n\nclass RedirectAfterUpdateHandlerImpl implements RedirectAfterUpdateEventHandler.Interface {\n constructor(private recordAuditLog: RecordAuditLogUseCase.Interface) {}\n\n async handle(event: RedirectAfterUpdateEventHandler.Event): Promise<void> {\n try {\n const { redirect, original } = event.payload;\n const recordResult = await this.recordAuditLog.execute({\n audit: AUDIT.WEBSITE_BUILDER.REDIRECT.UPDATE,\n message: \"Website Redirect Updated\",\n content: { before: original, after: redirect },\n entityId: redirect.id\n });\n if (recordResult.isFail()) {\n throw recordResult.error;\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing RedirectAfterUpdateEventHandler\",\n code: \"AUDIT_LOGS_AFTER_REDIRECT_UPDATE_HANDLER\"\n });\n }\n }\n}\n\nexport const RedirectAfterUpdateAuditHandler = RedirectAfterUpdateEventHandler.createImplementation(\n {\n implementation: RedirectAfterUpdateHandlerImpl,\n dependencies: [RecordAuditLogUseCase]\n }\n);\n"],"names":["RedirectAfterUpdateHandlerImpl","recordAuditLog","event","redirect","original","recordResult","AUDIT","error","WebinyError","RedirectAfterUpdateAuditHandler","RedirectAfterUpdateEventHandler","RecordAuditLogUseCase"],"mappings":";;;;AAKA,MAAMA;IACF,YAAoBC,cAA+C,CAAE;aAAjDA,cAAc,GAAdA;IAAkD;IAEtE,MAAM,OAAOC,KAA4C,EAAiB;QACtE,IAAI;YACA,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGF,MAAM,OAAO;YAC5C,MAAMG,eAAe,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBACnD,OAAOC,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM;gBAC5C,SAAS;gBACT,SAAS;oBAAE,QAAQF;oBAAU,OAAOD;gBAAS;gBAC7C,UAAUA,SAAS,EAAE;YACzB;YACA,IAAIE,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAEhC,EAAE,OAAOE,OAAO;YACZ,MAAMC,YAAY,IAAI,CAACD,OAAO;gBAC1B,SAAS;gBACT,MAAM;YACV;QACJ;IACJ;AACJ;AAEO,MAAME,kCAAkCC,gCAAgC,oBAAoB,CAC/F;IACI,gBAAgBV;IAChB,cAAc;QAACW;KAAsB;AACzC"}
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { GenericRecord } from "@webiny/api/types.js";
|
|
2
2
|
import type { Action, App, Entity } from "@webiny/common-audit-logs/types.js";
|
|
3
|
-
import type { DbContext } from "@webiny/handler-db/types.js";
|
|
4
|
-
import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
|
|
5
3
|
import type { IAuditLog } from "./storage/types.js";
|
|
6
4
|
import type { IStorageListParams } from "./storage/abstractions/Storage.js";
|
|
7
5
|
export interface AuditLogPayload extends Omit<IAuditLog, "id" | "tenant" | "createdOn" | "createdBy" | "expiresAt" | "content"> {
|
|
@@ -15,27 +13,6 @@ export interface IListAuditLogsResultMeta {
|
|
|
15
13
|
cursor: string | null;
|
|
16
14
|
hasMoreItems: boolean;
|
|
17
15
|
}
|
|
18
|
-
export interface IListAuditLogsSuccessResult {
|
|
19
|
-
items: IAuditLog[];
|
|
20
|
-
meta: IListAuditLogsResultMeta;
|
|
21
|
-
error?: never;
|
|
22
|
-
}
|
|
23
|
-
export interface IListAuditLogsErrorResult {
|
|
24
|
-
items?: never;
|
|
25
|
-
meta?: never;
|
|
26
|
-
error: Error;
|
|
27
|
-
}
|
|
28
|
-
export type IListAuditLogsResult = IListAuditLogsSuccessResult | IListAuditLogsErrorResult;
|
|
29
|
-
export interface AuditLogsContextValue {
|
|
30
|
-
deleteLogsAfterDays: number | undefined;
|
|
31
|
-
createAuditLog(payload: AuditLogPayload): Promise<IAuditLog>;
|
|
32
|
-
updateAuditLog(original: IAuditLog, payload: Partial<AuditLogPayload>): Promise<IAuditLog>;
|
|
33
|
-
getAuditLog(id: string): Promise<IAuditLog | null>;
|
|
34
|
-
listAuditLogs(params: IListAuditLogsParams): Promise<IListAuditLogsResult>;
|
|
35
|
-
}
|
|
36
|
-
export interface AuditLogsContext extends ApiCoreContext, Pick<DbContext, "db"> {
|
|
37
|
-
auditLogs: AuditLogsContextValue;
|
|
38
|
-
}
|
|
39
16
|
export interface AuditObject {
|
|
40
17
|
[app: string]: EntityObject;
|
|
41
18
|
}
|
package/types.js
CHANGED
package/utils/expiresAt.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const convertExpiresAtDaysToDate = (days)=>{
|
|
2
|
+
const date = new Date();
|
|
3
|
+
date.setTime(24 * days * 60 * 60 * 1000 + date.getTime());
|
|
4
|
+
return date;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return Math.floor(expiresAt.getTime() / 1000);
|
|
6
|
+
const convertExpiresAtToUnixTimestamp = (expiresAt)=>{
|
|
7
|
+
if ("string" == typeof expiresAt) expiresAt = new Date(expiresAt);
|
|
8
|
+
return Math.floor(expiresAt.getTime() / 1000);
|
|
11
9
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
return new Date(expiresAt * 1000);
|
|
10
|
+
const convertUnixTimestampToDate = (expiresAt)=>{
|
|
11
|
+
if (!expiresAt) return;
|
|
12
|
+
return new Date(1000 * expiresAt);
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
return convertUnixTimestampToDate(expiresAt)?.toISOString();
|
|
14
|
+
const convertUnixTimestampToISODateString = (expiresAt)=>{
|
|
15
|
+
if (!expiresAt) return;
|
|
16
|
+
return convertUnixTimestampToDate(expiresAt)?.toISOString();
|
|
23
17
|
};
|
|
18
|
+
export { convertExpiresAtDaysToDate, convertExpiresAtToUnixTimestamp, convertUnixTimestampToDate, convertUnixTimestampToISODateString };
|
|
24
19
|
|
|
25
20
|
//# sourceMappingURL=expiresAt.js.map
|
package/utils/expiresAt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/expiresAt.js","sources":["../../src/utils/expiresAt.ts"],"sourcesContent":["export const convertExpiresAtDaysToDate = (days: number): Date => {\n const date = new Date();\n date.setTime(days * 24 * 60 * 60 * 1000 + date.getTime());\n return date;\n};\n\nexport const convertExpiresAtToUnixTimestamp = (expiresAt: Date | string): number => {\n if (typeof expiresAt === \"string\") {\n expiresAt = new Date(expiresAt);\n }\n return Math.floor(expiresAt.getTime() / 1000);\n};\n\nexport const convertUnixTimestampToDate = (\n expiresAt: number | undefined | null\n): Date | undefined => {\n if (!expiresAt) {\n return undefined;\n }\n return new Date(expiresAt * 1000);\n};\n\nexport const convertUnixTimestampToISODateString = (\n expiresAt: number | undefined | null\n): string | undefined => {\n if (!expiresAt) {\n return undefined;\n }\n return convertUnixTimestampToDate(expiresAt)?.toISOString();\n};\n"],"names":["convertExpiresAtDaysToDate","days","date","Date","convertExpiresAtToUnixTimestamp","expiresAt","Math","convertUnixTimestampToDate","convertUnixTimestampToISODateString"],"mappings":"AAAO,MAAMA,6BAA6B,CAACC;IACvC,MAAMC,OAAO,IAAIC;IACjBD,KAAK,OAAO,CAACD,AAAO,KAAPA,OAAY,KAAK,KAAK,OAAOC,KAAK,OAAO;IACtD,OAAOA;AACX;AAEO,MAAME,kCAAkC,CAACC;IAC5C,IAAI,AAAqB,YAArB,OAAOA,WACPA,YAAY,IAAIF,KAAKE;IAEzB,OAAOC,KAAK,KAAK,CAACD,UAAU,OAAO,KAAK;AAC5C;AAEO,MAAME,6BAA6B,CACtCF;IAEA,IAAI,CAACA,WACD;IAEJ,OAAO,IAAIF,KAAKE,AAAY,OAAZA;AACpB;AAEO,MAAMG,sCAAsC,CAC/CH;IAEA,IAAI,CAACA,WACD;IAEJ,OAAOE,2BAA2BF,YAAY;AAClD"}
|
package/utils/getAuditObject.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
const getAuditObject = (apps)=>apps.reduce((result, app)=>{
|
|
2
|
+
result[app.app] = app.entities.reduce((entities, entity)=>{
|
|
3
|
+
entities[entity.type] = entity.actions.reduce((actions, action)=>{
|
|
4
|
+
actions[action.type] = {
|
|
5
|
+
app,
|
|
6
|
+
entity,
|
|
7
|
+
action
|
|
8
|
+
};
|
|
9
|
+
return actions;
|
|
10
|
+
}, {});
|
|
11
|
+
return entities;
|
|
12
|
+
}, {});
|
|
13
|
+
return result;
|
|
13
14
|
}, {});
|
|
14
|
-
|
|
15
|
-
}, {});
|
|
16
|
-
};
|
|
15
|
+
export { getAuditObject };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=getAuditObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/getAuditObject.js","sources":["../../src/utils/getAuditObject.ts"],"sourcesContent":["import type { ActionObject, AuditObject, EntityObject } from \"~/types.js\";\nimport type { App } from \"@webiny/common-audit-logs/types.js\";\n\nexport const getAuditObject = (apps: App[]) => {\n return apps.reduce<AuditObject>((result, app) => {\n result[app.app] = app.entities.reduce<EntityObject>((entities, entity) => {\n entities[entity.type] = entity.actions.reduce<ActionObject>((actions, action) => {\n actions[action.type] = {\n app,\n entity,\n action\n };\n\n return actions;\n }, {});\n\n return entities;\n }, {});\n\n return result;\n }, {});\n};\n"],"names":["getAuditObject","apps","result","app","entities","entity","actions","action"],"mappings":"AAGO,MAAMA,iBAAiB,CAACC,OACpBA,KAAK,MAAM,CAAc,CAACC,QAAQC;QACrCD,MAAM,CAACC,IAAI,GAAG,CAAC,GAAGA,IAAI,QAAQ,CAAC,MAAM,CAAe,CAACC,UAAUC;YAC3DD,QAAQ,CAACC,OAAO,IAAI,CAAC,GAAGA,OAAO,OAAO,CAAC,MAAM,CAAe,CAACC,SAASC;gBAClED,OAAO,CAACC,OAAO,IAAI,CAAC,GAAG;oBACnBJ;oBACAE;oBACAE;gBACJ;gBAEA,OAAOD;YACX,GAAG,CAAC;YAEJ,OAAOF;QACX,GAAG,CAAC;QAEJ,OAAOF;IACX,GAAG,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AuditLogsContext, AuditLogsContextValue } from "../types.js";
|
|
2
|
-
import type { IStorage } from "../storage/abstractions/Storage.js";
|
|
3
|
-
import type { EventPublisher } from "@webiny/api-core/features/EventPublisher";
|
|
4
|
-
export interface IAuditLogsContextValueParams {
|
|
5
|
-
getContext: () => AuditLogsContext;
|
|
6
|
-
deleteLogsAfterDays: number;
|
|
7
|
-
storage: IStorage;
|
|
8
|
-
eventPublisher: EventPublisher.Interface;
|
|
9
|
-
}
|
|
10
|
-
export declare const createAuditLogsContextValue: (params: IAuditLogsContextValueParams) => AuditLogsContextValue;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { convertExpiresAtDaysToDate } from "../utils/expiresAt.js";
|
|
2
|
-
import { mdbid } from "@webiny/utils/mdbid.js";
|
|
3
|
-
import { NotAuthorizedError } from "@webiny/api-core/features/security/shared/index.js";
|
|
4
|
-
import { AuditLogBeforeCreateEvent, AuditLogAfterCreateEvent, AuditLogBeforeUpdateEvent, AuditLogAfterUpdateEvent } from "../events/index.js";
|
|
5
|
-
class AuditLogsContextValueImpl {
|
|
6
|
-
constructor(params) {
|
|
7
|
-
this.getContext = params.getContext;
|
|
8
|
-
this.deleteLogsAfterDays = params.deleteLogsAfterDays;
|
|
9
|
-
this.storage = params.storage;
|
|
10
|
-
this.eventPublisher = params.eventPublisher;
|
|
11
|
-
}
|
|
12
|
-
async createAuditLog(payload) {
|
|
13
|
-
const context = this.getContext();
|
|
14
|
-
const expiresAt = convertExpiresAtDaysToDate(this.deleteLogsAfterDays);
|
|
15
|
-
const auditLog = {
|
|
16
|
-
id: mdbid(),
|
|
17
|
-
tenant: this.getTenantId(),
|
|
18
|
-
createdBy: this.getIdentity(),
|
|
19
|
-
createdOn: new Date(),
|
|
20
|
-
...payload,
|
|
21
|
-
content: JSON.stringify(payload.content),
|
|
22
|
-
expiresAt
|
|
23
|
-
};
|
|
24
|
-
await this.checkPermissions(auditLog);
|
|
25
|
-
const beforeCreateEvent = new AuditLogBeforeCreateEvent({
|
|
26
|
-
auditLog: auditLog,
|
|
27
|
-
context,
|
|
28
|
-
setAuditLog(input) {
|
|
29
|
-
Object.assign(auditLog, input);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
await this.eventPublisher.publish(beforeCreateEvent);
|
|
33
|
-
const result = await this.storage.store({
|
|
34
|
-
data: auditLog
|
|
35
|
-
});
|
|
36
|
-
if (result.success) {
|
|
37
|
-
const afterCreateEvent = new AuditLogAfterCreateEvent({
|
|
38
|
-
auditLog: auditLog,
|
|
39
|
-
context
|
|
40
|
-
});
|
|
41
|
-
await this.eventPublisher.publish(afterCreateEvent);
|
|
42
|
-
return result.data;
|
|
43
|
-
}
|
|
44
|
-
throw result.error;
|
|
45
|
-
}
|
|
46
|
-
async updateAuditLog(original, payload) {
|
|
47
|
-
const context = this.getContext();
|
|
48
|
-
const auditLog = {
|
|
49
|
-
...original,
|
|
50
|
-
...payload,
|
|
51
|
-
content: payload.content ? JSON.stringify(payload.content) : original.content
|
|
52
|
-
};
|
|
53
|
-
await this.checkPermissions(auditLog);
|
|
54
|
-
const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({
|
|
55
|
-
original,
|
|
56
|
-
auditLog,
|
|
57
|
-
context,
|
|
58
|
-
setAuditLog(input) {
|
|
59
|
-
Object.assign(auditLog, input);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
await this.eventPublisher.publish(beforeUpdateEvent);
|
|
63
|
-
const result = await this.storage.store({
|
|
64
|
-
data: auditLog
|
|
65
|
-
});
|
|
66
|
-
if (result.success) {
|
|
67
|
-
const afterUpdateEvent = new AuditLogAfterUpdateEvent({
|
|
68
|
-
original: original,
|
|
69
|
-
auditLog: auditLog,
|
|
70
|
-
context
|
|
71
|
-
});
|
|
72
|
-
await this.eventPublisher.publish(afterUpdateEvent);
|
|
73
|
-
return result.data;
|
|
74
|
-
}
|
|
75
|
-
throw result.error;
|
|
76
|
-
}
|
|
77
|
-
async getAuditLog(id) {
|
|
78
|
-
const result = await this.storage.fetch({
|
|
79
|
-
id,
|
|
80
|
-
tenant: this.getTenantId()
|
|
81
|
-
});
|
|
82
|
-
if (result.success) {
|
|
83
|
-
await this.checkPermissions(result.data);
|
|
84
|
-
return result.data;
|
|
85
|
-
}
|
|
86
|
-
throw result.error;
|
|
87
|
-
}
|
|
88
|
-
async listAuditLogs(params) {
|
|
89
|
-
const result = await this.storage.list({
|
|
90
|
-
...params,
|
|
91
|
-
tenant: this.getTenantId()
|
|
92
|
-
});
|
|
93
|
-
if (result.success) {
|
|
94
|
-
return {
|
|
95
|
-
items: result.data,
|
|
96
|
-
meta: {
|
|
97
|
-
cursor: result.meta.after || null,
|
|
98
|
-
hasMoreItems: result.meta.hasMoreItems
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
throw result.error;
|
|
103
|
-
}
|
|
104
|
-
async checkPermissions(auditLog) {
|
|
105
|
-
if (!auditLog.action) {
|
|
106
|
-
throw new Error("Audit log action is not defined. Cannot check permissions.");
|
|
107
|
-
}
|
|
108
|
-
const permissions = await this.getContext().security.getPermissions("al.*");
|
|
109
|
-
for (const permission of permissions) {
|
|
110
|
-
if (permission.name === "*") {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (permission.name === "al.*") {
|
|
114
|
-
return;
|
|
115
|
-
} else if (permission.name === `al.${auditLog.action}`) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
throw new NotAuthorizedError({
|
|
120
|
-
message: "You cannot access audit logs."
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
getTenantId() {
|
|
124
|
-
return this.getContext().tenancy.getCurrentTenant().id;
|
|
125
|
-
}
|
|
126
|
-
getIdentity() {
|
|
127
|
-
const identity = this.getContext().security.getIdentity();
|
|
128
|
-
return {
|
|
129
|
-
id: identity.id,
|
|
130
|
-
type: identity.type,
|
|
131
|
-
displayName: identity.displayName || "unknown"
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
export const createAuditLogsContextValue = params => {
|
|
136
|
-
return new AuditLogsContextValueImpl(params);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=AuditLogsContextValue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["convertExpiresAtDaysToDate","mdbid","NotAuthorizedError","AuditLogBeforeCreateEvent","AuditLogAfterCreateEvent","AuditLogBeforeUpdateEvent","AuditLogAfterUpdateEvent","AuditLogsContextValueImpl","constructor","params","getContext","deleteLogsAfterDays","storage","eventPublisher","createAuditLog","payload","context","expiresAt","auditLog","id","tenant","getTenantId","createdBy","getIdentity","createdOn","Date","content","JSON","stringify","checkPermissions","beforeCreateEvent","setAuditLog","input","Object","assign","publish","result","store","data","success","afterCreateEvent","error","updateAuditLog","original","beforeUpdateEvent","afterUpdateEvent","getAuditLog","fetch","listAuditLogs","list","items","meta","cursor","after","hasMoreItems","action","Error","permissions","security","getPermissions","permission","name","message","tenancy","getCurrentTenant","identity","type","displayName","createAuditLogsContextValue"],"sources":["AuditLogsContextValue.ts"],"sourcesContent":["import type {\n AuditLogPayload,\n AuditLogsContext,\n AuditLogsContextValue,\n IListAuditLogsParams,\n IListAuditLogsResult\n} from \"~/types.js\";\nimport { convertExpiresAtDaysToDate } from \"~/utils/expiresAt.js\";\nimport type { IAuditLog, IAuditLogCreatedBy } from \"~/storage/types.js\";\nimport { mdbid } from \"@webiny/utils/mdbid.js\";\nimport type { IStorage, IStorageListParams } from \"~/storage/abstractions/Storage.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport type { EventPublisher } from \"@webiny/api-core/features/EventPublisher\";\nimport {\n AuditLogBeforeCreateEvent,\n AuditLogAfterCreateEvent,\n AuditLogBeforeUpdateEvent,\n AuditLogAfterUpdateEvent\n} from \"~/events/index.js\";\n\nexport interface IAuditLogsContextValueParams {\n getContext: () => AuditLogsContext;\n deleteLogsAfterDays: number;\n storage: IStorage;\n eventPublisher: EventPublisher.Interface;\n}\n\nclass AuditLogsContextValueImpl implements AuditLogsContextValue {\n private readonly getContext;\n public readonly deleteLogsAfterDays;\n private readonly storage: IStorage;\n private readonly eventPublisher: EventPublisher.Interface;\n\n public constructor(params: IAuditLogsContextValueParams) {\n this.getContext = params.getContext;\n this.deleteLogsAfterDays = params.deleteLogsAfterDays;\n this.storage = params.storage;\n this.eventPublisher = params.eventPublisher;\n }\n\n public async createAuditLog(payload: AuditLogPayload): Promise<IAuditLog> {\n const context = this.getContext();\n const expiresAt = convertExpiresAtDaysToDate(this.deleteLogsAfterDays);\n\n const auditLog: IAuditLog = {\n id: mdbid(),\n tenant: this.getTenantId(),\n createdBy: this.getIdentity(),\n createdOn: new Date(),\n ...payload,\n content: JSON.stringify(payload.content),\n expiresAt\n };\n await this.checkPermissions(auditLog);\n\n const beforeCreateEvent = new AuditLogBeforeCreateEvent({\n auditLog: auditLog,\n context,\n setAuditLog(input) {\n Object.assign(auditLog, input);\n }\n });\n await this.eventPublisher.publish(beforeCreateEvent);\n\n const result = await this.storage.store({\n data: auditLog\n });\n if (result.success) {\n const afterCreateEvent = new AuditLogAfterCreateEvent({\n auditLog: auditLog,\n context\n });\n await this.eventPublisher.publish(afterCreateEvent);\n return result.data;\n }\n throw result.error;\n }\n\n public async updateAuditLog(\n original: IAuditLog,\n payload: Partial<AuditLogPayload>\n ): Promise<IAuditLog> {\n const context = this.getContext();\n const auditLog: IAuditLog = {\n ...original,\n ...payload,\n content: payload.content ? JSON.stringify(payload.content) : original.content\n };\n await this.checkPermissions(auditLog);\n\n const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({\n original,\n auditLog,\n context,\n setAuditLog(input) {\n Object.assign(auditLog, input);\n }\n });\n await this.eventPublisher.publish(beforeUpdateEvent);\n\n const result = await this.storage.store({\n data: auditLog\n });\n if (result.success) {\n const afterUpdateEvent = new AuditLogAfterUpdateEvent({\n original: original,\n auditLog: auditLog,\n context\n });\n await this.eventPublisher.publish(afterUpdateEvent);\n return result.data;\n }\n throw result.error;\n }\n\n public async getAuditLog(id: string): Promise<IAuditLog | null> {\n const result = await this.storage.fetch({\n id,\n tenant: this.getTenantId()\n });\n if (result.success) {\n await this.checkPermissions(result.data);\n return result.data;\n }\n throw result.error;\n }\n\n public async listAuditLogs(params: IListAuditLogsParams): Promise<IListAuditLogsResult> {\n const result = await this.storage.list({\n ...params,\n tenant: this.getTenantId()\n } as unknown as IStorageListParams);\n if (result.success) {\n return {\n items: result.data,\n meta: {\n cursor: result.meta.after || null,\n hasMoreItems: result.meta.hasMoreItems\n }\n };\n }\n throw result.error;\n }\n\n private async checkPermissions(auditLog: Pick<IAuditLog, \"action\">): Promise<void> {\n if (!auditLog.action) {\n throw new Error(\"Audit log action is not defined. Cannot check permissions.\");\n }\n const permissions = await this.getContext().security.getPermissions(\"al.*\");\n for (const permission of permissions) {\n if (permission.name === \"*\") {\n return;\n }\n if (permission.name === \"al.*\") {\n return;\n } else if (permission.name === `al.${auditLog.action}`) {\n return;\n }\n }\n\n throw new NotAuthorizedError({\n message: \"You cannot access audit logs.\"\n });\n }\n\n private getTenantId(): string {\n return this.getContext().tenancy.getCurrentTenant().id;\n }\n\n private getIdentity(): IAuditLogCreatedBy {\n const identity = this.getContext().security.getIdentity();\n return {\n id: identity.id,\n type: identity.type,\n displayName: identity.displayName || \"unknown\"\n };\n }\n}\n\nexport const createAuditLogsContextValue = (\n params: IAuditLogsContextValueParams\n): AuditLogsContextValue => {\n return new AuditLogsContextValueImpl(params);\n};\n"],"mappings":"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","ignoreList":[]}
|
package/context/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
|
-
import type { AuditLogsContext } from "../types.js";
|
|
4
|
-
export interface ISetupContextOptions {
|
|
5
|
-
deleteLogsAfterDays: number | undefined;
|
|
6
|
-
tableName: string | undefined;
|
|
7
|
-
documentClient: DynamoDBDocument | undefined;
|
|
8
|
-
}
|
|
9
|
-
export declare const createAuditLogsContext: (params?: ISetupContextOptions) => ContextPlugin<AuditLogsContext>;
|