@lobehub/lobehub 2.0.0-next.13 → 2.0.0-next.14
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/CHANGELOG.md +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/packages/const/src/version.ts +3 -3
- package/packages/database/src/repositories/dataImporter/deprecated/__tests__/index.test.ts +2 -1
- package/packages/database/src/repositories/dataImporter/deprecated/index.ts +7 -1
- package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +9 -0
- package/src/app/[variants]/(main)/(mobile)/me/(home)/layout.tsx +0 -2
- package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/Item/Actions.tsx +3 -28
- package/src/app/[variants]/(main)/chat/_layout/Desktop/index.tsx +0 -2
- package/src/app/[variants]/(main)/chat/_layout/Mobile.tsx +1 -5
- package/src/app/[variants]/(main)/chat/settings/features/HeaderContent.tsx +2 -62
- package/src/app/[variants]/(main)/image/page.tsx +0 -2
- package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +23 -24
- package/src/app/[variants]/(main)/profile/_layout/Mobile/index.tsx +5 -9
- package/src/app/[variants]/(main)/settings/_layout/Desktop/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/_layout/Mobile/index.tsx +0 -2
- package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +1 -1
- package/src/app/[variants]/loading/index.tsx +1 -10
- package/src/components/Link.tsx +12 -0
- package/src/envs/app.ts +5 -8
- package/src/features/DataImporter/index.tsx +15 -60
- package/src/features/DevPanel/PostgresViewer/usePgTable.ts +3 -2
- package/src/hooks/useInterceptingRoutes.test.ts +21 -3
- package/src/libs/trpc/client/index.ts +0 -1
- package/src/libs/trpc/client/lambda.ts +8 -5
- package/src/server/routers/desktop/mcp.ts +1 -3
- package/src/server/routers/lambda/config/index.test.ts +2 -2
- package/src/server/routers/tools/mcp.ts +2 -3
- package/src/server/routers/tools/search.test.ts +1 -7
- package/src/server/routers/tools/search.ts +1 -4
- package/src/services/__tests__/tool.test.ts +0 -3
- package/src/services/aiModel/index.test.ts +0 -3
- package/src/services/aiModel/index.ts +1 -7
- package/src/services/aiProvider/index.test.ts +0 -3
- package/src/services/aiProvider/index.ts +1 -7
- package/src/services/chatGroup/index.ts +1 -10
- package/src/services/config.ts +1 -65
- package/src/services/export/index.ts +1 -4
- package/src/services/file/index.ts +1 -11
- package/src/services/import/index.ts +1 -7
- package/src/services/message/index.ts +1 -11
- package/src/services/plugin/index.ts +1 -11
- package/src/services/session/index.ts +1 -11
- package/src/services/tableViewer/client.ts +12 -15
- package/src/services/thread/index.ts +1 -7
- package/src/services/topic/index.ts +1 -11
- package/src/services/user/index.ts +1 -13
- package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChat.test.ts +0 -241
- package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts +26 -1
- package/src/store/chat/slices/aiChat/actions/__tests__/helpers.ts +3 -1
- package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +1 -138
- package/src/store/user/slices/common/action.test.ts +1 -4
- package/src/app/(backend)/trpc/edge/[trpc]/route.ts +0 -26
- package/src/app/[variants]/(main)/(mobile)/me/data/features/Category.tsx +0 -48
- package/src/app/[variants]/(main)/(mobile)/me/data/features/Header.tsx +0 -33
- package/src/app/[variants]/(main)/(mobile)/me/data/layout.tsx +0 -13
- package/src/app/[variants]/(main)/(mobile)/me/data/loading.tsx +0 -5
- package/src/app/[variants]/(main)/(mobile)/me/data/page.tsx +0 -29
- package/src/app/[variants]/(main)/chat/features/Migration/DBReader.ts +0 -290
- package/src/app/[variants]/(main)/chat/features/Migration/ExportConfigButton.tsx +0 -35
- package/src/app/[variants]/(main)/chat/features/Migration/Failed.tsx +0 -120
- package/src/app/[variants]/(main)/chat/features/Migration/Modal.tsx +0 -81
- package/src/app/[variants]/(main)/chat/features/Migration/Start.tsx +0 -108
- package/src/app/[variants]/(main)/chat/features/Migration/UpgradeButton.tsx +0 -71
- package/src/app/[variants]/(main)/chat/features/Migration/const.ts +0 -15
- package/src/app/[variants]/(main)/chat/features/Migration/index.tsx +0 -50
- package/src/app/[variants]/loading/Client/Content.tsx +0 -48
- package/src/app/[variants]/loading/Client/Error.tsx +0 -27
- package/src/app/[variants]/loading/Client/Redirect.tsx +0 -47
- package/src/app/[variants]/loading/Client/index.tsx +0 -22
- package/src/components/InnerLink.tsx +0 -20
- package/src/database/_deprecated/core/__tests__/db-upgrade.test.ts +0 -42
- package/src/database/_deprecated/core/__tests__/db.test.ts +0 -79
- package/src/database/_deprecated/core/__tests__/model.test.ts +0 -55
- package/src/database/_deprecated/core/db.ts +0 -246
- package/src/database/_deprecated/core/index.ts +0 -2
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/input.json +0 -55
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/output.json +0 -60
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.test.ts +0 -14
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.ts +0 -22
- package/src/database/_deprecated/core/migrations/migrateSettingsToUser/type.ts +0 -105
- package/src/database/_deprecated/core/model.ts +0 -218
- package/src/database/_deprecated/core/schemas.ts +0 -88
- package/src/database/_deprecated/core/types/db.ts +0 -15
- package/src/database/_deprecated/models/__DEBUG.ts +0 -124
- package/src/database/_deprecated/models/__tests__/file.test.ts +0 -83
- package/src/database/_deprecated/models/__tests__/message.test.ts +0 -426
- package/src/database/_deprecated/models/__tests__/plugin.test.ts +0 -81
- package/src/database/_deprecated/models/__tests__/session.test.ts +0 -253
- package/src/database/_deprecated/models/__tests__/sessionGroup.test.ts +0 -220
- package/src/database/_deprecated/models/__tests__/topic.test.ts +0 -523
- package/src/database/_deprecated/models/__tests__/user.test.ts +0 -82
- package/src/database/_deprecated/models/file.ts +0 -51
- package/src/database/_deprecated/models/message.ts +0 -277
- package/src/database/_deprecated/models/plugin.ts +0 -62
- package/src/database/_deprecated/models/session.ts +0 -271
- package/src/database/_deprecated/models/sessionGroup.ts +0 -93
- package/src/database/_deprecated/models/topic.ts +0 -250
- package/src/database/_deprecated/models/user.ts +0 -69
- package/src/database/_deprecated/schemas/files.ts +0 -39
- package/src/database/_deprecated/schemas/message.ts +0 -50
- package/src/database/_deprecated/schemas/plugin.ts +0 -12
- package/src/database/_deprecated/schemas/session.ts +0 -54
- package/src/database/_deprecated/schemas/sessionGroup.ts +0 -8
- package/src/database/_deprecated/schemas/topic.ts +0 -12
- package/src/database/_deprecated/schemas/user.ts +0 -40
- package/src/features/DataImporter/_deprecated.ts +0 -43
- package/src/features/InitClientDB/EnableModal.tsx +0 -118
- package/src/features/InitClientDB/ErrorResult.tsx +0 -143
- package/src/features/InitClientDB/InitIndicator.tsx +0 -124
- package/src/features/InitClientDB/PGliteIcon.tsx +0 -28
- package/src/features/InitClientDB/features/DatabaseRepair/Backup.tsx +0 -75
- package/src/features/InitClientDB/features/DatabaseRepair/Diagnosis.tsx +0 -98
- package/src/features/InitClientDB/features/DatabaseRepair/Repair.tsx +0 -218
- package/src/features/InitClientDB/features/DatabaseRepair/index.tsx +0 -91
- package/src/features/InitClientDB/index.tsx +0 -37
- package/src/libs/trpc/client/edge.ts +0 -26
- package/src/libs/trpc/edge/context.ts +0 -71
- package/src/libs/trpc/edge/index.ts +0 -45
- package/src/libs/trpc/edge/init.ts +0 -26
- package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +0 -75
- package/src/libs/trpc/edge/middleware/jwtPayload.ts +0 -14
- package/src/migrations/FromV0ToV1.ts +0 -10
- package/src/migrations/FromV1ToV2/fixtures/input-v1-session.json +0 -191
- package/src/migrations/FromV1ToV2/fixtures/output-v2.json +0 -202
- package/src/migrations/FromV1ToV2/index.ts +0 -82
- package/src/migrations/FromV1ToV2/migrations.test.ts +0 -224
- package/src/migrations/FromV1ToV2/types/v1.ts +0 -78
- package/src/migrations/FromV1ToV2/types/v2.ts +0 -52
- package/src/migrations/FromV2ToV3/fixtures/input-v2-session.json +0 -72
- package/src/migrations/FromV2ToV3/fixtures/output-v3-from-v1.json +0 -203
- package/src/migrations/FromV2ToV3/fixtures/output-v3.json +0 -74
- package/src/migrations/FromV2ToV3/index.ts +0 -30
- package/src/migrations/FromV2ToV3/migrations.test.ts +0 -42
- package/src/migrations/FromV2ToV3/types/v3.ts +0 -27
- package/src/migrations/FromV3ToV4/fixtures/azure-input-v3.json +0 -79
- package/src/migrations/FromV3ToV4/fixtures/azure-output-v4.json +0 -75
- package/src/migrations/FromV3ToV4/fixtures/ollama-input-v3.json +0 -85
- package/src/migrations/FromV3ToV4/fixtures/ollama-output-v4.json +0 -86
- package/src/migrations/FromV3ToV4/fixtures/openai-input-v3.json +0 -77
- package/src/migrations/FromV3ToV4/fixtures/openai-output-v4.json +0 -77
- package/src/migrations/FromV3ToV4/fixtures/openrouter-input-v3.json +0 -82
- package/src/migrations/FromV3ToV4/fixtures/openrouter-output-v4.json +0 -85
- package/src/migrations/FromV3ToV4/fixtures/output-v4-from-v1.json +0 -203
- package/src/migrations/FromV3ToV4/index.ts +0 -102
- package/src/migrations/FromV3ToV4/migrations.test.ts +0 -195
- package/src/migrations/FromV3ToV4/types/v3.ts +0 -52
- package/src/migrations/FromV3ToV4/types/v4.ts +0 -37
- package/src/migrations/FromV4ToV5/fixtures/from-v1-to-v5-output.json +0 -245
- package/src/migrations/FromV4ToV5/fixtures/function-input-v4.json +0 -96
- package/src/migrations/FromV4ToV5/fixtures/function-output-v5.json +0 -120
- package/src/migrations/FromV4ToV5/index.ts +0 -58
- package/src/migrations/FromV4ToV5/migrations.test.ts +0 -49
- package/src/migrations/FromV4ToV5/types/v4.ts +0 -21
- package/src/migrations/FromV4ToV5/types/v5.ts +0 -27
- package/src/migrations/FromV5ToV6/fixtures/from-v1-to-v6-output.json +0 -247
- package/src/migrations/FromV5ToV6/fixtures/session-input-v5.json +0 -81
- package/src/migrations/FromV5ToV6/fixtures/session-output-v6.json +0 -85
- package/src/migrations/FromV5ToV6/index.ts +0 -61
- package/src/migrations/FromV5ToV6/migrations.test.ts +0 -50
- package/src/migrations/FromV5ToV6/types/v5.ts +0 -48
- package/src/migrations/FromV5ToV6/types/v6.ts +0 -63
- package/src/migrations/FromV6ToV7/fixtures/output-v7-from-v1.json +0 -203
- package/src/migrations/FromV6ToV7/fixtures/provider-input-v6.json +0 -103
- package/src/migrations/FromV6ToV7/fixtures/provider-output-v7.json +0 -118
- package/src/migrations/FromV6ToV7/index.ts +0 -101
- package/src/migrations/FromV6ToV7/migrations.test.ts +0 -64
- package/src/migrations/FromV6ToV7/types/v6.ts +0 -61
- package/src/migrations/FromV6ToV7/types/v7.ts +0 -69
- package/src/migrations/VersionController.test.ts +0 -88
- package/src/migrations/VersionController.ts +0 -67
- package/src/migrations/index.ts +0 -61
- package/src/server/routers/edge/appStatus.ts +0 -3
- package/src/server/routers/edge/index.ts +0 -14
- package/src/server/routers/edge/upload.ts +0 -16
- package/src/services/aiModel/client.ts +0 -70
- package/src/services/aiProvider/client.ts +0 -58
- package/src/services/baseClientService/index.ts +0 -9
- package/src/services/chatGroup/client.ts +0 -63
- package/src/services/export/_deprecated.ts +0 -155
- package/src/services/export/client.ts +0 -15
- package/src/services/file/_deprecated.test.ts +0 -119
- package/src/services/file/_deprecated.ts +0 -80
- package/src/services/file/client.test.ts +0 -199
- package/src/services/file/client.ts +0 -85
- package/src/services/import/_deprecated.ts +0 -115
- package/src/services/import/client.test.ts +0 -1015
- package/src/services/import/client.ts +0 -64
- package/src/services/message/_deprecated.test.ts +0 -398
- package/src/services/message/_deprecated.ts +0 -168
- package/src/services/message/client.test.ts +0 -410
- package/src/services/message/client.ts +0 -192
- package/src/services/plugin/_deprecated.test.ts +0 -162
- package/src/services/plugin/_deprecated.ts +0 -42
- package/src/services/plugin/client.test.ts +0 -177
- package/src/services/plugin/client.ts +0 -46
- package/src/services/session/_deprecated.test.ts +0 -440
- package/src/services/session/_deprecated.ts +0 -190
- package/src/services/session/client.test.ts +0 -413
- package/src/services/session/client.ts +0 -193
- package/src/services/thread/client.ts +0 -51
- package/src/services/topic/_deprecated.test.ts +0 -245
- package/src/services/topic/_deprecated.ts +0 -75
- package/src/services/topic/client.ts +0 -89
- package/src/services/topic/pglite.test.ts +0 -212
- package/src/services/user/_deprecated.test.ts +0 -101
- package/src/services/user/_deprecated.ts +0 -70
- package/src/services/user/client.test.ts +0 -111
- package/src/services/user/client.ts +0 -104
|
@@ -10,21 +10,27 @@ import { useSessionStore } from '@/store/session';
|
|
|
10
10
|
import { useOpenChatSettings } from './useInterceptingRoutes';
|
|
11
11
|
|
|
12
12
|
// Mocks
|
|
13
|
+
const mockPush = vi.fn((href) => href);
|
|
13
14
|
vi.mock('next/navigation', () => ({
|
|
14
15
|
useRouter: vi.fn(() => ({
|
|
15
|
-
push:
|
|
16
|
+
push: mockPush,
|
|
16
17
|
replace: vi.fn((href) => href),
|
|
17
18
|
})),
|
|
18
19
|
}));
|
|
19
20
|
vi.mock('nextjs-toploader/app', () => ({
|
|
20
21
|
useRouter: vi.fn(() => ({
|
|
21
|
-
push:
|
|
22
|
+
push: mockPush,
|
|
22
23
|
replace: vi.fn((href) => href),
|
|
23
24
|
})),
|
|
24
25
|
}));
|
|
25
26
|
vi.mock('@/hooks/useQuery', () => ({
|
|
26
27
|
useQuery: vi.fn(() => ({})),
|
|
27
28
|
}));
|
|
29
|
+
vi.mock('@/hooks/useQueryRoute', () => ({
|
|
30
|
+
useQueryRoute: vi.fn(() => ({
|
|
31
|
+
push: mockPush,
|
|
32
|
+
})),
|
|
33
|
+
}));
|
|
28
34
|
vi.mock('@/hooks/useIsMobile', () => ({
|
|
29
35
|
useIsMobile: vi.fn(),
|
|
30
36
|
}));
|
|
@@ -36,20 +42,32 @@ vi.mock('@/store/global', () => ({
|
|
|
36
42
|
setState: vi.fn(),
|
|
37
43
|
},
|
|
38
44
|
}));
|
|
45
|
+
let isDeprecatedEdition = false;
|
|
46
|
+
vi.mock('@/const/version', async (importOriginal) => {
|
|
47
|
+
const actual = await importOriginal<typeof import('@/const/version')>();
|
|
48
|
+
return {
|
|
49
|
+
...actual,
|
|
50
|
+
get isDeprecatedEdition() {
|
|
51
|
+
return isDeprecatedEdition;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
});
|
|
39
55
|
|
|
40
56
|
describe('useOpenChatSettings', () => {
|
|
41
57
|
it('should handle inbox session id correctly', () => {
|
|
58
|
+
isDeprecatedEdition = true;
|
|
42
59
|
vi.mocked(useSessionStore).mockReturnValue(INBOX_SESSION_ID);
|
|
43
60
|
const { result } = renderHook(() => useOpenChatSettings());
|
|
44
61
|
|
|
45
62
|
expect(result.current()).toBe('/settings?active=agent'); // Assuming openSettings returns a function
|
|
63
|
+
isDeprecatedEdition = false;
|
|
46
64
|
});
|
|
47
65
|
|
|
48
66
|
it('should handle mobile route for chat settings', () => {
|
|
49
67
|
vi.mocked(useSessionStore).mockReturnValue('123');
|
|
50
68
|
vi.mocked(useIsMobile).mockReturnValue(true);
|
|
51
69
|
const { result } = renderHook(() => useOpenChatSettings(ChatSettingsTabs.Meta));
|
|
52
|
-
expect(result.current()).toBe('/chat/settings
|
|
70
|
+
expect(result.current()).toBe('/chat/settings');
|
|
53
71
|
});
|
|
54
72
|
|
|
55
73
|
it('should handle desktop route for chat settings with session and tab', () => {
|
|
@@ -22,10 +22,12 @@ const errorHandlingLink: TRPCLink<LambdaRouter> = () => {
|
|
|
22
22
|
complete: () => observer.complete(),
|
|
23
23
|
error: async (err) => {
|
|
24
24
|
// Check if this is an abort error and should be ignored
|
|
25
|
-
const isAbortError =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const isAbortError =
|
|
26
|
+
err.message.includes('aborted') ||
|
|
27
|
+
err.name === 'AbortError' ||
|
|
28
|
+
err.cause?.name === 'AbortError' ||
|
|
29
|
+
err.message.includes('signal is aborted without reason');
|
|
30
|
+
|
|
29
31
|
const showError = (op.context?.showNotification as boolean) ?? true;
|
|
30
32
|
const status = err.data?.httpStatus as number;
|
|
31
33
|
|
|
@@ -50,7 +52,8 @@ const errorHandlingLink: TRPCLink<LambdaRouter> = () => {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
default: {
|
|
53
|
-
fetchErrorNotification
|
|
55
|
+
if (fetchErrorNotification)
|
|
56
|
+
fetchErrorNotification.error({ errorMessage: err.message, status });
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
|
@@ -2,8 +2,6 @@ import { GetStreamableMcpServerManifestInputSchema } from '@lobechat/types';
|
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { isServerMode } from '@/const/version';
|
|
6
|
-
import { passwordProcedure } from '@/libs/trpc/edge';
|
|
7
5
|
import { authedProcedure, router } from '@/libs/trpc/lambda';
|
|
8
6
|
import { mcpService } from '@/server/services/mcp';
|
|
9
7
|
|
|
@@ -24,7 +22,7 @@ const stdioParamsSchema = z.object({
|
|
|
24
22
|
type: z.literal('stdio').default('stdio'),
|
|
25
23
|
});
|
|
26
24
|
|
|
27
|
-
const mcpProcedure =
|
|
25
|
+
const mcpProcedure = authedProcedure;
|
|
28
26
|
|
|
29
27
|
export const mcpRouter = router({
|
|
30
28
|
getStdioMcpServerManifest: mcpProcedure.input(stdioParamsSchema).query(async ({ input }) => {
|
|
@@ -4,8 +4,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
4
4
|
/**
|
|
5
5
|
* This file contains the root router of your tRPC-backend
|
|
6
6
|
*/
|
|
7
|
-
import { createCallerFactory } from '@/libs/trpc/
|
|
8
|
-
import { AuthContext, createContextInner } from '@/libs/trpc/
|
|
7
|
+
import { createCallerFactory } from '@/libs/trpc/lambda';
|
|
8
|
+
import { AuthContext, createContextInner } from '@/libs/trpc/lambda/context';
|
|
9
9
|
|
|
10
10
|
import { configRouter } from './index';
|
|
11
11
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDesktop } from '@lobechat/const';
|
|
1
2
|
import {
|
|
2
3
|
GetStreamableMcpServerManifestInputSchema,
|
|
3
4
|
StreamableHTTPAuthSchema,
|
|
@@ -5,8 +6,6 @@ import {
|
|
|
5
6
|
import { TRPCError } from '@trpc/server';
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
|
|
8
|
-
import { isDesktop, isServerMode } from '@/const/version';
|
|
9
|
-
import { passwordProcedure } from '@/libs/trpc/edge';
|
|
10
9
|
import { authedProcedure, router } from '@/libs/trpc/lambda';
|
|
11
10
|
import { mcpService } from '@/server/services/mcp';
|
|
12
11
|
|
|
@@ -38,7 +37,7 @@ const checkStdioEnvironment = (params: z.infer<typeof mcpClientParamsSchema>) =>
|
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
39
|
|
|
41
|
-
const mcpProcedure =
|
|
40
|
+
const mcpProcedure = authedProcedure;
|
|
42
41
|
|
|
43
42
|
export const mcpRouter = router({
|
|
44
43
|
getStreamableMcpServerManifest: mcpProcedure
|
|
@@ -23,13 +23,7 @@ vi.mock('@/server/services/search/impls/searxng/client');
|
|
|
23
23
|
|
|
24
24
|
describe('searchRouter', () => {
|
|
25
25
|
const mockContext = {
|
|
26
|
-
|
|
27
|
-
headers: {
|
|
28
|
-
authorization: 'Bearer mock-token',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
authorizationHeader: 'Bearer mock-token',
|
|
32
|
-
jwtPayload: { userId: '1' },
|
|
26
|
+
userId: 'test-user-id',
|
|
33
27
|
};
|
|
34
28
|
|
|
35
29
|
beforeEach(() => {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { isServerMode } from '@lobechat/const';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
|
|
4
|
-
import { passwordProcedure } from '@/libs/trpc/edge';
|
|
5
3
|
import { authedProcedure, router } from '@/libs/trpc/lambda';
|
|
6
4
|
import { searchService } from '@/server/services/search';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
const searchProcedure = isServerMode ? authedProcedure : passwordProcedure;
|
|
6
|
+
const searchProcedure = authedProcedure;
|
|
10
7
|
|
|
11
8
|
export const searchRouter = router({
|
|
12
9
|
crawlPages: searchProcedure
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import { edgeClient } from '@/libs/trpc/client';
|
|
4
|
-
import { globalHelpers } from '@/store/global/helpers';
|
|
5
|
-
|
|
6
3
|
import { toolService } from '../tool';
|
|
7
4
|
import openAPIV3 from './openai/OpenAPI_V3.json';
|
|
8
5
|
import OpenAIPlugin from './openai/plugin.json';
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService } from './client';
|
|
4
1
|
import { ServerService } from './server';
|
|
5
2
|
|
|
6
|
-
export const aiModelService =
|
|
7
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
8
|
-
? new ServerService()
|
|
9
|
-
: new ClientService();
|
|
3
|
+
export const aiModelService = new ServerService();
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService } from './client';
|
|
4
1
|
import { ServerService } from './server';
|
|
5
2
|
|
|
6
|
-
export const aiProviderService =
|
|
7
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
8
|
-
? new ServerService()
|
|
9
|
-
: new ClientService();
|
|
3
|
+
export const aiProviderService = new ServerService();
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService } from './client';
|
|
4
1
|
import { ServerService } from './server';
|
|
5
2
|
|
|
6
|
-
const
|
|
7
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new ServerService();
|
|
8
|
-
|
|
9
|
-
export const chatGroupService =
|
|
10
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
11
|
-
? new ServerService()
|
|
12
|
-
: clientService;
|
|
3
|
+
export const chatGroupService = new ServerService();
|
package/src/services/config.ts
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import { BRANDING_NAME,
|
|
1
|
+
import { BRANDING_NAME, isServerMode } from '@lobechat/const';
|
|
2
2
|
import { downloadFile, exportJSONFile } from '@lobechat/utils/client';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
|
|
5
|
-
import { CURRENT_CONFIG_VERSION } from '@/migrations';
|
|
6
5
|
import { ImportPgDataStructure } from '@/types/export';
|
|
7
6
|
|
|
8
7
|
import { exportService } from './export';
|
|
9
|
-
import { configService as deprecatedExportService } from './export/_deprecated';
|
|
10
8
|
|
|
11
9
|
class ConfigService {
|
|
12
10
|
exportAll = async () => {
|
|
13
|
-
// TODO: remove this in V2
|
|
14
|
-
if (isDeprecatedEdition) {
|
|
15
|
-
const config = await deprecatedExportService.exportAll();
|
|
16
|
-
const filename = `${BRANDING_NAME}-config-v${CURRENT_CONFIG_VERSION}.json`;
|
|
17
|
-
exportJSONFile(config, filename);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
11
|
const { data, url } = await exportService.exportData();
|
|
22
12
|
const filename = `${dayjs().format('YYYY-MM-DD-hh-mm')}_${BRANDING_NAME}-data.json`;
|
|
23
13
|
|
|
@@ -34,60 +24,6 @@ class ConfigService {
|
|
|
34
24
|
exportJSONFile(result, filename);
|
|
35
25
|
};
|
|
36
26
|
|
|
37
|
-
exportAgents = async () => {
|
|
38
|
-
// TODO: remove this in V2
|
|
39
|
-
if (isDeprecatedEdition) {
|
|
40
|
-
const config = await deprecatedExportService.exportAgents();
|
|
41
|
-
const filename = `${BRANDING_NAME}-agents-v${CURRENT_CONFIG_VERSION}.json`;
|
|
42
|
-
exportJSONFile(config, filename);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
exportSingleAgent = async (agentId: string) => {
|
|
48
|
-
// TODO: remove this in V2
|
|
49
|
-
if (isDeprecatedEdition) {
|
|
50
|
-
const result = await deprecatedExportService.exportSingleAgent(agentId);
|
|
51
|
-
if (!result) return;
|
|
52
|
-
|
|
53
|
-
const filename = `${BRANDING_NAME}-${result.title}-v${CURRENT_CONFIG_VERSION}.json`;
|
|
54
|
-
exportJSONFile(result.config, filename);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
exportSessions = async () => {
|
|
60
|
-
// TODO: remove this in V2
|
|
61
|
-
if (isDeprecatedEdition) {
|
|
62
|
-
const config = await deprecatedExportService.exportSessions();
|
|
63
|
-
const filename = `${BRANDING_NAME}-sessions-v${CURRENT_CONFIG_VERSION}.json`;
|
|
64
|
-
exportJSONFile(config, filename);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exportSettings = async () => {
|
|
70
|
-
// TODO: remove this in V2
|
|
71
|
-
if (isDeprecatedEdition) {
|
|
72
|
-
const config = await deprecatedExportService.exportSessions();
|
|
73
|
-
const filename = `${BRANDING_NAME}-settings-v${CURRENT_CONFIG_VERSION}.json`;
|
|
74
|
-
exportJSONFile(config, filename);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
exportSingleSession = async (sessionId: string) => {
|
|
80
|
-
// TODO: remove this in V2
|
|
81
|
-
if (isDeprecatedEdition) {
|
|
82
|
-
const data = await deprecatedExportService.exportSingleSession(sessionId);
|
|
83
|
-
if (!data) return;
|
|
84
|
-
|
|
85
|
-
const filename = `${BRANDING_NAME}-${data.title}-v${CURRENT_CONFIG_VERSION}.json`;
|
|
86
|
-
exportJSONFile(data.config, filename);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
27
|
private createDataStructure = async (
|
|
92
28
|
data: any,
|
|
93
29
|
mode: 'pglite' | 'postgres',
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { isServerMode } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService } from './client';
|
|
4
1
|
import { ServerService } from './server';
|
|
5
2
|
|
|
6
|
-
export const exportService =
|
|
3
|
+
export const exportService = new ServerService();
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService as DeprecatedService } from './_deprecated';
|
|
4
|
-
import { ClientService } from './client';
|
|
5
1
|
import { ServerService } from './server';
|
|
6
2
|
|
|
7
|
-
const
|
|
8
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new DeprecatedService();
|
|
9
|
-
|
|
10
|
-
export const fileService =
|
|
11
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
12
|
-
? new ServerService()
|
|
13
|
-
: clientService;
|
|
3
|
+
export const fileService = new ServerService();
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { ClientService as DeprecatedService } from './_deprecated';
|
|
2
|
-
import { ClientService } from './client';
|
|
3
1
|
import { ServerService } from './server';
|
|
4
2
|
|
|
5
|
-
const
|
|
6
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new DeprecatedService();
|
|
7
|
-
|
|
8
|
-
export const importService =
|
|
9
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' ? new ServerService() : clientService;
|
|
3
|
+
export const importService = new ServerService();
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService as DeprecatedService } from './_deprecated';
|
|
4
|
-
import { ClientService } from './client';
|
|
5
1
|
import { ServerService } from './server';
|
|
6
2
|
|
|
7
|
-
const
|
|
8
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new DeprecatedService();
|
|
9
|
-
|
|
10
|
-
export const messageService =
|
|
11
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
12
|
-
? new ServerService()
|
|
13
|
-
: clientService;
|
|
3
|
+
export const messageService = new ServerService();
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService as DeprecatedService } from './_deprecated';
|
|
4
|
-
import { ClientService } from './client';
|
|
5
1
|
import { ServerService } from './server';
|
|
6
2
|
|
|
7
|
-
const
|
|
8
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new DeprecatedService();
|
|
9
|
-
|
|
10
|
-
export const pluginService =
|
|
11
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
12
|
-
? new ServerService()
|
|
13
|
-
: clientService;
|
|
3
|
+
export const pluginService = new ServerService();
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService as DeprecatedService } from './_deprecated';
|
|
4
|
-
import { ClientService } from './client';
|
|
5
1
|
import { ServerService } from './server';
|
|
6
2
|
|
|
7
|
-
const
|
|
8
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new DeprecatedService();
|
|
9
|
-
|
|
10
|
-
export const sessionService =
|
|
11
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
12
|
-
? new ServerService()
|
|
13
|
-
: clientService;
|
|
3
|
+
export const sessionService = new ServerService();
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getTableData = async (tableName: string) =>
|
|
15
|
-
this.tableViewerRepo.getTableData(tableName, { page: 1, pageSize: 300 });
|
|
1
|
+
export class ClientService {
|
|
2
|
+
getAllTables = async () => [];
|
|
3
|
+
|
|
4
|
+
getTableDetails = async (tableName: string) => {
|
|
5
|
+
console.log('getTableDetails:', tableName);
|
|
6
|
+
return [];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
getTableData = async (tableName: string) => {
|
|
10
|
+
console.log('getTableData:', tableName);
|
|
11
|
+
return [];
|
|
12
|
+
};
|
|
16
13
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService } from './client';
|
|
4
1
|
import { ServerService } from './server';
|
|
5
2
|
|
|
6
|
-
export const threadService =
|
|
7
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
8
|
-
? new ServerService()
|
|
9
|
-
: new ClientService();
|
|
3
|
+
export const threadService = new ServerService();
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService as DeprecatedService } from './_deprecated';
|
|
4
|
-
import { ClientService } from './client';
|
|
5
1
|
import { ServerService } from './server';
|
|
6
2
|
|
|
7
|
-
const
|
|
8
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new DeprecatedService();
|
|
9
|
-
|
|
10
|
-
export const topicService =
|
|
11
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
12
|
-
? new ServerService()
|
|
13
|
-
: clientService;
|
|
3
|
+
export const topicService = new ServerService();
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import { isDesktop } from '@/const/version';
|
|
2
|
-
|
|
3
|
-
import { ClientService as DeprecatedService } from './_deprecated';
|
|
4
|
-
import { ClientService } from './client';
|
|
5
1
|
import { ServerService } from './server';
|
|
6
2
|
|
|
7
|
-
const
|
|
8
|
-
process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite' ? new ClientService() : new DeprecatedService();
|
|
9
|
-
|
|
10
|
-
export const userService =
|
|
11
|
-
process.env.NEXT_PUBLIC_SERVICE_MODE === 'server' || isDesktop
|
|
12
|
-
? new ServerService()
|
|
13
|
-
: clientService;
|
|
14
|
-
|
|
15
|
-
export const userClientService = clientService;
|
|
3
|
+
export const userService = new ServerService();
|