Type template endpoints

This commit is contained in:
Andrew Kingston 2024-12-03 15:16:14 +00:00
parent ef28b033ac
commit edbcc1f764
No known key found for this signature in database
2 changed files with 22 additions and 3 deletions

View File

@ -1,4 +1,18 @@
export const buildTemplateEndpoints = API => ({ import { Template } from "@budibase/types"
import { BaseAPIClient } from "./types"
export interface TemplateEndpoints {
getEmailTemplates: () => Promise<Template[]>
// Missing request or response types
getEmailTemplateDefinitions: () => Promise<any>
saveEmailTemplate: (templaet: any) => Promise<any>
getAppTemplates: () => Promise<any>
}
export const buildTemplateEndpoints = (
API: BaseAPIClient
): TemplateEndpoints => ({
/** /**
* Gets the list of email template definitions. * Gets the list of email template definitions.
*/ */
@ -10,7 +24,10 @@ export const buildTemplateEndpoints = API => ({
* Gets the list of email templates. * Gets the list of email templates.
*/ */
getEmailTemplates: async () => { getEmailTemplates: async () => {
return await API.get({ url: "/api/global/template/email" }) const res = await API.get<Template | Template[]>({
url: "/api/global/template/email",
})
return Array.isArray(res) ? res : [res]
}, },
/** /**

View File

@ -28,6 +28,7 @@ import { RowEndpoints } from "./rows"
import { ScreenEndpoints } from "./screens" import { ScreenEndpoints } from "./screens"
import { SelfEndpoints } from "./self" import { SelfEndpoints } from "./self"
import { TableEndpoints } from "./tables" import { TableEndpoints } from "./tables"
import { TemplateEndpoints } from "./templates"
export enum HTTPMethod { export enum HTTPMethod {
POST = "POST", POST = "POST",
@ -126,4 +127,5 @@ export type APIClient = BaseAPIClient &
RowEndpoints & RowEndpoints &
ScreenEndpoints & ScreenEndpoints &
SelfEndpoints & SelfEndpoints &
TableEndpoints & { rowActions: RowActionEndpoints; [key: string]: any } TableEndpoints &
TemplateEndpoints & { rowActions: RowActionEndpoints; [key: string]: any }