perf: api dataset code
This commit is contained in:
6
packages/global/core/dataset/api.d.ts
vendored
6
packages/global/core/dataset/api.d.ts
vendored
@@ -17,6 +17,9 @@ import type { ParentIdType } from '../../common/parentFolder/type';
|
||||
/* ================= dataset ===================== */
|
||||
export type DatasetUpdateBody = {
|
||||
id: string;
|
||||
|
||||
apiDatasetServer?: DatasetSchemaType['apiDatasetServer'];
|
||||
|
||||
parentId?: ParentIdType;
|
||||
name?: string;
|
||||
avatar?: string;
|
||||
@@ -28,9 +31,6 @@ export type DatasetUpdateBody = {
|
||||
websiteConfig?: DatasetSchemaType['websiteConfig'];
|
||||
externalReadUrl?: DatasetSchemaType['externalReadUrl'];
|
||||
defaultPermission?: DatasetSchemaType['defaultPermission'];
|
||||
apiServer?: DatasetSchemaType['apiServer'];
|
||||
yuqueServer?: DatasetSchemaType['yuqueServer'];
|
||||
feishuServer?: DatasetSchemaType['feishuServer'];
|
||||
chunkSettings?: DatasetSchemaType['chunkSettings'];
|
||||
|
||||
// sync schedule
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RequireOnlyOne } from '../../common/type/utils';
|
||||
import type { ParentIdType } from '../../common/parentFolder/type.d';
|
||||
import { RequireOnlyOne } from '../../../common/type/utils';
|
||||
import type { ParentIdType } from '../../../common/parentFolder/type';
|
||||
|
||||
export type APIFileItem = {
|
||||
id: string;
|
||||
@@ -28,6 +28,12 @@ export type YuqueServer = {
|
||||
basePath?: string;
|
||||
};
|
||||
|
||||
export type ApiDatasetServerType = {
|
||||
apiServer?: APIFileServer;
|
||||
feishuServer?: FeishuServer;
|
||||
yuqueServer?: YuqueServer;
|
||||
};
|
||||
|
||||
// Api dataset api
|
||||
|
||||
export type APIFileListResponse = APIFileItem[];
|
||||
31
packages/global/core/dataset/apiDataset/utils.ts
Normal file
31
packages/global/core/dataset/apiDataset/utils.ts
Normal 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
|
||||
};
|
||||
};
|
||||
@@ -6,11 +6,51 @@ export enum DatasetTypeEnum {
|
||||
dataset = 'dataset',
|
||||
websiteDataset = 'websiteDataset', // depp link
|
||||
externalFile = 'externalFile',
|
||||
|
||||
apiDataset = 'apiDataset',
|
||||
feishu = 'feishu',
|
||||
yuque = 'yuque'
|
||||
}
|
||||
export const DatasetTypeMap = {
|
||||
|
||||
// @ts-ignore
|
||||
export const ApiDatasetTypeMap: Record<
|
||||
`${DatasetTypeEnum}`,
|
||||
{
|
||||
icon: string;
|
||||
label: any;
|
||||
collectionLabel: string;
|
||||
courseUrl?: string;
|
||||
}
|
||||
> = {
|
||||
[DatasetTypeEnum.apiDataset]: {
|
||||
icon: 'core/dataset/externalDatasetOutline',
|
||||
label: i18nT('dataset:api_file'),
|
||||
collectionLabel: i18nT('common:File'),
|
||||
courseUrl: '/docs/guide/knowledge_base/api_dataset/'
|
||||
},
|
||||
[DatasetTypeEnum.feishu]: {
|
||||
icon: 'core/dataset/feishuDatasetOutline',
|
||||
label: i18nT('dataset:feishu_dataset'),
|
||||
collectionLabel: i18nT('common:File'),
|
||||
courseUrl: '/docs/guide/knowledge_base/lark_dataset/'
|
||||
},
|
||||
[DatasetTypeEnum.yuque]: {
|
||||
icon: 'core/dataset/yuqueDatasetOutline',
|
||||
label: i18nT('dataset:yuque_dataset'),
|
||||
collectionLabel: i18nT('common:File'),
|
||||
courseUrl: '/docs/guide/knowledge_base/yuque_dataset/'
|
||||
}
|
||||
};
|
||||
export const DatasetTypeMap: Record<
|
||||
`${DatasetTypeEnum}`,
|
||||
{
|
||||
icon: string;
|
||||
label: any;
|
||||
collectionLabel: string;
|
||||
courseUrl?: string;
|
||||
}
|
||||
> = {
|
||||
...ApiDatasetTypeMap,
|
||||
[DatasetTypeEnum.folder]: {
|
||||
icon: 'common/folderFill',
|
||||
label: i18nT('dataset:folder_dataset'),
|
||||
@@ -24,27 +64,13 @@ export const DatasetTypeMap = {
|
||||
[DatasetTypeEnum.websiteDataset]: {
|
||||
icon: 'core/dataset/websiteDatasetOutline',
|
||||
label: i18nT('dataset:website_dataset'),
|
||||
collectionLabel: i18nT('common:Website')
|
||||
collectionLabel: i18nT('common:Website'),
|
||||
courseUrl: '/docs/guide/knowledge_base/websync/'
|
||||
},
|
||||
[DatasetTypeEnum.externalFile]: {
|
||||
icon: 'core/dataset/externalDatasetOutline',
|
||||
label: i18nT('dataset:external_file'),
|
||||
collectionLabel: i18nT('common:File')
|
||||
},
|
||||
[DatasetTypeEnum.apiDataset]: {
|
||||
icon: 'core/dataset/externalDatasetOutline',
|
||||
label: i18nT('dataset:api_file'),
|
||||
collectionLabel: i18nT('common:File')
|
||||
},
|
||||
[DatasetTypeEnum.feishu]: {
|
||||
icon: 'core/dataset/feishuDatasetOutline',
|
||||
label: i18nT('dataset:feishu_dataset'),
|
||||
collectionLabel: i18nT('common:File')
|
||||
},
|
||||
[DatasetTypeEnum.yuque]: {
|
||||
icon: 'core/dataset/yuqueDatasetOutline',
|
||||
label: i18nT('dataset:yuque_dataset'),
|
||||
collectionLabel: i18nT('common:File')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
15
packages/global/core/dataset/type.d.ts
vendored
15
packages/global/core/dataset/type.d.ts
vendored
@@ -13,7 +13,12 @@ import type {
|
||||
ChunkTriggerConfigTypeEnum
|
||||
} from './constants';
|
||||
import type { DatasetPermission } from '../../support/permission/dataset/controller';
|
||||
import type { APIFileServer, FeishuServer, YuqueServer } from './apiDataset';
|
||||
import type {
|
||||
ApiDatasetServerType,
|
||||
APIFileServer,
|
||||
FeishuServer,
|
||||
YuqueServer
|
||||
} from './apiDataset/type';
|
||||
import type { SourceMemberType } from 'support/user/type';
|
||||
import type { DatasetDataIndexTypeEnum } from './data/constants';
|
||||
import type { ParentIdType } from 'common/parentFolder/type';
|
||||
@@ -73,14 +78,16 @@ export type DatasetSchemaType = {
|
||||
chunkSettings?: ChunkSettingsType;
|
||||
|
||||
inheritPermission: boolean;
|
||||
apiServer?: APIFileServer;
|
||||
feishuServer?: FeishuServer;
|
||||
yuqueServer?: YuqueServer;
|
||||
|
||||
apiDatasetServer?: ApiDatasetServerType;
|
||||
|
||||
// abandon
|
||||
autoSync?: boolean;
|
||||
externalReadUrl?: string;
|
||||
defaultPermission?: number;
|
||||
apiServer?: APIFileServer;
|
||||
feishuServer?: FeishuServer;
|
||||
yuqueServer?: YuqueServer;
|
||||
};
|
||||
|
||||
export type DatasetCollectionSchemaType = ChunkSettingsType & {
|
||||
|
||||
Reference in New Issue
Block a user