@lobehub/chat 1.36.31 → 1.36.32

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 (42) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/changelog/v1.json +9 -0
  3. package/docs/self-hosting/environment-variables/model-provider.mdx +7 -0
  4. package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +7 -0
  5. package/docs/self-hosting/server-database/dokploy.zh-CN.mdx +12 -12
  6. package/package.json +1 -1
  7. package/src/database/repositories/dataImporter/__tests__/index.test.ts +11 -18
  8. package/src/database/repositories/dataImporter/index.ts +31 -46
  9. package/src/database/server/models/__tests__/_test_template.ts +1 -1
  10. package/src/database/server/models/__tests__/agent.test.ts +1 -1
  11. package/src/database/server/models/__tests__/asyncTask.test.ts +1 -1
  12. package/src/database/server/models/__tests__/chunk.test.ts +1 -1
  13. package/src/database/server/models/__tests__/file.test.ts +1 -1
  14. package/src/database/server/models/__tests__/knowledgeBase.test.ts +1 -2
  15. package/src/database/server/models/__tests__/message.test.ts +35 -72
  16. package/src/database/server/models/__tests__/nextauth.test.ts +1 -1
  17. package/src/database/server/models/__tests__/session.test.ts +1 -1
  18. package/src/database/server/models/__tests__/sessionGroup.test.ts +1 -2
  19. package/src/database/server/models/__tests__/topic.test.ts +1 -1
  20. package/src/database/server/models/__tests__/user.test.ts +1 -1
  21. package/src/database/server/models/_template.ts +2 -2
  22. package/src/database/server/models/agent.ts +17 -25
  23. package/src/database/server/models/asyncTask.ts +2 -2
  24. package/src/database/server/models/chunk.ts +14 -14
  25. package/src/database/server/models/embedding.ts +1 -1
  26. package/src/database/server/models/file.ts +8 -10
  27. package/src/database/server/models/knowledgeBase.ts +4 -6
  28. package/src/database/server/models/message.ts +54 -65
  29. package/src/database/server/models/plugin.ts +2 -2
  30. package/src/database/server/models/ragEval/dataset.ts +2 -2
  31. package/src/database/server/models/ragEval/datasetRecord.ts +3 -8
  32. package/src/database/server/models/ragEval/evaluation.ts +3 -2
  33. package/src/database/server/models/ragEval/evaluationRecord.ts +2 -2
  34. package/src/database/server/models/session.ts +38 -35
  35. package/src/database/server/models/sessionGroup.ts +4 -4
  36. package/src/database/server/models/thread.ts +2 -2
  37. package/src/database/server/models/topic.ts +48 -53
  38. package/src/database/server/models/user.ts +12 -12
  39. package/src/libs/agent-runtime/utils/streams/azureOpenai.test.ts +0 -1
  40. package/src/libs/next-auth/adapter/index.ts +1 -1
  41. package/src/server/routers/lambda/chunk.ts +2 -2
  42. package/vercel.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.36.32](https://github.com/lobehub/lobe-chat/compare/v1.36.31...v1.36.32)
6
+
7
+ <sup>Released on **2024-12-17**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor the drizzle code style.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Refactor the drizzle code style, closes [#5058](https://github.com/lobehub/lobe-chat/issues/5058) ([4057ad3](https://github.com/lobehub/lobe-chat/commit/4057ad3))
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.36.31](https://github.com/lobehub/lobe-chat/compare/v1.36.30...v1.36.31)
6
31
 
7
32
  <sup>Released on **2024-12-17**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Refactor the drizzle code style."
6
+ ]
7
+ },
8
+ "date": "2024-12-17",
9
+ "version": "1.36.32"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "improvements": [
@@ -288,6 +288,13 @@ If you need to use Azure OpenAI to provide model services, you can refer to the
288
288
  - Default: `https://api.Perplexity.ai`
289
289
  - Example: `https://my-Perplexity-proxy.com`
290
290
 
291
+ ### `PERPLEXITY_MODEL_LIST`
292
+
293
+ - Type: Optional
294
+ - Description: Used to control the model list, use `+` to add a model, use `-` to hide a model, use `model_name=display_name` to customize the display name of a model, separated by commas. Definition syntax rules see
295
+ - Default: `-`
296
+ - Example: `-all,+llama-3.1-sonar-small-128k-online,+llama-3.1-sonar-small-128k-chat`
297
+
291
298
  ## Minimax AI
292
299
 
293
300
  ### `MINIMAX_API_KEY`
@@ -279,6 +279,13 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,
279
279
  - 默认值:-
280
280
  - 示例:`pplx-xxxxxx...xxxxxx`
281
281
 
282
+ ### `PERPLEXITY_MODEL_LIST`
283
+
284
+ - 类型:可选
285
+ - 描述:用于指定自定义 Perplexity 语言模型。模型定义语法规则见 [模型列表][model-list]
286
+ - 默认值:-
287
+ - 示例: `-all,+llama-3.1-sonar-small-128k-online,+llama-3.1-sonar-small-128k-chat`
288
+
282
289
  ### `PERPLEXITY_PROXY_URL`
283
290
 
284
291
  - 类型:可选
@@ -1,15 +1,15 @@
1
- ---
2
- title: 在 Dokploy 上部署 LobeChat 的服务端数据库版本
3
- description: 本文详细介绍如何在 Dokploy 中部署服务端数据库版 LobeChat,包括数据库配置、身份验证服务配置的设置步骤。
4
- tags:
5
- - 服务端数据库
6
- - Postgres
7
- - Clerk
8
- - Dokploy部署
9
- - 数据库配置
10
- - 身份验证服务
11
- - 环境变量配置
12
- ---
1
+ ---
2
+ title: 在 Dokploy 上部署 LobeChat 的服务端数据库版本
3
+ description: 本文详细介绍如何在 Dokploy 中部署服务端数据库版 LobeChat,包括数据库配置、身份验证服务配置的设置步骤。
4
+ tags:
5
+ - 服务端数据库
6
+ - Postgres
7
+ - Clerk
8
+ - Dokploy部署
9
+ - 数据库配置
10
+ - 身份验证服务
11
+ - 环境变量配置
12
+ ---
13
13
 
14
14
  # 在 Dokploy 上部署服务端数据库版
15
15
  本文将详细介绍如何在 Dokploy 中部署服务端数据库版 LobeChat。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.36.31",
3
+ "version": "1.36.32",
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",
@@ -1,8 +1,7 @@
1
1
  // @vitest-environment node
2
- import { eq, inArray } from 'drizzle-orm';
2
+ import { eq, inArray } from 'drizzle-orm/expressions';
3
3
  import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
- import { getTestDBInstance } from '@/database/server/core/dbForTest';
6
5
  import {
7
6
  agents,
8
7
  agentsToSessions,
@@ -12,6 +11,7 @@ import {
12
11
  topics,
13
12
  users,
14
13
  } from '@/database/schemas';
14
+ import { getTestDBInstance } from '@/database/server/core/dbForTest';
15
15
  import { CURRENT_CONFIG_VERSION } from '@/migrations';
16
16
  import { ImporterEntryData } from '@/types/importer';
17
17
 
@@ -60,8 +60,7 @@ describe('DataImporter', () => {
60
60
  it('should skip existing session groups and return correct result', async () => {
61
61
  await serverDB
62
62
  .insert(sessionGroups)
63
- .values({ clientId: 'group1', name: 'Existing Group', userId })
64
- .execute();
63
+ .values({ clientId: 'group1', name: 'Existing Group', userId });
65
64
 
66
65
  const data: ImporterEntryData = {
67
66
  version: CURRENT_CONFIG_VERSION,
@@ -141,7 +140,7 @@ describe('DataImporter', () => {
141
140
  });
142
141
 
143
142
  it('should skip existing sessions and return correct result', async () => {
144
- await serverDB.insert(sessions).values({ clientId: 'session1', userId }).execute();
143
+ await serverDB.insert(sessions).values({ clientId: 'session1', userId });
145
144
 
146
145
  const data: ImporterEntryData = {
147
146
  version: CURRENT_CONFIG_VERSION,
@@ -477,10 +476,7 @@ describe('DataImporter', () => {
477
476
  });
478
477
 
479
478
  it('should skip existing topics and return correct result', async () => {
480
- await serverDB
481
- .insert(topics)
482
- .values({ clientId: 'topic1', title: 'Existing Topic', userId })
483
- .execute();
479
+ await serverDB.insert(topics).values({ clientId: 'topic1', title: 'Existing Topic', userId });
484
480
 
485
481
  const data: ImporterEntryData = {
486
482
  version: CURRENT_CONFIG_VERSION,
@@ -616,15 +612,12 @@ describe('DataImporter', () => {
616
612
  });
617
613
 
618
614
  it('should skip existing messages and return correct result', async () => {
619
- await serverDB
620
- .insert(messages)
621
- .values({
622
- clientId: 'msg1',
623
- content: 'Existing Message',
624
- role: 'user',
625
- userId,
626
- })
627
- .execute();
615
+ await serverDB.insert(messages).values({
616
+ clientId: 'msg1',
617
+ content: 'Existing Message',
618
+ role: 'user',
619
+ userId,
620
+ });
628
621
 
629
622
  const data: ImporterEntryData = {
630
623
  version: CURRENT_CONFIG_VERSION,
@@ -1,5 +1,5 @@
1
- import { eq, inArray, sql } from 'drizzle-orm';
2
- import { and } from 'drizzle-orm/expressions';
1
+ import { sql } from 'drizzle-orm';
2
+ import { and, eq, inArray } from 'drizzle-orm/expressions';
3
3
 
4
4
  import {
5
5
  agents,
@@ -71,8 +71,7 @@ export class DataImporterRepos {
71
71
  set: { updatedAt: new Date() },
72
72
  target: [sessionGroups.clientId, sessionGroups.userId],
73
73
  })
74
- .returning({ clientId: sessionGroups.clientId, id: sessionGroups.id })
75
- .execute();
74
+ .returning({ clientId: sessionGroups.clientId, id: sessionGroups.id });
76
75
 
77
76
  sessionGroupResult.added = mapArray.length - query.length;
78
77
 
@@ -109,8 +108,7 @@ export class DataImporterRepos {
109
108
  set: { updatedAt: new Date() },
110
109
  target: [sessions.clientId, sessions.userId],
111
110
  })
112
- .returning({ clientId: sessions.clientId, id: sessions.id })
113
- .execute();
111
+ .returning({ clientId: sessions.clientId, id: sessions.id });
114
112
 
115
113
  // get the session client-server id map
116
114
  sessionIdMap = Object.fromEntries(mapArray.map(({ clientId, id }) => [clientId, id]));
@@ -133,18 +131,14 @@ export class DataImporterRepos {
133
131
  userId: this.userId,
134
132
  })),
135
133
  )
136
- .returning({ id: agents.id })
137
- .execute();
134
+ .returning({ id: agents.id });
138
135
 
139
- await trx
140
- .insert(agentsToSessions)
141
- .values(
142
- shouldInsertSessionAgents.map(({ id }, index) => ({
143
- agentId: agentMapArray[index].id,
144
- sessionId: sessionIdMap[id],
145
- })),
146
- )
147
- .execute();
136
+ await trx.insert(agentsToSessions).values(
137
+ shouldInsertSessionAgents.map(({ id }, index) => ({
138
+ agentId: agentMapArray[index].id,
139
+ sessionId: sessionIdMap[id],
140
+ })),
141
+ );
148
142
  }
149
143
  }
150
144
 
@@ -178,8 +172,7 @@ export class DataImporterRepos {
178
172
  set: { updatedAt: new Date() },
179
173
  target: [topics.clientId, topics.userId],
180
174
  })
181
- .returning({ clientId: topics.clientId, id: topics.id })
182
- .execute();
175
+ .returning({ clientId: topics.clientId, id: topics.id });
183
176
 
184
177
  topicIdMap = Object.fromEntries(mapArray.map(({ clientId, id }) => [clientId, id]));
185
178
 
@@ -230,7 +223,7 @@ export class DataImporterRepos {
230
223
 
231
224
  for (let i = 0; i < inertValues.length; i += BATCH_SIZE) {
232
225
  const batch = inertValues.slice(i, i + BATCH_SIZE);
233
- await trx.insert(messages).values(batch).execute();
226
+ await trx.insert(messages).values(batch);
234
227
  }
235
228
 
236
229
  console.timeEnd('insert messages');
@@ -265,7 +258,7 @@ export class DataImporterRepos {
265
258
  .filter(Boolean);
266
259
 
267
260
  if (parentIdUpdates.length > 0) {
268
- const updateQuery = trx
261
+ await trx
269
262
  .update(messages)
270
263
  .set({
271
264
  parentId: sql`CASE ${sql.join(parentIdUpdates)} END`,
@@ -281,42 +274,34 @@ export class DataImporterRepos {
281
274
  // const SQL = updateQuery.toSQL();
282
275
  // console.log('sql:', SQL.sql);
283
276
  // console.log('params:', SQL.params);
284
-
285
- await updateQuery.execute();
286
277
  }
287
278
  console.timeEnd('execute updates parentId');
288
279
 
289
280
  // 4. insert message plugins
290
281
  const pluginInserts = shouldInsertMessages.filter((msg) => msg.plugin);
291
282
  if (pluginInserts.length > 0) {
292
- await trx
293
- .insert(messagePlugins)
294
- .values(
295
- pluginInserts.map((msg) => ({
296
- apiName: msg.plugin?.apiName,
297
- arguments: msg.plugin?.arguments,
298
- id: messageIdMap[msg.id],
299
- identifier: msg.plugin?.identifier,
300
- state: msg.pluginState,
301
- toolCallId: msg.tool_call_id,
302
- type: msg.plugin?.type,
303
- })),
304
- )
305
- .execute();
283
+ await trx.insert(messagePlugins).values(
284
+ pluginInserts.map((msg) => ({
285
+ apiName: msg.plugin?.apiName,
286
+ arguments: msg.plugin?.arguments,
287
+ id: messageIdMap[msg.id],
288
+ identifier: msg.plugin?.identifier,
289
+ state: msg.pluginState,
290
+ toolCallId: msg.tool_call_id,
291
+ type: msg.plugin?.type,
292
+ })),
293
+ );
306
294
  }
307
295
 
308
296
  // 5. insert message translate
309
297
  const translateInserts = shouldInsertMessages.filter((msg) => msg.extra?.translate);
310
298
  if (translateInserts.length > 0) {
311
- await trx
312
- .insert(messageTranslates)
313
- .values(
314
- translateInserts.map((msg) => ({
315
- id: messageIdMap[msg.id],
316
- ...msg.extra?.translate,
317
- })),
318
- )
319
- .execute();
299
+ await trx.insert(messageTranslates).values(
300
+ translateInserts.map((msg) => ({
301
+ id: messageIdMap[msg.id],
302
+ ...msg.extra?.translate,
303
+ })),
304
+ );
320
305
  }
321
306
 
322
307
  // TODO: 未来需要处理 TTS 和图片的插入 (目前存在 file 的部分,不方便处理)
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
2
+ import { eq } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,5 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq, inArray } from 'drizzle-orm';
2
+ import { eq, inArray } from 'drizzle-orm/expressions';
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,6 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
3
- import { and, desc } from 'drizzle-orm/expressions';
2
+ import { and, eq } from 'drizzle-orm/expressions';
4
3
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
5
4
 
6
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -1,4 +1,4 @@
1
- import { eq } from 'drizzle-orm';
1
+ import { eq } from 'drizzle-orm/expressions';
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
 
4
4
  import { getTestDBInstance } from '@/database/server/core/dbForTest';
@@ -514,11 +514,7 @@ describe('MessageModel', () => {
514
514
  await messageModel.create({ role: 'user', content: 'new message', sessionId: '1' });
515
515
 
516
516
  // 断言结果
517
- const result = await serverDB
518
- .select()
519
- .from(messages)
520
- .where(eq(messages.userId, userId))
521
- .execute();
517
+ const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
522
518
  expect(result).toHaveLength(1);
523
519
  expect(result[0].content).toBe('new message');
524
520
  });
@@ -549,11 +545,7 @@ describe('MessageModel', () => {
549
545
  });
550
546
 
551
547
  // 断言结果
552
- const result = await serverDB
553
- .select()
554
- .from(messages)
555
- .where(eq(messages.userId, userId))
556
- .execute();
548
+ const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
557
549
  expect(result[0].id).toBeDefined();
558
550
  expect(result[0].id).toHaveLength(18);
559
551
  });
@@ -582,8 +574,7 @@ describe('MessageModel', () => {
582
574
  const pluginResult = await serverDB
583
575
  .select()
584
576
  .from(messagePlugins)
585
- .where(eq(messagePlugins.id, result.id))
586
- .execute();
577
+ .where(eq(messagePlugins.id, result.id));
587
578
  expect(pluginResult).toHaveLength(1);
588
579
  expect(pluginResult[0].identifier).toBe('plugin1');
589
580
  });
@@ -650,8 +641,7 @@ describe('MessageModel', () => {
650
641
  const pluginResult = await serverDB
651
642
  .select()
652
643
  .from(messagePlugins)
653
- .where(eq(messagePlugins.id, result.id))
654
- .execute();
644
+ .where(eq(messagePlugins.id, result.id));
655
645
  expect(pluginResult).toHaveLength(1);
656
646
  expect(pluginResult[0].identifier).toBe('lobe-web-browsing');
657
647
  expect(pluginResult[0].state!).toMatchObject(state);
@@ -670,11 +660,7 @@ describe('MessageModel', () => {
670
660
  await messageModel.batchCreate(newMessages);
671
661
 
672
662
  // 断言结果
673
- const result = await serverDB
674
- .select()
675
- .from(messages)
676
- .where(eq(messages.userId, userId))
677
- .execute();
663
+ const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
678
664
  expect(result).toHaveLength(2);
679
665
  expect(result[0].content).toBe('message 1');
680
666
  expect(result[1].content).toBe('message 2');
@@ -692,7 +678,7 @@ describe('MessageModel', () => {
692
678
  await messageModel.update('1', { content: 'updated message' });
693
679
 
694
680
  // 断言结果
695
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
681
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
696
682
  expect(result[0].content).toBe('updated message');
697
683
  });
698
684
 
@@ -706,7 +692,7 @@ describe('MessageModel', () => {
706
692
  await messageModel.update('1', { content: 'updated message' });
707
693
 
708
694
  // 断言结果
709
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
695
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
710
696
  expect(result[0].content).toBe('message 1');
711
697
  });
712
698
 
@@ -745,7 +731,7 @@ describe('MessageModel', () => {
745
731
  });
746
732
 
747
733
  // 断言结果
748
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
734
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
749
735
  expect(result[0].tools[0].arguments).toBe(
750
736
  '{"query":"2024 杭州暴雨","searchEngines":["duckduckgo","google","brave"]}',
751
737
  );
@@ -763,7 +749,7 @@ describe('MessageModel', () => {
763
749
  await messageModel.deleteMessage('1');
764
750
 
765
751
  // 断言结果
766
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
752
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
767
753
  expect(result).toHaveLength(0);
768
754
  });
769
755
 
@@ -783,14 +769,13 @@ describe('MessageModel', () => {
783
769
  await messageModel.deleteMessage('1');
784
770
 
785
771
  // 断言结果
786
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
772
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
787
773
  expect(result).toHaveLength(0);
788
774
 
789
775
  const result2 = await serverDB
790
776
  .select()
791
777
  .from(messagePlugins)
792
- .where(eq(messagePlugins.id, '2'))
793
- .execute();
778
+ .where(eq(messagePlugins.id, '2'));
794
779
 
795
780
  expect(result2).toHaveLength(0);
796
781
  });
@@ -805,7 +790,7 @@ describe('MessageModel', () => {
805
790
  await messageModel.deleteMessage('1');
806
791
 
807
792
  // 断言结果
808
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
793
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
809
794
  expect(result).toHaveLength(1);
810
795
  });
811
796
  });
@@ -822,9 +807,9 @@ describe('MessageModel', () => {
822
807
  await messageModel.deleteMessages(['1', '2']);
823
808
 
824
809
  // 断言结果
825
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
810
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
826
811
  expect(result).toHaveLength(0);
827
- const result2 = await serverDB.select().from(messages).where(eq(messages.id, '2')).execute();
812
+ const result2 = await serverDB.select().from(messages).where(eq(messages.id, '2'));
828
813
  expect(result2).toHaveLength(0);
829
814
  });
830
815
 
@@ -839,7 +824,7 @@ describe('MessageModel', () => {
839
824
  await messageModel.deleteMessages(['1', '2']);
840
825
 
841
826
  // 断言结果
842
- const result = await serverDB.select().from(messages).where(eq(messages.id, '1')).execute();
827
+ const result = await serverDB.select().from(messages).where(eq(messages.id, '1'));
843
828
  expect(result).toHaveLength(1);
844
829
  });
845
830
  });
@@ -857,18 +842,12 @@ describe('MessageModel', () => {
857
842
  await messageModel.deleteAllMessages();
858
843
 
859
844
  // 断言结果
860
- const result = await serverDB
861
- .select()
862
- .from(messages)
863
- .where(eq(messages.userId, userId))
864
- .execute();
845
+ const result = await serverDB.select().from(messages).where(eq(messages.userId, userId));
846
+
865
847
  expect(result).toHaveLength(0);
866
848
 
867
- const otherResult = await serverDB
868
- .select()
869
- .from(messages)
870
- .where(eq(messages.userId, '456'))
871
- .execute();
849
+ const otherResult = await serverDB.select().from(messages).where(eq(messages.userId, '456'));
850
+
872
851
  expect(otherResult).toHaveLength(1);
873
852
  });
874
853
  });
@@ -887,11 +866,8 @@ describe('MessageModel', () => {
887
866
  await messageModel.updatePluginState('1', { key2: 'value2' });
888
867
 
889
868
  // 断言结果
890
- const result = await serverDB
891
- .select()
892
- .from(messagePlugins)
893
- .where(eq(messagePlugins.id, '1'))
894
- .execute();
869
+ const result = await serverDB.select().from(messagePlugins).where(eq(messagePlugins.id, '1'));
870
+
895
871
  expect(result[0].state).toEqual({ key1: 'value1', key2: 'value2' });
896
872
  });
897
873
 
@@ -916,11 +892,8 @@ describe('MessageModel', () => {
916
892
  await messageModel.updateMessagePlugin('1', { identifier: 'plugin2' });
917
893
 
918
894
  // 断言结果
919
- const result = await serverDB
920
- .select()
921
- .from(messagePlugins)
922
- .where(eq(messagePlugins.id, '1'))
923
- .execute();
895
+ const result = await serverDB.select().from(messagePlugins).where(eq(messagePlugins.id, '1'));
896
+
924
897
  expect(result[0].identifier).toEqual('plugin2');
925
898
  });
926
899
 
@@ -950,8 +923,8 @@ describe('MessageModel', () => {
950
923
  const result = await serverDB
951
924
  .select()
952
925
  .from(messageTranslates)
953
- .where(eq(messageTranslates.id, '1'))
954
- .execute();
926
+ .where(eq(messageTranslates.id, '1'));
927
+
955
928
  expect(result).toHaveLength(1);
956
929
  expect(result[0].content).toBe('translated message 1');
957
930
  });
@@ -974,8 +947,8 @@ describe('MessageModel', () => {
974
947
  const result = await serverDB
975
948
  .select()
976
949
  .from(messageTranslates)
977
- .where(eq(messageTranslates.id, '1'))
978
- .execute();
950
+ .where(eq(messageTranslates.id, '1'));
951
+
979
952
  expect(result[0].content).toBe('updated translated message 1');
980
953
  });
981
954
  });
@@ -991,11 +964,8 @@ describe('MessageModel', () => {
991
964
  await messageModel.updateTTS('1', { contentMd5: 'md5', file: 'f1', voice: 'voice1' });
992
965
 
993
966
  // 断言结果
994
- const result = await serverDB
995
- .select()
996
- .from(messageTTS)
997
- .where(eq(messageTTS.id, '1'))
998
- .execute();
967
+ const result = await serverDB.select().from(messageTTS).where(eq(messageTTS.id, '1'));
968
+
999
969
  expect(result).toHaveLength(1);
1000
970
  expect(result[0].voice).toBe('voice1');
1001
971
  });
@@ -1015,11 +985,8 @@ describe('MessageModel', () => {
1015
985
  await messageModel.updateTTS('1', { voice: 'updated voice1' });
1016
986
 
1017
987
  // 断言结果
1018
- const result = await serverDB
1019
- .select()
1020
- .from(messageTTS)
1021
- .where(eq(messageTTS.id, '1'))
1022
- .execute();
988
+ const result = await serverDB.select().from(messageTTS).where(eq(messageTTS.id, '1'));
989
+
1023
990
  expect(result[0].voice).toBe('updated voice1');
1024
991
  });
1025
992
  });
@@ -1037,8 +1004,8 @@ describe('MessageModel', () => {
1037
1004
  const result = await serverDB
1038
1005
  .select()
1039
1006
  .from(messageTranslates)
1040
- .where(eq(messageTranslates.id, '1'))
1041
- .execute();
1007
+ .where(eq(messageTranslates.id, '1'));
1008
+
1042
1009
  expect(result).toHaveLength(0);
1043
1010
  });
1044
1011
  });
@@ -1053,11 +1020,7 @@ describe('MessageModel', () => {
1053
1020
  await messageModel.deleteMessageTTS('1');
1054
1021
 
1055
1022
  // 断言结果
1056
- const result = await serverDB
1057
- .select()
1058
- .from(messageTTS)
1059
- .where(eq(messageTTS.id, '1'))
1060
- .execute();
1023
+ const result = await serverDB.select().from(messageTTS).where(eq(messageTTS.id, '1'));
1061
1024
  expect(result).toHaveLength(0);
1062
1025
  });
1063
1026
  });
@@ -5,7 +5,7 @@ import type {
5
5
  AdapterUser,
6
6
  VerificationToken,
7
7
  } from '@auth/core/adapters';
8
- import { eq } from 'drizzle-orm';
8
+ import { eq } from 'drizzle-orm/expressions';
9
9
  import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
10
10
 
11
11
  import {
@@ -1,4 +1,4 @@
1
- import { and, eq, inArray } from 'drizzle-orm';
1
+ import { and, eq, inArray } from 'drizzle-orm/expressions';
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
3
 
4
4
  import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
@@ -1,6 +1,5 @@
1
1
  // @vitest-environment node
2
- import { eq } from 'drizzle-orm';
3
- import { desc } from 'drizzle-orm/expressions';
2
+ import { eq } from 'drizzle-orm/expressions';
4
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
4
 
6
5
  import { getTestDBInstance } from '@/database/server/core/dbForTest';