diff --git a/Cargo.lock b/Cargo.lock index 24f8811..9980fab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,7 +97,6 @@ checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "codemp-proto" version = "0.8.0" - dependencies = [ "prost", "tonic", diff --git a/proto/auth.proto b/proto/auth.proto index 1f79acc..909cf80 100644 --- a/proto/auth.proto +++ b/proto/auth.proto @@ -8,7 +8,6 @@ import "common.proto"; service Auth { // Send credentials, returns valid session token. rpc Login (LoginRequest) returns (LoginResponse); - // If the given token has recently expired, get a new valid one. rpc Refresh (common.Token) returns (common.Token); } diff --git a/proto/buffer.proto b/proto/buffer.proto index 475f0d2..c73dd52 100644 --- a/proto/buffer.proto +++ b/proto/buffer.proto @@ -1,15 +1,15 @@ syntax = "proto2"; -import "common.proto"; - package buffer; +import "common.proto"; + // Handles buffer changes and keeps users in sync. service Buffer { // Attach to a buffer and receive operations. rpc Attach (stream Operation) returns (stream BufferEvent); - // Kicks all active users from the buffer. - rpc KickAll (common.Empty) returns (common.Empty); + // Send the keep alive signal and renew the token. + rpc KeepAlive (common.Empty) returns (common.Empty); } // Message representing an operation that has occurred. diff --git a/proto/cursor.proto b/proto/cursor.proto index a9c72a7..2490478 100644 --- a/proto/cursor.proto +++ b/proto/cursor.proto @@ -1,15 +1,17 @@ syntax = "proto2"; package cursor; + import "common.proto"; -import "files.proto"; // Handles cursor events and broadcasts them to all users. service Cursor { - // Retrieves all current cursor positions. + // Retrieves all current cursor positions. rpc List(common.Empty) returns (CursorEventList); // Subscribe to a workspace's cursor events. - rpc Attach (stream cursor.CursorPosition) returns (stream cursor.CursorEvent); + rpc Attach (stream CursorUpdate) returns (stream CursorEvent); + // Send the keep alive signal and renew the token. + rpc KeepAlive (common.Empty) returns (common.Empty); } // A message representing a list of cursor events. @@ -26,14 +28,20 @@ message RowCol { required int32 col = 2; } -// A message representing cursor position. +// A message representing a cursor position. message CursorPosition { - // The buffer where the cursor is located. - required files.BufferNode buffer = 1; // The cursor's start position. - required RowCol start = 2; + required RowCol start = 1; // The cursor's end position. - required RowCol end = 3; + required RowCol end = 2; +} + +// A message representing an update to the cursor position. +message CursorUpdate { + // The buffer where the cursor is located. + required string buffer = 1; + // A vector of cursor positions. + repeated CursorPosition cursors = 2; } // A message representing a cursor event. @@ -41,5 +49,5 @@ message CursorEvent { // The user moving the cursor. required common.Identifier user = 1; // The new cursor position. - repeated CursorPosition position = 2; + required CursorUpdate position = 2; } diff --git a/proto/session.proto b/proto/session.proto index 2f97fcf..d6f56e7 100644 --- a/proto/session.proto +++ b/proto/session.proto @@ -8,18 +8,24 @@ import "common.proto"; service Session { // Attach to a session and receive events. rpc Attach (common.Empty) returns (stream SessionEvent); - // Handle a workspace access request and return a workspace token. - rpc AccessWorkspace (WorkspaceRequest) returns (common.Token); + // Handle a workspace access request and return a workspace token for it given it's UUID. + rpc GetWorkspaceToken (common.Identifier) returns (common.Token); + // Quit a workspace given it's UUID. + rpc QuitWorkspace (common.Identifier) returns (common.Empty); // Create a workspace. rpc CreateWorkspace (OwnedWorkspaceRequest) returns (common.WorkspaceInfo); - // Delete a workspace. - rpc DeleteWorkspace (OwnedWorkspaceRequest) returns (common.Empty); + // Delete a workspace given it's UUID. + rpc DeleteWorkspace (common.Identifier) returns (common.Empty); // List all workspaces the user has been invited to. rpc FetchInvitedWorkspaces (common.Empty) returns (WorkspacesInvitedList); - //List all workspaces the user owns. + // List all workspaces the user owns. rpc FetchOwnedWorkspaces (common.Empty) returns (WorkspacesOwnedList); // Handle a workspace invite request. rpc InviteToWorkspace (InviteRequest) returns (common.Empty); + // Accept a pending invite to a workspace given it's UUID. + rpc AcceptInvite (common.Identifier) returns (common.Empty); + // Reject a pending invite to a workspace given it's UUID. + rpc RejectInvite (common.Identifier) returns (common.Empty); } // A message representing a request for an owned workspace. @@ -28,11 +34,6 @@ message OwnedWorkspaceRequest { required string name = 1; } -// A message representing a request for a specific workspace. -message WorkspaceRequest { - required common.Identifier id = 1; -} - // A message representing a list of workspaces. message WorkspacesInvitedList { // A vector of workspaces the user is invited to. @@ -49,7 +50,7 @@ message WorkspacesOwnedList { message InviteRequest { // The user the invitation is for. required string user = 1; - // The workspace the invitation is for. + // The workspace's uuid the invitation is for. required common.Identifier workspace = 2; } diff --git a/proto/workspace.proto b/proto/workspace.proto index 33e3fd4..a84f217 100644 --- a/proto/workspace.proto +++ b/proto/workspace.proto @@ -11,20 +11,22 @@ service Workspace { rpc Attach (common.Empty) returns (stream WorkspaceEvent); // Create a buffer within the workspace. rpc CreateBuffer (files.BufferNode) returns (common.Empty); - // Access a buffer within the workspace and returns a buffer token for it. - rpc AccessBuffer (files.BufferNode) returns (common.Token); - // Transforms an ephemeral buffer in a persistent one. - rpc PinBuffer (files.BufferRequest) returns (common.Empty); - // Delete a buffer. - rpc DeleteBuffer (files.BufferRequest) returns (common.Empty); - // List buffers in the workspace that are children of the given path. - rpc ListBuffers (files.BufferRequest) returns (files.BufferTree); - // List users in the workspace. - rpc ListUsers (common.Empty) returns (UserList); - // List users within a given buffer. - rpc ListBufferUsers (files.BufferRequest) returns (UserList); - // Revokes all invites and kicks all active users. - rpc KickAll (common.Empty) returns (common.Empty); + // Handle a buffer access request and return a buffer token for it given it's UUID. + rpc GetBufferToken (common.Identifier) returns (common.Token); + // Transforms an ephemeral buffer in a persistent one given it's UUID. + rpc PinBuffer (common.Identifier) returns (common.Empty); + // Transforms a persistent buffer in an ephemeral one given it's UUID. + rpc UnPinBuffer (common.Identifier) returns (common.Empty); + // Delete a buffer given it's UUID. + rpc DeleteBuffer (common.Identifier) returns (common.Empty); + // Retrieves the buffers in the workspace that are children of the given path. + rpc FetchBuffers (files.BufferRequest) returns (files.BufferTree); + // Retrieves the users in the workspace. + rpc FetchUsers (common.Empty) returns (UserList); + // Retrives the users within a given buffer. + rpc FetchBufferUsers (files.BufferRequest) returns (UserList); + // Send the keep alive signal and renew the token. + rpc KeepAlive (common.Empty) returns (common.Empty); } // A message representing a list of users. @@ -36,15 +38,17 @@ message UserList { // A message representing a workspace event. message WorkspaceEvent { // Event that occurs when a user joins a workspace. - message UserJoin { + message UserJoinWorkspace { // The user that joined. required common.User user = 1; } + // Event that occurs when a user leaves a workspace. - message UserLeave { + message UserLeaveWorkspace { // The user that left. required common.User user = 1; } + // Event that occurs when a file is created in a workspace. message FileCreate { // The path of the created file. @@ -52,6 +56,7 @@ message WorkspaceEvent { // Whether the buffer is ephemeral. required bool ephemeral = 2; } + // Event that occurs when a file is renamed in a workspace. message FileRename { // The old path of the file. @@ -59,18 +64,37 @@ message WorkspaceEvent { // The new path of the file. required string after = 2; } + // Event that occurs when a file is deleted in a workspace. message FileDelete { // The path of the deleted file required string path = 1; } + // Event that occurs when a user joins a buffer. + message UserJoinBuffer { + // The user that joined. + required common.User user = 1; + // The buffer the event happened on. + required string buffer = 2; + } + + // Event that occurs when a user leaves a buffer. + message UserLeaveBuffer { + // The user that left. + required common.User user = 1; + // The buffer the event happened on. + required string buffer = 2; + } + // The union containing actual event. oneof event { - UserJoin join = 1; - UserLeave leave = 2; + UserJoinWorkspace workspace_join = 1; + UserLeaveWorkspace workspace_leave = 2; FileCreate create = 3; FileRename rename = 4; FileDelete delete = 5; + UserJoinBuffer buffer_join = 6; + UserLeaveBuffer buffer_leave = 7; } }