1
0
Fork 0
mirror of synced 2024-05-17 19:04:06 +12:00

Adding an event for when a backup is triggered.

This commit is contained in:
mike12345567 2022-11-17 17:15:35 +00:00
parent 8cd36e25a8
commit 575a64d32a
3 changed files with 22 additions and 1 deletions

View file

@ -1,4 +1,9 @@
import { AppBackup, AppBackupRestoreEvent, Event } from "@budibase/types"
import {
AppBackup,
AppBackupRestoreEvent,
AppBackupTriggeredEvent,
Event,
} from "@budibase/types"
import { publishEvent } from "../events"
export async function appBackupRestored(backup: AppBackup) {
@ -10,3 +15,12 @@ export async function appBackupRestored(backup: AppBackup) {
await publishEvent(Event.APP_BACKUP_RESTORED, properties)
}
export async function appBackupTriggered(appId: string, name?: string) {
const properties: AppBackupTriggeredEvent = {
appId: appId,
backupName: name,
backupCreatedAt: new Date().toISOString(),
}
await publishEvent(Event.APP_BACKUP_TRIGGERED, properties)
}

View file

@ -5,3 +5,9 @@ export interface AppBackupRestoreEvent extends BaseEvent {
backupName: string
backupCreatedAt: string
}
export interface AppBackupTriggeredEvent extends BaseEvent {
appId: string
backupName?: string
backupCreatedAt: string
}

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