77ffb8d86d
* 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
69 lines
1.8 KiB
TypeScript
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]
|
|
}
|
|
}
|