Update backups store to TS£

This commit is contained in:
Andrew Kingston 2025-01-02 11:01:54 +00:00
parent 5088979b18
commit c21581f4cc
No known key found for this signature in database
2 changed files with 38 additions and 40 deletions

View File

@ -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()

View File

@ -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<BackupState> {
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()