Import specific controllers

This commit is contained in:
Adria Navarro 2024-01-26 11:07:06 +01:00
parent 9592f25b66
commit 12a08c6864
1 changed files with 25 additions and 16 deletions

View File

@ -27,6 +27,18 @@ import {
sessions, sessions,
tenancy, tenancy,
} from "@budibase/backend-core" } from "@budibase/backend-core"
import {
app as appController,
deploy as deployController,
role as roleController,
automation as automationController,
webhook as webhookController,
query as queryController,
screen as screenController,
layout as layoutController,
view as viewController,
} from "./controllers"
import * as controllers from "./controllers" import * as controllers from "./controllers"
import { cleanup } from "../../utilities/fileSystem" import { cleanup } from "../../utilities/fileSystem"
import newid from "../../db/newid" import newid from "../../db/newid"
@ -543,11 +555,7 @@ class TestConfiguration {
// clear any old app // clear any old app
this.appId = null this.appId = null
this.app = await context.doInTenant(this.tenantId!, async () => { this.app = await context.doInTenant(this.tenantId!, async () => {
const app = await this._req( const app = await this._req({ name: appName }, null, appController.create)
{ name: appName },
null,
controllers.app.create
)
this.appId = app.appId! this.appId = app.appId!
return app return app
}) })
@ -563,7 +571,7 @@ class TestConfiguration {
} }
async publish() { async publish() {
await this._req(null, null, controllers.deploy.publishApp) await this._req(null, null, deployController.publishApp)
// @ts-ignore // @ts-ignore
const prodAppId = this.getAppId().replace("_dev", "") const prodAppId = this.getAppId().replace("_dev", "")
this.prodAppId = prodAppId this.prodAppId = prodAppId
@ -578,7 +586,7 @@ class TestConfiguration {
const response = await this._req( const response = await this._req(
null, null,
{ appId: this.appId }, { appId: this.appId },
controllers.app.unpublish appController.unpublish
) )
this.prodAppId = null this.prodAppId = null
this.prodApp = null this.prodApp = null
@ -712,7 +720,7 @@ class TestConfiguration {
async createRole(config?: any) { async createRole(config?: any) {
config = config || basicRole() config = config || basicRole()
return this._req(config, null, controllers.role.save) return this._req(config, null, roleController.save)
} }
// VIEW // VIEW
@ -725,7 +733,7 @@ class TestConfiguration {
tableId: this.table!._id, tableId: this.table!._id,
name: generator.guid(), name: generator.guid(),
} }
return this._req(view, null, controllers.view.v1.save) return this._req(view, null, viewController.v1.save)
} }
async createView( async createView(
@ -755,13 +763,13 @@ class TestConfiguration {
delete config._rev delete config._rev
} }
this.automation = ( this.automation = (
await this._req(config, null, controllers.automation.create) await this._req(config, null, automationController.create)
).automation ).automation
return this.automation return this.automation
} }
async getAllAutomations() { async getAllAutomations() {
return this._req(null, null, controllers.automation.fetch) return this._req(null, null, automationController.fetch)
} }
async deleteAutomation(automation?: any) { async deleteAutomation(automation?: any) {
@ -772,7 +780,7 @@ class TestConfiguration {
return this._req( return this._req(
null, null,
{ id: automation._id, rev: automation._rev }, { id: automation._id, rev: automation._rev },
controllers.automation.destroy automationController.destroy
) )
} }
@ -781,7 +789,8 @@ class TestConfiguration {
throw "Must create an automation before creating webhook." throw "Must create an automation before creating webhook."
} }
config = config || basicWebhook(this.automation._id) config = config || basicWebhook(this.automation._id)
return (await this._req(config, null, controllers.webhook.save)).webhook
return (await this._req(config, null, webhookController.save)).webhook
} }
// DATASOURCE // DATASOURCE
@ -888,21 +897,21 @@ class TestConfiguration {
throw "No datasource created for query." throw "No datasource created for query."
} }
config = config || basicQuery(this.datasource!._id!) config = config || basicQuery(this.datasource!._id!)
return this._req(config, null, controllers.query.save) return this._req(config, null, queryController.save)
} }
// SCREEN // SCREEN
async createScreen(config?: any) { async createScreen(config?: any) {
config = config || basicScreen() config = config || basicScreen()
return this._req(config, null, controllers.screen.save) return this._req(config, null, screenController.save)
} }
// LAYOUT // LAYOUT
async createLayout(config?: any) { async createLayout(config?: any) {
config = config || basicLayout() config = config || basicLayout()
return await this._req(config, null, controllers.layout.save) return await this._req(config, null, layoutController.save)
} }
} }