dify/web/features/new-rag/document-detail-queries.ts
Stephen Zhou 2d5161a647
feat(dataset): add document detail (#39361)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-24 15:27:35 +00:00

29 lines
780 B
TypeScript

import { consoleQuery } from '@/service/client'
const CHUNK_PAGE_SIZE = 100
export function documentChunksQueryOptions({
documentId,
effectiveRevision,
knowledgeSpaceId,
}: {
documentId: string
effectiveRevision: number
knowledgeSpaceId: string
}) {
const chunksQuery =
consoleQuery.knowledgeFs.getKnowledgeSpacesByIdDocumentsByDocumentIdRevisionsByRevisionChunks
return chunksQuery.infiniteOptions({
input: (pageParam) => ({
params: { documentId, id: knowledgeSpaceId, revision: effectiveRevision },
query: {
limit: CHUNK_PAGE_SIZE,
...(typeof pageParam === 'string' ? { cursor: pageParam } : {}),
},
}),
getNextPageParam: (lastPage) => lastPage.nextCursor,
initialPageParam: null as string | null,
})
}