Skip to content

Commit

Permalink
♻️ refactor: deprecated the current client mode code (lobehub#4866)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Dec 2, 2024
1 parent e290230 commit 7dff458
Show file tree
Hide file tree
Showing 57 changed files with 72 additions and 72 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// This file is for debugging purposes only.
// DON'T USE IT IN PRODUCTION.
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
import { DBModel } from '@/database/client/core/types/db';
import { DB_Message } from '@/database/client/schemas/message';
import { DB_Topic } from '@/database/client/schemas/topic';
import { DBModel } from '@/database/_deprecated/core/types/db';
import { DB_Message } from '@/database/_deprecated/schemas/message';
import { DB_Topic } from '@/database/_deprecated/schemas/topic';

import { BaseModel } from '../core';
import { DB_Session, DB_SessionSchema } from '../schemas/session';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
import { CreateMessageParams, MessageModel } from '@/database/client/models/message';
import { SessionGroupModel } from '@/database/client/models/sessionGroup';
import { TopicModel } from '@/database/client/models/topic';
import { CreateMessageParams, MessageModel } from '@/database/_deprecated/models/message';
import { SessionGroupModel } from '@/database/_deprecated/models/sessionGroup';
import { TopicModel } from '@/database/_deprecated/models/topic';
import { LobeAgentConfig } from '@/types/agent';
import {
LobeAgentSession,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { SessionModel } from '@/database/client/models/session';
import { SessionModel } from '@/database/_deprecated/models/session';
import { SessionGroups } from '@/types/session';

import { DB_SessionGroup } from '../../schemas/sessionGroup';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { DBModel } from '@/database/client/core/types/db';
import { CreateMessageParams, MessageModel } from '@/database/client/models/message';
import { DB_Message } from '@/database/client/schemas/message';
import { DB_Topic } from '@/database/client/schemas/topic';
import { DBModel } from '@/database/_deprecated/core/types/db';
import { CreateMessageParams, MessageModel } from '@/database/_deprecated/models/message';
import { DB_Message } from '@/database/_deprecated/schemas/message';
import { DB_Topic } from '@/database/_deprecated/schemas/topic';
import { nanoid } from '@/utils/uuid';
import * as uuidUtils from '@/utils/uuid';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DBModel } from '@/database/client/core/types/db';
import { DB_File, DB_FileSchema } from '@/database/client/schemas/files';
import { DBModel } from '@/database/_deprecated/core/types/db';
import { DB_File, DB_FileSchema } from '@/database/_deprecated/schemas/files';
import { nanoid } from '@/utils/uuid';

import { BaseModel } from '../core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DeepPartial } from 'utility-types';

import { BaseModel } from '@/database/client/core';
import { DBModel } from '@/database/client/core/types/db';
import { DB_Message, DB_MessageSchema } from '@/database/client/schemas/message';
import { BaseModel } from '@/database/_deprecated/core';
import { DBModel } from '@/database/_deprecated/core/types/db';
import { DB_Message, DB_MessageSchema } from '@/database/_deprecated/schemas/message';
import { ChatMessage } from '@/types/message';
import { nanoid } from '@/utils/uuid';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';

import { BaseModel } from '@/database/client/core';
import { BaseModel } from '@/database/_deprecated/core';
import { LobeTool } from '@/types/tool';
import { merge } from '@/utils/merge';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DeepPartial } from 'utility-types';

