Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(server): internal api v1 specification #1392

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
97 changes: 97 additions & 0 deletions server/schemas/internel/v1/schema.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
syntax = "proto3";

package reearth.cms.v1;

import "google/protobuf/timestamp.proto";

option go_package = "proto/v1";

Comment on lines +1 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix directory structure and typo.

The directory structure needs to be adjusted:

  1. The package "reearth.cms.v1" should be within a directory "reearth/cms/v1"
  2. There's a typo in the directory name "internel" (should be "internal")

Please move this file to the correct directory structure and fix the typo:

-server/schemas/internel/v1/schema.proto
+server/schemas/internal/reearth/cms/v1/schema.proto
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
syntax = "proto3";
package reearth.cms.v1;
import "google/protobuf/timestamp.proto";
option go_package = "proto/v1";
// File moved to: server/schemas/internal/reearth/cms/v1/schema.proto
syntax = "proto3";
package reearth.cms.v1;
import "google/protobuf/timestamp.proto";
option go_package = "proto/v1";
🧰 Tools
🪛 Buf (1.47.2)

3-3: Files with package "reearth.cms.v1" must be within a directory "reearth/cms/v1" relative to root but were in directory "server/schemas/internel/v1".

(PACKAGE_DIRECTORY_MATCH)

service ReEarthCMS {
// Main operations
rpc CreateProject(CreateProjectRequest) returns (CreateProjectResponse) {}
rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) {}
rpc ListModels(ListModelsRequest) returns (ListModelsResponse) {}
rpc GetModelGeoJSONExportURL(ExportRequest) returns (ExportURLResponse) {}
}

// Implementation note:
// Authentication should be implemented using gRPC interceptors
// M2M tokens should be passed in metadata with key "authorization"
// Format: "Bearer <token>"
// UserId should be passed in metadata with key "user-id"

// Core messages
message Project {
string id = 1;
string name = 2;
string description = 3;
string workspace_id = 4;
ProjectPublication publication = 5;
google.protobuf.Timestamp created_at = 6;
google.protobuf.Timestamp updated_at = 7;
}

message ProjectPublication {
ProjectPublicationScope scope = 1;
bool asset_public = 2;
optional string token = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return the token? 🤔

}

enum ProjectPublicationScope {
SCOPE_UNSPECIFIED = 0;
PUBLIC = 1;
LIMITED = 2;
PRIVATE = 3;
}

message Model {
string id = 1;
string project_id = 2;
string name = 3;
string description = 4;
string key = 5;
bool public = 6;
google.protobuf.Timestamp created_at = 7;
google.protobuf.Timestamp updated_at = 8;
}
Comment on lines +47 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Rename the "public" field to avoid reserved word conflicts.

The public field in the Model message is a reserved word in many programming languages, which could cause issues during code generation.

 message Model {
   string id = 1;
   string project_id = 2;
   string name = 3;
   string description = 4;
   string key = 5;
-  bool public = 6;
+  bool is_public = 6;
   google.protobuf.Timestamp created_at = 7;
   google.protobuf.Timestamp updated_at = 8;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
message Model {
string id = 1;
string project_id = 2;
string name = 3;
string description = 4;
string key = 5;
bool public = 6;
google.protobuf.Timestamp created_at = 7;
google.protobuf.Timestamp updated_at = 8;
}
message Model {
string id = 1;
string project_id = 2;
string name = 3;
string description = 4;
string key = 5;
bool is_public = 6;
google.protobuf.Timestamp created_at = 7;
google.protobuf.Timestamp updated_at = 8;
}


// Request messages
message CreateProjectRequest {
string workspace_id = 1;
string name = 2;
string description = 3;
string alias = 4;
ProjectPublication publication = 5;
}

message ListProjectsRequest {
string workspace_id = 1;
}

message ListModelsRequest {
string project_id = 1;
}

message ExportRequest {
string project_id = 1;
string model_id = 2;
}

// Response messages
message CreateProjectResponse {
Project project = 1;
}

message ListProjectsResponse {
repeated Project projects = 1;
int32 total_count = 3;
}

message ListModelsResponse {
repeated Model models = 1;
int32 total_count = 3;
}
Comment on lines +85 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix field numbering in response messages.

The field numbers in ListProjectsResponse and ListModelsResponse are not sequential (skips number 2), which might indicate missing fields or a mistake.

 message ListProjectsResponse {
   repeated Project projects = 1;
-  int32 total_count = 3;
+  int32 total_count = 2;
 }

 message ListModelsResponse {
   repeated Model models = 1;
-  int32 total_count = 3;
+  int32 total_count = 2;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
message ListProjectsResponse {
repeated Project projects = 1;
int32 total_count = 3;
}
message ListModelsResponse {
repeated Model models = 1;
int32 total_count = 3;
}
message ListProjectsResponse {
repeated Project projects = 1;
int32 total_count = 2;
}
message ListModelsResponse {
repeated Model models = 1;
int32 total_count = 2;
}


message ExportURLResponse {
string url = 1;
}