Backup, component and datasource API typing.
This commit is contained in:
parent
d83bd47bd7
commit
1094b88042
|
@ -1,14 +1,16 @@
|
|||
import sdk from "../../sdk"
|
||||
import { events, context, db } from "@budibase/backend-core"
|
||||
import { DocumentType } from "../../db/utils"
|
||||
import { App, Ctx } from "@budibase/types"
|
||||
import {
|
||||
App,
|
||||
Ctx,
|
||||
ExportAppDumpRequest,
|
||||
ExportAppDumpResponse,
|
||||
} from "@budibase/types"
|
||||
|
||||
interface ExportAppDumpRequest {
|
||||
excludeRows: boolean
|
||||
encryptPassword?: string
|
||||
}
|
||||
|
||||
export async function exportAppDump(ctx: Ctx<ExportAppDumpRequest>) {
|
||||
export async function exportAppDump(
|
||||
ctx: Ctx<ExportAppDumpRequest, ExportAppDumpResponse>
|
||||
) {
|
||||
const { appId } = ctx.query as any
|
||||
const { excludeRows, encryptPassword } = ctx.request.body
|
||||
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
import { DocumentType } from "../../db/utils"
|
||||
import { App, Plugin, UserCtx } from "@budibase/types"
|
||||
import {
|
||||
App,
|
||||
FetchComponentDefinitionResponse,
|
||||
Plugin,
|
||||
UserCtx,
|
||||
} from "@budibase/types"
|
||||
import { db as dbCore, context, tenancy } from "@budibase/backend-core"
|
||||
import { getComponentLibraryManifest } from "../../utilities/fileSystem"
|
||||
|
||||
export async function fetchAppComponentDefinitions(ctx: UserCtx) {
|
||||
export async function fetchAppComponentDefinitions(
|
||||
ctx: UserCtx<void, FetchComponentDefinitionResponse>
|
||||
) {
|
||||
try {
|
||||
const db = context.getAppDB()
|
||||
const app = await db.get<App>(DocumentType.APP_METADATA)
|
||||
|
|
|
@ -23,13 +23,17 @@ import {
|
|||
Table,
|
||||
RowValue,
|
||||
DynamicVariable,
|
||||
FetchDatasourcesResponse,
|
||||
FindDatasourcesResponse,
|
||||
DestroyDatasourceResponse,
|
||||
FetchExternalSchemaResponse,
|
||||
} from "@budibase/types"
|
||||
import sdk from "../../sdk"
|
||||
import { builderSocket } from "../../websockets"
|
||||
import { isEqual } from "lodash"
|
||||
import { processTable } from "../../sdk/app/tables/getters"
|
||||
|
||||
export async function fetch(ctx: UserCtx) {
|
||||
export async function fetch(ctx: UserCtx<void, FetchDatasourcesResponse>) {
|
||||
ctx.body = await sdk.datasources.fetch()
|
||||
}
|
||||
|
||||
|
@ -260,7 +264,7 @@ async function destroyInternalTablesBySourceId(datasourceId: string) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function destroy(ctx: UserCtx) {
|
||||
export async function destroy(ctx: UserCtx<void, DestroyDatasourceResponse>) {
|
||||
const db = context.getAppDB()
|
||||
const datasourceId = ctx.params.datasourceId
|
||||
|
||||
|
@ -291,12 +295,14 @@ export async function destroy(ctx: UserCtx) {
|
|||
builderSocket?.emitDatasourceDeletion(ctx, datasourceId)
|
||||
}
|
||||
|
||||
export async function find(ctx: UserCtx) {
|
||||
export async function find(ctx: UserCtx<void, FindDatasourcesResponse>) {
|
||||
const datasource = await sdk.datasources.get(ctx.params.datasourceId)
|
||||
ctx.body = await sdk.datasources.removeSecretSingle(datasource)
|
||||
}
|
||||
|
||||
export async function getExternalSchema(ctx: UserCtx) {
|
||||
export async function getExternalSchema(
|
||||
ctx: UserCtx<void, FetchExternalSchemaResponse>
|
||||
) {
|
||||
const datasource = await sdk.datasources.get(ctx.params.datasourceId)
|
||||
const enrichedDatasource = await sdk.datasources.getAndMergeDatasource(
|
||||
datasource
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export type FetchComponentDefinitionResponse = Record<
|
||||
string,
|
||||
Record<string, any>
|
||||
>
|
|
@ -42,3 +42,14 @@ export interface BuildSchemaFromSourceResponse {
|
|||
datasource: Datasource
|
||||
errors: Record<string, string>
|
||||
}
|
||||
|
||||
export type FetchDatasourcesResponse = Datasource[]
|
||||
export type FindDatasourcesResponse = Datasource
|
||||
|
||||
export interface DestroyDatasourceResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface FetchExternalSchemaResponse {
|
||||
schema: string
|
||||
}
|
||||
|
|
|
@ -9,3 +9,4 @@ export * from "./attachment"
|
|||
export * from "./user"
|
||||
export * from "./rowAction"
|
||||
export * from "./automation"
|
||||
export * from "./component"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { PlanType } from "../../sdk"
|
||||
import type { Layout, App, Screen } from "../../documents"
|
||||
import { ReadStream } from "fs"
|
||||
|
||||
export interface SyncAppResponse {
|
||||
message: string
|
||||
|
@ -70,3 +71,10 @@ export interface ImportToUpdateAppResponse {
|
|||
export interface SetRevertableAppVersionRequest {
|
||||
revertableVersion: string
|
||||
}
|
||||
|
||||
export interface ExportAppDumpRequest {
|
||||
excludeRows: boolean
|
||||
encryptPassword?: string
|
||||
}
|
||||
|
||||
export type ExportAppDumpResponse = ReadStream
|
||||
|
|
Loading…
Reference in New Issue