@lobehub/lobehub 2.0.0-next.249 → 2.0.0-next.250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +4 -0
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +5 -0
- package/locales/en-US/file.json +2 -0
- package/locales/zh-CN/discover.json +3 -0
- package/locales/zh-CN/file.json +2 -0
- package/package.json +3 -3
- package/packages/types/package.json +2 -2
- package/packages/types/src/discover/mcp.ts +3 -1
- package/src/app/[variants]/(main)/community/(list)/(home)/index.tsx +2 -0
- package/src/app/[variants]/(main)/community/(list)/features/SortButton/index.tsx +4 -0
- package/src/app/[variants]/(main)/community/(list)/mcp/features/Category/index.tsx +7 -3
- package/src/app/[variants]/(main)/community/(list)/mcp/index.tsx +2 -2
- package/src/app/[variants]/(main)/home/_layout/Body/Project/List/Editing.tsx +1 -1
- package/src/app/[variants]/(main)/home/_layout/Body/Project/List/Item.tsx +1 -1
- package/src/app/[variants]/(main)/home/_layout/Body/Project/List/index.tsx +1 -1
- package/src/app/[variants]/(main)/home/_layout/Body/Project/List/useDropdownMenu.tsx +1 -1
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/{List/Item → Item}/Editing.tsx +1 -1
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/{List/Item → Item}/index.tsx +1 -1
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/{List/Item → Item}/useDropdownMenu.tsx +1 -1
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/index.tsx +16 -6
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/{KnowledgeBase.tsx → index.tsx} +2 -3
- package/src/app/[variants]/(main)/resource/(home)/_layout/Sidebar.tsx +2 -2
- package/src/app/[variants]/(main)/resource/(home)/index.tsx +23 -10
- package/src/app/[variants]/(main)/resource/features/DndContextWrapper.tsx +12 -37
- package/src/app/[variants]/(main)/resource/features/hooks/useKnowledgeItem.ts +1 -1
- package/src/app/[variants]/(main)/resource/features/store/action.ts +9 -39
- package/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx +1 -1
- package/src/app/[variants]/(main)/resource/library/index.tsx +13 -6
- package/src/features/LibraryModal/AddFilesToKnowledgeBase/SelectForm.tsx +1 -1
- package/src/features/LibraryModal/CreateNew/CreateForm.tsx +1 -1
- package/src/features/PageEditor/Header/Breadcrumb.tsx +1 -1
- package/src/features/PageEditor/store/action.ts +5 -2
- package/src/features/PageExplorer/PageExplorerPlaceholder.tsx +5 -7
- package/src/features/ResourceManager/components/Explorer/Header/Breadcrumb.tsx +1 -1
- package/src/features/ResourceManager/components/Explorer/ItemDropdown/useFileItemDropdown.tsx +57 -26
- package/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx +35 -6
- package/src/features/ResourceManager/components/Explorer/ListView/Skeleton.tsx +20 -14
- package/src/features/ResourceManager/components/Explorer/ListView/index.tsx +41 -31
- package/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/index.tsx +1 -1
- package/src/features/ResourceManager/components/Explorer/MasonryView/Skeleton.tsx +6 -2
- package/src/features/ResourceManager/components/Explorer/MasonryView/index.tsx +29 -18
- package/src/features/ResourceManager/components/Explorer/MoveToFolderModal.tsx +7 -34
- package/src/features/ResourceManager/components/Explorer/ToolBar/BatchActionsDropdown.tsx +1 -1
- package/src/features/ResourceManager/components/Explorer/index.tsx +58 -18
- package/src/features/ResourceManager/components/Explorer/useCheckTaskStatus.ts +6 -4
- package/src/features/ResourceManager/components/Header/AddButton.tsx +58 -35
- package/src/features/ResourceManager/components/Header/hooks/useNotionImport.ts +5 -5
- package/src/features/ResourceManager/components/Tree/TreeSkeleton.tsx +19 -9
- package/src/features/ResourceManager/components/Tree/index.tsx +110 -5
- package/src/features/ResourceManager/components/UploadDock/index.tsx +2 -1
- package/src/features/ResourceManager/constants.ts +3 -0
- package/src/hooks/useMCPCategory.tsx +7 -0
- package/src/locales/default/discover.ts +3 -0
- package/src/locales/default/file.ts +2 -0
- package/src/services/file/index.ts +34 -1
- package/src/services/resource/index.ts +249 -0
- package/src/store/discover/slices/mcp/action.ts +1 -1
- package/src/store/file/slices/chat/action.ts +2 -1
- package/src/store/file/slices/document/action.ts +10 -7
- package/src/store/file/slices/fileManager/action.ts +14 -4
- package/src/store/file/slices/fileManager/initialState.ts +2 -0
- package/src/store/file/slices/resource/action.ts +432 -0
- package/src/store/file/slices/resource/hooks.ts +82 -0
- package/src/store/file/slices/resource/initialState.ts +67 -0
- package/src/store/file/slices/resource/syncEngine.ts +326 -0
- package/src/store/file/store.ts +6 -1
- package/src/store/{knowledgeBase → library}/initialState.ts +2 -2
- package/src/store/{knowledgeBase → library}/slices/content/action.test.ts +37 -51
- package/src/store/{knowledgeBase → library}/slices/content/action.ts +8 -4
- package/src/store/{knowledgeBase → library}/slices/crud/action.ts +1 -1
- package/src/store/{knowledgeBase → library}/slices/crud/selectors.ts +1 -1
- package/src/store/{knowledgeBase → library}/slices/ragEval/actions/dataset.ts +1 -1
- package/src/store/{knowledgeBase → library}/slices/ragEval/actions/evaluation.ts +1 -1
- package/src/store/{knowledgeBase → library}/slices/ragEval/actions/index.ts +1 -1
- package/src/types/resource.ts +133 -0
- package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/List/index.tsx +0 -25
- /package/src/app/[variants]/(main)/resource/(home)/_layout/Body/LibraryList/{List/Item → Item}/Actions.tsx +0 -0
- /package/src/store/{knowledgeBase → library}/index.ts +0 -0
- /package/src/store/{knowledgeBase → library}/selectors.ts +0 -0
- /package/src/store/{knowledgeBase → library}/slices/content/index.ts +0 -0
- /package/src/store/{knowledgeBase → library}/slices/crud/action.test.ts +0 -0
- /package/src/store/{knowledgeBase → library}/slices/crud/index.ts +0 -0
- /package/src/store/{knowledgeBase → library}/slices/crud/initialState.ts +0 -0
- /package/src/store/{knowledgeBase → library}/slices/ragEval/index.ts +0 -0
- /package/src/store/{knowledgeBase → library}/slices/ragEval/initialState.ts +0 -0
- /package/src/store/{knowledgeBase → library}/store.ts +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { FilesTabs, SortType } from '@/types/files';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unified resource item that represents both files and documents
|
|
5
|
+
* Used by ResourceManager for optimistic updates and local-first state management
|
|
6
|
+
*/
|
|
7
|
+
export interface ResourceItem {
|
|
8
|
+
// Optimistic tracking (UI state, not persisted)
|
|
9
|
+
_optimistic?: {
|
|
10
|
+
error?: Error;
|
|
11
|
+
isPending: boolean;
|
|
12
|
+
lastSyncAttempt?: Date;
|
|
13
|
+
retryCount: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
chunkCount?: number | null;
|
|
17
|
+
chunkTaskId?: string | null;
|
|
18
|
+
chunkingError?: any | null;
|
|
19
|
+
chunkingStatus?: string | null;
|
|
20
|
+
|
|
21
|
+
// Document-specific (optional)
|
|
22
|
+
content?: string | null;
|
|
23
|
+
// Timestamps
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
|
|
26
|
+
editorData?: Record<string, any> | null;
|
|
27
|
+
embeddingError?: any | null;
|
|
28
|
+
|
|
29
|
+
embeddingStatus?: string | null;
|
|
30
|
+
embeddingTaskId?: string | null;
|
|
31
|
+
fileType: string;
|
|
32
|
+
finishEmbedding?: boolean;
|
|
33
|
+
// Identity
|
|
34
|
+
id: string;
|
|
35
|
+
knowledgeBaseId?: string;
|
|
36
|
+
// Metadata
|
|
37
|
+
metadata?: Record<string, any>;
|
|
38
|
+
// Real ID or temp-resource-{timestamp}-{random}
|
|
39
|
+
// Common fields
|
|
40
|
+
name: string;
|
|
41
|
+
// Hierarchy
|
|
42
|
+
parentId?: string | null;
|
|
43
|
+
|
|
44
|
+
// MIME type or custom/folder, custom/document
|
|
45
|
+
size: number;
|
|
46
|
+
slug?: string | null;
|
|
47
|
+
// bytes for files, char count for documents
|
|
48
|
+
sourceType: 'file' | 'document';
|
|
49
|
+
title?: string;
|
|
50
|
+
|
|
51
|
+
updatedAt: Date;
|
|
52
|
+
|
|
53
|
+
// File-specific (optional)
|
|
54
|
+
url?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Sync operation queued for background processing
|
|
59
|
+
*/
|
|
60
|
+
export interface SyncOperation {
|
|
61
|
+
id: string;
|
|
62
|
+
payload: any;
|
|
63
|
+
reject?: (reason?: any) => void;
|
|
64
|
+
// Promise resolver for async operations
|
|
65
|
+
resolve?: (value?: any) => void;
|
|
66
|
+
// Operation ID (sync-{resourceId}-{timestamp})
|
|
67
|
+
resourceId: string;
|
|
68
|
+
retryCount: number;
|
|
69
|
+
timestamp: Date;
|
|
70
|
+
// Resource ID (temp or real)
|
|
71
|
+
type: 'create' | 'update' | 'delete' | 'move';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Query parameters for fetching resources
|
|
76
|
+
*/
|
|
77
|
+
export interface ResourceQueryParams {
|
|
78
|
+
category?: FilesTabs;
|
|
79
|
+
libraryId?: string;
|
|
80
|
+
limit?: number;
|
|
81
|
+
offset?: number;
|
|
82
|
+
parentId?: string | null;
|
|
83
|
+
q?: string;
|
|
84
|
+
showFilesInKnowledgeBase?: boolean;
|
|
85
|
+
sortType?: SortType;
|
|
86
|
+
sorter?: 'name' | 'createdAt' | 'size';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Create operation payload for files
|
|
91
|
+
*/
|
|
92
|
+
export interface CreateFileParams {
|
|
93
|
+
fileType: string;
|
|
94
|
+
knowledgeBaseId?: string;
|
|
95
|
+
metadata?: Record<string, any>;
|
|
96
|
+
name: string;
|
|
97
|
+
parentId?: string;
|
|
98
|
+
size: number;
|
|
99
|
+
sourceType: 'file';
|
|
100
|
+
url: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Create operation payload for documents
|
|
105
|
+
*/
|
|
106
|
+
export interface CreateDocumentParams {
|
|
107
|
+
content: string;
|
|
108
|
+
editorData?: Record<string, any>;
|
|
109
|
+
fileType: 'custom/document' | 'custom/folder';
|
|
110
|
+
knowledgeBaseId?: string;
|
|
111
|
+
metadata?: Record<string, any>;
|
|
112
|
+
parentId?: string;
|
|
113
|
+
slug?: string;
|
|
114
|
+
sourceType: 'document';
|
|
115
|
+
title: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Union type for create operations
|
|
120
|
+
*/
|
|
121
|
+
export type CreateResourceParams = CreateFileParams | CreateDocumentParams;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Update operation payload
|
|
125
|
+
*/
|
|
126
|
+
export interface UpdateResourceParams {
|
|
127
|
+
content?: string;
|
|
128
|
+
editorData?: Record<string, any>;
|
|
129
|
+
metadata?: Record<string, any>;
|
|
130
|
+
name?: string;
|
|
131
|
+
parentId?: string | null;
|
|
132
|
+
title?: string;
|
|
133
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Flexbox } from '@lobehub/ui';
|
|
4
|
-
import { memo } from 'react';
|
|
5
|
-
|
|
6
|
-
import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
|
|
7
|
-
|
|
8
|
-
import Item from './Item';
|
|
9
|
-
|
|
10
|
-
const KnowledgeBaseListView = memo(() => {
|
|
11
|
-
const useFetchKnowledgeBaseList = useKnowledgeBaseStore((s) => s.useFetchKnowledgeBaseList);
|
|
12
|
-
const { data } = useFetchKnowledgeBaseList();
|
|
13
|
-
|
|
14
|
-
if (!data || data.length === 0) return null;
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Flexbox gap={1} paddingInline={4}>
|
|
18
|
-
{data.map((item) => (
|
|
19
|
-
<Item id={item.id} key={item.id} name={item.name} />
|
|
20
|
-
))}
|
|
21
|
-
</Flexbox>
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export default KnowledgeBaseListView;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|