Skip to content

Commit 5f7923f

Browse files
authored
Merge pull request #481 from Backendless/dev
Dev
2 parents a91e11d + 57dfe40 commit 5f7923f

File tree

6 files changed

+496
-30
lines changed

6 files changed

+496
-30
lines changed

src/automation.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const routes = prepareRoutes({
2020
flowInstances : '/api/app/:appId/automation/flow/:flowId/version/:versionId/analytics/instances/find',
2121
countInstances : '/api/app/:appId/automation/flow/:flowId/version/:versionId/analytics/instances/count',
2222
flowInstance : '/api/app/:appId/automation/flow/:flowId/version/:versionId/analytics/instances/:executionId',
23+
stopInstanceExecution : '/api/app/:appId/automation/flow/:flowId/version/:versionId/instances/:executionId/stop',
2324

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

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

159+
stopFlowInstanceExecution(appId, flowId, versionId, executionId) {
160+
return req.automation.post(routes.stopInstanceExecution(appId, flowId, versionId, executionId))
161+
},
162+
159163
cleanFlowVersionAnalytics(appId, flowId, versionId) {
160164
return req.automation.delete(routes.flowVersionAnalytics(appId, flowId, versionId))
161165
},
@@ -249,10 +253,6 @@ export default req => ({
249253
return req.automation.delete(routes.SLACalendar(appId, id))
250254
},
251255

252-
getAllowedAIModels(appId) {
253-
return req.automation.get(routes.allowedAIModels(appId))
254-
},
255-
256256
registerAIAssistant(appId, openAiAssistantId) {
257257
return req.automation.post(routes.registerAIAssistant(appId), { openAiAssistantId })
258258
},

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import consolePreview from './console-preview'
4747
import quickApps from './quick-apps'
4848
import frExtensions from './fr-extensions'
4949
import mcpServices from './mcp-services'
50+
import webhooks from './webhooks'
5051

5152
import { community } from './community'
5253
import { marketplace } from './marketplace'
@@ -222,6 +223,7 @@ const createClient = (serverUrl, authKey, options) => {
222223
consolePreview : consolePreview(request),
223224
quickApps : quickApps(request),
224225
integrations : integrations(request),
226+
webhooks : webhooks(request),
225227
pdf : pdf(request),
226228
frExtensions : frExtensions(request),
227229
mcpServices : mcpServices(request)

src/integrations.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { prepareRoutes } from './utils/routes'
22

33
const routes = prepareRoutes({
4-
integrations : '/:appId/console/integrations',
5-
integration : '/:appId/console/integrations/:name',
4+
integrations: '/:appId/console/integrations',
5+
integration : '/:appId/console/integrations/:name',
66
})
77

88
export default req => ({
@@ -21,5 +21,4 @@ export default req => ({
2121
deleteIntegration(appId, name) {
2222
return req.delete(routes.integration(appId, name))
2323
},
24-
2524
})

src/webhooks.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { prepareRoutes } from './utils/routes'
2+
3+
const routes = prepareRoutes({
4+
webhooks : '/:appId/console/webhook',
5+
operations: '/:appId/console/webhook/operations',
6+
webhook : '/:appId/console/webhook/:webhookId',
7+
})
8+
9+
export default req => ({
10+
getWebhooks(appId) {
11+
return req.get(routes.webhooks(appId))
12+
},
13+
14+
getWebhookOperations(appId) {
15+
return req.get(routes.operations(appId))
16+
},
17+
18+
saveWebhook(appId, configData) {
19+
return req.post(routes.webhooks(appId), configData)
20+
},
21+
22+
updateWebhook(appId, webhookId, configData) {
23+
return req.put(routes.webhook(appId, webhookId), configData)
24+
},
25+
26+
deleteWebhook(appId, webhookId) {
27+
return req.delete(routes.webhook(appId, webhookId))
28+
},
29+
})

tests/specs/automation.test.js

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,27 @@ describe('apiClient.automation', () => {
430430
})
431431
})
432432

433+
describe('stopFlowInstanceExecution', () => {
434+
it('should make POST request to stop flow instance execution', async () => {
435+
mockSuccessAPIRequest(successResult)
436+
437+
const result = await automationAPI.stopFlowInstanceExecution(appId, flowId, versionId, executionId)
438+
439+
expect(result).toEqual(successResult)
440+
expect(apiRequestCalls()).toEqual([
441+
{
442+
path: `http://test-host:3000/api/app/${appId}/automation/flow/${flowId}/version/${versionId}/instances/${executionId}/stop`,
443+
body: undefined,
444+
method: 'POST',
445+
encoding: 'utf8',
446+
headers: {},
447+
timeout: 0,
448+
withCredentials: false
449+
}
450+
])
451+
})
452+
})
453+
433454
describe('cleanFlowVersionAnalytics', () => {
434455
it('should make DELETE request to clean flow version analytics', async () => {
435456
mockSuccessAPIRequest(successResult)
@@ -868,27 +889,6 @@ describe('apiClient.automation', () => {
868889
})
869890

870891
describe('AI Assistant Methods', () => {
871-
describe('getAllowedAIModels', () => {
872-
it('should make GET request to get allowed AI models', async () => {
873-
mockSuccessAPIRequest(successResult)
874-
875-
const result = await automationAPI.getAllowedAIModels(appId)
876-
877-
expect(result).toEqual(successResult)
878-
expect(apiRequestCalls()).toEqual([
879-
{
880-
path: `http://test-host:3000/api/app/${appId}/automation/ai/assistants/allowed-models`,
881-
body: undefined,
882-
method: 'GET',
883-
encoding: 'utf8',
884-
headers: {},
885-
timeout: 0,
886-
withCredentials: false
887-
}
888-
])
889-
})
890-
})
891-
892892
describe('registerAIAssistant', () => {
893893
it('should make POST request to register AI assistant', async () => {
894894
mockSuccessAPIRequest(successResult)
@@ -1602,6 +1602,16 @@ describe('apiClient.automation', () => {
16021602
expect(error.status).toBe(500)
16031603
expect(error.message).toBe('Internal server error')
16041604
})
1605+
1606+
it('stopFlowInstanceExecution fails with not found error', async () => {
1607+
mockFailedAPIRequest('Flow instance not found', 404)
1608+
1609+
const error = await automationAPI.stopFlowInstanceExecution(appId, flowId, versionId, executionId).catch(e => e)
1610+
1611+
expect(error).toBeInstanceOf(Error)
1612+
expect(error.status).toBe(404)
1613+
expect(error.message).toBe('Flow instance not found')
1614+
})
16051615
})
16061616

16071617
describe('Debug Session Errors', () => {
@@ -1654,4 +1664,4 @@ describe('apiClient.automation', () => {
16541664
})
16551665
})
16561666
})
1657-
})
1667+
})

0 commit comments

Comments
 (0)