Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Restructure files, queries and mutations
Hakan Shehu25c2b35442fb
diff --git a/apps/desktop/components.json b/apps/desktop/components.jsonindex ed1fa076..b4e491ab 100644--- a/apps/desktop/components.json+++ b/apps/desktop/components.json@@ -12,6 +12,6 @@},"aliases": {"components": "@/renderer/components",- "utils": "@/lib/utils"+ "utils": "@/shared/lib/utils"}}diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.tsindex ca03bac9..39be848d 100644--- a/apps/desktop/electron.vite.config.ts+++ b/apps/desktop/electron.vite.config.ts@@ -21,9 +21,7 @@ export default defineConfig({resolve: {alias: {'@/main': resolve('src/main'),- '@/lib': resolve('src/lib'),- '@/types': resolve('src/types'),- '@/operations': resolve('src/operations'),+ '@/shared': resolve('src/shared'),},},},@@ -35,9 +33,7 @@ export default defineConfig({],resolve: {alias: {- '@/lib': resolve('src/lib'),- '@/types': resolve('src/types'),- '@/operations': resolve('src/operations'),+ '@/shared': resolve('src/shared'),},},},@@ -45,9 +41,7 @@ export default defineConfig({resolve: {alias: {'@/renderer': resolve('src/renderer'),- '@/lib': resolve('src/lib'),- '@/operations': resolve('src/operations'),- '@/types': resolve('src/types'),+ '@/shared': resolve('src/shared'),},},plugins: [react()],diff --git a/apps/desktop/src/main/data/database-service.ts b/apps/desktop/src/main/data/database-service.tsindex 5934ff09..13fb7a11 100644--- a/apps/desktop/src/main/data/database-service.ts+++ b/apps/desktop/src/main/data/database-service.ts@@ -56,6 +56,13 @@ class DatabaseService {return workspaceDatabase;}+ public async getWorkspaceDatabases(): Promise<+ Map<string, Kysely<WorkspaceDatabaseSchema>>+ > {+ await this.waitForInit();+ return this.workspaceDatabases;+ }+public async deleteWorkspaceDatabase(userId: string): Promise<void> {await this.waitForInit();diff --git a/apps/desktop/src/main/handlers/messages/index.ts b/apps/desktop/src/main/handlers/messages/index.tsindex c417e0cc..f5347120 100644--- a/apps/desktop/src/main/handlers/messages/index.ts+++ b/apps/desktop/src/main/handlers/messages/index.ts@@ -1,4 +1,4 @@-import { MessageHandler, MessageMap } from '@/operations/messages';+import { MessageHandler, MessageMap } from '@/shared/messages';import { LocalNodeSyncMessageHandler } from '@/main/handlers/messages/local-node-sync';import { LocalNodeDeleteMessageHandler } from '@/main/handlers/messages/local-node-delete';import { ServerNodeSyncMessageHandler } from '@/main/handlers/messages/server-node-sync';diff --git a/apps/desktop/src/main/handlers/messages/local-node-delete.ts b/apps/desktop/src/main/handlers/messages/local-node-delete.tsindex 0e0b19f5..a8df258e 100644--- a/apps/desktop/src/main/handlers/messages/local-node-delete.ts+++ b/apps/desktop/src/main/handlers/messages/local-node-delete.ts@@ -1,5 +1,5 @@-import { MessageContext, MessageHandler } from '@/operations/messages';-import { LocalNodeDeleteMessageInput } from '@/operations/messages/local-node-delete';+import { MessageContext, MessageHandler } from '@/shared/messages';+import { LocalNodeDeleteMessageInput } from '@/shared/messages/local-node-delete';import { socketService } from '@/main/services/socket-service';export class LocalNodeDeleteMessageHandlerdiff --git a/apps/desktop/src/main/handlers/messages/local-node-sync.ts b/apps/desktop/src/main/handlers/messages/local-node-sync.tsindex d760c488..8e481112 100644--- a/apps/desktop/src/main/handlers/messages/local-node-sync.ts+++ b/apps/desktop/src/main/handlers/messages/local-node-sync.ts@@ -1,5 +1,5 @@-import { MessageContext, MessageHandler } from '@/operations/messages';-import { LocalNodeSyncMessageInput } from '@/operations/messages/local-node-sync';+import { MessageContext, MessageHandler } from '@/shared/messages';+import { LocalNodeSyncMessageInput } from '../../../shared/messages/local-node-sync';import { socketService } from '@/main/services/socket-service';export class LocalNodeSyncMessageHandlerdiff --git a/apps/desktop/src/main/handlers/messages/local-user-node-sync.ts b/apps/desktop/src/main/handlers/messages/local-user-node-sync.tsindex ea276af8..1cb09f3a 100644--- a/apps/desktop/src/main/handlers/messages/local-user-node-sync.ts+++ b/apps/desktop/src/main/handlers/messages/local-user-node-sync.ts@@ -1,5 +1,5 @@-import { MessageContext, MessageHandler } from '@/operations/messages';-import { LocalUserNodeSyncMessageInput } from '@/operations/messages/local-user-node-sync';+import { MessageContext, MessageHandler } from '@/shared/messages';+import { LocalUserNodeSyncMessageInput } from '../../../shared/messages/local-user-node-sync';import { socketService } from '@/main/services/socket-service';export class LocalUserNodeSyncMessageHandlerdiff --git a/apps/desktop/src/main/handlers/messages/server-node-delete.ts b/apps/desktop/src/main/handlers/messages/server-node-delete.tsindex 79810d69..7863b5f0 100644--- a/apps/desktop/src/main/handlers/messages/server-node-delete.ts+++ b/apps/desktop/src/main/handlers/messages/server-node-delete.ts@@ -1,6 +1,6 @@-import { MessageContext, MessageHandler } from '@/operations/messages';-import { ServerNodeDeleteMessageInput } from '@/operations/messages/server-node-delete';-import { mediator } from '@/main/mediator';+import { MessageContext, MessageHandler } from '@/shared/messages';+import { ServerNodeDeleteMessageInput } from '../../../shared/messages/server-node-delete';+import { mutationService } from '@/main/services/mutation-service';export class ServerNodeDeleteMessageHandlerimplements MessageHandler<ServerNodeDeleteMessageInput>@@ -9,7 +9,7 @@ export class ServerNodeDeleteMessageHandlercontext: MessageContext,input: ServerNodeDeleteMessageInput): Promise<void> {- await mediator.executeMutation({+ await mutationService.executeMutation({type: 'server_node_delete',accountId: context.accountId,id: input.id,diff --git a/apps/desktop/src/main/handlers/messages/server-node-sync.ts b/apps/desktop/src/main/handlers/messages/server-node-sync.tsindex e2eed9ef..cc907646 100644--- a/apps/desktop/src/main/handlers/messages/server-node-sync.ts+++ b/apps/desktop/src/main/handlers/messages/server-node-sync.ts@@ -1,6 +1,6 @@-import { MessageContext, MessageHandler } from '@/operations/messages';-import { ServerNodeSyncMessageInput } from '@/operations/messages/server-node-sync';-import { mediator } from '@/main/mediator';+import { MessageContext, MessageHandler } from '@/shared/messages';+import { ServerNodeSyncMessageInput } from '../../../shared/messages/server-node-sync';+import { mutationService } from '@/main/services/mutation-service';export class ServerNodeSyncMessageHandlerimplements MessageHandler<ServerNodeSyncMessageInput>@@ -9,7 +9,7 @@ export class ServerNodeSyncMessageHandlercontext: MessageContext,input: ServerNodeSyncMessageInput): Promise<void> {- await mediator.executeMutation({+ await mutationService.executeMutation({type: 'server_node_sync',accountId: context.accountId,id: input.id,diff --git a/apps/desktop/src/main/handlers/messages/server-user-node-sync.ts b/apps/desktop/src/main/handlers/messages/server-user-node-sync.tsindex 7150d0fe..61781f4f 100644--- a/apps/desktop/src/main/handlers/messages/server-user-node-sync.ts+++ b/apps/desktop/src/main/handlers/messages/server-user-node-sync.ts@@ -1,6 +1,6 @@-import { MessageContext, MessageHandler } from '@/operations/messages';-import { ServerUserNodeSyncMessageInput } from '@/operations/messages/server-user-node-sync';-import { mediator } from '@/main/mediator';+import { MessageContext, MessageHandler } from '@/shared/messages';+import { ServerUserNodeSyncMessageInput } from '../../../shared/messages/server-user-node-sync';+import { mutationService } from '@/main/services/mutation-service';export class ServerUserNodeSyncMessageHandlerimplements MessageHandler<ServerUserNodeSyncMessageInput>@@ -9,7 +9,7 @@ export class ServerUserNodeSyncMessageHandlercontext: MessageContext,input: ServerUserNodeSyncMessageInput): Promise<void> {- await mediator.executeMutation({+ await mutationService.executeMutation({type: 'server_user_node_sync',accountId: context.accountId,nodeId: input.nodeId,diff --git a/apps/desktop/src/main/handlers/mutations/account-update.ts b/apps/desktop/src/main/handlers/mutations/account-update.tsindex 535927b7..8282e2ef 100644--- a/apps/desktop/src/main/handlers/mutations/account-update.ts+++ b/apps/desktop/src/main/handlers/mutations/account-update.ts@@ -1,15 +1,19 @@import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';-import { MutationHandler, MutationResult } from '@/main/types';-import { AccountUpdateOutput } from '@/types/accounts';-import { AccountUpdateMutationInput } from '@/operations/mutations/account-update';+import { httpClient } from '@/shared/lib/http-client';+import { MutationHandler } from '@/main/types';+import { AccountUpdateOutput } from '@/shared/types/accounts';+import {+ AccountUpdateMutationInput,+ AccountUpdateMutationOutput,+} from '@/shared/mutations/account-update';+import { eventBus } from '@/shared/lib/event-bus';export class AccountUpdateMutationHandlerimplements MutationHandler<AccountUpdateMutationInput>{async handleMutation(input: AccountUpdateMutationInput- ): Promise<MutationResult<AccountUpdateMutationInput>> {+ ): Promise<AccountUpdateMutationOutput> {const account = await databaseService.appDatabase.selectFrom('accounts').selectAll()@@ -43,25 +47,36 @@ export class AccountUpdateMutationHandler});- await databaseService.appDatabase+ const updatedAccount = await databaseService.appDatabase.updateTable('accounts').set({name: data.name,avatar: data.avatar,}).where('id', '=', input.id)- .execute();+ .returningAll()+ .executeTakeFirst();- return {- output: {- success: true,+ if (!updatedAccount) {+ throw new Error('Account not found');+ }++ eventBus.publish({+ type: 'account_updated',+ account: {+ id: updatedAccount.id,+ name: updatedAccount.name,+ email: updatedAccount.email,+ token: updatedAccount.token,+ avatar: updatedAccount.avatar,+ deviceId: updatedAccount.device_id,+ server: updatedAccount.server,+ status: updatedAccount.status,},- changes: [- {- type: 'app',- table: 'accounts',- },- ],+ });++ return {+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/avatar-upload.ts b/apps/desktop/src/main/handlers/mutations/avatar-upload.tsindex f12aac55..ffa0c48f 100644--- a/apps/desktop/src/main/handlers/mutations/avatar-upload.ts+++ b/apps/desktop/src/main/handlers/mutations/avatar-upload.ts@@ -1,9 +1,12 @@import fs from 'fs';import FormData from 'form-data';import { databaseService } from '@/main/data/database-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { AvatarUploadMutationInput } from '@/operations/mutations/avatar-upload';-import { httpClient } from '@/lib/http-client';+import { MutationHandler } from '@/main/types';+import {+ AvatarUploadMutationInput,+ AvatarUploadMutationOutput,+} from '@/shared/mutations/avatar-upload';+import { httpClient } from '@/shared/lib/http-client';interface AvatarUploadResponse {id: string;@@ -14,7 +17,7 @@ export class AvatarUploadMutationHandler{async handleMutation(input: AvatarUploadMutationInput- ): Promise<MutationResult<AvatarUploadMutationInput>> {+ ): Promise<AvatarUploadMutationOutput> {const credentials = await databaseService.appDatabase.selectFrom('accounts').innerJoin('servers', 'accounts.server', 'servers.domain')@@ -24,10 +27,8 @@ export class AvatarUploadMutationHandlerif (!credentials) {return {- output: {- status: 'error',- id: null,- },+ status: 'error',+ id: null,};}@@ -49,10 +50,8 @@ export class AvatarUploadMutationHandler);return {- output: {- status: 'success',- id: data.id,- },+ status: 'success',+ id: data.id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/channel-create.ts b/apps/desktop/src/main/handlers/mutations/channel-create.tsindex 9af5c4cc..cdc1d07f 100644--- a/apps/desktop/src/main/handlers/mutations/channel-create.ts+++ b/apps/desktop/src/main/handlers/mutations/channel-create.ts@@ -1,8 +1,11 @@import { databaseService } from '@/main/data/database-service';import { generateId, IdType } from '@colanode/core';-import { generateNodeIndex } from '@/lib/nodes';-import { MutationHandler, MutationResult } from '@/main/types';-import { ChannelCreateMutationInput } from '@/operations/mutations/channel-create';+import { generateNodeIndex } from '@/shared/lib/nodes';+import { MutationHandler } from '@/main/types';+import {+ ChannelCreateMutationInput,+ ChannelCreateMutationOutput,+} from '@/shared/mutations/channel-create';import { ChannelAttributes } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -11,7 +14,7 @@ export class ChannelCreateMutationHandler{async handleMutation(input: ChannelCreateMutationInput- ): Promise<MutationResult<ChannelCreateMutationInput>> {+ ): Promise<ChannelCreateMutationOutput> {const workspaceDatabase = await databaseService.getWorkspaceDatabase(input.userId);@@ -48,21 +51,7 @@ export class ChannelCreateMutationHandlerawait nodeService.createNode(input.userId, { id, attributes });return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id: id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/chat-create.ts b/apps/desktop/src/main/handlers/mutations/chat-create.tsindex 9fb67a6d..a00c45f8 100644--- a/apps/desktop/src/main/handlers/mutations/chat-create.ts+++ b/apps/desktop/src/main/handlers/mutations/chat-create.ts@@ -1,7 +1,10 @@import { databaseService } from '@/main/data/database-service';import { generateId, IdType, NodeTypes, NodeRoles } from '@colanode/core';-import { MutationHandler, MutationResult } from '@/main/types';-import { ChatCreateMutationInput } from '@/operations/mutations/chat-create';+import { MutationHandler } from '@/main/types';+import {+ ChatCreateMutationInput,+ ChatCreateMutationOutput,+} from '@/shared/mutations/chat-create';import { sql } from 'kysely';import { ChatAttributes } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -15,7 +18,7 @@ export class ChatCreateMutationHandler{public async handleMutation(input: ChatCreateMutationInput- ): Promise<MutationResult<ChatCreateMutationInput>> {+ ): Promise<ChatCreateMutationOutput> {const workspaceDatabase = await databaseService.getWorkspaceDatabase(input.userId);@@ -32,9 +35,7 @@ export class ChatCreateMutationHandlerif (existingChats.rows?.length > 0) {const chat = existingChats.rows[0];return {- output: {- id: chat.id,- },+ id: chat.id,};}@@ -51,21 +52,7 @@ export class ChatCreateMutationHandlerawait nodeService.createNode(input.userId, { id, attributes });return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/database-create.ts b/apps/desktop/src/main/handlers/mutations/database-create.tsindex f5a2d85e..4187c2cb 100644--- a/apps/desktop/src/main/handlers/mutations/database-create.ts+++ b/apps/desktop/src/main/handlers/mutations/database-create.ts@@ -1,7 +1,10 @@import { generateId, IdType } from '@colanode/core';-import { generateNodeIndex } from '@/lib/nodes';-import { MutationHandler, MutationResult } from '@/main/types';-import { DatabaseCreateMutationInput } from '@/operations/mutations/database-create';+import { generateNodeIndex } from '@/shared/lib/nodes';+import { MutationHandler } from '@/main/types';+import {+ DatabaseCreateMutationInput,+ DatabaseCreateMutationOutput,+} from '@/shared/mutations/database-create';import { DatabaseAttributes } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -10,7 +13,7 @@ export class DatabaseCreateMutationHandler{async handleMutation(input: DatabaseCreateMutationInput- ): Promise<MutationResult<DatabaseCreateMutationInput>> {+ ): Promise<DatabaseCreateMutationOutput> {const databaseId = generateId(IdType.Database);const viewId = generateId(IdType.View);const fieldId = generateId(IdType.Field);@@ -48,21 +51,7 @@ export class DatabaseCreateMutationHandler});return {- output: {- id: databaseId,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id: databaseId,};}}diff --git a/apps/desktop/src/main/handlers/mutations/document-save.ts b/apps/desktop/src/main/handlers/mutations/document-save.tsindex b27df3ec..0d395c84 100644--- a/apps/desktop/src/main/handlers/mutations/document-save.ts+++ b/apps/desktop/src/main/handlers/mutations/document-save.ts@@ -1,6 +1,9 @@-import { MutationHandler, MutationResult } from '@/main/types';-import { DocumentSaveMutationInput } from '@/operations/mutations/document-save';-import { mapContentsToBlocks } from '@/lib/editor';+import { MutationHandler } from '@/main/types';+import {+ DocumentSaveMutationInput,+ DocumentSaveMutationOutput,+} from '@/shared/mutations/document-save';+import { mapContentsToBlocks } from '@/shared/lib/editor';import { Block } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -9,7 +12,7 @@ export class DocumentSaveMutationHandler{async handleMutation(input: DocumentSaveMutationInput- ): Promise<MutationResult<DocumentSaveMutationInput>> {+ ): Promise<DocumentSaveMutationOutput> {await nodeService.updateNode(input.documentId,input.userId,@@ -44,21 +47,7 @@ export class DocumentSaveMutationHandler);return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/email-login.ts b/apps/desktop/src/main/handlers/mutations/email-login.tsindex 5cf3da79..35aa20b8 100644--- a/apps/desktop/src/main/handlers/mutations/email-login.ts+++ b/apps/desktop/src/main/handlers/mutations/email-login.ts@@ -1,15 +1,19 @@-import { LoginOutput } from '@/types/accounts';+import { LoginOutput } from '@/shared/types/accounts';import { databaseService } from '@/main/data/database-service';-import { EmailLoginMutationInput } from '@/operations/mutations/email-login';-import { MutationChange, MutationHandler, MutationResult } from '@/main/types';-import { httpClient } from '@/lib/http-client';+import {+ EmailLoginMutationInput,+ EmailLoginMutationOutput,+} from '@/shared/mutations/email-login';+import { MutationHandler } from '@/main/types';+import { httpClient } from '@/shared/lib/http-client';+import { eventBus } from '@/shared/lib/event-bus';export class EmailLoginMutationHandlerimplements MutationHandler<EmailLoginMutationInput>{async handleMutation(input: EmailLoginMutationInput- ): Promise<MutationResult<EmailLoginMutationInput>> {+ ): Promise<EmailLoginMutationOutput> {const server = await databaseService.appDatabase.selectFrom('servers').selectAll()@@ -18,9 +22,7 @@ export class EmailLoginMutationHandlerif (!server) {return {- output: {- success: false,- },+ success: false,};}@@ -36,7 +38,6 @@ export class EmailLoginMutationHandler});- const changedTables: MutationChange[] = [];await databaseService.appDatabase.transaction().execute(async (trx) => {await trx.insertInto('accounts')@@ -52,11 +53,6 @@ export class EmailLoginMutationHandler}).execute();- changedTables.push({- type: 'app',- table: 'accounts',- });-if (data.workspaces.length === 0) {return;}@@ -76,20 +72,33 @@ export class EmailLoginMutationHandler}))).execute();+ });- changedTables.push({- type: 'app',- table: 'workspaces',- });+ eventBus.publish({+ type: 'account_created',+ account: data.account,});+ if (data.workspaces.length > 0) {+ for (const workspace of data.workspaces) {+ eventBus.publish({+ type: 'workspace_created',+ workspace: {+ id: workspace.id,+ name: workspace.name,+ versionId: workspace.versionId,+ accountId: workspace.user.accountId,+ role: workspace.user.role,+ userId: workspace.user.id,+ },+ });+ }+ }+return {- output: {- success: true,- account: data.account,- workspaces: data.workspaces,- },- changes: changedTables,+ success: true,+ account: data.account,+ workspaces: data.workspaces,};}}diff --git a/apps/desktop/src/main/handlers/mutations/email-register.ts b/apps/desktop/src/main/handlers/mutations/email-register.tsindex 904ab841..019c762e 100644--- a/apps/desktop/src/main/handlers/mutations/email-register.ts+++ b/apps/desktop/src/main/handlers/mutations/email-register.ts@@ -1,15 +1,19 @@-import { LoginOutput } from '@/types/accounts';+import { LoginOutput } from '@/shared/types/accounts';import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';-import { EmailRegisterMutationInput } from '@/operations/mutations/email-register';-import { MutationChange, MutationHandler, MutationResult } from '@/main/types';+import { httpClient } from '@/shared/lib/http-client';+import {+ EmailRegisterMutationInput,+ EmailRegisterMutationOutput,+} from '@/shared/mutations/email-register';+import { MutationHandler } from '@/main/types';+import { eventBus } from '@/shared/lib/event-bus';export class EmailRegisterMutationHandlerimplements MutationHandler<EmailRegisterMutationInput>{- handleMutation = async (+ async handleMutation(input: EmailRegisterMutationInput- ): Promise<MutationResult<EmailRegisterMutationInput>> => {+ ): Promise<EmailRegisterMutationOutput> {const server = await databaseService.appDatabase.selectFrom('servers').selectAll()@@ -18,9 +22,7 @@ export class EmailRegisterMutationHandlerif (!server) {return {- output: {- success: false,- },+ success: false,};}@@ -37,7 +39,6 @@ export class EmailRegisterMutationHandler});- const changedTables: MutationChange[] = [];await databaseService.appDatabase.transaction().execute(async (trx) => {await trx.insertInto('accounts')@@ -53,11 +54,6 @@ export class EmailRegisterMutationHandler}).execute();- changedTables.push({- type: 'app',- table: 'accounts',- });-if (data.workspaces.length === 0) {return;}@@ -77,20 +73,33 @@ export class EmailRegisterMutationHandler}))).execute();+ });- changedTables.push({- type: 'app',- table: 'workspaces',- });+ eventBus.publish({+ type: 'account_created',+ account: data.account,});+ if (data.workspaces.length > 0) {+ for (const workspace of data.workspaces) {+ eventBus.publish({+ type: 'workspace_created',+ workspace: {+ id: workspace.id,+ name: workspace.name,+ versionId: workspace.versionId,+ accountId: workspace.user.accountId,+ role: workspace.user.role,+ userId: workspace.user.id,+ },+ });+ }+ }+return {- output: {- success: true,- account: data.account,- workspaces: data.workspaces,- },- changes: changedTables,+ success: true,+ account: data.account,+ workspaces: data.workspaces,};- };+ }}diff --git a/apps/desktop/src/main/handlers/mutations/field-create.ts b/apps/desktop/src/main/handlers/mutations/field-create.tsindex 454600fc..73434bf7 100644--- a/apps/desktop/src/main/handlers/mutations/field-create.ts+++ b/apps/desktop/src/main/handlers/mutations/field-create.ts@@ -1,8 +1,11 @@import { generateId, IdType } from '@colanode/core';-import { generateNodeIndex } from '@/lib/nodes';-import { compareString } from '@/lib/utils';-import { MutationHandler, MutationResult } from '@/main/types';-import { FieldCreateMutationInput } from '@/operations/mutations/field-create';+import { generateNodeIndex } from '@/shared/lib/nodes';+import { compareString } from '@/shared/lib/utils';+import { MutationHandler } from '@/main/types';+import {+ FieldCreateMutationInput,+ FieldCreateMutationOutput,+} from '@/shared/mutations/field-create';import { nodeService } from '@/main/services/node-service';export class FieldCreateMutationHandler@@ -10,7 +13,7 @@ export class FieldCreateMutationHandler{async handleMutation(input: FieldCreateMutationInput- ): Promise<MutationResult<FieldCreateMutationInput>> {+ ): Promise<FieldCreateMutationOutput> {const fieldId = generateId(IdType.Field);await nodeService.updateNode(input.databaseId,@@ -38,21 +41,7 @@ export class FieldCreateMutationHandler);return {- output: {- id: fieldId,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id: fieldId,};}}diff --git a/apps/desktop/src/main/handlers/mutations/file-create.ts b/apps/desktop/src/main/handlers/mutations/file-create.tsindex f0248e69..2bb5769c 100644--- a/apps/desktop/src/main/handlers/mutations/file-create.ts+++ b/apps/desktop/src/main/handlers/mutations/file-create.ts@@ -1,6 +1,9 @@-import { MutationHandler, MutationResult } from '@/main/types';+import { MutationHandler } from '@/main/types';import { generateId, IdType } from '@colanode/core';-import { FileCreateMutationInput } from '@/operations/mutations/file-create';+import {+ FileCreateMutationInput,+ FileCreateMutationOutput,+} from '@/shared/mutations/file-create';import { fileService } from '@/main/services/file-service';import { FileAttributes } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -10,7 +13,7 @@ export class FileCreateMutationHandler{async handleMutation(input: FileCreateMutationInput- ): Promise<MutationResult<FileCreateMutationInput>> {+ ): Promise<FileCreateMutationOutput> {const metadata = fileService.getFileMetadata(input.filePath);if (!metadata) {throw new Error('Invalid file');@@ -52,31 +55,7 @@ export class FileCreateMutationHandler});return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- {- type: 'workspace',- table: 'downloads',- userId: input.userId,- },- {- type: 'workspace',- table: 'uploads',- userId: input.userId,- },- ],+ id: id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/file-download.ts b/apps/desktop/src/main/handlers/mutations/file-download.tsindex 31ee2133..07ebf322 100644--- a/apps/desktop/src/main/handlers/mutations/file-download.ts+++ b/apps/desktop/src/main/handlers/mutations/file-download.ts@@ -1,13 +1,17 @@+import { eventBus } from '@/shared/lib/event-bus';import { databaseService } from '@/main/data/database-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { FileDownloadMutationInput } from '@/operations/mutations/file-download';+import { MutationHandler } from '@/main/types';+import {+ FileDownloadMutationInput,+ FileDownloadMutationOutput,+} from '@/shared/mutations/file-download';export class FileDownloadMutationHandlerimplements MutationHandler<FileDownloadMutationInput>{async handleMutation(input: FileDownloadMutationInput- ): Promise<MutationResult<FileDownloadMutationInput>> {+ ): Promise<FileDownloadMutationOutput> {const workspaceDatabase = await databaseService.getWorkspaceDatabase(input.userId);@@ -20,9 +24,7 @@ export class FileDownloadMutationHandlerif (!node) {return {- output: {- success: false,- },+ success: false,};}@@ -34,33 +36,35 @@ export class FileDownloadMutationHandlerif (download) {return {- output: {- success: true,- },+ success: true,};}+ const createdAt = new Date();await workspaceDatabase.insertInto('downloads').values({node_id: input.fileId,- created_at: new Date().toISOString(),+ created_at: createdAt.toISOString(),progress: 0,retry_count: 0,}).execute();- return {- output: {- success: true,+ eventBus.publish({+ type: 'download_created',+ userId: input.userId,+ download: {+ nodeId: node.id,+ createdAt: createdAt.toISOString(),+ updatedAt: null,+ progress: 0,+ retryCount: 0,},- changes: [- {- type: 'workspace',- table: 'downloads',- userId: input.userId,- },- ],+ });++ return {+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/folder-create.ts b/apps/desktop/src/main/handlers/mutations/folder-create.tsindex a8a290a5..3fd3a808 100644--- a/apps/desktop/src/main/handlers/mutations/folder-create.ts+++ b/apps/desktop/src/main/handlers/mutations/folder-create.ts@@ -1,6 +1,9 @@import { generateId, IdType } from '@colanode/core';-import { MutationHandler, MutationResult } from '@/main/types';-import { FolderCreateMutationInput } from '@/operations/mutations/folder-create';+import { MutationHandler } from '@/main/types';+import {+ FolderCreateMutationInput,+ FolderCreateMutationOutput,+} from '@/shared/mutations/folder-create';import { FolderAttributes } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -9,7 +12,7 @@ export class FolderCreateMutationHandler{async handleMutation(input: FolderCreateMutationInput- ): Promise<MutationResult<FolderCreateMutationInput>> {+ ): Promise<FolderCreateMutationOutput> {const id = generateId(IdType.Folder);const attributes: FolderAttributes = {type: 'folder',@@ -21,21 +24,7 @@ export class FolderCreateMutationHandlerawait nodeService.createNode(input.userId, { id, attributes });return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id: id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/index.ts b/apps/desktop/src/main/handlers/mutations/index.tsindex 5f3b9270..6f1b247f 100644--- a/apps/desktop/src/main/handlers/mutations/index.ts+++ b/apps/desktop/src/main/handlers/mutations/index.ts@@ -1,4 +1,4 @@-import { MutationMap } from '@/operations/mutations';+import { MutationMap } from '@/shared/mutations';import { MutationHandler } from '@/main/types';import { EmailLoginMutationHandler } from '@/main/handlers/mutations/email-login';import { EmailRegisterMutationHandler } from '@/main/handlers/mutations/email-register';diff --git a/apps/desktop/src/main/handlers/mutations/logout.ts b/apps/desktop/src/main/handlers/mutations/logout.tsindex adef5a12..4848c009 100644--- a/apps/desktop/src/main/handlers/mutations/logout.ts+++ b/apps/desktop/src/main/handlers/mutations/logout.ts@@ -1,18 +1,22 @@import fs from 'fs';import { databaseService } from '@/main/data/database-service';-import { LogoutMutationInput } from '@/operations/mutations/logout';-import { MutationHandler, MutationResult } from '@/main/types';+import {+ LogoutMutationInput,+ LogoutMutationOutput,+} from '@/shared/mutations/logout';+import { MutationHandler } from '@/main/types';import {getAccountAvatarsDirectoryPath,getWorkspaceDirectoryPath,} from '@/main/utils';+import { eventBus } from '@/shared/lib/event-bus';export class LogoutMutationHandlerimplements MutationHandler<LogoutMutationInput>{async handleMutation(input: LogoutMutationInput- ): Promise<MutationResult<LogoutMutationInput>> {+ ): Promise<LogoutMutationOutput> {const account = await databaseService.appDatabase.selectFrom('accounts').selectAll()@@ -21,9 +25,7 @@ export class LogoutMutationHandlerif (!account) {return {- output: {- success: false,- },+ success: false,};}@@ -47,16 +49,59 @@ export class LogoutMutationHandlerfs.rmSync(avatarsDir, { recursive: true });}- await databaseService.appDatabase+ const deletedAccount = await databaseService.appDatabase.deleteFrom('accounts')+ .returningAll().where('id', '=', account.id)- .execute();+ .executeTakeFirst();- await databaseService.appDatabase+ if (!deletedAccount) {+ return {+ success: false,+ };+ }++ eventBus.publish({+ type: 'account_deleted',+ account: {+ id: deletedAccount.id,+ server: deletedAccount.server,+ name: deletedAccount.name,+ email: deletedAccount.email,+ avatar: deletedAccount.avatar,+ token: deletedAccount.token,+ deviceId: deletedAccount.device_id,+ status: deletedAccount.status,+ },+ });++ const deletedWorkspaces = await databaseService.appDatabase.deleteFrom('workspaces').where('account_id', '=', account.id).execute();+ if (deletedWorkspaces.length !== workspaces.length) {+ return {+ success: false,+ };+ }++ for (const workspace of workspaces) {+ eventBus.publish({+ type: 'workspace_deleted',+ workspace: {+ id: workspace.workspace_id,+ userId: workspace.user_id,+ name: workspace.name,+ avatar: workspace.avatar,+ description: workspace.description,+ role: workspace.role,+ versionId: workspace.version_id,+ accountId: workspace.account_id,+ },+ });+ }+await databaseService.appDatabase.insertInto('deleted_tokens').values({@@ -68,19 +113,7 @@ export class LogoutMutationHandler.execute();return {- output: {- success: true,- },- changes: [- {- type: 'app',- table: 'accounts',- },- {- type: 'app',- table: 'workspaces',- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.ts b/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.tsindex b99b7ef6..ce8f00b7 100644--- a/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.ts+++ b/apps/desktop/src/main/handlers/mutations/mark-node-as-seen.ts@@ -1,15 +1,18 @@import { generateId, IdType } from '@colanode/core';import { databaseService } from '@/main/data/database-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { MarkNodeAsSeenMutationInput } from '@/operations/mutations/mark-node-as-seen';-import { LocalUserNodeChangeData } from '@/types/sync';+import { MutationHandler } from '@/main/types';+import {+ MarkNodeAsSeenMutationInput,+ MarkNodeAsSeenMutationOutput,+} from '@/shared/mutations/mark-node-as-seen';+import { LocalUserNodeChangeData } from '@/shared/types/sync';export class MarkNodeAsSeenMutationHandlerimplements MutationHandler<MarkNodeAsSeenMutationInput>{async handleMutation(input: MarkNodeAsSeenMutationInput- ): Promise<MutationResult<MarkNodeAsSeenMutationInput>> {+ ): Promise<MarkNodeAsSeenMutationOutput> {const workspaceDatabase = await databaseService.getWorkspaceDatabase(input.userId);@@ -48,21 +51,7 @@ export class MarkNodeAsSeenMutationHandler});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'user_nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/message-create.ts b/apps/desktop/src/main/handlers/mutations/message-create.tsindex 2f1733d8..a95b7109 100644--- a/apps/desktop/src/main/handlers/mutations/message-create.ts+++ b/apps/desktop/src/main/handlers/mutations/message-create.ts@@ -1,7 +1,10 @@import { generateId, IdType, EditorNodeTypes, NodeTypes } from '@colanode/core';-import { MutationChange, MutationHandler, MutationResult } from '@/main/types';-import { MessageCreateMutationInput } from '@/operations/mutations/message-create';-import { mapContentsToBlocks } from '@/lib/editor';+import { MutationHandler } from '@/main/types';+import {+ MessageCreateMutationInput,+ MessageCreateMutationOutput,+} from '@/shared/mutations/message-create';+import { mapContentsToBlocks } from '@/shared/lib/editor';import { fileService } from '@/main/services/file-service';import { Block, FileAttributes, MessageAttributes } from '@colanode/core';import { CreateNodeInput, nodeService } from '@/main/services/node-service';@@ -11,9 +14,8 @@ export class MessageCreateMutationHandler{async handleMutation(input: MessageCreateMutationInput- ): Promise<MutationResult<MessageCreateMutationInput>> {+ ): Promise<MessageCreateMutationOutput> {const inputs: CreateNodeInput[] = [];- let hasFiles = false;const messageId = generateId(IdType.Message);const createdAt = new Date().toISOString();@@ -71,8 +73,6 @@ export class MessageCreateMutationHandlerretry_count: 0,},});-- hasFiles = true;}}@@ -92,38 +92,8 @@ export class MessageCreateMutationHandlerinputs.unshift({ id: messageId, attributes: messageAttributes });await nodeService.createNode(input.userId, inputs);- const mutationChanges: MutationChange[] = [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ];-- if (hasFiles) {- mutationChanges.push({- type: 'workspace',- table: 'downloads',- userId: input.userId,- });-- mutationChanges.push({- type: 'workspace',- table: 'uploads',- userId: input.userId,- });- }-return {- output: {- id: messageId,- },- changes: mutationChanges,+ id: messageId,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-attribute-delete.ts b/apps/desktop/src/main/handlers/mutations/node-attribute-delete.tsindex bf728032..48ef7026 100644--- a/apps/desktop/src/main/handlers/mutations/node-attribute-delete.ts+++ b/apps/desktop/src/main/handlers/mutations/node-attribute-delete.ts@@ -1,5 +1,8 @@-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeAttributeDeleteMutationInput } from '@/operations/mutations/node-attribute-delete';+import { MutationHandler } from '@/main/types';+import {+ NodeAttributeDeleteMutationInput,+ NodeAttributeDeleteMutationOutput,+} from '@/shared/mutations/node-attribute-delete';import { nodeService } from '@/main/services/node-service';import { unset } from 'lodash-es';@@ -8,28 +11,14 @@ export class NodeAttributeDeleteMutationHandler{async handleMutation(input: NodeAttributeDeleteMutationInput- ): Promise<MutationResult<NodeAttributeDeleteMutationInput>> {+ ): Promise<NodeAttributeDeleteMutationOutput> {await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {unset(attributes, input.path);return attributes;});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-attribute-set.ts b/apps/desktop/src/main/handlers/mutations/node-attribute-set.tsindex 9855b5ed..6afa6f6b 100644--- a/apps/desktop/src/main/handlers/mutations/node-attribute-set.ts+++ b/apps/desktop/src/main/handlers/mutations/node-attribute-set.ts@@ -1,5 +1,8 @@-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeAttributeSetMutationInput } from '@/operations/mutations/node-attribute-set';+import { MutationHandler } from '@/main/types';+import {+ NodeAttributeSetMutationInput,+ NodeAttributeSetMutationOutput,+} from '@/shared/mutations/node-attribute-set';import { nodeService } from '@/main/services/node-service';import { set } from 'lodash-es';@@ -8,28 +11,14 @@ export class NodeAttributeSetMutationHandler{async handleMutation(input: NodeAttributeSetMutationInput- ): Promise<MutationResult<NodeAttributeSetMutationInput>> {+ ): Promise<NodeAttributeSetMutationOutput> {await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {set(attributes, input.path, input.value);return attributes;});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-collaborator-create.ts b/apps/desktop/src/main/handlers/mutations/node-collaborator-create.tsindex 72999a1c..6bda0225 100644--- a/apps/desktop/src/main/handlers/mutations/node-collaborator-create.ts+++ b/apps/desktop/src/main/handlers/mutations/node-collaborator-create.ts@@ -1,5 +1,8 @@-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeCollaboratorCreateMutationInput } from '@/operations/mutations/node-collaborator-create';+import { MutationHandler } from '@/main/types';+import {+ NodeCollaboratorCreateMutationInput,+ NodeCollaboratorCreateMutationOutput,+} from '@/shared/mutations/node-collaborator-create';import { nodeService } from '@/main/services/node-service';import { set } from 'lodash-es';@@ -8,7 +11,7 @@ export class NodeCollaboratorCreateMutationHandler{async handleMutation(input: NodeCollaboratorCreateMutationInput- ): Promise<MutationResult<NodeCollaboratorCreateMutationInput>> {+ ): Promise<NodeCollaboratorCreateMutationOutput> {await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {for (const collaboratorId of input.collaboratorIds) {set(attributes, `collaborators.${collaboratorId}`, input.role);@@ -17,21 +20,7 @@ export class NodeCollaboratorCreateMutationHandler});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.ts b/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.tsindex 4e9a1e5c..0542e681 100644--- a/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.ts+++ b/apps/desktop/src/main/handlers/mutations/node-collaborator-delete.ts@@ -1,6 +1,9 @@import { nodeService } from '@/main/services/node-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeCollaboratorDeleteMutationInput } from '@/operations/mutations/node-collaborator-delete';+import { MutationHandler } from '@/main/types';+import {+ NodeCollaboratorDeleteMutationInput,+ NodeCollaboratorDeleteMutationOutput,+} from '@/shared/mutations/node-collaborator-delete';import { unset } from 'lodash-es';export class NodeCollaboratorDeleteMutationHandler@@ -8,28 +11,14 @@ export class NodeCollaboratorDeleteMutationHandler{async handleMutation(input: NodeCollaboratorDeleteMutationInput- ): Promise<MutationResult<NodeCollaboratorDeleteMutationInput>> {+ ): Promise<NodeCollaboratorDeleteMutationOutput> {await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {unset(attributes, `collaborators.${input.collaboratorId}`);return attributes;});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-collaborator-update.ts b/apps/desktop/src/main/handlers/mutations/node-collaborator-update.tsindex bdedbc8f..822734a1 100644--- a/apps/desktop/src/main/handlers/mutations/node-collaborator-update.ts+++ b/apps/desktop/src/main/handlers/mutations/node-collaborator-update.ts@@ -1,6 +1,9 @@import { nodeService } from '@/main/services/node-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeCollaboratorUpdateMutationInput } from '@/operations/mutations/node-collaborator-update';+import { MutationHandler } from '@/main/types';+import {+ NodeCollaboratorUpdateMutationInput,+ NodeCollaboratorUpdateMutationOutput,+} from '@/shared/mutations/node-collaborator-update';import { set } from 'lodash-es';export class NodeCollaboratorUpdateMutationHandler@@ -8,28 +11,14 @@ export class NodeCollaboratorUpdateMutationHandler{async handleMutation(input: NodeCollaboratorUpdateMutationInput- ): Promise<MutationResult<NodeCollaboratorUpdateMutationInput>> {+ ): Promise<NodeCollaboratorUpdateMutationOutput> {await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {set(attributes, `collaborators.${input.collaboratorId}`, input.role);return attributes;});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-delete.ts b/apps/desktop/src/main/handlers/mutations/node-delete.tsindex 3cafdc63..d65fc097 100644--- a/apps/desktop/src/main/handlers/mutations/node-delete.ts+++ b/apps/desktop/src/main/handlers/mutations/node-delete.ts@@ -1,5 +1,8 @@-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeDeleteMutationInput } from '@/operations/mutations/node-delete';+import { MutationHandler } from '@/main/types';+import {+ NodeDeleteMutationInput,+ NodeDeleteMutationOutput,+} from '@/shared/mutations/node-delete';import { nodeService } from '@/main/services/node-service';export class NodeDeleteMutationHandler@@ -7,35 +10,11 @@ export class NodeDeleteMutationHandler{async handleMutation(input: NodeDeleteMutationInput- ): Promise<MutationResult<NodeDeleteMutationInput>> {+ ): Promise<NodeDeleteMutationOutput> {await nodeService.deleteNode(input.nodeId, input.userId);return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- {- type: 'workspace',- table: 'uploads',- userId: input.userId,- },- {- type: 'workspace',- table: 'downloads',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-reaction-create.ts b/apps/desktop/src/main/handlers/mutations/node-reaction-create.tsindex 02bf69d8..fb1dacba 100644--- a/apps/desktop/src/main/handlers/mutations/node-reaction-create.ts+++ b/apps/desktop/src/main/handlers/mutations/node-reaction-create.ts@@ -1,13 +1,16 @@import { nodeService } from '@/main/services/node-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeReactionCreateMutationInput } from '@/operations/mutations/node-reaction-create';+import { MutationHandler } from '@/main/types';+import {+ NodeReactionCreateMutationInput,+ NodeReactionCreateMutationOutput,+} from '@/shared/mutations/node-reaction-create';export class NodeReactionCreateMutationHandlerimplements MutationHandler<NodeReactionCreateMutationInput>{async handleMutation(input: NodeReactionCreateMutationInput- ): Promise<MutationResult<NodeReactionCreateMutationInput>> {+ ): Promise<NodeReactionCreateMutationOutput> {await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {if (attributes.type !== 'message') {throw new Error('Node is not a message');@@ -27,21 +30,7 @@ export class NodeReactionCreateMutationHandler});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/node-reaction-delete.ts b/apps/desktop/src/main/handlers/mutations/node-reaction-delete.tsindex 84c9e936..64f35835 100644--- a/apps/desktop/src/main/handlers/mutations/node-reaction-delete.ts+++ b/apps/desktop/src/main/handlers/mutations/node-reaction-delete.ts@@ -1,13 +1,16 @@import { nodeService } from '@/main/services/node-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { NodeReactionDeleteMutationInput } from '@/operations/mutations/node-reaction-delete';+import { MutationHandler } from '@/main/types';+import {+ NodeReactionDeleteMutationInput,+ NodeReactionDeleteMutationOutput,+} from '@/shared/mutations/node-reaction-delete';export class NodeReactionDeleteMutationHandlerimplements MutationHandler<NodeReactionDeleteMutationInput>{async handleMutation(input: NodeReactionDeleteMutationInput- ): Promise<MutationResult<NodeReactionDeleteMutationInput>> {+ ): Promise<NodeReactionDeleteMutationOutput> {await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {if (attributes.type !== 'message') {throw new Error('Node is not a message');@@ -30,21 +33,7 @@ export class NodeReactionDeleteMutationHandler});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/page-create.ts b/apps/desktop/src/main/handlers/mutations/page-create.tsindex 4dd5403d..0f942488 100644--- a/apps/desktop/src/main/handlers/mutations/page-create.ts+++ b/apps/desktop/src/main/handlers/mutations/page-create.ts@@ -1,6 +1,9 @@import { generateId, IdType } from '@colanode/core';-import { MutationHandler, MutationResult } from '@/main/types';-import { PageCreateMutationInput } from '@/operations/mutations/page-create';+import { MutationHandler } from '@/main/types';+import {+ PageCreateMutationInput,+ PageCreateMutationOutput,+} from '@/shared/mutations/page-create';import { PageAttributes } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -9,7 +12,7 @@ export class PageCreateMutationHandler{async handleMutation(input: PageCreateMutationInput- ): Promise<MutationResult<PageCreateMutationInput>> {+ ): Promise<PageCreateMutationOutput> {const id = generateId(IdType.Page);const attributes: PageAttributes = {type: 'page',@@ -21,21 +24,7 @@ export class PageCreateMutationHandlerawait nodeService.createNode(input.userId, { id, attributes });return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id: id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/record-create.ts b/apps/desktop/src/main/handlers/mutations/record-create.tsindex 32958153..bba34273 100644--- a/apps/desktop/src/main/handlers/mutations/record-create.ts+++ b/apps/desktop/src/main/handlers/mutations/record-create.ts@@ -1,6 +1,9 @@import { generateId, IdType } from '@colanode/core';-import { MutationHandler, MutationResult } from '@/main/types';-import { RecordCreateMutationInput } from '@/operations/mutations/record-create';+import { MutationHandler } from '@/main/types';+import {+ RecordCreateMutationInput,+ RecordCreateMutationOutput,+} from '@/shared/mutations/record-create';import { RecordAttributes } from '@colanode/core';import { nodeService } from '@/main/services/node-service';@@ -9,7 +12,7 @@ export class RecordCreateMutationHandler{async handleMutation(input: RecordCreateMutationInput- ): Promise<MutationResult<RecordCreateMutationInput>> {+ ): Promise<RecordCreateMutationOutput> {const id = generateId(IdType.Record);const attributes: RecordAttributes = {type: 'record',@@ -23,21 +26,7 @@ export class RecordCreateMutationHandlerawait nodeService.createNode(input.userId, { id, attributes });return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id: id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/select-option-create.ts b/apps/desktop/src/main/handlers/mutations/select-option-create.tsindex eecc77c0..049bfc57 100644--- a/apps/desktop/src/main/handlers/mutations/select-option-create.ts+++ b/apps/desktop/src/main/handlers/mutations/select-option-create.ts@@ -1,8 +1,11 @@import { generateId, IdType } from '@colanode/core';-import { generateNodeIndex } from '@/lib/nodes';-import { MutationHandler, MutationResult } from '@/main/types';-import { SelectOptionCreateMutationInput } from '@/operations/mutations/select-option-create';-import { compareString } from '@/lib/utils';+import { generateNodeIndex } from '@/shared/lib/nodes';+import { MutationHandler } from '@/main/types';+import {+ SelectOptionCreateMutationInput,+ SelectOptionCreateMutationOutput,+} from '@/shared/mutations/select-option-create';+import { compareString } from '@/shared/lib/utils';import { nodeService } from '@/main/services/node-service';export class SelectOptionCreateMutationHandler@@ -10,7 +13,7 @@ export class SelectOptionCreateMutationHandler{async handleMutation(input: SelectOptionCreateMutationInput- ): Promise<MutationResult<SelectOptionCreateMutationInput>> {+ ): Promise<SelectOptionCreateMutationOutput> {const id = generateId(IdType.SelectOption);await nodeService.updateNode(input.databaseId,@@ -52,16 +55,7 @@ export class SelectOptionCreateMutationHandler);return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- ],+ id: id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/server-create.ts b/apps/desktop/src/main/handlers/mutations/server-create.tsindex 7cac4f34..19b0a906 100644--- a/apps/desktop/src/main/handlers/mutations/server-create.ts+++ b/apps/desktop/src/main/handlers/mutations/server-create.ts@@ -1,19 +1,24 @@import axios from 'axios';import { databaseService } from '@/main/data/database-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { ServerCreateMutationInput } from '@/operations/mutations/server-create';-import { ServerConfig } from '@/types/servers';+import { MutationHandler } from '@/main/types';+import {+ ServerCreateMutationInput,+ ServerCreateMutationOutput,+} from '@/shared/mutations/server-create';+import { ServerConfig } from '@/shared/types/servers';+import { eventBus } from '@/shared/lib/event-bus';export class ServerCreateMutationHandlerimplements MutationHandler<ServerCreateMutationInput>{async handleMutation(input: ServerCreateMutationInput- ): Promise<MutationResult<ServerCreateMutationInput>> {+ ): Promise<ServerCreateMutationOutput> {const { data } = await axios.get<ServerConfig>(`http://${input.domain}/v1/config`);+ const createdAt = new Date();await databaseService.appDatabase.insertInto('servers').values({@@ -22,20 +27,25 @@ export class ServerCreateMutationHandleravatar: data.avatar,attributes: JSON.stringify(data.attributes),version: data.version,- created_at: new Date().toISOString(),+ created_at: createdAt.toISOString(),}).execute();- return {- output: {- success: true,+ eventBus.publish({+ type: 'server_created',+ server: {+ domain: input.domain,+ name: data.name,+ avatar: data.avatar,+ attributes: data.attributes,+ version: data.version,+ createdAt,+ lastSyncedAt: null,},- changes: [- {- type: 'app',- table: 'servers',- },- ],+ });++ return {+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/server-node-delete.ts b/apps/desktop/src/main/handlers/mutations/server-node-delete.tsindex 581d84a4..77181b2e 100644--- a/apps/desktop/src/main/handlers/mutations/server-node-delete.ts+++ b/apps/desktop/src/main/handlers/mutations/server-node-delete.ts@@ -1,16 +1,19 @@+import { eventBus } from '@/shared/lib/event-bus';import { databaseService } from '@/main/data/database-service';import { socketService } from '@/main/services/socket-service';-import { MutationChange, MutationHandler, MutationResult } from '@/main/types';-import { ServerNodeDeleteMutationInput } from '@/operations/mutations/server-node-delete';+import { MutationHandler } from '@/main/types';+import { mapNode } from '@/main/utils';+import {+ ServerNodeDeleteMutationInput,+ ServerNodeDeleteMutationOutput,+} from '@/shared/mutations/server-node-delete';export class ServerNodeDeleteMutationHandlerimplements MutationHandler<ServerNodeDeleteMutationInput>{public async handleMutation(input: ServerNodeDeleteMutationInput- ): Promise<MutationResult<ServerNodeDeleteMutationInput>> {- const changes: MutationChange[] = [];-+ ): Promise<ServerNodeDeleteMutationOutput> {const workspace = await databaseService.appDatabase.selectFrom('workspaces').selectAll()@@ -24,9 +27,7 @@ export class ServerNodeDeleteMutationHandlerif (!workspace) {return {- output: {- success: false,- },+ success: false,};}@@ -34,16 +35,11 @@ export class ServerNodeDeleteMutationHandlerconst workspaceDatabase =await databaseService.getWorkspaceDatabase(userId);- await workspaceDatabase+ const deletedNode = await workspaceDatabase.deleteFrom('nodes')+ .returningAll().where('id', '=', input.id)- .execute();-- changes.push({- type: 'workspace',- table: 'nodes',- userId: userId,- });+ .executeTakeFirst();socketService.sendMessage(workspace.account_id, {type: 'local_node_delete',@@ -51,11 +47,16 @@ export class ServerNodeDeleteMutationHandlerworkspaceId: input.workspaceId,});+ if (deletedNode) {+ eventBus.publish({+ type: 'node_deleted',+ userId,+ node: mapNode(deletedNode),+ });+ }+return {- output: {- success: true,- },- changes: changes,+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/server-node-sync.ts b/apps/desktop/src/main/handlers/mutations/server-node-sync.tsindex 8234136b..0733928a 100644--- a/apps/desktop/src/main/handlers/mutations/server-node-sync.ts+++ b/apps/desktop/src/main/handlers/mutations/server-node-sync.ts@@ -1,16 +1,20 @@import { databaseService } from '@/main/data/database-service';import { socketService } from '@/main/services/socket-service';-import { hasInsertChanges, hasUpdateChanges } from '@/main/utils';-import { MutationHandler, MutationResult } from '@/main/types';-import { ServerNodeSyncMutationInput } from '@/operations/mutations/server-node-sync';+import { mapNode } from '@/main/utils';+import { MutationHandler } from '@/main/types';+import {+ ServerNodeSyncMutationInput,+ ServerNodeSyncMutationOutput,+} from '@/shared/mutations/server-node-sync';import { YDoc } from '@colanode/crdt';+import { eventBus } from '@/shared/lib/event-bus';export class ServerNodeSyncMutationHandlerimplements MutationHandler<ServerNodeSyncMutationInput>{public async handleMutation(input: ServerNodeSyncMutationInput- ): Promise<MutationResult<ServerNodeSyncMutationInput>> {+ ): Promise<ServerNodeSyncMutationOutput> {const workspace = await databaseService.appDatabase.selectFrom('workspaces').selectAll()@@ -24,9 +28,7 @@ export class ServerNodeSyncMutationHandlerif (!workspace) {return {- output: {- success: false,- },+ success: false,};}@@ -49,6 +51,7 @@ export class ServerNodeSyncMutationHandlerconst result = await workspaceDatabase.insertInto('nodes')+ .returningAll().values({id: input.id,attributes: JSON.stringify(attributes),@@ -60,10 +63,9 @@ export class ServerNodeSyncMutationHandlerserver_version_id: input.versionId,}).onConflict((cb) => cb.doNothing())- .execute();+ .executeTakeFirst();- const isInserted = hasInsertChanges(result);- if (isInserted) {+ if (result) {socketService.sendMessage(workspace.account_id, {type: 'local_node_sync',nodeId: input.id,@@ -72,17 +74,14 @@ export class ServerNodeSyncMutationHandlerworkspaceId: input.workspaceId,});+ eventBus.publish({+ type: 'node_created',+ userId: userId,+ node: mapNode(result),+ });+return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: userId,- },- ],+ success: true,};}} else {@@ -92,8 +91,9 @@ export class ServerNodeSyncMutationHandlerconst attributes = ydoc.getAttributes();const state = ydoc.getState();- const result = await workspaceDatabase+ const updatedNode = await workspaceDatabase.updateTable('nodes')+ .returningAll().set({state: state,attributes: JSON.stringify(attributes),@@ -106,10 +106,9 @@ export class ServerNodeSyncMutationHandler}).where('id', '=', input.id).where('version_id', '=', existingNode.version_id)- .execute();+ .executeTakeFirst();- const isUpdated = hasUpdateChanges(result);- if (isUpdated) {+ if (updatedNode) {socketService.sendMessage(workspace.account_id, {type: 'local_node_sync',nodeId: input.id,@@ -118,26 +117,21 @@ export class ServerNodeSyncMutationHandlerworkspaceId: input.workspaceId,});+ eventBus.publish({+ type: 'node_updated',+ userId: userId,+ node: mapNode(updatedNode),+ });+return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: userId,- },- ],+ success: true,};}}}return {- output: {- success: false,- },+ success: false,};}}diff --git a/apps/desktop/src/main/handlers/mutations/server-user-node-sync.ts b/apps/desktop/src/main/handlers/mutations/server-user-node-sync.tsindex 984037d9..ef8d25ee 100644--- a/apps/desktop/src/main/handlers/mutations/server-user-node-sync.ts+++ b/apps/desktop/src/main/handlers/mutations/server-user-node-sync.ts@@ -1,14 +1,18 @@+import { eventBus } from '@/shared/lib/event-bus';import { databaseService } from '@/main/data/database-service';import { socketService } from '@/main/services/socket-service';-import { MutationHandler, MutationResult } from '@/main/types';-import { ServerUserNodeSyncMutationInput } from '@/operations/mutations/server-user-node-sync';+import { MutationHandler } from '@/main/types';+import {+ ServerUserNodeSyncMutationInput,+ ServerUserNodeSyncMutationOutput,+} from '@/shared/mutations/server-user-node-sync';export class ServerUserNodeSyncMutationHandlerimplements MutationHandler<ServerUserNodeSyncMutationInput>{public async handleMutation(input: ServerUserNodeSyncMutationInput- ): Promise<MutationResult<ServerUserNodeSyncMutationInput>> {+ ): Promise<ServerUserNodeSyncMutationOutput> {const workspace = await databaseService.appDatabase.selectFrom('workspaces').selectAll()@@ -22,9 +26,7 @@ export class ServerUserNodeSyncMutationHandlerif (!workspace) {return {- output: {- success: false,- },+ success: false,};}@@ -32,8 +34,9 @@ export class ServerUserNodeSyncMutationHandlerconst workspaceDatabase =await databaseService.getWorkspaceDatabase(userId);- await workspaceDatabase+ const createdUserNode = await workspaceDatabase.insertInto('user_nodes')+ .returningAll().values({user_id: input.userId,node_id: input.nodeId,@@ -53,7 +56,7 @@ export class ServerUserNodeSyncMutationHandlerversion_id: input.versionId,}))- .execute();+ .executeTakeFirst();socketService.sendMessage(workspace.account_id, {type: 'local_user_node_sync',@@ -63,17 +66,26 @@ export class ServerUserNodeSyncMutationHandlerworkspaceId: input.workspaceId,});- return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'user_nodes',- userId: userId,+ if (createdUserNode) {+ eventBus.publish({+ type: 'user_node_created',+ userId: userId,+ userNode: {+ userId: createdUserNode.user_id,+ nodeId: createdUserNode.node_id,+ lastSeenAt: createdUserNode.last_seen_at,+ lastSeenVersionId: createdUserNode.last_seen_version_id,+ mentionsCount: createdUserNode.mentions_count,+ attributes: createdUserNode.attributes,+ versionId: createdUserNode.version_id,+ createdAt: createdUserNode.created_at,+ updatedAt: createdUserNode.updated_at,},- ],+ });+ }++ return {+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/space-create.ts b/apps/desktop/src/main/handlers/mutations/space-create.tsindex 01085dba..b30f0b37 100644--- a/apps/desktop/src/main/handlers/mutations/space-create.ts+++ b/apps/desktop/src/main/handlers/mutations/space-create.ts@@ -1,7 +1,10 @@import { generateId, IdType, NodeRoles } from '@colanode/core';-import { generateNodeIndex } from '@/lib/nodes';-import { MutationHandler, MutationResult } from '@/main/types';-import { SpaceCreateMutationInput } from '@/operations/mutations/space-create';+import { generateNodeIndex } from '@/shared/lib/nodes';+import { MutationHandler } from '@/main/types';+import {+ SpaceCreateMutationInput,+ SpaceCreateMutationOutput,+} from '@/shared/mutations/space-create';import {ChannelAttributes,PageAttributes,@@ -15,7 +18,7 @@ export class SpaceCreateMutationHandler{async handleMutation(input: SpaceCreateMutationInput- ): Promise<MutationResult<SpaceCreateMutationInput>> {+ ): Promise<SpaceCreateMutationOutput> {const workspace = await databaseService.appDatabase.selectFrom('workspaces').where('user_id', '=', input.userId)@@ -75,21 +78,7 @@ export class SpaceCreateMutationHandler]);return {- output: {- id: spaceId,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ id: spaceId,};}}diff --git a/apps/desktop/src/main/handlers/mutations/space-update.ts b/apps/desktop/src/main/handlers/mutations/space-update.tsindex 0a96a4d3..d080574a 100644--- a/apps/desktop/src/main/handlers/mutations/space-update.ts+++ b/apps/desktop/src/main/handlers/mutations/space-update.ts@@ -1,5 +1,8 @@-import { MutationHandler, MutationResult } from '@/main/types';-import { SpaceUpdateMutationInput } from '@/operations/mutations/space-update';+import { MutationHandler } from '@/main/types';+import {+ SpaceUpdateMutationInput,+ SpaceUpdateMutationOutput,+} from '@/shared/mutations/space-update';import { nodeService } from '@/main/services/node-service';export class SpaceUpdateMutationHandler@@ -7,7 +10,7 @@ export class SpaceUpdateMutationHandler{async handleMutation(input: SpaceUpdateMutationInput- ): Promise<MutationResult<SpaceUpdateMutationInput>> {+ ): Promise<SpaceUpdateMutationOutput> {await nodeService.updateNode(input.id, input.userId, (attributes) => {if (attributes.type !== 'space') {throw new Error('Node is not a space');@@ -21,21 +24,7 @@ export class SpaceUpdateMutationHandler});return {- output: {- success: true,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- {- type: 'workspace',- table: 'changes',- userId: input.userId,- },- ],+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/view-create.ts b/apps/desktop/src/main/handlers/mutations/view-create.tsindex b535657d..a3d89f83 100644--- a/apps/desktop/src/main/handlers/mutations/view-create.ts+++ b/apps/desktop/src/main/handlers/mutations/view-create.ts@@ -1,8 +1,11 @@import { generateId, IdType } from '@colanode/core';-import { MutationHandler, MutationResult } from '@/main/types';-import { ViewCreateMutationInput } from '@/operations/mutations/view-create';-import { compareString } from '@/lib/utils';-import { generateNodeIndex } from '@/lib/nodes';+import { MutationHandler } from '@/main/types';+import {+ ViewCreateMutationInput,+ ViewCreateMutationOutput,+} from '@/shared/mutations/view-create';+import { compareString } from '@/shared/lib/utils';+import { generateNodeIndex } from '@/shared/lib/nodes';import { nodeService } from '@/main/services/node-service';export class ViewCreateMutationHandler@@ -10,7 +13,7 @@ export class ViewCreateMutationHandler{async handleMutation(input: ViewCreateMutationInput- ): Promise<MutationResult<ViewCreateMutationInput>> {+ ): Promise<ViewCreateMutationOutput> {const id = generateId(IdType.View);await nodeService.updateNode(input.databaseId,@@ -41,16 +44,7 @@ export class ViewCreateMutationHandler);return {- output: {- id: id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- ],+ id: id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/view-delete.ts b/apps/desktop/src/main/handlers/mutations/view-delete.tsindex 9fa9008a..8943c291 100644--- a/apps/desktop/src/main/handlers/mutations/view-delete.ts+++ b/apps/desktop/src/main/handlers/mutations/view-delete.ts@@ -1,13 +1,16 @@-import { MutationHandler, MutationResult } from '@/main/types';+import { MutationHandler } from '@/main/types';import { nodeService } from '@/main/services/node-service';-import { ViewDeleteMutationInput } from '@/operations/mutations/view-delete';+import {+ ViewDeleteMutationInput,+ ViewDeleteMutationOutput,+} from '@/shared/mutations/view-delete';export class ViewDeleteMutationHandlerimplements MutationHandler<ViewDeleteMutationInput>{async handleMutation(input: ViewDeleteMutationInput- ): Promise<MutationResult<ViewDeleteMutationInput>> {+ ): Promise<ViewDeleteMutationOutput> {await nodeService.updateNode(input.databaseId,input.userId,@@ -22,16 +25,7 @@ export class ViewDeleteMutationHandler);return {- output: {- id: input.viewId,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- ],+ id: input.viewId,};}}diff --git a/apps/desktop/src/main/handlers/mutations/view-update.ts b/apps/desktop/src/main/handlers/mutations/view-update.tsindex 66256226..387c901e 100644--- a/apps/desktop/src/main/handlers/mutations/view-update.ts+++ b/apps/desktop/src/main/handlers/mutations/view-update.ts@@ -1,13 +1,16 @@-import { MutationHandler, MutationResult } from '@/main/types';+import { MutationHandler } from '@/main/types';import { nodeService } from '@/main/services/node-service';-import { ViewUpdateMutationInput } from '@/operations/mutations/view-update';+import {+ ViewUpdateMutationInput,+ ViewUpdateMutationOutput,+} from '@/shared/mutations/view-update';export class ViewUpdateMutationHandlerimplements MutationHandler<ViewUpdateMutationInput>{async handleMutation(input: ViewUpdateMutationInput- ): Promise<MutationResult<ViewUpdateMutationInput>> {+ ): Promise<ViewUpdateMutationOutput> {await nodeService.updateNode(input.databaseId,input.userId,@@ -22,16 +25,7 @@ export class ViewUpdateMutationHandler);return {- output: {- id: input.view.id,- },- changes: [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- ],+ id: input.view.id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/workspace-create.ts b/apps/desktop/src/main/handlers/mutations/workspace-create.tsindex 49cf95cc..bba05823 100644--- a/apps/desktop/src/main/handlers/mutations/workspace-create.ts+++ b/apps/desktop/src/main/handlers/mutations/workspace-create.ts@@ -1,15 +1,19 @@import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';-import { WorkspaceCreateMutationInput } from '@/operations/mutations/workspace-create';-import { MutationHandler, MutationResult } from '@/main/types';+import { httpClient } from '@/shared/lib/http-client';+import {+ WorkspaceCreateMutationInput,+ WorkspaceCreateMutationOutput,+} from '@/shared/mutations/workspace-create';+import { MutationHandler } from '@/main/types';import { WorkspaceOutput } from '@colanode/core';+import { eventBus } from '@/shared/lib/event-bus';export class WorkspaceCreateMutationHandlerimplements MutationHandler<WorkspaceCreateMutationInput>{async handleMutation(input: WorkspaceCreateMutationInput- ): Promise<MutationResult<WorkspaceCreateMutationInput>> {+ ): Promise<WorkspaceCreateMutationOutput> {const account = await databaseService.appDatabase.selectFrom('accounts').selectAll()@@ -44,8 +48,9 @@ export class WorkspaceCreateMutationHandler});- await databaseService.appDatabase+ const createdWorkspace = await databaseService.appDatabase.insertInto('workspaces')+ .returningAll().values({workspace_id: data.id ?? data.id,account_id: data.user.accountId,@@ -57,24 +62,29 @@ export class WorkspaceCreateMutationHandlerversion_id: data.versionId,}).onConflict((cb) => cb.doNothing())- .execute();+ .executeTakeFirst();- return {- output: {- id: data.id,- userId: data.user.id,+ if (!createdWorkspace) {+ throw new Error('Failed to create workspace!');+ }++ eventBus.publish({+ type: 'workspace_created',+ workspace: {+ id: createdWorkspace.workspace_id,+ userId: createdWorkspace.user_id,+ name: createdWorkspace.name,+ versionId: createdWorkspace.version_id,+ accountId: createdWorkspace.account_id,+ role: createdWorkspace.role,+ avatar: createdWorkspace.avatar,+ description: createdWorkspace.description,},- changes: [- {- type: 'app',- table: 'workspaces',- },- {- type: 'workspace',- table: 'nodes',- userId: data.user.id,- },- ],+ });++ return {+ id: createdWorkspace.workspace_id,+ userId: createdWorkspace.user_id,};}}diff --git a/apps/desktop/src/main/handlers/mutations/workspace-update.ts b/apps/desktop/src/main/handlers/mutations/workspace-update.tsindex 305d2a98..b3694f06 100644--- a/apps/desktop/src/main/handlers/mutations/workspace-update.ts+++ b/apps/desktop/src/main/handlers/mutations/workspace-update.ts@@ -1,15 +1,19 @@import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';-import { WorkspaceUpdateMutationInput } from '@/operations/mutations/workspace-update';-import { MutationHandler, MutationResult } from '@/main/types';-import { Workspace } from '@/types/workspaces';+import { httpClient } from '@/shared/lib/http-client';+import {+ WorkspaceUpdateMutationInput,+ WorkspaceUpdateMutationOutput,+} from '@/shared/mutations/workspace-update';+import { MutationHandler } from '@/main/types';+import { Workspace } from '@/shared/types/workspaces';+import { eventBus } from '@/shared/lib/event-bus';export class WorkspaceUpdateMutationHandlerimplements MutationHandler<WorkspaceUpdateMutationInput>{async handleMutation(input: WorkspaceUpdateMutationInput- ): Promise<MutationResult<WorkspaceUpdateMutationInput>> {+ ): Promise<WorkspaceUpdateMutationOutput> {const account = await databaseService.appDatabase.selectFrom('accounts').selectAll()@@ -44,8 +48,9 @@ export class WorkspaceUpdateMutationHandler});- await databaseService.appDatabase+ const updatedWorkspace = await databaseService.appDatabase.updateTable('workspaces')+ .returningAll().set({name: data.name,description: data.description,@@ -59,18 +64,26 @@ export class WorkspaceUpdateMutationHandlereb('workspace_id', '=', input.id),]))- .execute();+ .executeTakeFirst();- return {- output: {- success: true,+ if (!updatedWorkspace) {+ throw new Error('Failed to update workspace!');+ }++ eventBus.publish({+ type: 'workspace_updated',+ workspace: {+ id: updatedWorkspace.workspace_id,+ userId: updatedWorkspace.user_id,+ name: updatedWorkspace.name,+ versionId: updatedWorkspace.version_id,+ accountId: updatedWorkspace.account_id,+ role: updatedWorkspace.role,},- changes: [- {- type: 'app',- table: 'workspaces',- },- ],+ });++ return {+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.ts b/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.tsindex 57c6934f..0bc5f1d6 100644--- a/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.ts+++ b/apps/desktop/src/main/handlers/mutations/workspace-user-role-update.ts@@ -1,16 +1,21 @@import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';-import { WorkspaceUserRoleUpdateMutationInput } from '@/operations/mutations/workspace-user-role-update';-import { MutationChange, MutationHandler, MutationResult } from '@/main/types';+import { httpClient } from '@/shared/lib/http-client';+import {+ WorkspaceUserRoleUpdateMutationInput,+ WorkspaceUserRoleUpdateMutationOutput,+} from '@/shared/mutations/workspace-user-role-update';import { WorkspaceUserRoleUpdateOutput } from '@colanode/core';+import { MutationHandler } from '@/main/types';import { toUint8Array } from 'js-base64';+import { eventBus } from '@/shared/lib/event-bus';+import { mapNode } from '@/main/utils';export class WorkspaceUserRoleUpdateMutationHandlerimplements MutationHandler<WorkspaceUserRoleUpdateMutationInput>{async handleMutation(input: WorkspaceUserRoleUpdateMutationInput- ): Promise<MutationResult<WorkspaceUserRoleUpdateMutationInput>> {+ ): Promise<WorkspaceUserRoleUpdateMutationOutput> {const workspace = await databaseService.appDatabase.selectFrom('workspaces').selectAll()@@ -19,9 +24,7 @@ export class WorkspaceUserRoleUpdateMutationHandlerif (!workspace) {return {- output: {- success: false,- },+ success: false,};}@@ -33,9 +36,7 @@ export class WorkspaceUserRoleUpdateMutationHandlerif (!account) {return {- output: {- success: false,- },+ success: false,};}@@ -47,9 +48,7 @@ export class WorkspaceUserRoleUpdateMutationHandlerif (!server) {return {- output: {- success: false,- },+ success: false,};}@@ -69,8 +68,9 @@ export class WorkspaceUserRoleUpdateMutationHandlerinput.userId);- await workspaceDatabase+ const updatedUser = await workspaceDatabase.updateTable('nodes')+ .returningAll().set({attributes: JSON.stringify(data.user.attributes),state: toUint8Array(data.user.state),@@ -81,21 +81,22 @@ export class WorkspaceUserRoleUpdateMutationHandlerserver_version_id: data.user.versionId,}).where('id', '=', data.user.id)- .execute();+ .executeTakeFirst();- const changedTables: MutationChange[] = [- {- type: 'workspace',- table: 'nodes',- userId: input.userId,- },- ];+ if (!updatedUser) {+ return {+ success: false,+ };+ }++ eventBus.publish({+ type: 'node_updated',+ userId: input.userId,+ node: mapNode(updatedUser),+ });return {- output: {- success: true,- },- changes: changedTables,+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/mutations/workspace-users-invite.ts b/apps/desktop/src/main/handlers/mutations/workspace-users-invite.tsindex 54ac9b59..3ac9d74a 100644--- a/apps/desktop/src/main/handlers/mutations/workspace-users-invite.ts+++ b/apps/desktop/src/main/handlers/mutations/workspace-users-invite.ts@@ -1,17 +1,22 @@import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';-import { WorkspaceUsersInviteMutationInput } from '@/operations/mutations/workspace-users-invite';-import { MutationChange, MutationHandler, MutationResult } from '@/main/types';+import { httpClient } from '@/shared/lib/http-client';+import {+ WorkspaceUsersInviteMutationInput,+ WorkspaceUsersInviteMutationOutput,+} from '@/shared/mutations/workspace-users-invite';+import { MutationHandler } from '@/main/types';import { WorkspaceUsersInviteOutput } from '@colanode/core';import { CreateNode } from '@/main/data/workspace/schema';import { toUint8Array } from 'js-base64';+import { eventBus } from '@/shared/lib/event-bus';+import { mapNode } from '@/main/utils';export class WorkspaceUsersInviteMutationHandlerimplements MutationHandler<WorkspaceUsersInviteMutationInput>{async handleMutation(input: WorkspaceUsersInviteMutationInput- ): Promise<MutationResult<WorkspaceUsersInviteMutationInput>> {+ ): Promise<WorkspaceUsersInviteMutationOutput> {const workspace = await databaseService.appDatabase.selectFrom('workspaces').selectAll()@@ -20,9 +25,7 @@ export class WorkspaceUsersInviteMutationHandlerif (!workspace) {return {- output: {- success: false,- },+ success: false,};}@@ -34,9 +37,7 @@ export class WorkspaceUsersInviteMutationHandlerif (!account) {return {- output: {- success: false,- },+ success: false,};}@@ -48,9 +49,7 @@ export class WorkspaceUsersInviteMutationHandlerif (!server) {return {- output: {- success: false,- },+ success: false,};}@@ -86,25 +85,29 @@ export class WorkspaceUsersInviteMutationHandler};});- await workspaceDatabase+ const createdNodes = await workspaceDatabase.insertInto('nodes')+ .returningAll().values(usersToCreate).onConflict((cb) => cb.doNothing()).execute();- const changedTables: MutationChange[] = [- {- type: 'workspace',- table: 'nodes',+ if (createdNodes.length !== usersToCreate.length) {+ return {+ success: false,+ };+ }++ for (const createdNode of createdNodes) {+ eventBus.publish({+ type: 'node_created',userId: input.userId,- },- ];+ node: mapNode(createdNode),+ });+ }return {- output: {- success: true,- },- changes: changedTables,+ success: true,};}}diff --git a/apps/desktop/src/main/handlers/queries/accounts-list.ts b/apps/desktop/src/main/handlers/queries/accounts-list.tsindex d275c60b..7e5f9b3b 100644--- a/apps/desktop/src/main/handlers/queries/accounts-list.ts+++ b/apps/desktop/src/main/handlers/queries/accounts-list.ts@@ -1,60 +1,58 @@-import { AccountListQueryInput } from '@/operations/queries/account-list';+import { AccountListQueryInput } from '@/shared/queries/account-list';import { databaseService } from '@/main/data/database-service';-import { Account } from '@/types/accounts';+import { Account } from '@/shared/types/accounts';import { SelectAccount } from '@/main/data/app/schema';-import { isEqual } from 'lodash-es';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { Event } from '@/shared/types/events';export class AccountListQueryHandlerimplements QueryHandler<AccountListQueryInput>{- public async handleQuery(- _: AccountListQueryInput- ): Promise<QueryResult<AccountListQueryInput>> {+ public async handleQuery(_: AccountListQueryInput): Promise<Account[]> {const rows = await this.fetchAccounts();- return {- output: this.buildAccounts(rows),- state: {- rows,- },- };+ return this.buildAccounts(rows);}public async checkForChanges(- changes: MutationChange[],+ event: Event,_: AccountListQueryInput,- state: Record<string, any>+ output: Account[]): Promise<ChangeCheckResult<AccountListQueryInput>> {- if (- !changes.some(- (change) => change.type === 'app' && change.table === 'accounts'- )- ) {+ if (event.type === 'account_created') {+ const newAccounts = [...output, event.account];return {- hasChanges: false,+ hasChanges: true,+ result: newAccounts,};}- const rows = await this.fetchAccounts();- if (isEqual(rows, state.rows)) {+ if (event.type === 'account_updated') {+ const updatedAccounts = output.map((account) => {+ if (account.id === event.account.id) {+ return event.account;+ }+ return account;+ });++ return {+ hasChanges: true,+ result: updatedAccounts,+ };+ }++ if (event.type === 'account_deleted') {+ const activeAccounts = output.filter(+ (account) => account.id !== event.account.id+ );+return {- hasChanges: false,+ hasChanges: true,+ result: activeAccounts,};}return {- hasChanges: true,- result: {- output: this.buildAccounts(rows),- state: {- rows,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/emojis-get.ts b/apps/desktop/src/main/handlers/queries/emojis-get.tsindex 38d42a0f..606e6bde 100644--- a/apps/desktop/src/main/handlers/queries/emojis-get.ts+++ b/apps/desktop/src/main/handlers/queries/emojis-get.ts@@ -1,30 +1,21 @@import { assetService } from '@/main/services/asset-service';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { EmojisGetQueryInput } from '@/operations/queries/emojis-get';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { EmojisGetQueryInput } from '@/shared/queries/emojis-get';+import { EmojiData } from '@/shared/types/emojis';+import { Event } from '@/shared/types/events';export class EmojisGetQueryHandlerimplements QueryHandler<EmojisGetQueryInput>{- public async handleQuery(- _: EmojisGetQueryInput- ): Promise<QueryResult<EmojisGetQueryInput>> {+ public async handleQuery(_: EmojisGetQueryInput): Promise<EmojiData> {const data = assetService.getEmojiData();-- return {- output: data,- state: {},- };+ return data;}public async checkForChanges(- _: MutationChange[],+ _: Event,__: EmojisGetQueryInput,- ___: Record<string, any>+ ___: EmojiData): Promise<ChangeCheckResult<EmojisGetQueryInput>> {return {hasChanges: false,diff --git a/apps/desktop/src/main/handlers/queries/file-list.ts b/apps/desktop/src/main/handlers/queries/file-list.tsindex 7aa296d0..525491d4 100644--- a/apps/desktop/src/main/handlers/queries/file-list.ts+++ b/apps/desktop/src/main/handlers/queries/file-list.ts@@ -1,15 +1,10 @@-import { FileListQueryInput } from '@/operations/queries/file-list';+import { FileListQueryInput } from '@/shared/queries/file-list';import { databaseService } from '@/main/data/database-service';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';+import { ChangeCheckResult, QueryHandler } from '@/main/types';import { NodeTypes } from '@colanode/core';-import { compareString } from '@/lib/utils';-import { isEqual } from 'lodash-es';-import { FileNode } from '@/types/files';+import { compareString } from '@/shared/lib/utils';+import { FileNode } from '@/shared/types/files';+import { Event } from '@/shared/types/events';interface FileRow {id: string;@@ -22,52 +17,84 @@ interface FileRow {}export class FileListQueryHandler implements QueryHandler<FileListQueryInput> {- public async handleQuery(- input: FileListQueryInput- ): Promise<QueryResult<FileListQueryInput>> {+ public async handleQuery(input: FileListQueryInput): Promise<FileNode[]> {const files = await this.fetchFiles(input);-- return {- output: this.buildFiles(files),- state: {- files,- },- };+ return this.buildFiles(files);}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: FileListQueryInput,- state: Record<string, any>+ output: FileNode[]): Promise<ChangeCheckResult<FileListQueryInput>> {if (- !changes.some(- (change) =>- change.type === 'workspace' &&- (change.table === 'nodes' || change.table === 'downloads') &&- change.userId === input.userId- )+ event.type === 'node_created' &&+ event.userId === input.userId &&+ event.node.type === 'file' &&+ event.node.parentId === input.parentId) {+ const output = await this.handleQuery(input);return {- hasChanges: false,+ hasChanges: true,+ result: output,};}- const files = await this.fetchFiles(input);- if (isEqual(files, state.files)) {- return {- hasChanges: false,- };+ if (+ event.type === 'node_updated' &&+ event.userId === input.userId &&+ event.node.type === 'file' &&+ event.node.parentId === input.parentId+ ) {+ const file = output.find((file) => file.id === event.node.id);+ if (file) {+ file.name = event.node.attributes.name;+ file.mimeType = event.node.attributes.mimeType;+ file.size = event.node.attributes.size;+ file.extension = event.node.attributes.extension;+ file.fileName = event.node.attributes.fileName;++ return {+ hasChanges: true,+ result: output,+ };+ }+ }++ if (+ event.type === 'node_deleted' &&+ event.userId === input.userId &&+ event.node.type === 'file' &&+ event.node.parentId === input.parentId+ ) {+ const file = output.find((file) => file.id === event.node.id);+ if (file) {+ output = output.filter((file) => file.id !== event.node.id);+ return {+ hasChanges: true,+ result: output,+ };+ }+ }++ if (+ (event.type === 'download_created' ||+ event.type === 'download_updated') &&+ event.userId === input.userId+ ) {+ const nodeId = event.download.nodeId;+ const file = output.find((file) => file.id === nodeId);+ if (file) {+ file.downloadProgress = event.download.progress;+ return {+ hasChanges: true,+ result: output,+ };+ }}return {- hasChanges: true,- result: {- output: this.buildFiles(files),- state: {- files,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/icons-get.ts b/apps/desktop/src/main/handlers/queries/icons-get.tsindex 692552bf..6ecf8d01 100644--- a/apps/desktop/src/main/handlers/queries/icons-get.ts+++ b/apps/desktop/src/main/handlers/queries/icons-get.ts@@ -1,28 +1,20 @@import { assetService } from '@/main/services/asset-service';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { IconsGetQueryInput } from '@/operations/queries/icons-get';+import { QueryHandler, ChangeCheckResult } from '@/main/types';+import { IconsGetQueryInput } from '@/shared/queries/icons-get';+import { IconData } from '@/shared/types/icons';+import { Event } from '@/shared/types/events';export class IconsGetQueryHandler implements QueryHandler<IconsGetQueryInput> {- public async handleQuery(- _: IconsGetQueryInput- ): Promise<QueryResult<IconsGetQueryInput>> {+ public async handleQuery(_: IconsGetQueryInput): Promise<IconData> {const data = assetService.getIconData();- return {- output: data,- state: {},- };+ return data;}public async checkForChanges(- _: MutationChange[],+ _: Event,__: IconsGetQueryInput,- ___: Record<string, any>+ ___: IconData): Promise<ChangeCheckResult<IconsGetQueryInput>> {return {hasChanges: false,diff --git a/apps/desktop/src/main/handlers/queries/index.ts b/apps/desktop/src/main/handlers/queries/index.tsindex 30f786f8..570b6309 100644--- a/apps/desktop/src/main/handlers/queries/index.ts+++ b/apps/desktop/src/main/handlers/queries/index.ts@@ -1,4 +1,4 @@-import { QueryMap } from '@/operations/queries';+import { QueryMap } from '@/shared/queries';import { QueryHandler } from '@/main/types';import { AccountListQueryHandler } from '@/main/handlers/queries/accounts-list';import { MessageListQueryHandler } from '@/main/handlers/queries/message-list';@@ -13,6 +13,7 @@ import { EmojisGetQueryHandler } from '@/main/handlers/queries/emojis-get';import { IconsGetQueryHandler } from '@/main/handlers/queries/icons-get';import { NodeTreeGetQueryHandler } from '@/main/handlers/queries/node-tree-get';import { NodeChildrenGetQueryHandler } from '@/main/handlers/queries/node-children-get';+import { ReadStatesGetQueryHandler } from '@/main/handlers/queries/read-states-get';type QueryHandlerMap = {[K in keyof QueryMap]: QueryHandler<QueryMap[K]['input']>;@@ -32,4 +33,5 @@ export const queryHandlerMap: QueryHandlerMap = {icons_get: new IconsGetQueryHandler(),node_tree_get: new NodeTreeGetQueryHandler(),node_children_get: new NodeChildrenGetQueryHandler(),+ read_states_get: new ReadStatesGetQueryHandler(),};diff --git a/apps/desktop/src/main/handlers/queries/message-list.ts b/apps/desktop/src/main/handlers/queries/message-list.tsindex 2a2166b4..2fe091d1 100644--- a/apps/desktop/src/main/handlers/queries/message-list.ts+++ b/apps/desktop/src/main/handlers/queries/message-list.ts@@ -1,77 +1,117 @@-import { MessageListQueryInput } from '@/operations/queries/message-list';+import { MessageListQueryInput } from '@/shared/queries/message-list';import { databaseService } from '@/main/data/database-service';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';+import { ChangeCheckResult, QueryHandler } from '@/main/types';import { SelectNode } from '@/main/data/workspace/schema';-import { NodeTypes } from '@colanode/core';+import { MessageAttributes, NodeTypes } from '@colanode/core';import {MessageNode,MessageReactionCount,MessageAuthor,-} from '@/types/messages';+} from '@/shared/types/messages';import { mapNode } from '@/main/utils';-import { compareString } from '@/lib/utils';-import { isEqual } from 'lodash-es';-import { mapBlocksToContents } from '@/lib/editor';+import { compareString } from '@/shared/lib/utils';+import { mapBlocksToContents } from '@/shared/lib/editor';+import { Event } from '@/shared/types/events';export class MessageListQueryHandlerimplements QueryHandler<MessageListQueryInput>{public async handleQuery(input: MessageListQueryInput- ): Promise<QueryResult<MessageListQueryInput>> {+ ): Promise<MessageNode[]> {const messages = await this.fetchMesssages(input);const authors = await this.fetchAuthors(input, messages);- return {- output: this.buildMessages(input.userId, messages, authors),- state: {- messages,- authors,- },- };+ return this.buildMessages(input.userId, messages, authors);}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: MessageListQueryInput,- state: Record<string, any>+ output: MessageNode[]): Promise<ChangeCheckResult<MessageListQueryInput>> {if (- !changes.some(- (change) =>- change.type === 'workspace' &&- change.table === 'nodes' &&- change.userId === input.userId- )+ event.type === 'node_created' &&+ event.userId === input.userId &&+ event.node.type === 'message' &&+ event.node.parentId === input.conversationId) {+ const messages = await this.fetchMesssages(input);+ const authors = await this.fetchAuthors(input, messages);+return {- hasChanges: false,+ hasChanges: true,+ result: this.buildMessages(input.userId, messages, authors),};}- const messages = await this.fetchMesssages(input);- const authors = await this.fetchAuthors(input, messages);+ if (event.type === 'node_updated' && event.userId === input.userId) {+ if (+ event.node.type === 'message' &&+ event.node.parentId === input.conversationId+ ) {+ const message = output.find((message) => message.id === event.node.id);+ if (message) {+ message.content = mapBlocksToContents(+ event.node.id,+ Object.values(event.node.attributes.content ?? {})+ );++ message.reactionCounts = this.buildReactionCounts(+ event.node.attributes,+ input.userId+ );++ message.createdAt = event.node.createdAt;+ message.versionId = event.node.versionId;++ return {+ hasChanges: true,+ result: output,+ };+ }+ }- if (isEqual(messages, state.messages) && isEqual(authors, state.authors)) {- return {- hasChanges: false,- };+ if (event.node.type === 'user') {+ let hasChanges = false;+ for (const message of output) {+ if (message.author.id === event.node.id) {+ message.author.name = event.node.attributes.name;+ message.author.email = event.node.attributes.email;+ message.author.avatar = event.node.attributes.avatar;++ hasChanges = true;+ }+ }++ if (hasChanges) {+ return {+ hasChanges: true,+ result: output,+ };+ }+ }+ }++ if (event.type === 'node_deleted' && event.userId === input.userId) {+ if (+ event.node.type === 'message' &&+ event.node.parentId === input.conversationId+ ) {+ const message = output.find((message) => message.id === event.node.id);++ if (message) {+ const newOutput = await this.handleQuery(input);+ return {+ hasChanges: true,+ result: newOutput,+ };+ }+ }}return {- hasChanges: true,- result: {- output: this.buildMessages(input.userId, messages, authors),- state: {- messages,- authors,- },- },+ hasChanges: false,};}@@ -154,16 +194,10 @@ export class MessageListQueryHandler}const author = authorMap.get(messageNode.createdBy);- const reactions =- (messageNode.attributes.reactions as Record<string, string[]>) ?? {};-- const reactionCounts: MessageReactionCount[] = Object.entries(reactions)- .map(([reaction, users]) => ({- reaction,- count: users.length,- isReactedTo: users.includes(userId),- }))- .filter((reactionCount) => reactionCount.count > 0);+ const reactionCounts = this.buildReactionCounts(+ messageNode.attributes,+ userId+ );const message: MessageNode = {id: messageNode.id,@@ -187,4 +221,18 @@ export class MessageListQueryHandlerreturn messages.sort((a, b) => compareString(a.id, b.id));};++ private buildReactionCounts(+ attributes: MessageAttributes,+ userId: string+ ): MessageReactionCount[] {+ const reactions = attributes.reactions as Record<string, string[]>;+ return Object.entries(reactions)+ .map(([reaction, users]) => ({+ reaction,+ count: users.length,+ isReactedTo: users.includes(userId),+ }))+ .filter((reactionCount) => reactionCount.count > 0);+ }}diff --git a/apps/desktop/src/main/handlers/queries/node-children-get.tsx b/apps/desktop/src/main/handlers/queries/node-children-get.tsxindex f52bdcca..4e493c31 100644--- a/apps/desktop/src/main/handlers/queries/node-children-get.tsx+++ b/apps/desktop/src/main/handlers/queries/node-children-get.tsx@@ -1,64 +1,74 @@-import { NodeChildrenGetQueryInput } from '@/operations/queries/node-children-get';+import { NodeChildrenGetQueryInput } from '@/shared/queries/node-children-get';import { databaseService } from '@/main/data/database-service';import { mapNode } from '@/main/utils';import { SelectNode } from '@/main/data/workspace/schema';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { isEqual } from 'lodash-es';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { Node } from '@colanode/core';+import { Event } from '@/shared/types/events';export class NodeChildrenGetQueryHandlerimplements QueryHandler<NodeChildrenGetQueryInput>{- public async handleQuery(- input: NodeChildrenGetQueryInput- ): Promise<QueryResult<NodeChildrenGetQueryInput>> {+ public async handleQuery(input: NodeChildrenGetQueryInput): Promise<Node[]> {const rows = await this.fetchChildren(input);-- return {- output: rows.map(mapNode),- state: {- rows,- },- };+ return rows.map(mapNode);}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: NodeChildrenGetQueryInput,- state: Record<string, any>+ output: Node[]): Promise<ChangeCheckResult<NodeChildrenGetQueryInput>> {if (- !changes.some(- (change) =>- change.type === 'workspace' &&- change.table === 'nodes' &&- change.userId === input.userId- )+ event.type === 'node_created' &&+ event.userId === input.userId &&+ event.node.parentId === input.nodeId &&+ (input.types === undefined || input.types.includes(event.node.type))) {+ const newChildren = [...output, event.node];return {- hasChanges: false,+ hasChanges: true,+ result: newChildren,};}- const rows = await this.fetchChildren(input);- if (isEqual(rows, state.rows)) {- return {- hasChanges: false,- };+ if (+ event.type === 'node_updated' &&+ event.userId === input.userId &&+ event.node.parentId === input.nodeId &&+ (input.types === undefined || input.types.includes(event.node.type))+ ) {+ const node = output.find((node) => node.id === event.node.id);+ if (node) {+ const newChildren = output.map((node) =>+ node.id === event.node.id ? event.node : node+ );++ return {+ hasChanges: true,+ result: newChildren,+ };+ }+ }++ if (+ event.type === 'node_deleted' &&+ event.userId === input.userId &&+ event.node.parentId === input.nodeId &&+ (input.types === undefined || input.types.includes(event.node.type))+ ) {+ const node = output.find((node) => node.id === event.node.id);+ if (node) {+ const newChildren = output.filter((node) => node.id !== event.node.id);+ return {+ hasChanges: true,+ result: newChildren,+ };+ }}return {- hasChanges: true,- result: {- output: rows.map(mapNode),- state: {- rows,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/node-get.ts b/apps/desktop/src/main/handlers/queries/node-get.tsindex dca34c0e..bd6cadf4 100644--- a/apps/desktop/src/main/handlers/queries/node-get.ts+++ b/apps/desktop/src/main/handlers/queries/node-get.ts@@ -1,62 +1,46 @@-import { NodeGetQueryInput } from '@/operations/queries/node-get';+import { NodeGetQueryInput } from '@/shared/queries/node-get';import { databaseService } from '@/main/data/database-service';import { mapNode } from '@/main/utils';import { SelectNode } from '@/main/data/workspace/schema';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { isEqual } from 'lodash-es';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { Node } from '@colanode/core';+import { Event } from '@/shared/types/events';export class NodeGetQueryHandler implements QueryHandler<NodeGetQueryInput> {- public async handleQuery(- input: NodeGetQueryInput- ): Promise<QueryResult<NodeGetQueryInput>> {+ public async handleQuery(input: NodeGetQueryInput): Promise<Node | null> {const row = await this.fetchNode(input);-- return {- output: row ? mapNode(row) : null,- state: {- row,- },- };+ return row ? mapNode(row) : null;}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: NodeGetQueryInput,- state: Record<string, any>+ _: Node | null): Promise<ChangeCheckResult<NodeGetQueryInput>> {if (- !changes.some(- (change) =>- change.type === 'workspace' &&- change.table === 'nodes' &&- change.userId === input.userId- )+ event.type === 'node_updated' &&+ event.userId === input.userId &&+ event.node.id === input.nodeId) {return {- hasChanges: false,+ hasChanges: true,+ result: event.node,};}- const row = await this.fetchNode(input);- if (isEqual(row, state.row)) {+ if (+ event.type === 'node_deleted' &&+ event.userId === input.userId &&+ event.node.id === input.nodeId+ ) {return {- hasChanges: false,+ hasChanges: true,+ result: null,};}return {- hasChanges: true,- result: {- output: row ? mapNode(row) : null,- state: {- row,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/node-tree-get.ts b/apps/desktop/src/main/handlers/queries/node-tree-get.tsindex ff30619a..9b391188 100644--- a/apps/desktop/src/main/handlers/queries/node-tree-get.ts+++ b/apps/desktop/src/main/handlers/queries/node-tree-get.ts@@ -1,65 +1,55 @@import { databaseService } from '@/main/data/database-service';import { mapNode } from '@/main/utils';import { SelectNode } from '@/main/data/workspace/schema';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { isEqual } from 'lodash-es';-import { NodeTreeGetQueryInput } from '@/operations/queries/node-tree-get';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { NodeTreeGetQueryInput } from '@/shared/queries/node-tree-get';import { fetchNodeAncestors } from '@/main/utils';+import { Event } from '@/shared/types/events';+import { Node } from '@colanode/core';export class NodeTreeGetQueryHandlerimplements QueryHandler<NodeTreeGetQueryInput>{- public async handleQuery(- input: NodeTreeGetQueryInput- ): Promise<QueryResult<NodeTreeGetQueryInput>> {+ public async handleQuery(input: NodeTreeGetQueryInput): Promise<Node[]> {const rows = await this.fetchNodes(input);-- return {- output: rows.map(mapNode),- state: {- rows,- },- };+ return rows.map(mapNode);}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: NodeTreeGetQueryInput,- state: Record<string, any>+ output: Node[]): Promise<ChangeCheckResult<NodeTreeGetQueryInput>> {- if (- !changes.some(- (change) =>- change.type === 'workspace' &&- change.table === 'nodes' &&- change.userId === input.userId- )- ) {- return {- hasChanges: false,- };+ if (event.type === 'node_updated' && event.userId === input.userId) {+ const node = output.find((node) => node.id === event.node.id);+ if (node) {+ const newNodes = output.map((node) => {+ if (node.id === event.node.id) {+ return event.node;+ }+ return node;+ });++ return {+ hasChanges: true,+ result: newNodes,+ };+ }}- const rows = await this.fetchNodes(input);- if (isEqual(rows, state.rows)) {- return {- hasChanges: false,- };+ if (event.type === 'node_deleted' && event.userId === input.userId) {+ const node = output.find((node) => node.id === event.node.id);+ if (node) {+ const newResult = await this.handleQuery(input);+ return {+ hasChanges: true,+ result: newResult,+ };+ }}return {- hasChanges: true,- result: {- output: rows.map(mapNode),- state: {- rows,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/read-states-get.ts b/apps/desktop/src/main/handlers/queries/read-states-get.tsnew file mode 100644index 00000000..7a219b53--- /dev/null+++ b/apps/desktop/src/main/handlers/queries/read-states-get.ts@@ -0,0 +1,39 @@+import { radarService } from '@/main/services/radar-service';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { ReadStatesGetQueryInput } from '@/shared/queries/read-states-get';+import { WorkspaceReadState } from '@/shared/types/radars';+import { Event } from '@/shared/types/events';++export class ReadStatesGetQueryHandler+ implements QueryHandler<ReadStatesGetQueryInput>+{+ public async handleQuery(+ _: ReadStatesGetQueryInput+ ): Promise<Record<string, WorkspaceReadState>> {+ const data = radarService.getWorkspaceStates();+ return data;+ }++ public async checkForChanges(+ event: Event,+ _: ReadStatesGetQueryInput,+ ___: Record<string, WorkspaceReadState>+ ): Promise<ChangeCheckResult<ReadStatesGetQueryInput>> {+ if (+ event.type === 'node_created' ||+ event.type === 'node_updated' ||+ event.type === 'node_deleted' ||+ event.type === 'user_node_created'+ ) {+ const data = radarService.getWorkspaceStates();+ return {+ hasChanges: true,+ result: data,+ };+ }++ return {+ hasChanges: false,+ };+ }+}diff --git a/apps/desktop/src/main/handlers/queries/record-list.ts b/apps/desktop/src/main/handlers/queries/record-list.tsindex 209914d0..d6515f64 100644--- a/apps/desktop/src/main/handlers/queries/record-list.ts+++ b/apps/desktop/src/main/handlers/queries/record-list.ts@@ -1,11 +1,6 @@-import { RecordListQueryInput } from '@/operations/queries/record-list';+import { RecordListQueryInput } from '@/shared/queries/record-list';import { databaseService } from '@/main/data/database-service';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';+import { ChangeCheckResult, QueryHandler } from '@/main/types';import { SelectNode } from '@/main/data/workspace/schema';import { sql } from 'kysely';import {@@ -26,60 +21,94 @@ import {DatabaseNode,RecordNode,} from '@colanode/core';-import { isStringArray } from '@/lib/utils';+import { isStringArray } from '@/shared/lib/utils';import { mapNode } from '@/main/utils';import { NodeTypes } from '@colanode/core';-import { isEqual } from 'lodash-es';+import { Event } from '@/shared/types/events';export class RecordListQueryHandlerimplements QueryHandler<RecordListQueryInput>{- public async handleQuery(- input: RecordListQueryInput- ): Promise<QueryResult<RecordListQueryInput>> {+ public async handleQuery(input: RecordListQueryInput): Promise<RecordNode[]> {const rows = await this.fetchRecords(input);-- return {- output: this.buildRecords(rows),- state: {- rows,- },- };+ return this.buildRecords(rows);}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: RecordListQueryInput,- state: Record<string, any>+ output: RecordNode[]): Promise<ChangeCheckResult<RecordListQueryInput>> {if (- !changes.some(- (change) =>- change.type === 'workspace' &&- change.table === 'nodes' &&- change.userId === input.userId- )+ event.type === 'node_created' &&+ event.userId === input.userId &&+ event.node.type === 'record') {+ const newResult = await this.handleQuery(input);return {- hasChanges: false,+ hasChanges: true,+ result: newResult,};}- const rows = await this.fetchRecords(input);- if (isEqual(rows, state.rows)) {- return {- hasChanges: false,- };+ if (event.type === 'node_updated' && event.userId === input.userId) {+ if (+ event.node.type === 'record' &&+ event.node.attributes.databaseId === input.databaseId+ ) {+ const record = output.find((record) => record.id === event.node.id);+ if (record) {+ const newResult = output.map((record) => {+ if (record.id === event.node.id) {+ return event.node as RecordNode;+ }+ return record;+ });++ return {+ hasChanges: true,+ result: newResult,+ };+ }+ }++ if (+ event.node.type === 'database' &&+ event.node.id === input.databaseId+ ) {+ const newResult = await this.handleQuery(input);+ return {+ hasChanges: true,+ result: newResult,+ };+ }+ }++ if (event.type === 'node_deleted' && event.userId === input.userId) {+ if (+ event.node.type === 'record' &&+ event.node.attributes.databaseId === input.databaseId+ ) {+ const newResult = await this.handleQuery(input);+ return {+ hasChanges: true,+ result: newResult,+ };+ }++ if (+ event.node.type === 'database' &&+ event.node.id === input.databaseId+ ) {+ return {+ hasChanges: true,+ result: [],+ };+ }}return {- hasChanges: true,- result: {- output: this.buildRecords(rows),- state: {- rows,- },- },+ hasChanges: false,};}@@ -99,28 +128,13 @@ export class RecordListQueryHandlerconst orderByQuery = `ORDER BY ${input.sorts.length > 0 ? this.buildSortOrdersQuery(input.sorts, database.attributes.fields) : 'n."index" ASC'}`;const offset = (input.page - 1) * input.count;const query = sql<SelectNode>`- WITH record_nodes AS (- SELECT n.*, ROW_NUMBER() OVER (${sql.raw(orderByQuery)}) AS order_number- FROM nodes n- WHERE n.parent_id = ${input.databaseId} AND n.type = ${NodeTypes.Record} ${sql.raw(filterQuery)}- ${sql.raw(orderByQuery)}- LIMIT ${sql.lit(input.count)}- OFFSET ${sql.lit(offset)}- ),- author_nodes AS (- SELECT *, NULL AS order_number- FROM nodes- WHERE id IN (SELECT DISTINCT created_by FROM record_nodes)- ),- all_nodes as (- SELECT * FROM record_nodes- UNION ALL- SELECT * FROM author_nodes- )SELECT n.*- FROM all_nodes n- ORDER BY n.order_number ASC- `.compile(workspaceDatabase);+ FROM nodes n+ WHERE n.parent_id = ${input.databaseId} AND n.type = ${NodeTypes.Record} ${sql.raw(filterQuery)}+ ${sql.raw(orderByQuery)}+ LIMIT ${sql.lit(input.count)}+ OFFSET ${sql.lit(offset)}+ `.compile(workspaceDatabase);const result = await workspaceDatabase.executeQuery(query);return result.rows;diff --git a/apps/desktop/src/main/handlers/queries/server-list.ts b/apps/desktop/src/main/handlers/queries/server-list.tsindex df01b614..6ed94bd5 100644--- a/apps/desktop/src/main/handlers/queries/server-list.ts+++ b/apps/desktop/src/main/handlers/queries/server-list.ts@@ -1,60 +1,33 @@-import { ServerListQueryInput } from '@/operations/queries/server-list';+import { ServerListQueryInput } from '@/shared/queries/server-list';import { databaseService } from '@/main/data/database-service';import { SelectServer } from '@/main/data/app/schema';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { isEqual } from 'lodash-es';-import { Server } from '@/types/servers';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { Server } from '@/shared/types/servers';+import { Event } from '@/shared/types/events';export class ServerListQueryHandlerimplements QueryHandler<ServerListQueryInput>{- async handleQuery(- _: ServerListQueryInput- ): Promise<QueryResult<ServerListQueryInput>> {+ async handleQuery(_: ServerListQueryInput): Promise<Server[]> {const rows = await this.fetchServers();- return {- output: this.mapServers(rows),- state: {- rows,- },- };+ return this.mapServers(rows);}async checkForChanges(- changes: MutationChange[],+ event: Event,_: ServerListQueryInput,- state: Record<string, any>+ output: Server[]): Promise<ChangeCheckResult<ServerListQueryInput>> {- if (- !changes.some(- (change) => change.type === 'app' && change.table === 'servers'- )- ) {- return {- hasChanges: false,- };- }-- const rows = await this.fetchServers();- if (isEqual(rows, state.rows)) {+ if (event.type === 'server_created') {+ const newServers = [...output, event.server];return {- hasChanges: false,+ hasChanges: true,+ result: newServers,};}return {- hasChanges: true,- result: {- output: this.mapServers(rows),- state: {- rows,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/user-search.ts b/apps/desktop/src/main/handlers/queries/user-search.tsindex a8ea2e3c..03e493ee 100644--- a/apps/desktop/src/main/handlers/queries/user-search.ts+++ b/apps/desktop/src/main/handlers/queries/user-search.ts@@ -1,73 +1,68 @@-import { UserSearchQueryInput } from '@/operations/queries/user-search';+import { UserSearchQueryInput } from '@/shared/queries/user-search';import { databaseService } from '@/main/data/database-service';import { sql } from 'kysely';import { SelectNode } from '@/main/data/workspace/schema';import { NodeTypes } from '@colanode/core';import { UserNode } from '@colanode/core';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { isEqual } from 'lodash-es';+import { ChangeCheckResult, QueryHandler } from '@/main/types';import { mapNode } from '@/main/utils';+import { Event } from '@/shared/types/events';export class UserSearchQueryHandlerimplements QueryHandler<UserSearchQueryInput>{- public async handleQuery(- input: UserSearchQueryInput- ): Promise<QueryResult<UserSearchQueryInput>> {+ public async handleQuery(input: UserSearchQueryInput): Promise<UserNode[]> {const rows =input.searchQuery.length > 0? await this.searchUsers(input): await this.fetchUsers(input);- return {- output: this.buildUserNodes(rows),- state: {- rows,- },- };++ return this.buildUserNodes(rows);}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: UserSearchQueryInput,- state: Record<string, any>+ _: UserNode[]): Promise<ChangeCheckResult<UserSearchQueryInput>> {if (- !changes.some(- (change) =>- change.type === 'workspace' &&- change.table === 'nodes' &&- change.userId === input.userId- )+ event.type === 'node_created' &&+ event.userId === input.userId &&+ event.node.type === 'user') {+ const newResult = await this.handleQuery(input);return {- hasChanges: false,+ hasChanges: true,+ result: newResult,};}- const rows =- input.searchQuery.length > 0- ? await this.searchUsers(input)- : await this.fetchUsers(input);+ if (+ event.type === 'node_updated' &&+ event.userId === input.userId &&+ event.node.type === 'user'+ ) {+ const newResult = await this.handleQuery(input);+ return {+ hasChanges: true,+ result: newResult,+ };+ }- if (isEqual(rows, state.rows)) {+ if (+ event.type === 'node_deleted' &&+ event.userId === input.userId &&+ event.node.type === 'user'+ ) {+ const newResult = await this.handleQuery(input);return {- hasChanges: false,+ hasChanges: true,+ result: newResult,};}return {- hasChanges: true,- result: {- output: this.buildUserNodes(rows),- state: {- rows,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/workspace-list.ts b/apps/desktop/src/main/handlers/queries/workspace-list.tsindex f40dd9d2..dabeaf97 100644--- a/apps/desktop/src/main/handlers/queries/workspace-list.ts+++ b/apps/desktop/src/main/handlers/queries/workspace-list.ts@@ -1,62 +1,59 @@-import { WorkspaceListQueryInput } from '@/operations/queries/workspace-list';+import { WorkspaceListQueryInput } from '@/shared/queries/workspace-list';import { databaseService } from '@/main/data/database-service';-import { Workspace } from '@/types/workspaces';+import { Workspace } from '@/shared/types/workspaces';import { WorkspaceRole } from '@colanode/core';import { SelectWorkspace } from '@/main/data/app/schema';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { isEqual } from 'lodash-es';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { Event } from '@/shared/types/events';export class WorkspaceListQueryHandlerimplements QueryHandler<WorkspaceListQueryInput>{- public async handleQuery(- _: WorkspaceListQueryInput- ): Promise<QueryResult<WorkspaceListQueryInput>> {+ public async handleQuery(_: WorkspaceListQueryInput): Promise<Workspace[]> {const rows = await this.fetchWorkspaces();-- return {- output: this.buildWorkspaces(rows),- state: {- rows,- },- };+ return this.buildWorkspaces(rows);}public async checkForChanges(- changes: MutationChange[],+ event: Event,_: WorkspaceListQueryInput,- state: Record<string, any>+ output: Workspace[]): Promise<ChangeCheckResult<WorkspaceListQueryInput>> {- if (- !changes.some(- (change) => change.type === 'app' && change.table === 'workspaces'- )- ) {+ if (event.type === 'workspace_created') {+ const newWorkspaces = [...output, event.workspace];return {- hasChanges: false,+ hasChanges: true,+ result: newWorkspaces,};}- const rows = await this.fetchWorkspaces();- if (isEqual(rows, state.rows)) {+ if (event.type === 'workspace_updated') {+ const updatedWorkspaces = output.map((workspace) => {+ if (workspace.id === event.workspace.id) {+ return event.workspace;+ }+ return workspace;+ });++ return {+ hasChanges: true,+ result: updatedWorkspaces,+ };+ }++ if (event.type === 'workspace_deleted') {+ const activeWorkspaces = output.filter(+ (workspace) => workspace.id !== event.workspace.id+ );+return {- hasChanges: false,+ hasChanges: true,+ result: activeWorkspaces,};}return {- hasChanges: true,- result: {- output: this.buildWorkspaces(rows),- state: {- rows,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/handlers/queries/workspace-user-list.ts b/apps/desktop/src/main/handlers/queries/workspace-user-list.tsindex 35ec26d7..dfa469e7 100644--- a/apps/desktop/src/main/handlers/queries/workspace-user-list.ts+++ b/apps/desktop/src/main/handlers/queries/workspace-user-list.ts@@ -1,65 +1,74 @@-import { WorkspaceUserListQueryInput } from '@/operations/queries/workspace-user-list';+import { WorkspaceUserListQueryInput } from '@/shared/queries/workspace-user-list';import { databaseService } from '@/main/data/database-service';import { NodeTypes } from '@colanode/core';import { mapNode } from '@/main/utils';import { SelectNode } from '@/main/data/workspace/schema';import { UserNode } from '@colanode/core';-import {- MutationChange,- ChangeCheckResult,- QueryHandler,- QueryResult,-} from '@/main/types';-import { isEqual } from 'lodash-es';+import { ChangeCheckResult, QueryHandler } from '@/main/types';+import { Event } from '@/shared/types/events';export class WorkspaceUserListQueryHandlerimplements QueryHandler<WorkspaceUserListQueryInput>{public async handleQuery(input: WorkspaceUserListQueryInput- ): Promise<QueryResult<WorkspaceUserListQueryInput>> {+ ): Promise<UserNode[]> {const rows = await this.fetchNodes(input);- return {- output: this.buildWorkspaceUserNodes(rows),- state: {- rows,- },- };+ return this.buildWorkspaceUserNodes(rows);}public async checkForChanges(- changes: MutationChange[],+ event: Event,input: WorkspaceUserListQueryInput,- state: Record<string, any>+ output: UserNode[]): Promise<ChangeCheckResult<WorkspaceUserListQueryInput>> {if (- !changes.some(- (change) =>- change.type === 'workspace' &&- change.table === 'nodes' &&- change.userId === input.userId- )+ event.type === 'node_created' &&+ event.userId === input.userId &&+ event.node.type === 'user') {+ const newResult = await this.handleQuery(input);return {- hasChanges: false,+ hasChanges: true,+ result: newResult,};}- const rows = await this.fetchNodes(input);- if (isEqual(rows, state.rows)) {+ if (+ event.type === 'node_updated' &&+ event.userId === input.userId &&+ event.node.type === 'user'+ ) {+ const user = output.find((user) => user.id === event.node.id);+ if (user) {+ const newUsers = output.map((user) => {+ if (user.id === event.node.id) {+ return event.node as UserNode;+ }+ return user;+ });++ return {+ hasChanges: true,+ result: newUsers,+ };+ }+ }++ if (+ event.type === 'node_deleted' &&+ event.userId === input.userId &&+ event.node.type === 'user'+ ) {+ const newResult = await this.handleQuery(input);return {- hasChanges: false,+ hasChanges: true,+ result: newResult,};}return {- hasChanges: true,- result: {- output: this.buildWorkspaceUserNodes(rows),- state: {- rows,- },- },+ hasChanges: false,};}diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.tsindex bcca77b9..3ab2cb65 100644--- a/apps/desktop/src/main/index.ts+++ b/apps/desktop/src/main/index.ts@@ -1,17 +1,19 @@import { app, shell, BrowserWindow, ipcMain, protocol, dialog } from 'electron';import { join } from 'path';import { electronApp, optimizer, is } from '@electron-toolkit/utils';-import { eventBus } from '@/lib/event-bus';+import { eventBus } from '@/shared/lib/event-bus';import { databaseService } from '@/main/data/database-service';import { socketService } from '@/main/services/socket-service';import { synchronizer } from '@/main/synchronizer';import { avatarService } from '@/main/services/avatar-service';import { fileService } from '@/main/services/file-service';-import { mediator } from '@/main/mediator';-import { FileMetadata } from '@/types/files';-import { MutationInput, MutationMap } from '@/operations/mutations';-import { QueryInput, QueryMap } from '@/operations/queries';+import { FileMetadata } from '@/shared/types/files';+import { MutationInput, MutationMap } from '@/shared/mutations';+import { QueryInput, QueryMap } from '@/shared/queries';import { assetService } from '@/main/services/asset-service';+import { radarService } from '@/main/services/radar-service';+import { mutationService } from '@/main/services/mutation-service';+import { queryService } from '@/main/services/query-service';let subscriptionId: string | null = null;const icon = join(__dirname, '../assets/icon.png');@@ -23,6 +25,7 @@ const createWindow = async (): Promise<void> => {assetService.checkAssets();socketService.init();synchronizer.init();+ radarService.init();// Create the browser window.const mainWindow = new BrowserWindow({@@ -56,7 +59,9 @@ const createWindow = async (): Promise<void> => {if (subscriptionId === null) {subscriptionId = eventBus.subscribe((event) => {- mainWindow.webContents.send('event', event);+ if (event.type === 'query_result_updated') {+ mainWindow.webContents.send('event', event);+ }});}@@ -133,7 +138,7 @@ ipcMain.handle(_: unknown,input: T): Promise<MutationMap[T['type']]['output']> => {- return mediator.executeMutation(input);+ return mutationService.executeMutation(input);});@@ -143,7 +148,7 @@ ipcMain.handle(_: unknown,input: T): Promise<QueryMap[T['type']]['output']> => {- return mediator.executeQuery(input);+ return queryService.executeQuery(input);});@@ -154,12 +159,12 @@ ipcMain.handle(id: string,input: T): Promise<QueryMap[T['type']]['output']> => {- return mediator.executeQueryAndSubscribe(id, input);+ return queryService.executeQueryAndSubscribe(id, input);});ipcMain.handle('unsubscribe-query', (_: unknown, id: string): void => {- mediator.unsubscribeQuery(id);+ queryService.unsubscribeQuery(id);});ipcMain.handle(diff --git a/apps/desktop/src/main/mediator.ts b/apps/desktop/src/main/mediator.tsindex 6ba2bdac..f65b26ff 100644--- a/apps/desktop/src/main/mediator.ts+++ b/apps/desktop/src/main/mediator.ts@@ -1,57 +1,11 @@-import { MutationInput, MutationMap } from '@/operations/mutations';-import { MutationChange, MutationHandler } from '@/main/types';-import { mutationHandlerMap } from '@/main/handlers/mutations';-import { QueryInput, QueryMap } from '@/operations/queries';-import { QueryHandler, SubscribedQuery } from '@/main/types';-import { queryHandlerMap } from '@/main/handlers/queries';-import { eventBus } from '@/lib/event-bus';import {MessageContext,MessageHandler,MessageInput,-} from '@/operations/messages';+} from '@/shared/messages';import { messageHandlerMap } from '@/main/handlers/messages';class Mediator {- private readonly subscribedQueries: Map<string, SubscribedQuery<QueryInput>> =- new Map();-- public async executeMutation<T extends MutationInput>(- input: T- ): Promise<MutationMap[T['type']]['output']> {- const handler = mutationHandlerMap[- input.type- ] as unknown as MutationHandler<T>;- const result = await handler.handleMutation(input);-- if (result.changes) {- await this.checkForQueryChanges(result.changes);- }-- return result.output;- }-- public async executeQuery<T extends QueryInput>(- input: T- ): Promise<QueryMap[T['type']]['output']> {- const handler = queryHandlerMap[input.type] as unknown as QueryHandler<T>;- const result = await handler.handleQuery(input);- return result.output;- }-- public async executeQueryAndSubscribe<T extends QueryInput>(- id: string,- input: T- ): Promise<QueryMap[T['type']]['output']> {- const handler = queryHandlerMap[input.type] as unknown as QueryHandler<T>;- const result = await handler.handleQuery(input);- this.subscribedQueries.set(id, {- input,- result,- });- return result.output;- }-public async executeMessage<T extends MessageInput>(context: MessageContext,input: T@@ -59,43 +13,6 @@ class Mediator {const handler = messageHandlerMap[input.type] as MessageHandler<T>;await handler.handleMessage(context, input);}-- public unsubscribeQuery(id: string) {- this.subscribedQueries.delete(id);- }-- public async checkForQueryChanges(changes: MutationChange[]): Promise<void> {- if (changes.length === 0) {- return;- }-- for (const [id, query] of this.subscribedQueries) {- const handler = queryHandlerMap[query.input.type] as QueryHandler<- typeof query.input- >;-- const changeCheckResult = await handler.checkForChanges(- changes,- query.input,- query.result.state- );- if (changeCheckResult.hasChanges && changeCheckResult.result) {- const newResult = changeCheckResult.result;- this.subscribedQueries.set(id, {- input: query.input,- result: newResult,- });-- eventBus.publish({- event: 'query_result_updated',- payload: {- id: id,- result: newResult.output,- },- });- }- }- }}export const mediator = new Mediator();diff --git a/apps/desktop/src/main/services/asset-service.ts b/apps/desktop/src/main/services/asset-service.tsindex 745ebe16..57a8ac0a 100644--- a/apps/desktop/src/main/services/asset-service.ts+++ b/apps/desktop/src/main/services/asset-service.ts@@ -2,8 +2,8 @@ import { app, net } from 'electron';import path from 'path';import fs from 'fs';import unzipper from 'unzipper';-import { EmojiData } from '@/types/emojis';-import { IconData } from '@/types/icons';+import { EmojiData } from '@/shared/types/emojis';+import { IconData } from '@/shared/types/icons';type AssetsVersion = {date: string;diff --git a/apps/desktop/src/main/services/avatar-service.ts b/apps/desktop/src/main/services/avatar-service.tsindex bde8d7d3..c0187c70 100644--- a/apps/desktop/src/main/services/avatar-service.ts+++ b/apps/desktop/src/main/services/avatar-service.ts@@ -2,7 +2,7 @@ import { net } from 'electron';import path from 'path';import fs from 'fs';import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';+import { httpClient } from '@/shared/lib/http-client';import { getAccountAvatarsDirectoryPath } from '@/main/utils';class AvatarService {diff --git a/apps/desktop/src/main/services/file-service.ts b/apps/desktop/src/main/services/file-service.tsindex 250d0eb3..0e577db5 100644--- a/apps/desktop/src/main/services/file-service.ts+++ b/apps/desktop/src/main/services/file-service.ts@@ -7,13 +7,13 @@ import {FileMetadata,ServerFileDownloadResponse,ServerFileUploadResponse,-} from '@/types/files';-import { WorkspaceCredentials } from '@/types/workspaces';+} from '@/shared/types/files';+import { WorkspaceCredentials } from '@/shared/types/workspaces';import { databaseService } from '@/main/data/database-service';-import { httpClient } from '@/lib/http-client';-import { mediator } from '@/main/mediator';+import { httpClient } from '@/shared/lib/http-client';import { getWorkspaceFilesDirectoryPath } from '@/main/utils';import { FileAttributes } from '@colanode/core';+import { eventBus } from '@/shared/lib/event-bus';class FileService {public async handleFileRequest(request: Request): Promise<Response> {@@ -178,14 +178,6 @@ class FileService {.execute();}}-- await mediator.checkForQueryChanges([- {- type: 'workspace',- userId: credentials.userId,- table: 'uploads',- },- ]);}public async checkForDownloads(@@ -223,6 +215,18 @@ class FileService {.where('node_id', '=', download.node_id).execute();+ eventBus.publish({+ type: 'download_deleted',+ userId: credentials.userId,+ download: {+ nodeId: download.node_id,+ createdAt: download.created_at,+ updatedAt: download.updated_at,+ progress: download.progress,+ retryCount: download.retry_count,+ },+ });+continue;}@@ -241,6 +245,18 @@ class FileService {.where('node_id', '=', download.node_id).execute();+ eventBus.publish({+ type: 'download_updated',+ userId: credentials.userId,+ download: {+ nodeId: download.node_id,+ createdAt: download.created_at,+ updatedAt: download.updated_at,+ progress: 100,+ retryCount: download.retry_count,+ },+ });+continue;}@@ -267,6 +283,18 @@ class FileService {.set({ progress: 100 }).where('node_id', '=', download.node_id).execute();++ eventBus.publish({+ type: 'download_updated',+ userId: credentials.userId,+ download: {+ nodeId: download.node_id,+ createdAt: download.created_at,+ updatedAt: download.updated_at,+ progress: 100,+ retryCount: download.retry_count,+ },+ });} catch (error) {console.log('error', error);@@ -275,16 +303,20 @@ class FileService {.set((eb) => ({ retry_count: eb('retry_count', '+', 1) })).where('node_id', '=', download.node_id).execute();++ eventBus.publish({+ type: 'download_updated',+ userId: credentials.userId,+ download: {+ nodeId: download.node_id,+ createdAt: download.created_at,+ updatedAt: download.updated_at,+ progress: download.progress,+ retryCount: download.retry_count + 1,+ },+ });}}-- await mediator.checkForQueryChanges([- {- type: 'workspace',- userId: credentials.userId,- table: 'downloads',- },- ]);}}diff --git a/apps/desktop/src/main/services/mutation-service.ts b/apps/desktop/src/main/services/mutation-service.tsnew file mode 100644index 00000000..d91ef895--- /dev/null+++ b/apps/desktop/src/main/services/mutation-service.ts@@ -0,0 +1,22 @@+import { MutationInput } from '@/shared/mutations';++import { MutationMap } from '@/shared/mutations';+import { mutationHandlerMap } from '@/main/handlers/mutations';+import { MutationHandler } from '@/main/types';++class MutationService {+ public async executeMutation<T extends MutationInput>(+ input: T+ ): Promise<MutationMap[T['type']]['output']> {+ const handler = mutationHandlerMap[+ input.type+ ] as unknown as MutationHandler<T>;+ if (!handler) {+ throw new Error(`No handler found for mutation type: ${input.type}`);+ }++ return handler.handleMutation(input);+ }+}++export const mutationService = new MutationService();diff --git a/apps/desktop/src/main/services/node-service.ts b/apps/desktop/src/main/services/node-service.tsindex 288d99de..bc267a06 100644--- a/apps/desktop/src/main/services/node-service.ts+++ b/apps/desktop/src/main/services/node-service.ts@@ -9,11 +9,14 @@ import {LocalCreateNodeChangeData,LocalDeleteNodeChangeData,LocalUpdateNodeChangeData,-} from '@/types/sync';+} from '@/shared/types/sync';import { generateId, IdType } from '@colanode/core';import { databaseService } from '@/main/data/database-service';-import { fetchNodeAncestors, hasUpdateChanges, mapNode } from '@/main/utils';+import { fetchNodeAncestors, mapNode } from '@/main/utils';import { CreateDownload, CreateUpload } from '@/main/data/workspace/schema';+import { eventBus } from '@/shared/lib/event-bus';+import { Download } from '@/shared/types/nodes';+import { Upload } from '@/shared/types/nodes';export type CreateNodeInput = {id: string;@@ -35,6 +38,9 @@ class NodeService {}const inputs = Array.isArray(input) ? input : [input];+ const createdNodes: Node[] = [];+ const createdUploads: Upload[] = [];+ const createdDownloads: Download[] = [];const workspaceDatabase =await databaseService.getWorkspaceDatabase(userId);@@ -82,8 +88,9 @@ class NodeService {versionId: versionId,};- await transaction+ const createdNodeRow = await transaction.insertInto('nodes')+ .returningAll().values({id: input.id,attributes: JSON.stringify(input.attributes),@@ -92,7 +99,12 @@ class NodeService {created_by: context.userId,version_id: versionId,})- .execute();+ .executeTakeFirst();++ if (createdNodeRow) {+ const createdNode = mapNode(createdNodeRow);+ createdNodes.push(createdNode);+ }await transaction.insertInto('changes')@@ -104,20 +116,66 @@ class NodeService {.execute();if (input.upload) {- await transaction+ const createdUploadRow = await transaction.insertInto('uploads')+ .returningAll().values(input.upload)- .execute();+ .executeTakeFirst();++ if (createdUploadRow) {+ createdUploads.push({+ nodeId: createdUploadRow.node_id,+ createdAt: createdUploadRow.created_at,+ updatedAt: createdUploadRow.updated_at,+ progress: createdUploadRow.progress,+ retryCount: createdUploadRow.retry_count,+ });+ }}if (input.download) {- await transaction+ const createdDownloadRow = await transaction.insertInto('downloads')+ .returningAll().values(input.download)- .execute();+ .executeTakeFirst();++ if (createdDownloadRow) {+ createdDownloads.push({+ nodeId: createdDownloadRow.node_id,+ createdAt: createdDownloadRow.created_at,+ updatedAt: createdDownloadRow.updated_at,+ progress: createdDownloadRow.progress,+ retryCount: createdDownloadRow.retry_count,+ });+ }}}});++ for (const createdNode of createdNodes) {+ eventBus.publish({+ type: 'node_created',+ userId,+ node: createdNode,+ });+ }++ for (const createdUpload of createdUploads) {+ eventBus.publish({+ type: 'upload_created',+ userId,+ upload: createdUpload,+ });+ }++ for (const createdDownload of createdDownloads) {+ eventBus.publish({+ type: 'download_created',+ userId,+ download: createdDownload,+ });+ }}async updateNode(@@ -161,7 +219,7 @@ class NodeService {}const ancestors = ancestorRows.map(mapNode);- const node = mapNode(nodeRow);+ let node = mapNode(nodeRow);if (!node) {throw new Error('Node not found');@@ -208,8 +266,9 @@ class NodeService {const result = await workspaceDatabase.transaction().execute(async (trx) => {- const result = await trx+ const updatedRow = await trx.updateTable('nodes')+ .returningAll().set({attributes: JSON.stringify(ydoc.getAttributes()),state: ydoc.getState(),@@ -219,11 +278,11 @@ class NodeService {}).where('id', '=', nodeId).where('version_id', '=', node.versionId)- .execute();+ .executeTakeFirst();- const hasChanges = hasUpdateChanges(result);+ if (updatedRow) {+ node = mapNode(updatedRow);- if (hasChanges) {await trx.insertInto('changes').values({@@ -234,9 +293,17 @@ class NodeService {.execute();}- return hasChanges;+ return true;});+ if (result) {+ eventBus.publish({+ type: 'node_updated',+ userId,+ node,+ });+ }+return result;}@@ -300,6 +367,12 @@ class NodeService {}).execute();});++ eventBus.publish({+ type: 'node_deleted',+ userId,+ node: node,+ });}}diff --git a/apps/desktop/src/main/services/query-service.ts b/apps/desktop/src/main/services/query-service.tsnew file mode 100644index 00000000..e11be225--- /dev/null+++ b/apps/desktop/src/main/services/query-service.ts@@ -0,0 +1,73 @@+import { QueryInput, QueryMap } from '@/shared/queries';+import { QueryHandler, SubscribedQuery } from '@/main/types';+import { queryHandlerMap } from '@/main/handlers/queries';+import { eventBus } from '@/shared/lib/event-bus';+import { Event } from '@/shared/types/events';++class QueryService {+ private readonly subscribedQueries: Map<string, SubscribedQuery<QueryInput>> =+ new Map();++ constructor() {+ eventBus.subscribe((event: Event) => {+ this.checkForQueryChanges(event);+ });+ }++ public async executeQuery<T extends QueryInput>(+ input: T+ ): Promise<QueryMap[T['type']]['output']> {+ const handler = queryHandlerMap[input.type] as unknown as QueryHandler<T>;+ const result = await handler.handleQuery(input);+ return result;+ }++ public async executeQueryAndSubscribe<T extends QueryInput>(+ id: string,+ input: T+ ): Promise<QueryMap[T['type']]['output']> {+ if (this.subscribedQueries.has(id)) {+ return this.subscribedQueries.get(id)!.result;+ }++ const handler = queryHandlerMap[input.type] as unknown as QueryHandler<T>;+ const result = await handler.handleQuery(input);+ this.subscribedQueries.set(id, {+ input,+ result,+ });+ return result;+ }++ public unsubscribeQuery(id: string) {+ this.subscribedQueries.delete(id);+ }++ private async checkForQueryChanges(event: Event): Promise<void> {+ for (const [id, query] of this.subscribedQueries) {+ const handler = queryHandlerMap[query.input.type] as QueryHandler<+ typeof query.input+ >;+ const changeCheckResult = await handler.checkForChanges(+ event,+ query.input,+ query.result+ );+ if (changeCheckResult.hasChanges && changeCheckResult.result) {+ const newResult = changeCheckResult.result;+ this.subscribedQueries.set(id, {+ input: query.input,+ result: newResult,+ });++ eventBus.publish({+ type: 'query_result_updated',+ id,+ result: newResult,+ });+ }+ }+ }+}++export const queryService = new QueryService();diff --git a/apps/desktop/src/main/services/radar-service.ts b/apps/desktop/src/main/services/radar-service.tsnew file mode 100644index 00000000..a7cdd527--- /dev/null+++ b/apps/desktop/src/main/services/radar-service.ts@@ -0,0 +1,93 @@+import { databaseService } from '@/main/data/database-service';+import { Kysely } from 'kysely';+import { WorkspaceDatabaseSchema } from '@/main/data/workspace/schema';+import { getIdType, IdType, NodeTypes } from '@colanode/core';+import { WorkspaceReadState } from '@/shared/types/radars';+import { eventBus } from '@/shared/lib/event-bus';++class RadarService {+ private readonly workspaceStates: Record<string, WorkspaceReadState> = {};++ constructor() {+ eventBus.subscribe((event) => {+ console.log('event', event);+ });+ }++ public async init(): Promise<void> {+ const workspaceDatabases = await databaseService.getWorkspaceDatabases();+ for (const [userId, workspaceDatabase] of workspaceDatabases.entries()) {+ await this.initWorkspace(userId, workspaceDatabase);+ }+ }++ public getWorkspaceStates(): Record<string, WorkspaceReadState> {+ return this.workspaceStates;+ }++ private async initWorkspace(+ userId: string,+ workspaceDatabase: Kysely<WorkspaceDatabaseSchema>+ ): Promise<void> {+ const workspaceState: WorkspaceReadState = {+ importantCount: 0,+ hasUnseenChanges: false,+ nodeStates: {},+ };++ const nodeUnreadMessageCounts = await workspaceDatabase+ .selectFrom('user_nodes as un')+ .innerJoin('nodes as n', 'un.node_id', 'n.id')+ .where('un.user_id', '=', userId)+ .where('n.type', '=', NodeTypes.Message)+ .where('un.last_seen_version_id', 'is', null)+ .select(['n.parent_id as node_id'])+ .select((eb) => [+ eb.fn.count<number>('un.node_id').as('messages_count'),+ eb.fn.sum<number>('un.mentions_count').as('mentions_count'),+ ])+ .groupBy('n.parent_id')+ .execute();++ for (const nodeUnreadMessageCount of nodeUnreadMessageCounts) {+ const idType = getIdType(nodeUnreadMessageCount.node_id);+ const nodeId = nodeUnreadMessageCount.node_id;+ const messagesCount = nodeUnreadMessageCount.messages_count;+ const mentionsCount = nodeUnreadMessageCount.mentions_count;++ if (idType === IdType.Chat) {+ workspaceState.nodeStates[nodeId] = {+ type: 'chat',+ nodeId,+ unseenMessagesCount: messagesCount,+ mentionsCount,+ };++ if (mentionsCount > 0) {+ workspaceState.importantCount += mentionsCount;+ }++ if (messagesCount > 0) {+ workspaceState.hasUnseenChanges = true;+ }+ } else if (idType === IdType.Channel) {+ workspaceState.nodeStates[nodeId] = {+ type: 'channel',+ nodeId,+ unseenMessagesCount: messagesCount,+ mentionsCount,+ };++ if (messagesCount > 0) {+ workspaceState.importantCount += messagesCount;+ } else if (mentionsCount > 0) {+ workspaceState.importantCount += mentionsCount;+ }+ }+ }++ this.workspaceStates[userId] = workspaceState;+ }+}++export const radarService = new RadarService();diff --git a/apps/desktop/src/main/services/socket-connection.ts b/apps/desktop/src/main/services/socket-connection.tsindex 33f83bac..e1a9ee2b 100644--- a/apps/desktop/src/main/services/socket-connection.ts+++ b/apps/desktop/src/main/services/socket-connection.ts@@ -1,9 +1,9 @@import { WebSocket } from 'ws';-import { BackoffCalculator } from '@/lib/backoff-calculator';-import { MessageContext, MessageInput } from '@/operations/messages';+import { BackoffCalculator } from '@/shared/lib/backoff-calculator';+import { MessageContext, MessageInput } from '@/shared/messages';import { mediator } from '@/main/mediator';import { SelectAccount, SelectServer } from '@/main/data/app/schema';-import { ServerAttributes } from '@/types/servers';+import { ServerAttributes } from '@/shared/types/servers';const buildSynapseUrl = (server: SelectServer, deviceId: string) => {const attributes = JSON.parse(server.attributes) as ServerAttributes;diff --git a/apps/desktop/src/main/services/socket-service.ts b/apps/desktop/src/main/services/socket-service.tsindex 001c8b01..28430f82 100644--- a/apps/desktop/src/main/services/socket-service.ts+++ b/apps/desktop/src/main/services/socket-service.ts@@ -1,6 +1,6 @@import { SocketConnection } from '@/main/services/socket-connection';import { databaseService } from '@/main/data/database-service';-import { MessageInput } from '@/operations/messages';+import { MessageInput } from '@/shared/messages';const EVENT_LOOP_INTERVAL = 5000;diff --git a/apps/desktop/src/main/synchronizer.ts b/apps/desktop/src/main/synchronizer.tsindex 086cbced..2fb3495c 100644--- a/apps/desktop/src/main/synchronizer.ts+++ b/apps/desktop/src/main/synchronizer.ts@@ -1,7 +1,7 @@-import { httpClient } from '@/lib/http-client';+import { httpClient } from '@/shared/lib/http-client';import { databaseService } from '@/main/data/database-service';-import { ServerSyncResponse } from '@/types/sync';-import { WorkspaceCredentials } from '@/types/workspaces';+import { ServerSyncResponse } from '@/shared/types/sync';+import { WorkspaceCredentials } from '@/shared/types/workspaces';import { fileService } from '@/main/services/file-service';const EVENT_LOOP_INTERVAL = 1000;diff --git a/apps/desktop/src/main/types.ts b/apps/desktop/src/main/types.tsindex cae48d04..f5ff3886 100644--- a/apps/desktop/src/main/types.ts+++ b/apps/desktop/src/main/types.ts@@ -1,50 +1,26 @@-import { AppDatabaseSchema } from '@/main/data/app/schema';-import { WorkspaceDatabaseSchema } from '@/main/data/workspace/schema';-import { MutationInput, MutationMap } from '@/operations/mutations';-import { QueryInput, QueryMap } from '@/operations/queries';+import { MutationInput, MutationMap } from '@/shared/mutations';+import { QueryInput, QueryMap } from '@/shared/queries';+import { Event } from '@/shared/types/events';export interface MutationHandler<T extends MutationInput> {- handleMutation: (input: T) => Promise<MutationResult<T>>;+ handleMutation: (input: T) => Promise<MutationMap[T['type']]['output']>;}-export type MutationResult<T extends MutationInput> = {- output: MutationMap[T['type']]['output'];- changes?: MutationChange[];-};--export type MutationChange = AppMutationChange | WorkspaceMutationChange;--export type AppMutationChange = {- type: 'app';- table: keyof AppDatabaseSchema;-};--export type WorkspaceMutationChange = {- type: 'workspace';- table: keyof WorkspaceDatabaseSchema;- userId: string;-};-export interface QueryHandler<T extends QueryInput> {- handleQuery: (input: T) => Promise<QueryResult<T>>;+ handleQuery: (input: T) => Promise<QueryMap[T['type']]['output']>;checkForChanges: (- changes: MutationChange[],+ event: Event,input: T,- state: Record<string, any>+ output: QueryMap[T['type']]['output']) => Promise<ChangeCheckResult<T>>;}-export type QueryResult<T extends QueryInput> = {- output: QueryMap[T['type']]['output'];- state: Record<string, any>;-};-export type SubscribedQuery<T extends QueryInput> = {input: T;- result: QueryResult<T>;+ result: QueryMap[T['type']]['output'];};export type ChangeCheckResult<T extends QueryInput> = {hasChanges: boolean;- result?: QueryResult<T>;+ result?: QueryMap[T['type']]['output'];};diff --git a/apps/desktop/src/preload/index.d.ts b/apps/desktop/src/preload/index.d.tsindex 817fb3b9..c60e1d7a 100644--- a/apps/desktop/src/preload/index.d.ts+++ b/apps/desktop/src/preload/index.d.ts@@ -1,7 +1,7 @@import { ElectronAPI } from '@electron-toolkit/preload';import { EventBus } from '@/lib/event-bus';-import { MutationMap, MutationInput } from '@/operations/mutations';-import { QueryMap, QueryInput } from '@/operations/queries';+import { MutationMap, MutationInput } from '@/shared/mutations';+import { QueryMap, QueryInput } from '@/shared/queries';import { FileMetadata } from '@/types/files';interface ColanodeApi {diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.tsindex 7cc3bc94..ebd45792 100644--- a/apps/desktop/src/preload/index.ts+++ b/apps/desktop/src/preload/index.ts@@ -1,8 +1,9 @@import { contextBridge, ipcRenderer } from 'electron';import { electronAPI } from '@electron-toolkit/preload';-import { eventBus, Event } from '@/lib/event-bus';-import { MutationInput, MutationMap } from '@/operations/mutations';-import { QueryInput, QueryMap } from '@/operations/queries';+import { eventBus } from '@/shared/lib/event-bus';+import { MutationInput, MutationMap } from '@/shared/mutations';+import { QueryInput, QueryMap } from '@/shared/queries';+import { Event } from '@/shared/types/events';// Use `contextBridge` APIs to expose Electron APIs to// renderer only if context isolation is enabled, otherwisediff --git a/apps/desktop/src/renderer/app.tsx b/apps/desktop/src/renderer/app.tsxindex df626617..993d905f 100644--- a/apps/desktop/src/renderer/app.tsx+++ b/apps/desktop/src/renderer/app.tsx@@ -7,6 +7,7 @@ import { AppContext } from '@/renderer/contexts/app';import { AccountProvider } from '@/renderer/components/accounts/account-provider';import { AccountLogout } from '@/renderer/components/accounts/account-logout';import { AccountSettingsDialog } from '@/renderer/components/accounts/account-settings-dialog';+import { RadarProvider } from '@/renderer/radar-provider';export const App = () => {const navigate = useNavigate();@@ -68,9 +69,11 @@ export const App = () => {},}}>- <AccountProvider>- <Outlet />- </AccountProvider>+ <RadarProvider>+ <AccountProvider>+ <Outlet />+ </AccountProvider>+ </RadarProvider>{logoutId && (<AccountLogoutid={logoutId}diff --git a/apps/desktop/src/renderer/components/accounts/account-update.tsx b/apps/desktop/src/renderer/components/accounts/account-update.tsxindex 4b89c87e..ce9de7da 100644--- a/apps/desktop/src/renderer/components/accounts/account-update.tsx+++ b/apps/desktop/src/renderer/components/accounts/account-update.tsx@@ -13,12 +13,12 @@ import { z } from 'zod';import { useMutation } from '@/renderer/hooks/use-mutation';import { toast } from '@/renderer/hooks/use-toast';import { Avatar } from '@/renderer/components/avatars/avatar';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Spinner } from '@/renderer/components/ui/spinner';import { Upload } from 'lucide-react';import { Input } from '@/renderer/components/ui/input';import { Button } from '@/renderer/components/ui/button';-import { Account } from '@/types/accounts';+import { Account } from '@/shared/types/accounts';const formSchema = z.object({name: z.string().min(3, 'Name must be at least 3 characters long.'),diff --git a/apps/desktop/src/renderer/components/accounts/email-login.tsx b/apps/desktop/src/renderer/components/accounts/email-login.tsxindex 8fc625fc..172ec40d 100644--- a/apps/desktop/src/renderer/components/accounts/email-login.tsx+++ b/apps/desktop/src/renderer/components/accounts/email-login.tsx@@ -12,7 +12,7 @@ import { z } from 'zod';import { useForm } from 'react-hook-form';import { zodResolver } from '@hookform/resolvers/zod';import { toast } from '@/renderer/hooks/use-toast';-import { Server } from '@/types/servers';+import { Server } from '@/shared/types/servers';import { useMutation } from '@/renderer/hooks/use-mutation';import { Mail } from 'lucide-react';import { useNavigate } from 'react-router-dom';diff --git a/apps/desktop/src/renderer/components/accounts/email-register.tsx b/apps/desktop/src/renderer/components/accounts/email-register.tsxindex 56048b86..db443958 100644--- a/apps/desktop/src/renderer/components/accounts/email-register.tsx+++ b/apps/desktop/src/renderer/components/accounts/email-register.tsx@@ -13,7 +13,7 @@ import { useForm } from 'react-hook-form';import { zodResolver } from '@hookform/resolvers/zod';import { toast } from '@/renderer/hooks/use-toast';import { useMutation } from '@/renderer/hooks/use-mutation';-import { Server } from '@/types/servers';+import { Server } from '@/shared/types/servers';import { Mail } from 'lucide-react';import { useNavigate } from 'react-router-dom';diff --git a/apps/desktop/src/renderer/components/avatars/avatar.tsx b/apps/desktop/src/renderer/components/avatars/avatar.tsxindex 050fb177..7b64f1ba 100644--- a/apps/desktop/src/renderer/components/avatars/avatar.tsx+++ b/apps/desktop/src/renderer/components/avatars/avatar.tsx@@ -1,13 +1,13 @@-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import {getAvatarSizeClasses,getAvatarUrl,getColorForId,getDefaultNodeAvatar,-} from '@/lib/avatars';+} from '@/shared/lib/avatars';import { getIdType, IdType } from '@colanode/core';-import { getEmojiUrl } from '@/lib/emojis';-import { getIconUrl } from '@/lib/icons';+import { getEmojiUrl } from '@/shared/lib/emojis';+import { getIconUrl } from '@/shared/lib/icons';import { useAccount } from '@/renderer/contexts/account';interface AvatarProps {diff --git a/apps/desktop/src/renderer/components/channels/channel-sidebar-item.tsx b/apps/desktop/src/renderer/components/channels/channel-sidebar-item.tsxindex a5b0f388..cbbddce1 100644--- a/apps/desktop/src/renderer/components/channels/channel-sidebar-item.tsx+++ b/apps/desktop/src/renderer/components/channels/channel-sidebar-item.tsx@@ -1,7 +1,8 @@-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { ChannelNode } from '@colanode/core';import { Avatar } from '@/renderer/components/avatars/avatar';import { useWorkspace } from '@/renderer/contexts/workspace';+import { useRadar } from '@/renderer/contexts/radar';interface ChannelSidebarItemProps {node: ChannelNode;@@ -9,9 +10,12 @@ interface ChannelSidebarItemProps {export const ChannelSidebarItem = ({ node }: ChannelSidebarItemProps) => {const workspace = useWorkspace();+ const radar = useRadar();+const isActive = workspace.isNodeActive(node.id);- const isUnread = false;- const mentionsCount = 0;+ const channelState = radar.getChannelState(workspace.userId, node.id);+ const unreadCount = channelState.unseenMessagesCount;+ const mentionsCount = channelState.mentionsCount;return (<button@@ -30,17 +34,17 @@ export const ChannelSidebarItem = ({ node }: ChannelSidebarItemProps) => {<spanclassName={cn('line-clamp-1 w-full flex-grow pl-2 text-left',- isUnread && 'font-bold'+ !isActive && unreadCount > 0 && 'font-semibold')}>{node.attributes.name ?? 'Unnamed'}</span>- {mentionsCount > 0 && (- <span className="mr-1 rounded-md bg-sidebar-accent px-1 py-0.5 text-xs text-sidebar-accent-foreground">+ {!isActive && mentionsCount > 0 && (+ <span className="mr-1 rounded-md bg-sidebar-accent px-1 py-0.5 text-xs bg-red-400 text-white">{mentionsCount}</span>)}- {mentionsCount == 0 && isUnread && (+ {!isActive && mentionsCount === 0 && unreadCount > 0 && (<span className="size-2 rounded-full bg-red-500" />)}</button>diff --git a/apps/desktop/src/renderer/components/chats/chat-sidebar-item.tsx b/apps/desktop/src/renderer/components/chats/chat-sidebar-item.tsxindex 1b1365e8..618e146e 100644--- a/apps/desktop/src/renderer/components/chats/chat-sidebar-item.tsx+++ b/apps/desktop/src/renderer/components/chats/chat-sidebar-item.tsx@@ -1,8 +1,9 @@-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { ChatNode } from '@colanode/core';import { Avatar } from '@/renderer/components/avatars/avatar';import { useWorkspace } from '@/renderer/contexts/workspace';import { useQuery } from '@/renderer/hooks/use-query';+import { useRadar } from '@/renderer/contexts/radar';interface ChatSidebarItemProps {node: ChatNode;@@ -10,6 +11,7 @@ interface ChatSidebarItemProps {export const ChatSidebarItem = ({ node }: ChatSidebarItemProps) => {const workspace = useWorkspace();+ const radar = useRadar();const collaboratorId =Object.keys(node.attributes.collaborators).find(@@ -26,9 +28,10 @@ export const ChatSidebarItem = ({ node }: ChatSidebarItemProps) => {return null;}+ const nodeReadState = radar.getChatState(workspace.userId, node.id);const isActive = workspace.isNodeActive(node.id);- const isUnread = false;- const mentionsCount = 0;+ const unreadCount =+ nodeReadState.unseenMessagesCount + nodeReadState.mentionsCount;return (<div@@ -47,19 +50,16 @@ export const ChatSidebarItem = ({ node }: ChatSidebarItemProps) => {<spanclassName={cn('line-clamp-1 w-full flex-grow pl-2 text-left',- isUnread && 'font-bold'+ !isActive && unreadCount > 0 && 'font-semibold')}>{data.attributes.name ?? 'Unnamed'}</span>- {mentionsCount > 0 && (- <span className="mr-1 rounded-md bg-sidebar-accent px-1 py-0.5 text-xs text-sidebar-accent-foreground">- {mentionsCount}+ {!isActive && unreadCount > 0 && (+ <span className="mr-1 rounded-md px-1 py-0.5 text-xs bg-red-400 text-white">+ {unreadCount}</span>)}- {mentionsCount == 0 && isUnread && (- <span className="size-2 rounded-full bg-red-500" />- )}</div>);};diff --git a/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsx b/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsxindex b5fdb1a1..a2879d36 100644--- a/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsx+++ b/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsx@@ -8,7 +8,7 @@ import {Node,NodeRole,} from '@colanode/core';-import { buildNodeCollaborators } from '@/lib/nodes';+import { buildNodeCollaborators } from '@/shared/lib/nodes';interface NodeCollaboratorsProps {nodeId: string;diff --git a/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsx b/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsxindex 0af4a5cd..0f87c388 100644--- a/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsx+++ b/apps/desktop/src/renderer/components/databases/boards/board-view-card.tsx@@ -7,7 +7,7 @@ import {SelectOptionAttributes,} from '@colanode/core';import { useDrag } from 'react-dnd';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';interface BoardViewCardProps {record: RecordNode;diff --git a/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsx b/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsxindex 63ce0c43..8adc72bb 100644--- a/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsx+++ b/apps/desktop/src/renderer/components/databases/boards/board-view-column.tsx@@ -1,6 +1,6 @@import React from 'react';-import { getSelectOptionLightColorClass } from '@/lib/databases';-import { cn } from '@/lib/utils';+import { getSelectOptionLightColorClass } from '@/shared/lib/databases';+import { cn } from '@/shared/lib/utils';import { useDrop } from 'react-dnd';import { SelectFieldAttributes, SelectOptionAttributes } from '@colanode/core';import { BoardViewColumnHeader } from '@/renderer/components/databases/boards/board-view-column-header';diff --git a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsx b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsxindex 28ab9ed4..8f0be249 100644--- a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsx+++ b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-card.tsx@@ -1,6 +1,6 @@import { useWorkspace } from '@/renderer/contexts/workspace';import { RecordNode } from '@colanode/core';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';interface CalendarViewCardProps {record: RecordNode;diff --git a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsx b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsxindex 1239d031..c0be7b58 100644--- a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsx+++ b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-day.tsx@@ -1,4 +1,4 @@-import { cn, isSameDay } from '@/lib/utils';+import { cn, isSameDay } from '@/shared/lib/utils';import { RecordNode } from '@colanode/core';import { CalendarViewCard } from '@/renderer/components/databases/calendars/calendar-view-card';import { Plus } from 'lucide-react';diff --git a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsx b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsxindex e7e3cbec..cb086756 100644--- a/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsx+++ b/apps/desktop/src/renderer/components/databases/calendars/calendar-view-grid.tsx@@ -1,11 +1,11 @@import React from 'react';import { buttonVariants } from '@/renderer/components/ui/button';-import { cn, getDisplayedDates, toUTCDate } from '@/lib/utils';+import { cn, getDisplayedDates, toUTCDate } from '@/shared/lib/utils';import { DayPicker, DayProps } from 'react-day-picker';import { CalendarViewDay } from '@/renderer/components/databases/calendars/calendar-view-day';import { FieldAttributes, ViewFilterAttributes } from '@colanode/core';import { useRecordsQuery } from '@/renderer/hooks/user-records-query';-import { filterRecords } from '@/lib/databases';+import { filterRecords } from '@/shared/lib/databases';import { useWorkspace } from '@/renderer/contexts/workspace';import { ChevronLeft, ChevronRight } from 'lucide-react';import { useView } from '@/renderer/contexts/view';diff --git a/apps/desktop/src/renderer/components/databases/database-sidiebar-item.tsx b/apps/desktop/src/renderer/components/databases/database-sidiebar-item.tsxindex 9c316096..905c644a 100644--- a/apps/desktop/src/renderer/components/databases/database-sidiebar-item.tsx+++ b/apps/desktop/src/renderer/components/databases/database-sidiebar-item.tsx@@ -1,4 +1,4 @@-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { DatabaseNode } from '@colanode/core';import { Avatar } from '@/renderer/components/avatars/avatar';import { useWorkspace } from '@/renderer/contexts/workspace';diff --git a/apps/desktop/src/renderer/components/databases/fields/field-select.tsx b/apps/desktop/src/renderer/components/databases/fields/field-select.tsxindex 88b34e19..d66f1170 100644--- a/apps/desktop/src/renderer/components/databases/fields/field-select.tsx+++ b/apps/desktop/src/renderer/components/databases/fields/field-select.tsx@@ -14,7 +14,7 @@ import {CommandList,} from '@/renderer/components/ui/command';import { FieldType, FieldAttributes } from '@colanode/core';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { FieldIcon } from './field-icon';import { Check, ChevronDown } from 'lucide-react';diff --git a/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsx b/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsxindex 8c8cadce..431cdb38 100644--- a/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsx+++ b/apps/desktop/src/renderer/components/databases/fields/field-type-select.tsx@@ -14,7 +14,7 @@ import {CommandList,} from '@/renderer/components/ui/command';import { FieldType } from '@colanode/core';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { FieldIcon } from './field-icon';import { Check, ChevronsUpDown } from 'lucide-react';diff --git a/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsx b/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsxindex 26e59fc1..5134a319 100644--- a/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsx+++ b/apps/desktop/src/renderer/components/databases/fields/select-field-options.tsx@@ -12,7 +12,7 @@ import {MultiSelectFieldAttributes,SelectFieldAttributes,} from '@colanode/core';-import { getRandomSelectOptionColor } from '@/lib/databases';+import { getRandomSelectOptionColor } from '@/shared/lib/databases';import { SelectOptionSettingsPopover } from '@/renderer/components/databases/fields/select-option-settings-popover';import { useWorkspace } from '@/renderer/contexts/workspace';import { useMutation } from '@/renderer/hooks/use-mutation';diff --git a/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsx b/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsxindex 8284fcd3..002bb302 100644--- a/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsx+++ b/apps/desktop/src/renderer/components/databases/fields/select-option-badge.tsx@@ -1,5 +1,5 @@-import { cn } from '@/lib/utils';-import { getSelectOptionColorClass } from '@/lib/databases';+import { cn } from '@/shared/lib/utils';+import { getSelectOptionColorClass } from '@/shared/lib/databases';interface SelectOptionBadgeProps {name: string;diff --git a/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsx b/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsxindex 52dfb186..44599e66 100644--- a/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsx+++ b/apps/desktop/src/renderer/components/databases/fields/select-option-settings-popover.tsx@@ -6,8 +6,8 @@ import {PopoverTrigger,} from '@/renderer/components/ui/popover';import { Separator } from '@/renderer/components/ui/separator';-import { selectOptionColors } from '@/lib/databases';-import { cn } from '@/lib/utils';+import { selectOptionColors } from '@/shared/lib/databases';+import { cn } from '@/shared/lib/utils';import { SelectOptionAttributes } from '@colanode/core';import { SelectOptionDeleteDialog } from '@/renderer/components/databases/fields/select-option-delete-dialog';import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';diff --git a/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsxindex bbf164fc..b1bba0f7 100644--- a/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-boolean-field-filter.tsx@@ -14,7 +14,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { booleanFieldFilterOperators } from '@/lib/databases';+import { booleanFieldFilterOperators } from '@/shared/lib/databases';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '../fields/field-icon';import { ChevronDown, Trash2 } from 'lucide-react';diff --git a/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsx b/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsxindex 74edea5b..73e01582 100644--- a/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-created-at-field-fitler.tsx@@ -14,7 +14,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { dateFieldFilterOperators } from '@/lib/databases';+import { dateFieldFilterOperators } from '@/shared/lib/databases';import { DatePicker } from '@/renderer/components/ui/date-picker';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '../fields/field-icon';diff --git a/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsxindex d046cf3a..2663b67f 100644--- a/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-date-field-filter.tsx@@ -11,7 +11,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { dateFieldFilterOperators } from '@/lib/databases';+import { dateFieldFilterOperators } from '@/shared/lib/databases';import { DatePicker } from '@/renderer/components/ui/date-picker';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';diff --git a/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsxindex 19be17d3..48823728 100644--- a/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-email-field-filter.tsx@@ -14,7 +14,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { emailFieldFilterOperators } from '@/lib/databases';+import { emailFieldFilterOperators } from '@/shared/lib/databases';import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';diff --git a/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsxindex 13d7d8c6..61f0034b 100644--- a/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-multi-select-field-filter.tsx@@ -14,7 +14,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { selectFieldFilterOperators } from '@/lib/databases';+import { selectFieldFilterOperators } from '@/shared/lib/databases';import { SelectFieldOptions } from '@/renderer/components/databases/fields/select-field-options';import { SelectOptionBadge } from '@/renderer/components/databases/fields/select-option-badge';import { useView } from '@/renderer/contexts/view';diff --git a/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsxindex 44752723..32515b7a 100644--- a/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-number-field-filter.tsx@@ -17,7 +17,7 @@ import { Button } from '@/renderer/components/ui/button';import { SmartNumberInput } from '@/renderer/components/ui/smart-number-input';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';-import { numberFieldFilterOperators } from '@/lib/databases';+import { numberFieldFilterOperators } from '@/shared/lib/databases';import { ChevronDown, Trash2 } from 'lucide-react';interface ViewNumberFieldFilterProps {diff --git a/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsxindex bc9750f2..758a8b12 100644--- a/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-phone-field-filter.tsx@@ -14,7 +14,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { phoneFieldFilterOperators } from '@/lib/databases';+import { phoneFieldFilterOperators } from '@/shared/lib/databases';import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';diff --git a/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsxindex 21c9b185..57e5c674 100644--- a/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-select-field-filter.tsx@@ -14,7 +14,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { selectFieldFilterOperators } from '@/lib/databases';+import { selectFieldFilterOperators } from '@/shared/lib/databases';import { SelectFieldOptions } from '@/renderer/components/databases/fields/select-field-options';import { SelectOptionBadge } from '@/renderer/components/databases/fields/select-option-badge';import { useView } from '@/renderer/contexts/view';diff --git a/apps/desktop/src/renderer/components/databases/search/view-sort-add-popover.tsx b/apps/desktop/src/renderer/components/databases/search/view-sort-add-popover.tsxindex 0860246d..bb33b04f 100644--- a/apps/desktop/src/renderer/components/databases/search/view-sort-add-popover.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-sort-add-popover.tsx@@ -13,7 +13,7 @@ import {CommandList,} from '@/renderer/components/ui/command';import { useDatabase } from '@/renderer/contexts/database';-import { isSortableField } from '@/lib/databases';+import { isSortableField } from '@/shared/lib/databases';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';diff --git a/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsxindex f0ed0472..d591609d 100644--- a/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-text-field-filter.tsx@@ -11,7 +11,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { textFieldFilterOperators } from '@/lib/databases';+import { textFieldFilterOperators } from '@/shared/lib/databases';import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';diff --git a/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsx b/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsxindex 66997370..1bdeef59 100644--- a/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsx+++ b/apps/desktop/src/renderer/components/databases/search/view-url-field-filter.tsx@@ -11,7 +11,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Button } from '@/renderer/components/ui/button';-import { urlFieldFilterOperators } from '@/lib/databases';+import { urlFieldFilterOperators } from '@/shared/lib/databases';import { SmartTextInput } from '@/renderer/components/ui/smart-text-input';import { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';diff --git a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsxindex a4c2097d..1f003c69 100644--- a/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsx+++ b/apps/desktop/src/renderer/components/databases/tables/cells/table-view-url-cell.tsx@@ -1,5 +1,5 @@import { UrlFieldAttributes } from '@colanode/core';-import { cn, isValidUrl } from '@/lib/utils';+import { cn, isValidUrl } from '@/shared/lib/utils';import {HoverCard,HoverCardContent,diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-field-header.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-field-header.tsxindex 0626c7fb..7eab4f3b 100644--- a/apps/desktop/src/renderer/components/databases/tables/table-view-field-header.tsx+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-field-header.tsx@@ -1,5 +1,5 @@import React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { useDrag, useDrop } from 'react-dnd';import { Resizable } from 're-resizable';import {@@ -13,7 +13,7 @@ import { FieldRenameInput } from '@/renderer/components/databases/fields/field-rimport { useView } from '@/renderer/contexts/view';import { FieldIcon } from '@/renderer/components/databases/fields/field-icon';import { ArrowDownAz, ArrowDownZa, EyeOff, Filter, Trash2 } from 'lucide-react';-import { ViewField } from '@/types/databases';+import { ViewField } from '@/shared/types/databases';import { useDatabase } from '@/renderer/contexts/database';interface TableViewFieldHeaderProps {diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsxindex e4cc9871..c1011b53 100644--- a/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsx+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-name-header.tsx@@ -9,7 +9,7 @@ import { Separator } from '@/renderer/components/ui/separator';import { Input } from '@/renderer/components/ui/input';import { useView } from '@/renderer/contexts/view';import { useDrop } from 'react-dnd';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { ArrowDownAz, ArrowDownZa, Filter, Type } from 'lucide-react';import { useDatabase } from '@/renderer/contexts/database';diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-settings-popover.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-settings-popover.tsxindex 7b5673f5..ac67f71e 100644--- a/apps/desktop/src/renderer/components/databases/tables/table-view-settings-popover.tsx+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-settings-popover.tsx@@ -7,7 +7,7 @@ import {import { useView } from '@/renderer/contexts/view';import { Separator } from '@/renderer/components/ui/separator';import { useDatabase } from '@/renderer/contexts/database';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import {Tooltip,TooltipContent,diff --git a/apps/desktop/src/renderer/components/databases/view-create-dialog.tsx b/apps/desktop/src/renderer/components/databases/view-create-dialog.tsxindex c335ceae..c7caceb8 100644--- a/apps/desktop/src/renderer/components/databases/view-create-dialog.tsx+++ b/apps/desktop/src/renderer/components/databases/view-create-dialog.tsx@@ -21,7 +21,7 @@ import { Button } from '@/renderer/components/ui/button';import { Spinner } from '@/renderer/components/ui/spinner';import { useForm } from 'react-hook-form';import { zodResolver } from '@hookform/resolvers/zod';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { useDatabase } from '@/renderer/contexts/database';import { FieldSelect } from '@/renderer/components/databases/fields/field-select';import { toast } from '@/renderer/hooks/use-toast';diff --git a/apps/desktop/src/renderer/components/databases/view-tab.tsx b/apps/desktop/src/renderer/components/databases/view-tab.tsxindex 5d4ee643..9f9701cc 100644--- a/apps/desktop/src/renderer/components/databases/view-tab.tsx+++ b/apps/desktop/src/renderer/components/databases/view-tab.tsx@@ -1,4 +1,4 @@-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Avatar } from '@/renderer/components/avatars/avatar';import { ViewAttributes } from '@colanode/core';diff --git a/apps/desktop/src/renderer/components/databases/view.tsx b/apps/desktop/src/renderer/components/databases/view.tsxindex f5b02a06..82aaf28c 100644--- a/apps/desktop/src/renderer/components/databases/view.tsx+++ b/apps/desktop/src/renderer/components/databases/view.tsx@@ -12,14 +12,14 @@ import { CalendarView } from '@/renderer/components/databases/calendars/calendarimport { ViewContext } from '@/renderer/contexts/view';import { useDatabase } from '@/renderer/contexts/database';import { useWorkspace } from '@/renderer/contexts/workspace';-import { compareString } from '@/lib/utils';+import { compareString } from '@/shared/lib/utils';import {generateViewFieldIndex,getDefaultFieldWidth,getDefaultNameWidth,getFieldFilterOperators,-} from '@/lib/databases';-import { ViewField } from '@/types/databases';+} from '@/shared/lib/databases';+import { ViewField } from '@/shared/types/databases';import { useMutation } from '@/renderer/hooks/use-mutation';interface ViewProps {diff --git a/apps/desktop/src/renderer/components/documents/document.tsx b/apps/desktop/src/renderer/components/documents/document.tsxindex 153158d2..93751c26 100644--- a/apps/desktop/src/renderer/components/documents/document.tsx+++ b/apps/desktop/src/renderer/components/documents/document.tsx@@ -1,6 +1,6 @@import { Block } from '@colanode/core';import { DocumentEditor } from '@/renderer/components/documents/document-editor';-import { mapBlocksToContents } from '@/lib/editor';+import { mapBlocksToContents } from '@/shared/lib/editor';interface DocumentProps {nodeId: string;diff --git a/apps/desktop/src/renderer/components/emojis/emoji-element.tsx b/apps/desktop/src/renderer/components/emojis/emoji-element.tsxindex 058d18fd..1c5abf47 100644--- a/apps/desktop/src/renderer/components/emojis/emoji-element.tsx+++ b/apps/desktop/src/renderer/components/emojis/emoji-element.tsx@@ -1,6 +1,6 @@import * as React from 'react';-import { getEmojiUrl } from '@/lib/emojis';+import { getEmojiUrl } from '@/shared/lib/emojis';interface Props extends React.ImgHTMLAttributes<HTMLImageElement> {id: string;diff --git a/apps/desktop/src/renderer/components/emojis/emoji-picker-browser-row.tsx b/apps/desktop/src/renderer/components/emojis/emoji-picker-browser-row.tsxindex 4481fedf..1fdfd307 100644--- a/apps/desktop/src/renderer/components/emojis/emoji-picker-browser-row.tsx+++ b/apps/desktop/src/renderer/components/emojis/emoji-picker-browser-row.tsx@@ -1,5 +1,5 @@import React from 'react';-import { EmojiPickerRowData } from '@/types/emojis';+import { EmojiPickerRowData } from '@/shared/types/emojis';import { EmojiPickerItem } from '@/renderer/components/emojis/emoji-picker-item';interface EmojiPickerBrowserRowProps {diff --git a/apps/desktop/src/renderer/components/emojis/emoji-picker-browser.tsx b/apps/desktop/src/renderer/components/emojis/emoji-picker-browser.tsxindex 7c0a1899..a5bdecf3 100644--- a/apps/desktop/src/renderer/components/emojis/emoji-picker-browser.tsx+++ b/apps/desktop/src/renderer/components/emojis/emoji-picker-browser.tsx@@ -1,4 +1,4 @@-import { EmojiPickerRowData } from '@/types/emojis';+import { EmojiPickerRowData } from '@/shared/types/emojis';import React from 'react';import AutoSizer from 'react-virtualized-auto-sizer';import { FixedSizeList } from 'react-window';diff --git a/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsx b/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsxindex 51063c72..d16ae050 100644--- a/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsx+++ b/apps/desktop/src/renderer/components/emojis/emoji-picker-item.tsx@@ -1,4 +1,4 @@-import { Emoji } from '@/types/emojis';+import { Emoji } from '@/shared/types/emojis';import { EmojiElement } from '@/renderer/components/emojis/emoji-element';import { useEmojiPicker } from '@/renderer/contexts/emoji-picker';diff --git a/apps/desktop/src/renderer/components/emojis/emoji-picker-search.tsx b/apps/desktop/src/renderer/components/emojis/emoji-picker-search.tsxindex 47c1f402..c816c165 100644--- a/apps/desktop/src/renderer/components/emojis/emoji-picker-search.tsx+++ b/apps/desktop/src/renderer/components/emojis/emoji-picker-search.tsx@@ -1,5 +1,5 @@import React from 'react';-import { searchEmojis } from '@/lib/emojis';+import { searchEmojis } from '@/shared/lib/emojis';import { EmojiPickerItem } from '@/renderer/components/emojis/emoji-picker-item';import { useEmojiPicker } from '@/renderer/contexts/emoji-picker';diff --git a/apps/desktop/src/renderer/components/emojis/emoji-picker.tsx b/apps/desktop/src/renderer/components/emojis/emoji-picker.tsxindex 649bc9c7..a3463089 100644--- a/apps/desktop/src/renderer/components/emojis/emoji-picker.tsx+++ b/apps/desktop/src/renderer/components/emojis/emoji-picker.tsx@@ -1,6 +1,6 @@import React from 'react';import { EmojiSkinToneSelector } from '@/renderer/components/emojis/emoji-skin-tone-selector';-import { Emoji } from '@/types/emojis';+import { Emoji } from '@/shared/types/emojis';import { EmojiPickerContext } from '@/renderer/contexts/emoji-picker';import { EmojiPickerBrowser } from '@/renderer/components/emojis/emoji-picker-browser';import { EmojiPickerSearch } from '@/renderer/components/emojis/emoji-picker-search';diff --git a/apps/desktop/src/renderer/components/emojis/emoji-skin-tone-selector.tsx b/apps/desktop/src/renderer/components/emojis/emoji-skin-tone-selector.tsxindex 942413fd..7832fb12 100644--- a/apps/desktop/src/renderer/components/emojis/emoji-skin-tone-selector.tsx+++ b/apps/desktop/src/renderer/components/emojis/emoji-skin-tone-selector.tsx@@ -1,5 +1,5 @@import React from 'react';-import { getEmojiUrl } from '@/lib/emojis';+import { getEmojiUrl } from '@/shared/lib/emojis';import { EmojiElement } from '@/renderer/components/emojis/emoji-element';import {Popover,diff --git a/apps/desktop/src/renderer/components/files/file-block.tsx b/apps/desktop/src/renderer/components/files/file-block.tsxindex a1a8452c..cd464ed9 100644--- a/apps/desktop/src/renderer/components/files/file-block.tsx+++ b/apps/desktop/src/renderer/components/files/file-block.tsx@@ -1,4 +1,4 @@-import { getFileUrl } from '@/lib/files';+import { getFileUrl } from '@/shared/lib/files';import { useWorkspace } from '@/renderer/contexts/workspace';import { useQuery } from '@/renderer/hooks/use-query';import { FilePreview } from '@/renderer/components/files/file-preview';diff --git a/apps/desktop/src/renderer/components/files/file-body.tsx b/apps/desktop/src/renderer/components/files/file-body.tsxindex 9deff5b7..eda9fa54 100644--- a/apps/desktop/src/renderer/components/files/file-body.tsx+++ b/apps/desktop/src/renderer/components/files/file-body.tsx@@ -5,7 +5,7 @@ import { SquareArrowOutUpRight } from 'lucide-react';import { FileDownload } from '@/renderer/components/files/file-download';import { FilePreview } from '@/renderer/components/files/file-preview';import { FileSidebar } from '@/renderer/components/files/file-sidebar';-import { getFileUrl } from '@/lib/files';+import { getFileUrl } from '@/shared/lib/files';interface FileBodyProps {file: FileNode;diff --git a/apps/desktop/src/renderer/components/files/file-preview.tsx b/apps/desktop/src/renderer/components/files/file-preview.tsxindex 0ef29f4b..181bdce9 100644--- a/apps/desktop/src/renderer/components/files/file-preview.tsx+++ b/apps/desktop/src/renderer/components/files/file-preview.tsx@@ -1,5 +1,5 @@import { match } from 'ts-pattern';-import { getFilePreviewType } from '@/lib/files';+import { getFilePreviewType } from '@/shared/lib/files';import { FilePreviewImage } from '@/renderer/components/files/previews/file-preview-image';import { FilePreviewVideo } from '@/renderer/components/files/previews/file-preview-video';import { FilePreviewOther } from '@/renderer/components/files/previews/file-preview-other';diff --git a/apps/desktop/src/renderer/components/files/file-sidebar.tsx b/apps/desktop/src/renderer/components/files/file-sidebar.tsxindex d8839118..dace3e42 100644--- a/apps/desktop/src/renderer/components/files/file-sidebar.tsx+++ b/apps/desktop/src/renderer/components/files/file-sidebar.tsx@@ -1,6 +1,6 @@import React from 'react';-import { formatBytes } from '@/lib/files';-import { formatDate } from '@/lib/utils';+import { formatBytes } from '@/shared/lib/files';+import { formatDate } from '@/shared/lib/utils';import { FileThumbnail } from '@/renderer/components/files/file-thumbnail';import { Avatar } from '@/renderer/components/avatars/avatar';import { FileNode } from '@colanode/core';diff --git a/apps/desktop/src/renderer/components/files/file-thumbnail.tsx b/apps/desktop/src/renderer/components/files/file-thumbnail.tsxindex b4cffc81..4949a4c2 100644--- a/apps/desktop/src/renderer/components/files/file-thumbnail.tsx+++ b/apps/desktop/src/renderer/components/files/file-thumbnail.tsx@@ -1,6 +1,6 @@-import { getFileUrl } from '@/lib/files';+import { getFileUrl } from '@/shared/lib/files';import { useWorkspace } from '@/renderer/contexts/workspace';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { FileIcon } from '@/renderer/components/files/file-icon';interface FileThumbnailProps {diff --git a/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsx b/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsxindex 152ad75e..68824e1e 100644--- a/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsx+++ b/apps/desktop/src/renderer/components/files/previews/file-preview-other.tsx@@ -1,4 +1,4 @@-import { getFriendlyNameFromMimeType } from '@/lib/files';+import { getFriendlyNameFromMimeType } from '@/shared/lib/files';import { FileIcon } from '@/renderer/components/files/file-icon';interface FilePreviewOtherProps {diff --git a/apps/desktop/src/renderer/components/folders/folder-body.tsx b/apps/desktop/src/renderer/components/folders/folder-body.tsxindex d9b4a826..c3b32e74 100644--- a/apps/desktop/src/renderer/components/folders/folder-body.tsx+++ b/apps/desktop/src/renderer/components/folders/folder-body.tsx@@ -10,7 +10,7 @@ import {DropdownMenuSeparator,DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';-import { FolderLayoutType } from '@/types/folders';+import { FolderLayoutType } from '@/shared/types/folders';import { ScrollArea } from '@/renderer/components/ui/scroll-area';import { useMutation } from '@/renderer/hooks/use-mutation';import { useWorkspace } from '@/renderer/contexts/workspace';diff --git a/apps/desktop/src/renderer/components/folders/folder-files.tsx b/apps/desktop/src/renderer/components/folders/folder-files.tsxindex cee8cac6..53e996ef 100644--- a/apps/desktop/src/renderer/components/folders/folder-files.tsx+++ b/apps/desktop/src/renderer/components/folders/folder-files.tsx@@ -1,14 +1,14 @@import React from 'react';import { match } from 'ts-pattern';import { FolderContext } from '@/renderer/contexts/folder';-import { FolderLayoutType } from '@/types/folders';+import { FolderLayoutType } from '@/shared/types/folders';import { useWorkspace } from '@/renderer/contexts/workspace';import { useQueries } from '@/renderer/hooks/use-queries';import { GridLayout } from '@/renderer/components/folders/grids/grid-layout';import { ListLayout } from '@/renderer/components/folders/lists/list-layout';import { GalleryLayout } from '@/renderer/components/folders/galleries/gallery-layout';import { getIdType, IdType } from '@colanode/core';-import { FileListQueryInput } from '@/operations/queries/file-list';+import { FileListQueryInput } from '@/shared/queries/file-list';const FILES_PER_PAGE = 100;diff --git a/apps/desktop/src/renderer/components/folders/folder-sidebar-item.tsx b/apps/desktop/src/renderer/components/folders/folder-sidebar-item.tsxindex 9e0abc2c..0b8ec7a5 100644--- a/apps/desktop/src/renderer/components/folders/folder-sidebar-item.tsx+++ b/apps/desktop/src/renderer/components/folders/folder-sidebar-item.tsx@@ -1,4 +1,4 @@-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { FolderNode } from '@colanode/core';import { Avatar } from '@/renderer/components/avatars/avatar';import { useWorkspace } from '@/renderer/contexts/workspace';diff --git a/apps/desktop/src/renderer/components/folders/grids/grid-file.tsx b/apps/desktop/src/renderer/components/folders/grids/grid-file.tsxindex 8a65d0b7..568ecdc2 100644--- a/apps/desktop/src/renderer/components/folders/grids/grid-file.tsx+++ b/apps/desktop/src/renderer/components/folders/grids/grid-file.tsx@@ -1,4 +1,4 @@-import { FileNode } from '@/types/files';+import { FileNode } from '@/shared/types/files';import { FileThumbnail } from '@/renderer/components/files/file-thumbnail';import { FileContextMenu } from '@/renderer/components/files/file-context-menu';import { GridItem } from './grid-item';diff --git a/apps/desktop/src/renderer/components/folders/grids/grid-item.tsx b/apps/desktop/src/renderer/components/folders/grids/grid-item.tsxindex c92a1e2c..edb013ca 100644--- a/apps/desktop/src/renderer/components/folders/grids/grid-item.tsx+++ b/apps/desktop/src/renderer/components/folders/grids/grid-item.tsx@@ -1,5 +1,5 @@import React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { useFolder } from '@/renderer/contexts/folder';interface GridItemProps {diff --git a/apps/desktop/src/renderer/components/icons/icon-element.tsx b/apps/desktop/src/renderer/components/icons/icon-element.tsxindex b39b9f24..ab5e2ff0 100644--- a/apps/desktop/src/renderer/components/icons/icon-element.tsx+++ b/apps/desktop/src/renderer/components/icons/icon-element.tsx@@ -1,6 +1,6 @@import * as React from 'react';-import { getIconUrl } from '@/lib/icons';+import { getIconUrl } from '@/shared/lib/icons';interface Props extends React.ImgHTMLAttributes<HTMLImageElement> {id: string;diff --git a/apps/desktop/src/renderer/components/icons/icon-picker-browser-row.tsx b/apps/desktop/src/renderer/components/icons/icon-picker-browser-row.tsxindex 9e167241..db31d5f3 100644--- a/apps/desktop/src/renderer/components/icons/icon-picker-browser-row.tsx+++ b/apps/desktop/src/renderer/components/icons/icon-picker-browser-row.tsx@@ -1,5 +1,5 @@import React from 'react';-import { IconPickerRowData } from '@/types/icons';+import { IconPickerRowData } from '@/shared/types/icons';import { IconPickerItem } from '@/renderer/components/icons/icon-picker-item';interface IconPickerBrowserRowProps {diff --git a/apps/desktop/src/renderer/components/icons/icon-picker-browser.tsx b/apps/desktop/src/renderer/components/icons/icon-picker-browser.tsxindex 2693f720..128f0b4c 100644--- a/apps/desktop/src/renderer/components/icons/icon-picker-browser.tsx+++ b/apps/desktop/src/renderer/components/icons/icon-picker-browser.tsx@@ -1,7 +1,7 @@import React from 'react';import AutoSizer from 'react-virtualized-auto-sizer';import { FixedSizeList } from 'react-window';-import { IconPickerRowData } from '@/types/icons';+import { IconPickerRowData } from '@/shared/types/icons';import { IconPickerBrowserRow } from '@/renderer/components/icons/icon-picker-browser-row';import { useIconPicker } from '@/renderer/contexts/icon-picker';diff --git a/apps/desktop/src/renderer/components/icons/icon-picker-item.tsx b/apps/desktop/src/renderer/components/icons/icon-picker-item.tsxindex a91532ee..ebd6088e 100644--- a/apps/desktop/src/renderer/components/icons/icon-picker-item.tsx+++ b/apps/desktop/src/renderer/components/icons/icon-picker-item.tsx@@ -1,4 +1,4 @@-import { Icon } from '@/types/icons';+import { Icon } from '@/shared/types/icons';import { useIconPicker } from '@/renderer/contexts/icon-picker';import { IconElement } from '@/renderer/components/icons/icon-element';diff --git a/apps/desktop/src/renderer/components/icons/icon-picker-search.tsx b/apps/desktop/src/renderer/components/icons/icon-picker-search.tsxindex 2465fe64..b1522489 100644--- a/apps/desktop/src/renderer/components/icons/icon-picker-search.tsx+++ b/apps/desktop/src/renderer/components/icons/icon-picker-search.tsx@@ -1,6 +1,6 @@import React from 'react';import { IconPickerItem } from '@/renderer/components/icons/icon-picker-item';-import { searchIcons } from '@/lib/icons';+import { searchIcons } from '@/shared/lib/icons';import { useIconPicker } from '@/renderer/contexts/icon-picker';interface IconPickerSearchProps {diff --git a/apps/desktop/src/renderer/components/icons/icon-picker.tsx b/apps/desktop/src/renderer/components/icons/icon-picker.tsxindex 9577e64d..ae87dbe9 100644--- a/apps/desktop/src/renderer/components/icons/icon-picker.tsx+++ b/apps/desktop/src/renderer/components/icons/icon-picker.tsx@@ -1,5 +1,5 @@import React from 'react';-import { Icon } from '@/types/icons';+import { Icon } from '@/shared/types/icons';import { IconPickerContext } from '@/renderer/contexts/icon-picker';import { IconPickerSearch } from '@/renderer/components/icons/icon-picker-search';import { IconPickerBrowser } from '@/renderer/components/icons/icon-picker-browser';diff --git a/apps/desktop/src/renderer/components/messages/message-create.tsx b/apps/desktop/src/renderer/components/messages/message-create.tsxindex 104a0a18..65ff085f 100644--- a/apps/desktop/src/renderer/components/messages/message-create.tsx+++ b/apps/desktop/src/renderer/components/messages/message-create.tsx@@ -5,8 +5,8 @@ import {} from '@/renderer/components/messages/message-editor';import { useMutation } from '@/renderer/hooks/use-mutation';import { useWorkspace } from '@/renderer/contexts/workspace';-import { MessageNode } from '@/types/messages';-import { editorHasContent } from '@/lib/editor';+import { MessageNode } from '@/shared/types/messages';+import { editorHasContent } from '@/shared/lib/editor';import { useConversation } from '@/renderer/contexts/conversation';import { MessageReplyBanner } from '@/renderer/components/messages/message-reply-banner';import { JSONContent } from '@tiptap/core';diff --git a/apps/desktop/src/renderer/components/messages/message-editor.tsx b/apps/desktop/src/renderer/components/messages/message-editor.tsxindex b9514377..b4d01dbb 100644--- a/apps/desktop/src/renderer/components/messages/message-editor.tsx+++ b/apps/desktop/src/renderer/components/messages/message-editor.tsx@@ -25,7 +25,7 @@ import {FileNode,} from '@/renderer/editor/extensions';import { EditorBubbleMenu } from '@/renderer/editor/menu/bubble-menu';-import { FileMetadata } from '@/types/files';+import { FileMetadata } from '@/shared/types/files';interface MessageEditorProps {conversationId: string;diff --git a/apps/desktop/src/renderer/components/messages/message-list.tsx b/apps/desktop/src/renderer/components/messages/message-list.tsxindex 7ca99032..9c0f117c 100644--- a/apps/desktop/src/renderer/components/messages/message-list.tsx+++ b/apps/desktop/src/renderer/components/messages/message-list.tsx@@ -2,9 +2,9 @@ import React from 'react';import { InView } from 'react-intersection-observer';import { Message } from '@/renderer/components/messages/message';import { useWorkspace } from '@/renderer/contexts/workspace';-import { compareString } from '@/lib/utils';+import { compareString } from '@/shared/lib/utils';import { useQueries } from '@/renderer/hooks/use-queries';-import { MessageListQueryInput } from '@/operations/queries/message-list';+import { MessageListQueryInput } from '@/shared/queries/message-list';import { useConversation } from '@/renderer/contexts/conversation';const MESSAGES_PER_PAGE = 50;diff --git a/apps/desktop/src/renderer/components/messages/message-reactions.tsx b/apps/desktop/src/renderer/components/messages/message-reactions.tsxindex 49b8438e..6cf52301 100644--- a/apps/desktop/src/renderer/components/messages/message-reactions.tsx+++ b/apps/desktop/src/renderer/components/messages/message-reactions.tsx@@ -1,6 +1,6 @@-import { MessageNode } from '@/types/messages';+import { MessageNode } from '@/shared/types/messages';import { EmojiElement } from '@/renderer/components/emojis/emoji-element';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';interface MessageReactionsProps {message: MessageNode;diff --git a/apps/desktop/src/renderer/components/messages/message-reply-banner.tsx b/apps/desktop/src/renderer/components/messages/message-reply-banner.tsxindex 06a1d607..cf60b764 100644--- a/apps/desktop/src/renderer/components/messages/message-reply-banner.tsx+++ b/apps/desktop/src/renderer/components/messages/message-reply-banner.tsx@@ -1,4 +1,4 @@-import { MessageNode } from '@/types/messages';+import { MessageNode } from '@/shared/types/messages';import { CircleX } from 'lucide-react';interface MessageReplyBannerProps {diff --git a/apps/desktop/src/renderer/components/messages/message.tsx b/apps/desktop/src/renderer/components/messages/message.tsxindex 5a3c7f86..9fc11182 100644--- a/apps/desktop/src/renderer/components/messages/message.tsx+++ b/apps/desktop/src/renderer/components/messages/message.tsx@@ -4,12 +4,12 @@ import {TooltipContent,TooltipTrigger,} from '@/renderer/components/ui/tooltip';-import { formatDate, timeAgo } from '@/lib/utils';+import { formatDate, timeAgo } from '@/shared/lib/utils';import { InView } from 'react-intersection-observer';import { MessageReactionCreatePopover } from '@/renderer/components/messages/message-reaction-create-popover';import { MessageDeleteButton } from '@/renderer/components/messages/message-delete-button';import { NodeRenderer } from '@/renderer/editor/renderers/node';-import { MessageNode } from '@/types/messages';+import { MessageNode } from '@/shared/types/messages';import { MessageReactions } from '@/renderer/components/messages/message-reactions';import { useMutation } from '@/renderer/hooks/use-mutation';import { useWorkspace } from '@/renderer/contexts/workspace';diff --git a/apps/desktop/src/renderer/components/pages/page-sidebar-item.tsx b/apps/desktop/src/renderer/components/pages/page-sidebar-item.tsxindex 61671141..3d8f9533 100644--- a/apps/desktop/src/renderer/components/pages/page-sidebar-item.tsx+++ b/apps/desktop/src/renderer/components/pages/page-sidebar-item.tsx@@ -1,4 +1,4 @@-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { PageNode } from '@colanode/core';import { Avatar } from '@/renderer/components/avatars/avatar';import { useWorkspace } from '@/renderer/contexts/workspace';diff --git a/apps/desktop/src/renderer/components/records/values/record-url-value.tsx b/apps/desktop/src/renderer/components/records/values/record-url-value.tsxindex dde5bb74..65cecabd 100644--- a/apps/desktop/src/renderer/components/records/values/record-url-value.tsx+++ b/apps/desktop/src/renderer/components/records/values/record-url-value.tsx@@ -1,5 +1,5 @@import { UrlFieldAttributes } from '@colanode/core';-import { cn, isValidUrl } from '@/lib/utils';+import { cn, isValidUrl } from '@/shared/lib/utils';import {HoverCard,HoverCardContent,diff --git a/apps/desktop/src/renderer/components/servers/server-dropdown.tsx b/apps/desktop/src/renderer/components/servers/server-dropdown.tsxindex ad395b29..c6a757a9 100644--- a/apps/desktop/src/renderer/components/servers/server-dropdown.tsx+++ b/apps/desktop/src/renderer/components/servers/server-dropdown.tsx@@ -6,7 +6,7 @@ import {DropdownMenuTrigger,} from '@/renderer/components/ui/dropdown-menu';import { Avatar } from '@/renderer/components/avatars/avatar';-import { Server } from '@/types/servers';+import { Server } from '@/shared/types/servers';import { ServerCreateDialog } from '@/renderer/components/servers/server-create-dialog';import { DropdownMenuSeparator } from '@radix-ui/react-dropdown-menu';import { ChevronDown } from 'lucide-react';diff --git a/apps/desktop/src/renderer/components/ui/alert-dialog.tsx b/apps/desktop/src/renderer/components/ui/alert-dialog.tsxindex 3d6b2fb1..ce0b7e7a 100644--- a/apps/desktop/src/renderer/components/ui/alert-dialog.tsx+++ b/apps/desktop/src/renderer/components/ui/alert-dialog.tsx@@ -1,7 +1,7 @@import * as React from 'react';import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { buttonVariants } from '@/renderer/components/ui/button';const AlertDialog = AlertDialogPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/badge.tsx b/apps/desktop/src/renderer/components/ui/badge.tsxindex 9c6c4d9b..1471bf15 100644--- a/apps/desktop/src/renderer/components/ui/badge.tsx+++ b/apps/desktop/src/renderer/components/ui/badge.tsx@@ -1,7 +1,7 @@import * as React from 'react';import { cva, type VariantProps } from 'class-variance-authority';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const badgeVariants = cva('inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',diff --git a/apps/desktop/src/renderer/components/ui/breadcrumb.tsx b/apps/desktop/src/renderer/components/ui/breadcrumb.tsxindex 9658ec7f..1e40445f 100644--- a/apps/desktop/src/renderer/components/ui/breadcrumb.tsx+++ b/apps/desktop/src/renderer/components/ui/breadcrumb.tsx@@ -2,7 +2,7 @@ import * as React from 'react';import { ChevronRightIcon, DotsHorizontalIcon } from '@radix-ui/react-icons';import { Slot } from '@radix-ui/react-slot';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Breadcrumb = React.forwardRef<HTMLElement,diff --git a/apps/desktop/src/renderer/components/ui/button.tsx b/apps/desktop/src/renderer/components/ui/button.tsxindex 626ffde4..e44fa78b 100644--- a/apps/desktop/src/renderer/components/ui/button.tsx+++ b/apps/desktop/src/renderer/components/ui/button.tsx@@ -2,7 +2,7 @@ import * as React from 'react';import { Slot } from '@radix-ui/react-slot';import { cva, type VariantProps } from 'class-variance-authority';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const buttonVariants = cva('inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:ring-0 disabled:pointer-events-none disabled:opacity-50',diff --git a/apps/desktop/src/renderer/components/ui/calendar.tsx b/apps/desktop/src/renderer/components/ui/calendar.tsxindex 1f0dacd1..7dc0d312 100644--- a/apps/desktop/src/renderer/components/ui/calendar.tsx+++ b/apps/desktop/src/renderer/components/ui/calendar.tsx@@ -2,7 +2,7 @@ import * as React from 'react';import { ChevronLeftIcon, ChevronRightIcon } from '@radix-ui/react-icons';import { DayPicker } from 'react-day-picker';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { buttonVariants } from '@/renderer/components/ui/button';export type CalendarProps = React.ComponentProps<typeof DayPicker>;diff --git a/apps/desktop/src/renderer/components/ui/checkbox.tsx b/apps/desktop/src/renderer/components/ui/checkbox.tsxindex e599a50e..5123e36f 100644--- a/apps/desktop/src/renderer/components/ui/checkbox.tsx+++ b/apps/desktop/src/renderer/components/ui/checkbox.tsx@@ -2,7 +2,7 @@ import * as React from 'react';import * as CheckboxPrimitive from '@radix-ui/react-checkbox';import { CheckIcon } from '@radix-ui/react-icons';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Checkbox = React.forwardRef<React.ElementRef<typeof CheckboxPrimitive.Root>,diff --git a/apps/desktop/src/renderer/components/ui/command.tsx b/apps/desktop/src/renderer/components/ui/command.tsxindex 5c70140b..a8b033cb 100644--- a/apps/desktop/src/renderer/components/ui/command.tsx+++ b/apps/desktop/src/renderer/components/ui/command.tsx@@ -3,7 +3,7 @@ import { type DialogProps } from '@radix-ui/react-dialog';import { MagnifyingGlassIcon } from '@radix-ui/react-icons';import { Command as CommandPrimitive } from 'cmdk';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Dialog, DialogContent } from '@/renderer/components/ui/dialog';const Command = React.forwardRef<diff --git a/apps/desktop/src/renderer/components/ui/context-menu.tsx b/apps/desktop/src/renderer/components/ui/context-menu.tsxindex 08787eca..d6b8c229 100644--- a/apps/desktop/src/renderer/components/ui/context-menu.tsx+++ b/apps/desktop/src/renderer/components/ui/context-menu.tsx@@ -6,7 +6,7 @@ import {DotFilledIcon,} from '@radix-ui/react-icons';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const ContextMenu = ContextMenuPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/date-picker.tsx b/apps/desktop/src/renderer/components/ui/date-picker.tsxindex bd581e32..1304beed 100644--- a/apps/desktop/src/renderer/components/ui/date-picker.tsx+++ b/apps/desktop/src/renderer/components/ui/date-picker.tsx@@ -5,7 +5,7 @@ import {PopoverContent,PopoverTrigger,} from '@/renderer/components/ui/popover';-import { cn, toUTCDate } from '@/lib/utils';+import { cn, toUTCDate } from '@/shared/lib/utils';interface DatePickerProps {value: Date | null;diff --git a/apps/desktop/src/renderer/components/ui/dialog.tsx b/apps/desktop/src/renderer/components/ui/dialog.tsxindex c871af56..e7ce8c23 100644--- a/apps/desktop/src/renderer/components/ui/dialog.tsx+++ b/apps/desktop/src/renderer/components/ui/dialog.tsx@@ -2,7 +2,7 @@ import * as React from 'react';import * as DialogPrimitive from '@radix-ui/react-dialog';import { Cross2Icon } from '@radix-ui/react-icons';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Dialog = DialogPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/dropdown-menu.tsx b/apps/desktop/src/renderer/components/ui/dropdown-menu.tsxindex 2bcca0e1..3f2a4e23 100644--- a/apps/desktop/src/renderer/components/ui/dropdown-menu.tsx+++ b/apps/desktop/src/renderer/components/ui/dropdown-menu.tsx@@ -6,7 +6,7 @@ import {DotFilledIcon,} from '@radix-ui/react-icons';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const DropdownMenu = DropdownMenuPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/form.tsx b/apps/desktop/src/renderer/components/ui/form.tsxindex be40da74..315784bc 100644--- a/apps/desktop/src/renderer/components/ui/form.tsx+++ b/apps/desktop/src/renderer/components/ui/form.tsx@@ -10,7 +10,7 @@ import {useFormContext,} from 'react-hook-form';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Label } from '@/renderer/components/ui/label';const Form = FormProvider;diff --git a/apps/desktop/src/renderer/components/ui/header.tsx b/apps/desktop/src/renderer/components/ui/header.tsxindex f34a959f..1e032c29 100644--- a/apps/desktop/src/renderer/components/ui/header.tsx+++ b/apps/desktop/src/renderer/components/ui/header.tsx@@ -1,5 +1,5 @@import * as React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Header = React.forwardRef<HTMLHeadingElement,diff --git a/apps/desktop/src/renderer/components/ui/hover-card.tsx b/apps/desktop/src/renderer/components/ui/hover-card.tsxindex 7b527522..6d093f12 100644--- a/apps/desktop/src/renderer/components/ui/hover-card.tsx+++ b/apps/desktop/src/renderer/components/ui/hover-card.tsx@@ -1,7 +1,7 @@import * as React from 'react';import * as HoverCardPrimitive from '@radix-ui/react-hover-card';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const HoverCard = HoverCardPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/input.tsx b/apps/desktop/src/renderer/components/ui/input.tsxindex 7c4a6915..5835e0e0 100644--- a/apps/desktop/src/renderer/components/ui/input.tsx+++ b/apps/desktop/src/renderer/components/ui/input.tsx@@ -1,6 +1,6 @@import * as React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';export interface InputPropsextends React.InputHTMLAttributes<HTMLInputElement> {}diff --git a/apps/desktop/src/renderer/components/ui/label.tsx b/apps/desktop/src/renderer/components/ui/label.tsxindex fba3aeb2..a472b78e 100644--- a/apps/desktop/src/renderer/components/ui/label.tsx+++ b/apps/desktop/src/renderer/components/ui/label.tsx@@ -2,7 +2,7 @@ import * as React from 'react';import * as LabelPrimitive from '@radix-ui/react-label';import { cva, type VariantProps } from 'class-variance-authority';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const labelVariants = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'diff --git a/apps/desktop/src/renderer/components/ui/popover.tsx b/apps/desktop/src/renderer/components/ui/popover.tsxindex 07b74e1a..8dae36c9 100644--- a/apps/desktop/src/renderer/components/ui/popover.tsx+++ b/apps/desktop/src/renderer/components/ui/popover.tsx@@ -1,7 +1,7 @@import * as React from 'react';import * as PopoverPrimitive from '@radix-ui/react-popover';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Popover = PopoverPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/scroll-area.tsx b/apps/desktop/src/renderer/components/ui/scroll-area.tsxindex 6b9cf489..22360f10 100644--- a/apps/desktop/src/renderer/components/ui/scroll-area.tsx+++ b/apps/desktop/src/renderer/components/ui/scroll-area.tsx@@ -1,7 +1,7 @@import * as React from 'react';import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const ScrollArea = React.forwardRef<React.ElementRef<typeof ScrollAreaPrimitive.Root>,diff --git a/apps/desktop/src/renderer/components/ui/separator.tsx b/apps/desktop/src/renderer/components/ui/separator.tsxindex aca42e91..acc64da5 100644--- a/apps/desktop/src/renderer/components/ui/separator.tsx+++ b/apps/desktop/src/renderer/components/ui/separator.tsx@@ -1,7 +1,7 @@import * as React from 'react';import * as SeparatorPrimitive from '@radix-ui/react-separator';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Separator = React.forwardRef<React.ElementRef<typeof SeparatorPrimitive.Root>,diff --git a/apps/desktop/src/renderer/components/ui/sheet.tsx b/apps/desktop/src/renderer/components/ui/sheet.tsxindex 3e813d10..5cf93e84 100644--- a/apps/desktop/src/renderer/components/ui/sheet.tsx+++ b/apps/desktop/src/renderer/components/ui/sheet.tsx@@ -3,7 +3,7 @@ import * as SheetPrimitive from '@radix-ui/react-dialog';import { Cross2Icon } from '@radix-ui/react-icons';import { cva, type VariantProps } from 'class-variance-authority';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Sheet = SheetPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/sidebar.tsx b/apps/desktop/src/renderer/components/ui/sidebar.tsxindex e36222ac..9fa59038 100644--- a/apps/desktop/src/renderer/components/ui/sidebar.tsx+++ b/apps/desktop/src/renderer/components/ui/sidebar.tsx@@ -5,7 +5,7 @@ import { Slot } from '@radix-ui/react-slot';import { VariantProps, cva } from 'class-variance-authority';import { useIsMobile } from '@/renderer/hooks/use-mobile';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Button } from '@/renderer/components/ui/button';import { Input } from '@/renderer/components/ui/input';import { Separator } from '@/renderer/components/ui/separator';diff --git a/apps/desktop/src/renderer/components/ui/skeleton.tsx b/apps/desktop/src/renderer/components/ui/skeleton.tsxindex 77ea9efc..2aef1faa 100644--- a/apps/desktop/src/renderer/components/ui/skeleton.tsx+++ b/apps/desktop/src/renderer/components/ui/skeleton.tsx@@ -1,6 +1,6 @@import * as React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';function Skeleton({className,diff --git a/apps/desktop/src/renderer/components/ui/smart-number-input.tsx b/apps/desktop/src/renderer/components/ui/smart-number-input.tsxindex 316897a7..2fff0959 100644--- a/apps/desktop/src/renderer/components/ui/smart-number-input.tsx+++ b/apps/desktop/src/renderer/components/ui/smart-number-input.tsx@@ -1,5 +1,5 @@import * as React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import debounce from 'lodash/debounce';interface SmartNumberInputProps {diff --git a/apps/desktop/src/renderer/components/ui/smart-text-input.tsx b/apps/desktop/src/renderer/components/ui/smart-text-input.tsxindex 2531d4a7..b091dc32 100644--- a/apps/desktop/src/renderer/components/ui/smart-text-input.tsx+++ b/apps/desktop/src/renderer/components/ui/smart-text-input.tsx@@ -1,5 +1,5 @@import * as React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import debounce from 'lodash/debounce';interface SmartTextInputProps {diff --git a/apps/desktop/src/renderer/components/ui/spinner.tsx b/apps/desktop/src/renderer/components/ui/spinner.tsxindex 0d35f7c1..e3d3fad6 100644--- a/apps/desktop/src/renderer/components/ui/spinner.tsx+++ b/apps/desktop/src/renderer/components/ui/spinner.tsx@@ -1,6 +1,6 @@import * as React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { LoaderCircle } from 'lucide-react';export interface SpinnerProps {diff --git a/apps/desktop/src/renderer/components/ui/tabs.tsx b/apps/desktop/src/renderer/components/ui/tabs.tsxindex e19b8ae6..bc530e49 100644--- a/apps/desktop/src/renderer/components/ui/tabs.tsx+++ b/apps/desktop/src/renderer/components/ui/tabs.tsx@@ -1,7 +1,7 @@import * as React from 'react';import * as TabsPrimitive from '@radix-ui/react-tabs';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const Tabs = TabsPrimitive.Root;diff --git a/apps/desktop/src/renderer/components/ui/textarea.tsx b/apps/desktop/src/renderer/components/ui/textarea.tsxindex 27a0b7a7..5e1d9f8f 100644--- a/apps/desktop/src/renderer/components/ui/textarea.tsx+++ b/apps/desktop/src/renderer/components/ui/textarea.tsx@@ -1,6 +1,6 @@import * as React from 'react';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';export interface TextareaPropsextends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}diff --git a/apps/desktop/src/renderer/components/ui/toast.tsx b/apps/desktop/src/renderer/components/ui/toast.tsxindex c6b87a39..2fd1814d 100644--- a/apps/desktop/src/renderer/components/ui/toast.tsx+++ b/apps/desktop/src/renderer/components/ui/toast.tsx@@ -3,7 +3,7 @@ import { Cross2Icon } from '@radix-ui/react-icons';import * as ToastPrimitives from '@radix-ui/react-toast';import { cva, type VariantProps } from 'class-variance-authority';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const ToastProvider = ToastPrimitives.Provider;diff --git a/apps/desktop/src/renderer/components/ui/tooltip.tsx b/apps/desktop/src/renderer/components/ui/tooltip.tsxindex 76a6112b..9982c02c 100644--- a/apps/desktop/src/renderer/components/ui/tooltip.tsx+++ b/apps/desktop/src/renderer/components/ui/tooltip.tsx@@ -1,7 +1,7 @@import * as React from 'react';import * as TooltipPrimitive from '@radix-ui/react-tooltip';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';const TooltipProvider = TooltipPrimitive.Provider;diff --git a/apps/desktop/src/renderer/components/workspaces/workspace-form.tsx b/apps/desktop/src/renderer/components/workspaces/workspace-form.tsxindex 5a9d65e2..fae90d03 100644--- a/apps/desktop/src/renderer/components/workspaces/workspace-form.tsx+++ b/apps/desktop/src/renderer/components/workspaces/workspace-form.tsx@@ -19,7 +19,7 @@ import { useMutation } from '@/renderer/hooks/use-mutation';import { useAccount } from '@/renderer/contexts/account';import { Avatar } from '@/renderer/components/avatars/avatar';import { generateId, IdType } from '@colanode/core';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Upload } from 'lucide-react';const formSchema = z.object({diff --git a/apps/desktop/src/renderer/components/workspaces/workspace-user-invite.tsx b/apps/desktop/src/renderer/components/workspaces/workspace-user-invite.tsxindex a64ec36c..d1338e5f 100644--- a/apps/desktop/src/renderer/components/workspaces/workspace-user-invite.tsx+++ b/apps/desktop/src/renderer/components/workspaces/workspace-user-invite.tsx@@ -1,5 +1,5 @@import React from 'react';-import { isValidEmail } from '@/lib/utils';+import { isValidEmail } from '@/shared/lib/utils';import { Button } from '@/renderer/components/ui/button';import { useMutation } from '@/renderer/hooks/use-mutation';import { Spinner } from '@/renderer/components/ui/spinner';diff --git a/apps/desktop/src/renderer/components/workspaces/workspace-users.tsx b/apps/desktop/src/renderer/components/workspaces/workspace-users.tsxindex a5bac185..8164ffaa 100644--- a/apps/desktop/src/renderer/components/workspaces/workspace-users.tsx+++ b/apps/desktop/src/renderer/components/workspaces/workspace-users.tsx@@ -8,7 +8,7 @@ import { InView } from 'react-intersection-observer';import { WorkspaceUserRoleDropdown } from '@/renderer/components/workspaces/workspace-user-role-dropdown';import { WorkspaceRole } from '@colanode/core';import { useWorkspace } from '@/renderer/contexts/workspace';-import { WorkspaceUserListQueryInput } from '@/operations/queries/workspace-user-list';+import { WorkspaceUserListQueryInput } from '../../../shared/queries/workspace-user-list';const USERS_PER_PAGE = 50;diff --git a/apps/desktop/src/renderer/contexts/account.ts b/apps/desktop/src/renderer/contexts/account.tsindex 032add17..aaed6c8e 100644--- a/apps/desktop/src/renderer/contexts/account.ts+++ b/apps/desktop/src/renderer/contexts/account.ts@@ -1,6 +1,6 @@import { createContext, useContext } from 'react';-import { Account } from '@/types/accounts';-import { Workspace } from '@/types/workspaces';+import { Account } from '@/shared/types/accounts';+import { Workspace } from '@/shared/types/workspaces';interface AccountContext extends Account {workspaces: Workspace[];diff --git a/apps/desktop/src/renderer/contexts/app.ts b/apps/desktop/src/renderer/contexts/app.tsindex 04c89f98..e11eccc5 100644--- a/apps/desktop/src/renderer/contexts/app.ts+++ b/apps/desktop/src/renderer/contexts/app.ts@@ -1,7 +1,7 @@import { createContext, useContext } from 'react';-import { Account } from '@/types/accounts';-import { Workspace } from '@/types/workspaces';-import { Server } from '@/types/servers';+import { Account } from '@/shared/types/accounts';+import { Workspace } from '@/shared/types/workspaces';+import { Server } from '@/shared/types/servers';interface AppContext {accounts: Account[];diff --git a/apps/desktop/src/renderer/contexts/conversation.ts b/apps/desktop/src/renderer/contexts/conversation.tsindex 1a930087..e0a9eade 100644--- a/apps/desktop/src/renderer/contexts/conversation.ts+++ b/apps/desktop/src/renderer/contexts/conversation.ts@@ -1,6 +1,6 @@import { NodeRole } from '@colanode/core';import { createContext, useContext } from 'react';-import { MessageNode } from '@/types/messages';+import { MessageNode } from '@/shared/types/messages';interface ConversationContext {id: string;diff --git a/apps/desktop/src/renderer/contexts/emoji-picker.ts b/apps/desktop/src/renderer/contexts/emoji-picker.tsindex ce242902..1d323c3e 100644--- a/apps/desktop/src/renderer/contexts/emoji-picker.ts+++ b/apps/desktop/src/renderer/contexts/emoji-picker.ts@@ -1,4 +1,4 @@-import { EmojiData, Emoji } from '@/types/emojis';+import { EmojiData, Emoji } from '@/shared/types/emojis';import { createContext, useContext } from 'react';interface EmojiPickerContextProps {diff --git a/apps/desktop/src/renderer/contexts/folder.ts b/apps/desktop/src/renderer/contexts/folder.tsindex 51c45720..8c8b8d6d 100644--- a/apps/desktop/src/renderer/contexts/folder.ts+++ b/apps/desktop/src/renderer/contexts/folder.ts@@ -1,4 +1,4 @@-import { FileNode } from '@/types/files';+import { FileNode } from '@/shared/types/files';import { createContext, useContext } from 'react';interface FolderContext {diff --git a/apps/desktop/src/renderer/contexts/icon-picker.ts b/apps/desktop/src/renderer/contexts/icon-picker.tsindex d6b977c1..13e822f7 100644--- a/apps/desktop/src/renderer/contexts/icon-picker.ts+++ b/apps/desktop/src/renderer/contexts/icon-picker.ts@@ -1,4 +1,4 @@-import { IconData, Icon } from '@/types/icons';+import { IconData, Icon } from '@/shared/types/icons';import { createContext, useContext } from 'react';interface IconPickerContextProps {diff --git a/apps/desktop/src/renderer/contexts/radar.ts b/apps/desktop/src/renderer/contexts/radar.tsnew file mode 100644index 00000000..551ce505--- /dev/null+++ b/apps/desktop/src/renderer/contexts/radar.ts@@ -0,0 +1,16 @@+import {+ ChannelReadState,+ ChatReadState,+ WorkspaceReadState,+} from '@/shared/types/radars';+import { createContext, useContext } from 'react';++interface RadarContext {+ getWorkspaceState: (userId: string) => WorkspaceReadState;+ getChatState: (userId: string, nodeId: string) => ChatReadState;+ getChannelState: (userId: string, nodeId: string) => ChannelReadState;+}++export const RadarContext = createContext<RadarContext>({} as RadarContext);++export const useRadar = () => useContext(RadarContext);diff --git a/apps/desktop/src/renderer/contexts/view.ts b/apps/desktop/src/renderer/contexts/view.tsindex 11109ba2..3f43e6fc 100644--- a/apps/desktop/src/renderer/contexts/view.ts+++ b/apps/desktop/src/renderer/contexts/view.ts@@ -1,5 +1,5 @@import { ViewFilterAttributes, ViewSortAttributes } from '@colanode/core';-import { ViewField } from '@/types/databases';+import { ViewField } from '@/shared/types/databases';import { createContext, useContext } from 'react';interface ViewContext {diff --git a/apps/desktop/src/renderer/contexts/workspace.ts b/apps/desktop/src/renderer/contexts/workspace.tsindex 477c3044..0c1e705a 100644--- a/apps/desktop/src/renderer/contexts/workspace.ts+++ b/apps/desktop/src/renderer/contexts/workspace.ts@@ -1,5 +1,5 @@import { createContext, useContext } from 'react';-import { Workspace } from '@/types/workspaces';+import { Workspace } from '@/shared/types/workspaces';interface WorkspaceContext extends Workspace {navigateToNode: (nodeId: string) => void;diff --git a/apps/desktop/src/renderer/editor/commands/blockquote.tsx b/apps/desktop/src/renderer/editor/commands/blockquote.tsxindex 39f99a70..9b61b1ce 100644--- a/apps/desktop/src/renderer/editor/commands/blockquote.tsx+++ b/apps/desktop/src/renderer/editor/commands/blockquote.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { Quote } from 'lucide-react';export const BlockquoteCommand: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/bullet-list.tsx b/apps/desktop/src/renderer/editor/commands/bullet-list.tsxindex 8b16555c..c7f5ddc3 100644--- a/apps/desktop/src/renderer/editor/commands/bullet-list.tsx+++ b/apps/desktop/src/renderer/editor/commands/bullet-list.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { List } from 'lucide-react';export const BulletListCommand: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/code-block.tsx b/apps/desktop/src/renderer/editor/commands/code-block.tsxindex 876629a3..fdd8cb86 100644--- a/apps/desktop/src/renderer/editor/commands/code-block.tsx+++ b/apps/desktop/src/renderer/editor/commands/code-block.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { Code } from 'lucide-react';export const CodeBlockCommand: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/divider.tsx b/apps/desktop/src/renderer/editor/commands/divider.tsxindex 965a1cd9..9af14b68 100644--- a/apps/desktop/src/renderer/editor/commands/divider.tsx+++ b/apps/desktop/src/renderer/editor/commands/divider.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { SeparatorHorizontal } from 'lucide-react';export const DividerCommand: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/file.tsx b/apps/desktop/src/renderer/editor/commands/file.tsxindex 9e9dc882..f525a2cd 100644--- a/apps/desktop/src/renderer/editor/commands/file.tsx+++ b/apps/desktop/src/renderer/editor/commands/file.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { NodeTypes } from '@colanode/core';import { FilePlus } from 'lucide-react';diff --git a/apps/desktop/src/renderer/editor/commands/folder.tsx b/apps/desktop/src/renderer/editor/commands/folder.tsxindex 5ceaef71..25c5d952 100644--- a/apps/desktop/src/renderer/editor/commands/folder.tsx+++ b/apps/desktop/src/renderer/editor/commands/folder.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { NodeTypes } from '@colanode/core';import { Folder } from 'lucide-react';diff --git a/apps/desktop/src/renderer/editor/commands/heading1.tsx b/apps/desktop/src/renderer/editor/commands/heading1.tsxindex f34c4f63..fcfe13a7 100644--- a/apps/desktop/src/renderer/editor/commands/heading1.tsx+++ b/apps/desktop/src/renderer/editor/commands/heading1.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { Heading1 } from 'lucide-react';export const Heading1Command: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/heading2.tsx b/apps/desktop/src/renderer/editor/commands/heading2.tsxindex 7bbbf1f3..275d9b31 100644--- a/apps/desktop/src/renderer/editor/commands/heading2.tsx+++ b/apps/desktop/src/renderer/editor/commands/heading2.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { Heading2 } from 'lucide-react';export const Heading2Command: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/heading3.tsx b/apps/desktop/src/renderer/editor/commands/heading3.tsxindex a1d63ef2..d799fa19 100644--- a/apps/desktop/src/renderer/editor/commands/heading3.tsx+++ b/apps/desktop/src/renderer/editor/commands/heading3.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { Heading3 } from 'lucide-react';export const Heading3Command: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/index.tsx b/apps/desktop/src/renderer/editor/commands/index.tsxindex 55442684..ca03253a 100644--- a/apps/desktop/src/renderer/editor/commands/index.tsx+++ b/apps/desktop/src/renderer/editor/commands/index.tsx@@ -11,7 +11,7 @@ import { TodoCommand } from '@/renderer/editor/commands/todo';import { PageCommand } from '@/renderer/editor/commands/page';import { FolderCommand } from '@/renderer/editor/commands/folder';import { FileCommand } from '@/renderer/editor/commands/file';-import { EditorCommand, EditorCommandProps } from '@/types/editor';+import { EditorCommand, EditorCommandProps } from '@/shared/types/editor';export type { EditorCommand, EditorCommandProps };diff --git a/apps/desktop/src/renderer/editor/commands/ordered-list.tsx b/apps/desktop/src/renderer/editor/commands/ordered-list.tsxindex 6f15dfdd..6aca8d27 100644--- a/apps/desktop/src/renderer/editor/commands/ordered-list.tsx+++ b/apps/desktop/src/renderer/editor/commands/ordered-list.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { ListOrdered } from 'lucide-react';export const OrderedListCommand: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/page.tsx b/apps/desktop/src/renderer/editor/commands/page.tsxindex 08c01144..b2a7bf2a 100644--- a/apps/desktop/src/renderer/editor/commands/page.tsx+++ b/apps/desktop/src/renderer/editor/commands/page.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { NodeTypes } from '@colanode/core';import { FileText } from 'lucide-react';diff --git a/apps/desktop/src/renderer/editor/commands/paragraph.tsx b/apps/desktop/src/renderer/editor/commands/paragraph.tsxindex 51304f8d..cf9733f9 100644--- a/apps/desktop/src/renderer/editor/commands/paragraph.tsx+++ b/apps/desktop/src/renderer/editor/commands/paragraph.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { Pilcrow } from 'lucide-react';export const ParagraphCommand: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/commands/todo.tsx b/apps/desktop/src/renderer/editor/commands/todo.tsxindex 017f0ef9..70726f5c 100644--- a/apps/desktop/src/renderer/editor/commands/todo.tsx+++ b/apps/desktop/src/renderer/editor/commands/todo.tsx@@ -1,4 +1,4 @@-import { EditorCommand } from '@/types/editor';+import { EditorCommand } from '@/shared/types/editor';import { ListTodo } from 'lucide-react';export const TodoCommand: EditorCommand = {diff --git a/apps/desktop/src/renderer/editor/extensions/code-block.tsx b/apps/desktop/src/renderer/editor/extensions/code-block.tsxindex 5b947fbc..6923e442 100644--- a/apps/desktop/src/renderer/editor/extensions/code-block.tsx+++ b/apps/desktop/src/renderer/editor/extensions/code-block.tsx@@ -3,7 +3,7 @@ import { ReactNodeViewRenderer } from '@tiptap/react';import { defaultClasses } from '@/renderer/editor/classes';import { CodeBlockNodeView } from '@/renderer/editor/views';-import { lowlight } from '@/lib/lowlight';+import { lowlight } from '@/shared/lib/lowlight';export const CodeBlockNode = CodeBlockLowlight.extend({addNodeView() {diff --git a/apps/desktop/src/renderer/editor/extensions/commander.tsx b/apps/desktop/src/renderer/editor/extensions/commander.tsxindex ca8fa1f9..1f8d2ee5 100644--- a/apps/desktop/src/renderer/editor/extensions/commander.tsx+++ b/apps/desktop/src/renderer/editor/extensions/commander.tsx@@ -7,8 +7,8 @@ import Suggestion, {type SuggestionProps,} from '@tiptap/suggestion';import tippy from 'tippy.js';-import { EditorCommandContext, EditorCommand } from '@/types/editor';-import { updateScrollView } from '@/lib/utils';+import { EditorCommandContext, EditorCommand } from '@/shared/types/editor';+import { updateScrollView } from '@/shared/lib/utils';interface CommanderOptions {commands: EditorCommand[];diff --git a/apps/desktop/src/renderer/editor/extensions/file-placeholder.tsx b/apps/desktop/src/renderer/editor/extensions/file-placeholder.tsxindex f6ce6ed8..29d1f778 100644--- a/apps/desktop/src/renderer/editor/extensions/file-placeholder.tsx+++ b/apps/desktop/src/renderer/editor/extensions/file-placeholder.tsx@@ -1,7 +1,7 @@import { mergeAttributes, Node, CommandProps } from '@tiptap/core';import { ReactNodeViewRenderer } from '@tiptap/react';import { FilePlaceholderNodeView } from '@/renderer/editor/views';-import { FileMetadata } from '@/types/files';+import { FileMetadata } from '@/shared/types/files';import { generateId, IdType } from '@colanode/core';declare module '@tiptap/core' {diff --git a/apps/desktop/src/renderer/editor/menu/bubble-menu.tsx b/apps/desktop/src/renderer/editor/menu/bubble-menu.tsxindex 2b824263..281ab1fa 100644--- a/apps/desktop/src/renderer/editor/menu/bubble-menu.tsx+++ b/apps/desktop/src/renderer/editor/menu/bubble-menu.tsx@@ -6,7 +6,7 @@ import {import { useState } from 'react';import { ColorButton } from '@/renderer/editor/menu/color-button';import { LinkButton } from '@/renderer/editor/menu/link-button';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Bold, Code, Italic, Strikethrough, Underline } from 'lucide-react';type EditorBubbleMenuProps = Omit<BubbleMenuProps, 'children'>;diff --git a/apps/desktop/src/renderer/editor/menu/color-button.tsx b/apps/desktop/src/renderer/editor/menu/color-button.tsxindex 710e2dbc..7a834d7d 100644--- a/apps/desktop/src/renderer/editor/menu/color-button.tsx+++ b/apps/desktop/src/renderer/editor/menu/color-button.tsx@@ -4,7 +4,7 @@ import {PopoverTrigger,PopoverContent,} from '@/renderer/components/ui/popover';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Baseline } from 'lucide-react';interface ColorItem {diff --git a/apps/desktop/src/renderer/editor/menu/link-button.tsx b/apps/desktop/src/renderer/editor/menu/link-button.tsxindex 788e6462..2baab81f 100644--- a/apps/desktop/src/renderer/editor/menu/link-button.tsx+++ b/apps/desktop/src/renderer/editor/menu/link-button.tsx@@ -6,7 +6,7 @@ import {PopoverTrigger,PopoverContent,} from '@/renderer/components/ui/popover';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { Check, Link, Trash2 } from 'lucide-react';const isValidUrl = (url: string) => {diff --git a/apps/desktop/src/renderer/editor/renderers/code-block.tsx b/apps/desktop/src/renderer/editor/renderers/code-block.tsxindex 8f1ff5ca..d069ee7f 100644--- a/apps/desktop/src/renderer/editor/renderers/code-block.tsx+++ b/apps/desktop/src/renderer/editor/renderers/code-block.tsx@@ -1,6 +1,6 @@import React from 'react';import { defaultClasses } from '@/renderer/editor/classes';-import { highlightCode, languages } from '@/lib/lowlight';+import { highlightCode, languages } from '@/shared/lib/lowlight';import { JSONContent } from '@tiptap/core';import { Clipboard } from 'lucide-react';diff --git a/apps/desktop/src/renderer/editor/renderers/paragraph.tsx b/apps/desktop/src/renderer/editor/renderers/paragraph.tsxindex d091ccdd..5c0ba0c0 100644--- a/apps/desktop/src/renderer/editor/renderers/paragraph.tsx+++ b/apps/desktop/src/renderer/editor/renderers/paragraph.tsx@@ -1,6 +1,6 @@import { defaultClasses } from '@/renderer/editor/classes';import { NodeChildrenRenderer } from '@/renderer/editor/renderers/node-children';-import { cn } from '@/lib/utils';+import { cn } from '@/shared/lib/utils';import { JSONContent } from '@tiptap/core';interface ParagraphRendererProps {diff --git a/apps/desktop/src/renderer/editor/views/code-block.tsx b/apps/desktop/src/renderer/editor/views/code-block.tsxindex eb8dd298..5f9ee6cc 100644--- a/apps/desktop/src/renderer/editor/views/code-block.tsx+++ b/apps/desktop/src/renderer/editor/views/code-block.tsx@@ -16,8 +16,8 @@ import {PopoverTrigger,} from '@/renderer/components/ui/popover';import { defaultClasses } from '@/renderer/editor/classes';-import { languages } from '@/lib/lowlight';-import { cn } from '@/lib/utils';+import { languages } from '@/shared/lib/lowlight';+import { cn } from '@/shared/lib/utils';import { ChevronDown, Check, Clipboard } from 'lucide-react';export const CodeBlockNodeView = ({diff --git a/apps/desktop/src/renderer/editor/views/file-placeholder.tsx b/apps/desktop/src/renderer/editor/views/file-placeholder.tsxindex 2fe6521b..75a1c00f 100644--- a/apps/desktop/src/renderer/editor/views/file-placeholder.tsx+++ b/apps/desktop/src/renderer/editor/views/file-placeholder.tsx@@ -1,7 +1,7 @@import { type NodeViewProps } from '@tiptap/core';import { NodeViewWrapper } from '@tiptap/react';import { FilePreview } from '@/renderer/components/files/file-preview';-import { getFilePlaceholderUrl } from '@/lib/files';+import { getFilePlaceholderUrl } from '@/shared/lib/files';import { X } from 'lucide-react';export const FilePlaceholderNodeView = ({diff --git a/apps/desktop/src/renderer/hooks/use-mutation.tsx b/apps/desktop/src/renderer/hooks/use-mutation.tsxindex c4033841..d87ddbfb 100644--- a/apps/desktop/src/renderer/hooks/use-mutation.tsx+++ b/apps/desktop/src/renderer/hooks/use-mutation.tsx@@ -1,5 +1,5 @@import React from 'react';-import { MutationInput, MutationMap } from '@/operations/mutations';+import { MutationInput, MutationMap } from '@/shared/mutations';interface MutationOptions<T extends MutationInput> {input: T;diff --git a/apps/desktop/src/renderer/hooks/use-queries.tsx b/apps/desktop/src/renderer/hooks/use-queries.tsxindex 6aa55e99..a3143d98 100644--- a/apps/desktop/src/renderer/hooks/use-queries.tsx+++ b/apps/desktop/src/renderer/hooks/use-queries.tsx@@ -1,4 +1,4 @@-import { QueryInput } from '@/operations/queries';+import { QueryInput } from '@/shared/queries';import { sha256 } from 'js-sha256';import { useQueries as useTanstackQueries } from '@tanstack/react-query';diff --git a/apps/desktop/src/renderer/hooks/use-query.tsx b/apps/desktop/src/renderer/hooks/use-query.tsxindex e56b6e8e..8c974d88 100644--- a/apps/desktop/src/renderer/hooks/use-query.tsx+++ b/apps/desktop/src/renderer/hooks/use-query.tsx@@ -1,4 +1,4 @@-import { QueryInput } from '@/operations/queries';+import { QueryInput } from '@/shared/queries';import { sha256 } from 'js-sha256';import { useQuery as useTanstackQuery } from '@tanstack/react-query';diff --git a/apps/desktop/src/renderer/hooks/user-records-query.tsx b/apps/desktop/src/renderer/hooks/user-records-query.tsxindex 53f36031..0907829b 100644--- a/apps/desktop/src/renderer/hooks/user-records-query.tsx+++ b/apps/desktop/src/renderer/hooks/user-records-query.tsx@@ -2,7 +2,7 @@ import React from 'react';import { useDatabase } from '@/renderer/contexts/database';import { useWorkspace } from '@/renderer/contexts/workspace';import { ViewFilterAttributes, ViewSortAttributes } from '@colanode/core';-import { RecordListQueryInput } from '@/operations/queries/record-list';+import { RecordListQueryInput } from '@/shared/queries/record-list';import { useQueries } from '@/renderer/hooks/use-queries';const RECORDS_PER_PAGE = 50;diff --git a/apps/desktop/src/renderer/radar-provider.tsx b/apps/desktop/src/renderer/radar-provider.tsxnew file mode 100644index 00000000..94699fe0--- /dev/null+++ b/apps/desktop/src/renderer/radar-provider.tsx@@ -0,0 +1,62 @@+import { RadarContext } from '@/renderer/contexts/radar';+import { useQuery } from '@/renderer/hooks/use-query';++interface RadarProviderProps {+ children: React.ReactNode;+}++export const RadarProvider = ({ children }: RadarProviderProps) => {+ const { data } = useQuery({+ type: 'read_states_get',+ });++ return (+ <RadarContext.Provider+ value={{+ getWorkspaceState: (userId) => {+ return (+ data?.[userId] ?? {+ nodeStates: {},+ importantCount: 0,+ hasUnseenChanges: false,+ }+ );+ },+ getChatState: (userId, nodeId) => {+ const workspaceState = data?.[userId];+ if (workspaceState) {+ const chatState = workspaceState.nodeStates[nodeId];+ if (chatState && chatState.type === 'chat') {+ return chatState;+ }+ }++ return {+ type: 'chat',+ nodeId,+ unseenMessagesCount: 0,+ mentionsCount: 0,+ };+ },+ getChannelState: (userId, nodeId) => {+ const workspaceState = data?.[userId];+ if (workspaceState) {+ const channelState = workspaceState.nodeStates[nodeId];+ if (channelState && channelState.type === 'channel') {+ return channelState;+ }+ }++ return {+ type: 'channel',+ nodeId,+ unseenMessagesCount: 0,+ mentionsCount: 0,+ };+ },+ }}+ >+ {children}+ </RadarContext.Provider>+ );+};diff --git a/apps/desktop/src/renderer/root.tsx b/apps/desktop/src/renderer/root.tsxindex 6bb1003e..d7dd6240 100644--- a/apps/desktop/src/renderer/root.tsx+++ b/apps/desktop/src/renderer/root.tsx@@ -46,14 +46,9 @@ const Root = () => {React.useEffect(() => {const id = eventBus.subscribe((event) => {- if (- event.event === 'query_result_updated' &&- event.payload &&- event.payload.id &&- event.payload.result- ) {- const result = event.payload.result;- const queryId = event.payload.id;+ if (event.type === 'query_result_updated' && event.id && event.result) {+ const result = event.result;+ const queryId = event.id;if (!result) {return;diff --git a/apps/desktop/src/lib/avatars.ts b/apps/desktop/src/shared/lib/avatars.tssimilarity index 96%rename from apps/desktop/src/lib/avatars.tsrename to apps/desktop/src/shared/lib/avatars.tsindex ae39802b..fda64fe3 100644--- a/apps/desktop/src/lib/avatars.ts+++ b/apps/desktop/src/shared/lib/avatars.ts@@ -1,4 +1,4 @@-import { hashCode } from '@/lib/utils';+import { hashCode } from '@/shared/lib/utils';import { IdType } from '@colanode/core';export const getAvatarSizeClasses = (size?: string) => {diff --git a/apps/desktop/src/lib/axios.ts b/apps/desktop/src/shared/lib/axios.tssimilarity index 94%rename from apps/desktop/src/lib/axios.tsrename to apps/desktop/src/shared/lib/axios.tsindex bff58aeb..9c6cab56 100644--- a/apps/desktop/src/lib/axios.ts+++ b/apps/desktop/src/shared/lib/axios.ts@@ -1,5 +1,5 @@import { isAxiosError } from 'axios';-import { ApiErrorOutput } from '@/types/errors';+import { ApiErrorOutput } from '@/shared/types/errors';export const parseApiError = (error: unknown): ApiErrorOutput => {if (isAxiosError(error) && error.response) {diff --git a/apps/desktop/src/lib/backoff-calculator.ts b/apps/desktop/src/shared/lib/backoff-calculator.tssimilarity index 100%rename from apps/desktop/src/lib/backoff-calculator.tsrename to apps/desktop/src/shared/lib/backoff-calculator.tsdiff --git a/apps/desktop/src/lib/databases.ts b/apps/desktop/src/shared/lib/databases.tssimilarity index 99%rename from apps/desktop/src/lib/databases.tsrename to apps/desktop/src/shared/lib/databases.tsindex 1d50d5af..8a56e50c 100644--- a/apps/desktop/src/lib/databases.ts+++ b/apps/desktop/src/shared/lib/databases.ts@@ -6,8 +6,8 @@ import {ViewFieldAttributes,RecordNode,} from '@colanode/core';-import { compareString, isStringArray } from '@/lib/utils';-import { generateNodeIndex } from '@/lib/nodes';+import { compareString, isStringArray } from '@/shared/lib/utils';+import { generateNodeIndex } from '@/shared/lib/nodes';export const getDefaultFieldWidth = (type: FieldType): number => {if (!type) return 0;diff --git a/apps/desktop/src/lib/editor.ts b/apps/desktop/src/shared/lib/editor.tssimilarity index 98%rename from apps/desktop/src/lib/editor.tsrename to apps/desktop/src/shared/lib/editor.tsindex 8f1a9d4c..532b1920 100644--- a/apps/desktop/src/lib/editor.ts+++ b/apps/desktop/src/shared/lib/editor.ts@@ -1,6 +1,6 @@import { EditorNodeTypes, generateId, getIdTypeFromNode } from '@colanode/core';-import { generateNodeIndex } from '@/lib/nodes';-import { compareString } from '@/lib/utils';+import { generateNodeIndex } from '@/shared/lib/nodes';+import { compareString } from '@/shared/lib/utils';import { JSONContent } from '@tiptap/core';import { Block, BlockLeaf } from '@colanode/core';diff --git a/apps/desktop/src/lib/emojis.ts b/apps/desktop/src/shared/lib/emojis.tssimilarity index 91%rename from apps/desktop/src/lib/emojis.tsrename to apps/desktop/src/shared/lib/emojis.tsindex 663737c7..7f07d75f 100644--- a/apps/desktop/src/lib/emojis.ts+++ b/apps/desktop/src/shared/lib/emojis.ts@@ -1,4 +1,4 @@-import { EmojiData, Emoji } from '@/types/emojis';+import { EmojiData, Emoji } from '@/shared/types/emojis';export const getEmojiUrl = (id: string): string => {return `asset://emojis/${id}.svg`;diff --git a/apps/desktop/src/lib/event-bus.ts b/apps/desktop/src/shared/lib/event-bus.tssimilarity index 94%rename from apps/desktop/src/lib/event-bus.tsrename to apps/desktop/src/shared/lib/event-bus.tsindex f905ce14..962f63d7 100644--- a/apps/desktop/src/lib/event-bus.ts+++ b/apps/desktop/src/shared/lib/event-bus.ts@@ -1,13 +1,10 @@+import { Event } from '@/shared/types/events';+export interface Subscription {id: string;callback: (event: Event) => void;}-export interface Event {- event: string;- payload: any;-}-export interface EventBus {subscribe(callback: (event: Event) => void): string;unsubscribe(subscriptionId: string): void;diff --git a/apps/desktop/src/lib/files.ts b/apps/desktop/src/shared/lib/files.tssimilarity index 98%rename from apps/desktop/src/lib/files.tsrename to apps/desktop/src/shared/lib/files.tsindex d26ce0b0..bafa3c25 100644--- a/apps/desktop/src/lib/files.ts+++ b/apps/desktop/src/shared/lib/files.ts@@ -1,4 +1,4 @@-import { FilePreviewType } from '@/types/files';+import { FilePreviewType } from '@/shared/types/files';export const formatBytes = (bytes: number, decimals?: number): string => {if (bytes === 0) {diff --git a/apps/desktop/src/lib/http-client.ts b/apps/desktop/src/shared/lib/http-client.tssimilarity index 96%rename from apps/desktop/src/lib/http-client.tsrename to apps/desktop/src/shared/lib/http-client.tsindex 2c38f7ee..40251570 100644--- a/apps/desktop/src/lib/http-client.ts+++ b/apps/desktop/src/shared/lib/http-client.ts@@ -1,5 +1,5 @@-import { BackoffCalculator } from '@/lib/backoff-calculator';-import { ServerAttributes } from '@/types/servers';+import { BackoffCalculator } from '@/shared/lib/backoff-calculator';+import { ServerAttributes } from '@/shared/types/servers';import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';interface HttpClientRequestConfig extends AxiosRequestConfig {diff --git a/apps/desktop/src/lib/icons.ts b/apps/desktop/src/shared/lib/icons.tssimilarity index 91%rename from apps/desktop/src/lib/icons.tsrename to apps/desktop/src/shared/lib/icons.tsindex b3d4eb2c..7376e498 100644--- a/apps/desktop/src/lib/icons.ts+++ b/apps/desktop/src/shared/lib/icons.ts@@ -1,4 +1,4 @@-import { IconData, Icon } from '@/types/icons';+import { IconData, Icon } from '@/shared/types/icons';export const getIconUrl = (id: string): string => {return `asset://icons/${id}.svg`;diff --git a/apps/desktop/src/lib/lowlight.ts b/apps/desktop/src/shared/lib/lowlight.tssimilarity index 100%rename from apps/desktop/src/lib/lowlight.tsrename to apps/desktop/src/shared/lib/lowlight.tsdiff --git a/apps/desktop/src/lib/nodes.ts b/apps/desktop/src/shared/lib/nodes.tssimilarity index 95%rename from apps/desktop/src/lib/nodes.tsrename to apps/desktop/src/shared/lib/nodes.tsindex 6a329611..9fab4a3b 100644--- a/apps/desktop/src/lib/nodes.ts+++ b/apps/desktop/src/shared/lib/nodes.ts@@ -1,6 +1,6 @@import { generateKeyBetween } from 'fractional-indexing-jittered';import { extractNodeCollaborators, Node, NodeTypes } from '@colanode/core';-import { NodeCollaborator } from '@/types/nodes';+import { NodeCollaborator } from '@/shared/types/nodes';export const generateNodeIndex = (previous?: string | null,diff --git a/apps/desktop/src/lib/utils.ts b/apps/desktop/src/shared/lib/utils.tssimilarity index 100%rename from apps/desktop/src/lib/utils.tsrename to apps/desktop/src/shared/lib/utils.tsdiff --git a/apps/desktop/src/operations/messages/index.ts b/apps/desktop/src/shared/messages/index.tssimilarity index 100%rename from apps/desktop/src/operations/messages/index.tsrename to apps/desktop/src/shared/messages/index.tsdiff --git a/apps/desktop/src/operations/messages/local-node-delete.ts b/apps/desktop/src/shared/messages/local-node-delete.tssimilarity index 83%rename from apps/desktop/src/operations/messages/local-node-delete.tsrename to apps/desktop/src/shared/messages/local-node-delete.tsindex 59ec3124..d7fe7ddb 100644--- a/apps/desktop/src/operations/messages/local-node-delete.ts+++ b/apps/desktop/src/shared/messages/local-node-delete.ts@@ -4,7 +4,7 @@ export type LocalNodeDeleteMessageInput = {workspaceId: string;};-declare module '@/operations/messages' {+declare module '@/shared/messages' {interface MessageMap {local_node_delete: LocalNodeDeleteMessageInput;}diff --git a/apps/desktop/src/operations/messages/local-node-sync.ts b/apps/desktop/src/shared/messages/local-node-sync.tssimilarity index 84%rename from apps/desktop/src/operations/messages/local-node-sync.tsrename to apps/desktop/src/shared/messages/local-node-sync.tsindex d8666992..dc3e9aee 100644--- a/apps/desktop/src/operations/messages/local-node-sync.ts+++ b/apps/desktop/src/shared/messages/local-node-sync.ts@@ -6,7 +6,7 @@ export type LocalNodeSyncMessageInput = {workspaceId: string;};-declare module '@/operations/messages' {+declare module '@/shared/messages' {interface MessageMap {local_node_sync: LocalNodeSyncMessageInput;}diff --git a/apps/desktop/src/operations/messages/local-user-node-sync.ts b/apps/desktop/src/shared/messages/local-user-node-sync.tssimilarity index 85%rename from apps/desktop/src/operations/messages/local-user-node-sync.tsrename to apps/desktop/src/shared/messages/local-user-node-sync.tsindex 1d74bbf9..0def691a 100644--- a/apps/desktop/src/operations/messages/local-user-node-sync.ts+++ b/apps/desktop/src/shared/messages/local-user-node-sync.ts@@ -6,7 +6,7 @@ export type LocalUserNodeSyncMessageInput = {versionId: string;};-declare module '@/operations/messages' {+declare module '@/shared/messages' {interface MessageMap {local_user_node_sync: LocalUserNodeSyncMessageInput;}diff --git a/apps/desktop/src/operations/messages/server-node-delete.ts b/apps/desktop/src/shared/messages/server-node-delete.tssimilarity index 83%rename from apps/desktop/src/operations/messages/server-node-delete.tsrename to apps/desktop/src/shared/messages/server-node-delete.tsindex 00e96953..7df6037a 100644--- a/apps/desktop/src/operations/messages/server-node-delete.ts+++ b/apps/desktop/src/shared/messages/server-node-delete.ts@@ -4,7 +4,7 @@ export type ServerNodeDeleteMessageInput = {workspaceId: string;};-declare module '@/operations/messages' {+declare module '@/shared/messages' {interface MessageMap {server_node_delete: ServerNodeDeleteMessageInput;}diff --git a/apps/desktop/src/operations/messages/server-node-sync.ts b/apps/desktop/src/shared/messages/server-node-sync.tssimilarity index 90%rename from apps/desktop/src/operations/messages/server-node-sync.tsrename to apps/desktop/src/shared/messages/server-node-sync.tsindex a44b3b39..a6b987b7 100644--- a/apps/desktop/src/operations/messages/server-node-sync.ts+++ b/apps/desktop/src/shared/messages/server-node-sync.ts@@ -12,7 +12,7 @@ export type ServerNodeSyncMessageInput = {versionId: string;};-declare module '@/operations/messages' {+declare module '@/shared/messages' {interface MessageMap {server_node_sync: ServerNodeSyncMessageInput;}diff --git a/apps/desktop/src/operations/messages/server-user-node-sync.ts b/apps/desktop/src/shared/messages/server-user-node-sync.tssimilarity index 90%rename from apps/desktop/src/operations/messages/server-user-node-sync.tsrename to apps/desktop/src/shared/messages/server-user-node-sync.tsindex d5cabdb9..d61dc99d 100644--- a/apps/desktop/src/operations/messages/server-user-node-sync.ts+++ b/apps/desktop/src/shared/messages/server-user-node-sync.ts@@ -11,7 +11,7 @@ export type ServerUserNodeSyncMessageInput = {updatedAt: string | null;};-declare module '@/operations/messages' {+declare module '@/shared/messages' {interface MessageMap {server_user_node_sync: ServerUserNodeSyncMessageInput;}diff --git a/apps/desktop/src/operations/mutations/account-update.ts b/apps/desktop/src/shared/mutations/account-update.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/account-update.tsrename to apps/desktop/src/shared/mutations/account-update.tsindex 72e6d331..dbc7a264 100644--- a/apps/desktop/src/operations/mutations/account-update.ts+++ b/apps/desktop/src/shared/mutations/account-update.ts@@ -9,7 +9,7 @@ export type AccountUpdateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {account_update: {input: AccountUpdateMutationInput;diff --git a/apps/desktop/src/operations/mutations/avatar-upload.ts b/apps/desktop/src/shared/mutations/avatar-upload.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/avatar-upload.tsrename to apps/desktop/src/shared/mutations/avatar-upload.tsindex 7cd1542d..acb47f1c 100644--- a/apps/desktop/src/operations/mutations/avatar-upload.ts+++ b/apps/desktop/src/shared/mutations/avatar-upload.ts@@ -9,7 +9,7 @@ export type AvatarUploadMutationOutput = {id: string | null;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {avatar_upload: {input: AvatarUploadMutationInput;diff --git a/apps/desktop/src/operations/mutations/channel-create.ts b/apps/desktop/src/shared/mutations/channel-create.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/channel-create.tsrename to apps/desktop/src/shared/mutations/channel-create.tsindex b2e4e0f7..8f126e59 100644--- a/apps/desktop/src/operations/mutations/channel-create.ts+++ b/apps/desktop/src/shared/mutations/channel-create.ts@@ -9,7 +9,7 @@ export type ChannelCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {channel_create: {input: ChannelCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/chat-create.ts b/apps/desktop/src/shared/mutations/chat-create.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/chat-create.tsrename to apps/desktop/src/shared/mutations/chat-create.tsindex 70e8bed2..cbb7ae22 100644--- a/apps/desktop/src/operations/mutations/chat-create.ts+++ b/apps/desktop/src/shared/mutations/chat-create.ts@@ -9,7 +9,7 @@ export type ChatCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {chat_create: {input: ChatCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/database-create.ts b/apps/desktop/src/shared/mutations/database-create.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/database-create.tsrename to apps/desktop/src/shared/mutations/database-create.tsindex e40d907d..3a2c176a 100644--- a/apps/desktop/src/operations/mutations/database-create.ts+++ b/apps/desktop/src/shared/mutations/database-create.ts@@ -9,7 +9,7 @@ export type DatabaseCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {database_create: {input: DatabaseCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/document-save.ts b/apps/desktop/src/shared/mutations/document-save.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/document-save.tsrename to apps/desktop/src/shared/mutations/document-save.tsindex f1056681..465ca7c8 100644--- a/apps/desktop/src/operations/mutations/document-save.ts+++ b/apps/desktop/src/shared/mutations/document-save.ts@@ -11,7 +11,7 @@ export type DocumentSaveMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {document_save: {input: DocumentSaveMutationInput;diff --git a/apps/desktop/src/operations/mutations/email-login.ts b/apps/desktop/src/shared/mutations/email-login.tssimilarity index 87%rename from apps/desktop/src/operations/mutations/email-login.tsrename to apps/desktop/src/shared/mutations/email-login.tsindex b8a080f0..f4b30602 100644--- a/apps/desktop/src/operations/mutations/email-login.ts+++ b/apps/desktop/src/shared/mutations/email-login.ts@@ -1,4 +1,4 @@-import { Account } from '@/types/accounts';+import { Account } from '@/shared/types/accounts';import { WorkspaceOutput } from '@colanode/core';export type EmailLoginMutationInput = {@@ -22,7 +22,7 @@ export type EmailLoginMutationErrorOutput = {success: false;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {email_login: {input: EmailLoginMutationInput;diff --git a/apps/desktop/src/operations/mutations/email-register.ts b/apps/desktop/src/shared/mutations/email-register.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/email-register.tsrename to apps/desktop/src/shared/mutations/email-register.tsindex a02a1c3f..8ebb999d 100644--- a/apps/desktop/src/operations/mutations/email-register.ts+++ b/apps/desktop/src/shared/mutations/email-register.ts@@ -1,4 +1,4 @@-import { Account } from '@/types/accounts';+import { Account } from '@/shared/types/accounts';import { WorkspaceOutput } from '@colanode/core';export type EmailRegisterMutationInput = {@@ -23,7 +23,7 @@ export type EmailRegisterMutationErrorOutput = {success: false;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {email_register: {input: EmailRegisterMutationInput;diff --git a/apps/desktop/src/operations/mutations/field-create.ts b/apps/desktop/src/shared/mutations/field-create.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/field-create.tsrename to apps/desktop/src/shared/mutations/field-create.tsindex 0761ec0e..9f212cd8 100644--- a/apps/desktop/src/operations/mutations/field-create.ts+++ b/apps/desktop/src/shared/mutations/field-create.ts@@ -12,7 +12,7 @@ export type FieldCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {field_create: {input: FieldCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/file-create.ts b/apps/desktop/src/shared/mutations/file-create.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/file-create.tsrename to apps/desktop/src/shared/mutations/file-create.tsindex 562526b8..639e7d88 100644--- a/apps/desktop/src/operations/mutations/file-create.ts+++ b/apps/desktop/src/shared/mutations/file-create.ts@@ -9,7 +9,7 @@ export type FileCreateMutationOutput = {id: string | null;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {file_create: {input: FileCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/file-download.ts b/apps/desktop/src/shared/mutations/file-download.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/file-download.tsrename to apps/desktop/src/shared/mutations/file-download.tsindex 06a8fbb8..0e89cf65 100644--- a/apps/desktop/src/operations/mutations/file-download.ts+++ b/apps/desktop/src/shared/mutations/file-download.ts@@ -8,7 +8,7 @@ export type FileDownloadMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {file_download: {input: FileDownloadMutationInput;diff --git a/apps/desktop/src/operations/mutations/folder-create.ts b/apps/desktop/src/shared/mutations/folder-create.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/folder-create.tsrename to apps/desktop/src/shared/mutations/folder-create.tsindex 13a4ee09..808a5c6c 100644--- a/apps/desktop/src/operations/mutations/folder-create.ts+++ b/apps/desktop/src/shared/mutations/folder-create.ts@@ -10,7 +10,7 @@ export type FolderCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {folder_create: {input: FolderCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/index.ts b/apps/desktop/src/shared/mutations/index.tssimilarity index 100%rename from apps/desktop/src/operations/mutations/index.tsrename to apps/desktop/src/shared/mutations/index.tsdiff --git a/apps/desktop/src/operations/mutations/logout.ts b/apps/desktop/src/shared/mutations/logout.tssimilarity index 86%rename from apps/desktop/src/operations/mutations/logout.tsrename to apps/desktop/src/shared/mutations/logout.tsindex 51811bc6..679a67c7 100644--- a/apps/desktop/src/operations/mutations/logout.ts+++ b/apps/desktop/src/shared/mutations/logout.ts@@ -7,7 +7,7 @@ export type LogoutMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {logout: {input: LogoutMutationInput;diff --git a/apps/desktop/src/operations/mutations/mark-node-as-seen.ts b/apps/desktop/src/shared/mutations/mark-node-as-seen.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/mark-node-as-seen.tsrename to apps/desktop/src/shared/mutations/mark-node-as-seen.tsindex 2bf2dbb5..72bd6843 100644--- a/apps/desktop/src/operations/mutations/mark-node-as-seen.ts+++ b/apps/desktop/src/shared/mutations/mark-node-as-seen.ts@@ -9,7 +9,7 @@ export type MarkNodeAsSeenMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {mark_node_as_seen: {input: MarkNodeAsSeenMutationInput;diff --git a/apps/desktop/src/operations/mutations/message-create.ts b/apps/desktop/src/shared/mutations/message-create.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/message-create.tsrename to apps/desktop/src/shared/mutations/message-create.tsindex 98c6125a..f3fac41f 100644--- a/apps/desktop/src/operations/mutations/message-create.ts+++ b/apps/desktop/src/shared/mutations/message-create.ts@@ -11,7 +11,7 @@ export type MessageCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {message_create: {input: MessageCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-attribute-delete.ts b/apps/desktop/src/shared/mutations/node-attribute-delete.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/node-attribute-delete.tsrename to apps/desktop/src/shared/mutations/node-attribute-delete.tsindex ab4d69a7..7aca398a 100644--- a/apps/desktop/src/operations/mutations/node-attribute-delete.ts+++ b/apps/desktop/src/shared/mutations/node-attribute-delete.ts@@ -9,7 +9,7 @@ export type NodeAttributeDeleteMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_attribute_delete: {input: NodeAttributeDeleteMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-attribute-set.ts b/apps/desktop/src/shared/mutations/node-attribute-set.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/node-attribute-set.tsrename to apps/desktop/src/shared/mutations/node-attribute-set.tsindex 553f9d3e..64c017cc 100644--- a/apps/desktop/src/operations/mutations/node-attribute-set.ts+++ b/apps/desktop/src/shared/mutations/node-attribute-set.ts@@ -10,7 +10,7 @@ export type NodeAttributeSetMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_attribute_set: {input: NodeAttributeSetMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-collaborator-create.ts b/apps/desktop/src/shared/mutations/node-collaborator-create.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/node-collaborator-create.tsrename to apps/desktop/src/shared/mutations/node-collaborator-create.tsindex 425eec4f..a1601b1f 100644--- a/apps/desktop/src/operations/mutations/node-collaborator-create.ts+++ b/apps/desktop/src/shared/mutations/node-collaborator-create.ts@@ -10,7 +10,7 @@ export type NodeCollaboratorCreateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_collaborator_create: {input: NodeCollaboratorCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-collaborator-delete.ts b/apps/desktop/src/shared/mutations/node-collaborator-delete.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/node-collaborator-delete.tsrename to apps/desktop/src/shared/mutations/node-collaborator-delete.tsindex acf88449..faedcfc2 100644--- a/apps/desktop/src/operations/mutations/node-collaborator-delete.ts+++ b/apps/desktop/src/shared/mutations/node-collaborator-delete.ts@@ -9,7 +9,7 @@ export type NodeCollaboratorDeleteMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_collaborator_delete: {input: NodeCollaboratorDeleteMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-collaborator-update.ts b/apps/desktop/src/shared/mutations/node-collaborator-update.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/node-collaborator-update.tsrename to apps/desktop/src/shared/mutations/node-collaborator-update.tsindex eea76059..f14b8492 100644--- a/apps/desktop/src/operations/mutations/node-collaborator-update.ts+++ b/apps/desktop/src/shared/mutations/node-collaborator-update.ts@@ -10,7 +10,7 @@ export type NodeCollaboratorUpdateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_collaborator_update: {input: NodeCollaboratorUpdateMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-delete.ts b/apps/desktop/src/shared/mutations/node-delete.tssimilarity index 87%rename from apps/desktop/src/operations/mutations/node-delete.tsrename to apps/desktop/src/shared/mutations/node-delete.tsindex 268e68bc..e6728fa6 100644--- a/apps/desktop/src/operations/mutations/node-delete.ts+++ b/apps/desktop/src/shared/mutations/node-delete.ts@@ -8,7 +8,7 @@ export type NodeDeleteMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_delete: {input: NodeDeleteMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-reaction-create.ts b/apps/desktop/src/shared/mutations/node-reaction-create.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/node-reaction-create.tsrename to apps/desktop/src/shared/mutations/node-reaction-create.tsindex 71e6a663..1460c7d0 100644--- a/apps/desktop/src/operations/mutations/node-reaction-create.ts+++ b/apps/desktop/src/shared/mutations/node-reaction-create.ts@@ -9,7 +9,7 @@ export type NodeReactionCreateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_reaction_create: {input: NodeReactionCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/node-reaction-delete.ts b/apps/desktop/src/shared/mutations/node-reaction-delete.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/node-reaction-delete.tsrename to apps/desktop/src/shared/mutations/node-reaction-delete.tsindex 42ebe142..6a38202b 100644--- a/apps/desktop/src/operations/mutations/node-reaction-delete.ts+++ b/apps/desktop/src/shared/mutations/node-reaction-delete.ts@@ -9,7 +9,7 @@ export type NodeReactionDeleteMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {node_reaction_delete: {input: NodeReactionDeleteMutationInput;diff --git a/apps/desktop/src/operations/mutations/page-create.ts b/apps/desktop/src/shared/mutations/page-create.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/page-create.tsrename to apps/desktop/src/shared/mutations/page-create.tsindex fe34eb5f..00ab9048 100644--- a/apps/desktop/src/operations/mutations/page-create.ts+++ b/apps/desktop/src/shared/mutations/page-create.ts@@ -10,7 +10,7 @@ export type PageCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {page_create: {input: PageCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/record-create.ts b/apps/desktop/src/shared/mutations/record-create.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/record-create.tsrename to apps/desktop/src/shared/mutations/record-create.tsindex 10918b03..24882906 100644--- a/apps/desktop/src/operations/mutations/record-create.ts+++ b/apps/desktop/src/shared/mutations/record-create.ts@@ -9,7 +9,7 @@ export type RecordCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {record_create: {input: RecordCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/select-option-create.ts b/apps/desktop/src/shared/mutations/select-option-create.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/select-option-create.tsrename to apps/desktop/src/shared/mutations/select-option-create.tsindex d0ba52d8..a2c58fc6 100644--- a/apps/desktop/src/operations/mutations/select-option-create.ts+++ b/apps/desktop/src/shared/mutations/select-option-create.ts@@ -11,7 +11,7 @@ export type SelectOptionCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {select_option_create: {input: SelectOptionCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/server-create.ts b/apps/desktop/src/shared/mutations/server-create.tssimilarity index 87%rename from apps/desktop/src/operations/mutations/server-create.tsrename to apps/desktop/src/shared/mutations/server-create.tsindex 9bd90a53..de0ab1fb 100644--- a/apps/desktop/src/operations/mutations/server-create.ts+++ b/apps/desktop/src/shared/mutations/server-create.ts@@ -7,7 +7,7 @@ export type ServerCreateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {server_create: {input: ServerCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/server-node-delete.ts b/apps/desktop/src/shared/mutations/server-node-delete.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/server-node-delete.tsrename to apps/desktop/src/shared/mutations/server-node-delete.tsindex cfe79701..c7659cdb 100644--- a/apps/desktop/src/operations/mutations/server-node-delete.ts+++ b/apps/desktop/src/shared/mutations/server-node-delete.ts@@ -9,7 +9,7 @@ export type ServerNodeDeleteMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {server_node_delete: {input: ServerNodeDeleteMutationInput;diff --git a/apps/desktop/src/operations/mutations/server-node-sync.ts b/apps/desktop/src/shared/mutations/server-node-sync.tssimilarity index 92%rename from apps/desktop/src/operations/mutations/server-node-sync.tsrename to apps/desktop/src/shared/mutations/server-node-sync.tsindex b2014aa8..37daa899 100644--- a/apps/desktop/src/operations/mutations/server-node-sync.ts+++ b/apps/desktop/src/shared/mutations/server-node-sync.ts@@ -17,7 +17,7 @@ export type ServerNodeSyncMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {server_node_sync: {input: ServerNodeSyncMutationInput;diff --git a/apps/desktop/src/operations/mutations/server-user-node-sync.ts b/apps/desktop/src/shared/mutations/server-user-node-sync.tssimilarity index 93%rename from apps/desktop/src/operations/mutations/server-user-node-sync.tsrename to apps/desktop/src/shared/mutations/server-user-node-sync.tsindex bf2eb6c6..5265bace 100644--- a/apps/desktop/src/operations/mutations/server-user-node-sync.ts+++ b/apps/desktop/src/shared/mutations/server-user-node-sync.ts@@ -16,7 +16,7 @@ export type ServerUserNodeSyncMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {server_user_node_sync: {input: ServerUserNodeSyncMutationInput;diff --git a/apps/desktop/src/operations/mutations/space-create.ts b/apps/desktop/src/shared/mutations/space-create.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/space-create.tsrename to apps/desktop/src/shared/mutations/space-create.tsindex 53d1d2bd..40ccee11 100644--- a/apps/desktop/src/operations/mutations/space-create.ts+++ b/apps/desktop/src/shared/mutations/space-create.ts@@ -10,7 +10,7 @@ export type SpaceCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {space_create: {input: SpaceCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/space-update.ts b/apps/desktop/src/shared/mutations/space-update.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/space-update.tsrename to apps/desktop/src/shared/mutations/space-update.tsindex 0bf840fd..f33a2b49 100644--- a/apps/desktop/src/operations/mutations/space-update.ts+++ b/apps/desktop/src/shared/mutations/space-update.ts@@ -11,7 +11,7 @@ export type SpaceUpdateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {space_update: {input: SpaceUpdateMutationInput;diff --git a/apps/desktop/src/operations/mutations/view-create.ts b/apps/desktop/src/shared/mutations/view-create.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/view-create.tsrename to apps/desktop/src/shared/mutations/view-create.tsindex a776ebd5..1bebe5dd 100644--- a/apps/desktop/src/operations/mutations/view-create.ts+++ b/apps/desktop/src/shared/mutations/view-create.ts@@ -11,7 +11,7 @@ export type ViewCreateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {view_create: {input: ViewCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/view-delete.ts b/apps/desktop/src/shared/mutations/view-delete.tssimilarity index 88%rename from apps/desktop/src/operations/mutations/view-delete.tsrename to apps/desktop/src/shared/mutations/view-delete.tsindex 3493c58b..d257d9c4 100644--- a/apps/desktop/src/operations/mutations/view-delete.ts+++ b/apps/desktop/src/shared/mutations/view-delete.ts@@ -9,7 +9,7 @@ export type ViewDeleteMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {view_delete: {input: ViewDeleteMutationInput;diff --git a/apps/desktop/src/operations/mutations/view-update.ts b/apps/desktop/src/shared/mutations/view-update.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/view-update.tsrename to apps/desktop/src/shared/mutations/view-update.tsindex b4e0a5fc..75b07240 100644--- a/apps/desktop/src/operations/mutations/view-update.ts+++ b/apps/desktop/src/shared/mutations/view-update.ts@@ -11,7 +11,7 @@ export type ViewUpdateMutationOutput = {id: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {view_update: {input: ViewUpdateMutationInput;diff --git a/apps/desktop/src/operations/mutations/workspace-create.ts b/apps/desktop/src/shared/mutations/workspace-create.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/workspace-create.tsrename to apps/desktop/src/shared/mutations/workspace-create.tsindex e1b53597..02f4b47f 100644--- a/apps/desktop/src/operations/mutations/workspace-create.ts+++ b/apps/desktop/src/shared/mutations/workspace-create.ts@@ -11,7 +11,7 @@ export type WorkspaceCreateMutationOutput = {userId: string;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {workspace_create: {input: WorkspaceCreateMutationInput;diff --git a/apps/desktop/src/operations/mutations/workspace-update.ts b/apps/desktop/src/shared/mutations/workspace-update.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/workspace-update.tsrename to apps/desktop/src/shared/mutations/workspace-update.tsindex 39b226e5..b99cb43d 100644--- a/apps/desktop/src/operations/mutations/workspace-update.ts+++ b/apps/desktop/src/shared/mutations/workspace-update.ts@@ -11,7 +11,7 @@ export type WorkspaceUpdateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {workspace_update: {input: WorkspaceUpdateMutationInput;diff --git a/apps/desktop/src/operations/mutations/workspace-user-role-update.ts b/apps/desktop/src/shared/mutations/workspace-user-role-update.tssimilarity index 90%rename from apps/desktop/src/operations/mutations/workspace-user-role-update.tsrename to apps/desktop/src/shared/mutations/workspace-user-role-update.tsindex c045200d..2e1c5a72 100644--- a/apps/desktop/src/operations/mutations/workspace-user-role-update.ts+++ b/apps/desktop/src/shared/mutations/workspace-user-role-update.ts@@ -9,7 +9,7 @@ export type WorkspaceUserRoleUpdateMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {workspace_user_role_update: {input: WorkspaceUserRoleUpdateMutationInput;diff --git a/apps/desktop/src/operations/mutations/workspace-users-invite.ts b/apps/desktop/src/shared/mutations/workspace-users-invite.tssimilarity index 89%rename from apps/desktop/src/operations/mutations/workspace-users-invite.tsrename to apps/desktop/src/shared/mutations/workspace-users-invite.tsindex b36cbc50..a335cfe9 100644--- a/apps/desktop/src/operations/mutations/workspace-users-invite.ts+++ b/apps/desktop/src/shared/mutations/workspace-users-invite.ts@@ -8,7 +8,7 @@ export type WorkspaceUsersInviteMutationOutput = {success: boolean;};-declare module '@/operations/mutations' {+declare module '@/shared/mutations' {interface MutationMap {workspace_users_invite: {input: WorkspaceUsersInviteMutationInput;diff --git a/apps/desktop/src/operations/queries/account-list.ts b/apps/desktop/src/shared/queries/account-list.tssimilarity index 67%rename from apps/desktop/src/operations/queries/account-list.tsrename to apps/desktop/src/shared/queries/account-list.tsindex 4e768515..13a7910f 100644--- a/apps/desktop/src/operations/queries/account-list.ts+++ b/apps/desktop/src/shared/queries/account-list.ts@@ -1,10 +1,10 @@-import { Account } from '@/types/accounts';+import { Account } from '@/shared/types/accounts';export type AccountListQueryInput = {type: 'account_list';};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {account_list: {input: AccountListQueryInput;diff --git a/apps/desktop/src/operations/queries/emojis-get.ts b/apps/desktop/src/shared/queries/emojis-get.tssimilarity index 66%rename from apps/desktop/src/operations/queries/emojis-get.tsrename to apps/desktop/src/shared/queries/emojis-get.tsindex b25e9207..bc3b4deb 100644--- a/apps/desktop/src/operations/queries/emojis-get.ts+++ b/apps/desktop/src/shared/queries/emojis-get.ts@@ -1,10 +1,10 @@-import { EmojiData } from '@/types/emojis';+import { EmojiData } from '@/shared/types/emojis';export type EmojisGetQueryInput = {type: 'emojis_get';};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {emojis_get: {input: EmojisGetQueryInput;diff --git a/apps/desktop/src/operations/queries/file-list.ts b/apps/desktop/src/shared/queries/file-list.tssimilarity index 74%rename from apps/desktop/src/operations/queries/file-list.tsrename to apps/desktop/src/shared/queries/file-list.tsindex 7d99e628..cd18754f 100644--- a/apps/desktop/src/operations/queries/file-list.ts+++ b/apps/desktop/src/shared/queries/file-list.ts@@ -1,4 +1,4 @@-import { FileNode } from '@/types/files';+import { FileNode } from '@/shared/types/files';export type FileListQueryInput = {type: 'file_list';@@ -8,7 +8,7 @@ export type FileListQueryInput = {userId: string;};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {file_list: {input: FileListQueryInput;diff --git a/apps/desktop/src/operations/queries/icons-get.ts b/apps/desktop/src/shared/queries/icons-get.tssimilarity index 66%rename from apps/desktop/src/operations/queries/icons-get.tsrename to apps/desktop/src/shared/queries/icons-get.tsindex 797604bb..c628efc1 100644--- a/apps/desktop/src/operations/queries/icons-get.ts+++ b/apps/desktop/src/shared/queries/icons-get.ts@@ -1,10 +1,10 @@-import { IconData } from '@/types/icons';+import { IconData } from '@/shared/types/icons';export type IconsGetQueryInput = {type: 'icons_get';};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {icons_get: {input: IconsGetQueryInput;diff --git a/apps/desktop/src/operations/queries/index.ts b/apps/desktop/src/shared/queries/index.tssimilarity index 100%rename from apps/desktop/src/operations/queries/index.tsrename to apps/desktop/src/shared/queries/index.tsdiff --git a/apps/desktop/src/operations/queries/message-list.ts b/apps/desktop/src/shared/queries/message-list.tssimilarity index 74%rename from apps/desktop/src/operations/queries/message-list.tsrename to apps/desktop/src/shared/queries/message-list.tsindex 2ef08281..7eac8c77 100644--- a/apps/desktop/src/operations/queries/message-list.ts+++ b/apps/desktop/src/shared/queries/message-list.ts@@ -1,4 +1,4 @@-import { MessageNode } from '@/types/messages';+import { MessageNode } from '@/shared/types/messages';export type MessageListQueryInput = {type: 'message_list';@@ -8,7 +8,7 @@ export type MessageListQueryInput = {userId: string;};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {message_list: {input: MessageListQueryInput;diff --git a/apps/desktop/src/operations/queries/node-children-get.tsx b/apps/desktop/src/shared/queries/node-children-get.tsxsimilarity index 88%rename from apps/desktop/src/operations/queries/node-children-get.tsxrename to apps/desktop/src/shared/queries/node-children-get.tsxindex 391fa211..ae5e0949 100644--- a/apps/desktop/src/operations/queries/node-children-get.tsx+++ b/apps/desktop/src/shared/queries/node-children-get.tsx@@ -7,7 +7,7 @@ export type NodeChildrenGetQueryInput = {types?: NodeType[];};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {node_children_get: {input: NodeChildrenGetQueryInput;diff --git a/apps/desktop/src/operations/queries/node-get.ts b/apps/desktop/src/shared/queries/node-get.tssimilarity index 85%rename from apps/desktop/src/operations/queries/node-get.tsrename to apps/desktop/src/shared/queries/node-get.tsindex 0607391c..2049e6e0 100644--- a/apps/desktop/src/operations/queries/node-get.ts+++ b/apps/desktop/src/shared/queries/node-get.ts@@ -6,7 +6,7 @@ export type NodeGetQueryInput = {userId: string;};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {node_get: {input: NodeGetQueryInput;diff --git a/apps/desktop/src/operations/queries/node-tree-get.ts b/apps/desktop/src/shared/queries/node-tree-get.tssimilarity index 86%rename from apps/desktop/src/operations/queries/node-tree-get.tsrename to apps/desktop/src/shared/queries/node-tree-get.tsindex 96741dbb..9fbb8c1a 100644--- a/apps/desktop/src/operations/queries/node-tree-get.ts+++ b/apps/desktop/src/shared/queries/node-tree-get.ts@@ -6,7 +6,7 @@ export type NodeTreeGetQueryInput = {userId: string;};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {node_tree_get: {input: NodeTreeGetQueryInput;diff --git a/apps/desktop/src/shared/queries/read-states-get.ts b/apps/desktop/src/shared/queries/read-states-get.tsnew file mode 100644index 00000000..de44b6da--- /dev/null+++ b/apps/desktop/src/shared/queries/read-states-get.ts@@ -0,0 +1,14 @@+import { WorkspaceReadState } from '@/shared/types/radars';++export type ReadStatesGetQueryInput = {+ type: 'read_states_get';+};++declare module '@/shared/queries' {+ interface QueryMap {+ read_states_get: {+ input: ReadStatesGetQueryInput;+ output: Record<string, WorkspaceReadState>;+ };+ }+}diff --git a/apps/desktop/src/operations/queries/record-list.ts b/apps/desktop/src/shared/queries/record-list.tssimilarity index 91%rename from apps/desktop/src/operations/queries/record-list.tsrename to apps/desktop/src/shared/queries/record-list.tsindex 013f5bf0..03a68dd7 100644--- a/apps/desktop/src/operations/queries/record-list.ts+++ b/apps/desktop/src/shared/queries/record-list.ts@@ -14,7 +14,7 @@ export type RecordListQueryInput = {userId: string;};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {record_list: {input: RecordListQueryInput;diff --git a/apps/desktop/src/operations/queries/server-list.ts b/apps/desktop/src/shared/queries/server-list.tssimilarity index 67%rename from apps/desktop/src/operations/queries/server-list.tsrename to apps/desktop/src/shared/queries/server-list.tsindex 6b71e530..20b138bb 100644--- a/apps/desktop/src/operations/queries/server-list.ts+++ b/apps/desktop/src/shared/queries/server-list.ts@@ -1,10 +1,10 @@-import { Server } from '@/types/servers';+import { Server } from '@/shared/types/servers';export type ServerListQueryInput = {type: 'server_list';};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {server_list: {input: ServerListQueryInput;diff --git a/apps/desktop/src/operations/queries/user-search.ts b/apps/desktop/src/shared/queries/user-search.tssimilarity index 87%rename from apps/desktop/src/operations/queries/user-search.tsrename to apps/desktop/src/shared/queries/user-search.tsindex 2e96114e..beadcf64 100644--- a/apps/desktop/src/operations/queries/user-search.ts+++ b/apps/desktop/src/shared/queries/user-search.ts@@ -7,7 +7,7 @@ export type UserSearchQueryInput = {exclude?: string[];};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {user_search: {input: UserSearchQueryInput;diff --git a/apps/desktop/src/operations/queries/workspace-list.ts b/apps/desktop/src/shared/queries/workspace-list.tssimilarity index 68%rename from apps/desktop/src/operations/queries/workspace-list.tsrename to apps/desktop/src/shared/queries/workspace-list.tsindex a3d72a1c..aaa93301 100644--- a/apps/desktop/src/operations/queries/workspace-list.ts+++ b/apps/desktop/src/shared/queries/workspace-list.ts@@ -1,10 +1,10 @@-import { Workspace } from '@/types/workspaces';+import { Workspace } from '@/shared/types/workspaces';export type WorkspaceListQueryInput = {type: 'workspace_list';};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {workspace_list: {input: WorkspaceListQueryInput;diff --git a/apps/desktop/src/operations/queries/workspace-user-list.ts b/apps/desktop/src/shared/queries/workspace-user-list.tssimilarity index 88%rename from apps/desktop/src/operations/queries/workspace-user-list.tsrename to apps/desktop/src/shared/queries/workspace-user-list.tsindex 616a0343..6189f41b 100644--- a/apps/desktop/src/operations/queries/workspace-user-list.ts+++ b/apps/desktop/src/shared/queries/workspace-user-list.ts@@ -7,7 +7,7 @@ export type WorkspaceUserListQueryInput = {count: number;};-declare module '@/operations/queries' {+declare module '@/shared/queries' {interface QueryMap {workspace_user_list: {input: WorkspaceUserListQueryInput;diff --git a/apps/desktop/src/types/accounts.ts b/apps/desktop/src/shared/types/accounts.tssimilarity index 100%rename from apps/desktop/src/types/accounts.tsrename to apps/desktop/src/shared/types/accounts.tsdiff --git a/apps/desktop/src/types/databases.ts b/apps/desktop/src/shared/types/databases.tssimilarity index 100%rename from apps/desktop/src/types/databases.tsrename to apps/desktop/src/shared/types/databases.tsdiff --git a/apps/desktop/src/types/editor.ts b/apps/desktop/src/shared/types/editor.tssimilarity index 100%rename from apps/desktop/src/types/editor.tsrename to apps/desktop/src/shared/types/editor.tsdiff --git a/apps/desktop/src/types/emojis.ts b/apps/desktop/src/shared/types/emojis.tssimilarity index 100%rename from apps/desktop/src/types/emojis.tsrename to apps/desktop/src/shared/types/emojis.tsdiff --git a/apps/desktop/src/types/errors.ts b/apps/desktop/src/shared/types/errors.tssimilarity index 100%rename from apps/desktop/src/types/errors.tsrename to apps/desktop/src/shared/types/errors.tsdiff --git a/apps/desktop/src/shared/types/events.ts b/apps/desktop/src/shared/types/events.tsnew file mode 100644index 00000000..50d15000--- /dev/null+++ b/apps/desktop/src/shared/types/events.ts@@ -0,0 +1,126 @@+import { Node } from '@colanode/core';+import { Account } from '@/shared/types/accounts';+import { Workspace } from '@/shared/types/workspaces';+import { Server } from '@/shared/types/servers';+import { Download, Upload, UserNode } from '@/shared/types/nodes';++export type NodeCreatedEvent = {+ type: 'node_created';+ userId: string;+ node: Node;+};++export type NodeUpdatedEvent = {+ type: 'node_updated';+ userId: string;+ node: Node;+};++export type NodeDeletedEvent = {+ type: 'node_deleted';+ userId: string;+ node: Node;+};++export type AccountCreatedEvent = {+ type: 'account_created';+ account: Account;+};++export type AccountUpdatedEvent = {+ type: 'account_updated';+ account: Account;+};++export type AccountDeletedEvent = {+ type: 'account_deleted';+ account: Account;+};++export type WorkspaceCreatedEvent = {+ type: 'workspace_created';+ workspace: Workspace;+};++export type WorkspaceUpdatedEvent = {+ type: 'workspace_updated';+ workspace: Workspace;+};++export type WorkspaceDeletedEvent = {+ type: 'workspace_deleted';+ workspace: Workspace;+};++export type ServerCreatedEvent = {+ type: 'server_created';+ server: Server;+};++export type UserNodeCreatedEvent = {+ type: 'user_node_created';+ userId: string;+ userNode: UserNode;+};++export type DownloadCreatedEvent = {+ type: 'download_created';+ userId: string;+ download: Download;+};++export type DownloadUpdatedEvent = {+ type: 'download_updated';+ userId: string;+ download: Download;+};++export type DownloadDeletedEvent = {+ type: 'download_deleted';+ userId: string;+ download: Download;+};++export type UploadCreatedEvent = {+ type: 'upload_created';+ userId: string;+ upload: Upload;+};++export type UploadUpdatedEvent = {+ type: 'upload_updated';+ userId: string;+ upload: Upload;+};++export type UploadDeletedEvent = {+ type: 'upload_deleted';+ userId: string;+ upload: Upload;+};++export type QueryResultUpdatedEvent = {+ type: 'query_result_updated';+ id: string;+ result: any;+};++export type Event =+ | NodeCreatedEvent+ | NodeUpdatedEvent+ | NodeDeletedEvent+ | AccountCreatedEvent+ | AccountUpdatedEvent+ | AccountDeletedEvent+ | WorkspaceCreatedEvent+ | WorkspaceUpdatedEvent+ | WorkspaceDeletedEvent+ | ServerCreatedEvent+ | UserNodeCreatedEvent+ | DownloadCreatedEvent+ | DownloadUpdatedEvent+ | DownloadDeletedEvent+ | UploadCreatedEvent+ | UploadUpdatedEvent+ | UploadDeletedEvent+ | QueryResultUpdatedEvent;diff --git a/apps/desktop/src/types/files.ts b/apps/desktop/src/shared/types/files.tssimilarity index 100%rename from apps/desktop/src/types/files.tsrename to apps/desktop/src/shared/types/files.tsdiff --git a/apps/desktop/src/types/folders.ts b/apps/desktop/src/shared/types/folders.tssimilarity index 100%rename from apps/desktop/src/types/folders.tsrename to apps/desktop/src/shared/types/folders.tsdiff --git a/apps/desktop/src/types/icons.ts b/apps/desktop/src/shared/types/icons.tssimilarity index 100%rename from apps/desktop/src/types/icons.tsrename to apps/desktop/src/shared/types/icons.tsdiff --git a/apps/desktop/src/types/messages.ts b/apps/desktop/src/shared/types/messages.tssimilarity index 100%rename from apps/desktop/src/types/messages.tsrename to apps/desktop/src/shared/types/messages.tsdiff --git a/apps/desktop/src/shared/types/nodes.ts b/apps/desktop/src/shared/types/nodes.tsnew file mode 100644index 00000000..a5af6ba3--- /dev/null+++ b/apps/desktop/src/shared/types/nodes.ts@@ -0,0 +1,35 @@+import { NodeRole } from '@colanode/core';++export type NodeCollaborator = {+ nodeId: string;+ collaboratorId: string;+ role: NodeRole;+};++export type UserNode = {+ userId: string;+ nodeId: string;+ lastSeenAt: string | null;+ lastSeenVersionId: string | null;+ mentionsCount: number;+ attributes: string | null;+ versionId: string;+ createdAt: string;+ updatedAt: string | null;+};++export type Download = {+ nodeId: string;+ createdAt: string;+ updatedAt: string | null;+ progress: number;+ retryCount: number;+};++export type Upload = {+ nodeId: string;+ createdAt: string;+ updatedAt: string | null;+ progress: number;+ retryCount: number;+};diff --git a/apps/desktop/src/shared/types/radars.ts b/apps/desktop/src/shared/types/radars.tsnew file mode 100644index 00000000..0cdd2b32--- /dev/null+++ b/apps/desktop/src/shared/types/radars.ts@@ -0,0 +1,53 @@+export type ChannelReadState = {+ type: 'channel';+ nodeId: string;+ unseenMessagesCount: number;+ mentionsCount: number;+};++export type ChatReadState = {+ type: 'chat';+ nodeId: string;+ unseenMessagesCount: number;+ mentionsCount: number;+};++export type DatabaseReadState = {+ type: 'database';+ nodeId: string;+ unseenRecordsCount: number;+};++export type RecordReadState = {+ type: 'record';+ nodeId: string;+ hasUnseenChanges: boolean;+ mentionsCount: number;+};++export type PageState = {+ type: 'page';+ nodeId: string;+ hasUnseenChanges: boolean;+ mentionsCount: number;+};++export type FolderState = {+ type: 'folder';+ nodeId: string;+ unseenFilesCount: number;+};++export type WorkspaceReadState = {+ importantCount: number;+ hasUnseenChanges: boolean;+ nodeStates: Record<string, ReadState>;+};++export type ReadState =+ | ChannelReadState+ | ChatReadState+ | DatabaseReadState+ | RecordReadState+ | PageState+ | FolderState;diff --git a/apps/desktop/src/types/servers.ts b/apps/desktop/src/shared/types/servers.tssimilarity index 100%rename from apps/desktop/src/types/servers.tsrename to apps/desktop/src/shared/types/servers.tsdiff --git a/apps/desktop/src/types/sync.ts b/apps/desktop/src/shared/types/sync.tssimilarity index 100%rename from apps/desktop/src/types/sync.tsrename to apps/desktop/src/shared/types/sync.tsdiff --git a/apps/desktop/src/types/workspaces.ts b/apps/desktop/src/shared/types/workspaces.tssimilarity index 100%rename from apps/desktop/src/types/workspaces.tsrename to apps/desktop/src/shared/types/workspaces.tsdiff --git a/apps/desktop/src/types/nodes.ts b/apps/desktop/src/types/nodes.tsdeleted file mode 100644index 5ab2d9d6..00000000--- a/apps/desktop/src/types/nodes.ts+++ /dev/null@@ -1,7 +0,0 @@-import { NodeRole } from '@colanode/core';--export type NodeCollaborator = {- nodeId: string;- collaboratorId: string;- role: NodeRole;-};diff --git a/apps/desktop/tsconfig.node.json b/apps/desktop/tsconfig.node.jsonindex fbbf388a..f73af61b 100644--- a/apps/desktop/tsconfig.node.json+++ b/apps/desktop/tsconfig.node.json@@ -4,17 +4,13 @@"electron.vite.config.*","src/main/**/*","src/preload/**/*",- "src/lib/**/*",- "src/operations/**/*",- "src/types/**/*"+ "src/shared/**/*"],"compilerOptions": {"composite": true,"types": ["electron-vite/node"],"paths": {- "@/lib/*": ["./src/lib/*"],- "@/operations/*": ["./src/operations/*"],- "@/types/*": ["./src/types/*"],+ "@/shared/*": ["./src/shared/*"],"@/main/*": ["./src/main/*"]}}diff --git a/apps/desktop/tsconfig.web.json b/apps/desktop/tsconfig.web.jsonindex f39a22e4..0b3a1b30 100644--- a/apps/desktop/tsconfig.web.json+++ b/apps/desktop/tsconfig.web.json@@ -4,18 +4,14 @@"src/renderer/env.d.ts","src/renderer/**/*","src/preload/*.d.ts",- "src/operations/**/*",- "src/types/**/*",- "src/lib/**/*"+ "src/shared/**/*"],"compilerOptions": {"composite": true,"jsx": "react-jsx","paths": {"@/renderer/*": ["./src/renderer/*"],- "@/lib/*": ["./src/lib/*"],- "@/operations/*": ["./src/operations/*"],- "@/types/*": ["./src/types/*"]+ "@/shared/*": ["./src/shared/*"]}}}