diff --git a/packages/frontend/@n8n/rest-api-client/src/api/index.ts b/packages/frontend/@n8n/rest-api-client/src/api/index.ts index d01161effa..30190ab166 100644 --- a/packages/frontend/@n8n/rest-api-client/src/api/index.ts +++ b/packages/frontend/@n8n/rest-api-client/src/api/index.ts @@ -13,3 +13,4 @@ export * from './sso'; export * from './ui'; export * from './versions'; export * from './webhooks'; +export * from './workflowHistory'; diff --git a/packages/frontend/@n8n/rest-api-client/src/api/workflowHistory.ts b/packages/frontend/@n8n/rest-api-client/src/api/workflowHistory.ts new file mode 100644 index 0000000000..9df5c2845e --- /dev/null +++ b/packages/frontend/@n8n/rest-api-client/src/api/workflowHistory.ts @@ -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 => { + const { data } = await get( + context.baseUrl, + `/workflow-history/workflow/${workflowId}`, + queryParams, + ); + return data; +}; + +export const getWorkflowVersion = async ( + context: IRestApiContext, + workflowId: string, + versionId: string, +): Promise => { + const { data } = await get( + context.baseUrl, + `/workflow-history/workflow/${workflowId}/version/${versionId}`, + ); + return data; +}; diff --git a/packages/frontend/editor-ui/src/api/workflowHistory.ts b/packages/frontend/editor-ui/src/api/workflowHistory.ts deleted file mode 100644 index 390225b46c..0000000000 --- a/packages/frontend/editor-ui/src/api/workflowHistory.ts +++ /dev/null @@ -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 => { - const { data } = await get( - context.baseUrl, - `/workflow-history/workflow/${workflowId}`, - queryParams, - ); - return data; -}; - -export const getWorkflowVersion = async ( - context: IRestApiContext, - workflowId: string, - versionId: string, -): Promise => { - const { data } = await get( - context.baseUrl, - `/workflow-history/workflow/${workflowId}/version/${versionId}`, - ); - return data; -}; diff --git a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.test.ts b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.test.ts index 395e8d9a90..2ea28ebbd1 100644 --- a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.test.ts +++ b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.test.ts @@ -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'; diff --git a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue index bc72ad280d..91fe867d2c 100644 --- a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue +++ b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryContent.vue @@ -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'; diff --git a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.test.ts b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.test.ts index edc2e09c6d..c3968eee63 100644 --- a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.test.ts +++ b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.test.ts @@ -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( diff --git a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.vue b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.vue index af0bc7d873..279e1e13b1 100644 --- a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.vue +++ b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryList.vue @@ -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<{ diff --git a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.test.ts b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.test.ts index ffd2ad5586..27f6d49611 100644 --- a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.test.ts +++ b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.test.ts @@ -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']; diff --git a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue index 2753220722..f559f73814 100644 --- a/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue +++ b/packages/frontend/editor-ui/src/components/WorkflowHistory/WorkflowHistoryListItem.vue @@ -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<{ diff --git a/packages/frontend/editor-ui/src/stores/__tests__/utils/workflowHistoryTestUtils.ts b/packages/frontend/editor-ui/src/stores/__tests__/utils/workflowHistoryTestUtils.ts index 7e62e20cb1..19b273c2fe 100644 --- a/packages/frontend/editor-ui/src/stores/__tests__/utils/workflowHistoryTestUtils.ts +++ b/packages/frontend/editor-ui/src/stores/__tests__/utils/workflowHistoryTestUtils.ts @@ -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(), diff --git a/packages/frontend/editor-ui/src/stores/workflowHistory.store.ts b/packages/frontend/editor-ui/src/stores/workflowHistory.store.ts index 2945bda20e..98a8803348 100644 --- a/packages/frontend/editor-ui/src/stores/workflowHistory.store.ts +++ b/packages/frontend/editor-ui/src/stores/workflowHistory.store.ts @@ -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'; diff --git a/packages/frontend/editor-ui/src/types/workflowHistory.ts b/packages/frontend/editor-ui/src/types/workflowHistory.ts deleted file mode 100644 index 0c66987156..0000000000 --- a/packages/frontend/editor-ui/src/types/workflowHistory.ts +++ /dev/null @@ -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 }; diff --git a/packages/frontend/editor-ui/src/views/WorkflowHistory.test.ts b/packages/frontend/editor-ui/src/views/WorkflowHistory.test.ts index 0175d0512e..f6ac74b63f 100644 --- a/packages/frontend/editor-ui/src/views/WorkflowHistory.test.ts +++ b/packages/frontend/editor-ui/src/views/WorkflowHistory.test.ts @@ -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'; diff --git a/packages/frontend/editor-ui/src/views/WorkflowHistory.vue b/packages/frontend/editor-ui/src/views/WorkflowHistory.vue index 98c2f8a3e5..49560be5bb 100644 --- a/packages/frontend/editor-ui/src/views/WorkflowHistory.vue +++ b/packages/frontend/editor-ui/src/views/WorkflowHistory.vue @@ -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';