Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion proto/auth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions proto/buffer.proto
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
26 changes: 17 additions & 9 deletions proto/cursor.proto
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -26,20 +28,26 @@ 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.
message CursorEvent {
// The user moving the cursor.
required common.Identifier user = 1;
// The new cursor position.
repeated CursorPosition position = 2;
required CursorUpdate position = 2;
}
23 changes: 12 additions & 11 deletions proto/session.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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;
}

Expand Down
60 changes: 42 additions & 18 deletions proto/workspace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -36,41 +38,63 @@ 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.
required string path = 1;
// 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.
required string before = 1;
// 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;
}
}