Skip to content

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

Update mutation naming convention (#47)

Hakan Shehu08ffd692293d
diff --git a/apps/server/src/api/client/routes/workspaces/mutations/mutations-sync.ts b/apps/server/src/api/client/routes/workspaces/mutations/mutations-sync.ts
index 32e89d94..c7203860 100644
--- a/apps/server/src/api/client/routes/workspaces/mutations/mutations-sync.ts
+++ b/apps/server/src/api/client/routes/workspaces/mutations/mutations-sync.ts
@@ -64,21 +64,21 @@ const handleMutation = async (
user: SelectUser,
mutation: Mutation
): Promise<MutationStatus> => {
- if (mutation.type === 'create_node') {
+ if (mutation.type === 'node.create') {
return await createNodeFromMutation(user, mutation.data);
- } else if (mutation.type === 'update_node') {
+ } else if (mutation.type === 'node.update') {
return await updateNodeFromMutation(user, mutation.data);
- } else if (mutation.type === 'delete_node') {
+ } else if (mutation.type === 'node.delete') {
return await deleteNodeFromMutation(user, mutation.data);
- } else if (mutation.type === 'create_node_reaction') {
+ } else if (mutation.type === 'node.reaction.create') {
return await createNodeReaction(user, mutation);
- } else if (mutation.type === 'delete_node_reaction') {
+ } else if (mutation.type === 'node.reaction.delete') {
return await deleteNodeReaction(user, mutation);
- } else if (mutation.type === 'mark_node_seen') {
+ } else if (mutation.type === 'node.interaction.seen') {
return await markNodeAsSeen(user, mutation);
- } else if (mutation.type === 'mark_node_opened') {
+ } else if (mutation.type === 'node.interaction.opened') {
return await markNodeAsOpened(user, mutation);
- } else if (mutation.type === 'update_document') {
+ } else if (mutation.type === 'document.update') {
return await updateDocumentFromMutation(user, mutation.data);
} else {
return MutationStatus.METHOD_NOT_ALLOWED;
diff --git a/apps/server/src/lib/node-interactions.ts b/apps/server/src/lib/node-interactions.ts
index 80f8c870..f4638015 100644
--- a/apps/server/src/lib/node-interactions.ts
+++ b/apps/server/src/lib/node-interactions.ts
@@ -1,8 +1,8 @@
import {
extractNodeRole,
hasNodeRole,
- MarkNodeOpenedMutation,
- MarkNodeSeenMutation,
+ NodeInteractionOpenedMutation,
+ NodeInteractionSeenMutation,
MutationStatus,
} from '@colanode/core';
import { database } from '@colanode/server/data/database';
@@ -12,7 +12,7 @@ import { mapNode } from '@colanode/server/lib/nodes';
export const markNodeAsSeen = async (
user: SelectUser,
- mutation: MarkNodeSeenMutation
+ mutation: NodeInteractionSeenMutation
): Promise<MutationStatus> => {
const node = await database
.selectFrom('nodes')
@@ -93,7 +93,7 @@ export const markNodeAsSeen = async (
export const markNodeAsOpened = async (
user: SelectUser,
- mutation: MarkNodeOpenedMutation
+ mutation: NodeInteractionOpenedMutation
): Promise<MutationStatus> => {
const node = await database
.selectFrom('nodes')
diff --git a/packages/client/src/handlers/mutations/index.ts b/packages/client/src/handlers/mutations/index.ts
index 7d631ef8..753ee84a 100644
--- a/packages/client/src/handlers/mutations/index.ts
+++ b/packages/client/src/handlers/mutations/index.ts
@@ -44,8 +44,8 @@ import { MessageDeleteMutationHandler } from './messages/message-delete';
import { NodeCollaboratorCreateMutationHandler } from './nodes/node-collaborator-create';
import { NodeCollaboratorDeleteMutationHandler } from './nodes/node-collaborator-delete';
import { NodeCollaboratorUpdateMutationHandler } from './nodes/node-collaborator-update';
-import { NodeMarkOpenedMutationHandler } from './nodes/node-mark-opened';
-import { NodeMarkSeenMutationHandler } from './nodes/node-mark-seen';
+import { NodeInteractionOpenedMutationHandler } from './nodes/node-interaction-opened';
+import { NodeInteractionSeenMutationHandler } from './nodes/node-interaction-seen';
import { NodeReactionCreateMutationHandler } from './nodes/node-reaction-create';
import { NodeReactionDeleteMutationHandler } from './nodes/node-reaction-delete';
import { PageCreateMutationHandler } from './pages/page-create';
@@ -97,8 +97,8 @@ export const buildMutationHandlerMap = (
'node.collaborator.create': new NodeCollaboratorCreateMutationHandler(app),
'node.collaborator.delete': new NodeCollaboratorDeleteMutationHandler(app),
'node.collaborator.update': new NodeCollaboratorUpdateMutationHandler(app),
- 'node.mark.opened': new NodeMarkOpenedMutationHandler(app),
- 'node.mark.seen': new NodeMarkSeenMutationHandler(app),
+ 'node.interaction.opened': new NodeInteractionOpenedMutationHandler(app),
+ 'node.interaction.seen': new NodeInteractionSeenMutationHandler(app),
'page.create': new PageCreateMutationHandler(app),
'page.delete': new PageDeleteMutationHandler(app),
'node.reaction.create': new NodeReactionCreateMutationHandler(app),
diff --git a/packages/client/src/handlers/mutations/nodes/node-mark-opened.ts b/packages/client/src/handlers/mutations/nodes/node-interaction-opened.ts
similarity index 86%
rename from packages/client/src/handlers/mutations/nodes/node-mark-opened.ts
rename to packages/client/src/handlers/mutations/nodes/node-interaction-opened.ts
index 828c5f27..fcd22f9c 100644
--- a/packages/client/src/handlers/mutations/nodes/node-mark-opened.ts
+++ b/packages/client/src/handlers/mutations/nodes/node-interaction-opened.ts
@@ -4,18 +4,22 @@ import { mapNodeInteraction } from '@colanode/client/lib/mappers';
import { MutationHandler } from '@colanode/client/lib/types';
import { fetchNode } from '@colanode/client/lib/utils';
import {
- NodeMarkOpenedMutationInput,
- NodeMarkOpenedMutationOutput,
-} from '@colanode/client/mutations/nodes/node-mark-opened';
-import { MarkNodeOpenedMutation, generateId, IdType } from '@colanode/core';
+ NodeInteractionOpenedMutationInput,
+ NodeInteractionOpenedMutationOutput,
+} from '@colanode/client/mutations/nodes/node-interaction-opened';
+import {
+ NodeInteractionOpenedMutation,
+ generateId,
+ IdType,
+} from '@colanode/core';
-export class NodeMarkOpenedMutationHandler
+export class NodeInteractionOpenedMutationHandler
extends WorkspaceMutationHandlerBase
- implements MutationHandler<NodeMarkOpenedMutationInput>
+ implements MutationHandler<NodeInteractionOpenedMutationInput>
{
async handleMutation(
- input: NodeMarkOpenedMutationInput
- ): Promise<NodeMarkOpenedMutationOutput> {
+ input: NodeInteractionOpenedMutationInput
+ ): Promise<NodeInteractionOpenedMutationOutput> {
const workspace = this.getWorkspace(input.accountId, input.workspaceId);
const node = await fetchNode(workspace.database, input.nodeId);
@@ -75,10 +79,10 @@ export class NodeMarkOpenedMutationHandler
throw new Error('Failed to create node interaction');
}
- const mutation: MarkNodeOpenedMutation = {
+ const mutation: NodeInteractionOpenedMutation = {
id: generateId(IdType.Mutation),
createdAt: new Date().toISOString(),
- type: 'mark_node_opened',
+ type: 'node.interaction.opened',
data: {
nodeId: input.nodeId,
collaboratorId: workspace.userId,
diff --git a/packages/client/src/handlers/mutations/nodes/node-mark-seen.ts b/packages/client/src/handlers/mutations/nodes/node-interaction-seen.ts
similarity index 86%
rename from packages/client/src/handlers/mutations/nodes/node-mark-seen.ts
rename to packages/client/src/handlers/mutations/nodes/node-interaction-seen.ts
index 583c4ee1..9f3ac3b8 100644
--- a/packages/client/src/handlers/mutations/nodes/node-mark-seen.ts
+++ b/packages/client/src/handlers/mutations/nodes/node-interaction-seen.ts
@@ -4,18 +4,22 @@ import { mapNodeInteraction } from '@colanode/client/lib/mappers';
import { MutationHandler } from '@colanode/client/lib/types';
import { fetchNode } from '@colanode/client/lib/utils';
import {
- NodeMarkSeenMutationInput,
- NodeMarkSeenMutationOutput,
-} from '@colanode/client/mutations/nodes/node-mark-seen';
-import { MarkNodeSeenMutation, generateId, IdType } from '@colanode/core';
+ NodeInteractionSeenMutationInput,
+ NodeInteractionSeenMutationOutput,
+} from '@colanode/client/mutations/nodes/node-interaction-seen';
+import {
+ NodeInteractionSeenMutation,
+ generateId,
+ IdType,
+} from '@colanode/core';
-export class NodeMarkSeenMutationHandler
+export class NodeInteractionSeenMutationHandler
extends WorkspaceMutationHandlerBase
- implements MutationHandler<NodeMarkSeenMutationInput>
+ implements MutationHandler<NodeInteractionSeenMutationInput>
{
async handleMutation(
- input: NodeMarkSeenMutationInput
- ): Promise<NodeMarkSeenMutationOutput> {
+ input: NodeInteractionSeenMutationInput
+ ): Promise<NodeInteractionSeenMutationOutput> {
const workspace = this.getWorkspace(input.accountId, input.workspaceId);
const node = await fetchNode(workspace.database, input.nodeId);
@@ -76,10 +80,10 @@ export class NodeMarkSeenMutationHandler
throw new Error('Failed to create node interaction');
}
- const mutation: MarkNodeSeenMutation = {
+ const mutation: NodeInteractionSeenMutation = {
id: generateId(IdType.Mutation),
createdAt: new Date().toISOString(),
- type: 'mark_node_seen',
+ type: 'node.interaction.seen',
data: {
nodeId: input.nodeId,
collaboratorId: workspace.userId,
diff --git a/packages/client/src/mutations/index.ts b/packages/client/src/mutations/index.ts
index b46ddcfd..df7cc3ec 100644
--- a/packages/client/src/mutations/index.ts
+++ b/packages/client/src/mutations/index.ts
@@ -40,8 +40,8 @@ export * from './messages/message-delete';
export * from './nodes/node-collaborator-create';
export * from './nodes/node-collaborator-delete';
export * from './nodes/node-collaborator-update';
-export * from './nodes/node-mark-opened';
-export * from './nodes/node-mark-seen';
+export * from './nodes/node-interaction-opened';
+export * from './nodes/node-interaction-seen';
export * from './nodes/node-reaction-create';
export * from './nodes/node-reaction-delete';
export * from './pages/page-create';
diff --git a/packages/client/src/mutations/nodes/node-interaction-opened.ts b/packages/client/src/mutations/nodes/node-interaction-opened.ts
new file mode 100644
index 00000000..695a94c7
--- /dev/null
+++ b/packages/client/src/mutations/nodes/node-interaction-opened.ts
@@ -0,0 +1,19 @@
+export type NodeInteractionOpenedMutationInput = {
+ type: 'node.interaction.opened';
+ accountId: string;
+ workspaceId: string;
+ nodeId: string;
+};
+
+export type NodeInteractionOpenedMutationOutput = {
+ success: boolean;
+};
+
+declare module '@colanode/client/mutations' {
+ interface MutationMap {
+ 'node.interaction.opened': {
+ input: NodeInteractionOpenedMutationInput;
+ output: NodeInteractionOpenedMutationOutput;
+ };
+ }
+}
diff --git a/packages/client/src/mutations/nodes/node-interaction-seen.ts b/packages/client/src/mutations/nodes/node-interaction-seen.ts
new file mode 100644
index 00000000..f25d79ed
--- /dev/null
+++ b/packages/client/src/mutations/nodes/node-interaction-seen.ts
@@ -0,0 +1,19 @@
+export type NodeInteractionSeenMutationInput = {
+ type: 'node.interaction.seen';
+ accountId: string;
+ workspaceId: string;
+ nodeId: string;
+};
+
+export type NodeInteractionSeenMutationOutput = {
+ success: boolean;
+};
+
+declare module '@colanode/client/mutations' {
+ interface MutationMap {
+ 'node.interaction.seen': {
+ input: NodeInteractionSeenMutationInput;
+ output: NodeInteractionSeenMutationOutput;
+ };
+ }
+}
diff --git a/packages/client/src/mutations/nodes/node-mark-opened.ts b/packages/client/src/mutations/nodes/node-mark-opened.ts
deleted file mode 100644
index ff3fc511..00000000
--- a/packages/client/src/mutations/nodes/node-mark-opened.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export type NodeMarkOpenedMutationInput = {
- type: 'node.mark.opened';
- accountId: string;
- workspaceId: string;
- nodeId: string;
-};
-
-export type NodeMarkOpenedMutationOutput = {
- success: boolean;
-};
-
-declare module '@colanode/client/mutations' {
- interface MutationMap {
- 'node.mark.opened': {
- input: NodeMarkOpenedMutationInput;
- output: NodeMarkOpenedMutationOutput;
- };
- }
-}
diff --git a/packages/client/src/mutations/nodes/node-mark-seen.ts b/packages/client/src/mutations/nodes/node-mark-seen.ts
deleted file mode 100644
index 142cce26..00000000
--- a/packages/client/src/mutations/nodes/node-mark-seen.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export type NodeMarkSeenMutationInput = {
- type: 'node.mark.seen';
- accountId: string;
- workspaceId: string;
- nodeId: string;
-};
-
-export type NodeMarkSeenMutationOutput = {
- success: boolean;
-};
-
-declare module '@colanode/client/mutations' {
- interface MutationMap {
- 'node.mark.seen': {
- input: NodeMarkSeenMutationInput;
- output: NodeMarkSeenMutationOutput;
- };
- }
-}
diff --git a/packages/client/src/services/workspaces/document-service.ts b/packages/client/src/services/workspaces/document-service.ts
index ac1f0ed3..25a7f87c 100644
--- a/packages/client/src/services/workspaces/document-service.ts
+++ b/packages/client/src/services/workspaces/document-service.ts
@@ -180,7 +180,7 @@ export class DocumentService {
.returningAll()
.values({
id: generateId(IdType.Mutation),
- type: 'update_document',
+ type: 'document.update',
data: JSON.stringify({
documentId: id,
updateId: updateId,
@@ -346,7 +346,7 @@ export class DocumentService {
.returningAll()
.values({
id: generateId(IdType.Mutation),
- type: 'update_document',
+ type: 'document.update',
data: JSON.stringify(mutationData),
created_at: updatedAt,
retries: 0,
diff --git a/packages/client/src/services/workspaces/mutation-service.ts b/packages/client/src/services/workspaces/mutation-service.ts
index 54247f62..c63b6527 100644
--- a/packages/client/src/services/workspaces/mutation-service.ts
+++ b/packages/client/src/services/workspaces/mutation-service.ts
@@ -149,21 +149,21 @@ export class MutationService {
for (const mutationRow of invalidMutations) {
const mutation = mapMutation(mutationRow);
- if (mutation.type === 'create_node') {
+ if (mutation.type === 'node.create') {
await this.workspace.nodes.revertNodeCreate(mutation.data);
- } else if (mutation.type === 'update_node') {
+ } else if (mutation.type === 'node.update') {
await this.workspace.nodes.revertNodeUpdate(mutation.data);
- } else if (mutation.type === 'delete_node') {
+ } else if (mutation.type === 'node.delete') {
await this.workspace.nodes.revertNodeDelete(mutation.data);
- } else if (mutation.type === 'create_node_reaction') {
+ } else if (mutation.type === 'node.reaction.create') {
await this.workspace.nodeReactions.revertNodeReactionCreate(
mutation.data
);
- } else if (mutation.type === 'delete_node_reaction') {
+ } else if (mutation.type === 'node.reaction.delete') {
await this.workspace.nodeReactions.revertNodeReactionDelete(
mutation.data
);
- } else if (mutation.type === 'update_document') {
+ } else if (mutation.type === 'document.update') {
await this.workspace.documents.revertDocumentUpdate(mutation.data);
}
}
@@ -212,7 +212,7 @@ export class MutationService {
continue;
}
- if (mutation.type === 'delete_node') {
+ if (mutation.type === 'node.delete') {
for (let j = i - 1; j >= 0; j--) {
const previousMutation = mutations[j];
if (!previousMutation) {
@@ -220,47 +220,47 @@ export class MutationService {
}
if (
- previousMutation.type === 'create_node' &&
+ previousMutation.type === 'node.create' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(mutation.id);
deletedMutationIds.add(previousMutation.id);
} else if (
- previousMutation.type === 'update_node' &&
+ previousMutation.type === 'node.update' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(mutation.id);
deletedMutationIds.add(previousMutation.id);
} else if (
- previousMutation.type === 'delete_node' &&
+ previousMutation.type === 'node.delete' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(previousMutation.id);
- } else if (previousMutation.type === 'update_document') {
+ } else if (previousMutation.type === 'document.update') {
deletedMutationIds.add(previousMutation.id);
} else if (
- previousMutation.type === 'mark_node_seen' &&
+ previousMutation.type === 'node.interaction.seen' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(previousMutation.id);
} else if (
- previousMutation.type === 'mark_node_opened' &&
+ previousMutation.type === 'node.interaction.opened' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(previousMutation.id);
} else if (
- previousMutation.type === 'create_node_reaction' &&
+ previousMutation.type === 'node.reaction.create' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(previousMutation.id);
} else if (
- previousMutation.type === 'delete_node_reaction' &&
+ previousMutation.type === 'node.reaction.delete' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(previousMutation.id);
}
}
- } else if (mutation.type === 'delete_node_reaction') {
+ } else if (mutation.type === 'node.reaction.delete') {
for (let j = i - 1; j >= 0; j--) {
const previousMutation = mutations[j];
if (!previousMutation) {
@@ -268,21 +268,21 @@ export class MutationService {
}
if (
- previousMutation.type === 'create_node_reaction' &&
+ previousMutation.type === 'node.reaction.create' &&
previousMutation.data.nodeId === mutation.data.nodeId &&
previousMutation.data.reaction === mutation.data.reaction
) {
deletedMutationIds.add(mutation.id);
deletedMutationIds.add(previousMutation.id);
} else if (
- previousMutation.type === 'delete_node_reaction' &&
+ previousMutation.type === 'node.reaction.delete' &&
previousMutation.data.nodeId === mutation.data.nodeId &&
previousMutation.data.reaction === mutation.data.reaction
) {
deletedMutationIds.add(previousMutation.id);
}
}
- } else if (mutation.type === 'mark_node_seen') {
+ } else if (mutation.type === 'node.interaction.seen') {
for (let j = i - 1; j >= 0; j--) {
const previousMutation = mutations[j];
if (!previousMutation) {
@@ -290,13 +290,13 @@ export class MutationService {
}
if (
- previousMutation.type === 'mark_node_seen' &&
+ previousMutation.type === 'node.interaction.seen' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(previousMutation.id);
}
}
- } else if (mutation.type === 'mark_node_opened') {
+ } else if (mutation.type === 'node.interaction.opened') {
for (let j = i - 1; j >= 0; j--) {
const previousMutation = mutations[j];
if (!previousMutation) {
@@ -304,7 +304,7 @@ export class MutationService {
}
if (
- previousMutation.type === 'mark_node_opened' &&
+ previousMutation.type === 'node.interaction.opened' &&
previousMutation.data.nodeId === mutation.data.nodeId
) {
deletedMutationIds.add(previousMutation.id);
diff --git a/packages/client/src/services/workspaces/node-reaction-service.ts b/packages/client/src/services/workspaces/node-reaction-service.ts
index eba8c740..740383b2 100644
--- a/packages/client/src/services/workspaces/node-reaction-service.ts
+++ b/packages/client/src/services/workspaces/node-reaction-service.ts
@@ -100,7 +100,7 @@ export class NodeReactionService {
const mutation: CreateNodeReactionMutation = {
id: generateId(IdType.Mutation),
createdAt: new Date().toISOString(),
- type: 'create_node_reaction',
+ type: 'node.reaction.create',
data: {
nodeId,
reaction,
@@ -179,7 +179,7 @@ export class NodeReactionService {
const mutation: DeleteNodeReactionMutation = {
id: generateId(IdType.Mutation),
createdAt: new Date().toISOString(),
- type: 'delete_node_reaction',
+ type: 'node.reaction.delete',
data: {
nodeId,
reaction,
diff --git a/packages/client/src/services/workspaces/node-service.ts b/packages/client/src/services/workspaces/node-service.ts
index 826882cb..17153826 100644
--- a/packages/client/src/services/workspaces/node-service.ts
+++ b/packages/client/src/services/workspaces/node-service.ts
@@ -146,7 +146,7 @@ export class NodeService {
.returningAll()
.values({
id: generateId(IdType.Mutation),
- type: 'create_node',
+ type: 'node.create',
data: JSON.stringify(mutationData),
created_at: createdAt,
retries: 0,
@@ -345,7 +345,7 @@ export class NodeService {
.returningAll()
.values({
id: generateId(IdType.Mutation),
- type: 'update_node',
+ type: 'node.update',
data: JSON.stringify(mutationData),
created_at: updatedAt,
retries: 0,
@@ -485,7 +485,7 @@ export class NodeService {
.returningAll()
.values({
id: generateId(IdType.Mutation),
- type: 'delete_node',
+ type: 'node.delete',
data: JSON.stringify(deleteMutationData),
created_at: new Date().toISOString(),
retries: 0,
diff --git a/packages/core/src/types/mutations.ts b/packages/core/src/types/mutations.ts
index a32e1e76..9593b835 100644
--- a/packages/core/src/types/mutations.ts
+++ b/packages/core/src/types/mutations.ts
@@ -52,7 +52,7 @@ export type CreateNodeMutationData = z.infer<
>;
export const createNodeMutationSchema = mutationBaseSchema.extend({
- type: z.literal('create_node'),
+ type: z.literal('node.create'),
data: createNodeMutationDataSchema,
});
@@ -70,7 +70,7 @@ export type UpdateNodeMutationData = z.infer<
>;
export const updateNodeMutationSchema = mutationBaseSchema.extend({
- type: z.literal('update_node'),
+ type: z.literal('node.update'),
data: updateNodeMutationDataSchema,
});
@@ -87,7 +87,7 @@ export type DeleteNodeMutationData = z.infer<
>;
export const deleteNodeMutationSchema = mutationBaseSchema.extend({
- type: z.literal('delete_node'),
+ type: z.literal('node.delete'),
data: deleteNodeMutationDataSchema,
});
@@ -105,7 +105,7 @@ export type CreateNodeReactionMutationData = z.infer<
>;
export const createNodeReactionMutationSchema = mutationBaseSchema.extend({
- type: z.literal('create_node_reaction'),
+ type: z.literal('node.reaction.create'),
data: createNodeReactionMutationDataSchema,
});
@@ -125,7 +125,7 @@ export type DeleteNodeReactionMutationData = z.infer<
>;
export const deleteNodeReactionMutationSchema = mutationBaseSchema.extend({
- type: z.literal('delete_node_reaction'),
+ type: z.literal('node.reaction.delete'),
data: deleteNodeReactionMutationDataSchema,
});
@@ -133,40 +133,42 @@ export type DeleteNodeReactionMutation = z.infer<
typeof deleteNodeReactionMutationSchema
>;
-export const markNodeSeenMutationDataSchema = z.object({
+export const nodeInteractionSeenMutationDataSchema = z.object({
nodeId: z.string(),
collaboratorId: z.string(),
seenAt: z.string(),
});
-export type MarkNodeSeenMutationData = z.infer<
- typeof markNodeSeenMutationDataSchema
+export type NodeInteractionSeenMutationData = z.infer<
+ typeof nodeInteractionSeenMutationDataSchema
>;
-export const markNodeSeenMutationSchema = mutationBaseSchema.extend({
- type: z.literal('mark_node_seen'),
- data: markNodeSeenMutationDataSchema,
+export const nodeInteractionSeenMutationSchema = mutationBaseSchema.extend({
+ type: z.literal('node.interaction.seen'),
+ data: nodeInteractionSeenMutationDataSchema,
});
-export type MarkNodeSeenMutation = z.infer<typeof markNodeSeenMutationSchema>;
+export type NodeInteractionSeenMutation = z.infer<
+ typeof nodeInteractionSeenMutationSchema
+>;
-export const markNodeOpenedMutationDataSchema = z.object({
+export const nodeInteractionOpenedMutationDataSchema = z.object({
nodeId: z.string(),
collaboratorId: z.string(),
openedAt: z.string(),
});
-export type MarkNodeOpenedMutationData = z.infer<
- typeof markNodeOpenedMutationDataSchema
+export type NodeInteractionOpenedMutationData = z.infer<
+ typeof nodeInteractionOpenedMutationDataSchema
>;
-export const markNodeOpenedMutationSchema = mutationBaseSchema.extend({
- type: z.literal('mark_node_opened'),
- data: markNodeOpenedMutationDataSchema,
+export const nodeInteractionOpenedMutationSchema = mutationBaseSchema.extend({
+ type: z.literal('node.interaction.opened'),
+ data: nodeInteractionOpenedMutationDataSchema,
});
-export type MarkNodeOpenedMutation = z.infer<
- typeof markNodeOpenedMutationSchema
+export type NodeInteractionOpenedMutation = z.infer<
+ typeof nodeInteractionOpenedMutationSchema
>;
export const updateDocumentMutationDataSchema = z.object({
@@ -181,7 +183,7 @@ export type UpdateDocumentMutationData = z.infer<
>;
export const updateDocumentMutationSchema = mutationBaseSchema.extend({
- type: z.literal('update_document'),
+ type: z.literal('document.update'),
data: updateDocumentMutationDataSchema,
});
@@ -195,8 +197,8 @@ export const mutationSchema = z.discriminatedUnion('type', [
deleteNodeMutationSchema,
createNodeReactionMutationSchema,
deleteNodeReactionMutationSchema,
- markNodeSeenMutationSchema,
- markNodeOpenedMutationSchema,
+ nodeInteractionSeenMutationSchema,
+ nodeInteractionOpenedMutationSchema,
updateDocumentMutationSchema,
]);
diff --git a/packages/ui/src/components/radar-provider.tsx b/packages/ui/src/components/radar-provider.tsx
index 1d407a07..c4a01cf5 100644
--- a/packages/ui/src/components/radar-provider.tsx
+++ b/packages/ui/src/components/radar-provider.tsx
@@ -70,7 +70,7 @@ export const RadarProvider = ({ children }: RadarProviderProps) => {
},
markNodeAsSeen: (accountId, workspaceId, nodeId) => {
window.colanode.executeMutation({
- type: 'node.mark.seen',
+ type: 'node.interaction.seen',
nodeId,
accountId,
workspaceId,
@@ -78,7 +78,7 @@ export const RadarProvider = ({ children }: RadarProviderProps) => {
},
markNodeAsOpened: (accountId, workspaceId, nodeId) => {
window.colanode.executeMutation({
- type: 'node.mark.opened',
+ type: 'node.interaction.opened',
nodeId,
accountId,
workspaceId,