@lobehub/chat 1.6.7 → 1.6.8

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 CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.6.8](https://github.com/lobehub/lobe-chat/compare/v1.6.7...v1.6.8)
6
+
7
+ <sup>Released on **2024-07-23**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Move server modules.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Move server modules, closes [#3291](https://github.com/lobehub/lobe-chat/issues/3291) ([c7c9f39](https://github.com/lobehub/lobe-chat/commit/c7c9f39))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 1.6.7](https://github.com/lobehub/lobe-chat/compare/v1.6.6...v1.6.7)
6
31
 
7
32
  <sup>Released on **2024-07-23**</sup>
package/README.md CHANGED
@@ -273,7 +273,7 @@ Our marketplace is not just a showcase platform but also a collaborative space.
273
273
  | [Convert SQL Table Structure to Dao and Mapper](https://chat-preview.lobehub.com/market?agent=my-batis-generator)<br/><sup>By **[MeYoung](https://github.com/MeYoung)** on **2024-07-17**</sup> | Generate entity class and MyBatis Mapper based on a table structure<br/>`sql` `sql` `mybatis` |
274
274
  | [Auto Extraction Data](https://chat-preview.lobehub.com/market?agent=the-20-autoextract)<br/><sup>By **[vkhoilq](https://github.com/vkhoilq)** on **2024-07-17**</sup> | The20 Auto Extraction Data<br/>`the-20` `autoextract` |
275
275
 
276
- > 📊 Total agents: [<kbd>**301**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
276
+ > 📊 Total agents: [<kbd>**302**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
277
277
 
278
278
  <!-- AGENT LIST -->
279
279
 
package/README.zh-CN.md CHANGED
@@ -261,7 +261,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
261
261
  | [SQL 表结构转 Dao 和 Mapper](https://chat-preview.lobehub.com/market?agent=my-batis-generator)<br/><sup>By **[MeYoung](https://github.com/MeYoung)** on **2024-07-17**</sup> | 给与一个表结构,生成表的实体和 MyBatis 的 Mapper<br/>`sql` `sql` `mybatis` |
262
262
  | [自动提取数据](https://chat-preview.lobehub.com/market?agent=the-20-autoextract)<br/><sup>By **[vkhoilq](https://github.com/vkhoilq)** on **2024-07-17**</sup> | The20 自动提取数据<br/>`the-20` `autoextract` |
263
263
 
264
- > 📊 Total agents: [<kbd>**301**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
264
+ > 📊 Total agents: [<kbd>**302**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
265
265
 
266
266
  <!-- AGENT LIST -->
267
267
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.6.7",
3
+ "version": "1.6.8",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
 
4
4
  import { INBOX_SESSION_ID } from '@/const/session';
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
6
- import { KeyVaultsGateKeeper } from '@/server/keyVaultsEncrypt';
6
+ import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt';
7
7
  import { UserPreference } from '@/types/user';
8
8
  import { UserSettings } from '@/types/user/settings';
9
9
 
@@ -3,7 +3,7 @@ import { eq } from 'drizzle-orm';
3
3
  import { DeepPartial } from 'utility-types';
4
4
 
5
5
  import { serverDB } from '@/database/server/core/db';
6
- import { KeyVaultsGateKeeper } from '@/server/keyVaultsEncrypt';
6
+ import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt';
7
7
  import { UserPreference } from '@/types/user';
8
8
  import { UserSettings } from '@/types/user/settings';
9
9
  import { merge } from '@/utils/merge';
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  import { passwordProcedure, router } from '@/libs/trpc';
4
- import { S3 } from '@/server/files/s3';
4
+ import { S3 } from '@/server/modules/S3';
5
5
 
6
6
  export const uploadRouter = router({
7
7
  createS3PreSignedUrl: passwordProcedure
@@ -2,12 +2,21 @@ import { TRPCError } from '@trpc/server';
2
2
  import { z } from 'zod';
3
3
 
4
4
  import { authedProcedure, router } from '@/libs/trpc';
5
- import { S3 } from '@/server/files/s3';
6
- import { DataImporter } from '@/server/modules/DataImporter';
5
+ import { S3 } from '@/server/modules/S3';
6
+ import { DataImporterService } from '@/server/services/dataImporter';
7
7
  import { ImportResults, ImporterEntryData } from '@/types/importer';
8
8
 
9
+ const importProcedure = authedProcedure.use(async (opts) => {
10
+ const { ctx } = opts;
11
+ const dataImporterService = new DataImporterService(ctx.userId);
12
+
13
+ return opts.next({
14
+ ctx: { dataImporterService },
15
+ });
16
+ });
17
+
9
18
  export const importerRouter = router({
10
- importByFile: authedProcedure
19
+ importByFile: importProcedure
11
20
  .input(z.object({ pathname: z.string() }))
12
21
  .mutation(async ({ input, ctx }): Promise<ImportResults> => {
13
22
  let data: ImporterEntryData | undefined;
@@ -27,12 +36,10 @@ export const importerRouter = router({
27
36
  });
28
37
  }
29
38
 
30
- const dataImporter = new DataImporter(ctx.userId);
31
-
32
- return dataImporter.importData(data);
39
+ return ctx.dataImporterService.importData(data);
33
40
  }),
34
41
 
35
- importByPost: authedProcedure
42
+ importByPost: importProcedure
36
43
  .input(
37
44
  z.object({
38
45
  data: z.object({
@@ -45,8 +52,6 @@ export const importerRouter = router({
45
52
  }),
46
53
  )
47
54
  .mutation(async ({ input, ctx }): Promise<ImportResults> => {
48
- const dataImporter = new DataImporter(ctx.userId);
49
-
50
- return dataImporter.importData(input.data);
55
+ return ctx.dataImporterService.importData(input.data);
51
56
  }),
52
57
  });
@@ -16,7 +16,7 @@ import { CURRENT_CONFIG_VERSION } from '@/migrations';
16
16
  import { ImportResult } from '@/services/config';
17
17
  import { ImporterEntryData } from '@/types/importer';
18
18
 
19
- import { DataImporter } from '../index';
19
+ import { DataImporterService } from '../index';
20
20
  import mockImportData from './fixtures/messages.json';
21
21
 
22
22
  let serverDB = await getTestDBInstance();
@@ -28,7 +28,7 @@ vi.mock('@/database/server/core/db', async () => ({
28
28
  }));
29
29
 
30
30
  const userId = 'test-user-id';
31
- let importer: DataImporter;
31
+ let importer: DataImporterService;
32
32
 
33
33
  beforeEach(async () => {
34
34
  await serverDB.delete(users);
@@ -38,7 +38,7 @@ beforeEach(async () => {
38
38
  await tx.insert(users).values({ id: userId });
39
39
  });
40
40
 
41
- importer = new DataImporter(userId);
41
+ importer = new DataImporterService(userId);
42
42
  });
43
43
 
44
44
  describe('DataImporter', () => {
@@ -15,7 +15,7 @@ import {
15
15
  import { ImportResult } from '@/services/config';
16
16
  import { ImporterEntryData } from '@/types/importer';
17
17
 
18
- export class DataImporter {
18
+ export class DataImporterService {
19
19
  private userId: string;
20
20
 
21
21
  /**
package/vitest.config.ts CHANGED
@@ -30,7 +30,7 @@ export default defineConfig({
30
30
  '**/dist/**',
31
31
  '**/build/**',
32
32
  'src/database/server/**/**',
33
- 'src/server/modules/**/**',
33
+ 'src/server/services/**/**',
34
34
  ],
35
35
  globals: true,
36
36
  server: {
File without changes