@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.
Files changed (210) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/changelog/v1.json +9 -0
  3. package/package.json +1 -1
  4. package/packages/const/src/version.ts +3 -3
  5. package/packages/database/src/repositories/dataImporter/deprecated/__tests__/index.test.ts +2 -1
  6. package/packages/database/src/repositories/dataImporter/deprecated/index.ts +7 -1
  7. package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +9 -0
  8. package/src/app/[variants]/(main)/(mobile)/me/(home)/layout.tsx +0 -2
  9. package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/Item/Actions.tsx +3 -28
  10. package/src/app/[variants]/(main)/chat/_layout/Desktop/index.tsx +0 -2
  11. package/src/app/[variants]/(main)/chat/_layout/Mobile.tsx +1 -5
  12. package/src/app/[variants]/(main)/chat/settings/features/HeaderContent.tsx +2 -62
  13. package/src/app/[variants]/(main)/image/page.tsx +0 -2
  14. package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +23 -24
  15. package/src/app/[variants]/(main)/profile/_layout/Mobile/index.tsx +5 -9
  16. package/src/app/[variants]/(main)/settings/_layout/Desktop/index.tsx +0 -2
  17. package/src/app/[variants]/(main)/settings/_layout/Mobile/index.tsx +0 -2
  18. package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +1 -1
  19. package/src/app/[variants]/loading/index.tsx +1 -10
  20. package/src/components/Link.tsx +12 -0
  21. package/src/envs/app.ts +5 -8
  22. package/src/features/DataImporter/index.tsx +15 -60
  23. package/src/features/DevPanel/PostgresViewer/usePgTable.ts +3 -2
  24. package/src/hooks/useInterceptingRoutes.test.ts +21 -3
  25. package/src/libs/trpc/client/index.ts +0 -1
  26. package/src/libs/trpc/client/lambda.ts +8 -5
  27. package/src/server/routers/desktop/mcp.ts +1 -3
  28. package/src/server/routers/lambda/config/index.test.ts +2 -2
  29. package/src/server/routers/tools/mcp.ts +2 -3
  30. package/src/server/routers/tools/search.test.ts +1 -7
  31. package/src/server/routers/tools/search.ts +1 -4
  32. package/src/services/__tests__/tool.test.ts +0 -3
  33. package/src/services/aiModel/index.test.ts +0 -3
  34. package/src/services/aiModel/index.ts +1 -7
  35. package/src/services/aiProvider/index.test.ts +0 -3
  36. package/src/services/aiProvider/index.ts +1 -7
  37. package/src/services/chatGroup/index.ts +1 -10
  38. package/src/services/config.ts +1 -65
  39. package/src/services/export/index.ts +1 -4
  40. package/src/services/file/index.ts +1 -11
  41. package/src/services/import/index.ts +1 -7
  42. package/src/services/message/index.ts +1 -11
  43. package/src/services/plugin/index.ts +1 -11
  44. package/src/services/session/index.ts +1 -11
  45. package/src/services/tableViewer/client.ts +12 -15
  46. package/src/services/thread/index.ts +1 -7
  47. package/src/services/topic/index.ts +1 -11
  48. package/src/services/user/index.ts +1 -13
  49. package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChat.test.ts +0 -241
  50. package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts +26 -1
  51. package/src/store/chat/slices/aiChat/actions/__tests__/helpers.ts +3 -1
  52. package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +1 -138
  53. package/src/store/user/slices/common/action.test.ts +1 -4
  54. package/src/app/(backend)/trpc/edge/[trpc]/route.ts +0 -26
  55. package/src/app/[variants]/(main)/(mobile)/me/data/features/Category.tsx +0 -48
  56. package/src/app/[variants]/(main)/(mobile)/me/data/features/Header.tsx +0 -33
  57. package/src/app/[variants]/(main)/(mobile)/me/data/layout.tsx +0 -13
  58. package/src/app/[variants]/(main)/(mobile)/me/data/loading.tsx +0 -5
  59. package/src/app/[variants]/(main)/(mobile)/me/data/page.tsx +0 -29
  60. package/src/app/[variants]/(main)/chat/features/Migration/DBReader.ts +0 -290
  61. package/src/app/[variants]/(main)/chat/features/Migration/ExportConfigButton.tsx +0 -35
  62. package/src/app/[variants]/(main)/chat/features/Migration/Failed.tsx +0 -120
  63. package/src/app/[variants]/(main)/chat/features/Migration/Modal.tsx +0 -81
  64. package/src/app/[variants]/(main)/chat/features/Migration/Start.tsx +0 -108
  65. package/src/app/[variants]/(main)/chat/features/Migration/UpgradeButton.tsx +0 -71
  66. package/src/app/[variants]/(main)/chat/features/Migration/const.ts +0 -15
  67. package/src/app/[variants]/(main)/chat/features/Migration/index.tsx +0 -50
  68. package/src/app/[variants]/loading/Client/Content.tsx +0 -48
  69. package/src/app/[variants]/loading/Client/Error.tsx +0 -27
  70. package/src/app/[variants]/loading/Client/Redirect.tsx +0 -47
  71. package/src/app/[variants]/loading/Client/index.tsx +0 -22
  72. package/src/components/InnerLink.tsx +0 -20
  73. package/src/database/_deprecated/core/__tests__/db-upgrade.test.ts +0 -42
  74. package/src/database/_deprecated/core/__tests__/db.test.ts +0 -79
  75. package/src/database/_deprecated/core/__tests__/model.test.ts +0 -55
  76. package/src/database/_deprecated/core/db.ts +0 -246
  77. package/src/database/_deprecated/core/index.ts +0 -2
  78. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/input.json +0 -55
  79. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/output.json +0 -60
  80. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.test.ts +0 -14
  81. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.ts +0 -22
  82. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/type.ts +0 -105
  83. package/src/database/_deprecated/core/model.ts +0 -218
  84. package/src/database/_deprecated/core/schemas.ts +0 -88
  85. package/src/database/_deprecated/core/types/db.ts +0 -15
  86. package/src/database/_deprecated/models/__DEBUG.ts +0 -124
  87. package/src/database/_deprecated/models/__tests__/file.test.ts +0 -83
  88. package/src/database/_deprecated/models/__tests__/message.test.ts +0 -426
  89. package/src/database/_deprecated/models/__tests__/plugin.test.ts +0 -81
  90. package/src/database/_deprecated/models/__tests__/session.test.ts +0 -253
  91. package/src/database/_deprecated/models/__tests__/sessionGroup.test.ts +0 -220
  92. package/src/database/_deprecated/models/__tests__/topic.test.ts +0 -523
  93. package/src/database/_deprecated/models/__tests__/user.test.ts +0 -82
  94. package/src/database/_deprecated/models/file.ts +0 -51
  95. package/src/database/_deprecated/models/message.ts +0 -277
  96. package/src/database/_deprecated/models/plugin.ts +0 -62
  97. package/src/database/_deprecated/models/session.ts +0 -271
  98. package/src/database/_deprecated/models/sessionGroup.ts +0 -93
  99. package/src/database/_deprecated/models/topic.ts +0 -250
  100. package/src/database/_deprecated/models/user.ts +0 -69
  101. package/src/database/_deprecated/schemas/files.ts +0 -39
  102. package/src/database/_deprecated/schemas/message.ts +0 -50
  103. package/src/database/_deprecated/schemas/plugin.ts +0 -12
  104. package/src/database/_deprecated/schemas/session.ts +0 -54
  105. package/src/database/_deprecated/schemas/sessionGroup.ts +0 -8
  106. package/src/database/_deprecated/schemas/topic.ts +0 -12
  107. package/src/database/_deprecated/schemas/user.ts +0 -40
  108. package/src/features/DataImporter/_deprecated.ts +0 -43
  109. package/src/features/InitClientDB/EnableModal.tsx +0 -118
  110. package/src/features/InitClientDB/ErrorResult.tsx +0 -143
  111. package/src/features/InitClientDB/InitIndicator.tsx +0 -124
  112. package/src/features/InitClientDB/PGliteIcon.tsx +0 -28
  113. package/src/features/InitClientDB/features/DatabaseRepair/Backup.tsx +0 -75
  114. package/src/features/InitClientDB/features/DatabaseRepair/Diagnosis.tsx +0 -98
  115. package/src/features/InitClientDB/features/DatabaseRepair/Repair.tsx +0 -218
  116. package/src/features/InitClientDB/features/DatabaseRepair/index.tsx +0 -91
  117. package/src/features/InitClientDB/index.tsx +0 -37
  118. package/src/libs/trpc/client/edge.ts +0 -26
  119. package/src/libs/trpc/edge/context.ts +0 -71
  120. package/src/libs/trpc/edge/index.ts +0 -45
  121. package/src/libs/trpc/edge/init.ts +0 -26
  122. package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +0 -75
  123. package/src/libs/trpc/edge/middleware/jwtPayload.ts +0 -14
  124. package/src/migrations/FromV0ToV1.ts +0 -10
  125. package/src/migrations/FromV1ToV2/fixtures/input-v1-session.json +0 -191
  126. package/src/migrations/FromV1ToV2/fixtures/output-v2.json +0 -202
  127. package/src/migrations/FromV1ToV2/index.ts +0 -82
  128. package/src/migrations/FromV1ToV2/migrations.test.ts +0 -224
  129. package/src/migrations/FromV1ToV2/types/v1.ts +0 -78
  130. package/src/migrations/FromV1ToV2/types/v2.ts +0 -52
  131. package/src/migrations/FromV2ToV3/fixtures/input-v2-session.json +0 -72
  132. package/src/migrations/FromV2ToV3/fixtures/output-v3-from-v1.json +0 -203
  133. package/src/migrations/FromV2ToV3/fixtures/output-v3.json +0 -74
  134. package/src/migrations/FromV2ToV3/index.ts +0 -30
  135. package/src/migrations/FromV2ToV3/migrations.test.ts +0 -42
  136. package/src/migrations/FromV2ToV3/types/v3.ts +0 -27
  137. package/src/migrations/FromV3ToV4/fixtures/azure-input-v3.json +0 -79
  138. package/src/migrations/FromV3ToV4/fixtures/azure-output-v4.json +0 -75
  139. package/src/migrations/FromV3ToV4/fixtures/ollama-input-v3.json +0 -85
  140. package/src/migrations/FromV3ToV4/fixtures/ollama-output-v4.json +0 -86
  141. package/src/migrations/FromV3ToV4/fixtures/openai-input-v3.json +0 -77
  142. package/src/migrations/FromV3ToV4/fixtures/openai-output-v4.json +0 -77
  143. package/src/migrations/FromV3ToV4/fixtures/openrouter-input-v3.json +0 -82
  144. package/src/migrations/FromV3ToV4/fixtures/openrouter-output-v4.json +0 -85
  145. package/src/migrations/FromV3ToV4/fixtures/output-v4-from-v1.json +0 -203
  146. package/src/migrations/FromV3ToV4/index.ts +0 -102
  147. package/src/migrations/FromV3ToV4/migrations.test.ts +0 -195
  148. package/src/migrations/FromV3ToV4/types/v3.ts +0 -52
  149. package/src/migrations/FromV3ToV4/types/v4.ts +0 -37
  150. package/src/migrations/FromV4ToV5/fixtures/from-v1-to-v5-output.json +0 -245
  151. package/src/migrations/FromV4ToV5/fixtures/function-input-v4.json +0 -96
  152. package/src/migrations/FromV4ToV5/fixtures/function-output-v5.json +0 -120
  153. package/src/migrations/FromV4ToV5/index.ts +0 -58
  154. package/src/migrations/FromV4ToV5/migrations.test.ts +0 -49
  155. package/src/migrations/FromV4ToV5/types/v4.ts +0 -21
  156. package/src/migrations/FromV4ToV5/types/v5.ts +0 -27
  157. package/src/migrations/FromV5ToV6/fixtures/from-v1-to-v6-output.json +0 -247
  158. package/src/migrations/FromV5ToV6/fixtures/session-input-v5.json +0 -81
  159. package/src/migrations/FromV5ToV6/fixtures/session-output-v6.json +0 -85
  160. package/src/migrations/FromV5ToV6/index.ts +0 -61
  161. package/src/migrations/FromV5ToV6/migrations.test.ts +0 -50
  162. package/src/migrations/FromV5ToV6/types/v5.ts +0 -48
  163. package/src/migrations/FromV5ToV6/types/v6.ts +0 -63
  164. package/src/migrations/FromV6ToV7/fixtures/output-v7-from-v1.json +0 -203
  165. package/src/migrations/FromV6ToV7/fixtures/provider-input-v6.json +0 -103
  166. package/src/migrations/FromV6ToV7/fixtures/provider-output-v7.json +0 -118
  167. package/src/migrations/FromV6ToV7/index.ts +0 -101
  168. package/src/migrations/FromV6ToV7/migrations.test.ts +0 -64
  169. package/src/migrations/FromV6ToV7/types/v6.ts +0 -61
  170. package/src/migrations/FromV6ToV7/types/v7.ts +0 -69
  171. package/src/migrations/VersionController.test.ts +0 -88
  172. package/src/migrations/VersionController.ts +0 -67
  173. package/src/migrations/index.ts +0 -61
  174. package/src/server/routers/edge/appStatus.ts +0 -3
  175. package/src/server/routers/edge/index.ts +0 -14
  176. package/src/server/routers/edge/upload.ts +0 -16
  177. package/src/services/aiModel/client.ts +0 -70
  178. package/src/services/aiProvider/client.ts +0 -58
  179. package/src/services/baseClientService/index.ts +0 -9
  180. package/src/services/chatGroup/client.ts +0 -63
  181. package/src/services/export/_deprecated.ts +0 -155
  182. package/src/services/export/client.ts +0 -15
  183. package/src/services/file/_deprecated.test.ts +0 -119
  184. package/src/services/file/_deprecated.ts +0 -80
  185. package/src/services/file/client.test.ts +0 -199
  186. package/src/services/file/client.ts +0 -85
  187. package/src/services/import/_deprecated.ts +0 -115
  188. package/src/services/import/client.test.ts +0 -1015
  189. package/src/services/import/client.ts +0 -64
  190. package/src/services/message/_deprecated.test.ts +0 -398
  191. package/src/services/message/_deprecated.ts +0 -168
  192. package/src/services/message/client.test.ts +0 -410
  193. package/src/services/message/client.ts +0 -192
  194. package/src/services/plugin/_deprecated.test.ts +0 -162
  195. package/src/services/plugin/_deprecated.ts +0 -42
  196. package/src/services/plugin/client.test.ts +0 -177
  197. package/src/services/plugin/client.ts +0 -46
  198. package/src/services/session/_deprecated.test.ts +0 -440
  199. package/src/services/session/_deprecated.ts +0 -190
  200. package/src/services/session/client.test.ts +0 -413
  201. package/src/services/session/client.ts +0 -193
  202. package/src/services/thread/client.ts +0 -51
  203. package/src/services/topic/_deprecated.test.ts +0 -245
  204. package/src/services/topic/_deprecated.ts +0 -75
  205. package/src/services/topic/client.ts +0 -89
  206. package/src/services/topic/pglite.test.ts +0 -212
  207. package/src/services/user/_deprecated.test.ts +0 -101
  208. package/src/services/user/_deprecated.ts +0 -70
  209. package/src/services/user/client.test.ts +0 -111
  210. 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: vi.fn((href) => href),
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: vi.fn((href) => href),
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?session=123');
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', () => {
@@ -1,5 +1,4 @@
1
1
  export { asyncClient } from './async';
