From edbcc1f7641a84f646c6b1a026456dbdd02b38e7 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Dec 2024 15:16:14 +0000 Subject: [PATCH] Type template endpoints --- .../src/api/{templates.js => templates.ts} | 21 +++++++++++++++++-- packages/frontend-core/src/api/types.ts | 4 +++- 2 files changed, 22 insertions(+), 3 deletions(-) rename packages/frontend-core/src/api/{templates.js => templates.ts} (52%) diff --git a/packages/frontend-core/src/api/templates.js b/packages/frontend-core/src/api/templates.ts similarity index 52% rename from packages/frontend-core/src/api/templates.js rename to packages/frontend-core/src/api/templates.ts index 660a85d745..dfdc8d26ec 100644 --- a/packages/frontend-core/src/api/templates.js +++ b/packages/frontend-core/src/api/templates.ts @@ -1,4 +1,18 @@ -export const buildTemplateEndpoints = API => ({ +import { Template } from "@budibase/types" +import { BaseAPIClient } from "./types" + +export interface TemplateEndpoints { + getEmailTemplates: () => Promise + + // Missing request or response types + getEmailTemplateDefinitions: () => Promise + saveEmailTemplate: (templaet: any) => Promise + getAppTemplates: () => Promise +} + +export const buildTemplateEndpoints = ( + API: BaseAPIClient +): TemplateEndpoints => ({ /** * Gets the list of email template definitions. */ @@ -10,7 +24,10 @@ export const buildTemplateEndpoints = API => ({ * Gets the list of email templates. */ getEmailTemplates: async () => { - return await API.get({ url: "/api/global/template/email" }) + const res = await API.get