import { DEFAULT_AGENT_LOBE_SESSION } from '@/const/session';
import { BaseModel } from '@/database/client/core';
import { DBModel } from '@/database/client/core/types/db';
import { DB_Session, DB_SessionSchema } from '@/database/client/schemas/session';
import { BaseModel } from '@/database/_deprecated/core';
import { DBModel } from '@/database/_deprecated/core/types/db';
import { DB_Session, DB_SessionSchema } from '@/database/_deprecated/schemas/session';
import { LobeAgentConfig } from '@/types/agent';
import {
ChatSessionList,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseModel } from '@/database/client/core';
import { DB_SessionGroup, DB_SessionGroupSchema } from '@/database/client/schemas/sessionGroup';
import { BaseModel } from '@/database/_deprecated/core';
import { DB_SessionGroup, DB_SessionGroupSchema } from '@/database/_deprecated/schemas/sessionGroup';
import { SessionGroups } from '@/types/session';
import { nanoid } from '@/utils/uuid';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BaseModel } from '@/database/client/core';
import { DBModel } from '@/database/client/core/types/db';
import { MessageModel } from '@/database/client/models/message';
import { DB_Topic, DB_TopicSchema } from '@/database/client/schemas/topic';
import { BaseModel } from '@/database/_deprecated/core';
import { DBModel } from '@/database/_deprecated/core/types/db';
import { MessageModel } from '@/database/_deprecated/models/message';
import { DB_Topic, DB_TopicSchema } from '@/database/_deprecated/schemas/topic';
import { ChatTopic } from '@/types/topic';
import { nanoid } from '@/utils/uuid';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DeepPartial } from 'utility-types';

import { BaseModel } from '@/database/client/core';
import { BaseModel } from '@/database/_deprecated/core';
import { LobeAgentConfig } from '@/types/agent';
import { uuid } from '@/utils/uuid';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod';

import { AgentSchema } from '@/database/client/schemas/session';
import { AgentSchema } from '@/database/_deprecated/schemas/session';
import { LobeMetaDataSchema } from '@/types/meta';

