n8n/packages/editor-ui/src/api/workflows.ts
Milorad FIlipović 5059c57f4a
refactor(editor): Refactor utils files and mixins (#4654)
*  Added `utils` module. Moved `canvasHelpers` and old `utils.ts` file to it
*  Moved rest of utils and helpers
*  Fixing sytax errors
* 🔨 Refactoring new utils files
* 🔨 Organizing imports, adding comments and a bit more refactoring
* ✔️ Fixing tests
* 🔨 Moving mixins to `src`
2022-11-23 13:41:53 +01:00

30 lines
1.1 KiB
TypeScript

import { IRestApiContext } from '@/Interface';
import { IDataObject } from 'n8n-workflow';
import { makeRestApiRequest } from '@/utils';
export async function getNewWorkflow(context: IRestApiContext, name?: string) {
const response = await makeRestApiRequest(context, 'GET', `/workflows/new`, name ? { name } : {});
return {
name: response.name,
onboardingFlowEnabled: response.onboardingFlowEnabled === true,
};
}
export async function getWorkflows(context: IRestApiContext, filter?: object) {
const sendData = filter ? { filter } : undefined;
return await makeRestApiRequest(context, 'GET', `/workflows`, sendData);
}
export async function getActiveWorkflows(context: IRestApiContext) {
return await makeRestApiRequest(context, 'GET', `/active`);
}
export async function getCurrentExecutions(context: IRestApiContext, filter: IDataObject) {
return await makeRestApiRequest(context, 'GET', '/executions-current', { filter });
}
export async function getFinishedExecutions(context: IRestApiContext, filter: IDataObject) {
return await makeRestApiRequest(context, 'GET', '/executions', { filter });
}