Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: remove redundant TypeScript type aliases (#44225)

Stephen Zhoue1f733f4a142
diff --git a/cli/src/errors/format.ts b/cli/src/errors/format.ts
index 55e9fea0f42..d9f414a51da 100644
--- a/cli/src/errors/format.ts
+++ b/cli/src/errors/format.ts
@@ -1,5 +1,5 @@
import type { ErrorEnvelope } from './base'
-import type { Style } from '@/sys/io/color'
+import type { ColorScheme } from '@/sys/io/color'
import { redactBearer } from '@/errors/sanitize'
const RAW_RESPONSE_HINT = 'run again with --verbose to see the raw server response'
@@ -15,7 +15,11 @@ function resolveHint(e: ErrorEnvelope['error'], opts: RenderOptions): string | u
return rawHiddenAndUnparsed ? RAW_RESPONSE_HINT : undefined
}
-export function renderEnvelope(env: ErrorEnvelope, style: Style, opts: RenderOptions): string {
+export function renderEnvelope(
+ env: ErrorEnvelope,
+ style: ColorScheme,
+ opts: RenderOptions,
+): string {
const e = env.error
const server = e.server
const headerCode = server?.code ?? e.code
diff --git a/cli/src/plugins/commands/text.ts b/cli/src/plugins/commands/text.ts
index da2971863e5..e60b44dee45 100644
--- a/cli/src/plugins/commands/text.ts
+++ b/cli/src/plugins/commands/text.ts
@@ -2,7 +2,7 @@ import type { CommandEffect } from './command'
import type { Descriptor } from './describe'
import type { HelpEntry, HelpHead, HelpListing, HelpMap } from './help'
import type { Example, JsonSchema } from '@/plugins/catalog'
-import type { Style } from '@/sys/io/color'
+import type { ColorScheme } from '@/sys/io/color'
import type { View } from '@/sys/io/view'
import { inputSchema } from '@/plugins/argv/parse'
import { GLOBAL_INPUT } from '@/plugins/global-flags'
@@ -20,7 +20,7 @@ export type FieldRow = Readonly<{
positional: boolean
}>
-type Section = Readonly<{ title: string; lines: (d: Descriptor, style: Style) => string[] }>
+type Section = Readonly<{ title: string; lines: (d: Descriptor, style: ColorScheme) => string[] }>
type Tagged = Readonly<{ effect?: CommandEffect; kind?: string; deprecated?: boolean }>
const PRESENCE = { Required: 'required', Optional: 'optional' } as const
@@ -187,12 +187,12 @@ function tagsOf(tagged: Tagged): string[] {
}
// Empty is no cell at all: a styled empty string is escape codes, not nothing.
-function tagCell(tagged: Tagged, style: Style): string[] {
+function tagCell(tagged: Tagged, style: ColorScheme): string[] {
const tags = tagsOf(tagged)
return tags.length === 0 ? [] : [style.dim(tags.join(COMMAND_SEPARATOR))]
}
-function descriptorText(d: Descriptor, style: Style): string {
+function descriptorText(d: Descriptor, style: ColorScheme): string {
const header = [style.bold(d.id), d.summary, ...tagCell(d, style)]
const blocks = [header.join(GAP)]
for (const section of SECTIONS) {
@@ -214,7 +214,7 @@ export function descriptorsView(rows: readonly Descriptor[]): View<{ commands: D
)
}
-function headText(head: HelpHead | undefined, style: Style): string {
+function headText(head: HelpHead | undefined, style: ColorScheme): string {
if (head === undefined) return ''
if (head.summary !== undefined) return head.summary
const noun = head.count === 1 ? COMMAND_NOUN.one : COMMAND_NOUN.many
@@ -232,7 +232,7 @@ export function mapView(map: HelpMap): View<HelpMap> {
)
}
-function listingRow(entry: HelpEntry, style: Style): string[] {
+function listingRow(entry: HelpEntry, style: ColorScheme): string[] {
return [entry.id, entry.summary, ...tagCell(entry, style)]
}
diff --git a/cli/src/plugins/io/index.ts b/cli/src/plugins/io/index.ts
index b94ae77258f..256e2f272d9 100644
--- a/cli/src/plugins/io/index.ts
+++ b/cli/src/plugins/io/index.ts
@@ -1,6 +1,6 @@
import type { Buffer } from 'node:buffer'
import type { OutputService } from '@/plugins/output'
-import type { Style } from '@/sys/io/color'
+import type { ColorScheme } from '@/sys/io/color'
import type { IOStreams } from '@/sys/io/streams'
import type { Printable, View } from '@/sys/io/view'
import { definePlugin } from '@/kernel/plugin'
@@ -49,7 +49,7 @@ export function ioService<S extends IOStreams>(
streams: S,
mode: OutputService = JSON_ONLY,
): IOService<S> {
- const styles: Readonly<Record<ChannelValue, Style>> = {
+ const styles: Readonly<Record<ChannelValue, ColorScheme>> = {
[Channel.Out]: colorScheme(
mode.out === OutputMode.Text && colorEnabled(CHANNEL_TTY[Channel.Out](streams), env()),
),
diff --git a/cli/src/sys/io/color.ts b/cli/src/sys/io/color.ts
index f5599e3c254..60c6afab8f1 100644
--- a/cli/src/sys/io/color.ts
+++ b/cli/src/sys/io/color.ts
@@ -12,8 +12,6 @@ export type ColorScheme = {
failureIcon: () => string
}
-export type Style = ColorScheme
-
const identity = (s: string): string => s
export function colorScheme(enabled: boolean): ColorScheme {
diff --git a/cli/src/sys/io/view.ts b/cli/src/sys/io/view.ts
index b90f908d7a7..cfb30533e0c 100644
--- a/cli/src/sys/io/view.ts
+++ b/cli/src/sys/io/view.ts
@@ -1,4 +1,4 @@
-import type { Style } from './color'
+import type { ColorScheme } from '@/sys/io/color'
type JsonPrimitive = string | number | boolean | null
@@ -6,7 +6,7 @@ export type Printable = JsonPrimitive | readonly unknown[] | Record<string, unkn
export type View<T extends Printable = Printable> = Readonly<{
json: T
- text: (style: Style) => string
+ text: (style: ColorScheme) => string
}>
const TEXT_KEY = 'text'
diff --git a/web/__tests__/base/notion-page-selector-flow.test.tsx b/web/__tests__/base/notion-page-selector-flow.test.tsx
index 5fdf9ed68bf..f69ceaf4eb1 100644
--- a/web/__tests__/base/notion-page-selector-flow.test.tsx
+++ b/web/__tests__/base/notion-page-selector-flow.test.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '@/app/components/header/account-setting/data-source-page-new/types'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { DataSourceNotionWorkspace } from '@/models/common'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -52,7 +52,7 @@ const buildCredential = (
id: string,
name: string,
workspaceName: string,
-): DataSourceCredential => ({
+): DatasourceCredentialResponse => ({
id,
name,
type: CredentialTypeEnum.OAUTH2,
@@ -64,7 +64,7 @@ const buildCredential = (
},
})
-const credentials: DataSourceCredential[] = [
+const credentials: DatasourceCredentialResponse[] = [
buildCredential('c1', 'Cred 1', 'Workspace 1'),
buildCredential('c2', 'Cred 2', 'Workspace 2'),
]
diff --git a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx
index d0ec9948e1e..9db38435d44 100644
--- a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx
+++ b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { DataSet } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -64,7 +64,7 @@ const DatasetDetailPageTitle = ({ title }: { title: string }) => {
}
const getDatasetRedirectionPath = (
- dataset: DataSet,
+ dataset: DatasetDetailWithPartialMembersResponse,
datasetACLCapabilities: ReturnType<typeof getDatasetACLCapabilities>,
) => {
if (dataset.provider === 'external') {
diff --git a/web/app/components/access-rules-editor/__tests__/index.spec.tsx b/web/app/components/access-rules-editor/__tests__/index.spec.tsx
index a77fcafa207..6dfb91a9745 100644
--- a/web/app/components/access-rules-editor/__tests__/index.spec.tsx
+++ b/web/app/components/access-rules-editor/__tests__/index.spec.tsx
@@ -1,11 +1,11 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { AccessPolicyWithBindings, ResourceUserAccessSetting } from '@/models/access-control'
-import type { Member } from '@/models/common'
import { fireEvent, render, screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import AccessRulesEditor from '../index'
const mockMembers = vi.hoisted(() => ({
- accounts: [] as Member[] | null,
+ accounts: [] as AccountWithRoleResponse[] | null,
isLoading: false,
}))
const mockMembersQuery = vi.hoisted(() => vi.fn())
@@ -72,7 +72,7 @@ const createDefaultUserAccessSetting = (): ResourceUserAccessSetting => ({
access_policies: [],
})
-const createMember = (overrides: Partial<Member> = {}): Member =>
+const createMember = (overrides: Partial<AccountWithRoleResponse> = {}): AccountWithRoleResponse =>
({
id: 'account-2',
name: 'Mia',
@@ -83,7 +83,7 @@ const createMember = (overrides: Partial<Member> = {}): Member =>
role: 'normal',
roles: [],
...overrides,
- }) as Member
+ }) as AccountWithRoleResponse
describe('AccessRulesEditor', () => {
beforeEach(() => {
diff --git a/web/app/components/app-sidebar/__tests__/dataset-detail-section.spec.tsx b/web/app/components/app-sidebar/__tests__/dataset-detail-section.spec.tsx
index 52d5bde5d8a..4a5770d388b 100644
--- a/web/app/components/app-sidebar/__tests__/dataset-detail-section.spec.tsx
+++ b/web/app/components/app-sidebar/__tests__/dataset-detail-section.spec.tsx
@@ -1,12 +1,15 @@
-import type { DataSet, RelatedAppResponse } from '@/models/datasets'
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ RelatedAppListResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { screen } from '@testing-library/react'
import { renderWithConsoleQuery } from '@/test/console/query-data'
import { DatasetACLPermission } from '@/utils/permission'
import DatasetDetailSection from '../dataset-detail-section'
let mockPathname = '/datasets/dataset-1/documents'
-let mockDataset: DataSet | undefined
-let mockRelatedApps: RelatedAppResponse | undefined
+let mockDataset: DatasetDetailWithPartialMembersResponse | undefined
+let mockRelatedApps: RelatedAppListResponse | undefined
let mockIsRbacEnabled = true
const mockConsoleState = vi.hoisted(() => ({
current: {
@@ -55,7 +58,9 @@ vi.mock('../../datasets/extra-info', () => ({
default: () => <div>dataset extra info</div>,
}))
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet =>
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse =>
({
id: 'dataset-1',
name: 'Camera Technical Spec',
@@ -85,7 +90,7 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet =>
enable_api: true,
permission_keys: [DatasetACLPermission.Edit],
...overrides,
- }) as DataSet
+ }) as DatasetDetailWithPartialMembersResponse
describe('DatasetDetailSection', () => {
beforeEach(() => {
diff --git a/web/app/components/app-sidebar/dataset-info/__tests__/dropdown-callbacks.spec.tsx b/web/app/components/app-sidebar/dataset-info/__tests__/dropdown-callbacks.spec.tsx
index 8d5c8494b28..b3dd2b7fc6b 100644
--- a/web/app/components/app-sidebar/dataset-info/__tests__/dropdown-callbacks.spec.tsx
+++ b/web/app/components/app-sidebar/dataset-info/__tests__/dropdown-callbacks.spec.tsx
@@ -1,9 +1,10 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { QueryClient } from '@tanstack/react-query'
import { screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { consoleQuery } from '@/service/console'
import { createHttpError } from '@/service/http-error'
import { renderWithConsoleQuery } from '@/test/console/query-data'
@@ -12,7 +13,7 @@ import { RETRIEVE_METHOD } from '@/types/app'
import { DatasetACLPermission } from '@/utils/permission'
import Dropdown from '../dropdown'
-let mockDataset: DataSet
+let mockDataset: DatasetDetailWithPartialMembersResponse
const mockReplace = vi.fn()
const invalidateQueries = vi.spyOn(QueryClient.prototype, 'invalidateQueries')
const datasetListKey = consoleQuery.datasets.get.key()
@@ -38,7 +39,9 @@ const render = (ui: Parameters<typeof renderWithConsoleQuery>[0]) =>
},
})
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Dataset Name',
@@ -49,9 +52,10 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1690000000,
@@ -100,8 +104,9 @@ vi.mock('@/next/navigation', () => ({
}))
vi.mock('@/context/dataset-detail', () => ({
- useDatasetDetailContextWithSelector: (selector: (state: { dataset?: DataSet }) => unknown) =>
- selector({ dataset: mockDataset }),
+ useDatasetDetailContextWithSelector: (
+ selector: (state: { dataset?: DatasetDetailWithPartialMembersResponse }) => unknown,
+ ) => selector({ dataset: mockDataset }),
}))
vi.mock('@/context/permission-state', async () => {
diff --git a/web/app/components/app-sidebar/dataset-info/__tests__/index.spec.tsx b/web/app/components/app-sidebar/dataset-info/__tests__/index.spec.tsx
index 0ac8030d0d6..0b6de81589c 100644
--- a/web/app/components/app-sidebar/dataset-info/__tests__/index.spec.tsx
+++ b/web/app/components/app-sidebar/dataset-info/__tests__/index.spec.tsx
@@ -1,10 +1,11 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { QueryClient } from '@tanstack/react-query'
import { screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { isEqual } from 'es-toolkit/compat'
import * as React from 'react'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { consoleQuery } from '@/service/console'
import { renderWithConsoleQuery } from '@/test/console/query-data'
import { createDatasetFixture } from '@/test/fixtures/dataset'
@@ -13,7 +14,7 @@ import { DatasetACLPermission } from '@/utils/permission'
import DatasetInfo from '..'
import Dropdown from '../dropdown'
-let mockDataset: DataSet
+let mockDataset: DatasetDetailWithPartialMembersResponse
const mockPush = vi.fn()
const mockReplace = vi.fn()
const invalidateQueries = vi.spyOn(QueryClient.prototype, 'invalidateQueries')
@@ -36,7 +37,9 @@ const render = (ui: Parameters<typeof renderWithConsoleQuery>[0]) =>
},
})
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Dataset Name',
@@ -47,9 +50,10 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1690000000,
@@ -104,8 +108,9 @@ vi.mock('@/next/navigation', () => ({
}))
vi.mock('@/context/dataset-detail', () => ({
- useDatasetDetailContextWithSelector: (selector: (state: { dataset?: DataSet }) => unknown) =>
- selector({ dataset: mockDataset }),
+ useDatasetDetailContextWithSelector: (
+ selector: (state: { dataset?: DatasetDetailWithPartialMembersResponse }) => unknown,
+ ) => selector({ dataset: mockDataset }),
}))
vi.mock('@/context/permission-state', async () => {
diff --git a/web/app/components/app-sidebar/dataset-info/dropdown.tsx b/web/app/components/app-sidebar/dataset-info/dropdown.tsx
index d8b73f3f3ea..c395bc0a748 100644
--- a/web/app/components/app-sidebar/dataset-info/dropdown.tsx
+++ b/web/app/components/app-sidebar/dataset-info/dropdown.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -47,7 +47,9 @@ const DropDown = ({ expand, triggerClassName }: DropDownProps) => {
const [confirmMessage, setConfirmMessage] = useState<string>('')
const [showConfirmDelete, setShowConfirmDelete] = useState(false)
- const dataset = useDatasetDetailContextWithSelector((state) => state.dataset) as DataSet
+ const dataset = useDatasetDetailContextWithSelector(
+ (state) => state.dataset,
+ ) as DatasetDetailWithPartialMembersResponse
const { data: currentUserId } = useSuspenseQuery({
...userProfileQueryOptions(),
select: (data) => data.profile.id,
diff --git a/web/app/components/app-sidebar/dataset-info/index.tsx b/web/app/components/app-sidebar/dataset-info/index.tsx
index f8c9241975c..a7d3763dbe9 100644
--- a/web/app/components/app-sidebar/dataset-info/index.tsx
+++ b/web/app/components/app-sidebar/dataset-info/index.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
@@ -16,7 +16,9 @@ type DatasetInfoProps = {
const DatasetInfo = ({ expand }: DatasetInfoProps) => {
const { t } = useTranslation(['dataset'])
- const dataset = useDatasetDetailContextWithSelector((state) => state.dataset) as DataSet
+ const dataset = useDatasetDetailContextWithSelector(
+ (state) => state.dataset,
+ ) as DatasetDetailWithPartialMembersResponse
const iconInfo = dataset.icon_info || {
icon: '📙',
icon_type: 'emoji',
diff --git a/web/app/components/app/access-point/__tests__/trigger-card.spec.tsx b/web/app/components/app/access-point/__tests__/trigger-card.spec.tsx
index fc0965dc2e5..52565dfc9a6 100644
--- a/web/app/components/app/access-point/__tests__/trigger-card.spec.tsx
+++ b/web/app/components/app/access-point/__tests__/trigger-card.spec.tsx
@@ -1,4 +1,4 @@
-import type { AppTrigger } from '@/app/components/tools/types'
+import type { WorkflowTriggerResponse } from '@dify/contracts/api/console/apps/types.gen'
import { QueryClientProvider } from '@tanstack/react-query'
import { screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -11,7 +11,7 @@ import { TriggerAccessPointCard } from '../built-in-access-points/trigger-card'
const mocks = vi.hoisted(() => ({
setTriggerStatuses: vi.fn(),
triggerQuery: {
- data: undefined as { data: AppTrigger[] } | undefined,
+ data: undefined as { data: WorkflowTriggerResponse[] } | undefined,
isLoading: false,
},
updateTriggerStatus: vi.fn(),
@@ -79,7 +79,10 @@ const appInfo = createAppDetailFixture({
mode: 'workflow' as const,
})
-function createTrigger(id: string, status: AppTrigger['status']): AppTrigger {
+function createTrigger(
+ id: string,
+ status: WorkflowTriggerResponse['status'],
+): WorkflowTriggerResponse {
return {
id,
trigger_type: 'trigger-webhook',
diff --git a/web/app/components/app/access-point/built-in-access-points/trigger-card.tsx b/web/app/components/app/access-point/built-in-access-points/trigger-card.tsx
index 6398864f3a1..d2093a71091 100644
--- a/web/app/components/app/access-point/built-in-access-points/trigger-card.tsx
+++ b/web/app/components/app/access-point/built-in-access-points/trigger-card.tsx
@@ -1,7 +1,9 @@
'use client'
-import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
-import type { AppTrigger } from '@/app/components/tools/types'
+import type {
+ AppDetailWithSite,
+ WorkflowTriggerResponse,
+} from '@dify/contracts/api/console/apps/types.gen'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import { StatusDot } from '@langgenius/dify-ui/status-dot'
import { Switch } from '@langgenius/dify-ui/switch'
@@ -24,7 +26,7 @@ function TriggerIcon({
trigger,
triggerPlugins,
}: {
- trigger: AppTrigger
+ trigger: WorkflowTriggerResponse
triggerPlugins: TriggerWithProvider[]
}) {
const blockType =
@@ -59,7 +61,7 @@ function TriggerAccessPointItem({
}: {
appId: string
canManageAccessPoint: boolean
- trigger: AppTrigger
+ trigger: WorkflowTriggerResponse
triggerPlugins: TriggerWithProvider[]
}) {
const { t } = useTranslation(['agentV2', 'appOverview', 'common'])
diff --git a/web/app/components/app/annotation/__tests__/index.spec.tsx b/web/app/components/app/annotation/__tests__/index.spec.tsx
index d8fb422ecfd..12c11c5b0c2 100644
--- a/web/app/components/app/annotation/__tests__/index.spec.tsx
+++ b/web/app/components/app/annotation/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { Annotation as AnnotationData } from '@dify/contracts/api/console/apps/types.gen'
import type { ReactElement } from 'react'
-import type { AnnotationItem } from '../type'
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
import * as React from 'react'
import { toast } from '@/app/notifications'
@@ -196,7 +196,7 @@ const appDetail = createAppDetailFixture({
mode: 'chat' as const,
})
-const createAnnotation = (overrides: Partial<AnnotationItem> = {}): AnnotationItem => ({
+const createAnnotation = (overrides: Partial<AnnotationData> = {}): AnnotationData => ({
id: overrides.id ?? 'annotation-1',
question: overrides.question ?? 'Question 1',
answer: overrides.answer ?? 'Answer 1',
diff --git a/web/app/components/app/annotation/__tests__/list.spec.tsx b/web/app/components/app/annotation/__tests__/list.spec.tsx
index 14b40c37767..37913a6038e 100644
--- a/web/app/components/app/annotation/__tests__/list.spec.tsx
+++ b/web/app/components/app/annotation/__tests__/list.spec.tsx
@@ -1,4 +1,4 @@
-import type { AnnotationItem } from '../type'
+import type { Annotation } from '@dify/contracts/api/console/apps/types.gen'
import { fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
@@ -23,7 +23,7 @@ vi.mock('@/service/base', async (importOriginal) => ({
request: mockedRequest,
}))
-const createAnnotation = (overrides: Partial<AnnotationItem> = {}): AnnotationItem => ({
+const createAnnotation = (overrides: Partial<Annotation> = {}): Annotation => ({
id: overrides.id ?? 'annotation-id',
question: overrides.question ?? 'question 1',
answer: overrides.answer ?? 'answer 1',
diff --git a/web/app/components/app/annotation/header-opts/index.tsx b/web/app/components/app/annotation/header-opts/index.tsx
index 01b3cc6c645..ed5e91206ec 100644
--- a/web/app/components/app/annotation/header-opts/index.tsx
+++ b/web/app/components/app/annotation/header-opts/index.tsx
@@ -1,6 +1,7 @@
'use client'
+import type { Annotation } from '@dify/contracts/api/console/apps/types.gen'
import type { FC } from 'react'
-import type { AnnotationItem, AnnotationItemBasic } from '../type'
+import type { AnnotationItemBasic } from '../type'
import { AlertDialog } from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import {
@@ -36,24 +37,24 @@ type Props = Readonly<{
}>
type OperationsMenuProps = {
- list: AnnotationItem[]
+ list: Annotation[]
onBulkImport: () => void
onClearAll: () => void
onExportJsonl: () => void
}
-const buildAnnotationJsonlRecords = (list: AnnotationItem[]) =>
+const buildAnnotationJsonlRecords = (list: Annotation[]) =>
list.map((item) => {
return `{"messages": [{"role": "system", "content": ""}, {"role": "user", "content": ${JSON.stringify(item.question ?? '')}}, {"role": "assistant", "content": ${JSON.stringify(item.answer ?? '')}}]}`
})
-const downloadAnnotationJsonl = (list: AnnotationItem[], locale: string) => {
+const downloadAnnotationJsonl = (list: Annotation[], locale: string) => {
const content = buildAnnotationJsonlRecords(list).join('\n')
const file = new Blob([content], { type: 'application/jsonl' })
downloadBlob({ data: file, fileName: `annotations-${locale}.jsonl` })
}
-const downloadAnnotationCsv = (list: AnnotationItem[], locale: string) => {
+const downloadAnnotationCsv = (list: Annotation[], locale: string) => {
const content = jsonToCSV([
locale !== LanguagesSupported[1] ? CSV_HEADER_QA_EN : CSV_HEADER_QA_CN,
...list.map((item) => [item.question ?? '', item.answer ?? '']),
@@ -130,7 +131,7 @@ const OperationsMenu: FC<OperationsMenuProps> = ({
const HeaderOptions: FC<Props> = ({ appId, onAdd, onAdded, controlUpdateList }) => {
const { t } = useTranslation(['appAnnotation', 'common'])
const locale = useLocale()
- const [list, setList] = useState<AnnotationItem[]>([])
+ const [list, setList] = useState<Annotation[]>([])
const fetchList = React.useCallback(async () => {
const { data } = await consoleClient.apps.byAppId.annotations.export.get({
diff --git a/web/app/components/app/annotation/index.tsx b/web/app/components/app/annotation/index.tsx
index 7ba059288cb..b56a6c7da5a 100644
--- a/web/app/components/app/annotation/index.tsx
+++ b/web/app/components/app/annotation/index.tsx
@@ -1,9 +1,9 @@
'use client'
-import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
+import type { Annotation, AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
import type { FC } from 'react'
import type { QueryParam } from './filter'
-import type { AnnotationItem, AnnotationItemBasic } from './type'
+import type { AnnotationItemBasic } from './type'
import type { AnnotationReplyConfig } from '@/models/debug'
import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
@@ -65,12 +65,12 @@ const Annotation: FC<Props> = (props) => {
const [queryParams, setQueryParams] = useState<QueryParam>({})
const [currPage, setCurrPage] = useState(0)
const [limit, setLimit] = useState(APP_PAGE_LIMIT)
- const [list, setList] = useState<AnnotationItem[]>([])
+ const [list, setList] = useState<Annotation[]>([])
const [total, setTotal] = useState(0)
const totalPages = total ? Math.max(Math.ceil(total / limit), 1) : 1
const [isLoading, setIsLoading] = useState(false)
const [controlUpdateList, setControlUpdateList] = useState(() => Date.now())
- const [currItem, setCurrItem] = useState<AnnotationItem | null>(null)
+ const [currItem, setCurrItem] = useState<Annotation | null>(null)
const [isShowViewModal, setIsShowViewModal] = useState(false)
const [selectedIds, setSelectedIds] = useState<string[]>([])
const debouncedQueryParams = useDebounce(queryParams, { wait: 500 })
@@ -150,7 +150,7 @@ const Annotation: FC<Props> = (props) => {
}
}
- const handleView = (item: AnnotationItem) => {
+ const handleView = (item: Annotation) => {
setCurrItem(item)
setIsShowViewModal(true)
}
@@ -302,9 +302,9 @@ const Annotation: FC<Props> = (props) => {
isShow={isShowViewModal}
onHide={() => setIsShowViewModal(false)}
onRemove={async () => {
- await handleRemove((currItem as AnnotationItem)?.id)
+ await handleRemove((currItem as Annotation)?.id)
}}
- item={currItem as AnnotationItem}
+ item={currItem as Annotation}
onSave={handleSave}
/>
)}
diff --git a/web/app/components/app/annotation/list.tsx b/web/app/components/app/annotation/list.tsx
index 491f5e497b7..ba32bd0549b 100644
--- a/web/app/components/app/annotation/list.tsx
+++ b/web/app/components/app/annotation/list.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { Annotation } from '@dify/contracts/api/console/apps/types.gen'
import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
-import type { AnnotationItem } from './type'
import { AlertDialog, AlertDialogTrigger } from '@langgenius/dify-ui/alert-dialog'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { CheckboxGroup } from '@langgenius/dify-ui/checkbox-group'
@@ -15,8 +15,8 @@ import { RemoveAnnotationConfirmContent } from './remove-annotation-confirm-moda
type Props = Readonly<{
appId: string
- list: AnnotationItem[]
- onView: (item: AnnotationItem) => void
+ list: Annotation[]
+ onView: (item: Annotation) => void
onRemoved: () => void
selectedIds: string[]
onSelectedIdsChange: (selectedIds: string[]) => void
@@ -25,9 +25,9 @@ type Props = Readonly<{
type AnnotationTableRowProps = {
appId: string
- item: AnnotationItem
+ item: Annotation
formattedCreatedAt: string
- onView: (item: AnnotationItem) => void
+ onView: (item: Annotation) => void
onRemoved: () => void
}
diff --git a/web/app/components/app/annotation/type.ts b/web/app/components/app/annotation/type.ts
index bf0f1a6603b..fb6cf3b201b 100644
--- a/web/app/components/app/annotation/type.ts
+++ b/web/app/components/app/annotation/type.ts
@@ -1,15 +1,9 @@
-import type { Annotation, AnnotationHitHistory } from '@dify/contracts/api/console/apps/types.gen'
-
export type AnnotationItemBasic = {
message_id?: string
question: string
answer: string
}
-export type AnnotationItem = Annotation
-
-export type HitHistoryItem = AnnotationHitHistory
-
export type EmbeddingModelConfig = {
embedding_provider_name: string
embedding_model_name: string
diff --git a/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsx b/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsx
index 7b23991c5e4..25b56cfba69 100644
--- a/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsx
+++ b/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import type { AnnotationItem, HitHistoryItem } from '../../type'
+import type { Annotation, AnnotationHitHistory } from '@dify/contracts/api/console/apps/types.gen'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
@@ -53,7 +53,7 @@ vi.mock('../../edit-annotation-modal/edit-item', () => {
}
})
-const createAnnotationItem = (overrides: Partial<AnnotationItem> = {}): AnnotationItem => ({
+const createAnnotationItem = (overrides: Partial<Annotation> = {}): Annotation => ({
id: overrides.id ?? 'annotation-id',
question: overrides.question ?? 'question',
answer: overrides.answer ?? 'answer',
@@ -61,7 +61,9 @@ const createAnnotationItem = (overrides: Partial<AnnotationItem> = {}): Annotati
hit_count: overrides.hit_count ?? 0,
})
-const createHitHistoryItem = (overrides: Partial<HitHistoryItem> = {}): HitHistoryItem => ({
+const createHitHistoryItem = (
+ overrides: Partial<AnnotationHitHistory> = {},
+): AnnotationHitHistory => ({
id: overrides.id ?? 'hit-id',
question: overrides.question ?? 'query',
match: overrides.match ?? 'match',
diff --git a/web/app/components/app/annotation/view-annotation-modal/index.tsx b/web/app/components/app/annotation/view-annotation-modal/index.tsx
index 3a65b2a9883..3fe5b297e72 100644
--- a/web/app/components/app/annotation/view-annotation-modal/index.tsx
+++ b/web/app/components/app/annotation/view-annotation-modal/index.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { Annotation, AnnotationHitHistory } from '@dify/contracts/api/console/apps/types.gen'
import type { AlertDialogActions } from '@langgenius/dify-ui/alert-dialog'
import type { FC } from 'react'
-import type { AnnotationItem, HitHistoryItem } from '../type'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -38,7 +38,7 @@ type Props = Readonly<{
appId: string
isShow: boolean
onHide: () => void
- item: AnnotationItem
+ item: Annotation
onSave: (editedQuery: string, editedAnswer: string) => Promise<void>
onRemove: () => void
}>
@@ -61,7 +61,7 @@ const ViewAnnotationModal: FC<Props> = ({ appId, isShow, onHide, item, onSave, o
const [currPage, setCurrPage] = React.useState<number>(0)
const [total, setTotal] = useState(0)
const totalPages = total ? Math.max(Math.ceil(total / APP_PAGE_LIMIT), 1) : 1
- const [hitHistoryList, setHitHistoryList] = useState<HitHistoryItem[]>([])
+ const [hitHistoryList, setHitHistoryList] = useState<AnnotationHitHistory[]>([])
// Update local state when item prop changes (e.g., when modal is reopened with updated data)
useEffect(() => {
diff --git a/web/app/components/app/app-publisher/__tests__/sections.spec.tsx b/web/app/components/app/app-publisher/__tests__/sections.spec.tsx
index 080cb1a10d2..4c96e7c5e0d 100644
--- a/web/app/components/app/app-publisher/__tests__/sections.spec.tsx
+++ b/web/app/components/app/app-publisher/__tests__/sections.spec.tsx
@@ -1,5 +1,5 @@
import type { ComponentProps } from 'react'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { act, fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -26,7 +26,9 @@ vi.mock('../publish-with-multiple-model', () => ({
),
}))
-const createVersionInfo = (overrides: Partial<VersionHistory> = {}): VersionHistory => ({
+const createVersionInfo = (
+ overrides: Partial<FetchWorkflowDraftResponse> = {},
+): FetchWorkflowDraftResponse => ({
id: 'workflow-version-1',
graph: {
nodes: [],
diff --git a/web/app/components/app/configuration/dataset-config/__tests__/index.spec.tsx b/web/app/components/app/configuration/dataset-config/__tests__/index.spec.tsx
index adbc1cde66e..558dac420e2 100644
--- a/web/app/components/app/configuration/dataset-config/__tests__/index.spec.tsx
+++ b/web/app/components/app/configuration/dataset-config/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { DatasetConfigs } from '@/models/debug'
import { fireEvent, screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -8,7 +8,8 @@ import {
LogicalOperator,
} from '@/app/components/workflow/nodes/knowledge-retrieval/types'
import { getSelectedDatasetsMode } from '@/app/components/workflow/nodes/knowledge-retrieval/utils'
-import { DatasetPermission, DataSourceType } from '@/models/datasets'
+import { DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createConsoleQueryWrapper } from '@/test/console/query-data'
import { render as renderWithConsoleState } from '@/test/console/render'
import { createDatasetFixture } from '@/test/fixtures/dataset'
@@ -242,8 +243,10 @@ vi.mock('use-context-selector', () => ({
useContext: vi.fn(() => mockConfigContext),
}))
-const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet => {
- const defaultDataset: DataSet = {
+const createMockDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => {
+ const defaultDataset: DatasetDetailWithPartialMembersResponse = {
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
@@ -254,7 +257,7 @@ const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet => {
icon_url: '',
},
description: 'Test dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
indexing_technique: 'high_quality' as any,
author_name: 'Test Author',
@@ -468,7 +471,7 @@ describe('DatasetConfig', () => {
it('should disable dataset editing when ACL does not grant edit even if legacy dataset permission allows it', () => {
const dataset = createMockDataset({
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
permission_keys: [DatasetACLPermission.Use],
})
vi.mocked(getDatasetACLCapabilities).mockReturnValue({
diff --git a/web/app/components/app/configuration/dataset-config/card-item/__tests__/index.spec.tsx b/web/app/components/app/configuration/dataset-config/card-item/__tests__/index.spec.tsx
index 68b4da276ad..63e99d95628 100644
--- a/web/app/components/app/configuration/dataset-config/card-item/__tests__/index.spec.tsx
+++ b/web/app/components/app/configuration/dataset-config/card-item/__tests__/index.spec.tsx
@@ -1,12 +1,13 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type * as React from 'react'
import type { MockedFunction } from 'vite-plus/test'
import type { IndexingType } from '@/app/components/datasets/create/step-two'
-import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD } from '@/types/app'
import Item from '../index'
@@ -17,9 +18,9 @@ vi.mock('../../settings-modal', () => ({
onCancel,
currentDataset,
}: {
- currentDataset: DataSet
+ currentDataset: DatasetDetailWithPartialMembersResponse
onCancel: () => void
- onSave: (newDataset: DataSet) => void
+ onSave: (newDataset: DatasetDetailWithPartialMembersResponse) => void
}) => (
<div>
<div>Mock settings modal</div>
@@ -55,7 +56,9 @@ const baseRetrievalConfig: RetrievalConfig = {
const defaultIndexingTechnique: IndexingType = 'high_quality' as IndexingType
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => {
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => {
const { retrieval_model_dict, icon_info, ...restOverrides } = overrides
const resolvedRetrievalModelDict = {
@@ -78,7 +81,7 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => {
name: 'Dataset Name',
icon_info: resolvedIconInfo,
description: 'A test dataset',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
indexing_technique: defaultIndexingTechnique,
author_name: 'author',
@@ -119,7 +122,10 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => {
}
}
-const renderItem = (config: DataSet, props?: Partial<React.ComponentProps<typeof Item>>) => {
+const renderItem = (
+ config: DatasetDetailWithPartialMembersResponse,
+ props?: Partial<React.ComponentProps<typeof Item>>,
+) => {
const onSave = vi.fn()
const onRemove = vi.fn()
diff --git a/web/app/components/app/configuration/dataset-config/card-item/index.tsx b/web/app/components/app/configuration/dataset-config/card-item/index.tsx
index 25d37b25738..e5782c70d77 100644
--- a/web/app/components/app/configuration/dataset-config/card-item/index.tsx
+++ b/web/app/components/app/configuration/dataset-config/card-item/index.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { DrawerActions } from '@langgenius/dify-ui/drawer'
import type { FC } from 'react'
-import type { DataSet } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import {
Drawer,
@@ -24,10 +24,10 @@ import SettingsModal from '../settings-modal'
type ItemProps = {
className?: string
- config: DataSet
+ config: DatasetDetailWithPartialMembersResponse
onRemove: (id: string) => void
readonly?: boolean
- onSave: (newDataset: DataSet) => void
+ onSave: (newDataset: DatasetDetailWithPartialMembersResponse) => void
editable?: boolean
}
@@ -38,7 +38,7 @@ const Item: FC<ItemProps> = ({ config, onSave, onRemove, readonly = false, edita
const { formatIndexingTechniqueAndMethod } = useKnowledge()
const { t } = useTranslation(['common', 'dataset'])
- const handleSave = (newDataset: DataSet) => {
+ const handleSave = (newDataset: DatasetDetailWithPartialMembersResponse) => {
onSave(newDataset)
settingsDrawerActionsRef.current?.close()
}
diff --git a/web/app/components/app/configuration/dataset-config/index.tsx b/web/app/components/app/configuration/dataset-config/index.tsx
index 17ef4a510c7..e38f9989b02 100644
--- a/web/app/components/app/configuration/dataset-config/index.tsx
+++ b/web/app/components/app/configuration/dataset-config/index.tsx
@@ -1,5 +1,6 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
import type {
HandleAddCondition,
@@ -8,7 +9,6 @@ import type {
HandleUpdateCondition,
MetadataFilteringModeEnum,
} from '@/app/components/workflow/nodes/knowledge-retrieval/types'
-import type { DataSet } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { useSuspenseQuery } from '@tanstack/react-query'
import { intersectionBy } from 'es-toolkit/compat'
@@ -133,7 +133,7 @@ const DatasetConfig: FC<Props> = ({ readonly, hideMetadataFilter }) => {
formattingChangedDispatcher()
}
- const handleSave = (newDataset: DataSet) => {
+ const handleSave = (newDataset: DatasetDetailWithPartialMembersResponse) => {
const index = dataSet.findIndex((item) => item.id === newDataset.id)
const newDatasets = [...dataSet.slice(0, index), newDataset, ...dataSet.slice(index + 1)]
diff --git a/web/app/components/app/configuration/dataset-config/params-config/__tests__/config-content.spec.tsx b/web/app/components/app/configuration/dataset-config/params-config/__tests__/config-content.spec.tsx
index 12ed1833510..e46b0275a01 100644
--- a/web/app/components/app/configuration/dataset-config/params-config/__tests__/config-content.spec.tsx
+++ b/web/app/components/app/configuration/dataset-config/params-config/__tests__/config-content.spec.tsx
@@ -1,6 +1,6 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { MockedFunction, MockInstance } from 'vite-plus/test'
import type { IndexingType } from '@/app/components/datasets/create/step-two'
-import type { DataSet } from '@/models/datasets'
import type { DatasetConfigs } from '@/models/debug'
import type { RetrievalConfig } from '@/types/app'
import { render, screen, waitFor } from '@testing-library/react'
@@ -12,11 +12,11 @@ import {
} from '@/app/components/header/account-setting/model-provider-page/hooks'
import {
ChunkingMode,
- DatasetPermission,
DataSourceType,
RerankingModeEnum,
WeightedScoreEnum,
} from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD, RETRIEVE_TYPE } from '@/types/app'
import ConfigContent from '../config-content'
@@ -77,7 +77,9 @@ const baseRetrievalConfig: RetrievalConfig = {
const defaultIndexingTechnique: IndexingType = 'high_quality' as IndexingType
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => {
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => {
const { retrieval_model_dict, icon_info, ...restOverrides } = overrides
const resolvedRetrievalModelDict = {
@@ -100,7 +102,7 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => {
name: 'Dataset Name',
icon_info: resolvedIconInfo,
description: 'A test dataset',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
indexing_technique: defaultIndexingTechnique,
author_name: 'author',
@@ -218,7 +220,7 @@ describe('ConfigContent', () => {
const datasetConfigs = createDatasetConfigs({
reranking_mode: RerankingModeEnum.WeightedScore,
})
- const selectedDatasets: DataSet[] = [
+ const selectedDatasets: DatasetDetailWithPartialMembersResponse[] = [
createDataset({
indexing_technique: 'high_quality' as IndexingType,
provider: 'dify',
@@ -268,7 +270,7 @@ describe('ConfigContent', () => {
},
},
})
- const selectedDatasets: DataSet[] = [
+ const selectedDatasets: DatasetDetailWithPartialMembersResponse[] = [
createDataset({
indexing_technique: 'high_quality' as IndexingType,
provider: 'dify',
@@ -311,7 +313,7 @@ describe('ConfigContent', () => {
const datasetConfigs = createDatasetConfigs({
reranking_mode: RerankingModeEnum.WeightedScore,
})
- const selectedDatasets: DataSet[] = [
+ const selectedDatasets: DatasetDetailWithPartialMembersResponse[] = [
createDataset({
indexing_technique: 'high_quality' as IndexingType,
provider: 'dify',
@@ -350,7 +352,7 @@ describe('ConfigContent', () => {
const datasetConfigs = createDatasetConfigs({
reranking_enable: false,
})
- const selectedDatasets: DataSet[] = [
+ const selectedDatasets: DatasetDetailWithPartialMembersResponse[] = [
createDataset({
indexing_technique: 'economy' as IndexingType,
provider: 'dify',
diff --git a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx
index 0f6b2fb0cef..059f437ac0f 100644
--- a/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx
+++ b/web/app/components/app/configuration/dataset-config/params-config/config-content.tsx
@@ -1,9 +1,9 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
import type { ModelParameterModalProps } from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
import type { ModelConfig } from '@/app/components/workflow/types'
-import type { DataSet } from '@/models/datasets'
import type { DatasetConfigs } from '@/models/debug'
import { cn } from '@langgenius/dify-ui/cn'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
@@ -29,7 +29,7 @@ import WeightedScore from './weighted-score'
type Props = Readonly<{
datasetConfigs: DatasetConfigs
onChange: (configs: DatasetConfigs, isRetrievalModeChange?: boolean) => void
- selectedDatasets?: DataSet[]
+ selectedDatasets?: DatasetDetailWithPartialMembersResponse[]
isInWorkflow?: boolean
singleRetrievalModelConfig?: ModelConfig
onSingleRetrievalModelChange?: ModelParameterModalProps['setModel']
diff --git a/web/app/components/app/configuration/dataset-config/params-config/index.tsx b/web/app/components/app/configuration/dataset-config/params-config/index.tsx
index 6055d389978..92481b3bc60 100644
--- a/web/app/components/app/configuration/dataset-config/params-config/index.tsx
+++ b/web/app/components/app/configuration/dataset-config/params-config/index.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { DatasetConfigs } from '@/models/debug'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
@@ -22,7 +22,7 @@ import ConfigContent from './config-content'
type ParamsConfigProps = {
disabled?: boolean
- selectedDatasets: DataSet[]
+ selectedDatasets: DatasetDetailWithPartialMembersResponse[]
}
const ParamsConfig = ({ disabled, selectedDatasets }: ParamsConfigProps) => {
const { t } = useTranslation(['appDebug', 'common', 'dataset'])
diff --git a/web/app/components/app/configuration/dataset-config/select-dataset/__tests__/index.spec.tsx b/web/app/components/app/configuration/dataset-config/select-dataset/__tests__/index.spec.tsx
index f8fac885214..8eee0ef345c 100644
--- a/web/app/components/app/configuration/dataset-config/select-dataset/__tests__/index.spec.tsx
+++ b/web/app/components/app/configuration/dataset-config/select-dataset/__tests__/index.spec.tsx
@@ -1,9 +1,9 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
import * as React from 'react'
import { describe, expect, it, vi } from 'vite-plus/test'
import { IndexingType } from '@/app/components/datasets/create/step-two'
-import { DatasetPermission } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { render } from '@/test/console/render'
import { RETRIEVE_METHOD } from '@/types/app'
import SelectDataSet from '../index'
@@ -47,7 +47,9 @@ const baseProps = {
onSelect: vi.fn(),
}
-const makeDataset = (overrides: Partial<DataSet>): DataSet =>
+const makeDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse>,
+): DatasetDetailWithPartialMembersResponse =>
({
id: 'dataset-id',
name: 'Dataset Name',
@@ -61,7 +63,7 @@ const makeDataset = (overrides: Partial<DataSet>): DataSet =>
embedding_available: true,
is_multimodal: false,
description: '',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
indexing_technique: IndexingType.ECONOMICAL,
retrieval_model_dict: {
search_method: RETRIEVE_METHOD.fullText,
@@ -75,7 +77,7 @@ const makeDataset = (overrides: Partial<DataSet>): DataSet =>
score_threshold: 0,
},
...overrides,
- }) as DataSet
+ }) as DatasetDetailWithPartialMembersResponse
describe('SelectDataSet', () => {
beforeEach(() => {
diff --git a/web/app/components/app/configuration/dataset-config/select-dataset/index.tsx b/web/app/components/app/configuration/dataset-config/select-dataset/index.tsx
index 4f66898bffe..2abbabdcae2 100644
--- a/web/app/components/app/configuration/dataset-config/select-dataset/index.tsx
+++ b/web/app/components/app/configuration/dataset-config/select-dataset/index.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { DataSet } from '@/models/datasets'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import { Dialog, DialogClose, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'
@@ -27,7 +27,7 @@ type ISelectDataSetProps = {
modal?: boolean
onClose: () => void
selectedIds: string[]
- onSelect: (dataSet: DataSet[]) => void
+ onSelect: (dataSet: DatasetDetailWithPartialMembersResponse[]) => void
}
const SelectDataSet: FC<ISelectDataSetProps> = ({
@@ -61,7 +61,9 @@ const SelectDataSet: FC<ISelectDataSetProps> = ({
}, [data])
const datasetMap = useMemo(() => new Map(datasets.map((item) => [item.id, item])), [datasets])
const selected = useMemo(() => {
- return selectedIdsInModal.map((id) => datasetMap.get(id) || ({ id } as DataSet))
+ return selectedIdsInModal.map(
+ (id) => datasetMap.get(id) || ({ id } as DatasetDetailWithPartialMembersResponse),
+ )
}, [datasetMap, selectedIdsInModal])
const hasNoData = !isLoading && datasets.length === 0
@@ -81,7 +83,7 @@ const SelectDataSet: FC<ISelectDataSetProps> = ({
},
)
- const toggleSelect = (dataSet: DataSet) => {
+ const toggleSelect = (dataSet: DatasetDetailWithPartialMembersResponse) => {
setSelectedIdsInModal((prev) => {
const isSelected = prev.includes(dataSet.id)
if (isSelected) return prev.filter((id) => id !== dataSet.id)
diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx
index 1c28cb2af25..82e30217da8 100644
--- a/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx
+++ b/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx
@@ -1,7 +1,7 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { GetWorkspacesCurrentModelsModelTypesByModelTypeData } from '@dify/contracts/api/console/workspaces/types.gen'
import type { OperationKey } from '@orpc/tanstack-query'
import type { MockedFunction } from 'vite-plus/test'
-import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { screen, waitFor } from '@testing-library/react'
@@ -9,12 +9,8 @@ import userEvent from '@testing-library/user-event'
import { IndexingType } from '@/app/components/datasets/create/step-two'
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import {
- ChunkingMode,
- DatasetPermission,
- DataSourceType,
- RerankingModeEnum,
-} from '@/models/datasets'
+import { ChunkingMode, DataSourceType, RerankingModeEnum } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { consoleQuery } from '@/service/console'
import { updateDatasetSetting } from '@/service/datasets'
import { seedAccountProfileQuery } from '@/test/console/account-profile'
@@ -134,9 +130,9 @@ const createRetrievalConfig = (overrides: Partial<RetrievalConfig> = {}): Retrie
})
const createDataset = (
- overrides: Partial<DataSet> = {},
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
retrievalOverrides: Partial<RetrievalConfig> = {},
-): DataSet => {
+): DatasetDetailWithPartialMembersResponse => {
const retrievalConfig = createRetrievalConfig(retrievalOverrides)
return {
...createDatasetFixture(),
@@ -147,7 +143,7 @@ const createDataset = (
icon_type: 'emoji',
},
description: 'Description',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
author_name: 'Author',
@@ -193,7 +189,7 @@ const createDataset = (
}
}
-const renderWithProviders = (dataset: DataSet) => {
+const renderWithProviders = (dataset: DatasetDetailWithPartialMembersResponse) => {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false, staleTime: Number.POSITIVE_INFINITY } },
})
@@ -210,9 +206,11 @@ const renderWithProviders = (dataset: DataSet) => {
)
}
-const createMemberList = (): DataSet['partial_member_list'] => ['member-2']
+const createMemberList = (): DatasetDetailWithPartialMembersResponse['partial_member_list'] => [
+ 'member-2',
+]
-const renderSettingsModal = async (dataset: DataSet) => {
+const renderSettingsModal = async (dataset: DatasetDetailWithPartialMembersResponse) => {
renderWithProviders(dataset)
await waitFor(() => expect(mockUseMembers).toHaveBeenCalled())
}
@@ -487,7 +485,7 @@ describe('SettingsModal', () => {
expect.objectContaining({
body: expect.objectContaining({
name: 'Updated Internal Dataset',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
}),
}),
)
@@ -592,7 +590,7 @@ describe('SettingsModal', () => {
const dataset = createDataset(
{
provider: 'external',
- permission: DatasetPermission.partialMembers,
+ permission: PermissionLevel.partialMembers,
partial_member_list: createMemberList(),
external_retrieval_model: {
top_k: 5,
@@ -616,7 +614,7 @@ describe('SettingsModal', () => {
expect(mockUpdateDatasetSetting).toHaveBeenCalledWith(
expect.objectContaining({
body: expect.objectContaining({
- permission: DatasetPermission.partialMembers,
+ permission: PermissionLevel.partialMembers,
external_retrieval_model: expect.objectContaining({
top_k: 5,
}),
@@ -642,7 +640,7 @@ describe('SettingsModal', () => {
it('should disable save button while saving', async () => {
// Arrange
const user = userEvent.setup()
- let finishSave!: (dataset: DataSet) => void
+ let finishSave!: (dataset: DatasetDetailWithPartialMembersResponse) => void
mockUpdateDatasetSetting.mockImplementation(
() =>
new Promise((resolve) => {
diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/retrieval-section.spec.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/retrieval-section.spec.tsx
index d32da33f2c2..44058055e88 100644
--- a/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/retrieval-section.spec.tsx
+++ b/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/retrieval-section.spec.tsx
@@ -1,20 +1,16 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { GetWorkspacesCurrentModelsModelTypesByModelTypeData } from '@dify/contracts/api/console/workspaces/types.gen'
import type { OperationKey } from '@orpc/tanstack-query'
import type { TFunction } from 'i18next'
import type { ReactElement } from 'react'
-import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import type { DocPathWithoutLang } from '@/types/doc-paths'
import { screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { IndexingType } from '@/app/components/datasets/create/step-two'
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import {
- ChunkingMode,
- DatasetPermission,
- DataSourceType,
- RerankingModeEnum,
-} from '@/models/datasets'
+import { ChunkingMode, DataSourceType, RerankingModeEnum } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { consoleQuery } from '@/service/console'
import { createConsoleQueryClient, renderWithConsoleQuery } from '@/test/console/query-data'
import { createDatasetFixture } from '@/test/fixtures/dataset'
@@ -80,9 +76,9 @@ const createRetrievalConfig = (overrides: Partial<RetrievalConfig> = {}): Retrie
})
const createDataset = (
- overrides: Partial<DataSet> = {},
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
retrievalOverrides: Partial<RetrievalConfig> = {},
-): DataSet => {
+): DatasetDetailWithPartialMembersResponse => {
const retrievalConfig = createRetrievalConfig(retrievalOverrides)
return {
...createDatasetFixture(),
@@ -93,7 +89,7 @@ const createDataset = (
icon_type: 'emoji',
},
description: 'Description',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
author_name: 'Author',
diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx
index 3d33c1abfbd..301781531b7 100644
--- a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx
+++ b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx
@@ -1,6 +1,6 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { FC } from 'react'
-import type { Member } from '@/models/common'
-import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
@@ -29,16 +29,16 @@ import {
settingsQueryParser,
} from '@/app/components/header/account-setting/query-params'
import { useDocLink } from '@/context/i18n'
-import { DatasetPermission } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { consoleQuery } from '@/service/console'
import { updateDatasetSetting } from '@/service/datasets'
import { RetrievalChangeTip, RetrievalSection } from './retrieval-section'
type SettingsModalProps = {
- currentDataset: DataSet
+ currentDataset: DatasetDetailWithPartialMembersResponse
height?: string
onCancel: () => void
- onSave: (newDataset: DataSet) => void
+ onSave: (newDataset: DatasetDetailWithPartialMembersResponse) => void
}
const rowClass = `
@@ -85,7 +85,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
const [selectedMemberIDs, setSelectedMemberIDs] = useState<string[]>(
currentDataset.partial_member_list || [],
)
- const [memberList, setMemberList] = useState<Member[]>([])
+ const [memberList, setMemberList] = useState<AccountWithRoleResponse[]>([])
const { data: membersData } = useQuery(
consoleQuery.workspaces.current.members.get.queryOptions({ input: {} }),
)
@@ -174,7 +174,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
}),
},
} as any
- if (permission === DatasetPermission.partialMembers) {
+ if (permission === PermissionLevel.partialMembers) {
requestParams.body.partial_member_list = selectedMemberIDs.map((id) => {
return {
user_id: id,
diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.tsx
index fef660c7fdc..266d85ff298 100644
--- a/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.tsx
+++ b/web/app/components/app/configuration/dataset-config/settings-modal/retrieval-section.tsx
@@ -1,6 +1,6 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { TFunction } from 'i18next'
import type { FC } from 'react'
-import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import type { DocPathWithoutLang } from '@/types/doc-paths'
import { cn } from '@langgenius/dify-ui/cn'
@@ -28,7 +28,7 @@ type ExternalRetrievalSectionProps = CommonSectionProps & {
score_threshold?: number
score_threshold_enabled?: boolean
}) => void
- currentDataset: DataSet
+ currentDataset: DatasetDetailWithPartialMembersResponse
}
const ExternalRetrievalSection: FC<ExternalRetrievalSectionProps> = ({
diff --git a/web/app/components/app/configuration/hooks/configuration-lifecycle/dataset.ts b/web/app/components/app/configuration/hooks/configuration-lifecycle/dataset.ts
index ab582ac2a6a..41d70a462cd 100644
--- a/web/app/components/app/configuration/hooks/configuration-lifecycle/dataset.ts
+++ b/web/app/components/app/configuration/hooks/configuration-lifecycle/dataset.ts
@@ -1,5 +1,5 @@
import type { AppModelConfigResponse } from '@dify/contracts/api/console/apps/types.gen'
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { DatasetConfigs } from '@/models/debug'
import { produce } from 'immer'
import { useMemo } from 'react'
@@ -21,7 +21,7 @@ export function buildConfigurationDatasetConfigs({
backendModelConfig: AppModelConfigResponse
currentRerankModel?: string
currentRerankProvider?: string
- nextDataSets: DataSet[]
+ nextDataSets: DatasetDetailWithPartialMembersResponse[]
}): DatasetConfigs {
const retrievalConfig = getMultipleRetrievalConfig(
{
@@ -93,12 +93,12 @@ export function buildConfigurationDatasetConfigs({
type DatasetSelectHandlerOptions = {
currentRerankModel?: string
currentRerankProvider?: string
- dataSets: DataSet[]
+ dataSets: DatasetDetailWithPartialMembersResponse[]
datasetConfigs: DatasetConfigs
datasetConfigsRef: { current: DatasetConfigs }
formattingChangedDispatcher: () => void
hideSelectDataSet: () => void
- setDataSets: (data: DataSet[]) => void
+ setDataSets: (data: DatasetDetailWithPartialMembersResponse[]) => void
setDatasetConfigs: (configs: DatasetConfigs) => void
setRerankSettingModalOpen: (visible: boolean) => void
}
@@ -116,7 +116,7 @@ export const createDatasetSelectHandler =
setDatasetConfigs,
setRerankSettingModalOpen,
}: DatasetSelectHandlerOptions) =>
- (nextDataSets: DataSet[]) => {
+ (nextDataSets: DatasetDetailWithPartialMembersResponse[]) => {
if (
nextDataSets.map((item) => item.id).join(',') === dataSets.map((item) => item.id).join(',')
) {
diff --git a/web/app/components/app/configuration/hooks/configuration-lifecycle/load.ts b/web/app/components/app/configuration/hooks/configuration-lifecycle/load.ts
index 6d23c62ff87..274f3948e60 100644
--- a/web/app/components/app/configuration/hooks/configuration-lifecycle/load.ts
+++ b/web/app/components/app/configuration/hooks/configuration-lifecycle/load.ts
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { zAppLegacyDatasetToolResponse } from '@dify/contracts/api/console/apps/zod.gen'
import { PromptMode } from '@/models/debug'
import { consoleClient } from '@/service/console'
@@ -29,7 +29,7 @@ export async function loadConfigurationState({
if (!backendModelConfig) throw new Error(`App ${appId} has no model configuration`)
const nextPromptMode =
backendModelConfig.prompt_type === PromptMode.advanced ? PromptMode.advanced : PromptMode.simple
- let nextDataSets: DataSet[] = []
+ let nextDataSets: DatasetDetailWithPartialMembersResponse[] = []
const agentDatasets = (backendModelConfig.agent_mode.tools ?? []).flatMap((tool) => {
const result = zAppLegacyDatasetToolResponse.safeParse(tool)
return result.success ? [result.data.dataset] : []
diff --git a/web/app/components/app/configuration/hooks/configuration-lifecycle/publish.ts b/web/app/components/app/configuration/hooks/configuration-lifecycle/publish.ts
index 14fd005378c..4c1d020444d 100644
--- a/web/app/components/app/configuration/hooks/configuration-lifecycle/publish.ts
+++ b/web/app/components/app/configuration/hooks/configuration-lifecycle/publish.ts
@@ -1,10 +1,10 @@
import type { AppModelConfigPayload } from '@dify/contracts/api/console/apps/types.gen'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { TFunction } from 'i18next'
import type { ConfigurationPublishConfig } from './types'
import type { ConfigurationAppMode } from '@/app/components/app/configuration/hooks/configuration-lifecycle/types'
import type { Features as FeaturesData } from '@/app/components/base/features/types'
import type { FormValue } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import type { DataSet } from '@/models/datasets'
import type { DatasetConfigs, ModelConfig, PromptVariable } from '@/models/debug'
import type { ConsoleClient } from '@/service/console'
import {
@@ -49,7 +49,7 @@ export function buildPublishBody({
completionParams: FormValue
completionPromptConfig: ModelConfig['completion_prompt_config']
contextVar?: string
- dataSets: DataSet[]
+ dataSets: DatasetDetailWithPartialMembersResponse[]
datasetConfigs: DatasetConfigs
externalDataToolsConfig: ModelConfig['external_data_tools']
features?: FeaturesData
@@ -147,7 +147,7 @@ export const createPublishHandler =
completionPromptConfig: ModelConfig['completion_prompt_config']
contextVar?: string
contextVarEmpty: boolean
- dataSets: DataSet[]
+ dataSets: DatasetDetailWithPartialMembersResponse[]
datasetConfigs: DatasetConfigs
externalDataToolsConfig: ModelConfig['external_data_tools']
hasSetBlockStatus: { history: boolean; query: boolean }
diff --git a/web/app/components/app/configuration/hooks/configuration-lifecycle/published-config.ts b/web/app/components/app/configuration/hooks/configuration-lifecycle/published-config.ts
index 55d3a37031d..35eaf2be005 100644
--- a/web/app/components/app/configuration/hooks/configuration-lifecycle/published-config.ts
+++ b/web/app/components/app/configuration/hooks/configuration-lifecycle/published-config.ts
@@ -2,10 +2,10 @@ import type {
AppModelConfigResponse,
DeletedTool,
} from '@dify/contracts/api/console/apps/types.gen'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ConfigurationPublishConfig } from './types'
import type { ConfigurationAppMode } from '@/app/components/app/configuration/hooks/configuration-lifecycle/types'
import type { Collection } from '@/app/components/tools/types'
-import type { DataSet } from '@/models/datasets'
import type { AnnotationReplyConfig, DatasetConfigs, ModelConfig } from '@/models/debug'
import {
zAppExternalDataToolPayload,
@@ -52,7 +52,7 @@ function buildPublishedModelConfig({
collectionList: Collection[]
deletedTools?: DeletedTool[]
mode: ConfigurationAppMode
- nextDataSets: DataSet[]
+ nextDataSets: DatasetDetailWithPartialMembersResponse[]
}): ModelConfig {
const model = backendModelConfig.model
const externalDataTools = backendModelConfig.external_data_tools.map((tool) => {
@@ -172,7 +172,7 @@ export function buildPublishedConfig({
datasetConfigs: DatasetConfigs
deletedTools?: DeletedTool[]
mode: ConfigurationAppMode
- nextDataSets: DataSet[]
+ nextDataSets: DatasetDetailWithPartialMembersResponse[]
}): ConfigurationPublishConfig {
const modelConfig = buildPublishedModelConfig({
backendModelConfig,
diff --git a/web/app/components/app/configuration/hooks/configuration-lifecycle/use-configuration-publish.ts b/web/app/components/app/configuration/hooks/configuration-lifecycle/use-configuration-publish.ts
index 354f70b22e6..cf23560085c 100644
--- a/web/app/components/app/configuration/hooks/configuration-lifecycle/use-configuration-publish.ts
+++ b/web/app/components/app/configuration/hooks/configuration-lifecycle/use-configuration-publish.ts
@@ -1,11 +1,10 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { TFunction } from 'i18next'
import type { Dispatch, SetStateAction } from 'react'
-import type { ConfigurationPublishConfig } from './types'
+import type { ConfigurationAppMode, ConfigurationPublishConfig } from './types'
import type { AppPublisherPublishParams } from '@/app/components/app/app-publisher/types'
-import type { ConfigurationAppMode } from '@/app/components/app/configuration/hooks/configuration-lifecycle/types'
import type { Features as FeaturesData } from '@/app/components/base/features/types'
import type { FormValue } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import type { DataSet } from '@/models/datasets'
import type { DatasetConfigs, ModelConfig, PromptMode } from '@/models/debug'
import type { ConsoleClient } from '@/service/console'
import type { ModelModeType } from '@/types/app'
@@ -20,7 +19,7 @@ type UseConfigurationPublishParams = {
completionPromptConfig: ModelConfig['completion_prompt_config']
contextVar?: string
contextVarEmpty: boolean
- dataSets: DataSet[]
+ dataSets: DatasetDetailWithPartialMembersResponse[]
datasetConfigs: DatasetConfigs
externalDataToolsConfig: ModelConfig['external_data_tools']
hasSetBlockStatus: { history: boolean; query: boolean }
diff --git a/web/app/components/app/configuration/hooks/configuration-lifecycle/use-dataset-configuration-state.ts b/web/app/components/app/configuration/hooks/configuration-lifecycle/use-dataset-configuration-state.ts
index c634c083919..e2d4eb0e878 100644
--- a/web/app/components/app/configuration/hooks/configuration-lifecycle/use-dataset-configuration-state.ts
+++ b/web/app/components/app/configuration/hooks/configuration-lifecycle/use-dataset-configuration-state.ts
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { DatasetConfigs } from '@/models/debug'
import { useCallback, useRef, useState } from 'react'
import { DATASET_DEFAULT } from '@/config'
@@ -23,7 +23,7 @@ export function useDatasetConfigurationState() {
setDatasetConfigs(nextDatasetConfigs)
datasetConfigsRef.current = nextDatasetConfigs
}, [])
- const [dataSets, setDataSets] = useState<DataSet[]>([])
+ const [dataSets, setDataSets] = useState<DatasetDetailWithPartialMembersResponse[]>([])
return {
dataSets,
diff --git a/web/app/components/app/configuration/hooks/configuration-lifecycle/use-published-config-sync.ts b/web/app/components/app/configuration/hooks/configuration-lifecycle/use-published-config-sync.ts
index dec7a1d3a5e..2f52d309458 100644
--- a/web/app/components/app/configuration/hooks/configuration-lifecycle/use-published-config-sync.ts
+++ b/web/app/components/app/configuration/hooks/configuration-lifecycle/use-published-config-sync.ts
@@ -1,7 +1,7 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ConfigurationPublishConfig } from './types'
import type { FormValue } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { ExternalDataTool } from '@/models/common'
-import type { DataSet } from '@/models/datasets'
import type {
DatasetConfigs,
ModelConfig,
@@ -20,7 +20,7 @@ type UsePublishedConfigSyncParams = {
setCitationConfig: (value: MoreLikeThisConfig) => void
setCompletionParams: (value: FormValue) => void
setCompletionPromptConfig: (value: ConfigurationPublishConfig['completionPromptConfig']) => void
- setDataSets: (value: DataSet[]) => void
+ setDataSets: (value: DatasetDetailWithPartialMembersResponse[]) => void
setDatasetConfigs: (value: DatasetConfigs) => void
setExternalDataToolsConfig: (value: ExternalDataTool[]) => void
setIntroduction: (value: string) => void
diff --git a/web/app/components/app/configuration/hooks/configuration-view-model.ts b/web/app/components/app/configuration/hooks/configuration-view-model.ts
index d6e35aa99f1..9760bed5ccb 100644
--- a/web/app/components/app/configuration/hooks/configuration-view-model.ts
+++ b/web/app/components/app/configuration/hooks/configuration-view-model.ts
@@ -1,3 +1,4 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ComponentProps } from 'react'
import type AppPublisher from '@/app/components/app/app-publisher/features-wrapper'
import type { ModelAndParameter } from '@/app/components/app/configuration/debug/types'
@@ -8,7 +9,6 @@ import type {
import type { FormValue } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
import type ConfigContext from '@/context/debug-configuration'
-import type { DataSet } from '@/models/datasets'
import type { ModelConfig, PromptVariable } from '@/models/debug'
export type DebugConfigurationValue = ComponentProps<typeof ConfigContext.Provider>['value']
@@ -42,7 +42,7 @@ export type ConfigurationViewModel = {
onSaveHistory: (
data: DebugConfigurationValue['completionPromptConfig']['conversation_histories_role'],
) => void
- onSelectDataSets: (data: DataSet[]) => void
+ onSelectDataSets: (data: DatasetDetailWithPartialMembersResponse[]) => void
promptVariables: PromptVariable[]
selectedIds: string[]
showAppConfigureFeaturesModal: boolean
diff --git a/web/app/components/app/log/list-utils.ts b/web/app/components/app/log/list-utils.ts
index 02d5a5a929a..bbcdcbe8051 100644
--- a/web/app/components/app/log/list-utils.ts
+++ b/web/app/components/app/log/list-utils.ts
@@ -49,13 +49,11 @@ const getUserInputVariable = (item: unknown) => {
return typeof variable === 'string' ? variable : undefined
}
-type LogMessage = MessageDetailResponse
-
const isTransferMethod = (value: string): value is TransferMethod =>
(Object.values(TransferMethod) as string[]).includes(value)
// Agent thoughts keep raw message files; the agent content renderer converts them once.
-const toThoughtFiles = (item: LogMessage): VisionFile[] =>
+const toThoughtFiles = (item: MessageDetailResponse): VisionFile[] =>
item.message_files.map((file) => ({
id: file.id,
type: file.type,
@@ -67,7 +65,7 @@ const toThoughtFiles = (item: LogMessage): VisionFile[] =>
belongs_to: file.belongs_to ?? undefined,
}))
-const toFileResponse = (file: LogMessage['message_files'][number]): FileResponse => ({
+const toFileResponse = (file: MessageDetailResponse['message_files'][number]): FileResponse => ({
related_id: file.id ?? file.upload_file_id,
extension: '',
filename: '',
@@ -85,19 +83,21 @@ const toFileResponse = (file: LogMessage['message_files'][number]): FileResponse
const toText = (value: unknown) => (typeof value === 'string' && value ? value : undefined)
// `inputs` values are untyped JSON in the console API response.
-export const getStringInputs = (inputs: LogMessage['inputs']) =>
+export const getStringInputs = (inputs: MessageDetailResponse['inputs']) =>
Object.fromEntries(
Object.entries(inputs).filter(
(entry): entry is [string, string] => typeof entry[1] === 'string',
),
)
-const toFeedback = (feedback?: LogMessage['feedbacks'][number]): FeedbackType | undefined =>
+const toFeedback = (
+ feedback?: MessageDetailResponse['feedbacks'][number],
+): FeedbackType | undefined =>
feedback?.rating === 'like' || feedback?.rating === 'dislike'
? { rating: feedback.rating, content: feedback.content }
: undefined
-const toThoughtItems = (message: LogMessage): ThoughtItem[] =>
+const toThoughtItems = (message: MessageDetailResponse): ThoughtItem[] =>
message.agent_thoughts.map((thought) => ({
id: thought.id,
tool: thought.tool ?? '',
@@ -116,15 +116,15 @@ const toThoughtItems = (message: LogMessage): ThoughtItem[] =>
}))
// `message` and `metadata` are untyped JSON in the console API response.
-const getPromptLog = (message: LogMessage) =>
+const getPromptLog = (message: MessageDetailResponse) =>
(Array.isArray(message.message) ? message.message : []) as NonNullable<IChatItem['log']>
-const getCitations = (message: LogMessage) =>
+const getCitations = (message: MessageDetailResponse) =>
isPlainObject(message.metadata) && Array.isArray(message.metadata.retriever_resources)
? (message.metadata.retriever_resources as CitationItem[])
: undefined
-const getAnnotation = (message: LogMessage): Annotation | undefined => {
+const getAnnotation = (message: MessageDetailResponse): Annotation | undefined => {
if (message.annotation_hit_history) {
return {
id: message.annotation_hit_history.annotation_id,
@@ -152,7 +152,7 @@ const getAnnotation = (message: LogMessage): Annotation | undefined => {
}
export const getFormattedChatList = (
- messages: LogMessage[],
+ messages: MessageDetailResponse[],
conversationId: string,
timezone: string,
format: string,
diff --git a/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsx b/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsx
index ce8b091e4ee..1c5542a9bdc 100644
--- a/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsx
+++ b/web/app/components/base/agent-log-modal/__tests__/detail.spec.tsx
@@ -1,6 +1,6 @@
+import type { AgentLogResponse } from '@dify/contracts/api/console/apps/types.gen'
import type { ComponentProps, ReactNode } from 'react'
import type { IChatItem } from '@/app/components/base/chat/chat/type'
-import type { AgentLogDetailResponse } from '@/models/log'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import { createHttpError } from '@/service/http-error'
import AgentLogDetail from '../detail'
@@ -79,9 +79,7 @@ const createMockLog = (overrides: Partial<IChatItem> = {}): IChatItem => ({
...overrides,
})
-const createMockResponse = (
- overrides: Partial<AgentLogDetailResponse> = {},
-): AgentLogDetailResponse => ({
+const createMockResponse = (overrides: Partial<AgentLogResponse> = {}): AgentLogResponse => ({
meta: {
status: 'succeeded',
executor: 'User',
diff --git a/web/app/components/base/agent-log-modal/__tests__/iteration.spec.tsx b/web/app/components/base/agent-log-modal/__tests__/iteration.spec.tsx
index 3e841d76363..ebba8587144 100644
--- a/web/app/components/base/agent-log-modal/__tests__/iteration.spec.tsx
+++ b/web/app/components/base/agent-log-modal/__tests__/iteration.spec.tsx
@@ -1,4 +1,4 @@
-import type { AgentIteration } from '@/models/log'
+import type { AgentIterationLogResponse } from '@dify/contracts/api/console/apps/types.gen'
import { render, screen } from '@testing-library/react'
import Iteration from '../iteration'
@@ -15,7 +15,7 @@ vi.mock('@/app/components/workflow/block-icon', () => ({
default: () => <div data-testid="block-icon" />,
}))
-const mockIterationInfo: AgentIteration = {
+const mockIterationInfo: AgentIterationLogResponse = {
created_at: '2023-01-01',
files: [],
thought: 'Test thought',
diff --git a/web/app/components/base/agent-log-modal/__tests__/tracing.spec.tsx b/web/app/components/base/agent-log-modal/__tests__/tracing.spec.tsx
index 4d744ebf256..944abd959a7 100644
--- a/web/app/components/base/agent-log-modal/__tests__/tracing.spec.tsx
+++ b/web/app/components/base/agent-log-modal/__tests__/tracing.spec.tsx
@@ -1,4 +1,4 @@
-import type { AgentIteration } from '@/models/log'
+import type { AgentIterationLogResponse } from '@dify/contracts/api/console/apps/types.gen'
import { render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vite-plus/test'
import TracingPanel from '../tracing'
@@ -16,7 +16,7 @@ vi.mock('@/app/components/workflow/nodes/_base/components/editor/code-editor', (
),
}))
-const createIteration = (thought: string, tokens: number): AgentIteration => ({
+const createIteration = (thought: string, tokens: number): AgentIterationLogResponse => ({
created_at: '',
files: [],
thought,
@@ -36,7 +36,7 @@ const createIteration = (thought: string, tokens: number): AgentIteration => ({
tool_raw: { inputs: '', outputs: '' },
})
-const mockList: AgentIteration[] = [
+const mockList: AgentIterationLogResponse[] = [
createIteration('Thought 1', 10),
createIteration('Thought 2', 20),
createIteration('Thought 3', 30),
diff --git a/web/app/components/base/agent-log-modal/detail.tsx b/web/app/components/base/agent-log-modal/detail.tsx
index 8c078660d6e..397c037696c 100644
--- a/web/app/components/base/agent-log-modal/detail.tsx
+++ b/web/app/components/base/agent-log-modal/detail.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { AgentLogResponse } from '@dify/contracts/api/console/apps/types.gen'
import type { FC } from 'react'
import type { IChatItem } from '@/app/components/base/chat/chat/type'
-import type { AgentLogDetailResponse } from '@/models/log'
import { cn } from '@langgenius/dify-ui/cn'
import { uniq } from 'es-toolkit/array'
import * as React from 'react'
@@ -79,7 +79,7 @@ function AgentLogContent({
currentTab,
}: AgentLogContentProps) {
const [loading, setLoading] = useState(true)
- const [runDetail, setRunDetail] = useState<AgentLogDetailResponse>()
+ const [runDetail, setRunDetail] = useState<AgentLogResponse>()
const tools = useMemo(
() =>
uniq(
diff --git a/web/app/components/base/agent-log-modal/index.stories.tsx b/web/app/components/base/agent-log-modal/index.stories.tsx
index 80dfb397d3b..1aedc7bf759 100644
--- a/web/app/components/base/agent-log-modal/index.stories.tsx
+++ b/web/app/components/base/agent-log-modal/index.stories.tsx
@@ -1,11 +1,11 @@
+import type { AgentLogResponse } from '@dify/contracts/api/console/apps/types.gen'
import type { Meta, StoryObj } from '@storybook/nextjs-vite'
import type { IChatItem } from '@/app/components/base/chat/chat/type'
-import type { AgentLogDetailResponse } from '@/models/log'
import { useEffect, useRef } from 'react'
import { AppToastHost } from '@/app/notifications/host'
import AgentLogModal from '.'
-const MOCK_RESPONSE: AgentLogDetailResponse = {
+const MOCK_RESPONSE: AgentLogResponse = {
meta: {
status: 'finished',
executor: 'Agent Runner',
diff --git a/web/app/components/base/agent-log-modal/iteration.tsx b/web/app/components/base/agent-log-modal/iteration.tsx
index 7b62654f0bb..12452c87b60 100644
--- a/web/app/components/base/agent-log-modal/iteration.tsx
+++ b/web/app/components/base/agent-log-modal/iteration.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { AgentIterationLogResponse } from '@dify/contracts/api/console/apps/types.gen'
import type { FC } from 'react'
-import type { AgentIteration } from '@/models/log'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
import { useTranslation } from 'react-i18next'
@@ -9,7 +9,7 @@ import ToolCall from './tool-call'
type Props = Readonly<{
isFinal: boolean
index: number
- iterationInfo: AgentIteration
+ iterationInfo: AgentIterationLogResponse
}>
const Iteration: FC<Props> = ({ iterationInfo, isFinal, index }) => {
diff --git a/web/app/components/base/agent-log-modal/tool-call.tsx b/web/app/components/base/agent-log-modal/tool-call.tsx
index 1aab26d4e91..04d4bba00a0 100644
--- a/web/app/components/base/agent-log-modal/tool-call.tsx
+++ b/web/app/components/base/agent-log-modal/tool-call.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { AgentToolCallResponse } from '@dify/contracts/api/console/apps/types.gen'
import type { FC } from 'react'
-import type { ToolCall } from '@/models/log'
import { cn } from '@langgenius/dify-ui/cn'
import { RiCheckboxCircleLine, RiErrorWarningLine } from '@remixicon/react'
import { useState } from 'react'
@@ -10,7 +10,7 @@ import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
import { BlockEnum } from '@/app/components/workflow/types'
-const getToolIcon = (icon: ToolCall['tool_icon']) => {
+const getToolIcon = (icon: AgentToolCallResponse['tool_icon']) => {
if (typeof icon === 'string') return icon
if (icon?.content !== undefined && icon.background !== undefined)
return { content: icon.content, background: icon.background }
@@ -18,7 +18,7 @@ const getToolIcon = (icon: ToolCall['tool_icon']) => {
}
type Props = Readonly<{
- toolCall: Partial<ToolCall> & Pick<ToolCall, 'status'>
+ toolCall: Partial<AgentToolCallResponse> & Pick<AgentToolCallResponse, 'status'>
isLLM: boolean
isFinal?: boolean
tokens?: number
diff --git a/web/app/components/base/agent-log-modal/tracing.tsx b/web/app/components/base/agent-log-modal/tracing.tsx
index 0edd2176940..455cf0af40b 100644
--- a/web/app/components/base/agent-log-modal/tracing.tsx
+++ b/web/app/components/base/agent-log-modal/tracing.tsx
@@ -1,10 +1,10 @@
'use client'
+import type { AgentIterationLogResponse } from '@dify/contracts/api/console/apps/types.gen'
import type { FC } from 'react'
-import type { AgentIteration } from '@/models/log'
import Iteration from './iteration'
type TracingPanelProps = Readonly<{
- list: AgentIteration[]
+ list: AgentIterationLogResponse[]
}>
const TracingPanel: FC<TracingPanelProps> = ({ list }) => {
diff --git a/web/app/components/base/features/types.ts b/web/app/components/base/features/types.ts
index e38fb25c779..d6747d60988 100644
--- a/web/app/components/base/features/types.ts
+++ b/web/app/components/base/features/types.ts
@@ -1,13 +1,11 @@
import type { AppModelSelectionResponse } from '@dify/contracts/api/console/apps/types.gen'
-import type { FileUploadConfigResponse } from '@/models/common'
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { Resolution, TransferMethod, TtsAutoPlay } from '@/types/app'
type EnabledOrDisabled = {
enabled?: boolean
}
-type MoreLikeThis = EnabledOrDisabled
-
export type OpeningStatement = EnabledOrDisabled & {
opening_statement?: string
suggested_questions?: string[]
@@ -24,10 +22,6 @@ type TextToSpeech = EnabledOrDisabled & {
autoPlay?: TtsAutoPlay
}
-type SpeechToText = EnabledOrDisabled
-
-type RetrieverResource = EnabledOrDisabled
-
type SensitiveWordAvoidance = EnabledOrDisabled & {
type?: string
config?: any
@@ -66,7 +60,7 @@ export type FileUpload = {
allowed_file_extensions?: string[]
allowed_file_upload_methods?: TransferMethod[]
number_limits?: number
- fileUploadConfig?: FileUploadConfigResponse
+ fileUploadConfig?: UploadConfig
preview_config?: {
mode?: PreviewMode
file_type_list?: string[]
@@ -98,12 +92,12 @@ export const FeatureEnum = {
export type FeatureEnum = (typeof FeatureEnum)[keyof typeof FeatureEnum]
export type Features = {
- [FeatureEnum.moreLikeThis]?: MoreLikeThis
+ [FeatureEnum.moreLikeThis]?: EnabledOrDisabled
[FeatureEnum.opening]?: OpeningStatement
[FeatureEnum.suggested]?: SuggestedQuestionsAfterAnswer
[FeatureEnum.text2speech]?: TextToSpeech
- [FeatureEnum.speech2text]?: SpeechToText
- [FeatureEnum.citation]?: RetrieverResource
+ [FeatureEnum.speech2text]?: EnabledOrDisabled
+ [FeatureEnum.citation]?: EnabledOrDisabled
[FeatureEnum.moderation]?: SensitiveWordAvoidance
[FeatureEnum.file]?: FileUpload
[FeatureEnum.annotationReply]?: AnnotationReplyConfig
diff --git a/web/app/components/base/file-uploader/__tests__/hooks.spec.ts b/web/app/components/base/file-uploader/__tests__/hooks.spec.ts
index 7272a52090a..0c5225ab96a 100644
--- a/web/app/components/base/file-uploader/__tests__/hooks.spec.ts
+++ b/web/app/components/base/file-uploader/__tests__/hooks.spec.ts
@@ -1,6 +1,6 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { FileEntity } from '../types'
import type { FileUpload } from '@/app/components/base/features/types'
-import type { FileUploadConfigResponse } from '@/models/common'
import { act, renderHook } from '@testing-library/react'
import { useFile, useFileSizeLimit } from '../hooks'
@@ -84,14 +84,14 @@ describe('useFileSizeLimit', () => {
})
it('should use config values when provided', () => {
- const config: FileUploadConfigResponse = {
+ const config: UploadConfig = {
image_file_size_limit: 20,
file_size_limit: 30,
audio_file_size_limit: 100,
video_file_size_limit: 200,
skill_file_size_limit: 60,
workflow_file_upload_limit: 20,
- } as FileUploadConfigResponse
+ } as UploadConfig
const { result } = renderHook(() => useFileSizeLimit(config))
@@ -111,7 +111,7 @@ describe('useFileSizeLimit', () => {
video_file_size_limit: 0,
skill_file_size_limit: 0,
workflow_file_upload_limit: 0,
- } as FileUploadConfigResponse
+ } as UploadConfig
const { result } = renderHook(() => useFileSizeLimit(config))
diff --git a/web/app/components/base/file-uploader/hooks.ts b/web/app/components/base/file-uploader/hooks.ts
index 8a1871fcde1..1cb1db97e4c 100644
--- a/web/app/components/base/file-uploader/hooks.ts
+++ b/web/app/components/base/file-uploader/hooks.ts
@@ -1,7 +1,7 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { ClipboardEvent } from 'react'
import type { FileEntity } from './types'
import type { FileUpload } from '@/app/components/base/features/types'
-import type { FileUploadConfigResponse } from '@/models/common'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
import { useCallback, useState } from 'react'
@@ -31,7 +31,7 @@ import {
isAllowedFileExtension,
} from './utils'
-export const useFileSizeLimit = (fileUploadConfig?: FileUploadConfigResponse) => {
+export const useFileSizeLimit = (fileUploadConfig?: UploadConfig) => {
const imgSizeLimit =
Number(fileUploadConfig?.image_file_size_limit) * 1024 * 1024 || IMG_SIZE_LIMIT
const docSizeLimit = Number(fileUploadConfig?.file_size_limit) * 1024 * 1024 || FILE_SIZE_LIMIT
diff --git a/web/app/components/base/linked-apps-panel/index.stories.tsx b/web/app/components/base/linked-apps-panel/index.stories.tsx
index 80a92d5d2ac..6154fdf0a62 100644
--- a/web/app/components/base/linked-apps-panel/index.stories.tsx
+++ b/web/app/components/base/linked-apps-panel/index.stories.tsx
@@ -1,8 +1,8 @@
+import type { RelatedAppResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { Meta, StoryObj } from '@storybook/nextjs-vite'
-import type { RelatedApp } from '@/models/datasets'
import LinkedAppsPanel from '.'
-const mockRelatedApps: RelatedApp[] = [
+const mockRelatedApps: RelatedAppResponse[] = [
{
id: 'app-cx',
name: 'Customer Support Assistant',
diff --git a/web/app/components/base/linked-apps-panel/index.tsx b/web/app/components/base/linked-apps-panel/index.tsx
index 1899186c6f3..f93b42ff2d5 100644
--- a/web/app/components/base/linked-apps-panel/index.tsx
+++ b/web/app/components/base/linked-apps-panel/index.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { RelatedAppResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { RelatedApp } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { RiArrowRightUpLine } from '@remixicon/react'
import * as React from 'react'
@@ -10,11 +10,11 @@ import Link from '@/next/link'
type ILikedItemProps = Readonly<{
appStatus?: boolean
- detail: RelatedApp
+ detail: RelatedAppResponse
isMobile: boolean
}>
-const appTypeMap: Partial<Record<RelatedApp['mode'], string>> = {
+const appTypeMap: Partial<Record<RelatedAppResponse['mode'], string>> = {
chat: 'Chatbot',
completion: 'Completion',
'agent-chat': 'Agent',
@@ -50,7 +50,7 @@ const LikedItem = ({ detail, isMobile }: ILikedItemProps) => {
}
type Props = Readonly<{
- relatedApps: RelatedApp[]
+ relatedApps: RelatedAppResponse[]
isMobile: boolean
}>
diff --git a/web/app/components/base/notion-page-selector/__tests__/base.spec.tsx b/web/app/components/base/notion-page-selector/__tests__/base.spec.tsx
index f5ce1df6354..db01df3e76a 100644
--- a/web/app/components/base/notion-page-selector/__tests__/base.spec.tsx
+++ b/web/app/components/base/notion-page-selector/__tests__/base.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '../../../header/account-setting/data-source-page-new/types'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { DataSourceNotionWorkspace } from '@/models/common'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -30,7 +30,7 @@ const buildCredential = (
id: string,
name: string,
workspaceName: string,
-): DataSourceCredential => ({
+): DatasourceCredentialResponse => ({
id,
name,
type: CredentialTypeEnum.OAUTH2,
@@ -42,7 +42,7 @@ const buildCredential = (
},
})
-const mockCredentialList: DataSourceCredential[] = [
+const mockCredentialList: DatasourceCredentialResponse[] = [
buildCredential('c1', 'Cred 1', 'Workspace 1'),
buildCredential('c2', 'Cred 2', 'Workspace 2'),
]
diff --git a/web/app/components/base/notion-page-selector/base.tsx b/web/app/components/base/notion-page-selector/base.tsx
index 89f89806586..444f0cb50f5 100644
--- a/web/app/components/base/notion-page-selector/base.tsx
+++ b/web/app/components/base/notion-page-selector/base.tsx
@@ -1,5 +1,5 @@
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { NotionIntegrateInfoListResponse } from '@dify/contracts/api/console/notion/types.gen'
-import type { DataSourceCredential } from '../../header/account-setting/data-source-page-new/types'
import type { NotionCredential } from './credential-selector'
import type {
DataSourceNotionPageMap,
@@ -51,7 +51,7 @@ type NotionPageSelectorProps = {
previewPageId?: string
onPreview?: (selectedPage: NotionPage) => void
datasetId?: string
- credentialList: DataSourceCredential[]
+ credentialList: DatasourceCredentialResponse[]
onSelectCredential?: (credentialId: string) => void
}
diff --git a/web/app/components/base/notion-page-selector/index.stories.tsx b/web/app/components/base/notion-page-selector/index.stories.tsx
index aed090b5c4d..17ef4ff6360 100644
--- a/web/app/components/base/notion-page-selector/index.stories.tsx
+++ b/web/app/components/base/notion-page-selector/index.stories.tsx
@@ -1,12 +1,12 @@
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { Meta, StoryObj } from '@storybook/nextjs-vite'
-import type { DataSourceCredential } from '@/app/components/header/account-setting/data-source-page-new/types'
import type { NotionPage } from '@/models/common'
import { useEffect, useMemo, useState } from 'react'
import { CredentialTypeEnum } from '@/app/components/plugins/plugin-auth/types'
import { NotionPageSelector } from '.'
const DATASET_ID = 'dataset-demo'
-const CREDENTIALS: DataSourceCredential[] = [
+const CREDENTIALS: DatasourceCredentialResponse[] = [
{
id: 'cred-1',
name: 'Marketing Workspace',
diff --git a/web/app/components/base/prompt-editor/plugins/error-message-block/node.tsx b/web/app/components/base/prompt-editor/plugins/error-message-block/node.tsx
index 09d8a78d940..d0adbd9e96c 100644
--- a/web/app/components/base/prompt-editor/plugins/error-message-block/node.tsx
+++ b/web/app/components/base/prompt-editor/plugins/error-message-block/node.tsx
@@ -2,8 +2,6 @@ import type { NodeKey, SerializedLexicalNode } from 'lexical'
import { DecoratorNode } from 'lexical'
import ErrorMessageBlockComponent from './component'
-type SerializedNode = SerializedLexicalNode
-
export class ErrorMessageBlockNode extends DecoratorNode<React.JSX.Element> {
static override getType(): string {
return 'error-message-block'
@@ -41,7 +39,7 @@ export class ErrorMessageBlockNode extends DecoratorNode<React.JSX.Element> {
return node
}
- override exportJSON(): SerializedNode {
+ override exportJSON(): SerializedLexicalNode {
return {
type: 'error-message-block',
version: 1,
diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx
index cd4fe8ea5e6..48f23f98038 100644
--- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx
+++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx
@@ -2,8 +2,8 @@ import type { Hotkey } from '@tanstack/react-hotkeys'
import type { Item as TypeSelectItem } from '@/app/components/app/configuration/config-var/config-modal/type-select'
import type {
FormInputItem,
- FormInputItemDefault,
ParagraphFormInput,
+ StringDefault,
} from '@/app/components/workflow/nodes/human-input/types'
import type { UploadFileSetting, ValueSelector } from '@/app/components/workflow/types'
import { Button } from '@langgenius/dify-ui/button'
@@ -121,7 +121,7 @@ const InputField: React.FC<InputFieldProps> = ({
)
}, [])
const handleDefaultValueChange = useCallback(
- (key: keyof FormInputItemDefault) => {
+ (key: keyof StringDefault) => {
return (value: ValueSelector | string) => {
const nextValue = produce(paragraphPayload, (draft) => {
if (key === 'selector') {
diff --git a/web/app/components/base/prompt-editor/plugins/last-run-block/node.tsx b/web/app/components/base/prompt-editor/plugins/last-run-block/node.tsx
index 90a48263759..c2aa7d7f23b 100644
--- a/web/app/components/base/prompt-editor/plugins/last-run-block/node.tsx
+++ b/web/app/components/base/prompt-editor/plugins/last-run-block/node.tsx
@@ -2,8 +2,6 @@ import type { NodeKey, SerializedLexicalNode } from 'lexical'
import { DecoratorNode } from 'lexical'
import LastRunBlockComponent from './component'
-type SerializedNode = SerializedLexicalNode
-
export class LastRunBlockNode extends DecoratorNode<React.JSX.Element> {
static override getType(): string {
return 'last-run-block'
@@ -41,7 +39,7 @@ export class LastRunBlockNode extends DecoratorNode<React.JSX.Element> {
return node
}
- override exportJSON(): SerializedNode {
+ override exportJSON(): SerializedLexicalNode {
return {
type: 'last-run-block',
version: 1,
diff --git a/web/app/components/base/prompt-editor/plugins/query-block/node.tsx b/web/app/components/base/prompt-editor/plugins/query-block/node.tsx
index 394970d625e..784d6c84be5 100644
--- a/web/app/components/base/prompt-editor/plugins/query-block/node.tsx
+++ b/web/app/components/base/prompt-editor/plugins/query-block/node.tsx
@@ -2,8 +2,6 @@ import type { LexicalNode, SerializedLexicalNode } from 'lexical'
import { DecoratorNode } from 'lexical'
import QueryBlockComponent from './component'
-type SerializedNode = SerializedLexicalNode
-
export class QueryBlockNode extends DecoratorNode<React.JSX.Element> {
static override getType(): string {
return 'query-block'
@@ -37,7 +35,7 @@ export class QueryBlockNode extends DecoratorNode<React.JSX.Element> {
return node
}
- override exportJSON(): SerializedNode {
+ override exportJSON(): SerializedLexicalNode {
return {
type: 'query-block',
version: 1,
diff --git a/web/app/components/base/prompt-editor/plugins/request-url-block/node.tsx b/web/app/components/base/prompt-editor/plugins/request-url-block/node.tsx
index 203a38fbc11..9f7812545d2 100644
--- a/web/app/components/base/prompt-editor/plugins/request-url-block/node.tsx
+++ b/web/app/components/base/prompt-editor/plugins/request-url-block/node.tsx
@@ -2,8 +2,6 @@ import type { SerializedLexicalNode } from 'lexical'
import { DecoratorNode } from 'lexical'
import RequestURLBlockComponent from './component'
-type SerializedNode = SerializedLexicalNode
-
export class RequestURLBlockNode extends DecoratorNode<React.JSX.Element> {
static override getType(): string {
return 'request-url-block'
@@ -37,7 +35,7 @@ export class RequestURLBlockNode extends DecoratorNode<React.JSX.Element> {
return node
}
- override exportJSON(): SerializedNode {
+ override exportJSON(): SerializedLexicalNode {
return {
type: 'request-url-block',
version: 1,
diff --git a/web/app/components/datasets/common/document-picker/__tests__/document-list.spec.tsx b/web/app/components/datasets/common/document-picker/__tests__/document-list.spec.tsx
index 318ce3457c3..dd3c9681ca2 100644
--- a/web/app/components/datasets/common/document-picker/__tests__/document-list.spec.tsx
+++ b/web/app/components/datasets/common/document-picker/__tests__/document-list.spec.tsx
@@ -1,4 +1,4 @@
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { Combobox } from '@langgenius/dify-ui/combobox'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -13,7 +13,9 @@ vi.mock('../../document-file-icon', () => ({
),
}))
-const createDocument = (overrides: Partial<SimpleDocumentDetail> = {}): SimpleDocumentDetail => ({
+const createDocument = (
+ overrides: Partial<DocumentWithSegmentsResponse> = {},
+): DocumentWithSegmentsResponse => ({
id: 'doc-1',
position: 1,
data_source_type: DataSourceType.FILE,
@@ -56,7 +58,7 @@ const createDocument = (overrides: Partial<SimpleDocumentDetail> = {}): SimpleDo
...overrides,
})
-const renderDocumentList = (list: SimpleDocumentDetail[], onValueChange = vi.fn()) => ({
+const renderDocumentList = (list: DocumentWithSegmentsResponse[], onValueChange = vi.fn()) => ({
onValueChange,
...render(
<Combobox
diff --git a/web/app/components/datasets/common/document-picker/__tests__/index.spec.tsx b/web/app/components/datasets/common/document-picker/__tests__/index.spec.tsx
index eb735992cfd..a55579eabf5 100644
--- a/web/app/components/datasets/common/document-picker/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/common/document-picker/__tests__/index.spec.tsx
@@ -1,11 +1,11 @@
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { ChunkingMode, DataSourceType } from '@/models/datasets'
import { DocumentPicker } from '../index'
-let mockDocumentListData: { data: SimpleDocumentDetail[] } | undefined
+let mockDocumentListData: { data: DocumentWithSegmentsResponse[] } | undefined
const { mockUseDocumentList } = vi.hoisted(() => ({
mockUseDocumentList: vi.fn(),
@@ -24,7 +24,9 @@ vi.mock('@tanstack/react-query', async (importOriginal) => {
})
})
-const createDocument = (overrides: Partial<SimpleDocumentDetail> = {}): SimpleDocumentDetail => ({
+const createDocument = (
+ overrides: Partial<DocumentWithSegmentsResponse> = {},
+): DocumentWithSegmentsResponse => ({
id: 'doc-1',
position: 1,
data_source_type: DataSourceType.FILE,
diff --git a/web/app/components/datasets/common/document-picker/document-list.tsx b/web/app/components/datasets/common/document-picker/document-list.tsx
index fbb0a573a6d..41aa58fda35 100644
--- a/web/app/components/datasets/common/document-picker/document-list.tsx
+++ b/web/app/components/datasets/common/document-picker/document-list.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import { ComboboxItem, ComboboxItemText, ComboboxList } from '@langgenius/dify-ui/combobox'
import { getUploadFileExtension } from '@/app/components/datasets/documents/document-source'
@@ -9,7 +9,7 @@ type Props = Readonly<{
className?: string
}>
-function getDocumentExtension(document: SimpleDocumentDetail) {
+function getDocumentExtension(document: DocumentWithSegmentsResponse) {
const detailExtension = document.data_source_detail_dict?.upload_file?.extension
if (detailExtension) return detailExtension
@@ -18,7 +18,9 @@ function getDocumentExtension(document: SimpleDocumentDetail) {
export default function DocumentList({ className }: Props) {
return (
- <ComboboxList<SimpleDocumentDetail> className={cn('max-h-[calc(100vh-120px)]', className)}>
+ <ComboboxList<DocumentWithSegmentsResponse>
+ className={cn('max-h-[calc(100vh-120px)]', className)}
+ >
{(item) => {
const extension = getDocumentExtension(item)
return (
diff --git a/web/app/components/datasets/common/document-picker/index.tsx b/web/app/components/datasets/common/document-picker/index.tsx
index 0302eab536e..1e9ecacb049 100644
--- a/web/app/components/datasets/common/document-picker/index.tsx
+++ b/web/app/components/datasets/common/document-picker/index.tsx
@@ -1,6 +1,7 @@
'use client'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ComboboxChangeEventDetails } from '@langgenius/dify-ui/combobox'
-import type { ParentMode, SimpleDocumentDetail } from '@/models/datasets'
+import type { ParentMode } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import {
Combobox,
@@ -26,9 +27,12 @@ import FileIcon from '../document-file-icon'
import DocumentList from './document-list'
// The list query and the document detail query both describe the picked document.
-export type PickerDocument = Pick<SimpleDocumentDetail, 'id' | 'doc_form' | 'data_source_info'> & {
+export type PickerDocument = Pick<
+ DocumentWithSegmentsResponse,
+ 'id' | 'doc_form' | 'data_source_info'
+> & {
name?: string | null
- data_source_detail_dict?: SimpleDocumentDetail['data_source_detail_dict'] | null
+ data_source_detail_dict?: DocumentWithSegmentsResponse['data_source_detail_dict'] | null
}
type Props = Readonly<{
diff --git a/web/app/components/datasets/common/image-uploader/__tests__/utils.spec.ts b/web/app/components/datasets/common/image-uploader/__tests__/utils.spec.ts
index 8533770117c..2728e2e9348 100644
--- a/web/app/components/datasets/common/image-uploader/__tests__/utils.spec.ts
+++ b/web/app/components/datasets/common/image-uploader/__tests__/utils.spec.ts
@@ -1,5 +1,5 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { FileEntity } from '../types'
-import type { FileUploadConfigResponse } from '@/models/common'
import { describe, expect, it } from 'vite-plus/test'
import {
DEFAULT_IMAGE_FILE_BATCH_LIMIT,
@@ -76,13 +76,13 @@ describe('image-uploader utils', () => {
})
it('should return values from response when valid', () => {
- const response: Partial<FileUploadConfigResponse> = {
+ const response: Partial<UploadConfig> = {
image_file_batch_limit: 20,
single_chunk_attachment_limit: 10,
attachment_image_file_size_limit: 5,
}
- const result = getFileUploadConfig(response as FileUploadConfigResponse)
+ const result = getFileUploadConfig(response as UploadConfig)
expect(result).toEqual({
imageFileSizeLimit: 5,
imageFileBatchLimit: 20,
@@ -91,13 +91,13 @@ describe('image-uploader utils', () => {
})
it('should use default values when response values are 0', () => {
- const response: Partial<FileUploadConfigResponse> = {
+ const response: Partial<UploadConfig> = {
image_file_batch_limit: 0,
single_chunk_attachment_limit: 0,
attachment_image_file_size_limit: 0,
}
- const result = getFileUploadConfig(response as FileUploadConfigResponse)
+ const result = getFileUploadConfig(response as UploadConfig)
expect(result).toEqual({
imageFileSizeLimit: DEFAULT_IMAGE_FILE_SIZE_LIMIT,
imageFileBatchLimit: DEFAULT_IMAGE_FILE_BATCH_LIMIT,
@@ -106,13 +106,13 @@ describe('image-uploader utils', () => {
})
it('should use default values when response values are negative', () => {
- const response: Partial<FileUploadConfigResponse> = {
+ const response: Partial<UploadConfig> = {
image_file_batch_limit: -5,
single_chunk_attachment_limit: -10,
attachment_image_file_size_limit: -1,
}
- const result = getFileUploadConfig(response as FileUploadConfigResponse)
+ const result = getFileUploadConfig(response as UploadConfig)
expect(result).toEqual({
imageFileSizeLimit: DEFAULT_IMAGE_FILE_SIZE_LIMIT,
imageFileBatchLimit: DEFAULT_IMAGE_FILE_BATCH_LIMIT,
@@ -125,7 +125,7 @@ describe('image-uploader utils', () => {
image_file_batch_limit: '15',
single_chunk_attachment_limit: '8',
attachment_image_file_size_limit: '3',
- } as unknown as FileUploadConfigResponse
+ } as unknown as UploadConfig
const result = getFileUploadConfig(response)
expect(result).toEqual({
@@ -140,7 +140,7 @@ describe('image-uploader utils', () => {
image_file_batch_limit: null,
single_chunk_attachment_limit: null,
attachment_image_file_size_limit: null,
- } as unknown as FileUploadConfigResponse
+ } as unknown as UploadConfig
const result = getFileUploadConfig(response)
expect(result).toEqual({
@@ -155,7 +155,7 @@ describe('image-uploader utils', () => {
image_file_batch_limit: undefined,
single_chunk_attachment_limit: undefined,
attachment_image_file_size_limit: undefined,
- } as unknown as FileUploadConfigResponse
+ } as unknown as UploadConfig
const result = getFileUploadConfig(response)
expect(result).toEqual({
@@ -166,11 +166,11 @@ describe('image-uploader utils', () => {
})
it('should handle partial response', () => {
- const response: Partial<FileUploadConfigResponse> = {
+ const response: Partial<UploadConfig> = {
image_file_batch_limit: 25,
}
- const result = getFileUploadConfig(response as FileUploadConfigResponse)
+ const result = getFileUploadConfig(response as UploadConfig)
expect(result.imageFileBatchLimit).toBe(25)
expect(result.imageFileSizeLimit).toBe(DEFAULT_IMAGE_FILE_SIZE_LIMIT)
expect(result.singleChunkAttachmentLimit).toBe(DEFAULT_SINGLE_CHUNK_ATTACHMENT_LIMIT)
@@ -183,7 +183,7 @@ describe('image-uploader utils', () => {
image_file_batch_limit: { invalid: 'object' }, // Object - not number or string
single_chunk_attachment_limit: true, // Boolean - not number or string
attachment_image_file_size_limit: ['array'], // Array - not number or string
- } as unknown as FileUploadConfigResponse
+ } as unknown as UploadConfig
const result = getFileUploadConfig(response)
// All should fall back to defaults since getNumberValue returns 0 for these types
@@ -199,7 +199,7 @@ describe('image-uploader utils', () => {
image_file_batch_limit: 'not-a-number',
single_chunk_attachment_limit: '',
attachment_image_file_size_limit: 'abc',
- } as unknown as FileUploadConfigResponse
+ } as unknown as UploadConfig
const result = getFileUploadConfig(response)
// NaN values should result in defaults (since NaN > 0 is false)
diff --git a/web/app/components/datasets/common/image-uploader/utils.ts b/web/app/components/datasets/common/image-uploader/utils.ts
index 6bf02494504..e06d8bd4f5e 100644
--- a/web/app/components/datasets/common/image-uploader/utils.ts
+++ b/web/app/components/datasets/common/image-uploader/utils.ts
@@ -1,5 +1,5 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { FileEntity } from './types'
-import type { FileUploadConfigResponse } from '@/models/common'
import {
DEFAULT_IMAGE_FILE_BATCH_LIMIT,
DEFAULT_IMAGE_FILE_SIZE_LIMIT,
@@ -58,9 +58,7 @@ const getNumberValue = (value: number | string | undefined | null): number => {
return 0
}
-export const getFileUploadConfig = (
- fileUploadConfigResponse: FileUploadConfigResponse | undefined,
-) => {
+export const getFileUploadConfig = (fileUploadConfigResponse: UploadConfig | undefined) => {
if (!fileUploadConfigResponse) {
return {
imageFileSizeLimit: DEFAULT_IMAGE_FILE_SIZE_LIMIT,
diff --git a/web/app/components/datasets/create/__tests__/index.spec.tsx b/web/app/components/datasets/create/__tests__/index.spec.tsx
index cc6f4464683..8c79c87f441 100644
--- a/web/app/components/datasets/create/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/create/__tests__/index.spec.tsx
@@ -1,16 +1,18 @@
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ComponentProps } from 'react'
import type StepOneComponent from '../step-one'
import type StepThreeComponent from '../step-three'
import type { StepTwoProps } from '../step-two/types'
import type { TopBarProps } from '../top-bar'
-import type { DataSourceAuth } from '@/app/components/header/account-setting/data-source-page-new/types'
import type { NotionPage } from '@/models/common'
-import type { DataSet, FileItem } from '@/models/datasets'
+import type { FileItem } from '@/models/datasets'
import { QueryClientProvider } from '@tanstack/react-query'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import * as React from 'react'
import { DataSourceProvider } from '@/models/common'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createAccountProfileQueryClient } from '@/test/console/account-profile'
import { render as renderWithConsoleState } from '@/test/console/render'
import { createDatasetFixture } from '@/test/fixtures/dataset'
@@ -23,8 +25,9 @@ type StepThreeTestProps = ComponentProps<typeof StepThreeComponent>
// IndexingType values from step-two (defined here since we mock step-two)
// Using type assertion to match the expected IndexingType enum from step-two
const IndexingTypeValues = {
- QUALIFIED: 'high_quality' as unknown as DataSet['indexing_technique'],
- ECONOMICAL: 'economy' as unknown as DataSet['indexing_technique'],
+ QUALIFIED:
+ 'high_quality' as unknown as DatasetDetailWithPartialMembersResponse['indexing_technique'],
+ ECONOMICAL: 'economy' as unknown as DatasetDetailWithPartialMembersResponse['indexing_technique'],
}
// Mock next/link
@@ -89,10 +92,10 @@ vi.mock('nuqs', async (importOriginal) => {
})
// Mock dataset detail context
-let mockDatasetDetail: DataSet | undefined
+let mockDatasetDetail: DatasetDetailWithPartialMembersResponse | undefined
vi.mock('@/context/dataset-detail', () => ({
useDatasetDetailContextWithSelector: (
- selector: (state: { dataset: DataSet | undefined }) => unknown,
+ selector: (state: { dataset: DatasetDetailWithPartialMembersResponse | undefined }) => unknown,
) => {
const state = {
dataset: mockDatasetDetail,
@@ -112,7 +115,7 @@ vi.mock('@/app/components/header/account-setting/model-provider-page/hooks', ()
}))
// Mock useGetDefaultDataSourceListAuth hook
-let mockDataSourceList: { result: DataSourceAuth[] } | undefined
+let mockDataSourceList: { result: DatasourceProviderAuthResponse[] } | undefined
let mockIsLoadingDataSourceList = false
let mockFetchingError = false
vi.mock('@tanstack/react-query', async (importOriginal) => {
@@ -299,13 +302,15 @@ vi.mock('../top-bar', () => ({
},
}))
-const createMockDataset = (overrides?: Partial<DataSet>): DataSet => ({
+const createMockDataset = (
+ overrides?: Partial<DatasetDetailWithPartialMembersResponse>,
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-123',
name: 'Test Dataset',
icon_info: { icon: '', icon_background: '', icon_type: 'emoji' as const },
description: 'Test description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingTypeValues.QUALIFIED,
created_by: 'user-1',
@@ -349,13 +354,15 @@ const createMockDataset = (overrides?: Partial<DataSet>): DataSet => ({
...overrides,
})
-const createMockDataSourceAuth = (overrides?: Partial<DataSourceAuth>): DataSourceAuth =>
+const createMockDataSourceAuth = (
+ overrides?: Partial<DatasourceProviderAuthResponse>,
+): DatasourceProviderAuthResponse =>
({
credential_id: 'cred-1',
provider: 'notion',
plugin_id: 'plugin-1',
...overrides,
- }) as DataSourceAuth
+ }) as DatasourceProviderAuthResponse
describe('DatasetUpdateForm', () => {
beforeEach(() => {
diff --git a/web/app/components/datasets/create/embedding-process/__tests__/index.spec.tsx b/web/app/components/datasets/create/embedding-process/__tests__/index.spec.tsx
index e1a5e0fe6e8..297f22a2a56 100644
--- a/web/app/components/datasets/create/embedding-process/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/create/embedding-process/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactElement } from 'react'
-import type { IndexingStatusResponse } from '@/models/datasets'
import { QueryClient } from '@tanstack/react-query'
import { screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -10,7 +10,7 @@ import EmbeddingProcess from '../index'
let deploymentEdition: 'CLOUD' | 'COMMUNITY' = 'COMMUNITY'
let mockPlanType: 'sandbox' | 'professional' | 'team' = 'sandbox'
let mockPollingState: {
- statusList: IndexingStatusResponse[]
+ statusList: DocumentStatusResponse[]
isEmbedding: boolean
isEmbeddingCompleted: boolean
} = {
@@ -124,7 +124,7 @@ describe('EmbeddingProcess', () => {
error_code: 'vector_space_estimate_exceeded',
estimated_vector_space_mb: 61,
vector_space_limit_mb: 50,
- } as IndexingStatusResponse,
+ } as DocumentStatusResponse,
],
isEmbedding: false,
isEmbeddingCompleted: true,
@@ -147,7 +147,7 @@ describe('EmbeddingProcess', () => {
error_code: null,
estimated_vector_space_mb: 61,
vector_space_limit_mb: 50,
- } as IndexingStatusResponse,
+ } as DocumentStatusResponse,
],
isEmbedding: false,
isEmbeddingCompleted: true,
@@ -169,7 +169,7 @@ describe('EmbeddingProcess', () => {
error_code: 'vector_space_estimate_exceeded',
estimated_vector_space_mb: 61,
vector_space_limit_mb: 50,
- } as IndexingStatusResponse,
+ } as DocumentStatusResponse,
],
isEmbedding: false,
isEmbeddingCompleted: true,
diff --git a/web/app/components/datasets/create/embedding-process/__tests__/indexing-progress-item.spec.tsx b/web/app/components/datasets/create/embedding-process/__tests__/indexing-progress-item.spec.tsx
index 662e0b75e6e..87de63c4f3c 100644
--- a/web/app/components/datasets/create/embedding-process/__tests__/indexing-progress-item.spec.tsx
+++ b/web/app/components/datasets/create/embedding-process/__tests__/indexing-progress-item.spec.tsx
@@ -1,4 +1,4 @@
-import type { IndexingStatusResponse } from '@/models/datasets'
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -19,7 +19,7 @@ describe('IndexingProgressItem', () => {
vi.clearAllMocks()
})
- const makeDetail = (overrides: Partial<IndexingStatusResponse> = {}): IndexingStatusResponse => ({
+ const makeDetail = (overrides: Partial<DocumentStatusResponse> = {}): DocumentStatusResponse => ({
id: 'doc-1',
indexing_status: 'indexing',
processing_started_at: 0,
diff --git a/web/app/components/datasets/create/embedding-process/__tests__/rule-detail.spec.tsx b/web/app/components/datasets/create/embedding-process/__tests__/rule-detail.spec.tsx
index 646653611a5..463a11bc0cb 100644
--- a/web/app/components/datasets/create/embedding-process/__tests__/rule-detail.spec.tsx
+++ b/web/app/components/datasets/create/embedding-process/__tests__/rule-detail.spec.tsx
@@ -1,4 +1,4 @@
-import type { ProcessRuleResponse } from '@/models/datasets'
+import type { ProcessRuleResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { ProcessMode } from '@/models/datasets'
diff --git a/web/app/components/datasets/create/embedding-process/__tests__/utils.spec.ts b/web/app/components/datasets/create/embedding-process/__tests__/utils.spec.ts
index a100a89fc09..5c6b6958265 100644
--- a/web/app/components/datasets/create/embedding-process/__tests__/utils.spec.ts
+++ b/web/app/components/datasets/create/embedding-process/__tests__/utils.spec.ts
@@ -1,4 +1,7 @@
-import type { IndexingStatusResponse, InitialDocumentDetail } from '@/models/datasets'
+import type {
+ DocumentResponse,
+ DocumentStatusResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { describe, expect, it } from 'vite-plus/test'
import { createDocumentLookup, getFileType, getSourcePercent, isSourceEmbedding } from '../utils'
@@ -7,41 +10,41 @@ describe('isSourceEmbedding', () => {
const nonEmbeddingStatuses = ['completed', 'error', 'paused', 'unknown']
it.each(embeddingStatuses)('should return true for status "%s"', (status) => {
- expect(isSourceEmbedding({ indexing_status: status } as IndexingStatusResponse)).toBe(true)
+ expect(isSourceEmbedding({ indexing_status: status } as DocumentStatusResponse)).toBe(true)
})
it.each(nonEmbeddingStatuses)('should return false for status "%s"', (status) => {
- expect(isSourceEmbedding({ indexing_status: status } as IndexingStatusResponse)).toBe(false)
+ expect(isSourceEmbedding({ indexing_status: status } as DocumentStatusResponse)).toBe(false)
})
})
describe('getSourcePercent', () => {
it('should calculate correct percentage', () => {
expect(
- getSourcePercent({ completed_segments: 50, total_segments: 100 } as IndexingStatusResponse),
+ getSourcePercent({ completed_segments: 50, total_segments: 100 } as DocumentStatusResponse),
).toBe(50)
})
it('should return 0 when total is 0', () => {
expect(
- getSourcePercent({ completed_segments: 0, total_segments: 0 } as IndexingStatusResponse),
+ getSourcePercent({ completed_segments: 0, total_segments: 0 } as DocumentStatusResponse),
).toBe(0)
})
it('should cap at 100', () => {
expect(
- getSourcePercent({ completed_segments: 150, total_segments: 100 } as IndexingStatusResponse),
+ getSourcePercent({ completed_segments: 150, total_segments: 100 } as DocumentStatusResponse),
).toBe(100)
})
it('should round to nearest integer', () => {
expect(
- getSourcePercent({ completed_segments: 1, total_segments: 3 } as IndexingStatusResponse),
+ getSourcePercent({ completed_segments: 1, total_segments: 3 } as DocumentStatusResponse),
).toBe(33)
})
it('should handle undefined segments as 0', () => {
- expect(getSourcePercent({} as IndexingStatusResponse)).toBe(0)
+ expect(getSourcePercent({} as DocumentStatusResponse)).toBe(0)
})
})
@@ -83,7 +86,7 @@ describe('createDocumentLookup', () => {
notion_page_icon: 'https://icon.url',
},
},
- ] as unknown as InitialDocumentDetail[]
+ ] as unknown as DocumentResponse[]
it('should get document by id', () => {
const lookup = createDocumentLookup(documents)
@@ -116,7 +119,7 @@ describe('createDocumentLookup', () => {
id: 'doc-3',
data_source_info: { some_other: 'field' },
},
- ] as unknown as InitialDocumentDetail[]
+ ] as unknown as DocumentResponse[]
const lookup = createDocumentLookup(docs)
expect(lookup.getNotionIcon('doc-3')).toBeUndefined()
})
diff --git a/web/app/components/datasets/create/embedding-process/index.tsx b/web/app/components/datasets/create/embedding-process/index.tsx
index 382adf60671..73845a5bf89 100644
--- a/web/app/components/datasets/create/embedding-process/index.tsx
+++ b/web/app/components/datasets/create/embedding-process/index.tsx
@@ -1,5 +1,5 @@
+import type { DocumentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { InitialDocumentDetail } from '@/models/datasets'
import type { RETRIEVE_METHOD } from '@/types/app'
import { buttonVariants } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
@@ -23,7 +23,7 @@ import { createDocumentLookup } from './utils'
type EmbeddingProcessProps = {
datasetId: string
batchId: string
- documents?: InitialDocumentDetail[]
+ documents?: DocumentResponse[]
indexingType?: string
retrievalMethod?: RETRIEVE_METHOD
}
diff --git a/web/app/components/datasets/create/embedding-process/indexing-progress-item.tsx b/web/app/components/datasets/create/embedding-process/indexing-progress-item.tsx
index f62412e4935..052696c0e83 100644
--- a/web/app/components/datasets/create/embedding-process/indexing-progress-item.tsx
+++ b/web/app/components/datasets/create/embedding-process/indexing-progress-item.tsx
@@ -1,5 +1,5 @@
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ComponentProps, FC } from 'react'
-import type { IndexingStatusResponse } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
import { RiCheckboxCircleFill } from '@remixicon/react'
@@ -12,7 +12,7 @@ import DocumentFileIcon from '../../common/document-file-icon'
import { getFileType, getSourcePercent, isSourceEmbedding } from './utils'
type IndexingProgressItemProps = {
- detail: IndexingStatusResponse
+ detail: DocumentStatusResponse
name?: string
sourceType?: DataSourceType
notionIcon?: ComponentProps<typeof NotionIcon>['src']
diff --git a/web/app/components/datasets/create/embedding-process/rule-detail.tsx b/web/app/components/datasets/create/embedding-process/rule-detail.tsx
index cee66e0bfb3..89bdc34e08f 100644
--- a/web/app/components/datasets/create/embedding-process/rule-detail.tsx
+++ b/web/app/components/datasets/create/embedding-process/rule-detail.tsx
@@ -1,5 +1,5 @@
+import type { ProcessRuleResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { ProcessRuleResponse } from '@/models/datasets'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { FieldInfo } from '@/app/components/datasets/documents/detail/metadata'
diff --git a/web/app/components/datasets/create/embedding-process/use-indexing-status-polling.ts b/web/app/components/datasets/create/embedding-process/use-indexing-status-polling.ts
index f3c1314f6a6..b56b2bd44d2 100644
--- a/web/app/components/datasets/create/embedding-process/use-indexing-status-polling.ts
+++ b/web/app/components/datasets/create/embedding-process/use-indexing-status-polling.ts
@@ -1,4 +1,4 @@
-import type { IndexingStatusResponse } from '@/models/datasets'
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { useEffect, useRef, useState } from 'react'
import { fetchIndexingStatusBatch } from '@/service/datasets'
@@ -12,7 +12,7 @@ type IndexingStatusPollingParams = {
}
type IndexingStatusPollingResult = {
- statusList: IndexingStatusResponse[]
+ statusList: DocumentStatusResponse[]
isEmbedding: boolean
isEmbeddingCompleted: boolean
}
@@ -20,7 +20,7 @@ type IndexingStatusPollingResult = {
const isStatusCompleted = (status: string): boolean =>
COMPLETED_STATUSES.includes(status as (typeof COMPLETED_STATUSES)[number])
-const isAllCompleted = (statusList: IndexingStatusResponse[]): boolean =>
+const isAllCompleted = (statusList: DocumentStatusResponse[]): boolean =>
statusList.every((item) => isStatusCompleted(item.indexing_status))
/**
@@ -31,7 +31,7 @@ export const useIndexingStatusPolling = ({
datasetId,
batchId,
}: IndexingStatusPollingParams): IndexingStatusPollingResult => {
- const [statusList, setStatusList] = useState<IndexingStatusResponse[]>([])
+ const [statusList, setStatusList] = useState<DocumentStatusResponse[]>([])
const isStopPollingRef = useRef(false)
useEffect(() => {
@@ -39,7 +39,7 @@ export const useIndexingStatusPolling = ({
isStopPollingRef.current = false
let timeoutId: ReturnType<typeof setTimeout> | null = null
- const fetchStatus = async (): Promise<IndexingStatusResponse[]> => {
+ const fetchStatus = async (): Promise<DocumentStatusResponse[]> => {
const response = await fetchIndexingStatusBatch({ datasetId, batchId })
setStatusList(response.data)
return response.data
diff --git a/web/app/components/datasets/create/embedding-process/utils.ts b/web/app/components/datasets/create/embedding-process/utils.ts
index 3b7e2249174..7b89035ad33 100644
--- a/web/app/components/datasets/create/embedding-process/utils.ts
+++ b/web/app/components/datasets/create/embedding-process/utils.ts
@@ -1,4 +1,7 @@
-import type { IndexingStatusResponse, InitialDocumentDetail } from '@/models/datasets'
+import type {
+ DocumentResponse,
+ DocumentStatusResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { toCreationDataSourceType } from '@/app/components/datasets/dataset-fields'
import { getNotionPageIcon } from '@/app/components/datasets/documents/document-source'
@@ -7,13 +10,13 @@ const EMBEDDING_STATUSES = ['indexing', 'splitting', 'parsing', 'cleaning', 'wai
/**
* Check if a status indicates the source is being embedded
*/
-export const isSourceEmbedding = (detail: IndexingStatusResponse): boolean =>
+export const isSourceEmbedding = (detail: DocumentStatusResponse): boolean =>
EMBEDDING_STATUSES.includes(detail.indexing_status as (typeof EMBEDDING_STATUSES)[number])
/**
* Calculate the progress percentage for a document
*/
-export const getSourcePercent = (detail: IndexingStatusResponse): number => {
+export const getSourcePercent = (detail: DocumentStatusResponse): number => {
const completedCount = detail.completed_segments || 0
const totalCount = detail.total_segments || 0
@@ -31,7 +34,7 @@ export const getFileType = (name?: string): string => name?.split('.').pop() ||
/**
* Document lookup utilities - provides document info by ID from a list
*/
-export const createDocumentLookup = (documents: InitialDocumentDetail[]) => {
+export const createDocumentLookup = (documents: DocumentResponse[]) => {
const documentMap = new Map(documents.map((doc) => [doc.id, doc]))
return {
diff --git a/web/app/components/datasets/create/index.tsx b/web/app/components/datasets/create/index.tsx
index 660acaffe18..e9b84881db8 100644
--- a/web/app/components/datasets/create/index.tsx
+++ b/web/app/components/datasets/create/index.tsx
@@ -1,12 +1,8 @@
'use client'
+import type { DatasetAndDocumentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { NotionPage } from '@/models/common'
-import type {
- CrawlOptions,
- CrawlResultItem,
- createDocumentResponse,
- FileItem,
-} from '@/models/datasets'
+import type { CrawlOptions, CrawlResultItem, FileItem } from '@/models/datasets'
import type { RETRIEVE_METHOD } from '@/types/app'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { produce } from 'immer'
@@ -80,7 +76,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
const [indexingTypeCache, setIndexTypeCache] = useState('')
const [retrievalMethodCache, setRetrievalMethodCache] = useState<RETRIEVE_METHOD | ''>('')
const [fileList, setFiles] = useState<FileItem[]>([])
- const [result, setResult] = useState<createDocumentResponse | undefined>()
+ const [result, setResult] = useState<DatasetAndDocumentResponse | undefined>()
const [notionPages, setNotionPages] = useState<NotionPage[]>([])
const [notionCredentialId, setNotionCredentialId] = useState<string>('')
const [websitePages, setWebsitePages] = useState<CrawlResultItem[]>([])
@@ -123,7 +119,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
setIndexTypeCache(type)
}, [])
- const updateResultCache = useCallback((res?: createDocumentResponse) => {
+ const updateResultCache = useCallback((res?: DatasetAndDocumentResponse) => {
setResult(res)
}, [])
diff --git a/web/app/components/datasets/create/step-one/__tests__/index.spec.tsx b/web/app/components/datasets/create/step-one/__tests__/index.spec.tsx
index 8a8990ffabe..542a590e353 100644
--- a/web/app/components/datasets/create/step-one/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/create/step-one/__tests__/index.spec.tsx
@@ -1,7 +1,8 @@
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
-import type { DataSourceAuth } from '@/app/components/header/account-setting/data-source-page-new/types'
import type { NotionPage } from '@/models/common'
-import type { CrawlOptions, CrawlResultItem, DataSet, FileItem } from '@/models/datasets'
+import type { CrawlOptions, CrawlResultItem, FileItem } from '@/models/datasets'
import { fireEvent, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
@@ -63,10 +64,12 @@ vi.mock('@/config', async (importOriginal) => ({
}))
// Mock dataset detail context
-let mockDatasetDetail: DataSet | undefined
+let mockDatasetDetail: DatasetDetailWithPartialMembersResponse | undefined
vi.mock('@/context/dataset-detail', () => ({
useDatasetDetailContextWithSelector: (
- selector: (state: { dataset: DataSet | undefined }) => DataSet | undefined,
+ selector: (state: {
+ dataset: DatasetDetailWithPartialMembersResponse | undefined
+ }) => DatasetDetailWithPartialMembersResponse | undefined,
) => {
return selector({ dataset: mockDatasetDetail })
},
@@ -198,14 +201,16 @@ const createMockCrawlResult = (overrides: Partial<CrawlResultItem> = {}): CrawlR
...overrides,
})
-const createMockDataSourceAuth = (overrides: Partial<DataSourceAuth> = {}): DataSourceAuth =>
+const createMockDataSourceAuth = (
+ overrides: Partial<DatasourceProviderAuthResponse> = {},
+): DatasourceProviderAuthResponse =>
({
credential_id: 'cred-1',
provider: 'notion_datasource',
plugin_id: 'plugin-1',
credentials_list: [{ id: 'cred-1', name: 'Workspace 1' }],
...overrides,
- }) as DataSourceAuth
+ }) as DatasourceProviderAuthResponse
const defaultProps = {
dataSourceType: DataSourceType.FILE,
@@ -234,7 +239,7 @@ const defaultProps = {
use_sitemap: true,
} as CrawlOptions,
onCrawlOptionsChange: vi.fn(),
- authedDataSourceList: [] as DataSourceAuth[],
+ authedDataSourceList: [] as DatasourceProviderAuthResponse[],
}
// NOTE: Child component unit tests (usePreviewState, DataSourceTypeSelector,
diff --git a/web/app/components/datasets/create/step-one/index.tsx b/web/app/components/datasets/create/step-one/index.tsx
index 910445322d9..dd560409127 100644
--- a/web/app/components/datasets/create/step-one/index.tsx
+++ b/web/app/components/datasets/create/step-one/index.tsx
@@ -1,6 +1,6 @@
'use client'
-import type { DataSourceAuth } from '@/app/components/header/account-setting/data-source-page-new/types'
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { DataSourceProvider, NotionPage } from '@/models/common'
import type { CrawlOptions, CrawlResultItem, FileItem } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
@@ -47,17 +47,17 @@ type IStepOneProps = {
onWebsiteCrawlJobIdChange: (jobId: string) => void
crawlOptions: CrawlOptions
onCrawlOptionsChange: (payload: CrawlOptions) => void
- authedDataSourceList: DataSourceAuth[]
+ authedDataSourceList: DatasourceProviderAuthResponse[]
}
// Helper function to check if notion is authenticated
-function checkNotionAuth(authedDataSourceList: DataSourceAuth[]): boolean {
+function checkNotionAuth(authedDataSourceList: DatasourceProviderAuthResponse[]): boolean {
const notionSource = authedDataSourceList.find((item) => item.provider === 'notion_datasource')
return Boolean(notionSource && notionSource.credentials_list.length > 0)
}
// Helper function to get notion credential list
-function getNotionCredentialList(authedDataSourceList: DataSourceAuth[]) {
+function getNotionCredentialList(authedDataSourceList: DatasourceProviderAuthResponse[]) {
return (
authedDataSourceList.find((item) => item.provider === 'notion_datasource')?.credentials_list ||
[]
diff --git a/web/app/components/datasets/create/step-three/index.tsx b/web/app/components/datasets/create/step-three/index.tsx
index 158ab953738..8b8e2056f68 100644
--- a/web/app/components/datasets/create/step-three/index.tsx
+++ b/web/app/components/datasets/create/step-three/index.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { createDocumentResponse } from '@/models/datasets'
+import type { DatasetAndDocumentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { RETRIEVE_METHOD } from '@/types/app'
import { Separator } from '@langgenius/dify-ui/separator'
import { RiBookOpenLine } from '@remixicon/react'
@@ -14,7 +14,7 @@ type StepThreeProps = {
datasetName?: string
indexingType?: string
retrievalMethod?: RETRIEVE_METHOD
- creationCache?: createDocumentResponse
+ creationCache?: DatasetAndDocumentResponse
}
const StepThree = ({
diff --git a/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx b/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx
index 4001b92de1d..2bef20dbfe4 100644
--- a/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/create/step-two/__tests__/index.spec.tsx
@@ -1,15 +1,12 @@
-import type { ProviderWithModelsResponse } from '@dify/contracts/api/console/workspaces/types.gen'
-import type { DataSourceProvider, NotionPage } from '@/models/common'
import type {
- CrawlOptions,
- CrawlResultItem,
- CustomFile,
- DataSet,
- FileIndexingEstimateResponse,
- FullDocumentDetail,
+ DatasetDetailWithPartialMembersResponse,
+ DocumentDetailResponse,
+ IndexingEstimateResponse,
PreProcessingRule,
- Rules,
-} from '@/models/datasets'
+} from '@dify/contracts/api/console/datasets/types.gen'
+import type { ProviderWithModelsResponse } from '@dify/contracts/api/console/workspaces/types.gen'
+import type { DataSourceProvider, NotionPage } from '@/models/common'
+import type { CrawlOptions, CrawlResultItem, CustomFile, Rules } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { act, cleanup, fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -50,7 +47,7 @@ vi.mock('@/hooks/use-breakpoints', async (importOriginal) => {
})
const mockDataset: Pick<
- DataSet,
+ DatasetDetailWithPartialMembersResponse,
| 'id'
| 'doc_form'
| 'data_source_type'
@@ -227,7 +224,9 @@ const createMockWebsitePage = (overrides?: Partial<CrawlResultItem>): CrawlResul
...overrides,
}) as CrawlResultItem
-const createMockDocumentDetail = (overrides?: Partial<FullDocumentDetail>): FullDocumentDetail =>
+const createMockDocumentDetail = (
+ overrides?: Partial<DocumentDetailResponse>,
+): DocumentDetailResponse =>
({
id: 'doc-1',
doc_form: ChunkingMode.text,
@@ -240,7 +239,7 @@ const createMockDocumentDetail = (overrides?: Partial<FullDocumentDetail>): Full
},
},
...overrides,
- }) as FullDocumentDetail
+ }) as DocumentDetailResponse
const createMockRules = (overrides?: Partial<Rules>): Rules => ({
segmentation: { separator: '\\n\\n', max_tokens: 1024, chunk_overlap: 50 },
@@ -254,8 +253,8 @@ const createMockRules = (overrides?: Partial<Rules>): Rules => ({
})
const createMockEstimate = (
- overrides?: Partial<FileIndexingEstimateResponse>,
-): FileIndexingEstimateResponse => ({
+ overrides?: Partial<IndexingEstimateResponse>,
+): IndexingEstimateResponse => ({
total_segments: 10,
tokens: 5000,
total_price: 0.01,
@@ -1775,7 +1774,7 @@ describe('PreviewPanel', () => {
onClose: vi.fn(),
dataSourceType: DataSourceType.FILE,
currentDocForm: ChunkingMode.text,
- estimate: undefined as FileIndexingEstimateResponse | undefined,
+ estimate: undefined as IndexingEstimateResponse | undefined,
parentChildConfig: defaultParentChildConfig,
isSetting: false,
pickerFiles: [{ id: 'file-1', name: 'test.pdf', extension: 'pdf' }],
diff --git a/web/app/components/datasets/create/step-two/components/__tests__/general-chunking-options.spec.tsx b/web/app/components/datasets/create/step-two/components/__tests__/general-chunking-options.spec.tsx
index ad616ba03eb..6c68d82bec5 100644
--- a/web/app/components/datasets/create/step-two/components/__tests__/general-chunking-options.spec.tsx
+++ b/web/app/components/datasets/create/step-two/components/__tests__/general-chunking-options.spec.tsx
@@ -1,4 +1,4 @@
-import type { PreProcessingRule } from '@/models/datasets'
+import type { PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { fireEvent, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
diff --git a/web/app/components/datasets/create/step-two/components/__tests__/parent-child-options.spec.tsx b/web/app/components/datasets/create/step-two/components/__tests__/parent-child-options.spec.tsx
index f605b3233ef..27911343d2e 100644
--- a/web/app/components/datasets/create/step-two/components/__tests__/parent-child-options.spec.tsx
+++ b/web/app/components/datasets/create/step-two/components/__tests__/parent-child-options.spec.tsx
@@ -1,5 +1,5 @@
+import type { PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
import type { ParentChildConfig } from '../../hooks'
-import type { PreProcessingRule } from '@/models/datasets'
import { RadioGroup } from '@langgenius/dify-ui/radio-group'
import { fireEvent, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
diff --git a/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx b/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx
index 9fce7fc260c..4370916da83 100644
--- a/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx
+++ b/web/app/components/datasets/create/step-two/components/__tests__/preview-panel.spec.tsx
@@ -1,5 +1,5 @@
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ParentChildConfig } from '../../hooks'
-import type { FileIndexingEstimateResponse } from '@/models/datasets'
import { render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useRef, useState } from 'react'
@@ -100,7 +100,7 @@ describe('PreviewPanel', () => {
rerender(
<PreviewPanel
{...defaultProps}
- estimate={{ total_segments: 3, preview: [] } as unknown as FileIndexingEstimateResponse}
+ estimate={{ total_segments: 3, preview: [] } as unknown as IndexingEstimateResponse}
/>,
)
expect(screen.getByRole('status')).toHaveTextContent(
@@ -165,48 +165,48 @@ describe('PreviewPanel', () => {
})
it('should render text preview chunks', () => {
- const estimate: Partial<FileIndexingEstimateResponse> = {
+ const estimate: Partial<IndexingEstimateResponse> = {
total_segments: 2,
preview: [
{ content: 'chunk 1 text', child_chunks: [], summary: '' },
{ content: 'chunk 2 text', child_chunks: [], summary: 'summary text' },
],
}
- render(<PreviewPanel {...defaultProps} estimate={estimate as FileIndexingEstimateResponse} />)
+ render(<PreviewPanel {...defaultProps} estimate={estimate as IndexingEstimateResponse} />)
expect(screen.getAllByTestId('chunk-container')).toHaveLength(2)
})
it('should render QA preview', () => {
- const estimate: Partial<FileIndexingEstimateResponse> = {
+ const estimate: Partial<IndexingEstimateResponse> = {
qa_preview: [{ question: 'Q1', answer: 'A1' }],
}
render(
<PreviewPanel
{...defaultProps}
currentDocForm={ChunkingMode.qa}
- estimate={estimate as FileIndexingEstimateResponse}
+ estimate={estimate as IndexingEstimateResponse}
/>,
)
expect(screen.getByTestId('qa-preview')).toHaveTextContent('Q1')
})
it('should render parent-child preview', () => {
- const estimate: Partial<FileIndexingEstimateResponse> = {
+ const estimate: Partial<IndexingEstimateResponse> = {
preview: [{ content: 'parent chunk', child_chunks: ['child1', 'child2'], summary: '' }],
}
render(
<PreviewPanel
{...defaultProps}
currentDocForm={ChunkingMode.parentChild}
- estimate={estimate as FileIndexingEstimateResponse}
+ estimate={estimate as IndexingEstimateResponse}
/>,
)
expect(screen.getAllByTestId('preview-slice')).toHaveLength(2)
})
it('should show badge with chunk count for non-QA mode', () => {
- const estimate: Partial<FileIndexingEstimateResponse> = { total_segments: 5, preview: [] }
- render(<PreviewPanel {...defaultProps} estimate={estimate as FileIndexingEstimateResponse} />)
+ const estimate: Partial<IndexingEstimateResponse> = { total_segments: 5, preview: [] }
+ render(<PreviewPanel {...defaultProps} estimate={estimate as IndexingEstimateResponse} />)
expect(screen.getByTestId('badge')).toBeInTheDocument()
})
})
diff --git a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx
index d1f28a5243f..6a37409efbb 100644
--- a/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx
+++ b/web/app/components/datasets/create/step-two/components/general-chunking-options.tsx
@@ -1,10 +1,8 @@
'use client'
+import type { PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC, MouseEventHandler } from 'react'
-import type {
- PreProcessingRule,
- SummaryIndexSetting as SummaryIndexSettingType,
-} from '@/models/datasets'
+import type { SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets'
import { Button } from '@langgenius/dify-ui/button'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
diff --git a/web/app/components/datasets/create/step-two/components/parent-child-options.tsx b/web/app/components/datasets/create/step-two/components/parent-child-options.tsx
index 07d3b02395e..3f6ecfb43f8 100644
--- a/web/app/components/datasets/create/step-two/components/parent-child-options.tsx
+++ b/web/app/components/datasets/create/step-two/components/parent-child-options.tsx
@@ -1,12 +1,9 @@
'use client'
+import type { PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC, MouseEventHandler } from 'react'
import type { ParentChildConfig } from '../hooks'
-import type {
- ParentMode,
- PreProcessingRule,
- SummaryIndexSetting as SummaryIndexSettingType,
-} from '@/models/datasets'
+import type { ParentMode, SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets'
import { Button } from '@langgenius/dify-ui/button'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { RadioGroup } from '@langgenius/dify-ui/radio-group'
diff --git a/web/app/components/datasets/create/step-two/components/preview-panel.tsx b/web/app/components/datasets/create/step-two/components/preview-panel.tsx
index 1c68ce6d3d0..fa8fd37cd4c 100644
--- a/web/app/components/datasets/create/step-two/components/preview-panel.tsx
+++ b/web/app/components/datasets/create/step-two/components/preview-panel.tsx
@@ -1,8 +1,9 @@
'use client'
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ComponentProps, FC } from 'react'
import type { ParentChildConfig } from '../hooks'
-import type { DataSourceType, FileIndexingEstimateResponse } from '@/models/datasets'
+import type { DataSourceType } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { RiSearchEyeLine } from '@remixicon/react'
import { useTranslation } from 'react-i18next'
@@ -31,7 +32,7 @@ type PreviewPanelProps = {
finalFocus?: ComponentProps<typeof FloatRightContainer>['finalFocus']
dataSourceType: DataSourceType
currentDocForm: ChunkingMode
- estimate?: FileIndexingEstimateResponse
+ estimate?: IndexingEstimateResponse
parentChildConfig: ParentChildConfig
isSetting?: boolean
// Picker
diff --git a/web/app/components/datasets/create/step-two/creation-params.ts b/web/app/components/datasets/create/step-two/creation-params.ts
index ca8d0356baf..94f5ee8d9dc 100644
--- a/web/app/components/datasets/create/step-two/creation-params.ts
+++ b/web/app/components/datasets/create/step-two/creation-params.ts
@@ -1,4 +1,7 @@
-import type { IndexingEstimatePayload } from '@dify/contracts/api/console/datasets/types.gen'
+import type {
+ IndexingEstimatePayload,
+ NotionInfo,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { IndexingType } from './hooks/use-indexing-config'
import type { StepTwoFile, StepTwoNotionPage } from './types'
import type { DataSourceProvider } from '@/models/common'
@@ -7,7 +10,6 @@ import type {
CrawlOptions,
CrawlResultItem,
DataSourceType,
- NotionInfo,
ProcessRule,
} from '@/models/datasets'
import { groupBy } from 'es-toolkit/compat'
diff --git a/web/app/components/datasets/create/step-two/hooks/__tests__/use-document-creation.spec.ts b/web/app/components/datasets/create/step-two/hooks/__tests__/use-document-creation.spec.ts
index 8875b1950ac..6a0492fac61 100644
--- a/web/app/components/datasets/create/step-two/hooks/__tests__/use-document-creation.spec.ts
+++ b/web/app/components/datasets/create/step-two/hooks/__tests__/use-document-creation.spec.ts
@@ -1,9 +1,5 @@
-import type {
- CreateDocumentReq,
- CustomFile,
- FullDocumentDetail,
- ProcessRule,
-} from '@/models/datasets'
+import type { DocumentDetailResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { CreateDocumentReq, CustomFile, ProcessRule } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { QueryClient } from '@tanstack/react-query'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -164,7 +160,7 @@ describe('useDocumentCreation', () => {
})
it('should build params for isSetting mode', () => {
- const detail = { id: 'doc-1' } as FullDocumentDetail
+ const detail = { id: 'doc-1' } as DocumentDetailResponse
const { result } = renderHookWithConsoleQuery(() =>
useDocumentCreation({ ...defaultOptions, isSetting: true, documentDetail: detail }),
)
diff --git a/web/app/components/datasets/create/step-two/hooks/__tests__/use-segmentation-state.spec.ts b/web/app/components/datasets/create/step-two/hooks/__tests__/use-segmentation-state.spec.ts
index 8156ebafeec..2aafb0b83ca 100644
--- a/web/app/components/datasets/create/step-two/hooks/__tests__/use-segmentation-state.spec.ts
+++ b/web/app/components/datasets/create/step-two/hooks/__tests__/use-segmentation-state.spec.ts
@@ -1,4 +1,5 @@
-import type { PreProcessingRule, Rules } from '@/models/datasets'
+import type { PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
+import type { Rules } from '@/models/datasets'
import { act, renderHook } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { ChunkingMode, ProcessMode } from '@/models/datasets'
diff --git a/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts b/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts
index 4fc150fbaef..142b9b400b5 100644
--- a/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts
+++ b/web/app/components/datasets/create/step-two/hooks/use-document-creation.ts
@@ -1,3 +1,7 @@
+import type {
+ DatasetAndDocumentResponse,
+ DocumentDetailResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { ProviderWithModelsResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { StepTwoFile, StepTwoNotionPage } from '../types'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
@@ -6,8 +10,6 @@ import type {
CrawlOptions,
CrawlResultItem,
CreateDocumentReq,
- createDocumentResponse,
- FullDocumentDetail,
ProcessRule,
SummaryIndexSetting as SummaryIndexSettingType,
} from '@/models/datasets'
@@ -28,7 +30,7 @@ import { MAXIMUM_CHUNK_TOKEN_LENGTH } from './use-segmentation-state'
type UseDocumentCreationOptions = {
datasetId?: string
isSetting?: boolean
- documentDetail?: FullDocumentDetail
+ documentDetail?: DocumentDetailResponse
dataSourceType: DataSourceType
files: StepTwoFile[]
notionPages: StepTwoNotionPage[]
@@ -41,7 +43,7 @@ type UseDocumentCreationOptions = {
// Callbacks
onStepChange?: (delta: number) => void
updateIndexingTypeCache?: (type: string) => void
- updateResultCache?: (res: createDocumentResponse) => void
+ updateResultCache?: (res: DatasetAndDocumentResponse) => void
updateRetrievalMethodCache?: (method: RETRIEVE_METHOD | '') => void
onSave?: () => void
mutateDatasetRes?: () => void
diff --git a/web/app/components/datasets/create/step-two/hooks/use-preview-state.ts b/web/app/components/datasets/create/step-two/hooks/use-preview-state.ts
index 41cefaf60c7..cf4b9a18fa6 100644
--- a/web/app/components/datasets/create/step-two/hooks/use-preview-state.ts
+++ b/web/app/components/datasets/create/step-two/hooks/use-preview-state.ts
@@ -1,5 +1,6 @@
+import type { DocumentDetailResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { StepTwoFile, StepTwoNotionPage } from '../types'
-import type { CrawlResultItem, DocumentItem, FullDocumentDetail } from '@/models/datasets'
+import type { CrawlResultItem, DocumentItem } from '@/models/datasets'
import { useCallback, useState } from 'react'
import { DataSourceType } from '@/models/datasets'
@@ -8,7 +9,7 @@ type UsePreviewStateOptions = {
files: StepTwoFile[]
notionPages: StepTwoNotionPage[]
websitePages: CrawlResultItem[]
- documentDetail?: FullDocumentDetail
+ documentDetail?: DocumentDetailResponse
datasetId?: string
}
diff --git a/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts b/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts
index b8a92274e6f..cac0b40ce89 100644
--- a/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts
+++ b/web/app/components/datasets/create/step-two/hooks/use-segmentation-state.ts
@@ -1,6 +1,6 @@
+import type { PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
import type {
ParentMode,
- PreProcessingRule,
ProcessRule,
Rules,
SummaryIndexSetting as SummaryIndexSettingType,
diff --git a/web/app/components/datasets/create/step-two/process-rule.ts b/web/app/components/datasets/create/step-two/process-rule.ts
index 7c23e97302b..4daefaf65d0 100644
--- a/web/app/components/datasets/create/step-two/process-rule.ts
+++ b/web/app/components/datasets/create/step-two/process-rule.ts
@@ -1,8 +1,9 @@
import type {
DocumentProcessRulesResponse,
+ PreProcessingRule,
Rule,
} from '@dify/contracts/api/console/datasets/types.gen'
-import type { PreProcessingRule, Rules } from '@/models/datasets'
+import type { Rules } from '@/models/datasets'
import { ProcessMode } from '@/models/datasets'
const PRE_PROCESSING_RULE_IDS = new Set<string>([
diff --git a/web/app/components/datasets/create/step-two/types.ts b/web/app/components/datasets/create/step-two/types.ts
index 591b114ac43..7337393fd37 100644
--- a/web/app/components/datasets/create/step-two/types.ts
+++ b/web/app/components/datasets/create/step-two/types.ts
@@ -1,13 +1,10 @@
+import type {
+ DatasetAndDocumentResponse,
+ DocumentDetailResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { IndexingType } from './hooks'
import type { DataSourceProvider, NotionPage } from '@/models/common'
-import type {
- CrawlOptions,
- CrawlResultItem,
- createDocumentResponse,
- CustomFile,
- DataSourceType,
- FullDocumentDetail,
-} from '@/models/datasets'
+import type { CrawlOptions, CrawlResultItem, CustomFile, DataSourceType } from '@/models/datasets'
import type { RETRIEVE_METHOD } from '@/types/app'
/** The fields step two reads from a file to index; uploads and stored documents both provide them. */
@@ -21,7 +18,7 @@ export type StepTwoNotionPage = Pick<
export type StepTwoProps = {
isSetting?: boolean
- documentDetail?: FullDocumentDetail
+ documentDetail?: DocumentDetailResponse
isAPIKeySet: boolean
onSetting: () => void
datasetId?: string
@@ -39,7 +36,7 @@ export type StepTwoProps = {
onStepChange?: (delta: number) => void
updateIndexingTypeCache?: (type: string) => void
updateRetrievalMethodCache?: (method: RETRIEVE_METHOD | '') => void
- updateResultCache?: (res: createDocumentResponse) => void
+ updateResultCache?: (res: DatasetAndDocumentResponse) => void
onSave?: () => void
onCancel?: () => void
}
diff --git a/web/app/components/datasets/create/website/__tests__/index.spec.tsx b/web/app/components/datasets/create/website/__tests__/index.spec.tsx
index d6d0696f6c1..fd19ae6061a 100644
--- a/web/app/components/datasets/create/website/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/create/website/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceAuth } from '@/app/components/header/account-setting/data-source-page-new/types'
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { CrawlOptions, CrawlResultItem } from '@/models/datasets'
import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -83,7 +83,10 @@ const createMockCrawlOptions = (overrides: Partial<CrawlOptions> = {}): CrawlOpt
...overrides,
})
-const createMockDataSourceAuth = (provider: string, credentialsCount = 1): DataSourceAuth => ({
+const createMockDataSourceAuth = (
+ provider: string,
+ credentialsCount = 1,
+): DatasourceProviderAuthResponse => ({
author: 'test',
provider,
plugin_id: `${provider}-plugin`,
@@ -105,7 +108,7 @@ const createMockDataSourceAuth = (provider: string, credentialsCount = 1): DataS
})
type RenderProps = {
- authedDataSourceList?: DataSourceAuth[]
+ authedDataSourceList?: DatasourceProviderAuthResponse[]
enableJina?: boolean
enableFirecrawl?: boolean
enableWatercrawl?: boolean
diff --git a/web/app/components/datasets/create/website/index.tsx b/web/app/components/datasets/create/website/index.tsx
index 44fc47953cc..b4ed95a914b 100644
--- a/web/app/components/datasets/create/website/index.tsx
+++ b/web/app/components/datasets/create/website/index.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { FC } from 'react'
-import type { DataSourceAuth } from '@/app/components/header/account-setting/data-source-page-new/types'
import type { CrawlOptions, CrawlResultItem } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { RadioGroup, RadioItem } from '@langgenius/dify-ui/radio-group'
@@ -32,7 +32,7 @@ type Props = Readonly<{
onJobIdChange: (jobId: string) => void
crawlOptions: CrawlOptions
onCrawlOptionsChange: (payload: CrawlOptions) => void
- authedDataSourceList: DataSourceAuth[]
+ authedDataSourceList: DatasourceProviderAuthResponse[]
}>
const Website: FC<Props> = ({
diff --git a/web/app/components/datasets/documents/components/__tests__/list.spec.tsx b/web/app/components/datasets/documents/components/__tests__/list.spec.tsx
index f6e6d46031a..9da3d5a4a0c 100644
--- a/web/app/components/datasets/documents/components/__tests__/list.spec.tsx
+++ b/web/app/components/datasets/documents/components/__tests__/list.spec.tsx
@@ -1,4 +1,4 @@
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { fireEvent, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -61,7 +61,7 @@ vi.mock('@/context/dataset-detail', () => ({
// Mock child components that are complex
vi.mock('../document-list/components', async (importOriginal) => ({
...(await importOriginal<typeof import('../document-list/components')>()),
- DocumentTableRow: ({ doc, index }: { doc: SimpleDocumentDetail; index: number }) => (
+ DocumentTableRow: ({ doc, index }: { doc: DocumentWithSegmentsResponse; index: number }) => (
<tr data-testid={`doc-row-${doc.id}`}>
<td>{index + 1}</td>
<td>{doc.name}</td>
@@ -97,7 +97,9 @@ vi.mock('@/app/components/datasets/metadata/edit-metadata-batch/modal', () => ({
),
}))
-function createDoc(overrides: Partial<SimpleDocumentDetail> = {}): SimpleDocumentDetail {
+function createDoc(
+ overrides: Partial<DocumentWithSegmentsResponse> = {},
+): DocumentWithSegmentsResponse {
return {
id: `doc-${Math.random().toString(36).slice(2, 8)}`,
name: 'Test Doc',
@@ -114,12 +116,12 @@ function createDoc(overrides: Partial<SimpleDocumentDetail> = {}): SimpleDocumen
created_from: 'web',
created_at: 1234567890,
...overrides,
- } as SimpleDocumentDetail
+ } as DocumentWithSegmentsResponse
}
const defaultProps = {
embeddingAvailable: true,
- documents: [] as SimpleDocumentDetail[],
+ documents: [] as DocumentWithSegmentsResponse[],
selectedIds: [] as string[],
onSelectedIdChange: vi.fn(),
datasetId: 'ds-1',
diff --git a/web/app/components/datasets/documents/components/document-list/__tests__/index.spec.tsx b/web/app/components/datasets/documents/components/document-list/__tests__/index.spec.tsx
index 55daa66e5e5..5c410098178 100644
--- a/web/app/components/datasets/documents/components/document-list/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/components/document-list/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { act, fireEvent, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { ChunkingMode, DataSourceType } from '@/models/datasets'
@@ -75,7 +75,9 @@ vi.mock('@/app/components/datasets/metadata/hooks/use-batch-edit-document-metada
const createWrapper = () => createConsoleQueryWrapper().wrapper
-const createMockDoc = (overrides: Partial<SimpleDocumentDetail> = {}): SimpleDocumentDetail =>
+const createMockDoc = (
+ overrides: Partial<DocumentWithSegmentsResponse> = {},
+): DocumentWithSegmentsResponse =>
({
id: `doc-${Math.random().toString(36).substr(2, 9)}`,
position: 1,
@@ -108,7 +110,7 @@ const createMockDoc = (overrides: Partial<SimpleDocumentDetail> = {}): SimpleDoc
hit_count: 10,
doc_form: 'text_model',
...overrides,
- }) as SimpleDocumentDetail
+ }) as DocumentWithSegmentsResponse
const defaultPagination: PaginationProps = {
current: 1,
diff --git a/web/app/components/datasets/documents/components/document-list/components/__tests__/document-table-row.spec.tsx b/web/app/components/datasets/documents/components/document-list/components/__tests__/document-table-row.spec.tsx
index 7412ff44f8d..e30c09ee175 100644
--- a/web/app/components/datasets/documents/components/document-list/components/__tests__/document-table-row.spec.tsx
+++ b/web/app/components/datasets/documents/components/document-list/components/__tests__/document-table-row.spec.tsx
@@ -1,5 +1,5 @@
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactNode } from 'react'
-import type { SimpleDocumentDetail } from '@/models/datasets'
import { CheckboxGroup } from '@langgenius/dify-ui/checkbox-group'
import { fireEvent, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -49,7 +49,7 @@ const createWrapper = (value: string[] = [], onValueChange = vi.fn()) => {
)
}
-type LocalDoc = SimpleDocumentDetail & { percent?: number }
+type LocalDoc = DocumentWithSegmentsResponse & { percent?: number }
const createMockDoc = (overrides: Record<string, unknown> = {}): LocalDoc =>
({
diff --git a/web/app/components/datasets/documents/components/document-list/components/document-source-icon.tsx b/web/app/components/datasets/documents/components/document-list/components/document-source-icon.tsx
index 57d4a131fd7..5a85e841262 100644
--- a/web/app/components/datasets/documents/components/document-list/components/document-source-icon.tsx
+++ b/web/app/components/datasets/documents/components/document-list/components/document-source-icon.tsx
@@ -1,5 +1,5 @@
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { SimpleDocumentDetail } from '@/models/datasets'
import { RiGlobalLine } from '@remixicon/react'
import * as React from 'react'
import FileTypeIcon from '@/app/components/base/file-uploader/file-type-icon'
@@ -15,7 +15,7 @@ import {
} from '../../../document-source'
type DocumentSourceIconProps = {
- doc: SimpleDocumentDetail
+ doc: DocumentWithSegmentsResponse
fileType?: string
}
diff --git a/web/app/components/datasets/documents/components/document-list/components/document-table-row.tsx b/web/app/components/datasets/documents/components/document-list/components/document-table-row.tsx
index ffd42ac1a75..be4bcce8127 100644
--- a/web/app/components/datasets/documents/components/document-list/components/document-table-row.tsx
+++ b/web/app/components/datasets/documents/components/document-list/components/document-table-row.tsx
@@ -1,4 +1,4 @@
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
@@ -24,7 +24,7 @@ import { getDatasetACLCapabilities } from '@/utils/permission'
import DocumentSourceIcon from './document-source-icon'
import { renderTdValue } from './utils'
-type LocalDoc = SimpleDocumentDetail & { percent?: number }
+type LocalDoc = DocumentWithSegmentsResponse & { percent?: number }
type DocumentTableRowProps = {
doc: LocalDoc
diff --git a/web/app/components/datasets/documents/components/document-list/hooks/__tests__/use-document-selection.spec.ts b/web/app/components/datasets/documents/components/document-list/hooks/__tests__/use-document-selection.spec.ts
index 6eefa13e7c5..58559bff249 100644
--- a/web/app/components/datasets/documents/components/document-list/hooks/__tests__/use-document-selection.spec.ts
+++ b/web/app/components/datasets/documents/components/document-list/hooks/__tests__/use-document-selection.spec.ts
@@ -1,10 +1,10 @@
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { act, renderHook } from '@testing-library/react'
import { describe, expect, it, vi } from 'vite-plus/test'
import { DataSourceType } from '@/models/datasets'
import { useDocumentSelection } from '../use-document-selection'
-type LocalDoc = SimpleDocumentDetail & { percent?: number }
+type LocalDoc = DocumentWithSegmentsResponse & { percent?: number }
const createMockDocument = (overrides: Partial<LocalDoc> = {}): LocalDoc =>
({
diff --git a/web/app/components/datasets/documents/components/document-list/hooks/use-document-selection.ts b/web/app/components/datasets/documents/components/document-list/hooks/use-document-selection.ts
index 4ac2de01c0f..4eaa638af28 100644
--- a/web/app/components/datasets/documents/components/document-list/hooks/use-document-selection.ts
+++ b/web/app/components/datasets/documents/components/document-list/hooks/use-document-selection.ts
@@ -1,8 +1,8 @@
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { useCallback, useMemo } from 'react'
import { DataSourceType } from '@/models/datasets'
-type LocalDoc = SimpleDocumentDetail & { percent?: number }
+type LocalDoc = DocumentWithSegmentsResponse & { percent?: number }
type UseDocumentSelectionOptions = {
documents: LocalDoc[]
diff --git a/web/app/components/datasets/documents/components/list.tsx b/web/app/components/datasets/documents/components/list.tsx
index f16404ad3d5..6f39db0b21f 100644
--- a/web/app/components/datasets/documents/components/list.tsx
+++ b/web/app/components/datasets/documents/components/list.tsx
@@ -1,6 +1,6 @@
'use client'
-import type { SimpleDocumentDetail } from '@/models/datasets'
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { CheckboxGroup } from '@langgenius/dify-ui/checkbox-group'
import { Pagination } from '@langgenius/dify-ui/pagination'
@@ -22,7 +22,7 @@ import { DocumentTableRow, SortHeader } from './document-list/components'
import { useDocumentActions, useDocumentSelection, useDocumentSort } from './document-list/hooks'
import RenameModal from './rename-modal'
-type LocalDoc = SimpleDocumentDetail & { percent?: number }
+type LocalDoc = DocumentWithSegmentsResponse & { percent?: number }
type PaginationProps = {
className?: string
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx
index 2720b42237d..c70d2facf3c 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '@/types/pipeline'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import CredentialSelector from '../index'
@@ -21,7 +21,7 @@ const credentials = [
type: 'oauth2',
is_default: false,
},
-] as DataSourceCredential[]
+] as DatasourceCredentialResponse[]
describe('CredentialSelector', () => {
it('renders the current credential as an accessible trigger', () => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/item.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/item.spec.tsx
index 2bebd23e904..57c2796e83d 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/item.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/item.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '@/types/pipeline'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import Item from '../item'
@@ -13,7 +13,7 @@ describe('CredentialSelectorItem', () => {
id: 'cred-1',
name: 'My Account',
avatar_url: 'https://example.com/avatar.png',
- } as DataSourceCredential,
+ } as DatasourceCredentialResponse,
isSelected: false,
onCredentialChange: vi.fn(),
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/list.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/list.spec.tsx
index 8700cf93331..f38b09a5c32 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/list.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/__tests__/list.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '@/types/pipeline'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import List from '../list'
@@ -8,9 +8,9 @@ vi.mock('@/app/components/datasets/common/credential-icon', () => ({
}))
describe('CredentialSelectorList', () => {
- const mockCredentials: DataSourceCredential[] = [
- { id: 'cred-1', name: 'Account A', avatar_url: '' } as DataSourceCredential,
- { id: 'cred-2', name: 'Account B', avatar_url: '' } as DataSourceCredential,
+ const mockCredentials: DatasourceCredentialResponse[] = [
+ { id: 'cred-1', name: 'Account A', avatar_url: '' } as DatasourceCredentialResponse,
+ { id: 'cred-2', name: 'Account B', avatar_url: '' } as DatasourceCredentialResponse,
]
const defaultProps = {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx
index 89e6b6a8955..24a3b23d8f5 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/index.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '@/types/pipeline'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { useBoolean } from 'ahooks'
@@ -10,7 +10,7 @@ import Trigger from './trigger'
export type CredentialSelectorProps = {
currentCredentialId: string
onCredentialChange: (credentialId: string) => void
- credentials: Array<DataSourceCredential>
+ credentials: Array<DatasourceCredentialResponse>
}
const CredentialSelector = ({
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx
index 13e8424f326..b290d9fbf0e 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/item.tsx
@@ -1,11 +1,11 @@
-import type { DataSourceCredential } from '@/types/pipeline'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { RiCheckLine } from '@remixicon/react'
import * as React from 'react'
import { useCallback } from 'react'
import { CredentialIcon } from '@/app/components/datasets/common/credential-icon'
type ItemProps = {
- credential: DataSourceCredential
+ credential: DatasourceCredentialResponse
isSelected: boolean
onCredentialChange: (credentialId: string) => void
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/list.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/list.tsx
index 05389384423..4a9947aae95 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/list.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/list.tsx
@@ -1,10 +1,10 @@
-import type { DataSourceCredential } from '@/types/pipeline'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import * as React from 'react'
import Item from './item'
type ListProps = {
currentCredentialId: string
- credentials: Array<DataSourceCredential>
+ credentials: Array<DatasourceCredentialResponse>
onCredentialChange: (credentialId: string) => void
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/trigger.tsx b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/trigger.tsx
index 2bb9c18132b..995846ea63b 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/trigger.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/data-source/base/credential-selector/trigger.tsx
@@ -1,11 +1,11 @@
-import type { DataSourceCredential } from '@/types/pipeline'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import { RiArrowDownSLine } from '@remixicon/react'
import * as React from 'react'
import { CredentialIcon } from '@/app/components/datasets/common/credential-icon'
type TriggerProps = {
- currentCredential: DataSourceCredential | undefined
+ currentCredential: DatasourceCredentialResponse | undefined
isOpen: boolean
}
diff --git a/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts b/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts
index f4f0924f08c..0027b820a0d 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts
+++ b/web/app/components/datasets/documents/create-from-pipeline/hooks/use-datasource-actions.ts
@@ -1,14 +1,11 @@
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { PipelineGenerateResponse } from '@dify/contracts/api/console/rag/types.gen'
import type { StoreApi } from 'zustand'
import type { DataSourceShape } from '@/app/components/datasets/documents/create-from-pipeline/data-source/store'
import type { Datasource } from '@/app/components/rag-pipeline/components/panel/test-run/types'
import type { DataSourceNotionPageMap, NotionPage } from '@/models/common'
-import type {
- CrawlResultItem,
- DocumentItem,
- CustomFile as File,
- FileIndexingEstimateResponse,
-} from '@/models/datasets'
-import type { OnlineDriveFile, PublishedPipelineRunResponse } from '@/models/pipeline'
+import type { CrawlResultItem, DocumentItem, CustomFile as File } from '@/models/datasets'
+import type { OnlineDriveFile } from '@/models/pipeline'
import { useMutation } from '@tanstack/react-query'
import { useCallback, useRef } from 'react'
import { trackEvent } from '@/app/components/base/amplitude'
@@ -30,9 +27,9 @@ type DatasourceActionsParams = {
datasourceType: string | undefined
pipelineId: string | undefined
dataSourceStore: StoreApi<DataSourceShape>
- setEstimateData: (data: FileIndexingEstimateResponse | undefined) => void
+ setEstimateData: (data: IndexingEstimateResponse | undefined) => void
setBatchId: (id: string) => void
- setDocuments: (docs: PublishedPipelineRunResponse['documents']) => void
+ setDocuments: (docs: PipelineGenerateResponse['documents']) => void
handleNextStep: () => void
PagesMapAndSelectedPagesId: DataSourceNotionPageMap
currentWorkspacePages: { page_id: string }[] | undefined
diff --git a/web/app/components/datasets/documents/create-from-pipeline/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/index.tsx
index 263f83825c1..e037f3b3c58 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/index.tsx
@@ -1,9 +1,9 @@
'use client'
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { PipelineDocument } from '@dify/contracts/api/console/rag/types.gen'
import type { Datasource } from '@/app/components/rag-pipeline/components/panel/test-run/types'
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
import type { Node } from '@/app/components/workflow/types'
-import type { FileIndexingEstimateResponse } from '@/models/datasets'
-import type { InitialDocumentDetail } from '@/models/pipeline'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { useBoolean } from 'ahooks'
import { useAtomValue } from 'jotai'
@@ -67,11 +67,9 @@ const CreateFormPipeline = () => {
// Core state
const [datasource, setDatasource] = useState<Datasource>()
- const [estimateData, setEstimateData] = useState<FileIndexingEstimateResponse | undefined>(
- undefined,
- )
+ const [estimateData, setEstimateData] = useState<IndexingEstimateResponse | undefined>(undefined)
const [batchId, setBatchId] = useState('')
- const [documents, setDocuments] = useState<InitialDocumentDetail[]>([])
+ const [documents, setDocuments] = useState<PipelineDocument[]>([])
// Data fetching
const { data: pipelineNodes, isFetching: isFetchingPipelineInfo } = useQuery(
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/chunk-preview.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/chunk-preview.spec.tsx
index b38907c0739..898d8adefc8 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/chunk-preview.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/__tests__/chunk-preview.spec.tsx
@@ -1,5 +1,6 @@
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { NotionPage } from '@/models/common'
-import type { CrawlResultItem, CustomFile, FileIndexingEstimateResponse } from '@/models/datasets'
+import type { CrawlResultItem, CustomFile } from '@/models/datasets'
import type { OnlineDriveFile } from '@/models/pipeline'
import { fireEvent, render, screen } from '@testing-library/react'
import * as React from 'react'
@@ -95,8 +96,8 @@ const createMockOnlineDriveFile = (overrides?: Partial<OnlineDriveFile>): Online
})
const createMockEstimateData = (
- overrides?: Partial<FileIndexingEstimateResponse>,
-): FileIndexingEstimateResponse => ({
+ overrides?: Partial<IndexingEstimateResponse>,
+): IndexingEstimateResponse => ({
tokens: 1000,
total_price: 0.01,
currency: 'USD',
diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx
index 252857f1372..ea2cbe09516 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx
@@ -1,10 +1,6 @@
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { NotionPage } from '@/models/common'
-import type {
- CrawlResultItem,
- CustomFile,
- DocumentItem,
- FileIndexingEstimateResponse,
-} from '@/models/datasets'
+import type { CrawlResultItem, CustomFile, DocumentItem } from '@/models/datasets'
import type { OnlineDriveFile } from '@/models/pipeline'
import { Button } from '@langgenius/dify-ui/button'
import { RiSearchEyeLine } from '@remixicon/react'
@@ -38,7 +34,7 @@ type ChunkPreviewProps = {
onlineDriveFiles: OnlineDriveFile[]
isIdle: boolean
isPending: boolean
- estimateData: FileIndexingEstimateResponse | undefined
+ estimateData: IndexingEstimateResponse | undefined
onPreview: () => void
handlePreviewFileChange: (file: DocumentItem) => void
handlePreviewOnlineDocumentChange: (page: NotionPage) => void
diff --git a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/__tests__/index.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/__tests__/index.spec.tsx
index ada869aa1e8..52972647bb3 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/__tests__/index.spec.tsx
@@ -1,8 +1,8 @@
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
+import type { PipelineDocument } from '@dify/contracts/api/console/rag/types.gen'
import type { ReactElement } from 'react'
import type { Mock } from 'vite-plus/test'
-import type { IndexingStatusResponse } from '@/models/datasets'
-import type { InitialDocumentDetail } from '@/models/pipeline'
import { QueryClient } from '@tanstack/react-query'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
@@ -55,7 +55,7 @@ vi.mock('@/app/components/datasets/common/vector-space-admission-alert', () => (
// Mock the batch indexing status request
let mockFetchIndexingStatus: Mock
-let mockIndexingStatusData: IndexingStatusResponse[] = []
+let mockIndexingStatusData: DocumentStatusResponse[] = []
vi.mock('@tanstack/react-query', async (importOriginal) => {
const { mockConsoleOperationHooks } = await import('@/test/console/operation-hooks')
return mockConsoleOperationHooks(await importOriginal(), {
@@ -83,28 +83,26 @@ vi.mock('@/hooks/use-api-access-url', () => ({
* Uses deterministic counter-based IDs to avoid flaky tests
*/
let documentIdCounter = 0
-const createMockDocument = (
- overrides: Partial<InitialDocumentDetail> = {},
-): InitialDocumentDetail => ({
+const createMockDocument = (overrides: Partial<PipelineDocument> = {}): PipelineDocument => ({
id: overrides.id ?? `doc-${++documentIdCounter}`,
name: 'test-document.txt',
data_source_type: DatasourceType.localFile,
data_source_info: {},
enabled: true,
error: '',
- indexing_status: 'waiting' as IndexingStatusResponse['indexing_status'],
+ indexing_status: 'waiting' as DocumentStatusResponse['indexing_status'],
position: 0,
...overrides,
})
/**
- * Creates a mock IndexingStatusResponse for testing
+ * Creates a mock DocumentStatusResponse for testing
*/
const createMockIndexingStatus = (
- overrides: Partial<IndexingStatusResponse> = {},
-): IndexingStatusResponse => ({
+ overrides: Partial<DocumentStatusResponse> = {},
+): DocumentStatusResponse => ({
id: `doc-${Math.random().toString(36).slice(2, 9)}`,
- indexing_status: 'waiting' as IndexingStatusResponse['indexing_status'],
+ indexing_status: 'waiting' as DocumentStatusResponse['indexing_status'],
processing_started_at: Date.now(),
parsing_completed_at: 0,
cleaning_completed_at: 0,
@@ -125,7 +123,7 @@ const createDefaultProps = (
overrides: Partial<{
datasetId: string
batchId: string
- documents: InitialDocumentDetail[]
+ documents: PipelineDocument[]
indexingType: IndexingType
retrievalMethod: RETRIEVE_METHOD
}> = {},
@@ -897,7 +895,7 @@ describe('EmbeddingProcess', () => {
mockIndexingStatusData = [
createMockIndexingStatus({
id: 'doc-1',
- indexing_status: undefined as unknown as IndexingStatusResponse['indexing_status'],
+ indexing_status: undefined as unknown as DocumentStatusResponse['indexing_status'],
}),
]
const props = createDefaultProps({ documents: [doc1] })
diff --git a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/index.tsx
index 0dabd932adf..0113339459f 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/index.tsx
@@ -1,7 +1,7 @@
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { PipelineDocument } from '@dify/contracts/api/console/rag/types.gen'
import type { IndexingType } from '@/app/components/datasets/create/step-two'
import type { DataSourceNotionPage } from '@/models/common'
-import type { IndexingStatusResponse } from '@/models/datasets'
-import type { InitialDocumentDetail } from '@/models/pipeline'
import type { RETRIEVE_METHOD } from '@/types/app'
import { buttonVariants } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
@@ -38,7 +38,7 @@ const isNotionPageIcon = (value: unknown): value is DataSourceNotionPage['page_i
type EmbeddingProcessProps = {
datasetId: string
batchId: string
- documents?: InitialDocumentDetail[]
+ documents?: PipelineDocument[]
indexingType?: IndexingType
retrievalMethod?: RETRIEVE_METHOD
}
@@ -58,7 +58,7 @@ const EmbeddingProcess = ({
select: (data) => data.billing.subscription.plan,
}),
)
- const [indexingStatusBatchDetail, setIndexingStatusDetail] = useState<IndexingStatusResponse[]>(
+ const [indexingStatusBatchDetail, setIndexingStatusDetail] = useState<DocumentStatusResponse[]>(
[],
)
const [shouldPoll, setShouldPoll] = useState(true)
@@ -147,7 +147,7 @@ const EmbeddingProcess = ({
return doc?.name
}
const getFileType = (name?: string) => name?.split('.').pop() || 'txt'
- const getSourcePercent = (detail: IndexingStatusResponse) => {
+ const getSourcePercent = (detail: DocumentStatusResponse) => {
const completedCount = detail.completed_segments || 0
const totalCount = detail.total_segments || 0
if (totalCount === 0) return 0
@@ -164,7 +164,7 @@ const EmbeddingProcess = ({
const icon = doc?.data_source_info?.notion_page_icon
return typeof icon === 'string' || isNotionPageIcon(icon) ? icon : undefined
}
- const isSourceEmbedding = (detail: IndexingStatusResponse) =>
+ const isSourceEmbedding = (detail: DocumentStatusResponse) =>
['indexing', 'splitting', 'parsing', 'cleaning', 'waiting'].includes(
detail.indexing_status || '',
)
diff --git a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
index 62c33382549..76ba4b7ce19 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
@@ -1,4 +1,4 @@
-import type { ProcessRuleResponse } from '@/models/datasets'
+import type { ProcessRuleResponse } from '@dify/contracts/api/console/datasets/types.gen'
import * as React from 'react'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
diff --git a/web/app/components/datasets/documents/create-from-pipeline/processing/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/processing/index.tsx
index 8915459f609..3c2e4eaebb7 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/processing/index.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/processing/index.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { InitialDocumentDetail } from '@/models/pipeline'
+import type { PipelineDocument } from '@dify/contracts/api/console/rag/types.gen'
import { RiBookOpenLine } from '@remixicon/react'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
@@ -9,7 +9,7 @@ import EmbeddingProcess from './embedding-process'
type ProcessingProps = {
batchId: string
- documents: InitialDocumentDetail[]
+ documents: PipelineDocument[]
}
const Processing = ({ batchId, documents }: ProcessingProps) => {
diff --git a/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/preview-panel.spec.tsx b/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/preview-panel.spec.tsx
index d4b66f5ddb1..5d817f9043b 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/preview-panel.spec.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/steps/__tests__/preview-panel.spec.tsx
@@ -1,12 +1,8 @@
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { Datasource } from '@/app/components/rag-pipeline/components/panel/test-run/types'
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
import type { NotionPage } from '@/models/common'
-import type {
- CrawlResultItem,
- CustomFile,
- FileIndexingEstimateResponse,
- FileItem,
-} from '@/models/datasets'
+import type { CrawlResultItem, CustomFile, FileItem } from '@/models/datasets'
import type { OnlineDriveFile } from '@/models/pipeline'
import { render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -194,11 +190,11 @@ describe('StepTwoPreview', () => {
{ id: 'drive-1', name: 'drive-file.txt' } as OnlineDriveFile,
]
- const mockEstimateData: FileIndexingEstimateResponse = {
+ const mockEstimateData: IndexingEstimateResponse = {
tokens: 1000,
total_price: 0.01,
total_segments: 10,
- } as FileIndexingEstimateResponse
+ } as IndexingEstimateResponse
const defaultProps = {
datasourceType: DatasourceType.localFile,
diff --git a/web/app/components/datasets/documents/create-from-pipeline/steps/preview-panel.tsx b/web/app/components/datasets/documents/create-from-pipeline/steps/preview-panel.tsx
index 087cf8c3dda..0a16f13aac1 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/steps/preview-panel.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/steps/preview-panel.tsx
@@ -1,13 +1,8 @@
'use client'
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { Datasource } from '@/app/components/rag-pipeline/components/panel/test-run/types'
import type { NotionPage } from '@/models/common'
-import type {
- CrawlResultItem,
- CustomFile,
- DocumentItem,
- FileIndexingEstimateResponse,
- FileItem,
-} from '@/models/datasets'
+import type { CrawlResultItem, CustomFile, DocumentItem, FileItem } from '@/models/datasets'
import type { DatasourceType, OnlineDriveFile } from '@/models/pipeline'
import { memo } from 'react'
import ChunkPreview from '../preview/chunk-preview'
@@ -66,7 +61,7 @@ type StepTwoPreviewProps = {
selectedOnlineDriveFileList: OnlineDriveFile[]
isIdle: boolean
isPendingPreview: boolean
- estimateData: FileIndexingEstimateResponse | undefined
+ estimateData: IndexingEstimateResponse | undefined
onPreview: () => void
handlePreviewFileChange: (file: DocumentItem) => void
handlePreviewOnlineDocumentChange: (page: NotionPage) => void
diff --git a/web/app/components/datasets/documents/create-from-pipeline/steps/step-three-content.tsx b/web/app/components/datasets/documents/create-from-pipeline/steps/step-three-content.tsx
index aed578fd3bd..443b51a05b1 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/steps/step-three-content.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/steps/step-three-content.tsx
@@ -1,11 +1,11 @@
'use client'
-import type { InitialDocumentDetail } from '@/models/pipeline'
+import type { PipelineDocument } from '@dify/contracts/api/console/rag/types.gen'
import { memo } from 'react'
import Processing from '../processing'
type StepThreeContentProps = {
batchId: string
- documents: InitialDocumentDetail[]
+ documents: PipelineDocument[]
}
const StepThreeContent = ({ batchId, documents }: StepThreeContentProps) => {
diff --git a/web/app/components/datasets/documents/detail/completed/__tests__/child-segment-list.spec.tsx b/web/app/components/datasets/documents/detail/completed/__tests__/child-segment-list.spec.tsx
index 8c52aaaf0d4..a051a6649c4 100644
--- a/web/app/components/datasets/documents/detail/completed/__tests__/child-segment-list.spec.tsx
+++ b/web/app/components/datasets/documents/detail/completed/__tests__/child-segment-list.spec.tsx
@@ -1,4 +1,4 @@
-import type { ChildChunkDetail } from '@/models/datasets'
+import type { ChildChunkResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import ChildSegmentList from '../child-segment-list'
@@ -85,7 +85,11 @@ describe('ChildSegmentList', () => {
mockCurrChildChunk = null
})
- const createMockChildChunk = (id: string, content: string, edited = false): ChildChunkDetail => ({
+ const createMockChildChunk = (
+ id: string,
+ content: string,
+ edited = false,
+ ): ChildChunkResponse => ({
id,
content,
position: 1,
diff --git a/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsx b/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsx
index eba3633d12f..0af15e808a2 100644
--- a/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/detail/completed/__tests__/index.spec.tsx
@@ -1,10 +1,9 @@
-import type { DocumentContextValue } from '@/app/components/datasets/documents/detail/context'
import type {
- ChildChunkDetail,
- ChunkingMode,
- ParentMode,
- SegmentDetailModel,
-} from '@/models/datasets'
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
+import type { DocumentContextValue } from '@/app/components/datasets/documents/detail/context'
+import type { ChunkingMode, ParentMode } from '@/models/datasets'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import * as React from 'react'
@@ -44,12 +43,12 @@ const {
off: vi.fn(),
},
mockSegmentListData: {
- data: [] as SegmentDetailModel[],
+ data: [] as SegmentResponse[],
total: 0,
total_pages: 0,
},
mockChildSegmentListData: {
- data: [] as ChildChunkDetail[],
+ data: [] as ChildChunkResponse[],
total: 0,
total_pages: 0,
},
@@ -230,9 +229,7 @@ vi.mock('../common/batch-action', () => ({
),
}))
-const createMockSegmentDetail = (
- overrides: Partial<SegmentDetailModel> = {},
-): SegmentDetailModel => ({
+const createMockSegmentDetail = (overrides: Partial<SegmentResponse> = {}): SegmentResponse => ({
id: `segment-${Math.random().toString(36).substr(2, 9)}`,
position: 1,
document_id: 'doc-1',
@@ -263,7 +260,9 @@ const createMockSegmentDetail = (
...overrides,
})
-const _createMockChildChunk = (overrides: Partial<ChildChunkDetail> = {}): ChildChunkDetail => ({
+const _createMockChildChunk = (
+ overrides: Partial<ChildChunkResponse> = {},
+): ChildChunkResponse => ({
id: `child-${Math.random().toString(36).substr(2, 9)}`,
position: 1,
segment_id: 'segment-1',
diff --git a/web/app/components/datasets/documents/detail/completed/__tests__/permissions.spec.tsx b/web/app/components/datasets/documents/detail/completed/__tests__/permissions.spec.tsx
index 75fb658241a..160e5f5ea4c 100644
--- a/web/app/components/datasets/documents/detail/completed/__tests__/permissions.spec.tsx
+++ b/web/app/components/datasets/documents/detail/completed/__tests__/permissions.spec.tsx
@@ -1,4 +1,8 @@
-import type { ChildChunkDetail, ParentMode, SegmentDetailModel } from '@/models/datasets'
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
+import type { ParentMode } from '@/models/datasets'
import { screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -7,7 +11,7 @@ import { renderWithConsoleQuery as render } from '@/test/console/query-data'
import { DocumentContext } from '../../context'
import Completed from '../index'
-const childChunk: ChildChunkDetail = {
+const childChunk: ChildChunkResponse = {
id: 'child-1',
segment_id: 'segment-1',
position: 1,
@@ -18,7 +22,7 @@ const childChunk: ChildChunkDetail = {
type: 'automatic',
}
-const segment: SegmentDetailModel = {
+const segment: SegmentResponse = {
id: 'segment-1',
document_id: 'document-1',
position: 1,
diff --git a/web/app/components/datasets/documents/detail/completed/__tests__/segment-list.spec.tsx b/web/app/components/datasets/documents/detail/completed/__tests__/segment-list.spec.tsx
index 4f7c11b72fa..22991522fa2 100644
--- a/web/app/components/datasets/documents/detail/completed/__tests__/segment-list.spec.tsx
+++ b/web/app/components/datasets/documents/detail/completed/__tests__/segment-list.spec.tsx
@@ -1,4 +1,4 @@
-import type { SegmentDetailModel } from '@/models/datasets'
+import type { SegmentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { ChunkingMode } from '@/models/datasets'
@@ -59,7 +59,7 @@ vi.mock('../segment-card', () => ({
embeddingAvailable,
focused,
}: {
- detail: SegmentDetailModel
+ detail: SegmentResponse
onClick: () => void
onChangeSwitch: (enabled: boolean, segId?: string) => Promise<void>
onClickEdit: () => void
@@ -122,7 +122,7 @@ describe('SegmentList', () => {
mockCurrChildChunk = null
})
- const createMockSegment = (id: string, content: string): SegmentDetailModel =>
+ const createMockSegment = (id: string, content: string): SegmentResponse =>
({
id,
content,
@@ -143,7 +143,7 @@ describe('SegmentList', () => {
error: null,
disabled_at: null,
disabled_by: null,
- }) as unknown as SegmentDetailModel
+ }) as unknown as SegmentResponse
const defaultProps = {
ref: null,
diff --git a/web/app/components/datasets/documents/detail/completed/child-segment-detail.tsx b/web/app/components/datasets/documents/detail/completed/child-segment-detail.tsx
index 0b1da6413fc..f5c6baea985 100644
--- a/web/app/components/datasets/documents/detail/completed/child-segment-detail.tsx
+++ b/web/app/components/datasets/documents/detail/completed/child-segment-detail.tsx
@@ -1,5 +1,6 @@
+import type { ChildChunkResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { ChildChunkDetail, ChunkingMode } from '@/models/datasets'
+import type { ChunkingMode } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
import { RiCloseLine, RiCollapseDiagonalLine, RiExpandDiagonalLine } from '@remixicon/react'
@@ -18,7 +19,7 @@ import { useSegmentListContext } from './index'
type IChildSegmentDetailProps = {
chunkId: string
- childChunkInfo?: Partial<ChildChunkDetail> & { id: string }
+ childChunkInfo?: Partial<ChildChunkResponse> & { id: string }
onUpdate: (segmentId: string, childChunkId: string, content: string) => void
onCancel: () => void
docForm: ChunkingMode
diff --git a/web/app/components/datasets/documents/detail/completed/child-segment-list.tsx b/web/app/components/datasets/documents/detail/completed/child-segment-list.tsx
index b4286c16d2e..99f8928e249 100644
--- a/web/app/components/datasets/documents/detail/completed/child-segment-list.tsx
+++ b/web/app/components/datasets/documents/detail/completed/child-segment-list.tsx
@@ -1,5 +1,5 @@
+import type { ChildChunkResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { ChildChunkDetail } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
import { RiArrowDownSLine, RiArrowRightSLine } from '@remixicon/react'
@@ -15,13 +15,13 @@ import { useSegmentListContext } from './index'
import FullDocListSkeleton from './skeleton/full-doc-list-skeleton'
type IChildSegmentCardProps = {
- childChunks: ChildChunkDetail[]
+ childChunks: ChildChunkResponse[]
parentChunkId: string
handleInputChange?: (value: string) => void
handleAddNewChildChunk?: (parentChunkId: string) => void
enabled: boolean
onDelete?: (segId: string, childChunkId: string) => Promise<void>
- onClickSlice?: (childChunk: ChildChunkDetail) => void
+ onClickSlice?: (childChunk: ChildChunkResponse) => void
total?: number
inputValue?: string
onClearFilter?: () => void
@@ -107,7 +107,7 @@ const ChildSegmentList: FC<IChildSegmentCardProps> = ({
return <Icon className={cn('mr-0.5 size-4 text-text-secondary', collapsed && 'opacity-50')} />
}
- const renderChildChunkItem = (childChunk: ChildChunkDetail) => {
+ const renderChildChunkItem = (childChunk: ChildChunkResponse) => {
const isEdited = childChunk.updated_at !== childChunk.created_at
const isFocused = currChildChunk?.childChunkInfo?.id === childChunk.id
const label = isEdited
diff --git a/web/app/components/datasets/documents/detail/completed/common/keywords.tsx b/web/app/components/datasets/documents/detail/completed/common/keywords.tsx
index 32405fc6362..8bc249bbb07 100644
--- a/web/app/components/datasets/documents/detail/completed/common/keywords.tsx
+++ b/web/app/components/datasets/documents/detail/completed/common/keywords.tsx
@@ -1,12 +1,12 @@
+import type { SegmentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { SegmentDetailModel } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import TagInput from '@/app/components/base/tag-input'
type IKeywordsProps = {
- segInfo?: Partial<SegmentDetailModel> & { id: string }
+ segInfo?: Partial<SegmentResponse> & { id: string }
className?: string
keywords: string[]
onKeywordsChange: (keywords: string[]) => void
diff --git a/web/app/components/datasets/documents/detail/completed/components/drawer-group.tsx b/web/app/components/datasets/documents/detail/completed/components/drawer-group.tsx
index d79433e0ff6..9f227c4b094 100644
--- a/web/app/components/datasets/documents/detail/completed/components/drawer-group.tsx
+++ b/web/app/components/datasets/documents/detail/completed/components/drawer-group.tsx
@@ -1,6 +1,10 @@
'use client'
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { FileEntity } from '@/app/components/datasets/common/image-uploader/types'
-import type { ChildChunkDetail, ChunkingMode, SegmentDetailModel } from '@/models/datasets'
+import type { ChunkingMode } from '@/models/datasets'
import NewSegment from '@/app/components/datasets/documents/detail/new-segment'
import ChildSegmentDetail from '../child-segment-detail'
import { DocumentDetailDrawer } from '../common/full-screen-drawer'
@@ -9,7 +13,7 @@ import { SegmentDetail } from '../segment-detail'
type DrawerGroupProps = {
currSegment: {
- segInfo?: SegmentDetailModel
+ segInfo?: SegmentResponse
showModal: boolean
isEditMode?: boolean
}
@@ -28,7 +32,7 @@ type DrawerGroupProps = {
onSaveNewSegment: () => void
viewNewlyAddedChunk: () => void
currChildChunk: {
- childChunkInfo?: ChildChunkDetail
+ childChunkInfo?: ChildChunkResponse
showModal: boolean
}
currChunkId: string
@@ -36,7 +40,7 @@ type DrawerGroupProps = {
onUpdateChildChunk: (segmentId: string, childChunkId: string, content: string) => Promise<void>
showNewChildSegmentModal: boolean
onCloseNewChildChunkModal: () => void
- onSaveNewChildChunk: (newChildChunk?: ChildChunkDetail) => void
+ onSaveNewChildChunk: (newChildChunk?: ChildChunkResponse) => void
viewNewlyAddedChildChunk: () => void
fullScreen: boolean
docForm: ChunkingMode
diff --git a/web/app/components/datasets/documents/detail/completed/components/segment-list-content.tsx b/web/app/components/datasets/documents/detail/completed/components/segment-list-content.tsx
index 96e001a59d6..9fc1c62b18d 100644
--- a/web/app/components/datasets/documents/detail/completed/components/segment-list-content.tsx
+++ b/web/app/components/datasets/documents/detail/completed/components/segment-list-content.tsx
@@ -1,22 +1,25 @@
'use client'
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import ChildSegmentList from '../child-segment-list'
import SegmentCard from '../segment-card'
import SegmentList from '../segment-list'
type FullDocModeContentProps = {
- segments: SegmentDetailModel[]
- childSegments: ChildChunkDetail[]
+ segments: SegmentResponse[]
+ childSegments: ChildChunkResponse[]
isLoadingSegmentList: boolean
isLoadingChildSegmentList: boolean
currSegmentId?: string
- onClickCard: (detail: SegmentDetailModel, isEditMode?: boolean) => void
+ onClickCard: (detail: SegmentResponse, isEditMode?: boolean) => void
onDeleteChildChunk: (segmentId: string, childChunkId: string) => Promise<void>
handleInputChange: (value: string) => void
handleAddNewChildChunk: (parentChunkId: string) => void
- onClickSlice: (detail: ChildChunkDetail) => void
+ onClickSlice: (detail: ChildChunkResponse) => void
archived?: boolean
childChunkTotal: number
inputValue: string
@@ -78,14 +81,14 @@ type GeneralModeContentProps = {
segmentListRef: React.RefObject<HTMLDivElement | null>
embeddingAvailable: boolean
isLoadingSegmentList: boolean
- segments: SegmentDetailModel[]
+ segments: SegmentResponse[]
onChangeSwitch: (enable: boolean, segId?: string) => Promise<void>
onDelete: (segId?: string) => Promise<void>
- onClickCard: (detail: SegmentDetailModel, isEditMode?: boolean) => void
+ onClickCard: (detail: SegmentResponse, isEditMode?: boolean) => void
archived?: boolean
onDeleteChildChunk: (segmentId: string, childChunkId: string) => Promise<void>
handleAddNewChildChunk: (parentChunkId: string) => void
- onClickSlice: (detail: ChildChunkDetail) => void
+ onClickSlice: (detail: ChildChunkResponse) => void
onClearFilter: () => void
}
diff --git a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts
index 036ebf35ea8..a5604deeb89 100644
--- a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts
+++ b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-child-segment-data.spec.ts
@@ -1,11 +1,10 @@
-import type { DocumentContextValue } from '@/app/components/datasets/documents/detail/context'
import type {
- ChildChunkDetail,
- ChildSegmentsResponse,
- ChunkingMode,
- ParentMode,
- SegmentDetailModel,
-} from '@/models/datasets'
+ ChildChunkListResponse,
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
+import type { DocumentContextValue } from '@/app/components/datasets/documents/detail/context'
+import type { ChunkingMode, ParentMode } from '@/models/datasets'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { act, renderHook } from '@testing-library/react'
import * as React from 'react'
@@ -13,7 +12,7 @@ import { consoleQuery } from '@/service/console'
import { useChildSegmentData } from '../use-child-segment-data'
// Type for mutation callbacks
-type MutationResponse = { data: ChildChunkDetail }
+type MutationResponse = { data: ChildChunkResponse }
type MutationCallbacks = {
onSuccess: (res: MutationResponse) => void
onSettled: () => void
@@ -40,8 +39,8 @@ const {
mockEventEmitter: { emit: vi.fn(), on: vi.fn(), off: vi.fn() },
mockQueryClient: { setQueryData: vi.fn(), invalidateQueries: vi.fn() },
mockChildSegmentListData: {
- current: { data: [] as ChildChunkDetail[], total: 0, total_pages: 0 } as
- | ChildSegmentsResponse
+ current: { data: [] as ChildChunkResponse[], total: 0, total_pages: 0 } as
+ | ChildChunkListResponse
| undefined,
},
mockDeleteChildSegment: vi.fn(),
@@ -113,7 +112,7 @@ const createWrapper = () => {
React.createElement(QueryClientProvider, { client: queryClient }, children)
}
-const createMockChildChunk = (overrides: Partial<ChildChunkDetail> = {}): ChildChunkDetail => ({
+const createMockChildChunk = (overrides: Partial<ChildChunkResponse> = {}): ChildChunkResponse => ({
id: `child-${Math.random().toString(36).substr(2, 9)}`,
position: 1,
segment_id: 'segment-1',
@@ -125,7 +124,7 @@ const createMockChildChunk = (overrides: Partial<ChildChunkDetail> = {}): ChildC
...overrides,
})
-const createMockSegment = (overrides: Partial<SegmentDetailModel> = {}): SegmentDetailModel => ({
+const createMockSegment = (overrides: Partial<SegmentResponse> = {}): SegmentResponse => ({
id: 'segment-1',
position: 1,
document_id: 'doc-1',
@@ -160,7 +159,7 @@ const defaultOptions = {
searchValue: '',
currentPage: 1,
limit: 10,
- segments: [createMockSegment()] as SegmentDetailModel[],
+ segments: [createMockSegment()] as SegmentResponse[],
currChunkId: 'segment-1',
isFullDocMode: true,
onCloseChildSegmentDetail: vi.fn(),
@@ -665,7 +664,7 @@ describe('useChildSegmentData', () => {
],
total: 2,
total_pages: 1,
- }) as ChildSegmentsResponse
+ }) as ChildChunkListResponse
expect(resultWithData.data[0]!.content).toBe('new content')
expect(resultWithData.data[1]!.content).toBe('other')
}
diff --git a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-modal-state.spec.ts b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-modal-state.spec.ts
index c9f0c0cbd6a..0c5b821e238 100644
--- a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-modal-state.spec.ts
+++ b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-modal-state.spec.ts
@@ -1,4 +1,7 @@
-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { act, renderHook } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import * as modalStateHooks from '../use-modal-state'
@@ -27,7 +30,7 @@ describe('useModalState', () => {
it('should open segment detail on card click', () => {
const { result } = renderModalState()
- const detail = { id: 'seg-1', content: 'test' } as unknown as SegmentDetailModel
+ const detail = { id: 'seg-1', content: 'test' } as unknown as SegmentResponse
act(() => {
result.current.onClickCard(detail, true)
@@ -40,8 +43,8 @@ describe('useModalState', () => {
it('should close child detail when opening segment detail', () => {
const { result } = renderModalState()
- const childDetail = { id: 'child-1', segment_id: 'seg-1' } as unknown as ChildChunkDetail
- const segmentDetail = { id: 'seg-1' } as unknown as SegmentDetailModel
+ const childDetail = { id: 'child-1', segment_id: 'seg-1' } as unknown as ChildChunkResponse
+ const segmentDetail = { id: 'seg-1' } as unknown as SegmentResponse
act(() => {
result.current.onClickSlice(childDetail)
@@ -59,7 +62,7 @@ describe('useModalState', () => {
const { result } = renderModalState()
act(() => {
- result.current.onClickCard({ id: 'seg-1' } as unknown as SegmentDetailModel)
+ result.current.onClickCard({ id: 'seg-1' } as unknown as SegmentResponse)
})
act(() => {
result.current.setFullScreen(true)
@@ -74,7 +77,7 @@ describe('useModalState', () => {
it('should open child segment detail on slice click', () => {
const { result } = renderModalState()
- const childDetail = { id: 'child-1', segment_id: 'seg-1' } as unknown as ChildChunkDetail
+ const childDetail = { id: 'child-1', segment_id: 'seg-1' } as unknown as ChildChunkResponse
act(() => {
result.current.onClickSlice(childDetail)
@@ -87,8 +90,8 @@ describe('useModalState', () => {
it('should close segment detail when opening child detail', () => {
const { result } = renderModalState()
- const segmentDetail = { id: 'seg-1' } as unknown as SegmentDetailModel
- const childDetail = { id: 'child-1', segment_id: 'seg-1' } as unknown as ChildChunkDetail
+ const segmentDetail = { id: 'seg-1' } as unknown as SegmentResponse
+ const childDetail = { id: 'child-1', segment_id: 'seg-1' } as unknown as ChildChunkResponse
act(() => {
result.current.onClickCard(segmentDetail)
@@ -106,7 +109,7 @@ describe('useModalState', () => {
const { result } = renderModalState()
act(() => {
- result.current.onClickSlice({ id: 'c1', segment_id: 's1' } as unknown as ChildChunkDetail)
+ result.current.onClickSlice({ id: 'c1', segment_id: 's1' } as unknown as ChildChunkResponse)
})
act(() => {
result.current.onCloseChildSegmentDetail()
diff --git a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts
index eff3a316c65..6703473abed 100644
--- a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts
+++ b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts
@@ -1,11 +1,10 @@
+import type {
+ ConsoleSegmentListResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { FileEntity } from '@/app/components/datasets/common/image-uploader/types'
import type { DocumentContextValue } from '@/app/components/datasets/documents/detail/context'
-import type {
- ChunkingMode,
- ParentMode,
- SegmentDetailModel,
- SegmentsResponse,
-} from '@/models/datasets'
+import type { ChunkingMode, ParentMode } from '@/models/datasets'
import type { SegmentImportStatus } from '@/types/dataset'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { act, renderHook } from '@testing-library/react'
@@ -16,7 +15,7 @@ import { segmentImportStatus } from '@/types/dataset'
import { useSegmentListData } from '../use-segment-list-data'
// Type for mutation callbacks
-type SegmentMutationResponse = { data: SegmentDetailModel }
+type SegmentMutationResponse = { data: SegmentResponse }
type SegmentMutationCallbacks = {
onSuccess: (res: SegmentMutationResponse) => void
onSettled: () => void
@@ -61,12 +60,12 @@ const {
mockQueryClient: { setQueryData: vi.fn(), invalidateQueries: vi.fn() },
mockSegmentListData: {
current: {
- data: [] as SegmentDetailModel[],
+ data: [] as SegmentResponse[],
total: 0,
total_pages: 0,
limit: 20,
page: 1,
- } as SegmentsResponse | undefined,
+ } as ConsoleSegmentListResponse | undefined,
},
mockEnableSegment: vi.fn(),
mockDisableSegment: vi.fn(),
@@ -154,7 +153,7 @@ const createWrapper = () => {
React.createElement(QueryClientProvider, { client: queryClient }, children)
}
-const createMockSegment = (overrides: Partial<SegmentDetailModel> = {}): SegmentDetailModel => ({
+const createMockSegment = (overrides: Partial<SegmentResponse> = {}): SegmentResponse => ({
id: `segment-${Math.random().toString(36).substr(2, 9)}`,
position: 1,
document_id: 'doc-1',
diff --git a/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts b/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts
index 068e97cdf5e..2b0f1bc20df 100644
--- a/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts
+++ b/web/app/components/datasets/documents/detail/completed/hooks/use-child-segment-data.ts
@@ -1,9 +1,9 @@
import type {
- ChildChunkDetail,
- ChildSegmentsResponse,
- SegmentDetailModel,
- SegmentUpdater,
-} from '@/models/datasets'
+ ChildChunkListResponse,
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
+import type { SegmentUpdater } from '@/models/datasets'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useCallback, useEffect, useMemo, useRef } from 'react'
import { useTranslation } from 'react-i18next'
@@ -16,20 +16,20 @@ type UseChildSegmentDataOptions = {
searchValue: string
currentPage: number
limit: number
- segments: SegmentDetailModel[]
+ segments: SegmentResponse[]
currChunkId: string
isFullDocMode: boolean
onCloseChildSegmentDetail: () => void
refreshChunkListDataWithDetailChanged: () => void
updateSegmentInCache: (
segmentId: string,
- updater: (seg: SegmentDetailModel) => SegmentDetailModel,
+ updater: (seg: SegmentResponse) => SegmentResponse,
) => void
}
type UseChildSegmentDataReturn = {
- childSegments: ChildChunkDetail[]
+ childSegments: ChildChunkResponse[]
isLoadingChildSegmentList: boolean
- childChunkListData: ChildSegmentsResponse | undefined
+ childChunkListData: ChildChunkListResponse | undefined
childSegmentListRef: React.RefObject<HTMLDivElement | null>
needScrollToBottom: React.RefObject<boolean>
// Operations
@@ -39,7 +39,7 @@ type UseChildSegmentDataReturn = {
childChunkId: string,
content: string,
) => Promise<void>
- onSaveNewChildChunk: (newChildChunk?: ChildChunkDetail) => void
+ onSaveNewChildChunk: (newChildChunk?: ChildChunkResponse) => void
resetChildList: () => void
viewNewlyAddedChildChunk: () => void
}
@@ -114,8 +114,8 @@ export const useChildSegmentData = (
}, [invalidChildSegmentList])
// Optimistic update helper for child segments
const updateChildSegmentInCache = useCallback(
- (childChunkId: string, updater: (chunk: ChildChunkDetail) => ChildChunkDetail) => {
- queryClient.setQueryData<ChildSegmentsResponse>(currentQueryKey, (old) => {
+ (childChunkId: string, updater: (chunk: ChildChunkResponse) => ChildChunkResponse) => {
+ queryClient.setQueryData<ChildChunkListResponse>(currentQueryKey, (old) => {
if (!old) return old
return {
...old,
@@ -241,7 +241,7 @@ export const useChildSegmentData = (
],
)
const onSaveNewChildChunk = useCallback(
- (newChildChunk?: ChildChunkDetail) => {
+ (newChildChunk?: ChildChunkResponse) => {
if (parentMode === 'paragraph') {
// Update parent segment's child_chunks in cache
updateSegmentInCache(currChunkId, (seg) => ({
diff --git a/web/app/components/datasets/documents/detail/completed/hooks/use-modal-state.ts b/web/app/components/datasets/documents/detail/completed/hooks/use-modal-state.ts
index 83081bfc07c..cdc4472d0de 100644
--- a/web/app/components/datasets/documents/detail/completed/hooks/use-modal-state.ts
+++ b/web/app/components/datasets/documents/detail/completed/hooks/use-modal-state.ts
@@ -1,24 +1,27 @@
-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { useCallback, useState } from 'react'
type CurrSegmentType = {
- segInfo?: SegmentDetailModel
+ segInfo?: SegmentResponse
showModal: boolean
isEditMode?: boolean
}
type CurrChildChunkType = {
- childChunkInfo?: ChildChunkDetail
+ childChunkInfo?: ChildChunkResponse
showModal: boolean
}
type UseModalStateReturn = {
currSegment: CurrSegmentType
- onClickCard: (detail: SegmentDetailModel, isEditMode?: boolean) => void
+ onClickCard: (detail: SegmentResponse, isEditMode?: boolean) => void
onCloseSegmentDetail: () => void
currChildChunk: CurrChildChunkType
currChunkId: string
- onClickSlice: (detail: ChildChunkDetail) => void
+ onClickSlice: (detail: ChildChunkResponse) => void
onCloseChildSegmentDetail: () => void
onCloseNewSegmentModal: () => void
showNewChildSegmentModal: boolean
@@ -45,7 +48,7 @@ export const useModalState = (options: UseModalStateOptions): UseModalStateRetur
const [fullScreen, setFullScreen] = useState(false)
const [isCollapsed, setIsCollapsed] = useState(true)
- const onClickCard = useCallback((detail: SegmentDetailModel, isEditMode = false) => {
+ const onClickCard = useCallback((detail: SegmentResponse, isEditMode = false) => {
setCurrChildChunk({ showModal: false })
setCurrSegment({ segInfo: detail, showModal: true, isEditMode })
}, [])
@@ -55,7 +58,7 @@ export const useModalState = (options: UseModalStateOptions): UseModalStateRetur
setFullScreen(false)
}, [])
- const onClickSlice = useCallback((detail: ChildChunkDetail) => {
+ const onClickSlice = useCallback((detail: ChildChunkResponse) => {
setCurrSegment({ showModal: false })
setCurrChildChunk({ childChunkInfo: detail, showModal: true })
setCurrChunkId(detail.segment_id)
diff --git a/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts b/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts
index 861f7094e9e..ba528712be4 100644
--- a/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts
+++ b/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts
@@ -1,5 +1,9 @@
+import type {
+ ConsoleSegmentListResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { FileEntity } from '@/app/components/datasets/common/image-uploader/types'
-import type { SegmentDetailModel, SegmentsResponse, SegmentUpdater } from '@/models/datasets'
+import type { SegmentUpdater } from '@/models/datasets'
import type { SegmentImportStatus } from '@/types/dataset'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useCallback, useEffect, useMemo, useRef } from 'react'
@@ -25,9 +29,9 @@ type UseSegmentListDataOptions = {
clearSelection: () => void
}
type UseSegmentListDataReturn = {
- segments: SegmentDetailModel[]
+ segments: SegmentResponse[]
isLoadingSegmentList: boolean
- segmentListData: SegmentsResponse | undefined
+ segmentListData: ConsoleSegmentListResponse | undefined
totalText: string
isFullDocMode: boolean
segmentListRef: React.RefObject<HTMLDivElement | null>
@@ -50,7 +54,7 @@ type UseSegmentListDataReturn = {
markOtherStatusListsStale: () => void
updateSegmentInCache: (
segmentId: string,
- updater: (seg: SegmentDetailModel) => SegmentDetailModel,
+ updater: (seg: SegmentResponse) => SegmentResponse,
) => void
}
export const useSegmentListData = (
@@ -151,8 +155,8 @@ export const useSegmentListData = (
}, [selectedStatus, markOtherStatusListsStale, invalidSegmentList])
// Optimistic update helper using React Query's setQueryData
const updateSegmentInCache = useCallback(
- (segmentId: string, updater: (seg: SegmentDetailModel) => SegmentDetailModel) => {
- queryClient.setQueryData<SegmentsResponse>(currentQueryKey, (old) => {
+ (segmentId: string, updater: (seg: SegmentResponse) => SegmentResponse) => {
+ queryClient.setQueryData<ConsoleSegmentListResponse>(currentQueryKey, (old) => {
if (!old) return old
return {
...old,
@@ -164,8 +168,8 @@ export const useSegmentListData = (
)
// Batch update helper
const updateSegmentsInCache = useCallback(
- (segmentIds: string[], updater: (seg: SegmentDetailModel) => SegmentDetailModel) => {
- queryClient.setQueryData<SegmentsResponse>(currentQueryKey, (old) => {
+ (segmentIds: string[], updater: (seg: SegmentResponse) => SegmentResponse) => {
+ queryClient.setQueryData<ConsoleSegmentListResponse>(currentQueryKey, (old) => {
if (!old) return old
return {
...old,
diff --git a/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx b/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx
index fb7f20463c8..9a75a169648 100644
--- a/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx
+++ b/web/app/components/datasets/documents/detail/completed/new-child-segment.tsx
@@ -1,5 +1,6 @@
+import type { ChildChunkResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { ChildChunkDetail, SegmentUpdater } from '@/models/datasets'
+import type { SegmentUpdater } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
import { RiCloseLine, RiExpandDiagonalLine } from '@remixicon/react'
@@ -22,7 +23,7 @@ import { useSegmentListContext } from './index'
type NewChildSegmentModalProps = {
chunkId: string
onCancel: () => void
- onSave: (ChildChunk?: ChildChunkDetail) => void
+ onSave: (ChildChunk?: ChildChunkResponse) => void
viewNewlyAddedChildChunk?: () => void
}
diff --git a/web/app/components/datasets/documents/detail/completed/segment-card/__tests__/index.spec.tsx b/web/app/components/datasets/documents/detail/completed/segment-card/__tests__/index.spec.tsx
index f32adf16b99..48c65f625ae 100644
--- a/web/app/components/datasets/documents/detail/completed/segment-card/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/detail/completed/segment-card/__tests__/index.spec.tsx
@@ -1,11 +1,10 @@
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { SegmentListContextValue } from '@/app/components/datasets/documents/detail/completed'
import type { DocumentContextValue } from '@/app/components/datasets/documents/detail/context'
-import type {
- Attachment,
- ChildChunkDetail,
- ParentMode,
- SegmentDetailModel,
-} from '@/models/datasets'
+import type { Attachment, ParentMode } from '@/models/datasets'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
@@ -107,7 +106,7 @@ const createMockAttachment = (overrides: Partial<Attachment> = {}): Attachment =
...overrides,
})
-const createMockChildChunk = (overrides: Partial<ChildChunkDetail> = {}): ChildChunkDetail => ({
+const createMockChildChunk = (overrides: Partial<ChildChunkResponse> = {}): ChildChunkResponse => ({
id: 'child-chunk-1',
position: 1,
segment_id: 'segment-1',
@@ -120,8 +119,8 @@ const createMockChildChunk = (overrides: Partial<ChildChunkDetail> = {}): ChildC
})
const createMockSegmentDetail = (
- overrides: Partial<SegmentDetailModel & { document?: { name: string } }> = {},
-): SegmentDetailModel & { document?: { name: string } } => ({
+ overrides: Partial<SegmentResponse & { document?: { name: string } }> = {},
+): SegmentResponse & { document?: { name: string } } => ({
id: 'segment-1',
position: 1,
document_id: 'doc-1',
@@ -819,7 +818,7 @@ describe('SegmentCard', () => {
it('should handle empty detail object gracefully', () => {
render(
- <SegmentCard loading={false} detail={{} as SegmentDetailModel} focused={defaultFocused} />,
+ <SegmentCard loading={false} detail={{} as SegmentResponse} focused={defaultFocused} />,
)
expect(screen.getByText(/Chunk/i)).toBeInTheDocument()
diff --git a/web/app/components/datasets/documents/detail/completed/segment-card/index.tsx b/web/app/components/datasets/documents/detail/completed/segment-card/index.tsx
index 0870dfaea24..3dbc575f722 100644
--- a/web/app/components/datasets/documents/detail/completed/segment-card/index.tsx
+++ b/web/app/components/datasets/documents/detail/completed/segment-card/index.tsx
@@ -1,5 +1,8 @@
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -34,13 +37,13 @@ import ChunkContent from './chunk-content'
type ISegmentCardProps = {
loading: boolean
- detail?: SegmentDetailModel & { document?: { name: string }; status?: string }
+ detail?: SegmentResponse & { document?: { name: string }; status?: string }
onClick?: () => void
onChangeSwitch?: (enabled: boolean, segId?: string) => Promise<void>
onDelete?: (segId: string) => Promise<void>
onDeleteChildChunk?: (segId: string, childChunkId: string) => Promise<void>
handleAddNewChildChunk?: (parentChunkId: string) => void
- onClickSlice?: (childChunk: ChildChunkDetail) => void
+ onClickSlice?: (childChunk: ChildChunkResponse) => void
onClickEdit?: () => void
className?: string
archived?: boolean
diff --git a/web/app/components/datasets/documents/detail/completed/segment-detail.tsx b/web/app/components/datasets/documents/detail/completed/segment-detail.tsx
index 8de69e65382..38d9eff3bf7 100644
--- a/web/app/components/datasets/documents/detail/completed/segment-detail.tsx
+++ b/web/app/components/datasets/documents/detail/completed/segment-detail.tsx
@@ -1,5 +1,5 @@
+import type { SegmentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FileEntity } from '@/app/components/datasets/common/image-uploader/types'
-import type { SegmentDetailModel } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
import { RiCloseLine, RiCollapseDiagonalLine, RiExpandDiagonalLine } from '@remixicon/react'
@@ -23,7 +23,7 @@ import SummaryText from './common/summary-text'
import { useSegmentListContext } from './index'
type ISegmentDetailProps = {
- segInfo?: Partial<SegmentDetailModel> & { id: string }
+ segInfo?: Partial<SegmentResponse> & { id: string }
onUpdate: (
segmentId: string,
q: string,
diff --git a/web/app/components/datasets/documents/detail/completed/segment-list-context.ts b/web/app/components/datasets/documents/detail/completed/segment-list-context.ts
index b81a3056147..6f35d95fc6d 100644
--- a/web/app/components/datasets/documents/detail/completed/segment-list-context.ts
+++ b/web/app/components/datasets/documents/detail/completed/segment-list-context.ts
@@ -1,15 +1,18 @@
-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { noop } from 'es-toolkit/function'
import { createContext, useContextSelector } from 'use-context-selector'
type CurrSegmentType = {
- segInfo?: SegmentDetailModel
+ segInfo?: SegmentResponse
showModal: boolean
isEditMode?: boolean
}
type CurrChildChunkType = {
- childChunkInfo?: ChildChunkDetail
+ childChunkInfo?: ChildChunkResponse
showModal: boolean
}
diff --git a/web/app/components/datasets/documents/detail/completed/segment-list.tsx b/web/app/components/datasets/documents/detail/completed/segment-list.tsx
index 46e81ceee7c..76e94a9cc53 100644
--- a/web/app/components/datasets/documents/detail/completed/segment-list.tsx
+++ b/web/app/components/datasets/documents/detail/completed/segment-list.tsx
@@ -1,4 +1,7 @@
-import type { ChildChunkDetail, SegmentDetailModel } from '@/models/datasets'
+import type {
+ ChildChunkResponse,
+ SegmentResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { Separator } from '@langgenius/dify-ui/separator'
import * as React from 'react'
@@ -14,13 +17,13 @@ import ParagraphListSkeleton from './skeleton/paragraph-list-skeleton'
type ISegmentListProps = {
isLoading: boolean
- items: SegmentDetailModel[]
- onClick: (detail: SegmentDetailModel, isEditMode?: boolean) => void
+ items: SegmentResponse[]
+ onClick: (detail: SegmentResponse, isEditMode?: boolean) => void
onChangeSwitch: (enabled: boolean, segId?: string) => Promise<void>
onDelete: (segId: string) => Promise<void>
onDeleteChildChunk: (sgId: string, childChunkId: string) => Promise<void>
handleAddNewChildChunk: (parentChunkId: string) => void
- onClickSlice: (childChunk: ChildChunkDetail) => void
+ onClickSlice: (childChunk: ChildChunkResponse) => void
archived?: boolean
embeddingAvailable: boolean
onClearFilter: () => void
diff --git a/web/app/components/datasets/documents/detail/embedding/__tests__/index.spec.tsx b/web/app/components/datasets/documents/detail/embedding/__tests__/index.spec.tsx
index 0ce9cd9d972..df17f0f22e8 100644
--- a/web/app/components/datasets/documents/detail/embedding/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/documents/detail/embedding/__tests__/index.spec.tsx
@@ -1,6 +1,9 @@
+import type {
+ DocumentStatusResponse,
+ ProcessRuleResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactNode } from 'react'
import type { DocumentContextValue } from '../../context'
-import type { IndexingStatusResponse, ProcessRuleResponse } from '@/models/datasets'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -63,8 +66,8 @@ const createWrapper = (
}
const mockIndexingStatus = (
- overrides: Partial<IndexingStatusResponse> = {},
-): IndexingStatusResponse => ({
+ overrides: Partial<DocumentStatusResponse> = {},
+): DocumentStatusResponse => ({
id: 'doc1',
indexing_status: 'indexing',
completed_segments: 50,
diff --git a/web/app/components/datasets/documents/detail/embedding/components/rule-detail.tsx b/web/app/components/datasets/documents/detail/embedding/components/rule-detail.tsx
index b7a04954c80..15708e72343 100644
--- a/web/app/components/datasets/documents/detail/embedding/components/rule-detail.tsx
+++ b/web/app/components/datasets/documents/detail/embedding/components/rule-detail.tsx
@@ -1,5 +1,5 @@
+import type { ProcessRuleResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { ProcessRuleResponse } from '@/models/datasets'
import type { RETRIEVE_METHOD } from '@/types/app'
import { Separator } from '@langgenius/dify-ui/separator'
import * as React from 'react'
diff --git a/web/app/components/datasets/documents/detail/embedding/hooks/__tests__/use-embedding-status.spec.tsx b/web/app/components/datasets/documents/detail/embedding/hooks/__tests__/use-embedding-status.spec.tsx
index 3e379ccfaf7..c41a1e6c689 100644
--- a/web/app/components/datasets/documents/detail/embedding/hooks/__tests__/use-embedding-status.spec.tsx
+++ b/web/app/components/datasets/documents/detail/embedding/hooks/__tests__/use-embedding-status.spec.tsx
@@ -1,5 +1,5 @@
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactNode } from 'react'
-import type { IndexingStatusResponse } from '@/models/datasets'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { act, renderHook, waitFor } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -35,8 +35,8 @@ const createWrapper = () => {
}
const mockIndexingStatus = (
- overrides: Partial<IndexingStatusResponse> = {},
-): IndexingStatusResponse => ({
+ overrides: Partial<DocumentStatusResponse> = {},
+): DocumentStatusResponse => ({
id: 'doc1',
indexing_status: 'indexing',
completed_segments: 50,
diff --git a/web/app/components/datasets/documents/detail/embedding/hooks/use-embedding-status.ts b/web/app/components/datasets/documents/detail/embedding/hooks/use-embedding-status.ts
index 0deec51d98e..5459b86279b 100644
--- a/web/app/components/datasets/documents/detail/embedding/hooks/use-embedding-status.ts
+++ b/web/app/components/datasets/documents/detail/embedding/hooks/use-embedding-status.ts
@@ -1,4 +1,4 @@
-import type { IndexingStatusResponse } from '@/models/datasets'
+import type { DocumentStatusResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useCallback, useEffect, useMemo, useRef } from 'react'
import { fetchIndexingStatus, pauseDocIndexing, resumeDocIndexing } from '@/service/datasets'
@@ -48,7 +48,7 @@ export const useEmbeddingStatus = ({
[datasetId, documentId],
)
- const query = useQuery<IndexingStatusResponse>({
+ const query = useQuery<DocumentStatusResponse>({
queryKey,
queryFn: () => fetchIndexingStatus({ datasetId: datasetId!, documentId: documentId! }),
enabled: enabled && !!datasetId && !!documentId,
diff --git a/web/app/components/datasets/documents/detail/index.tsx b/web/app/components/datasets/documents/detail/index.tsx
index e91396689f5..e8a138b1422 100644
--- a/web/app/components/datasets/documents/detail/index.tsx
+++ b/web/app/components/datasets/documents/detail/index.tsx
@@ -1,7 +1,8 @@
'use client'
+import type { DocumentDetailResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { FileItem, FullDocumentDetail } from '@/models/datasets'
+import type { FileItem } from '@/models/datasets'
import type { SegmentImportStatus } from '@/types/dataset'
import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
@@ -266,7 +267,7 @@ const DocumentDetail: FC<DocumentDetailProps> = ({ datasetId, documentId }) => {
],
)
- const docDetail = useMemo((): FullDocumentDetail | undefined => {
+ const docDetail = useMemo((): DocumentDetailResponse | undefined => {
if (!documentDetail) return undefined
return {
...documentDetail,
diff --git a/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx b/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx
index 0e39765dbd5..da33e315001 100644
--- a/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx
+++ b/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx
@@ -1,5 +1,6 @@
+import type { IndexingEstimateResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { NotionPage } from '@/models/common'
-import type { CrawlResultItem, CustomFile, FileIndexingEstimateResponse } from '@/models/datasets'
+import type { CrawlResultItem, CustomFile } from '@/models/datasets'
import type { OnlineDriveFile } from '@/models/pipeline'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { noop } from 'es-toolkit/function'
@@ -28,9 +29,7 @@ type PipelineSettingsProps = {
const PipelineSettings = ({ datasetId, documentId }: PipelineSettingsProps) => {
const { t } = useTranslation(['datasetCreation', 'datasetPipeline'])
const { push } = useRouter()
- const [estimateData, setEstimateData] = useState<FileIndexingEstimateResponse | undefined>(
- undefined,
- )
+ const [estimateData, setEstimateData] = useState<IndexingEstimateResponse | undefined>(undefined)
const pipelineId = useDatasetDetailContextWithSelector((state) => state.dataset?.pipeline_id)
const isPreview = useRef(false)
diff --git a/web/app/components/datasets/external-api/external-api-modal/index.tsx b/web/app/components/datasets/external-api/external-api-modal/index.tsx
index 87953f313c0..d971cbe1c22 100644
--- a/web/app/components/datasets/external-api/external-api-modal/index.tsx
+++ b/web/app/components/datasets/external-api/external-api-modal/index.tsx
@@ -1,6 +1,6 @@
+import type { ExternalKnowledgeApiResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
import type { CreateExternalAPIReq, FormSchema } from '../declarations'
-import type { ExternalAPIItem } from '@/models/datasets'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -23,7 +23,7 @@ import Form from './Form'
type AddExternalAPIModalProps = {
data?: CreateExternalAPIReq
- onSave: (api: ExternalAPIItem) => void
+ onSave: (api: ExternalKnowledgeApiResponse) => void
onCancel: () => void
onEdit?: (formValue: CreateExternalAPIReq) => Promise<void>
datasetBindings?: {
diff --git a/web/app/components/datasets/external-api/external-knowledge-api-card/__tests__/index.spec.tsx b/web/app/components/datasets/external-api/external-knowledge-api-card/__tests__/index.spec.tsx
index 95dd57b4126..834fff58a9a 100644
--- a/web/app/components/datasets/external-api/external-knowledge-api-card/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/external-api/external-knowledge-api-card/__tests__/index.spec.tsx
@@ -1,5 +1,4 @@
import type { ExternalKnowledgeApiResponse } from '@dify/contracts/api/console/datasets/types.gen'
-import type { ExternalAPIItem } from '@/models/datasets'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
// Import mocked services
@@ -134,7 +133,7 @@ describe('ExternalKnowledgeAPICard', () => {
describe('User Interactions - Edit', () => {
it('should fetch API details and open modal when edit button is clicked', async () => {
- const mockResponse: ExternalAPIItem = {
+ const mockResponse: ExternalKnowledgeApiResponse = {
id: 'api-123',
tenant_id: 'tenant-1',
name: 'Test External API',
@@ -192,7 +191,7 @@ describe('ExternalKnowledgeAPICard', () => {
})
it('should invalidate the generated list query after editing', async () => {
- const mockResponse: ExternalAPIItem = {
+ const mockResponse: ExternalKnowledgeApiResponse = {
id: 'api-123',
tenant_id: 'tenant-1',
name: 'Test External API',
@@ -241,7 +240,7 @@ describe('ExternalKnowledgeAPICard', () => {
})
it('should not refresh the list query when editing is canceled', async () => {
- const mockResponse: ExternalAPIItem = {
+ const mockResponse: ExternalKnowledgeApiResponse = {
id: 'api-123',
tenant_id: 'tenant-1',
name: 'Test External API',
diff --git a/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsx b/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsx
index 74366f7e285..4393efee395 100644
--- a/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/external-knowledge-base/connector/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { ExternalKnowledgeApiResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { Mock } from 'vite-plus/test'
-import type { ExternalAPIItem } from '@/models/datasets'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { createExternalKnowledgeBase } from '@/service/datasets'
@@ -52,7 +52,9 @@ vi.mock('@/service/datasets', () => ({
}))
// Factory function to create mock ExternalAPIItem
-const createMockExternalAPIItem = (overrides: Partial<ExternalAPIItem> = {}): ExternalAPIItem => ({
+const createMockExternalAPIItem = (
+ overrides: Partial<ExternalKnowledgeApiResponse> = {},
+): ExternalKnowledgeApiResponse => ({
id: 'api-default',
tenant_id: 'tenant-1',
name: 'Default API',
@@ -68,7 +70,7 @@ const createMockExternalAPIItem = (overrides: Partial<ExternalAPIItem> = {}): Ex
})
// Default mock API list
-const createDefaultMockApiList = (): ExternalAPIItem[] => [
+const createDefaultMockApiList = (): ExternalKnowledgeApiResponse[] => [
createMockExternalAPIItem({
id: 'api-1',
name: 'Test API 1',
@@ -81,7 +83,7 @@ const createDefaultMockApiList = (): ExternalAPIItem[] => [
}),
]
-let mockExternalKnowledgeApiList: ExternalAPIItem[] = createDefaultMockApiList()
+let mockExternalKnowledgeApiList: ExternalKnowledgeApiResponse[] = createDefaultMockApiList()
vi.mock('@tanstack/react-query', async (importOriginal) => {
const original = await importOriginal<typeof import('@tanstack/react-query')>()
diff --git a/web/app/components/datasets/external-knowledge-base/create/__tests__/index.spec.tsx b/web/app/components/datasets/external-knowledge-base/create/__tests__/index.spec.tsx
index 7e2cdfafaeb..8a63d9ef0ee 100644
--- a/web/app/components/datasets/external-knowledge-base/create/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/external-knowledge-base/create/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import type { ExternalAPIItem } from '@/models/datasets'
+import type { ExternalKnowledgeApiResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
@@ -38,7 +38,9 @@ vi.mock('@/context/modal-context', () => ({
}))
// Factory function to create mock ExternalAPIItem (following project conventions)
-const createMockExternalAPIItem = (overrides: Partial<ExternalAPIItem> = {}): ExternalAPIItem => ({
+const createMockExternalAPIItem = (
+ overrides: Partial<ExternalKnowledgeApiResponse> = {},
+): ExternalKnowledgeApiResponse => ({
id: 'api-default',
tenant_id: 'tenant-1',
name: 'Default API',
@@ -54,7 +56,7 @@ const createMockExternalAPIItem = (overrides: Partial<ExternalAPIItem> = {}): Ex
})
// Default mock API list
-const createDefaultMockApiList = (): ExternalAPIItem[] => [
+const createDefaultMockApiList = (): ExternalKnowledgeApiResponse[] => [
createMockExternalAPIItem({
id: 'api-1',
name: 'Test API 1',
@@ -69,7 +71,7 @@ const createDefaultMockApiList = (): ExternalAPIItem[] => [
const mockInvalidateQueries = vi.fn()
const externalKnowledgeApiQueryKey = ['console', 'datasets', 'externalKnowledgeApi', 'get']
-let mockExternalKnowledgeApiList: ExternalAPIItem[] = createDefaultMockApiList()
+let mockExternalKnowledgeApiList: ExternalKnowledgeApiResponse[] = createDefaultMockApiList()
vi.mock('@tanstack/react-query', async (importOriginal) => {
const original = await importOriginal<typeof import('@tanstack/react-query')>()
diff --git a/web/app/components/datasets/extra-info/__tests__/statistics.spec.tsx b/web/app/components/datasets/extra-info/__tests__/statistics.spec.tsx
index ecea7fa16e7..e0c923284ed 100644
--- a/web/app/components/datasets/extra-info/__tests__/statistics.spec.tsx
+++ b/web/app/components/datasets/extra-info/__tests__/statistics.spec.tsx
@@ -1,4 +1,4 @@
-import type { RelatedAppResponse } from '@/models/datasets'
+import type { RelatedAppListResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import Statistics from '../statistics'
@@ -17,7 +17,7 @@ describe('Statistics', () => {
<Statistics
expand
documentCount={12}
- relatedApps={{ total: 3, data: [] } as RelatedAppResponse}
+ relatedApps={{ total: 3, data: [] } as RelatedAppListResponse}
/>,
)
@@ -31,7 +31,7 @@ describe('Statistics', () => {
<Statistics
expand
documentCount={12}
- relatedApps={{ total: 1, data: [{ id: 'app-1' }] } as RelatedAppResponse}
+ relatedApps={{ total: 1, data: [{ id: 'app-1' }] } as RelatedAppListResponse}
/>,
)
diff --git a/web/app/components/datasets/extra-info/index.tsx b/web/app/components/datasets/extra-info/index.tsx
index 94aded52e60..e5fb54fe4cc 100644
--- a/web/app/components/datasets/extra-info/index.tsx
+++ b/web/app/components/datasets/extra-info/index.tsx
@@ -1,11 +1,11 @@
-import type { RelatedAppResponse } from '@/models/datasets'
+import type { RelatedAppListResponse } from '@dify/contracts/api/console/datasets/types.gen'
import * as React from 'react'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import ApiAccess from './api-access'
import Statistics from './statistics'
type IExtraInfoProps = {
- relatedApps?: RelatedAppResponse
+ relatedApps?: RelatedAppListResponse
documentCount?: number
expand: boolean
}
diff --git a/web/app/components/datasets/extra-info/statistics.tsx b/web/app/components/datasets/extra-info/statistics.tsx
index 524029bcff7..079ca211f97 100644
--- a/web/app/components/datasets/extra-info/statistics.tsx
+++ b/web/app/components/datasets/extra-info/statistics.tsx
@@ -1,4 +1,4 @@
-import type { RelatedAppResponse } from '@/models/datasets'
+import type { RelatedAppListResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { RiInformation2Line } from '@remixicon/react'
import * as React from 'react'
@@ -9,7 +9,7 @@ import NoLinkedAppsPanel from '../no-linked-apps-panel'
type StatisticsProps = {
expand: boolean
documentCount?: number
- relatedApps?: RelatedAppResponse
+ relatedApps?: RelatedAppListResponse
}
const Statistics = ({ expand, documentCount, relatedApps }: StatisticsProps) => {
diff --git a/web/app/components/datasets/hit-testing/__tests__/index.spec.tsx b/web/app/components/datasets/hit-testing/__tests__/index.spec.tsx
index 6b4695b4eed..956f75bc796 100644
--- a/web/app/components/datasets/hit-testing/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/hit-testing/__tests__/index.spec.tsx
@@ -1,7 +1,12 @@
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetQueryDetailResponse,
+ HitTestingRecord,
+ HitTestingResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { GetWorkspacesCurrentModelsModelTypesByModelTypeData } from '@dify/contracts/api/console/workspaces/types.gen'
import type { OperationKey } from '@orpc/tanstack-query'
import type { ReactNode } from 'react'
-import type { DataSet, HitTesting, HitTestingRecord, HitTestingResponse } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { screen, waitFor, within } from '@testing-library/react'
@@ -104,7 +109,7 @@ const mockDataset = {
},
is_multimodal: false,
permission_keys: ['dataset.acl.retrieval_recall'],
-} as Partial<DataSet>
+} as Partial<DatasetDetailWithPartialMembersResponse>
let mockConsoleState = {
userProfile: { id: 'user-1' },
@@ -123,7 +128,7 @@ vi.mock('@/context/dataset-detail', () => ({
useDatasetDetailContext: vi.fn(() => ({ dataset: mockDataset })),
useDatasetDetailContextWithSelector: vi.fn(
(selector: (v: { dataset?: typeof mockDataset }) => unknown) =>
- selector({ dataset: mockDataset as DataSet }),
+ selector({ dataset: mockDataset as DatasetDetailWithPartialMembersResponse }),
),
}))
@@ -322,13 +327,13 @@ const createMockSegment = (overrides = {}) => ({
...overrides,
})
-const createMockHitTesting = (overrides = {}): HitTesting => ({
+const createMockHitTesting = (overrides = {}): HitTestingRecord => ({
...createHitTestingRecordFixture(),
- segment: createMockSegment() as HitTesting['segment'],
+ segment: createMockSegment() as HitTestingRecord['segment'],
...overrides,
})
-const createMockRecord = (overrides = {}): HitTestingRecord => ({
+const createMockRecord = (overrides = {}): DatasetQueryDetailResponse => ({
id: 'record-1',
source: 'hit_testing',
source_app_id: 'app-1',
diff --git a/web/app/components/datasets/hit-testing/components/__tests__/chunk-detail-dialog.spec.tsx b/web/app/components/datasets/hit-testing/components/__tests__/chunk-detail-dialog.spec.tsx
index a3d5c35b069..a4b6619bb8d 100644
--- a/web/app/components/datasets/hit-testing/components/__tests__/chunk-detail-dialog.spec.tsx
+++ b/web/app/components/datasets/hit-testing/components/__tests__/chunk-detail-dialog.spec.tsx
@@ -1,4 +1,4 @@
-import type { HitTesting } from '@/models/datasets'
+import type { HitTestingRecord } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { describe, expect, it } from 'vite-plus/test'
@@ -6,10 +6,10 @@ import { createHitTestingRecordFixture } from '@/test/fixtures/hit-testing'
import { ResultItem } from '../result-item'
function makePayload(
- overrides: Partial<Omit<HitTesting, 'segment'>> & {
- segment?: Partial<HitTesting['segment']>
+ overrides: Partial<Omit<HitTestingRecord, 'segment'>> & {
+ segment?: Partial<HitTestingRecord['segment']>
} = {},
-): HitTesting {
+): HitTestingRecord {
return createHitTestingRecordFixture({
score: 0.85,
...overrides,
@@ -17,7 +17,7 @@ function makePayload(
})
}
-async function openDetail(payload: HitTesting) {
+async function openDetail(payload: HitTestingRecord) {
const user = userEvent.setup()
render(<ResultItem payload={payload} />)
await user.click(screen.getByRole('button', { name: 'datasetHitTesting.open file.pdf' }))
diff --git a/web/app/components/datasets/hit-testing/components/__tests__/records.spec.tsx b/web/app/components/datasets/hit-testing/components/__tests__/records.spec.tsx
index e2bb893705f..993c7bb8c0a 100644
--- a/web/app/components/datasets/hit-testing/components/__tests__/records.spec.tsx
+++ b/web/app/components/datasets/hit-testing/components/__tests__/records.spec.tsx
@@ -1,4 +1,4 @@
-import type { HitTestingRecord } from '@/models/datasets'
+import type { DatasetQueryDetailResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -20,7 +20,7 @@ const makeRecord = (id: string, source: string, created_at: number, content = 'q
source,
created_at,
queries: [{ content, content_type: 'text_query', file_info: null }],
- }) as unknown as HitTestingRecord
+ }) as unknown as DatasetQueryDetailResponse
describe('Records', () => {
const mockOnClick = vi.fn()
@@ -123,7 +123,7 @@ describe('Records', () => {
},
],
},
- ] as unknown as HitTestingRecord[]
+ ] as unknown as DatasetQueryDetailResponse[]
render(<Records records={records} onClickRecord={mockOnClick} />)
expect(screen.getByTestId('image-list')).toBeInTheDocument()
await user.click(screen.getByRole('button', { name: 'time-1000' }))
diff --git a/web/app/components/datasets/hit-testing/components/__tests__/result-dialogs.browser.spec.tsx b/web/app/components/datasets/hit-testing/components/__tests__/result-dialogs.browser.spec.tsx
index 54609ad7c49..83720fb40b0 100644
--- a/web/app/components/datasets/hit-testing/components/__tests__/result-dialogs.browser.spec.tsx
+++ b/web/app/components/datasets/hit-testing/components/__tests__/result-dialogs.browser.spec.tsx
@@ -1,11 +1,14 @@
-import type { ExternalKnowledgeBaseHitTesting, HitTesting } from '@/models/datasets'
+import type {
+ ExternalHitTestingRecordResponse,
+ HitTestingRecord,
+} from '@dify/contracts/api/console/datasets/types.gen'
import { page, userEvent } from 'vite-plus/test/browser'
import { render } from 'vitest-browser-react'
import { createHitTestingRecordFixture } from '@/test/fixtures/hit-testing'
import { ResultItem } from '../result-item'
import { ResultItemExternal } from '../result-item-external'
-function createResult(overrides: Partial<HitTesting> = {}): HitTesting {
+function createResult(overrides: Partial<HitTestingRecord> = {}): HitTestingRecord {
return createHitTestingRecordFixture({
score: 0.9,
...overrides,
@@ -86,7 +89,7 @@ it('opens attachments independently and nests their preview only while details a
it('keeps external details scrollable and Close reachable on a narrow viewport through keyboard and exit', async () => {
await page.viewport(414, 900)
vi.stubGlobal('BASE_UI_ANIMATIONS_DISABLED', false)
- const payload: ExternalKnowledgeBaseHitTesting = {
+ const payload: ExternalHitTestingRecordResponse = {
title: 'External handbook',
content: `${'External retrieval content. '.repeat(200)}${'unbroken'.repeat(60)}`,
score: 0.85,
diff --git a/web/app/components/datasets/hit-testing/components/__tests__/result-item-external.spec.tsx b/web/app/components/datasets/hit-testing/components/__tests__/result-item-external.spec.tsx
index 730a63ec2bd..b2b03b4dd72 100644
--- a/web/app/components/datasets/hit-testing/components/__tests__/result-item-external.spec.tsx
+++ b/web/app/components/datasets/hit-testing/components/__tests__/result-item-external.spec.tsx
@@ -1,11 +1,11 @@
-import type { ExternalKnowledgeBaseHitTesting } from '@/models/datasets'
+import type { ExternalHitTestingRecordResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { ResultItemExternal } from '../result-item-external'
const createExternalPayload = (
- overrides: Partial<ExternalKnowledgeBaseHitTesting> = {},
-): ExternalKnowledgeBaseHitTesting => ({
+ overrides: Partial<ExternalHitTestingRecordResponse> = {},
+): ExternalHitTestingRecordResponse => ({
content: 'This is the chunk content for testing.',
title: 'Test Document Title',
score: 0.85,
diff --git a/web/app/components/datasets/hit-testing/components/__tests__/result-item.spec.tsx b/web/app/components/datasets/hit-testing/components/__tests__/result-item.spec.tsx
index b056d074c34..537578cd2dc 100644
--- a/web/app/components/datasets/hit-testing/components/__tests__/result-item.spec.tsx
+++ b/web/app/components/datasets/hit-testing/components/__tests__/result-item.spec.tsx
@@ -1,4 +1,4 @@
-import type { HitTesting } from '@/models/datasets'
+import type { HitTestingRecord } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { describe, expect, it } from 'vite-plus/test'
@@ -6,10 +6,10 @@ import { createHitTestingRecordFixture } from '@/test/fixtures/hit-testing'
import { ResultItem } from '../result-item'
function makePayload(
- overrides: Partial<Omit<HitTesting, 'segment'>> & {
- segment?: Partial<HitTesting['segment']>
+ overrides: Partial<Omit<HitTestingRecord, 'segment'>> & {
+ segment?: Partial<HitTestingRecord['segment']>
} = {},
-): HitTesting {
+): HitTestingRecord {
return createHitTestingRecordFixture({
score: 0.95,
...overrides,
diff --git a/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx b/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx
index 3742c2c5b92..090ad48c2a0 100644
--- a/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx
+++ b/web/app/components/datasets/hit-testing/components/child-chunks-item.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { HitTestingChildChunk } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { HitTestingChildChunk } from '@/models/datasets'
import * as React from 'react'
import { SliceContent } from '../../formatted-text/flavours/shared'
import { Score } from './score'
diff --git a/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx b/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx
index 2a60f9eeb58..a78911a888a 100644
--- a/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx
+++ b/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { HitTestingRecord } from '@dify/contracts/api/console/datasets/types.gen'
import type { DialogProps } from '@langgenius/dify-ui/dialog'
import type { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'
-import type { HitTesting } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import {
Dialog,
@@ -29,7 +29,7 @@ import { Score } from './score'
const i18nPrefix = ''
type ChunkDetailDialogProps = Required<Pick<DialogProps, 'open' | 'onOpenChange'>> & {
- payload: HitTesting
+ payload: HitTestingRecord
}
export function ChunkDetailDialog({ payload, open, onOpenChange }: ChunkDetailDialogProps) {
diff --git a/web/app/components/datasets/hit-testing/components/query-input/__tests__/index.spec.tsx b/web/app/components/datasets/hit-testing/components/query-input/__tests__/index.spec.tsx
index 74101bf0ac9..ffda0b2cb82 100644
--- a/web/app/components/datasets/hit-testing/components/query-input/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/hit-testing/components/query-input/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { DatasetQueryContentResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FileEntity } from '@/app/components/datasets/common/image-uploader/types'
-import type { Query } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -86,7 +86,7 @@ describe('QueryInput', () => {
loading: false,
queries: [
{ content: 'test query', content_type: 'text_query', file_info: null },
- ] satisfies Query[],
+ ] satisfies DatasetQueryContentResponse[],
setQueries: vi.fn(),
isExternal: false,
onClickRetrievalMethod: vi.fn(),
@@ -158,7 +158,9 @@ describe('QueryInput', () => {
it('should disable submit button when text is empty', () => {
const props = {
...defaultProps,
- queries: [{ content: '', content_type: 'text_query', file_info: null }] satisfies Query[],
+ queries: [
+ { content: '', content_type: 'text_query', file_info: null },
+ ] satisfies DatasetQueryContentResponse[],
}
render(<QueryInput {...props} />)
expect(screen.getByRole('button', { name: /input\.testing/ }))!.toBeDisabled()
@@ -185,7 +187,7 @@ describe('QueryInput', () => {
...defaultProps,
queries: [
{ content: 'a'.repeat(201), content_type: 'text_query', file_info: null },
- ] satisfies Query[],
+ ] satisfies DatasetQueryContentResponse[],
}
render(<QueryInput {...props} />)
expect(screen.getByRole('button', { name: /input\.testing/ }))!.toBeDisabled()
@@ -201,7 +203,7 @@ describe('QueryInput', () => {
// Cover line 83: images useMemo with image_query data
describe('Image Queries', () => {
it('should parse image_query entries from queries', () => {
- const queries: Query[] = [
+ const queries: DatasetQueryContentResponse[] = [
{ content: 'test', content_type: 'text_query', file_info: null },
{
content: 'https://img.example.com/1.png',
@@ -417,7 +419,7 @@ describe('QueryInput', () => {
})
it('should replace all existing image queries with new ones', () => {
- const queries: Query[] = [
+ const queries: DatasetQueryContentResponse[] = [
{ content: 'text', content_type: 'text_query', file_info: null },
{
content: 'old-img',
@@ -441,7 +443,7 @@ describe('QueryInput', () => {
expect.arrayContaining([expect.objectContaining({ content_type: 'text_query' })]),
)
// Should not contain image_query
- const calledWith = defaultProps.setQueries.mock.calls[0]![0] as Query[]
+ const calledWith = defaultProps.setQueries.mock.calls[0]![0] as DatasetQueryContentResponse[]
expect(calledWith.filter((q) => q.content_type === 'image_query')).toHaveLength(0)
})
})
@@ -548,7 +550,7 @@ describe('QueryInput', () => {
})
it('should include image attachment_ids in submit request', async () => {
- const queries: Query[] = [
+ const queries: DatasetQueryContentResponse[] = [
{ content: 'test', content_type: 'text_query', file_info: null },
{
content: 'img-url',
diff --git a/web/app/components/datasets/hit-testing/components/query-input/index.tsx b/web/app/components/datasets/hit-testing/components/query-input/index.tsx
index 9f35898ef91..2b825b7031f 100644
--- a/web/app/components/datasets/hit-testing/components/query-input/index.tsx
+++ b/web/app/components/datasets/hit-testing/components/query-input/index.tsx
@@ -1,13 +1,15 @@
+import type {
+ DatasetQueryContentResponse,
+ ExternalHitTestingResponse,
+ HitTestingResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { UseMutateAsyncFunction } from '@tanstack/react-query'
import type { ChangeEvent } from 'react'
import type { FileEntity } from '@/app/components/datasets/common/image-uploader/types'
import type {
Attachment,
ExternalKnowledgeBaseHitTestingRequest,
- ExternalKnowledgeBaseHitTestingResponse,
HitTestingRequest,
- HitTestingResponse,
- Query,
} from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { Button } from '@langgenius/dify-ui/button'
@@ -27,10 +29,10 @@ import Textarea from './textarea'
type QueryInputProps = {
onUpdateList: () => void
setHitResult: (res: HitTestingResponse) => void
- setExternalHitResult: (res: ExternalKnowledgeBaseHitTestingResponse) => void
+ setExternalHitResult: (res: ExternalHitTestingResponse) => void
loading: boolean
- queries: Query[]
- setQueries: (v: Query[]) => void
+ queries: DatasetQueryContentResponse[]
+ setQueries: (v: DatasetQueryContentResponse[]) => void
isExternal?: boolean
onClickRetrievalMethod: () => void
retrievalConfig: RetrievalConfig
@@ -39,7 +41,7 @@ type QueryInputProps = {
onSubmit?: () => void
hitTestingMutation: UseMutateAsyncFunction<HitTestingResponse, Error, HitTestingRequest, unknown>
externalKnowledgeBaseHitTestingMutation: UseMutateAsyncFunction<
- ExternalKnowledgeBaseHitTestingResponse,
+ ExternalHitTestingResponse,
Error,
ExternalKnowledgeBaseHitTestingRequest,
unknown
diff --git a/web/app/components/datasets/hit-testing/components/records.tsx b/web/app/components/datasets/hit-testing/components/records.tsx
index 37ea38e6530..f27090b927f 100644
--- a/web/app/components/datasets/hit-testing/components/records.tsx
+++ b/web/app/components/datasets/hit-testing/components/records.tsx
@@ -1,4 +1,8 @@
-import type { Attachment, HitTestingRecord, Query } from '@/models/datasets'
+import type {
+ DatasetQueryContentResponse,
+ DatasetQueryDetailResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
+import type { Attachment } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { RiApps2Line, RiArrowDownLine, RiFocus2Line } from '@remixicon/react'
import * as React from 'react'
@@ -8,8 +12,8 @@ import useTimestamp from '@/hooks/use-timestamp'
import ImageList from '../../common/image-list'
type RecordsProps = {
- records: HitTestingRecord[]
- onClickRecord: (record: HitTestingRecord) => void
+ records: DatasetQueryDetailResponse[]
+ onClickRecord: (record: DatasetQueryDetailResponse) => void
}
const Records = ({ records, onClickRecord }: RecordsProps) => {
@@ -28,7 +32,7 @@ const Records = ({ records, onClickRecord }: RecordsProps) => {
})
}, [records, sortTimeOrder])
- const getImageList = (queries: Query[]) => {
+ const getImageList = (queries: DatasetQueryContentResponse[]) => {
const imageQueries = queries
.filter((query) => query.content_type === 'image_query')
.map((query) => query.file_info)
diff --git a/web/app/components/datasets/hit-testing/components/result-item-external.tsx b/web/app/components/datasets/hit-testing/components/result-item-external.tsx
index 9f8b67d4047..f96423a5d96 100644
--- a/web/app/components/datasets/hit-testing/components/result-item-external.tsx
+++ b/web/app/components/datasets/hit-testing/components/result-item-external.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { ExternalKnowledgeBaseHitTesting } from '@/models/datasets'
+import type { ExternalHitTestingRecordResponse } from '@dify/contracts/api/console/datasets/types.gen'
import {
Dialog,
DialogClose,
@@ -15,7 +15,7 @@ import { ResultItemFooter } from './result-item-footer'
import { ResultItemMeta } from './result-item-meta'
type ResultItemExternalProps = {
- payload: ExternalKnowledgeBaseHitTesting
+ payload: ExternalHitTestingRecordResponse
positionId: number
}
diff --git a/web/app/components/datasets/hit-testing/components/result-item.tsx b/web/app/components/datasets/hit-testing/components/result-item.tsx
index 11c7c2061d5..a6b67d7b80e 100644
--- a/web/app/components/datasets/hit-testing/components/result-item.tsx
+++ b/web/app/components/datasets/hit-testing/components/result-item.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { HitTesting } from '@/models/datasets'
+import type { HitTestingRecord } from '@dify/contracts/api/console/datasets/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import { RiArrowDownSLine, RiArrowRightSLine } from '@remixicon/react'
import { useBoolean } from 'ahooks'
@@ -17,7 +17,7 @@ const i18nPrefix = ''
const INTERACTIVE_SELECTOR =
'a, button, input, select, textarea, summary, audio, video, [role="button"]'
type ResultItemProps = {
- payload: HitTesting
+ payload: HitTestingRecord
}
export const ResultItem = memo(({ payload }: ResultItemProps) => {
diff --git a/web/app/components/datasets/hit-testing/index.tsx b/web/app/components/datasets/hit-testing/index.tsx
index 88fe93b4f33..0d6ceed192f 100644
--- a/web/app/components/datasets/hit-testing/index.tsx
+++ b/web/app/components/datasets/hit-testing/index.tsx
@@ -1,16 +1,15 @@
'use client'
-import type { FC } from 'react'
import type {
- ExternalKnowledgeBaseHitTesting,
- ExternalKnowledgeBaseHitTestingRequest,
- ExternalKnowledgeBaseHitTestingResponse,
- HitTesting,
+ DatasetQueryContentResponse,
+ DatasetQueryDetailResponse,
+ ExternalHitTestingRecordResponse,
+ ExternalHitTestingResponse,
HitTestingRecord,
- HitTestingRequest,
HitTestingResponse,
- Query,
-} from '@/models/datasets'
+} from '@dify/contracts/api/console/datasets/types.gen'
+import type { FC } from 'react'
+import type { ExternalKnowledgeBaseHitTestingRequest, HitTestingRequest } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { cn } from '@langgenius/dify-ui/cn'
import {
@@ -61,9 +60,9 @@ const HitTestingPage: FC<Props> = ({ datasetId }: Props) => {
const [hitResult, setHitResult] = useState<HitTestingResponse | undefined>()
const [externalHitResult, setExternalHitResult] = useState<
- ExternalKnowledgeBaseHitTestingResponse | undefined
+ ExternalHitTestingResponse | undefined
>()
- const [queries, setQueries] = useState<Query[]>([])
+ const [queries, setQueries] = useState<DatasetQueryContentResponse[]>([])
const [queryInputKey, setQueryInputKey] = useState(Date.now())
const [currPage, setCurrPage] = useState<number>(0)
@@ -149,7 +148,7 @@ const HitTestingPage: FC<Props> = ({ datasetId }: Props) => {
? resultTitle
: ''
- const renderHitResults = (results: HitTesting[] | ExternalKnowledgeBaseHitTesting[]) => (
+ const renderHitResults = (results: HitTestingRecord[] | ExternalHitTestingRecordResponse[]) => (
<div className="flex h-full flex-col rounded-tl-2xl bg-background-body px-4 py-3">
<h2 className="mb-2 shrink-0 pl-2 leading-6 font-semibold text-text-primary">
{t(($) => $['hit.title'], { ns: 'datasetHitTesting', num: results.length })}
@@ -160,10 +159,10 @@ const HitTestingPage: FC<Props> = ({ datasetId }: Props) => {
<ResultItemExternal
key={idx}
positionId={idx + 1}
- payload={record as ExternalKnowledgeBaseHitTesting}
+ payload={record as ExternalHitTestingRecordResponse}
/>
) : (
- <ResultItem key={idx} payload={record as HitTesting} />
+ <ResultItem key={idx} payload={record as HitTestingRecord} />
),
)}
</div>
@@ -181,7 +180,7 @@ const HitTestingPage: FC<Props> = ({ datasetId }: Props) => {
</div>
)
- const handleClickRecord = useCallback((record: HitTestingRecord) => {
+ const handleClickRecord = useCallback((record: DatasetQueryDetailResponse) => {
setQueries(record.queries)
setQueryInputKey(Date.now())
}, [])
diff --git a/web/app/components/datasets/list/__tests__/datasets.spec.tsx b/web/app/components/datasets/list/__tests__/datasets.spec.tsx
index d60b2a86e53..4746bf14082 100644
--- a/web/app/components/datasets/list/__tests__/datasets.spec.tsx
+++ b/web/app/components/datasets/list/__tests__/datasets.spec.tsx
@@ -1,10 +1,14 @@
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetListResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { InfiniteData } from '@tanstack/react-query'
-import type { DataSet, DataSetListResponse } from '@/models/datasets'
import { screen } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { IndexingType } from '@/app/components/datasets/create/step-two'
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { renderWithConsoleQuery } from '@/test/console/query-data'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import Datasets from '../datasets'
@@ -25,7 +29,7 @@ vi.mock('@/hooks/use-knowledge', () => ({
}),
}))
-type DatasetListItem = DataSetListResponse['data'][number]
+type DatasetListItem = DatasetListResponse['data'][number]
const mockFetchNextPage = vi.fn()
@@ -56,7 +60,7 @@ vi.mock('../dataset-card', () => ({
stepByStepTourActionMenuOpen,
stepByStepTourCardTarget,
}: {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
stepByStepTourActionMenuHighlightPart?: string
stepByStepTourActionMenuOpen?: boolean
stepByStepTourCardTarget?: string
@@ -81,7 +85,7 @@ function createMockDataset(overrides: Partial<DatasetListItem> = {}): DatasetLis
name: 'Test Dataset',
description: 'Test description',
provider: 'vendor',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
embedding_available: true,
@@ -130,7 +134,7 @@ class MockIntersectionObserver {
describe('Datasets', () => {
const createDatasetListData = (
- pages: Array<Pick<DataSetListResponse, 'data'> & Partial<Omit<DataSetListResponse, 'data'>>> = [
+ pages: Array<Pick<DatasetListResponse, 'data'> & Partial<Omit<DatasetListResponse, 'data'>>> = [
{
data: [
createMockDataset({ id: 'dataset-1', name: 'Dataset 1' }),
@@ -148,7 +152,7 @@ describe('Datasets', () => {
...page,
})),
pageParams: pages.map((_, index) => index + 1),
- }) satisfies InfiniteData<DataSetListResponse, number>
+ }) satisfies InfiniteData<DatasetListResponse, number>
const defaultProps = {
datasetList: createDatasetListData(),
diff --git a/web/app/components/datasets/list/dataset-card/__tests__/index.spec.tsx b/web/app/components/datasets/list/dataset-card/__tests__/index.spec.tsx
index 1ac43e45220..55c450f23ce 100644
--- a/web/app/components/datasets/list/dataset-card/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/list/dataset-card/__tests__/index.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { QueryClientProvider } from '@tanstack/react-query'
import { fireEvent, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -6,7 +6,8 @@ import * as React from 'react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { IndexingType } from '@/app/components/datasets/create/step-two'
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createAccountProfileQueryClient } from '@/test/console/account-profile'
import { render as renderWithConsoleState } from '@/test/console/render'
import { DatasetACLPermission } from '@/utils/permission'
@@ -114,7 +115,13 @@ vi.mock('../components/corner-labels', () => ({
default: () => <div data-testid="corner-labels" />,
}))
vi.mock('../components/dataset-card-header', () => ({
- default: ({ dataset, nameId }: { dataset: DataSet; nameId?: string }) => (
+ default: ({
+ dataset,
+ nameId,
+ }: {
+ dataset: DatasetDetailWithPartialMembersResponse
+ nameId?: string
+ }) => (
<div id={nameId} data-testid="card-header">
{dataset.name}
</div>
@@ -157,13 +164,15 @@ vi.mock('../components/operations-dropdown', () => ({
}))
// Factory function for DataSet mock data
-const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet =>
+const createMockDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse =>
({
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
provider: 'vendor',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
embedding_available: true,
@@ -180,7 +189,7 @@ const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet =>
total_available_documents: 10,
runtime_mode: 'general',
...overrides,
- }) as DataSet
+ }) as DatasetDetailWithPartialMembersResponse
describe('DatasetCard Integration', () => {
beforeEach(() => {
diff --git a/web/app/components/datasets/list/dataset-card/components/__tests__/corner-labels.spec.tsx b/web/app/components/datasets/list/dataset-card/components/__tests__/corner-labels.spec.tsx
index bcf10ecde5a..530181355ad 100644
--- a/web/app/components/datasets/list/dataset-card/components/__tests__/corner-labels.spec.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/__tests__/corner-labels.spec.tsx
@@ -1,16 +1,17 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen } from '@testing-library/react'
import { IndexingType } from '@/app/components/datasets/create/step-two'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import CornerLabels from '../corner-labels'
-const createDataset = (embeddingAvailable: boolean): DataSet =>
+const createDataset = (embeddingAvailable: boolean): DatasetDetailWithPartialMembersResponse =>
({
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
provider: 'vendor',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
embedding_available: embeddingAvailable,
@@ -24,7 +25,7 @@ const createDataset = (embeddingAvailable: boolean): DataSet =>
embedding_model_provider: 'openai',
created_by: 'user-1',
doc_form: ChunkingMode.text,
- }) as unknown as DataSet
+ }) as unknown as DatasetDetailWithPartialMembersResponse
describe('CornerLabels', () => {
it('shows that a dataset is unavailable when embedding is unavailable', () => {
diff --git a/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-footer.spec.tsx b/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-footer.spec.tsx
index ce54233bb60..ee35db947d1 100644
--- a/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-footer.spec.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-footer.spec.tsx
@@ -1,8 +1,9 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { IndexingType } from '@/app/components/datasets/create/step-two'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import DatasetCardFooter from '../dataset-card-footer'
vi.mock('@/hooks/use-format-time-from-now', () => ({
@@ -11,13 +12,15 @@ vi.mock('@/hooks/use-format-time-from-now', () => ({
}),
}))
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet =>
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse =>
({
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
provider: 'vendor',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
embedding_available: true,
@@ -33,7 +36,7 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet =>
doc_form: ChunkingMode.text,
total_available_documents: 10,
...overrides,
- }) as DataSet
+ }) as DatasetDetailWithPartialMembersResponse
describe('DatasetCardFooter', () => {
it.each([
diff --git a/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-header.spec.tsx b/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-header.spec.tsx
index 1636b647594..3d1e76bedaa 100644
--- a/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-header.spec.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-header.spec.tsx
@@ -1,7 +1,8 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { render, screen } from '@testing-library/react'
import { IndexingType } from '@/app/components/datasets/create/step-two'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD } from '@/types/app'
import DatasetCardHeader from '../dataset-card-header'
@@ -23,13 +24,15 @@ vi.mock('react-i18next', async () => {
}
})
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
provider: 'vendor',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
embedding_available: true,
@@ -56,7 +59,7 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
},
retrieval_model_dict: {
search_method: RETRIEVE_METHOD.semantic,
- } as DataSet['retrieval_model_dict'],
+ } as DatasetDetailWithPartialMembersResponse['retrieval_model_dict'],
external_knowledge_info: {
external_knowledge_id: '',
external_knowledge_api_id: '',
diff --git a/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-modals.spec.tsx b/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-modals.spec.tsx
index cb8eac0ed1f..9e7836bbf6c 100644
--- a/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-modals.spec.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/__tests__/dataset-card-modals.spec.tsx
@@ -1,8 +1,9 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { fireEvent, render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vite-plus/test'
import { IndexingType } from '@/app/components/datasets/create/step-two'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import DatasetCardModals from '../dataset-card-modals'
@@ -26,13 +27,13 @@ vi.mock('../../../../rename-modal', () => ({
}))
describe('DatasetCardModals', () => {
- const mockDataset: DataSet = {
+ const mockDataset: DatasetDetailWithPartialMembersResponse = {
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
provider: 'vendor',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
embedding_available: true,
@@ -56,7 +57,7 @@ describe('DatasetCardModals', () => {
icon_background: '#FFF4ED',
icon_url: '',
},
- retrieval_model_dict: {} as DataSet['retrieval_model_dict'],
+ retrieval_model_dict: {} as DatasetDetailWithPartialMembersResponse['retrieval_model_dict'],
external_knowledge_info: {
external_knowledge_id: '',
external_knowledge_api_id: '',
diff --git a/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.browser.spec.tsx b/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.browser.spec.tsx
index af9a324adea..ed21943a9e5 100644
--- a/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.browser.spec.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.browser.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { userEvent } from 'vite-plus/test/browser'
import { render } from 'vitest-browser-react'
@@ -55,7 +55,7 @@ it('keeps operations visible on keyboard focus without covering the unavailable
runtime_mode: 'general',
embedding_available: false,
permission_keys: [DatasetACLPermission.Edit],
- } as DataSet
+ } as DatasetDetailWithPartialMembersResponse
const screen = await render(
<QueryClientProvider client={queryClient}>
<button type="button">Before dataset</button>
diff --git a/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.spec.tsx b/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.spec.tsx
index 10a796034f4..c0e0f975ef8 100644
--- a/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.spec.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.spec.tsx
@@ -1,8 +1,9 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { createEvent, fireEvent, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { IndexingType } from '@/app/components/datasets/create/step-two'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { renderWithConsoleQuery } from '@/test/console/query-data'
import { DatasetACLPermission } from '@/utils/permission'
import OperationsDropdown from '../operations-dropdown'
@@ -33,13 +34,15 @@ vi.mock('@/context/permission-state', async () => {
return createPermissionStateModuleMock(() => mockConsoleState)
})
describe('OperationsDropdown', () => {
- const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet =>
+ const createMockDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+ ): DatasetDetailWithPartialMembersResponse =>
({
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
provider: 'vendor',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
embedding_available: true,
@@ -60,7 +63,7 @@ describe('OperationsDropdown', () => {
DatasetACLPermission.AccessConfig,
],
...overrides,
- }) as DataSet
+ }) as DatasetDetailWithPartialMembersResponse
const defaultProps = {
dataset: createMockDataset(),
diff --git a/web/app/components/datasets/list/dataset-card/components/corner-labels.tsx b/web/app/components/datasets/list/dataset-card/components/corner-labels.tsx
index c64dda9968b..da45275d366 100644
--- a/web/app/components/datasets/list/dataset-card/components/corner-labels.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/corner-labels.tsx
@@ -1,10 +1,10 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import CornerLabel from '@/app/components/base/corner-label'
type CornerLabelsProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
}
const CornerLabels = ({ dataset }: CornerLabelsProps) => {
diff --git a/web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx b/web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx
index 9fb84e13fa6..16894d0fdf2 100644
--- a/web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import {
@@ -16,7 +16,7 @@ import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now'
const EXTERNAL_PROVIDER = 'external'
type DatasetCardFooterProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
}
const DatasetCardFooter = ({ dataset }: DatasetCardFooterProps) => {
diff --git a/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx b/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx
index 1c1230c75a4..7ca4327a868 100644
--- a/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useMemo } from 'react'
@@ -13,13 +13,13 @@ const docModeInfoClassName =
'flex min-h-3 items-center gap-x-3 system-2xs-medium-uppercase text-text-tertiary'
type DatasetCardHeaderProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
nameId?: string
}
// DocModeInfo component - placed before usage
type DocModeInfoProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
isExternalProvider: boolean
isShowDocModeInfo: boolean
}
diff --git a/web/app/components/datasets/list/dataset-card/components/dataset-card-modals.tsx b/web/app/components/datasets/list/dataset-card/components/dataset-card-modals.tsx
index 7ef0f26defd..81afe66dd18 100644
--- a/web/app/components/datasets/list/dataset-card/components/dataset-card-modals.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/dataset-card-modals.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -20,7 +20,7 @@ type ModalState = {
}
type DatasetCardModalsProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
modalState: ModalState
onCloseRename: () => void
onCloseConfirm: () => void
diff --git a/web/app/components/datasets/list/dataset-card/components/description.tsx b/web/app/components/datasets/list/dataset-card/components/description.tsx
index 3980a305f96..d5ca69eaa24 100644
--- a/web/app/components/datasets/list/dataset-card/components/description.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/description.tsx
@@ -1,9 +1,9 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
type DescriptionProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
}
const Description = ({ dataset }: DescriptionProps) => (
diff --git a/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx b/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx
index dd38777f850..4b6e8d7ce89 100644
--- a/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx
+++ b/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import {
DropdownMenu,
@@ -21,7 +21,7 @@ import { systemFeaturesQueryOptions } from '@/features/system-features/client'
import { getDatasetACLCapabilities } from '@/utils/permission'
type OperationsDropdownProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
openRenameModal: () => void
handleExportPipeline: (include?: boolean) => void
detectIsUsedByApp: () => void
diff --git a/web/app/components/datasets/list/dataset-card/hooks/__tests__/use-dataset-card-state.spec.ts b/web/app/components/datasets/list/dataset-card/hooks/__tests__/use-dataset-card-state.spec.ts
index b882c73a89a..f97f2ff6f8c 100644
--- a/web/app/components/datasets/list/dataset-card/hooks/__tests__/use-dataset-card-state.spec.ts
+++ b/web/app/components/datasets/list/dataset-card/hooks/__tests__/use-dataset-card-state.spec.ts
@@ -1,5 +1,5 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactNode } from 'react'
-import type { DataSet } from '@/models/datasets'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { act, renderHook } from '@testing-library/react'
import { createElement } from 'react'
@@ -29,7 +29,7 @@ vi.mock('@tanstack/react-query', async (importOriginal) => {
const dataset = {
id: 'dataset-1',
name: 'Test Dataset',
-} as DataSet
+} as DatasetDetailWithPartialMembersResponse
function renderDatasetCardState() {
const onSuccess = vi.fn()
diff --git a/web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts b/web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts
index 6e0dfe3eba3..9fbbb4108d1 100644
--- a/web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts
+++ b/web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts
@@ -1,4 +1,4 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -15,7 +15,7 @@ type ModalState = {
}
type UseDatasetCardStateOptions = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
onSuccess?: () => void
}
diff --git a/web/app/components/datasets/list/dataset-card/index.tsx b/web/app/components/datasets/list/dataset-card/index.tsx
index 778d59eb2d9..3bfa1699f7e 100644
--- a/web/app/components/datasets/list/dataset-card/index.tsx
+++ b/web/app/components/datasets/list/dataset-card/index.tsx
@@ -1,6 +1,6 @@
'use client'
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -27,7 +27,7 @@ import { useDatasetCardState as useDatasetCardController } from './hooks/use-dat
const EXTERNAL_PROVIDER = 'external'
type DatasetCardProps = {
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
onSuccess?: () => void
onOpenTagManagement?: () => void
stepByStepTourActionMenuHighlightPart?: string
diff --git a/web/app/components/datasets/list/datasets.tsx b/web/app/components/datasets/list/datasets.tsx
index 9fc438e51db..0dc05a62183 100644
--- a/web/app/components/datasets/list/datasets.tsx
+++ b/web/app/components/datasets/list/datasets.tsx
@@ -1,8 +1,8 @@
'use client'
+import type { DatasetListResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { InfiniteData, UseInfiniteQueryResult } from '@tanstack/react-query'
import type { ReactNode } from 'react'
-import type { DataSetListResponse } from '@/models/datasets'
import { useQueryClient } from '@tanstack/react-query'
import { useCallback, useEffect, useRef } from 'react'
import { useTranslation } from 'react-i18next'
@@ -11,7 +11,7 @@ import { consoleQuery } from '@/service/console'
import DatasetCard from './dataset-card'
import DatasetCardSkeleton from './dataset-card-skeleton'
-type DatasetListQuery = UseInfiniteQueryResult<InfiniteData<DataSetListResponse, number>>
+type DatasetListQuery = UseInfiniteQueryResult<InfiniteData<DatasetListResponse, number>>
type Props = Readonly<{
datasetList: DatasetListQuery['data'] | null
diff --git a/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts b/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts
index fb528975de9..e0bdbd8cc85 100644
--- a/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts
+++ b/web/app/components/datasets/metadata/hooks/use-batch-edit-document-metadata.ts
@@ -1,10 +1,10 @@
+import type { DocumentWithSegmentsResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type {
MetadataBatchEditToServer,
MetadataItemInBatchEdit,
MetadataItemWithEdit,
MetadataItemWithValue,
} from '../types'
-import type { SimpleDocumentDetail } from '@/models/datasets'
import { useMutation } from '@tanstack/react-query'
import { useBoolean } from 'ahooks'
import { t } from 'i18next'
@@ -15,7 +15,7 @@ import { UpdateType } from '../types'
type Props = Readonly<{
datasetId: string
- docList: SimpleDocumentDetail[]
+ docList: DocumentWithSegmentsResponse[]
selectedDocumentIds?: string[]
onUpdate: () => void
}>
diff --git a/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.ts b/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.ts
index e882146f980..5b355573905 100644
--- a/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.ts
+++ b/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.ts
@@ -1,5 +1,5 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { BuiltInMetadataItem, MetadataItemWithValueLength } from '../types'
-import type { DataSet } from '@/models/datasets'
import { useMutation, useQuery } from '@tanstack/react-query'
import { useBoolean } from 'ahooks'
import { useCallback, useEffect, useState } from 'react'
@@ -14,7 +14,7 @@ const useEditDatasetMetadata = ({
onUpdateDocList,
}: {
datasetId: string
- dataset?: DataSet
+ dataset?: DatasetDetailWithPartialMembersResponse
onUpdateDocList: () => void
}) => {
const [isShowEditModal, { setTrue: showEditModal, setFalse: hideEditModal }] = useBoolean(false)
diff --git a/web/app/components/datasets/metadata/hooks/use-metadata-document.ts b/web/app/components/datasets/metadata/hooks/use-metadata-document.ts
index 1922ad44b64..362e385a611 100644
--- a/web/app/components/datasets/metadata/hooks/use-metadata-document.ts
+++ b/web/app/components/datasets/metadata/hooks/use-metadata-document.ts
@@ -1,5 +1,5 @@
+import type { DocumentDetailResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { BuiltInMetadataItem, MetadataItemWithValue } from '../types'
-import type { FullDocumentDetail } from '@/models/datasets'
import { useMutation, useQuery } from '@tanstack/react-query'
import { get } from 'es-toolkit/compat'
import { useCallback, useState } from 'react'
@@ -14,7 +14,7 @@ import useCheckMetadataName from './use-check-metadata-name'
type Props = Readonly<{
datasetId: string
documentId: string
- docDetail: FullDocumentDetail
+ docDetail: DocumentDetailResponse
}>
const useMetadataDocument = ({ datasetId, documentId, docDetail }: Props) => {
const { t } = useTranslation(['common'])
diff --git a/web/app/components/datasets/metadata/metadata-document/index.tsx b/web/app/components/datasets/metadata/metadata-document/index.tsx
index 6422025c14e..9e7751d9181 100644
--- a/web/app/components/datasets/metadata/metadata-document/index.tsx
+++ b/web/app/components/datasets/metadata/metadata-document/index.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { DocumentDetailResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { FullDocumentDetail } from '@/models/datasets'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
@@ -16,7 +16,7 @@ type Props = Readonly<{
datasetId: string
documentId: string
className?: string
- docDetail: FullDocumentDetail
+ docDetail: DocumentDetailResponse
canEdit?: boolean
}>
const MetadataDocument: FC<Props> = ({
diff --git a/web/app/components/datasets/rename-modal/__tests__/index.spec.tsx b/web/app/components/datasets/rename-modal/__tests__/index.spec.tsx
index a2a0c3fe1c0..8594490f87d 100644
--- a/web/app/components/datasets/rename-modal/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/rename-modal/__tests__/index.spec.tsx
@@ -1,8 +1,9 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { IndexingType } from '@/app/components/datasets/create/step-two'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { mockEmojiData, renderWithEmoji as render } from '@/test/emoji-picker'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import RenameDatasetModal from '../index'
@@ -33,7 +34,9 @@ vi.mock('@/service/datasets', () => ({
describe('RenameDatasetModal', () => {
// Create a base dataset with emoji icon
- const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+ const createMockDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+ ): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
@@ -44,7 +47,7 @@ describe('RenameDatasetModal', () => {
icon_background: '#FFEAD5',
icon_url: undefined,
},
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
created_by: 'user-1',
@@ -58,7 +61,7 @@ describe('RenameDatasetModal', () => {
embedding_model: 'text-embedding-ada-002',
embedding_model_provider: 'openai',
embedding_available: true,
- retrieval_model_dict: {} as DataSet['retrieval_model_dict'],
+ retrieval_model_dict: {} as DatasetDetailWithPartialMembersResponse['retrieval_model_dict'],
tags: [],
external_knowledge_info: {
external_knowledge_id: '',
@@ -79,7 +82,7 @@ describe('RenameDatasetModal', () => {
})
// Create a dataset with image icon
- const createMockDatasetWithImageIcon = (): DataSet =>
+ const createMockDatasetWithImageIcon = (): DatasetDetailWithPartialMembersResponse =>
createMockDataset({
icon_info: {
icon: 'file-id-123',
@@ -90,7 +93,7 @@ describe('RenameDatasetModal', () => {
})
// Create a dataset with external knowledge info
- const createMockExternalDataset = (): DataSet =>
+ const createMockExternalDataset = (): DatasetDetailWithPartialMembersResponse =>
createMockDataset({
external_knowledge_info: {
external_knowledge_id: 'ext-knowledge-1',
@@ -321,7 +324,7 @@ describe('RenameDatasetModal', () => {
it('should disable save button while loading', async () => {
// Create a promise that we can control
- let resolvePromise: (value: DataSet) => void
+ let resolvePromise: (value: DatasetDetailWithPartialMembersResponse) => void
mockUpdateDatasetSetting.mockImplementation(
() =>
new Promise((resolve) => {
@@ -1062,7 +1065,7 @@ describe('RenameDatasetModal', () => {
it('should handle double click on save button', async () => {
// Use a promise we can control to ensure the first click is still "loading"
- let resolvePromise: (value: DataSet) => void
+ let resolvePromise: (value: DatasetDetailWithPartialMembersResponse) => void
mockUpdateDatasetSetting.mockImplementationOnce(
() =>
new Promise((resolve) => {
@@ -1182,7 +1185,7 @@ describe('RenameDatasetModal', () => {
describe('Loading State', () => {
it('should show loading state during API call', async () => {
- let resolvePromise: (value: DataSet) => void
+ let resolvePromise: (value: DatasetDetailWithPartialMembersResponse) => void
mockUpdateDatasetSetting.mockImplementation(
() =>
new Promise((resolve) => {
diff --git a/web/app/components/datasets/rename-modal/index.tsx b/web/app/components/datasets/rename-modal/index.tsx
index 14784af506d..75e28f3969b 100644
--- a/web/app/components/datasets/rename-modal/index.tsx
+++ b/web/app/components/datasets/rename-modal/index.tsx
@@ -1,7 +1,9 @@
'use client'
-import type { DatasetUpdatePayload } from '@dify/contracts/api/console/datasets/types.gen'
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetUpdatePayload,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { IconPickerValue } from '@/app/components/base/icon-picker'
-import type { DataSet } from '@/models/datasets'
import { Button } from '@langgenius/dify-ui/button'
import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'
import { Field, FieldLabel } from '@langgenius/dify-ui/field'
@@ -21,7 +23,7 @@ import { updateDatasetSetting } from '@/service/datasets'
type RenameDatasetModalProps = {
show: boolean
- dataset: DataSet
+ dataset: DatasetDetailWithPartialMembersResponse
onSuccess?: () => void
onClose: () => void
}
diff --git a/web/app/components/datasets/settings/form/__tests__/index.spec.tsx b/web/app/components/datasets/settings/form/__tests__/index.spec.tsx
index 2d7e71b0d05..10c08dd7659 100644
--- a/web/app/components/datasets/settings/form/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/settings/form/__tests__/index.spec.tsx
@@ -1,10 +1,11 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { GetWorkspacesCurrentModelsModelTypesByModelTypeData } from '@dify/contracts/api/console/workspaces/types.gen'
import type { OperationKey } from '@orpc/tanstack-query'
import type { ReactElement } from 'react'
-import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { fireEvent, screen, waitFor } from '@testing-library/react'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { expectLoadingButton } from '@/test/button'
import { createConsoleQueryWrapper } from '@/test/console/query-data'
import { render as renderWithConsoleState } from '@/test/console/render'
@@ -54,12 +55,14 @@ function render(ui: ReactElement) {
return renderWithConsoleState(ui, { wrapper })
}
-const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createMockDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
icon_info: {
icon_type: 'emoji',
icon: '📚',
@@ -112,11 +115,14 @@ const createMockDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
...overrides,
})
-let mockDataset: DataSet = createMockDataset()
+let mockDataset: DatasetDetailWithPartialMembersResponse = createMockDataset()
vi.mock('@/context/dataset-detail', () => ({
useDatasetDetailContextWithSelector: (
- selector: (state: { dataset: DataSet | null; mutateDatasetRes: () => void }) => unknown,
+ selector: (state: {
+ dataset: DatasetDetailWithPartialMembersResponse | null
+ mutateDatasetRes: () => void
+ }) => unknown,
) => {
const state = {
dataset: mockDataset,
@@ -174,7 +180,7 @@ vi.mock('../components/indexing-section', () => ({
currentDataset,
indexMethod,
}: {
- currentDataset?: DataSet
+ currentDataset?: DatasetDetailWithPartialMembersResponse
indexMethod?: IndexingType
}) => (
<div data-testid="indexing-section">
diff --git a/web/app/components/datasets/settings/form/components/__tests__/basic-info-section.spec.tsx b/web/app/components/datasets/settings/form/components/__tests__/basic-info-section.spec.tsx
index 95f58d64577..013a2ef7c43 100644
--- a/web/app/components/datasets/settings/form/components/__tests__/basic-info-section.spec.tsx
+++ b/web/app/components/datasets/settings/form/components/__tests__/basic-info-section.spec.tsx
@@ -1,10 +1,12 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { ReactElement } from 'react'
-import type { Member } from '@/models/common'
-import type { DataSet, IconInfo } from '@/models/datasets'
+import type { IconInfo } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createConsoleQueryWrapper } from '@/test/console/query-data'
import { render as renderWithConsoleState } from '@/test/console/render'
import { mockEmojiData } from '@/test/emoji-picker'
@@ -61,12 +63,12 @@ vi.mock('@/app/components/base/image-uploader/hooks', () => ({
}))
describe('BasicInfoSection', () => {
- const mockDataset: DataSet = {
+ const mockDataset: DatasetDetailWithPartialMembersResponse = {
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
icon_info: {
icon_type: 'emoji',
icon: '📚',
@@ -117,7 +119,7 @@ describe('BasicInfoSection', () => {
is_multimodal: false,
}
- const mockMemberList: Member[] = [
+ const mockMemberList: AccountWithRoleResponse[] = [
{
id: 'user-1',
name: 'User 1',
@@ -159,7 +161,7 @@ describe('BasicInfoSection', () => {
setDescription: vi.fn(),
iconInfo: mockIconInfo,
handleSelectAppIcon: vi.fn(),
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
setPermission: vi.fn(),
selectedMemberIDs: ['user-1'],
setSelectedMemberIDs: vi.fn(),
@@ -327,13 +329,13 @@ describe('BasicInfoSection', () => {
describe('Permission Selector', () => {
it('should render with correct permission value', () => {
- render(<BasicInfoSection {...defaultProps} permission={DatasetPermission.onlyMe} />)
+ render(<BasicInfoSection {...defaultProps} permission={PermissionLevel.onlyMe} />)
expect(screen.getByText(/form\.permissionsOnlyMe/i))!.toBeInTheDocument()
})
it('should render all team members permission', () => {
- render(<BasicInfoSection {...defaultProps} permission={DatasetPermission.allTeamMembers} />)
+ render(<BasicInfoSection {...defaultProps} permission={PermissionLevel.allTeamMembers} />)
expect(screen.getByText(/form\.permissionsAllMember/i))!.toBeInTheDocument()
})
@@ -368,7 +370,7 @@ describe('BasicInfoSection', () => {
fireEvent.click(allMemberOptions[0]!)
})
- expect(setPermission).toHaveBeenCalledWith(DatasetPermission.allTeamMembers)
+ expect(setPermission).toHaveBeenCalledWith(PermissionLevel.allTeamMembers)
})
})
@@ -407,12 +409,12 @@ describe('BasicInfoSection', () => {
it('should update when permission prop changes', () => {
const { rerender } = render(
- <BasicInfoSection {...defaultProps} permission={DatasetPermission.onlyMe} />,
+ <BasicInfoSection {...defaultProps} permission={PermissionLevel.onlyMe} />,
)
expect(screen.getByText(/form\.permissionsOnlyMe/i))!.toBeInTheDocument()
- rerender(<BasicInfoSection {...defaultProps} permission={DatasetPermission.allTeamMembers} />)
+ rerender(<BasicInfoSection {...defaultProps} permission={PermissionLevel.allTeamMembers} />)
expect(screen.getByText(/form\.permissionsAllMember/i))!.toBeInTheDocument()
})
diff --git a/web/app/components/datasets/settings/form/components/__tests__/external-knowledge-section.spec.tsx b/web/app/components/datasets/settings/form/components/__tests__/external-knowledge-section.spec.tsx
index 6084cddaa0c..68e26ae56b5 100644
--- a/web/app/components/datasets/settings/form/components/__tests__/external-knowledge-section.spec.tsx
+++ b/web/app/components/datasets/settings/form/components/__tests__/external-knowledge-section.spec.tsx
@@ -1,7 +1,8 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { RetrievalConfig } from '@/types/app'
import { render, screen } from '@testing-library/react'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD } from '@/types/app'
import { IndexingType } from '../../../../create/step-two'
@@ -20,12 +21,12 @@ describe('ExternalKnowledgeSection', () => {
score_threshold: 0.5,
}
- const mockDataset: DataSet = {
+ const mockDataset: DatasetDetailWithPartialMembersResponse = {
...createDatasetFixture(),
id: 'dataset-1',
name: 'External Dataset',
description: 'External dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
icon_info: {
icon_type: 'emoji',
icon: '📚',
diff --git a/web/app/components/datasets/settings/form/components/__tests__/indexing-section.spec.tsx b/web/app/components/datasets/settings/form/components/__tests__/indexing-section.spec.tsx
index a9931f3f765..d28531dd757 100644
--- a/web/app/components/datasets/settings/form/components/__tests__/indexing-section.spec.tsx
+++ b/web/app/components/datasets/settings/form/components/__tests__/indexing-section.spec.tsx
@@ -1,7 +1,8 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ProviderWithModelsResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { ComponentProps } from 'react'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import type { DataSet, SummaryIndexSetting } from '@/models/datasets'
+import type { SummaryIndexSetting } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { fireEvent, screen } from '@testing-library/react'
import {
@@ -9,7 +10,8 @@ import {
ModelStatusEnum,
ModelTypeEnum,
} from '@/app/components/header/account-setting/model-provider-page/declarations'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { renderWithConsoleQuery as render } from '@/test/console/query-data'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD } from '@/types/app'
@@ -163,12 +165,12 @@ describe('IndexingSection', () => {
score_threshold: 0.5,
}
- const mockDataset: DataSet = {
+ const mockDataset: DatasetDetailWithPartialMembersResponse = {
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
icon_info: {
icon_type: 'emoji',
icon: '📚',
diff --git a/web/app/components/datasets/settings/form/components/__tests__/reflow.browser.spec.tsx b/web/app/components/datasets/settings/form/components/__tests__/reflow.browser.spec.tsx
index 21dedbf42ee..577844f276b 100644
--- a/web/app/components/datasets/settings/form/components/__tests__/reflow.browser.spec.tsx
+++ b/web/app/components/datasets/settings/form/components/__tests__/reflow.browser.spec.tsx
@@ -1,11 +1,12 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { RetrievalConfig } from '@/types/app'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { useState } from 'react'
import { page } from 'vite-plus/test/browser'
import { render } from 'vitest-browser-react'
import datasetSettings from '@/i18n/locales/en-US/dataset-settings.json'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD } from '@/types/app'
import { IndexingType } from '../../../../create/step-two'
@@ -55,12 +56,12 @@ const mockRetrievalConfig: RetrievalConfig = {
score_threshold: 0.5,
}
-const mockDataset: DataSet = {
+const mockDataset: DatasetDetailWithPartialMembersResponse = {
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
icon_info: {
icon_type: 'emoji',
icon: '📚',
diff --git a/web/app/components/datasets/settings/form/components/basic-info-section.tsx b/web/app/components/datasets/settings/form/components/basic-info-section.tsx
index 2b99a9f5b67..e3ee8956ef3 100644
--- a/web/app/components/datasets/settings/form/components/basic-info-section.tsx
+++ b/web/app/components/datasets/settings/form/components/basic-info-section.tsx
@@ -1,7 +1,9 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { IconPickerValue } from '@/app/components/base/icon-picker'
-import type { Member } from '@/models/common'
-import type { DataSet, DatasetPermission, IconInfo } from '@/models/datasets'
+import type { IconInfo } from '@/models/datasets'
+import type { PermissionLevel } from '@/models/permission'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Input } from '@langgenius/dify-ui/input'
import { Textarea } from '@langgenius/dify-ui/textarea'
@@ -19,18 +21,18 @@ const rowClass = 'flex min-w-0 flex-col gap-2 @3xl/settings:flex-row @3xl/settin
const labelClass = 'flex shrink-0 flex-col pt-1 @3xl/settings:w-45'
type BasicInfoSectionProps = {
- currentDataset: DataSet | undefined
+ currentDataset: DatasetDetailWithPartialMembersResponse | undefined
name: string
setName: (value: string) => void
description: string
setDescription: (value: string) => void
iconInfo: IconInfo
handleSelectAppIcon: (icon: IconPickerValue) => void
- permission: DatasetPermission | undefined
- setPermission: (value: DatasetPermission | undefined) => void
+ permission: PermissionLevel | undefined
+ setPermission: (value: PermissionLevel | undefined) => void
selectedMemberIDs: string[]
setSelectedMemberIDs: (value: string[]) => void
- memberList: Member[]
+ memberList: AccountWithRoleResponse[]
readonly?: boolean
}
diff --git a/web/app/components/datasets/settings/form/components/external-knowledge-section.tsx b/web/app/components/datasets/settings/form/components/external-knowledge-section.tsx
index 27a7ae67a4d..452be08e6e7 100644
--- a/web/app/components/datasets/settings/form/components/external-knowledge-section.tsx
+++ b/web/app/components/datasets/settings/form/components/external-knowledge-section.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { Separator } from '@langgenius/dify-ui/separator'
import { useTranslation } from 'react-i18next'
import RetrievalSettings from '../../../external-knowledge-base/create/RetrievalSettings'
@@ -8,7 +8,7 @@ const rowClass = 'flex min-w-0 flex-col gap-2 @3xl/settings:flex-row @3xl/settin
const labelClass = 'flex shrink-0 flex-col pt-1 @3xl/settings:w-45'
type ExternalKnowledgeSectionProps = {
- currentDataset: DataSet
+ currentDataset: DatasetDetailWithPartialMembersResponse
topK: number
scoreThreshold: number
scoreThresholdEnabled: boolean
diff --git a/web/app/components/datasets/settings/form/components/indexing-section.tsx b/web/app/components/datasets/settings/form/components/indexing-section.tsx
index de7bcb3f17e..d6ed804ef27 100644
--- a/web/app/components/datasets/settings/form/components/indexing-section.tsx
+++ b/web/app/components/datasets/settings/form/components/indexing-section.tsx
@@ -1,7 +1,8 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ProviderWithModelsResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import type { DataSet, SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets'
+import type { SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { Separator } from '@langgenius/dify-ui/separator'
import { useSuspenseQuery } from '@tanstack/react-query'
@@ -27,7 +28,7 @@ const rowClass = 'flex min-w-0 flex-col gap-2 @3xl/settings:flex-row @3xl/settin
const labelClass = 'flex shrink-0 flex-col pt-1 @3xl/settings:w-45'
type IndexingSectionProps = {
- currentDataset: DataSet | undefined
+ currentDataset: DatasetDetailWithPartialMembersResponse | undefined
indexMethod: IndexingType | undefined
setIndexMethod: (value: IndexingType | undefined) => void
keywordNumber: number
diff --git a/web/app/components/datasets/settings/form/hooks/__tests__/use-form-state.spec.ts b/web/app/components/datasets/settings/form/hooks/__tests__/use-form-state.spec.ts
index e3a34ddd8a9..76e53309ba8 100644
--- a/web/app/components/datasets/settings/form/hooks/__tests__/use-form-state.spec.ts
+++ b/web/app/components/datasets/settings/form/hooks/__tests__/use-form-state.spec.ts
@@ -1,16 +1,16 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { GetWorkspacesCurrentModelsModelTypesByModelTypeData } from '@dify/contracts/api/console/workspaces/types.gen'
import type { OperationKey } from '@orpc/tanstack-query'
-import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { QueryClient } from '@tanstack/react-query'
import { act, waitFor } from '@testing-library/react'
import {
ChunkingMode,
- DatasetPermission,
DataSourceType,
RerankingModeEnum,
WeightedScoreEnum,
} from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { consoleQuery } from '@/service/console'
import { createAccountProfileQueryWrapper } from '@/test/console/account-profile'
import { renderHook as renderHookWithConsoleState } from '@/test/console/render'
@@ -61,12 +61,12 @@ vi.mock('@/features/system-features/state', async () => {
}))
})
-const createDefaultMockDataset = (): DataSet => ({
+const createDefaultMockDataset = (): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Test Dataset',
description: 'Test description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
icon_info: {
icon_type: 'emoji',
icon: '📚',
@@ -118,11 +118,14 @@ const createDefaultMockDataset = (): DataSet => ({
permission_keys: [DatasetACLPermission.Edit],
})
-let mockDataset: DataSet = createDefaultMockDataset()
+let mockDataset: DatasetDetailWithPartialMembersResponse = createDefaultMockDataset()
vi.mock('@/context/dataset-detail', () => ({
useDatasetDetailContextWithSelector: (
- selector: (state: { dataset: DataSet | null; mutateDatasetRes: () => void }) => unknown,
+ selector: (state: {
+ dataset: DatasetDetailWithPartialMembersResponse | null
+ mutateDatasetRes: () => void
+ }) => unknown,
) => {
const state = {
dataset: mockDataset,
@@ -161,7 +164,7 @@ describe('useFormState', () => {
expect(result.current.name).toBe('Test Dataset')
expect(result.current.description).toBe('Test description')
- expect(result.current.permission).toBe(DatasetPermission.onlyMe)
+ expect(result.current.permission).toBe(PermissionLevel.onlyMe)
expect(result.current.indexMethod).toBe(IndexingType.QUALIFIED)
expect(result.current.keywordNumber).toBe(10)
})
@@ -236,10 +239,10 @@ describe('useFormState', () => {
const { result } = renderHook(() => useFormState(mockDataset))
act(() => {
- result.current.setPermission(DatasetPermission.allTeamMembers)
+ result.current.setPermission(PermissionLevel.allTeamMembers)
})
- expect(result.current.permission).toBe(DatasetPermission.allTeamMembers)
+ expect(result.current.permission).toBe(PermissionLevel.allTeamMembers)
})
it('should update indexMethod when setIndexMethod is called', () => {
@@ -444,7 +447,7 @@ describe('useFormState', () => {
body: expect.objectContaining({
name: 'Test Dataset',
description: 'Test description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
}),
})
})
@@ -557,7 +560,7 @@ describe('useFormState', () => {
const { result } = renderHook(() => useFormState(mockDataset))
act(() => {
- result.current.setPermission(DatasetPermission.partialMembers)
+ result.current.setPermission(PermissionLevel.partialMembers)
result.current.setSelectedMemberIDs(['user-1', 'user-2'])
})
diff --git a/web/app/components/datasets/settings/form/hooks/use-form-state.ts b/web/app/components/datasets/settings/form/hooks/use-form-state.ts
index b0c65b101eb..fd276f2aa3c 100644
--- a/web/app/components/datasets/settings/form/hooks/use-form-state.ts
+++ b/web/app/components/datasets/settings/form/hooks/use-form-state.ts
@@ -1,12 +1,9 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { IconPickerValue } from '@/app/components/base/icon-picker'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import type { Member } from '@/models/common'
-import type {
- DataSet,
- IconInfo,
- SummaryIndexSetting as SummaryIndexSettingType,
-} from '@/models/datasets'
+import type { IconInfo, SummaryIndexSetting as SummaryIndexSettingType } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { useQuery, useQueryClient, useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -21,7 +18,7 @@ import { toast } from '@/app/notifications'
import { useDatasetDetailContextWithSelector } from '@/context/dataset-detail'
import { workspacePermissionKeysAtom } from '@/context/permission-state'
import { userProfileQueryOptions } from '@/features/account-profile/client'
-import { DatasetPermission } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { consoleQuery } from '@/service/console'
import { updateDatasetSetting } from '@/service/datasets'
import { getDatasetACLCapabilities } from '@/utils/permission'
@@ -35,7 +32,7 @@ const DEFAULT_APP_ICON: IconInfo = {
icon_url: '',
}
-export const useFormState = (currentDataset: DataSet) => {
+export const useFormState = (currentDataset: DatasetDetailWithPartialMembersResponse) => {
const { t } = useTranslation(['appDebug', 'common', 'datasetSettings'])
const mutateDatasets = useDatasetDetailContextWithSelector((state) => state.mutateDatasetRes)
const { data: currentUserId } = useSuspenseQuery({
@@ -70,7 +67,7 @@ export const useFormState = (currentDataset: DataSet) => {
)
// Permission state
- const [permission, setPermission] = useState<DatasetPermission | undefined>(
+ const [permission, setPermission] = useState<PermissionLevel | undefined>(
currentDataset.permission,
)
const [selectedMemberIDs, setSelectedMemberIDs] = useState<string[]>(
@@ -135,7 +132,7 @@ export const useFormState = (currentDataset: DataSet) => {
}, [queryClient])
// Derive member list from API data
- const memberList = useMemo<Member[]>(() => {
+ const memberList = useMemo<AccountWithRoleResponse[]>(() => {
return membersData?.accounts ?? []
}, [membersData])
@@ -222,7 +219,7 @@ export const useFormState = (currentDataset: DataSet) => {
}
}
- if (permission === DatasetPermission.partialMembers) {
+ if (permission === PermissionLevel.partialMembers) {
body.partial_member_list = selectedMemberIDs.map((id) => {
return {
user_id: id,
diff --git a/web/app/components/datasets/settings/form/index.tsx b/web/app/components/datasets/settings/form/index.tsx
index 5c1f6e2623f..91212580078 100644
--- a/web/app/components/datasets/settings/form/index.tsx
+++ b/web/app/components/datasets/settings/form/index.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { Button } from '@langgenius/dify-ui/button'
import { Separator } from '@langgenius/dify-ui/separator'
import { useTranslation } from 'react-i18next'
@@ -9,7 +9,11 @@ import ExternalKnowledgeSection from './components/external-knowledge-section'
import IndexingSection from './components/indexing-section'
import { useFormState } from './hooks/use-form-state'
-const DatasetSettingsForm = ({ currentDataset }: { currentDataset: DataSet }) => {
+const DatasetSettingsForm = ({
+ currentDataset,
+}: {
+ currentDataset: DatasetDetailWithPartialMembersResponse
+}) => {
const { t } = useTranslation(['datasetSettings'])
const {
canEditSettings,
diff --git a/web/app/components/datasets/settings/permission-selector/__tests__/index.spec.tsx b/web/app/components/datasets/settings/permission-selector/__tests__/index.spec.tsx
index 6e2c5e23169..175d7245589 100644
--- a/web/app/components/datasets/settings/permission-selector/__tests__/index.spec.tsx
+++ b/web/app/components/datasets/settings/permission-selector/__tests__/index.spec.tsx
@@ -1,12 +1,12 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { ComponentProps, ReactNode } from 'react'
-import type { Member } from '@/models/common'
import { QueryClientProvider } from '@tanstack/react-query'
import { render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { Provider } from 'jotai'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { DatasetPermission } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createSystemFeaturesFixture } from '@/test/console/system-features'
import { createQueryAtomTestStore } from '@/test/query-atom'
import PermissionSelector from '../index'
@@ -21,7 +21,7 @@ const currentUser = {
timezone: 'UTC',
}
-const memberList: Member[] = [
+const memberList: AccountWithRoleResponse[] = [
{
...currentUser,
avatar_url: '',
@@ -58,7 +58,7 @@ const memberList: Member[] = [
]
const defaultProps: ComponentProps<typeof PermissionSelector> = {
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
value: ['user-1'],
memberList,
onChange: vi.fn(),
@@ -127,23 +127,22 @@ describe('PermissionSelector', () => {
})
it.each([
- [DatasetPermission.onlyMe, /permissionsOnlyMe/],
- [DatasetPermission.allTeamMembers, /permissionsAllMember/],
+ [PermissionLevel.onlyMe, /permissionsOnlyMe/],
+ [PermissionLevel.allTeamMembers, /permissionsAllMember/],
])('selects %s and closes the popover', async (permission, optionName) => {
const user = userEvent.setup()
const onChange = vi.fn()
renderSelector({
permission:
- permission === DatasetPermission.onlyMe
- ? DatasetPermission.allTeamMembers
- : DatasetPermission.onlyMe,
+ permission === PermissionLevel.onlyMe
+ ? PermissionLevel.allTeamMembers
+ : PermissionLevel.onlyMe,
onChange,
})
await user.click(
screen.getByRole('button', {
- name:
- permission === DatasetPermission.onlyMe ? /permissionsAllMember/ : /permissionsOnlyMe/,
+ name: permission === PermissionLevel.onlyMe ? /permissionsAllMember/ : /permissionsOnlyMe/,
}),
)
const popover = screen.getByRole('dialog', { name: /form.permissions/ })
@@ -163,7 +162,7 @@ describe('PermissionSelector', () => {
const popover = screen.getByRole('dialog', { name: /form.permissions/ })
await user.click(within(popover).getByRole('radio', { name: /permissionsInvitedMembers/ }))
- expect(onChange).toHaveBeenCalledWith(DatasetPermission.partialMembers)
+ expect(onChange).toHaveBeenCalledWith(PermissionLevel.partialMembers)
expect(onMemberSelect).toHaveBeenCalledWith(['user-1'])
expect(screen.getByRole('dialog', { name: /form.permissions/ })).toBeInTheDocument()
})
@@ -179,7 +178,7 @@ describe('PermissionSelector', () => {
onlyMe.focus()
await user.keyboard('{ArrowDown}')
- expect(onChange).toHaveBeenCalledWith(DatasetPermission.allTeamMembers)
+ expect(onChange).toHaveBeenCalledWith(PermissionLevel.allTeamMembers)
expect(dialog).toBeInTheDocument()
})
@@ -190,7 +189,7 @@ describe('PermissionSelector', () => {
const user = userEvent.setup()
const onMemberSelect = vi.fn()
renderSelector({
- permission: DatasetPermission.partialMembers,
+ permission: PermissionLevel.partialMembers,
value,
onMemberSelect,
})
@@ -203,7 +202,7 @@ describe('PermissionSelector', () => {
it('filters members after the search debounce and clears the query', async () => {
const user = userEvent.setup()
- renderSelector({ permission: DatasetPermission.partialMembers })
+ renderSelector({ permission: PermissionLevel.partialMembers })
await user.click(screen.getByRole('button', { name: /Current User/ }))
const search = screen.getByRole('searchbox', { name: /operation.search/ })
@@ -223,7 +222,7 @@ describe('PermissionSelector', () => {
it('shows the empty state when no member matches', async () => {
const user = userEvent.setup()
- renderSelector({ permission: DatasetPermission.partialMembers })
+ renderSelector({ permission: PermissionLevel.partialMembers })
await user.click(screen.getByRole('button', { name: /Current User/ }))
await user.type(screen.getByRole('searchbox', { name: /operation.search/ }), 'Nobody')
diff --git a/web/app/components/datasets/settings/permission-selector/index.tsx b/web/app/components/datasets/settings/permission-selector/index.tsx
index 78b3bc321a2..0f1587947fb 100644
--- a/web/app/components/datasets/settings/permission-selector/index.tsx
+++ b/web/app/components/datasets/settings/permission-selector/index.tsx
@@ -1,4 +1,4 @@
-import type { Member } from '@/models/common'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import { Avatar, AvatarFallback, AvatarImage } from '@langgenius/dify-ui/avatar'
import { cn } from '@langgenius/dify-ui/cn'
import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '@langgenius/dify-ui/popover'
@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next'
import { SearchInput } from '@/app/components/base/search-input'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
-import { DatasetPermission } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { getAvatarInitial } from '@/utils/avatar'
import MemberItem from './member-item'
import PermissionItem from './permission-item'
@@ -18,10 +18,10 @@ import PermissionItem from './permission-item'
type PermissionSelectorProps = {
'aria-labelledby'?: string
disabled?: boolean
- permission?: DatasetPermission
+ permission?: PermissionLevel
value: string[]
- memberList: Member[]
- onChange: (permission?: DatasetPermission) => void
+ memberList: AccountWithRoleResponse[]
+ onChange: (permission?: PermissionLevel) => void
onMemberSelect: (value: string[]) => void
}
@@ -47,7 +47,7 @@ const PermissionSelector = ({
const [keywords, setKeywords] = useState('')
const debouncedKeywords = useDebouncedValue(keywords, 500)
const searchKeywords = keywords ? debouncedKeywords : ''
- const selectMember = (member: Member) => {
+ const selectMember = (member: AccountWithRoleResponse) => {
if (value.includes(member.id)) onMemberSelect(value.filter((id) => id !== member.id))
else onMemberSelect([...value, member.id])
}
@@ -69,9 +69,9 @@ const PermissionSelector = ({
[memberList, searchKeywords, userProfile.id],
)
- const isOnlyMe = permission === DatasetPermission.onlyMe
- const isAllTeamMembers = permission === DatasetPermission.allTeamMembers
- const isPartialMembers = permission === DatasetPermission.partialMembers
+ const isOnlyMe = permission === PermissionLevel.onlyMe
+ const isAllTeamMembers = permission === PermissionLevel.allTeamMembers
+ const isPartialMembers = permission === PermissionLevel.partialMembers
const showMe =
userProfile.name.includes(searchKeywords) || userProfile.email.includes(searchKeywords)
const selectedMemberNames = selectedMembers.map((member) => member.name).join(', ')
@@ -169,18 +169,18 @@ const PermissionSelector = ({
>
<PopoverTitle className="sr-only">{permissionLabel}</PopoverTitle>
<div className="relative w-120 max-w-full rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg shadow-shadow-shadow-5">
- <RadioGroup<DatasetPermission>
+ <RadioGroup<PermissionLevel>
value={permission}
onValueChange={(nextPermission) => {
onChange(nextPermission)
- if (nextPermission === DatasetPermission.partialMembers)
+ if (nextPermission === PermissionLevel.partialMembers)
onMemberSelect([userProfile.id])
}}
aria-label={permissionLabel}
className="flex-col items-stretch gap-0 p-1"
>
<PermissionItem
- value={DatasetPermission.onlyMe}
+ value={PermissionLevel.onlyMe}
closeOnSelect
leftIcon={
<Avatar className="shrink-0" size="sm" aria-hidden="true">
@@ -192,7 +192,7 @@ const PermissionSelector = ({
isSelected={isOnlyMe}
/>
<PermissionItem
- value={DatasetPermission.allTeamMembers}
+ value={PermissionLevel.allTeamMembers}
closeOnSelect
leftIcon={
<div className="flex size-6 shrink-0 items-center justify-center">
@@ -206,7 +206,7 @@ const PermissionSelector = ({
isSelected={isAllTeamMembers}
/>
<PermissionItem
- value={DatasetPermission.partialMembers}
+ value={PermissionLevel.partialMembers}
leftIcon={
<div className="flex size-6 shrink-0 items-center justify-center">
<span
diff --git a/web/app/components/datasets/settings/permission-selector/permission-item.tsx b/web/app/components/datasets/settings/permission-selector/permission-item.tsx
index ab13e34df30..5e3dd242754 100644
--- a/web/app/components/datasets/settings/permission-selector/permission-item.tsx
+++ b/web/app/components/datasets/settings/permission-selector/permission-item.tsx
@@ -1,10 +1,10 @@
import type { ReactNode } from 'react'
-import type { DatasetPermission } from '@/models/datasets'
+import type { PermissionLevel } from '@/models/permission'
import { PopoverClose } from '@langgenius/dify-ui/popover'
import { RadioItem } from '@langgenius/dify-ui/radio-group'
type PermissionItemProps = {
- value: DatasetPermission
+ value: PermissionLevel
leftIcon: ReactNode
text: string
isSelected: boolean
@@ -33,14 +33,14 @@ const PermissionItem = ({
if (closeOnSelect) {
return (
- <PopoverClose render={<RadioItem<DatasetPermission> value={value} />} className={className}>
+ <PopoverClose render={<RadioItem<PermissionLevel> value={value} />} className={className}>
{content}
</PopoverClose>
)
}
return (
- <RadioItem<DatasetPermission> value={value} className={className}>
+ <RadioItem<PermissionLevel> value={value} className={className}>
{content}
</RadioItem>
)
diff --git a/web/app/components/header/account-setting/data-source-page-new/__tests__/card.spec.tsx b/web/app/components/header/account-setting/data-source-page-new/__tests__/card.spec.tsx
index dc2cea4e09a..40cee33e2ab 100644
--- a/web/app/components/header/account-setting/data-source-page-new/__tests__/card.spec.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/__tests__/card.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceAuth } from '../types'
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { AddOAuthButtonProps } from '@/app/components/plugins/plugin-auth/types'
import { fireEvent, screen, waitFor, within } from '@testing-library/react'
import { FormTypeEnum } from '@/app/components/base/form/types'
@@ -142,7 +142,7 @@ describe('Card Component', () => {
...overrides,
})
- const mockItem: DataSourceAuth = {
+ const mockItem: DatasourceProviderAuthResponse = {
author: 'Test Author',
provider: 'test-provider',
plugin_id: 'test-plugin-id',
@@ -507,7 +507,7 @@ describe('Card Component', () => {
describe('Integration', () => {
it('should call handleAuthUpdate when Configure component triggers update', async () => {
// Arrange
- const configurableItem: DataSourceAuth = {
+ const configurableItem: DatasourceProviderAuthResponse = {
...mockItem,
credential_schema: [
{
@@ -533,7 +533,7 @@ describe('Card Component', () => {
it('should disable configure credential actions when user lacks credential.create', () => {
// Arrange
mockWorkspacePermissionKeys = ['credential.use']
- const configurableItem: DataSourceAuth = {
+ const configurableItem: DatasourceProviderAuthResponse = {
...mockItem,
credential_schema: [
{
diff --git a/web/app/components/header/account-setting/data-source-page-new/__tests__/configure.spec.tsx b/web/app/components/header/account-setting/data-source-page-new/__tests__/configure.spec.tsx
index e9ceba8393b..cd58166fba6 100644
--- a/web/app/components/header/account-setting/data-source-page-new/__tests__/configure.spec.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/__tests__/configure.spec.tsx
@@ -1,8 +1,8 @@
import type {
DatasourceOAuthSchemaResponse,
+ DatasourceProviderAuthResponse,
ProviderConfig,
} from '@dify/contracts/api/console/auth/types.gen'
-import type { DataSourceAuth } from '../types'
import type {
AddApiKeyButtonProps,
AddOAuthButtonProps,
@@ -65,7 +65,7 @@ describe('Configure Component', () => {
provider: 'test-provider',
}
- const mockItemBase: DataSourceAuth = {
+ const mockItemBase: DatasourceProviderAuthResponse = {
author: 'Test Author',
provider: 'test-provider',
plugin_id: 'test-plugin-id',
@@ -106,7 +106,7 @@ describe('Configure Component', () => {
it('should toggle and manage the open state correctly', () => {
// Arrange
// Add a schema so we can detect if it's open by checking for button presence
- const itemWithApiKey: DataSourceAuth = {
+ const itemWithApiKey: DatasourceProviderAuthResponse = {
...mockItemBase,
credential_schema: [mockFormSchema],
}
@@ -132,7 +132,7 @@ describe('Configure Component', () => {
describe('Conditional Rendering', () => {
it('should render AddApiKeyButton when credential_schema is non-empty', () => {
// Arrange
- const itemWithApiKey: DataSourceAuth = {
+ const itemWithApiKey: DatasourceProviderAuthResponse = {
...mockItemBase,
credential_schema: [mockFormSchema],
}
@@ -148,7 +148,7 @@ describe('Configure Component', () => {
it('should render AddOAuthButton when oauth_schema with client_schema is non-empty', () => {
// Arrange
- const itemWithOAuth: DataSourceAuth = {
+ const itemWithOAuth: DatasourceProviderAuthResponse = {
...mockItemBase,
oauth_schema: createOAuthSchema({
client_schema: [mockFormSchema],
@@ -166,7 +166,7 @@ describe('Configure Component', () => {
it('should render both buttons and the OR divider when both schemes are available', () => {
// Arrange
- const itemWithBoth: DataSourceAuth = {
+ const itemWithBoth: DatasourceProviderAuthResponse = {
...mockItemBase,
credential_schema: [mockFormSchema],
oauth_schema: createOAuthSchema({
@@ -187,7 +187,7 @@ describe('Configure Component', () => {
describe('Update Handling', () => {
it('should keep the permission dialog mounted after the OAuth menu closes', () => {
- const itemWithOAuth: DataSourceAuth = {
+ const itemWithOAuth: DatasourceProviderAuthResponse = {
...mockItemBase,
oauth_schema: createOAuthSchema({
client_schema: [mockFormSchema],
@@ -211,7 +211,7 @@ describe('Configure Component', () => {
it('should call onUpdate and close the portal when an update is triggered', () => {
// Arrange
- const itemWithApiKey: DataSourceAuth = {
+ const itemWithApiKey: DatasourceProviderAuthResponse = {
...mockItemBase,
credential_schema: [mockFormSchema],
}
@@ -234,7 +234,7 @@ describe('Configure Component', () => {
it('should handle missing onUpdate callback gracefully', () => {
// Arrange
- const itemWithBoth: DataSourceAuth = {
+ const itemWithBoth: DatasourceProviderAuthResponse = {
...mockItemBase,
credential_schema: [mockFormSchema],
oauth_schema: createOAuthSchema({
@@ -257,7 +257,7 @@ describe('Configure Component', () => {
describe('Props and Edge Cases', () => {
it('should pass the disabled prop to both configuration buttons', () => {
// Arrange
- const itemWithBoth: DataSourceAuth = {
+ const itemWithBoth: DatasourceProviderAuthResponse = {
...mockItemBase,
credential_schema: [mockFormSchema],
oauth_schema: createOAuthSchema({
@@ -284,7 +284,7 @@ describe('Configure Component', () => {
expect(screen.queryByTestId('add-oauth')).not.toBeInTheDocument()
// Arrange (Empty schemas)
- const itemEmpty: DataSourceAuth = {
+ const itemEmpty: DatasourceProviderAuthResponse = {
...mockItemBase,
credential_schema: [],
oauth_schema: createOAuthSchema({ client_schema: [] }),
@@ -297,7 +297,7 @@ describe('Configure Component', () => {
expect(screen.queryByTestId('add-oauth')).not.toBeInTheDocument()
// Arrange (Partial OAuth schema)
- const itemPartialOAuth: DataSourceAuth = {
+ const itemPartialOAuth: DatasourceProviderAuthResponse = {
...mockItemBase,
oauth_schema: createOAuthSchema({
is_oauth_custom_client_enabled: true,
@@ -325,7 +325,7 @@ describe('Configure Component', () => {
oauth_custom_client_params: {},
redirect_uri: '',
}),
- } as unknown as DataSourceAuth
+ } as unknown as DatasourceProviderAuthResponse
render(<Configure item={itemWithGlitchedSchema} pluginPayload={mockPluginPayload} />)
fireEvent.click(screen.getByRole('button', { name: /dataSource.configure/i }))
diff --git a/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsx b/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsx
index 267ab5fea0a..9ae2b46c2d2 100644
--- a/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { UseQueryResult } from '@tanstack/react-query'
-import type { DataSourceAuth } from '../types'
import type { PluginDetail } from '@/app/components/plugins/types'
import { fireEvent, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -97,7 +97,7 @@ vi.mock('@/app/components/header/account-setting/update-setting-dialog', () => (
}))
describe('DataSourcePage Component', () => {
- const mockProviders: DataSourceAuth[] = [
+ const mockProviders: DatasourceProviderAuthResponse[] = [
{
author: 'Dify',
provider: 'dify',
@@ -219,7 +219,7 @@ describe('DataSourcePage Component', () => {
mockDataSourceListAuth.mockReturnValue({
data: { result: [] },
isLoading: false,
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage stickyToolbar />, {
@@ -252,7 +252,7 @@ describe('DataSourcePage Component', () => {
mockDataSourceListAuth.mockReturnValue({
data: undefined,
isLoading: true,
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage stickyToolbar />, {
@@ -273,7 +273,7 @@ describe('DataSourcePage Component', () => {
// Arrange
mockDataSourceListAuth.mockReturnValue({
data: { result: mockProviders },
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage />, {
@@ -290,7 +290,7 @@ describe('DataSourcePage Component', () => {
// Arrange
mockDataSourceListAuth.mockReturnValue({
data: { result: mockProviders },
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
vi.mocked(useInstalledPluginList).mockReturnValue({
data: { plugins: [mockPluginDetail], total: 1 },
} as unknown as ReturnType<typeof useInstalledPluginList>)
@@ -316,7 +316,7 @@ describe('DataSourcePage Component', () => {
// Arrange
mockDataSourceListAuth.mockReturnValue({
data: { result: mockProviders },
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage />, {
@@ -336,7 +336,7 @@ describe('DataSourcePage Component', () => {
mockDataSourceListAuth.mockReturnValue({
data: { result: mockProviders },
isLoading: false,
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
const user = userEvent.setup()
renderWithConsoleQuery(<DataSourcePage />, {
systemFeatures: { enable_marketplace: false },
@@ -360,7 +360,7 @@ describe('DataSourcePage Component', () => {
// Arrange
mockDataSourceListAuth.mockReturnValue({
data: { result: mockProviders },
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage />, {
@@ -376,7 +376,7 @@ describe('DataSourcePage Component', () => {
// Arrange
mockDataSourceListAuth.mockReturnValue({
data: undefined,
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage />, {
@@ -391,7 +391,7 @@ describe('DataSourcePage Component', () => {
// Arrange
mockDataSourceListAuth.mockReturnValue({
data: { result: [] },
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage />, {
@@ -407,7 +407,7 @@ describe('DataSourcePage Component', () => {
// Arrange
mockDataSourceListAuth.mockReturnValue({
data: { result: [] },
- } as unknown as UseQueryResult<{ result: DataSourceAuth[] }, Error>)
+ } as unknown as UseQueryResult<{ result: DatasourceProviderAuthResponse[] }, Error>)
// Act
renderWithConsoleQuery(<DataSourcePage />, {
diff --git a/web/app/components/header/account-setting/data-source-page-new/__tests__/install-from-marketplace.spec.tsx b/web/app/components/header/account-setting/data-source-page-new/__tests__/install-from-marketplace.spec.tsx
index e802e8a3e28..d851b56036a 100644
--- a/web/app/components/header/account-setting/data-source-page-new/__tests__/install-from-marketplace.spec.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/__tests__/install-from-marketplace.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceAuth } from '../types'
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { Plugin } from '@/app/components/plugins/types'
import { fireEvent, render, screen } from '@testing-library/react'
import { useTheme } from 'next-themes'
@@ -74,7 +74,7 @@ vi.mock('@/app/components/plugins/plugin-page/use-reference-setting', () => ({
}))
describe('InstallFromMarketplace Component', () => {
- const mockProviders: DataSourceAuth[] = [
+ const mockProviders: DatasourceProviderAuthResponse[] = [
{
author: 'Author',
provider: 'provider',
diff --git a/web/app/components/header/account-setting/data-source-page-new/__tests__/item.spec.tsx b/web/app/components/header/account-setting/data-source-page-new/__tests__/item.spec.tsx
index d2e4eca8044..3f1dd89f938 100644
--- a/web/app/components/header/account-setting/data-source-page-new/__tests__/item.spec.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/__tests__/item.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '../types'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { CredentialTypeEnum } from '@/app/components/plugins/plugin-auth/types'
@@ -22,7 +22,7 @@ const triggerRename = async () => {
describe('Item Component', () => {
const mockOnAction = vi.fn()
- const mockCredentialItem: DataSourceCredential = {
+ const mockCredentialItem: DatasourceCredentialResponse = {
id: 'test-id',
name: 'Test Credential',
credential: {},
diff --git a/web/app/components/header/account-setting/data-source-page-new/__tests__/operator.spec.tsx b/web/app/components/header/account-setting/data-source-page-new/__tests__/operator.spec.tsx
index 37a8653ac3c..07d8313e05a 100644
--- a/web/app/components/header/account-setting/data-source-page-new/__tests__/operator.spec.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/__tests__/operator.spec.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from '../types'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { CredentialTypeEnum } from '@/app/components/plugins/plugin-auth/types'
@@ -14,7 +14,7 @@ describe('Operator Component', () => {
const mockOnAction = vi.fn()
const mockOnRename = vi.fn()
- const createMockCredential = (type: CredentialTypeEnum): DataSourceCredential => ({
+ const createMockCredential = (type: CredentialTypeEnum): DatasourceCredentialResponse => ({
id: 'test-id',
name: 'Test Credential',
credential: {},
diff --git a/web/app/components/header/account-setting/data-source-page-new/card.tsx b/web/app/components/header/account-setting/data-source-page-new/card.tsx
index a285438c32e..9d68d4fcb78 100644
--- a/web/app/components/header/account-setting/data-source-page-new/card.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/card.tsx
@@ -1,4 +1,7 @@
-import type { DataSourceAuth, DataSourceCredential } from './types'
+import type {
+ DatasourceCredentialResponse,
+ DatasourceProviderAuthResponse,
+} from '@dify/contracts/api/console/auth/types.gen'
import type { PluginDetail } from '@/app/components/plugins/types'
import {
AlertDialog,
@@ -30,7 +33,7 @@ const getPluginVersion = (uniqueIdentifier?: string) => {
}
type CardProps = {
- item: DataSourceAuth
+ item: DatasourceProviderAuthResponse
disabled?: boolean
pluginDetail?: PluginDetail
onPluginUpdate?: (isDelete?: boolean) => void
@@ -86,7 +89,7 @@ const Card = ({ item, disabled, pluginDetail, onPluginUpdate }: CardProps) => {
const handleAction = useCallback(
(
action: string,
- credentialItem: DataSourceCredential,
+ credentialItem: DatasourceCredentialResponse,
renamePayload?: { credential_id: string; name: string },
) => {
if (action === 'edit') {
diff --git a/web/app/components/header/account-setting/data-source-page-new/configure.tsx b/web/app/components/header/account-setting/data-source-page-new/configure.tsx
index 9c9334dc319..041450788ff 100644
--- a/web/app/components/header/account-setting/data-source-page-new/configure.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/configure.tsx
@@ -1,5 +1,5 @@
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { ReactNode } from 'react'
-import type { DataSourceAuth } from './types'
import type {
AddApiKeyButtonProps,
AddOAuthButtonProps,
@@ -14,7 +14,7 @@ import { useRenderI18nObject } from '@/hooks/use-i18n'
import { providerConfigToFormSchema } from './utils'
type ConfigureProps = {
- item: DataSourceAuth
+ item: DatasourceProviderAuthResponse
pluginPayload: PluginPayload
onUpdate?: () => void
disabled?: boolean
diff --git a/web/app/components/header/account-setting/data-source-page-new/install-from-marketplace.tsx b/web/app/components/header/account-setting/data-source-page-new/install-from-marketplace.tsx
index 1be41a72fe8..9cfbc1ad349 100644
--- a/web/app/components/header/account-setting/data-source-page-new/install-from-marketplace.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/install-from-marketplace.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceAuth } from './types'
+import type { DatasourceProviderAuthResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { Plugin } from '@/app/components/plugins/types'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
@@ -16,7 +16,7 @@ import { useMarketplaceAllPlugins } from './hooks'
type InstallFromMarketplaceProps = {
onOpenMarketplace?: () => void
- providers: DataSourceAuth[]
+ providers: DatasourceProviderAuthResponse[]
searchText: string
}
const InstallFromMarketplace = ({
diff --git a/web/app/components/header/account-setting/data-source-page-new/item.tsx b/web/app/components/header/account-setting/data-source-page-new/item.tsx
index 8f767b195e7..59cc9dcfeb7 100644
--- a/web/app/components/header/account-setting/data-source-page-new/item.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/item.tsx
@@ -1,4 +1,4 @@
-import type { DataSourceCredential } from './types'
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import { Button } from '@langgenius/dify-ui/button'
import { Input } from '@langgenius/dify-ui/input'
import { StatusDot } from '@langgenius/dify-ui/status-dot'
@@ -7,10 +7,10 @@ import { useTranslation } from 'react-i18next'
import Operator from './operator'
type ItemProps = {
- credentialItem: DataSourceCredential
+ credentialItem: DatasourceCredentialResponse
onAction: (
action: string,
- credentialItem: DataSourceCredential,
+ credentialItem: DatasourceCredentialResponse,
renamePayload?: { credential_id: string; name: string },
) => void
canUseCredential?: boolean
diff --git a/web/app/components/header/account-setting/data-source-page-new/operator.tsx b/web/app/components/header/account-setting/data-source-page-new/operator.tsx
index cdfe7bd4cc1..7f36e698902 100644
--- a/web/app/components/header/account-setting/data-source-page-new/operator.tsx
+++ b/web/app/components/header/account-setting/data-source-page-new/operator.tsx
@@ -1,5 +1,5 @@
+import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
import type { Ref } from 'react'
-import type { DataSourceCredential } from './types'
import {
DropdownMenu,
DropdownMenuContent,
@@ -13,8 +13,8 @@ import { useTranslation } from 'react-i18next'
import { CredentialTypeEnum } from '@/app/components/plugins/plugin-auth/types'
type OperatorProps = {
- credentialItem: DataSourceCredential
- onAction: (action: string, credentialItem: DataSourceCredential) => void
+ credentialItem: DatasourceCredentialResponse
+ onAction: (action: string, credentialItem: DatasourceCredentialResponse) => void
onRename?: () => void
triggerRef?: Ref<HTMLButtonElement>
canUseCredential?: boolean
diff --git a/web/app/components/header/account-setting/data-source-page-new/types.ts b/web/app/components/header/account-setting/data-source-page-new/types.ts
deleted file mode 100644
index ea2a402b011..00000000000
--- a/web/app/components/header/account-setting/data-source-page-new/types.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type {
- DatasourceCredentialResponse,
- DatasourceProviderAuthResponse,
-} from '@dify/contracts/api/console/auth/types.gen'
-
-export type DataSourceCredential = DatasourceCredentialResponse
-export type DataSourceAuth = DatasourceProviderAuthResponse
diff --git a/web/app/components/header/account-setting/members-page/__tests__/index.spec.tsx b/web/app/components/header/account-setting/members-page/__tests__/index.spec.tsx
index cbe621fd653..624f8e2adb0 100644
--- a/web/app/components/header/account-setting/members-page/__tests__/index.spec.tsx
+++ b/web/app/components/header/account-setting/members-page/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Role } from '@/models/access-control'
-import type { Member } from '@/models/common'
import type { ConsoleQueryTestOptions } from '@/test/console/query-data'
import type { ConsoleStateFixture } from '@/test/console/state-fixture'
import { screen, waitFor, within } from '@testing-library/react'
@@ -126,7 +126,7 @@ vi.mock('../member-menu', () => ({
onTransferOwnership,
canTransferOwnership,
}: {
- member: Member
+ member: AccountWithRoleResponse
isCurrentUser?: boolean
onTransferOwnership?: () => void
canTransferOwnership?: boolean
@@ -161,7 +161,7 @@ vi.mock('../member-details-modal', () => ({
canAssignRoles,
onAssignSubmit,
}: {
- member: Member
+ member: AccountWithRoleResponse
onClose: () => void
canAssignRoles?: boolean
onAssignSubmit?: (roles: Role[]) => void
@@ -193,7 +193,7 @@ describe('MembersPage', () => {
const mockFormatTimeFromNow = vi.fn(() => 'just now')
const mockUpdateRolesOfMember = vi.fn()
- const mockAccounts: Member[] = [
+ const mockAccounts: AccountWithRoleResponse[] = [
{
id: '1',
name: 'Owner User',
@@ -410,7 +410,7 @@ describe('MembersPage', () => {
})
it('should show pending status and you indicator', () => {
- const pendingAccount: Member = {
+ const pendingAccount: AccountWithRoleResponse = {
...mockAccounts[1]!,
status: 'pending',
}
@@ -537,7 +537,7 @@ describe('MembersPage', () => {
})
it('should use created_at as fallback when last_active_at is empty', () => {
- const memberNoLastActive: Member = {
+ const memberNoLastActive: AccountWithRoleResponse = {
...mockAccounts[1]!,
last_active_at: null,
created_at: 1700000000,
@@ -589,7 +589,9 @@ describe('MembersPage', () => {
isCurrentWorkspaceManager: false,
} as unknown as ConsoleStateFixture)
vi.mocked(mockMembersHook).mockReturnValue({
- data: { accounts: [{ ...mockAccounts[1], role: 'unknown_role' as Member['role'] }] },
+ data: {
+ accounts: [{ ...mockAccounts[1], role: 'unknown_role' as AccountWithRoleResponse['role'] }],
+ },
refetch: mockRefetch,
})
diff --git a/web/app/components/header/account-setting/members-page/__tests__/member-menu.spec.tsx b/web/app/components/header/account-setting/members-page/__tests__/member-menu.spec.tsx
index b37176d7146..6d946dbf8c9 100644
--- a/web/app/components/header/account-setting/members-page/__tests__/member-menu.spec.tsx
+++ b/web/app/components/header/account-setting/members-page/__tests__/member-menu.spec.tsx
@@ -1,5 +1,5 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Role } from '@/models/access-control'
-import type { Member } from '@/models/common'
import { QueryClient } from '@tanstack/react-query'
import { screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
@@ -58,7 +58,7 @@ const roles = [
createRole({ id: 'role-2', name: 'Second role' }),
]
-const member: Member = {
+const member: AccountWithRoleResponse = {
id: 'member-1',
name: 'Member User',
diff --git a/web/app/components/header/account-setting/members-page/__tests__/member-row.spec.tsx b/web/app/components/header/account-setting/members-page/__tests__/member-row.spec.tsx
index 7a67759b3c5..1be1ac6f7cc 100644
--- a/web/app/components/header/account-setting/members-page/__tests__/member-row.spec.tsx
+++ b/web/app/components/header/account-setting/members-page/__tests__/member-row.spec.tsx
@@ -1,4 +1,4 @@
-import type { Member } from '@/models/common'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import { screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now'
@@ -18,7 +18,7 @@ vi.mock('@tanstack/react-query', async (importOriginal) => {
vi.mock('@/hooks/use-format-time-from-now')
-const member: Member = {
+const member: AccountWithRoleResponse = {
id: 'member-1',
name: 'Member User',
diff --git a/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx b/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx
index bdb817a12d7..87c4e7ab4d1 100644
--- a/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/assign-roles-modal/index.tsx
@@ -20,14 +20,12 @@ type AssignRolesModalProps = {
onSubmit: (roles: Role[]) => void
}
-type AssignRolesModalBodyProps = AssignRolesModalProps
-
const AssignRolesModalBody = ({
selectedRoles,
allowMultipleRoles = true,
onClose,
onSubmit,
-}: AssignRolesModalBodyProps) => {
+}: AssignRolesModalProps) => {
const { t } = useTranslation(['common', 'workspaceMembers'])
const [selected, setSelected] = useState(selectedRoles)
const selectedRoleIds = selected.map((role) => role.id)
diff --git a/web/app/components/header/account-setting/members-page/index.tsx b/web/app/components/header/account-setting/members-page/index.tsx
index f295c9c0a88..b5fdce19489 100644
--- a/web/app/components/header/account-setting/members-page/index.tsx
+++ b/web/app/components/header/account-setting/members-page/index.tsx
@@ -1,7 +1,9 @@
'use client'
-import type { MemberInviteResponse } from '@dify/contracts/api/console/workspaces/types.gen'
+import type {
+ AccountWithRoleResponse,
+ MemberInviteResponse,
+} from '@dify/contracts/api/console/workspaces/types.gen'
import type { Role } from '@/models/access-control'
-import type { Member } from '@/models/common'
import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'
import { useMutation, useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -65,14 +67,14 @@ const MembersPage = () => {
accounts.length >= features.members.limit
const [editWorkspaceModalVisible, setEditWorkspaceModalVisible] = useState(false)
const [showTransferOwnershipModal, setShowTransferOwnershipModal] = useState(false)
- const [detailsMember, setDetailsMember] = useState<Member | null>(null)
+ const [detailsMember, setDetailsMember] = useState<AccountWithRoleResponse | null>(null)
const canManageMembers = hasPermission(workspacePermissionKeys, 'workspace.member.manage')
const roleColumnLabel = systemFeatures.rbac_enabled
? t(($) => $['members.roles'], { ns: 'workspaceMembers' })
: t(($) => $['members.role'], { ns: 'workspaceMembers' })
- const handleOpenDetails = useCallback((member: Member) => {
+ const handleOpenDetails = useCallback((member: AccountWithRoleResponse) => {
setDetailsMember(member)
}, [])
diff --git a/web/app/components/header/account-setting/members-page/member-details-modal/__tests__/index.spec.tsx b/web/app/components/header/account-setting/members-page/member-details-modal/__tests__/index.spec.tsx
index e7e5bba4177..485cdb4bcfc 100644
--- a/web/app/components/header/account-setting/members-page/member-details-modal/__tests__/index.spec.tsx
+++ b/web/app/components/header/account-setting/members-page/member-details-modal/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Role } from '@/models/access-control'
-import type { Member } from '@/models/common'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { vi } from 'vite-plus/test'
@@ -31,7 +31,7 @@ const createRole = (overrides: Partial<Role>): Role => ({
...overrides,
})
-const member: Member = {
+const member: AccountWithRoleResponse = {
id: 'member-1',
name: 'Admin User',
diff --git a/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx b/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
index fcd9ac706f7..71912727414 100644
--- a/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
+++ b/web/app/components/header/account-setting/members-page/member-details-modal/index.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Role } from '@/models/access-control'
-import type { Member } from '@/models/common'
import { Avatar, AvatarFallback, AvatarImage } from '@langgenius/dify-ui/avatar'
import { Button } from '@langgenius/dify-ui/button'
import { Dialog, DialogClose, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'
@@ -18,7 +18,7 @@ import AssignRolesModal from '../assign-roles-modal'
import PermissionRoleChip from './permission-role-chip'
type MemberDetailsModalProps = {
- member: Member
+ member: AccountWithRoleResponse
canAssignRoles?: boolean
allowMultipleRoles?: boolean
onClose: () => void
diff --git a/web/app/components/header/account-setting/members-page/member-menu.tsx b/web/app/components/header/account-setting/members-page/member-menu.tsx
index 98b9a899bce..8ac71f11927 100644
--- a/web/app/components/header/account-setting/members-page/member-menu.tsx
+++ b/web/app/components/header/account-setting/members-page/member-menu.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Role } from '@/models/access-control'
-import type { Member } from '@/models/common'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -27,7 +27,7 @@ import { createSelectedRolePlaceholder } from '../workspace-role-list-query'
import AssignRolesModal from './assign-roles-modal'
type MemberMenuProps = {
- member: Member
+ member: AccountWithRoleResponse
isCurrentUser: boolean
canTransferOwnership?: boolean
allowMultipleRoles?: boolean
diff --git a/web/app/components/header/account-setting/members-page/member-row.tsx b/web/app/components/header/account-setting/members-page/member-row.tsx
index 117be0b02b4..0f16499dd98 100644
--- a/web/app/components/header/account-setting/members-page/member-row.tsx
+++ b/web/app/components/header/account-setting/members-page/member-row.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { MouseEvent } from 'react'
-import type { Member } from '@/models/common'
import { Avatar, AvatarFallback, AvatarImage } from '@langgenius/dify-ui/avatar'
import { memo, useCallback } from 'react'
import { useTranslation } from 'react-i18next'
@@ -10,7 +10,7 @@ import MemberMenu from './member-menu'
import RoleBadges from './role-badges'
type MemberRowProps = {
- member: Member
+ member: AccountWithRoleResponse
roles: Array<{
id: string
name: string
@@ -19,7 +19,7 @@ type MemberRowProps = {
canManage: boolean
canTransferOwnership: boolean
allowMultipleRoles: boolean
- onOpenDetails: (member: Member) => void
+ onOpenDetails: (member: AccountWithRoleResponse) => void
onTransferOwnership: () => void
}
diff --git a/web/app/components/header/account-setting/model-provider-page/declarations.ts b/web/app/components/header/account-setting/model-provider-page/declarations.ts
index 554f2bc84c6..22ee89e6a24 100644
--- a/web/app/components/header/account-setting/model-provider-page/declarations.ts
+++ b/web/app/components/header/account-setting/model-provider-page/declarations.ts
@@ -1,7 +1,7 @@
import type {
FormType as ContractFormType,
- QuotaConfiguration as ContractQuotaConfiguration,
GetWorkspacesCurrentDefaultModelResponse,
+ QuotaConfiguration,
} from '@dify/contracts/api/console/workspaces/types.gen'
import type { Field } from '@/app/components/workflow/nodes/llm/types'
@@ -199,8 +199,6 @@ export const QuotaUnitEnum = {
export type QuotaUnitEnum = (typeof QuotaUnitEnum)[keyof typeof QuotaUnitEnum]
-type QuotaConfiguration = ContractQuotaConfiguration
-
export type Credential = {
credential_id: string
credential_name?: string
diff --git a/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx b/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx
index f4fe27441da..cbfffca25a4 100644
--- a/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx
+++ b/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx
@@ -1,6 +1,7 @@
'use client'
+import type { PluginInstallTaskStartResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { FC } from 'react'
-import type { InstallPackageResponse, Plugin, PluginManifestInMarket } from '../../../types'
+import type { Plugin, PluginManifestInMarket } from '../../../types'
import { Button } from '@langgenius/dify-ui/button'
import { RiLoader2Line } from '@remixicon/react'
import { useSuspenseQuery } from '@tanstack/react-query'
@@ -78,7 +79,7 @@ const Installed: FC<Props> = ({
try {
let taskId
let isInstalled
- let installResponse: InstallPackageResponse | undefined
+ let installResponse: PluginInstallTaskStartResponse | undefined
if (hasInstalled) {
const response = await updatePackageFromMarketPlace({
original_plugin_unique_identifier: installedInfoPayload.uniqueIdentifier,
diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts b/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts
index 55a9345a882..98329acf875 100644
--- a/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts
+++ b/web/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema.ts
@@ -5,8 +5,8 @@ import type {
AppPartial,
WorkflowResponse,
} from '@dify/contracts/api/console/apps/types.gen'
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { FileUpload } from '@/app/components/base/features/types'
-import type { FileUploadConfigResponse } from '@/models/common'
import { useQuery } from '@tanstack/react-query'
import { useMemo } from 'react'
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
@@ -37,7 +37,7 @@ type InputSchemaItem = {
variable?: string
type: string
required: boolean
- fileUploadConfig?: FileUploadConfigResponse
+ fileUploadConfig?: UploadConfig
[key: string]: unknown
}
@@ -77,7 +77,7 @@ function buildFileConfig(fileConfig: FileUpload | undefined) {
function mapBasicAppInputItem(
item: Record<string, unknown>,
- fileUploadConfig?: FileUploadConfigResponse,
+ fileUploadConfig?: UploadConfig,
): InputSchemaItem | null {
for (const [key, type] of Object.entries(BASIC_INPUT_TYPE_MAP)) {
if (!item[key]) continue
@@ -105,7 +105,7 @@ function mapBasicAppInputItem(
function mapWorkflowVariable(
variable: Record<string, unknown>,
- fileUploadConfig?: FileUploadConfigResponse,
+ fileUploadConfig?: UploadConfig,
): InputSchemaItem {
const needsFileConfig = WORKFLOW_FILE_VAR_TYPES.has(variable.type as InputVarType)
@@ -119,7 +119,7 @@ function mapWorkflowVariable(
function createImageUploadSchema(
basicFileConfig: ReturnType<typeof buildFileConfig>,
- fileUploadConfig?: FileUploadConfigResponse,
+ fileUploadConfig?: UploadConfig,
): InputSchemaItem {
return {
label: 'Image Upload',
@@ -133,7 +133,7 @@ function createImageUploadSchema(
function buildBasicAppSchema(
currentApp: AppDetailWithSite,
- fileUploadConfig?: FileUploadConfigResponse,
+ fileUploadConfig?: UploadConfig,
): InputSchemaItem[] {
const userInputForm = currentApp.model_config?.user_input_form as
| Array<Record<string, unknown>>
@@ -148,7 +148,7 @@ function buildBasicAppSchema(
function buildWorkflowSchema(
workflow: Pick<WorkflowResponse, 'graph'>,
- fileUploadConfig?: FileUploadConfigResponse,
+ fileUploadConfig?: UploadConfig,
): InputSchemaItem[] {
const nodes = workflow.graph.nodes
if (!Array.isArray(nodes)) return []
@@ -171,7 +171,7 @@ type UseAppInputsFormSchemaResult = {
isError: boolean
isLoading: boolean
retry: () => void
- fileUploadConfig?: FileUploadConfigResponse
+ fileUploadConfig?: UploadConfig
}
export function useAppInputsFormSchema({
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.helpers.ts b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.helpers.ts
index b85df1eb2b4..ae8e50565a6 100644
--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.helpers.ts
+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.helpers.ts
@@ -1,3 +1,4 @@
+import type { ReasoningConfigValue } from './reasoning-config-form'
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { ToolFormSchema } from '@/app/components/tools/utils/to-form-schema'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
@@ -6,19 +7,6 @@ import { FormTypeEnum } from '@/app/components/header/account-setting/model-prov
import { VarKindType } from '@/app/components/workflow/nodes/_base/types'
import { VarType } from '@/app/components/workflow/types'
-type ReasoningConfigInputValue = {
- type?: VarKindType
- value?: unknown
- [key: string]: unknown
-} | null
-
-type ReasoningConfigInput = {
- value: ReasoningConfigInputValue
- auto?: 0 | 1
-}
-
-export type ReasoningConfigValue = Record<string, ReasoningConfigInput>
-
export const getVarKindType = (type: string) => {
if (type === FormTypeEnum.file || type === FormTypeEnum.files) return VarKindType.variable
@@ -179,7 +167,7 @@ export const updateVariableSelectorValue = (
})
}
-export const getFieldFlags = (type: string, varInput?: ReasoningConfigInputValue) => {
+export const getFieldFlags = (type: string, varInput?: ReasoningConfigValue[string]['value']) => {
const isDateRange = type === FormTypeEnum.dateRange
const isDate = type === FormTypeEnum.date
const isString = type === FormTypeEnum.textInput || type === FormTypeEnum.secretInput
diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx
index c6eff351693..2edef0bc967 100644
--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx
@@ -1,5 +1,4 @@
import type { Node } from 'reactflow'
-import type { ReasoningConfigValue as ReasoningConfigValueShape } from './reasoning-config-form.helpers'
import type { ToolFormSchema } from '@/app/components/tools/utils/to-form-schema'
import type { NodeOutPutVar, ValueSelector } from '@/app/components/workflow/types'
import { cn } from '@langgenius/dify-ui/cn'
@@ -42,7 +41,17 @@ import {
} from './reasoning-config-form.helpers'
import { SchemaDialog } from './schema-dialog'
-export type ReasoningConfigValue = ReasoningConfigValueShape
+export type ReasoningConfigValue = Record<
+ string,
+ {
+ value: {
+ type?: VarKindType
+ value?: unknown
+ [key: string]: unknown
+ } | null
+ auto?: 0 | 1
+ }
+>
type Props = Readonly<{
value: ReasoningConfigValue
diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts
index 895a9e68adc..e9ec6c44ebf 100644
--- a/web/app/components/plugins/types.ts
+++ b/web/app/components/plugins/types.ts
@@ -4,7 +4,6 @@ import type {
EndpointProviderDeclarationResponse,
PluginInstallTask,
PluginInstallTaskPluginStatus,
- PluginInstallTaskStartResponse,
} from '@dify/contracts/api/console/workspaces/types.gen'
import type { FormTypeEnum } from '../base/form/types'
import type { CredentialFormSchemaBase } from '../header/account-setting/model-provider-page/declarations'
@@ -353,8 +352,6 @@ export type GitHubRepoReleaseResponse = {
assets: GitHubAsset[]
}
-export type InstallPackageResponse = PluginInstallTaskStartResponse
-
export type InstallStatusResponse = {
status: TaskStatus
taskId: string
@@ -382,8 +379,6 @@ export type PluginStatus = PluginInstallTaskPluginStatus & {
export type PluginTask = Omit<PluginInstallTask, 'plugins'> & { plugins: PluginStatus[] }
-export type PluginTaskStart = PluginInstallTask
-
export type MetaData = {
repo: string
version: string
diff --git a/web/app/components/rag-pipeline/hooks/__tests__/use-pipeline-run.spec.ts b/web/app/components/rag-pipeline/hooks/__tests__/use-pipeline-run.spec.ts
index ecf56bd1a29..d907a9208e8 100644
--- a/web/app/components/rag-pipeline/hooks/__tests__/use-pipeline-run.spec.ts
+++ b/web/app/components/rag-pipeline/hooks/__tests__/use-pipeline-run.spec.ts
@@ -1,4 +1,4 @@
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { act } from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { renderEditorHook as renderHook } from '@/app/components/workflow/editor-resource/__tests__/render'
@@ -318,7 +318,7 @@ describe('usePipelineRunByCanEdit', () => {
act(() => {
result.current.handleRestoreFromPublishedWorkflow(
- publishedWorkflow as unknown as VersionHistory,
+ publishedWorkflow as unknown as FetchWorkflowDraftResponse,
)
})
@@ -346,7 +346,7 @@ describe('usePipelineRunByCanEdit', () => {
act(() => {
result.current.handleRestoreFromPublishedWorkflow(
- publishedWorkflow as unknown as VersionHistory,
+ publishedWorkflow as unknown as FetchWorkflowDraftResponse,
)
})
@@ -370,7 +370,7 @@ describe('usePipelineRunByCanEdit', () => {
act(() => {
result.current.handleRestoreFromPublishedWorkflow(
- publishedWorkflow as unknown as VersionHistory,
+ publishedWorkflow as unknown as FetchWorkflowDraftResponse,
)
})
@@ -396,7 +396,7 @@ describe('usePipelineRunByCanEdit', () => {
act(() => {
result.current.handleRestoreFromPublishedWorkflow(
- publishedWorkflow as unknown as VersionHistory,
+ publishedWorkflow as unknown as FetchWorkflowDraftResponse,
)
})
diff --git a/web/app/components/rag-pipeline/hooks/use-pipeline-config.ts b/web/app/components/rag-pipeline/hooks/use-pipeline-config.ts
index 547b9facce3..643d9e3df62 100644
--- a/web/app/components/rag-pipeline/hooks/use-pipeline-config.ts
+++ b/web/app/components/rag-pipeline/hooks/use-pipeline-config.ts
@@ -1,4 +1,4 @@
-import type { FileUploadConfigResponse } from '@/models/common'
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { useQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -47,7 +47,7 @@ export const usePipelineConfig = () => {
)
const handleUpdateWorkflowFileUploadConfig = useCallback(
- (config: FileUploadConfigResponse) => {
+ (config: UploadConfig) => {
const { setFileUploadConfig } = workflowStore.getState()
setFileUploadConfig(config)
},
diff --git a/web/app/components/rag-pipeline/hooks/use-pipeline-run.ts b/web/app/components/rag-pipeline/hooks/use-pipeline-run.ts
index 7c9214543f6..1026b5a8112 100644
--- a/web/app/components/rag-pipeline/hooks/use-pipeline-run.ts
+++ b/web/app/components/rag-pipeline/hooks/use-pipeline-run.ts
@@ -1,6 +1,6 @@
import type { useNodesSyncDraft } from './use-nodes-sync-draft'
import type { IOtherOptions } from '@/service/base'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { produce } from 'immer'
import { useAtomValue } from 'jotai'
import { useCallback, useRef } from 'react'
@@ -271,7 +271,7 @@ const usePipelineRunBase = (doSyncWorkflowDraft: DoSyncWorkflowDraft) => {
)
const handleRestoreFromPublishedWorkflow = useCallback(
- (publishedWorkflow: VersionHistory) => {
+ (publishedWorkflow: FetchWorkflowDraftResponse) => {
const nodes = publishedWorkflow.graph.nodes.map((node) => ({
...node,
selected: false,
diff --git a/web/app/components/rag-pipeline/utils/query-select.ts b/web/app/components/rag-pipeline/utils/query-select.ts
index ad12dfaa859..ac65e3bfcda 100644
--- a/web/app/components/rag-pipeline/utils/query-select.ts
+++ b/web/app/components/rag-pipeline/utils/query-select.ts
@@ -1,4 +1,7 @@
-import type { DocumentPipelineExecutionLogResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type {
+ DocumentPipelineExecutionLogResponse,
+ IndexingEstimateResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type {
PipelineGenerateResponse,
PipelineTemplateDetailResponse,
@@ -15,7 +18,7 @@ import type {
import type { Viewport } from 'reactflow'
import type { Dependency } from '@/app/components/plugins/types'
import type { Edge, Node } from '@/app/components/workflow/types'
-import type { FileIndexingEstimateResponse, IconInfo } from '@/models/datasets'
+import type { IconInfo } from '@/models/datasets'
import type {
PipelineExecutionLogResponse,
PipelineTemplate,
@@ -23,7 +26,7 @@ import type {
RAGPipelineVariable,
} from '@/models/pipeline'
import type { AppIconType } from '@/types/app'
-import type { NodeRunResult } from '@/types/workflow'
+import type { NodeTracing } from '@/types/workflow'
import { BlockEnum, SupportUploadFileTypes } from '@/app/components/workflow/types'
import { ChunkingMode } from '@/models/datasets'
import { DatasourceType, PipelineInputVarType } from '@/models/pipeline'
@@ -181,7 +184,7 @@ export const isPipelineProcessingRun = (
): response is PipelineGenerateResponse => 'batch' in response
// Preview runs return the indexing estimate as the workflow outputs.
-const isFileIndexingEstimate = (value: unknown): value is FileIndexingEstimateResponse =>
+const isFileIndexingEstimate = (value: unknown): value is IndexingEstimateResponse =>
isRecord(value) && typeof value.total_segments === 'number' && Array.isArray(value.preview)
export const selectPreviewRunEstimate = (response: WorkflowAppBlockingResponse) =>
@@ -195,7 +198,7 @@ const BLOCKS: Record<string, BlockEnum> = BlockEnum
export const selectDatasourceSingleRun = (
execution: WorkflowRunNodeExecutionResponse,
-): NodeRunResult => {
+): NodeTracing => {
const metadata = isRecord(execution.execution_metadata) ? execution.execution_metadata : undefined
return {
id: execution.id,
diff --git a/web/app/components/snippets/__tests__/create-snippet-dialog.spec.tsx b/web/app/components/snippets/__tests__/create-snippet-dialog.spec.tsx
index 57248fcc7eb..a0f32e0b6d6 100644
--- a/web/app/components/snippets/__tests__/create-snippet-dialog.spec.tsx
+++ b/web/app/components/snippets/__tests__/create-snippet-dialog.spec.tsx
@@ -1,4 +1,5 @@
-import type { SnippetCanvasData, SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
+import type { SnippetCanvasData } from '@/models/snippet'
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { PipelineInputVarType } from '@/models/pipeline'
@@ -11,7 +12,7 @@ const selectedGraph: SnippetCanvasData = {
viewport: { x: 12, y: 24, zoom: 0.8 },
}
-const inputFields: SnippetInputField[] = [
+const inputFields: InputVar[] = [
{
label: 'topic',
variable: 'topic',
diff --git a/web/app/components/snippets/components/__tests__/snippet-main.spec.tsx b/web/app/components/snippets/components/__tests__/snippet-main.spec.tsx
index 3ffad9db548..9615029dae5 100644
--- a/web/app/components/snippets/components/__tests__/snippet-main.spec.tsx
+++ b/web/app/components/snippets/components/__tests__/snippet-main.spec.tsx
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react'
import type { WorkflowProps } from '@/app/components/workflow'
-import type { SnippetDetail, SnippetDetailPayload, SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
+import type { SnippetDetail, SnippetDetailPayload } from '@/models/snippet'
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
import { renderWorkflowComponent } from '@/app/components/workflow/__tests__/workflow-test-env'
import { BlockEnum } from '@/app/components/workflow/types'
@@ -63,7 +64,7 @@ vi.mock('@/context/permission-state', async () => {
let capturedHooksStore: Record<string, unknown> | undefined
let capturedWorkflowNodes: WorkflowProps['nodes'] | undefined
let snippetDetailStoreState: {
- onFieldsChange?: (fields: SnippetInputField[]) => void
+ onFieldsChange?: (fields: InputVar[]) => void
readonly: boolean
reset: typeof mockReset
setNavigationState: typeof mockSetNavigationState
diff --git a/web/app/components/snippets/components/__tests__/snippet-run-panel.spec.tsx b/web/app/components/snippets/components/__tests__/snippet-run-panel.spec.tsx
index e718cf55759..58a06220930 100644
--- a/web/app/components/snippets/components/__tests__/snippet-run-panel.spec.tsx
+++ b/web/app/components/snippets/components/__tests__/snippet-run-panel.spec.tsx
@@ -1,4 +1,4 @@
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { fireEvent, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { ReactFlowProvider } from 'reactflow'
@@ -89,7 +89,7 @@ vi.mock('@/app/components/workflow/run/tracing-panel', () => ({
default: ({ list }: { list: unknown[] }) => <div>{`tracing-${list.length}`}</div>,
}))
-const fields: SnippetInputField[] = [
+const fields: InputVar[] = [
{
label: 'Topic',
variable: 'topic',
diff --git a/web/app/components/snippets/components/__tests__/snippet-sidebar.spec.tsx b/web/app/components/snippets/components/__tests__/snippet-sidebar.spec.tsx
index 6f2aa1866d4..3ee8d96f738 100644
--- a/web/app/components/snippets/components/__tests__/snippet-sidebar.spec.tsx
+++ b/web/app/components/snippets/components/__tests__/snippet-sidebar.spec.tsx
@@ -1,5 +1,6 @@
import type { InputVar } from '@/app/components/workflow/types'
-import type { SnippetDetail, SnippetInputField } from '@/models/snippet'
+import type { InputVar as PipelineInputVar } from '@/models/pipeline'
+import type { SnippetDetail } from '@/models/snippet'
import { fireEvent, render, screen } from '@testing-library/react'
import { toast } from '@/app/notifications'
import { PipelineInputVarType } from '@/models/pipeline'
@@ -81,7 +82,7 @@ const snippet: SnippetDetail = {
tags: [],
}
-const fields: SnippetInputField[] = [
+const fields: PipelineInputVar[] = [
{
type: PipelineInputVarType.textInput,
label: 'Query',
diff --git a/web/app/components/snippets/components/hooks/__tests__/use-snippet-input-field-actions.spec.ts b/web/app/components/snippets/components/hooks/__tests__/use-snippet-input-field-actions.spec.ts
index 98a78b4f42e..d5f49655fcd 100644
--- a/web/app/components/snippets/components/hooks/__tests__/use-snippet-input-field-actions.spec.ts
+++ b/web/app/components/snippets/components/hooks/__tests__/use-snippet-input-field-actions.spec.ts
@@ -1,4 +1,4 @@
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { act, renderHook } from '@testing-library/react'
import { PipelineInputVarType } from '@/models/pipeline'
import { useSnippetDraftStore } from '../../../draft-store'
@@ -12,7 +12,7 @@ vi.mock('../../../hooks/use-nodes-sync-draft', () => ({
}),
}))
-const createField = (overrides: Partial<SnippetInputField> = {}): SnippetInputField => ({
+const createField = (overrides: Partial<InputVar> = {}): InputVar => ({
type: PipelineInputVarType.textInput,
label: 'Blog URL',
variable: 'blog_url',
diff --git a/web/app/components/snippets/components/hooks/use-snippet-input-field-actions.ts b/web/app/components/snippets/components/hooks/use-snippet-input-field-actions.ts
index 70c8b8cff5b..97b8ecdd1e3 100644
--- a/web/app/components/snippets/components/hooks/use-snippet-input-field-actions.ts
+++ b/web/app/components/snippets/components/hooks/use-snippet-input-field-actions.ts
@@ -1,4 +1,4 @@
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { useCallback } from 'react'
import { useShallow } from 'zustand/react/shallow'
import { useSnippetDraftStore } from '../../draft-store'
@@ -22,7 +22,7 @@ export const useSnippetInputFieldActions = ({
)
const handleFieldsChange = useCallback(
- (newFields: SnippetInputField[]) => {
+ (newFields: InputVar[]) => {
if (!canEdit) return
setInputFields(newFields)
diff --git a/web/app/components/snippets/components/snippet-children.tsx b/web/app/components/snippets/components/snippet-children.tsx
index 77665049502..e8abdbc294d 100644
--- a/web/app/components/snippets/components/snippet-children.tsx
+++ b/web/app/components/snippets/components/snippet-children.tsx
@@ -1,12 +1,12 @@
'use client'
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import SnippetHeader from './snippet-header'
import SnippetWorkflowPanel from './workflow-panel'
type SnippetChildrenProps = {
snippetId: string
- fields: SnippetInputField[]
+ fields: InputVar[]
canSave: boolean
canEdit: boolean
isPublishing: boolean
diff --git a/web/app/components/snippets/components/snippet-main.tsx b/web/app/components/snippets/components/snippet-main.tsx
index 1d2c3cbe5ea..ab09e93f54e 100644
--- a/web/app/components/snippets/components/snippet-main.tsx
+++ b/web/app/components/snippets/components/snippet-main.tsx
@@ -2,7 +2,8 @@
import type { WorkflowProps } from '@/app/components/workflow'
import type { Shape as HooksStoreShape } from '@/app/components/workflow/hooks-store'
-import type { SnippetCanvasData, SnippetDetailPayload, SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
+import type { SnippetCanvasData, SnippetDetailPayload } from '@/models/snippet'
import type { SnippetDraftSyncPayload } from '@/types/snippet'
import { useAtomValue } from 'jotai'
import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'
@@ -44,7 +45,7 @@ type SnippetMainProps = {
type SnippetMainContentProps = {
snippetId: string
- fields: SnippetInputField[]
+ fields: InputVar[]
canSave: boolean
canEdit: boolean
onBeforePublish: () => Promise<Omit<SnippetDraftSyncPayload, 'hash'> | void>
@@ -246,7 +247,7 @@ const SnippetMain = ({ draftPayload, draftNodes, draftEdges, draftViewport }: Sn
}, [canEditSnippet, syncWorkflowDraftWhenPageClose])
const handleFieldsChange = useCallback(
- (nextFields: SnippetInputField[]) => {
+ (nextFields: InputVar[]) => {
handleSnippetFieldsChange(nextFields)
},
[handleSnippetFieldsChange],
@@ -280,7 +281,7 @@ const SnippetMain = ({ draftPayload, draftNodes, draftEdges, draftViewport }: Sn
: { x: 0, y: 0, zoom: 1 },
}
const inputFields = Array.isArray(syncedDraftPayload.input_fields)
- ? (syncedDraftPayload.input_fields as SnippetInputField[])
+ ? (syncedDraftPayload.input_fields as InputVar[])
: fields
setLocalDraftState({
diff --git a/web/app/components/snippets/components/snippet-run-panel.tsx b/web/app/components/snippets/components/snippet-run-panel.tsx
index f648c58e2d1..04cabc8c902 100644
--- a/web/app/components/snippets/components/snippet-run-panel.tsx
+++ b/web/app/components/snippets/components/snippet-run-panel.tsx
@@ -2,7 +2,7 @@
import type { InputForm } from '@/app/components/base/chat/chat/type'
import type { InputVar as WorkflowInputVar } from '@/app/components/workflow/types'
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { Button } from '@langgenius/dify-ui/button'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'
@@ -28,7 +28,7 @@ import { toast } from '@/app/notifications'
import { PipelineInputVarType } from '@/models/pipeline'
type SnippetRunPanelProps = {
- fields: SnippetInputField[]
+ fields: InputVar[]
}
type SnippetRunField = WorkflowInputVar & InputForm
@@ -43,7 +43,7 @@ const PIPELINE_TO_WORKFLOW_INPUT_VAR_TYPE: Record<PipelineInputVarType, InputVar
[PipelineInputVarType.checkbox]: InputVarType.checkbox,
}
-const buildPreviewFields = (fields: SnippetInputField[]): SnippetRunField[] => {
+const buildPreviewFields = (fields: InputVar[]): SnippetRunField[] => {
return fields.map((field) => ({
type: PIPELINE_TO_WORKFLOW_INPUT_VAR_TYPE[field.type],
label: field.label,
diff --git a/web/app/components/snippets/components/snippet-sidebar.tsx b/web/app/components/snippets/components/snippet-sidebar.tsx
index ea50e4f074b..b2f33be9b31 100644
--- a/web/app/components/snippets/components/snippet-sidebar.tsx
+++ b/web/app/components/snippets/components/snippet-sidebar.tsx
@@ -1,7 +1,8 @@
'use client'
import type { InputVar } from '@/app/components/workflow/types'
-import type { SnippetDetail, SnippetInputField } from '@/models/snippet'
+import type { InputVar as PipelineInputVar } from '@/models/pipeline'
+import type { SnippetDetail } from '@/models/snippet'
import { cn } from '@langgenius/dify-ui/cn'
import { isEqual } from 'es-toolkit/predicate'
import { useCallback, useMemo, useState } from 'react'
@@ -17,24 +18,24 @@ import { SnippetPlaceholderIcon } from './snippet-placeholder-icon'
type SnippetSidebarProps = {
snippet: SnippetDetail
- fields: SnippetInputField[]
+ fields: PipelineInputVar[]
readonly: boolean
- onFieldsChange: (fields: SnippetInputField[]) => void
+ onFieldsChange: (fields: PipelineInputVar[]) => void
}
type SnippetSidebarContentProps = SnippetSidebarProps & {
className?: string
}
-const toWorkflowInputVar = (field: SnippetInputField): InputVar => ({
+const toWorkflowInputVar = (field: PipelineInputVar): InputVar => ({
...field,
type: field.type as InputVar['type'],
})
-const toSnippetInputField = (field: InputVar): SnippetInputField => ({
+const toSnippetInputField = (field: InputVar): PipelineInputVar => ({
...field,
label: typeof field.label === 'string' ? field.label : field.label.variable,
- type: field.type as SnippetInputField['type'],
+ type: field.type as PipelineInputVar['type'],
})
export const SnippetSidebarContent = ({
@@ -57,7 +58,7 @@ export const SnippetSidebarContent = ({
}, [])
const validateFields = useCallback(
- (nextFields: SnippetInputField[]) => {
+ (nextFields: PipelineInputVar[]) => {
let errorMsgKey: 'varKeyError.keyAlreadyExists' | '' = ''
let typeName: 'variableConfig.varName' | 'variableConfig.labelName' | '' = ''
if (hasDuplicateStr(nextFields.map((item) => item.variable))) {
diff --git a/web/app/components/snippets/components/workflow-panel.tsx b/web/app/components/snippets/components/workflow-panel.tsx
index 7906203a9a9..ea1f6ff0e04 100644
--- a/web/app/components/snippets/components/workflow-panel.tsx
+++ b/web/app/components/snippets/components/workflow-panel.tsx
@@ -1,7 +1,7 @@
'use client'
import type { PanelProps } from '@/app/components/workflow/panel'
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import dynamic from 'next/dynamic'
import { memo, useMemo } from 'react'
import Panel from '@/app/components/workflow/panel'
@@ -16,7 +16,7 @@ const SnippetRunPanel = dynamic(() => import('./snippet-run-panel'), {
type SnippetWorkflowPanelProps = {
snippetId: string
- fields: SnippetInputField[]
+ fields: InputVar[]
}
const SnippetPanelOnRight = ({ fields }: Pick<SnippetWorkflowPanelProps, 'fields'>) => {
diff --git a/web/app/components/snippets/create-snippet-dialog.tsx b/web/app/components/snippets/create-snippet-dialog.tsx
index 81196f7f1ca..320c8a1c47e 100644
--- a/web/app/components/snippets/create-snippet-dialog.tsx
+++ b/web/app/components/snippets/create-snippet-dialog.tsx
@@ -1,6 +1,7 @@
'use client'
import type { Hotkey } from '@tanstack/react-hotkeys'
-import type { SnippetCanvasData, SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
+import type { SnippetCanvasData } from '@/models/snippet'
import { Button } from '@langgenius/dify-ui/button'
import {
Dialog,
@@ -23,7 +24,7 @@ export type CreateSnippetDialogPayload = {
name: string
description: string
graph: SnippetCanvasData
- input_fields?: SnippetInputField[]
+ input_fields?: InputVar[]
}
type CreateSnippetDialogInitialValue = {
@@ -34,7 +35,7 @@ type CreateSnippetDialogInitialValue = {
type CreateSnippetDialogProps = {
isOpen: boolean
selectedGraph?: SnippetCanvasData
- inputFields?: SnippetInputField[]
+ inputFields?: InputVar[]
onClose: () => void
onConfirm: (payload: CreateSnippetDialogPayload) => void
isSubmitting?: boolean
diff --git a/web/app/components/snippets/draft-store/index.ts b/web/app/components/snippets/draft-store/index.ts
index 3cfe0c028ad..9a441b6b673 100644
--- a/web/app/components/snippets/draft-store/index.ts
+++ b/web/app/components/snippets/draft-store/index.ts
@@ -1,19 +1,19 @@
'use client'
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { create } from 'zustand'
type SnippetDraftState = {
snippetId?: string
- inputFields: SnippetInputField[]
- hydrateDraft: (payload: { snippetId: string; inputFields: SnippetInputField[] }) => void
- setInputFields: (inputFields: SnippetInputField[]) => void
+ inputFields: InputVar[]
+ hydrateDraft: (payload: { snippetId: string; inputFields: InputVar[] }) => void
+ setInputFields: (inputFields: InputVar[]) => void
reset: () => void
}
const initialState = {
snippetId: undefined,
- inputFields: [] as SnippetInputField[],
+ inputFields: [] as InputVar[],
}
export const useSnippetDraftStore = create<SnippetDraftState>((set) => ({
diff --git a/web/app/components/snippets/hooks/__tests__/use-create-snippet-from-selection.spec.tsx b/web/app/components/snippets/hooks/__tests__/use-create-snippet-from-selection.spec.tsx
index 77165047b25..fcb8970e554 100644
--- a/web/app/components/snippets/hooks/__tests__/use-create-snippet-from-selection.spec.tsx
+++ b/web/app/components/snippets/hooks/__tests__/use-create-snippet-from-selection.spec.tsx
@@ -1,7 +1,8 @@
import type { ReactElement } from 'react'
import type { LLMNodeType } from '@/app/components/workflow/nodes/llm/types'
import type { Edge, EnvironmentVariable, Node } from '@/app/components/workflow/types'
-import type { SnippetCanvasData, SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
+import type { SnippetCanvasData } from '@/models/snippet'
import { act, renderHook } from '@testing-library/react'
import { BlockEnum } from '@/app/components/workflow/types'
import { toast } from '@/app/notifications'
@@ -32,7 +33,7 @@ vi.mock('@/app/notifications', () => ({
type DialogProps = {
selectedGraph?: SnippetCanvasData
- inputFields?: SnippetInputField[]
+ inputFields?: InputVar[]
}
const createNode = (id: string, data: Record<string, unknown>): Node =>
diff --git a/web/app/components/snippets/hooks/__tests__/use-file-settings.spec.ts b/web/app/components/snippets/hooks/__tests__/use-file-settings.spec.ts
index 5a5a681e058..214a61cbe2a 100644
--- a/web/app/components/snippets/hooks/__tests__/use-file-settings.spec.ts
+++ b/web/app/components/snippets/hooks/__tests__/use-file-settings.spec.ts
@@ -1,4 +1,4 @@
-import type { FileUploadConfigResponse } from '@/models/common'
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import { act } from '@testing-library/react'
import { renderWorkflowHook } from '@/app/components/workflow/__tests__/workflow-test-env'
import { Resolution, TransferMethod } from '@/types/app'
@@ -6,7 +6,7 @@ import { useFileSettings } from '../use-file-settings'
describe('useFileSettings', () => {
it('updates upload limits from the editor while keeping snippet image inputs disabled', () => {
- const fileUploadConfig = { workflow_file_upload_limit: 10 } as FileUploadConfigResponse
+ const fileUploadConfig = { workflow_file_upload_limit: 10 } as UploadConfig
const { result, store } = renderWorkflowHook(useFileSettings, {
resource: { kind: 'snippet', snippetId: 'snippet-1' },
initialStoreState: { fileUploadConfig },
diff --git a/web/app/components/snippets/hooks/__tests__/use-nodes-sync-draft.spec.ts b/web/app/components/snippets/hooks/__tests__/use-nodes-sync-draft.spec.ts
index 4f1324458fb..42bc0182ed1 100644
--- a/web/app/components/snippets/hooks/__tests__/use-nodes-sync-draft.spec.ts
+++ b/web/app/components/snippets/hooks/__tests__/use-nodes-sync-draft.spec.ts
@@ -1,4 +1,4 @@
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { ORPCError } from '@orpc/client'
import { act, renderHook } from '@testing-library/react'
import { PipelineInputVarType } from '@/models/pipeline'
@@ -87,7 +87,7 @@ vi.mock('../use-snippet-refresh-draft', () => ({
}),
}))
-const createInputField = (variable: string): SnippetInputField => ({
+const createInputField = (variable: string): InputVar => ({
type: PipelineInputVarType.textInput,
label: variable,
variable,
diff --git a/web/app/components/snippets/hooks/__tests__/use-snippet-start-run.spec.ts b/web/app/components/snippets/hooks/__tests__/use-snippet-start-run.spec.ts
index 9745957f4e7..b674deaeb1e 100644
--- a/web/app/components/snippets/hooks/__tests__/use-snippet-start-run.spec.ts
+++ b/web/app/components/snippets/hooks/__tests__/use-snippet-start-run.spec.ts
@@ -1,4 +1,4 @@
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { renderHook } from '@testing-library/react'
import { act } from 'react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -27,7 +27,7 @@ const mockSetShowEnvPanel = vi.fn()
const mockSetShowGlobalVariablePanel = vi.fn()
const mockHandleRun = vi.fn()
-const inputFields: SnippetInputField[] = [
+const inputFields: InputVar[] = [
{
type: PipelineInputVarType.textInput,
label: 'Query',
diff --git a/web/app/components/snippets/hooks/use-create-snippet-from-selection.tsx b/web/app/components/snippets/hooks/use-create-snippet-from-selection.tsx
index 5a87906e7dc..1cc64953290 100644
--- a/web/app/components/snippets/hooks/use-create-snippet-from-selection.tsx
+++ b/web/app/components/snippets/hooks/use-create-snippet-from-selection.tsx
@@ -5,7 +5,8 @@ import type {
Node,
ValueSelector,
} from '@/app/components/workflow/types'
-import type { SnippetCanvasData, SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
+import type { SnippetCanvasData } from '@/models/snippet'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getNodesBounds } from 'reactflow'
@@ -152,7 +153,7 @@ const getExternalVariableInputFields = (nodes: Node[], selectedNodeIds: Set<stri
nodes.forEach((node) => collectVariableSelectors(node.data, selectors))
const usedVariables = new Set<string>()
- const fieldBySelector = new Map<string, SnippetInputField>()
+ const fieldBySelector = new Map<string, InputVar>()
selectors.forEach((selector) => {
if (!isExternalVariableSelector(selector, selectedNodeIds)) return
@@ -284,9 +285,7 @@ export const useCreateSnippetFromSelection = ({
}: UseCreateSnippetFromSelectionParams) => {
const { t } = useTranslation(['workflow'])
const [selectedSnippetGraph, setSelectedSnippetGraph] = useState<SnippetCanvasData>()
- const [selectedSnippetInputFields, setSelectedSnippetInputFields] = useState<SnippetInputField[]>(
- [],
- )
+ const [selectedSnippetInputFields, setSelectedSnippetInputFields] = useState<InputVar[]>([])
const {
createSnippetMutation,
handleCloseCreateSnippetDialog,
@@ -298,7 +297,7 @@ export const useCreateSnippetFromSelection = ({
const handleOpenCreateSnippet = useCallback(() => {
let graph: SnippetCanvasData
- let inputFields: SnippetInputField[]
+ let inputFields: InputVar[]
try {
const result = getSelectedSnippetGraph(selectedNodes, edges, environmentVariables)
graph = result.graph
diff --git a/web/app/components/snippets/hooks/use-nodes-sync-draft.ts b/web/app/components/snippets/hooks/use-nodes-sync-draft.ts
index ee100dbd7eb..e2368deb075 100644
--- a/web/app/components/snippets/hooks/use-nodes-sync-draft.ts
+++ b/web/app/components/snippets/hooks/use-nodes-sync-draft.ts
@@ -1,5 +1,5 @@
import type { SyncDraftCallback } from '@/app/components/workflow/hooks-store'
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import type {
SnippetDraftSyncPayload,
SnippetDraftSyncResponse,
@@ -19,7 +19,7 @@ import { useSnippetDraftStore } from '../draft-store'
import { useSnippetRefreshDraft } from './use-snippet-refresh-draft'
type SyncInputFieldsDraftCallback = SyncDraftCallback & {
- onRefresh?: (inputFields: SnippetInputField[]) => void
+ onRefresh?: (inputFields: InputVar[]) => void
}
const snippetDraftSyncQueues = new Map<string, Promise<unknown>>()
@@ -47,14 +47,14 @@ export const useNodesSyncDraft = (snippetId: string) => {
const { getNodesReadOnly } = useNodesReadOnlyByCanEdit(true)
const { handleRefreshWorkflowDraft } = useSnippetRefreshDraft(snippetId)
- const getInputFieldsSyncPayload = useCallback((inputFields?: SnippetInputField[]) => {
+ const getInputFieldsSyncPayload = useCallback((inputFields?: InputVar[]) => {
return {
input_fields: inputFields ?? useSnippetDraftStore.getState().inputFields,
}
}, [])
const getDraftSyncPayload = useCallback(
- (inputFields?: SnippetInputField[]) => {
+ (inputFields?: InputVar[]) => {
const { getNodes, edges, transform } = store.getState()
const nodes = getNodes().filter((node) => !node.data?._isTempNode)
const [x, y, zoom] = transform
@@ -171,7 +171,7 @@ export const useNodesSyncDraft = (snippetId: string) => {
const response = await enqueueSnippetDraftSync(snippetId, () =>
syncDraft(draftPayload, false, callback, (draftWorkflow) => {
const refreshedInputFields = Array.isArray(draftWorkflow.input_fields)
- ? (draftWorkflow.input_fields as SnippetInputField[])
+ ? (draftWorkflow.input_fields as InputVar[])
: []
callback?.onRefresh?.(refreshedInputFields)
}),
@@ -192,7 +192,7 @@ export const useNodesSyncDraft = (snippetId: string) => {
)
const syncInputFieldsDraft = useCallback(
- (inputFields: SnippetInputField[], callback?: SyncInputFieldsDraftCallback) => {
+ (inputFields: InputVar[], callback?: SyncInputFieldsDraftCallback) => {
const draftPayload = getDraftSyncPayload(inputFields)
return syncInputFieldsDraftWithPayload(draftPayload, callback)
},
diff --git a/web/app/components/snippets/hooks/use-snippet-refresh-draft.ts b/web/app/components/snippets/hooks/use-snippet-refresh-draft.ts
index 348fe361d57..6567fe4120f 100644
--- a/web/app/components/snippets/hooks/use-snippet-refresh-draft.ts
+++ b/web/app/components/snippets/hooks/use-snippet-refresh-draft.ts
@@ -1,5 +1,5 @@
import type { WorkflowDataUpdater } from '@/app/components/workflow/types'
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import type { SnippetWorkflow } from '@/types/snippet'
import { useCallback } from 'react'
import { useWorkflowUpdate } from '@/app/components/workflow/hooks/use-workflow-update'
@@ -24,7 +24,7 @@ export const useSnippetRefreshDraft = (snippetId: string) => {
if (!response) return
const inputFields = Array.isArray(response.input_fields)
- ? (response.input_fields as SnippetInputField[])
+ ? (response.input_fields as InputVar[])
: []
handleUpdateWorkflowCanvas({
diff --git a/web/app/components/snippets/hooks/use-snippet-run.ts b/web/app/components/snippets/hooks/use-snippet-run.ts
index 19a69b7d76e..f2362fc15c7 100644
--- a/web/app/components/snippets/hooks/use-snippet-run.ts
+++ b/web/app/components/snippets/hooks/use-snippet-run.ts
@@ -1,6 +1,6 @@
import type { IOtherOptions } from '@/service/base'
import type { SnippetDraftRunPayload } from '@/types/snippet'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { produce } from 'immer'
import { useAtomValue } from 'jotai'
import { useCallback, useRef } from 'react'
@@ -277,7 +277,7 @@ export const useSnippetRun = () => {
)
const handleRestoreFromPublishedWorkflow = useCallback(
- (publishedWorkflow: VersionHistory) => {
+ (publishedWorkflow: FetchWorkflowDraftResponse) => {
const nodes = publishedWorkflow.graph.nodes.map((node) => ({
...node,
selected: false,
diff --git a/web/app/components/snippets/store/index.ts b/web/app/components/snippets/store/index.ts
index 4fbd4187181..a77f3c8893b 100644
--- a/web/app/components/snippets/store/index.ts
+++ b/web/app/components/snippets/store/index.ts
@@ -1,13 +1,14 @@
'use client'
-import type { SnippetDetail, SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
+import type { SnippetDetail } from '@/models/snippet'
import { create } from 'zustand'
type SnippetNavigationState = {
snippet?: SnippetDetail
snippetId?: string
readonly: boolean
- onFieldsChange?: (fields: SnippetInputField[]) => void
+ onFieldsChange?: (fields: InputVar[]) => void
}
type SnippetDetailUIState = {
diff --git a/web/app/components/tools/types.ts b/web/app/components/tools/types.ts
index 54b4c151d00..6b737518c4c 100644
--- a/web/app/components/tools/types.ts
+++ b/web/app/components/tools/types.ts
@@ -1,4 +1,3 @@
-import type { WorkflowTriggerResponse } from '@dify/contracts/api/console/apps/types.gen'
import type {
ToolParameter as ContractToolParameter,
DatasourceProviderType,
@@ -292,5 +291,3 @@ export const MCPAuthMethod = {
} as const
export type MCPAuthMethod = (typeof MCPAuthMethod)[keyof typeof MCPAuthMethod]
-
-export type AppTrigger = WorkflowTriggerResponse
diff --git a/web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts b/web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts
index 0bfbe01a805..0e62070212f 100644
--- a/web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts
+++ b/web/app/components/workflow-app/hooks/use-nodes-sync-draft.ts
@@ -1,9 +1,9 @@
+import type { WorkflowFeaturesConfigPayload } from '@dify/contracts/api/console/apps/types.gen'
import type {
SyncDraftCallback,
SyncDraftOptions,
SyncDraftResult,
} from '@/app/components/workflow/hooks-store'
-import type { WorkflowDraftFeaturesPayload } from '@/service/workflow'
import { safe } from '@orpc/client'
import { skipToken, useQuery, useSuspenseQuery } from '@tanstack/react-query'
import { produce } from 'immer'
@@ -117,7 +117,7 @@ const useNodesSyncDraftBase = (getNodesReadOnly: () => boolean) => {
})
},
)
- const featuresPayload: WorkflowDraftFeaturesPayload = {
+ const featuresPayload: WorkflowFeaturesConfigPayload = {
opening_statement: features.opening?.enabled ? features.opening?.opening_statement || '' : '',
suggested_questions: features.opening?.enabled
? features.opening?.suggested_questions || []
diff --git a/web/app/components/workflow-app/hooks/use-workflow-init.ts b/web/app/components/workflow-app/hooks/use-workflow-init.ts
index bb98542ae9c..b0be1d009c6 100644
--- a/web/app/components/workflow-app/hooks/use-workflow-init.ts
+++ b/web/app/components/workflow-app/hooks/use-workflow-init.ts
@@ -1,5 +1,5 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { Edge, Node } from '@/app/components/workflow/types'
-import type { FileUploadConfigResponse } from '@/models/common'
import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { ORPCError } from '@orpc/client'
import { useQueryClient, useSuspenseQuery } from '@tanstack/react-query'
@@ -83,7 +83,7 @@ export const useWorkflowInit = () => {
const [isLoading, setIsLoading] = useState(true)
const handleUpdateWorkflowFileUploadConfig = useCallback(
- (config: FileUploadConfigResponse) => {
+ (config: UploadConfig) => {
const { setFileUploadConfig } = workflowStore.getState()
setFileUploadConfig(config)
},
diff --git a/web/app/components/workflow-app/hooks/use-workflow-run-utils.ts b/web/app/components/workflow-app/hooks/use-workflow-run-utils.ts
index b6bf7854e47..f2b2245b440 100644
--- a/web/app/components/workflow-app/hooks/use-workflow-run-utils.ts
+++ b/web/app/components/workflow-app/hooks/use-workflow-run-utils.ts
@@ -2,7 +2,7 @@ import type { AppMode } from '@dify/contracts/api/console/apps/types.gen'
import type { Features as FeaturesData } from '@/app/components/base/features/types'
import type { TriggerNodeType } from '@/app/components/workflow/types'
import type { IOtherOptions } from '@/service/base'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { noop } from 'es-toolkit/function'
import { isInstalledAppPath } from '@/app/components/explore/installed-app/routes'
import { TriggerType } from '@/app/components/workflow/header/test-run-menu'
@@ -11,9 +11,8 @@ import { toast } from '@/app/notifications'
import { handleStream, post } from '@/service/base'
import { ContentType } from '@/service/fetch'
-type HandleRunMode = TriggerType
export type HandleRunOptions = {
- mode?: HandleRunMode
+ mode?: TriggerType
scheduleNodeId?: string
webhookNodeId?: string
pluginNodeId?: string
@@ -122,7 +121,7 @@ export const buildRunHistoryUrl = (appDetail?: AppDetailLike) => {
export const resolveWorkflowRunUrl = (
appDetail: AppDetailLike | undefined,
- runMode: HandleRunMode,
+ runMode: TriggerType,
isInWorkflowDebug: boolean,
) => {
if (
@@ -156,7 +155,7 @@ export const resolveWorkflowRunUrl = (
}
export const buildWorkflowRunRequestBody = (
- runMode: HandleRunMode,
+ runMode: TriggerType,
resolvedParams: Record<string, unknown>,
options?: HandleRunOptions,
) => {
@@ -171,7 +170,7 @@ export const buildWorkflowRunRequestBody = (
return resolvedParams
}
-export const validateWorkflowRunRequest = (runMode: HandleRunMode, options?: HandleRunOptions) => {
+export const validateWorkflowRunRequest = (runMode: TriggerType, options?: HandleRunOptions) => {
if (runMode === TriggerType.Schedule && !options?.scheduleNodeId)
return 'handleRun: schedule trigger run requires node id'
@@ -187,9 +186,7 @@ export const validateWorkflowRunRequest = (runMode: HandleRunMode, options?: Han
return ''
}
-export const isDebuggableTriggerType = (
- runMode: HandleRunMode,
-): runMode is DebuggableTriggerType => {
+export const isDebuggableTriggerType = (runMode: TriggerType): runMode is DebuggableTriggerType => {
return (
runMode === TriggerType.Schedule ||
runMode === TriggerType.Webhook ||
@@ -215,7 +212,7 @@ export const buildListeningTriggerNodeIds = (
export const applyRunningStateForMode = (
actions: ListeningStateActions,
- runMode: HandleRunMode,
+ runMode: TriggerType,
options?: HandleRunOptions,
) => {
if (isDebuggableTriggerType(runMode)) {
@@ -295,7 +292,9 @@ export const buildTTSConfig = (resolvedParams: TTSParamsLike, pathname: string)
}
}
-export const mapPublishedWorkflowFeatures = (publishedWorkflow: VersionHistory): FeaturesData => {
+export const mapPublishedWorkflowFeatures = (
+ publishedWorkflow: FetchWorkflowDraftResponse,
+): FeaturesData => {
return {
opening: {
enabled:
@@ -313,7 +312,7 @@ export const mapPublishedWorkflowFeatures = (publishedWorkflow: VersionHistory):
}
}
-export const normalizePublishedWorkflowNodes = (publishedWorkflow: VersionHistory) => {
+export const normalizePublishedWorkflowNodes = (publishedWorkflow: FetchWorkflowDraftResponse) => {
return publishedWorkflow.graph.nodes.map((node) => ({
...node,
selected: false,
diff --git a/web/app/components/workflow-app/hooks/use-workflow-run.ts b/web/app/components/workflow-app/hooks/use-workflow-run.ts
index 3111e94dc62..c3cfa45da5c 100644
--- a/web/app/components/workflow-app/hooks/use-workflow-run.ts
+++ b/web/app/components/workflow-app/hooks/use-workflow-run.ts
@@ -2,7 +2,7 @@ import type { HandleRunOptions } from './use-workflow-run-utils'
import type { AudioPlayer } from '@/app/components/base/audio-btn/audio'
import type { Node } from '@/app/components/workflow/types'
import type { IOtherOptions } from '@/service/base'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { useSuspenseQuery } from '@tanstack/react-query'
import { noop } from 'es-toolkit/function'
import { produce } from 'immer'
@@ -531,7 +531,7 @@ const useWorkflowRunBase = (doSyncWorkflowDraft: DoSyncWorkflowDraft) => {
)
const handleRestoreFromPublishedWorkflow = useCallback(
- (publishedWorkflow: VersionHistory) => {
+ (publishedWorkflow: FetchWorkflowDraftResponse) => {
const nodes = normalizePublishedWorkflowNodes(publishedWorkflow)
const edges = publishedWorkflow.graph.edges
const viewport = publishedWorkflow.graph.viewport!
diff --git a/web/app/components/workflow-app/utils.ts b/web/app/components/workflow-app/utils.ts
index fd54f0fa218..5565b35a52d 100644
--- a/web/app/components/workflow-app/utils.ts
+++ b/web/app/components/workflow-app/utils.ts
@@ -1,5 +1,5 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { Features as FeaturesData } from '@/app/components/base/features/types'
-import type { FileUploadConfigResponse } from '@/models/common'
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
import { TransferMethod } from '@/types/app'
@@ -72,7 +72,7 @@ export const coerceReplayUserInputs = (
export const buildInitialFeatures = (
featuresSource: WorkflowFeaturesLike | null | undefined,
- fileUploadConfigResponse: FileUploadConfigResponse | undefined,
+ fileUploadConfigResponse: UploadConfig | undefined,
): FeaturesData => {
const features = featuresSource || {}
const fileUpload = features.file_upload
diff --git a/web/app/components/workflow/block-selector/types.ts b/web/app/components/workflow/block-selector/types.ts
index 40f0ac8d15f..8ce50e47346 100644
--- a/web/app/components/workflow/block-selector/types.ts
+++ b/web/app/components/workflow/block-selector/types.ts
@@ -204,7 +204,7 @@ export const TriggerCredentialType = {
export type TriggerCredentialType =
(typeof TriggerCredentialType)[keyof typeof TriggerCredentialType]
-type TriggerSubscriptionStructure = {
+export type TriggerSubscription = {
id: string
name: string
provider: string
@@ -216,9 +216,7 @@ type TriggerSubscriptionStructure = {
workflows_in_use: number
}
-export type TriggerSubscription = TriggerSubscriptionStructure
-
-export type TriggerSubscriptionBuilder = TriggerSubscriptionStructure
+export type TriggerSubscriptionBuilder = TriggerSubscription
// OAuth configuration types
export type TriggerOAuthConfig = {
diff --git a/web/app/components/workflow/comment/__tests__/comment-close-focus.spec.tsx b/web/app/components/workflow/comment/__tests__/comment-close-focus.spec.tsx
index c4cf70a4c34..e6ea2aa7003 100644
--- a/web/app/components/workflow/comment/__tests__/comment-close-focus.spec.tsx
+++ b/web/app/components/workflow/comment/__tests__/comment-close-focus.spec.tsx
@@ -1,4 +1,4 @@
-import type { WorkflowCommentList } from '../types'
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import { act, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { Fragment } from 'react'
@@ -52,7 +52,7 @@ vi.mock('@/service/console', async (importOriginal) => {
}
})
-const comment: WorkflowCommentList = {
+const comment: WorkflowCommentBasic = {
id: 'comment-1',
position_x: 10,
position_y: 20,
@@ -242,7 +242,7 @@ describe('Comment keyboard focus lifecycle', () => {
it('restores the last viewed comment marker after navigating to another thread', async () => {
const user = userEvent.setup()
- const otherComment: WorkflowCommentList = {
+ const otherComment: WorkflowCommentBasic = {
...comment,
id: 'comment-2',
content: 'Another comment',
diff --git a/web/app/components/workflow/comment/__tests__/comment-thread-focus.spec.tsx b/web/app/components/workflow/comment/__tests__/comment-thread-focus.spec.tsx
index 2b5db15b602..77e5e365111 100644
--- a/web/app/components/workflow/comment/__tests__/comment-thread-focus.spec.tsx
+++ b/web/app/components/workflow/comment/__tests__/comment-thread-focus.spec.tsx
@@ -1,4 +1,8 @@
-import type { UserProfile, WorkflowCommentDetail, WorkflowCommentList } from '../types'
+import type {
+ WorkflowCommentBasic,
+ WorkflowCommentDetail,
+} from '@dify/contracts/api/console/apps/types.gen'
+import type { UserProfile } from '../types'
import { act, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useState } from 'react'
@@ -33,7 +37,7 @@ vi.mock('../../store', () => ({
useWorkflowStore: () => ({ getState: () => storeState }),
}))
-const createComment = (): WorkflowCommentDetail & WorkflowCommentList => ({
+const createComment = (): WorkflowCommentDetail & WorkflowCommentBasic => ({
id: 'comment-1',
position_x: 120,
position_y: 80,
diff --git a/web/app/components/workflow/comment/comment-icon.spec.tsx b/web/app/components/workflow/comment/comment-icon.spec.tsx
index a9c63a0b72c..d0ce532e396 100644
--- a/web/app/components/workflow/comment/comment-icon.spec.tsx
+++ b/web/app/components/workflow/comment/comment-icon.spec.tsx
@@ -1,5 +1,5 @@
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import type { ReactElement } from 'react'
-import type { WorkflowCommentList } from '@/app/components/workflow/comment/types'
import { fireEvent, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useState } from 'react'
@@ -56,7 +56,7 @@ vi.mock('./comment-preview', () => ({
),
}))
-const createComment = (overrides: Partial<WorkflowCommentList> = {}): WorkflowCommentList => ({
+const createComment = (overrides: Partial<WorkflowCommentBasic> = {}): WorkflowCommentBasic => ({
id: 'comment-1',
position_x: 0,
position_y: 0,
diff --git a/web/app/components/workflow/comment/comment-icon.tsx b/web/app/components/workflow/comment/comment-icon.tsx
index 6e3126daf6a..eb03e9477a4 100644
--- a/web/app/components/workflow/comment/comment-icon.tsx
+++ b/web/app/components/workflow/comment/comment-icon.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import type { FC, PointerEvent as ReactPointerEvent } from 'react'
-import type { WorkflowCommentList } from '@/app/components/workflow/comment/types'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useSuspenseQuery } from '@tanstack/react-query'
import { memo, useCallback, useId, useMemo, useRef, useState } from 'react'
@@ -13,7 +13,7 @@ import { getKeyboardMovement } from '../utils/keyboard-movement'
import CommentPreview from './comment-preview'
type CommentIconProps = {
- comment: WorkflowCommentList
+ comment: WorkflowCommentBasic
onClick: () => void
isActive?: boolean
onPositionUpdate?: (position: { x: number; y: number }) => void
diff --git a/web/app/components/workflow/comment/comment-movement.browser.spec.tsx b/web/app/components/workflow/comment/comment-movement.browser.spec.tsx
index 99e956d2133..c03a623639e 100644
--- a/web/app/components/workflow/comment/comment-movement.browser.spec.tsx
+++ b/web/app/components/workflow/comment/comment-movement.browser.spec.tsx
@@ -1,4 +1,4 @@
-import type { WorkflowCommentList } from './types'
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Suspense, useState } from 'react'
import ReactFlow, { ReactFlowProvider } from 'reactflow'
@@ -17,7 +17,7 @@ vi.mock('@/features/account-profile/client', () => ({
vi.mock('./comment-preview', () => ({ default: () => null }))
vi.mock('./mention-input', () => ({ MentionInput: () => <textarea aria-label="Comment text" /> }))
-const comment: WorkflowCommentList = {
+const comment: WorkflowCommentBasic = {
id: 'comment',
content: 'Comment',
created_by: 'author',
diff --git a/web/app/components/workflow/comment/comment-preview.spec.tsx b/web/app/components/workflow/comment/comment-preview.spec.tsx
index cdf1fde19dc..db2001956e2 100644
--- a/web/app/components/workflow/comment/comment-preview.spec.tsx
+++ b/web/app/components/workflow/comment/comment-preview.spec.tsx
@@ -1,9 +1,9 @@
-import type { WorkflowCommentList } from '@/app/components/workflow/comment/types'
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import { fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import CommentPreview from './comment-preview'
-type UserProfile = NonNullable<WorkflowCommentList['created_by_account']>
+type UserProfile = NonNullable<WorkflowCommentBasic['created_by_account']>
const mockSetHovering = vi.fn()
let capturedUsers: UserProfile[] = []
@@ -27,7 +27,7 @@ vi.mock('../store', () => ({
) => selector({ setCommentPreviewHovering: mockSetHovering }),
}))
-const createComment = (overrides: Partial<WorkflowCommentList> = {}): WorkflowCommentList => {
+const createComment = (overrides: Partial<WorkflowCommentBasic> = {}): WorkflowCommentBasic => {
const author = { id: 'user-1', name: 'Alice', email: '[email protected]', avatar_url: null }
const participant = { id: 'user-2', name: 'Bob', email: '[email protected]', avatar_url: null }
diff --git a/web/app/components/workflow/comment/comment-preview.tsx b/web/app/components/workflow/comment/comment-preview.tsx
index cf8e0f5915c..14f6735859c 100644
--- a/web/app/components/workflow/comment/comment-preview.tsx
+++ b/web/app/components/workflow/comment/comment-preview.tsx
@@ -1,14 +1,14 @@
'use client'
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import type { FC } from 'react'
-import type { WorkflowCommentList } from '@/app/components/workflow/comment/types'
import { memo, useEffect, useMemo } from 'react'
import { UserAvatarList } from '@/app/components/base/user-avatar-list'
import { useFormatTimeFromNow } from '@/hooks/use-format-time-from-now'
import { useStore } from '../store'
type CommentPreviewProps = {
- comment: WorkflowCommentList
+ comment: WorkflowCommentBasic
onClick?: () => void
}
diff --git a/web/app/components/workflow/comment/reply-deletion.browser.spec.tsx b/web/app/components/workflow/comment/reply-deletion.browser.spec.tsx
index 8914bc0bfd8..71d031ab9cc 100644
--- a/web/app/components/workflow/comment/reply-deletion.browser.spec.tsx
+++ b/web/app/components/workflow/comment/reply-deletion.browser.spec.tsx
@@ -1,4 +1,4 @@
-import type { WorkflowCommentDetail } from './types'
+import type { WorkflowCommentDetail } from '@dify/contracts/api/console/apps/types.gen'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Suspense, useState } from 'react'
import { page, userEvent } from 'vite-plus/test/browser'
diff --git a/web/app/components/workflow/comment/thread.spec.tsx b/web/app/components/workflow/comment/thread.spec.tsx
index 51ecda037f4..6a9bbfa9ccc 100644
--- a/web/app/components/workflow/comment/thread.spec.tsx
+++ b/web/app/components/workflow/comment/thread.spec.tsx
@@ -1,5 +1,5 @@
+import type { WorkflowCommentDetail } from '@dify/contracts/api/console/apps/types.gen'
import type { ReactElement } from 'react'
-import type { WorkflowCommentDetail } from '@/app/components/workflow/comment/types'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { createAccountProfileQueryWrapper } from '@/test/console/account-profile'
diff --git a/web/app/components/workflow/comment/thread.tsx b/web/app/components/workflow/comment/thread.tsx
index cac0974f962..f280ab30a34 100644
--- a/web/app/components/workflow/comment/thread.tsx
+++ b/web/app/components/workflow/comment/thread.tsx
@@ -1,10 +1,10 @@
'use client'
-import type { ReactNode } from 'react'
import type {
WorkflowCommentDetail,
- WorkflowCommentDetailReply,
-} from '@/app/components/workflow/comment/types'
+ WorkflowCommentReply,
+} from '@dify/contracts/api/console/apps/types.gen'
+import type { ReactNode } from 'react'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -316,7 +316,7 @@ function CommentThreadComponent({
[screenPosition.x, screenPosition.y, containerLeft, containerTop],
)
- const handleStartEdit = useCallback((reply: WorkflowCommentDetailReply) => {
+ const handleStartEdit = useCallback((reply: WorkflowCommentReply) => {
setEditingReply({ id: reply.id, content: reply.content })
setIsCommentEditing(false)
setActiveReplyMenuId(null)
diff --git a/web/app/components/workflow/comment/types.ts b/web/app/components/workflow/comment/types.ts
index a196cba1d20..9b1faff16df 100644
--- a/web/app/components/workflow/comment/types.ts
+++ b/web/app/components/workflow/comment/types.ts
@@ -1,14 +1,5 @@
-import type {
- AccountWithRoleResponse,
- WorkflowCommentDetail as GeneratedWorkflowCommentDetail,
- WorkflowCommentBasic,
- WorkflowCommentReply,
-} from '@dify/contracts/api/console/apps/types.gen'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/apps/types.gen'
export type UserProfile = Pick<AccountWithRoleResponse, 'id' | 'name' | 'email' | 'avatar_url'> & {
avatar_url?: string | null
}
-
-export type WorkflowCommentList = WorkflowCommentBasic
-export type WorkflowCommentDetail = GeneratedWorkflowCommentDetail
-export type WorkflowCommentDetailReply = WorkflowCommentReply
diff --git a/web/app/components/workflow/datasets-detail-store/__tests__/provider.spec.tsx b/web/app/components/workflow/datasets-detail-store/__tests__/provider.spec.tsx
index a12b108ff96..fa99a418906 100644
--- a/web/app/components/workflow/datasets-detail-store/__tests__/provider.spec.tsx
+++ b/web/app/components/workflow/datasets-detail-store/__tests__/provider.spec.tsx
@@ -1,5 +1,5 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { Node } from '../../types'
-import type { DataSet } from '@/models/datasets'
import { render, screen, waitFor } from '@testing-library/react'
import { BlockEnum } from '../../types'
import DatasetsDetailProvider from '../provider'
@@ -29,11 +29,11 @@ const createWorkflowNode = (datasetIds: string[] = []): Node =>
},
}) as unknown as Node
-const createDataset = (id: string): DataSet =>
+const createDataset = (id: string): DatasetDetailWithPartialMembersResponse =>
({
id,
name: `Dataset ${id}`,
- }) as DataSet
+ }) as DatasetDetailWithPartialMembersResponse
describe('datasets-detail-store provider', () => {
beforeEach(() => {
diff --git a/web/app/components/workflow/datasets-detail-store/__tests__/store.spec.tsx b/web/app/components/workflow/datasets-detail-store/__tests__/store.spec.tsx
index 970468c27f4..d1e03120378 100644
--- a/web/app/components/workflow/datasets-detail-store/__tests__/store.spec.tsx
+++ b/web/app/components/workflow/datasets-detail-store/__tests__/store.spec.tsx
@@ -1,11 +1,15 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { renderHook } from '@testing-library/react'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { DatasetsDetailContext } from '../provider'
import { createDatasetsDetailStore, useDatasetsDetailStore } from '../store'
-const createDataset = (id: string, name = `dataset-${id}`): DataSet => ({
+const createDataset = (
+ id: string,
+ name = `dataset-${id}`,
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id,
name,
@@ -14,9 +18,10 @@ const createDataset = (id: string, name = `dataset-${id}`): DataSet => ({
icon_type: 'emoji',
},
description: `${name} description`,
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1,
@@ -28,7 +33,7 @@ const createDataset = (id: string, name = `dataset-${id}`): DataSet => ({
embedding_model: 'model',
embedding_model_provider: 'provider',
embedding_available: true,
- retrieval_model_dict: {} as DataSet['retrieval_model_dict'],
+ retrieval_model_dict: {} as DatasetDetailWithPartialMembersResponse['retrieval_model_dict'],
tags: [],
external_knowledge_info: {
external_knowledge_id: '',
diff --git a/web/app/components/workflow/datasets-detail-store/store.ts b/web/app/components/workflow/datasets-detail-store/store.ts
index f91d7ce8c78..8cf1be87404 100644
--- a/web/app/components/workflow/datasets-detail-store/store.ts
+++ b/web/app/components/workflow/datasets-detail-store/store.ts
@@ -1,20 +1,22 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { produce } from 'immer'
import { use } from 'react'
import { createStore, useStore } from 'zustand'
import { DatasetsDetailContext } from './provider'
type DatasetsDetailStore = {
- datasetsDetail: Record<string, DataSet>
- updateDatasetsDetail: (datasetsDetail: DataSet[]) => void
+ datasetsDetail: Record<string, DatasetDetailWithPartialMembersResponse>
+ updateDatasetsDetail: (datasetsDetail: DatasetDetailWithPartialMembersResponse[]) => void
}
export const createDatasetsDetailStore = () => {
return createStore<DatasetsDetailStore>((set, get) => ({
datasetsDetail: {},
- updateDatasetsDetail: (datasets: DataSet[]) => {
+ updateDatasetsDetail: (datasets: DatasetDetailWithPartialMembersResponse[]) => {
const oldDatasetsDetail = get().datasetsDetail
- const datasetsDetail = datasets.reduce<Record<string, DataSet>>((acc, dataset) => {
+ const datasetsDetail = datasets.reduce<
+ Record<string, DatasetDetailWithPartialMembersResponse>
+ >((acc, dataset) => {
acc[dataset.id] = dataset
return acc
}, {})
diff --git a/web/app/components/workflow/features.tsx b/web/app/components/workflow/features.tsx
index bb91305ad0d..7ef8357b85d 100644
--- a/web/app/components/workflow/features.tsx
+++ b/web/app/components/workflow/features.tsx
@@ -1,7 +1,7 @@
+import type { WorkflowFeaturesConfigPayload } from '@dify/contracts/api/console/apps/types.gen'
import type { StartNodeType } from './nodes/start/types'
import type { CommonNodeType, InputVar, Node } from './types'
import type { PromptVariable } from '@/models/debug'
-import type { WorkflowDraftFeaturesPayload } from '@/service/workflow'
import { useAtomValue } from 'jotai'
import { memo, useCallback } from 'react'
import { useNodes } from 'reactflow'
@@ -46,7 +46,7 @@ const Features = () => {
const currentFeatures = featuresStore.getState().features
// Transform features to match the expected server format (same as doSyncWorkflowDraft)
- const transformedFeatures: WorkflowDraftFeaturesPayload = {
+ const transformedFeatures: WorkflowFeaturesConfigPayload = {
opening_statement: currentFeatures.opening?.enabled
? currentFeatures.opening?.opening_statement || ''
: '',
diff --git a/web/app/components/workflow/header/__tests__/header-in-restoring.spec.tsx b/web/app/components/workflow/header/__tests__/header-in-restoring.spec.tsx
index f2c42b707a3..9379b15e280 100644
--- a/web/app/components/workflow/header/__tests__/header-in-restoring.spec.tsx
+++ b/web/app/components/workflow/header/__tests__/header-in-restoring.spec.tsx
@@ -1,5 +1,5 @@
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { fireEvent, screen } from '@testing-library/react'
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
import {
@@ -58,7 +58,9 @@ vi.mock('../../hooks/use-workflow-refresh-draft', () => ({
}),
}))
-const createVersion = (overrides: Partial<VersionHistory> = {}): VersionHistory => ({
+const createVersion = (
+ overrides: Partial<FetchWorkflowDraftResponse> = {},
+): FetchWorkflowDraftResponse => ({
id: 'version-1',
graph: {
nodes: [],
diff --git a/web/app/components/workflow/header/__tests__/restoring-title.spec.tsx b/web/app/components/workflow/header/__tests__/restoring-title.spec.tsx
index 8dcbb234ddb..483005e9520 100644
--- a/web/app/components/workflow/header/__tests__/restoring-title.spec.tsx
+++ b/web/app/components/workflow/header/__tests__/restoring-title.spec.tsx
@@ -1,4 +1,4 @@
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { renderWorkflowComponent } from '../../__tests__/workflow-test-env'
import { WorkflowVersion } from '../../types'
import RestoringTitle from '../restoring-title'
@@ -18,7 +18,9 @@ vi.mock('@/hooks/use-format-time-from-now', () => ({
}),
}))
-const createVersion = (overrides: Partial<VersionHistory> = {}): VersionHistory => ({
+const createVersion = (
+ overrides: Partial<FetchWorkflowDraftResponse> = {},
+): FetchWorkflowDraftResponse => ({
id: 'version-1',
graph: {
nodes: [],
diff --git a/web/app/components/workflow/hooks-store/store.ts b/web/app/components/workflow/hooks-store/store.ts
index dbaec1ca49e..3cceb95c7bd 100644
--- a/web/app/components/workflow/hooks-store/store.ts
+++ b/web/app/components/workflow/hooks-store/store.ts
@@ -1,3 +1,4 @@
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { FileUpload } from '../../base/features/types'
import type {
BlockEnum,
@@ -7,7 +8,6 @@ import type {
WorkflowPluginCatalogs,
} from '@/app/components/workflow/types'
import type { IOtherOptions } from '@/service/base'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import type { EnvironmentVariablePatch } from '@/service/workflow'
import type { VarInInspect } from '@/types/workflow'
import { noop } from 'es-toolkit/function'
@@ -79,7 +79,7 @@ type CommonHooksFnMap = {
passInVars?: boolean
vars?: VarInInspect[]
passedInAllPluginInfoList?: WorkflowPluginCatalogs
- passedInSchemaTypeDefinitions?: SchemaTypeDefinition[]
+ passedInSchemaTypeDefinitions?: SchemaDefinitionItemResponse[]
}) => Promise<void>
hasNodeInspectVars: (nodeId: string) => boolean
hasSetInspectVar: (
@@ -90,7 +90,7 @@ type CommonHooksFnMap = {
) => boolean
fetchInspectVarValue: (
selector: ValueSelector,
- schemaTypeDefinitions: SchemaTypeDefinition[],
+ schemaTypeDefinitions: SchemaDefinitionItemResponse[],
) => Promise<void>
editInspectVarValue: (nodeId: string, varId: string, value: any) => Promise<void>
renameInspectVarName: (nodeId: string, oldName: string, newName: string) => Promise<void>
diff --git a/web/app/components/workflow/hooks/__tests__/use-fetch-workflow-inspect-vars.spec.ts b/web/app/components/workflow/hooks/__tests__/use-fetch-workflow-inspect-vars.spec.ts
index aebe5217275..08568de591e 100644
--- a/web/app/components/workflow/hooks/__tests__/use-fetch-workflow-inspect-vars.spec.ts
+++ b/web/app/components/workflow/hooks/__tests__/use-fetch-workflow-inspect-vars.spec.ts
@@ -1,4 +1,4 @@
-import type { SchemaTypeDefinition } from '@/service/use-common'
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { VarInInspect } from '@/types/workflow'
import { act, waitFor } from '@testing-library/react'
import { createNode } from '../../__tests__/fixtures'
@@ -13,7 +13,7 @@ const mockInvalidateSysVarValues = vi.hoisted(() => vi.fn())
const mockHandleCancelAllNodeSuccessStatus = vi.hoisted(() => vi.fn())
const mockToNodeOutputVars = vi.hoisted(() => vi.fn())
-const schemaTypeDefinitions: SchemaTypeDefinition[] = [
+const schemaTypeDefinitions: SchemaDefinitionItemResponse[] = [
{
name: 'simple',
label: 'Simple',
diff --git a/web/app/components/workflow/hooks/__tests__/use-inspect-vars-crud-common.spec.ts b/web/app/components/workflow/hooks/__tests__/use-inspect-vars-crud-common.spec.ts
index 2a3461aa72b..63a3ca66498 100644
--- a/web/app/components/workflow/hooks/__tests__/use-inspect-vars-crud-common.spec.ts
+++ b/web/app/components/workflow/hooks/__tests__/use-inspect-vars-crud-common.spec.ts
@@ -1,4 +1,4 @@
-import type { SchemaTypeDefinition } from '@/service/use-common'
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { VarInInspect } from '@/types/workflow'
import { act, waitFor } from '@testing-library/react'
import { createNode } from '../../__tests__/fixtures'
@@ -18,7 +18,7 @@ const mockHandleCancelNodeSuccessStatus = vi.hoisted(() => vi.fn())
const mockHandleEdgeCancelRunningStatus = vi.hoisted(() => vi.fn())
const mockToNodeOutputVars = vi.hoisted(() => vi.fn())
-const schemaTypeDefinitions: SchemaTypeDefinition[] = [
+const schemaTypeDefinitions: SchemaDefinitionItemResponse[] = [
{
name: 'simple',
label: 'Simple',
diff --git a/web/app/components/workflow/hooks/__tests__/use-workflow-comment.spec.ts b/web/app/components/workflow/hooks/__tests__/use-workflow-comment.spec.ts
index 560c77c95e5..a945f21c8a2 100644
--- a/web/app/components/workflow/hooks/__tests__/use-workflow-comment.spec.ts
+++ b/web/app/components/workflow/hooks/__tests__/use-workflow-comment.spec.ts
@@ -1,7 +1,7 @@
import type {
+ WorkflowCommentBasic,
WorkflowCommentDetail,
- WorkflowCommentList,
-} from '@/app/components/workflow/comment/types'
+} from '@dify/contracts/api/console/apps/types.gen'
import { act, waitFor } from '@testing-library/react'
import { seedAccountProfileQuery } from '@/test/console/account-profile'
import { createConsoleQueryClient, seedSystemFeatures } from '@/test/console/query-data'
@@ -102,7 +102,7 @@ vi.mock('@/app/components/workflow/collaboration/core/collaboration-manager', ()
},
}))
-const baseComment = (): WorkflowCommentList => ({
+const baseComment = (): WorkflowCommentBasic => ({
id: 'comment-1',
position_x: 10,
position_y: 20,
@@ -406,7 +406,7 @@ describe('useWorkflowComment', () => {
it('focuses comment thread, loads detail, and updates navigation/create/close states', async () => {
const commentA = baseComment()
- const commentB: WorkflowCommentList = {
+ const commentB: WorkflowCommentBasic = {
...baseComment(),
id: 'comment-2',
content: 'second',
@@ -471,7 +471,7 @@ describe('useWorkflowComment', () => {
it('runs resolve, delete, and reply lifecycle handlers with collaboration sync', async () => {
const commentA = baseComment()
- const commentB: WorkflowCommentList = {
+ const commentB: WorkflowCommentBasic = {
...baseComment(),
id: 'comment-2',
content: 'fallback',
@@ -664,7 +664,7 @@ describe('useWorkflowComment', () => {
it('does not overwrite the active comment when a different comment is resolved/refreshed', async () => {
const commentA = baseComment()
- const commentB: WorkflowCommentList = {
+ const commentB: WorkflowCommentBasic = {
...baseComment(),
id: 'comment-2',
content: 'second',
diff --git a/web/app/components/workflow/hooks/use-checklist.ts b/web/app/components/workflow/hooks/use-checklist.ts
index 8b3167adc1f..84e3c7233d3 100644
--- a/web/app/components/workflow/hooks/use-checklist.ts
+++ b/web/app/components/workflow/hooks/use-checklist.ts
@@ -1,3 +1,4 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { ModelProviderSummaryResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { AgentNodeType } from '../nodes/agent/types'
import type { DataSourceNodeType } from '../nodes/data-source/types'
@@ -18,7 +19,6 @@ import type { ModelItem } from '@/app/components/header/account-setting/model-pr
import type { Emoji } from '@/app/components/tools/types'
import type { EditorResource } from '@/app/components/workflow/editor-resource/resource'
import type { AgentToolPublishIssue } from '@/features/agent-v2/agent-detail/configure/tool-provider-catalog'
-import type { DataSet } from '@/models/datasets'
import { useQueries, useQuery, useQueryClient } from '@tanstack/react-query'
import isDeepEqual from 'fast-deep-equal'
import { useAtomValue } from 'jotai'
@@ -340,10 +340,13 @@ export const useChecklist = (nodes: Node[], edges: Edge[]) => {
let checkData = data
if (data.type === BlockEnum.KnowledgeRetrieval) {
const datasetIds = (data as CommonNodeType<KnowledgeRetrievalNodeType>).dataset_ids
- const _datasets = datasetIds.reduce<DataSet[]>((acc, id) => {
- if (datasetsDetail[id]) acc.push(datasetsDetail[id])
- return acc
- }, [])
+ const _datasets = datasetIds.reduce<DatasetDetailWithPartialMembersResponse[]>(
+ (acc, id) => {
+ if (datasetsDetail[id]) acc.push(datasetsDetail[id])
+ return acc
+ },
+ [],
+ )
checkData = {
...data,
_datasets,
@@ -671,20 +674,25 @@ export const useChecklistBeforePublish = () => {
const getCheckData = useCallback(
(
data: CommonNodeType<object>,
- datasets: DataSet[],
+ datasets: DatasetDetailWithPartialMembersResponse[],
embeddingProviderModelMap?: Partial<Record<string, ModelItem[]>>,
) => {
let checkData = data
if (data.type === BlockEnum.KnowledgeRetrieval) {
const datasetIds = (data as CommonNodeType<KnowledgeRetrievalNodeType>).dataset_ids
- const datasetsDetail = datasets.reduce<Record<string, DataSet>>((acc, dataset) => {
+ const datasetsDetail = datasets.reduce<
+ Record<string, DatasetDetailWithPartialMembersResponse>
+ >((acc, dataset) => {
acc[dataset.id] = dataset
return acc
}, {})
- const _datasets = datasetIds.reduce<DataSet[]>((acc, id) => {
- if (datasetsDetail[id]) acc.push(datasetsDetail[id])
- return acc
- }, [])
+ const _datasets = datasetIds.reduce<DatasetDetailWithPartialMembersResponse[]>(
+ (acc, id) => {
+ if (datasetsDetail[id]) acc.push(datasetsDetail[id])
+ return acc
+ },
+ [],
+ )
checkData = {
...data,
_datasets,
@@ -748,7 +756,9 @@ export const useChecklistBeforePublish = () => {
return modelMap
}
- const fetchLatestDatasets = async (): Promise<DataSet[] | null> => {
+ const fetchLatestDatasets = async (): Promise<
+ DatasetDetailWithPartialMembersResponse[] | null
+ > => {
const allDatasetIds = new Set<string>()
filteredNodes.forEach((node) => {
if (node.data.type !== BlockEnum.KnowledgeRetrieval) return
diff --git a/web/app/components/workflow/hooks/use-fetch-workflow-inspect-vars.ts b/web/app/components/workflow/hooks/use-fetch-workflow-inspect-vars.ts
index c56fe014d8f..7c06f788dcc 100644
--- a/web/app/components/workflow/hooks/use-fetch-workflow-inspect-vars.ts
+++ b/web/app/components/workflow/hooks/use-fetch-workflow-inspect-vars.ts
@@ -1,5 +1,5 @@
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { Node, WorkflowPluginCatalogs } from '@/app/components/workflow/types'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import type { NodeWithVar, VarInInspect } from '@/types/workflow'
import { useQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
@@ -58,7 +58,7 @@ export const useSetWorkflowVarsWithValue = () => {
(
inspectVars: VarInInspect[],
passedInAllPluginInfoList?: WorkflowPluginCatalogs,
- passedInSchemaTypeDefinitions?: SchemaTypeDefinition[],
+ passedInSchemaTypeDefinitions?: SchemaDefinitionItemResponse[],
) => {
const { setNodesWithInspectVars } = workflowStore.getState()
const { getNodes } = store.getState()
@@ -128,7 +128,7 @@ export const useSetWorkflowVarsWithValue = () => {
passInVars?: boolean
vars?: VarInInspect[]
passedInAllPluginInfoList?: WorkflowPluginCatalogs
- passedInSchemaTypeDefinitions?: SchemaTypeDefinition[]
+ passedInSchemaTypeDefinitions?: SchemaDefinitionItemResponse[]
}) => {
const { passInVars, vars, passedInAllPluginInfoList, passedInSchemaTypeDefinitions } = params
invalidateConversationVarValues()
diff --git a/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts b/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts
index 1fbbc4a455b..dcd9d8ebfce 100644
--- a/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts
+++ b/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts
@@ -1,5 +1,5 @@
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { Node, ValueSelector } from '@/app/components/workflow/types'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import type { VarInInspect } from '@/types/workflow'
import { useQuery } from '@tanstack/react-query'
import { produce } from 'immer'
@@ -120,7 +120,7 @@ export const useInspectVarsCrudCommon = () => {
)
const fetchInspectVarValue = useCallback(
- async (selector: ValueSelector, schemaTypeDefinitions: SchemaTypeDefinition[]) => {
+ async (selector: ValueSelector, schemaTypeDefinitions: SchemaDefinitionItemResponse[]) => {
const { setNodeInspectVars, dataSourceList } = workflowStore.getState()
const nodeId = selector[0]
const isSystemVar = nodeId === 'sys'
diff --git a/web/app/components/workflow/hooks/use-node-data-update.ts b/web/app/components/workflow/hooks/use-node-data-update.ts
index bca8dea8493..893edf7cfa3 100644
--- a/web/app/components/workflow/hooks/use-node-data-update.ts
+++ b/web/app/components/workflow/hooks/use-node-data-update.ts
@@ -1,4 +1,4 @@
-import type { SyncCallback } from './use-nodes-sync-draft'
+import type { SyncDraftCallback } from '@/app/components/workflow/hooks-store'
import { produce } from 'immer'
import { useCallback } from 'react'
import { useCollaborativeWorkflow } from './use-collaborative-workflow'
@@ -34,7 +34,7 @@ export const useNodeDataUpdate = () => {
options?: {
sync?: boolean
notRefreshWhenSyncError?: boolean
- callback?: SyncCallback
+ callback?: SyncDraftCallback
},
) => {
if (getNodesReadOnly()) return
diff --git a/web/app/components/workflow/hooks/use-nodes-sync-draft.ts b/web/app/components/workflow/hooks/use-nodes-sync-draft.ts
index 370b6e83f41..8b47d0643e6 100644
--- a/web/app/components/workflow/hooks/use-nodes-sync-draft.ts
+++ b/web/app/components/workflow/hooks/use-nodes-sync-draft.ts
@@ -4,8 +4,6 @@ import { useHooksStore } from '@/app/components/workflow/hooks-store'
import { useStore } from '../store'
import { useNodesReadOnly } from './use-workflow'
-export type SyncCallback = SyncDraftCallback
-
export const useNodesSyncDraft = () => {
const { getNodesReadOnly } = useNodesReadOnly()
const debouncedSyncWorkflowDraft = useStore((s) => s.debouncedSyncWorkflowDraft)
diff --git a/web/app/components/workflow/hooks/use-workflow-comment.ts b/web/app/components/workflow/hooks/use-workflow-comment.ts
index e2d63a0e0de..eb0b7391183 100644
--- a/web/app/components/workflow/hooks/use-workflow-comment.ts
+++ b/web/app/components/workflow/hooks/use-workflow-comment.ts
@@ -1,8 +1,8 @@
import type {
- UserProfile,
+ WorkflowCommentBasic,
WorkflowCommentDetail,
- WorkflowCommentList,
-} from '@/app/components/workflow/comment/types'
+} from '@dify/contracts/api/console/apps/types.gen'
+import type { UserProfile } from '@/app/components/workflow/comment/types'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useAtomValue } from 'jotai'
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react'
@@ -28,7 +28,7 @@ const normalizeTimestamp = (value: number | string | null | undefined): number =
return Math.floor(Date.parse(value) / 1000)
}
-const toCommentDetailPreview = (comment: WorkflowCommentList): WorkflowCommentDetail => ({
+const toCommentDetailPreview = (comment: WorkflowCommentBasic): WorkflowCommentDetail => ({
...comment,
replies: [],
mentions: [],
@@ -200,7 +200,7 @@ export const useWorkflowComment = () => {
}
const participants = Array.from(uniqueParticipantsMap.values())
- const composedComment: WorkflowCommentList = {
+ const composedComment: WorkflowCommentBasic = {
id: newComment.id,
position_x: flowPosition.x,
position_y: flowPosition.y,
@@ -278,7 +278,7 @@ export const useWorkflowComment = () => {
}, [isCommentPlacing, isCommentQuickAdd, pendingComment, setCommentQuickAdd])
const handleCommentIconClick = useCallback(
- async (comment: WorkflowCommentList) => {
+ async (comment: WorkflowCommentBasic) => {
commentFocusToRestoreRef.current = null
setPendingComment(null)
diff --git a/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts b/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts
index 355ce736cbd..debd4f6c1b5 100644
--- a/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts
+++ b/web/app/components/workflow/nodes/_base/components/variable/use-match-schema-type.ts
@@ -1,12 +1,12 @@
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { AnyObj } from './match-schema-type'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import { useQuery } from '@tanstack/react-query'
import { consoleQuery } from '@/service/console'
import matchTheSchemaType from './match-schema-type'
export const getMatchedSchemaType = (
obj: AnyObj,
- schemaTypeDefinitions?: SchemaTypeDefinition[],
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): string => {
if (!schemaTypeDefinitions || obj === undefined || obj === null) return ''
const matched = schemaTypeDefinitions.find((def) => matchTheSchemaType(obj, def.schema))
diff --git a/web/app/components/workflow/nodes/_base/components/variable/utils.ts b/web/app/components/workflow/nodes/_base/components/variable/utils.ts
index 19e8c884a89..aa90c63817b 100644
--- a/web/app/components/workflow/nodes/_base/components/variable/utils.ts
+++ b/web/app/components/workflow/nodes/_base/components/variable/utils.ts
@@ -1,3 +1,4 @@
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { TFunction } from 'i18next'
import type { AnswerNodeType } from '../../../answer/types'
import type { CodeNodeType } from '../../../code/types'
@@ -35,7 +36,6 @@ import type {
WorkflowPluginCatalogs,
} from '@/app/components/workflow/types'
import type { RAGPipelineVariable } from '@/models/pipeline'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import { uniq } from 'es-toolkit/array'
import { isArray } from 'es-toolkit/compat'
import { produce } from 'immer'
@@ -303,7 +303,7 @@ const formatItem = (
filterVar: (payload: Var, selector: ValueSelector) => boolean,
allPluginInfoList: WorkflowPluginCatalogs,
ragVars?: Var[],
- schemaTypeDefinitions: SchemaTypeDefinition[] = [],
+ schemaTypeDefinitions: SchemaDefinitionItemResponse[] = [],
): NodeOutPutVar => {
const { id, data } = item
@@ -747,7 +747,7 @@ export const toNodeOutputVars = (
conversationVariables: ConversationVariable[] = [],
ragVariables: RAGPipelineVariable[] = [],
allPluginInfoList: WorkflowPluginCatalogs,
- schemaTypeDefinitions?: SchemaTypeDefinition[],
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): NodeOutPutVar[] => {
// ENV_NODE data format
const ENV_NODE = {
@@ -966,7 +966,7 @@ export const getVarType = ({
conversationVariables?: ConversationVariable[]
ragVariables?: RAGPipelineVariable[]
allPluginInfoList: WorkflowPluginCatalogs
- schemaTypeDefinitions?: SchemaTypeDefinition[]
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[]
preferSchemaType?: boolean
}): VarType => {
if (isConstant) return VarType.string
@@ -1110,7 +1110,7 @@ export const toNodeAvailableVars = ({
ragVariables?: RAGPipelineVariable[]
filterVar: (payload: Var, selector: ValueSelector) => boolean
allPluginInfoList: WorkflowPluginCatalogs
- schemaTypeDefinitions?: SchemaTypeDefinition[]
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[]
}): NodeOutPutVar[] => {
const beforeNodesOutputVars = toNodeOutputVars(
beforeNodes,
diff --git a/web/app/components/workflow/nodes/_base/hooks/snippet-input-field-vars.ts b/web/app/components/workflow/nodes/_base/hooks/snippet-input-field-vars.ts
index 43c3bad4176..43d92174ddf 100644
--- a/web/app/components/workflow/nodes/_base/hooks/snippet-input-field-vars.ts
+++ b/web/app/components/workflow/nodes/_base/hooks/snippet-input-field-vars.ts
@@ -1,5 +1,5 @@
import type { InputVarType, Node, NodeOutPutVar } from '@/app/components/workflow/types'
-import type { SnippetInputField } from '@/models/snippet'
+import type { InputVar } from '@/models/pipeline'
import { NODE_WIDTH } from '@/app/components/workflow/constants'
import { BlockEnum } from '@/app/components/workflow/types'
import { PipelineInputVarType } from '@/models/pipeline'
@@ -18,12 +18,9 @@ export const filterSnippetSystemVars = (availableVars: NodeOutPutVar[], isSnippe
.filter((nodeVar) => nodeVar.vars.length > 0)
}
-const toWorkflowInputType = (type: SnippetInputField['type']) => type as InputVarType
+const toWorkflowInputType = (type: InputVar['type']) => type as InputVarType
-const buildSnippetInputFieldNode = (
- fields: SnippetInputField[],
- title: string,
-): Node | undefined => {
+const buildSnippetInputFieldNode = (fields: InputVar[], title: string): Node | undefined => {
const variables = fields.filter((field) => !!field.variable)
if (!variables.length) return undefined
@@ -57,7 +54,7 @@ const buildSnippetInputFieldNode = (
}
const buildSnippetInputFieldVars = (
- fields: SnippetInputField[],
+ fields: InputVar[],
title: string,
): NodeOutPutVar | undefined => {
const vars = fields
@@ -90,7 +87,7 @@ export const appendSnippetInputFieldVars = ({
}: {
availableNodes: Node[]
isSnippetFlow: boolean
- fields?: SnippetInputField[]
+ fields?: InputVar[]
title: string
}) => {
const inputFields = fields ?? []
diff --git a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts
index c9e64c0ee3a..fa715443514 100644
--- a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts
+++ b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts
@@ -8,7 +8,7 @@ import type {
Var,
Variable,
} from '@/app/components/workflow/types'
-import type { NodeRunResult, NodeTracing } from '@/types/workflow'
+import type { NodeTracing } from '@/types/workflow'
import { useQuery } from '@tanstack/react-query'
import { unionBy } from 'es-toolkit/compat'
import { noop } from 'es-toolkit/function'
@@ -301,7 +301,7 @@ const useOneStepRun = <T>({
[workflowStore, store],
)
const invalidLastRun = useInvalidateLastRun(resource, id)
- const [runResult, doSetRunResult] = useState<NodeRunResult | null>(null)
+ const [runResult, doSetRunResult] = useState<NodeTracing | null>(null)
const { appendNodeInspectVars, invalidateSysVarValues, invalidateConversationVarValues } =
useInspectVarsCrud()
const runningStatus = data._singleRunningStatus || NodeRunningStatus.NotStart
@@ -327,7 +327,7 @@ const useOneStepRun = <T>({
const isTriggerNode = isWebhookTriggerNode || isPluginTriggerNode || isScheduleTriggerNode
const setRunResult = useCallback(
- async (data: NodeRunResult | null) => {
+ async (data: NodeTracing | null) => {
const isPaused = isPausedRef.current
// The backend don't support pause the single run, so the frontend handle the pause state.
@@ -447,7 +447,7 @@ const useOneStepRun = <T>({
setListeningTriggerIsAll,
])
- const runScheduleSingleRun = useCallback(async (): Promise<NodeRunResult | null> => {
+ const runScheduleSingleRun = useCallback(async (): Promise<NodeTracing | null> => {
if (resource.kind !== 'app') return null
try {
@@ -478,7 +478,7 @@ const useOneStepRun = <T>({
},
})
- return response as NodeRunResult
+ return response as NodeTracing
} catch (error) {
console.error('handleRun: schedule trigger single run error', error)
handleNodeDataUpdate({
diff --git a/web/app/components/workflow/nodes/data-source-empty/default.ts b/web/app/components/workflow/nodes/data-source-empty/default.ts
index 5ba1ca75432..87980a8c12c 100644
--- a/web/app/components/workflow/nodes/data-source-empty/default.ts
+++ b/web/app/components/workflow/nodes/data-source-empty/default.ts
@@ -1,5 +1,4 @@
-import type { NodeDefault } from '../../types'
-import type { DataSourceEmptyNodeType } from './types'
+import type { CommonNodeType, NodeDefault } from '../../types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
@@ -9,7 +8,7 @@ const metaData = genNodeMetaData({
isUndeletable: true,
isSingleton: true,
})
-const nodeDefault: NodeDefault<DataSourceEmptyNodeType> = {
+const nodeDefault: NodeDefault<CommonNodeType> = {
metaData,
defaultValue: {},
checkValid() {
diff --git a/web/app/components/workflow/nodes/data-source-empty/types.ts b/web/app/components/workflow/nodes/data-source-empty/types.ts
deleted file mode 100644
index f9668f931e0..00000000000
--- a/web/app/components/workflow/nodes/data-source-empty/types.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import type { CommonNodeType } from '@/app/components/workflow/types'
-
-export type DataSourceEmptyNodeType = CommonNodeType
diff --git a/web/app/components/workflow/nodes/data-source/default.ts b/web/app/components/workflow/nodes/data-source/default.ts
index 0412bfa4354..36db1b90a86 100644
--- a/web/app/components/workflow/nodes/data-source/default.ts
+++ b/web/app/components/workflow/nodes/data-source/default.ts
@@ -1,8 +1,8 @@
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { TFunction } from 'i18next'
import type { NodeDefault, Var } from '../../types'
import type { getDataSourceCheckParams } from '../../utils/data-source'
import type { DataSourceNodeType } from './types'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import { VarKindType } from '@/app/components/workflow/nodes/_base/types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
@@ -21,7 +21,7 @@ const metaData = genNodeMetaData({
})
const getOutputProperties = (
schema: unknown,
- schemaTypeDefinitions?: SchemaTypeDefinition[],
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): Var[] => {
if (!schema || typeof schema !== 'object' || !('properties' in schema)) return []
const properties = schema.properties
diff --git a/web/app/components/workflow/nodes/data-source/hooks/use-before-run-form.ts b/web/app/components/workflow/nodes/data-source/hooks/use-before-run-form.ts
index bc1587ba3a3..9c2fbeb03a1 100644
--- a/web/app/components/workflow/nodes/data-source/hooks/use-before-run-form.ts
+++ b/web/app/components/workflow/nodes/data-source/hooks/use-before-run-form.ts
@@ -1,5 +1,5 @@
import type { CustomRunFormProps, DataSourceNodeType } from '../types'
-import type { NodeRunResult } from '@/types/workflow'
+import type { NodeTracing } from '@/types/workflow'
import { useMutation } from '@tanstack/react-query'
import { useEffect, useMemo, useRef } from 'react'
import { useStoreApi } from 'reactflow'
@@ -85,7 +85,7 @@ const useBeforeRunForm = ({
const invalidLastRun = useInvalidateLastRun(resource, nodeId)
- const updateRunResult = async (data: NodeRunResult | undefined) => {
+ const updateRunResult = async (data: NodeTracing | undefined) => {
const isPaused = isPausedRef.current
// The backend don't support pause the single run, so the frontend handle the pause state.
diff --git a/web/app/components/workflow/nodes/data-source/types.ts b/web/app/components/workflow/nodes/data-source/types.ts
index 1bc32181bfb..3976d809e17 100644
--- a/web/app/components/workflow/nodes/data-source/types.ts
+++ b/web/app/components/workflow/nodes/data-source/types.ts
@@ -3,7 +3,7 @@ import type { Dispatch, SetStateAction } from 'react'
import type { ResourceVarInputs } from '../_base/types'
import type { EditorResource } from '@/app/components/workflow/editor-resource/resource'
import type { CommonNodeType, Node } from '@/app/components/workflow/types'
-import type { NodeRunResult, VarInInspect } from '@/types/workflow'
+import type { NodeTracing, VarInInspect } from '@/types/workflow'
export const DataSourceClassification = {
localFile: 'local_file',
@@ -25,7 +25,7 @@ export type CustomRunFormProps = {
nodeId: string
resource: EditorResource
payload: CommonNodeType
- setRunResult: Dispatch<SetStateAction<NodeRunResult | null>>
+ setRunResult: Dispatch<SetStateAction<NodeTracing | null>>
setIsRunAfterSingleRun: Dispatch<SetStateAction<boolean>>
isPaused: boolean
isRunAfterSingleRun: boolean
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/email-input.spec.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/email-input.spec.tsx
index f6dc30c658b..ab553d67691 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/email-input.spec.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/email-input.spec.tsx
@@ -1,5 +1,5 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Recipient as RecipientItem } from '../../../../types'
-import type { Member } from '@/models/common'
import { fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import EmailInput from '../email-input'
@@ -38,7 +38,7 @@ vi.mock('../member-list', () => ({
},
}))
-const createMember = (overrides: Partial<Member>): Member => ({
+const createMember = (overrides: Partial<AccountWithRoleResponse>): AccountWithRoleResponse => ({
id: 'member-1',
name: 'Member One',
@@ -53,7 +53,7 @@ const createMember = (overrides: Partial<Member>): Member => ({
...overrides,
})
-const members: Member[] = [
+const members: AccountWithRoleResponse[] = [
createMember({}),
createMember({
id: 'member-2',
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-list.spec.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-list.spec.tsx
index 439ffbc00c5..12d1573bb64 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-list.spec.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-list.spec.tsx
@@ -1,10 +1,10 @@
-import type { Member } from '@/models/common'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import { fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useState } from 'react'
import MemberList from '../member-list'
-const createMember = (overrides: Partial<Member>): Member => ({
+const createMember = (overrides: Partial<AccountWithRoleResponse>): AccountWithRoleResponse => ({
id: 'member-1',
name: 'Owner',
@@ -19,7 +19,7 @@ const createMember = (overrides: Partial<Member>): Member => ({
...overrides,
})
-const members: Member[] = [
+const members: AccountWithRoleResponse[] = [
createMember({}),
createMember({
id: 'member-2',
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-selector.spec.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-selector.spec.tsx
index d4f1e48dc51..7bc2cfb7d62 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-selector.spec.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/__tests__/member-selector.spec.tsx
@@ -1,4 +1,4 @@
-import type { Member } from '@/models/common'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import MemberSelector from '../member-selector'
@@ -9,7 +9,7 @@ vi.mock('../member-list', () => ({
__esModule: true,
default: (props: {
searchValue: string
- list: Member[]
+ list: AccountWithRoleResponse[]
email: string
onSearchChange: (value: string) => void
onSelect: (memberId: string) => void
@@ -30,7 +30,7 @@ vi.mock('../member-list', () => ({
},
}))
-const members: Member[] = [
+const members: AccountWithRoleResponse[] = [
{
id: 'member-1',
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-input.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-input.tsx
index 41ef0af8e41..760b207b7ae 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-input.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-input.tsx
@@ -1,5 +1,5 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Recipient as RecipientItem } from '../../../types'
-import type { Member } from '@/models/common'
import { cn } from '@langgenius/dify-ui/cn'
import {
Popover,
@@ -18,7 +18,7 @@ const i18nPrefix = 'nodes.humanInput'
type Props = Readonly<{
email: string
value: RecipientItem[]
- list: Member[]
+ list: AccountWithRoleResponse[]
onDelete: (recipient: RecipientItem) => void
onSelect: (value: string) => void
onAdd: (email: string) => void
@@ -133,7 +133,7 @@ const EmailInput = ({ email, value, list, onDelete, onSelect, onAdd, disabled =
<EmailItem
key={item.user_id || item.email}
email={email}
- data={item as unknown as Member}
+ data={item as unknown as AccountWithRoleResponse}
onDelete={onDelete}
disabled={disabled}
isError={isErrorMember(item)}
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-item.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-item.tsx
index 2b28df0239c..a9d47f24717 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-item.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/email-item.tsx
@@ -1,5 +1,5 @@
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { Recipient as RecipientItem } from '../../../types'
-import type { Member } from '@/models/common'
import { Avatar, AvatarFallback, AvatarImage } from '@langgenius/dify-ui/avatar'
import { cn } from '@langgenius/dify-ui/cn'
import { RiCloseCircleFill, RiErrorWarningFill } from '@remixicon/react'
@@ -9,7 +9,7 @@ import { getAvatarInitial } from '@/utils/avatar'
type Props = Readonly<{
email: string
- data: Member
+ data: AccountWithRoleResponse
disabled?: boolean
onDelete: (recipient: RecipientItem) => void
isError: boolean
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-list.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-list.tsx
index b93b7ccf4fc..b020d6786cd 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-list.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-list.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { FC } from 'react'
import type { Recipient } from '@/app/components/workflow/nodes/human-input/types'
-import type { Member } from '@/models/common'
import { Avatar, AvatarFallback, AvatarImage } from '@langgenius/dify-ui/avatar'
import { cn } from '@langgenius/dify-ui/cn'
import { InputGroup, InputGroupAddon, InputGroupInput } from '@langgenius/dify-ui/input-group'
@@ -15,7 +15,7 @@ type Props = Readonly<{
value: Recipient[]
searchValue: string
onSearchChange: (value: string) => void
- list: Member[]
+ list: AccountWithRoleResponse[]
onSelect: (value: string) => void
email: string
hideSearch?: boolean
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-selector.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-selector.tsx
index 58d44829a9f..81fd3005633 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-selector.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/recipient/member-selector.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { FC } from 'react'
import type { Recipient } from '@/app/components/workflow/nodes/human-input/types'
-import type { Member } from '@/models/common'
import { Button } from '@langgenius/dify-ui/button'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { RiContactsBookLine } from '@remixicon/react'
@@ -15,7 +15,7 @@ type Props = Readonly<{
value: Recipient[]
email: string
onSelect: (value: string) => void
- list: Member[]
+ list: AccountWithRoleResponse[]
}>
const MemberSelector: FC<Props> = ({ value, email, onSelect, list = [] }) => {
diff --git a/web/app/components/workflow/nodes/human-input/types.ts b/web/app/components/workflow/nodes/human-input/types.ts
index 7d9ab0db011..08bc5508bab 100644
--- a/web/app/components/workflow/nodes/human-input/types.ts
+++ b/web/app/components/workflow/nodes/human-input/types.ts
@@ -65,7 +65,7 @@ export type UserAction = {
button_style: UserActionButtonType
}
-type StringDefault = {
+export type StringDefault = {
selector: ValueSelector
type: 'variable' | 'constant'
value: string
@@ -77,9 +77,6 @@ type StringListSource = {
value: string[]
}
-// Preserve the old export during the transition to the new schema names.
-export type FormInputItemDefault = StringDefault
-
type BaseFormInputItem = {
output_variable_name: string
}
diff --git a/web/app/components/workflow/nodes/iteration-start/default.ts b/web/app/components/workflow/nodes/iteration-start/default.ts
index 70b8b4c45e2..b3cd6b5c4db 100644
--- a/web/app/components/workflow/nodes/iteration-start/default.ts
+++ b/web/app/components/workflow/nodes/iteration-start/default.ts
@@ -1,5 +1,4 @@
-import type { NodeDefault } from '../../types'
-import type { IterationStartNodeType } from './types'
+import type { CommonNodeType, NodeDefault } from '../../types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
@@ -7,7 +6,7 @@ const metaData = genNodeMetaData({
sort: -1,
type: BlockEnum.IterationStart,
})
-const nodeDefault: NodeDefault<IterationStartNodeType> = {
+const nodeDefault: NodeDefault<CommonNodeType> = {
metaData,
defaultValue: {},
checkValid() {
diff --git a/web/app/components/workflow/nodes/iteration-start/types.ts b/web/app/components/workflow/nodes/iteration-start/types.ts
deleted file mode 100644
index 319cce0bc24..00000000000
--- a/web/app/components/workflow/nodes/iteration-start/types.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import type { CommonNodeType } from '@/app/components/workflow/types'
-
-export type IterationStartNodeType = CommonNodeType
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/integration.spec.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/integration.spec.tsx
index dbe3df2f266..c2e395e703d 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/integration.spec.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/integration.spec.tsx
@@ -1,10 +1,14 @@
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetDocMetadataResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactElement } from 'react'
import type { ComparisonOperator, MetadataFilteringCondition, MetadataShape } from '../types'
-import type { DataSet, MetadataInDoc } from '@/models/datasets'
import { fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useEffect, useRef } from 'react'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import {
createAccountProfileQueryClient,
createAccountProfileQueryWrapper,
@@ -50,11 +54,13 @@ const mockHasEditPermissionForDataset = vi.fn(
_datasetConfig: {
createdBy: string
partialMemberList: string[]
- permission: DatasetPermission
+ permission: PermissionLevel
},
) => true,
)
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Dataset Name',
@@ -65,9 +71,10 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
maintainer: 'user-1',
updated_by: 'user-1',
@@ -110,7 +117,9 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
...overrides,
})
-const createMetadata = (overrides: Partial<MetadataInDoc> = {}): MetadataInDoc => ({
+const createMetadata = (
+ overrides: Partial<DatasetDocMetadataResponse> = {},
+): DatasetDocMetadataResponse => ({
id: 'meta-1',
name: 'topic',
type: MetadataFilteringVariableType.string,
@@ -162,7 +171,7 @@ vi.mock('@/utils/permission', () => ({
datasetConfig: {
createdBy: string
partialMemberList: string[]
- permission: DatasetPermission
+ permission: PermissionLevel
},
) => mockHasEditPermissionForDataset(userId, datasetConfig),
}))
@@ -188,7 +197,7 @@ vi.mock('@/app/components/app/configuration/dataset-config/select-dataset', () =
onSelect,
onClose,
}: {
- onSelect: (datasets: DataSet[]) => void
+ onSelect: (datasets: DatasetDetailWithPartialMembersResponse[]) => void
onClose: () => void
}) => (
<div>
@@ -212,8 +221,8 @@ vi.mock('@/app/components/app/configuration/dataset-config/settings-modal', () =
onSave,
onCancel,
}: {
- currentDataset: DataSet
- onSave: (dataset: DataSet) => void
+ currentDataset: DatasetDetailWithPartialMembersResponse
+ onSave: (dataset: DatasetDetailWithPartialMembersResponse) => void
onCancel: () => void
}) {
const hasSavedRef = useRef(false)
@@ -429,7 +438,7 @@ describe('knowledge-retrieval path', () => {
it('should hide dataset settings when ACL does not grant edit even if legacy dataset permission allows it', () => {
const dataset = createDataset({
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
permission_keys: [DatasetACLPermission.Use],
})
mockHasEditPermissionForDataset.mockReturnValue(true)
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/node.spec.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/node.spec.tsx
index 5bd9d4398a9..19d3a822f7f 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/node.spec.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/node.spec.tsx
@@ -1,7 +1,8 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { KnowledgeRetrievalNodeType } from '../types'
-import type { DataSet } from '@/models/datasets'
import { render, screen } from '@testing-library/react'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD, RETRIEVE_TYPE } from '@/types/app'
import { DatasetsDetailContext } from '../../../datasets-detail-store/provider'
@@ -10,7 +11,9 @@ import { BlockEnum } from '../../../types'
import Node from '../node'
import { MetadataFilteringModeEnum } from '../types'
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Dataset Name',
@@ -21,9 +24,10 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1690000000,
@@ -79,7 +83,10 @@ const createData = (
...overrides,
})
-const renderWithDatasets = (data: KnowledgeRetrievalNodeType, datasets: DataSet[] = []) => {
+const renderWithDatasets = (
+ data: KnowledgeRetrievalNodeType,
+ datasets: DatasetDetailWithPartialMembersResponse[] = [],
+) => {
const store = createDatasetsDetailStore()
store.getState().updateDatasetsDetail(datasets)
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/panel.spec.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/panel.spec.tsx
index 9549e5d4745..a38e0684c99 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/panel.spec.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/panel.spec.tsx
@@ -1,11 +1,15 @@
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetDocMetadataResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactNode } from 'react'
import type { KnowledgeRetrievalNodeType } from '../types'
import type { NodePanelProps } from '@/app/components/workflow/types'
-import type { DataSet, MetadataInDoc } from '@/models/datasets'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { BlockEnum, VarType } from '@/app/components/workflow/types'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD, RETRIEVE_TYPE } from '@/types/app'
import Panel from '../panel'
@@ -23,7 +27,9 @@ const mockDatasetList = vi.hoisted(() => vi.fn())
const mockAddKnowledge = vi.hoisted(() => vi.fn())
const mockMetadataFilter = vi.hoisted(() => vi.fn())
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Dataset Name',
@@ -34,9 +40,10 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1690000000,
@@ -78,7 +85,9 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
...overrides,
})
-const createMetadata = (overrides: Partial<MetadataInDoc> = {}): MetadataInDoc => ({
+const createMetadata = (
+ overrides: Partial<DatasetDocMetadataResponse> = {},
+): DatasetDocMetadataResponse => ({
id: 'meta-1',
name: 'topic',
type: MetadataFilteringVariableType.string,
@@ -152,7 +161,10 @@ vi.mock('../components/retrieval-config', () => ({
vi.mock('../components/dataset-list', () => ({
__esModule: true,
- default: (props: { list: DataSet[]; onChange: (datasets: DataSet[]) => void }) => {
+ default: (props: {
+ list: DatasetDetailWithPartialMembersResponse[]
+ onChange: (datasets: DatasetDetailWithPartialMembersResponse[]) => void
+ }) => {
mockDatasetList(props)
return (
<button
@@ -169,7 +181,10 @@ vi.mock('../components/dataset-list', () => ({
vi.mock('../components/add-dataset', () => ({
__esModule: true,
- default: (props: { selectedIds: string[]; onChange: (datasets: DataSet[]) => void }) => {
+ default: (props: {
+ selectedIds: string[]
+ onChange: (datasets: DatasetDetailWithPartialMembersResponse[]) => void
+ }) => {
mockAddKnowledge(props)
return (
<button
@@ -185,8 +200,8 @@ vi.mock('../components/add-dataset', () => ({
vi.mock('../components/metadata/metadata-filter', () => ({
__esModule: true,
default: (props: {
- metadataList: MetadataInDoc[]
- handleAddCondition: ({ id, name, type }: MetadataInDoc) => void
+ metadataList: DatasetDocMetadataResponse[]
+ handleAddCondition: ({ id, name, type }: DatasetDocMetadataResponse) => void
handleMetadataFilterModeChange: (mode: MetadataFilteringModeEnum) => void
handleRemoveCondition: (id: string) => void
handleToggleConditionLogicalOperator: () => void
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/use-config.spec.ts b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/use-config.spec.ts
index 16f4eaf77da..cb9f53faad3 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/use-config.spec.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/__tests__/use-config.spec.ts
@@ -1,5 +1,9 @@
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetDocMetadataResponse,
+ DatasetListResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { KnowledgeRetrievalNodeType } from '../types'
-import type { DataSet, DataSetListResponse, MetadataInDoc } from '@/models/datasets'
import { act, renderHook, waitFor } from '@testing-library/react'
import { isEqual } from 'es-toolkit/predicate'
import { useState } from 'react'
@@ -12,7 +16,8 @@ import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import { BlockEnum, VarType } from '@/app/components/workflow/types'
import { DATASET_DEFAULT } from '@/config'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { fetchDatasets } from '@/service/datasets'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD, RETRIEVE_TYPE } from '@/types/app'
@@ -68,7 +73,7 @@ vi.mock('@/service/datasets', () => ({
fetchDatasets: vi.fn(),
}))
-type DatasetListItem = DataSetListResponse['data'][number]
+type DatasetListItem = DatasetListResponse['data'][number]
const mockUseNodesReadOnly = vi.mocked(useNodesReadOnly)
const mockUseIsChatMode = vi.hoisted(() => vi.fn())
@@ -93,9 +98,10 @@ const createDataset = (overrides: Partial<DatasetListItem> = {}): DatasetListIte
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1690000000,
@@ -137,7 +143,9 @@ const createDataset = (overrides: Partial<DatasetListItem> = {}): DatasetListIte
...overrides,
})
-const createMetadata = (overrides: Partial<MetadataInDoc> = {}): MetadataInDoc => ({
+const createMetadata = (
+ overrides: Partial<DatasetDocMetadataResponse> = {},
+): DatasetDocMetadataResponse => ({
id: 'meta-1',
name: 'topic',
type: MetadataFilteringVariableType.string,
@@ -406,13 +414,15 @@ describe('knowledge-retrieval/use-config', () => {
createDataset({
id: 'dataset-2',
name: 'Economic',
- indexing_technique: 'economy' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'economy' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
is_multimodal: false,
}),
createDataset({
id: 'dataset-3',
name: 'High Quality',
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
is_multimodal: false,
}),
])
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/add-dataset.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/add-dataset.tsx
index 797b9d80490..cc85fe033ac 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/add-dataset.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/add-dataset.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { DataSet } from '@/models/datasets'
import * as React from 'react'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -9,7 +9,7 @@ import SelectDataset from '@/app/components/app/configuration/dataset-config/sel
type Props = Readonly<{
selectedIds: string[]
modal?: boolean
- onChange: (dataSets: DataSet[]) => void
+ onChange: (dataSets: DatasetDetailWithPartialMembersResponse[]) => void
}>
const AddDataset: FC<Props> = ({ selectedIds, modal, onChange }) => {
@@ -17,7 +17,7 @@ const AddDataset: FC<Props> = ({ selectedIds, modal, onChange }) => {
const [isShowModal, setIsShowModal] = useState(false)
const handleSelect = useCallback(
- (datasets: DataSet[]) => {
+ (datasets: DatasetDetailWithPartialMembersResponse[]) => {
onChange(datasets)
setIsShowModal(false)
},
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx
index 25669f7051e..3dec83a5560 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-item.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { DrawerActions } from '@langgenius/dify-ui/drawer'
import type { FC } from 'react'
-import type { DataSet } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import {
Drawer,
@@ -25,9 +25,9 @@ import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import { useKnowledge } from '@/hooks/use-knowledge'
type Props = Readonly<{
- payload: DataSet
+ payload: DatasetDetailWithPartialMembersResponse
onRemove: () => void
- onChange: (dataSet: DataSet) => void
+ onChange: (dataSet: DatasetDetailWithPartialMembersResponse) => void
readonly?: boolean
editable?: boolean
settingsDrawerBackdropClassName?: string
@@ -56,7 +56,7 @@ const DatasetItem: FC<Props> = ({
const settingsDrawerActionsRef = useRef<DrawerActions>(null)
const handleSave = useCallback(
- (newDataset: DataSet) => {
+ (newDataset: DatasetDetailWithPartialMembersResponse) => {
onChange(newDataset)
settingsDrawerActionsRef.current?.close()
},
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-list.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-list.tsx
index 94de1210de1..dacbeeb4a3d 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-list.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/dataset-list.tsx
@@ -1,7 +1,7 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
-import type { DataSet } from '@/models/datasets'
import { useSuspenseQuery } from '@tanstack/react-query'
import { produce } from 'immer'
import { useAtomValue } from 'jotai'
@@ -14,8 +14,8 @@ import { getDatasetACLCapabilities } from '@/utils/permission'
import Item from './dataset-item'
type Props = Readonly<{
- list: DataSet[]
- onChange: (list: DataSet[]) => void
+ list: DatasetDetailWithPartialMembersResponse[]
+ onChange: (list: DatasetDetailWithPartialMembersResponse[]) => void
readonly?: boolean
settingsDrawerBackdropClassName?: string
settingsDrawerBackdropForceRender?: boolean
@@ -53,7 +53,7 @@ const DatasetList: FC<Props> = ({
const handleChange = useCallback(
(index: number) => {
- return (value: DataSet) => {
+ return (value: DatasetDetailWithPartialMembersResponse) => {
const newList = produce(list, (draft) => {
draft[index] = value
})
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
index 17ef7109440..da632c31f8c 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/components/retrieval-config.tsx
@@ -1,9 +1,9 @@
'use client'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
import type { ModelConfig } from '../../../types'
import type { MultipleRetrievalConfig, SingleRetrievalConfig } from '../types'
import type { ModelParameterModalProps } from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
-import type { DataSet } from '@/models/datasets'
import type { DatasetConfigs } from '@/models/debug'
import { Button } from '@langgenius/dify-ui/button'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
@@ -30,7 +30,7 @@ type Props = Readonly<{
modal?: boolean
rerankModalOpen: boolean
onRerankModelOpenChange: (open: boolean) => void
- selectedDatasets: DataSet[]
+ selectedDatasets: DatasetDetailWithPartialMembersResponse[]
}>
const RetrievalConfig: FC<Props> = ({
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/hooks.ts b/web/app/components/workflow/nodes/knowledge-retrieval/hooks.ts
index 936dd75fbd4..9d0bf41ea9b 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/hooks.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/hooks.ts
@@ -1,8 +1,9 @@
-import type { DataSet, SelectedDatasetsMode } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
+import type { SelectedDatasetsMode } from '@/models/datasets'
import { useMemo } from 'react'
import { getSelectedDatasetsMode } from './utils'
-export const useSelectedDatasetsMode = (datasets: DataSet[]) => {
+export const useSelectedDatasetsMode = (datasets: DatasetDetailWithPartialMembersResponse[]) => {
const selectedDatasetsMode: SelectedDatasetsMode = useMemo(() => {
return getSelectedDatasetsMode(datasets)
}, [datasets])
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-dataset-selection.spec.ts b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-dataset-selection.spec.ts
index e78e7ce35e4..6f1311d268a 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-dataset-selection.spec.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-dataset-selection.spec.ts
@@ -1,9 +1,13 @@
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetListResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { MutableRefObject } from 'react'
import type { KnowledgeRetrievalNodeType } from '../../types'
-import type { DataSet, DataSetListResponse } from '@/models/datasets'
import { act, renderHook, waitFor } from '@testing-library/react'
import { BlockEnum } from '@/app/components/workflow/types'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { fetchDatasets } from '@/service/datasets'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD, RETRIEVE_TYPE } from '@/types/app'
@@ -13,7 +17,7 @@ vi.mock('@/service/datasets', () => ({
fetchDatasets: vi.fn(),
}))
-type DatasetListItem = DataSetListResponse['data'][number]
+type DatasetListItem = DatasetListResponse['data'][number]
const mockFetchDatasets = vi.mocked(fetchDatasets)
@@ -28,9 +32,10 @@ const createDataset = (overrides: Partial<DatasetListItem> = {}): DatasetListIte
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1690000000,
@@ -193,13 +198,15 @@ describe('use-knowledge-dataset-selection', () => {
createDataset({
id: 'dataset-2',
name: 'Economic Internal',
- indexing_technique: 'economy' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'economy' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
provider: 'internal',
}),
createDataset({
id: 'dataset-3',
name: 'High Quality Internal',
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
provider: 'internal',
}),
]
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-model-config.spec.ts b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-model-config.spec.ts
index 3e345425025..189b0970c2d 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-model-config.spec.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/__tests__/use-knowledge-model-config.spec.ts
@@ -1,15 +1,18 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { MutableRefObject } from 'react'
import type { KnowledgeRetrievalNodeType } from '../../types'
-import type { DataSet } from '@/models/datasets'
import { act, renderHook, waitFor } from '@testing-library/react'
import { BlockEnum } from '@/app/components/workflow/types'
import { DATASET_DEFAULT } from '@/config'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { createDatasetFixture } from '@/test/fixtures/dataset'
import { RETRIEVE_METHOD, RETRIEVE_TYPE } from '@/types/app'
import useKnowledgeModelConfig from '../use-knowledge-model-config'
-const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
+const createDataset = (
+ overrides: Partial<DatasetDetailWithPartialMembersResponse> = {},
+): DatasetDetailWithPartialMembersResponse => ({
...createDatasetFixture(),
id: 'dataset-1',
name: 'Dataset Name',
@@ -20,9 +23,10 @@ const createDataset = (overrides: Partial<DataSet> = {}): DataSet => ({
icon_url: '',
},
description: 'Dataset description',
- permission: DatasetPermission.onlyMe,
+ permission: PermissionLevel.onlyMe,
data_source_type: DataSourceType.FILE,
- indexing_technique: 'high_quality' as DataSet['indexing_technique'],
+ indexing_technique:
+ 'high_quality' as DatasetDetailWithPartialMembersResponse['indexing_technique'],
created_by: 'user-1',
updated_by: 'user-1',
updated_at: 1690000000,
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-dataset-selection.ts b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-dataset-selection.ts
index c106df2e940..0bec408c74b 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-dataset-selection.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-dataset-selection.ts
@@ -1,6 +1,6 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { MutableRefObject } from 'react'
import type { KnowledgeRetrievalNodeType } from '../types'
-import type { DataSet } from '@/models/datasets'
import { produce } from 'immer'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { fetchDatasets } from '@/service/datasets'
@@ -17,7 +17,7 @@ type Params = {
inputRef: MutableRefObject<KnowledgeRetrievalNodeType>
setInputs: (inputs: KnowledgeRetrievalNodeType) => void
payloadRetrievalMode: RETRIEVE_TYPE
- updateDatasetsDetail: (datasets: DataSet[]) => void
+ updateDatasetsDetail: (datasets: DatasetDetailWithPartialMembersResponse[]) => void
fallbackRerankModel: ModelIdentity
}
@@ -29,7 +29,9 @@ const useKnowledgeDatasetSelection = ({
updateDatasetsDetail,
fallbackRerankModel,
}: Params) => {
- const [selectedDatasets, setSelectedDatasets] = useState<DataSet[]>([])
+ const [selectedDatasets, setSelectedDatasets] = useState<
+ DatasetDetailWithPartialMembersResponse[]
+ >([])
const [selectedDatasetsLoaded, setSelectedDatasetsLoaded] = useState(false)
const [rerankModelOpen, setRerankModelOpen] = useState(false)
@@ -56,7 +58,7 @@ const useKnowledgeDatasetSelection = ({
}, [inputRef, setInputs])
const handleOnDatasetsChange = useCallback(
- (newDatasets: DataSet[]) => {
+ (newDatasets: DatasetDetailWithPartialMembersResponse[]) => {
const {
mixtureHighQualityAndEconomic,
mixtureInternalAndExternal,
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-model-config.ts b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-model-config.ts
index 46ec719dffa..d620e3f7f2a 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-model-config.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/hooks/use-knowledge-model-config.ts
@@ -1,7 +1,7 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { MutableRefObject } from 'react'
import type { KnowledgeRetrievalNodeType, MultipleRetrievalConfig } from '../types'
import type { ModelConfig } from '@/app/components/workflow/types'
-import type { DataSet } from '@/models/datasets'
import { isEqual } from 'es-toolkit/predicate'
import { produce } from 'immer'
import { useCallback, useEffect } from 'react'
@@ -29,7 +29,7 @@ type Params = {
inputs: KnowledgeRetrievalNodeType
inputRef: MutableRefObject<KnowledgeRetrievalNodeType>
setInputs: (inputs: KnowledgeRetrievalNodeType) => void
- selectedDatasets: DataSet[]
+ selectedDatasets: DatasetDetailWithPartialMembersResponse[]
currentProvider?: TextProvider
currentModel?: TextModel
fallbackRerankModel: ModelIdentity
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/node.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/node.tsx
index f1f3163ec82..2e414e01973 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/node.tsx
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/node.tsx
@@ -1,22 +1,27 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FC } from 'react'
import type { KnowledgeRetrievalNodeType } from './types'
import type { NodeProps } from '@/app/components/workflow/types'
-import type { DataSet } from '@/models/datasets'
import * as React from 'react'
import { useEffect, useState } from 'react'
import AppIcon from '@/app/components/base/app-icon'
import { useDatasetsDetailStore } from '../../datasets-detail-store/store'
const Node: FC<NodeProps<KnowledgeRetrievalNodeType>> = ({ data }) => {
- const [selectedDatasets, setSelectedDatasets] = useState<DataSet[]>([])
+ const [selectedDatasets, setSelectedDatasets] = useState<
+ DatasetDetailWithPartialMembersResponse[]
+ >([])
const datasetsDetail = useDatasetsDetailStore((s) => s.datasetsDetail)
useEffect(() => {
if (data.dataset_ids?.length > 0) {
- const dataSetsWithDetail = data.dataset_ids.reduce<DataSet[]>((acc, id) => {
- if (datasetsDetail[id]) acc.push(datasetsDetail[id])
- return acc
- }, [])
+ const dataSetsWithDetail = data.dataset_ids.reduce<DatasetDetailWithPartialMembersResponse[]>(
+ (acc, id) => {
+ if (datasetsDetail[id]) acc.push(datasetsDetail[id])
+ return acc
+ },
+ [],
+ )
setSelectedDatasets(dataSetsWithDetail)
} else {
setSelectedDatasets([])
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts
index 4b3ebc5c994..12a9063c980 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/types.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/types.ts
@@ -1,3 +1,7 @@
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetDocMetadataResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type {
CommonNodeType,
ModelConfig,
@@ -5,12 +9,7 @@ import type {
NodeOutPutVar,
ValueSelector,
} from '@/app/components/workflow/types'
-import type {
- DataSet,
- MetadataInDoc,
- RerankingModeEnum,
- WeightedScoreEnum,
-} from '@/models/datasets'
+import type { RerankingModeEnum, WeightedScoreEnum } from '@/models/datasets'
import type { RETRIEVE_TYPE } from '@/types/app'
export type MultipleRetrievalConfig = {
@@ -113,19 +112,19 @@ export type KnowledgeRetrievalNodeType = CommonNodeType & {
retrieval_mode: RETRIEVE_TYPE
multiple_retrieval_config?: MultipleRetrievalConfig
single_retrieval_config?: SingleRetrievalConfig
- _datasets?: DataSet[]
+ _datasets?: DatasetDetailWithPartialMembersResponse[]
metadata_filtering_mode?: MetadataFilteringModeEnum
metadata_filtering_conditions?: MetadataFilteringConditions
metadata_model_config?: ModelConfig
}
-export type HandleAddCondition = (metadataItem: MetadataInDoc) => void
+export type HandleAddCondition = (metadataItem: DatasetDocMetadataResponse) => void
export type HandleRemoveCondition = (id: string) => void
export type HandleUpdateCondition = (id: string, newCondition: MetadataFilteringCondition) => void
export type HandleToggleConditionLogicalOperator = () => void
export type MetadataShape = {
- metadataList?: MetadataInDoc[]
+ metadataList?: DatasetDocMetadataResponse[]
selectedDatasetsLoaded?: boolean
metadataFilteringConditions?: MetadataFilteringConditions
handleAddCondition: HandleAddCondition
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/use-single-run-form-params.ts b/web/app/components/workflow/nodes/knowledge-retrieval/use-single-run-form-params.ts
index 976d24f9cea..40800372b7b 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/use-single-run-form-params.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/use-single-run-form-params.ts
@@ -1,8 +1,8 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { RefObject } from 'react'
import type { KnowledgeRetrievalNodeType } from './types'
import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form'
import type { InputVar, Var, Variable } from '@/app/components/workflow/types'
-import type { DataSet } from '@/models/datasets'
import { useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { InputVarType, VarType } from '@/app/components/workflow/types'
@@ -67,7 +67,7 @@ const useSingleRunFormParams = ({
const forms = useMemo(() => {
const datasetIds = payload.dataset_ids
- const datasets = datasetIds.reduce<DataSet[]>((acc, id) => {
+ const datasets = datasetIds.reduce<DatasetDetailWithPartialMembersResponse[]>((acc, id) => {
if (datasetsDetail[id]) acc.push(datasetsDetail[id])
return acc
}, [])
diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts b/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts
index 81d8f9a4fcb..9d2978f6c73 100644
--- a/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts
+++ b/web/app/components/workflow/nodes/knowledge-retrieval/utils.ts
@@ -1,12 +1,15 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { MultipleRetrievalConfig } from './types'
-import type { DataSet, SelectedDatasetsMode } from '@/models/datasets'
+import type { SelectedDatasetsMode } from '@/models/datasets'
import { uniq } from 'es-toolkit/array'
import { xorBy } from 'es-toolkit/compat'
import { DATASET_DEFAULT } from '@/config'
import { DEFAULT_WEIGHTED_SCORE, RerankingModeEnum, WeightedScoreEnum } from '@/models/datasets'
import { RETRIEVE_METHOD } from '@/types/app'
-export const getSelectedDatasetsMode = (datasets: DataSet[] = []) => {
+export const getSelectedDatasetsMode = (
+ datasets: DatasetDetailWithPartialMembersResponse[] = [],
+) => {
if (datasets === null) datasets = []
let allHighQuality = true
let allHighQualityVectorSearch = true
@@ -75,8 +78,8 @@ export const getSelectedDatasetsMode = (datasets: DataSet[] = []) => {
export const getMultipleRetrievalConfig = (
multipleRetrievalConfig: MultipleRetrievalConfig,
- selectedDatasets: DataSet[],
- originalDatasets: DataSet[],
+ selectedDatasets: DatasetDetailWithPartialMembersResponse[],
+ originalDatasets: DatasetDetailWithPartialMembersResponse[],
fallbackRerankModel?: { provider?: string; model?: string }, // fallback rerank model
) => {
// Check if the selected datasets are different from the original datasets
@@ -255,7 +258,7 @@ export const getMultipleRetrievalConfig = (
}
export const checkoutRerankModelConfiguredInRetrievalSettings = (
- datasets: DataSet[],
+ datasets: DatasetDetailWithPartialMembersResponse[],
multipleRetrievalConfig?: MultipleRetrievalConfig,
) => {
if (!multipleRetrievalConfig) return true
diff --git a/web/app/components/workflow/nodes/loop-end/default.ts b/web/app/components/workflow/nodes/loop-end/default.ts
index fb37cbc0cd2..58a6488a088 100644
--- a/web/app/components/workflow/nodes/loop-end/default.ts
+++ b/web/app/components/workflow/nodes/loop-end/default.ts
@@ -1,5 +1,4 @@
-import type { NodeDefault } from '../../types'
-import type { SimpleNodeType } from '@/app/components/workflow/simple-node/types'
+import type { CommonNodeType, NodeDefault } from '../../types'
import { BlockClassification } from '@/app/components/workflow/block-selector/types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
@@ -10,7 +9,7 @@ const metaData = genNodeMetaData({
type: BlockEnum.LoopEnd,
isSingleton: true,
})
-const nodeDefault: NodeDefault<SimpleNodeType> = {
+const nodeDefault: NodeDefault<CommonNodeType> = {
metaData,
defaultValue: {},
checkValid() {
diff --git a/web/app/components/workflow/nodes/loop-start/default.ts b/web/app/components/workflow/nodes/loop-start/default.ts
index 7b39eff078a..4f672adc6ef 100644
--- a/web/app/components/workflow/nodes/loop-start/default.ts
+++ b/web/app/components/workflow/nodes/loop-start/default.ts
@@ -1,5 +1,4 @@
-import type { NodeDefault } from '../../types'
-import type { LoopStartNodeType } from './types'
+import type { CommonNodeType, NodeDefault } from '../../types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
@@ -7,7 +6,7 @@ const metaData = genNodeMetaData({
sort: -1,
type: BlockEnum.LoopStart,
})
-const nodeDefault: NodeDefault<LoopStartNodeType> = {
+const nodeDefault: NodeDefault<CommonNodeType> = {
metaData,
defaultValue: {},
checkValid() {
diff --git a/web/app/components/workflow/nodes/loop-start/types.ts b/web/app/components/workflow/nodes/loop-start/types.ts
deleted file mode 100644
index 1ba7136926d..00000000000
--- a/web/app/components/workflow/nodes/loop-start/types.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import type { CommonNodeType } from '@/app/components/workflow/types'
-
-export type LoopStartNodeType = CommonNodeType
diff --git a/web/app/components/workflow/nodes/start-placeholder/default.ts b/web/app/components/workflow/nodes/start-placeholder/default.ts
index 848135e6cf4..d26fa4e0adc 100644
--- a/web/app/components/workflow/nodes/start-placeholder/default.ts
+++ b/web/app/components/workflow/nodes/start-placeholder/default.ts
@@ -1,6 +1,5 @@
import type { TFunction } from 'i18next'
-import type { NodeDefault } from '../../types'
-import type { StartPlaceholderNodeType } from './types'
+import type { CommonNodeType, NodeDefault } from '../../types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
@@ -13,7 +12,7 @@ const metaData = genNodeMetaData({
helpLinkUri: 'start',
})
-const nodeDefault: NodeDefault<StartPlaceholderNodeType> = {
+const nodeDefault: NodeDefault<CommonNodeType> = {
metaData,
defaultValue: {
title: 'Workflow start',
diff --git a/web/app/components/workflow/nodes/start-placeholder/panel.tsx b/web/app/components/workflow/nodes/start-placeholder/panel.tsx
index e924fe15b25..3018acf769a 100644
--- a/web/app/components/workflow/nodes/start-placeholder/panel.tsx
+++ b/web/app/components/workflow/nodes/start-placeholder/panel.tsx
@@ -1,10 +1,9 @@
import type { FC } from 'react'
-import type { StartPlaceholderNodeType } from './types'
import type {
PluginDefaultValue,
TriggerDefaultValue,
} from '@/app/components/workflow/block-selector/types'
-import type { NodePanelProps } from '@/app/components/workflow/types'
+import type { CommonNodeType, NodePanelProps } from '@/app/components/workflow/types'
import * as React from 'react'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -42,7 +41,7 @@ const getTriggerPluginNodeData = (
}
}
-const Panel: FC<NodePanelProps<StartPlaceholderNodeType>> = ({ id }) => {
+const Panel: FC<NodePanelProps<CommonNodeType>> = ({ id }) => {
const { t } = useTranslation(['workflow'])
const [searchText, setSearchText] = useState('')
const [tags, setTags] = useState<string[]>([])
diff --git a/web/app/components/workflow/nodes/start-placeholder/types.ts b/web/app/components/workflow/nodes/start-placeholder/types.ts
deleted file mode 100644
index 30f354f5b08..00000000000
--- a/web/app/components/workflow/nodes/start-placeholder/types.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import type { CommonNodeType } from '@/app/components/workflow/types'
-
-export type StartPlaceholderNodeType = CommonNodeType
diff --git a/web/app/components/workflow/nodes/tool/output-schema-utils.ts b/web/app/components/workflow/nodes/tool/output-schema-utils.ts
index 7b087f3056c..60c7552a9f3 100644
--- a/web/app/components/workflow/nodes/tool/output-schema-utils.ts
+++ b/web/app/components/workflow/nodes/tool/output-schema-utils.ts
@@ -1,4 +1,4 @@
-import type { SchemaTypeDefinition } from '@/service/use-common'
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import { VarType } from '@/app/components/workflow/types'
import { getMatchedSchemaType } from '../_base/components/variable/use-match-schema-type'
@@ -68,7 +68,7 @@ export const pickItemSchema = (schema: any) => {
*/
export const resolveVarType = (
schema: any,
- schemaTypeDefinitions?: SchemaTypeDefinition[],
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): { type: VarType; schemaType?: string } => {
const schemaType = getMatchedSchemaType(schema, schemaTypeDefinitions)
if (schema && typeof schema.type === 'string') {
diff --git a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsx b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsx
index 463980abc36..4e6bb841331 100644
--- a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsx
+++ b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsx
@@ -3,15 +3,15 @@ import type { FC } from 'react'
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { Event } from '@/app/components/tools/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
-import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'
+import type { ResourceVarInputs } from '@/app/components/workflow/nodes/_base/types'
import { TriggerFormItem } from './item'
type Props = Readonly<{
readOnly: boolean
nodeId: string
schema: CredentialFormSchema[]
- value: PluginTriggerVarInputs
- onChange: (value: PluginTriggerVarInputs) => void
+ value: ResourceVarInputs
+ onChange: (value: ResourceVarInputs) => void
onOpen?: (index: number) => void
currentEvent?: Event
currentProvider?: TriggerWithProvider
diff --git a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx
index 50cc2a7d890..efb73bddbf0 100644
--- a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx
+++ b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx
@@ -2,7 +2,7 @@
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { Event } from '@/app/components/tools/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
-import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'
+import type { ResourceVarInputs } from '@/app/components/workflow/nodes/_base/types'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
import { useId } from 'react'
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
@@ -14,8 +14,8 @@ type Props = Readonly<{
readOnly: boolean
nodeId: string
schema: CredentialFormSchema
- value: PluginTriggerVarInputs
- onChange: (value: PluginTriggerVarInputs) => void
+ value: ResourceVarInputs
+ onChange: (value: ResourceVarInputs) => void
currentEvent?: Event
currentProvider?: TriggerWithProvider
extraParams?: Record<string, unknown>
diff --git a/web/app/components/workflow/nodes/trigger-plugin/default.ts b/web/app/components/workflow/nodes/trigger-plugin/default.ts
index 61a30c45384..2f25671dec3 100644
--- a/web/app/components/workflow/nodes/trigger-plugin/default.ts
+++ b/web/app/components/workflow/nodes/trigger-plugin/default.ts
@@ -1,8 +1,8 @@
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { TFunction } from 'i18next'
import type { NodeDefault, Var } from '../../types'
import type { Field, StructuredOutput } from '../llm/types'
import type { PluginTriggerNodeType } from './types'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import { BlockEnum, VarType } from '../../types'
import { genNodeMetaData } from '../../utils'
import { VarKindType } from '../_base/types'
@@ -40,7 +40,7 @@ const pickItemSchema = (schema: any) => {
const extractSchemaType = (
schema: any,
- _schemaTypeDefinitions?: SchemaTypeDefinition[],
+ _schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): string | undefined => {
if (!schema) return undefined
@@ -53,7 +53,7 @@ const extractSchemaType = (
const resolveVarType = (
schema: any,
- schemaTypeDefinitions?: SchemaTypeDefinition[],
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): { type: VarType; schemaType?: string } => {
const schemaType = extractSchemaType(schema, schemaTypeDefinitions)
const normalizedType = normalizeJsonSchemaType(schema)
@@ -129,7 +129,7 @@ const toArrayItemType = (type: Type): Exclude<Type, typeof Type.array> => {
const convertJsonSchemaToField = (
schema: any,
- schemaTypeDefinitions?: SchemaTypeDefinition[],
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): Field => {
const schemaType = extractSchemaType(schema, schemaTypeDefinitions)
const normalizedType = normalizeJsonSchemaType(schema)
@@ -177,7 +177,7 @@ const convertJsonSchemaToField = (
const buildOutputVars = (
schema: Record<string, any>,
- schemaTypeDefinitions?: SchemaTypeDefinition[],
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[],
): Var[] => {
if (!schema || typeof schema !== 'object') return []
diff --git a/web/app/components/workflow/nodes/trigger-plugin/types.ts b/web/app/components/workflow/nodes/trigger-plugin/types.ts
index 2ec1521749c..a2f7200b792 100644
--- a/web/app/components/workflow/nodes/trigger-plugin/types.ts
+++ b/web/app/components/workflow/nodes/trigger-plugin/types.ts
@@ -1,5 +1,5 @@
-import type { ResourceVarInputs } from '../_base/types'
import type { CollectionType } from '@/app/components/tools/types'
+import type { ResourceVarInputs } from '@/app/components/workflow/nodes/_base/types'
import type { CommonNodeType } from '@/app/components/workflow/types'
export type PluginTriggerNodeType = CommonNodeType & {
@@ -8,7 +8,7 @@ export type PluginTriggerNodeType = CommonNodeType & {
provider_name: string
event_name: string
event_label: string
- event_parameters: PluginTriggerVarInputs
+ event_parameters: ResourceVarInputs
event_configurations: Record<string, any>
output_schema: Record<string, any>
parameters_schema?: Record<string, any>[]
@@ -18,7 +18,3 @@ export type PluginTriggerNodeType = CommonNodeType & {
config?: Record<string, any>
plugin_unique_identifier?: string
}
-
-// Use base types directly
-
-export type PluginTriggerVarInputs = ResourceVarInputs
diff --git a/web/app/components/workflow/nodes/trigger-plugin/use-config.ts b/web/app/components/workflow/nodes/trigger-plugin/use-config.ts
index 0cbed38dd9e..7cf69d8477f 100644
--- a/web/app/components/workflow/nodes/trigger-plugin/use-config.ts
+++ b/web/app/components/workflow/nodes/trigger-plugin/use-config.ts
@@ -1,6 +1,7 @@
-import type { PluginTriggerNodeType, PluginTriggerVarInputs } from './types'
+import type { PluginTriggerNodeType } from './types'
import type { Event } from '@/app/components/tools/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
+import type { ResourceVarInputs } from '@/app/components/workflow/nodes/_base/types'
import type { InputVar } from '@/app/components/workflow/types'
import { produce } from 'immer'
import { useCallback, useEffect, useMemo } from 'react'
@@ -14,17 +15,16 @@ import { useNodesReadOnly } from '../../hooks/use-workflow'
import { VarKindType } from '../_base/types'
const normalizeEventParameters = (
- params: PluginTriggerVarInputs | Record<string, unknown> | null | undefined,
+ params: ResourceVarInputs | Record<string, unknown> | null | undefined,
{ allowScalars = false }: { allowScalars?: boolean } = {},
-): PluginTriggerVarInputs => {
- if (!params || typeof params !== 'object' || Array.isArray(params))
- return {} as PluginTriggerVarInputs
+): ResourceVarInputs => {
+ if (!params || typeof params !== 'object' || Array.isArray(params)) return {} as ResourceVarInputs
return Object.entries(params).reduce((acc, [key, entry]) => {
if (!entry && entry !== 0 && entry !== false) return acc
if (typeof entry === 'object' && !Array.isArray(entry) && 'type' in entry && 'value' in entry) {
- const normalizedEntry = { ...(entry as PluginTriggerVarInputs[string]) }
+ const normalizedEntry = { ...(entry as ResourceVarInputs[string]) }
if (normalizedEntry.type === VarKindType.mixed) normalizedEntry.type = VarKindType.constant
acc[key] = normalizedEntry
return acc
@@ -56,7 +56,7 @@ const normalizeEventParameters = (
}
return acc
- }, {} as PluginTriggerVarInputs)
+ }, {} as ResourceVarInputs)
}
const useConfig = (id: string, payload: PluginTriggerNodeType) => {
@@ -120,7 +120,7 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
}, [triggerSpecificParameterSchema])
const triggerParameterValue = useMemo(() => {
- if (!triggerParameterSchema.length) return {} as PluginTriggerVarInputs
+ if (!triggerParameterSchema.length) return {} as ResourceVarInputs
const hasStoredParameters = event_parameters && Object.keys(event_parameters).length > 0
const baseValue = hasStoredParameters ? event_parameters : legacy_config_parameters
@@ -128,7 +128,7 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
const configuredValue = getConfiguredValue(
baseValue,
triggerParameterSchema,
- ) as PluginTriggerVarInputs
+ ) as ResourceVarInputs
return normalizeEventParameters(configuredValue)
}, [triggerParameterSchema, event_parameters, legacy_config_parameters])
@@ -147,7 +147,7 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
}, [doSetInputs, event_parameters, inputs, triggerParameterSchema, triggerParameterValue])
const setTriggerParameterValue = useCallback(
- (value: PluginTriggerVarInputs) => {
+ (value: ResourceVarInputs) => {
const sanitizedValue = normalizeEventParameters(value)
const newInputs = produce(inputs, (draft) => {
draft.event_parameters = sanitizedValue
@@ -167,7 +167,7 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
type: VarKindType.variable,
value: varDetail.variable,
},
- } as PluginTriggerVarInputs)
+ } as ResourceVarInputs)
draft.event_parameters = nextEventParameters
draft.config = nextEventParameters
diff --git a/web/app/components/workflow/panel/comments-panel/__tests__/index.spec.tsx b/web/app/components/workflow/panel/comments-panel/__tests__/index.spec.tsx
index fa8ec21d60d..2ce471b355c 100644
--- a/web/app/components/workflow/panel/comments-panel/__tests__/index.spec.tsx
+++ b/web/app/components/workflow/panel/comments-panel/__tests__/index.spec.tsx
@@ -1,5 +1,5 @@
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import type { ReactElement } from 'react'
-import type { WorkflowCommentList } from '@/app/components/workflow/comment/types'
import { fireEvent, screen } from '@testing-library/react'
import { createAccountProfileQueryWrapper } from '@/test/console/account-profile'
import { render as renderWithConsoleState } from '@/test/console/render'
@@ -19,7 +19,7 @@ const render = (ui: ReactElement) =>
wrapper: createAccountProfileQueryWrapper(mockConsoleState.userProfile),
})
-const commentFixtures: WorkflowCommentList[] = [
+const commentFixtures: WorkflowCommentBasic[] = [
{
id: 'c-1',
position_x: 10,
diff --git a/web/app/components/workflow/panel/comments-panel/index.tsx b/web/app/components/workflow/panel/comments-panel/index.tsx
index d78df25f5ae..2ab01458991 100644
--- a/web/app/components/workflow/panel/comments-panel/index.tsx
+++ b/web/app/components/workflow/panel/comments-panel/index.tsx
@@ -1,4 +1,4 @@
-import type { WorkflowCommentList } from '@/app/components/workflow/comment/types'
+import type { WorkflowCommentBasic } from '@dify/contracts/api/console/apps/types.gen'
import { cn } from '@langgenius/dify-ui/cn'
import { Separator } from '@langgenius/dify-ui/separator'
import { Switch } from '@langgenius/dify-ui/switch'
@@ -33,7 +33,7 @@ const CommentsPanel = () => {
const [showFilter, setShowFilter] = useState(false)
const handleSelect = useCallback(
- (comment: WorkflowCommentList) => {
+ (comment: WorkflowCommentBasic) => {
handleCommentIconClick(comment)
},
[handleCommentIconClick],
@@ -53,7 +53,7 @@ const CommentsPanel = () => {
}, [comments, currentUserId, showOnlyMine, showResolvedComments])
const handleResolve = useCallback(
- async (comment: WorkflowCommentList) => {
+ async (comment: WorkflowCommentBasic) => {
if (comment.resolved) return
try {
await handleCommentResolve(comment.id)
diff --git a/web/app/components/workflow/panel/version-history-panel/__tests__/delete-confirm-modal.spec.tsx b/web/app/components/workflow/panel/version-history-panel/__tests__/delete-confirm-modal.spec.tsx
index 57267b977a9..6596595cdef 100644
--- a/web/app/components/workflow/panel/version-history-panel/__tests__/delete-confirm-modal.spec.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/__tests__/delete-confirm-modal.spec.tsx
@@ -1,9 +1,11 @@
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import DeleteConfirmModal from '../delete-confirm-modal'
-const createVersionInfo = (overrides: Partial<VersionHistory> = {}): VersionHistory => ({
+const createVersionInfo = (
+ overrides: Partial<FetchWorkflowDraftResponse> = {},
+): FetchWorkflowDraftResponse => ({
id: 'version-1',
graph: {
nodes: [],
diff --git a/web/app/components/workflow/panel/version-history-panel/__tests__/index.spec.tsx b/web/app/components/workflow/panel/version-history-panel/__tests__/index.spec.tsx
index 94d47050ad5..a08efcf03a4 100644
--- a/web/app/components/workflow/panel/version-history-panel/__tests__/index.spec.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/__tests__/index.spec.tsx
@@ -1,7 +1,7 @@
import type { CloudPlan } from '@dify/contracts/api/console/features/types.gen'
import type { ReactElement } from 'react'
import type { Shape } from '../../../store'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
@@ -30,11 +30,13 @@ const mockToast = vi.hoisted(() => ({
}))
let mockPlanType: CloudPlan = 'professional'
let deploymentEdition: 'CLOUD' | 'COMMUNITY' = 'CLOUD'
-let mockPublishedEnvironments: VersionHistory['environments']
+let mockPublishedEnvironments: FetchWorkflowDraftResponse['environments']
let mockHasNextPage = false
let mockIsFetching = false
-const createVersionHistory = (overrides: Partial<VersionHistory> = {}): VersionHistory => ({
+const createVersionHistory = (
+ overrides: Partial<FetchWorkflowDraftResponse> = {},
+): FetchWorkflowDraftResponse => ({
id: 'version-id',
version: WorkflowVersion.Draft,
graph: { nodes: [], edges: [] },
@@ -60,7 +62,7 @@ const createVersionHistory = (overrides: Partial<VersionHistory> = {}): VersionH
...overrides,
})
-let mockCurrentVersion: VersionHistory | null = null
+let mockCurrentVersion: FetchWorkflowDraftResponse | null = null
type MockVersionStoreState = Pick<
Shape,
@@ -68,15 +70,15 @@ type MockVersionStoreState = Pick<
>
type MockRestoreConfirmModalProps = {
isOpen: boolean
- versionInfo: VersionHistory
- onRestore: (item: VersionHistory) => void
+ versionInfo: FetchWorkflowDraftResponse
+ onRestore: (item: FetchWorkflowDraftResponse) => void
}
type MockDeleteConfirmModalProps = {
isOpen: boolean
}
type MockVersionHistoryItemProps = {
- item: VersionHistory
- onClick: (item: VersionHistory) => void
+ item: FetchWorkflowDraftResponse
+ onClick: (item: FetchWorkflowDraftResponse) => void
handleClickActionMenuItem: (operation: VersionHistoryContextMenuOptions) => void
}
@@ -200,7 +202,7 @@ vi.mock('@/app/components/app/app-publisher/version-info-modal', () => ({
versionInfo,
onPublish,
}: {
- versionInfo: VersionHistory
+ versionInfo: FetchWorkflowDraftResponse
onPublish: (params: { id?: string; title: string; releaseNotes: string }) => Promise<void>
}) => (
<button
diff --git a/web/app/components/workflow/panel/version-history-panel/__tests__/restore-confirm-modal.spec.tsx b/web/app/components/workflow/panel/version-history-panel/__tests__/restore-confirm-modal.spec.tsx
index a08b823b010..ad51464716b 100644
--- a/web/app/components/workflow/panel/version-history-panel/__tests__/restore-confirm-modal.spec.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/__tests__/restore-confirm-modal.spec.tsx
@@ -1,9 +1,11 @@
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import RestoreConfirmModal from '../restore-confirm-modal'
-const createVersionInfo = (overrides: Partial<VersionHistory> = {}): VersionHistory => ({
+const createVersionInfo = (
+ overrides: Partial<FetchWorkflowDraftResponse> = {},
+): FetchWorkflowDraftResponse => ({
id: 'version-1',
graph: {
nodes: [],
diff --git a/web/app/components/workflow/panel/version-history-panel/__tests__/version-history-item.spec.tsx b/web/app/components/workflow/panel/version-history-panel/__tests__/version-history-item.spec.tsx
index 9bcc932db30..3730d24c5a8 100644
--- a/web/app/components/workflow/panel/version-history-panel/__tests__/version-history-item.spec.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/__tests__/version-history-item.spec.tsx
@@ -1,4 +1,4 @@
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { renderEditor as render } from '@/app/components/workflow/editor-resource/__tests__/render'
@@ -10,7 +10,9 @@ vi.mock('@/app/components/workflow/store', () => ({
selector({ pipelineId: undefined }),
}))
-const createVersionHistory = (overrides: Partial<VersionHistory> = {}): VersionHistory => ({
+const createVersionHistory = (
+ overrides: Partial<FetchWorkflowDraftResponse> = {},
+): FetchWorkflowDraftResponse => ({
id: 'version-1',
graph: {
nodes: [],
diff --git a/web/app/components/workflow/panel/version-history-panel/delete-confirm-modal.tsx b/web/app/components/workflow/panel/version-history-panel/delete-confirm-modal.tsx
index 99c07fccd32..46dc9250a95 100644
--- a/web/app/components/workflow/panel/version-history-panel/delete-confirm-modal.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/delete-confirm-modal.tsx
@@ -1,5 +1,5 @@
import type { FC } from 'react'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -15,7 +15,7 @@ import { getWorkflowVersionName } from '@/app/components/workflow/utils/version'
type DeleteConfirmModalProps = {
isOpen: boolean
- versionInfo: VersionHistory
+ versionInfo: FetchWorkflowDraftResponse
onClose: () => void
onDelete: (id: string) => void
}
diff --git a/web/app/components/workflow/panel/version-history-panel/index.tsx b/web/app/components/workflow/panel/version-history-panel/index.tsx
index e8cc9ef3622..4ae8115605c 100644
--- a/web/app/components/workflow/panel/version-history-panel/index.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/index.tsx
@@ -1,6 +1,6 @@
'use client'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { Separator } from '@langgenius/dify-ui/separator'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
import copy from 'copy-to-clipboard'
@@ -63,7 +63,7 @@ export const VersionHistoryPanel = ({
WorkflowVersionFilterOptions.all,
)
const [isOnlyShowNamedVersions, setIsOnlyShowNamedVersions] = useState(false)
- const [operatedItem, setOperatedItem] = useState<VersionHistory>()
+ const [operatedItem, setOperatedItem] = useState<FetchWorkflowDraftResponse>()
const [restoreConfirmOpen, setRestoreConfirmOpen] = useState(false)
const [isRestorePlanUpgradeModalOpen, setIsRestorePlanUpgradeModalOpen] = useState(false)
const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false)
@@ -109,7 +109,7 @@ export const VersionHistoryPanel = ({
})
const handleVersionClick = useCallback(
- (item: VersionHistory) => {
+ (item: FetchWorkflowDraftResponse) => {
if (item.id !== currentVersion?.id) {
setCurrentVersion(item)
if (item.version === WorkflowVersion.Draft) handleLoadBackupDraft()
@@ -148,7 +148,7 @@ export const VersionHistoryPanel = ({
}, [])
const handleClickActionMenuItem = useCallback(
- (item: VersionHistory, operation: VersionHistoryContextMenuOptions) => {
+ (item: FetchWorkflowDraftResponse, operation: VersionHistoryContextMenuOptions) => {
if (operation === VersionHistoryContextMenuOptions.delete && item.environments?.length) {
toast.error(
t(($) => $['versionHistory.action.deleteDeployedVersionError'], {
@@ -209,7 +209,7 @@ export const VersionHistoryPanel = ({
}, [])
const emitRestoreIntent = useCallback(
- async (item: VersionHistory) => {
+ async (item: FetchWorkflowDraftResponse) => {
try {
const { collaborationManager } =
await import('../../collaboration/core/collaboration-manager')
@@ -230,7 +230,7 @@ export const VersionHistoryPanel = ({
)
const emitRestoreComplete = useCallback(
- async (item: VersionHistory, success: boolean, errorMessage?: string) => {
+ async (item: FetchWorkflowDraftResponse, success: boolean, errorMessage?: string) => {
try {
const { collaborationManager } =
await import('../../collaboration/core/collaboration-manager')
@@ -263,7 +263,7 @@ export const VersionHistoryPanel = ({
const { mutateAsync: restoreWorkflow } = useRestoreWorkflow(resource)
const handleRestore = useCallback(
- async (item: VersionHistory) => {
+ async (item: FetchWorkflowDraftResponse) => {
setShowWorkflowVersionHistoryPanel(false)
await emitRestoreIntent(item)
diff --git a/web/app/components/workflow/panel/version-history-panel/restore-confirm-modal.tsx b/web/app/components/workflow/panel/version-history-panel/restore-confirm-modal.tsx
index bf265b9a6e3..2c558a75333 100644
--- a/web/app/components/workflow/panel/version-history-panel/restore-confirm-modal.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/restore-confirm-modal.tsx
@@ -1,5 +1,5 @@
import type { FC } from 'react'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import {
AlertDialog,
AlertDialogCancelButton,
@@ -15,9 +15,9 @@ import { getWorkflowVersionName } from '@/app/components/workflow/utils/version'
type RestoreConfirmModalProps = {
isOpen: boolean
- versionInfo: VersionHistory
+ versionInfo: FetchWorkflowDraftResponse
onClose: () => void
- onRestore: (item: VersionHistory) => void
+ onRestore: (item: FetchWorkflowDraftResponse) => void
}
const RestoreConfirmModal: FC<RestoreConfirmModalProps> = ({
diff --git a/web/app/components/workflow/panel/version-history-panel/version-history-item.tsx b/web/app/components/workflow/panel/version-history-panel/version-history-item.tsx
index 265336aac8d..ae42f9b2250 100644
--- a/web/app/components/workflow/panel/version-history-panel/version-history-item.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/version-history-item.tsx
@@ -1,5 +1,5 @@
import type { VersionHistoryContextMenuOptions } from '../../types'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { cn } from '@langgenius/dify-ui/cn'
import dayjs from 'dayjs'
import * as React from 'react'
@@ -11,17 +11,20 @@ import { WorkflowVersion } from '../../types'
import ActionMenu from './action-menu'
type VersionHistoryItemProps = {
- item: VersionHistory
- currentVersion: VersionHistory | null
+ item: FetchWorkflowDraftResponse
+ currentVersion: FetchWorkflowDraftResponse | null
latestVersionId: string
- onClick: (item: VersionHistory) => void
+ onClick: (item: FetchWorkflowDraftResponse) => void
handleClickActionMenuItem: (operation: VersionHistoryContextMenuOptions) => void
canImportExportDSL: boolean
isLast: boolean
hideActionMenu?: boolean
}
-const formatVersion = (versionHistory: VersionHistory, latestVersionId: string): string => {
+const formatVersion = (
+ versionHistory: FetchWorkflowDraftResponse,
+ latestVersionId: string,
+): string => {
const { version, id } = versionHistory
if (version === WorkflowVersion.Draft) return WorkflowVersion.Draft
if (id === latestVersionId) return WorkflowVersion.Latest
diff --git a/web/app/components/workflow/simple-node/index.tsx b/web/app/components/workflow/simple-node/index.tsx
index 1f4fffb1073..e1b2c33da56 100644
--- a/web/app/components/workflow/simple-node/index.tsx
+++ b/web/app/components/workflow/simple-node/index.tsx
@@ -14,9 +14,7 @@ import { NodeTargetHandle } from '@/app/components/workflow/nodes/_base/componen
import { NodeRunningStatus } from '@/app/components/workflow/types'
import { useNodesReadOnly } from '../hooks/use-workflow'
-type SimpleNodeProps = NodeProps
-
-const SimpleNode: FC<SimpleNodeProps> = ({ id, data }) => {
+const SimpleNode: FC<NodeProps> = ({ id, data }) => {
const { nodesReadOnly } = useNodesReadOnly()
const showSelectedBorder = data.selected || data._isBundled || data._isEntering
diff --git a/web/app/components/workflow/simple-node/types.ts b/web/app/components/workflow/simple-node/types.ts
deleted file mode 100644
index 8768d692a88..00000000000
--- a/web/app/components/workflow/simple-node/types.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import type { CommonNodeType } from '@/app/components/workflow/types'
-
-export type SimpleNodeType = CommonNodeType
diff --git a/web/app/components/workflow/store/__tests__/datasets-detail-store.spec.ts b/web/app/components/workflow/store/__tests__/datasets-detail-store.spec.ts
index ad313f05f75..1b8dba2acff 100644
--- a/web/app/components/workflow/store/__tests__/datasets-detail-store.spec.ts
+++ b/web/app/components/workflow/store/__tests__/datasets-detail-store.spec.ts
@@ -1,8 +1,8 @@
-import type { DataSet } from '@/models/datasets'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import { createDatasetsDetailStore } from '../../datasets-detail-store/store'
-function makeDataset(id: string, name: string): DataSet {
- return { id, name } as DataSet
+function makeDataset(id: string, name: string): DatasetDetailWithPartialMembersResponse {
+ return { id, name } as DatasetDetailWithPartialMembersResponse
}
describe('DatasetsDetailStore', () => {
diff --git a/web/app/components/workflow/store/__tests__/version-slice.spec.ts b/web/app/components/workflow/store/__tests__/version-slice.spec.ts
index d85946354d8..d86adaa14bb 100644
--- a/web/app/components/workflow/store/__tests__/version-slice.spec.ts
+++ b/web/app/components/workflow/store/__tests__/version-slice.spec.ts
@@ -1,4 +1,4 @@
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import { createTestWorkflowStore } from '../../__tests__/workflow-test-env'
function createStore() {
@@ -42,7 +42,11 @@ describe('Version Slice', () => {
it('should update current version', () => {
const store = createStore()
- const version = { hash: 'abc', updated_at: 1000, version: '1.0' } as VersionHistory
+ const version = {
+ hash: 'abc',
+ updated_at: 1000,
+ version: '1.0',
+ } as FetchWorkflowDraftResponse
store.getState().setCurrentVersion(version)
expect(store.getState().currentVersion).toEqual(version)
})
diff --git a/web/app/components/workflow/store/workflow/comment-slice.ts b/web/app/components/workflow/store/workflow/comment-slice.ts
index 4595ba41dc9..0277aac651f 100644
--- a/web/app/components/workflow/store/workflow/comment-slice.ts
+++ b/web/app/components/workflow/store/workflow/comment-slice.ts
@@ -1,13 +1,13 @@
-import type { StateCreator } from 'zustand'
import type {
- UserProfile,
+ WorkflowCommentBasic,
WorkflowCommentDetail,
- WorkflowCommentList,
-} from '@/app/components/workflow/comment/types'
+} from '@dify/contracts/api/console/apps/types.gen'
+import type { StateCreator } from 'zustand'
+import type { UserProfile } from '@/app/components/workflow/comment/types'
export type CommentSliceShape = {
- comments: WorkflowCommentList[]
- setComments: (comments: WorkflowCommentList[]) => void
+ comments: WorkflowCommentBasic[]
+ setComments: (comments: WorkflowCommentBasic[]) => void
commentsLoading: boolean
setCommentsLoading: (loading: boolean) => void
showResolvedComments: boolean
diff --git a/web/app/components/workflow/store/workflow/history-slice.ts b/web/app/components/workflow/store/workflow/history-slice.ts
index 437ece2dc06..1dabc3e42fe 100644
--- a/web/app/components/workflow/store/workflow/history-slice.ts
+++ b/web/app/components/workflow/store/workflow/history-slice.ts
@@ -2,7 +2,7 @@ import type { StateCreator } from 'zustand'
import type { WorkflowHistoryEventT } from '../../hooks/use-workflow-history'
import type { Edge, Node } from '../../types'
import type { HistoryWorkflowData } from '@/app/components/workflow/types'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
import isDeepEqual from 'fast-deep-equal'
export type WorkflowHistoryEventMeta = {
@@ -43,8 +43,8 @@ export type HistorySliceShape = {
setHistoryWorkflowData: (historyWorkflowData?: HistoryWorkflowData) => void
showRunHistory: boolean
setShowRunHistory: (showRunHistory: boolean) => void
- versionHistory: VersionHistory[]
- setVersionHistory: (versionHistory: VersionHistory[]) => void
+ versionHistory: FetchWorkflowDraftResponse[]
+ setVersionHistory: (versionHistory: FetchWorkflowDraftResponse[]) => void
}
export const createHistorySlice: StateCreator<HistorySliceShape> = (set) => ({
diff --git a/web/app/components/workflow/store/workflow/version-slice.ts b/web/app/components/workflow/store/workflow/version-slice.ts
index d121156ce6f..b5c7a499ecb 100644
--- a/web/app/components/workflow/store/workflow/version-slice.ts
+++ b/web/app/components/workflow/store/workflow/version-slice.ts
@@ -1,13 +1,13 @@
import type { StateCreator } from 'zustand'
-import type { VersionHistory } from '@/types/workflow'
+import type { FetchWorkflowDraftResponse } from '@/types/workflow'
export type VersionSliceShape = {
draftUpdatedAt: number
setDraftUpdatedAt: (draftUpdatedAt: number) => void
publishedAt: number
setPublishedAt: (publishedAt: number) => void
- currentVersion: VersionHistory | null
- setCurrentVersion: (currentVersion: VersionHistory) => void
+ currentVersion: FetchWorkflowDraftResponse | null
+ setCurrentVersion: (currentVersion: FetchWorkflowDraftResponse) => void
isRestoring: boolean
setIsRestoring: (isRestoring: boolean) => void
}
diff --git a/web/app/components/workflow/store/workflow/workflow-slice.ts b/web/app/components/workflow/store/workflow/workflow-slice.ts
index 074cebe02cb..6f781065213 100644
--- a/web/app/components/workflow/store/workflow/workflow-slice.ts
+++ b/web/app/components/workflow/store/workflow/workflow-slice.ts
@@ -1,3 +1,4 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { StateCreator } from 'zustand'
import type {
Edge,
@@ -5,7 +6,6 @@ import type {
TriggerNodeType,
WorkflowRunningData,
} from '@/app/components/workflow/types'
-import type { FileUploadConfigResponse } from '@/models/common'
type PreviewRunningData = WorkflowRunningData & {
resultTabActive?: boolean
@@ -68,8 +68,8 @@ export type WorkflowSliceShape = {
setControlPromptEditorRerenderKey: (controlPromptEditorRerenderKey: number) => void
showImportDSLModal: boolean
setShowImportDSLModal: (showImportDSLModal: boolean) => void
- fileUploadConfig?: FileUploadConfigResponse
- setFileUploadConfig: (fileUploadConfig: FileUploadConfigResponse) => void
+ fileUploadConfig?: UploadConfig
+ setFileUploadConfig: (fileUploadConfig: UploadConfig) => void
}
export const createWorkflowSlice: StateCreator<WorkflowSliceShape> = (set) => ({
diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts
index 5d5782ebe6d..2fec245f97d 100644
--- a/web/app/components/workflow/types.ts
+++ b/web/app/components/workflow/types.ts
@@ -1,4 +1,5 @@
import type { RagPipelineDatasourceProviderResponse } from '@dify/contracts/api/console/rag/types.gen'
+import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { MarketplacePlugin } from '@dify/contracts/marketplace'
import type { Edge as ReactFlowEdge, Node as ReactFlowNode, Viewport, XYPosition } from 'reactflow'
import type { PluginMeta } from '@/app/components/plugins/types'
@@ -16,7 +17,6 @@ import type { WorkflowRetryConfig } from '@/app/components/workflow/nodes/_base/
import type { VarKindType } from '@/app/components/workflow/nodes/_base/types'
import type { StructuredOutput } from '@/app/components/workflow/nodes/llm/types'
import type { ChatVarType } from '@/app/components/workflow/panel/chat-variable-panel/type'
-import type { SchemaTypeDefinition } from '@/service/use-common'
import type { Resolution, TransferMethod } from '@/types/app'
import type {
FileResponse,
@@ -395,7 +395,7 @@ export type NodeDefault<T = {}> = {
allPluginInfoList: WorkflowPluginCatalogs,
ragVariables?: Var[],
utils?: {
- schemaTypeDefinitions?: SchemaTypeDefinition[]
+ schemaTypeDefinitions?: SchemaDefinitionItemResponse[]
},
) => Var[]
}
diff --git a/web/app/components/workflow/variable-inspect/__tests__/value-content-sections.spec.tsx b/web/app/components/workflow/variable-inspect/__tests__/value-content-sections.spec.tsx
index 7e8e6fd48a4..aa032fe911b 100644
--- a/web/app/components/workflow/variable-inspect/__tests__/value-content-sections.spec.tsx
+++ b/web/app/components/workflow/variable-inspect/__tests__/value-content-sections.spec.tsx
@@ -1,4 +1,4 @@
-import type { FileUploadConfigResponse } from '@/models/common'
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { VarInInspect } from '@/types/workflow'
import { fireEvent, render, screen } from '@testing-library/react'
import { VarType } from '@/app/components/workflow/types'
@@ -50,7 +50,7 @@ vi.mock('@/next/navigation', () => ({
}))
describe('value-content sections', () => {
- const createFileUploadConfig = (): FileUploadConfigResponse =>
+ const createFileUploadConfig = (): UploadConfig =>
createFileUploadConfigFixture({
batch_count_limit: 10,
image_file_batch_limit: 10,
diff --git a/web/app/components/workflow/variable-inspect/value-content-sections.tsx b/web/app/components/workflow/variable-inspect/value-content-sections.tsx
index 73d280f8f09..a24813f4ecf 100644
--- a/web/app/components/workflow/variable-inspect/value-content-sections.tsx
+++ b/web/app/components/workflow/variable-inspect/value-content-sections.tsx
@@ -1,5 +1,5 @@
+import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { FileEntity } from '@/app/components/base/file-uploader/types'
-import type { FileUploadConfigResponse } from '@/models/common'
import type { VarInInspect } from '@/types/workflow'
import { cn } from '@langgenius/dify-ui/cn'
import { Textarea } from '@langgenius/dify-ui/textarea'
@@ -129,7 +129,7 @@ export const JsonEditorSection = ({
type FileEditorSectionProps = {
currentVar: VarInInspect
fileValue: FileEntity[]
- fileUploadConfig?: FileUploadConfigResponse
+ fileUploadConfig?: UploadConfig
textEditorDisabled: boolean
onChange: (files: FileEntity[]) => void
}
diff --git a/web/app/components/workflow/workflow-generator/__tests__/generation-plan.spec.tsx b/web/app/components/workflow/workflow-generator/__tests__/generation-plan.spec.tsx
index 49fb210cd4b..db342e0a9fa 100644
--- a/web/app/components/workflow/workflow-generator/__tests__/generation-plan.spec.tsx
+++ b/web/app/components/workflow/workflow-generator/__tests__/generation-plan.spec.tsx
@@ -1,4 +1,4 @@
-import type { WorkflowGenPlan } from '@/service/workflow-generator'
+import type { WorkflowGeneratePlanEventResponse } from '@dify/contracts/api/console/workflow-generate/types.gen'
import { render, screen } from '@testing-library/react'
import GenerationPlan from '../generation-plan'
@@ -15,7 +15,7 @@ describe('GenerationPlan', () => {
// Once the plan streams in, the outline (node purposes + identity) renders and
// the footer flips to "Building…" while the builder fills in the graph.
it('renders the plan outline and the building state once the plan lands', () => {
- const plan: WorkflowGenPlan = {
+ const plan: WorkflowGeneratePlanEventResponse = {
app_name: 'URL Summarizer',
description: 'Summarize any URL',
icon: '📰',
@@ -37,11 +37,11 @@ describe('GenerationPlan', () => {
})
it('renders correctly when plan has no icon, app_name, or title', () => {
- const plan: WorkflowGenPlan = {
+ const plan: WorkflowGeneratePlanEventResponse = {
mode: 'workflow',
nodes: [{ label: 'Start', node_type: 'start' }],
start_inputs: [],
- } as unknown as WorkflowGenPlan
+ } as unknown as WorkflowGeneratePlanEventResponse
render(<GenerationPlan plan={plan} />)
expect(screen.getByText('Start')).toBeInTheDocument()
@@ -49,13 +49,13 @@ describe('GenerationPlan', () => {
})
it('falls back to plan.title when plan.app_name is empty', () => {
- const plan: WorkflowGenPlan = {
+ const plan: WorkflowGeneratePlanEventResponse = {
app_name: '',
title: 'Fallback Title',
mode: 'workflow',
nodes: [],
start_inputs: [],
- } as unknown as WorkflowGenPlan
+ } as unknown as WorkflowGeneratePlanEventResponse
render(<GenerationPlan plan={plan} />)
expect(screen.getByText('Fallback Title')).toBeInTheDocument()
diff --git a/web/app/components/workflow/workflow-generator/__tests__/use-gen-graph.spec.ts b/web/app/components/workflow/workflow-generator/__tests__/use-gen-graph.spec.ts
index 3114a42b8e6..5e3341148ad 100644
--- a/web/app/components/workflow/workflow-generator/__tests__/use-gen-graph.spec.ts
+++ b/web/app/components/workflow/workflow-generator/__tests__/use-gen-graph.spec.ts
@@ -1,8 +1,8 @@
-import type { GenerateWorkflowResponse } from '../types'
+import type { WorkflowGenerateResponse } from '@dify/contracts/api/console/workflow-generate/types.gen'
import { act, renderHook } from '@testing-library/react'
import useGenGraph from '../use-gen-graph'
-const makeVersion = (marker: string): GenerateWorkflowResponse => ({
+const makeVersion = (marker: string): WorkflowGenerateResponse => ({
graph: {
nodes: [{ id: marker } as never],
edges: [],
diff --git a/web/app/components/workflow/workflow-generator/generation-plan.tsx b/web/app/components/workflow/workflow-generator/generation-plan.tsx
index fcadd5cca96..1b82b3ef005 100644
--- a/web/app/components/workflow/workflow-generator/generation-plan.tsx
+++ b/web/app/components/workflow/workflow-generator/generation-plan.tsx
@@ -1,6 +1,6 @@
'use client'
+import type { WorkflowGeneratePlanEventResponse } from '@dify/contracts/api/console/workflow-generate/types.gen'
import type { BlockEnum } from '@/app/components/workflow/types'
-import type { WorkflowGenPlan } from '@/service/workflow-generator'
import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { SkeletonContainer, SkeletonRectangle, SkeletonRow } from '@/app/components/base/skeleton'
@@ -12,7 +12,7 @@ type Props = Readonly<{
* is still running. Drives the two honest phases of the generation:
* "Planning…" (skeleton outline) → plan outline + "Building…".
*/
- plan: WorkflowGenPlan | null
+ plan: WorkflowGeneratePlanEventResponse | null
}>
// Stable keys for the planning skeleton's placeholder rows — avoids array-index
diff --git a/web/app/components/workflow/workflow-generator/index.tsx b/web/app/components/workflow/workflow-generator/index.tsx
index 07f62ab439c..f87f43ef3f0 100644
--- a/web/app/components/workflow/workflow-generator/index.tsx
+++ b/web/app/components/workflow/workflow-generator/index.tsx
@@ -1,14 +1,14 @@
'use client'
-import type { WorkflowGenerateErrorResponse } from '@dify/contracts/api/console/workflow-generate/types.gen'
+import type {
+ WorkflowGenerateResponse as StreamResult,
+ WorkflowGenerateErrorResponse,
+ WorkflowGeneratePayload,
+ WorkflowGeneratePlanEventResponse,
+} from '@dify/contracts/api/console/workflow-generate/types.gen'
import type { Hotkey } from '@tanstack/react-hotkeys'
import type { SelectorParam, TFunction } from 'i18next'
import type { GeneratedGraph } from './types'
import type { FormValue } from '@/app/components/header/account-setting/model-provider-page/declarations'
-import type {
- GenerateWorkflowBody,
- GenerateWorkflowResponse as StreamResult,
- WorkflowGenPlan,
-} from '@/service/workflow-generator'
import type { CompletionParams, ModelModeType } from '@/types/app'
import {
AlertDialog,
@@ -66,7 +66,7 @@ const WORKFLOW_GENERATOR_SUBMIT_HOTKEY = 'Mod+Enter' satisfies Hotkey
// A single structured generation error. Mirrors the backend ``errors[]`` entry
// (stable ``code`` + human ``detail`` + optional ``node_id``) so the error panel
// can localise the message and point at the offending node.
-type GenError = WorkflowGenerateErrorResponse
+
type WorkflowGeneratorErrorCode = WorkflowGenerateErrorResponse['code']
const workflowGeneratorErrorSelectors: Record<
@@ -90,7 +90,10 @@ const workflowGeneratorErrorSelectors: Record<
UNRESOLVED_REFERENCE: ($) => $['workflowGenerator.errors.UNRESOLVED_REFERENCE'],
}
-function getWorkflowGeneratorErrorMessage(error: GenError, t: TFunction<['workflowGenerator']>) {
+function getWorkflowGeneratorErrorMessage(
+ error: WorkflowGenerateErrorResponse,
+ t: TFunction<['workflowGenerator']>,
+) {
return t(workflowGeneratorErrorSelectors[error.code])
}
@@ -216,10 +219,10 @@ function WorkflowGeneratorModal() {
const instructionRef = useRef<HTMLTextAreaElement>(null)
const [instruction, setInstruction] = useState(initialInstruction || lastInstruction || '')
// Planner result, streamed ahead of the graph (null until it lands).
- const [plan, setPlan] = useState<WorkflowGenPlan | null>(null)
+ const [plan, setPlan] = useState<WorkflowGeneratePlanEventResponse | null>(null)
// Structured generation errors (validation / model). Drives the actionable
// error panel; null when the last attempt succeeded or hasn't run.
- const [genError, setGenError] = useState<GenError[] | null>(null)
+ const [genError, setGenError] = useState<WorkflowGenerateErrorResponse[] | null>(null)
// Refine base graph captured at Generate time, diffed against the result so
// the user can see what "apply" changes before overwriting their draft.
const [refineBaseGraph, setRefineBaseGraph] = useState<GeneratedGraph | null>(null)
@@ -380,14 +383,14 @@ function WorkflowGeneratorModal() {
}
setRefineBaseGraph(currentGraph ?? null)
- const body: GenerateWorkflowBody = {
+ const body: WorkflowGeneratePayload = {
// Auto-mode sends 'auto' so the planner picks Workflow vs Chatflow; the
// resolved concrete mode comes back on the result and drives apply.
mode: autoMode ? 'auto' : mode,
instruction,
model_config: { ...model, mode: model.mode || 'chat' },
...(currentGraph
- ? { current_graph: currentGraph as unknown as GenerateWorkflowBody['current_graph'] }
+ ? { current_graph: currentGraph as unknown as WorkflowGeneratePayload['current_graph'] }
: {}),
}
diff --git a/web/app/components/workflow/workflow-generator/types.ts b/web/app/components/workflow/workflow-generator/types.ts
index 5c6e300b493..d607dc6a31f 100644
--- a/web/app/components/workflow/workflow-generator/types.ts
+++ b/web/app/components/workflow/workflow-generator/types.ts
@@ -1,7 +1,4 @@
-import type {
- WorkflowGeneratePayload,
- WorkflowGenerateResponse,
-} from '@dify/contracts/api/console/workflow-generate/types.gen'
+import type { WorkflowGeneratePayload } from '@dify/contracts/api/console/workflow-generate/types.gen'
import type { Viewport } from 'reactflow'
import type { Edge, Node } from '@/app/components/workflow/types'
@@ -20,4 +17,3 @@ export type GeneratedGraph = {
edges: Edge[]
viewport: Viewport
}
-export type GenerateWorkflowResponse = WorkflowGenerateResponse
diff --git a/web/app/components/workflow/workflow-generator/use-gen-graph.ts b/web/app/components/workflow/workflow-generator/use-gen-graph.ts
index b721fa5b867..4c83a770e0d 100644
--- a/web/app/components/workflow/workflow-generator/use-gen-graph.ts
+++ b/web/app/components/workflow/workflow-generator/use-gen-graph.ts
@@ -1,4 +1,4 @@
-import type { GenerateWorkflowResponse } from './types'
+import type { WorkflowGenerateResponse } from '@dify/contracts/api/console/workflow-generate/types.gen'
import { useSessionStorageState } from 'ahooks'
import { useCallback, useEffect, useRef } from 'react'
@@ -22,7 +22,7 @@ type Params = {
* version selector) matches the existing Prompt Generator.
*/
const useGenGraph = ({ storageKey }: Params) => {
- const [versions, setVersions] = useSessionStorageState<GenerateWorkflowResponse[]>(
+ const [versions, setVersions] = useSessionStorageState<WorkflowGenerateResponse[]>(
`${KEY_PREFIX}${storageKey}-versions`,
{ defaultValue: [] },
)
@@ -47,7 +47,7 @@ const useGenGraph = ({ storageKey }: Params) => {
}, [versions])
const addVersion = useCallback(
- (version: GenerateWorkflowResponse) => {
+ (version: WorkflowGenerateResponse) => {
const nextCount = Math.min(versionCountRef.current + 1, MAX_VERSIONS)
versionCountRef.current = nextCount
// Functional update so batched adds append instead of clobbering each
diff --git a/web/context/dataset-detail.ts b/web/context/dataset-detail.ts
index ae38dfdd49a..4df0ecb0489 100644
--- a/web/context/dataset-detail.ts
+++ b/web/context/dataset-detail.ts
@@ -1,14 +1,14 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { QueryObserverResult, RefetchOptions } from '@tanstack/react-query'
import type { IndexingType } from '@/app/components/datasets/create/step-two'
-import type { DataSet } from '@/models/datasets'
import { createContext, useContext, useContextSelector } from 'use-context-selector'
type DatasetDetailContextValue = {
indexingTechnique?: IndexingType
- dataset?: DataSet
+ dataset?: DatasetDetailWithPartialMembersResponse
mutateDatasetRes?: (
options?: RefetchOptions | undefined,
- ) => Promise<QueryObserverResult<DataSet, Error>>
+ ) => Promise<QueryObserverResult<DatasetDetailWithPartialMembersResponse, Error>>
}
const DatasetDetailContext = createContext<DatasetDetailContextValue>({})
diff --git a/web/context/debug-configuration.ts b/web/context/debug-configuration.ts
index d6632a3d7d9..3a91ca53251 100644
--- a/web/context/debug-configuration.ts
+++ b/web/context/debug-configuration.ts
@@ -1,9 +1,9 @@
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { RefObject } from 'react'
import type { ConfigurationAppMode } from '@/app/components/app/configuration/hooks/configuration-lifecycle/types'
import type { FormValue } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { Collection } from '@/app/components/tools/types'
import type { ExternalDataTool } from '@/models/common'
-import type { DataSet } from '@/models/datasets'
import type {
AnnotationReplyConfig,
BlockStatus,
@@ -99,8 +99,8 @@ type IDebugConfiguration = {
// model_config
modelConfig: ModelConfig
setModelConfig: (modelConfig: ModelConfig) => void
- dataSets: DataSet[]
- setDataSets: (dataSet: DataSet[]) => void
+ dataSets: DatasetDetailWithPartialMembersResponse[]
+ setDataSets: (dataSet: DatasetDetailWithPartialMembersResponse[]) => void
showSelectDataSet: () => void
// dataset config
datasetConfigs: DatasetConfigs
diff --git a/web/features/agent-v2/agent-composer/form-state.ts b/web/features/agent-v2/agent-composer/form-state.ts
index ad93897b302..65896ed938f 100644
--- a/web/features/agent-v2/agent-composer/form-state.ts
+++ b/web/features/agent-v2/agent-composer/form-state.ts
@@ -4,6 +4,7 @@ import type {
AgentSoulModelConfig,
ToolProviderType,
} from '@dify/contracts/api/console/agent/types.gen'
+import type { DatasetDetailWithPartialMembersResponse } from '@dify/contracts/api/console/datasets/types.gen'
import type { FileTreeIconType } from '@langgenius/dify-ui/file-tree'
import type { DefaultModel } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
@@ -14,7 +15,6 @@ import type {
SingleRetrievalConfig,
} from '@/app/components/workflow/nodes/knowledge-retrieval/types'
import type { ModelConfig } from '@/app/components/workflow/types'
-import type { DataSet } from '@/models/datasets'
import type { RETRIEVE_TYPE } from '@/types/app'
import type { I18nKeysWithPrefix } from '@/types/i18n'
@@ -67,7 +67,7 @@ export type AgentKnowledgeRetrievalItem = {
queryMode?: 'agent' | 'custom'
customQuery?: string
datasetRefs?: AgentKnowledgeDatasetConfig[]
- selectedDatasets?: DataSet[]
+ selectedDatasets?: DatasetDetailWithPartialMembersResponse[]
retrievalMode?: RETRIEVE_TYPE
multipleRetrievalConfig?: MultipleRetrievalConfig
singleRetrievalConfig?: SingleRetrievalConfig
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx
index 5bb6077e030..6d16d5e6e5d 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/dialog.tsx
@@ -1,6 +1,10 @@
'use client'
import type { AgentKnowledgeDatasetConfig } from '@dify/contracts/api/console/agent/types.gen'
+import type {
+ DatasetDetailWithPartialMembersResponse,
+ DatasetDocMetadataResponse,
+} from '@dify/contracts/api/console/datasets/types.gen'
import type { ReactNode } from 'react'
import type {
MetadataFilteringCondition,
@@ -10,7 +14,6 @@ import type {
} from '@/app/components/workflow/nodes/knowledge-retrieval/types'
import type { ModelConfig } from '@/app/components/workflow/types'
import type { AgentKnowledgeRetrievalItem } from '@/features/agent-v2/agent-composer/form-state'
-import type { DataSet, MetadataInDoc } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
import { Dialog, DialogClose, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'
import { IconButton } from '@langgenius/dify-ui/icon-button'
@@ -46,7 +49,8 @@ import {
validateKnowledgeRetrievals,
} from '@/features/agent-v2/agent-composer/knowledge-validation'
import { agentComposerKnowledgeRetrievalsAtom } from '@/features/agent-v2/agent-composer/store-modules/knowledge'
-import { ChunkingMode, DatasetPermission, DataSourceType } from '@/models/datasets'
+import { ChunkingMode, DataSourceType } from '@/models/datasets'
+import { PermissionLevel } from '@/models/permission'
import { RETRIEVE_METHOD, RETRIEVE_TYPE } from '@/types/app'
type KnowledgeRetrievalQueryMode = 'agent' | 'custom'
@@ -64,7 +68,7 @@ type KnowledgeRetrievalDialogState = {
name: string
queryMode: KnowledgeRetrievalQueryMode
retrievalMode: (typeof RETRIEVE_TYPE)[keyof typeof RETRIEVE_TYPE]
- selectedDatasets: DataSet[]
+ selectedDatasets: DatasetDetailWithPartialMembersResponse[]
singleRetrievalConfig?: SingleRetrievalConfig
}
@@ -116,7 +120,10 @@ const createDefaultMetadataFilteringConditions = (): MetadataFilteringConditions
conditions: [],
})
-const createDatasetFromRef = (dataset: AgentKnowledgeDatasetConfig, index: number): DataSet => {
+const createDatasetFromRef = (
+ dataset: AgentKnowledgeDatasetConfig,
+ index: number,
+): DatasetDetailWithPartialMembersResponse => {
const id = dataset.id ?? dataset.name ?? `dataset-${index}`
const name = dataset.name ?? id
@@ -130,7 +137,7 @@ const createDatasetFromRef = (dataset: AgentKnowledgeDatasetConfig, index: numbe
icon_url: '',
},
description: dataset.description ?? '',
- permission: DatasetPermission.allTeamMembers,
+ permission: PermissionLevel.allTeamMembers,
data_source_type: DataSourceType.FILE,
indexing_technique: IndexingType.QUALIFIED,
created_by: '',
@@ -213,7 +220,7 @@ const createMetadataCondition = ({
id,
name,
type,
-}: MetadataInDoc): MetadataFilteringCondition => ({
+}: DatasetDocMetadataResponse): MetadataFilteringCondition => ({
id: globalThis.crypto?.randomUUID?.() ?? `${Date.now()}`,
metadata_id: id,
name,
@@ -404,7 +411,9 @@ function AgentKnowledgeRetrievalDialogContent({
return nextState
}
- const handleSelectedDatasetsChange = (nextDatasets: DataSet[]) => {
+ const handleSelectedDatasetsChange = (
+ nextDatasets: DatasetDetailWithPartialMembersResponse[],
+ ) => {
const nextMultipleRetrievalConfig =
retrievalMode === RETRIEVE_TYPE.multiWay && nextDatasets.length > 0
? resolveMultipleRetrievalConfig(multipleRetrievalConfig, nextDatasets)
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx
index 765a804ce26..5306e0cc513 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/detail-dialog.tsx
@@ -22,8 +22,6 @@ import { useTranslation } from 'react-i18next'
import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'
import { AgentFileTree } from '../files/tree'
-type AgentSkillFileNode = AgentFileNode
-
type AgentSkillDetailSection = {
id: string
title: string
@@ -42,8 +40,8 @@ export type AgentSkillDetail = {
fileListTreeClassName?: string
fileListTreeListClassName?: string
fileListTitle?: string
- files: AgentSkillFileNode[]
- folderOpenState?: (context: { file: AgentSkillFileNode; depth: number }) => boolean
+ files: AgentFileNode[]
+ folderOpenState?: (context: { file: AgentFileNode; depth: number }) => boolean
filePreview?: {
binary?: boolean
content?: string
@@ -57,11 +55,11 @@ export type AgentSkillDetail = {
isImage?: boolean
isLoading?: boolean
}
- onFolderOpenChange?: (context: { file: AgentSkillFileNode; depth: number; open: boolean }) => void
- onFolderEnter?: (context: { file: AgentSkillFileNode; depth: number }) => void
+ onFolderOpenChange?: (context: { file: AgentFileNode; depth: number; open: boolean }) => void
+ onFolderEnter?: (context: { file: AgentFileNode; depth: number }) => void
onDownloadFile?: (action: AgentSkillDetailDownloadAction) => void
- onSelectFile?: (file: AgentSkillFileNode) => void
- renderFolderSuffix?: (context: { file: AgentSkillFileNode; depth: number }) => ReactNode
+ onSelectFile?: (file: AgentFileNode) => void
+ renderFolderSuffix?: (context: { file: AgentFileNode; depth: number }) => ReactNode
selectedFileId?: string
sections: AgentSkillDetailSection[]
}
@@ -87,11 +85,11 @@ function AgentSkillFileList({
fileListTreeClassName?: string
fileListTreeListClassName?: string
fileListTitle?: string
- files: AgentSkillFileNode[]
+ files: AgentFileNode[]
folderOpenState?: AgentSkillDetail['folderOpenState']
onFolderOpenChange?: AgentSkillDetail['onFolderOpenChange']
onFolderEnter?: AgentSkillDetail['onFolderEnter']
- onSelectFile?: (file: AgentSkillFileNode) => void
+ onSelectFile?: (file: AgentFileNode) => void
renderFolderSuffix?: AgentSkillDetail['renderFolderSuffix']
selectedFileId?: string
}) {
diff --git a/web/models/access-control.ts b/web/models/access-control.ts
index 64b910f9f25..beac2e0bfe1 100644
--- a/web/models/access-control.ts
+++ b/web/models/access-control.ts
@@ -164,31 +164,17 @@ export type ResourceUserAccessSetting = {
access_policies: Omit<AccessPolicy, 'created_at' | 'updated_at'>[]
}
-type ResourceUserAccessSettingsResponse = {
+export type ResourceUserAccessSettingsResponse = {
data: ResourceUserAccessSetting[]
pagination: Pagination
}
-export type GetAppUserAccessSettingsResponse = ResourceUserAccessSettingsResponse
-
-export type GetDatasetUserAccessSettingsResponse = ResourceUserAccessSettingsResponse
-
-type UpdateResourceUserAccessSettingsRequest = {
+export type UpdateResourceUserAccessSettingsRequest = {
accountId: string
accessPolicyIds: string[]
}
-export type UpdateAppUserAccessSettingsRequest = UpdateResourceUserAccessSettingsRequest
-
-export type UpdateDatasetUserAccessSettingsRequest = UpdateResourceUserAccessSettingsRequest
-
-type RemoveResourceAccessPolicyMemberBindingsRequest = {
+export type RemoveResourceAccessPolicyMemberBindingsRequest = {
accessPolicyId: string
accountIds: string[]
}
-
-export type RemoveAppAccessPolicyMemberBindingsRequest =
- RemoveResourceAccessPolicyMemberBindingsRequest
-
-export type RemoveDatasetAccessPolicyMemberBindingsRequest =
- RemoveResourceAccessPolicyMemberBindingsRequest
diff --git a/web/models/common.ts b/web/models/common.ts
index f79aa12db55..17fc7b17c7f 100644
--- a/web/models/common.ts
+++ b/web/models/common.ts
@@ -1,14 +1,10 @@
import type { AppConfigJsonValue } from '@dify/contracts/api/console/apps/types.gen'
-import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
-import type { AccountWithRoleResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { I18nText } from '@/i18n/language'
export type CommonResponse = {
result: 'success' | 'fail'
}
-export type Member = AccountWithRoleResponse
-
export type DataSourceNotionPage = {
page_icon: null | {
type: string | null
@@ -46,8 +42,6 @@ export const DataSourceProvider = {
} as const
export type DataSourceProvider = (typeof DataSourceProvider)[keyof typeof DataSourceProvider]
-export type FileUploadConfigResponse = UploadConfig
-
export type CodeBasedExtensionForm = {
type: string
label: I18nText
diff --git a/web/models/datasets.ts b/web/models/datasets.ts
index 6b9a6699b8f..dafc27a4927 100644
--- a/web/models/datasets.ts
+++ b/web/models/datasets.ts
@@ -1,36 +1,8 @@
-import type {
- ChildChunkListResponse,
- ChildChunkResponse,
- ConsoleSegmentListResponse,
- DocumentDetailResponse as ContractDocumentDetailResponse,
- DocumentResponse as ContractDocumentResponse,
- IndexingEstimateResponse as ContractIndexingEstimateResponse,
- ProcessRuleResponse as ContractProcessRuleResponse,
- RelatedAppResponse as ContractRelatedAppResponse,
- DatasetAndDocumentResponse,
- DatasetDetailWithPartialMembersResponse,
- DatasetDocMetadataResponse,
- DatasetListResponse,
- DatasetQueryContentResponse,
- DatasetQueryDetailResponse,
- DocumentStatusResponse,
- DocumentWithSegmentsResponse,
- ExternalHitTestingRecordResponse,
- ExternalHitTestingResponse,
- ExternalKnowledgeApiResponse,
- HitTestingChildChunk as GeneratedHitTestingChildChunk,
- HitTestingResponse as GeneratedHitTestingResponse,
- HitTestingRecord as HitTestingRecordResponse,
- NotionInfo as NotionInfoPayload,
- PreProcessingRule as PreProcessingRulePayload,
- RelatedAppListResponse,
- SegmentResponse,
-} from '@dify/contracts/api/console/datasets/types.gen'
+import type { NotionInfo, PreProcessingRule } from '@dify/contracts/api/console/datasets/types.gen'
import type { DataSourceNotionPage, DataSourceProvider } from './common'
import type { IndexingType } from '@/app/components/datasets/create/step-two'
import type { AppIconType, RetrievalConfig, TransferMethod } from '@/types/app'
import type { I18nKeysByPrefix } from '@/types/i18n'
-import { PermissionLevel } from './permission'
export const DataSourceType = {
FILE: 'upload_file',
@@ -40,11 +12,6 @@ export const DataSourceType = {
export type DataSourceType = (typeof DataSourceType)[keyof typeof DataSourceType]
-// Re-export PermissionLevel as DatasetPermission for backward compatibility
-export const DatasetPermission = PermissionLevel
-
-export type DatasetPermission = PermissionLevel
-
export const ChunkingMode = {
text: 'text_model', // General text
qa: 'qa_model', // General QA
@@ -54,8 +21,6 @@ export const ChunkingMode = {
export type ChunkingMode = (typeof ChunkingMode)[keyof typeof ChunkingMode]
-export type MetadataInDoc = DatasetDocMetadataResponse
-
export type IconInfo = {
icon: string
icon_background?: string
@@ -70,10 +35,6 @@ export type SummaryIndexSetting = {
summary_prompt?: string
}
-export type DataSet = DatasetDetailWithPartialMembersResponse
-
-export type ExternalAPIItem = ExternalKnowledgeApiResponse
-
export type CustomFile = File & {
id?: string
extension?: string
@@ -135,17 +96,11 @@ export type FetchDatasetsParams = {
}
}
-export type DataSetListResponse = DatasetListResponse
-
export type QA = {
question: string
answer: string
}
-export type FileIndexingEstimateResponse = ContractIndexingEstimateResponse
-
-export type IndexingStatusResponse = DocumentStatusResponse
-
export const ProcessMode = {
general: 'custom',
parentChild: 'hierarchical',
@@ -155,8 +110,6 @@ export type ProcessMode = (typeof ProcessMode)[keyof typeof ProcessMode]
export type ParentMode = 'full-doc' | 'paragraph'
-export type ProcessRuleResponse = ContractProcessRuleResponse
-
export type Rules = {
pre_processing_rules: PreProcessingRule[]
segmentation: Segmentation
@@ -164,8 +117,6 @@ export type Rules = {
subchunk_segmentation?: Segmentation
}
-export type PreProcessingRule = PreProcessingRulePayload
-
type Segmentation = {
separator: string
max_tokens: number
@@ -244,11 +195,6 @@ export type UploadFileIdInfo = {
upload_file_id: string
}
-export type InitialDocumentDetail = ContractDocumentResponse
-
-// A document in the dataset document list.
-export type SimpleDocumentDetail = DocumentWithSegmentsResponse
-
type DocumentReq = {
original_document_id?: string
indexing_technique?: IndexingType
@@ -282,19 +228,12 @@ type DataSource = {
}
}
-export type NotionInfo = NotionInfoPayload
-
export type ProcessRule = {
mode: ProcessMode
rules: Rules
summary_index_setting?: SummaryIndexSetting
}
-export type createDocumentResponse = DatasetAndDocumentResponse
-
-// A dataset document as the document detail query returns it.
-export type FullDocumentDetail = ContractDocumentDetailResponse
-
type CustomizableDocType =
| 'book'
| 'web_page'
@@ -315,18 +254,6 @@ export type Attachment = {
source_url: string
}
-export type SegmentDetailModel = SegmentResponse
-
-export type SegmentsResponse = ConsoleSegmentListResponse
-
-export type Query = DatasetQueryContentResponse
-
-export type HitTestingRecord = DatasetQueryDetailResponse
-
-export type RelatedApp = ContractRelatedAppResponse
-
-export type RelatedAppResponse = RelatedAppListResponse
-
export type SegmentUpdater = {
content: string
answer?: string
@@ -378,10 +305,6 @@ export const DEFAULT_WEIGHTED_SCORE = {
},
}
-export type ChildChunkDetail = ChildChunkResponse
-
-export type ChildSegmentsResponse = ChildChunkListResponse
-
// Used in api url
export const DocumentActionType = {
enable: 'enable',
@@ -425,9 +348,3 @@ export type ExternalKnowledgeBaseHitTestingRequest = {
score_threshold_enabled: boolean
}
}
-
-export type HitTestingChildChunk = GeneratedHitTestingChildChunk
-export type HitTesting = HitTestingRecordResponse
-export type HitTestingResponse = GeneratedHitTestingResponse
-export type ExternalKnowledgeBaseHitTesting = ExternalHitTestingRecordResponse
-export type ExternalKnowledgeBaseHitTestingResponse = ExternalHitTestingResponse
diff --git a/web/models/debug.ts b/web/models/debug.ts
index fca9c91e2ca..059f59991b6 100644
--- a/web/models/debug.ts
+++ b/web/models/debug.ts
@@ -84,7 +84,9 @@ export type SuggestedQuestionsAfterAnswerConfig = MoreLikeThisConfig & {
prompt?: string
}
-export type SpeechToTextConfig = MoreLikeThisConfig
+export type SpeechToTextConfig = {
+ enabled: boolean
+}
export type TextToSpeechConfig = {
enabled: boolean
@@ -93,7 +95,9 @@ export type TextToSpeechConfig = {
autoPlay?: TtsAutoPlay
}
-export type CitationConfig = MoreLikeThisConfig
+export type CitationConfig = {
+ enabled: boolean
+}
export type AnnotationReplyConfig = {
id: string
@@ -119,7 +123,9 @@ export type ModerationConfig = MoreLikeThisConfig & {
} & Partial<Record<string, unknown>>
}
-type RetrieverResourceConfig = MoreLikeThisConfig
+type RetrieverResourceConfig = {
+ enabled: boolean
+}
export type AgentConfig = {
enabled: boolean
strategy: AgentStrategy
diff --git a/web/models/log.ts b/web/models/log.ts
index 0bf99b4fe2e..c7de88d7d2a 100644
--- a/web/models/log.ts
+++ b/web/models/log.ts
@@ -1,8 +1,3 @@
-import type {
- AgentIterationLogResponse,
- AgentLogResponse,
- AgentToolCallResponse,
-} from '@dify/contracts/api/console/apps/types.gen'
import type { Viewport } from 'reactflow'
import type { Edge, Node } from '@/app/components/workflow/types'
@@ -100,7 +95,3 @@ export type WorkflowRunDetailResponse = {
finished_at: number
exceptions_count?: number
}
-
-export type AgentLogDetailResponse = AgentLogResponse
-export type AgentIteration = AgentIterationLogResponse
-export type ToolCall = AgentToolCallResponse
diff --git a/web/models/pipeline.ts b/web/models/pipeline.ts
index 41a8d15aebc..66341e92521 100644
--- a/web/models/pipeline.ts
+++ b/web/models/pipeline.ts
@@ -1,7 +1,3 @@
-import type {
- PipelineDocument,
- PipelineGenerateResponse,
-} from '@dify/contracts/api/console/rag/types.gen'
import type { Viewport } from 'reactflow'
import type { ChunkingMode, IconInfo } from './datasets'
import type { Edge, Node, SupportUploadFileTypes } from '@/app/components/workflow/types'
@@ -83,10 +79,6 @@ export type RAGPipelineVariable = {
export type InputVar = Omit<RAGPipelineVariable, 'belong_to_node_id'>
export type RAGPipelineVariables = RAGPipelineVariable[]
-export type PublishedPipelineRunResponse = PipelineGenerateResponse
-
-export type InitialDocumentDetail = PipelineDocument
-
export type PipelineExecutionLogResponse = {
datasource_info: Record<string, any>
datasource_type: DatasourceType
diff --git a/web/models/snippet.ts b/web/models/snippet.ts
index ab5006e4b34..89741ed70be 100644
--- a/web/models/snippet.ts
+++ b/web/models/snippet.ts
@@ -33,8 +33,6 @@ export type SnippetCanvasData = {
viewport: Viewport
}
-export type SnippetInputField = InputVar
-
type SnippetDetailUIModel = {
inputFieldCount: number
checklistCount: number
@@ -44,6 +42,6 @@ type SnippetDetailUIModel = {
export type SnippetDetailPayload = {
snippet: SnippetDetail
graph: SnippetCanvasData
- inputFields: SnippetInputField[]
+ inputFields: InputVar[]
uiMeta: SnippetDetailUIModel
}
diff --git a/web/service/__tests__/use-plugins.spec.tsx b/web/service/__tests__/use-plugins.spec.tsx
index 80f22835aeb..4f3206e3765 100644
--- a/web/service/__tests__/use-plugins.spec.tsx
+++ b/web/service/__tests__/use-plugins.spec.tsx
@@ -3,9 +3,10 @@ import type {
PluginCategoryInstalledPluginResponse,
PluginEntity,
PluginInstallationItemResponse,
+ PluginInstallTask,
} from '@dify/contracts/api/console/workspaces/types.gen'
import type { ReactNode } from 'react'
-import type { Permissions, PluginTaskStart } from '@/app/components/plugins/types'
+import type { Permissions } from '@/app/components/plugins/types'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { act, waitFor } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
@@ -1145,7 +1146,7 @@ describe('usePluginTaskList', () => {
})
mockGet.mockResolvedValue({ tasks: [] })
- const startedTask: PluginTaskStart = {
+ const startedTask: PluginInstallTask = {
id: 'task-new',
created_at: '2026-06-05T03:34:59.578653Z',
updated_at: '2026-06-05T03:34:59.578653Z',
@@ -1161,7 +1162,7 @@ describe('usePluginTaskList', () => {
icon: 'gitlab.png',
labels: {
en_US: 'GitLab',
- } as PluginTaskStart['plugins'][number]['labels'],
+ } as PluginInstallTask['plugins'][number]['labels'],
source: PluginSource.marketplace,
},
],
@@ -1284,7 +1285,7 @@ describe('usePluginTaskList', () => {
plugins: [],
}
mockGet.mockResolvedValue({ tasks: [staleTask] })
- const startedTask: PluginTaskStart = {
+ const startedTask: PluginInstallTask = {
id: 'task-new',
created_at: '2026-06-05T03:34:59.578653Z',
updated_at: '2026-06-05T03:34:59.578653Z',
@@ -1300,7 +1301,7 @@ describe('usePluginTaskList', () => {
icon: 'gitlab.png',
labels: {
en_US: 'GitLab',
- } as PluginTaskStart['plugins'][number]['labels'],
+ } as PluginInstallTask['plugins'][number]['labels'],
source: PluginSource.marketplace,
},
],
diff --git a/web/service/access-control/normalizers.ts b/web/service/access-control/normalizers.ts
index 37b6fae8316..71bbccf026f 100644
--- a/web/service/access-control/normalizers.ts
+++ b/web/service/access-control/normalizers.ts
@@ -3,10 +3,9 @@ import type {
AccessPolicyResourceType,
AccessPolicyWithBindings,
GetAppAccessPolicyByAppIdResponse,
- GetAppUserAccessSettingsResponse,
GetDatasetAccessPolicyByDatasetIdResponse,
- GetDatasetUserAccessSettingsResponse,
ResourceUserAccessSetting,
+ ResourceUserAccessSettingsResponse,
Role,
} from '@/models/access-control'
@@ -142,7 +141,7 @@ const normalizeResourceUserAccessSetting = (
const normalizeResourceUserAccessPolicies = (
response: GeneratedResourceUserAccessPoliciesResponse,
fallbackResourceType: AccessPolicyResourceType,
-): GetAppUserAccessSettingsResponse | GetDatasetUserAccessSettingsResponse => ({
+): ResourceUserAccessSettingsResponse | ResourceUserAccessSettingsResponse => ({
data: (response.data ?? []).map((setting) =>
normalizeResourceUserAccessSetting(setting, fallbackResourceType),
),
@@ -174,12 +173,12 @@ export const normalizeDatasetAccessMatrix = (
export const normalizeAppUserAccessPolicies = (
response: GeneratedResourceUserAccessPoliciesResponse,
-): GetAppUserAccessSettingsResponse => {
+): ResourceUserAccessSettingsResponse => {
return normalizeResourceUserAccessPolicies(response, 'app')
}
export const normalizeDatasetUserAccessPolicies = (
response: GeneratedResourceUserAccessPoliciesResponse,
-): GetDatasetUserAccessSettingsResponse => {
+): ResourceUserAccessSettingsResponse => {
return normalizeResourceUserAccessPolicies(response, 'dataset')
}
diff --git a/web/service/access-control/use-app-access-config.ts b/web/service/access-control/use-app-access-config.ts
index 41f66097974..3fa10afb144 100644
--- a/web/service/access-control/use-app-access-config.ts
+++ b/web/service/access-control/use-app-access-config.ts
@@ -1,7 +1,7 @@
import type { AccessControlTemplateLanguage } from '@/i18n/language'
import type {
- RemoveAppAccessPolicyMemberBindingsRequest,
- UpdateAppUserAccessSettingsRequest,
+ RemoveResourceAccessPolicyMemberBindingsRequest,
+ UpdateResourceUserAccessSettingsRequest,
} from '@/models/access-control'
import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { consoleClient, consoleQuery } from '@/service/console'
@@ -81,7 +81,7 @@ export const useUpdateAppUserAccessSettings = (appId: string) => {
return useMutation({
mutationKey: [NAME_SPACE, 'update-app-user-access-settings', appId],
- mutationFn: (payload: UpdateAppUserAccessSettingsRequest) =>
+ mutationFn: (payload: UpdateResourceUserAccessSettingsRequest) =>
appRbacClient.users.byTargetAccountId.accessPolicies.put({
params: {
app_id: appId,
@@ -112,7 +112,7 @@ export const useRemoveAppAccessPolicyMemberBindings = (appId: string) => {
return useMutation({
mutationKey: [NAME_SPACE, 'remove-app-access-policy-member-bindings', appId],
- mutationFn: (removals: RemoveAppAccessPolicyMemberBindingsRequest[]) =>
+ mutationFn: (removals: RemoveResourceAccessPolicyMemberBindingsRequest[]) =>
Promise.all(
removals.map((removal) =>
appRbacClient.accessPolicies.byPolicyId.memberBindings.delete({
diff --git a/web/service/access-control/use-dataset-access-config.ts b/web/service/access-control/use-dataset-access-config.ts
index b976a88ad85..679f02ee824 100644
--- a/web/service/access-control/use-dataset-access-config.ts
+++ b/web/service/access-control/use-dataset-access-config.ts
@@ -1,7 +1,7 @@
import type { AccessControlTemplateLanguage } from '@/i18n/language'
import type {
- RemoveDatasetAccessPolicyMemberBindingsRequest,
- UpdateDatasetUserAccessSettingsRequest,
+ RemoveResourceAccessPolicyMemberBindingsRequest,
+ UpdateResourceUserAccessSettingsRequest,
} from '@/models/access-control'
import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { consoleClient, consoleQuery } from '@/service/console'
@@ -100,7 +100,7 @@ export const useUpdateDatasetUserAccessSettings = (datasetId: string) => {
return useMutation({
mutationKey: [NAME_SPACE, 'update-dataset-user-access-settings', datasetId],
- mutationFn: (payload: UpdateDatasetUserAccessSettingsRequest) =>
+ mutationFn: (payload: UpdateResourceUserAccessSettingsRequest) =>
datasetRbacClient.users.byTargetAccountId.accessPolicies.put({
params: {
dataset_id: datasetId,
@@ -131,7 +131,7 @@ export const useRemoveDatasetAccessPolicyMemberBindings = (datasetId: string) =>
return useMutation({
mutationKey: [NAME_SPACE, 'remove-dataset-access-policy-member-bindings', datasetId],
- mutationFn: (removals: RemoveDatasetAccessPolicyMemberBindingsRequest[]) =>
+ mutationFn: (removals: RemoveResourceAccessPolicyMemberBindingsRequest[]) =>
Promise.all(
removals.map((removal) =>
datasetRbacClient.accessPolicies.byPolicyId.memberBindings.delete({
diff --git a/web/service/use-common.ts b/web/service/use-common.ts
index b11e6f19d2e..77d08e0512c 100644
--- a/web/service/use-common.ts
+++ b/web/service/use-common.ts
@@ -1,4 +1,3 @@
-import type { SchemaDefinitionItemResponse } from '@dify/contracts/api/console/spec/types.gen'
import type { CommonResponse } from '@/models/common'
import { useMutation, useQuery } from '@tanstack/react-query'
import { discardRegistrationSessionState } from '@/app/components/base/amplitude/registration-session-state'
@@ -16,8 +15,6 @@ const commonQueryKeys = {
[NAME_SPACE, 'forgot-password-validity', token] as const,
}
-export type SchemaTypeDefinition = SchemaDefinitionItemResponse
-
export const useLogout = ({ redirectTo = '/signin' }: { redirectTo?: string } = {}) => {
return useMutation(
consoleQuery.logout.post.mutationOptions({
diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts
index a31725a7007..5f9f2f785ef 100644
--- a/web/service/use-plugins.ts
+++ b/web/service/use-plugins.ts
@@ -5,6 +5,8 @@ import type {
PluginCategoryListResponse,
PluginEntity,
PluginInstallationItemResponse,
+ PluginInstallTask,
+ PluginInstallTaskStartResponse,
PluginListResponse,
PluginParameterOption,
} from '@dify/contracts/api/console/workspaces/types.gen'
@@ -19,7 +21,6 @@ import type { AutoUpdateConfig } from '@/app/components/plugins/reference-settin
import type {
Dependency,
GitHubItemAndMarketPlaceDependency,
- InstallPackageResponse,
InstallStatusResponse,
MetaData,
PackageDependency,
@@ -28,7 +29,6 @@ import type {
PluginDeclaration,
PluginDetail,
PluginTask,
- PluginTaskStart,
ReferenceSetting,
VersionInfo,
VersionListResponse,
@@ -483,7 +483,7 @@ const isUnfinishedPluginTask = (task: PluginTask) =>
task.status === TaskStatus.pending || task.status === TaskStatus.running
// Each plugin status records its task so a single status can be cleared.
-const normalizeStartedPluginTask = (task: PluginTaskStart): PluginTask => ({
+const normalizeStartedPluginTask = (task: PluginInstallTask): PluginTask => ({
...task,
plugins: task.plugins.map((plugin) => ({
...plugin,
@@ -491,7 +491,10 @@ const normalizeStartedPluginTask = (task: PluginTaskStart): PluginTask => ({
})),
})
-const upsertStartedPluginTask = (queryClient: QueryClient, response: InstallPackageResponse) => {
+const upsertStartedPluginTask = (
+ queryClient: QueryClient,
+ response: PluginInstallTaskStartResponse,
+) => {
if (!response.task) return
const startedTask = normalizeStartedPluginTask(response.task)
@@ -806,7 +809,7 @@ export const useInvalidateInstalledPluginList = () => {
}
export const useInstallPackageFromMarketPlace = (
- options?: MutateOptions<InstallPackageResponse, Error, string>,
+ options?: MutateOptions<PluginInstallTaskStartResponse, Error, string>,
) => {
const queryClient = useQueryClient()
return useMutation({
@@ -824,7 +827,7 @@ export const useInstallPackageFromMarketPlace = (
}
export const useUpdatePackageFromMarketPlace = (
- options?: MutateOptions<InstallPackageResponse, Error, ParserMarketplaceUpgrade>,
+ options?: MutateOptions<PluginInstallTaskStartResponse, Error, ParserMarketplaceUpgrade>,
) => {
const queryClient = useQueryClient()
return useMutation({
@@ -1449,7 +1452,7 @@ export const usePluginTaskList = (category?: PluginCategoryEnum | string) => {
}, [refetch])
const handleInstallTaskStart = useCallback(
- (response: InstallPackageResponse) => {
+ (response: PluginInstallTaskStartResponse) => {
if (response.all_installed) return
upsertStartedPluginTask(queryClient, response)
diff --git a/web/service/use-snippets.ts b/web/service/use-snippets.ts
index c24911ca261..59b9eae99f6 100644
--- a/web/service/use-snippets.ts
+++ b/web/service/use-snippets.ts
@@ -1,8 +1,8 @@
+import type { InputVar as SnippetInputFieldUIModel } from '@/models/pipeline'
import type {
SnippetCanvasData,
SnippetDetailPayload,
SnippetDetail as SnippetDetailUIModel,
- SnippetInputField as SnippetInputFieldUIModel,
SnippetListItem as SnippetListItemUIModel,
} from '@/models/snippet'
import type {
diff --git a/web/service/workflow-generator.ts b/web/service/workflow-generator.ts
index 4eff9f6eff2..148f723d4b6 100644
--- a/web/service/workflow-generator.ts
+++ b/web/service/workflow-generator.ts
@@ -10,36 +10,31 @@ import { consoleClient } from '@/service/console'
// oxlint-disable-next-line no-restricted-imports
import { sseGeneratorPost } from './base'
-export type GenerateWorkflowBody = WorkflowGeneratePayload
-export type GenerateWorkflowResponse = WorkflowGenerateResponse
-export type WorkflowGenPlan = WorkflowGeneratePlanEventResponse
-export type WorkflowInstructionSuggestionsBody = WorkflowInstructionSuggestionsPayload
-
export type GenerateWorkflowOptions = {
getAbortController?: (controller: AbortController) => void
}
-export function generateWorkflow(body: GenerateWorkflowBody, options?: GenerateWorkflowOptions) {
+export function generateWorkflow(body: WorkflowGeneratePayload, options?: GenerateWorkflowOptions) {
const controller = new AbortController()
options?.getAbortController?.(controller)
return consoleClient.workflowGenerate.post({ body }, { signal: controller.signal })
}
export type GenerateWorkflowStreamCallbacks = {
- onPlan?: (plan: WorkflowGenPlan) => void
- onResult?: (result: GenerateWorkflowResponse) => void
+ onPlan?: (plan: WorkflowGeneratePlanEventResponse) => void
+ onResult?: (result: WorkflowGenerateResponse) => void
onError?: (message: string) => void
onCompleted?: () => void
getAbortController?: (controller: AbortController) => void
}
export function generateWorkflowStream(
- body: GenerateWorkflowBody,
+ body: WorkflowGeneratePayload,
callbacks: GenerateWorkflowStreamCallbacks,
) {
return sseGeneratorPost('/workflow-generate/stream', body, {
- onPlan: (data) => callbacks.onPlan?.(data as WorkflowGenPlan),
- onResult: (data) => callbacks.onResult?.(data as GenerateWorkflowResponse),
+ onPlan: (data) => callbacks.onPlan?.(data as WorkflowGeneratePlanEventResponse),
+ onResult: (data) => callbacks.onResult?.(data as WorkflowGenerateResponse),
onError: callbacks.onError,
onCompleted: callbacks.onCompleted,
getAbortController: callbacks.getAbortController,
@@ -47,7 +42,7 @@ export function generateWorkflowStream(
}
export function fetchWorkflowInstructionSuggestions(
- body: WorkflowInstructionSuggestionsBody,
+ body: WorkflowInstructionSuggestionsPayload,
options?: GenerateWorkflowOptions,
) {
const controller = new AbortController()
diff --git a/web/service/workflow.ts b/web/service/workflow.ts
index 692abaa0faa..9c682430cd7 100644
--- a/web/service/workflow.ts
+++ b/web/service/workflow.ts
@@ -19,8 +19,6 @@ import type {
import { consoleClient } from '@/service/console'
import { get, post } from './base'
-export type WorkflowDraftFeaturesPayload = WorkflowFeaturesConfigPayload
-
export type EnvironmentVariablePatch = {
environmentVariables: EnvironmentVariable[]
deletedEnvironmentVariableIds: string[]
@@ -207,7 +205,7 @@ export const updateFeatures = ({
features,
}: {
appId: string
- features: WorkflowDraftFeaturesPayload
+ features: WorkflowFeaturesConfigPayload
}) => {
return consoleClient.apps.byAppId.workflows.draft.features.post({
params: { app_id: appId },
diff --git a/web/types/pipeline.tsx b/web/types/pipeline.tsx
index afa6a63b3af..bc69afdbd18 100644
--- a/web/types/pipeline.tsx
+++ b/web/types/pipeline.tsx
@@ -1,5 +1,3 @@
-import type { DatasourceCredentialResponse } from '@dify/contracts/api/console/auth/types.gen'
-
export type DataSourceNodeProcessingResponse = {
event: 'datasource_processing'
total: number
@@ -30,5 +28,3 @@ export type DataSourceNodeErrorResponse = {
event: 'datasource_error'
error: string
}
-
-export type DataSourceCredential = DatasourceCredentialResponse
diff --git a/web/types/snippet.ts b/web/types/snippet.ts
index e511614bcc0..889a2ee54b7 100644
--- a/web/types/snippet.ts
+++ b/web/types/snippet.ts
@@ -1,11 +1,9 @@
-import type { TagResponse as Tag } from '@dify/contracts/api/console/tags/types.gen'
+import type { TagResponse } from '@dify/contracts/api/console/tags/types.gen'
type SnippetType = 'node' | 'group'
type SnippetInputField = Record<string, unknown>
-type SnippetTag = Tag
-
type SnippetAccount = {
id: string
name: string
@@ -21,7 +19,7 @@ export type SnippetListItem = {
version: number
use_count: number
icon_info?: Record<string, unknown> | null
- tags: SnippetTag[]
+ tags: TagResponse[]
created_at: number
created_by: string | null
author_name?: string | null
diff --git a/web/types/workflow.ts b/web/types/workflow.ts
index ec955f3528a..92ce9a31166 100644
--- a/web/types/workflow.ts
+++ b/web/types/workflow.ts
@@ -158,8 +158,6 @@ export type FetchWorkflowDraftResponse = {
environments?: VersionEnvironment[]
}
-export type VersionHistory = FetchWorkflowDraftResponse
-
export type FetchWorkflowDraftPageParams = {
url: string
initialPage: number
@@ -169,7 +167,7 @@ export type FetchWorkflowDraftPageParams = {
}
export type FetchWorkflowDraftPageResponse = {
- items: VersionHistory[]
+ items: FetchWorkflowDraftResponse[]
has_more: boolean
page: number
}
@@ -474,8 +472,6 @@ export type PanelProps = {
runResult: any
}
-export type NodeRunResult = NodeTracing
-
// Var Inspect
export const VarInInspectType = {
conversation: 'conversation',