Skip to content
10 changes: 5 additions & 5 deletions src/automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const routes = prepareRoutes({
flowInstances : '/api/app/:appId/automation/flow/:flowId/version/:versionId/analytics/instances/find',
countInstances : '/api/app/:appId/automation/flow/:flowId/version/:versionId/analytics/instances/count',
flowInstance : '/api/app/:appId/automation/flow/:flowId/version/:versionId/analytics/instances/:executionId',
stopInstanceExecution : '/api/app/:appId/automation/flow/:flowId/version/:versionId/instances/:executionId/stop',

elementExecutionInfo: '/api/app/:appId/automation/flow/:flowId/version/:versionId/analytics/instances/:executionId/element/:elementId',
flowSlA : '/api/app/:appId/automation/flow/:flowId/version/:versionId/sla/goals',
Expand All @@ -38,7 +39,6 @@ const routes = prepareRoutes({
debugExecutionContext: '/api/app/:appId/automation/flow/:flowId/version/:versionId/debug/test-monitor/execution-context',
runElementInDebugMode: '/api/app/:appId/automation/flow/:flowId/version/:versionId/debug/run/element/:elementId',

allowedAIModels : '/api/app/:appId/automation/ai/assistants/allowed-models',
registerAIAssistant: '/api/app/:appId/automation/ai/assistants/register',
aiAssistants : '/api/app/:appId/automation/ai/assistants',
aiAssistant : '/api/app/:appId/automation/ai/assistants/:id',
Expand Down Expand Up @@ -156,6 +156,10 @@ export default req => ({
return req.automation.get(routes.flowInstance(appId, flowId, versionId, executionId))
},

stopFlowInstanceExecution(appId, flowId, versionId, executionId) {
return req.automation.post(routes.stopInstanceExecution(appId, flowId, versionId, executionId))
},

cleanFlowVersionAnalytics(appId, flowId, versionId) {
return req.automation.delete(routes.flowVersionAnalytics(appId, flowId, versionId))
},
Expand Down Expand Up @@ -249,10 +253,6 @@ export default req => ({
return req.automation.delete(routes.SLACalendar(appId, id))
},

getAllowedAIModels(appId) {
return req.automation.get(routes.allowedAIModels(appId))
},

registerAIAssistant(appId, openAiAssistantId) {
return req.automation.post(routes.registerAIAssistant(appId), { openAiAssistantId })
},
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import consolePreview from './console-preview'
import quickApps from './quick-apps'
import frExtensions from './fr-extensions'
import mcpServices from './mcp-services'
import webhooks from './webhooks'

import { community } from './community'
import { marketplace } from './marketplace'
Expand Down Expand Up @@ -222,6 +223,7 @@ const createClient = (serverUrl, authKey, options) => {
consolePreview : consolePreview(request),
quickApps : quickApps(request),
integrations : integrations(request),
webhooks : webhooks(request),
pdf : pdf(request),
frExtensions : frExtensions(request),
mcpServices : mcpServices(request)
Expand Down
5 changes: 2 additions & 3 deletions src/integrations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { prepareRoutes } from './utils/routes'

const routes = prepareRoutes({
integrations : '/:appId/console/integrations',
integration : '/:appId/console/integrations/:name',
integrations: '/:appId/console/integrations',
integration : '/:appId/console/integrations/:name',
})

export default req => ({
Expand All @@ -21,5 +21,4 @@ export default req => ({
deleteIntegration(appId, name) {
return req.delete(routes.integration(appId, name))
},

})
29 changes: 29 additions & 0 deletions src/webhooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { prepareRoutes } from './utils/routes'

const routes = prepareRoutes({
webhooks : '/:appId/console/webhook',
operations: '/:appId/console/webhook/operations',
webhook : '/:appId/console/webhook/:webhookId',
})

export default req => ({
getWebhooks(appId) {
return req.get(routes.webhooks(appId))
},

getWebhookOperations(appId) {
return req.get(routes.operations(appId))
},

saveWebhook(appId, configData) {
return req.post(routes.webhooks(appId), configData)
},

updateWebhook(appId, webhookId, configData) {
return req.put(routes.webhook(appId, webhookId), configData)
},

deleteWebhook(appId, webhookId) {
return req.delete(routes.webhook(appId, webhookId))
},
})
54 changes: 32 additions & 22 deletions tests/specs/automation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,27 @@ describe('apiClient.automation', () => {
})
})

describe('stopFlowInstanceExecution', () => {
it('should make POST request to stop flow instance execution', async () => {
mockSuccessAPIRequest(successResult)

const result = await automationAPI.stopFlowInstanceExecution(appId, flowId, versionId, executionId)

expect(result).toEqual(successResult)
expect(apiRequestCalls()).toEqual([
{
path: `http://test-host:3000/api/app/${appId}/automation/flow/${flowId}/version/${versionId}/instances/${executionId}/stop`,
body: undefined,
method: 'POST',
encoding: 'utf8',
headers: {},
timeout: 0,
withCredentials: false
}
])
})
})

describe('cleanFlowVersionAnalytics', () => {
it('should make DELETE request to clean flow version analytics', async () => {
mockSuccessAPIRequest(successResult)
Expand Down Expand Up @@ -868,27 +889,6 @@ describe('apiClient.automation', () => {
})

describe('AI Assistant Methods', () => {
describe('getAllowedAIModels', () => {
it('should make GET request to get allowed AI models', async () => {
mockSuccessAPIRequest(successResult)

const result = await automationAPI.getAllowedAIModels(appId)

expect(result).toEqual(successResult)
expect(apiRequestCalls()).toEqual([
{
path: `http://test-host:3000/api/app/${appId}/automation/ai/assistants/allowed-models`,
body: undefined,
method: 'GET',
encoding: 'utf8',
headers: {},
timeout: 0,
withCredentials: false
}
])
})
})

describe('registerAIAssistant', () => {
it('should make POST request to register AI assistant', async () => {
mockSuccessAPIRequest(successResult)
Expand Down Expand Up @@ -1602,6 +1602,16 @@ describe('apiClient.automation', () => {
expect(error.status).toBe(500)
expect(error.message).toBe('Internal server error')
})

it('stopFlowInstanceExecution fails with not found error', async () => {
mockFailedAPIRequest('Flow instance not found', 404)

const error = await automationAPI.stopFlowInstanceExecution(appId, flowId, versionId, executionId).catch(e => e)

expect(error).toBeInstanceOf(Error)
expect(error.status).toBe(404)
expect(error.message).toBe('Flow instance not found')
})
})

describe('Debug Session Errors', () => {
Expand Down Expand Up @@ -1654,4 +1664,4 @@ describe('apiClient.automation', () => {
})
})
})
})
})
Loading