Reformatting types to allow queue to be used for import and export.
This commit is contained in:
parent
8003f8b283
commit
f795cb0e33
|
@ -5,8 +5,9 @@ import { Job } from "bull"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import env from "../../../environment"
|
import env from "../../../environment"
|
||||||
|
|
||||||
export async function init() {
|
async function importProcessor(job: Job) {}
|
||||||
await backups.addAppBackupProcessor(async (job: Job) => {
|
|
||||||
|
async function exportProcessor(job: Job) {
|
||||||
const appId = job.data.appId,
|
const appId = job.data.appId,
|
||||||
trigger = job.data.trigger,
|
trigger = job.data.trigger,
|
||||||
name = job.data.name
|
name = job.data.name
|
||||||
|
@ -37,5 +38,8 @@ export async function init() {
|
||||||
// clear up the tarball after uploading it
|
// clear up the tarball after uploading it
|
||||||
fs.rmSync(tarPath)
|
fs.rmSync(tarPath)
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
|
export async function init() {
|
||||||
|
await backups.addAppBackupProcessors(importProcessor, exportProcessor)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { db as dbCore } from "@budibase/backend-core"
|
import { db as dbCore } from "@budibase/backend-core"
|
||||||
import { APP_PREFIX, TABLE_ROW_PREFIX } from "../../../db/utils"
|
import { TABLE_ROW_PREFIX } from "../../../db/utils"
|
||||||
import { budibaseTempDir } from "../../../utilities/budibaseDir"
|
import { budibaseTempDir } from "../../../utilities/budibaseDir"
|
||||||
import {
|
import {
|
||||||
DB_EXPORT_FILE,
|
DB_EXPORT_FILE,
|
||||||
|
|
|
@ -6,6 +6,11 @@ export enum AppBackupTrigger {
|
||||||
SCHEDULED = "scheduled",
|
SCHEDULED = "scheduled",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum AppBackupEventType {
|
||||||
|
EXPORT = "export",
|
||||||
|
IMPORT = "import",
|
||||||
|
}
|
||||||
|
|
||||||
export interface AppBackup extends Document {
|
export interface AppBackup extends Document {
|
||||||
trigger: AppBackupTrigger
|
trigger: AppBackupTrigger
|
||||||
name: string
|
name: string
|
||||||
|
@ -31,12 +36,22 @@ export type AppBackupFetchOpts = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppBackupQueueData {
|
export interface AppBackupQueueData {
|
||||||
trigger: AppBackupTrigger
|
eventType: AppBackupEventType
|
||||||
createdBy?: string
|
|
||||||
name?: string
|
|
||||||
appId: string
|
appId: string
|
||||||
|
export?: {
|
||||||
|
trigger: AppBackupTrigger
|
||||||
|
name?: string
|
||||||
|
createdBy?: string
|
||||||
|
}
|
||||||
|
import?: {
|
||||||
|
backupId: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppBackupMetadata extends AppBackupQueueData {
|
export interface AppBackupMetadata {
|
||||||
|
appId: string
|
||||||
|
trigger: AppBackupTrigger
|
||||||
|
name?: string
|
||||||
|
createdBy?: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue