Merge branch 'develop' of github.com:Budibase/budibase into data-section-multidev

This commit is contained in:
Andrew Kingston 2023-05-22 16:01:50 +01:00
commit 9ab5c8792a
46 changed files with 6220 additions and 369 deletions

View File

@ -22,43 +22,44 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: "yarn"
- run: yarn
- run: yarn lint
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: "yarn"
- run: yarn
- run: yarn bootstrap
- run: yarn build
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: "yarn"
- run: yarn
- run: yarn bootstrap
- run: yarn build
- run: yarn build --scope=@budibase/types --scope=@budibase/shared-core --scope=@budibase/string-templates
- run: yarn test --ignore=@budibase/pro
- uses: codecov/codecov-action@v3
with:
@ -69,32 +70,34 @@ jobs:
test-pro:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x
cache: "yarn"
- run: yarn
- run: yarn bootstrap
- run: yarn build --scope=@budibase/types --scope=@budibase/shared-core
- run: yarn test --scope=@budibase/pro
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x
- run: yarn && yarn bootstrap && yarn build
- run: |
cache: "yarn"
- run: yarn
- run: yarn build
- name: Run tests
run: |
cd qa-core
yarn setup
yarn test:ci
@ -106,7 +109,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

View File

@ -1,5 +1,5 @@
{
"version": "2.6.16-alpha.5",
"version": "2.6.19-alpha.2",
"npmClient": "yarn",
"packages": [
"packages/backend-core",

View File

@ -104,6 +104,22 @@ async function newContext(updates: ContextMap, task: any) {
return Context.run(context, task)
}
export async function doInAutomationContext(params: {
appId: string
automationId: string
task: any
}): Promise<any> {
const tenantId = getTenantIDFromAppID(params.appId)
return newContext(
{
tenantId,
appId: params.appId,
automationId: params.automationId,
},
params.task
)
}
export async function doInContext(appId: string, task: any): Promise<any> {
const tenantId = getTenantIDFromAppID(appId)
return newContext(
@ -187,6 +203,11 @@ export function getTenantId(): string {
return tenantId
}
export function getAutomationId(): string | undefined {
const context = Context.get()
return context?.automationId
}
export function getAppId(): string | undefined {
const context = Context.get()
const foundId = context?.appId

View File

@ -7,4 +7,5 @@ export type ContextMap = {
identity?: IdentityContext
environmentVariables?: Record<string, string>
isScim?: boolean
automationId?: string
}

View File

@ -39,6 +39,7 @@ if (!env.DISABLE_PINO_LOGGER) {
objects?: any[]
tenantId?: string
appId?: string
automationId?: string
identityId?: string
identityType?: IdentityType
correlationId?: string
@ -86,18 +87,44 @@ if (!env.DISABLE_PINO_LOGGER) {
contextObject = {
tenantId: getTenantId(),
appId: getAppId(),
automationId: getAutomationId(),
identityId: identity?._id,
identityType: identity?.type,
correlationId: correlation.getId(),
}
}
const mergingObject = {
objects: objects.length ? objects : undefined,
const mergingObject: any = {
err: error,
...contextObject,
}
if (objects.length) {
// init generic data object for params supplied that don't have a
// '_logKey' field. This prints an object using argument index as the key
// e.g. { 0: {}, 1: {} }
const data: any = {}
let dataIndex = 0
for (let i = 0; i < objects.length; i++) {
const object = objects[i]
// the object has specified a log key
// use this instead of generic key
const logKey = object._logKey
if (logKey) {
delete object._logKey
mergingObject[logKey] = object
} else {
data[dataIndex] = object
dataIndex++
}
}
if (Object.keys(data).length) {
mergingObject.data = data
}
}
return [mergingObject, message]
}
@ -159,6 +186,16 @@ if (!env.DISABLE_PINO_LOGGER) {
return appId
}
const getAutomationId = () => {
let appId
try {
appId = context.getAutomationId()
} catch (e) {
// do nothing
}
return appId
}
const getIdentity = () => {
let identity
try {

View File

@ -128,6 +128,7 @@ class InMemoryQueue {
on() {
// do nothing
return this
}
async waitForCompletion() {

View File

@ -1,5 +1,6 @@
import { Job, JobId, Queue } from "bull"
import { JobQueue } from "./constants"
import * as context from "../context"
export type StalledFn = (job: Job) => Promise<void>
@ -31,77 +32,164 @@ function handleStalled(queue: Queue, removeStalledCb?: StalledFn) {
})
}
function logging(queue: Queue, jobQueue: JobQueue) {
let eventType: string
switch (jobQueue) {
case JobQueue.AUTOMATION:
eventType = "automation-event"
break
case JobQueue.APP_BACKUP:
eventType = "app-backup-event"
break
case JobQueue.AUDIT_LOG:
eventType = "audit-log-event"
break
case JobQueue.SYSTEM_EVENT_QUEUE:
eventType = "system-event"
break
function getLogParams(
eventType: QueueEventType,
event: BullEvent,
opts: {
job?: Job
jobId?: JobId
error?: Error
} = {},
extra: any = {}
) {
const message = `[BULL] ${eventType}=${event}`
const err = opts.error
const bullLog = {
_logKey: "bull",
eventType,
event,
job: opts.job,
jobId: opts.jobId || opts.job?.id,
...extra,
}
let automationLog
if (opts.job?.data?.automation) {
automationLog = {
_logKey: "automation",
trigger: opts.job
? opts.job.data.automation.definition.trigger.event
: undefined,
}
}
return [message, err, bullLog, automationLog]
}
enum BullEvent {
ERROR = "error",
WAITING = "waiting",
ACTIVE = "active",
STALLED = "stalled",
PROGRESS = "progress",
COMPLETED = "completed",
FAILED = "failed",
PAUSED = "paused",
RESUMED = "resumed",
CLEANED = "cleaned",
DRAINED = "drained",
REMOVED = "removed",
}
enum QueueEventType {
AUTOMATION_EVENT = "automation-event",
APP_BACKUP_EVENT = "app-backup-event",
AUDIT_LOG_EVENT = "audit-log-event",
SYSTEM_EVENT = "system-event",
}
const EventTypeMap: { [key in JobQueue]: QueueEventType } = {
[JobQueue.AUTOMATION]: QueueEventType.AUTOMATION_EVENT,
[JobQueue.APP_BACKUP]: QueueEventType.APP_BACKUP_EVENT,
[JobQueue.AUDIT_LOG]: QueueEventType.AUDIT_LOG_EVENT,
[JobQueue.SYSTEM_EVENT_QUEUE]: QueueEventType.SYSTEM_EVENT,
}
function logging(queue: Queue, jobQueue: JobQueue) {
const eventType = EventTypeMap[jobQueue]
function doInJobContext(job: Job, task: any) {
// if this is an automation job try to get the app id
const appId = job.data.event?.appId
if (appId) {
return context.doInContext(appId, task)
} else {
task()
}
}
queue
.on(BullEvent.STALLED, async (job: Job) => {
// A job has been marked as stalled. This is useful for debugging job
// workers that crash or pause the event loop.
await doInJobContext(job, () => {
console.error(...getLogParams(eventType, BullEvent.STALLED, { job }))
})
})
.on(BullEvent.ERROR, (error: any) => {
// An error occurred.
console.error(...getLogParams(eventType, BullEvent.ERROR, { error }))
})
if (process.env.NODE_DEBUG?.includes("bull")) {
queue
.on("error", (error: any) => {
// An error occurred.
console.error(`${eventType}=error error=${JSON.stringify(error)}`)
})
.on("waiting", (jobId: JobId) => {
.on(BullEvent.WAITING, (jobId: JobId) => {
// A Job is waiting to be processed as soon as a worker is idling.
console.log(`${eventType}=waiting jobId=${jobId}`)
console.info(...getLogParams(eventType, BullEvent.WAITING, { jobId }))
})
.on("active", (job: Job, jobPromise: any) => {
.on(BullEvent.ACTIVE, async (job: Job, jobPromise: any) => {
// A job has started. You can use `jobPromise.cancel()`` to abort it.
console.log(`${eventType}=active jobId=${job.id}`)
await doInJobContext(job, () => {
console.info(...getLogParams(eventType, BullEvent.ACTIVE, { job }))
})
})
.on("stalled", (job: Job) => {
// A job has been marked as stalled. This is useful for debugging job
// workers that crash or pause the event loop.
console.error(
`${eventType}=stalled jobId=${job.id} job=${JSON.stringify(job)}`
)
.on(BullEvent.PROGRESS, async (job: Job, progress: any) => {
// A job's progress was updated
await doInJobContext(job, () => {
console.info(
...getLogParams(
eventType,
BullEvent.PROGRESS,
{ job },
{ progress }
)
)
})
})
.on("progress", (job: Job, progress: any) => {
// A job's progress was updated!
console.log(
`${eventType}=progress jobId=${job.id} progress=${progress}`
)
})
.on("completed", (job: Job, result) => {
.on(BullEvent.COMPLETED, async (job: Job, result) => {
// A job successfully completed with a `result`.
console.log(`${eventType}=completed jobId=${job.id} result=${result}`)
await doInJobContext(job, () => {
console.info(
...getLogParams(eventType, BullEvent.COMPLETED, { job }, { result })
)
})
})
.on("failed", (job, err: any) => {
.on(BullEvent.FAILED, async (job: Job, error: any) => {
// A job failed with reason `err`!
console.log(`${eventType}=failed jobId=${job.id} error=${err}`)
await doInJobContext(job, () => {
console.error(
...getLogParams(eventType, BullEvent.FAILED, { job, error })
)
})
})
.on("paused", () => {
.on(BullEvent.PAUSED, () => {
// The queue has been paused.
console.log(`${eventType}=paused`)
console.info(...getLogParams(eventType, BullEvent.PAUSED))
})
.on("resumed", (job: Job) => {
.on(BullEvent.RESUMED, () => {
// The queue has been resumed.
console.log(`${eventType}=paused jobId=${job.id}`)
console.info(...getLogParams(eventType, BullEvent.RESUMED))
})
.on("cleaned", (jobs: Job[], type: string) => {
.on(BullEvent.CLEANED, (jobs: Job[], type: string) => {
// Old jobs have been cleaned from the queue. `jobs` is an array of cleaned
// jobs, and `type` is the type of jobs cleaned.
console.log(`${eventType}=cleaned length=${jobs.length} type=${type}`)
console.info(
...getLogParams(
eventType,
BullEvent.CLEANED,
{},
{ length: jobs.length, type }
)
)
})
.on("drained", () => {
.on(BullEvent.DRAINED, () => {
// Emitted every time the queue has processed all the waiting jobs (even if there can be some delayed jobs not yet processed)
console.log(`${eventType}=drained`)
console.info(...getLogParams(eventType, BullEvent.DRAINED))
})
.on("removed", (job: Job) => {
.on(BullEvent.REMOVED, (job: Job) => {
// A job successfully removed.
console.log(`${eventType}=removed jobId=${job.id}`)
console.info(...getLogParams(eventType, BullEvent.REMOVED, { job }))
})
}
}

View File

@ -4,12 +4,7 @@
"composite": true,
"declaration": true,
"sourceMap": true,
"baseUrl": ".",
"paths": {
"@budibase/types": ["../types/src"],
"@budibase/backend-core": ["../backend-core/src"],
"@budibase/backend-core/*": ["../backend-core/*.js"]
}
"baseUrl": "."
},
"ts-node": {
"require": ["tsconfig-paths/register"]

@ -1 +1 @@
Subproject commit 64a2025727c25d5813832c92eb360de3947b7aa6
Subproject commit a590dc237a16983b8f39dc8e65005b7736d23467

View File

@ -9,7 +9,7 @@ import { checkTestFlag } from "../utilities/redis"
import * as utils from "./utils"
import env from "../environment"
import { context, db as dbCore } from "@budibase/backend-core"
import { Automation, Row } from "@budibase/types"
import { Automation, Row, AutomationData, AutomationJob } from "@budibase/types"
export const TRIGGER_DEFINITIONS = definitions
const JOB_OPTS = {
@ -109,14 +109,16 @@ export async function externalTrigger(
}
params.fields = coercedFields
}
const data: Record<string, any> = { automation, event: params }
const data: AutomationData = { automation, event: params as any }
if (getResponses) {
data.event = {
...data.event,
appId: context.getAppId(),
automation,
}
return utils.processEvent({ data })
const job = { data } as AutomationJob
return utils.processEvent(job)
} else {
return automationQueue.add(data, JOB_OPTS)
}

View File

@ -8,7 +8,7 @@ import { db as dbCore, context } from "@budibase/backend-core"
import { getAutomationMetadataParams } from "../db/utils"
import { cloneDeep } from "lodash/fp"
import { quotas } from "@budibase/pro"
import { Automation, WebhookActionType } from "@budibase/types"
import { Automation, AutomationJob, WebhookActionType } from "@budibase/types"
import sdk from "../sdk"
const REBOOT_CRON = "@reboot"
@ -16,27 +16,40 @@ const WH_STEP_ID = definitions.WEBHOOK.stepId
const CRON_STEP_ID = definitions.CRON.stepId
const Runner = new Thread(ThreadType.AUTOMATION)
const jobMessage = (job: any, message: string) => {
return `app=${job.data.event.appId} automation=${job.data.automation._id} jobId=${job.id} trigger=${job.data.automation.definition.trigger.event} : ${message}`
function loggingArgs(job: AutomationJob) {
return [
{
_logKey: "automation",
trigger: job.data.automation.definition.trigger.event,
},
{
_logKey: "bull",
jobId: job.id,
},
]
}
export async function processEvent(job: any) {
try {
const automationId = job.data.automation._id
console.log(jobMessage(job, "running"))
// need to actually await these so that an error can be captured properly
return await context.doInContext(job.data.event.appId, async () => {
export async function processEvent(job: AutomationJob) {
const appId = job.data.event.appId!
const automationId = job.data.automation._id!
const task = async () => {
try {
// need to actually await these so that an error can be captured properly
console.log("automation running", ...loggingArgs(job))
const runFn = () => Runner.run(job)
return quotas.addAutomation(runFn, {
const result = await quotas.addAutomation(runFn, {
automationId,
})
})
} catch (err) {
const errJson = JSON.stringify(err)
console.error(jobMessage(job, `was unable to run - ${errJson}`))
console.trace(err)
return { err }
console.log("automation completed", ...loggingArgs(job))
return result
} catch (err) {
console.error(`automation was unable to run`, err, ...loggingArgs(job))
return { err }
}
}
return await context.doInAutomationContext({ appId, automationId, task })
}
export async function updateTestHistory(

View File

@ -1,4 +1,4 @@
import { AutomationResults, AutomationStep, Document } from "@budibase/types"
import { AutomationResults, AutomationStep } from "@budibase/types"
export enum LoopStepType {
ARRAY = "Array",
@ -27,7 +27,3 @@ export interface AutomationContext extends AutomationResults {
env?: Record<string, string>
trigger: any
}
export interface AutomationMetadata extends Document {
errorCount?: number
}

View File

@ -13,13 +13,18 @@ import { generateAutomationMetadataID, isProdAppID } from "../db/utils"
import { definitions as triggerDefs } from "../automations/triggerInfo"
import { AutomationErrors, MAX_AUTOMATION_RECURRING_ERRORS } from "../constants"
import { storeLog } from "../automations/logging"
import { Automation, AutomationStep, AutomationStatus } from "@budibase/types"
import {
Automation,
AutomationStep,
AutomationStatus,
AutomationMetadata,
AutomationJob,
} from "@budibase/types"
import {
LoopStep,
LoopInput,
TriggerOutput,
AutomationContext,
AutomationMetadata,
} from "../definitions/automations"
import { WorkerCallback } from "./definitions"
import { context, logging } from "@budibase/backend-core"
@ -60,11 +65,11 @@ class Orchestrator {
_job: Job
executionOutput: AutomationContext
constructor(job: Job) {
let automation = job.data.automation,
triggerOutput = job.data.event
constructor(job: AutomationJob) {
let automation = job.data.automation
let triggerOutput = job.data.event
const metadata = triggerOutput.metadata
this._chainCount = metadata ? metadata.automationChainCount : 0
this._chainCount = metadata ? metadata.automationChainCount! : 0
this._appId = triggerOutput.appId as string
this._job = job
const triggerStepId = automation.definition.trigger.stepId

View File

@ -1,5 +1,3 @@
import { EnvironmentVariablesDecrypted } from "@budibase/types"
export type WorkerCallback = (error: any, response?: any) => void
export interface QueryEvent {

View File

@ -1,5 +1,7 @@
import workerFarm from "worker-farm"
import env from "../environment"
import { AutomationJob } from "@budibase/types"
import { QueryEvent } from "./definitions"
export const ThreadType = {
QUERY: "query",
@ -64,11 +66,11 @@ export class Thread {
)
}
run(data: any) {
run(job: AutomationJob | QueryEvent) {
const timeout = this.timeoutMs
return new Promise((resolve, reject) => {
function fire(worker: any) {
worker.execute(data, (err: any, response: any) => {
worker.execute(job, (err: any, response: any) => {
if (err && err.type === "TimeoutError") {
reject(
new Error(`Query response time exceeded ${timeout}ms timeout.`)

View File

@ -35,7 +35,7 @@ export const getComponentLibraryManifest = async (library: string) => {
const filename = "manifest.json"
if (env.isDev() || env.isTest()) {
const path = join(NODE_MODULES_PATH, "@budibase", "client", filename)
const path = join(TOP_LEVEL_PATH, "../client", filename)
// always load from new so that updates are refreshed
delete require.cache[require.resolve(path)]
return require(path)

View File

@ -178,3 +178,8 @@ export type AutomationStepInput = {
appId: string
apiKey?: string
}
export interface AutomationMetadata extends Document {
errorCount?: number
automationChainCount?: number
}

View File

@ -21,4 +21,5 @@ export interface Screen extends Document {
width?: string
routing: ScreenRouting
props: ScreenProps
name?: string
}

View File

@ -0,0 +1,15 @@
import { Automation, AutomationMetadata } from "../../documents"
import { Job } from "bull"
export interface AutomationDataEvent {
appId?: string
metadata?: AutomationMetadata
automation?: Automation
}
export interface AutomationData {
event: AutomationDataEvent
automation: Automation
}
export type AutomationJob = Job<AutomationData>

View File

@ -1,3 +1,4 @@
export * from "./automations"
export * from "./hosting"
export * from "./context"
export * from "./events"

View File

@ -16,6 +16,7 @@ const config: Config.InitialOptions = {
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
"@budibase/backend-core": "<rootDir>/../backend-core/src",
"@budibase/types": "<rootDir>/../types/src",
"@budibase/shared-core": ["<rootDir>/../shared-core/src"],
},
}

View File

@ -18,7 +18,7 @@ export const UserGroup = () => {
apps: [],
color: generator.color(),
icon: generator.word(),
name: generator.word({ length: 2 }),
name: generator.word(),
roles: roles,
users: [],
}

View File

@ -16,11 +16,7 @@
"require": ["tsconfig-paths/register"],
"swc": true
},
"references": [
{ "path": "../types" },
{ "path": "../backend-core" },
{ "path": "../../../budibase-pro/packages/pro" }
],
"references": [{ "path": "../types" }, { "path": "../backend-core" }],
"include": ["src/**/*"],
"exclude": ["dist"]
}

5669
qa-core/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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]

View File

@ -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]
}
}

View File

@ -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
}
}

View File

@ -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]

View File

@ -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]
}
}

View File

@ -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]
}
}

View File

@ -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]
}
}

View File

@ -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]

View File

@ -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]
}
}

View File

@ -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
}

View File

@ -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]
}

View File

@ -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]
}
}

View File

@ -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",

View File

@ -57,7 +57,7 @@ export const expectedSchemaFields = {
running_time_secs: "number",
title: "string",
year: "number",
_id: "json",
_id: "string",
},
postgres: {
address: "string",

View File

@ -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,

View File

@ -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
)

View File

@ -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
)

View File

@ -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!
)

View File

@ -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!
)

View File

@ -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
}

View File

@ -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"

View File

@ -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
}