perf: api dataset code

This commit is contained in:
archer
2025-06-03 18:31:35 +08:00
parent 2507997d20
commit e32ca8a3e9
63 changed files with 347 additions and 530 deletions

View File

@@ -0,0 +1,54 @@
import { RequireOnlyOne } from '../../../common/type/utils';
import type { ParentIdType } from '../../../common/parentFolder/type';
export type APIFileItem = {
id: string;
parentId: ParentIdType;
name: string;
type: 'file' | 'folder';
updateTime: Date;
createTime: Date;
hasChild?: boolean;
};
// Api dataset config
export type APIFileServer = {
baseUrl: string;
authorization?: string;
basePath?: string;
};
export type FeishuServer = {
appId: string;
appSecret?: string;
folderToken: string;
};
export type YuqueServer = {
userId: string;
token?: string;
basePath?: string;
};
export type ApiDatasetServerType = {
apiServer?: APIFileServer;
feishuServer?: FeishuServer;
yuqueServer?: YuqueServer;
};
// Api dataset api
export type APIFileListResponse = APIFileItem[];
export type ApiFileReadContentResponse = {
title?: string;
rawText: string;
};
export type APIFileReadResponse = {
url: string;
};
export type ApiDatasetDetailResponse = {
id: string;
name: string;
parentId: ParentIdType;
};

View File

@@ -0,0 +1,31 @@
import type { ApiDatasetServerType } from './type';
export const filterApiDatasetServerPublicData = (apiDatasetServer?: ApiDatasetServerType) => {
if (!apiDatasetServer) return undefined;
const { apiServer, yuqueServer, feishuServer } = apiDatasetServer;
return {
apiServer: apiServer
? {
baseUrl: apiServer.baseUrl,
authorization: '',
basePath: apiServer.basePath
}
: undefined,
yuqueServer: yuqueServer
? {
userId: yuqueServer.userId,
token: '',
basePath: yuqueServer.basePath
}
: undefined,
feishuServer: feishuServer
? {
appId: feishuServer.appId,
appSecret: '',
folderToken: feishuServer.folderToken
}
: undefined
};
};