@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
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
interface V6OpenAICompatibleConfig {
|
|
2
|
-
apiKey?: string;
|
|
3
|
-
autoFetchModelLists?: boolean;
|
|
4
|
-
customModelCards?: any[];
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
enabledModels?: string[] | null;
|
|
7
|
-
endpoint?: string;
|
|
8
|
-
fetchOnClient?: boolean;
|
|
9
|
-
latestFetchTime?: number;
|
|
10
|
-
remoteModelCards?: any[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface AzureOpenAIConfig extends Omit<V6OpenAICompatibleConfig, 'endpoint'> {
|
|
14
|
-
apiVersion?: string;
|
|
15
|
-
endpoint?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface AWSBedrockConfig extends Omit<V6OpenAICompatibleConfig, 'apiKey' | 'endpoint'> {
|
|
19
|
-
accessKeyId?: string;
|
|
20
|
-
region?: string;
|
|
21
|
-
secretAccessKey?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface V6ModelProviderConfig {
|
|
25
|
-
anthropic: V6OpenAICompatibleConfig;
|
|
26
|
-
azure: AzureOpenAIConfig;
|
|
27
|
-
bedrock: AWSBedrockConfig;
|
|
28
|
-
deepseek: V6OpenAICompatibleConfig;
|
|
29
|
-
google: V6OpenAICompatibleConfig;
|
|
30
|
-
groq: V6OpenAICompatibleConfig;
|
|
31
|
-
minimax: V6OpenAICompatibleConfig;
|
|
32
|
-
mistral: V6OpenAICompatibleConfig;
|
|
33
|
-
moonshot: V6OpenAICompatibleConfig;
|
|
34
|
-
ollama: V6OpenAICompatibleConfig;
|
|
35
|
-
openai: V6OpenAICompatibleConfig;
|
|
36
|
-
openrouter: V6OpenAICompatibleConfig;
|
|
37
|
-
perplexity: V6OpenAICompatibleConfig;
|
|
38
|
-
togetherai: V6OpenAICompatibleConfig;
|
|
39
|
-
zeroone: V6OpenAICompatibleConfig;
|
|
40
|
-
zhipu: V6OpenAICompatibleConfig;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type V6ProviderKey = keyof V6ModelProviderConfig;
|
|
44
|
-
|
|
45
|
-
export interface V6Settings {
|
|
46
|
-
defaultAgent: any;
|
|
47
|
-
fontSize: number;
|
|
48
|
-
language: string;
|
|
49
|
-
languageModel?: V6ModelProviderConfig;
|
|
50
|
-
neutralColor?: string;
|
|
51
|
-
password: string;
|
|
52
|
-
primaryColor?: string;
|
|
53
|
-
sync: any;
|
|
54
|
-
themeMode: string;
|
|
55
|
-
tool: any;
|
|
56
|
-
tts: any;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface V6ConfigState {
|
|
60
|
-
settings?: V6Settings;
|
|
61
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
interface OpenAICompatibleKeyVault {
|
|
2
|
-
apiKey?: string;
|
|
3
|
-
baseURL?: string;
|
|
4
|
-
}
|
|
5
|
-
interface AzureOpenAIKeyVault {
|
|
6
|
-
apiKey?: string;
|
|
7
|
-
apiVersion?: string;
|
|
8
|
-
endpoint?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface AWSBedrockKeyVault {
|
|
12
|
-
accessKeyId?: string;
|
|
13
|
-
region?: string;
|
|
14
|
-
secretAccessKey?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface V7KeyVaults {
|
|
18
|
-
anthropic: OpenAICompatibleKeyVault;
|
|
19
|
-
azure: AzureOpenAIKeyVault;
|
|
20
|
-
bedrock: AWSBedrockKeyVault;
|
|
21
|
-
deepseek: OpenAICompatibleKeyVault;
|
|
22
|
-
google: OpenAICompatibleKeyVault;
|
|
23
|
-
groq: OpenAICompatibleKeyVault;
|
|
24
|
-
minimax: OpenAICompatibleKeyVault;
|
|
25
|
-
mistral: OpenAICompatibleKeyVault;
|
|
26
|
-
moonshot: OpenAICompatibleKeyVault;
|
|
27
|
-
ollama: OpenAICompatibleKeyVault;
|
|
28
|
-
openai: OpenAICompatibleKeyVault;
|
|
29
|
-
openrouter: OpenAICompatibleKeyVault;
|
|
30
|
-
password: string;
|
|
31
|
-
perplexity: OpenAICompatibleKeyVault;
|
|
32
|
-
togetherai: OpenAICompatibleKeyVault;
|
|
33
|
-
zeroone: OpenAICompatibleKeyVault;
|
|
34
|
-
zhipu: OpenAICompatibleKeyVault;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface V7ProviderConfig {
|
|
38
|
-
autoFetchModelLists?: boolean;
|
|
39
|
-
customModelCards?: any[];
|
|
40
|
-
enabled: boolean;
|
|
41
|
-
enabledModels?: string[] | null;
|
|
42
|
-
fetchOnClient?: boolean;
|
|
43
|
-
latestFetchTime?: number;
|
|
44
|
-
remoteModelCards?: any[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type V7ModelProviderConfig = Record<string, V7ProviderConfig>;
|
|
48
|
-
|
|
49
|
-
export interface V7GeneralSettings {
|
|
50
|
-
fontSize: number;
|
|
51
|
-
language: string;
|
|
52
|
-
neutralColor?: string;
|
|
53
|
-
primaryColor?: string;
|
|
54
|
-
themeMode: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface V7Settings {
|
|
58
|
-
defaultAgent: any;
|
|
59
|
-
general: V7GeneralSettings;
|
|
60
|
-
keyVaults: V7KeyVaults;
|
|
61
|
-
languageModel?: V7ModelProviderConfig;
|
|
62
|
-
sync: any;
|
|
63
|
-
tool: any;
|
|
64
|
-
tts: any;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface V7ConfigState {
|
|
68
|
-
settings?: V7Settings;
|
|
69
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Migration, MigrationData, VersionController } from './VersionController';
|
|
2
|
-
|
|
3
|
-
class TestMigration0 implements Migration {
|
|
4
|
-
version = 0;
|
|
5
|
-
|
|
6
|
-
migrate(data: MigrationData): MigrationData {
|
|
7
|
-
return data;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
class TestMigration1 implements Migration {
|
|
11
|
-
version = 1;
|
|
12
|
-
|
|
13
|
-
migrate(data: MigrationData): MigrationData {
|
|
14
|
-
return {
|
|
15
|
-
state: {
|
|
16
|
-
...data.state,
|
|
17
|
-
value1: data.state.value * 2,
|
|
18
|
-
},
|
|
19
|
-
version: this.version,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class TestMigration2 implements Migration {
|
|
25
|
-
version = 2;
|
|
26
|
-
|
|
27
|
-
migrate(data: MigrationData): MigrationData {
|
|
28
|
-
return {
|
|
29
|
-
state: {
|
|
30
|
-
...data.state,
|
|
31
|
-
value2: data.state.value1 * 2,
|
|
32
|
-
},
|
|
33
|
-
version: this.version,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
describe('VersionController', () => {
|
|
39
|
-
let migrations;
|
|
40
|
-
let versionController: VersionController<any>;
|
|
41
|
-
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
migrations = [TestMigration0, TestMigration1, TestMigration2];
|
|
44
|
-
versionController = new VersionController(migrations);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should instantiate with sorted migrations', () => {
|
|
48
|
-
expect(versionController['migrations'][0].version).toBe(0);
|
|
49
|
-
expect(versionController['migrations'][1].version).toBe(1);
|
|
50
|
-
expect(versionController['migrations'][2].version).toBe(2);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should throw error if data version is undefined', () => {
|
|
54
|
-
const data = {
|
|
55
|
-
state: { value: 10 },
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
expect(() => versionController.migrate(data as any)).toThrow();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should migrate data correctly through multiple versions', () => {
|
|
62
|
-
const data: MigrationData = {
|
|
63
|
-
state: { value: 10 },
|
|
64
|
-
version: 0,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const migratedData = versionController.migrate(data);
|
|
68
|
-
|
|
69
|
-
expect(migratedData).toEqual({
|
|
70
|
-
state: { value: 10, value1: 20, value2: 40 },
|
|
71
|
-
version: 3,
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should migrate data correctly if starting from a specific version', () => {
|
|
76
|
-
const data: MigrationData = {
|
|
77
|
-
state: { value: 10, value1: 20 },
|
|
78
|
-
version: 1,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const migratedData = versionController.migrate(data);
|
|
82
|
-
|
|
83
|
-
expect(migratedData).toEqual({
|
|
84
|
-
state: { value: 10, value1: 20, value2: 40 },
|
|
85
|
-
version: 3,
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { t } from 'i18next';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 迁移接口
|
|
5
|
-
* @template T - 状态类型
|
|
6
|
-
*/
|
|
7
|
-
export interface Migration<T = any> {
|
|
8
|
-
/**
|
|
9
|
-
* 迁移数据
|
|
10
|
-
* @param data - 迁移数据
|
|
11
|
-
* @returns 迁移后的数据
|
|
12
|
-
*/
|
|
13
|
-
migrate(data: MigrationData<T>): MigrationData;
|
|
14
|
-
/**
|
|
15
|
-
* 迁移版本号
|
|
16
|
-
*/
|
|
17
|
-
version: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 迁移数据接口
|
|
22
|
-
* @template T - 状态类型
|
|
23
|
-
*/
|
|
24
|
-
export interface MigrationData<T = any> {
|
|
25
|
-
/**
|
|
26
|
-
* 状态数据
|
|
27
|
-
*/
|
|
28
|
-
state: T;
|
|
29
|
-
/**
|
|
30
|
-
* 迁移版本号
|
|
31
|
-
*/
|
|
32
|
-
version: number;
|
|
33
|
-
}
|
|
34
|
-
export class VersionController<T> {
|
|
35
|
-
private migrations: Migration[];
|
|
36
|
-
targetVersion: number;
|
|
37
|
-
|
|
38
|
-
constructor(migrations: any[], targetVersion: number = migrations.length) {
|
|
39
|
-
this.migrations = migrations
|
|
40
|
-
.map((cls) => {
|
|
41
|
-
return new cls() as Migration;
|
|
42
|
-
})
|
|
43
|
-
.sort((a, b) => a.version - b.version);
|
|
44
|
-
|
|
45
|
-
this.targetVersion = targetVersion;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
migrate(data: MigrationData<T>): MigrationData<T> {
|
|
49
|
-
let nextData = data;
|
|
50
|
-
const targetVersion = this.targetVersion || this.migrations.length;
|
|
51
|
-
if (data.version === undefined)
|
|
52
|
-
throw new Error(t('migrateError.missVersion', { ns: 'migration' }));
|
|
53
|
-
const currentVersion = data.version;
|
|
54
|
-
|
|
55
|
-
for (let i = currentVersion || 0; i < targetVersion; i++) {
|
|
56
|
-
const migration = this.migrations.find((m) => m.version === i);
|
|
57
|
-
if (!migration) throw new Error(t('migrateError.noMigration', { ns: 'migration' }));
|
|
58
|
-
|
|
59
|
-
nextData = migration.migrate(nextData);
|
|
60
|
-
|
|
61
|
-
nextData.version += 1;
|
|
62
|
-
console.debug('迁移器:', migration, '数据:', nextData, '迁移后版本:', nextData.version);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return nextData;
|
|
66
|
-
}
|
|
67
|
-
}
|
package/src/migrations/index.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { MigrationV2ToV3 } from '@/migrations/FromV2ToV3';
|
|
2
|
-
import { VersionController } from '@/migrations/VersionController';
|
|
3
|
-
import { ConfigStateAll } from '@/types/exportConfig';
|
|
4
|
-
|
|
5
|
-
import { MigrationV0ToV1 } from './FromV0ToV1';
|
|
6
|
-
import { MigrationV1ToV2 } from './FromV1ToV2';
|
|
7
|
-
import { MigrationV3ToV4 } from './FromV3ToV4';
|
|
8
|
-
import { MigrationV4ToV5 } from './FromV4ToV5';
|
|
9
|
-
import { MigrationV5ToV6 } from './FromV5ToV6';
|
|
10
|
-
import { MigrationV6ToV7 } from './FromV6ToV7';
|
|
11
|
-
|
|
12
|
-
// Current latest version
|
|
13
|
-
export const CURRENT_CONFIG_VERSION = 7;
|
|
14
|
-
|
|
15
|
-
// Version migrations module
|
|
16
|
-
const ConfigMigrations = [
|
|
17
|
-
/**
|
|
18
|
-
* 2024.05.27
|
|
19
|
-
*
|
|
20
|
-
* apiKey in languageModel change to keyVaults
|
|
21
|
-
*/
|
|
22
|
-
MigrationV6ToV7,
|
|
23
|
-
/**
|
|
24
|
-
* 2024.05.24
|
|
25
|
-
*
|
|
26
|
-
* some config in agentConfig change to chatConfig
|
|
27
|
-
*/ MigrationV5ToV6,
|
|
28
|
-
/**
|
|
29
|
-
* 2024.05.11
|
|
30
|
-
*
|
|
31
|
-
* role=function to role=tool
|
|
32
|
-
*/
|
|
33
|
-
MigrationV4ToV5,
|
|
34
|
-
/**
|
|
35
|
-
* 2024.04.09
|
|
36
|
-
* settings migrate the `languageModel`
|
|
37
|
-
* - from `openAI` to `openai`, `azure`
|
|
38
|
-
* - from customModelName to `enabledModels` and `customModelCards`
|
|
39
|
-
*/
|
|
40
|
-
MigrationV3ToV4,
|
|
41
|
-
/**
|
|
42
|
-
* 2024.01.22
|
|
43
|
-
* from `group = pinned` to `pinned:true`
|
|
44
|
-
*/
|
|
45
|
-
MigrationV2ToV3,
|
|
46
|
-
/**
|
|
47
|
-
* 2023.11.27
|
|
48
|
-
* 从单 key 数据库转换为基于 dexie 的关系型结构
|
|
49
|
-
*/
|
|
50
|
-
MigrationV1ToV2,
|
|
51
|
-
/**
|
|
52
|
-
* 2023.07.11
|
|
53
|
-
* just the first version, Nothing to do
|
|
54
|
-
*/
|
|
55
|
-
MigrationV0ToV1,
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
export const Migration = new VersionController<ConfigStateAll>(
|
|
59
|
-
ConfigMigrations,
|
|
60
|
-
CURRENT_CONFIG_VERSION,
|
|
61
|
-
);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated
|
|
3
|
-
* TODO: it will be remove in V2.0
|
|
4
|
-
*/
|
|
5
|
-
import { publicProcedure, router } from '@/libs/trpc/edge';
|
|
6
|
-
|
|
7
|
-
import { uploadRouter } from './upload';
|
|
8
|
-
|
|
9
|
-
export const edgeRouter = router({
|
|
10
|
-
healthcheck: publicProcedure.query(() => "i'm live!"),
|
|
11
|
-
upload: uploadRouter,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export type EdgeRouter = typeof edgeRouter;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import { passwordProcedure, router } from '@/libs/trpc/edge';
|
|
4
|
-
import { S3 } from '@/server/modules/S3';
|
|
5
|
-
|
|
6
|
-
export const uploadRouter = router({
|
|
7
|
-
createS3PreSignedUrl: passwordProcedure
|
|
8
|
-
.input(z.object({ pathname: z.string() }))
|
|
9
|
-
.mutation(async ({ input }) => {
|
|
10
|
-
const s3 = new S3();
|
|
11
|
-
|
|
12
|
-
return await s3.createPreSignedUrl(input.pathname);
|
|
13
|
-
}),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export type FileRouter = typeof uploadRouter;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { clientDB } from '@/database/client/db';
|
|
2
|
-
import { AiModelModel } from '@/database/models/aiModel';
|
|
3
|
-
import { AiInfraRepos } from '@/database/repositories/aiInfra';
|
|
4
|
-
import { BaseClientService } from '@/services/baseClientService';
|
|
5
|
-
|
|
6
|
-
import { IAiModelService } from './type';
|
|
7
|
-
|
|
8
|
-
export class ClientService extends BaseClientService implements IAiModelService {
|
|
9
|
-
private get aiModel(): AiModelModel {
|
|
10
|
-
return new AiModelModel(clientDB as any, this.userId);
|
|
11
|
-
}
|
|
12
|
-
private get aiInfraRepos(): AiInfraRepos {
|
|
13
|
-
let config = {};
|
|
14
|
-
|
|
15
|
-
if (typeof window !== 'undefined') {
|
|
16
|
-
config = window.global_serverConfigStore.getState().serverConfig.aiProvider || {};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return new AiInfraRepos(clientDB as any, this.userId, config);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
createAiModel: IAiModelService['createAiModel'] = async (params) => {
|
|
23
|
-
const data = await this.aiModel.create(params);
|
|
24
|
-
|
|
25
|
-
return data?.id;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
getAiProviderModelList: IAiModelService['getAiProviderModelList'] = async (id) => {
|
|
29
|
-
return this.aiInfraRepos.getAiProviderModelList(id);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
getAiModelById: IAiModelService['getAiModelById'] = async (id) => {
|
|
33
|
-
return this.aiModel.findById(id);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
toggleModelEnabled: IAiModelService['toggleModelEnabled'] = async (params) => {
|
|
37
|
-
return this.aiModel.toggleModelEnabled(params);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
updateAiModel: IAiModelService['updateAiModel'] = async (id, providerId, value) => {
|
|
41
|
-
return this.aiModel.update(id, providerId, value);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
batchUpdateAiModels: IAiModelService['batchUpdateAiModels'] = async (id, models) => {
|
|
45
|
-
return this.aiModel.batchUpdateAiModels(id, models);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
batchToggleAiModels: IAiModelService['batchToggleAiModels'] = async (id, models, enabled) => {
|
|
49
|
-
return this.aiModel.batchToggleAiModels(id, models, enabled);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
clearRemoteModels: IAiModelService['clearRemoteModels'] = async (providerId) => {
|
|
53
|
-
return this.aiModel.clearRemoteModels(providerId);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
clearModelsByProvider: IAiModelService['clearModelsByProvider'] = async (providerId) => {
|
|
57
|
-
return this.aiModel.clearModelsByProvider(providerId);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
updateAiModelOrder: IAiModelService['updateAiModelOrder'] = async (providerId, items) => {
|
|
61
|
-
return this.aiModel.updateModelsOrder(providerId, items);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
deleteAiModel: IAiModelService['deleteAiModel'] = async (params: {
|
|
65
|
-
id: string;
|
|
66
|
-
providerId: string;
|
|
67
|
-
}) => {
|
|
68
|
-
return this.aiModel.delete(params.id, params.providerId);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { clientDB } from '@/database/client/db';
|
|
2
|
-
import { AiProviderModel } from '@/database/models/aiProvider';
|
|
3
|
-
import { AiInfraRepos } from '@/database/repositories/aiInfra';
|
|
4
|
-
import { BaseClientService } from '@/services/baseClientService';
|
|
5
|
-
|
|
6
|
-
import { IAiProviderService } from './type';
|
|
7
|
-
|
|
8
|
-
export class ClientService extends BaseClientService implements IAiProviderService {
|
|
9
|
-
private get aiProviderModel(): AiProviderModel {
|
|
10
|
-
return new AiProviderModel(clientDB as any, this.userId);
|
|
11
|
-
}
|
|
12
|
-
private get aiInfraRepos(): AiInfraRepos {
|
|
13
|
-
let config = {};
|
|
14
|
-
if (typeof window !== 'undefined') {
|
|
15
|
-
config = window.global_serverConfigStore.getState().serverConfig.aiProvider || {};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return new AiInfraRepos(clientDB as any, this.userId, config);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
createAiProvider: IAiProviderService['createAiProvider'] = async (params) => {
|
|
22
|
-
const data = await this.aiProviderModel.create(params);
|
|
23
|
-
|
|
24
|
-
return data?.id;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
getAiProviderById: IAiProviderService['getAiProviderById'] = async (id) => {
|
|
28
|
-
return this.aiInfraRepos.getAiProviderDetail(id);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
getAiProviderList: IAiProviderService['getAiProviderList'] = async () => {
|
|
32
|
-
return await this.aiInfraRepos.getAiProviderList();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
getAiProviderRuntimeState: IAiProviderService['getAiProviderRuntimeState'] = async () => {
|
|
36
|
-
return await this.aiInfraRepos.getAiProviderRuntimeState();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
toggleProviderEnabled: IAiProviderService['toggleProviderEnabled'] = async (id, enabled) => {
|
|
40
|
-
return this.aiProviderModel.toggleProviderEnabled(id, enabled);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
updateAiProvider: IAiProviderService['updateAiProvider'] = async (id, value) => {
|
|
44
|
-
return this.aiProviderModel.update(id, value);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
updateAiProviderConfig: IAiProviderService['updateAiProviderConfig'] = async (id, value) => {
|
|
48
|
-
return this.aiProviderModel.updateConfig(id, value);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
updateAiProviderOrder: IAiProviderService['updateAiProviderOrder'] = async (items) => {
|
|
52
|
-
return this.aiProviderModel.updateOrder(items);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
deleteAiProvider: IAiProviderService['deleteAiProvider'] = async (id) => {
|
|
56
|
-
return this.aiProviderModel.delete(id);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { clientDB } from '@/database/client/db';
|
|
2
|
-
import { ChatGroupModel } from '@/database/models/chatGroup';
|
|
3
|
-
import {
|
|
4
|
-
ChatGroupAgentItem,
|
|
5
|
-
ChatGroupItem,
|
|
6
|
-
NewChatGroup,
|
|
7
|
-
NewChatGroupAgent,
|
|
8
|
-
} from '@/database/schemas/chatGroup';
|
|
9
|
-
import { BaseClientService } from '@/services/baseClientService';
|
|
10
|
-
|
|
11
|
-
import { IChatGroupService } from './type';
|
|
12
|
-
|
|
13
|
-
export class ClientService extends BaseClientService implements IChatGroupService {
|
|
14
|
-
private get chatGroupModel(): ChatGroupModel {
|
|
15
|
-
return new ChatGroupModel(clientDB as any, this.userId);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async createGroup(params: Omit<NewChatGroup, 'userId'>): Promise<ChatGroupItem> {
|
|
19
|
-
return this.chatGroupModel.create(params);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async updateGroup(id: string, value: Partial<ChatGroupItem>): Promise<ChatGroupItem> {
|
|
23
|
-
return this.chatGroupModel.update(id, value);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async deleteGroup(id: string): Promise<any> {
|
|
27
|
-
return this.chatGroupModel.delete(id);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async deleteAllGroups(): Promise<any> {
|
|
31
|
-
return this.chatGroupModel.deleteAll();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async getGroup(id: string): Promise<ChatGroupItem | undefined> {
|
|
35
|
-
return this.chatGroupModel.findById(id);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async getGroups(): Promise<ChatGroupItem[]> {
|
|
39
|
-
return this.chatGroupModel.queryWithMemberDetails();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async addAgentsToGroup(groupId: string, agentIds: string[]): Promise<ChatGroupAgentItem[]> {
|
|
43
|
-
return this.chatGroupModel.addAgentsToGroup(groupId, agentIds);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async removeAgentsFromGroup(groupId: string, agentIds: string[]): Promise<any> {
|
|
47
|
-
for (const agentId of agentIds) {
|
|
48
|
-
await this.chatGroupModel.removeAgentFromGroup(groupId, agentId);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async updateAgentInGroup(
|
|
53
|
-
groupId: string,
|
|
54
|
-
agentId: string,
|
|
55
|
-
updates: Partial<Pick<NewChatGroupAgent, 'order' | 'role'>>,
|
|
56
|
-
): Promise<ChatGroupAgentItem> {
|
|
57
|
-
return this.chatGroupModel.updateAgentInGroup(groupId, agentId, updates);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async getGroupAgents(groupId: string): Promise<ChatGroupAgentItem[]> {
|
|
61
|
-
return this.chatGroupModel.getGroupAgents(groupId);
|
|
62
|
-
}
|
|
63
|
-
}
|