mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(editor): Move workflowHistory api to @n8n/rest-api-client (no-changelog) (#16183)
This commit is contained in:
@@ -13,3 +13,4 @@ export * from './sso';
|
||||
export * from './ui';
|
||||
export * from './versions';
|
||||
export * from './webhooks';
|
||||
export * from './workflowHistory';
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { IConnections, INode } from 'n8n-workflow';
|
||||
|
||||
import type { IRestApiContext } from '../types';
|
||||
import { get } from '../utils';
|
||||
|
||||
export type WorkflowHistory = {
|
||||
versionId: string;
|
||||
authors: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type WorkflowVersionId = WorkflowHistory['versionId'];
|
||||
|
||||
export type WorkflowVersion = WorkflowHistory & {
|
||||
workflowId: string;
|
||||
nodes: INode[];
|
||||
connections: IConnections;
|
||||
};
|
||||
|
||||
export type WorkflowHistoryActionTypes = ['restore', 'clone', 'open', 'download'];
|
||||
|
||||
export type WorkflowHistoryRequestParams = { take: number; skip?: number };
|
||||
|
||||
export const getWorkflowHistory = async (
|
||||
context: IRestApiContext,
|
||||
workflowId: string,
|
||||
queryParams: WorkflowHistoryRequestParams,
|
||||
): Promise<WorkflowHistory[]> => {
|
||||
const { data } = await get(
|
||||
context.baseUrl,
|
||||
`/workflow-history/workflow/${workflowId}`,
|
||||
queryParams,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getWorkflowVersion = async (
|
||||
context: IRestApiContext,
|
||||
workflowId: string,
|
||||
versionId: string,
|
||||
): Promise<WorkflowVersion> => {
|
||||
const { data } = await get(
|
||||
context.baseUrl,
|
||||
`/workflow-history/workflow/${workflowId}/version/${versionId}`,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
Reference in New Issue
Block a user