diff --git a/packages/backend-core/src/events/publishers/backup.ts b/packages/backend-core/src/events/publishers/backup.ts new file mode 100644 index 0000000000..00b4f8db69 --- /dev/null +++ b/packages/backend-core/src/events/publishers/backup.ts @@ -0,0 +1,12 @@ +import { AppBackup, AppBackupRevertEvent, Event } from "@budibase/types" +import { publishEvent } from "../events" + +export async function appBackupRestored(backup: AppBackup) { + const properties: AppBackupRevertEvent = { + appId: backup.appId, + backupName: backup.name, + backupCreatedAt: backup.createdAt, + } + + await publishEvent(Event.APP_BACKUP_RESTORED, properties) +} diff --git a/packages/backend-core/src/events/publishers/index.ts b/packages/backend-core/src/events/publishers/index.ts index 6fe42c4bda..7306312a8f 100644 --- a/packages/backend-core/src/events/publishers/index.ts +++ b/packages/backend-core/src/events/publishers/index.ts @@ -19,3 +19,4 @@ export * as installation from "./installation" export * as backfill from "./backfill" export * as group from "./group" export * as plugin from "./plugin" +export * as backup from "./backup" diff --git a/packages/types/src/sdk/events/backup.ts b/packages/types/src/sdk/events/backup.ts new file mode 100644 index 0000000000..f3ddafcafc --- /dev/null +++ b/packages/types/src/sdk/events/backup.ts @@ -0,0 +1,7 @@ +import { BaseEvent } from "./event" + +export interface AppBackupRevertEvent extends BaseEvent { + appId: string + backupName: string + backupCreatedAt: string +} diff --git a/packages/types/src/sdk/events/event.ts b/packages/types/src/sdk/events/event.ts index 73e5315713..71caf2bf96 100644 --- a/packages/types/src/sdk/events/event.ts +++ b/packages/types/src/sdk/events/event.ts @@ -168,6 +168,9 @@ export enum Event { PLUGIN_INIT = "plugin:init", PLUGIN_IMPORTED = "plugin:imported", PLUGIN_DELETED = "plugin:deleted", + + // BACKUP + APP_BACKUP_RESTORED = "app:backup:restored", } // properties added at the final stage of the event pipeline diff --git a/packages/types/src/sdk/events/index.ts b/packages/types/src/sdk/events/index.ts index cc0c2b9aa1..5abc30f5b9 100644 --- a/packages/types/src/sdk/events/index.ts +++ b/packages/types/src/sdk/events/index.ts @@ -20,3 +20,4 @@ export * from "./backfill" export * from "./identification" export * from "./userGroup" export * from "./plugin" +export * from "./backup"