1
0
Fork 0
mirror of synced 2024-05-16 18:33:53 +12:00
budibase/qa-core/src/public-api/api/apis/AppAPI.ts
Rory Powell 77ffb8d86d Run integration suite in CI again / auto detect tenancy / refactors (#10209)
* qa-core-ci-fixes

* global setup and teardown wip

* Updates to logs and setup

* Remove date and console mocking

* Update CI to spin up minimal dev env

* Update readme

* Fix scopeBackend.sh

* Ensure docker services are initialised before starting worker

* Lint

* Fix admin user being created on startup (#10219)

* use regular bootstrap and build

* Lint

* Temp: re-use global setup to get around app limit in QA
2023-04-05 15:33:56 +01:00

69 lines
1.8 KiB
TypeScript

import { Response } from "node-fetch"
import BudibasePublicAPIClient from "../BudibasePublicAPIClient"
import * as fixtures from "../../fixtures"
import {
Application,
SearchInputParams,
CreateApplicationParams,
} from "../../../types"
export default class AppAPI {
client: BudibasePublicAPIClient
constructor(client: BudibasePublicAPIClient) {
this.client = client
}
async seed(): Promise<[Response, Application]> {
return this.create(fixtures.apps.generateApp())
}
async create(
body: CreateApplicationParams
): Promise<[Response, Application]> {
const [response, json] = await this.client.post(`/applications`, { body })
return [response, json.data]
}
async read(id: string): Promise<[Response, Application]> {
const [response, json] = await this.client.get(`/applications/${id}`)
return [response, json.data]
}
async search(body: SearchInputParams): Promise<[Response, [Application]]> {
const [response, json] = await this.client.post(`/applications/search`, {
body,
})
return [response, json.data]
}
async update(
id: string,
body: Application
): Promise<[Response, Application]> {
const [response, json] = await this.client.put(`/applications/${id}`, {
body,
})
return [response, json.data]
}
async delete(id: string): Promise<[Response, Application]> {
const [response, json] = await this.client.del(`/applications/${id}`)
return [response, json.data]
}
async publish(id: string): Promise<[Response, any]> {
const [response, json] = await this.client.post(
`/applications/${id}/publish`
)
return [response, json.data]
}
async unpublish(id: string): Promise<[Response]> {
const [response, json] = await this.client.post(
`/applications/${id}/unpublish`
)
return [response]
}
}