Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Restructure mutations

Hakan Shehua9c99043a915
diff --git a/apps/desktop/src/main/mutations/account-logout.ts b/apps/desktop/src/main/mutations/accounts/account-logout.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/account-logout.ts
rename to apps/desktop/src/main/mutations/accounts/account-logout.ts
index b4bff472..3f3ad278 100644
--- a/apps/desktop/src/main/mutations/account-logout.ts
+++ b/apps/desktop/src/main/mutations/accounts/account-logout.ts
@@ -4,7 +4,7 @@ import { MutationHandler } from '@/main/types';
import {
AccountLogoutMutationInput,
AccountLogoutMutationOutput,
-} from '@/shared/mutations/account-logout';
+} from '@/shared/mutations/accounts/account-logout';
export class AccountLogoutMutationHandler
implements MutationHandler<AccountLogoutMutationInput>
diff --git a/apps/desktop/src/main/mutations/account-update.ts b/apps/desktop/src/main/mutations/accounts/account-update.ts
similarity index 97%
rename from apps/desktop/src/main/mutations/account-update.ts
rename to apps/desktop/src/main/mutations/accounts/account-update.ts
index 3ee1c1a5..af28290a 100644
--- a/apps/desktop/src/main/mutations/account-update.ts
+++ b/apps/desktop/src/main/mutations/accounts/account-update.ts
@@ -7,7 +7,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
AccountUpdateMutationInput,
AccountUpdateMutationOutput,
-} from '@/shared/mutations/account-update';
+} from '@/shared/mutations/accounts/account-update';
export class AccountUpdateMutationHandler
implements MutationHandler<AccountUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/email-login.ts b/apps/desktop/src/main/mutations/accounts/email-login.ts
similarity index 98%
rename from apps/desktop/src/main/mutations/email-login.ts
rename to apps/desktop/src/main/mutations/accounts/email-login.ts
index 5eee0de3..d64399ce 100644
--- a/apps/desktop/src/main/mutations/email-login.ts
+++ b/apps/desktop/src/main/mutations/accounts/email-login.ts
@@ -7,7 +7,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
EmailLoginMutationInput,
EmailLoginMutationOutput,
-} from '@/shared/mutations/email-login';
+} from '@/shared/mutations/accounts/email-login';
import { Account } from '@/shared/types/accounts';
export class EmailLoginMutationHandler
diff --git a/apps/desktop/src/main/mutations/email-register.ts b/apps/desktop/src/main/mutations/accounts/email-register.ts
similarity index 98%
rename from apps/desktop/src/main/mutations/email-register.ts
rename to apps/desktop/src/main/mutations/accounts/email-register.ts
index 0f77258c..dc134296 100644
--- a/apps/desktop/src/main/mutations/email-register.ts
+++ b/apps/desktop/src/main/mutations/accounts/email-register.ts
@@ -7,7 +7,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
EmailRegisterMutationInput,
EmailRegisterMutationOutput,
-} from '@/shared/mutations/email-register';
+} from '@/shared/mutations/accounts/email-register';
import { Account } from '@/shared/types/accounts';
export class EmailRegisterMutationHandler
diff --git a/apps/desktop/src/main/mutations/avatar-upload.ts b/apps/desktop/src/main/mutations/avatars/avatar-upload.ts
similarity index 96%
rename from apps/desktop/src/main/mutations/avatar-upload.ts
rename to apps/desktop/src/main/mutations/avatars/avatar-upload.ts
index 8a6940f3..45bdd081 100644
--- a/apps/desktop/src/main/mutations/avatar-upload.ts
+++ b/apps/desktop/src/main/mutations/avatars/avatar-upload.ts
@@ -8,7 +8,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
AvatarUploadMutationInput,
AvatarUploadMutationOutput,
-} from '@/shared/mutations/avatar-upload';
+} from '@/shared/mutations/avatars/avatar-upload';
interface AvatarUploadResponse {
id: string;
diff --git a/apps/desktop/src/main/mutations/channel-create.ts b/apps/desktop/src/main/mutations/channels/channel-create.ts
similarity index 89%
rename from apps/desktop/src/main/mutations/channel-create.ts
rename to apps/desktop/src/main/mutations/channels/channel-create.ts
index 30cec7a3..d01ddaf7 100644
--- a/apps/desktop/src/main/mutations/channel-create.ts
+++ b/apps/desktop/src/main/mutations/channels/channel-create.ts
@@ -1,4 +1,4 @@
-import { ChannelAttributes,generateId, IdType } from '@colanode/core';
+import { ChannelAttributes, generateId, IdType } from '@colanode/core';
import { databaseService } from '@/main/data/database-service';
import { nodeService } from '@/main/services/node-service';
@@ -6,7 +6,7 @@ import { MutationHandler } from '@/main/types';
import {
ChannelCreateMutationInput,
ChannelCreateMutationOutput,
-} from '@/shared/mutations/channel-create';
+} from '@/shared/mutations/channels/channel-create';
export class ChannelCreateMutationHandler
implements MutationHandler<ChannelCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/channels/channel-delete.ts b/apps/desktop/src/main/mutations/channels/channel-delete.ts
new file mode 100644
index 00000000..21865e0b
--- /dev/null
+++ b/apps/desktop/src/main/mutations/channels/channel-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ ChannelDeleteMutationInput,
+ ChannelDeleteMutationOutput,
+} from '@/shared/mutations/channels/channel-delete';
+
+export class ChannelDeleteMutationHandler
+ implements MutationHandler<ChannelDeleteMutationInput>
+{
+ async handleMutation(
+ input: ChannelDeleteMutationInput
+ ): Promise<ChannelDeleteMutationOutput> {
+ await nodeService.deleteNode(input.channelId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/channel-update.ts b/apps/desktop/src/main/mutations/channels/channel-update.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/channel-update.ts
rename to apps/desktop/src/main/mutations/channels/channel-update.ts
index 4805c72c..09dfe463 100644
--- a/apps/desktop/src/main/mutations/channel-update.ts
+++ b/apps/desktop/src/main/mutations/channels/channel-update.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
ChannelUpdateMutationInput,
ChannelUpdateMutationOutput,
-} from '@/shared/mutations/channel-update';
+} from '@/shared/mutations/channels/channel-update';
export class ChannelUpdateMutationHandler
implements MutationHandler<ChannelUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/chat-create.ts b/apps/desktop/src/main/mutations/chats/chat-create.ts
similarity index 92%
rename from apps/desktop/src/main/mutations/chat-create.ts
rename to apps/desktop/src/main/mutations/chats/chat-create.ts
index 9dc26353..ff9f11a7 100644
--- a/apps/desktop/src/main/mutations/chat-create.ts
+++ b/apps/desktop/src/main/mutations/chats/chat-create.ts
@@ -1,4 +1,4 @@
-import { ChatAttributes,generateId, IdType, NodeTypes } from '@colanode/core';
+import { ChatAttributes, generateId, IdType, NodeTypes } from '@colanode/core';
import { sql } from 'kysely';
import { databaseService } from '@/main/data/database-service';
@@ -7,7 +7,7 @@ import { MutationHandler } from '@/main/types';
import {
ChatCreateMutationInput,
ChatCreateMutationOutput,
-} from '@/shared/mutations/chat-create';
+} from '@/shared/mutations/chats/chat-create';
interface ChatRow {
id: string;
diff --git a/apps/desktop/src/main/mutations/node-collaborator-create.ts b/apps/desktop/src/main/mutations/collaborators/node-collaborator-create.ts
similarity index 91%
rename from apps/desktop/src/main/mutations/node-collaborator-create.ts
rename to apps/desktop/src/main/mutations/collaborators/node-collaborator-create.ts
index 6177beb9..76978370 100644
--- a/apps/desktop/src/main/mutations/node-collaborator-create.ts
+++ b/apps/desktop/src/main/mutations/collaborators/node-collaborator-create.ts
@@ -5,7 +5,7 @@ import { MutationHandler } from '@/main/types';
import {
NodeCollaboratorCreateMutationInput,
NodeCollaboratorCreateMutationOutput,
-} from '@/shared/mutations/node-collaborator-create';
+} from '@/shared/mutations/collaborators/node-collaborator-create';
export class NodeCollaboratorCreateMutationHandler
implements MutationHandler<NodeCollaboratorCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/node-collaborator-delete.ts b/apps/desktop/src/main/mutations/collaborators/node-collaborator-delete.ts
similarity index 91%
rename from apps/desktop/src/main/mutations/node-collaborator-delete.ts
rename to apps/desktop/src/main/mutations/collaborators/node-collaborator-delete.ts
index 7676543b..1f510736 100644
--- a/apps/desktop/src/main/mutations/node-collaborator-delete.ts
+++ b/apps/desktop/src/main/mutations/collaborators/node-collaborator-delete.ts
@@ -5,7 +5,7 @@ import { MutationHandler } from '@/main/types';
import {
NodeCollaboratorDeleteMutationInput,
NodeCollaboratorDeleteMutationOutput,
-} from '@/shared/mutations/node-collaborator-delete';
+} from '@/shared/mutations/collaborators/node-collaborator-delete';
export class NodeCollaboratorDeleteMutationHandler
implements MutationHandler<NodeCollaboratorDeleteMutationInput>
diff --git a/apps/desktop/src/main/mutations/node-collaborator-update.ts b/apps/desktop/src/main/mutations/collaborators/node-collaborator-update.ts
similarity index 91%
rename from apps/desktop/src/main/mutations/node-collaborator-update.ts
rename to apps/desktop/src/main/mutations/collaborators/node-collaborator-update.ts
index 9e5d0ddd..f0136b63 100644
--- a/apps/desktop/src/main/mutations/node-collaborator-update.ts
+++ b/apps/desktop/src/main/mutations/collaborators/node-collaborator-update.ts
@@ -5,7 +5,7 @@ import { MutationHandler } from '@/main/types';
import {
NodeCollaboratorUpdateMutationInput,
NodeCollaboratorUpdateMutationOutput,
-} from '@/shared/mutations/node-collaborator-update';
+} from '@/shared/mutations/collaborators/node-collaborator-update';
export class NodeCollaboratorUpdateMutationHandler
implements MutationHandler<NodeCollaboratorUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/database-create.ts b/apps/desktop/src/main/mutations/databases/database-create.ts
similarity index 96%
rename from apps/desktop/src/main/mutations/database-create.ts
rename to apps/desktop/src/main/mutations/databases/database-create.ts
index 3860d169..b7c45a5c 100644
--- a/apps/desktop/src/main/mutations/database-create.ts
+++ b/apps/desktop/src/main/mutations/databases/database-create.ts
@@ -10,7 +10,7 @@ import { MutationHandler } from '@/main/types';
import {
DatabaseCreateMutationInput,
DatabaseCreateMutationOutput,
-} from '@/shared/mutations/database-create';
+} from '@/shared/mutations/databases/database-create';
export class DatabaseCreateMutationHandler
implements MutationHandler<DatabaseCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/databases/database-delete.ts b/apps/desktop/src/main/mutations/databases/database-delete.ts
new file mode 100644
index 00000000..545dc142
--- /dev/null
+++ b/apps/desktop/src/main/mutations/databases/database-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ DatabaseDeleteMutationInput,
+ DatabaseDeleteMutationOutput,
+} from '@/shared/mutations/databases/database-delete';
+
+export class DatabaseDeleteMutationHandler
+ implements MutationHandler<DatabaseDeleteMutationInput>
+{
+ async handleMutation(
+ input: DatabaseDeleteMutationInput
+ ): Promise<DatabaseDeleteMutationOutput> {
+ await nodeService.deleteNode(input.databaseId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/database-update.ts b/apps/desktop/src/main/mutations/databases/database-update.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/database-update.ts
rename to apps/desktop/src/main/mutations/databases/database-update.ts
index 9a0228ba..0af934b2 100644
--- a/apps/desktop/src/main/mutations/database-update.ts
+++ b/apps/desktop/src/main/mutations/databases/database-update.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
DatabaseUpdateMutationInput,
DatabaseUpdateMutationOutput,
-} from '@/shared/mutations/database-update';
+} from '@/shared/mutations/databases/database-update';
export class DatabaseUpdateMutationHandler
implements MutationHandler<DatabaseUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/field-create.ts b/apps/desktop/src/main/mutations/databases/field-create.ts
similarity index 95%
rename from apps/desktop/src/main/mutations/field-create.ts
rename to apps/desktop/src/main/mutations/databases/field-create.ts
index 715e781b..16d35b3d 100644
--- a/apps/desktop/src/main/mutations/field-create.ts
+++ b/apps/desktop/src/main/mutations/databases/field-create.ts
@@ -10,7 +10,7 @@ import { MutationHandler } from '@/main/types';
import {
FieldCreateMutationInput,
FieldCreateMutationOutput,
-} from '@/shared/mutations/field-create';
+} from '@/shared/mutations/databases/field-create';
export class FieldCreateMutationHandler
implements MutationHandler<FieldCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/databases/field-delete.ts b/apps/desktop/src/main/mutations/databases/field-delete.ts
new file mode 100644
index 00000000..9cdaca21
--- /dev/null
+++ b/apps/desktop/src/main/mutations/databases/field-delete.ts
@@ -0,0 +1,32 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ FieldDeleteMutationInput,
+ FieldDeleteMutationOutput,
+} from '@/shared/mutations/databases/field-delete';
+
+export class FieldDeleteMutationHandler
+ implements MutationHandler<FieldDeleteMutationInput>
+{
+ async handleMutation(
+ input: FieldDeleteMutationInput
+ ): Promise<FieldDeleteMutationOutput> {
+ await nodeService.updateNode(
+ input.databaseId,
+ input.userId,
+ (attributes) => {
+ if (attributes.type !== 'database') {
+ throw new Error('Invalid node type');
+ }
+
+ delete attributes.fields[input.fieldId];
+
+ return attributes;
+ }
+ );
+
+ return {
+ id: input.fieldId,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/databases/field-name-update.ts b/apps/desktop/src/main/mutations/databases/field-name-update.ts
new file mode 100644
index 00000000..32abd34b
--- /dev/null
+++ b/apps/desktop/src/main/mutations/databases/field-name-update.ts
@@ -0,0 +1,36 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ FieldNameUpdateMutationInput,
+ FieldNameUpdateMutationOutput,
+} from '@/shared/mutations/databases/field-name-update';
+
+export class FieldNameUpdateMutationHandler
+ implements MutationHandler<FieldNameUpdateMutationInput>
+{
+ async handleMutation(
+ input: FieldNameUpdateMutationInput
+ ): Promise<FieldNameUpdateMutationOutput> {
+ await nodeService.updateNode(
+ input.databaseId,
+ input.userId,
+ (attributes) => {
+ if (attributes.type !== 'database') {
+ throw new Error('Invalid node type');
+ }
+
+ const field = attributes.fields[input.fieldId];
+ if (!field) {
+ throw new Error('Field not found');
+ }
+
+ field.name = input.name;
+ return attributes;
+ }
+ );
+
+ return {
+ id: input.fieldId,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/select-option-create.ts b/apps/desktop/src/main/mutations/databases/select-option-create.ts
similarity index 96%
rename from apps/desktop/src/main/mutations/select-option-create.ts
rename to apps/desktop/src/main/mutations/databases/select-option-create.ts
index 5c012106..7d17bb0b 100644
--- a/apps/desktop/src/main/mutations/select-option-create.ts
+++ b/apps/desktop/src/main/mutations/databases/select-option-create.ts
@@ -10,7 +10,7 @@ import { MutationHandler } from '@/main/types';
import {
SelectOptionCreateMutationInput,
SelectOptionCreateMutationOutput,
-} from '@/shared/mutations/select-option-create';
+} from '@/shared/mutations/databases/select-option-create';
export class SelectOptionCreateMutationHandler
implements MutationHandler<SelectOptionCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/databases/select-option-delete.ts b/apps/desktop/src/main/mutations/databases/select-option-delete.ts
new file mode 100644
index 00000000..63f9bd24
--- /dev/null
+++ b/apps/desktop/src/main/mutations/databases/select-option-delete.ts
@@ -0,0 +1,45 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ SelectOptionDeleteMutationInput,
+ SelectOptionDeleteMutationOutput,
+} from '@/shared/mutations/databases/select-option-delete';
+
+export class SelectOptionDeleteMutationHandler
+ implements MutationHandler<SelectOptionDeleteMutationInput>
+{
+ async handleMutation(
+ input: SelectOptionDeleteMutationInput
+ ): Promise<SelectOptionDeleteMutationOutput> {
+ await nodeService.updateNode(
+ input.databaseId,
+ input.userId,
+ (attributes) => {
+ if (attributes.type !== 'database') {
+ throw new Error('Node is not a database');
+ }
+
+ const field = attributes.fields[input.fieldId];
+ if (!field) {
+ throw new Error('Field not found');
+ }
+
+ if (field.type !== 'select' && field.type !== 'multiSelect') {
+ throw new Error('Field is not a select');
+ }
+
+ if (!field.options) {
+ field.options = {};
+ }
+
+ delete field.options[input.optionId];
+
+ return attributes;
+ }
+ );
+
+ return {
+ id: input.optionId,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/databases/select-option-update.ts b/apps/desktop/src/main/mutations/databases/select-option-update.ts
new file mode 100644
index 00000000..5c35f60e
--- /dev/null
+++ b/apps/desktop/src/main/mutations/databases/select-option-update.ts
@@ -0,0 +1,50 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ SelectOptionUpdateMutationInput,
+ SelectOptionUpdateMutationOutput,
+} from '@/shared/mutations/databases/select-option-update';
+
+export class SelectOptionUpdateMutationHandler
+ implements MutationHandler<SelectOptionUpdateMutationInput>
+{
+ async handleMutation(
+ input: SelectOptionUpdateMutationInput
+ ): Promise<SelectOptionUpdateMutationOutput> {
+ await nodeService.updateNode(
+ input.databaseId,
+ input.userId,
+ (attributes) => {
+ if (attributes.type !== 'database') {
+ throw new Error('Node is not a database');
+ }
+
+ const field = attributes.fields[input.fieldId];
+ if (!field) {
+ throw new Error('Field not found');
+ }
+
+ if (field.type !== 'select' && field.type !== 'multiSelect') {
+ throw new Error('Field is not a select');
+ }
+
+ if (!field.options) {
+ field.options = {};
+ }
+
+ const option = field.options[input.optionId];
+ if (!option) {
+ throw new Error('Option not found');
+ }
+
+ option.name = input.name;
+ option.color = input.color;
+ return attributes;
+ }
+ );
+
+ return {
+ id: input.optionId,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/view-create.ts b/apps/desktop/src/main/mutations/databases/view-create.ts
similarity index 96%
rename from apps/desktop/src/main/mutations/view-create.ts
rename to apps/desktop/src/main/mutations/databases/view-create.ts
index 6f497975..a3a12fc7 100644
--- a/apps/desktop/src/main/mutations/view-create.ts
+++ b/apps/desktop/src/main/mutations/databases/view-create.ts
@@ -10,7 +10,7 @@ import { MutationHandler } from '@/main/types';
import {
ViewCreateMutationInput,
ViewCreateMutationOutput,
-} from '@/shared/mutations/view-create';
+} from '@/shared/mutations/databases/view-create';
export class ViewCreateMutationHandler
implements MutationHandler<ViewCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/view-delete.ts b/apps/desktop/src/main/mutations/databases/view-delete.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/view-delete.ts
rename to apps/desktop/src/main/mutations/databases/view-delete.ts
index 51ba138a..8ade17bb 100644
--- a/apps/desktop/src/main/mutations/view-delete.ts
+++ b/apps/desktop/src/main/mutations/databases/view-delete.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
ViewDeleteMutationInput,
ViewDeleteMutationOutput,
-} from '@/shared/mutations/view-delete';
+} from '@/shared/mutations/databases/view-delete';
export class ViewDeleteMutationHandler
implements MutationHandler<ViewDeleteMutationInput>
diff --git a/apps/desktop/src/main/mutations/databases/view-name-update.ts b/apps/desktop/src/main/mutations/databases/view-name-update.ts
new file mode 100644
index 00000000..53e4ee71
--- /dev/null
+++ b/apps/desktop/src/main/mutations/databases/view-name-update.ts
@@ -0,0 +1,36 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ ViewNameUpdateMutationInput,
+ ViewNameUpdateMutationOutput,
+} from '@/shared/mutations/databases/view-name-update';
+
+export class ViewNameUpdateMutationHandler
+ implements MutationHandler<ViewNameUpdateMutationInput>
+{
+ async handleMutation(
+ input: ViewNameUpdateMutationInput
+ ): Promise<ViewNameUpdateMutationOutput> {
+ await nodeService.updateNode(
+ input.databaseId,
+ input.userId,
+ (attributes) => {
+ if (attributes.type !== 'database') {
+ throw new Error('Invalid node type');
+ }
+
+ const view = attributes.views[input.viewId];
+ if (!view) {
+ throw new Error('View not found');
+ }
+
+ view.name = input.name;
+ return attributes;
+ }
+ );
+
+ return {
+ id: input.viewId,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/view-update.ts b/apps/desktop/src/main/mutations/databases/view-update.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/view-update.ts
rename to apps/desktop/src/main/mutations/databases/view-update.ts
index 2e17c27e..63bb875b 100644
--- a/apps/desktop/src/main/mutations/view-update.ts
+++ b/apps/desktop/src/main/mutations/databases/view-update.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
ViewUpdateMutationInput,
ViewUpdateMutationOutput,
-} from '@/shared/mutations/view-update';
+} from '@/shared/mutations/databases/view-update';
export class ViewUpdateMutationHandler
implements MutationHandler<ViewUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/document-save.ts b/apps/desktop/src/main/mutations/document-save.ts
deleted file mode 100644
index 15c3d82c..00000000
--- a/apps/desktop/src/main/mutations/document-save.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { Block } from '@colanode/core';
-
-import { nodeService } from '@/main/services/node-service';
-import { MutationHandler } from '@/main/types';
-import { mapContentsToBlocks } from '@/shared/lib/editor';
-import {
- DocumentSaveMutationInput,
- DocumentSaveMutationOutput,
-} from '@/shared/mutations/document-save';
-
-export class DocumentSaveMutationHandler
- implements MutationHandler<DocumentSaveMutationInput>
-{
- async handleMutation(
- input: DocumentSaveMutationInput
- ): Promise<DocumentSaveMutationOutput> {
- await nodeService.updateNode(
- input.documentId,
- input.userId,
- (attributes) => {
- if (attributes.type !== 'page' && attributes.type !== 'record') {
- throw new Error('Invalid node type');
- }
-
- const blocksMap = new Map<string, Block>();
- if (attributes.content) {
- for (const [key, value] of Object.entries(attributes.content)) {
- blocksMap.set(key, value);
- }
- }
-
- const blocks = mapContentsToBlocks(
- input.documentId,
- input.content.content ?? [],
- blocksMap
- );
-
- attributes.content = blocks.reduce(
- (acc, block) => {
- acc[block.id] = block;
- return acc;
- },
- {} as Record<string, Block>
- );
-
- return attributes;
- }
- );
-
- return {
- success: true,
- };
- }
-}
diff --git a/apps/desktop/src/main/mutations/file-create.ts b/apps/desktop/src/main/mutations/files/file-create.ts
similarity index 97%
rename from apps/desktop/src/main/mutations/file-create.ts
rename to apps/desktop/src/main/mutations/files/file-create.ts
index 57c3c047..c81ddd5e 100644
--- a/apps/desktop/src/main/mutations/file-create.ts
+++ b/apps/desktop/src/main/mutations/files/file-create.ts
@@ -11,7 +11,7 @@ import { MutationHandler } from '@/main/types';
import {
FileCreateMutationInput,
FileCreateMutationOutput,
-} from '@/shared/mutations/file-create';
+} from '@/shared/mutations/files/file-create';
export class FileCreateMutationHandler
implements MutationHandler<FileCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/files/file-delete.ts b/apps/desktop/src/main/mutations/files/file-delete.ts
new file mode 100644
index 00000000..f8aea54e
--- /dev/null
+++ b/apps/desktop/src/main/mutations/files/file-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ FileDeleteMutationInput,
+ FileDeleteMutationOutput,
+} from '@/shared/mutations/files/file-delete';
+
+export class FileDeleteMutationHandler
+ implements MutationHandler<FileDeleteMutationInput>
+{
+ async handleMutation(
+ input: FileDeleteMutationInput
+ ): Promise<FileDeleteMutationOutput> {
+ await nodeService.deleteNode(input.fileId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/file-download.ts b/apps/desktop/src/main/mutations/files/file-download.ts
similarity index 97%
rename from apps/desktop/src/main/mutations/file-download.ts
rename to apps/desktop/src/main/mutations/files/file-download.ts
index 7dc99db2..0ea1f684 100644
--- a/apps/desktop/src/main/mutations/file-download.ts
+++ b/apps/desktop/src/main/mutations/files/file-download.ts
@@ -5,7 +5,7 @@ import { eventBus } from '@/shared/lib/event-bus';
import {
FileDownloadMutationInput,
FileDownloadMutationOutput,
-} from '@/shared/mutations/file-download';
+} from '@/shared/mutations/files/file-download';
export class FileDownloadMutationHandler
implements MutationHandler<FileDownloadMutationInput>
diff --git a/apps/desktop/src/main/mutations/folder-create.ts b/apps/desktop/src/main/mutations/folders/folder-create.ts
similarity index 85%
rename from apps/desktop/src/main/mutations/folder-create.ts
rename to apps/desktop/src/main/mutations/folders/folder-create.ts
index 06742074..b060e8e0 100644
--- a/apps/desktop/src/main/mutations/folder-create.ts
+++ b/apps/desktop/src/main/mutations/folders/folder-create.ts
@@ -1,11 +1,11 @@
-import { FolderAttributes,generateId, IdType } from '@colanode/core';
+import { FolderAttributes, generateId, IdType } from '@colanode/core';
import { nodeService } from '@/main/services/node-service';
import { MutationHandler } from '@/main/types';
import {
FolderCreateMutationInput,
FolderCreateMutationOutput,
-} from '@/shared/mutations/folder-create';
+} from '@/shared/mutations/folders/folder-create';
export class FolderCreateMutationHandler
implements MutationHandler<FolderCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/folders/folder-delete.ts b/apps/desktop/src/main/mutations/folders/folder-delete.ts
new file mode 100644
index 00000000..55956958
--- /dev/null
+++ b/apps/desktop/src/main/mutations/folders/folder-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ FolderDeleteMutationInput,
+ FolderDeleteMutationOutput,
+} from '@/shared/mutations/folders/folder-delete';
+
+export class FolderDeleteMutationHandler
+ implements MutationHandler<FolderDeleteMutationInput>
+{
+ async handleMutation(
+ input: FolderDeleteMutationInput
+ ): Promise<FolderDeleteMutationOutput> {
+ await nodeService.deleteNode(input.folderId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/folder-update.ts b/apps/desktop/src/main/mutations/folders/folder-update.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/folder-update.ts
rename to apps/desktop/src/main/mutations/folders/folder-update.ts
index cad72397..0f2c5aac 100644
--- a/apps/desktop/src/main/mutations/folder-update.ts
+++ b/apps/desktop/src/main/mutations/folders/folder-update.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
FolderUpdateMutationInput,
FolderUpdateMutationOutput,
-} from '@/shared/mutations/folder-update';
+} from '@/shared/mutations/folders/folder-update';
export class FolderUpdateMutationHandler
implements MutationHandler<FolderUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/index.ts b/apps/desktop/src/main/mutations/index.ts
index 800cef54..a53dd62f 100644
--- a/apps/desktop/src/main/mutations/index.ts
+++ b/apps/desktop/src/main/mutations/index.ts
@@ -1,43 +1,58 @@
-import { AccountLogoutMutationHandler } from '@/main/mutations/account-logout';
-import { AccountUpdateMutationHandler } from '@/main/mutations/account-update';
-import { AvatarUploadMutationHandler } from '@/main/mutations/avatar-upload';
-import { ChannelCreateMutationHandler } from '@/main/mutations/channel-create';
-import { ChannelUpdateMutationHandler } from '@/main/mutations/channel-update';
-import { ChatCreateMutationHandler } from '@/main/mutations/chat-create';
-import { DatabaseCreateMutationHandler } from '@/main/mutations/database-create';
-import { DatabaseUpdateMutationHandler } from '@/main/mutations/database-update';
-import { DocumentSaveMutationHandler } from '@/main/mutations/document-save';
-import { EmailLoginMutationHandler } from '@/main/mutations/email-login';
-import { EmailRegisterMutationHandler } from '@/main/mutations/email-register';
-import { FieldCreateMutationHandler } from '@/main/mutations/field-create';
-import { FileCreateMutationHandler } from '@/main/mutations/file-create';
-import { FileDownloadMutationHandler } from '@/main/mutations/file-download';
-import { FolderCreateMutationHandler } from '@/main/mutations/folder-create';
-import { FolderUpdateMutationHandler } from '@/main/mutations/folder-update';
-import { MarkNodeAsSeenMutationHandler } from '@/main/mutations/mark-node-as-seen';
-import { MessageCreateMutationHandler } from '@/main/mutations/message-create';
-import { NodeAttributeDeleteMutationHandler } from '@/main/mutations/node-attribute-delete';
-import { NodeAttributeSetMutationHandler } from '@/main/mutations/node-attribute-set';
-import { NodeCollaboratorCreateMutationHandler } from '@/main/mutations/node-collaborator-create';
-import { NodeCollaboratorDeleteMutationHandler } from '@/main/mutations/node-collaborator-delete';
-import { NodeCollaboratorUpdateMutationHandler } from '@/main/mutations/node-collaborator-update';
-import { NodeDeleteMutationHandler } from '@/main/mutations/node-delete';
-import { NodeReactionCreateMutationHandler } from '@/main/mutations/node-reaction-create';
-import { NodeReactionDeleteMutationHandler } from '@/main/mutations/node-reaction-delete';
-import { PageCreateMutationHandler } from '@/main/mutations/page-create';
-import { PageUpdateMutationHandler } from '@/main/mutations/page-update';
-import { RecordCreateMutationHandler } from '@/main/mutations/record-create';
-import { SelectOptionCreateMutationHandler } from '@/main/mutations/select-option-create';
-import { ServerCreateMutationHandler } from '@/main/mutations/server-create';
-import { SpaceCreateMutationHandler } from '@/main/mutations/space-create';
-import { SpaceUpdateMutationHandler } from '@/main/mutations/space-update';
-import { ViewCreateMutationHandler } from '@/main/mutations/view-create';
-import { ViewDeleteMutationHandler } from '@/main/mutations/view-delete';
-import { ViewUpdateMutationHandler } from '@/main/mutations/view-update';
-import { WorkspaceCreateMutationHandler } from '@/main/mutations/workspace-create';
-import { WorkspaceUpdateMutationHandler } from '@/main/mutations/workspace-update';
-import { WorkspaceUserRoleUpdateMutationHandler } from '@/main/mutations/workspace-user-role-update';
-import { WorkspaceUsersInviteMutationHandler } from '@/main/mutations/workspace-users-invite';
+import { PageContentUpdateMutationHandler } from '@/main/mutations/pages/page-content-update';
+import { RecordContentUpdateMutationHandler } from '@/main/mutations/records/record-content-update';
+import { AccountLogoutMutationHandler } from '@/main/mutations/accounts/account-logout';
+import { AccountUpdateMutationHandler } from '@/main/mutations/accounts/account-update';
+import { AvatarUploadMutationHandler } from '@/main/mutations/avatars/avatar-upload';
+import { ChannelCreateMutationHandler } from '@/main/mutations/channels/channel-create';
+import { ChannelUpdateMutationHandler } from '@/main/mutations/channels/channel-update';
+import { ChannelDeleteMutationHandler } from '@/main/mutations/channels/channel-delete';
+import { ChatCreateMutationHandler } from '@/main/mutations/chats/chat-create';
+import { DatabaseCreateMutationHandler } from '@/main/mutations/databases/database-create';
+import { DatabaseUpdateMutationHandler } from '@/main/mutations/databases/database-update';
+import { DatabaseDeleteMutationHandler } from '@/main/mutations/databases/database-delete';
+import { EmailLoginMutationHandler } from '@/main/mutations/accounts/email-login';
+import { EmailRegisterMutationHandler } from '@/main/mutations/accounts/email-register';
+import { FieldCreateMutationHandler } from '@/main/mutations/databases/field-create';
+import { FieldDeleteMutationHandler } from '@/main/mutations/databases/field-delete';
+import { FieldNameUpdateMutationHandler } from '@/main/mutations/databases/field-name-update';
+import { FileCreateMutationHandler } from '@/main/mutations/files/file-create';
+import { FileDeleteMutationHandler } from '@/main/mutations/files/file-delete';
+import { FileDownloadMutationHandler } from '@/main/mutations/files/file-download';
+import { FolderCreateMutationHandler } from '@/main/mutations/folders/folder-create';
+import { FolderUpdateMutationHandler } from '@/main/mutations/folders/folder-update';
+import { FolderDeleteMutationHandler } from '@/main/mutations/folders/folder-delete';
+import { MarkNodeAsSeenMutationHandler } from '@/main/mutations/interactions/mark-node-as-seen';
+import { MessageCreateMutationHandler } from '@/main/mutations/messages/message-create';
+import { MessageDeleteMutationHandler } from '@/main/mutations/messages/message-delete';
+import { NodeCollaboratorCreateMutationHandler } from '@/main/mutations/collaborators/node-collaborator-create';
+import { NodeCollaboratorDeleteMutationHandler } from '@/main/mutations/collaborators/node-collaborator-delete';
+import { NodeCollaboratorUpdateMutationHandler } from '@/main/mutations/collaborators/node-collaborator-update';
+import { MessageReactionCreateMutationHandler } from '@/main/mutations/messages/message-reaction-create';
+import { MessageReactionDeleteMutationHandler } from '@/main/mutations/messages/message-reaction-delete';
+import { PageCreateMutationHandler } from '@/main/mutations/pages/page-create';
+import { PageUpdateMutationHandler } from '@/main/mutations/pages/page-update';
+import { PageDeleteMutationHandler } from '@/main/mutations/pages/page-delete';
+import { RecordAvatarUpdateMutationHandler } from '@/main/mutations/records/record-avatar-update';
+import { RecordCreateMutationHandler } from '@/main/mutations/records/record-create';
+import { RecordDeleteMutationHandler } from '@/main/mutations/records/record-delete';
+import { RecordFieldValueDeleteMutationHandler } from '@/main/mutations/records/record-field-value-delete';
+import { RecordNameUpdateMutationHandler } from '@/main/mutations/records/record-name-update';
+import { RecordFieldValueSetMutationHandler } from '@/main/mutations/records/record-field-value-set';
+import { SelectOptionCreateMutationHandler } from '@/main/mutations/databases/select-option-create';
+import { SelectOptionDeleteMutationHandler } from '@/main/mutations/databases/select-option-delete';
+import { SelectOptionUpdateMutationHandler } from '@/main/mutations/databases/select-option-update';
+import { ServerCreateMutationHandler } from '@/main/mutations/servers/server-create';
+import { SpaceCreateMutationHandler } from '@/main/mutations/spaces/space-create';
+import { SpaceDeleteMutationHandler } from '@/main/mutations/spaces/space-delete';
+import { SpaceUpdateMutationHandler } from '@/main/mutations/spaces/space-update';
+import { ViewCreateMutationHandler } from '@/main/mutations/databases/view-create';
+import { ViewDeleteMutationHandler } from '@/main/mutations/databases/view-delete';
+import { ViewUpdateMutationHandler } from '@/main/mutations/databases/view-update';
+import { ViewNameUpdateMutationHandler } from '@/main/mutations/databases/view-name-update';
+import { WorkspaceCreateMutationHandler } from '@/main/mutations/workspaces/workspace-create';
+import { WorkspaceUpdateMutationHandler } from '@/main/mutations/workspaces/workspace-update';
+import { WorkspaceUserRoleUpdateMutationHandler } from '@/main/mutations/workspaces/workspace-user-role-update';
+import { WorkspaceUsersInviteMutationHandler } from '@/main/mutations/workspaces/workspace-users-invite';
import { MutationHandler } from '@/main/types';
import { MutationMap } from '@/shared/mutations';
@@ -50,28 +65,42 @@ export const mutationHandlerMap: MutationHandlerMap = {
email_register: new EmailRegisterMutationHandler(),
view_create: new ViewCreateMutationHandler(),
channel_create: new ChannelCreateMutationHandler(),
+ channel_delete: new ChannelDeleteMutationHandler(),
chat_create: new ChatCreateMutationHandler(),
database_create: new DatabaseCreateMutationHandler(),
+ database_delete: new DatabaseDeleteMutationHandler(),
field_create: new FieldCreateMutationHandler(),
+ field_delete: new FieldDeleteMutationHandler(),
+ field_name_update: new FieldNameUpdateMutationHandler(),
message_create: new MessageCreateMutationHandler(),
- node_attribute_delete: new NodeAttributeDeleteMutationHandler(),
- node_attribute_set: new NodeAttributeSetMutationHandler(),
+ file_delete: new FileDeleteMutationHandler(),
+ folder_delete: new FolderDeleteMutationHandler(),
node_collaborator_create: new NodeCollaboratorCreateMutationHandler(),
node_collaborator_delete: new NodeCollaboratorDeleteMutationHandler(),
node_collaborator_update: new NodeCollaboratorUpdateMutationHandler(),
- node_delete: new NodeDeleteMutationHandler(),
page_create: new PageCreateMutationHandler(),
- node_reaction_create: new NodeReactionCreateMutationHandler(),
- node_reaction_delete: new NodeReactionDeleteMutationHandler(),
+ page_delete: new PageDeleteMutationHandler(),
+ page_content_update: new PageContentUpdateMutationHandler(),
+ message_reaction_create: new MessageReactionCreateMutationHandler(),
+ message_reaction_delete: new MessageReactionDeleteMutationHandler(),
+ message_delete: new MessageDeleteMutationHandler(),
record_create: new RecordCreateMutationHandler(),
+ record_delete: new RecordDeleteMutationHandler(),
+ record_content_update: new RecordContentUpdateMutationHandler(),
+ record_avatar_update: new RecordAvatarUpdateMutationHandler(),
+ record_name_update: new RecordNameUpdateMutationHandler(),
+ record_field_value_delete: new RecordFieldValueDeleteMutationHandler(),
+ record_field_value_set: new RecordFieldValueSetMutationHandler(),
select_option_create: new SelectOptionCreateMutationHandler(),
+ select_option_delete: new SelectOptionDeleteMutationHandler(),
+ select_option_update: new SelectOptionUpdateMutationHandler(),
server_create: new ServerCreateMutationHandler(),
space_create: new SpaceCreateMutationHandler(),
+ space_delete: new SpaceDeleteMutationHandler(),
workspace_user_role_update: new WorkspaceUserRoleUpdateMutationHandler(),
workspace_users_invite: new WorkspaceUsersInviteMutationHandler(),
workspace_create: new WorkspaceCreateMutationHandler(),
workspace_update: new WorkspaceUpdateMutationHandler(),
- document_save: new DocumentSaveMutationHandler(),
avatar_upload: new AvatarUploadMutationHandler(),
account_logout: new AccountLogoutMutationHandler(),
folder_create: new FolderCreateMutationHandler(),
@@ -82,6 +111,7 @@ export const mutationHandlerMap: MutationHandlerMap = {
mark_node_as_seen: new MarkNodeAsSeenMutationHandler(),
view_update: new ViewUpdateMutationHandler(),
view_delete: new ViewDeleteMutationHandler(),
+ view_name_update: new ViewNameUpdateMutationHandler(),
channel_update: new ChannelUpdateMutationHandler(),
page_update: new PageUpdateMutationHandler(),
folder_update: new FolderUpdateMutationHandler(),
diff --git a/apps/desktop/src/main/mutations/mark-node-as-seen.ts b/apps/desktop/src/main/mutations/interactions/mark-node-as-seen.ts
similarity index 91%
rename from apps/desktop/src/main/mutations/mark-node-as-seen.ts
rename to apps/desktop/src/main/mutations/interactions/mark-node-as-seen.ts
index deb72c60..a1453018 100644
--- a/apps/desktop/src/main/mutations/mark-node-as-seen.ts
+++ b/apps/desktop/src/main/mutations/interactions/mark-node-as-seen.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
MarkNodeAsSeenMutationInput,
MarkNodeAsSeenMutationOutput,
-} from '@/shared/mutations/mark-node-as-seen';
+} from '@/shared/mutations/interactions/mark-node-as-seen';
export class MarkNodeAsSeenMutationHandler
implements MutationHandler<MarkNodeAsSeenMutationInput>
diff --git a/apps/desktop/src/main/mutations/message-create.ts b/apps/desktop/src/main/mutations/messages/message-create.ts
similarity index 98%
rename from apps/desktop/src/main/mutations/message-create.ts
rename to apps/desktop/src/main/mutations/messages/message-create.ts
index 01957121..250eb4d1 100644
--- a/apps/desktop/src/main/mutations/message-create.ts
+++ b/apps/desktop/src/main/mutations/messages/message-create.ts
@@ -16,7 +16,7 @@ import { mapContentsToBlocks } from '@/shared/lib/editor';
import {
MessageCreateMutationInput,
MessageCreateMutationOutput,
-} from '@/shared/mutations/message-create';
+} from '@/shared/mutations/messages/message-create';
export class MessageCreateMutationHandler
implements MutationHandler<MessageCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/messages/message-delete.ts b/apps/desktop/src/main/mutations/messages/message-delete.ts
new file mode 100644
index 00000000..13c39dda
--- /dev/null
+++ b/apps/desktop/src/main/mutations/messages/message-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ MessageDeleteMutationInput,
+ MessageDeleteMutationOutput,
+} from '@/shared/mutations/messages/message-delete';
+
+export class MessageDeleteMutationHandler
+ implements MutationHandler<MessageDeleteMutationInput>
+{
+ async handleMutation(
+ input: MessageDeleteMutationInput
+ ): Promise<MessageDeleteMutationOutput> {
+ await nodeService.deleteNode(input.messageId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/messages/message-reaction-create.ts b/apps/desktop/src/main/mutations/messages/message-reaction-create.ts
new file mode 100644
index 00000000..d55c1d72
--- /dev/null
+++ b/apps/desktop/src/main/mutations/messages/message-reaction-create.ts
@@ -0,0 +1,37 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ MessageReactionCreateMutationInput,
+ MessageReactionCreateMutationOutput,
+} from '@/shared/mutations/messages/message-reaction-create';
+
+export class MessageReactionCreateMutationHandler
+ implements MutationHandler<MessageReactionCreateMutationInput>
+{
+ async handleMutation(
+ input: MessageReactionCreateMutationInput
+ ): Promise<MessageReactionCreateMutationOutput> {
+ await nodeService.updateNode(
+ input.messageId,
+ input.userId,
+ (attributes) => {
+ if (attributes.type !== 'message') {
+ throw new Error('Node is not a message');
+ }
+
+ const reactionsUsers = attributes.reactions[input.reaction] ?? [];
+ if (reactionsUsers.includes(input.userId)) {
+ return attributes;
+ }
+
+ reactionsUsers.push(input.userId);
+ attributes.reactions[input.reaction] = reactionsUsers;
+ return attributes;
+ }
+ );
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/messages/message-reaction-delete.ts b/apps/desktop/src/main/mutations/messages/message-reaction-delete.ts
new file mode 100644
index 00000000..38678f08
--- /dev/null
+++ b/apps/desktop/src/main/mutations/messages/message-reaction-delete.ts
@@ -0,0 +1,42 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ MessageReactionDeleteMutationInput,
+ MessageReactionDeleteMutationOutput,
+} from '@/shared/mutations/messages/message-reaction-delete';
+
+export class MessageReactionDeleteMutationHandler
+ implements MutationHandler<MessageReactionDeleteMutationInput>
+{
+ async handleMutation(
+ input: MessageReactionDeleteMutationInput
+ ): Promise<MessageReactionDeleteMutationOutput> {
+ await nodeService.updateNode(
+ input.messageId,
+ input.userId,
+ (attributes) => {
+ if (attributes.type !== 'message') {
+ throw new Error('Node is not a message');
+ }
+
+ const reactionUsers = attributes.reactions[input.reaction] ?? [];
+ if (!reactionUsers.includes(input.userId)) {
+ return attributes;
+ }
+
+ const index = reactionUsers.indexOf(input.userId);
+ if (index === -1) {
+ return attributes;
+ }
+
+ reactionUsers.splice(index, 1);
+ attributes.reactions[input.reaction] = reactionUsers;
+ return attributes;
+ }
+ );
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/node-attribute-delete.ts b/apps/desktop/src/main/mutations/node-attribute-delete.ts
deleted file mode 100644
index c8d101aa..00000000
--- a/apps/desktop/src/main/mutations/node-attribute-delete.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { unset } from 'lodash-es';
-
-import { nodeService } from '@/main/services/node-service';
-import { MutationHandler } from '@/main/types';
-import {
- NodeAttributeDeleteMutationInput,
- NodeAttributeDeleteMutationOutput,
-} from '@/shared/mutations/node-attribute-delete';
-
-export class NodeAttributeDeleteMutationHandler
- implements MutationHandler<NodeAttributeDeleteMutationInput>
-{
- async handleMutation(
- input: NodeAttributeDeleteMutationInput
- ): Promise<NodeAttributeDeleteMutationOutput> {
- await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {
- unset(attributes, input.path);
- return attributes;
- });
-
- return {
- success: true,
- };
- }
-}
diff --git a/apps/desktop/src/main/mutations/node-attribute-set.ts b/apps/desktop/src/main/mutations/node-attribute-set.ts
deleted file mode 100644
index 36ee6501..00000000
--- a/apps/desktop/src/main/mutations/node-attribute-set.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { set } from 'lodash-es';
-
-import { nodeService } from '@/main/services/node-service';
-import { MutationHandler } from '@/main/types';
-import {
- NodeAttributeSetMutationInput,
- NodeAttributeSetMutationOutput,
-} from '@/shared/mutations/node-attribute-set';
-
-export class NodeAttributeSetMutationHandler
- implements MutationHandler<NodeAttributeSetMutationInput>
-{
- async handleMutation(
- input: NodeAttributeSetMutationInput
- ): Promise<NodeAttributeSetMutationOutput> {
- await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {
- set(attributes, input.path, input.value);
- return attributes;
- });
-
- return {
- success: true,
- };
- }
-}
diff --git a/apps/desktop/src/main/mutations/node-delete.ts b/apps/desktop/src/main/mutations/node-delete.ts
deleted file mode 100644
index 68e84b24..00000000
--- a/apps/desktop/src/main/mutations/node-delete.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { nodeService } from '@/main/services/node-service';
-import { MutationHandler } from '@/main/types';
-import {
- NodeDeleteMutationInput,
- NodeDeleteMutationOutput,
-} from '@/shared/mutations/node-delete';
-
-export class NodeDeleteMutationHandler
- implements MutationHandler<NodeDeleteMutationInput>
-{
- async handleMutation(
- input: NodeDeleteMutationInput
- ): Promise<NodeDeleteMutationOutput> {
- await nodeService.deleteNode(input.nodeId, input.userId);
-
- return {
- success: true,
- };
- }
-}
diff --git a/apps/desktop/src/main/mutations/node-reaction-create.ts b/apps/desktop/src/main/mutations/node-reaction-create.ts
deleted file mode 100644
index fb8b2fa7..00000000
--- a/apps/desktop/src/main/mutations/node-reaction-create.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { nodeService } from '@/main/services/node-service';
-import { MutationHandler } from '@/main/types';
-import {
- NodeReactionCreateMutationInput,
- NodeReactionCreateMutationOutput,
-} from '@/shared/mutations/node-reaction-create';
-
-export class NodeReactionCreateMutationHandler
- implements MutationHandler<NodeReactionCreateMutationInput>
-{
- async handleMutation(
- input: NodeReactionCreateMutationInput
- ): Promise<NodeReactionCreateMutationOutput> {
- await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {
- if (attributes.type !== 'message') {
- throw new Error('Node is not a message');
- }
-
- const reactionsUsers = attributes.reactions[input.reaction] ?? [];
- if (reactionsUsers.includes(input.userId)) {
- return attributes;
- }
-
- reactionsUsers.push(input.userId);
- attributes.reactions[input.reaction] = reactionsUsers;
- return attributes;
- });
-
- return {
- success: true,
- };
- }
-}
diff --git a/apps/desktop/src/main/mutations/node-reaction-delete.ts b/apps/desktop/src/main/mutations/node-reaction-delete.ts
deleted file mode 100644
index fefaa0cd..00000000
--- a/apps/desktop/src/main/mutations/node-reaction-delete.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { nodeService } from '@/main/services/node-service';
-import { MutationHandler } from '@/main/types';
-import {
- NodeReactionDeleteMutationInput,
- NodeReactionDeleteMutationOutput,
-} from '@/shared/mutations/node-reaction-delete';
-
-export class NodeReactionDeleteMutationHandler
- implements MutationHandler<NodeReactionDeleteMutationInput>
-{
- async handleMutation(
- input: NodeReactionDeleteMutationInput
- ): Promise<NodeReactionDeleteMutationOutput> {
- await nodeService.updateNode(input.nodeId, input.userId, (attributes) => {
- if (attributes.type !== 'message') {
- throw new Error('Node is not a message');
- }
-
- const reactionUsers = attributes.reactions[input.reaction] ?? [];
- if (!reactionUsers.includes(input.userId)) {
- return attributes;
- }
-
- const index = reactionUsers.indexOf(input.userId);
- if (index === -1) {
- return attributes;
- }
-
- reactionUsers.splice(index, 1);
- attributes.reactions[input.reaction] = reactionUsers;
- return attributes;
- });
-
- return {
- success: true,
- };
- }
-}
diff --git a/apps/desktop/src/main/mutations/pages/page-content-update.ts b/apps/desktop/src/main/mutations/pages/page-content-update.ts
new file mode 100644
index 00000000..90021b39
--- /dev/null
+++ b/apps/desktop/src/main/mutations/pages/page-content-update.ts
@@ -0,0 +1,50 @@
+import { Block } from '@colanode/core';
+
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import { mapContentsToBlocks } from '@/shared/lib/editor';
+import {
+ PageContentUpdateMutationInput,
+ PageContentUpdateMutationOutput,
+} from '@/shared/mutations/pages/page-content-update';
+
+export class PageContentUpdateMutationHandler
+ implements MutationHandler<PageContentUpdateMutationInput>
+{
+ async handleMutation(
+ input: PageContentUpdateMutationInput
+ ): Promise<PageContentUpdateMutationOutput> {
+ await nodeService.updateNode(input.pageId, input.userId, (attributes) => {
+ if (attributes.type !== 'page') {
+ throw new Error('Invalid node type');
+ }
+
+ const blocksMap = new Map<string, Block>();
+ if (attributes.content) {
+ for (const [key, value] of Object.entries(attributes.content)) {
+ blocksMap.set(key, value);
+ }
+ }
+
+ const blocks = mapContentsToBlocks(
+ input.pageId,
+ input.content.content ?? [],
+ blocksMap
+ );
+
+ attributes.content = blocks.reduce(
+ (acc, block) => {
+ acc[block.id] = block;
+ return acc;
+ },
+ {} as Record<string, Block>
+ );
+
+ return attributes;
+ });
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/page-create.ts b/apps/desktop/src/main/mutations/pages/page-create.ts
similarity index 94%
rename from apps/desktop/src/main/mutations/page-create.ts
rename to apps/desktop/src/main/mutations/pages/page-create.ts
index ae812364..3e89fe4a 100644
--- a/apps/desktop/src/main/mutations/page-create.ts
+++ b/apps/desktop/src/main/mutations/pages/page-create.ts
@@ -5,7 +5,7 @@ import { MutationHandler } from '@/main/types';
import {
PageCreateMutationInput,
PageCreateMutationOutput,
-} from '@/shared/mutations/page-create';
+} from '@/shared/mutations/pages/page-create';
export class PageCreateMutationHandler
implements MutationHandler<PageCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/pages/page-delete.ts b/apps/desktop/src/main/mutations/pages/page-delete.ts
new file mode 100644
index 00000000..68fc789a
--- /dev/null
+++ b/apps/desktop/src/main/mutations/pages/page-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ PageDeleteMutationInput,
+ PageDeleteMutationOutput,
+} from '@/shared/mutations/pages/page-delete';
+
+export class PageDeleteMutationHandler
+ implements MutationHandler<PageDeleteMutationInput>
+{
+ async handleMutation(
+ input: PageDeleteMutationInput
+ ): Promise<PageDeleteMutationOutput> {
+ await nodeService.deleteNode(input.pageId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/page-update.ts b/apps/desktop/src/main/mutations/pages/page-update.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/page-update.ts
rename to apps/desktop/src/main/mutations/pages/page-update.ts
index 3139a90c..8557057c 100644
--- a/apps/desktop/src/main/mutations/page-update.ts
+++ b/apps/desktop/src/main/mutations/pages/page-update.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
PageUpdateMutationInput,
PageUpdateMutationOutput,
-} from '@/shared/mutations/page-update';
+} from '@/shared/mutations/pages/page-update';
export class PageUpdateMutationHandler
implements MutationHandler<PageUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/records/record-avatar-update.ts b/apps/desktop/src/main/mutations/records/record-avatar-update.ts
new file mode 100644
index 00000000..28f5f7e8
--- /dev/null
+++ b/apps/desktop/src/main/mutations/records/record-avatar-update.ts
@@ -0,0 +1,27 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ RecordAvatarUpdateMutationInput,
+ RecordAvatarUpdateMutationOutput,
+} from '@/shared/mutations/records/record-avatar-update';
+
+export class RecordAvatarUpdateMutationHandler
+ implements MutationHandler<RecordAvatarUpdateMutationInput>
+{
+ async handleMutation(
+ input: RecordAvatarUpdateMutationInput
+ ): Promise<RecordAvatarUpdateMutationOutput> {
+ await nodeService.updateNode(input.recordId, input.userId, (attributes) => {
+ if (attributes.type !== 'record') {
+ throw new Error('Invalid node type');
+ }
+
+ attributes.avatar = input.avatar;
+ return attributes;
+ });
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/records/record-content-update.ts b/apps/desktop/src/main/mutations/records/record-content-update.ts
new file mode 100644
index 00000000..ad578fc9
--- /dev/null
+++ b/apps/desktop/src/main/mutations/records/record-content-update.ts
@@ -0,0 +1,50 @@
+import { Block } from '@colanode/core';
+
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import { mapContentsToBlocks } from '@/shared/lib/editor';
+import {
+ RecordContentUpdateMutationInput,
+ RecordContentUpdateMutationOutput,
+} from '@/shared/mutations/records/record-content-update';
+
+export class RecordContentUpdateMutationHandler
+ implements MutationHandler<RecordContentUpdateMutationInput>
+{
+ async handleMutation(
+ input: RecordContentUpdateMutationInput
+ ): Promise<RecordContentUpdateMutationOutput> {
+ await nodeService.updateNode(input.recordId, input.userId, (attributes) => {
+ if (attributes.type !== 'record') {
+ throw new Error('Invalid node type');
+ }
+
+ const blocksMap = new Map<string, Block>();
+ if (attributes.content) {
+ for (const [key, value] of Object.entries(attributes.content)) {
+ blocksMap.set(key, value);
+ }
+ }
+
+ const blocks = mapContentsToBlocks(
+ input.recordId,
+ input.content.content ?? [],
+ blocksMap
+ );
+
+ attributes.content = blocks.reduce(
+ (acc, block) => {
+ acc[block.id] = block;
+ return acc;
+ },
+ {} as Record<string, Block>
+ );
+
+ return attributes;
+ });
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/record-create.ts b/apps/desktop/src/main/mutations/records/record-create.ts
similarity index 94%
rename from apps/desktop/src/main/mutations/record-create.ts
rename to apps/desktop/src/main/mutations/records/record-create.ts
index 31fb9516..e3a2e4c5 100644
--- a/apps/desktop/src/main/mutations/record-create.ts
+++ b/apps/desktop/src/main/mutations/records/record-create.ts
@@ -5,7 +5,7 @@ import { MutationHandler } from '@/main/types';
import {
RecordCreateMutationInput,
RecordCreateMutationOutput,
-} from '@/shared/mutations/record-create';
+} from '@/shared/mutations/records/record-create';
export class RecordCreateMutationHandler
implements MutationHandler<RecordCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/records/record-delete.ts b/apps/desktop/src/main/mutations/records/record-delete.ts
new file mode 100644
index 00000000..4a55667b
--- /dev/null
+++ b/apps/desktop/src/main/mutations/records/record-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ RecordDeleteMutationInput,
+ RecordDeleteMutationOutput,
+} from '@/shared/mutations/records/record-delete';
+
+export class RecordDeleteMutationHandler
+ implements MutationHandler<RecordDeleteMutationInput>
+{
+ async handleMutation(
+ input: RecordDeleteMutationInput
+ ): Promise<RecordDeleteMutationOutput> {
+ await nodeService.deleteNode(input.recordId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/records/record-field-value-delete.ts b/apps/desktop/src/main/mutations/records/record-field-value-delete.ts
new file mode 100644
index 00000000..633589c0
--- /dev/null
+++ b/apps/desktop/src/main/mutations/records/record-field-value-delete.ts
@@ -0,0 +1,27 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ RecordFieldValueDeleteMutationInput,
+ RecordFieldValueDeleteMutationOutput,
+} from '@/shared/mutations/records/record-field-value-delete';
+
+export class RecordFieldValueDeleteMutationHandler
+ implements MutationHandler<RecordFieldValueDeleteMutationInput>
+{
+ async handleMutation(
+ input: RecordFieldValueDeleteMutationInput
+ ): Promise<RecordFieldValueDeleteMutationOutput> {
+ await nodeService.updateNode(input.recordId, input.userId, (attributes) => {
+ if (attributes.type !== 'record') {
+ throw new Error('Invalid node type');
+ }
+
+ delete attributes.fields[input.fieldId];
+ return attributes;
+ });
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/records/record-field-value-set.ts b/apps/desktop/src/main/mutations/records/record-field-value-set.ts
new file mode 100644
index 00000000..209bbffa
--- /dev/null
+++ b/apps/desktop/src/main/mutations/records/record-field-value-set.ts
@@ -0,0 +1,27 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ RecordFieldValueSetMutationInput,
+ RecordFieldValueSetMutationOutput,
+} from '@/shared/mutations/records/record-field-value-set';
+
+export class RecordFieldValueSetMutationHandler
+ implements MutationHandler<RecordFieldValueSetMutationInput>
+{
+ async handleMutation(
+ input: RecordFieldValueSetMutationInput
+ ): Promise<RecordFieldValueSetMutationOutput> {
+ await nodeService.updateNode(input.recordId, input.userId, (attributes) => {
+ if (attributes.type !== 'record') {
+ throw new Error('Invalid node type');
+ }
+
+ attributes.fields[input.fieldId] = input.value;
+ return attributes;
+ });
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/records/record-name-update.ts b/apps/desktop/src/main/mutations/records/record-name-update.ts
new file mode 100644
index 00000000..8e441a3e
--- /dev/null
+++ b/apps/desktop/src/main/mutations/records/record-name-update.ts
@@ -0,0 +1,27 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ RecordNameUpdateMutationInput,
+ RecordNameUpdateMutationOutput,
+} from '@/shared/mutations/records/record-name-update';
+
+export class RecordNameUpdateMutationHandler
+ implements MutationHandler<RecordNameUpdateMutationInput>
+{
+ async handleMutation(
+ input: RecordNameUpdateMutationInput
+ ): Promise<RecordNameUpdateMutationOutput> {
+ await nodeService.updateNode(input.recordId, input.userId, (attributes) => {
+ if (attributes.type !== 'record') {
+ throw new Error('Invalid node type');
+ }
+
+ attributes.name = input.name;
+ return attributes;
+ });
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/server-create.ts b/apps/desktop/src/main/mutations/servers/server-create.ts
similarity index 96%
rename from apps/desktop/src/main/mutations/server-create.ts
rename to apps/desktop/src/main/mutations/servers/server-create.ts
index 8bcb94ba..e8f1b863 100644
--- a/apps/desktop/src/main/mutations/server-create.ts
+++ b/apps/desktop/src/main/mutations/servers/server-create.ts
@@ -5,7 +5,7 @@ import { eventBus } from '@/shared/lib/event-bus';
import {
ServerCreateMutationInput,
ServerCreateMutationOutput,
-} from '@/shared/mutations/server-create';
+} from '@/shared/mutations/servers/server-create';
export class ServerCreateMutationHandler
implements MutationHandler<ServerCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/space-create.ts b/apps/desktop/src/main/mutations/spaces/space-create.ts
similarity index 97%
rename from apps/desktop/src/main/mutations/space-create.ts
rename to apps/desktop/src/main/mutations/spaces/space-create.ts
index 91206f42..cd6134c3 100644
--- a/apps/desktop/src/main/mutations/space-create.ts
+++ b/apps/desktop/src/main/mutations/spaces/space-create.ts
@@ -12,7 +12,7 @@ import { MutationHandler } from '@/main/types';
import {
SpaceCreateMutationInput,
SpaceCreateMutationOutput,
-} from '@/shared/mutations/space-create';
+} from '@/shared/mutations/spaces/space-create';
export class SpaceCreateMutationHandler
implements MutationHandler<SpaceCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/spaces/space-delete.ts b/apps/desktop/src/main/mutations/spaces/space-delete.ts
new file mode 100644
index 00000000..626b1297
--- /dev/null
+++ b/apps/desktop/src/main/mutations/spaces/space-delete.ts
@@ -0,0 +1,20 @@
+import { nodeService } from '@/main/services/node-service';
+import { MutationHandler } from '@/main/types';
+import {
+ SpaceDeleteMutationInput,
+ SpaceDeleteMutationOutput,
+} from '@/shared/mutations/spaces/space-delete';
+
+export class SpaceDeleteMutationHandler
+ implements MutationHandler<SpaceDeleteMutationInput>
+{
+ async handleMutation(
+ input: SpaceDeleteMutationInput
+ ): Promise<SpaceDeleteMutationOutput> {
+ await nodeService.deleteNode(input.spaceId, input.userId);
+
+ return {
+ success: true,
+ };
+ }
+}
diff --git a/apps/desktop/src/main/mutations/space-update.ts b/apps/desktop/src/main/mutations/spaces/space-update.ts
similarity index 93%
rename from apps/desktop/src/main/mutations/space-update.ts
rename to apps/desktop/src/main/mutations/spaces/space-update.ts
index 4384080c..01a71d08 100644
--- a/apps/desktop/src/main/mutations/space-update.ts
+++ b/apps/desktop/src/main/mutations/spaces/space-update.ts
@@ -3,7 +3,7 @@ import { MutationHandler } from '@/main/types';
import {
SpaceUpdateMutationInput,
SpaceUpdateMutationOutput,
-} from '@/shared/mutations/space-update';
+} from '@/shared/mutations/spaces/space-update';
export class SpaceUpdateMutationHandler
implements MutationHandler<SpaceUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/workspace-create.ts b/apps/desktop/src/main/mutations/workspaces/workspace-create.ts
similarity index 97%
rename from apps/desktop/src/main/mutations/workspace-create.ts
rename to apps/desktop/src/main/mutations/workspaces/workspace-create.ts
index d1d5fa2f..b65f2cb9 100644
--- a/apps/desktop/src/main/mutations/workspace-create.ts
+++ b/apps/desktop/src/main/mutations/workspaces/workspace-create.ts
@@ -7,7 +7,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
WorkspaceCreateMutationInput,
WorkspaceCreateMutationOutput,
-} from '@/shared/mutations/workspace-create';
+} from '@/shared/mutations/workspaces/workspace-create';
export class WorkspaceCreateMutationHandler
implements MutationHandler<WorkspaceCreateMutationInput>
diff --git a/apps/desktop/src/main/mutations/workspace-update.ts b/apps/desktop/src/main/mutations/workspaces/workspace-update.ts
similarity index 97%
rename from apps/desktop/src/main/mutations/workspace-update.ts
rename to apps/desktop/src/main/mutations/workspaces/workspace-update.ts
index 56d791dd..7c073cbb 100644
--- a/apps/desktop/src/main/mutations/workspace-update.ts
+++ b/apps/desktop/src/main/mutations/workspaces/workspace-update.ts
@@ -5,7 +5,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
WorkspaceUpdateMutationInput,
WorkspaceUpdateMutationOutput,
-} from '@/shared/mutations/workspace-update';
+} from '@/shared/mutations/workspaces/workspace-update';
import { Workspace } from '@/shared/types/workspaces';
export class WorkspaceUpdateMutationHandler
diff --git a/apps/desktop/src/main/mutations/workspace-user-role-update.ts b/apps/desktop/src/main/mutations/workspaces/workspace-user-role-update.ts
similarity index 96%
rename from apps/desktop/src/main/mutations/workspace-user-role-update.ts
rename to apps/desktop/src/main/mutations/workspaces/workspace-user-role-update.ts
index 2b52f5a3..0a6ed6d8 100644
--- a/apps/desktop/src/main/mutations/workspace-user-role-update.ts
+++ b/apps/desktop/src/main/mutations/workspaces/workspace-user-role-update.ts
@@ -6,7 +6,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
WorkspaceUserRoleUpdateMutationInput,
WorkspaceUserRoleUpdateMutationOutput,
-} from '@/shared/mutations/workspace-user-role-update';
+} from '@/shared/mutations/workspaces/workspace-user-role-update';
export class WorkspaceUserRoleUpdateMutationHandler
implements MutationHandler<WorkspaceUserRoleUpdateMutationInput>
diff --git a/apps/desktop/src/main/mutations/workspace-users-invite.ts b/apps/desktop/src/main/mutations/workspaces/workspace-users-invite.ts
similarity index 96%
rename from apps/desktop/src/main/mutations/workspace-users-invite.ts
rename to apps/desktop/src/main/mutations/workspaces/workspace-users-invite.ts
index c49e0688..f743eedb 100644
--- a/apps/desktop/src/main/mutations/workspace-users-invite.ts
+++ b/apps/desktop/src/main/mutations/workspaces/workspace-users-invite.ts
@@ -6,7 +6,7 @@ import { httpClient } from '@/shared/lib/http-client';
import {
WorkspaceUsersInviteMutationInput,
WorkspaceUsersInviteMutationOutput,
-} from '@/shared/mutations/workspace-users-invite';
+} from '@/shared/mutations/workspaces/workspace-users-invite';
export class WorkspaceUsersInviteMutationHandler
implements MutationHandler<WorkspaceUsersInviteMutationInput>
diff --git a/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx b/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx
index 380fc43b..4acda462 100644
--- a/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/channels/channel-delete-dialog.tsx
@@ -45,8 +45,8 @@ export const ChannelDeleteDialog = ({
onClick={() => {
mutate({
input: {
- type: 'node_delete',
- nodeId,
+ type: 'channel_delete',
+ channelId: nodeId,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx b/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx
index 96eb1080..ec1bb0bd 100644
--- a/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/databases/database-delete-dialog.tsx
@@ -45,8 +45,8 @@ export const DatabaseDeleteDialog = ({
onClick={() => {
mutate({
input: {
- type: 'node_delete',
- nodeId,
+ type: 'database_delete',
+ databaseId: nodeId,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/databases/database.tsx b/apps/desktop/src/renderer/components/databases/database.tsx
index b6d06a10..2ef9efc3 100644
--- a/apps/desktop/src/renderer/components/databases/database.tsx
+++ b/apps/desktop/src/renderer/components/databases/database.tsx
@@ -55,10 +55,10 @@ export const Database = ({ database, role, children }: DatabaseProps) => {
mutate({
input: {
- type: 'node_attribute_set',
- nodeId: database.id,
- path: `fields.${id}.name`,
- value: name,
+ type: 'field_name_update',
+ databaseId: database.id,
+ fieldId: id,
+ name,
userId: workspace.userId,
},
});
@@ -70,9 +70,9 @@ export const Database = ({ database, role, children }: DatabaseProps) => {
mutate({
input: {
- type: 'node_attribute_delete',
- nodeId: database.id,
- path: `fields.${id}`,
+ type: 'field_delete',
+ databaseId: database.id,
+ fieldId: id,
userId: workspace.userId,
},
});
@@ -100,10 +100,12 @@ export const Database = ({ database, role, children }: DatabaseProps) => {
mutate({
input: {
- type: 'node_attribute_set',
- nodeId: database.id,
- path: `fields.${fieldId}.options.${attributes.id}`,
- value: attributes,
+ type: 'select_option_update',
+ databaseId: database.id,
+ fieldId,
+ optionId: attributes.id,
+ name: attributes.name,
+ color: attributes.color,
userId: workspace.userId,
},
});
@@ -115,9 +117,10 @@ export const Database = ({ database, role, children }: DatabaseProps) => {
mutate({
input: {
- type: 'node_attribute_delete',
- nodeId: database.id,
- path: `fields.${fieldId}.options.${optionId}`,
+ type: 'select_option_delete',
+ databaseId: database.id,
+ fieldId,
+ optionId,
userId: workspace.userId,
},
});
diff --git a/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx b/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx
index f7997341..cedb941b 100644
--- a/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/databases/fields/select-option-delete-dialog.tsx
@@ -8,22 +8,22 @@ import {
AlertDialogTitle,
} from '@/renderer/components/ui/alert-dialog';
import { Button } from '@/renderer/components/ui/button';
-import { useWorkspace } from '@/renderer/contexts/workspace';
-import { useMutation } from '@/renderer/hooks/use-mutation';
+import { useDatabase } from '@/renderer/contexts/database';
interface SelectOptionDeleteDialogProps {
- id: string;
+ fieldId: string;
+ optionId: string;
open: boolean;
onOpenChange: (open: boolean) => void;
}
export const SelectOptionDeleteDialog = ({
- id,
+ fieldId,
+ optionId,
open,
onOpenChange,
}: SelectOptionDeleteDialogProps) => {
- const workspace = useWorkspace();
- const { mutate, isPending } = useMutation();
+ const database = useDatabase();
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
@@ -41,15 +41,8 @@ export const SelectOptionDeleteDialog = ({
<AlertDialogCancel>Cancel</AlertDialogCancel>
<Button
variant="destructive"
- disabled={isPending}
onClick={() => {
- mutate({
- input: {
- type: 'node_delete',
- nodeId: id,
- userId: workspace.userId,
- },
- });
+ database.deleteSelectOption(fieldId, optionId);
}}
>
Delete
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.tsx
index 1a06536b..c633df5c 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
@@ -88,7 +88,8 @@ export const SelectOptionSettingsPopover = ({
<SelectOptionDeleteDialog
open={openDeleteDialog}
onOpenChange={setOpenDeleteDialog}
- id={option.id}
+ fieldId={fieldId}
+ optionId={option.id}
/>
</React.Fragment>
);
diff --git a/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx b/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx
index b8c75408..bacc2533 100644
--- a/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx
+++ b/apps/desktop/src/renderer/components/databases/tables/table-view-name-cell.tsx
@@ -62,10 +62,10 @@ export const TableViewNameCell = ({ record }: TableViewNameCellProps) => {
const handleSave = (newName: string) => {
mutate({
input: {
- type: 'node_attribute_set',
- nodeId: record.id,
- path: 'name',
- value: newName,
+ type: 'view_name_update',
+ databaseId: record.attributes.databaseId,
+ viewId: record.id,
+ name: newName,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/documents/document-editor.tsx b/apps/desktop/src/renderer/components/documents/document-editor.tsx
index a07f6ccc..ace4d8b1 100644
--- a/apps/desktop/src/renderer/components/documents/document-editor.tsx
+++ b/apps/desktop/src/renderer/components/documents/document-editor.tsx
@@ -1,6 +1,6 @@
import '@/renderer/styles/editor.css';
-import { EditorContent, JSONContent,useEditor } from '@tiptap/react';
+import { EditorContent, JSONContent, useEditor } from '@tiptap/react';
import { debounce } from 'lodash-es';
import React from 'react';
@@ -56,13 +56,13 @@ import {
UnderlineMark,
} from '@/renderer/editor/extensions';
import { EditorBubbleMenu } from '@/renderer/editor/menu/bubble-menu';
-import { useMutation } from '@/renderer/hooks/use-mutation';
interface DocumentEditorProps {
documentId: string;
content: JSONContent;
transactionId: string;
canEdit: boolean;
+ onUpdate: (content: JSONContent) => void;
}
export const DocumentEditor = ({
@@ -70,9 +70,9 @@ export const DocumentEditor = ({
content,
transactionId,
canEdit,
+ onUpdate,
}: DocumentEditorProps) => {
const workspace = useWorkspace();
- const { mutate } = useMutation();
const hasPendingChanges = React.useRef(false);
const transactionIdRef = React.useRef(transactionId);
@@ -80,16 +80,9 @@ export const DocumentEditor = ({
() =>
debounce((content: JSONContent) => {
hasPendingChanges.current = false;
- mutate({
- input: {
- type: 'document_save',
- documentId: documentId,
- userId: workspace.userId,
- content,
- },
- });
+ onUpdate(content);
}, 500),
- [mutate, documentId, workspace.userId]
+ [onUpdate]
);
const editor = useEditor(
diff --git a/apps/desktop/src/renderer/components/documents/document.tsx b/apps/desktop/src/renderer/components/documents/document.tsx
index a7c4b82f..9e29c0e9 100644
--- a/apps/desktop/src/renderer/components/documents/document.tsx
+++ b/apps/desktop/src/renderer/components/documents/document.tsx
@@ -1,4 +1,5 @@
import { Block } from '@colanode/core';
+import { JSONContent } from '@tiptap/core';
import { DocumentEditor } from '@/renderer/components/documents/document-editor';
import { mapBlocksToContents } from '@/shared/lib/editor';
@@ -8,6 +9,7 @@ interface DocumentProps {
content?: Record<string, Block> | null;
transactionId: string;
canEdit: boolean;
+ onUpdate: (content: JSONContent) => void;
}
export const Document = ({
@@ -15,6 +17,7 @@ export const Document = ({
content,
transactionId,
canEdit,
+ onUpdate,
}: DocumentProps) => {
const nodeBlocks = Object.values(content ?? {});
const contents = mapBlocksToContents(nodeId, nodeBlocks);
@@ -37,6 +40,7 @@ export const Document = ({
content={tiptapContent}
transactionId={transactionId}
canEdit={canEdit}
+ onUpdate={onUpdate}
/>
);
};
diff --git a/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx b/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx
index 04cace6e..4f6c6744 100644
--- a/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/files/file-delete-dialog.tsx
@@ -45,8 +45,8 @@ export const FileDeleteDialog = ({
onClick={() => {
mutate({
input: {
- type: 'node_delete',
- nodeId,
+ type: 'file_delete',
+ fileId: nodeId,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx b/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx
index 3f941897..6500cbc1 100644
--- a/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/folders/folder-delete-dialog.tsx
@@ -45,8 +45,8 @@ export const FolderDeleteDialog = ({
onClick={() => {
mutate({
input: {
- type: 'node_delete',
- nodeId,
+ type: 'folder_delete',
+ folderId: nodeId,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/messages/message-actions.tsx b/apps/desktop/src/renderer/components/messages/message-actions.tsx
index e015fc0e..b6e35c75 100644
--- a/apps/desktop/src/renderer/components/messages/message-actions.tsx
+++ b/apps/desktop/src/renderer/components/messages/message-actions.tsx
@@ -44,8 +44,8 @@ export const MessageActions = ({ message }: MessageActionsProps) => {
mutate({
input: {
- type: 'node_reaction_create',
- nodeId: message.id,
+ type: 'message_reaction_create',
+ messageId: message.id,
userId: workspace.userId,
reaction,
},
@@ -80,8 +80,8 @@ export const MessageActions = ({ message }: MessageActionsProps) => {
mutate({
input: {
- type: 'node_reaction_create',
- nodeId: message.id,
+ type: 'message_reaction_create',
+ messageId: message.id,
userId: workspace.userId,
reaction,
},
diff --git a/apps/desktop/src/renderer/components/messages/message-delete-button.tsx b/apps/desktop/src/renderer/components/messages/message-delete-button.tsx
index cde77e75..fbae52c2 100644
--- a/apps/desktop/src/renderer/components/messages/message-delete-button.tsx
+++ b/apps/desktop/src/renderer/components/messages/message-delete-button.tsx
@@ -48,8 +48,8 @@ export const MessageDeleteButton = ({ id }: MessageDeleteButtonProps) => {
onClick={() => {
mutate({
input: {
- type: 'node_delete',
- nodeId: id,
+ type: 'message_delete',
+ messageId: id,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/messages/message-reactions.tsx b/apps/desktop/src/renderer/components/messages/message-reactions.tsx
index 470ef2d7..832598f8 100644
--- a/apps/desktop/src/renderer/components/messages/message-reactions.tsx
+++ b/apps/desktop/src/renderer/components/messages/message-reactions.tsx
@@ -55,8 +55,8 @@ export const MessageReactions = ({ message }: MessageReactionsProps) => {
) {
mutate({
input: {
- type: 'node_reaction_delete',
- nodeId: message.id,
+ type: 'message_reaction_delete',
+ messageId: message.id,
userId: workspace.userId,
reaction: reaction.reaction,
},
@@ -64,8 +64,8 @@ export const MessageReactions = ({ message }: MessageReactionsProps) => {
} else {
mutate({
input: {
- type: 'node_reaction_create',
- nodeId: message.id,
+ type: 'message_reaction_create',
+ messageId: message.id,
userId: workspace.userId,
reaction: reaction.reaction,
},
diff --git a/apps/desktop/src/renderer/components/pages/page-body.tsx b/apps/desktop/src/renderer/components/pages/page-body.tsx
index bf54f5f0..ecdf5111 100644
--- a/apps/desktop/src/renderer/components/pages/page-body.tsx
+++ b/apps/desktop/src/renderer/components/pages/page-body.tsx
@@ -1,7 +1,11 @@
+import { useCallback } from 'react';
import { hasEditorAccess, NodeRole, PageNode } from '@colanode/core';
+import { JSONContent } from '@tiptap/core';
import { Document } from '@/renderer/components/documents/document';
import { ScrollArea } from '@/renderer/components/ui/scroll-area';
+import { useWorkspace } from '@/renderer/contexts/workspace';
+import { useMutation } from '@/renderer/hooks/use-mutation';
interface PageBodyProps {
page: PageNode;
@@ -9,8 +13,24 @@ interface PageBodyProps {
}
export const PageBody = ({ page, role }: PageBodyProps) => {
+ const workspace = useWorkspace();
+ const { mutate } = useMutation();
const canEdit = hasEditorAccess(role);
+ const handleUpdate = useCallback(
+ (content: JSONContent) => {
+ mutate({
+ input: {
+ type: 'page_content_update',
+ userId: workspace.userId,
+ pageId: page.id,
+ content,
+ },
+ });
+ },
+ [mutate, workspace.userId, page.id]
+ );
+
return (
<ScrollArea className="h-full max-h-full w-full overflow-y-auto px-10 pb-12">
<Document
@@ -18,6 +38,7 @@ export const PageBody = ({ page, role }: PageBodyProps) => {
content={page.attributes.content}
transactionId={page.transactionId}
canEdit={canEdit}
+ onUpdate={handleUpdate}
/>
</ScrollArea>
);
diff --git a/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx b/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx
index 26c9ea54..cc3c9a37 100644
--- a/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/pages/page-delete-dialog.tsx
@@ -45,8 +45,8 @@ export const PageDeleteDialog = ({
onClick={() => {
mutate({
input: {
- type: 'node_delete',
- nodeId,
+ type: 'page_delete',
+ pageId: nodeId,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/records/record-avatar.tsx b/apps/desktop/src/renderer/components/records/record-avatar.tsx
index 23642c9a..12f77d49 100644
--- a/apps/desktop/src/renderer/components/records/record-avatar.tsx
+++ b/apps/desktop/src/renderer/components/records/record-avatar.tsx
@@ -32,10 +32,9 @@ export const RecordAvatar = () => {
mutate({
input: {
- type: 'node_attribute_set',
- nodeId: record.id,
- path: 'avatar',
- value: avatar,
+ type: 'record_avatar_update',
+ recordId: record.id,
+ avatar,
userId: workspace.userId,
},
});
diff --git a/apps/desktop/src/renderer/components/records/record-body.tsx b/apps/desktop/src/renderer/components/records/record-body.tsx
index d5d064e7..eece384a 100644
--- a/apps/desktop/src/renderer/components/records/record-body.tsx
+++ b/apps/desktop/src/renderer/components/records/record-body.tsx
@@ -4,6 +4,8 @@ import {
NodeRole,
RecordNode,
} from '@colanode/core';
+import { JSONContent } from '@tiptap/core';
+import { useCallback } from 'react';
import { Database } from '@/renderer/components/databases/database';
import { Document } from '@/renderer/components/documents/document';
@@ -12,6 +14,7 @@ import { RecordProvider } from '@/renderer/components/records/record-provider';
import { ScrollArea } from '@/renderer/components/ui/scroll-area';
import { Separator } from '@/renderer/components/ui/separator';
import { useWorkspace } from '@/renderer/contexts/workspace';
+import { useMutation } from '@/renderer/hooks/use-mutation';
interface RecordBodyProps {
record: RecordNode;
@@ -27,9 +30,25 @@ export const RecordBody = ({
databaseRole,
}: RecordBodyProps) => {
const workspace = useWorkspace();
+ const { mutate } = useMutation();
+
const canEdit =
record.createdBy === workspace.userId || hasEditorAccess(recordRole);
+ const handleUpdate = useCallback(
+ (content: JSONContent) => {
+ mutate({
+ input: {
+ type: 'record_content_update',
+ userId: workspace.userId,
+ recordId: record.id,
+ content,
+ },
+ });
+ },
+ [mutate]
+ );
+
return (
<Database database={database} role={databaseRole}>
<ScrollArea className="h-full max-h-full w-full overflow-y-auto px-10 pb-12">
@@ -42,6 +61,7 @@ export const RecordBody = ({
content={record.attributes.content}
transactionId={record.transactionId}
canEdit={canEdit}
+ onUpdate={handleUpdate}
/>
</ScrollArea>
</Database>
diff --git a/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx b/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx
index 7fbbf13c..d7b038d0 100644
--- a/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx
+++ b/apps/desktop/src/renderer/components/records/record-delete-dialog.tsx
@@ -45,8 +45,8 @@ export const RecordDeleteDialog = ({
onClick={() => {
mutate({
input: {
- type: 'node_delete',
- nodeId,
+ type: 'record_delete',
+ recordId: nodeId,
userId: workspace.userId,
},
onSuccess() {
diff --git a/apps/desktop/src/renderer/components/records/record-name.tsx b/apps/desktop/src/renderer/components/records/record-name.tsx
index 5b499711..9337d1b3 100644
--- a/apps/desktop/src/renderer/components/records/record-name.tsx
+++ b/apps/desktop/src/renderer/components/records/record-name.tsx
@@ -23,10 +23,9 @@ export const RecordName = () => {
mutate({
input: {
- type: 'node_attribute_set',
- nodeId: record.id,
- path: 'name',
- value: value,
+ type: 'record_name_update',
+ recordId: record.id,
+ name: value,
userId: workspace.userId,
},
});
diff --git a/apps/desktop/src/renderer/components/records/record-provider.tsx b/apps/desktop/src/renderer/components/records/record-provider.tsx
index 7abde45a..50ebe471 100644
--- a/apps/desktop/src/renderer/components/records/record-provider.tsx
+++ b/apps/desktop/src/renderer/components/records/record-provider.tsx
@@ -35,9 +35,9 @@ export const RecordProvider = ({
updateFieldValue: (field, value) => {
mutate({
input: {
- type: 'node_attribute_set',
- nodeId: record.id,
- path: `fields.${field.id}`,
+ type: 'record_field_value_set',
+ recordId: record.id,
+ fieldId: field.id,
value,
userId: workspace.userId,
},
@@ -46,9 +46,9 @@ export const RecordProvider = ({
removeFieldValue: (field) => {
mutate({
input: {
- type: 'node_attribute_delete',
- nodeId: record.id,
- path: `fields.${field.id}`,
+ type: 'record_field_value_delete',
+ recordId: record.id,
+ fieldId: field.id,
userId: workspace.userId,
},
});
diff --git a/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx b/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx
index f0ad6514..a1457b73 100644
--- a/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx
+++ b/apps/desktop/src/renderer/components/spaces/space-delete-form.tsx
@@ -29,9 +29,9 @@ export const SpaceDeleteForm = ({ id }: SpaceDeleteFormProps) => {
onClick={() => {
mutate({
input: {
- type: 'node_delete',
+ type: 'space_delete',
userId: workspace.userId,
- nodeId: id,
+ spaceId: id,
},
onSuccess() {
toast({
diff --git a/apps/desktop/src/shared/mutations/account-logout.ts b/apps/desktop/src/shared/mutations/accounts/account-logout.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/account-logout.ts
rename to apps/desktop/src/shared/mutations/accounts/account-logout.ts
diff --git a/apps/desktop/src/shared/mutations/account-update.ts b/apps/desktop/src/shared/mutations/accounts/account-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/account-update.ts
rename to apps/desktop/src/shared/mutations/accounts/account-update.ts
diff --git a/apps/desktop/src/shared/mutations/email-login.ts b/apps/desktop/src/shared/mutations/accounts/email-login.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/email-login.ts
rename to apps/desktop/src/shared/mutations/accounts/email-login.ts
diff --git a/apps/desktop/src/shared/mutations/email-register.ts b/apps/desktop/src/shared/mutations/accounts/email-register.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/email-register.ts
rename to apps/desktop/src/shared/mutations/accounts/email-register.ts
diff --git a/apps/desktop/src/shared/mutations/accounts/errors.ts b/apps/desktop/src/shared/mutations/accounts/errors.ts
new file mode 100644
index 00000000..5e1e9ba8
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/accounts/errors.ts
@@ -0,0 +1,10 @@
+export type AccountNotFoundError = {
+ type: 'account_not_found';
+ message: string;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationErrorMap {
+ account_not_found: AccountNotFoundError;
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/avatar-upload.ts b/apps/desktop/src/shared/mutations/avatars/avatar-upload.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/avatar-upload.ts
rename to apps/desktop/src/shared/mutations/avatars/avatar-upload.ts
diff --git a/apps/desktop/src/shared/mutations/channel-create.ts b/apps/desktop/src/shared/mutations/channels/channel-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/channel-create.ts
rename to apps/desktop/src/shared/mutations/channels/channel-create.ts
diff --git a/apps/desktop/src/shared/mutations/channels/channel-delete.ts b/apps/desktop/src/shared/mutations/channels/channel-delete.ts
new file mode 100644
index 00000000..784a2388
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/channels/channel-delete.ts
@@ -0,0 +1,18 @@
+export type ChannelDeleteMutationInput = {
+ type: 'channel_delete';
+ userId: string;
+ channelId: string;
+};
+
+export type ChannelDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ channel_delete: {
+ input: ChannelDeleteMutationInput;
+ output: ChannelDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/channel-update.ts b/apps/desktop/src/shared/mutations/channels/channel-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/channel-update.ts
rename to apps/desktop/src/shared/mutations/channels/channel-update.ts
diff --git a/apps/desktop/src/shared/mutations/chat-create.ts b/apps/desktop/src/shared/mutations/chats/chat-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/chat-create.ts
rename to apps/desktop/src/shared/mutations/chats/chat-create.ts
diff --git a/apps/desktop/src/shared/mutations/node-collaborator-create.ts b/apps/desktop/src/shared/mutations/collaborators/node-collaborator-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/node-collaborator-create.ts
rename to apps/desktop/src/shared/mutations/collaborators/node-collaborator-create.ts
diff --git a/apps/desktop/src/shared/mutations/node-collaborator-delete.ts b/apps/desktop/src/shared/mutations/collaborators/node-collaborator-delete.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/node-collaborator-delete.ts
rename to apps/desktop/src/shared/mutations/collaborators/node-collaborator-delete.ts
diff --git a/apps/desktop/src/shared/mutations/node-collaborator-update.ts b/apps/desktop/src/shared/mutations/collaborators/node-collaborator-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/node-collaborator-update.ts
rename to apps/desktop/src/shared/mutations/collaborators/node-collaborator-update.ts
diff --git a/apps/desktop/src/shared/mutations/database-create.ts b/apps/desktop/src/shared/mutations/databases/database-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/database-create.ts
rename to apps/desktop/src/shared/mutations/databases/database-create.ts
diff --git a/apps/desktop/src/shared/mutations/databases/database-delete.ts b/apps/desktop/src/shared/mutations/databases/database-delete.ts
new file mode 100644
index 00000000..8b33030c
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/databases/database-delete.ts
@@ -0,0 +1,18 @@
+export type DatabaseDeleteMutationInput = {
+ type: 'database_delete';
+ userId: string;
+ databaseId: string;
+};
+
+export type DatabaseDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ database_delete: {
+ input: DatabaseDeleteMutationInput;
+ output: DatabaseDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/database-update.ts b/apps/desktop/src/shared/mutations/databases/database-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/database-update.ts
rename to apps/desktop/src/shared/mutations/databases/database-update.ts
diff --git a/apps/desktop/src/shared/mutations/field-create.ts b/apps/desktop/src/shared/mutations/databases/field-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/field-create.ts
rename to apps/desktop/src/shared/mutations/databases/field-create.ts
diff --git a/apps/desktop/src/shared/mutations/databases/field-delete.ts b/apps/desktop/src/shared/mutations/databases/field-delete.ts
new file mode 100644
index 00000000..b0dc24a8
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/databases/field-delete.ts
@@ -0,0 +1,19 @@
+export type FieldDeleteMutationInput = {
+ type: 'field_delete';
+ databaseId: string;
+ fieldId: string;
+ userId: string;
+};
+
+export type FieldDeleteMutationOutput = {
+ id: string;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ field_delete: {
+ input: FieldDeleteMutationInput;
+ output: FieldDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/databases/field-name-update.ts b/apps/desktop/src/shared/mutations/databases/field-name-update.ts
new file mode 100644
index 00000000..c72b5e9c
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/databases/field-name-update.ts
@@ -0,0 +1,20 @@
+export type FieldNameUpdateMutationInput = {
+ type: 'field_name_update';
+ databaseId: string;
+ fieldId: string;
+ name: string;
+ userId: string;
+};
+
+export type FieldNameUpdateMutationOutput = {
+ id: string;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ field_name_update: {
+ input: FieldNameUpdateMutationInput;
+ output: FieldNameUpdateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/select-option-create.ts b/apps/desktop/src/shared/mutations/databases/select-option-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/select-option-create.ts
rename to apps/desktop/src/shared/mutations/databases/select-option-create.ts
diff --git a/apps/desktop/src/shared/mutations/databases/select-option-delete.ts b/apps/desktop/src/shared/mutations/databases/select-option-delete.ts
new file mode 100644
index 00000000..6147b07b
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/databases/select-option-delete.ts
@@ -0,0 +1,20 @@
+export type SelectOptionDeleteMutationInput = {
+ type: 'select_option_delete';
+ userId: string;
+ databaseId: string;
+ fieldId: string;
+ optionId: string;
+};
+
+export type SelectOptionDeleteMutationOutput = {
+ id: string;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ select_option_delete: {
+ input: SelectOptionDeleteMutationInput;
+ output: SelectOptionDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/databases/select-option-update.ts b/apps/desktop/src/shared/mutations/databases/select-option-update.ts
new file mode 100644
index 00000000..cb56422f
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/databases/select-option-update.ts
@@ -0,0 +1,22 @@
+export type SelectOptionUpdateMutationInput = {
+ type: 'select_option_update';
+ userId: string;
+ databaseId: string;
+ fieldId: string;
+ optionId: string;
+ name: string;
+ color: string;
+};
+
+export type SelectOptionUpdateMutationOutput = {
+ id: string;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ select_option_update: {
+ input: SelectOptionUpdateMutationInput;
+ output: SelectOptionUpdateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/view-create.ts b/apps/desktop/src/shared/mutations/databases/view-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/view-create.ts
rename to apps/desktop/src/shared/mutations/databases/view-create.ts
diff --git a/apps/desktop/src/shared/mutations/view-delete.ts b/apps/desktop/src/shared/mutations/databases/view-delete.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/view-delete.ts
rename to apps/desktop/src/shared/mutations/databases/view-delete.ts
diff --git a/apps/desktop/src/shared/mutations/databases/view-name-update.ts b/apps/desktop/src/shared/mutations/databases/view-name-update.ts
new file mode 100644
index 00000000..e3ac6d18
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/databases/view-name-update.ts
@@ -0,0 +1,20 @@
+export type ViewNameUpdateMutationInput = {
+ type: 'view_name_update';
+ databaseId: string;
+ viewId: string;
+ name: string;
+ userId: string;
+};
+
+export type ViewNameUpdateMutationOutput = {
+ id: string;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ view_name_update: {
+ input: ViewNameUpdateMutationInput;
+ output: ViewNameUpdateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/view-update.ts b/apps/desktop/src/shared/mutations/databases/view-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/view-update.ts
rename to apps/desktop/src/shared/mutations/databases/view-update.ts
diff --git a/apps/desktop/src/shared/mutations/document-save.ts b/apps/desktop/src/shared/mutations/document-save.ts
deleted file mode 100644
index 465ca7c8..00000000
--- a/apps/desktop/src/shared/mutations/document-save.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { JSONContent } from '@tiptap/core';
-
-export type DocumentSaveMutationInput = {
- type: 'document_save';
- userId: string;
- documentId: string;
- content: JSONContent;
-};
-
-export type DocumentSaveMutationOutput = {
- success: boolean;
-};
-
-declare module '@/shared/mutations' {
- interface MutationMap {
- document_save: {
- input: DocumentSaveMutationInput;
- output: DocumentSaveMutationOutput;
- };
- }
-}
diff --git a/apps/desktop/src/shared/mutations/file-create.ts b/apps/desktop/src/shared/mutations/files/file-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/file-create.ts
rename to apps/desktop/src/shared/mutations/files/file-create.ts
diff --git a/apps/desktop/src/shared/mutations/files/file-delete.ts b/apps/desktop/src/shared/mutations/files/file-delete.ts
new file mode 100644
index 00000000..1c03cda7
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/files/file-delete.ts
@@ -0,0 +1,18 @@
+export type FileDeleteMutationInput = {
+ type: 'file_delete';
+ userId: string;
+ fileId: string;
+};
+
+export type FileDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ file_delete: {
+ input: FileDeleteMutationInput;
+ output: FileDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/file-download.ts b/apps/desktop/src/shared/mutations/files/file-download.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/file-download.ts
rename to apps/desktop/src/shared/mutations/files/file-download.ts
diff --git a/apps/desktop/src/shared/mutations/folder-create.ts b/apps/desktop/src/shared/mutations/folders/folder-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/folder-create.ts
rename to apps/desktop/src/shared/mutations/folders/folder-create.ts
diff --git a/apps/desktop/src/shared/mutations/folders/folder-delete.ts b/apps/desktop/src/shared/mutations/folders/folder-delete.ts
new file mode 100644
index 00000000..4b22245e
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/folders/folder-delete.ts
@@ -0,0 +1,18 @@
+export type FolderDeleteMutationInput = {
+ type: 'folder_delete';
+ userId: string;
+ folderId: string;
+};
+
+export type FolderDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ folder_delete: {
+ input: FolderDeleteMutationInput;
+ output: FolderDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/folder-update.ts b/apps/desktop/src/shared/mutations/folders/folder-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/folder-update.ts
rename to apps/desktop/src/shared/mutations/folders/folder-update.ts
diff --git a/apps/desktop/src/shared/mutations/index.ts b/apps/desktop/src/shared/mutations/index.ts
index ca9bd1b2..c01210de 100644
--- a/apps/desktop/src/shared/mutations/index.ts
+++ b/apps/desktop/src/shared/mutations/index.ts
@@ -1,4 +1,7 @@
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface MutationMap {}
+// eslint-disable-next-line @typescript-eslint/no-empty-object-type
+export interface MutationErrorMap {}
+
export type MutationInput = MutationMap[keyof MutationMap]['input'];
diff --git a/apps/desktop/src/shared/mutations/mark-node-as-seen.ts b/apps/desktop/src/shared/mutations/interactions/mark-node-as-seen.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/mark-node-as-seen.ts
rename to apps/desktop/src/shared/mutations/interactions/mark-node-as-seen.ts
diff --git a/apps/desktop/src/shared/mutations/message-create.ts b/apps/desktop/src/shared/mutations/messages/message-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/message-create.ts
rename to apps/desktop/src/shared/mutations/messages/message-create.ts
diff --git a/apps/desktop/src/shared/mutations/messages/message-delete.ts b/apps/desktop/src/shared/mutations/messages/message-delete.ts
new file mode 100644
index 00000000..428578ce
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/messages/message-delete.ts
@@ -0,0 +1,18 @@
+export type MessageDeleteMutationInput = {
+ type: 'message_delete';
+ userId: string;
+ messageId: string;
+};
+
+export type MessageDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ message_delete: {
+ input: MessageDeleteMutationInput;
+ output: MessageDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/messages/message-reaction-create.ts b/apps/desktop/src/shared/mutations/messages/message-reaction-create.ts
new file mode 100644
index 00000000..3dd5a6d0
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/messages/message-reaction-create.ts
@@ -0,0 +1,19 @@
+export type MessageReactionCreateMutationInput = {
+ type: 'message_reaction_create';
+ userId: string;
+ messageId: string;
+ reaction: string;
+};
+
+export type MessageReactionCreateMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ message_reaction_create: {
+ input: MessageReactionCreateMutationInput;
+ output: MessageReactionCreateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/messages/message-reaction-delete.ts b/apps/desktop/src/shared/mutations/messages/message-reaction-delete.ts
new file mode 100644
index 00000000..e759dba4
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/messages/message-reaction-delete.ts
@@ -0,0 +1,19 @@
+export type MessageReactionDeleteMutationInput = {
+ type: 'message_reaction_delete';
+ userId: string;
+ messageId: string;
+ reaction: string;
+};
+
+export type MessageReactionDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ message_reaction_delete: {
+ input: MessageReactionDeleteMutationInput;
+ output: MessageReactionDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/node-attribute-delete.ts b/apps/desktop/src/shared/mutations/node-attribute-delete.ts
deleted file mode 100644
index 7aca398a..00000000
--- a/apps/desktop/src/shared/mutations/node-attribute-delete.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export type NodeAttributeDeleteMutationInput = {
- type: 'node_attribute_delete';
- userId: string;
- nodeId: string;
- path: string;
-};
-
-export type NodeAttributeDeleteMutationOutput = {
- success: boolean;
-};
-
-declare module '@/shared/mutations' {
- interface MutationMap {
- node_attribute_delete: {
- input: NodeAttributeDeleteMutationInput;
- output: NodeAttributeDeleteMutationOutput;
- };
- }
-}
diff --git a/apps/desktop/src/shared/mutations/node-attribute-set.ts b/apps/desktop/src/shared/mutations/node-attribute-set.ts
deleted file mode 100644
index b92e7203..00000000
--- a/apps/desktop/src/shared/mutations/node-attribute-set.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export type NodeAttributeSetMutationInput = {
- type: 'node_attribute_set';
- userId: string;
- nodeId: string;
- path: string;
- value: unknown;
-};
-
-export type NodeAttributeSetMutationOutput = {
- success: boolean;
-};
-
-declare module '@/shared/mutations' {
- interface MutationMap {
- node_attribute_set: {
- input: NodeAttributeSetMutationInput;
- output: NodeAttributeSetMutationOutput;
- };
- }
-}
diff --git a/apps/desktop/src/shared/mutations/node-delete.ts b/apps/desktop/src/shared/mutations/node-delete.ts
deleted file mode 100644
index e6728fa6..00000000
--- a/apps/desktop/src/shared/mutations/node-delete.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-export type NodeDeleteMutationInput = {
- type: 'node_delete';
- userId: string;
- nodeId: string;
-};
-
-export type NodeDeleteMutationOutput = {
- success: boolean;
-};
-
-declare module '@/shared/mutations' {
- interface MutationMap {
- node_delete: {
- input: NodeDeleteMutationInput;
- output: NodeDeleteMutationOutput;
- };
- }
-}
diff --git a/apps/desktop/src/shared/mutations/node-reaction-create.ts b/apps/desktop/src/shared/mutations/node-reaction-create.ts
deleted file mode 100644
index 1460c7d0..00000000
--- a/apps/desktop/src/shared/mutations/node-reaction-create.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export type NodeReactionCreateMutationInput = {
- type: 'node_reaction_create';
- userId: string;
- nodeId: string;
- reaction: string;
-};
-
-export type NodeReactionCreateMutationOutput = {
- success: boolean;
-};
-
-declare module '@/shared/mutations' {
- interface MutationMap {
- node_reaction_create: {
- input: NodeReactionCreateMutationInput;
- output: NodeReactionCreateMutationOutput;
- };
- }
-}
diff --git a/apps/desktop/src/shared/mutations/node-reaction-delete.ts b/apps/desktop/src/shared/mutations/node-reaction-delete.ts
deleted file mode 100644
index 6a38202b..00000000
--- a/apps/desktop/src/shared/mutations/node-reaction-delete.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export type NodeReactionDeleteMutationInput = {
- type: 'node_reaction_delete';
- userId: string;
- nodeId: string;
- reaction: string;
-};
-
-export type NodeReactionDeleteMutationOutput = {
- success: boolean;
-};
-
-declare module '@/shared/mutations' {
- interface MutationMap {
- node_reaction_delete: {
- input: NodeReactionDeleteMutationInput;
- output: NodeReactionDeleteMutationOutput;
- };
- }
-}
diff --git a/apps/desktop/src/shared/mutations/pages/page-content-update.ts b/apps/desktop/src/shared/mutations/pages/page-content-update.ts
new file mode 100644
index 00000000..90308108
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/pages/page-content-update.ts
@@ -0,0 +1,21 @@
+import { JSONContent } from '@tiptap/core';
+
+export type PageContentUpdateMutationInput = {
+ type: 'page_content_update';
+ userId: string;
+ pageId: string;
+ content: JSONContent;
+};
+
+export type PageContentUpdateMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ page_content_update: {
+ input: PageContentUpdateMutationInput;
+ output: PageContentUpdateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/page-create.ts b/apps/desktop/src/shared/mutations/pages/page-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/page-create.ts
rename to apps/desktop/src/shared/mutations/pages/page-create.ts
diff --git a/apps/desktop/src/shared/mutations/pages/page-delete.ts b/apps/desktop/src/shared/mutations/pages/page-delete.ts
new file mode 100644
index 00000000..7da4e8ac
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/pages/page-delete.ts
@@ -0,0 +1,18 @@
+export type PageDeleteMutationInput = {
+ type: 'page_delete';
+ userId: string;
+ pageId: string;
+};
+
+export type PageDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ page_delete: {
+ input: PageDeleteMutationInput;
+ output: PageDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/page-update.ts b/apps/desktop/src/shared/mutations/pages/page-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/page-update.ts
rename to apps/desktop/src/shared/mutations/pages/page-update.ts
diff --git a/apps/desktop/src/shared/mutations/records/record-avatar-update.ts b/apps/desktop/src/shared/mutations/records/record-avatar-update.ts
new file mode 100644
index 00000000..5163bcc1
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/records/record-avatar-update.ts
@@ -0,0 +1,19 @@
+export type RecordAvatarUpdateMutationInput = {
+ type: 'record_avatar_update';
+ userId: string;
+ recordId: string;
+ avatar: string;
+};
+
+export type RecordAvatarUpdateMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ record_avatar_update: {
+ input: RecordAvatarUpdateMutationInput;
+ output: RecordAvatarUpdateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/records/record-content-update.ts b/apps/desktop/src/shared/mutations/records/record-content-update.ts
new file mode 100644
index 00000000..7ad851a0
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/records/record-content-update.ts
@@ -0,0 +1,21 @@
+import { JSONContent } from '@tiptap/core';
+
+export type RecordContentUpdateMutationInput = {
+ type: 'record_content_update';
+ userId: string;
+ recordId: string;
+ content: JSONContent;
+};
+
+export type RecordContentUpdateMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ record_content_update: {
+ input: RecordContentUpdateMutationInput;
+ output: RecordContentUpdateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/record-create.ts b/apps/desktop/src/shared/mutations/records/record-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/record-create.ts
rename to apps/desktop/src/shared/mutations/records/record-create.ts
diff --git a/apps/desktop/src/shared/mutations/records/record-delete.ts b/apps/desktop/src/shared/mutations/records/record-delete.ts
new file mode 100644
index 00000000..d53d599a
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/records/record-delete.ts
@@ -0,0 +1,18 @@
+export type RecordDeleteMutationInput = {
+ type: 'record_delete';
+ userId: string;
+ recordId: string;
+};
+
+export type RecordDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ record_delete: {
+ input: RecordDeleteMutationInput;
+ output: RecordDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/records/record-field-value-delete.ts b/apps/desktop/src/shared/mutations/records/record-field-value-delete.ts
new file mode 100644
index 00000000..af34f08e
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/records/record-field-value-delete.ts
@@ -0,0 +1,19 @@
+export type RecordFieldValueDeleteMutationInput = {
+ type: 'record_field_value_delete';
+ userId: string;
+ recordId: string;
+ fieldId: string;
+};
+
+export type RecordFieldValueDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ record_field_value_delete: {
+ input: RecordFieldValueDeleteMutationInput;
+ output: RecordFieldValueDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/records/record-field-value-set.ts b/apps/desktop/src/shared/mutations/records/record-field-value-set.ts
new file mode 100644
index 00000000..3ac350f7
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/records/record-field-value-set.ts
@@ -0,0 +1,22 @@
+import { FieldValue } from '@colanode/core';
+
+export type RecordFieldValueSetMutationInput = {
+ type: 'record_field_value_set';
+ userId: string;
+ recordId: string;
+ fieldId: string;
+ value: FieldValue;
+};
+
+export type RecordFieldValueSetMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ record_field_value_set: {
+ input: RecordFieldValueSetMutationInput;
+ output: RecordFieldValueSetMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/records/record-name-update.ts b/apps/desktop/src/shared/mutations/records/record-name-update.ts
new file mode 100644
index 00000000..242fa168
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/records/record-name-update.ts
@@ -0,0 +1,19 @@
+export type RecordNameUpdateMutationInput = {
+ type: 'record_name_update';
+ userId: string;
+ recordId: string;
+ name: string;
+};
+
+export type RecordNameUpdateMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ record_name_update: {
+ input: RecordNameUpdateMutationInput;
+ output: RecordNameUpdateMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/server-create.ts b/apps/desktop/src/shared/mutations/servers/server-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/server-create.ts
rename to apps/desktop/src/shared/mutations/servers/server-create.ts
diff --git a/apps/desktop/src/shared/mutations/space-create.ts b/apps/desktop/src/shared/mutations/spaces/space-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/space-create.ts
rename to apps/desktop/src/shared/mutations/spaces/space-create.ts
diff --git a/apps/desktop/src/shared/mutations/spaces/space-delete.ts b/apps/desktop/src/shared/mutations/spaces/space-delete.ts
new file mode 100644
index 00000000..7d69ebff
--- /dev/null
+++ b/apps/desktop/src/shared/mutations/spaces/space-delete.ts
@@ -0,0 +1,18 @@
+export type SpaceDeleteMutationInput = {
+ type: 'space_delete';
+ userId: string;
+ spaceId: string;
+};
+
+export type SpaceDeleteMutationOutput = {
+ success: boolean;
+};
+
+declare module '@/shared/mutations' {
+ interface MutationMap {
+ space_delete: {
+ input: SpaceDeleteMutationInput;
+ output: SpaceDeleteMutationOutput;
+ };
+ }
+}
diff --git a/apps/desktop/src/shared/mutations/space-update.ts b/apps/desktop/src/shared/mutations/spaces/space-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/space-update.ts
rename to apps/desktop/src/shared/mutations/spaces/space-update.ts
diff --git a/apps/desktop/src/shared/mutations/workspace-create.ts b/apps/desktop/src/shared/mutations/workspaces/workspace-create.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/workspace-create.ts
rename to apps/desktop/src/shared/mutations/workspaces/workspace-create.ts
diff --git a/apps/desktop/src/shared/mutations/workspace-update.ts b/apps/desktop/src/shared/mutations/workspaces/workspace-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/workspace-update.ts
rename to apps/desktop/src/shared/mutations/workspaces/workspace-update.ts
diff --git a/apps/desktop/src/shared/mutations/workspace-user-role-update.ts b/apps/desktop/src/shared/mutations/workspaces/workspace-user-role-update.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/workspace-user-role-update.ts
rename to apps/desktop/src/shared/mutations/workspaces/workspace-user-role-update.ts
diff --git a/apps/desktop/src/shared/mutations/workspace-users-invite.ts b/apps/desktop/src/shared/mutations/workspaces/workspace-users-invite.ts
similarity index 100%
rename from apps/desktop/src/shared/mutations/workspace-users-invite.ts
rename to apps/desktop/src/shared/mutations/workspaces/workspace-users-invite.ts