Merge pull request #8717 from Budibase/fix/backup-event
App backup triggered event
This commit is contained in:
commit
b60befdd61
3 changed files with 34 additions and 3 deletions
|
@ -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"
|
import { publishEvent } from "../events"
|
||||||
|
|
||||||
export async function appBackupRestored(backup: AppBackup) {
|
export async function appBackupRestored(backup: AppBackup) {
|
||||||
const properties: AppBackupRestoreEvent = {
|
const properties: AppBackupRestoreEvent = {
|
||||||
appId: backup.appId,
|
appId: backup.appId,
|
||||||
backupName: backup.name!,
|
restoreId: backup._id!,
|
||||||
backupCreatedAt: backup.timestamp,
|
backupCreatedAt: backup.timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
await publishEvent(Event.APP_BACKUP_RESTORED, properties)
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
import { BaseEvent } from "./event"
|
import { BaseEvent } from "./event"
|
||||||
|
import { AppBackupTrigger, AppBackupType } from "../../documents"
|
||||||
|
|
||||||
export interface AppBackupRestoreEvent extends BaseEvent {
|
export interface AppBackupRestoreEvent extends BaseEvent {
|
||||||
appId: string
|
appId: string
|
||||||
backupName: string
|
restoreId: string
|
||||||
backupCreatedAt: string
|
backupCreatedAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AppBackupTriggeredEvent extends BaseEvent {
|
||||||
|
backupId: string
|
||||||
|
appId: string
|
||||||
|
trigger: AppBackupTrigger
|
||||||
|
type: AppBackupType
|
||||||
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@ export enum Event {
|
||||||
|
|
||||||
// BACKUP
|
// BACKUP
|
||||||
APP_BACKUP_RESTORED = "app:backup:restored",
|
APP_BACKUP_RESTORED = "app:backup:restored",
|
||||||
|
APP_BACKUP_TRIGGERED = "app:backup:triggered",
|
||||||
}
|
}
|
||||||
|
|
||||||
// properties added at the final stage of the event pipeline
|
// properties added at the final stage of the event pipeline
|
||||||
|
|
Loading…
Reference in a new issue