const generalSechma = z.object({
Expand Down
4 changes: 2 additions & 2 deletions src/services/__tests__/sync.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { dataSync } from '@/database/client/core';
import { dataSync } from '@/database/_deprecated/core';
import { StartDataSyncParams } from '@/types/sync';

import { syncService } from '../sync';

vi.mock('@/database/client/core', () => ({
vi.mock('@/database/_deprecated/core', () => ({
dataSync: {
startDataSync: vi.fn(),
disconnect: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/services/debug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEBUG_MODEL } from '@/database/client/models/__DEBUG';
import { DEBUG_MODEL } from '@/database/_deprecated/models/__DEBUG';

class DebugService {
async insertLargeDataToDB() {
Expand Down
6 changes: 3 additions & 3 deletions src/services/file/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Mock, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';

import { fileEnv } from '@/config/file';
import { FileModel } from '@/database/client/models/file';
import { DB_File } from '@/database/client/schemas/files';
import { FileModel } from '@/database/_deprecated/models/file';
import { DB_File } from '@/database/_deprecated/schemas/files';
import { serverConfigSelectors } from '@/store/serverConfig/selectors';
import { createServerConfigStore } from '@/store/serverConfig/store';

Expand All @@ -14,7 +14,7 @@ beforeAll(() => {
createServerConfigStore();
});
// Mocks for the FileModel
vi.mock('@/database/client/models/file', () => ({
vi.mock('@/database/_deprecated/models/file', () => ({
FileModel: {
create: vi.fn(),
delete: vi.fn(),
Expand Down
4 changes: 2 additions & 2 deletions src/services/file/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FileModel } from '@/database/client/models/file';
import { DB_File } from '@/database/client/schemas/files';
import { FileModel } from '@/database/_deprecated/models/file';
import { DB_File } from '@/database/_deprecated/schemas/files';
import { FileItem } from '@/types/files';

import { IFileService } from './type';
Expand Down
8 changes: 4 additions & 4 deletions src/services/import/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MessageModel } from '@/database/client/models/message';
import { SessionModel } from '@/database/client/models/session';
import { SessionGroupModel } from '@/database/client/models/sessionGroup';
import { TopicModel } from '@/database/client/models/topic';
import { MessageModel } from '@/database/_deprecated/models/message';
import { SessionModel } from '@/database/_deprecated/models/session';
import { SessionGroupModel } from '@/database/_deprecated/models/sessionGroup';
import { TopicModel } from '@/database/_deprecated/models/topic';
import { ImportResult, ImportResults } from '@/services/config';
import { useUserStore } from '@/store/user';
import { ImportStage, ImporterEntryData, OnImportCallbacks } from '@/types/importer';
Expand Down
4 changes: 2 additions & 2 deletions src/services/message/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dayjs from 'dayjs';
import { Mock, describe, expect, it, vi } from 'vitest';

import { CreateMessageParams, MessageModel } from '@/database/client/models/message';
import { CreateMessageParams, MessageModel } from '@/database/_deprecated/models/message';
import {
ChatMessage,
ChatMessageError,
Expand All @@ -15,7 +15,7 @@ import { ClientService } from './client';
const messageService = new ClientService();

// Mock the MessageModel
vi.mock('@/database/client/models/message', () => {
vi.mock('@/database/_deprecated/models/message', () => {
return {
MessageModel: {
create: vi.fn(),
Expand Down
6 changes: 3 additions & 3 deletions src/services/message/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import dayjs from 'dayjs';

import { FileModel } from '@/database/client/models/file';
import { MessageModel } from '@/database/client/models/message';
import { DB_Message } from '@/database/client/schemas/message';
import { FileModel } from '@/database/_deprecated/models/file';
import { MessageModel } from '@/database/_deprecated/models/message';
import { DB_Message } from '@/database/_deprecated/schemas/message';
import {
ChatFileItem,
ChatMessage,
Expand Down
4 changes: 2 additions & 2 deletions src/services/message/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Mock, describe, expect, it, vi } from 'vitest';

import { CreateMessageParams, MessageModel } from '@/database/client/models/message';
import { CreateMessageParams, MessageModel } from '@/database/_deprecated/models/message';
import { ChatMessage, ChatMessageError, ChatPluginPayload } from '@/types/message';

import { messageService } from './index';

// Mock the MessageModel
vi.mock('@/database/client/models/message', () => {
vi.mock('@/database/_deprecated/models/message', () => {
return {
MessageModel: {
count: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/services/message/type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DB_Message } from '@/database/client/schemas/message';
import { DB_Message } from '@/database/_deprecated/schemas/message';
import {
ChatMessage,
ChatMessageError,
Expand Down
6 changes: 3 additions & 3 deletions src/services/plugin/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import { PluginModel } from '@/database/client/models/plugin';
import { DB_Plugin } from '@/database/client/schemas/plugin';
import { PluginModel } from '@/database/_deprecated/models/plugin';
import { DB_Plugin } from '@/database/_deprecated/schemas/plugin';
import { LobeTool } from '@/types/tool';
import { LobeToolCustomPlugin } from '@/types/tool/plugin';

Expand All @@ -13,7 +13,7 @@ const pluginService = new ClientService();

// Mocking modules and functions

vi.mock('@/database/client/models/plugin', () => ({
vi.mock('@/database/_deprecated/models/plugin', () => ({
PluginModel: {
getList: vi.fn(),
create: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/services/plugin/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';

import { PluginModel } from '@/database/client/models/plugin';
import { PluginModel } from '@/database/_deprecated/models/plugin';
import { LobeTool } from '@/types/tool';
import { LobeToolCustomPlugin } from '@/types/tool/plugin';

Expand Down
8 changes: 4 additions & 4 deletions src/services/session/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';

import { SessionModel } from '@/database/client/models/session';
import { SessionGroupModel } from '@/database/client/models/sessionGroup';
import { SessionModel } from '@/database/_deprecated/models/session';
import { SessionGroupModel } from '@/database/_deprecated/models/sessionGroup';
import { LobeAgentConfig } from '@/types/agent';
import { LobeAgentSession, LobeSessionType, SessionGroups } from '@/types/session';

Expand All @@ -10,7 +10,7 @@ import { ClientService } from './client';
const sessionService = new ClientService();

// Mock the SessionModel
vi.mock('@/database/client/models/session', () => {
vi.mock('@/database/_deprecated/models/session', () => {
return {
SessionModel: {
create: vi.fn(),
Expand All @@ -33,7 +33,7 @@ vi.mock('@/database/client/models/session', () => {
});

// Mock the SessionGroupModel
vi.mock('@/database/client/models/sessionGroup', () => {
vi.mock('@/database/_deprecated/models/sessionGroup', () => {
return {
SessionGroupModel: {
create: vi.fn(),
Expand Down
6 changes: 3 additions & 3 deletions src/services/session/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DeepPartial } from 'utility-types';

import { INBOX_SESSION_ID } from '@/const/session';
import { SessionModel } from '@/database/client/models/session';
import { SessionGroupModel } from '@/database/client/models/sessionGroup';
import { UserModel } from '@/database/client/models/user';
import { SessionModel } from '@/database/_deprecated/models/session';
import { SessionGroupModel } from '@/database/_deprecated/models/sessionGroup';
import { UserModel } from '@/database/_deprecated/models/user';
import { useUserStore } from '@/store/user';
import { LobeAgentChatConfig, LobeAgentConfig } from '@/types/agent';
import { MetaData } from '@/types/meta';
Expand Down
2 changes: 1 addition & 1 deletion src/services/sync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dataSync } from '@/database/client/core';
import { dataSync } from '@/database/_deprecated/core';
import { StartDataSyncParams } from '@/types/sync';

class SyncService {
Expand Down
6 changes: 3 additions & 3 deletions src/services/topic/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Mock, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';

import { SessionModel } from '@/database/client/models/session';
import { CreateTopicParams, TopicModel } from '@/database/client/models/topic';
import { SessionModel } from '@/database/_deprecated/models/session';
import { CreateTopicParams, TopicModel } from '@/database/_deprecated/models/topic';
import { ChatTopic } from '@/types/topic';

import { ClientService } from './client';

const topicService = new ClientService();
// Mock the TopicModel
vi.mock('@/database/client/models/topic', () => {
vi.mock('@/database/_deprecated/models/topic', () => {
return {
TopicModel: {
create: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/services/topic/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TopicModel } from '@/database/client/models/topic';
import { TopicModel } from '@/database/_deprecated/models/topic';
import { ChatTopic } from '@/types/topic';

import { CreateTopicParams, ITopicService, QueryTopicParams } from './type';
Expand Down
2 changes: 1 addition & 1 deletion src/services/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class UploadService {
};

uploadToClientDB = async (params: UploadFileParams, file: File) => {
const { FileModel } = await import('@/database/client/models/file');
const { FileModel } = await import('@/database/_deprecated/models/file');
const fileArrayBuffer = await file.arrayBuffer();

// save to local storage
Expand Down
4 changes: 2 additions & 2 deletions src/services/user/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DeepPartial } from 'utility-types';
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';

import { UserModel } from '@/database/client/models/user';
import { UserModel } from '@/database/_deprecated/models/user';
import { UserPreference } from '@/types/user';
import { UserSettings } from '@/types/user/settings';
import { AsyncLocalStorage } from '@/utils/localStorage';

import { ClientService } from './client';

vi.mock('@/database/client/models/user', () => ({
vi.mock('@/database/_deprecated/models/user', () => ({
UserModel: {
getUser: vi.fn(),
updateSettings: vi.fn(),
Expand Down
6 changes: 3 additions & 3 deletions src/services/user/client.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DeepPartial } from 'utility-types';

import { MessageModel } from '@/database/client/models/message';
import { SessionModel } from '@/database/client/models/session';
import { UserModel } from '@/database/client/models/user';
import { MessageModel } from '@/database/_deprecated/models/message';
import { SessionModel } from '@/database/_deprecated/models/session';
import { UserModel } from '@/database/_deprecated/models/user';
import { UserGuide, UserInitializationState, UserPreference } from '@/types/user';
import { UserSettings } from '@/types/user/settings';
import { AsyncLocalStorage } from '@/utils/localStorage';
Expand Down
2 changes: 1 addition & 1 deletion src/store/file/slices/chat/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useSWR from 'swr';
import { Mock, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';

import { notification } from '@/components/AntdStaticMethods';
import { DB_File } from '@/database/client/schemas/files';
import { DB_File } from '@/database/_deprecated/schemas/files';
import { fileService } from '@/services/file';
import { uploadService } from '@/services/upload';

Expand Down
2 changes: 1 addition & 1 deletion src/types/sync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LobeDBSchemaMap } from '@/database/client/core/db';
import { LobeDBSchemaMap } from '@/database/_deprecated/core/db';

export type OnSyncEvent = (tableKey: keyof LobeDBSchemaMap) => void;
export type OnSyncStatusChange = (status: PeerSyncStatus) => void;
Expand Down

0 comments on commit 7dff458

Please sign in to comment.