From a3df34b3509daa084bf896321846c8d1a85be835 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 6 Dec 2024 10:50:39 +0000 Subject: [PATCH] Renaming new type. --- .../server/src/api/controllers/templates.ts | 4 +-- packages/types/src/api/web/global/template.ts | 26 +++++++-------- .../src/api/controllers/global/templates.ts | 32 ++++++++++--------- .../worker/src/middleware/cloudRestricted.ts | 4 +-- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/packages/server/src/api/controllers/templates.ts b/packages/server/src/api/controllers/templates.ts index 8008b63fd3..fd3e28aa55 100644 --- a/packages/server/src/api/controllers/templates.ts +++ b/packages/server/src/api/controllers/templates.ts @@ -3,7 +3,7 @@ import { downloadTemplate as dlTemplate } from "../../utilities/fileSystem" import env from "../../environment" import { DownloadTemplateResponse, - FetchTemplateResponse, + FetchGlobalTemplateResponse, UserCtx, } from "@budibase/types" @@ -11,7 +11,7 @@ import { const DEFAULT_TEMPLATES_BUCKET = "prod-budi-templates.s3-eu-west-1.amazonaws.com" -export async function fetch(ctx: UserCtx) { +export async function fetch(ctx: UserCtx) { let type = env.TEMPLATE_REPOSITORY let response, error = false diff --git a/packages/types/src/api/web/global/template.ts b/packages/types/src/api/web/global/template.ts index 0e79cbe62d..069e6d3d1b 100644 --- a/packages/types/src/api/web/global/template.ts +++ b/packages/types/src/api/web/global/template.ts @@ -1,30 +1,30 @@ -import { Document, Template } from "../../../documents" +import { Template } from "../../../documents" -export interface TemplateDefinition { +export interface GlobalTemplateDefinition { name: string description: string category: string } -export interface TemplateBinding { +export interface GlobalTemplateBinding { name: string description: string } -export interface FetchTemplateDefinitionResponse { - info: Record - bindings: Record +export interface FetchGlobalTemplateDefinitionResponse { + info: Record + bindings: Record } -export interface SaveTemplateRequest extends Template {} -export interface SaveTemplateResponse extends Template {} +export interface SaveGlobalTemplateRequest extends Template {} +export interface SaveGlobalTemplateResponse extends Template {} -export type FetchTemplateResponse = Template[] -export type FetchTemplateByTypeResponse = Template[] -export type FetchTemplateByOwnerIDResponse = Template[] +export type FetchGlobalTemplateResponse = Template[] +export type FetchGlobalTemplateByTypeResponse = Template[] +export type FetchGlobalTemplateByOwnerIDResponse = Template[] -export interface FindTemplateResponse extends Template {} +export interface FindGlobalTemplateResponse extends Template {} -export interface DeleteTemplateResponse { +export interface DeleteGlobalTemplateResponse { message: string } diff --git a/packages/worker/src/api/controllers/global/templates.ts b/packages/worker/src/api/controllers/global/templates.ts index 5fba215e96..e175773723 100644 --- a/packages/worker/src/api/controllers/global/templates.ts +++ b/packages/worker/src/api/controllers/global/templates.ts @@ -6,21 +6,21 @@ import { import { getTemplateByID, getTemplates } from "../../../constants/templates" import { tenancy, db as dbCore } from "@budibase/backend-core" import { - DeleteTemplateResponse, - FetchTemplateByOwnerIDResponse, - FetchTemplateByTypeResponse, - FetchTemplateDefinitionResponse, - FetchTemplateResponse, - FindTemplateResponse, - SaveTemplateRequest, - SaveTemplateResponse, + DeleteGlobalTemplateResponse, + FetchGlobalTemplateByOwnerIDResponse, + FetchGlobalTemplateByTypeResponse, + FetchGlobalTemplateDefinitionResponse, + FetchGlobalTemplateResponse, + FindGlobalTemplateResponse, + SaveGlobalTemplateRequest, + SaveGlobalTemplateResponse, TemplateBinding, TemplateDefinition, UserCtx, } from "@budibase/types" export async function save( - ctx: UserCtx + ctx: UserCtx ) { const db = tenancy.getGlobalDB() let template = ctx.request.body @@ -39,7 +39,7 @@ export async function save( } export async function definitions( - ctx: UserCtx + ctx: UserCtx ) { const bindings: Record = {} const info: Record = {} @@ -61,12 +61,12 @@ export async function definitions( } } -export async function fetch(ctx: UserCtx) { +export async function fetch(ctx: UserCtx) { ctx.body = await getTemplates() } export async function fetchByType( - ctx: UserCtx + ctx: UserCtx ) { ctx.body = await getTemplates({ type: ctx.params.type, @@ -74,7 +74,7 @@ export async function fetchByType( } export async function fetchByOwner( - ctx: UserCtx + ctx: UserCtx ) { // @ts-ignore ctx.body = await getTemplates({ @@ -82,11 +82,13 @@ export async function fetchByOwner( }) } -export async function find(ctx: UserCtx) { +export async function find(ctx: UserCtx) { ctx.body = await getTemplateByID(ctx.params.id) } -export async function destroy(ctx: UserCtx) { +export async function destroy( + ctx: UserCtx +) { const db = tenancy.getGlobalDB() await db.remove(ctx.params.id, ctx.params.rev) ctx.body = { message: `Template ${ctx.params.id} deleted.` } diff --git a/packages/worker/src/middleware/cloudRestricted.ts b/packages/worker/src/middleware/cloudRestricted.ts index f9ab86e2e9..747510479e 100644 --- a/packages/worker/src/middleware/cloudRestricted.ts +++ b/packages/worker/src/middleware/cloudRestricted.ts @@ -1,12 +1,12 @@ import env from "../environment" import { constants, utils } from "@budibase/backend-core" -import { BBContext } from "@budibase/types" +import { UserCtx } from "@budibase/types" /** * This is a restricted endpoint in the cloud. * Ensure that the correct API key has been supplied. */ -export default async (ctx: BBContext, next: any) => { +export default async (ctx: UserCtx, next: any) => { if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) { const apiKey = ctx.request.headers[constants.Header.API_KEY] if (!apiKey) {