feat(rag): 补齐知识工作台聚合与转换分层

This commit is contained in:
2026-06-01 03:38:41 +08:00
parent 07ad8bb36b
commit d9cf838ace
15 changed files with 823 additions and 79 deletions

View File

@@ -0,0 +1,20 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { getKnowledgeWorkspace } from '../knowledgeWorkspace';
import { get } from '../request';
vi.mock('../request', () => ({
get: vi.fn(),
}));
describe('knowledge workspace api', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('loads workspace aggregate by store id', () => {
getKnowledgeWorkspace('1001');
expect(get).toHaveBeenCalledWith('/knowledge/workspaces/1001');
});
});

View File

@@ -0,0 +1,40 @@
import { get } from './request';
export interface KnowledgeWorkspaceDocument {
documentId: string;
documentTitle?: string | null;
parseStatus?: string | null;
indexStatus?: string | null;
enabled?: boolean | null;
updateTime?: string | null;
}
export interface KnowledgeWorkspace {
storeId: string;
storeCode?: string | null;
storeName?: string | null;
description?: string | null;
status?: string | null;
remark?: string | null;
documentCount: number;
parsedDocumentCount: number;
parseFailedDocumentCount: number;
indexedDocumentCount: number;
pendingIndexDocumentCount: number;
healthScore: number;
embeddingModelId?: string | null;
embeddingDimension?: number | null;
chunkStrategy?: number | null;
chunkSize?: number | null;
chunkOverlap?: number | null;
indexVersion?: number | null;
chunkCount?: number | null;
embeddingCount?: number | null;
pendingTaskCount?: number | null;
publishImpact?: string | null;
documents: KnowledgeWorkspaceDocument[];
}
export function getKnowledgeWorkspace(storeId: string) {
return get<KnowledgeWorkspace>(`/knowledge/workspaces/${storeId}`);
}