Commit d71fd2f8 authored by Steven's avatar Steven

refactor: auth service

parent 9972a77d
...@@ -4,26 +4,40 @@ package memos.api.v1; ...@@ -4,26 +4,40 @@ package memos.api.v1;
import "api/v1/user_service.proto"; import "api/v1/user_service.proto";
import "google/api/annotations.proto"; import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/empty.proto"; import "google/protobuf/empty.proto";
option go_package = "gen/api/v1"; option go_package = "gen/api/v1";
service AuthService { service AuthService {
// GetAuthStatus returns the current auth status of the user. // GetAuthStatus returns the current authentication status of the user.
// This method is idempotent and safe, suitable for checking authentication state.
rpc GetAuthStatus(GetAuthStatusRequest) returns (User) { rpc GetAuthStatus(GetAuthStatusRequest) returns (User) {
option (google.api.http) = {post: "/api/v1/auth/status"}; option (google.api.http) = {get: "/api/v1/auth/status"};
} }
// SignIn signs in the user.
rpc SignIn(SignInRequest) returns (User) { // CreateSession authenticates a user and creates a new session.
option (google.api.http) = {post: "/api/v1/auth/signin"}; // Returns the authenticated user information upon successful authentication.
rpc CreateSession(CreateSessionRequest) returns (User) {
option (google.api.http) = {
post: "/api/v1/auth/sessions"
body: "*"
};
} }
// SignUp signs up the user with the given username and password.
rpc SignUp(SignUpRequest) returns (User) { // RegisterUser creates a new user account with username and password.
option (google.api.http) = {post: "/api/v1/auth/signup"}; // Returns the newly created user information upon successful registration.
rpc RegisterUser(RegisterUserRequest) returns (User) {
option (google.api.http) = {
post: "/api/v1/auth/users"
body: "*"
};
} }
// SignOut signs out the user.
rpc SignOut(SignOutRequest) returns (google.protobuf.Empty) { // DeleteSession terminates the current user session.
option (google.api.http) = {post: "/api/v1/auth/signout"}; // This is an idempotent operation that invalidates the user's authentication.
rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v1/auth/sessions/current"};
} }
} }
...@@ -33,8 +47,9 @@ message GetAuthStatusResponse { ...@@ -33,8 +47,9 @@ message GetAuthStatusResponse {
User user = 1; User user = 1;
} }
message SignInRequest { message CreateSessionRequest {
// Provide one authentication method (username/password or SSO). // Provide one authentication method (username/password or SSO).
// Required field to specify the authentication method.
oneof method { oneof method {
// Username and password authentication method. // Username and password authentication method.
PasswordCredentials password_credentials = 1; PasswordCredentials password_credentials = 1;
...@@ -42,31 +57,44 @@ message SignInRequest { ...@@ -42,31 +57,44 @@ message SignInRequest {
// SSO provider authentication method. // SSO provider authentication method.
SSOCredentials sso_credentials = 2; SSOCredentials sso_credentials = 2;
} }
// Whether the session should never expire. // Whether the session should never expire.
bool never_expire = 3; // Optional field that defaults to false for security.
bool never_expire = 3 [(google.api.field_behavior) = OPTIONAL];
} }
message PasswordCredentials { message PasswordCredentials {
// The username to sign in with. // The username to sign in with.
string username = 1; // Required field for password-based authentication.
string username = 1 [(google.api.field_behavior) = REQUIRED];
// The password to sign in with. // The password to sign in with.
string password = 2; // Required field for password-based authentication.
string password = 2 [(google.api.field_behavior) = REQUIRED];
} }
message SSOCredentials { message SSOCredentials {
// The ID of the SSO provider. // The ID of the SSO provider.
int32 idp_id = 1; // Required field to identify the SSO provider.
// The code to sign in with. int32 idp_id = 1 [(google.api.field_behavior) = REQUIRED];
string code = 2;
// The redirect URI. // The authorization code from the SSO provider.
string redirect_uri = 3; // Required field for completing the SSO flow.
string code = 2 [(google.api.field_behavior) = REQUIRED];
// The redirect URI used in the SSO flow.
// Required field for security validation.
string redirect_uri = 3 [(google.api.field_behavior) = REQUIRED];
} }
message SignUpRequest { message RegisterUserRequest {
// The username to sign up with. // The username to sign up with.
string username = 1; // Required field that must be unique across the system.
string username = 1 [(google.api.field_behavior) = REQUIRED];
// The password to sign up with. // The password to sign up with.
string password = 2; // Required field that should meet security requirements.
string password = 2 [(google.api.field_behavior) = REQUIRED];
} }
message SignOutRequest {} message DeleteSessionRequest {}
...@@ -3,68 +3,88 @@ syntax = "proto3"; ...@@ -3,68 +3,88 @@ syntax = "proto3";
package memos.api.v1; package memos.api.v1;
import "google/api/annotations.proto"; import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
option go_package = "gen/api/v1"; option go_package = "gen/api/v1";
service MarkdownService { service MarkdownService {
// ParseMarkdown parses the given markdown content and returns a list of nodes. // ParseMarkdown parses the given markdown content and returns a list of nodes.
// This is a utility method that transforms markdown text into structured nodes.
rpc ParseMarkdown(ParseMarkdownRequest) returns (ParseMarkdownResponse) { rpc ParseMarkdown(ParseMarkdownRequest) returns (ParseMarkdownResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/markdown:parse" post: "/api/v1/markdown:parse"
body: "*" body: "*"
}; };
} }
// RestoreMarkdownNodes restores the given nodes to markdown content. // RestoreMarkdownNodes restores the given nodes to markdown content.
// This is the inverse operation of ParseMarkdown.
rpc RestoreMarkdownNodes(RestoreMarkdownNodesRequest) returns (RestoreMarkdownNodesResponse) { rpc RestoreMarkdownNodes(RestoreMarkdownNodesRequest) returns (RestoreMarkdownNodesResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/markdown/node:restore" post: "/api/v1/markdown:restore"
body: "*" body: "*"
}; };
} }
// StringifyMarkdownNodes stringify the given nodes to plain text content. // StringifyMarkdownNodes stringify the given nodes to plain text content.
// This removes all markdown formatting and returns plain text.
rpc StringifyMarkdownNodes(StringifyMarkdownNodesRequest) returns (StringifyMarkdownNodesResponse) { rpc StringifyMarkdownNodes(StringifyMarkdownNodesRequest) returns (StringifyMarkdownNodesResponse) {
option (google.api.http) = { option (google.api.http) = {
post: "/api/v1/markdown/node:stringify" post: "/api/v1/markdown:stringify"
body: "*" body: "*"
}; };
} }
// GetLinkMetadata returns metadata for a given link. // GetLinkMetadata returns metadata for a given link.
// This is useful for generating link previews.
rpc GetLinkMetadata(GetLinkMetadataRequest) returns (LinkMetadata) { rpc GetLinkMetadata(GetLinkMetadataRequest) returns (LinkMetadata) {
option (google.api.http) = {get: "/api/v1/markdown/link:metadata"}; option (google.api.http) = {get: "/api/v1/markdown/links:getMetadata"};
} }
} }
message ParseMarkdownRequest { message ParseMarkdownRequest {
string markdown = 1; // The markdown content to parse.
string markdown = 1 [(google.api.field_behavior) = REQUIRED];
} }
message ParseMarkdownResponse { message ParseMarkdownResponse {
// The parsed markdown nodes.
repeated Node nodes = 1; repeated Node nodes = 1;
} }
message RestoreMarkdownNodesRequest { message RestoreMarkdownNodesRequest {
repeated Node nodes = 1; // The nodes to restore to markdown content.
repeated Node nodes = 1 [(google.api.field_behavior) = REQUIRED];
} }
message RestoreMarkdownNodesResponse { message RestoreMarkdownNodesResponse {
// The restored markdown content.
string markdown = 1; string markdown = 1;
} }
message StringifyMarkdownNodesRequest { message StringifyMarkdownNodesRequest {
repeated Node nodes = 1; // The nodes to stringify to plain text.
repeated Node nodes = 1 [(google.api.field_behavior) = REQUIRED];
} }
message StringifyMarkdownNodesResponse { message StringifyMarkdownNodesResponse {
// The plain text content.
string plain_text = 1; string plain_text = 1;
} }
message GetLinkMetadataRequest { message GetLinkMetadataRequest {
string link = 1; // The link URL to get metadata for.
string link = 1 [(google.api.field_behavior) = REQUIRED];
} }
message LinkMetadata { message LinkMetadata {
// The title of the linked page.
string title = 1; string title = 1;
// The description of the linked page.
string description = 2; string description = 2;
// The URL of the preview image for the linked page.
string image = 3; string image = 3;
} }
...@@ -218,7 +238,10 @@ message TableNode { ...@@ -218,7 +238,10 @@ message TableNode {
} }
message EmbeddedContentNode { message EmbeddedContentNode {
// The resource name of the embedded content.
string resource_name = 1; string resource_name = 1;
// Additional parameters for the embedded content.
string params = 2; string params = 2;
} }
...@@ -289,7 +312,10 @@ message SuperscriptNode { ...@@ -289,7 +312,10 @@ message SuperscriptNode {
} }
message ReferencedContentNode { message ReferencedContentNode {
// The resource name of the referenced content.
string resource_name = 1; string resource_name = 1;
// Additional parameters for the referenced content.
string params = 2; string params = 2;
} }
......
...@@ -103,35 +103,37 @@ func (x *GetAuthStatusResponse) GetUser() *User { ...@@ -103,35 +103,37 @@ func (x *GetAuthStatusResponse) GetUser() *User {
return nil return nil
} }
type SignInRequest struct { type CreateSessionRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// Provide one authentication method (username/password or SSO). // Provide one authentication method (username/password or SSO).
// Required field to specify the authentication method.
// //
// Types that are valid to be assigned to Method: // Types that are valid to be assigned to Method:
// //
// *SignInRequest_PasswordCredentials // *CreateSessionRequest_PasswordCredentials
// *SignInRequest_SsoCredentials // *CreateSessionRequest_SsoCredentials
Method isSignInRequest_Method `protobuf_oneof:"method"` Method isCreateSessionRequest_Method `protobuf_oneof:"method"`
// Whether the session should never expire. // Whether the session should never expire.
// Optional field that defaults to false for security.
NeverExpire bool `protobuf:"varint,3,opt,name=never_expire,json=neverExpire,proto3" json:"never_expire,omitempty"` NeverExpire bool `protobuf:"varint,3,opt,name=never_expire,json=neverExpire,proto3" json:"never_expire,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
func (x *SignInRequest) Reset() { func (x *CreateSessionRequest) Reset() {
*x = SignInRequest{} *x = CreateSessionRequest{}
mi := &file_api_v1_auth_service_proto_msgTypes[2] mi := &file_api_v1_auth_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
func (x *SignInRequest) String() string { func (x *CreateSessionRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*SignInRequest) ProtoMessage() {} func (*CreateSessionRequest) ProtoMessage() {}
func (x *SignInRequest) ProtoReflect() protoreflect.Message { func (x *CreateSessionRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_v1_auth_service_proto_msgTypes[2] mi := &file_api_v1_auth_service_proto_msgTypes[2]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
...@@ -143,66 +145,68 @@ func (x *SignInRequest) ProtoReflect() protoreflect.Message { ...@@ -143,66 +145,68 @@ func (x *SignInRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use SignInRequest.ProtoReflect.Descriptor instead. // Deprecated: Use CreateSessionRequest.ProtoReflect.Descriptor instead.
func (*SignInRequest) Descriptor() ([]byte, []int) { func (*CreateSessionRequest) Descriptor() ([]byte, []int) {
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{2} return file_api_v1_auth_service_proto_rawDescGZIP(), []int{2}
} }
func (x *SignInRequest) GetMethod() isSignInRequest_Method { func (x *CreateSessionRequest) GetMethod() isCreateSessionRequest_Method {
if x != nil { if x != nil {
return x.Method return x.Method
} }
return nil return nil
} }
func (x *SignInRequest) GetPasswordCredentials() *PasswordCredentials { func (x *CreateSessionRequest) GetPasswordCredentials() *PasswordCredentials {
if x != nil { if x != nil {
if x, ok := x.Method.(*SignInRequest_PasswordCredentials); ok { if x, ok := x.Method.(*CreateSessionRequest_PasswordCredentials); ok {
return x.PasswordCredentials return x.PasswordCredentials
} }
} }
return nil return nil
} }
func (x *SignInRequest) GetSsoCredentials() *SSOCredentials { func (x *CreateSessionRequest) GetSsoCredentials() *SSOCredentials {
if x != nil { if x != nil {
if x, ok := x.Method.(*SignInRequest_SsoCredentials); ok { if x, ok := x.Method.(*CreateSessionRequest_SsoCredentials); ok {
return x.SsoCredentials return x.SsoCredentials
} }
} }
return nil return nil
} }
func (x *SignInRequest) GetNeverExpire() bool { func (x *CreateSessionRequest) GetNeverExpire() bool {
if x != nil { if x != nil {
return x.NeverExpire return x.NeverExpire
} }
return false return false
} }
type isSignInRequest_Method interface { type isCreateSessionRequest_Method interface {
isSignInRequest_Method() isCreateSessionRequest_Method()
} }
type SignInRequest_PasswordCredentials struct { type CreateSessionRequest_PasswordCredentials struct {
// Username and password authentication method. // Username and password authentication method.
PasswordCredentials *PasswordCredentials `protobuf:"bytes,1,opt,name=password_credentials,json=passwordCredentials,proto3,oneof"` PasswordCredentials *PasswordCredentials `protobuf:"bytes,1,opt,name=password_credentials,json=passwordCredentials,proto3,oneof"`
} }
type SignInRequest_SsoCredentials struct { type CreateSessionRequest_SsoCredentials struct {
// SSO provider authentication method. // SSO provider authentication method.
SsoCredentials *SSOCredentials `protobuf:"bytes,2,opt,name=sso_credentials,json=ssoCredentials,proto3,oneof"` SsoCredentials *SSOCredentials `protobuf:"bytes,2,opt,name=sso_credentials,json=ssoCredentials,proto3,oneof"`
} }
func (*SignInRequest_PasswordCredentials) isSignInRequest_Method() {} func (*CreateSessionRequest_PasswordCredentials) isCreateSessionRequest_Method() {}
func (*SignInRequest_SsoCredentials) isSignInRequest_Method() {} func (*CreateSessionRequest_SsoCredentials) isCreateSessionRequest_Method() {}
type PasswordCredentials struct { type PasswordCredentials struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The username to sign in with. // The username to sign in with.
// Required field for password-based authentication.
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
// The password to sign in with. // The password to sign in with.
// Required field for password-based authentication.
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -255,10 +259,13 @@ func (x *PasswordCredentials) GetPassword() string { ...@@ -255,10 +259,13 @@ func (x *PasswordCredentials) GetPassword() string {
type SSOCredentials struct { type SSOCredentials struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The ID of the SSO provider. // The ID of the SSO provider.
// Required field to identify the SSO provider.
IdpId int32 `protobuf:"varint,1,opt,name=idp_id,json=idpId,proto3" json:"idp_id,omitempty"` IdpId int32 `protobuf:"varint,1,opt,name=idp_id,json=idpId,proto3" json:"idp_id,omitempty"`
// The code to sign in with. // The authorization code from the SSO provider.
// Required field for completing the SSO flow.
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
// The redirect URI. // The redirect URI used in the SSO flow.
// Required field for security validation.
RedirectUri string `protobuf:"bytes,3,opt,name=redirect_uri,json=redirectUri,proto3" json:"redirect_uri,omitempty"` RedirectUri string `protobuf:"bytes,3,opt,name=redirect_uri,json=redirectUri,proto3" json:"redirect_uri,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -315,30 +322,32 @@ func (x *SSOCredentials) GetRedirectUri() string { ...@@ -315,30 +322,32 @@ func (x *SSOCredentials) GetRedirectUri() string {
return "" return ""
} }
type SignUpRequest struct { type RegisterUserRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The username to sign up with. // The username to sign up with.
// Required field that must be unique across the system.
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
// The password to sign up with. // The password to sign up with.
// Required field that should meet security requirements.
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
func (x *SignUpRequest) Reset() { func (x *RegisterUserRequest) Reset() {
*x = SignUpRequest{} *x = RegisterUserRequest{}
mi := &file_api_v1_auth_service_proto_msgTypes[5] mi := &file_api_v1_auth_service_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
func (x *SignUpRequest) String() string { func (x *RegisterUserRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*SignUpRequest) ProtoMessage() {} func (*RegisterUserRequest) ProtoMessage() {}
func (x *SignUpRequest) ProtoReflect() protoreflect.Message { func (x *RegisterUserRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_v1_auth_service_proto_msgTypes[5] mi := &file_api_v1_auth_service_proto_msgTypes[5]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
...@@ -350,45 +359,45 @@ func (x *SignUpRequest) ProtoReflect() protoreflect.Message { ...@@ -350,45 +359,45 @@ func (x *SignUpRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use SignUpRequest.ProtoReflect.Descriptor instead. // Deprecated: Use RegisterUserRequest.ProtoReflect.Descriptor instead.
func (*SignUpRequest) Descriptor() ([]byte, []int) { func (*RegisterUserRequest) Descriptor() ([]byte, []int) {
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{5} return file_api_v1_auth_service_proto_rawDescGZIP(), []int{5}
} }
func (x *SignUpRequest) GetUsername() string { func (x *RegisterUserRequest) GetUsername() string {
if x != nil { if x != nil {
return x.Username return x.Username
} }
return "" return ""
} }
func (x *SignUpRequest) GetPassword() string { func (x *RegisterUserRequest) GetPassword() string {
if x != nil { if x != nil {
return x.Password return x.Password
} }
return "" return ""
} }
type SignOutRequest struct { type DeleteSessionRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
} }
func (x *SignOutRequest) Reset() { func (x *DeleteSessionRequest) Reset() {
*x = SignOutRequest{} *x = DeleteSessionRequest{}
mi := &file_api_v1_auth_service_proto_msgTypes[6] mi := &file_api_v1_auth_service_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
func (x *SignOutRequest) String() string { func (x *DeleteSessionRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*SignOutRequest) ProtoMessage() {} func (*DeleteSessionRequest) ProtoMessage() {}
func (x *SignOutRequest) ProtoReflect() protoreflect.Message { func (x *DeleteSessionRequest) ProtoReflect() protoreflect.Message {
mi := &file_api_v1_auth_service_proto_msgTypes[6] mi := &file_api_v1_auth_service_proto_msgTypes[6]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
...@@ -400,8 +409,8 @@ func (x *SignOutRequest) ProtoReflect() protoreflect.Message { ...@@ -400,8 +409,8 @@ func (x *SignOutRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use SignOutRequest.ProtoReflect.Descriptor instead. // Deprecated: Use DeleteSessionRequest.ProtoReflect.Descriptor instead.
func (*SignOutRequest) Descriptor() ([]byte, []int) { func (*DeleteSessionRequest) Descriptor() ([]byte, []int) {
return file_api_v1_auth_service_proto_rawDescGZIP(), []int{6} return file_api_v1_auth_service_proto_rawDescGZIP(), []int{6}
} }
...@@ -409,31 +418,31 @@ var File_api_v1_auth_service_proto protoreflect.FileDescriptor ...@@ -409,31 +418,31 @@ var File_api_v1_auth_service_proto protoreflect.FileDescriptor
const file_api_v1_auth_service_proto_rawDesc = "" + const file_api_v1_auth_service_proto_rawDesc = "" +
"\n" + "\n" +
"\x19api/v1/auth_service.proto\x12\fmemos.api.v1\x1a\x19api/v1/user_service.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x16\n" + "\x19api/v1/auth_service.proto\x12\fmemos.api.v1\x1a\x19api/v1/user_service.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x16\n" +
"\x14GetAuthStatusRequest\"?\n" + "\x14GetAuthStatusRequest\"?\n" +
"\x15GetAuthStatusResponse\x12&\n" + "\x15GetAuthStatusResponse\x12&\n" +
"\x04user\x18\x01 \x01(\v2\x12.memos.api.v1.UserR\x04user\"\xdd\x01\n" + "\x04user\x18\x01 \x01(\v2\x12.memos.api.v1.UserR\x04user\"\xe9\x01\n" +
"\rSignInRequest\x12V\n" + "\x14CreateSessionRequest\x12V\n" +
"\x14password_credentials\x18\x01 \x01(\v2!.memos.api.v1.PasswordCredentialsH\x00R\x13passwordCredentials\x12G\n" + "\x14password_credentials\x18\x01 \x01(\v2!.memos.api.v1.PasswordCredentialsH\x00R\x13passwordCredentials\x12G\n" +
"\x0fsso_credentials\x18\x02 \x01(\v2\x1c.memos.api.v1.SSOCredentialsH\x00R\x0essoCredentials\x12!\n" + "\x0fsso_credentials\x18\x02 \x01(\v2\x1c.memos.api.v1.SSOCredentialsH\x00R\x0essoCredentials\x12&\n" +
"\fnever_expire\x18\x03 \x01(\bR\vneverExpireB\b\n" + "\fnever_expire\x18\x03 \x01(\bB\x03\xe0A\x01R\vneverExpireB\b\n" +
"\x06method\"M\n" + "\x06method\"W\n" +
"\x13PasswordCredentials\x12\x1a\n" + "\x13PasswordCredentials\x12\x1f\n" +
"\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\busername\x18\x01 \x01(\tB\x03\xe0A\x02R\busername\x12\x1f\n" +
"\bpassword\x18\x02 \x01(\tR\bpassword\"^\n" + "\bpassword\x18\x02 \x01(\tB\x03\xe0A\x02R\bpassword\"m\n" +
"\x0eSSOCredentials\x12\x15\n" + "\x0eSSOCredentials\x12\x1a\n" +
"\x06idp_id\x18\x01 \x01(\x05R\x05idpId\x12\x12\n" + "\x06idp_id\x18\x01 \x01(\x05B\x03\xe0A\x02R\x05idpId\x12\x17\n" +
"\x04code\x18\x02 \x01(\tR\x04code\x12!\n" + "\x04code\x18\x02 \x01(\tB\x03\xe0A\x02R\x04code\x12&\n" +
"\fredirect_uri\x18\x03 \x01(\tR\vredirectUri\"G\n" + "\fredirect_uri\x18\x03 \x01(\tB\x03\xe0A\x02R\vredirectUri\"W\n" +
"\rSignUpRequest\x12\x1a\n" + "\x13RegisterUserRequest\x12\x1f\n" +
"\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\busername\x18\x01 \x01(\tB\x03\xe0A\x02R\busername\x12\x1f\n" +
"\bpassword\x18\x02 \x01(\tR\bpassword\"\x10\n" + "\bpassword\x18\x02 \x01(\tB\x03\xe0A\x02R\bpassword\"\x16\n" +
"\x0eSignOutRequest2\x82\x03\n" + "\x14DeleteSessionRequest2\xb8\x03\n" +
"\vAuthService\x12d\n" + "\vAuthService\x12d\n" +
"\rGetAuthStatus\x12\".memos.api.v1.GetAuthStatusRequest\x1a\x12.memos.api.v1.User\"\x1b\x82\xd3\xe4\x93\x02\x15\"\x13/api/v1/auth/status\x12V\n" + "\rGetAuthStatus\x12\".memos.api.v1.GetAuthStatusRequest\x1a\x12.memos.api.v1.User\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/api/v1/auth/status\x12i\n" +
"\x06SignIn\x12\x1b.memos.api.v1.SignInRequest\x1a\x12.memos.api.v1.User\"\x1b\x82\xd3\xe4\x93\x02\x15\"\x13/api/v1/auth/signin\x12V\n" + "\rCreateSession\x12\".memos.api.v1.CreateSessionRequest\x1a\x12.memos.api.v1.User\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/auth/sessions\x12d\n" +
"\x06SignUp\x12\x1b.memos.api.v1.SignUpRequest\x1a\x12.memos.api.v1.User\"\x1b\x82\xd3\xe4\x93\x02\x15\"\x13/api/v1/auth/signup\x12]\n" + "\fRegisterUser\x12!.memos.api.v1.RegisterUserRequest\x1a\x12.memos.api.v1.User\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/users\x12r\n" +
"\aSignOut\x12\x1c.memos.api.v1.SignOutRequest\x1a\x16.google.protobuf.Empty\"\x1c\x82\xd3\xe4\x93\x02\x16\"\x14/api/v1/auth/signoutB\xa8\x01\n" + "\rDeleteSession\x12\".memos.api.v1.DeleteSessionRequest\x1a\x16.google.protobuf.Empty\"%\x82\xd3\xe4\x93\x02\x1f*\x1d/api/v1/auth/sessions/currentB\xa8\x01\n" +
"\x10com.memos.api.v1B\x10AuthServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3" "\x10com.memos.api.v1B\x10AuthServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3"
var ( var (
...@@ -452,26 +461,26 @@ var file_api_v1_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7) ...@@ -452,26 +461,26 @@ var file_api_v1_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_api_v1_auth_service_proto_goTypes = []any{ var file_api_v1_auth_service_proto_goTypes = []any{
(*GetAuthStatusRequest)(nil), // 0: memos.api.v1.GetAuthStatusRequest (*GetAuthStatusRequest)(nil), // 0: memos.api.v1.GetAuthStatusRequest
(*GetAuthStatusResponse)(nil), // 1: memos.api.v1.GetAuthStatusResponse (*GetAuthStatusResponse)(nil), // 1: memos.api.v1.GetAuthStatusResponse
(*SignInRequest)(nil), // 2: memos.api.v1.SignInRequest (*CreateSessionRequest)(nil), // 2: memos.api.v1.CreateSessionRequest
(*PasswordCredentials)(nil), // 3: memos.api.v1.PasswordCredentials (*PasswordCredentials)(nil), // 3: memos.api.v1.PasswordCredentials
(*SSOCredentials)(nil), // 4: memos.api.v1.SSOCredentials (*SSOCredentials)(nil), // 4: memos.api.v1.SSOCredentials
(*SignUpRequest)(nil), // 5: memos.api.v1.SignUpRequest (*RegisterUserRequest)(nil), // 5: memos.api.v1.RegisterUserRequest
(*SignOutRequest)(nil), // 6: memos.api.v1.SignOutRequest (*DeleteSessionRequest)(nil), // 6: memos.api.v1.DeleteSessionRequest
(*User)(nil), // 7: memos.api.v1.User (*User)(nil), // 7: memos.api.v1.User
(*emptypb.Empty)(nil), // 8: google.protobuf.Empty (*emptypb.Empty)(nil), // 8: google.protobuf.Empty
} }
var file_api_v1_auth_service_proto_depIdxs = []int32{ var file_api_v1_auth_service_proto_depIdxs = []int32{
7, // 0: memos.api.v1.GetAuthStatusResponse.user:type_name -> memos.api.v1.User 7, // 0: memos.api.v1.GetAuthStatusResponse.user:type_name -> memos.api.v1.User
3, // 1: memos.api.v1.SignInRequest.password_credentials:type_name -> memos.api.v1.PasswordCredentials 3, // 1: memos.api.v1.CreateSessionRequest.password_credentials:type_name -> memos.api.v1.PasswordCredentials
4, // 2: memos.api.v1.SignInRequest.sso_credentials:type_name -> memos.api.v1.SSOCredentials 4, // 2: memos.api.v1.CreateSessionRequest.sso_credentials:type_name -> memos.api.v1.SSOCredentials
0, // 3: memos.api.v1.AuthService.GetAuthStatus:input_type -> memos.api.v1.GetAuthStatusRequest 0, // 3: memos.api.v1.AuthService.GetAuthStatus:input_type -> memos.api.v1.GetAuthStatusRequest
2, // 4: memos.api.v1.AuthService.SignIn:input_type -> memos.api.v1.SignInRequest 2, // 4: memos.api.v1.AuthService.CreateSession:input_type -> memos.api.v1.CreateSessionRequest
5, // 5: memos.api.v1.AuthService.SignUp:input_type -> memos.api.v1.SignUpRequest 5, // 5: memos.api.v1.AuthService.RegisterUser:input_type -> memos.api.v1.RegisterUserRequest
6, // 6: memos.api.v1.AuthService.SignOut:input_type -> memos.api.v1.SignOutRequest 6, // 6: memos.api.v1.AuthService.DeleteSession:input_type -> memos.api.v1.DeleteSessionRequest
7, // 7: memos.api.v1.AuthService.GetAuthStatus:output_type -> memos.api.v1.User 7, // 7: memos.api.v1.AuthService.GetAuthStatus:output_type -> memos.api.v1.User
7, // 8: memos.api.v1.AuthService.SignIn:output_type -> memos.api.v1.User 7, // 8: memos.api.v1.AuthService.CreateSession:output_type -> memos.api.v1.User
7, // 9: memos.api.v1.AuthService.SignUp:output_type -> memos.api.v1.User 7, // 9: memos.api.v1.AuthService.RegisterUser:output_type -> memos.api.v1.User
8, // 10: memos.api.v1.AuthService.SignOut:output_type -> google.protobuf.Empty 8, // 10: memos.api.v1.AuthService.DeleteSession:output_type -> google.protobuf.Empty
7, // [7:11] is the sub-list for method output_type 7, // [7:11] is the sub-list for method output_type
3, // [3:7] is the sub-list for method input_type 3, // [3:7] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension type_name
...@@ -486,8 +495,8 @@ func file_api_v1_auth_service_proto_init() { ...@@ -486,8 +495,8 @@ func file_api_v1_auth_service_proto_init() {
} }
file_api_v1_user_service_proto_init() file_api_v1_user_service_proto_init()
file_api_v1_auth_service_proto_msgTypes[2].OneofWrappers = []any{ file_api_v1_auth_service_proto_msgTypes[2].OneofWrappers = []any{
(*SignInRequest_PasswordCredentials)(nil), (*CreateSessionRequest_PasswordCredentials)(nil),
(*SignInRequest_SsoCredentials)(nil), (*CreateSessionRequest_SsoCredentials)(nil),
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
......
...@@ -54,88 +54,70 @@ func local_request_AuthService_GetAuthStatus_0(ctx context.Context, marshaler ru ...@@ -54,88 +54,70 @@ func local_request_AuthService_GetAuthStatus_0(ctx context.Context, marshaler ru
return msg, metadata, err return msg, metadata, err
} }
var filter_AuthService_SignIn_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_AuthService_CreateSession_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func request_AuthService_SignIn_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var ( var (
protoReq SignInRequest protoReq CreateSessionRequest
metadata runtime.ServerMetadata metadata runtime.ServerMetadata
) )
io.Copy(io.Discard, req.Body) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_SignIn_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
} }
msg, err := client.SignIn(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) msg, err := client.CreateSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err return msg, metadata, err
} }
func local_request_AuthService_SignIn_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { func local_request_AuthService_CreateSession_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var ( var (
protoReq SignInRequest protoReq CreateSessionRequest
metadata runtime.ServerMetadata metadata runtime.ServerMetadata
) )
if err := req.ParseForm(); err != nil { if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_SignIn_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
} }
msg, err := server.SignIn(ctx, &protoReq) msg, err := server.CreateSession(ctx, &protoReq)
return msg, metadata, err return msg, metadata, err
} }
var filter_AuthService_SignUp_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_AuthService_RegisterUser_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
func request_AuthService_SignUp_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var ( var (
protoReq SignUpRequest protoReq RegisterUserRequest
metadata runtime.ServerMetadata metadata runtime.ServerMetadata
) )
io.Copy(io.Discard, req.Body) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_SignUp_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
} }
msg, err := client.SignUp(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) msg, err := client.RegisterUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err return msg, metadata, err
} }
func local_request_AuthService_SignUp_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { func local_request_AuthService_RegisterUser_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var ( var (
protoReq SignUpRequest protoReq RegisterUserRequest
metadata runtime.ServerMetadata metadata runtime.ServerMetadata
) )
if err := req.ParseForm(); err != nil { if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_SignUp_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
} }
msg, err := server.SignUp(ctx, &protoReq) msg, err := server.RegisterUser(ctx, &protoReq)
return msg, metadata, err return msg, metadata, err
} }
func request_AuthService_SignOut_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { func request_AuthService_DeleteSession_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var ( var (
protoReq SignOutRequest protoReq DeleteSessionRequest
metadata runtime.ServerMetadata metadata runtime.ServerMetadata
) )
io.Copy(io.Discard, req.Body) io.Copy(io.Discard, req.Body)
msg, err := client.SignOut(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) msg, err := client.DeleteSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err return msg, metadata, err
} }
func local_request_AuthService_SignOut_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { func local_request_AuthService_DeleteSession_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var ( var (
protoReq SignOutRequest protoReq DeleteSessionRequest
metadata runtime.ServerMetadata metadata runtime.ServerMetadata
) )
msg, err := server.SignOut(ctx, &protoReq) msg, err := server.DeleteSession(ctx, &protoReq)
return msg, metadata, err return msg, metadata, err
} }
...@@ -145,7 +127,7 @@ func local_request_AuthService_SignOut_0(ctx context.Context, marshaler runtime. ...@@ -145,7 +127,7 @@ func local_request_AuthService_SignOut_0(ctx context.Context, marshaler runtime.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error { func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error {
mux.Handle(http.MethodPost, pattern_AuthService_GetAuthStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodGet, pattern_AuthService_GetAuthStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
...@@ -165,65 +147,65 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux ...@@ -165,65 +147,65 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
} }
forward_AuthService_GetAuthStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_GetAuthStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_AuthService_SignIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodPost, pattern_AuthService_CreateSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/SignIn", runtime.WithHTTPPathPattern("/api/v1/auth/signin")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/CreateSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
} }
resp, md, err := local_request_AuthService_SignIn_0(annotatedContext, inboundMarshaler, server, req, pathParams) resp, md, err := local_request_AuthService_CreateSession_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil { if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return return
} }
forward_AuthService_SignIn_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_CreateSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_AuthService_SignUp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodPost, pattern_AuthService_RegisterUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/SignUp", runtime.WithHTTPPathPattern("/api/v1/auth/signup")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/RegisterUser", runtime.WithHTTPPathPattern("/api/v1/auth/users"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
} }
resp, md, err := local_request_AuthService_SignUp_0(annotatedContext, inboundMarshaler, server, req, pathParams) resp, md, err := local_request_AuthService_RegisterUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil { if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return return
} }
forward_AuthService_SignUp_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_RegisterUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_AuthService_SignOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodDelete, pattern_AuthService_DeleteSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/SignOut", runtime.WithHTTPPathPattern("/api/v1/auth/signout")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/DeleteSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
} }
resp, md, err := local_request_AuthService_SignOut_0(annotatedContext, inboundMarshaler, server, req, pathParams) resp, md, err := local_request_AuthService_DeleteSession_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil { if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return return
} }
forward_AuthService_SignOut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_DeleteSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
return nil return nil
...@@ -265,7 +247,7 @@ func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn ...@@ -265,7 +247,7 @@ func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. // "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error { func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error {
mux.Handle(http.MethodPost, pattern_AuthService_GetAuthStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodGet, pattern_AuthService_GetAuthStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
...@@ -282,70 +264,70 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ...@@ -282,70 +264,70 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
} }
forward_AuthService_GetAuthStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_GetAuthStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_AuthService_SignIn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodPost, pattern_AuthService_CreateSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/SignIn", runtime.WithHTTPPathPattern("/api/v1/auth/signin")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/CreateSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
} }
resp, md, err := request_AuthService_SignIn_0(annotatedContext, inboundMarshaler, client, req, pathParams) resp, md, err := request_AuthService_CreateSession_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil { if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return return
} }
forward_AuthService_SignIn_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_CreateSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_AuthService_SignUp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodPost, pattern_AuthService_RegisterUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/SignUp", runtime.WithHTTPPathPattern("/api/v1/auth/signup")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/RegisterUser", runtime.WithHTTPPathPattern("/api/v1/auth/users"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
} }
resp, md, err := request_AuthService_SignUp_0(annotatedContext, inboundMarshaler, client, req, pathParams) resp, md, err := request_AuthService_RegisterUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil { if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return return
} }
forward_AuthService_SignUp_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_RegisterUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
mux.Handle(http.MethodPost, pattern_AuthService_SignOut_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { mux.Handle(http.MethodDelete, pattern_AuthService_DeleteSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/SignOut", runtime.WithHTTPPathPattern("/api/v1/auth/signout")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/DeleteSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
} }
resp, md, err := request_AuthService_SignOut_0(annotatedContext, inboundMarshaler, client, req, pathParams) resp, md, err := request_AuthService_DeleteSession_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil { if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return return
} }
forward_AuthService_SignOut_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) forward_AuthService_DeleteSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
}) })
return nil return nil
} }
var ( var (
pattern_AuthService_GetAuthStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "status"}, "")) pattern_AuthService_GetAuthStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "status"}, ""))
pattern_AuthService_SignIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signin"}, "")) pattern_AuthService_CreateSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "sessions"}, ""))
pattern_AuthService_SignUp_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signup"}, "")) pattern_AuthService_RegisterUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "users"}, ""))
pattern_AuthService_SignOut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signout"}, "")) pattern_AuthService_DeleteSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"api", "v1", "auth", "sessions", "current"}, ""))
) )
var ( var (
forward_AuthService_GetAuthStatus_0 = runtime.ForwardResponseMessage forward_AuthService_GetAuthStatus_0 = runtime.ForwardResponseMessage
forward_AuthService_SignIn_0 = runtime.ForwardResponseMessage forward_AuthService_CreateSession_0 = runtime.ForwardResponseMessage
forward_AuthService_SignUp_0 = runtime.ForwardResponseMessage forward_AuthService_RegisterUser_0 = runtime.ForwardResponseMessage
forward_AuthService_SignOut_0 = runtime.ForwardResponseMessage forward_AuthService_DeleteSession_0 = runtime.ForwardResponseMessage
) )
...@@ -21,23 +21,27 @@ const _ = grpc.SupportPackageIsVersion9 ...@@ -21,23 +21,27 @@ const _ = grpc.SupportPackageIsVersion9
const ( const (
AuthService_GetAuthStatus_FullMethodName = "/memos.api.v1.AuthService/GetAuthStatus" AuthService_GetAuthStatus_FullMethodName = "/memos.api.v1.AuthService/GetAuthStatus"
AuthService_SignIn_FullMethodName = "/memos.api.v1.AuthService/SignIn" AuthService_CreateSession_FullMethodName = "/memos.api.v1.AuthService/CreateSession"
AuthService_SignUp_FullMethodName = "/memos.api.v1.AuthService/SignUp" AuthService_RegisterUser_FullMethodName = "/memos.api.v1.AuthService/RegisterUser"
AuthService_SignOut_FullMethodName = "/memos.api.v1.AuthService/SignOut" AuthService_DeleteSession_FullMethodName = "/memos.api.v1.AuthService/DeleteSession"
) )
// AuthServiceClient is the client API for AuthService service. // AuthServiceClient is the client API for AuthService service.
// //
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type AuthServiceClient interface { type AuthServiceClient interface {
// GetAuthStatus returns the current auth status of the user. // GetAuthStatus returns the current authentication status of the user.
// This method is idempotent and safe, suitable for checking authentication state.
GetAuthStatus(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*User, error) GetAuthStatus(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*User, error)
// SignIn signs in the user. // CreateSession authenticates a user and creates a new session.
SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*User, error) // Returns the authenticated user information upon successful authentication.
// SignUp signs up the user with the given username and password. CreateSession(ctx context.Context, in *CreateSessionRequest, opts ...grpc.CallOption) (*User, error)
SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*User, error) // RegisterUser creates a new user account with username and password.
// SignOut signs out the user. // Returns the newly created user information upon successful registration.
SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*User, error)
// DeleteSession terminates the current user session.
// This is an idempotent operation that invalidates the user's authentication.
DeleteSession(ctx context.Context, in *DeleteSessionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
} }
type authServiceClient struct { type authServiceClient struct {
...@@ -58,30 +62,30 @@ func (c *authServiceClient) GetAuthStatus(ctx context.Context, in *GetAuthStatus ...@@ -58,30 +62,30 @@ func (c *authServiceClient) GetAuthStatus(ctx context.Context, in *GetAuthStatus
return out, nil return out, nil
} }
func (c *authServiceClient) SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*User, error) { func (c *authServiceClient) CreateSession(ctx context.Context, in *CreateSessionRequest, opts ...grpc.CallOption) (*User, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(User) out := new(User)
err := c.cc.Invoke(ctx, AuthService_SignIn_FullMethodName, in, out, cOpts...) err := c.cc.Invoke(ctx, AuthService_CreateSession_FullMethodName, in, out, cOpts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *authServiceClient) SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*User, error) { func (c *authServiceClient) RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*User, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(User) out := new(User)
err := c.cc.Invoke(ctx, AuthService_SignUp_FullMethodName, in, out, cOpts...) err := c.cc.Invoke(ctx, AuthService_RegisterUser_FullMethodName, in, out, cOpts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { func (c *authServiceClient) DeleteSession(ctx context.Context, in *DeleteSessionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(emptypb.Empty) out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, AuthService_SignOut_FullMethodName, in, out, cOpts...) err := c.cc.Invoke(ctx, AuthService_DeleteSession_FullMethodName, in, out, cOpts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -92,14 +96,18 @@ func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opt ...@@ -92,14 +96,18 @@ func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opt
// All implementations must embed UnimplementedAuthServiceServer // All implementations must embed UnimplementedAuthServiceServer
// for forward compatibility. // for forward compatibility.
type AuthServiceServer interface { type AuthServiceServer interface {
// GetAuthStatus returns the current auth status of the user. // GetAuthStatus returns the current authentication status of the user.
// This method is idempotent and safe, suitable for checking authentication state.
GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error) GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error)
// SignIn signs in the user. // CreateSession authenticates a user and creates a new session.
SignIn(context.Context, *SignInRequest) (*User, error) // Returns the authenticated user information upon successful authentication.
// SignUp signs up the user with the given username and password. CreateSession(context.Context, *CreateSessionRequest) (*User, error)
SignUp(context.Context, *SignUpRequest) (*User, error) // RegisterUser creates a new user account with username and password.
// SignOut signs out the user. // Returns the newly created user information upon successful registration.
SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error) RegisterUser(context.Context, *RegisterUserRequest) (*User, error)
// DeleteSession terminates the current user session.
// This is an idempotent operation that invalidates the user's authentication.
DeleteSession(context.Context, *DeleteSessionRequest) (*emptypb.Empty, error)
mustEmbedUnimplementedAuthServiceServer() mustEmbedUnimplementedAuthServiceServer()
} }
...@@ -113,14 +121,14 @@ type UnimplementedAuthServiceServer struct{} ...@@ -113,14 +121,14 @@ type UnimplementedAuthServiceServer struct{}
func (UnimplementedAuthServiceServer) GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error) { func (UnimplementedAuthServiceServer) GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAuthStatus not implemented") return nil, status.Errorf(codes.Unimplemented, "method GetAuthStatus not implemented")
} }
func (UnimplementedAuthServiceServer) SignIn(context.Context, *SignInRequest) (*User, error) { func (UnimplementedAuthServiceServer) CreateSession(context.Context, *CreateSessionRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method SignIn not implemented") return nil, status.Errorf(codes.Unimplemented, "method CreateSession not implemented")
} }
func (UnimplementedAuthServiceServer) SignUp(context.Context, *SignUpRequest) (*User, error) { func (UnimplementedAuthServiceServer) RegisterUser(context.Context, *RegisterUserRequest) (*User, error) {
return nil, status.Errorf(codes.Unimplemented, "method SignUp not implemented") return nil, status.Errorf(codes.Unimplemented, "method RegisterUser not implemented")
} }
func (UnimplementedAuthServiceServer) SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error) { func (UnimplementedAuthServiceServer) DeleteSession(context.Context, *DeleteSessionRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SignOut not implemented") return nil, status.Errorf(codes.Unimplemented, "method DeleteSession not implemented")
} }
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
...@@ -161,56 +169,56 @@ func _AuthService_GetAuthStatus_Handler(srv interface{}, ctx context.Context, de ...@@ -161,56 +169,56 @@ func _AuthService_GetAuthStatus_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _AuthService_SignIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _AuthService_CreateSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SignInRequest) in := new(CreateSessionRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(AuthServiceServer).SignIn(ctx, in) return srv.(AuthServiceServer).CreateSession(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: AuthService_SignIn_FullMethodName, FullMethod: AuthService_CreateSession_FullMethodName,
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).SignIn(ctx, req.(*SignInRequest)) return srv.(AuthServiceServer).CreateSession(ctx, req.(*CreateSessionRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _AuthService_SignUp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _AuthService_RegisterUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SignUpRequest) in := new(RegisterUserRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(AuthServiceServer).SignUp(ctx, in) return srv.(AuthServiceServer).RegisterUser(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: AuthService_SignUp_FullMethodName, FullMethod: AuthService_RegisterUser_FullMethodName,
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).SignUp(ctx, req.(*SignUpRequest)) return srv.(AuthServiceServer).RegisterUser(ctx, req.(*RegisterUserRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _AuthService_SignOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _AuthService_DeleteSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SignOutRequest) in := new(DeleteSessionRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(AuthServiceServer).SignOut(ctx, in) return srv.(AuthServiceServer).DeleteSession(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: AuthService_SignOut_FullMethodName, FullMethod: AuthService_DeleteSession_FullMethodName,
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).SignOut(ctx, req.(*SignOutRequest)) return srv.(AuthServiceServer).DeleteSession(ctx, req.(*DeleteSessionRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
...@@ -227,16 +235,16 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{ ...@@ -227,16 +235,16 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{
Handler: _AuthService_GetAuthStatus_Handler, Handler: _AuthService_GetAuthStatus_Handler,
}, },
{ {
MethodName: "SignIn", MethodName: "CreateSession",
Handler: _AuthService_SignIn_Handler, Handler: _AuthService_CreateSession_Handler,
}, },
{ {
MethodName: "SignUp", MethodName: "RegisterUser",
Handler: _AuthService_SignUp_Handler, Handler: _AuthService_RegisterUser_Handler,
}, },
{ {
MethodName: "SignOut", MethodName: "DeleteSession",
Handler: _AuthService_SignOut_Handler, Handler: _AuthService_DeleteSession_Handler,
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
......
...@@ -214,6 +214,7 @@ func (ListNode_Kind) EnumDescriptor() ([]byte, []int) { ...@@ -214,6 +214,7 @@ func (ListNode_Kind) EnumDescriptor() ([]byte, []int) {
type ParseMarkdownRequest struct { type ParseMarkdownRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The markdown content to parse.
Markdown string `protobuf:"bytes,1,opt,name=markdown,proto3" json:"markdown,omitempty"` Markdown string `protobuf:"bytes,1,opt,name=markdown,proto3" json:"markdown,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -258,6 +259,7 @@ func (x *ParseMarkdownRequest) GetMarkdown() string { ...@@ -258,6 +259,7 @@ func (x *ParseMarkdownRequest) GetMarkdown() string {
type ParseMarkdownResponse struct { type ParseMarkdownResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The parsed markdown nodes.
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"` Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -302,6 +304,7 @@ func (x *ParseMarkdownResponse) GetNodes() []*Node { ...@@ -302,6 +304,7 @@ func (x *ParseMarkdownResponse) GetNodes() []*Node {
type RestoreMarkdownNodesRequest struct { type RestoreMarkdownNodesRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The nodes to restore to markdown content.
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"` Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -346,6 +349,7 @@ func (x *RestoreMarkdownNodesRequest) GetNodes() []*Node { ...@@ -346,6 +349,7 @@ func (x *RestoreMarkdownNodesRequest) GetNodes() []*Node {
type RestoreMarkdownNodesResponse struct { type RestoreMarkdownNodesResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The restored markdown content.
Markdown string `protobuf:"bytes,1,opt,name=markdown,proto3" json:"markdown,omitempty"` Markdown string `protobuf:"bytes,1,opt,name=markdown,proto3" json:"markdown,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -390,6 +394,7 @@ func (x *RestoreMarkdownNodesResponse) GetMarkdown() string { ...@@ -390,6 +394,7 @@ func (x *RestoreMarkdownNodesResponse) GetMarkdown() string {
type StringifyMarkdownNodesRequest struct { type StringifyMarkdownNodesRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The nodes to stringify to plain text.
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"` Nodes []*Node `protobuf:"bytes,1,rep,name=nodes,proto3" json:"nodes,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -434,6 +439,7 @@ func (x *StringifyMarkdownNodesRequest) GetNodes() []*Node { ...@@ -434,6 +439,7 @@ func (x *StringifyMarkdownNodesRequest) GetNodes() []*Node {
type StringifyMarkdownNodesResponse struct { type StringifyMarkdownNodesResponse struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The plain text content.
PlainText string `protobuf:"bytes,1,opt,name=plain_text,json=plainText,proto3" json:"plain_text,omitempty"` PlainText string `protobuf:"bytes,1,opt,name=plain_text,json=plainText,proto3" json:"plain_text,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -478,6 +484,7 @@ func (x *StringifyMarkdownNodesResponse) GetPlainText() string { ...@@ -478,6 +484,7 @@ func (x *StringifyMarkdownNodesResponse) GetPlainText() string {
type GetLinkMetadataRequest struct { type GetLinkMetadataRequest struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The link URL to get metadata for.
Link string `protobuf:"bytes,1,opt,name=link,proto3" json:"link,omitempty"` Link string `protobuf:"bytes,1,opt,name=link,proto3" json:"link,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -522,8 +529,11 @@ func (x *GetLinkMetadataRequest) GetLink() string { ...@@ -522,8 +529,11 @@ func (x *GetLinkMetadataRequest) GetLink() string {
type LinkMetadata struct { type LinkMetadata struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The title of the linked page.
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
// The description of the linked page.
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
// The URL of the preview image for the linked page.
Image string `protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"` Image string `protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -1762,7 +1772,9 @@ func (x *TableNode) GetRows() []*TableNode_Row { ...@@ -1762,7 +1772,9 @@ func (x *TableNode) GetRows() []*TableNode_Row {
type EmbeddedContentNode struct { type EmbeddedContentNode struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The resource name of the embedded content.
ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3" json:"resource_name,omitempty"` ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3" json:"resource_name,omitempty"`
// Additional parameters for the embedded content.
Params string `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` Params string `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -2522,7 +2534,9 @@ func (x *SuperscriptNode) GetContent() string { ...@@ -2522,7 +2534,9 @@ func (x *SuperscriptNode) GetContent() string {
type ReferencedContentNode struct { type ReferencedContentNode struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
// The resource name of the referenced content.
ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3" json:"resource_name,omitempty"` ResourceName string `protobuf:"bytes,1,opt,name=resource_name,json=resourceName,proto3" json:"resource_name,omitempty"`
// Additional parameters for the referenced content.
Params string `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` Params string `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
...@@ -2716,22 +2730,22 @@ var File_api_v1_markdown_service_proto protoreflect.FileDescriptor ...@@ -2716,22 +2730,22 @@ var File_api_v1_markdown_service_proto protoreflect.FileDescriptor
const file_api_v1_markdown_service_proto_rawDesc = "" + const file_api_v1_markdown_service_proto_rawDesc = "" +
"\n" + "\n" +
"\x1dapi/v1/markdown_service.proto\x12\fmemos.api.v1\x1a\x1cgoogle/api/annotations.proto\"2\n" + "\x1dapi/v1/markdown_service.proto\x12\fmemos.api.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\"7\n" +
"\x14ParseMarkdownRequest\x12\x1a\n" + "\x14ParseMarkdownRequest\x12\x1f\n" +
"\bmarkdown\x18\x01 \x01(\tR\bmarkdown\"A\n" + "\bmarkdown\x18\x01 \x01(\tB\x03\xe0A\x02R\bmarkdown\"A\n" +
"\x15ParseMarkdownResponse\x12(\n" + "\x15ParseMarkdownResponse\x12(\n" +
"\x05nodes\x18\x01 \x03(\v2\x12.memos.api.v1.NodeR\x05nodes\"G\n" + "\x05nodes\x18\x01 \x03(\v2\x12.memos.api.v1.NodeR\x05nodes\"L\n" +
"\x1bRestoreMarkdownNodesRequest\x12(\n" + "\x1bRestoreMarkdownNodesRequest\x12-\n" +
"\x05nodes\x18\x01 \x03(\v2\x12.memos.api.v1.NodeR\x05nodes\":\n" + "\x05nodes\x18\x01 \x03(\v2\x12.memos.api.v1.NodeB\x03\xe0A\x02R\x05nodes\":\n" +
"\x1cRestoreMarkdownNodesResponse\x12\x1a\n" + "\x1cRestoreMarkdownNodesResponse\x12\x1a\n" +
"\bmarkdown\x18\x01 \x01(\tR\bmarkdown\"I\n" + "\bmarkdown\x18\x01 \x01(\tR\bmarkdown\"N\n" +
"\x1dStringifyMarkdownNodesRequest\x12(\n" + "\x1dStringifyMarkdownNodesRequest\x12-\n" +
"\x05nodes\x18\x01 \x03(\v2\x12.memos.api.v1.NodeR\x05nodes\"?\n" + "\x05nodes\x18\x01 \x03(\v2\x12.memos.api.v1.NodeB\x03\xe0A\x02R\x05nodes\"?\n" +
"\x1eStringifyMarkdownNodesResponse\x12\x1d\n" + "\x1eStringifyMarkdownNodesResponse\x12\x1d\n" +
"\n" + "\n" +
"plain_text\x18\x01 \x01(\tR\tplainText\",\n" + "plain_text\x18\x01 \x01(\tR\tplainText\"1\n" +
"\x16GetLinkMetadataRequest\x12\x12\n" + "\x16GetLinkMetadataRequest\x12\x17\n" +
"\x04link\x18\x01 \x01(\tR\x04link\"\\\n" + "\x04link\x18\x01 \x01(\tB\x03\xe0A\x02R\x04link\"\\\n" +
"\fLinkMetadata\x12\x14\n" + "\fLinkMetadata\x12\x14\n" +
"\x05title\x18\x01 \x01(\tR\x05title\x12 \n" + "\x05title\x18\x01 \x01(\tR\x05title\x12 \n" +
"\vdescription\x18\x02 \x01(\tR\vdescription\x12\x14\n" + "\vdescription\x18\x02 \x01(\tR\vdescription\x12\x14\n" +
...@@ -2907,12 +2921,12 @@ const file_api_v1_markdown_service_proto_rawDesc = "" + ...@@ -2907,12 +2921,12 @@ const file_api_v1_markdown_service_proto_rawDesc = "" +
"\vSUPERSCRIPT\x10A\x12\x16\n" + "\vSUPERSCRIPT\x10A\x12\x16\n" +
"\x12REFERENCED_CONTENT\x10B\x12\v\n" + "\x12REFERENCED_CONTENT\x10B\x12\v\n" +
"\aSPOILER\x10C\x12\x10\n" + "\aSPOILER\x10C\x12\x10\n" +
"\fHTML_ELEMENT\x10D2\xc7\x04\n" + "\fHTML_ELEMENT\x10D2\xc1\x04\n" +
"\x0fMarkdownService\x12{\n" + "\x0fMarkdownService\x12{\n" +
"\rParseMarkdown\x12\".memos.api.v1.ParseMarkdownRequest\x1a#.memos.api.v1.ParseMarkdownResponse\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/api/v1/markdown:parse\x12\x97\x01\n" + "\rParseMarkdown\x12\".memos.api.v1.ParseMarkdownRequest\x1a#.memos.api.v1.ParseMarkdownResponse\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/api/v1/markdown:parse\x12\x92\x01\n" +
"\x14RestoreMarkdownNodes\x12).memos.api.v1.RestoreMarkdownNodesRequest\x1a*.memos.api.v1.RestoreMarkdownNodesResponse\"(\x82\xd3\xe4\x93\x02\":\x01*\"\x1d/api/v1/markdown/node:restore\x12\x9f\x01\n" + "\x14RestoreMarkdownNodes\x12).memos.api.v1.RestoreMarkdownNodesRequest\x1a*.memos.api.v1.RestoreMarkdownNodesResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/api/v1/markdown:restore\x12\x9a\x01\n" +
"\x16StringifyMarkdownNodes\x12+.memos.api.v1.StringifyMarkdownNodesRequest\x1a,.memos.api.v1.StringifyMarkdownNodesResponse\"*\x82\xd3\xe4\x93\x02$:\x01*\"\x1f/api/v1/markdown/node:stringify\x12{\n" + "\x16StringifyMarkdownNodes\x12+.memos.api.v1.StringifyMarkdownNodesRequest\x1a,.memos.api.v1.StringifyMarkdownNodesResponse\"%\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/api/v1/markdown:stringify\x12\x7f\n" +
"\x0fGetLinkMetadata\x12$.memos.api.v1.GetLinkMetadataRequest\x1a\x1a.memos.api.v1.LinkMetadata\"&\x82\xd3\xe4\x93\x02 \x12\x1e/api/v1/markdown/link:metadataB\xac\x01\n" + "\x0fGetLinkMetadata\x12$.memos.api.v1.GetLinkMetadataRequest\x1a\x1a.memos.api.v1.LinkMetadata\"*\x82\xd3\xe4\x93\x02$\x12\"/api/v1/markdown/links:getMetadataB\xac\x01\n" +
"\x10com.memos.api.v1B\x14MarkdownServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3" "\x10com.memos.api.v1B\x14MarkdownServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3"
var ( var (
......
...@@ -172,7 +172,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv ...@@ -172,7 +172,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:restore")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:restore"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -192,7 +192,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv ...@@ -192,7 +192,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:stringify")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:stringify"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -212,7 +212,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv ...@@ -212,7 +212,7 @@ func RegisterMarkdownServiceHandlerServer(ctx context.Context, mux *runtime.Serv
var stream runtime.ServerTransportStream var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/link:metadata")) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/links:getMetadata"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -287,7 +287,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -287,7 +287,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:restore")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/RestoreMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:restore"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -304,7 +304,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -304,7 +304,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown/node:stringify")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/StringifyMarkdownNodes", runtime.WithHTTPPathPattern("/api/v1/markdown:stringify"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -321,7 +321,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -321,7 +321,7 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
ctx, cancel := context.WithCancel(req.Context()) ctx, cancel := context.WithCancel(req.Context())
defer cancel() defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/link:metadata")) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MarkdownService/GetLinkMetadata", runtime.WithHTTPPathPattern("/api/v1/markdown/links:getMetadata"))
if err != nil { if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return return
...@@ -339,9 +339,9 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv ...@@ -339,9 +339,9 @@ func RegisterMarkdownServiceHandlerClient(ctx context.Context, mux *runtime.Serv
var ( var (
pattern_MarkdownService_ParseMarkdown_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "parse")) pattern_MarkdownService_ParseMarkdown_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "parse"))
pattern_MarkdownService_RestoreMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "node"}, "restore")) pattern_MarkdownService_RestoreMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "restore"))
pattern_MarkdownService_StringifyMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "node"}, "stringify")) pattern_MarkdownService_StringifyMarkdownNodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "markdown"}, "stringify"))
pattern_MarkdownService_GetLinkMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "link"}, "metadata")) pattern_MarkdownService_GetLinkMetadata_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "markdown", "links"}, "getMetadata"))
) )
var ( var (
......
...@@ -30,12 +30,16 @@ const ( ...@@ -30,12 +30,16 @@ const (
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MarkdownServiceClient interface { type MarkdownServiceClient interface {
// ParseMarkdown parses the given markdown content and returns a list of nodes. // ParseMarkdown parses the given markdown content and returns a list of nodes.
// This is a utility method that transforms markdown text into structured nodes.
ParseMarkdown(ctx context.Context, in *ParseMarkdownRequest, opts ...grpc.CallOption) (*ParseMarkdownResponse, error) ParseMarkdown(ctx context.Context, in *ParseMarkdownRequest, opts ...grpc.CallOption) (*ParseMarkdownResponse, error)
// RestoreMarkdownNodes restores the given nodes to markdown content. // RestoreMarkdownNodes restores the given nodes to markdown content.
// This is the inverse operation of ParseMarkdown.
RestoreMarkdownNodes(ctx context.Context, in *RestoreMarkdownNodesRequest, opts ...grpc.CallOption) (*RestoreMarkdownNodesResponse, error) RestoreMarkdownNodes(ctx context.Context, in *RestoreMarkdownNodesRequest, opts ...grpc.CallOption) (*RestoreMarkdownNodesResponse, error)
// StringifyMarkdownNodes stringify the given nodes to plain text content. // StringifyMarkdownNodes stringify the given nodes to plain text content.
// This removes all markdown formatting and returns plain text.
StringifyMarkdownNodes(ctx context.Context, in *StringifyMarkdownNodesRequest, opts ...grpc.CallOption) (*StringifyMarkdownNodesResponse, error) StringifyMarkdownNodes(ctx context.Context, in *StringifyMarkdownNodesRequest, opts ...grpc.CallOption) (*StringifyMarkdownNodesResponse, error)
// GetLinkMetadata returns metadata for a given link. // GetLinkMetadata returns metadata for a given link.
// This is useful for generating link previews.
GetLinkMetadata(ctx context.Context, in *GetLinkMetadataRequest, opts ...grpc.CallOption) (*LinkMetadata, error) GetLinkMetadata(ctx context.Context, in *GetLinkMetadataRequest, opts ...grpc.CallOption) (*LinkMetadata, error)
} }
...@@ -92,12 +96,16 @@ func (c *markdownServiceClient) GetLinkMetadata(ctx context.Context, in *GetLink ...@@ -92,12 +96,16 @@ func (c *markdownServiceClient) GetLinkMetadata(ctx context.Context, in *GetLink
// for forward compatibility. // for forward compatibility.
type MarkdownServiceServer interface { type MarkdownServiceServer interface {
// ParseMarkdown parses the given markdown content and returns a list of nodes. // ParseMarkdown parses the given markdown content and returns a list of nodes.
// This is a utility method that transforms markdown text into structured nodes.
ParseMarkdown(context.Context, *ParseMarkdownRequest) (*ParseMarkdownResponse, error) ParseMarkdown(context.Context, *ParseMarkdownRequest) (*ParseMarkdownResponse, error)
// RestoreMarkdownNodes restores the given nodes to markdown content. // RestoreMarkdownNodes restores the given nodes to markdown content.
// This is the inverse operation of ParseMarkdown.
RestoreMarkdownNodes(context.Context, *RestoreMarkdownNodesRequest) (*RestoreMarkdownNodesResponse, error) RestoreMarkdownNodes(context.Context, *RestoreMarkdownNodesRequest) (*RestoreMarkdownNodesResponse, error)
// StringifyMarkdownNodes stringify the given nodes to plain text content. // StringifyMarkdownNodes stringify the given nodes to plain text content.
// This removes all markdown formatting and returns plain text.
StringifyMarkdownNodes(context.Context, *StringifyMarkdownNodesRequest) (*StringifyMarkdownNodesResponse, error) StringifyMarkdownNodes(context.Context, *StringifyMarkdownNodesRequest) (*StringifyMarkdownNodesResponse, error)
// GetLinkMetadata returns metadata for a given link. // GetLinkMetadata returns metadata for a given link.
// This is useful for generating link previews.
GetLinkMetadata(context.Context, *GetLinkMetadataRequest) (*LinkMetadata, error) GetLinkMetadata(context.Context, *GetLinkMetadataRequest) (*LinkMetadata, error)
mustEmbedUnimplementedMarkdownServiceServer() mustEmbedUnimplementedMarkdownServiceServer()
} }
......
...@@ -131,10 +131,12 @@ paths: ...@@ -131,10 +131,12 @@ paths:
type: string type: string
tags: tags:
- AttachmentService - AttachmentService
/api/v1/auth/signin: /api/v1/auth/sessions:
post: post:
summary: SignIn signs in the user. summary: |-
operationId: AuthService_SignIn CreateSession authenticates a user and creates a new session.
Returns the authenticated user information upon successful authentication.
operationId: AuthService_CreateSession
responses: responses:
"200": "200":
description: A successful response. description: A successful response.
...@@ -145,43 +147,19 @@ paths: ...@@ -145,43 +147,19 @@ paths:
schema: schema:
$ref: '#/definitions/googlerpcStatus' $ref: '#/definitions/googlerpcStatus'
parameters: parameters:
- name: passwordCredentials.username - name: body
description: The username to sign in with. in: body
in: query required: true
required: false schema:
type: string $ref: '#/definitions/v1CreateSessionRequest'
- name: passwordCredentials.password
description: The password to sign in with.
in: query
required: false
type: string
- name: ssoCredentials.idpId
description: The ID of the SSO provider.
in: query
required: false
type: integer
format: int32
- name: ssoCredentials.code
description: The code to sign in with.
in: query
required: false
type: string
- name: ssoCredentials.redirectUri
description: The redirect URI.
in: query
required: false
type: string
- name: neverExpire
description: Whether the session should never expire.
in: query
required: false
type: boolean
tags: tags:
- AuthService - AuthService
/api/v1/auth/signout: /api/v1/auth/sessions/current:
post: delete:
summary: SignOut signs out the user. summary: |-
operationId: AuthService_SignOut DeleteSession terminates the current user session.
This is an idempotent operation that invalidates the user's authentication.
operationId: AuthService_DeleteSession
responses: responses:
"200": "200":
description: A successful response. description: A successful response.
...@@ -194,10 +172,12 @@ paths: ...@@ -194,10 +172,12 @@ paths:
$ref: '#/definitions/googlerpcStatus' $ref: '#/definitions/googlerpcStatus'
tags: tags:
- AuthService - AuthService
/api/v1/auth/signup: /api/v1/auth/status:
post: get:
summary: SignUp signs up the user with the given username and password. summary: |-
operationId: AuthService_SignUp GetAuthStatus returns the current authentication status of the user.
This method is idempotent and safe, suitable for checking authentication state.
operationId: AuthService_GetAuthStatus
responses: responses:
"200": "200":
description: A successful response. description: A successful response.
...@@ -207,23 +187,14 @@ paths: ...@@ -207,23 +187,14 @@ paths:
description: An unexpected error response. description: An unexpected error response.
schema: schema:
$ref: '#/definitions/googlerpcStatus' $ref: '#/definitions/googlerpcStatus'
parameters:
- name: username
description: The username to sign up with.
in: query
required: false
type: string
- name: password
description: The password to sign up with.
in: query
required: false
type: string
tags: tags:
- AuthService - AuthService
/api/v1/auth/status: /api/v1/auth/users:
post: post:
summary: GetAuthStatus returns the current auth status of the user. summary: |-
operationId: AuthService_GetAuthStatus RegisterUser creates a new user account with username and password.
Returns the newly created user information upon successful registration.
operationId: AuthService_RegisterUser
responses: responses:
"200": "200":
description: A successful response. description: A successful response.
...@@ -233,6 +204,12 @@ paths: ...@@ -233,6 +204,12 @@ paths:
description: An unexpected error response. description: An unexpected error response.
schema: schema:
$ref: '#/definitions/googlerpcStatus' $ref: '#/definitions/googlerpcStatus'
parameters:
- name: body
in: body
required: true
schema:
$ref: '#/definitions/v1RegisterUserRequest'
tags: tags:
- AuthService - AuthService
/api/v1/identityProviders: /api/v1/identityProviders:
...@@ -292,9 +269,11 @@ paths: ...@@ -292,9 +269,11 @@ paths:
type: string type: string
tags: tags:
- IdentityProviderService - IdentityProviderService
/api/v1/markdown/link:metadata: /api/v1/markdown/links:getMetadata:
get: get:
summary: GetLinkMetadata returns metadata for a given link. summary: |-
GetLinkMetadata returns metadata for a given link.
This is useful for generating link previews.
operationId: MarkdownService_GetLinkMetadata operationId: MarkdownService_GetLinkMetadata
responses: responses:
"200": "200":
...@@ -307,20 +286,23 @@ paths: ...@@ -307,20 +286,23 @@ paths:
$ref: '#/definitions/googlerpcStatus' $ref: '#/definitions/googlerpcStatus'
parameters: parameters:
- name: link - name: link
description: The link URL to get metadata for.
in: query in: query
required: false required: true
type: string type: string
tags: tags:
- MarkdownService - MarkdownService
/api/v1/markdown/node:restore: /api/v1/markdown:parse:
post: post:
summary: RestoreMarkdownNodes restores the given nodes to markdown content. summary: |-
operationId: MarkdownService_RestoreMarkdownNodes ParseMarkdown parses the given markdown content and returns a list of nodes.
This is a utility method that transforms markdown text into structured nodes.
operationId: MarkdownService_ParseMarkdown
responses: responses:
"200": "200":
description: A successful response. description: A successful response.
schema: schema:
$ref: '#/definitions/v1RestoreMarkdownNodesResponse' $ref: '#/definitions/v1ParseMarkdownResponse'
default: default:
description: An unexpected error response. description: An unexpected error response.
schema: schema:
...@@ -330,18 +312,20 @@ paths: ...@@ -330,18 +312,20 @@ paths:
in: body in: body
required: true required: true
schema: schema:
$ref: '#/definitions/v1RestoreMarkdownNodesRequest' $ref: '#/definitions/v1ParseMarkdownRequest'
tags: tags:
- MarkdownService - MarkdownService
/api/v1/markdown/node:stringify: /api/v1/markdown:restore:
post: post:
summary: StringifyMarkdownNodes stringify the given nodes to plain text content. summary: |-
operationId: MarkdownService_StringifyMarkdownNodes RestoreMarkdownNodes restores the given nodes to markdown content.
This is the inverse operation of ParseMarkdown.
operationId: MarkdownService_RestoreMarkdownNodes
responses: responses:
"200": "200":
description: A successful response. description: A successful response.
schema: schema:
$ref: '#/definitions/v1StringifyMarkdownNodesResponse' $ref: '#/definitions/v1RestoreMarkdownNodesResponse'
default: default:
description: An unexpected error response. description: An unexpected error response.
schema: schema:
...@@ -351,18 +335,20 @@ paths: ...@@ -351,18 +335,20 @@ paths:
in: body in: body
required: true required: true
schema: schema:
$ref: '#/definitions/v1StringifyMarkdownNodesRequest' $ref: '#/definitions/v1RestoreMarkdownNodesRequest'
tags: tags:
- MarkdownService - MarkdownService
/api/v1/markdown:parse: /api/v1/markdown:stringify:
post: post:
summary: ParseMarkdown parses the given markdown content and returns a list of nodes. summary: |-
operationId: MarkdownService_ParseMarkdown StringifyMarkdownNodes stringify the given nodes to plain text content.
This removes all markdown formatting and returns plain text.
operationId: MarkdownService_StringifyMarkdownNodes
responses: responses:
"200": "200":
description: A successful response. description: A successful response.
schema: schema:
$ref: '#/definitions/v1ParseMarkdownResponse' $ref: '#/definitions/v1StringifyMarkdownNodesResponse'
default: default:
description: An unexpected error response. description: An unexpected error response.
schema: schema:
...@@ -372,7 +358,7 @@ paths: ...@@ -372,7 +358,7 @@ paths:
in: body in: body
required: true required: true
schema: schema:
$ref: '#/definitions/v1ParseMarkdownRequest' $ref: '#/definitions/v1StringifyMarkdownNodesRequest'
tags: tags:
- MarkdownService - MarkdownService
/api/v1/memos: /api/v1/memos:
...@@ -3324,13 +3310,29 @@ definitions: ...@@ -3324,13 +3310,29 @@ definitions:
properties: properties:
content: content:
type: string type: string
v1CreateSessionRequest:
type: object
properties:
passwordCredentials:
$ref: '#/definitions/v1PasswordCredentials'
description: Username and password authentication method.
ssoCredentials:
$ref: '#/definitions/v1SSOCredentials'
description: SSO provider authentication method.
neverExpire:
type: boolean
description: |-
Whether the session should never expire.
Optional field that defaults to false for security.
v1EmbeddedContentNode: v1EmbeddedContentNode:
type: object type: object
properties: properties:
resourceName: resourceName:
type: string type: string
description: The resource name of the embedded content.
params: params:
type: string type: string
description: Additional parameters for the embedded content.
v1EscapingCharacterNode: v1EscapingCharacterNode:
type: object type: object
properties: properties:
...@@ -3452,10 +3454,13 @@ definitions: ...@@ -3452,10 +3454,13 @@ definitions:
properties: properties:
title: title:
type: string type: string
description: The title of the linked page.
description: description:
type: string type: string
description: The description of the linked page.
image: image:
type: string type: string
description: The URL of the preview image for the linked page.
v1LinkNode: v1LinkNode:
type: object type: object
properties: properties:
...@@ -3906,6 +3911,9 @@ definitions: ...@@ -3906,6 +3911,9 @@ definitions:
properties: properties:
markdown: markdown:
type: string type: string
description: The markdown content to parse.
required:
- markdown
v1ParseMarkdownResponse: v1ParseMarkdownResponse:
type: object type: object
properties: properties:
...@@ -3914,15 +3922,23 @@ definitions: ...@@ -3914,15 +3922,23 @@ definitions:
items: items:
type: object type: object
$ref: '#/definitions/v1Node' $ref: '#/definitions/v1Node'
description: The parsed markdown nodes.
v1PasswordCredentials: v1PasswordCredentials:
type: object type: object
properties: properties:
username: username:
type: string type: string
description: The username to sign in with. description: |-
The username to sign in with.
Required field for password-based authentication.
password: password:
type: string type: string
description: The password to sign in with. description: |-
The password to sign in with.
Required field for password-based authentication.
required:
- username
- password
v1Reaction: v1Reaction:
type: object type: object
properties: properties:
...@@ -3964,8 +3980,26 @@ definitions: ...@@ -3964,8 +3980,26 @@ definitions:
properties: properties:
resourceName: resourceName:
type: string type: string
description: The resource name of the referenced content.
params: params:
type: string type: string
description: Additional parameters for the referenced content.
v1RegisterUserRequest:
type: object
properties:
username:
type: string
description: |-
The username to sign up with.
Required field that must be unique across the system.
password:
type: string
description: |-
The password to sign up with.
Required field that should meet security requirements.
required:
- username
- password
v1RestoreMarkdownNodesRequest: v1RestoreMarkdownNodesRequest:
type: object type: object
properties: properties:
...@@ -3974,24 +4008,38 @@ definitions: ...@@ -3974,24 +4008,38 @@ definitions:
items: items:
type: object type: object
$ref: '#/definitions/v1Node' $ref: '#/definitions/v1Node'
description: The nodes to restore to markdown content.
required:
- nodes
v1RestoreMarkdownNodesResponse: v1RestoreMarkdownNodesResponse:
type: object type: object
properties: properties:
markdown: markdown:
type: string type: string
description: The restored markdown content.
v1SSOCredentials: v1SSOCredentials:
type: object type: object
properties: properties:
idpId: idpId:
type: integer type: integer
format: int32 format: int32
description: The ID of the SSO provider. description: |-
The ID of the SSO provider.
Required field to identify the SSO provider.
code: code:
type: string type: string
description: The code to sign in with. description: |-
The authorization code from the SSO provider.
Required field for completing the SSO flow.
redirectUri: redirectUri:
type: string type: string
description: The redirect URI. description: |-
The redirect URI used in the SSO flow.
Required field for security validation.
required:
- idpId
- code
- redirectUri
v1SearchUsersResponse: v1SearchUsersResponse:
type: object type: object
properties: properties:
...@@ -4033,11 +4081,15 @@ definitions: ...@@ -4033,11 +4081,15 @@ definitions:
items: items:
type: object type: object
$ref: '#/definitions/v1Node' $ref: '#/definitions/v1Node'
description: The nodes to stringify to plain text.
required:
- nodes
v1StringifyMarkdownNodesResponse: v1StringifyMarkdownNodesResponse:
type: object type: object
properties: properties:
plainText: plainText:
type: string type: string
description: The plain text content.
v1SubscriptNode: v1SubscriptNode:
type: object type: object
properties: properties:
......
...@@ -6,10 +6,9 @@ var authenticationAllowlistMethods = map[string]bool{ ...@@ -6,10 +6,9 @@ var authenticationAllowlistMethods = map[string]bool{
"/memos.api.v1.IdentityProviderService/GetIdentityProvider": true, "/memos.api.v1.IdentityProviderService/GetIdentityProvider": true,
"/memos.api.v1.IdentityProviderService/ListIdentityProviders": true, "/memos.api.v1.IdentityProviderService/ListIdentityProviders": true,
"/memos.api.v1.AuthService/GetAuthStatus": true, "/memos.api.v1.AuthService/GetAuthStatus": true,
"/memos.api.v1.AuthService/SignIn": true, "/memos.api.v1.AuthService/CreateSession": true,
"/memos.api.v1.AuthService/SignInWithSSO": true, "/memos.api.v1.AuthService/RegisterUser": true,
"/memos.api.v1.AuthService/SignOut": true, "/memos.api.v1.AuthService/DeleteSession": true,
"/memos.api.v1.AuthService/SignUp": true,
"/memos.api.v1.UserService/GetUser": true, "/memos.api.v1.UserService/GetUser": true,
"/memos.api.v1.UserService/GetUserAvatar": true, "/memos.api.v1.UserService/GetUserAvatar": true,
"/memos.api.v1.UserService/GetUserStats": true, "/memos.api.v1.UserService/GetUserStats": true,
......
...@@ -44,7 +44,7 @@ func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusR ...@@ -44,7 +44,7 @@ func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusR
return convertUserFromStore(user), nil return convertUserFromStore(user), nil
} }
func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest) (*v1pb.User, error) { func (s *APIV1Service) CreateSession(ctx context.Context, request *v1pb.CreateSessionRequest) (*v1pb.User, error) {
var existingUser *store.User var existingUser *store.User
if passwordCredentials := request.GetPasswordCredentials(); passwordCredentials != nil { if passwordCredentials := request.GetPasswordCredentials(); passwordCredentials != nil {
user, err := s.Store.GetUser(ctx, &store.FindUser{ user, err := s.Store.GetUser(ctx, &store.FindUser{
...@@ -189,7 +189,7 @@ func (s *APIV1Service) doSignIn(ctx context.Context, user *store.User, expireTim ...@@ -189,7 +189,7 @@ func (s *APIV1Service) doSignIn(ctx context.Context, user *store.User, expireTim
return nil return nil
} }
func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) (*v1pb.User, error) { func (s *APIV1Service) RegisterUser(ctx context.Context, request *v1pb.RegisterUserRequest) (*v1pb.User, error) {
workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx) workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get workspace general setting, error: %v", err) return nil, status.Errorf(codes.Internal, "failed to get workspace general setting, error: %v", err)
...@@ -237,7 +237,7 @@ func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) ...@@ -237,7 +237,7 @@ func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest)
return convertUserFromStore(user), nil return convertUserFromStore(user), nil
} }
func (s *APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*emptypb.Empty, error) { func (s *APIV1Service) DeleteSession(ctx context.Context, _ *v1pb.DeleteSessionRequest) (*emptypb.Empty, error) {
accessToken, ok := ctx.Value(accessTokenContextKey).(string) accessToken, ok := ctx.Value(accessTokenContextKey).(string)
// Try to delete the access token from the store. // Try to delete the access token from the store.
if ok { if ok {
......
...@@ -45,7 +45,7 @@ const PasswordSignInForm = observer(() => { ...@@ -45,7 +45,7 @@ const PasswordSignInForm = observer(() => {
try { try {
actionBtnLoadingState.setLoading(); actionBtnLoadingState.setLoading();
await authServiceClient.signIn({ passwordCredentials: { username, password }, neverExpire: remember }); await authServiceClient.createSession({ passwordCredentials: { username, password }, neverExpire: remember });
await initialUserStore(); await initialUserStore();
navigateTo("/"); navigateTo("/");
} catch (error: any) { } catch (error: any) {
......
...@@ -19,7 +19,7 @@ const UserBanner = (props: Props) => { ...@@ -19,7 +19,7 @@ const UserBanner = (props: Props) => {
const currentUser = useCurrentUser(); const currentUser = useCurrentUser();
const handleSignOut = async () => { const handleSignOut = async () => {
await authServiceClient.signOut({}); await authServiceClient.deleteSession({});
window.location.href = Routes.AUTH; window.location.href = Routes.AUTH;
}; };
......
...@@ -46,7 +46,7 @@ const AuthCallback = observer(() => { ...@@ -46,7 +46,7 @@ const AuthCallback = observer(() => {
const redirectUri = absolutifyLink("/auth/callback"); const redirectUri = absolutifyLink("/auth/callback");
(async () => { (async () => {
try { try {
await authServiceClient.signIn({ await authServiceClient.createSession({
ssoCredentials: { ssoCredentials: {
idpId: identityProviderId, idpId: identityProviderId,
code, code,
......
...@@ -47,7 +47,7 @@ const SignUp = observer(() => { ...@@ -47,7 +47,7 @@ const SignUp = observer(() => {
try { try {
actionBtnLoadingState.setLoading(); actionBtnLoadingState.setLoading();
await authServiceClient.signUp({ username, password }); await authServiceClient.registerUser({ username, password });
await initialUserStore(); await initialUserStore();
navigateTo("/"); navigateTo("/");
} catch (error: any) { } catch (error: any) {
......
...@@ -18,7 +18,7 @@ export interface GetAuthStatusResponse { ...@@ -18,7 +18,7 @@ export interface GetAuthStatusResponse {
user?: User | undefined; user?: User | undefined;
} }
export interface SignInRequest { export interface CreateSessionRequest {
/** Username and password authentication method. */ /** Username and password authentication method. */
passwordCredentials?: passwordCredentials?:
| PasswordCredentials | PasswordCredentials
...@@ -27,34 +27,58 @@ export interface SignInRequest { ...@@ -27,34 +27,58 @@ export interface SignInRequest {
ssoCredentials?: ssoCredentials?:
| SSOCredentials | SSOCredentials
| undefined; | undefined;
/** Whether the session should never expire. */ /**
* Whether the session should never expire.
* Optional field that defaults to false for security.
*/
neverExpire: boolean; neverExpire: boolean;
} }
export interface PasswordCredentials { export interface PasswordCredentials {
/** The username to sign in with. */ /**
* The username to sign in with.
* Required field for password-based authentication.
*/
username: string; username: string;
/** The password to sign in with. */ /**
* The password to sign in with.
* Required field for password-based authentication.
*/
password: string; password: string;
} }
export interface SSOCredentials { export interface SSOCredentials {
/** The ID of the SSO provider. */ /**
* The ID of the SSO provider.
* Required field to identify the SSO provider.
*/
idpId: number; idpId: number;
/** The code to sign in with. */ /**
* The authorization code from the SSO provider.
* Required field for completing the SSO flow.
*/
code: string; code: string;
/** The redirect URI. */ /**
* The redirect URI used in the SSO flow.
* Required field for security validation.
*/
redirectUri: string; redirectUri: string;
} }
export interface SignUpRequest { export interface RegisterUserRequest {
/** The username to sign up with. */ /**
* The username to sign up with.
* Required field that must be unique across the system.
*/
username: string; username: string;
/** The password to sign up with. */ /**
* The password to sign up with.
* Required field that should meet security requirements.
*/
password: string; password: string;
} }
export interface SignOutRequest { export interface DeleteSessionRequest {
} }
function createBaseGetAuthStatusRequest(): GetAuthStatusRequest { function createBaseGetAuthStatusRequest(): GetAuthStatusRequest {
...@@ -137,12 +161,12 @@ export const GetAuthStatusResponse: MessageFns<GetAuthStatusResponse> = { ...@@ -137,12 +161,12 @@ export const GetAuthStatusResponse: MessageFns<GetAuthStatusResponse> = {
}, },
}; };
function createBaseSignInRequest(): SignInRequest { function createBaseCreateSessionRequest(): CreateSessionRequest {
return { passwordCredentials: undefined, ssoCredentials: undefined, neverExpire: false }; return { passwordCredentials: undefined, ssoCredentials: undefined, neverExpire: false };
} }
export const SignInRequest: MessageFns<SignInRequest> = { export const CreateSessionRequest: MessageFns<CreateSessionRequest> = {
encode(message: SignInRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { encode(message: CreateSessionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.passwordCredentials !== undefined) { if (message.passwordCredentials !== undefined) {
PasswordCredentials.encode(message.passwordCredentials, writer.uint32(10).fork()).join(); PasswordCredentials.encode(message.passwordCredentials, writer.uint32(10).fork()).join();
} }
...@@ -155,10 +179,10 @@ export const SignInRequest: MessageFns<SignInRequest> = { ...@@ -155,10 +179,10 @@ export const SignInRequest: MessageFns<SignInRequest> = {
return writer; return writer;
}, },
decode(input: BinaryReader | Uint8Array, length?: number): SignInRequest { decode(input: BinaryReader | Uint8Array, length?: number): CreateSessionRequest {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSignInRequest(); const message = createBaseCreateSessionRequest();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
...@@ -195,11 +219,11 @@ export const SignInRequest: MessageFns<SignInRequest> = { ...@@ -195,11 +219,11 @@ export const SignInRequest: MessageFns<SignInRequest> = {
return message; return message;
}, },
create(base?: DeepPartial<SignInRequest>): SignInRequest { create(base?: DeepPartial<CreateSessionRequest>): CreateSessionRequest {
return SignInRequest.fromPartial(base ?? {}); return CreateSessionRequest.fromPartial(base ?? {});
}, },
fromPartial(object: DeepPartial<SignInRequest>): SignInRequest { fromPartial(object: DeepPartial<CreateSessionRequest>): CreateSessionRequest {
const message = createBaseSignInRequest(); const message = createBaseCreateSessionRequest();
message.passwordCredentials = (object.passwordCredentials !== undefined && object.passwordCredentials !== null) message.passwordCredentials = (object.passwordCredentials !== undefined && object.passwordCredentials !== null)
? PasswordCredentials.fromPartial(object.passwordCredentials) ? PasswordCredentials.fromPartial(object.passwordCredentials)
: undefined; : undefined;
...@@ -339,12 +363,12 @@ export const SSOCredentials: MessageFns<SSOCredentials> = { ...@@ -339,12 +363,12 @@ export const SSOCredentials: MessageFns<SSOCredentials> = {
}, },
}; };
function createBaseSignUpRequest(): SignUpRequest { function createBaseRegisterUserRequest(): RegisterUserRequest {
return { username: "", password: "" }; return { username: "", password: "" };
} }
export const SignUpRequest: MessageFns<SignUpRequest> = { export const RegisterUserRequest: MessageFns<RegisterUserRequest> = {
encode(message: SignUpRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { encode(message: RegisterUserRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.username !== "") { if (message.username !== "") {
writer.uint32(10).string(message.username); writer.uint32(10).string(message.username);
} }
...@@ -354,10 +378,10 @@ export const SignUpRequest: MessageFns<SignUpRequest> = { ...@@ -354,10 +378,10 @@ export const SignUpRequest: MessageFns<SignUpRequest> = {
return writer; return writer;
}, },
decode(input: BinaryReader | Uint8Array, length?: number): SignUpRequest { decode(input: BinaryReader | Uint8Array, length?: number): RegisterUserRequest {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSignUpRequest(); const message = createBaseRegisterUserRequest();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
...@@ -386,30 +410,30 @@ export const SignUpRequest: MessageFns<SignUpRequest> = { ...@@ -386,30 +410,30 @@ export const SignUpRequest: MessageFns<SignUpRequest> = {
return message; return message;
}, },
create(base?: DeepPartial<SignUpRequest>): SignUpRequest { create(base?: DeepPartial<RegisterUserRequest>): RegisterUserRequest {
return SignUpRequest.fromPartial(base ?? {}); return RegisterUserRequest.fromPartial(base ?? {});
}, },
fromPartial(object: DeepPartial<SignUpRequest>): SignUpRequest { fromPartial(object: DeepPartial<RegisterUserRequest>): RegisterUserRequest {
const message = createBaseSignUpRequest(); const message = createBaseRegisterUserRequest();
message.username = object.username ?? ""; message.username = object.username ?? "";
message.password = object.password ?? ""; message.password = object.password ?? "";
return message; return message;
}, },
}; };
function createBaseSignOutRequest(): SignOutRequest { function createBaseDeleteSessionRequest(): DeleteSessionRequest {
return {}; return {};
} }
export const SignOutRequest: MessageFns<SignOutRequest> = { export const DeleteSessionRequest: MessageFns<DeleteSessionRequest> = {
encode(_: SignOutRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { encode(_: DeleteSessionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
return writer; return writer;
}, },
decode(input: BinaryReader | Uint8Array, length?: number): SignOutRequest { decode(input: BinaryReader | Uint8Array, length?: number): DeleteSessionRequest {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSignOutRequest(); const message = createBaseDeleteSessionRequest();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
...@@ -422,11 +446,11 @@ export const SignOutRequest: MessageFns<SignOutRequest> = { ...@@ -422,11 +446,11 @@ export const SignOutRequest: MessageFns<SignOutRequest> = {
return message; return message;
}, },
create(base?: DeepPartial<SignOutRequest>): SignOutRequest { create(base?: DeepPartial<DeleteSessionRequest>): DeleteSessionRequest {
return SignOutRequest.fromPartial(base ?? {}); return DeleteSessionRequest.fromPartial(base ?? {});
}, },
fromPartial(_: DeepPartial<SignOutRequest>): SignOutRequest { fromPartial(_: DeepPartial<DeleteSessionRequest>): DeleteSessionRequest {
const message = createBaseSignOutRequest(); const message = createBaseDeleteSessionRequest();
return message; return message;
}, },
}; };
...@@ -436,7 +460,10 @@ export const AuthServiceDefinition = { ...@@ -436,7 +460,10 @@ export const AuthServiceDefinition = {
name: "AuthService", name: "AuthService",
fullName: "memos.api.v1.AuthService", fullName: "memos.api.v1.AuthService",
methods: { methods: {
/** GetAuthStatus returns the current auth status of the user. */ /**
* GetAuthStatus returns the current authentication status of the user.
* This method is idempotent and safe, suitable for checking authentication state.
*/
getAuthStatus: { getAuthStatus: {
name: "GetAuthStatus", name: "GetAuthStatus",
requestType: GetAuthStatusRequest, requestType: GetAuthStatusRequest,
...@@ -448,7 +475,7 @@ export const AuthServiceDefinition = { ...@@ -448,7 +475,7 @@ export const AuthServiceDefinition = {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
21, 21,
34, 18,
19, 19,
47, 47,
97, 97,
...@@ -474,10 +501,13 @@ export const AuthServiceDefinition = { ...@@ -474,10 +501,13 @@ export const AuthServiceDefinition = {
}, },
}, },
}, },
/** SignIn signs in the user. */ /**
signIn: { * CreateSession authenticates a user and creates a new session.
name: "SignIn", * Returns the authenticated user information upon successful authentication.
requestType: SignInRequest, */
createSession: {
name: "CreateSession",
requestType: CreateSessionRequest,
requestStream: false, requestStream: false,
responseType: User, responseType: User,
responseStream: false, responseStream: false,
...@@ -485,9 +515,12 @@ export const AuthServiceDefinition = { ...@@ -485,9 +515,12 @@ export const AuthServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
21, 26,
58,
1,
42,
34, 34,
19, 21,
47, 47,
97, 97,
112, 112,
...@@ -502,20 +535,25 @@ export const AuthServiceDefinition = { ...@@ -502,20 +535,25 @@ export const AuthServiceDefinition = {
104, 104,
47, 47,
115, 115,
101,
115,
115,
105, 105,
103, 111,
110,
105,
110, 110,
115,
]), ]),
], ],
}, },
}, },
}, },
/** SignUp signs up the user with the given username and password. */ /**
signUp: { * RegisterUser creates a new user account with username and password.
name: "SignUp", * Returns the newly created user information upon successful registration.
requestType: SignUpRequest, */
registerUser: {
name: "RegisterUser",
requestType: RegisterUserRequest,
requestStream: false, requestStream: false,
responseType: User, responseType: User,
responseStream: false, responseStream: false,
...@@ -523,9 +561,12 @@ export const AuthServiceDefinition = { ...@@ -523,9 +561,12 @@ export const AuthServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
21, 23,
58,
1,
42,
34, 34,
19, 18,
47, 47,
97, 97,
112, 112,
...@@ -539,21 +580,23 @@ export const AuthServiceDefinition = { ...@@ -539,21 +580,23 @@ export const AuthServiceDefinition = {
116, 116,
104, 104,
47, 47,
115,
105,
103,
110,
117, 117,
112, 115,
101,
114,
115,
]), ]),
], ],
}, },
}, },
}, },
/** SignOut signs out the user. */ /**
signOut: { * DeleteSession terminates the current user session.
name: "SignOut", * This is an idempotent operation that invalidates the user's authentication.
requestType: SignOutRequest, */
deleteSession: {
name: "DeleteSession",
requestType: DeleteSessionRequest,
requestStream: false, requestStream: false,
responseType: Empty, responseType: Empty,
responseStream: false, responseStream: false,
...@@ -561,9 +604,9 @@ export const AuthServiceDefinition = { ...@@ -561,9 +604,9 @@ export const AuthServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
22, 31,
34, 42,
20, 29,
47, 47,
97, 97,
112, 112,
...@@ -578,11 +621,20 @@ export const AuthServiceDefinition = { ...@@ -578,11 +621,20 @@ export const AuthServiceDefinition = {
104, 104,
47, 47,
115, 115,
101,
115,
115,
105, 105,
103,
110,
111, 111,
110,
115,
47,
99,
117, 117,
114,
114,
101,
110,
116, 116,
]), ]),
], ],
......
...@@ -225,36 +225,46 @@ export function nodeTypeToNumber(object: NodeType): number { ...@@ -225,36 +225,46 @@ export function nodeTypeToNumber(object: NodeType): number {
} }
export interface ParseMarkdownRequest { export interface ParseMarkdownRequest {
/** The markdown content to parse. */
markdown: string; markdown: string;
} }
export interface ParseMarkdownResponse { export interface ParseMarkdownResponse {
/** The parsed markdown nodes. */
nodes: Node[]; nodes: Node[];
} }
export interface RestoreMarkdownNodesRequest { export interface RestoreMarkdownNodesRequest {
/** The nodes to restore to markdown content. */
nodes: Node[]; nodes: Node[];
} }
export interface RestoreMarkdownNodesResponse { export interface RestoreMarkdownNodesResponse {
/** The restored markdown content. */
markdown: string; markdown: string;
} }
export interface StringifyMarkdownNodesRequest { export interface StringifyMarkdownNodesRequest {
/** The nodes to stringify to plain text. */
nodes: Node[]; nodes: Node[];
} }
export interface StringifyMarkdownNodesResponse { export interface StringifyMarkdownNodesResponse {
/** The plain text content. */
plainText: string; plainText: string;
} }
export interface GetLinkMetadataRequest { export interface GetLinkMetadataRequest {
/** The link URL to get metadata for. */
link: string; link: string;
} }
export interface LinkMetadata { export interface LinkMetadata {
/** The title of the linked page. */
title: string; title: string;
/** The description of the linked page. */
description: string; description: string;
/** The URL of the preview image for the linked page. */
image: string; image: string;
} }
...@@ -407,7 +417,9 @@ export interface TableNode_Row { ...@@ -407,7 +417,9 @@ export interface TableNode_Row {
} }
export interface EmbeddedContentNode { export interface EmbeddedContentNode {
/** The resource name of the embedded content. */
resourceName: string; resourceName: string;
/** Additional parameters for the embedded content. */
params: string; params: string;
} }
...@@ -478,7 +490,9 @@ export interface SuperscriptNode { ...@@ -478,7 +490,9 @@ export interface SuperscriptNode {
} }
export interface ReferencedContentNode { export interface ReferencedContentNode {
/** The resource name of the referenced content. */
resourceName: string; resourceName: string;
/** Additional parameters for the referenced content. */
params: string; params: string;
} }
...@@ -3202,7 +3216,10 @@ export const MarkdownServiceDefinition = { ...@@ -3202,7 +3216,10 @@ export const MarkdownServiceDefinition = {
name: "MarkdownService", name: "MarkdownService",
fullName: "memos.api.v1.MarkdownService", fullName: "memos.api.v1.MarkdownService",
methods: { methods: {
/** ParseMarkdown parses the given markdown content and returns a list of nodes. */ /**
* ParseMarkdown parses the given markdown content and returns a list of nodes.
* This is a utility method that transforms markdown text into structured nodes.
*/
parseMarkdown: { parseMarkdown: {
name: "ParseMarkdown", name: "ParseMarkdown",
requestType: ParseMarkdownRequest, requestType: ParseMarkdownRequest,
...@@ -3246,7 +3263,10 @@ export const MarkdownServiceDefinition = { ...@@ -3246,7 +3263,10 @@ export const MarkdownServiceDefinition = {
}, },
}, },
}, },
/** RestoreMarkdownNodes restores the given nodes to markdown content. */ /**
* RestoreMarkdownNodes restores the given nodes to markdown content.
* This is the inverse operation of ParseMarkdown.
*/
restoreMarkdownNodes: { restoreMarkdownNodes: {
name: "RestoreMarkdownNodes", name: "RestoreMarkdownNodes",
requestType: RestoreMarkdownNodesRequest, requestType: RestoreMarkdownNodesRequest,
...@@ -3257,12 +3277,12 @@ export const MarkdownServiceDefinition = { ...@@ -3257,12 +3277,12 @@ export const MarkdownServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
34, 29,
58, 58,
1, 1,
42, 42,
34, 34,
29, 24,
47, 47,
97, 97,
112, 112,
...@@ -3279,11 +3299,6 @@ export const MarkdownServiceDefinition = { ...@@ -3279,11 +3299,6 @@ export const MarkdownServiceDefinition = {
111, 111,
119, 119,
110, 110,
47,
110,
111,
100,
101,
58, 58,
114, 114,
101, 101,
...@@ -3297,7 +3312,10 @@ export const MarkdownServiceDefinition = { ...@@ -3297,7 +3312,10 @@ export const MarkdownServiceDefinition = {
}, },
}, },
}, },
/** StringifyMarkdownNodes stringify the given nodes to plain text content. */ /**
* StringifyMarkdownNodes stringify the given nodes to plain text content.
* This removes all markdown formatting and returns plain text.
*/
stringifyMarkdownNodes: { stringifyMarkdownNodes: {
name: "StringifyMarkdownNodes", name: "StringifyMarkdownNodes",
requestType: StringifyMarkdownNodesRequest, requestType: StringifyMarkdownNodesRequest,
...@@ -3308,12 +3326,12 @@ export const MarkdownServiceDefinition = { ...@@ -3308,12 +3326,12 @@ export const MarkdownServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
36, 31,
58, 58,
1, 1,
42, 42,
34, 34,
31, 26,
47, 47,
97, 97,
112, 112,
...@@ -3330,11 +3348,6 @@ export const MarkdownServiceDefinition = { ...@@ -3330,11 +3348,6 @@ export const MarkdownServiceDefinition = {
111, 111,
119, 119,
110, 110,
47,
110,
111,
100,
101,
58, 58,
115, 115,
116, 116,
...@@ -3350,7 +3363,10 @@ export const MarkdownServiceDefinition = { ...@@ -3350,7 +3363,10 @@ export const MarkdownServiceDefinition = {
}, },
}, },
}, },
/** GetLinkMetadata returns metadata for a given link. */ /**
* GetLinkMetadata returns metadata for a given link.
* This is useful for generating link previews.
*/
getLinkMetadata: { getLinkMetadata: {
name: "GetLinkMetadata", name: "GetLinkMetadata",
requestType: GetLinkMetadataRequest, requestType: GetLinkMetadataRequest,
...@@ -3361,9 +3377,9 @@ export const MarkdownServiceDefinition = { ...@@ -3361,9 +3377,9 @@ export const MarkdownServiceDefinition = {
_unknownFields: { _unknownFields: {
578365826: [ 578365826: [
new Uint8Array([ new Uint8Array([
32, 36,
18, 18,
30, 34,
47, 47,
97, 97,
112, 112,
...@@ -3385,8 +3401,12 @@ export const MarkdownServiceDefinition = { ...@@ -3385,8 +3401,12 @@ export const MarkdownServiceDefinition = {
105, 105,
110, 110,
107, 107,
115,
58, 58,
109, 103,
101,
116,
77,
101, 101,
116, 116,
97, 97,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment