refactor(editor): Decouple REST calls from views (no-changelog) (#5202)
* decouple rest calls * remove console.log
This commit is contained in:
committed by
GitHub
parent
7aa65315cc
commit
b69f480d4c
54
packages/editor-ui/src/api/eventbus.ee.ts
Normal file
54
packages/editor-ui/src/api/eventbus.ee.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { IRestApiContext } from '@/Interface';
|
||||
import { makeRestApiRequest } from '@/utils';
|
||||
import { IDataObject, MessageEventBusDestinationOptions } from 'n8n-workflow';
|
||||
|
||||
export async function saveDestinationToDb(
|
||||
context: IRestApiContext,
|
||||
destination: MessageEventBusDestinationOptions,
|
||||
subscribedEvents: string[] = [],
|
||||
) {
|
||||
if (destination.id) {
|
||||
const data: IDataObject = {
|
||||
...destination,
|
||||
subscribedEvents,
|
||||
};
|
||||
return makeRestApiRequest(context, 'POST', '/eventbus/destination', data);
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteDestinationFromDb(context: IRestApiContext, destinationId: string) {
|
||||
return makeRestApiRequest(context, 'DELETE', `/eventbus/destination?id=${destinationId}`);
|
||||
}
|
||||
|
||||
export async function sendTestMessageToDestination(
|
||||
context: IRestApiContext,
|
||||
destination: MessageEventBusDestinationOptions,
|
||||
) {
|
||||
if (destination.id) {
|
||||
const data: IDataObject = {
|
||||
...destination,
|
||||
};
|
||||
return makeRestApiRequest(context, 'GET', '/eventbus/testmessage', data);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getEventNamesFromBackend(context: IRestApiContext): Promise<string[]> {
|
||||
return makeRestApiRequest(context, 'GET', '/eventbus/eventnames');
|
||||
}
|
||||
|
||||
export async function getDestinationsFromBackend(
|
||||
context: IRestApiContext,
|
||||
): Promise<MessageEventBusDestinationOptions[]> {
|
||||
return makeRestApiRequest(context, 'GET', '/eventbus/destination');
|
||||
}
|
||||
|
||||
export async function getExecutionEvents(context: IRestApiContext, executionId: string) {
|
||||
return makeRestApiRequest(context, 'GET', `/eventbus/execution/${executionId}`);
|
||||
}
|
||||
|
||||
export async function recoverExecutionDataFromEvents(
|
||||
context: IRestApiContext,
|
||||
executionId: string,
|
||||
) {
|
||||
return makeRestApiRequest(context, 'GET', `/eventbus/execution-recover/${executionId}`);
|
||||
}
|
||||
Reference in New Issue
Block a user