Type event endpoints

This commit is contained in:
Andrew Kingston 2024-12-02 15:19:33 +00:00
parent dedd5f273a
commit 417286b16d
No known key found for this signature in database
3 changed files with 20 additions and 14 deletions

View File

@ -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,
},
})
},
})

View File

@ -0,0 +1,17 @@
import { EventPublishType, PostEventPublishRequest } from "@budibase/types"
import { BaseAPIClient } from "./types"
export interface EventEndpoints {
publishEvent: (type: EventPublishType) => Promise<void>
}
export const buildEventEndpoints = (API: BaseAPIClient): EventEndpoints => ({
publishEvent: async type => {
return await API.post<PostEventPublishRequest>({
url: `/api/global/event/publish`,
body: {
type,
},
})
},
})

View File

@ -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