Moving some types around - make sure app types are all correctly filed away.

This commit is contained in:
mike12345567 2024-12-04 14:27:09 +00:00
parent a8ef736051
commit fdb328aaa1
10 changed files with 81 additions and 72 deletions

View File

@ -1,13 +1,17 @@
import nodeFetch from "node-fetch" import nodeFetch from "node-fetch"
import { downloadTemplate as dlTemplate } from "../../utilities/fileSystem" import { downloadTemplate as dlTemplate } from "../../utilities/fileSystem"
import env from "../../environment" 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 // development flag, can be used to test against templates exported locally
const DEFAULT_TEMPLATES_BUCKET = const DEFAULT_TEMPLATES_BUCKET =
"prod-budi-templates.s3-eu-west-1.amazonaws.com" "prod-budi-templates.s3-eu-west-1.amazonaws.com"
export async function fetch(ctx: BBContext) { export async function fetch(ctx: UserCtx<void, FetchTemplateResponse>) {
let type = env.TEMPLATE_REPOSITORY let type = env.TEMPLATE_REPOSITORY
let response, let response,
error = false error = false
@ -32,7 +36,9 @@ export async function fetch(ctx: BBContext) {
// can't currently test this, have to ignore from coverage // can't currently test this, have to ignore from coverage
/* istanbul ignore next */ /* istanbul ignore next */
export async function downloadTemplate(ctx: BBContext) { export async function downloadTemplate(
ctx: UserCtx<void, DownloadTemplateResponse>
) {
const { type, name } = ctx.params const { type, name } = ctx.params
await dlTemplate(type, name) await dlTemplate(type, name)

View File

@ -1,5 +1,5 @@
import type { PlanType } from "../../sdk" import type { PlanType } from "../../../sdk"
import type { Layout, App, Screen } from "../../documents" import type { Layout, App, Screen } from "../../../documents"
import { ReadStream } from "fs" import { ReadStream } from "fs"
export interface SyncAppResponse { export interface SyncAppResponse {

View File

@ -1,9 +1,14 @@
import { import {
Automation,
AutomationActionStepId, AutomationActionStepId,
AutomationLogPage,
AutomationStatus,
AutomationStepDefinition, AutomationStepDefinition,
AutomationTriggerDefinition, AutomationTriggerDefinition,
AutomationTriggerStepId, AutomationTriggerStepId,
Row,
} from "../../../documents" } from "../../../documents"
import { DocumentDestroyResponse } from "@budibase/nano"
export type GetAutomationTriggerDefinitionsResponse = Record< export type GetAutomationTriggerDefinitionsResponse = Record<
keyof typeof AutomationTriggerStepId, keyof typeof AutomationTriggerStepId,
@ -19,3 +24,54 @@ export interface GetAutomationStepDefinitionsResponse {
trigger: GetAutomationTriggerDefinitionsResponse trigger: GetAutomationTriggerDefinitionsResponse
action: GetAutomationActionDefinitionsResponse 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<string, any>
// time in seconds
timeout: number
}
export type TriggerAutomationResponse = Record<string, any> | undefined
export interface TestAutomationRequest {
id?: string
revision?: string
fields: Record<string, any>
row?: Row
}
export interface TestAutomationResponse {}

View File

@ -1,4 +1,4 @@
import { DeploymentDoc, DeploymentStatus } from "../../documents" import { DeploymentDoc, DeploymentStatus } from "../../../documents"
export interface PublishAppResponse extends DeploymentDoc {} export interface PublishAppResponse extends DeploymentDoc {}

View File

@ -13,3 +13,7 @@ export * from "./integration"
export * from "./metadata" export * from "./metadata"
export * from "./query" export * from "./query"
export * from "./screen" export * from "./screen"
export * from "./application"
export * from "./layout"
export * from "./deployment"
export * from "./role"

View File

@ -1,4 +1,4 @@
import { Layout } from "../../documents" import { Layout } from "../../../documents"
export interface SaveLayoutRequest extends Layout {} export interface SaveLayoutRequest extends Layout {}

View File

@ -1,5 +1,5 @@
import { Role, RoleUIMetadata } from "../../documents" import { Role, RoleUIMetadata } from "../../../documents"
import { PermissionLevel, BuiltinPermissionID } from "../../sdk" import { PermissionLevel, BuiltinPermissionID } from "../../../sdk"
export interface SaveRoleRequest { export interface SaveRoleRequest {
_id?: string _id?: string

View File

@ -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<string, any>
// time in seconds
timeout: number
}
export type TriggerAutomationResponse = Record<string, any> | undefined
export interface TestAutomationRequest {
id?: string
revision?: string
fields: Record<string, any>
row?: Row
}
export interface TestAutomationResponse {}

View File

@ -1,4 +1,3 @@
export * from "./application"
export * from "./analytics" export * from "./analytics"
export * from "./auth" export * from "./auth"
export * from "./user" export * from "./user"
@ -11,10 +10,7 @@ export * from "./global"
export * from "./pagination" export * from "./pagination"
export * from "./searchFilter" export * from "./searchFilter"
export * from "./cookies" export * from "./cookies"
export * from "./automation"
export * from "./layout"
export * from "./role"
export * from "./plugins" export * from "./plugins"
export * from "./apikeys" export * from "./apikeys"
export * from "./deployment"
export * from "./dev" export * from "./dev"
export * from "./template"

View File

@ -0,0 +1,5 @@
export interface FetchTemplateResponse {}
export interface DownloadTemplateResponse {
message: string
}