@lobehub/chat 1.114.3 → 1.114.5
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/.github/scripts/docker-pr-comment.js +89 -0
- package/.github/workflows/docker-database.yml +21 -0
- package/.github/workflows/release.yml +7 -5
- package/.github/workflows/test.yml +9 -7
- package/CHANGELOG.md +50 -0
- package/Dockerfile.database +1 -1
- package/changelog/v1.json +18 -0
- package/codecov.yml +30 -2
- package/docs/development/database-schema.dbml +14 -0
- package/drizzle.config.ts +2 -2
- package/package.json +5 -5
- package/packages/const/src/index.ts +2 -0
- package/{src/utils → packages/const/src/settings}/genUserLLMConfig.test.ts +1 -1
- package/{src/utils → packages/const/src/settings}/genUserLLMConfig.ts +1 -1
- package/packages/const/src/settings/index.ts +0 -2
- package/packages/const/src/settings/llm.ts +1 -1
- package/{src → packages}/database/migrations/0028_oauth_handoffs.sql +1 -1
- package/{src → packages}/database/migrations/0029_add_apikey_manage.sql +1 -1
- package/packages/database/package.json +24 -0
- package/{src/database → packages/database/src}/client/db.ts +2 -2
- package/{src/database → packages/database/src}/core/db-adaptor.ts +3 -3
- package/{src/database → packages/database/src}/core/dbForTest.ts +1 -1
- package/{src/database → packages/database/src}/core/electron.ts +3 -3
- package/{src/database/client → packages/database/src/core}/migrations.json +12 -2
- package/{src/database → packages/database/src}/core/web-server.ts +2 -3
- package/{src/database → packages/database/src}/models/__tests__/_test_template.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/_util.ts +3 -3
- package/{src/database → packages/database/src}/models/__tests__/agent.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/aiModel.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/aiProvider.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/asyncTask.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/chunk.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/file.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/generation.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/generationBatch.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/generationTopic.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/knowledgeBase.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/message.test.ts +2 -2
- package/{src/database → packages/database/src}/models/__tests__/plugin.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/session.test.ts +2 -2
- package/{src/database → packages/database/src}/models/__tests__/sessionGroup.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/topic.test.ts +1 -2
- package/{src/database → packages/database/src}/models/_template.ts +1 -2
- package/{src/database → packages/database/src}/models/agent.ts +2 -2
- package/{src/database → packages/database/src}/models/aiModel.ts +1 -1
- package/{src/database → packages/database/src}/models/aiProvider.ts +1 -1
- package/{src/database → packages/database/src}/models/apiKey.ts +1 -1
- package/{src/database → packages/database/src}/models/asyncTask.ts +1 -1
- package/{src/database → packages/database/src}/models/chunk.ts +1 -1
- package/{src/database → packages/database/src}/models/document.ts +1 -1
- package/{src/database → packages/database/src}/models/drizzleMigration.ts +1 -1
- package/{src/database → packages/database/src}/models/embedding.ts +1 -1
- package/{src/database → packages/database/src}/models/file.ts +1 -1
- package/{src/database → packages/database/src}/models/generation.ts +1 -1
- package/{src/database → packages/database/src}/models/generationBatch.ts +1 -1
- package/{src/database → packages/database/src}/models/generationTopic.ts +1 -1
- package/{src/database → packages/database/src}/models/knowledgeBase.ts +1 -1
- package/{src/database → packages/database/src}/models/message.ts +3 -3
- package/{src/database → packages/database/src}/models/oauthHandoff.ts +1 -1
- package/{src/database → packages/database/src}/models/plugin.ts +1 -1
- package/{src/database → packages/database/src}/models/session.ts +3 -3
- package/{src/database → packages/database/src}/models/sessionGroup.ts +2 -2
- package/{src/database → packages/database/src}/models/thread.ts +1 -1
- package/{src/database → packages/database/src}/models/topic.ts +3 -3
- package/{src/database → packages/database/src}/models/user.ts +1 -1
- package/{src/database → packages/database/src}/repositories/aiInfra/index.ts +4 -3
- package/{src/database → packages/database/src}/repositories/dataExporter/index.ts +2 -2
- package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/index.test.ts +2 -2
- package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/index.ts +6 -5
- package/{src/database → packages/database/src}/repositories/dataImporter/index.ts +2 -2
- package/{src/database → packages/database/src}/repositories/tableViewer/index.test.ts +1 -1
- package/{src/database → packages/database/src}/repositories/tableViewer/index.ts +2 -1
- package/{src/database → packages/database/src}/schemas/agent.ts +1 -1
- package/{src/database → packages/database/src}/schemas/aiInfra.ts +3 -2
- package/{src/database → packages/database/src}/schemas/document.ts +2 -2
- package/{src/database → packages/database/src}/schemas/file.ts +1 -1
- package/{src/database → packages/database/src}/schemas/generation.ts +1 -1
- package/{src/database → packages/database/src}/schemas/message.ts +1 -1
- package/{src/database → packages/database/src}/schemas/ragEvals.ts +1 -1
- package/{src/database → packages/database/src}/schemas/relations.ts +1 -2
- package/{src/database → packages/database/src}/schemas/session.ts +1 -2
- package/{src/database → packages/database/src}/schemas/topic.ts +2 -2
- package/{src/database → packages/database/src}/server/models/__tests__/adapter.test.ts +5 -4
- package/{src/database → packages/database/src}/server/models/__tests__/nextauth.test.ts +4 -4
- package/{src/database → packages/database/src}/server/models/__tests__/user.test.ts +1 -2
- package/{src/database → packages/database/src}/server/models/ragEval/dataset.ts +3 -3
- package/{src/database → packages/database/src}/server/models/ragEval/datasetRecord.ts +3 -3
- package/{src/database → packages/database/src}/server/models/ragEval/evaluation.ts +3 -3
- package/{src/database → packages/database/src}/server/models/ragEval/evaluationRecord.ts +2 -2
- package/{src/database → packages/database/src}/utils/idGenerator.ts +4 -1
- package/{vitest.config.server.ts → packages/database/vitest.config.ts} +8 -7
- package/packages/model-runtime/package.json +1 -0
- package/packages/model-runtime/src/bfl/createImage.test.ts +4 -4
- package/packages/model-runtime/src/bfl/createImage.ts +1 -1
- package/packages/model-runtime/src/google/index.test.ts +1 -1
- package/packages/model-runtime/src/google/index.ts +1 -3
- package/packages/model-runtime/src/ollama/index.ts +3 -2
- package/packages/model-runtime/src/utils/anthropicHelpers.test.ts +2 -3
- package/packages/model-runtime/src/utils/anthropicHelpers.ts +1 -2
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.ts +1 -1
- package/packages/model-runtime/src/utils/openaiHelpers.test.ts +2 -3
- package/packages/model-runtime/src/utils/openaiHelpers.ts +2 -2
- package/packages/model-runtime/src/utils/streams/bedrock/claude.ts +1 -2
- package/packages/model-runtime/src/utils/streams/bedrock/llama.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/bedrock/llama.ts +1 -2
- package/packages/model-runtime/src/utils/streams/google-ai.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/google-ai.ts +1 -1
- package/packages/model-runtime/src/utils/streams/ollama.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/ollama.ts +1 -1
- package/packages/model-runtime/src/utils/streams/protocol.ts +2 -2
- package/packages/model-runtime/src/utils/streams/vertex-ai.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/vertex-ai.ts +1 -1
- package/packages/model-runtime/vitest.config.ts +2 -0
- package/packages/types/src/index.ts +5 -0
- package/packages/utils/package.json +17 -0
- package/{src/utils → packages/utils/src}/client/cookie.test.ts +1 -3
- package/{src/utils → packages/utils/src}/client/cookie.ts +1 -1
- package/{src/utils → packages/utils/src}/client/parserPlaceholder.test.ts +2 -2
- package/{src/utils → packages/utils/src}/client/parserPlaceholder.ts +77 -73
- package/{src/utils → packages/utils/src}/client/topic.test.ts +1 -1
- package/{src/utils → packages/utils/src}/compressImage.test.ts +2 -0
- package/{src/utils → packages/utils/src}/fetch/__tests__/fetchSSE.test.ts +3 -4
- package/{src/utils → packages/utils/src}/fetch/fetchSSE.ts +1 -1
- package/{src/utils → packages/utils/src}/getFallbackModelProperty.test.ts +1 -1
- package/packages/utils/src/index.ts +5 -0
- package/{src/utils → packages/utils/src}/locale.ts +2 -1
- package/{src/utils → packages/utils/src}/merge.test.ts +1 -3
- package/{src/utils → packages/utils/src}/parseModels.ts +3 -2
- package/{src/utils → packages/utils/src}/platform.test.ts +1 -1
- package/{src/utils → packages/utils/src}/platform.ts +1 -1
- package/{src/utils → packages/utils/src}/sanitizeUTF8.test.ts +2 -0
- package/{src/utils → packages/utils/src}/server/__tests__/geo.test.ts +1 -1
- package/{src/utils → packages/utils/src}/server/xor.test.ts +1 -2
- package/{src/utils → packages/utils/src}/url.test.ts +1 -1
- package/packages/utils/tests/setup.ts +10 -0
- package/packages/utils/vitest.config.ts +16 -0
- package/scripts/dbmlWorkflow/index.ts +1 -1
- package/scripts/migrateClientDB/compile-migrations.ts +2 -2
- package/scripts/migrateServerDB/index.ts +2 -2
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/CreateDataset/CreateForm.tsx +1 -1
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetDetail/index.tsx +1 -1
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetList/Item.tsx +1 -2
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetList/index.tsx +1 -2
- package/src/app/[variants]/(main)/repos/[id]/evals/evaluation/CreateEvaluation/CreateForm.tsx +1 -1
- package/src/app/[variants]/(main)/repos/[id]/evals/evaluation/EvaluationList/index.tsx +1 -1
- package/src/config/aiModels/mistral.ts +2 -0
- package/src/features/AgentSetting/store/index.ts +1 -2
- package/src/server/routers/async/ragEval.ts +1 -1
- package/src/server/routers/lambda/ragEval.ts +9 -9
- package/src/services/config.ts +1 -1
- package/src/services/ragEval.ts +4 -3
- package/src/store/knowledgeBase/slices/ragEval/actions/dataset.ts +6 -6
- package/src/store/knowledgeBase/slices/ragEval/actions/evaluation.ts +1 -1
- package/src/store/serverConfig/store.ts +1 -1
- package/src/utils/client/switchLang.test.ts +2 -2
- package/src/utils/client/switchLang.ts +2 -3
- package/tests/setup.ts +0 -11
- package/tsconfig.json +2 -0
- package/vitest.config.ts +6 -2
- /package/{src → packages}/database/migrations/0000_init.sql +0 -0
- /package/{src → packages}/database/migrations/0001_add_client_id.sql +0 -0
- /package/{src → packages}/database/migrations/0002_amusing_puma.sql +0 -0
- /package/{src → packages}/database/migrations/0003_naive_echo.sql +0 -0
- /package/{src → packages}/database/migrations/0004_add_next_auth.sql +0 -0
- /package/{src → packages}/database/migrations/0005_pgvector.sql +0 -0
- /package/{src → packages}/database/migrations/0006_add_knowledge_base.sql +0 -0
- /package/{src → packages}/database/migrations/0007_fix_embedding_table.sql +0 -0
- /package/{src → packages}/database/migrations/0008_add_rag_evals.sql +0 -0
- /package/{src → packages}/database/migrations/0009_remove_unused_user_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0010_add_accessed_at_and_clean_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0011_add_topic_history_summary.sql +0 -0
- /package/{src → packages}/database/migrations/0012_add_thread.sql +0 -0
- /package/{src → packages}/database/migrations/0013_add_ai_infra.sql +0 -0
- /package/{src → packages}/database/migrations/0014_add_message_reasoning.sql +0 -0
- /package/{src → packages}/database/migrations/0015_add_message_search_metadata.sql +0 -0
- /package/{src → packages}/database/migrations/0016_add_message_index.sql +0 -0
- /package/{src → packages}/database/migrations/0017_add_user_id_to_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0018_add_client_id_for_entities.sql +0 -0
- /package/{src → packages}/database/migrations/0019_add_hotkey_user_settings.sql +0 -0
- /package/{src → packages}/database/migrations/0020_add_oidc.sql +0 -0
- /package/{src → packages}/database/migrations/0021_add_agent_opening_settings.sql +0 -0
- /package/{src → packages}/database/migrations/0022_add_documents.sql +0 -0
- /package/{src → packages}/database/migrations/0023_remove_param_and_doubao.sql +0 -0
- /package/{src → packages}/database/migrations/0024_add_rbac_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0025_add_provider_config.sql +0 -0
- /package/{src → packages}/database/migrations/0026_add_autovacuum_tuning.sql +0 -0
- /package/{src → packages}/database/migrations/0027_ai_image.sql +0 -0
- /package/{src → packages}/database/migrations/meta/0000_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0001_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0002_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0003_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0004_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0005_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0006_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0007_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0008_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0009_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0010_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0011_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0012_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0013_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0014_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0015_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0016_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0017_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0018_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0019_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0020_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0021_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0022_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0023_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0024_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0025_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0026_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0027_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0028_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0029_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/_journal.json +0 -0
- /package/{src/database → packages/database/src}/client/db.test.ts +0 -0
- /package/{src/database → packages/database/src}/client/pglite.ts +0 -0
- /package/{src/database → packages/database/src}/client/pglite.worker.ts +0 -0
- /package/{src/database → packages/database/src}/client/type.ts +0 -0
- /package/{src/database → packages/database/src}/models/__tests__/fixtures/embedding.ts +0 -0
- /package/{src/database → packages/database/src}/repositories/aiInfra/index.test.ts +0 -0
- /package/{src/database → packages/database/src}/repositories/dataExporter/index.test.ts +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/agents.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/agentsToSessions.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/topic.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/userSettings.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/with-client-id.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/__tests__/fixtures/messages.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/__tests__/index.test.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/_helpers.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/apiKey.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/asyncTask.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/index.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/nextauth.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/oidc.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/rag.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/rbac.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/user.ts +0 -0
- /package/{src/database → packages/database/src}/server/index.ts +0 -0
- /package/{src/database → packages/database/src}/server/models/ragEval/index.ts +0 -0
- /package/{src/database → packages/database/src}/type.ts +0 -0
- /package/{src/database → packages/database/src}/utils/genWhere.ts +0 -0
- /package/{src/database → packages/database/src}/utils/idGenerator.test.ts +0 -0
- /package/{tests → packages/database/tests}/setup-db.ts +0 -0
- /package/{src/utils → packages/types/src}/zustand.ts +0 -0
- /package/{src/utils → packages/utils/src}/__snapshots__/parseModels.test.ts.snap +0 -0
- /package/{src/utils → packages/utils/src}/_deprecated/__snapshots__/parseModels.test.ts.snap +0 -0
- /package/{src/utils → packages/utils/src}/_deprecated/parseModels.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/_deprecated/parseModels.ts +0 -0
- /package/{src/utils → packages/utils/src}/apiKey.ts +0 -0
- /package/{src/utils → packages/utils/src}/basePath.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/GlobalAgentContextManager.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/downloadFile.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/exportFile.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/topic.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/xor-obfuscation.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/xor-obfuscation.ts +0 -0
- /package/{src/utils → packages/utils/src}/clientIP.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/clientIP.ts +0 -0
- /package/{src/utils → packages/utils/src}/clipboard.ts +0 -0
- /package/{src/utils → packages/utils/src}/colorUtils.ts +0 -0
- /package/{src/utils → packages/utils/src}/compass.ts +0 -0
- /package/{src/utils → packages/utils/src}/compressImage.ts +0 -0
- /package/{src/utils → packages/utils/src}/difference.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/difference.ts +0 -0
- /package/{src/utils → packages/utils/src}/electron/desktopRemoteRPCFetch.ts +0 -0
- /package/{src/utils → packages/utils/src}/env.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/__tests__/parseError.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/fetchEventSource/index.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/fetchEventSource/parse.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/headers.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/index.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/parseError.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/request.ts +0 -0
- /package/{src/utils → packages/utils/src}/format.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/format.ts +0 -0
- /package/{src/utils → packages/utils/src}/genOG.ts +0 -0
- /package/{src/utils → packages/utils/src}/getFallbackModelProperty.ts +0 -0
- /package/{src/utils → packages/utils/src}/imageToBase64.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/imageToBase64.ts +0 -0
- /package/{src/utils → packages/utils/src}/isChunkingUnsupported.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/isChunkingUnsupported.ts +0 -0
- /package/{src/utils → packages/utils/src}/keyboard.ts +0 -0
- /package/{src/utils → packages/utils/src}/localStorage.ts +0 -0
- /package/{src/utils → packages/utils/src}/locale.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/merge.ts +0 -0
- /package/{src/utils → packages/utils/src}/number.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/number.ts +0 -0
- /package/{src/utils → packages/utils/src}/object.ts +0 -0
- /package/{src/utils → packages/utils/src}/parseMarkdown.ts +0 -0
- /package/{src/utils → packages/utils/src}/parseModels.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/pricing.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/pricing.ts +0 -0
- /package/{src/utils → packages/utils/src}/promptTemplate.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/promptTemplate.ts +0 -0
- /package/{src/utils → packages/utils/src}/safeParseJSON.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/safeParseJSON.ts +0 -0
- /package/{src/utils → packages/utils/src}/sanitizeUTF8.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/__tests__/auth.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/auth.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/correctOIDCUrl.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/geo.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/pageProps.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/responsive.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/routeVariants.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/xor.ts +0 -0
- /package/{src/utils → packages/utils/src}/sleep.ts +0 -0
- /package/{src/utils → packages/utils/src}/storeDebug.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/storeDebug.ts +0 -0
- /package/{src/utils → packages/utils/src}/time.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/time.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/client.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/estimated.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/index.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/server.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/tokenizer.worker.ts +0 -0
- /package/{src/utils → packages/utils/src}/toolCall.ts +0 -0
- /package/{src/utils → packages/utils/src}/toolManifest.ts +0 -0
- /package/{src/utils → packages/utils/src}/trace.ts +0 -0
- /package/{src/utils → packages/utils/src}/units.ts +0 -0
- /package/{src/utils → packages/utils/src}/uploadFIle.ts +0 -0
- /package/{src/utils → packages/utils/src}/url.ts +0 -0
- /package/{src/utils → packages/utils/src}/uuid.ts +0 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
/**
|
2
|
+
* Generate or update PR comment with Docker build info
|
3
|
+
*/
|
4
|
+
module.exports = async ({
|
5
|
+
github,
|
6
|
+
context,
|
7
|
+
dockerMetaJson,
|
8
|
+
image,
|
9
|
+
version,
|
10
|
+
dockerhubUrl,
|
11
|
+
platforms,
|
12
|
+
}) => {
|
13
|
+
const COMMENT_IDENTIFIER = '<!-- DOCKER-BUILD-COMMENT -->';
|
14
|
+
|
15
|
+
const parseTags = () => {
|
16
|
+
try {
|
17
|
+
if (dockerMetaJson) {
|
18
|
+
const parsed = JSON.parse(dockerMetaJson);
|
19
|
+
if (Array.isArray(parsed.tags) && parsed.tags.length > 0) {
|
20
|
+
return parsed.tags;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
} catch (e) {
|
24
|
+
// ignore parsing error, fallback below
|
25
|
+
}
|
26
|
+
if (image && version) {
|
27
|
+
return [`${image}:${version}`];
|
28
|
+
}
|
29
|
+
return [];
|
30
|
+
};
|
31
|
+
|
32
|
+
const generateCommentBody = () => {
|
33
|
+
const tags = parseTags();
|
34
|
+
const buildTime = new Date().toISOString();
|
35
|
+
|
36
|
+
// Use the first tag as the main version
|
37
|
+
const mainTag = tags.length > 0 ? tags[0] : `${image}:${version}`;
|
38
|
+
const tagVersion = mainTag.includes(':') ? mainTag.split(':')[1] : version;
|
39
|
+
|
40
|
+
return [
|
41
|
+
COMMENT_IDENTIFIER,
|
42
|
+
'',
|
43
|
+
'### 🐳 Database Docker Build Completed!',
|
44
|
+
`**Version**: \`${tagVersion || 'N/A'}\``,
|
45
|
+
`**Build Time**: \`${buildTime}\``,
|
46
|
+
'',
|
47
|
+
dockerhubUrl ? `🔗 View all tags on Docker Hub: ${dockerhubUrl}` : '',
|
48
|
+
'',
|
49
|
+
'### Pull Image',
|
50
|
+
'Download the Docker image to your local machine:',
|
51
|
+
'',
|
52
|
+
'```bash',
|
53
|
+
`docker pull ${mainTag}`,
|
54
|
+
'```',
|
55
|
+
'> [!IMPORTANT]',
|
56
|
+
'> This build is for testing and validation purposes.',
|
57
|
+
]
|
58
|
+
.filter(Boolean)
|
59
|
+
.join('\n');
|
60
|
+
};
|
61
|
+
|
62
|
+
const body = generateCommentBody();
|
63
|
+
|
64
|
+
// List comments on the PR
|
65
|
+
const { data: comments } = await github.rest.issues.listComments({
|
66
|
+
issue_number: context.issue.number,
|
67
|
+
owner: context.repo.owner,
|
68
|
+
repo: context.repo.repo,
|
69
|
+
});
|
70
|
+
|
71
|
+
const existing = comments.find((c) => c.body && c.body.includes(COMMENT_IDENTIFIER));
|
72
|
+
if (existing) {
|
73
|
+
await github.rest.issues.updateComment({
|
74
|
+
comment_id: existing.id,
|
75
|
+
owner: context.repo.owner,
|
76
|
+
repo: context.repo.repo,
|
77
|
+
body,
|
78
|
+
});
|
79
|
+
return { updated: true, id: existing.id };
|
80
|
+
}
|
81
|
+
|
82
|
+
const result = await github.rest.issues.createComment({
|
83
|
+
issue_number: context.issue.number,
|
84
|
+
owner: context.repo.owner,
|
85
|
+
repo: context.repo.repo,
|
86
|
+
body,
|
87
|
+
});
|
88
|
+
return { updated: false, id: result.data.id };
|
89
|
+
};
|
@@ -159,3 +159,24 @@ jobs:
|
|
159
159
|
- name: Inspect image
|
160
160
|
run: |
|
161
161
|
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
162
|
+
|
163
|
+
|
164
|
+
- name: Comment on PR with Docker build info
|
165
|
+
if: github.event_name == 'pull_request'
|
166
|
+
uses: actions/github-script@v7
|
167
|
+
with:
|
168
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
169
|
+
script: |
|
170
|
+
const prComment = require('${{ github.workspace }}/.github/scripts/docker-pr-comment.js');
|
171
|
+
const result = await prComment({
|
172
|
+
github,
|
173
|
+
context,
|
174
|
+
dockerMetaJson: ${{ toJSON(steps.meta.outputs.json) }},
|
175
|
+
image: "${{ env.REGISTRY_IMAGE }}",
|
176
|
+
version: "${{ steps.meta.outputs.version }}",
|
177
|
+
dockerhubUrl: "https://hub.docker.com/r/${{ env.REGISTRY_IMAGE }}/tags",
|
178
|
+
platforms: "linux/amd64, linux/arm64",
|
179
|
+
});
|
180
|
+
core.info(`Status: ${result.updated ? 'Updated' : 'Created'}, ID: ${result.id}`);
|
181
|
+
|
182
|
+
|
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
|
12
12
|
services:
|
13
13
|
postgres:
|
14
|
-
image:
|
14
|
+
image: paradedb/paradedb:latest
|
15
15
|
env:
|
16
16
|
POSTGRES_PASSWORD: postgres
|
17
17
|
options: >-
|
@@ -38,8 +38,10 @@ jobs:
|
|
38
38
|
- name: Lint
|
39
39
|
run: bun run lint
|
40
40
|
|
41
|
-
-
|
42
|
-
|
41
|
+
- uses: pnpm/action-setup@v4
|
42
|
+
|
43
|
+
- name: Test Database Coverage
|
44
|
+
run: pnpm --filter @lobechat/database test
|
43
45
|
env:
|
44
46
|
DATABASE_TEST_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
45
47
|
DATABASE_DRIVER: node
|
@@ -48,8 +50,8 @@ jobs:
|
|
48
50
|
S3_PUBLIC_DOMAIN: https://example.com
|
49
51
|
APP_URL: https://home.com
|
50
52
|
|
51
|
-
- name: Test App
|
52
|
-
run: bun run test-app
|
53
|
+
- name: Test App
|
54
|
+
run: bun run test-app
|
53
55
|
|
54
56
|
- name: Release
|
55
57
|
run: bun run release
|
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
|
-
package: [file-loaders, prompts, model-runtime, web-crawler, electron-server-ipc]
|
14
|
+
package: [file-loaders, prompts, model-runtime, web-crawler, electron-server-ipc, utils]
|
15
15
|
|
16
16
|
name: Test package ${{ matrix.package }}
|
17
17
|
|
@@ -75,7 +75,7 @@ jobs:
|
|
75
75
|
files: ./coverage/app/lcov.info
|
76
76
|
flags: app
|
77
77
|
|
78
|
-
test-
|
78
|
+
test-databsae:
|
79
79
|
name: Test Database
|
80
80
|
|
81
81
|
runs-on: ubuntu-latest
|
@@ -109,8 +109,10 @@ jobs:
|
|
109
109
|
- name: Lint
|
110
110
|
run: bun run lint
|
111
111
|
|
112
|
-
-
|
113
|
-
|
112
|
+
- uses: pnpm/action-setup@v4
|
113
|
+
|
114
|
+
- name: Test Coverage
|
115
|
+
run: pnpm --filter @lobechat/database test:coverage
|
114
116
|
env:
|
115
117
|
DATABASE_TEST_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
116
118
|
DATABASE_DRIVER: node
|
@@ -119,9 +121,9 @@ jobs:
|
|
119
121
|
S3_PUBLIC_DOMAIN: https://example.com
|
120
122
|
APP_URL: https://home.com
|
121
123
|
|
122
|
-
- name: Upload
|
124
|
+
- name: Upload Database coverage to Codecov
|
123
125
|
uses: codecov/codecov-action@v4
|
124
126
|
with:
|
125
127
|
token: ${{ secrets.CODECOV_TOKEN }}
|
126
|
-
files: ./coverage/
|
127
|
-
flags:
|
128
|
+
files: ./packages/database/coverage/lcov.info
|
129
|
+
flags: database
|
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.114.5](https://github.com/lobehub/lobe-chat/compare/v1.114.4...v1.114.5)
|
6
|
+
|
7
|
+
<sup>Released on **2025-08-22**</sup>
|
8
|
+
|
9
|
+
#### 💄 Styles
|
10
|
+
|
11
|
+
- **misc**: Update mistral model vision ability.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Styles
|
19
|
+
|
20
|
+
- **misc**: Update mistral model vision ability, closes [#8885](https://github.com/lobehub/lobe-chat/issues/8885) ([915c0ff](https://github.com/lobehub/lobe-chat/commit/915c0ff))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.114.4](https://github.com/lobehub/lobe-chat/compare/v1.114.3...v1.114.4)
|
31
|
+
|
32
|
+
<sup>Released on **2025-08-22**</sup>
|
33
|
+
|
34
|
+
#### ♻ Code Refactoring
|
35
|
+
|
36
|
+
- **misc**: Move database to packages.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### Code refactoring
|
44
|
+
|
45
|
+
- **misc**: Move database to packages, closes [#8874](https://github.com/lobehub/lobe-chat/issues/8874) ([af1f715](https://github.com/lobehub/lobe-chat/commit/af1f715))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.114.3](https://github.com/lobehub/lobe-chat/compare/v1.114.2...v1.114.3)
|
6
56
|
|
7
57
|
<sup>Released on **2025-08-21**</sup>
|
package/Dockerfile.database
CHANGED
@@ -120,7 +120,7 @@ COPY --from=base /distroless/ /
|
|
120
120
|
COPY --from=builder /app/.next/standalone /app/
|
121
121
|
|
122
122
|
# Copy database migrations
|
123
|
-
COPY --from=builder /app/
|
123
|
+
COPY --from=builder /app/packages/database/migrations /app/migrations
|
124
124
|
COPY --from=builder /app/scripts/migrateServerDB/docker.cjs /app/docker.cjs
|
125
125
|
COPY --from=builder /app/scripts/migrateServerDB/errorHint.js /app/errorHint.js
|
126
126
|
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"improvements": [
|
5
|
+
"Update mistral model vision ability."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2025-08-22",
|
9
|
+
"version": "1.114.5"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {
|
13
|
+
"improvements": [
|
14
|
+
"Move database to packages."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"date": "2025-08-22",
|
18
|
+
"version": "1.114.4"
|
19
|
+
},
|
2
20
|
{
|
3
21
|
"children": {},
|
4
22
|
"date": "2025-08-21",
|
package/codecov.yml
CHANGED
@@ -1,11 +1,39 @@
|
|
1
|
+
component_management:
|
2
|
+
individual_components:
|
3
|
+
# App architecture layers
|
4
|
+
- component_id: app_store
|
5
|
+
name: "Store"
|
6
|
+
paths:
|
7
|
+
- src/store/**
|
8
|
+
- component_id: app_services
|
9
|
+
name: "Services"
|
10
|
+
paths:
|
11
|
+
- src/services/**
|
12
|
+
- component_id: app_server
|
13
|
+
name: "Server"
|
14
|
+
paths:
|
15
|
+
- src/server/**
|
16
|
+
- component_id: app_libs
|
17
|
+
name: "Libs"
|
18
|
+
paths:
|
19
|
+
- src/libs/**
|
20
|
+
- component_id: app_utils
|
21
|
+
name: "Utils"
|
22
|
+
paths:
|
23
|
+
- src/utils/**
|
24
|
+
|
1
25
|
coverage:
|
2
26
|
status:
|
3
27
|
project:
|
4
28
|
default: off
|
5
|
-
|
29
|
+
database:
|
6
30
|
flags:
|
7
|
-
-
|
31
|
+
- database
|
8
32
|
app:
|
9
33
|
flags:
|
10
34
|
- app
|
11
35
|
patch: off
|
36
|
+
|
37
|
+
|
38
|
+
comment:
|
39
|
+
layout: "header, diff, flags, components" # show component info in the PR comment
|
@@ -104,6 +104,19 @@ table ai_providers {
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
|
107
|
+
table api_keys {
|
108
|
+
id integer [pk, not null]
|
109
|
+
name varchar(256) [not null]
|
110
|
+
key varchar(256) [not null, unique]
|
111
|
+
enabled boolean [default: true]
|
112
|
+
expires_at "timestamp with time zone"
|
113
|
+
last_used_at "timestamp with time zone"
|
114
|
+
user_id text [not null]
|
115
|
+
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
116
|
+
created_at "timestamp with time zone" [not null, default: `now()`]
|
117
|
+
updated_at "timestamp with time zone" [not null, default: `now()`]
|
118
|
+
}
|
119
|
+
|
107
120
|
table async_tasks {
|
108
121
|
id uuid [pk, not null, default: `gen_random_uuid()`]
|
109
122
|
type text
|
@@ -702,6 +715,7 @@ table rbac_roles {
|
|
702
715
|
description text
|
703
716
|
is_system boolean [not null, default: false]
|
704
717
|
is_active boolean [not null, default: true]
|
718
|
+
metadata jsonb [default: `{}`]
|
705
719
|
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
706
720
|
created_at "timestamp with time zone" [not null, default: `now()`]
|
707
721
|
updated_at "timestamp with time zone" [not null, default: `now()`]
|
package/drizzle.config.ts
CHANGED
@@ -22,8 +22,8 @@ export default {
|
|
22
22
|
url: connectionString,
|
23
23
|
},
|
24
24
|
dialect: 'postgresql',
|
25
|
-
out: './
|
25
|
+
out: './packages/database/migrations',
|
26
26
|
|
27
|
-
schema: './
|
27
|
+
schema: './packages/database/src/schemas',
|
28
28
|
strict: true,
|
29
29
|
} satisfies Config;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.114.
|
3
|
+
"version": "1.114.5",
|
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",
|
@@ -73,8 +73,6 @@
|
|
73
73
|
"test": "npm run test-app && npm run test-server",
|
74
74
|
"test-app": "vitest run --config vitest.config.ts",
|
75
75
|
"test-app:coverage": "vitest run --config vitest.config.ts --coverage",
|
76
|
-
"test-server": "vitest run --config vitest.config.server.ts",
|
77
|
-
"test-server:coverage": "vitest run --config vitest.config.server.ts --coverage",
|
78
76
|
"test:update": "vitest -u",
|
79
77
|
"type-check": "tsgo --noEmit",
|
80
78
|
"webhook:ngrok": "ngrok http http://localhost:3011",
|
@@ -141,11 +139,14 @@
|
|
141
139
|
"@icons-pack/react-simple-icons": "9.6.0",
|
142
140
|
"@khmyznikov/pwa-install": "0.3.9",
|
143
141
|
"@langchain/community": "^0.3.50",
|
142
|
+
"@lobechat/const": "workspace:*",
|
143
|
+
"@lobechat/database": "workspace:*",
|
144
144
|
"@lobechat/electron-client-ipc": "workspace:*",
|
145
145
|
"@lobechat/electron-server-ipc": "workspace:*",
|
146
146
|
"@lobechat/file-loaders": "workspace:*",
|
147
147
|
"@lobechat/model-runtime": "workspace:*",
|
148
148
|
"@lobechat/prompts": "workspace:*",
|
149
|
+
"@lobechat/utils": "workspace:*",
|
149
150
|
"@lobechat/web-crawler": "workspace:*",
|
150
151
|
"@lobehub/analytics": "^1.6.0",
|
151
152
|
"@lobehub/charts": "^2.0.0",
|
@@ -361,8 +362,7 @@
|
|
361
362
|
"unified": "^11.0.5",
|
362
363
|
"unist-util-visit": "^5.0.0",
|
363
364
|
"vite": "^5.4.19",
|
364
|
-
"vitest": "^3.2.4"
|
365
|
-
"vitest-canvas-mock": "^0.3.3"
|
365
|
+
"vitest": "^3.2.4"
|
366
366
|
},
|
367
367
|
"packageManager": "pnpm@10.14.0",
|
368
368
|
"publishConfig": {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ModelProvider } from '@lobechat/model-runtime';
|
2
|
+
import { UserModelProviderConfig } from '@lobechat/types';
|
2
3
|
|
3
4
|
import * as ProviderCards from '@/config/modelProviders';
|
4
5
|
import { ModelProviderCard } from '@/types/llm';
|
5
|
-
import { UserModelProviderConfig } from '@/types/user/settings';
|
6
6
|
|
7
7
|
export const genUserLLMConfig = (specificConfig: Record<any, any>): UserModelProviderConfig => {
|
8
8
|
return Object.keys(ModelProvider).reduce((config, providerKey) => {
|
@@ -9,8 +9,6 @@ import { DEFAULT_SYSTEM_AGENT_CONFIG } from './systemAgent';
|
|
9
9
|
import { DEFAULT_TOOL_CONFIG } from './tool';
|
10
10
|
import { DEFAULT_TTS_CONFIG } from './tts';
|
11
11
|
|
12
|
-
export const COOKIE_CACHE_DAYS = 30;
|
13
|
-
|
14
12
|
export * from './agent';
|
15
13
|
export * from './hotkey';
|
16
14
|
export * from './llm';
|
@@ -12,5 +12,5 @@ CREATE TABLE IF NOT EXISTS "api_keys" (
|
|
12
12
|
CONSTRAINT "api_keys_key_unique" UNIQUE("key")
|
13
13
|
);
|
14
14
|
--> statement-breakpoint
|
15
|
-
ALTER TABLE "rbac_roles" ADD COLUMN "metadata" jsonb DEFAULT '{}'::jsonb;--> statement-breakpoint
|
15
|
+
ALTER TABLE "rbac_roles" ADD COLUMN IF NOT EXISTS "metadata" jsonb DEFAULT '{}'::jsonb;--> statement-breakpoint
|
16
16
|
ALTER TABLE "api_keys" ADD CONSTRAINT "api_keys_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "@lobechat/database",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"private": true,
|
5
|
+
"main": "src/index.ts",
|
6
|
+
"types": "src/index.ts",
|
7
|
+
"scripts": {
|
8
|
+
"test": "vitest",
|
9
|
+
"test:coverage": "vitest --coverage"
|
10
|
+
},
|
11
|
+
"dependencies": {
|
12
|
+
"@electric-sql/pglite": "^0.2.17",
|
13
|
+
"@lobechat/const": "workspace:*",
|
14
|
+
"@lobechat/types": "workspace:*",
|
15
|
+
"@lobechat/utils": "workspace:*",
|
16
|
+
"dayjs": "^1.11.13",
|
17
|
+
"drizzle-orm": "^0.44.4",
|
18
|
+
"nanoid": "^5.1.5",
|
19
|
+
"pg": "^8.16.3",
|
20
|
+
"random-words": "^2.0.1",
|
21
|
+
"ts-md5": "^2.0.1",
|
22
|
+
"ws": "^8.18.3"
|
23
|
+
}
|
24
|
+
}
|
@@ -2,7 +2,6 @@ import { sql } from 'drizzle-orm';
|
|
2
2
|
import { PgliteDatabase, drizzle } from 'drizzle-orm/pglite';
|
3
3
|
import { Md5 } from 'ts-md5';
|
4
4
|
|
5
|
-
import { DrizzleMigrationModel } from '@/database/models/drizzleMigration';
|
6
5
|
import {
|
7
6
|
ClientDBLoadingProgress,
|
8
7
|
DatabaseLoadingState,
|
@@ -11,8 +10,9 @@ import {
|
|
11
10
|
} from '@/types/clientDB';
|
12
11
|
import { sleep } from '@/utils/sleep';
|
13
12
|
|
13
|
+
import migrations from '../core/migrations.json';
|
14
|
+
import { DrizzleMigrationModel } from '../models/drizzleMigration';
|
14
15
|
import * as schema from '../schemas';
|
15
|
-
import migrations from './migrations.json';
|
16
16
|
|
17
17
|
const pgliteSchemaHashCache = 'LOBE_CHAT_PGLITE_SCHEMA_HASH';
|
18
18
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { isDesktop } from '
|
2
|
-
import { getDBInstance } from '@/database/core/web-server';
|
3
|
-
import { LobeChatDatabase } from '@/database/type';
|
1
|
+
import { isDesktop } from '@lobechat/const';
|
4
2
|
|
3
|
+
import { LobeChatDatabase } from '../type';
|
5
4
|
import { getPgliteInstance } from './electron';
|
5
|
+
import { getDBInstance } from './web-server';
|
6
6
|
|
7
7
|
/**
|
8
8
|
* 懒加载数据库实例
|
@@ -11,7 +11,7 @@ import { serverDBEnv } from '@/config/db';
|
|
11
11
|
|
12
12
|
import * as schema from '../schemas';
|
13
13
|
|
14
|
-
const migrationsFolder = join(__dirname, '
|
14
|
+
const migrationsFolder = join(__dirname, '../../migrations');
|
15
15
|
|
16
16
|
export const getTestDBInstance = async () => {
|
17
17
|
let connectionString = serverDBEnv.DATABASE_TEST_URL;
|
@@ -4,13 +4,13 @@ import { drizzle as pgliteDrizzle } from 'drizzle-orm/pglite';
|
|
4
4
|
import fs from 'node:fs';
|
5
5
|
import { Md5 } from 'ts-md5';
|
6
6
|
|
7
|
-
import { DrizzleMigrationModel } from '@/database/models/drizzleMigration';
|
8
|
-
import * as schema from '@/database/schemas';
|
9
7
|
import { electronIpcClient } from '@/server/modules/ElectronIPCClient';
|
10
8
|
import { MigrationTableItem } from '@/types/clientDB';
|
11
9
|
|
12
|
-
import
|
10
|
+
import { DrizzleMigrationModel } from '../models/drizzleMigration';
|
11
|
+
import * as schema from '../schemas';
|
13
12
|
import { LobeChatDatabase } from '../type';
|
13
|
+
import migrations from './migrations.json';
|
14
14
|
|
15
15
|
// 用于实例管理的全局对象
|
16
16
|
interface LobeGlobal {
|
@@ -544,10 +544,20 @@
|
|
544
544
|
},
|
545
545
|
{
|
546
546
|
"sql": [
|
547
|
-
"CREATE TABLE \"oauth_handoffs\" (\n\t\"id\" text PRIMARY KEY NOT NULL,\n\t\"client\" varchar(50) NOT NULL,\n\t\"payload\" jsonb NOT NULL,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n"
|
547
|
+
"CREATE TABLE IF NOT EXISTS \"oauth_handoffs\" (\n\t\"id\" text PRIMARY KEY NOT NULL,\n\t\"client\" varchar(50) NOT NULL,\n\t\"payload\" jsonb NOT NULL,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL\n);\n"
|
548
548
|
],
|
549
549
|
"bps": true,
|
550
550
|
"folderMillis": 1752567402506,
|
551
|
-
"hash": "
|
551
|
+
"hash": "83c410b18ef5c8667b4bdfd7880ef7db4c3278d826e6e87e9d3e05dde67fe8e1"
|
552
|
+
},
|
553
|
+
{
|
554
|
+
"sql": [
|
555
|
+
"CREATE TABLE IF NOT EXISTS \"api_keys\" (\n\t\"id\" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name \"api_keys_id_seq\" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),\n\t\"name\" varchar(256) NOT NULL,\n\t\"key\" varchar(256) NOT NULL,\n\t\"enabled\" boolean DEFAULT true,\n\t\"expires_at\" timestamp with time zone,\n\t\"last_used_at\" timestamp with time zone,\n\t\"user_id\" text NOT NULL,\n\t\"accessed_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"created_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp with time zone DEFAULT now() NOT NULL,\n\tCONSTRAINT \"api_keys_key_unique\" UNIQUE(\"key\")\n);\n",
|
556
|
+
"\nALTER TABLE \"rbac_roles\" ADD COLUMN IF NOT EXISTS \"metadata\" jsonb DEFAULT '{}'::jsonb;",
|
557
|
+
"\nALTER TABLE \"api_keys\" ADD CONSTRAINT \"api_keys_user_id_users_id_fk\" FOREIGN KEY (\"user_id\") REFERENCES \"public\".\"users\"(\"id\") ON DELETE cascade ON UPDATE no action;\n"
|
558
|
+
],
|
559
|
+
"bps": true,
|
560
|
+
"folderMillis": 1753201379817,
|
561
|
+
"hash": "fe5c0d7c2768189771c42ef93693fc1d58586b468c4bdde7fb6f2dc58cc9931c"
|
552
562
|
}
|
553
563
|
]
|
@@ -5,13 +5,12 @@ import { Pool as NodePool } from 'pg';
|
|
5
5
|
import ws from 'ws';
|
6
6
|
|
7
7
|
import { serverDBEnv } from '@/config/db';
|
8
|
-
import { isServerMode } from '@/const/version';
|
9
|
-
import * as schema from '@/database/schemas';
|
10
8
|
|
9
|
+
import * as schema from '../schemas';
|
11
10
|
import { LobeChatDatabase } from '../type';
|
12
11
|
|
13
12
|
export const getDBInstance = (): LobeChatDatabase => {
|
14
|
-
if (!
|
13
|
+
if (!(process.env.NEXT_PUBLIC_SERVICE_MODE === 'server')) return {} as any;
|
15
14
|
|
16
15
|
if (!serverDBEnv.KEY_VAULTS_SECRET) {
|
17
16
|
throw new Error(
|
@@ -2,9 +2,8 @@
|
|
2
2
|
import { eq } from 'drizzle-orm';
|
3
3
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
4
4
|
|
5
|
-
import { LobeChatDatabase } from '@/database/type';
|
6
|
-
|
7
5
|
import { sessionGroups, users } from '../../schemas';
|
6
|
+
import { LobeChatDatabase } from '../../type';
|
8
7
|
import { SessionGroupModel } from '../sessionGroup';
|
9
8
|
import { getTestDB } from './_util';
|
10
9
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { clientDB, initializeDB } from '
|
2
|
-
import { LobeChatDatabase } from '
|
1
|
+
import { clientDB, initializeDB } from '../../client/db';
|
2
|
+
import { LobeChatDatabase } from '../../type';
|
3
3
|
|
4
4
|
const isServerDBMode = process.env.TEST_SERVER_DB === '1';
|
5
5
|
|
6
6
|
export const getTestDB = async () => {
|
7
7
|
if (isServerDBMode) {
|
8
|
-
const { getTestDBInstance } = await import('
|
8
|
+
const { getTestDBInstance } = await import('../../core/dbForTest');
|
9
9
|
return await getTestDBInstance();
|
10
10
|
}
|
11
11
|
|
@@ -2,10 +2,10 @@
|
|
2
2
|
import { eq } from 'drizzle-orm';
|
3
3
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
4
4
|
|
5
|
-
import { LobeChatDatabase } from '@/database/type';
|
6
5
|
import { AiProviderModelListItem } from '@/types/aiModel';
|
7
6
|
|
8
7
|
import { AiModelSelectItem, NewAiModelItem, aiModels, users } from '../../schemas';
|
8
|
+
import { LobeChatDatabase } from '../../type';
|
9
9
|
import { AiModelModel } from '../aiModel';
|
10
10
|
import { getTestDB } from './_util';
|
11
11
|
|