2
2
  export * from './desktop';
3
- export { edgeClient } from './edge';
4
3
  export * from './lambda';
5
4
  export * from './tools';
@@ -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 = err.message.includes('aborted') || err.name === 'AbortError' ||
26
- err.cause?.name === 'AbortError' ||
27
- err.message.includes('signal is aborted without reason');
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.error({ errorMessage: err.message, status });
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 = isServerMode ? authedProcedure : passwordProcedure;
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/edge';
8
- import { AuthContext, createContextInner } from '@/libs/trpc/edge/context';
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 = isServerMode ? authedProcedure : passwordProcedure;
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
- req: {
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
- // TODO: password procedure 未来的处理方式可能要思考下
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,10 +1,7 @@
1
1
  import { testService } from '~test-utils';
2
2
 
3
- import { ClientService } from './client';
4
3
  import { ServerService } from './server';
5
4
 
6
5
  describe('aiModelService', () => {
7
6
  testService(ServerService);
8
-
9
- testService(ClientService);
10
7
  });
@@ -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,10 +1,7 @@
1
1
  import { testService } from '~test-utils';
2
2
 
3
- import { ClientService } from './client';
4
3
  import { ServerService } from './server';
5
4
 
6
5
  describe('aiProviderService', () => {
7
6
  testService(ServerService);
8
-
9
- testService(ClientService);
10
7
  });
@@ -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 clientService =
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();
@@ -1,23 +1,13 @@
1
- import { BRANDING_NAME, isDeprecatedEdition, isServerMode } from '@lobechat/const';
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 = isServerMode ? new ServerService() : new ClientService();
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 clientService =
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 clientService =
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 clientService =
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 clientService =
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 clientService =
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
- import { clientDB } from '@/database/client/db';
2
- import { TableViewerRepo } from '@/database/repositories/tableViewer';
3
- import { BaseClientService } from '@/services/baseClientService';
4
-
5
- export class ClientService extends BaseClientService {
6
- private get tableViewerRepo(): TableViewerRepo {
7
- return new TableViewerRepo(clientDB as any, this.userId);
8
- }
9
-
10
- getAllTables = async () => this.tableViewerRepo.getAllTables();
11
-
12
- getTableDetails = async (tableName: string) => this.tableViewerRepo.getTableDetails(tableName);
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 clientService =
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 clientService =
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();