Update automation endpoints with new types
This commit is contained in:
parent
dcb9fd2c53
commit
0da9ad02a7
|
@ -1,19 +1,30 @@
|
||||||
import {
|
import {
|
||||||
Automation,
|
ClearAutomationLogRequest,
|
||||||
AutomationLogPage,
|
ClearAutomationLogResponse,
|
||||||
|
CreateAutomationRequest,
|
||||||
|
CreateAutomationResponse,
|
||||||
DeleteAutomationResponse,
|
DeleteAutomationResponse,
|
||||||
FetchAutomationResponse,
|
FetchAutomationResponse,
|
||||||
|
GetAutomationStepDefinitionsResponse,
|
||||||
|
SearchAutomationLogsRequest,
|
||||||
|
SearchAutomationLogsResponse,
|
||||||
|
TestAutomationRequest,
|
||||||
|
TestAutomationResponse,
|
||||||
|
TriggerAutomationRequest,
|
||||||
|
TriggerAutomationResponse,
|
||||||
|
UpdateAutomationRequest,
|
||||||
|
UpdateAutomationResponse,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { BaseAPIClient } from "./types"
|
import { BaseAPIClient } from "./types"
|
||||||
|
|
||||||
export interface AutomationEndpoints {
|
export interface AutomationEndpoints {
|
||||||
getAutomations: () => Promise<FetchAutomationResponse>
|
getAutomations: () => Promise<FetchAutomationResponse>
|
||||||
createAutomation: (
|
createAutomation: (
|
||||||
automation: Automation
|
automation: CreateAutomationRequest
|
||||||
) => Promise<{ message: string; automation: Automation }>
|
) => Promise<CreateAutomationResponse>
|
||||||
updateAutomation: (
|
updateAutomation: (
|
||||||
automation: Automation
|
automation: UpdateAutomationRequest
|
||||||
) => Promise<{ message: string; automation: Automation }>
|
) => Promise<UpdateAutomationResponse>
|
||||||
deleteAutomation: (
|
deleteAutomation: (
|
||||||
automationId: string,
|
automationId: string,
|
||||||
automationRev: string
|
automationRev: string
|
||||||
|
@ -21,20 +32,20 @@ export interface AutomationEndpoints {
|
||||||
clearAutomationLogErrors: (
|
clearAutomationLogErrors: (
|
||||||
automationId: string,
|
automationId: string,
|
||||||
appId: string
|
appId: string
|
||||||
) => Promise<{ message: string }>
|
) => Promise<ClearAutomationLogResponse>
|
||||||
|
|
||||||
// Missing request or response types
|
|
||||||
triggerAutomation: (
|
triggerAutomation: (
|
||||||
automationId: string,
|
automationId: string,
|
||||||
fields: Record<string, any>,
|
fields: Record<string, any>,
|
||||||
timeout?: number
|
timeout: number
|
||||||
) => Promise<any>
|
) => Promise<TriggerAutomationResponse>
|
||||||
testAutomation: (
|
testAutomation: (
|
||||||
automationdId: string,
|
automationdId: string,
|
||||||
testData: Record<string, any>
|
data: TestAutomationRequest
|
||||||
) => Promise<any>
|
) => Promise<TestAutomationResponse>
|
||||||
getAutomationDefinitions: () => Promise<any>
|
getAutomationDefinitions: () => Promise<GetAutomationStepDefinitionsResponse>
|
||||||
getAutomationLogs: (options: any) => Promise<AutomationLogPage>
|
getAutomationLogs: (
|
||||||
|
options: SearchAutomationLogsRequest
|
||||||
|
) => Promise<SearchAutomationLogsResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buildAutomationEndpoints = (
|
export const buildAutomationEndpoints = (
|
||||||
|
@ -44,10 +55,10 @@ export const buildAutomationEndpoints = (
|
||||||
* Executes an automation. Must have "App Action" trigger.
|
* Executes an automation. Must have "App Action" trigger.
|
||||||
* @param automationId the ID of the automation to trigger
|
* @param automationId the ID of the automation to trigger
|
||||||
* @param fields the fields to trigger the automation with
|
* @param fields the fields to trigger the automation with
|
||||||
* @param timeout an optional timeout override
|
* @param timeout a timeout override
|
||||||
*/
|
*/
|
||||||
triggerAutomation: async (automationId, fields, timeout) => {
|
triggerAutomation: async (automationId, fields, timeout) => {
|
||||||
return await API.post({
|
return await API.post<TriggerAutomationRequest, TriggerAutomationResponse>({
|
||||||
url: `/api/automations/${automationId}/trigger`,
|
url: `/api/automations/${automationId}/trigger`,
|
||||||
body: { fields, timeout },
|
body: { fields, timeout },
|
||||||
})
|
})
|
||||||
|
@ -56,12 +67,12 @@ export const buildAutomationEndpoints = (
|
||||||
/**
|
/**
|
||||||
* Tests an automation with data.
|
* Tests an automation with data.
|
||||||
* @param automationId the ID of the automation to test
|
* @param automationId the ID of the automation to test
|
||||||
* @param testData the test data to run against the automation
|
* @param data the test data to run against the automation
|
||||||
*/
|
*/
|
||||||
testAutomation: async (automationId, testData) => {
|
testAutomation: async (automationId, data) => {
|
||||||
return await API.post({
|
return await API.post({
|
||||||
url: `/api/automations/${automationId}/test`,
|
url: `/api/automations/${automationId}/test`,
|
||||||
body: testData,
|
body: data,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -118,20 +129,11 @@ export const buildAutomationEndpoints = (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the logs for the app, or by automation ID.
|
* Get the logs for the app, or by automation ID.
|
||||||
* @param automationId The ID of the automation to get logs for.
|
|
||||||
* @param startDate An ISO date string to state the start of the date range.
|
|
||||||
* @param status The status, error or success.
|
|
||||||
* @param page The page to retrieve.
|
|
||||||
*/
|
*/
|
||||||
getAutomationLogs: async ({ automationId, startDate, status, page }) => {
|
getAutomationLogs: async data => {
|
||||||
return await API.post({
|
return await API.post({
|
||||||
url: "/api/automations/logs/search",
|
url: "/api/automations/logs/search",
|
||||||
body: {
|
body: data,
|
||||||
automationId,
|
|
||||||
startDate,
|
|
||||||
status,
|
|
||||||
page,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -142,7 +144,10 @@ export const buildAutomationEndpoints = (
|
||||||
* @param appId The app ID to clear errors for.
|
* @param appId The app ID to clear errors for.
|
||||||
*/
|
*/
|
||||||
clearAutomationLogErrors: async (automationId, appId) => {
|
clearAutomationLogErrors: async (automationId, appId) => {
|
||||||
return await API.delete({
|
return await API.delete<
|
||||||
|
ClearAutomationLogRequest,
|
||||||
|
ClearAutomationLogResponse
|
||||||
|
>({
|
||||||
url: "/api/automations/logs",
|
url: "/api/automations/logs",
|
||||||
body: {
|
body: {
|
||||||
appId,
|
appId,
|
||||||
|
|
Loading…
Reference in New Issue