refactor(editor): Move workflowHistory api to @n8n/rest-api-client (no-changelog) (#16183)

This commit is contained in:
Alex Grozav
2025-06-10 14:50:18 +02:00
committed by GitHub
parent e3675bdfb4
commit 023aa156b3
14 changed files with 60 additions and 64 deletions

View File

@@ -13,3 +13,4 @@ export * from './sso';
export * from './ui';
export * from './versions';
export * from './webhooks';
export * from './workflowHistory';

View File

@@ -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;
};

View File

@@ -1,32 +0,0 @@
import type { IRestApiContext } from '@n8n/rest-api-client';
import { get } from '@n8n/rest-api-client';
import type {
WorkflowHistory,
WorkflowVersion,
WorkflowHistoryRequestParams,
} from '@/types/workflowHistory';
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;
};

View File

@@ -6,7 +6,7 @@ import userEvent from '@testing-library/user-event';
import type { UserAction } from '@n8n/design-system';
import { createComponentRenderer } from '@/__tests__/render';
import WorkflowHistoryContent from '@/components/WorkflowHistory/WorkflowHistoryContent.vue';
import type { WorkflowHistoryActionTypes } from '@/types/workflowHistory';
import type { WorkflowHistoryActionTypes } from '@n8n/rest-api-client/api/workflowHistory';
import { workflowVersionDataFactory } from '@/stores/__tests__/utils/workflowHistoryTestUtils';
import type { IWorkflowDb } from '@/Interface';

View File

@@ -5,7 +5,7 @@ import type {
WorkflowVersion,
WorkflowHistoryActionTypes,
WorkflowVersionId,
} from '@/types/workflowHistory';
} from '@n8n/rest-api-client/api/workflowHistory';
import WorkflowPreview from '@/components/WorkflowPreview.vue';
import WorkflowHistoryListItem from '@/components/WorkflowHistory/WorkflowHistoryListItem.vue';
import { useI18n } from '@n8n/i18n';

View File

@@ -5,7 +5,7 @@ import { faker } from '@faker-js/faker';
import type { UserAction } from '@n8n/design-system';
import { createComponentRenderer } from '@/__tests__/render';
import WorkflowHistoryList from '@/components/WorkflowHistory/WorkflowHistoryList.vue';
import type { WorkflowHistoryActionTypes } from '@/types/workflowHistory';
import type { WorkflowHistoryActionTypes } from '@n8n/rest-api-client/api/workflowHistory';
import { workflowHistoryDataFactory } from '@/stores/__tests__/utils/workflowHistoryTestUtils';
vi.stubGlobal(

View File

@@ -7,7 +7,7 @@ import type {
WorkflowVersionId,
WorkflowHistoryActionTypes,
WorkflowHistoryRequestParams,
} from '@/types/workflowHistory';
} from '@n8n/rest-api-client/api/workflowHistory';
import WorkflowHistoryListItem from '@/components/WorkflowHistory/WorkflowHistoryListItem.vue';
const props = defineProps<{

View File

@@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event';
import type { UserAction } from '@n8n/design-system';
import { createComponentRenderer } from '@/__tests__/render';
import WorkflowHistoryListItem from '@/components/WorkflowHistory/WorkflowHistoryListItem.vue';
import type { WorkflowHistoryActionTypes } from '@/types/workflowHistory';
import type { WorkflowHistoryActionTypes } from '@n8n/rest-api-client/api/workflowHistory';
import { workflowHistoryDataFactory } from '@/stores/__tests__/utils/workflowHistoryTestUtils';
const actionTypes: WorkflowHistoryActionTypes = ['restore', 'clone', 'open', 'download'];

View File

@@ -6,7 +6,7 @@ import type {
WorkflowHistory,
WorkflowVersionId,
WorkflowHistoryActionTypes,
} from '@/types/workflowHistory';
} from '@n8n/rest-api-client/api/workflowHistory';
import { useI18n } from '@n8n/i18n';
const props = defineProps<{

View File

@@ -1,5 +1,5 @@
import { faker } from '@faker-js/faker';
import type { WorkflowHistory, WorkflowVersion } from '@/types/workflowHistory';
import type { WorkflowHistory, WorkflowVersion } from '@n8n/rest-api-client/api/workflowHistory';
export const workflowHistoryDataFactory: () => WorkflowHistory = () => ({
versionId: faker.string.nanoid(),

View File

@@ -7,8 +7,8 @@ import type {
WorkflowVersion,
WorkflowHistoryRequestParams,
WorkflowVersionId,
} from '@/types/workflowHistory';
import * as whApi from '@/api/workflowHistory';
} from '@n8n/rest-api-client/api/workflowHistory';
import * as whApi from '@n8n/rest-api-client/api/workflowHistory';
import { useRootStore } from '@n8n/stores/useRootStore';
import { useSettingsStore } from '@/stores/settings.store';
import { useWorkflowsStore } from '@/stores/workflows.store';

View File

@@ -1,21 +0,0 @@
import type { IConnections } from 'n8n-workflow';
import type { INodeUi } from '@/Interface';
export type WorkflowHistory = {
versionId: string;
authors: string;
createdAt: string;
updatedAt: string;
};
export type WorkflowVersionId = WorkflowHistory['versionId'];
export type WorkflowVersion = WorkflowHistory & {
workflowId: string;
nodes: INodeUi[];
connections: IConnections;
};
export type WorkflowHistoryActionTypes = ['restore', 'clone', 'open', 'download'];
export type WorkflowHistoryRequestParams = { take: number; skip?: number };

View File

@@ -17,7 +17,7 @@ import {
workflowHistoryDataFactory,
workflowVersionDataFactory,
} from '@/stores/__tests__/utils/workflowHistoryTestUtils';
import type { WorkflowVersion } from '@/types/workflowHistory';
import type { WorkflowVersion } from '@n8n/rest-api-client/api/workflowHistory';
import type { IWorkflowDb } from '@/Interface';
import { telemetry } from '@/plugins/telemetry';

View File

@@ -11,7 +11,7 @@ import type {
WorkflowHistoryRequestParams,
WorkflowHistory,
WorkflowVersion,
} from '@/types/workflowHistory';
} from '@n8n/rest-api-client/api/workflowHistory';
import WorkflowHistoryList from '@/components/WorkflowHistory/WorkflowHistoryList.vue';
import WorkflowHistoryContent from '@/components/WorkflowHistory/WorkflowHistoryContent.vue';
import { useWorkflowHistoryStore } from '@/stores/workflowHistory.store';