diff --git a/packages/server/src/api/controllers/templates.ts b/packages/server/src/api/controllers/templates.ts index 6774fa2766..8008b63fd3 100644 --- a/packages/server/src/api/controllers/templates.ts +++ b/packages/server/src/api/controllers/templates.ts @@ -1,13 +1,17 @@ import nodeFetch from "node-fetch" import { downloadTemplate as dlTemplate } from "../../utilities/fileSystem" import env from "../../environment" -import { BBContext } from "@budibase/types" +import { + DownloadTemplateResponse, + FetchTemplateResponse, + UserCtx, +} from "@budibase/types" // development flag, can be used to test against templates exported locally const DEFAULT_TEMPLATES_BUCKET = "prod-budi-templates.s3-eu-west-1.amazonaws.com" -export async function fetch(ctx: BBContext) { +export async function fetch(ctx: UserCtx) { let type = env.TEMPLATE_REPOSITORY let response, error = false @@ -32,7 +36,9 @@ export async function fetch(ctx: BBContext) { // can't currently test this, have to ignore from coverage /* istanbul ignore next */ -export async function downloadTemplate(ctx: BBContext) { +export async function downloadTemplate( + ctx: UserCtx +) { const { type, name } = ctx.params await dlTemplate(type, name) diff --git a/packages/types/src/api/web/application.ts b/packages/types/src/api/web/app/application.ts similarity index 93% rename from packages/types/src/api/web/application.ts rename to packages/types/src/api/web/app/application.ts index ed999ee574..bc00ade217 100644 --- a/packages/types/src/api/web/application.ts +++ b/packages/types/src/api/web/app/application.ts @@ -1,5 +1,5 @@ -import type { PlanType } from "../../sdk" -import type { Layout, App, Screen } from "../../documents" +import type { PlanType } from "../../../sdk" +import type { Layout, App, Screen } from "../../../documents" import { ReadStream } from "fs" export interface SyncAppResponse { diff --git a/packages/types/src/api/web/app/automation.ts b/packages/types/src/api/web/app/automation.ts index c10f19c88d..40f69fc467 100644 --- a/packages/types/src/api/web/app/automation.ts +++ b/packages/types/src/api/web/app/automation.ts @@ -1,9 +1,14 @@ import { + Automation, AutomationActionStepId, + AutomationLogPage, + AutomationStatus, AutomationStepDefinition, AutomationTriggerDefinition, AutomationTriggerStepId, + Row, } from "../../../documents" +import { DocumentDestroyResponse } from "@budibase/nano" export type GetAutomationTriggerDefinitionsResponse = Record< keyof typeof AutomationTriggerStepId, @@ -19,3 +24,54 @@ export interface GetAutomationStepDefinitionsResponse { trigger: GetAutomationTriggerDefinitionsResponse action: GetAutomationActionDefinitionsResponse } + +export interface DeleteAutomationResponse extends DocumentDestroyResponse {} + +export interface FetchAutomationResponse { + automations: Automation[] +} + +export interface FindAutomationResponse extends Automation {} + +export interface UpdateAutomationRequest extends Automation {} +export interface UpdateAutomationResponse { + message: string + automation: Automation +} + +export interface CreateAutomationRequest extends Automation {} +export interface CreateAutomationResponse { + message: string + automation: Automation +} + +export interface SearchAutomationLogsRequest { + startDate?: string + status?: AutomationStatus + automationId?: string + page?: string +} +export interface SearchAutomationLogsResponse extends AutomationLogPage {} + +export interface ClearAutomationLogRequest { + automationId: string + appId: string +} +export interface ClearAutomationLogResponse { + message: string +} + +export interface TriggerAutomationRequest { + fields: Record + // time in seconds + timeout: number +} +export type TriggerAutomationResponse = Record | undefined + +export interface TestAutomationRequest { + id?: string + revision?: string + fields: Record + row?: Row +} +export interface TestAutomationResponse {} diff --git a/packages/types/src/api/web/deployment.ts b/packages/types/src/api/web/app/deployment.ts similarity index 78% rename from packages/types/src/api/web/deployment.ts rename to packages/types/src/api/web/app/deployment.ts index f5ed9242b1..eed3f6eb77 100644 --- a/packages/types/src/api/web/deployment.ts +++ b/packages/types/src/api/web/app/deployment.ts @@ -1,4 +1,4 @@ -import { DeploymentDoc, DeploymentStatus } from "../../documents" +import { DeploymentDoc, DeploymentStatus } from "../../../documents" export interface PublishAppResponse extends DeploymentDoc {} diff --git a/packages/types/src/api/web/app/index.ts b/packages/types/src/api/web/app/index.ts index d130d19a42..90dfd7833e 100644 --- a/packages/types/src/api/web/app/index.ts +++ b/packages/types/src/api/web/app/index.ts @@ -13,3 +13,7 @@ export * from "./integration" export * from "./metadata" export * from "./query" export * from "./screen" +export * from "./application" +export * from "./layout" +export * from "./deployment" +export * from "./role" diff --git a/packages/types/src/api/web/layout.ts b/packages/types/src/api/web/app/layout.ts similarity index 79% rename from packages/types/src/api/web/layout.ts rename to packages/types/src/api/web/app/layout.ts index 45f7fb9d0a..3067a1f49f 100644 --- a/packages/types/src/api/web/layout.ts +++ b/packages/types/src/api/web/app/layout.ts @@ -1,4 +1,4 @@ -import { Layout } from "../../documents" +import { Layout } from "../../../documents" export interface SaveLayoutRequest extends Layout {} diff --git a/packages/types/src/api/web/role.ts b/packages/types/src/api/web/app/role.ts similarity index 79% rename from packages/types/src/api/web/role.ts rename to packages/types/src/api/web/app/role.ts index eeedaea163..f23b2fd232 100644 --- a/packages/types/src/api/web/role.ts +++ b/packages/types/src/api/web/app/role.ts @@ -1,5 +1,5 @@ -import { Role, RoleUIMetadata } from "../../documents" -import { PermissionLevel, BuiltinPermissionID } from "../../sdk" +import { Role, RoleUIMetadata } from "../../../documents" +import { PermissionLevel, BuiltinPermissionID } from "../../../sdk" export interface SaveRoleRequest { _id?: string diff --git a/packages/types/src/api/web/automation.ts b/packages/types/src/api/web/automation.ts deleted file mode 100644 index 0f0699939e..0000000000 --- a/packages/types/src/api/web/automation.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { DocumentDestroyResponse } from "@budibase/nano" -import { - Automation, - AutomationLogPage, - AutomationStatus, - Row, -} from "../../documents" - -export interface DeleteAutomationResponse extends DocumentDestroyResponse {} - -export interface FetchAutomationResponse { - automations: Automation[] -} - -export interface FindAutomationResponse extends Automation {} - -export interface UpdateAutomationRequest extends Automation {} -export interface UpdateAutomationResponse { - message: string - automation: Automation -} - -export interface CreateAutomationRequest extends Automation {} -export interface CreateAutomationResponse { - message: string - automation: Automation -} - -export interface SearchAutomationLogsRequest { - startDate?: string - status?: AutomationStatus - automationId?: string - page?: string -} -export interface SearchAutomationLogsResponse extends AutomationLogPage {} - -export interface ClearAutomationLogRequest { - automationId: string - appId: string -} -export interface ClearAutomationLogResponse { - message: string -} - -export interface TriggerAutomationRequest { - fields: Record - // time in seconds - timeout: number -} -export type TriggerAutomationResponse = Record | undefined - -export interface TestAutomationRequest { - id?: string - revision?: string - fields: Record - row?: Row -} -export interface TestAutomationResponse {} diff --git a/packages/types/src/api/web/index.ts b/packages/types/src/api/web/index.ts index dd2ee3beae..9fcfb77f4f 100644 --- a/packages/types/src/api/web/index.ts +++ b/packages/types/src/api/web/index.ts @@ -1,4 +1,3 @@ -export * from "./application" export * from "./analytics" export * from "./auth" export * from "./user" @@ -11,10 +10,7 @@ export * from "./global" export * from "./pagination" export * from "./searchFilter" export * from "./cookies" -export * from "./automation" -export * from "./layout" -export * from "./role" export * from "./plugins" export * from "./apikeys" -export * from "./deployment" export * from "./dev" +export * from "./template" diff --git a/packages/types/src/api/web/template.ts b/packages/types/src/api/web/template.ts new file mode 100644 index 0000000000..bd5fdf1cb0 --- /dev/null +++ b/packages/types/src/api/web/template.ts @@ -0,0 +1,5 @@ +export interface FetchTemplateResponse {} + +export interface DownloadTemplateResponse { + message: string +}