@lobehub/chat 1.61.4 → 1.61.6
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 +50 -0
- package/changelog/v1.json +18 -0
- package/docs/self-hosting/advanced/auth/next-auth/casdoor.mdx +2 -1
- package/docs/self-hosting/advanced/auth/next-auth/casdoor.zh-CN.mdx +2 -1
- package/locales/ar/auth.json +10 -1
- package/locales/bg-BG/auth.json +10 -1
- package/locales/de-DE/auth.json +10 -1
- package/locales/en-US/auth.json +10 -1
- package/locales/es-ES/auth.json +10 -1
- package/locales/fa-IR/auth.json +10 -1
- package/locales/fr-FR/auth.json +10 -1
- package/locales/it-IT/auth.json +10 -1
- package/locales/ja-JP/auth.json +10 -1
- package/locales/ko-KR/auth.json +10 -1
- package/locales/nl-NL/auth.json +10 -1
- package/locales/pl-PL/auth.json +10 -1
- package/locales/pt-BR/auth.json +10 -1
- package/locales/ru-RU/auth.json +10 -1
- package/locales/tr-TR/auth.json +10 -1
- package/locales/vi-VN/auth.json +10 -1
- package/locales/zh-CN/auth.json +9 -0
- package/locales/zh-TW/auth.json +10 -1
- package/package.json +1 -1
- package/src/app/(backend)/api/webhooks/casdoor/route.ts +5 -7
- package/src/app/(backend)/api/webhooks/casdoor/validateRequest.ts +7 -4
- package/src/app/[variants]/(main)/profile/(home)/Client.tsx +9 -0
- package/src/app/[variants]/(main)/profile/(home)/features/SSOProvidersList/AuthIcons.tsx +37 -0
- package/src/app/[variants]/(main)/profile/(home)/features/SSOProvidersList/index.tsx +93 -0
- package/src/database/server/models/user.ts +24 -1
- package/src/locales/default/auth.ts +10 -0
- package/src/server/globalConfig/index.test.ts +81 -0
- package/src/server/routers/lambda/user.test.ts +305 -0
- package/src/server/routers/lambda/user.ts +32 -2
- package/src/server/services/nextAuthUser/index.ts +2 -2
- package/src/services/user/_deprecated.ts +9 -0
- package/src/services/user/client.ts +9 -0
- package/src/services/user/server.ts +11 -0
- package/src/services/user/type.ts +3 -0
- package/src/types/user/index.ts +5 -0
- package/src/utils/errorResponse.test.ts +37 -1
package/src/types/user/index.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
2
2
|
|
3
3
|
import { AgentRuntimeErrorType } from '@/libs/agent-runtime';
|
4
4
|
import { ChatErrorType } from '@/types/fetch';
|
@@ -32,6 +32,30 @@ describe('createErrorResponse', () => {
|
|
32
32
|
expect(response.status).toBe(403);
|
33
33
|
});
|
34
34
|
|
35
|
+
it('returns a 429 status for InsufficientQuota error type', () => {
|
36
|
+
const errorType = AgentRuntimeErrorType.InsufficientQuota;
|
37
|
+
const response = createErrorResponse(errorType);
|
38
|
+
expect(response.status).toBe(429);
|
39
|
+
});
|
40
|
+
|
41
|
+
it('returns a 429 status for QuotaLimitReached error type', () => {
|
42
|
+
const errorType = AgentRuntimeErrorType.QuotaLimitReached;
|
43
|
+
const response = createErrorResponse(errorType);
|
44
|
+
expect(response.status).toBe(429);
|
45
|
+
});
|
46
|
+
|
47
|
+
it('returns a 400 status for ExceededContextWindow error type', () => {
|
48
|
+
const errorType = AgentRuntimeErrorType.ExceededContextWindow;
|
49
|
+
const response = createErrorResponse(errorType);
|
50
|
+
expect(response.status).toBe(400);
|
51
|
+
});
|
52
|
+
|
53
|
+
it('returns a 400 status for SystemTimeNotMatchError error type', () => {
|
54
|
+
const errorType = ChatErrorType.SystemTimeNotMatchError;
|
55
|
+
const response = createErrorResponse(errorType);
|
56
|
+
expect(response.status).toBe(400);
|
57
|
+
});
|
58
|
+
|
35
59
|
describe('Provider Biz Error', () => {
|
36
60
|
it('returns a 471 status for ProviderBizError error type', () => {
|
37
61
|
const errorType = AgentRuntimeErrorType.ProviderBizError;
|
@@ -44,6 +68,18 @@ describe('createErrorResponse', () => {
|
|
44
68
|
const response = createErrorResponse(errorType);
|
45
69
|
expect(response.status).toBe(470);
|
46
70
|
});
|
71
|
+
|
72
|
+
it('returns a 472 status for OllamaBizError error type', () => {
|
73
|
+
const errorType = AgentRuntimeErrorType.OllamaBizError;
|
74
|
+
const response = createErrorResponse(errorType);
|
75
|
+
expect(response.status).toBe(472);
|
76
|
+
});
|
77
|
+
|
78
|
+
it('returns a 472 status for OllamaServiceUnavailable error type', () => {
|
79
|
+
const errorType = ChatErrorType.OllamaServiceUnavailable;
|
80
|
+
const response = createErrorResponse(errorType);
|
81
|
+
expect(response.status).toBe(472);
|
82
|
+
});
|
47
83
|
});
|
48
84
|
|
49
85
|
// 测试状态码不在200-599范围内的情况
|