Renaming new type.
This commit is contained in:
parent
165ff4e768
commit
a3df34b350
|
@ -3,7 +3,7 @@ import { downloadTemplate as dlTemplate } from "../../utilities/fileSystem"
|
||||||
import env from "../../environment"
|
import env from "../../environment"
|
||||||
import {
|
import {
|
||||||
DownloadTemplateResponse,
|
DownloadTemplateResponse,
|
||||||
FetchTemplateResponse,
|
FetchGlobalTemplateResponse,
|
||||||
UserCtx,
|
UserCtx,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import {
|
||||||
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: UserCtx<void, FetchTemplateResponse>) {
|
export async function fetch(ctx: UserCtx<void, FetchGlobalTemplateResponse>) {
|
||||||
let type = env.TEMPLATE_REPOSITORY
|
let type = env.TEMPLATE_REPOSITORY
|
||||||
let response,
|
let response,
|
||||||
error = false
|
error = false
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
import { Document, Template } from "../../../documents"
|
import { Template } from "../../../documents"
|
||||||
|
|
||||||
export interface TemplateDefinition {
|
export interface GlobalTemplateDefinition {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
category: string
|
category: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TemplateBinding {
|
export interface GlobalTemplateBinding {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FetchTemplateDefinitionResponse {
|
export interface FetchGlobalTemplateDefinitionResponse {
|
||||||
info: Record<string, TemplateDefinition>
|
info: Record<string, GlobalTemplateDefinition>
|
||||||
bindings: Record<string, TemplateBinding[]>
|
bindings: Record<string, GlobalTemplateBinding[]>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SaveTemplateRequest extends Template {}
|
export interface SaveGlobalTemplateRequest extends Template {}
|
||||||
export interface SaveTemplateResponse extends Template {}
|
export interface SaveGlobalTemplateResponse extends Template {}
|
||||||
|
|
||||||
export type FetchTemplateResponse = Template[]
|
export type FetchGlobalTemplateResponse = Template[]
|
||||||
export type FetchTemplateByTypeResponse = Template[]
|
export type FetchGlobalTemplateByTypeResponse = Template[]
|
||||||
export type FetchTemplateByOwnerIDResponse = Template[]
|
export type FetchGlobalTemplateByOwnerIDResponse = Template[]
|
||||||
|
|
||||||
export interface FindTemplateResponse extends Template {}
|
export interface FindGlobalTemplateResponse extends Template {}
|
||||||
|
|
||||||
export interface DeleteTemplateResponse {
|
export interface DeleteGlobalTemplateResponse {
|
||||||
message: string
|
message: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,21 @@ import {
|
||||||
import { getTemplateByID, getTemplates } from "../../../constants/templates"
|
import { getTemplateByID, getTemplates } from "../../../constants/templates"
|
||||||
import { tenancy, db as dbCore } from "@budibase/backend-core"
|
import { tenancy, db as dbCore } from "@budibase/backend-core"
|
||||||
import {
|
import {
|
||||||
DeleteTemplateResponse,
|
DeleteGlobalTemplateResponse,
|
||||||
FetchTemplateByOwnerIDResponse,
|
FetchGlobalTemplateByOwnerIDResponse,
|
||||||
FetchTemplateByTypeResponse,
|
FetchGlobalTemplateByTypeResponse,
|
||||||
FetchTemplateDefinitionResponse,
|
FetchGlobalTemplateDefinitionResponse,
|
||||||
FetchTemplateResponse,
|
FetchGlobalTemplateResponse,
|
||||||
FindTemplateResponse,
|
FindGlobalTemplateResponse,
|
||||||
SaveTemplateRequest,
|
SaveGlobalTemplateRequest,
|
||||||
SaveTemplateResponse,
|
SaveGlobalTemplateResponse,
|
||||||
TemplateBinding,
|
TemplateBinding,
|
||||||
TemplateDefinition,
|
TemplateDefinition,
|
||||||
UserCtx,
|
UserCtx,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
export async function save(
|
export async function save(
|
||||||
ctx: UserCtx<SaveTemplateRequest, SaveTemplateResponse>
|
ctx: UserCtx<SaveGlobalTemplateRequest, SaveGlobalTemplateResponse>
|
||||||
) {
|
) {
|
||||||
const db = tenancy.getGlobalDB()
|
const db = tenancy.getGlobalDB()
|
||||||
let template = ctx.request.body
|
let template = ctx.request.body
|
||||||
|
@ -39,7 +39,7 @@ export async function save(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function definitions(
|
export async function definitions(
|
||||||
ctx: UserCtx<void, FetchTemplateDefinitionResponse>
|
ctx: UserCtx<void, FetchGlobalTemplateDefinitionResponse>
|
||||||
) {
|
) {
|
||||||
const bindings: Record<string, TemplateBinding[]> = {}
|
const bindings: Record<string, TemplateBinding[]> = {}
|
||||||
const info: Record<string, TemplateDefinition> = {}
|
const info: Record<string, TemplateDefinition> = {}
|
||||||
|
@ -61,12 +61,12 @@ export async function definitions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetch(ctx: UserCtx<void, FetchTemplateResponse>) {
|
export async function fetch(ctx: UserCtx<void, FetchGlobalTemplateResponse>) {
|
||||||
ctx.body = await getTemplates()
|
ctx.body = await getTemplates()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchByType(
|
export async function fetchByType(
|
||||||
ctx: UserCtx<void, FetchTemplateByTypeResponse>
|
ctx: UserCtx<void, FetchGlobalTemplateByTypeResponse>
|
||||||
) {
|
) {
|
||||||
ctx.body = await getTemplates({
|
ctx.body = await getTemplates({
|
||||||
type: ctx.params.type,
|
type: ctx.params.type,
|
||||||
|
@ -74,7 +74,7 @@ export async function fetchByType(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchByOwner(
|
export async function fetchByOwner(
|
||||||
ctx: UserCtx<void, FetchTemplateByOwnerIDResponse>
|
ctx: UserCtx<void, FetchGlobalTemplateByOwnerIDResponse>
|
||||||
) {
|
) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
ctx.body = await getTemplates({
|
ctx.body = await getTemplates({
|
||||||
|
@ -82,11 +82,13 @@ export async function fetchByOwner(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function find(ctx: UserCtx<void, FindTemplateResponse>) {
|
export async function find(ctx: UserCtx<void, FindGlobalTemplateResponse>) {
|
||||||
ctx.body = await getTemplateByID(ctx.params.id)
|
ctx.body = await getTemplateByID(ctx.params.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function destroy(ctx: UserCtx<void, DeleteTemplateResponse>) {
|
export async function destroy(
|
||||||
|
ctx: UserCtx<void, DeleteGlobalTemplateResponse>
|
||||||
|
) {
|
||||||
const db = tenancy.getGlobalDB()
|
const db = tenancy.getGlobalDB()
|
||||||
await db.remove(ctx.params.id, ctx.params.rev)
|
await db.remove(ctx.params.id, ctx.params.rev)
|
||||||
ctx.body = { message: `Template ${ctx.params.id} deleted.` }
|
ctx.body = { message: `Template ${ctx.params.id} deleted.` }
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
import { constants, utils } from "@budibase/backend-core"
|
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.
|
* This is a restricted endpoint in the cloud.
|
||||||
* Ensure that the correct API key has been supplied.
|
* 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) {
|
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
|
||||||
const apiKey = ctx.request.headers[constants.Header.API_KEY]
|
const apiKey = ctx.request.headers[constants.Header.API_KEY]
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
|
|
Loading…
Reference in New Issue