From 417286b16d24f1e00cce26be57e74af115334e47 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Dec 2024 15:19:33 +0000 Subject: [PATCH] Type event endpoints --- packages/frontend-core/src/api/events.js | 13 ------------- packages/frontend-core/src/api/events.ts | 17 +++++++++++++++++ packages/frontend-core/src/api/types.ts | 4 +++- 3 files changed, 20 insertions(+), 14 deletions(-) delete mode 100644 packages/frontend-core/src/api/events.js create mode 100644 packages/frontend-core/src/api/events.ts diff --git a/packages/frontend-core/src/api/events.js b/packages/frontend-core/src/api/events.js deleted file mode 100644 index 3f17722d3e..0000000000 --- a/packages/frontend-core/src/api/events.js +++ /dev/null @@ -1,13 +0,0 @@ -export const buildEventEndpoints = API => ({ - /** - * Publish a specific event to the backend. - */ - publishEvent: async eventType => { - return await API.post({ - url: `/api/global/event/publish`, - body: { - type: eventType, - }, - }) - }, -}) diff --git a/packages/frontend-core/src/api/events.ts b/packages/frontend-core/src/api/events.ts new file mode 100644 index 0000000000..9e6cc40de3 --- /dev/null +++ b/packages/frontend-core/src/api/events.ts @@ -0,0 +1,17 @@ +import { EventPublishType, PostEventPublishRequest } from "@budibase/types" +import { BaseAPIClient } from "./types" + +export interface EventEndpoints { + publishEvent: (type: EventPublishType) => Promise +} + +export const buildEventEndpoints = (API: BaseAPIClient): EventEndpoints => ({ + publishEvent: async type => { + return await API.post({ + url: `/api/global/event/publish`, + body: { + type, + }, + }) + }, +}) diff --git a/packages/frontend-core/src/api/types.ts b/packages/frontend-core/src/api/types.ts index 192576731c..9c71ed4e25 100644 --- a/packages/frontend-core/src/api/types.ts +++ b/packages/frontend-core/src/api/types.ts @@ -9,6 +9,7 @@ import { BackupEndpoints } from "./backups" import { ConfigEndpoints } from "./configs" import { DatasourceEndpoints } from "./datasources" import { EnvironmentVariableEndpoints } from "./environmentVariables" +import { EventEndpoints } from "./events" export enum HTTPMethod { POST = "POST", @@ -79,4 +80,5 @@ export type APIClient = BaseAPIClient & BackupEndpoints & ConfigEndpoints & DatasourceEndpoints & - EnvironmentVariableEndpoints + EnvironmentVariableEndpoints & + EventEndpoints