Merge branch 'develop' into chore/esbuild
This commit is contained in:
commit
8487447376
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.6.19-alpha.1",
|
||||
"version": "2.6.19-alpha.2",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/backend-core",
|
||||
|
|
|
@ -21,4 +21,5 @@ export interface Screen extends Document {
|
|||
width?: string
|
||||
routing: ScreenRouting
|
||||
props: ScreenProps
|
||||
name?: string
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,80 +5,71 @@ import {
|
|||
AppPackageResponse,
|
||||
DeployConfig,
|
||||
MessageResponse,
|
||||
CreateAppRequest,
|
||||
} from "../../../types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class AppAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
interface RenameAppBody {
|
||||
name: string
|
||||
}
|
||||
|
||||
export default class AppAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
// TODO Fix the fetch apps to receive an optional number of apps and compare if the received app is more or less.
|
||||
// each possible scenario should have its own method.
|
||||
async fetchEmptyAppList(): Promise<[Response, App[]]> {
|
||||
const [response, json] = await this.client.get(`/applications?status=all`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/applications?status=all`)
|
||||
expect(json.length).toBeGreaterThanOrEqual(0)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async fetchAllApplications(): Promise<[Response, App[]]> {
|
||||
const [response, json] = await this.client.get(`/applications?status=all`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/applications?status=all`)
|
||||
expect(json.length).toBeGreaterThanOrEqual(1)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async canRender(): Promise<[Response, boolean]> {
|
||||
const [response, json] = await this.client.get("/routing/client")
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get("/routing/client")
|
||||
const publishedAppRenders = Object.keys(json.routes).length > 0
|
||||
expect(publishedAppRenders).toBe(true)
|
||||
return [response, publishedAppRenders]
|
||||
}
|
||||
|
||||
async getAppPackage(appId: string): Promise<[Response, AppPackageResponse]> {
|
||||
const [response, json] = await this.client.get(
|
||||
`/applications/${appId}/appPackage`
|
||||
)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/applications/${appId}/appPackage`)
|
||||
expect(json.application.appId).toEqual(appId)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async publish(appId: string | undefined): Promise<[Response, DeployConfig]> {
|
||||
const [response, json] = await this.client.post(
|
||||
`/applications/${appId}/publish`
|
||||
)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/applications/${appId}/publish`)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async create(body: any): Promise<App> {
|
||||
const [response, json] = await this.client.post(`/applications`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
async create(body: CreateAppRequest): Promise<App> {
|
||||
const [response, json] = await this.post(`/applications`, body)
|
||||
expect(json._id).toBeDefined()
|
||||
return json
|
||||
}
|
||||
|
||||
async read(id: string): Promise<[Response, App]> {
|
||||
const [response, json] = await this.client.get(`/applications/${id}`)
|
||||
const [response, json] = await this.get(`/applications/${id}`)
|
||||
return [response, json.data]
|
||||
}
|
||||
|
||||
async sync(appId: string): Promise<[Response, MessageResponse]> {
|
||||
const [response, json] = await this.client.post(
|
||||
`/applications/${appId}/sync`
|
||||
)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/applications/${appId}/sync`)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
// TODO
|
||||
async updateClient(appId: string, body: any): Promise<[Response, App]> {
|
||||
const [response, json] = await this.client.put(
|
||||
const [response, json] = await this.put(
|
||||
`/applications/${appId}/client/update`,
|
||||
{ body }
|
||||
)
|
||||
|
@ -86,8 +77,7 @@ export default class AppAPI {
|
|||
}
|
||||
|
||||
async revertPublished(appId: string): Promise<[Response, MessageResponse]> {
|
||||
const [response, json] = await this.client.post(`/dev/${appId}/revert`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/dev/${appId}/revert`)
|
||||
expect(json).toEqual({
|
||||
message: "Reverted changes successfully.",
|
||||
})
|
||||
|
@ -95,8 +85,11 @@ export default class AppAPI {
|
|||
}
|
||||
|
||||
async revertUnpublished(appId: string): Promise<[Response, MessageResponse]> {
|
||||
const [response, json] = await this.client.post(`/dev/${appId}/revert`)
|
||||
expect(response).toHaveStatusCode(400)
|
||||
const [response, json] = await this.post(
|
||||
`/dev/${appId}/revert`,
|
||||
undefined,
|
||||
400
|
||||
)
|
||||
expect(json).toEqual({
|
||||
message: "App has not yet been deployed",
|
||||
status: 400,
|
||||
|
@ -105,32 +98,22 @@ export default class AppAPI {
|
|||
}
|
||||
|
||||
async delete(appId: string): Promise<Response> {
|
||||
const [response, _] = await this.client.del(`/applications/${appId}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, _] = await this.del(`/applications/${appId}`)
|
||||
return response
|
||||
}
|
||||
|
||||
async rename(
|
||||
appId: string,
|
||||
oldName: string,
|
||||
body: any
|
||||
body: RenameAppBody
|
||||
): Promise<[Response, App]> {
|
||||
const [response, json] = await this.client.put(`/applications/${appId}`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.put(`/applications/${appId}`, body)
|
||||
expect(json.name).not.toEqual(oldName)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async addScreentoApp(body: any): Promise<[Response, App]> {
|
||||
const [response, json] = await this.client.post(`/screens`, { body })
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getRoutes(screenExists?: boolean): Promise<[Response, RouteConfig]> {
|
||||
const [response, json] = await this.client.get(`/routing`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/routing`)
|
||||
if (screenExists) {
|
||||
expect(json.routes["/test"]).toBeTruthy()
|
||||
} else {
|
||||
|
@ -141,16 +124,16 @@ export default class AppAPI {
|
|||
}
|
||||
|
||||
async unpublish(appId: string): Promise<[Response]> {
|
||||
const [response, json] = await this.client.post(
|
||||
`/applications/${appId}/unpublish`
|
||||
const [response, json] = await this.post(
|
||||
`/applications/${appId}/unpublish`,
|
||||
undefined,
|
||||
204
|
||||
)
|
||||
expect(response).toHaveStatusCode(204)
|
||||
return [response]
|
||||
}
|
||||
|
||||
async unlock(appId: string): Promise<[Response, MessageResponse]> {
|
||||
const [response, json] = await this.client.del(`/dev/${appId}/lock`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.del(`/dev/${appId}/lock`)
|
||||
expect(json.message).toEqual("Lock released successfully.")
|
||||
return [response, json]
|
||||
}
|
||||
|
@ -162,10 +145,7 @@ export default class AppAPI {
|
|||
color: "var(--spectrum-global-color-red-400)",
|
||||
},
|
||||
}
|
||||
const [response, json] = await this.client.put(`/applications/${appId}`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.put(`/applications/${appId}`, body)
|
||||
expect(json.icon.name).toEqual(body.icon.name)
|
||||
expect(json.icon.color).toEqual(body.icon.color)
|
||||
return [response, json]
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import { Response } from "node-fetch"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
|
||||
export default class BaseAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async get(url: string): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.get(url)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async post(
|
||||
url: string,
|
||||
body?: any,
|
||||
statusCode?: number
|
||||
): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.post(url, { body })
|
||||
expect(response).toHaveStatusCode(statusCode ? statusCode : 200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async put(
|
||||
url: string,
|
||||
body?: any,
|
||||
statusCode?: number
|
||||
): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.put(url, { body })
|
||||
expect(response).toHaveStatusCode(statusCode ? statusCode : 200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async patch(
|
||||
url: string,
|
||||
body?: any,
|
||||
statusCode?: number
|
||||
): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.patch(url, { body })
|
||||
expect(response).toHaveStatusCode(statusCode ? statusCode : 200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async del(
|
||||
url: string,
|
||||
statusCode?: number,
|
||||
body?: any
|
||||
): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.del(url, { body })
|
||||
expect(response).toHaveStatusCode(statusCode ? statusCode : 200)
|
||||
return [response, json]
|
||||
}
|
||||
}
|
|
@ -5,91 +5,58 @@ import {
|
|||
UpdateDatasourceResponse,
|
||||
} from "@budibase/types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
import { DatasourceRequest } from "../../../types"
|
||||
|
||||
export default class DatasourcesAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class DatasourcesAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async getIntegrations(): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.get(`/integrations`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/integrations`)
|
||||
const integrationsCount = Object.keys(json).length
|
||||
expect(integrationsCount).toBe(16)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getAll(): Promise<[Response, Datasource[]]> {
|
||||
const [response, json] = await this.client.get(`/datasources`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/datasources`)
|
||||
expect(json.length).toBeGreaterThan(0)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getTable(dataSourceId: string): Promise<[Response, Datasource]> {
|
||||
const [response, json] = await this.client.get(
|
||||
`/datasources/${dataSourceId}`
|
||||
)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/datasources/${dataSourceId}`)
|
||||
expect(json._id).toEqual(dataSourceId)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async add(body: any): Promise<[Response, CreateDatasourceResponse]> {
|
||||
const [response, json] = await this.client.post(`/datasources`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
async add(
|
||||
body: DatasourceRequest
|
||||
): Promise<[Response, CreateDatasourceResponse]> {
|
||||
const [response, json] = await this.post(`/datasources`, body)
|
||||
expect(json.datasource._id).toBeDefined()
|
||||
expect(json.datasource._rev).toBeDefined()
|
||||
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async update(body: any): Promise<[Response, UpdateDatasourceResponse]> {
|
||||
const [response, json] = await this.client.put(`/datasources/${body._id}`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
async update(
|
||||
body: Datasource
|
||||
): Promise<[Response, UpdateDatasourceResponse]> {
|
||||
const [response, json] = await this.put(`/datasources/${body._id}`, body)
|
||||
expect(json.datasource._id).toBeDefined()
|
||||
expect(json.datasource._rev).toBeDefined()
|
||||
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async previewQuery(body: any): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.post(`/queries/preview`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async saveQuery(body: any): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.post(`/queries`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getQuery(queryId: string): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.get(`/queries/${queryId}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getQueryPermissions(queryId: string): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.get(`/permissions/${queryId}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async delete(dataSourceId: string, revId: string): Promise<Response> {
|
||||
const [response, json] = await this.client.del(
|
||||
const [response, json] = await this.del(
|
||||
`/datasources/${dataSourceId}/${revId}`
|
||||
)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
import { Response } from "node-fetch"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class IntegrationsAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class IntegrationsAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async getAll(): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.get(`/integrations`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/integrations`)
|
||||
const integrationsCount = Object.keys(json).length
|
||||
expect(integrationsCount).toBeGreaterThan(0)
|
||||
return [response, json]
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
import { Response } from "node-fetch"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class PermissionsAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class PermissionsAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async getAll(id: string): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.get(`/permissions/${id}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/permissions/${id}`)
|
||||
return [response, json]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,25 @@
|
|||
import { Response } from "node-fetch"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import { PreviewQueryRequest, Query } from "@budibase/types"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class DatasourcesAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class QueriesAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async preview(body: PreviewQueryRequest): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.post(`/queries/preview`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/queries/preview`, body)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async save(body: Query): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.post(`/queries`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/queries`, body)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async get(queryId: string): Promise<[Response, any]> {
|
||||
const [response, json] = await this.client.get(`/queries/${queryId}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
async getQuery(queryId: string): Promise<[Response, any]> {
|
||||
const [response, json] = await this.get(`/queries/${queryId}`)
|
||||
return [response, json]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
import { Response } from "node-fetch"
|
||||
import { Role, UserRoles } from "@budibase/types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class RoleAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class RoleAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async getRoles(): Promise<[Response, Role[]]> {
|
||||
const [response, json] = await this.client.get(`/roles`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/roles`)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async createRole(body: Partial<UserRoles>): Promise<[Response, UserRoles]> {
|
||||
const [response, json] = await this.client.post(`/roles`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/roles`, body)
|
||||
return [response, json]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
import { Response } from "node-fetch"
|
||||
import { Row } from "@budibase/types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class RowAPI {
|
||||
export default class RowAPI extends BaseAPI {
|
||||
rowAdded: boolean
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
this.rowAdded = false
|
||||
}
|
||||
|
||||
async getAll(tableId: string): Promise<[Response, Row[]]> {
|
||||
const [response, json] = await this.client.get(`/${tableId}/rows`)
|
||||
const [response, json] = await this.get(`/${tableId}/rows`)
|
||||
if (this.rowAdded) {
|
||||
expect(response).toHaveStatusCode(200)
|
||||
expect(json.length).toBeGreaterThanOrEqual(1)
|
||||
}
|
||||
return [response, json]
|
||||
}
|
||||
async add(tableId: string, body: any): Promise<[Response, Row]> {
|
||||
const [response, json] = await this.client.post(`/${tableId}/rows`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
async add(tableId: string, body: Row): Promise<[Response, Row]> {
|
||||
const [response, json] = await this.post(`/${tableId}/rows`, body)
|
||||
expect(json._id).toBeDefined()
|
||||
expect(json._rev).toBeDefined()
|
||||
expect(json.tableId).toEqual(tableId)
|
||||
|
@ -31,34 +27,29 @@ export default class RowAPI {
|
|||
return [response, json]
|
||||
}
|
||||
|
||||
async delete(tableId: string, body: any): Promise<[Response, Row[]]> {
|
||||
const [response, json] = await this.client.del(`/${tableId}/rows/`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
async delete(tableId: string, body: Row): Promise<[Response, Row[]]> {
|
||||
const [response, json] = await this.del(
|
||||
`/${tableId}/rows/`,
|
||||
undefined,
|
||||
body
|
||||
)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async searchNoPagination(
|
||||
tableId: string,
|
||||
body: any
|
||||
body: string
|
||||
): Promise<[Response, Row[]]> {
|
||||
const [response, json] = await this.client.post(`/${tableId}/search`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/${tableId}/search`, body)
|
||||
expect(json.hasNextPage).toEqual(false)
|
||||
return [response, json.rows]
|
||||
}
|
||||
|
||||
async searchWithPagination(
|
||||
tableId: string,
|
||||
body: any
|
||||
body: string
|
||||
): Promise<[Response, Row[]]> {
|
||||
const [response, json] = await this.client.post(`/${tableId}/search`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/${tableId}/search`, body)
|
||||
expect(json.hasNextPage).toEqual(true)
|
||||
expect(json.rows.length).toEqual(10)
|
||||
return [response, json.rows]
|
||||
|
|
|
@ -1,27 +1,23 @@
|
|||
import { Screen } from "@budibase/types"
|
||||
import { Response } from "node-fetch"
|
||||
import { Screen } from "@budibase/types"
|
||||
import { ScreenRequest } from "../../../types/screens"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class ScreenAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class ScreenAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async create(body: any): Promise<[Response, Screen]> {
|
||||
const [response, json] = await this.client.post(`/screens`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
async create(body: ScreenRequest): Promise<[Response, Screen]> {
|
||||
const [response, json] = await this.post(`/screens`, body)
|
||||
expect(json._id).toBeDefined()
|
||||
expect(json.routing.roleId).toBe(body.routing.roleId)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async delete(screenId: string, rev: string): Promise<[Response, Screen]> {
|
||||
const [response, json] = await this.client.del(
|
||||
`/screens/${screenId}/${rev}`
|
||||
)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.del(`/screens/${screenId}/${rev}`)
|
||||
return [response, json]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,31 +2,27 @@ import { Response } from "node-fetch"
|
|||
import { User } from "@budibase/types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import { ApiKeyResponse } from "../../../types"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class SelfAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class SelfAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async getSelf(): Promise<[Response, Partial<User>]> {
|
||||
const [response, json] = await this.client.get(`/global/self`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/global/self`)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async changeSelfPassword(body: Partial<User>): Promise<[Response, User]> {
|
||||
const [response, json] = await this.client.post(`/global/self`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/self`, body)
|
||||
expect(json._id).toEqual(body._id)
|
||||
expect(json._rev).not.toEqual(body._rev)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getApiKey(): Promise<ApiKeyResponse> {
|
||||
const [response, json] = await this.client.get(`/global/self/api_key`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/global/self/api_key`)
|
||||
expect(json).toHaveProperty("apiKey")
|
||||
return json
|
||||
}
|
||||
|
|
|
@ -2,31 +2,27 @@ import { Response } from "node-fetch"
|
|||
import { Table } from "@budibase/types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import { MessageResponse } from "../../../types"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class TableAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class TableAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async getAll(expectedNumber: Number): Promise<[Response, Table[]]> {
|
||||
const [response, json] = await this.client.get(`/tables`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/tables`)
|
||||
expect(json.length).toBe(expectedNumber)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getTableById(id: string): Promise<[Response, Table]> {
|
||||
const [response, json] = await this.client.get(`/tables/${id}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/tables/${id}`)
|
||||
expect(json._id).toEqual(id)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async save(body: any, columnAdded?: boolean): Promise<[Response, Table]> {
|
||||
const [response, json] = await this.client.post(`/tables`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/tables`, body)
|
||||
expect(json._id).toBeDefined()
|
||||
expect(json._rev).toBeDefined()
|
||||
if (columnAdded) {
|
||||
|
@ -37,9 +33,7 @@ export default class TableAPI {
|
|||
}
|
||||
|
||||
async forbiddenSave(body: any): Promise<[Response, Table]> {
|
||||
const [response, json] = await this.client.post(`/tables`, { body })
|
||||
expect(response).toHaveStatusCode(403)
|
||||
|
||||
const [response, json] = await this.post(`/tables`, body, 403)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
|
@ -47,8 +41,7 @@ export default class TableAPI {
|
|||
id: string,
|
||||
revId: string
|
||||
): Promise<[Response, MessageResponse]> {
|
||||
const [response, json] = await this.client.del(`/tables/${id}/${revId}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.del(`/tables/${id}/${revId}`)
|
||||
expect(json.message).toEqual(`Table ${id} deleted.`)
|
||||
return [response, json]
|
||||
}
|
||||
|
|
|
@ -2,30 +2,29 @@ import { Response } from "node-fetch"
|
|||
import { Role, User, UserDeletedEvent, UserRoles } from "@budibase/types"
|
||||
import BudibaseInternalAPIClient from "../BudibaseInternalAPIClient"
|
||||
import { MessageResponse } from "../../../types"
|
||||
import BaseAPI from "./BaseAPI"
|
||||
|
||||
export default class UserAPI {
|
||||
client: BudibaseInternalAPIClient
|
||||
|
||||
export default class UserAPI extends BaseAPI {
|
||||
constructor(client: BudibaseInternalAPIClient) {
|
||||
this.client = client
|
||||
super(client)
|
||||
}
|
||||
|
||||
async search(): Promise<[Response, Partial<User>[]]> {
|
||||
const [response, json] = await this.client.post(`/global/users/search`, {})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/users/search`, {})
|
||||
|
||||
expect(json.data.length).toBeGreaterThan(0)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getSelf(): Promise<[Response, Partial<User>]> {
|
||||
const [response, json] = await this.client.get(`/global/self`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/global/self`)
|
||||
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getAll(): Promise<[Response, Partial<User>[]]> {
|
||||
const [response, json] = await this.client.get(`/global/users`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/global/users`)
|
||||
|
||||
expect(json.length).toBeGreaterThan(0)
|
||||
return [response, json]
|
||||
}
|
||||
|
@ -38,10 +37,8 @@ export default class UserAPI {
|
|||
groups: [],
|
||||
},
|
||||
}
|
||||
const [response, json] = await this.client.post(`/global/users/bulk`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/users/bulk`, body)
|
||||
|
||||
expect(json.created.unsuccessful.length).toEqual(0)
|
||||
expect(json.created.successful.length).toEqual(body.create.users.length)
|
||||
return [response, json]
|
||||
|
@ -53,73 +50,58 @@ export default class UserAPI {
|
|||
userIds: [userId],
|
||||
},
|
||||
}
|
||||
const [response, json] = await this.client.post(`/global/users/bulk`, {
|
||||
body,
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/users/bulk`, body)
|
||||
expect(json.deleted.successful.length).toEqual(1)
|
||||
expect(json.deleted.unsuccessful.length).toEqual(0)
|
||||
expect(json.deleted.successful[0].userId).toEqual(userId)
|
||||
return [response, json]
|
||||
}
|
||||
async delete(userId: string): Promise<[Response, UserDeletedEvent]> {
|
||||
const [response, json] = await this.client.del(`/global/users/${userId}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.del(`/global/users/${userId}`)
|
||||
expect(json.message).toEqual(`User ${userId} deleted.`)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async invite(body: any): Promise<[Response, MessageResponse]> {
|
||||
const [response, json] = await this.client.post(
|
||||
`/global/users/multi/invite`,
|
||||
{ body }
|
||||
)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/users/multi/invite`, body)
|
||||
expect(json.unsuccessful.length).toEqual(0)
|
||||
expect(json.successful.length).toEqual(body.length)
|
||||
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getRoles(): Promise<[Response, Role[]]> {
|
||||
const [response, json] = await this.client.get(`/roles`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/roles`)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async updateInfo(body: any): Promise<[Response, User]> {
|
||||
const [response, json] = await this.client.post(`/global/users/`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/users/`, body)
|
||||
expect(json._id).toEqual(body._id)
|
||||
expect(json._rev).not.toEqual(body._rev)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async forcePasswordReset(body: any): Promise<[Response, User]> {
|
||||
const [response, json] = await this.client.post(`/global/users/`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/users/`, body)
|
||||
expect(json._id).toEqual(body._id)
|
||||
expect(json._rev).not.toEqual(body._rev)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async getInfo(userId: string): Promise<[Response, User]> {
|
||||
const [response, json] = await this.client.get(`/global/users/${userId}`)
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.get(`/global/users/${userId}`)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async changeSelfPassword(body: Partial<User>): Promise<[Response, User]> {
|
||||
const [response, json] = await this.client.post(`/global/self`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/global/self`, body)
|
||||
expect(json._id).toEqual(body._id)
|
||||
expect(json._rev).not.toEqual(body._rev)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async createRole(body: Partial<UserRoles>): Promise<[Response, UserRoles]> {
|
||||
const [response, json] = await this.client.post(`/roles`, { body })
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const [response, json] = await this.post(`/roles`, body)
|
||||
return [response, json]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { DatasourceRequest } from "../../types"
|
||||
// Add information about the data source to the fixtures file from 1password
|
||||
export const mongoDB = () => {
|
||||
export const mongoDB = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "MongoDB",
|
||||
|
@ -15,7 +16,7 @@ export const mongoDB = () => {
|
|||
}
|
||||
}
|
||||
|
||||
export const postgresSQL = () => {
|
||||
export const postgresSQL = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "PostgresSQL",
|
||||
|
@ -34,7 +35,7 @@ export const postgresSQL = () => {
|
|||
fetchSchema: true,
|
||||
}
|
||||
}
|
||||
export const mariaDB = () => {
|
||||
export const mariaDB = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "MariaDB",
|
||||
|
@ -54,7 +55,7 @@ export const mariaDB = () => {
|
|||
}
|
||||
}
|
||||
|
||||
export const restAPI = () => {
|
||||
export const restAPI = (): DatasourceRequest => {
|
||||
return {
|
||||
datasource: {
|
||||
name: "RestAPI",
|
||||
|
|
|
@ -57,7 +57,7 @@ export const expectedSchemaFields = {
|
|||
running_time_secs: "number",
|
||||
title: "string",
|
||||
year: "number",
|
||||
_id: "json",
|
||||
_id: "string",
|
||||
},
|
||||
postgres: {
|
||||
address: "string",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { generator } from "../../shared"
|
||||
|
||||
import { ScreenRequest } from "../../types"
|
||||
const randomId = generator.guid()
|
||||
|
||||
export const generateScreen = (roleId: string): any => ({
|
||||
export const generateScreen = (roleId: string): ScreenRequest => ({
|
||||
showNavigation: true,
|
||||
width: "Large",
|
||||
name: randomId,
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: MariaDB", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
<string>saveQueryJson._id
|
||||
)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: MongoDB", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
<string>saveQueryJson._id
|
||||
)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: PostgresSQL", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
saveQueryJson._id!
|
||||
)
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("Internal API - Data Sources: REST API", () => {
|
|||
datasourcetoSave
|
||||
)
|
||||
// Get Query
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.get(
|
||||
const [getQueryResponse, getQueryJson] = await config.api.queries.getQuery(
|
||||
saveQueryJson._id!
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
export interface DatasourceRequest {
|
||||
datasource: {
|
||||
name: string
|
||||
plus?: boolean
|
||||
source: string
|
||||
type: string
|
||||
config: {
|
||||
connectionString?: string
|
||||
db?: string
|
||||
database?: string
|
||||
host?: string
|
||||
password?: string
|
||||
port?: string
|
||||
schema?: string
|
||||
user?: string
|
||||
defaultHeaders?: {}
|
||||
rejectUnauthorized?: boolean
|
||||
url?: string
|
||||
}
|
||||
}
|
||||
fetchSchema: boolean
|
||||
}
|
|
@ -8,7 +8,7 @@ export * from "./responseMessage"
|
|||
export * from "./routing"
|
||||
export * from "./state"
|
||||
export * from "./unpublishAppResponse"
|
||||
export * from "./addedDatasource"
|
||||
|
||||
export * from "./screens"
|
||||
export * from "./datasources"
|
||||
// re-export public api types
|
||||
export * from "@budibase/server/api/controllers/public/mapping/types"
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
export interface ScreenRequest {
|
||||
showNavigation: boolean
|
||||
width: string
|
||||
name: string
|
||||
template: string
|
||||
props: ScreenProps
|
||||
routing: ScreenRouting
|
||||
}
|
||||
|
||||
interface ScreenProps {
|
||||
_id: string
|
||||
_component: string
|
||||
_styles: {
|
||||
normal: {}
|
||||
hover: {}
|
||||
active: {}
|
||||
selected: {}
|
||||
}
|
||||
_children: []
|
||||
_instanceName: string
|
||||
direction: string
|
||||
hAlign: string
|
||||
vAlign: string
|
||||
size: string
|
||||
gap: string
|
||||
}
|
||||
|
||||
interface ScreenRouting {
|
||||
route: string
|
||||
roleId: string
|
||||
homeScreen: boolean
|
||||
}
|
Loading…
Reference in New Issue