@webiny/api-audit-logs 6.6.0-alpha.1 → 6.6.0-alpha.10
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.js +17 -27
- package/AuditLogsFeature.js.map +1 -1
- package/abstractions.d.ts +9 -4
- package/abstractions.js +2 -2
- package/abstractions.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/abstractions.d.ts +0 -5
- package/events/abstractions.js.map +1 -1
- 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 +1 -0
- package/graphql/AuditLogsGraphQLSchema.js +18 -13
- package/graphql/AuditLogsGraphQLSchema.js.map +1 -1
- package/graphql/validation.d.ts +3 -3
- package/package.json +25 -24
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.d.ts +3 -3
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js +18 -9
- package/subscriptions/aco/handlers/AuditLogFolderAfterCreateHandler.js.map +1 -1
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js +35 -13
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js.map +1 -1
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js +24 -15
- package/subscriptions/aco/handlers/AuditLogFolderAfterUpdateHandler.js.map +1 -1
- package/subscriptions/aco/index.d.ts +2 -2
- package/subscriptions/aco/index.js +4 -4
- package/subscriptions/aco/index.js.map +1 -1
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.d.ts +3 -3
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js +21 -17
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js.map +1 -1
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.d.ts +3 -3
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js +18 -14
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js.map +1 -1
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.d.ts +3 -3
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js +19 -15
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js.map +1 -1
- package/subscriptions/ai/index.d.ts +2 -2
- package/subscriptions/ai/index.js +4 -4
- package/subscriptions/ai/index.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js +11 -7
- package/subscriptions/fileManager/handlers/AuditLogFileAfterCreateHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js +11 -7
- package/subscriptions/fileManager/handlers/AuditLogFileAfterDeleteHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js +14 -10
- package/subscriptions/fileManager/handlers/AuditLogFileAfterUpdateHandler.js.map +1 -1
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js +14 -10
- package/subscriptions/fileManager/handlers/AuditLogSettingsAfterUpdateHandler.js.map +1 -1
- package/subscriptions/fileManager/index.d.ts +2 -2
- package/subscriptions/fileManager/index.js +5 -5
- package/subscriptions/fileManager/index.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js +18 -9
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterPublishEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterRestoreFromBinEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUnpublishEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js +14 -10
- package/subscriptions/headlessCms/handlers/AuditLogEntryAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogEntryRevisionAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js +14 -10
- package/subscriptions/headlessCms/handlers/AuditLogGroupAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterCreateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js +11 -7
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterDeleteEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.d.ts +3 -3
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js +14 -10
- package/subscriptions/headlessCms/handlers/AuditLogModelAfterUpdateEventHandler.js.map +1 -1
- package/subscriptions/headlessCms/index.d.ts +2 -2
- package/subscriptions/headlessCms/index.js +15 -15
- package/subscriptions/headlessCms/index.js.map +1 -1
- package/subscriptions/index.d.ts +2 -2
- package/subscriptions/index.js +8 -8
- package/subscriptions/index.js.map +1 -1
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.d.ts +3 -3
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js +13 -9
- package/subscriptions/mailer/handlers/AuditLogMailerSettingsAfterSaveHandler.js.map +1 -1
- package/subscriptions/mailer/index.d.ts +2 -2
- package/subscriptions/mailer/index.js +2 -2
- package/subscriptions/mailer/index.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogApiKeyAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogApiKeyAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js +14 -10
- package/subscriptions/security/handlers/AuditLogApiKeyAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogRoleAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogRoleAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js +14 -10
- package/subscriptions/security/handlers/AuditLogRoleAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogTeamAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogTeamAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js +14 -10
- package/subscriptions/security/handlers/AuditLogTeamAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogUserAfterCreateHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js +11 -7
- package/subscriptions/security/handlers/AuditLogUserAfterDeleteHandler.js.map +1 -1
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js +14 -10
- package/subscriptions/security/handlers/AuditLogUserAfterUpdateHandler.js.map +1 -1
- package/subscriptions/security/index.d.ts +2 -2
- package/subscriptions/security/index.js +13 -13
- 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 +15 -13
- package/subscriptions/websiteBuilder/index.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js +11 -7
- package/subscriptions/websiteBuilder/pages/PageAfterCreateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js +11 -7
- package/subscriptions/websiteBuilder/pages/PageAfterCreateRevisionFromHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js +11 -7
- package/subscriptions/websiteBuilder/pages/PageAfterDeleteHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js +14 -10
- package/subscriptions/websiteBuilder/pages/PageAfterDuplicateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js +11 -7
- package/subscriptions/websiteBuilder/pages/PageAfterMoveHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js +11 -7
- package/subscriptions/websiteBuilder/pages/PageAfterPublishHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js +11 -7
- package/subscriptions/websiteBuilder/pages/PageAfterUnpublishHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js +14 -10
- package/subscriptions/websiteBuilder/pages/PageAfterUpdateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js +11 -7
- package/subscriptions/websiteBuilder/redirects/RedirectAfterCreateHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js +11 -7
- package/subscriptions/websiteBuilder/redirects/RedirectAfterDeleteHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js +11 -7
- package/subscriptions/websiteBuilder/redirects/RedirectAfterMoveHandler.js.map +1 -1
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.d.ts +3 -3
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js +14 -10
- package/subscriptions/websiteBuilder/redirects/RedirectAfterUpdateHandler.js.map +1 -1
- package/types.d.ts +0 -22
- package/context/AuditLogsContextValue.d.ts +0 -10
- package/context/AuditLogsContextValue.js +0 -131
- package/context/AuditLogsContextValue.js.map +0 -1
- package/utils/getAuditConfig.d.ts +0 -4
- package/utils/getAuditConfig.js +0 -88
- package/utils/getAuditConfig.js.map +0 -1
|
@@ -1,131 +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 { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
5
|
-
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
6
|
-
import { AuditLogAfterCreateEvent, AuditLogAfterUpdateEvent, AuditLogBeforeCreateEvent, AuditLogBeforeUpdateEvent } from "../events/index.js";
|
|
7
|
-
class AuditLogsContextValueImpl {
|
|
8
|
-
constructor(params){
|
|
9
|
-
this.getContext = params.getContext;
|
|
10
|
-
this.deleteLogsAfterDays = params.deleteLogsAfterDays;
|
|
11
|
-
this.storage = params.storage;
|
|
12
|
-
this.eventPublisher = params.eventPublisher;
|
|
13
|
-
}
|
|
14
|
-
async createAuditLog(payload) {
|
|
15
|
-
const context = this.getContext();
|
|
16
|
-
const expiresAt = convertExpiresAtDaysToDate(this.deleteLogsAfterDays);
|
|
17
|
-
const auditLog = {
|
|
18
|
-
id: mdbid(),
|
|
19
|
-
tenant: this.getTenantId(),
|
|
20
|
-
createdBy: this.getIdentity(),
|
|
21
|
-
createdOn: new Date(),
|
|
22
|
-
...payload,
|
|
23
|
-
content: JSON.stringify(payload.content),
|
|
24
|
-
expiresAt
|
|
25
|
-
};
|
|
26
|
-
await this.checkPermissions(auditLog);
|
|
27
|
-
const beforeCreateEvent = new AuditLogBeforeCreateEvent({
|
|
28
|
-
auditLog: auditLog,
|
|
29
|
-
context,
|
|
30
|
-
setAuditLog (input) {
|
|
31
|
-
Object.assign(auditLog, input);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
await this.eventPublisher.publish(beforeCreateEvent);
|
|
35
|
-
const result = await this.storage.store({
|
|
36
|
-
data: auditLog
|
|
37
|
-
});
|
|
38
|
-
if (result.success) {
|
|
39
|
-
const afterCreateEvent = new AuditLogAfterCreateEvent({
|
|
40
|
-
auditLog: auditLog,
|
|
41
|
-
context
|
|
42
|
-
});
|
|
43
|
-
await this.eventPublisher.publish(afterCreateEvent);
|
|
44
|
-
return result.data;
|
|
45
|
-
}
|
|
46
|
-
throw result.error;
|
|
47
|
-
}
|
|
48
|
-
async updateAuditLog(original, payload) {
|
|
49
|
-
const context = this.getContext();
|
|
50
|
-
const auditLog = {
|
|
51
|
-
...original,
|
|
52
|
-
...payload,
|
|
53
|
-
content: payload.content ? JSON.stringify(payload.content) : original.content
|
|
54
|
-
};
|
|
55
|
-
await this.checkPermissions(auditLog);
|
|
56
|
-
const beforeUpdateEvent = new AuditLogBeforeUpdateEvent({
|
|
57
|
-
original,
|
|
58
|
-
auditLog,
|
|
59
|
-
context,
|
|
60
|
-
setAuditLog (input) {
|
|
61
|
-
Object.assign(auditLog, input);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
await this.eventPublisher.publish(beforeUpdateEvent);
|
|
65
|
-
const result = await this.storage.store({
|
|
66
|
-
data: auditLog
|
|
67
|
-
});
|
|
68
|
-
if (result.success) {
|
|
69
|
-
const afterUpdateEvent = new AuditLogAfterUpdateEvent({
|
|
70
|
-
original: original,
|
|
71
|
-
auditLog: auditLog,
|
|
72
|
-
context
|
|
73
|
-
});
|
|
74
|
-
await this.eventPublisher.publish(afterUpdateEvent);
|
|
75
|
-
return result.data;
|
|
76
|
-
}
|
|
77
|
-
throw result.error;
|
|
78
|
-
}
|
|
79
|
-
async getAuditLog(id) {
|
|
80
|
-
const result = await this.storage.fetch({
|
|
81
|
-
id,
|
|
82
|
-
tenant: this.getTenantId()
|
|
83
|
-
});
|
|
84
|
-
if (result.success) {
|
|
85
|
-
await this.checkPermissions(result.data);
|
|
86
|
-
return result.data;
|
|
87
|
-
}
|
|
88
|
-
throw result.error;
|
|
89
|
-
}
|
|
90
|
-
async listAuditLogs(params) {
|
|
91
|
-
const result = await this.storage.list({
|
|
92
|
-
...params,
|
|
93
|
-
tenant: this.getTenantId()
|
|
94
|
-
});
|
|
95
|
-
if (result.success) return {
|
|
96
|
-
items: result.data,
|
|
97
|
-
meta: {
|
|
98
|
-
cursor: result.meta.after || null,
|
|
99
|
-
hasMoreItems: result.meta.hasMoreItems
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
throw result.error;
|
|
103
|
-
}
|
|
104
|
-
async checkPermissions(auditLog) {
|
|
105
|
-
if (!auditLog.action) throw new Error("Audit log action is not defined. Cannot check permissions.");
|
|
106
|
-
const permissions = await this.getContext().container.resolve(IdentityContext).getPermissions("al.*");
|
|
107
|
-
for (const permission of permissions){
|
|
108
|
-
if ("*" === permission.name) return;
|
|
109
|
-
if ("al.*" === permission.name) return;
|
|
110
|
-
if (permission.name === `al.${auditLog.action}`) return;
|
|
111
|
-
}
|
|
112
|
-
throw new NotAuthorizedError({
|
|
113
|
-
message: "You cannot access audit logs."
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
getTenantId() {
|
|
117
|
-
return this.getContext().container.resolve(TenantContext).getTenant().id;
|
|
118
|
-
}
|
|
119
|
-
getIdentity() {
|
|
120
|
-
const identity = this.getContext().container.resolve(IdentityContext).getIdentity();
|
|
121
|
-
return {
|
|
122
|
-
id: identity.id,
|
|
123
|
-
type: identity.type,
|
|
124
|
-
displayName: identity.displayName || "unknown"
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const createAuditLogsContextValue = (params)=>new AuditLogsContextValueImpl(params);
|
|
129
|
-
export { createAuditLogsContextValue };
|
|
130
|
-
|
|
131
|
-
//# sourceMappingURL=AuditLogsContextValue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context/AuditLogsContextValue.js","sources":["../../src/context/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 { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport type { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\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()\n .container.resolve(IdentityContext)\n .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().container.resolve(TenantContext).getTenant().id;\n }\n\n private getIdentity(): IAuditLogCreatedBy {\n const identity = this.getContext().container.resolve(IdentityContext).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"],"names":["AuditLogsContextValueImpl","params","payload","context","expiresAt","convertExpiresAtDaysToDate","auditLog","mdbid","Date","JSON","beforeCreateEvent","AuditLogBeforeCreateEvent","input","Object","result","afterCreateEvent","AuditLogAfterCreateEvent","original","beforeUpdateEvent","AuditLogBeforeUpdateEvent","afterUpdateEvent","AuditLogAfterUpdateEvent","id","Error","permissions","IdentityContext","permission","NotAuthorizedError","TenantContext","identity","createAuditLogsContextValue"],"mappings":";;;;;;AA6BA,MAAMA;IAMF,YAAmBC,MAAoC,CAAE;QACrD,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU;QACnC,IAAI,CAAC,mBAAmB,GAAGA,OAAO,mBAAmB;QACrD,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,cAAc,GAAGA,OAAO,cAAc;IAC/C;IAEA,MAAa,eAAeC,OAAwB,EAAsB;QACtE,MAAMC,UAAU,IAAI,CAAC,UAAU;QAC/B,MAAMC,YAAYC,2BAA2B,IAAI,CAAC,mBAAmB;QAErE,MAAMC,WAAsB;YACxB,IAAIC;YACJ,QAAQ,IAAI,CAAC,WAAW;YACxB,WAAW,IAAI,CAAC,WAAW;YAC3B,WAAW,IAAIC;YACf,GAAGN,OAAO;YACV,SAASO,KAAK,SAAS,CAACP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WAAW,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,OAAO,CAACJ,iBAAiB,WAAW;QACjF,OAAO;YACH,IAAII,SAAS,EAAE;YACf,MAAMA,SAAS,IAAI;YACnB,aAAaA,SAAS,WAAW,IAAI;QACzC;IACJ;AACJ;AAEO,MAAMC,8BAA8B,CACvC7B,SAEO,IAAID,0BAA0BC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AuditAction, AuditLogsContext } from "../types.js";
|
|
2
|
-
import type { IAuditLog } from "../storage/types.js";
|
|
3
|
-
import type { GenericRecord } from "@webiny/api/types.js";
|
|
4
|
-
export declare const getAuditConfig: (audit: AuditAction) => (message: string, content: GenericRecord, entityId: string, context: AuditLogsContext) => Promise<IAuditLog | null>;
|
package/utils/getAuditConfig.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import _webiny_error from "@webiny/error";
|
|
2
|
-
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
|
|
3
|
-
const createAuditLog = async (params)=>{
|
|
4
|
-
const { context, payload } = params;
|
|
5
|
-
try {
|
|
6
|
-
return await context.auditLogs.createAuditLog(payload);
|
|
7
|
-
} catch (error) {
|
|
8
|
-
throw _webiny_error.from(error);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
const createAuditLogDelayDate = (delay)=>{
|
|
12
|
-
if (!delay) return;
|
|
13
|
-
const date = new Date();
|
|
14
|
-
date.setTime(date.getTime() - 1000 * delay);
|
|
15
|
-
return date;
|
|
16
|
-
};
|
|
17
|
-
const createOrMergeAuditLog = async (params)=>{
|
|
18
|
-
const { context, payload, delay } = params;
|
|
19
|
-
const results = await context.auditLogs.listAuditLogs({
|
|
20
|
-
app: payload.app,
|
|
21
|
-
entityId: payload.entityId,
|
|
22
|
-
limit: 1,
|
|
23
|
-
createdOn_gte: createAuditLogDelayDate(delay),
|
|
24
|
-
sort: "DESC"
|
|
25
|
-
});
|
|
26
|
-
if (results.error) throw _webiny_error.from(results.error);
|
|
27
|
-
const original = results.items?.[0];
|
|
28
|
-
if (!original) return createAuditLog(params);
|
|
29
|
-
const beforePayloadData = original.content ? JSON.parse(original.content)?.before : void 0;
|
|
30
|
-
const afterPayloadData = payload.content?.after;
|
|
31
|
-
const updatedPayloadData = beforePayloadData ? {
|
|
32
|
-
before: beforePayloadData,
|
|
33
|
-
after: afterPayloadData
|
|
34
|
-
} : payload.content;
|
|
35
|
-
try {
|
|
36
|
-
return await context.auditLogs.updateAuditLog(original, {
|
|
37
|
-
...payload,
|
|
38
|
-
content: updatedPayloadData
|
|
39
|
-
});
|
|
40
|
-
} catch (ex) {
|
|
41
|
-
throw _webiny_error.from(ex);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const getAuditConfig = (audit)=>async (message, content, entityId, context)=>{
|
|
45
|
-
if (context.auditLogs) {
|
|
46
|
-
if (!audit) {
|
|
47
|
-
console.log("No Audit Action defined!");
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
console.log("No AuditLogs defined.");
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const payload = {
|
|
55
|
-
message,
|
|
56
|
-
app: audit.app.app,
|
|
57
|
-
entityId,
|
|
58
|
-
entity: audit.entity.type,
|
|
59
|
-
action: audit.action.type,
|
|
60
|
-
content,
|
|
61
|
-
tags: []
|
|
62
|
-
};
|
|
63
|
-
const delay = audit.action.newEntryDelay || 0;
|
|
64
|
-
const identityContext = context.container.resolve(IdentityContext);
|
|
65
|
-
if (!identityContext.getIdentity()?.id) {
|
|
66
|
-
console.log("No identity - skipping audit log creation.");
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return await identityContext.withoutAuthorization(async ()=>{
|
|
70
|
-
if (delay > 0) {
|
|
71
|
-
try {
|
|
72
|
-
return await createOrMergeAuditLog({
|
|
73
|
-
context,
|
|
74
|
-
payload,
|
|
75
|
-
delay
|
|
76
|
-
});
|
|
77
|
-
} catch {}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
return await createAuditLog({
|
|
81
|
-
context,
|
|
82
|
-
payload
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
export { getAuditConfig };
|
|
87
|
-
|
|
88
|
-
//# sourceMappingURL=getAuditConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils/getAuditConfig.js","sources":["../../src/utils/getAuditConfig.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type { AuditAction, AuditLogPayload, AuditLogsContext } from \"~/types.js\";\nimport type { IAuditLog } from \"~/storage/types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\ninterface CreateAuditLogParams {\n context: Pick<AuditLogsContext, \"auditLogs\">;\n payload: AuditLogPayload;\n}\n\nconst createAuditLog = async (params: CreateAuditLogParams): Promise<IAuditLog> => {\n const { context, payload } = params;\n\n try {\n return await context.auditLogs.createAuditLog(payload);\n } catch (error) {\n throw WebinyError.from(error);\n }\n};\n\ninterface CreateOrMergeAuditLogParams {\n context: AuditLogsContext;\n payload: AuditLogPayload;\n delay: number;\n}\n\nconst createAuditLogDelayDate = (delay: number | undefined) => {\n if (!delay) {\n return undefined;\n }\n const date = new Date();\n date.setTime(date.getTime() - delay * 1000);\n return date;\n};\n\nconst createOrMergeAuditLog = async (params: CreateOrMergeAuditLogParams): Promise<IAuditLog> => {\n const { context, payload, delay } = params;\n\n const results = await context.auditLogs.listAuditLogs({\n app: payload.app,\n entityId: payload.entityId,\n limit: 1,\n createdOn_gte: createAuditLogDelayDate(delay),\n sort: \"DESC\"\n });\n if (results.error) {\n throw WebinyError.from(results.error);\n }\n const original = results.items?.[0];\n if (!original) {\n return createAuditLog(params);\n }\n // Update latest audit log with new \"after\" payload.\n const beforePayloadData = original.content ? JSON.parse(original.content)?.before : undefined;\n /**\n * We can assume that there is a possible \"after\" in the payload data.\n */\n const afterPayloadData = payload.content?.after;\n const updatedPayloadData = beforePayloadData\n ? {\n before: beforePayloadData,\n after: afterPayloadData\n }\n : payload.content;\n\n try {\n return await context.auditLogs.updateAuditLog(original, {\n ...payload,\n content: updatedPayloadData\n });\n } catch (ex) {\n throw WebinyError.from(ex);\n }\n};\n\nexport const getAuditConfig = (audit: AuditAction) => {\n return async (\n message: string,\n content: GenericRecord,\n entityId: string,\n context: AuditLogsContext\n ): Promise<IAuditLog | null> => {\n if (!context.auditLogs) {\n console.log(\"No AuditLogs defined.\");\n return null;\n } else if (!audit) {\n console.log(`No Audit Action defined!`);\n return 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 const identityContext = context.container.resolve(IdentityContext);\n if (!identityContext.getIdentity()?.id) {\n console.log(\"No identity - skipping audit log creation.\");\n return null;\n }\n\n return await identityContext.withoutAuthorization(async () => {\n // Check if there is delay on audit log creation for this action.\n if (delay > 0) {\n try {\n return await createOrMergeAuditLog({\n context,\n payload,\n delay\n });\n } catch {\n // Don't care at this point!\n }\n return null;\n }\n return await createAuditLog({\n context,\n payload\n });\n });\n };\n};\n"],"names":["createAuditLog","params","context","payload","error","WebinyError","createAuditLogDelayDate","delay","date","Date","createOrMergeAuditLog","results","original","beforePayloadData","JSON","undefined","afterPayloadData","updatedPayloadData","ex","getAuditConfig","audit","message","content","entityId","console","identityContext","IdentityContext"],"mappings":";;AAWA,MAAMA,iBAAiB,OAAOC;IAC1B,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;IAE7B,IAAI;QACA,OAAO,MAAMC,QAAQ,SAAS,CAAC,cAAc,CAACC;IAClD,EAAE,OAAOC,OAAO;QACZ,MAAMC,cAAAA,IAAgB,CAACD;IAC3B;AACJ;AAQA,MAAME,0BAA0B,CAACC;I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