diff --git a/packages/builder/src/stores/portal/backups.js b/packages/builder/src/stores/portal/backups.js deleted file mode 100644 index 7bd98c78ea..0000000000 --- a/packages/builder/src/stores/portal/backups.js +++ /dev/null @@ -1,40 +0,0 @@ -import { writable } from "svelte/store" -import { API } from "@/api" - -export function createBackupsStore() { - const store = writable({}) - - function selectBackup(backupId) { - store.update(state => { - state.selectedBackup = backupId - return state - }) - } - - async function searchBackups(appId, opts) { - return API.searchBackups(appId, opts) - } - - async function restoreBackup(appId, backupId, name) { - return API.restoreBackup(appId, backupId, name) - } - - async function deleteBackup(appId, backupId) { - return API.deleteBackup(appId, backupId) - } - - async function createManualBackup(appId) { - return API.createManualBackup(appId) - } - - return { - createManualBackup, - searchBackups, - selectBackup, - deleteBackup, - restoreBackup, - subscribe: store.subscribe, - } -} - -export const backups = createBackupsStore() diff --git a/packages/builder/src/stores/portal/backups.ts b/packages/builder/src/stores/portal/backups.ts new file mode 100644 index 0000000000..59b0754c71 --- /dev/null +++ b/packages/builder/src/stores/portal/backups.ts @@ -0,0 +1,38 @@ +import { API } from "@/api" +import { BudiStore } from "../BudiStore" +import { SearchAppBackupsRequest } from "@budibase/types" + +interface BackupState { + selectedBackup?: string +} + +class BackupStore extends BudiStore { + constructor() { + super({}) + } + + selectBackup(backupId: string) { + this.update(state => { + state.selectedBackup = backupId + return state + }) + } + + async searchBackups(appId: string, opts: SearchAppBackupsRequest) { + return API.searchBackups(appId, opts) + } + + async restoreBackup(appId: string, backupId: string, name?: string) { + return API.restoreBackup(appId, backupId, name) + } + + async deleteBackup(appId: string, backupId: string) { + return API.deleteBackup(appId, backupId) + } + + async createManualBackup(appId: string) { + return API.createManualBackup(appId) + } +} + +export const backups = new BackupStore()