Merge pull request #8717 from Budibase/fix/backup-event

App backup triggered event
This commit is contained in:
Michael Drury 2022-11-21 12:43:35 +00:00 committed by GitHub
commit 3b7a68aa50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 3 deletions

View File

@ -1,12 +1,34 @@
import { AppBackup, AppBackupRestoreEvent, Event } from "@budibase/types"
import {
AppBackup,
AppBackupRestoreEvent,
AppBackupTriggeredEvent,
AppBackupTrigger,
AppBackupType,
Event,
} from "@budibase/types"
import { publishEvent } from "../events"
export async function appBackupRestored(backup: AppBackup) {
const properties: AppBackupRestoreEvent = {
appId: backup.appId,
backupName: backup.name!,
restoreId: backup._id!,
backupCreatedAt: backup.timestamp,
}
await publishEvent(Event.APP_BACKUP_RESTORED, properties)
}
export async function appBackupTriggered(
appId: string,
backupId: string,
type: AppBackupType,
trigger: AppBackupTrigger
) {
const properties: AppBackupTriggeredEvent = {
appId: appId,
backupId,
type,
trigger,
}
await publishEvent(Event.APP_BACKUP_TRIGGERED, properties)
}

View File

@ -1,7 +1,15 @@
import { BaseEvent } from "./event"
import { AppBackupTrigger, AppBackupType } from "../../documents"
export interface AppBackupRestoreEvent extends BaseEvent {
appId: string
backupName: string
restoreId: string
backupCreatedAt: string
}
export interface AppBackupTriggeredEvent extends BaseEvent {
backupId: string
appId: string
trigger: AppBackupTrigger
type: AppBackupType
}

View File

@ -171,6 +171,7 @@ export enum Event {
// BACKUP
APP_BACKUP_RESTORED = "app:backup:restored",
APP_BACKUP_TRIGGERED = "app:backup:triggered",
}
// properties added at the final stage of the event pipeline