first commit
Some checks failed
Backend Tests / Static Checks (push) Has been cancelled
Backend Tests / Tests (other) (push) Has been cancelled
Backend Tests / Tests (plugin) (push) Has been cancelled
Backend Tests / Tests (server) (push) Has been cancelled
Backend Tests / Tests (store) (push) Has been cancelled
Build Canary Image / build-frontend (push) Has been cancelled
Build Canary Image / build-push (linux/amd64) (push) Has been cancelled
Build Canary Image / build-push (linux/arm64) (push) Has been cancelled
Build Canary Image / merge (push) Has been cancelled
Frontend Tests / Lint (push) Has been cancelled
Frontend Tests / Build (push) Has been cancelled
Proto Linter / Lint Protos (push) Has been cancelled

This commit is contained in:
2026-03-04 06:30:47 +00:00
commit bb402d4ccc
777 changed files with 135661 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/activity_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// ActivityServiceName is the fully-qualified name of the ActivityService service.
ActivityServiceName = "memos.api.v1.ActivityService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// ActivityServiceListActivitiesProcedure is the fully-qualified name of the ActivityService's
// ListActivities RPC.
ActivityServiceListActivitiesProcedure = "/memos.api.v1.ActivityService/ListActivities"
// ActivityServiceGetActivityProcedure is the fully-qualified name of the ActivityService's
// GetActivity RPC.
ActivityServiceGetActivityProcedure = "/memos.api.v1.ActivityService/GetActivity"
)
// ActivityServiceClient is a client for the memos.api.v1.ActivityService service.
type ActivityServiceClient interface {
// ListActivities returns a list of activities.
ListActivities(context.Context, *connect.Request[v1.ListActivitiesRequest]) (*connect.Response[v1.ListActivitiesResponse], error)
// GetActivity returns the activity with the given id.
GetActivity(context.Context, *connect.Request[v1.GetActivityRequest]) (*connect.Response[v1.Activity], error)
}
// NewActivityServiceClient constructs a client for the memos.api.v1.ActivityService service. By
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewActivityServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ActivityServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
activityServiceMethods := v1.File_api_v1_activity_service_proto.Services().ByName("ActivityService").Methods()
return &activityServiceClient{
listActivities: connect.NewClient[v1.ListActivitiesRequest, v1.ListActivitiesResponse](
httpClient,
baseURL+ActivityServiceListActivitiesProcedure,
connect.WithSchema(activityServiceMethods.ByName("ListActivities")),
connect.WithClientOptions(opts...),
),
getActivity: connect.NewClient[v1.GetActivityRequest, v1.Activity](
httpClient,
baseURL+ActivityServiceGetActivityProcedure,
connect.WithSchema(activityServiceMethods.ByName("GetActivity")),
connect.WithClientOptions(opts...),
),
}
}
// activityServiceClient implements ActivityServiceClient.
type activityServiceClient struct {
listActivities *connect.Client[v1.ListActivitiesRequest, v1.ListActivitiesResponse]
getActivity *connect.Client[v1.GetActivityRequest, v1.Activity]
}
// ListActivities calls memos.api.v1.ActivityService.ListActivities.
func (c *activityServiceClient) ListActivities(ctx context.Context, req *connect.Request[v1.ListActivitiesRequest]) (*connect.Response[v1.ListActivitiesResponse], error) {
return c.listActivities.CallUnary(ctx, req)
}
// GetActivity calls memos.api.v1.ActivityService.GetActivity.
func (c *activityServiceClient) GetActivity(ctx context.Context, req *connect.Request[v1.GetActivityRequest]) (*connect.Response[v1.Activity], error) {
return c.getActivity.CallUnary(ctx, req)
}
// ActivityServiceHandler is an implementation of the memos.api.v1.ActivityService service.
type ActivityServiceHandler interface {
// ListActivities returns a list of activities.
ListActivities(context.Context, *connect.Request[v1.ListActivitiesRequest]) (*connect.Response[v1.ListActivitiesResponse], error)
// GetActivity returns the activity with the given id.
GetActivity(context.Context, *connect.Request[v1.GetActivityRequest]) (*connect.Response[v1.Activity], error)
}
// NewActivityServiceHandler builds an HTTP handler from the service implementation. It returns the
// path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewActivityServiceHandler(svc ActivityServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
activityServiceMethods := v1.File_api_v1_activity_service_proto.Services().ByName("ActivityService").Methods()
activityServiceListActivitiesHandler := connect.NewUnaryHandler(
ActivityServiceListActivitiesProcedure,
svc.ListActivities,
connect.WithSchema(activityServiceMethods.ByName("ListActivities")),
connect.WithHandlerOptions(opts...),
)
activityServiceGetActivityHandler := connect.NewUnaryHandler(
ActivityServiceGetActivityProcedure,
svc.GetActivity,
connect.WithSchema(activityServiceMethods.ByName("GetActivity")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.ActivityService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case ActivityServiceListActivitiesProcedure:
activityServiceListActivitiesHandler.ServeHTTP(w, r)
case ActivityServiceGetActivityProcedure:
activityServiceGetActivityHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedActivityServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedActivityServiceHandler struct{}
func (UnimplementedActivityServiceHandler) ListActivities(context.Context, *connect.Request[v1.ListActivitiesRequest]) (*connect.Response[v1.ListActivitiesResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.ActivityService.ListActivities is not implemented"))
}
func (UnimplementedActivityServiceHandler) GetActivity(context.Context, *connect.Request[v1.GetActivityRequest]) (*connect.Response[v1.Activity], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.ActivityService.GetActivity is not implemented"))
}

View File

@@ -0,0 +1,236 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/attachment_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// AttachmentServiceName is the fully-qualified name of the AttachmentService service.
AttachmentServiceName = "memos.api.v1.AttachmentService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// AttachmentServiceCreateAttachmentProcedure is the fully-qualified name of the AttachmentService's
// CreateAttachment RPC.
AttachmentServiceCreateAttachmentProcedure = "/memos.api.v1.AttachmentService/CreateAttachment"
// AttachmentServiceListAttachmentsProcedure is the fully-qualified name of the AttachmentService's
// ListAttachments RPC.
AttachmentServiceListAttachmentsProcedure = "/memos.api.v1.AttachmentService/ListAttachments"
// AttachmentServiceGetAttachmentProcedure is the fully-qualified name of the AttachmentService's
// GetAttachment RPC.
AttachmentServiceGetAttachmentProcedure = "/memos.api.v1.AttachmentService/GetAttachment"
// AttachmentServiceUpdateAttachmentProcedure is the fully-qualified name of the AttachmentService's
// UpdateAttachment RPC.
AttachmentServiceUpdateAttachmentProcedure = "/memos.api.v1.AttachmentService/UpdateAttachment"
// AttachmentServiceDeleteAttachmentProcedure is the fully-qualified name of the AttachmentService's
// DeleteAttachment RPC.
AttachmentServiceDeleteAttachmentProcedure = "/memos.api.v1.AttachmentService/DeleteAttachment"
)
// AttachmentServiceClient is a client for the memos.api.v1.AttachmentService service.
type AttachmentServiceClient interface {
// CreateAttachment creates a new attachment.
CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
// ListAttachments lists all attachments.
ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error)
// GetAttachment returns a attachment by name.
GetAttachment(context.Context, *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error)
// UpdateAttachment updates a attachment.
UpdateAttachment(context.Context, *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
// DeleteAttachment deletes a attachment by name.
DeleteAttachment(context.Context, *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewAttachmentServiceClient constructs a client for the memos.api.v1.AttachmentService service. By
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewAttachmentServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AttachmentServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
attachmentServiceMethods := v1.File_api_v1_attachment_service_proto.Services().ByName("AttachmentService").Methods()
return &attachmentServiceClient{
createAttachment: connect.NewClient[v1.CreateAttachmentRequest, v1.Attachment](
httpClient,
baseURL+AttachmentServiceCreateAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
connect.WithClientOptions(opts...),
),
listAttachments: connect.NewClient[v1.ListAttachmentsRequest, v1.ListAttachmentsResponse](
httpClient,
baseURL+AttachmentServiceListAttachmentsProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("ListAttachments")),
connect.WithClientOptions(opts...),
),
getAttachment: connect.NewClient[v1.GetAttachmentRequest, v1.Attachment](
httpClient,
baseURL+AttachmentServiceGetAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("GetAttachment")),
connect.WithClientOptions(opts...),
),
updateAttachment: connect.NewClient[v1.UpdateAttachmentRequest, v1.Attachment](
httpClient,
baseURL+AttachmentServiceUpdateAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("UpdateAttachment")),
connect.WithClientOptions(opts...),
),
deleteAttachment: connect.NewClient[v1.DeleteAttachmentRequest, emptypb.Empty](
httpClient,
baseURL+AttachmentServiceDeleteAttachmentProcedure,
connect.WithSchema(attachmentServiceMethods.ByName("DeleteAttachment")),
connect.WithClientOptions(opts...),
),
}
}
// attachmentServiceClient implements AttachmentServiceClient.
type attachmentServiceClient struct {
createAttachment *connect.Client[v1.CreateAttachmentRequest, v1.Attachment]
listAttachments *connect.Client[v1.ListAttachmentsRequest, v1.ListAttachmentsResponse]
getAttachment *connect.Client[v1.GetAttachmentRequest, v1.Attachment]
updateAttachment *connect.Client[v1.UpdateAttachmentRequest, v1.Attachment]
deleteAttachment *connect.Client[v1.DeleteAttachmentRequest, emptypb.Empty]
}
// CreateAttachment calls memos.api.v1.AttachmentService.CreateAttachment.
func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, req *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
return c.createAttachment.CallUnary(ctx, req)
}
// ListAttachments calls memos.api.v1.AttachmentService.ListAttachments.
func (c *attachmentServiceClient) ListAttachments(ctx context.Context, req *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error) {
return c.listAttachments.CallUnary(ctx, req)
}
// GetAttachment calls memos.api.v1.AttachmentService.GetAttachment.
func (c *attachmentServiceClient) GetAttachment(ctx context.Context, req *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
return c.getAttachment.CallUnary(ctx, req)
}
// UpdateAttachment calls memos.api.v1.AttachmentService.UpdateAttachment.
func (c *attachmentServiceClient) UpdateAttachment(ctx context.Context, req *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
return c.updateAttachment.CallUnary(ctx, req)
}
// DeleteAttachment calls memos.api.v1.AttachmentService.DeleteAttachment.
func (c *attachmentServiceClient) DeleteAttachment(ctx context.Context, req *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteAttachment.CallUnary(ctx, req)
}
// AttachmentServiceHandler is an implementation of the memos.api.v1.AttachmentService service.
type AttachmentServiceHandler interface {
// CreateAttachment creates a new attachment.
CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
// ListAttachments lists all attachments.
ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error)
// GetAttachment returns a attachment by name.
GetAttachment(context.Context, *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error)
// UpdateAttachment updates a attachment.
UpdateAttachment(context.Context, *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
// DeleteAttachment deletes a attachment by name.
DeleteAttachment(context.Context, *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewAttachmentServiceHandler builds an HTTP handler from the service implementation. It returns
// the path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
attachmentServiceMethods := v1.File_api_v1_attachment_service_proto.Services().ByName("AttachmentService").Methods()
attachmentServiceCreateAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceCreateAttachmentProcedure,
svc.CreateAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceListAttachmentsHandler := connect.NewUnaryHandler(
AttachmentServiceListAttachmentsProcedure,
svc.ListAttachments,
connect.WithSchema(attachmentServiceMethods.ByName("ListAttachments")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceGetAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceGetAttachmentProcedure,
svc.GetAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("GetAttachment")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceUpdateAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceUpdateAttachmentProcedure,
svc.UpdateAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("UpdateAttachment")),
connect.WithHandlerOptions(opts...),
)
attachmentServiceDeleteAttachmentHandler := connect.NewUnaryHandler(
AttachmentServiceDeleteAttachmentProcedure,
svc.DeleteAttachment,
connect.WithSchema(attachmentServiceMethods.ByName("DeleteAttachment")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.AttachmentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case AttachmentServiceCreateAttachmentProcedure:
attachmentServiceCreateAttachmentHandler.ServeHTTP(w, r)
case AttachmentServiceListAttachmentsProcedure:
attachmentServiceListAttachmentsHandler.ServeHTTP(w, r)
case AttachmentServiceGetAttachmentProcedure:
attachmentServiceGetAttachmentHandler.ServeHTTP(w, r)
case AttachmentServiceUpdateAttachmentProcedure:
attachmentServiceUpdateAttachmentHandler.ServeHTTP(w, r)
case AttachmentServiceDeleteAttachmentProcedure:
attachmentServiceDeleteAttachmentHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedAttachmentServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedAttachmentServiceHandler struct{}
func (UnimplementedAttachmentServiceHandler) CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.CreateAttachment is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.ListAttachments is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) GetAttachment(context.Context, *connect.Request[v1.GetAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.GetAttachment is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) UpdateAttachment(context.Context, *connect.Request[v1.UpdateAttachmentRequest]) (*connect.Response[v1.Attachment], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.UpdateAttachment is not implemented"))
}
func (UnimplementedAttachmentServiceHandler) DeleteAttachment(context.Context, *connect.Request[v1.DeleteAttachmentRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.DeleteAttachment is not implemented"))
}

View File

@@ -0,0 +1,217 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/auth_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// AuthServiceName is the fully-qualified name of the AuthService service.
AuthServiceName = "memos.api.v1.AuthService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// AuthServiceGetCurrentUserProcedure is the fully-qualified name of the AuthService's
// GetCurrentUser RPC.
AuthServiceGetCurrentUserProcedure = "/memos.api.v1.AuthService/GetCurrentUser"
// AuthServiceSignInProcedure is the fully-qualified name of the AuthService's SignIn RPC.
AuthServiceSignInProcedure = "/memos.api.v1.AuthService/SignIn"
// AuthServiceSignOutProcedure is the fully-qualified name of the AuthService's SignOut RPC.
AuthServiceSignOutProcedure = "/memos.api.v1.AuthService/SignOut"
// AuthServiceRefreshTokenProcedure is the fully-qualified name of the AuthService's RefreshToken
// RPC.
AuthServiceRefreshTokenProcedure = "/memos.api.v1.AuthService/RefreshToken"
)
// AuthServiceClient is a client for the memos.api.v1.AuthService service.
type AuthServiceClient interface {
// GetCurrentUser returns the authenticated user's information.
// Validates the access token and returns user details.
// Similar to OIDC's /userinfo endpoint.
GetCurrentUser(context.Context, *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error)
// SignIn authenticates a user with credentials and returns tokens.
// On success, returns an access token and sets a refresh token cookie.
// Supports password-based and SSO authentication methods.
SignIn(context.Context, *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error)
// SignOut terminates the user's authentication.
// Revokes the refresh token and clears the authentication cookie.
SignOut(context.Context, *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
// RefreshToken exchanges a valid refresh token for a new access token.
// The refresh token is read from the HttpOnly cookie.
// Returns a new short-lived access token.
RefreshToken(context.Context, *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error)
}
// NewAuthServiceClient constructs a client for the memos.api.v1.AuthService service. By default, it
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
// connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewAuthServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuthServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
authServiceMethods := v1.File_api_v1_auth_service_proto.Services().ByName("AuthService").Methods()
return &authServiceClient{
getCurrentUser: connect.NewClient[v1.GetCurrentUserRequest, v1.GetCurrentUserResponse](
httpClient,
baseURL+AuthServiceGetCurrentUserProcedure,
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
connect.WithClientOptions(opts...),
),
signIn: connect.NewClient[v1.SignInRequest, v1.SignInResponse](
httpClient,
baseURL+AuthServiceSignInProcedure,
connect.WithSchema(authServiceMethods.ByName("SignIn")),
connect.WithClientOptions(opts...),
),
signOut: connect.NewClient[v1.SignOutRequest, emptypb.Empty](
httpClient,
baseURL+AuthServiceSignOutProcedure,
connect.WithSchema(authServiceMethods.ByName("SignOut")),
connect.WithClientOptions(opts...),
),
refreshToken: connect.NewClient[v1.RefreshTokenRequest, v1.RefreshTokenResponse](
httpClient,
baseURL+AuthServiceRefreshTokenProcedure,
connect.WithSchema(authServiceMethods.ByName("RefreshToken")),
connect.WithClientOptions(opts...),
),
}
}
// authServiceClient implements AuthServiceClient.
type authServiceClient struct {
getCurrentUser *connect.Client[v1.GetCurrentUserRequest, v1.GetCurrentUserResponse]
signIn *connect.Client[v1.SignInRequest, v1.SignInResponse]
signOut *connect.Client[v1.SignOutRequest, emptypb.Empty]
refreshToken *connect.Client[v1.RefreshTokenRequest, v1.RefreshTokenResponse]
}
// GetCurrentUser calls memos.api.v1.AuthService.GetCurrentUser.
func (c *authServiceClient) GetCurrentUser(ctx context.Context, req *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error) {
return c.getCurrentUser.CallUnary(ctx, req)
}
// SignIn calls memos.api.v1.AuthService.SignIn.
func (c *authServiceClient) SignIn(ctx context.Context, req *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error) {
return c.signIn.CallUnary(ctx, req)
}
// SignOut calls memos.api.v1.AuthService.SignOut.
func (c *authServiceClient) SignOut(ctx context.Context, req *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
return c.signOut.CallUnary(ctx, req)
}
// RefreshToken calls memos.api.v1.AuthService.RefreshToken.
func (c *authServiceClient) RefreshToken(ctx context.Context, req *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error) {
return c.refreshToken.CallUnary(ctx, req)
}
// AuthServiceHandler is an implementation of the memos.api.v1.AuthService service.
type AuthServiceHandler interface {
// GetCurrentUser returns the authenticated user's information.
// Validates the access token and returns user details.
// Similar to OIDC's /userinfo endpoint.
GetCurrentUser(context.Context, *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error)
// SignIn authenticates a user with credentials and returns tokens.
// On success, returns an access token and sets a refresh token cookie.
// Supports password-based and SSO authentication methods.
SignIn(context.Context, *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error)
// SignOut terminates the user's authentication.
// Revokes the refresh token and clears the authentication cookie.
SignOut(context.Context, *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error)
// RefreshToken exchanges a valid refresh token for a new access token.
// The refresh token is read from the HttpOnly cookie.
// Returns a new short-lived access token.
RefreshToken(context.Context, *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error)
}
// NewAuthServiceHandler builds an HTTP handler from the service implementation. It returns the path
// on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewAuthServiceHandler(svc AuthServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
authServiceMethods := v1.File_api_v1_auth_service_proto.Services().ByName("AuthService").Methods()
authServiceGetCurrentUserHandler := connect.NewUnaryHandler(
AuthServiceGetCurrentUserProcedure,
svc.GetCurrentUser,
connect.WithSchema(authServiceMethods.ByName("GetCurrentUser")),
connect.WithHandlerOptions(opts...),
)
authServiceSignInHandler := connect.NewUnaryHandler(
AuthServiceSignInProcedure,
svc.SignIn,
connect.WithSchema(authServiceMethods.ByName("SignIn")),
connect.WithHandlerOptions(opts...),
)
authServiceSignOutHandler := connect.NewUnaryHandler(
AuthServiceSignOutProcedure,
svc.SignOut,
connect.WithSchema(authServiceMethods.ByName("SignOut")),
connect.WithHandlerOptions(opts...),
)
authServiceRefreshTokenHandler := connect.NewUnaryHandler(
AuthServiceRefreshTokenProcedure,
svc.RefreshToken,
connect.WithSchema(authServiceMethods.ByName("RefreshToken")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.AuthService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case AuthServiceGetCurrentUserProcedure:
authServiceGetCurrentUserHandler.ServeHTTP(w, r)
case AuthServiceSignInProcedure:
authServiceSignInHandler.ServeHTTP(w, r)
case AuthServiceSignOutProcedure:
authServiceSignOutHandler.ServeHTTP(w, r)
case AuthServiceRefreshTokenProcedure:
authServiceRefreshTokenHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedAuthServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedAuthServiceHandler struct{}
func (UnimplementedAuthServiceHandler) GetCurrentUser(context.Context, *connect.Request[v1.GetCurrentUserRequest]) (*connect.Response[v1.GetCurrentUserResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.GetCurrentUser is not implemented"))
}
func (UnimplementedAuthServiceHandler) SignIn(context.Context, *connect.Request[v1.SignInRequest]) (*connect.Response[v1.SignInResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.SignIn is not implemented"))
}
func (UnimplementedAuthServiceHandler) SignOut(context.Context, *connect.Request[v1.SignOutRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.SignOut is not implemented"))
}
func (UnimplementedAuthServiceHandler) RefreshToken(context.Context, *connect.Request[v1.RefreshTokenRequest]) (*connect.Response[v1.RefreshTokenResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AuthService.RefreshToken is not implemented"))
}

View File

@@ -0,0 +1,237 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/idp_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// IdentityProviderServiceName is the fully-qualified name of the IdentityProviderService service.
IdentityProviderServiceName = "memos.api.v1.IdentityProviderService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// IdentityProviderServiceListIdentityProvidersProcedure is the fully-qualified name of the
// IdentityProviderService's ListIdentityProviders RPC.
IdentityProviderServiceListIdentityProvidersProcedure = "/memos.api.v1.IdentityProviderService/ListIdentityProviders"
// IdentityProviderServiceGetIdentityProviderProcedure is the fully-qualified name of the
// IdentityProviderService's GetIdentityProvider RPC.
IdentityProviderServiceGetIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/GetIdentityProvider"
// IdentityProviderServiceCreateIdentityProviderProcedure is the fully-qualified name of the
// IdentityProviderService's CreateIdentityProvider RPC.
IdentityProviderServiceCreateIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/CreateIdentityProvider"
// IdentityProviderServiceUpdateIdentityProviderProcedure is the fully-qualified name of the
// IdentityProviderService's UpdateIdentityProvider RPC.
IdentityProviderServiceUpdateIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/UpdateIdentityProvider"
// IdentityProviderServiceDeleteIdentityProviderProcedure is the fully-qualified name of the
// IdentityProviderService's DeleteIdentityProvider RPC.
IdentityProviderServiceDeleteIdentityProviderProcedure = "/memos.api.v1.IdentityProviderService/DeleteIdentityProvider"
)
// IdentityProviderServiceClient is a client for the memos.api.v1.IdentityProviderService service.
type IdentityProviderServiceClient interface {
// ListIdentityProviders lists identity providers.
ListIdentityProviders(context.Context, *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error)
// GetIdentityProvider gets an identity provider.
GetIdentityProvider(context.Context, *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
// CreateIdentityProvider creates an identity provider.
CreateIdentityProvider(context.Context, *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
// UpdateIdentityProvider updates an identity provider.
UpdateIdentityProvider(context.Context, *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
// DeleteIdentityProvider deletes an identity provider.
DeleteIdentityProvider(context.Context, *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewIdentityProviderServiceClient constructs a client for the memos.api.v1.IdentityProviderService
// service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for
// gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply
// the connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewIdentityProviderServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) IdentityProviderServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
identityProviderServiceMethods := v1.File_api_v1_idp_service_proto.Services().ByName("IdentityProviderService").Methods()
return &identityProviderServiceClient{
listIdentityProviders: connect.NewClient[v1.ListIdentityProvidersRequest, v1.ListIdentityProvidersResponse](
httpClient,
baseURL+IdentityProviderServiceListIdentityProvidersProcedure,
connect.WithSchema(identityProviderServiceMethods.ByName("ListIdentityProviders")),
connect.WithClientOptions(opts...),
),
getIdentityProvider: connect.NewClient[v1.GetIdentityProviderRequest, v1.IdentityProvider](
httpClient,
baseURL+IdentityProviderServiceGetIdentityProviderProcedure,
connect.WithSchema(identityProviderServiceMethods.ByName("GetIdentityProvider")),
connect.WithClientOptions(opts...),
),
createIdentityProvider: connect.NewClient[v1.CreateIdentityProviderRequest, v1.IdentityProvider](
httpClient,
baseURL+IdentityProviderServiceCreateIdentityProviderProcedure,
connect.WithSchema(identityProviderServiceMethods.ByName("CreateIdentityProvider")),
connect.WithClientOptions(opts...),
),
updateIdentityProvider: connect.NewClient[v1.UpdateIdentityProviderRequest, v1.IdentityProvider](
httpClient,
baseURL+IdentityProviderServiceUpdateIdentityProviderProcedure,
connect.WithSchema(identityProviderServiceMethods.ByName("UpdateIdentityProvider")),
connect.WithClientOptions(opts...),
),
deleteIdentityProvider: connect.NewClient[v1.DeleteIdentityProviderRequest, emptypb.Empty](
httpClient,
baseURL+IdentityProviderServiceDeleteIdentityProviderProcedure,
connect.WithSchema(identityProviderServiceMethods.ByName("DeleteIdentityProvider")),
connect.WithClientOptions(opts...),
),
}
}
// identityProviderServiceClient implements IdentityProviderServiceClient.
type identityProviderServiceClient struct {
listIdentityProviders *connect.Client[v1.ListIdentityProvidersRequest, v1.ListIdentityProvidersResponse]
getIdentityProvider *connect.Client[v1.GetIdentityProviderRequest, v1.IdentityProvider]
createIdentityProvider *connect.Client[v1.CreateIdentityProviderRequest, v1.IdentityProvider]
updateIdentityProvider *connect.Client[v1.UpdateIdentityProviderRequest, v1.IdentityProvider]
deleteIdentityProvider *connect.Client[v1.DeleteIdentityProviderRequest, emptypb.Empty]
}
// ListIdentityProviders calls memos.api.v1.IdentityProviderService.ListIdentityProviders.
func (c *identityProviderServiceClient) ListIdentityProviders(ctx context.Context, req *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error) {
return c.listIdentityProviders.CallUnary(ctx, req)
}
// GetIdentityProvider calls memos.api.v1.IdentityProviderService.GetIdentityProvider.
func (c *identityProviderServiceClient) GetIdentityProvider(ctx context.Context, req *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
return c.getIdentityProvider.CallUnary(ctx, req)
}
// CreateIdentityProvider calls memos.api.v1.IdentityProviderService.CreateIdentityProvider.
func (c *identityProviderServiceClient) CreateIdentityProvider(ctx context.Context, req *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
return c.createIdentityProvider.CallUnary(ctx, req)
}
// UpdateIdentityProvider calls memos.api.v1.IdentityProviderService.UpdateIdentityProvider.
func (c *identityProviderServiceClient) UpdateIdentityProvider(ctx context.Context, req *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
return c.updateIdentityProvider.CallUnary(ctx, req)
}
// DeleteIdentityProvider calls memos.api.v1.IdentityProviderService.DeleteIdentityProvider.
func (c *identityProviderServiceClient) DeleteIdentityProvider(ctx context.Context, req *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteIdentityProvider.CallUnary(ctx, req)
}
// IdentityProviderServiceHandler is an implementation of the memos.api.v1.IdentityProviderService
// service.
type IdentityProviderServiceHandler interface {
// ListIdentityProviders lists identity providers.
ListIdentityProviders(context.Context, *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error)
// GetIdentityProvider gets an identity provider.
GetIdentityProvider(context.Context, *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
// CreateIdentityProvider creates an identity provider.
CreateIdentityProvider(context.Context, *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
// UpdateIdentityProvider updates an identity provider.
UpdateIdentityProvider(context.Context, *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error)
// DeleteIdentityProvider deletes an identity provider.
DeleteIdentityProvider(context.Context, *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewIdentityProviderServiceHandler builds an HTTP handler from the service implementation. It
// returns the path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewIdentityProviderServiceHandler(svc IdentityProviderServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
identityProviderServiceMethods := v1.File_api_v1_idp_service_proto.Services().ByName("IdentityProviderService").Methods()
identityProviderServiceListIdentityProvidersHandler := connect.NewUnaryHandler(
IdentityProviderServiceListIdentityProvidersProcedure,
svc.ListIdentityProviders,
connect.WithSchema(identityProviderServiceMethods.ByName("ListIdentityProviders")),
connect.WithHandlerOptions(opts...),
)
identityProviderServiceGetIdentityProviderHandler := connect.NewUnaryHandler(
IdentityProviderServiceGetIdentityProviderProcedure,
svc.GetIdentityProvider,
connect.WithSchema(identityProviderServiceMethods.ByName("GetIdentityProvider")),
connect.WithHandlerOptions(opts...),
)
identityProviderServiceCreateIdentityProviderHandler := connect.NewUnaryHandler(
IdentityProviderServiceCreateIdentityProviderProcedure,
svc.CreateIdentityProvider,
connect.WithSchema(identityProviderServiceMethods.ByName("CreateIdentityProvider")),
connect.WithHandlerOptions(opts...),
)
identityProviderServiceUpdateIdentityProviderHandler := connect.NewUnaryHandler(
IdentityProviderServiceUpdateIdentityProviderProcedure,
svc.UpdateIdentityProvider,
connect.WithSchema(identityProviderServiceMethods.ByName("UpdateIdentityProvider")),
connect.WithHandlerOptions(opts...),
)
identityProviderServiceDeleteIdentityProviderHandler := connect.NewUnaryHandler(
IdentityProviderServiceDeleteIdentityProviderProcedure,
svc.DeleteIdentityProvider,
connect.WithSchema(identityProviderServiceMethods.ByName("DeleteIdentityProvider")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.IdentityProviderService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case IdentityProviderServiceListIdentityProvidersProcedure:
identityProviderServiceListIdentityProvidersHandler.ServeHTTP(w, r)
case IdentityProviderServiceGetIdentityProviderProcedure:
identityProviderServiceGetIdentityProviderHandler.ServeHTTP(w, r)
case IdentityProviderServiceCreateIdentityProviderProcedure:
identityProviderServiceCreateIdentityProviderHandler.ServeHTTP(w, r)
case IdentityProviderServiceUpdateIdentityProviderProcedure:
identityProviderServiceUpdateIdentityProviderHandler.ServeHTTP(w, r)
case IdentityProviderServiceDeleteIdentityProviderProcedure:
identityProviderServiceDeleteIdentityProviderHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedIdentityProviderServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedIdentityProviderServiceHandler struct{}
func (UnimplementedIdentityProviderServiceHandler) ListIdentityProviders(context.Context, *connect.Request[v1.ListIdentityProvidersRequest]) (*connect.Response[v1.ListIdentityProvidersResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.ListIdentityProviders is not implemented"))
}
func (UnimplementedIdentityProviderServiceHandler) GetIdentityProvider(context.Context, *connect.Request[v1.GetIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.GetIdentityProvider is not implemented"))
}
func (UnimplementedIdentityProviderServiceHandler) CreateIdentityProvider(context.Context, *connect.Request[v1.CreateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.CreateIdentityProvider is not implemented"))
}
func (UnimplementedIdentityProviderServiceHandler) UpdateIdentityProvider(context.Context, *connect.Request[v1.UpdateIdentityProviderRequest]) (*connect.Response[v1.IdentityProvider], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.UpdateIdentityProvider is not implemented"))
}
func (UnimplementedIdentityProviderServiceHandler) DeleteIdentityProvider(context.Context, *connect.Request[v1.DeleteIdentityProviderRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.IdentityProviderService.DeleteIdentityProvider is not implemented"))
}

View File

@@ -0,0 +1,173 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/instance_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// InstanceServiceName is the fully-qualified name of the InstanceService service.
InstanceServiceName = "memos.api.v1.InstanceService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// InstanceServiceGetInstanceProfileProcedure is the fully-qualified name of the InstanceService's
// GetInstanceProfile RPC.
InstanceServiceGetInstanceProfileProcedure = "/memos.api.v1.InstanceService/GetInstanceProfile"
// InstanceServiceGetInstanceSettingProcedure is the fully-qualified name of the InstanceService's
// GetInstanceSetting RPC.
InstanceServiceGetInstanceSettingProcedure = "/memos.api.v1.InstanceService/GetInstanceSetting"
// InstanceServiceUpdateInstanceSettingProcedure is the fully-qualified name of the
// InstanceService's UpdateInstanceSetting RPC.
InstanceServiceUpdateInstanceSettingProcedure = "/memos.api.v1.InstanceService/UpdateInstanceSetting"
)
// InstanceServiceClient is a client for the memos.api.v1.InstanceService service.
type InstanceServiceClient interface {
// Gets the instance profile.
GetInstanceProfile(context.Context, *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error)
// Gets an instance setting.
GetInstanceSetting(context.Context, *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
// Updates an instance setting.
UpdateInstanceSetting(context.Context, *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
}
// NewInstanceServiceClient constructs a client for the memos.api.v1.InstanceService service. By
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewInstanceServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) InstanceServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
instanceServiceMethods := v1.File_api_v1_instance_service_proto.Services().ByName("InstanceService").Methods()
return &instanceServiceClient{
getInstanceProfile: connect.NewClient[v1.GetInstanceProfileRequest, v1.InstanceProfile](
httpClient,
baseURL+InstanceServiceGetInstanceProfileProcedure,
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceProfile")),
connect.WithClientOptions(opts...),
),
getInstanceSetting: connect.NewClient[v1.GetInstanceSettingRequest, v1.InstanceSetting](
httpClient,
baseURL+InstanceServiceGetInstanceSettingProcedure,
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceSetting")),
connect.WithClientOptions(opts...),
),
updateInstanceSetting: connect.NewClient[v1.UpdateInstanceSettingRequest, v1.InstanceSetting](
httpClient,
baseURL+InstanceServiceUpdateInstanceSettingProcedure,
connect.WithSchema(instanceServiceMethods.ByName("UpdateInstanceSetting")),
connect.WithClientOptions(opts...),
),
}
}
// instanceServiceClient implements InstanceServiceClient.
type instanceServiceClient struct {
getInstanceProfile *connect.Client[v1.GetInstanceProfileRequest, v1.InstanceProfile]
getInstanceSetting *connect.Client[v1.GetInstanceSettingRequest, v1.InstanceSetting]
updateInstanceSetting *connect.Client[v1.UpdateInstanceSettingRequest, v1.InstanceSetting]
}
// GetInstanceProfile calls memos.api.v1.InstanceService.GetInstanceProfile.
func (c *instanceServiceClient) GetInstanceProfile(ctx context.Context, req *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error) {
return c.getInstanceProfile.CallUnary(ctx, req)
}
// GetInstanceSetting calls memos.api.v1.InstanceService.GetInstanceSetting.
func (c *instanceServiceClient) GetInstanceSetting(ctx context.Context, req *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
return c.getInstanceSetting.CallUnary(ctx, req)
}
// UpdateInstanceSetting calls memos.api.v1.InstanceService.UpdateInstanceSetting.
func (c *instanceServiceClient) UpdateInstanceSetting(ctx context.Context, req *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
return c.updateInstanceSetting.CallUnary(ctx, req)
}
// InstanceServiceHandler is an implementation of the memos.api.v1.InstanceService service.
type InstanceServiceHandler interface {
// Gets the instance profile.
GetInstanceProfile(context.Context, *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error)
// Gets an instance setting.
GetInstanceSetting(context.Context, *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
// Updates an instance setting.
UpdateInstanceSetting(context.Context, *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error)
}
// NewInstanceServiceHandler builds an HTTP handler from the service implementation. It returns the
// path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewInstanceServiceHandler(svc InstanceServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
instanceServiceMethods := v1.File_api_v1_instance_service_proto.Services().ByName("InstanceService").Methods()
instanceServiceGetInstanceProfileHandler := connect.NewUnaryHandler(
InstanceServiceGetInstanceProfileProcedure,
svc.GetInstanceProfile,
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceProfile")),
connect.WithHandlerOptions(opts...),
)
instanceServiceGetInstanceSettingHandler := connect.NewUnaryHandler(
InstanceServiceGetInstanceSettingProcedure,
svc.GetInstanceSetting,
connect.WithSchema(instanceServiceMethods.ByName("GetInstanceSetting")),
connect.WithHandlerOptions(opts...),
)
instanceServiceUpdateInstanceSettingHandler := connect.NewUnaryHandler(
InstanceServiceUpdateInstanceSettingProcedure,
svc.UpdateInstanceSetting,
connect.WithSchema(instanceServiceMethods.ByName("UpdateInstanceSetting")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.InstanceService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case InstanceServiceGetInstanceProfileProcedure:
instanceServiceGetInstanceProfileHandler.ServeHTTP(w, r)
case InstanceServiceGetInstanceSettingProcedure:
instanceServiceGetInstanceSettingHandler.ServeHTTP(w, r)
case InstanceServiceUpdateInstanceSettingProcedure:
instanceServiceUpdateInstanceSettingHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedInstanceServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedInstanceServiceHandler struct{}
func (UnimplementedInstanceServiceHandler) GetInstanceProfile(context.Context, *connect.Request[v1.GetInstanceProfileRequest]) (*connect.Response[v1.InstanceProfile], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.GetInstanceProfile is not implemented"))
}
func (UnimplementedInstanceServiceHandler) GetInstanceSetting(context.Context, *connect.Request[v1.GetInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.GetInstanceSetting is not implemented"))
}
func (UnimplementedInstanceServiceHandler) UpdateInstanceSetting(context.Context, *connect.Request[v1.UpdateInstanceSettingRequest]) (*connect.Response[v1.InstanceSetting], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.InstanceService.UpdateInstanceSetting is not implemented"))
}

View File

@@ -0,0 +1,510 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/memo_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// MemoServiceName is the fully-qualified name of the MemoService service.
MemoServiceName = "memos.api.v1.MemoService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// MemoServiceCreateMemoProcedure is the fully-qualified name of the MemoService's CreateMemo RPC.
MemoServiceCreateMemoProcedure = "/memos.api.v1.MemoService/CreateMemo"
// MemoServiceListMemosProcedure is the fully-qualified name of the MemoService's ListMemos RPC.
MemoServiceListMemosProcedure = "/memos.api.v1.MemoService/ListMemos"
// MemoServiceGetMemoProcedure is the fully-qualified name of the MemoService's GetMemo RPC.
MemoServiceGetMemoProcedure = "/memos.api.v1.MemoService/GetMemo"
// MemoServiceUpdateMemoProcedure is the fully-qualified name of the MemoService's UpdateMemo RPC.
MemoServiceUpdateMemoProcedure = "/memos.api.v1.MemoService/UpdateMemo"
// MemoServiceDeleteMemoProcedure is the fully-qualified name of the MemoService's DeleteMemo RPC.
MemoServiceDeleteMemoProcedure = "/memos.api.v1.MemoService/DeleteMemo"
// MemoServiceSetMemoAttachmentsProcedure is the fully-qualified name of the MemoService's
// SetMemoAttachments RPC.
MemoServiceSetMemoAttachmentsProcedure = "/memos.api.v1.MemoService/SetMemoAttachments"
// MemoServiceListMemoAttachmentsProcedure is the fully-qualified name of the MemoService's
// ListMemoAttachments RPC.
MemoServiceListMemoAttachmentsProcedure = "/memos.api.v1.MemoService/ListMemoAttachments"
// MemoServiceSetMemoRelationsProcedure is the fully-qualified name of the MemoService's
// SetMemoRelations RPC.
MemoServiceSetMemoRelationsProcedure = "/memos.api.v1.MemoService/SetMemoRelations"
// MemoServiceListMemoRelationsProcedure is the fully-qualified name of the MemoService's
// ListMemoRelations RPC.
MemoServiceListMemoRelationsProcedure = "/memos.api.v1.MemoService/ListMemoRelations"
// MemoServiceCreateMemoCommentProcedure is the fully-qualified name of the MemoService's
// CreateMemoComment RPC.
MemoServiceCreateMemoCommentProcedure = "/memos.api.v1.MemoService/CreateMemoComment"
// MemoServiceListMemoCommentsProcedure is the fully-qualified name of the MemoService's
// ListMemoComments RPC.
MemoServiceListMemoCommentsProcedure = "/memos.api.v1.MemoService/ListMemoComments"
// MemoServiceListMemoReactionsProcedure is the fully-qualified name of the MemoService's
// ListMemoReactions RPC.
MemoServiceListMemoReactionsProcedure = "/memos.api.v1.MemoService/ListMemoReactions"
// MemoServiceUpsertMemoReactionProcedure is the fully-qualified name of the MemoService's
// UpsertMemoReaction RPC.
MemoServiceUpsertMemoReactionProcedure = "/memos.api.v1.MemoService/UpsertMemoReaction"
// MemoServiceDeleteMemoReactionProcedure is the fully-qualified name of the MemoService's
// DeleteMemoReaction RPC.
MemoServiceDeleteMemoReactionProcedure = "/memos.api.v1.MemoService/DeleteMemoReaction"
)
// MemoServiceClient is a client for the memos.api.v1.MemoService service.
type MemoServiceClient interface {
// CreateMemo creates a memo.
CreateMemo(context.Context, *connect.Request[v1.CreateMemoRequest]) (*connect.Response[v1.Memo], error)
// ListMemos lists memos with pagination and filter.
ListMemos(context.Context, *connect.Request[v1.ListMemosRequest]) (*connect.Response[v1.ListMemosResponse], error)
// GetMemo gets a memo.
GetMemo(context.Context, *connect.Request[v1.GetMemoRequest]) (*connect.Response[v1.Memo], error)
// UpdateMemo updates a memo.
UpdateMemo(context.Context, *connect.Request[v1.UpdateMemoRequest]) (*connect.Response[v1.Memo], error)
// DeleteMemo deletes a memo.
DeleteMemo(context.Context, *connect.Request[v1.DeleteMemoRequest]) (*connect.Response[emptypb.Empty], error)
// SetMemoAttachments sets attachments for a memo.
SetMemoAttachments(context.Context, *connect.Request[v1.SetMemoAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
// ListMemoAttachments lists attachments for a memo.
ListMemoAttachments(context.Context, *connect.Request[v1.ListMemoAttachmentsRequest]) (*connect.Response[v1.ListMemoAttachmentsResponse], error)
// SetMemoRelations sets relations for a memo.
SetMemoRelations(context.Context, *connect.Request[v1.SetMemoRelationsRequest]) (*connect.Response[emptypb.Empty], error)
// ListMemoRelations lists relations for a memo.
ListMemoRelations(context.Context, *connect.Request[v1.ListMemoRelationsRequest]) (*connect.Response[v1.ListMemoRelationsResponse], error)
// CreateMemoComment creates a comment for a memo.
CreateMemoComment(context.Context, *connect.Request[v1.CreateMemoCommentRequest]) (*connect.Response[v1.Memo], error)
// ListMemoComments lists comments for a memo.
ListMemoComments(context.Context, *connect.Request[v1.ListMemoCommentsRequest]) (*connect.Response[v1.ListMemoCommentsResponse], error)
// ListMemoReactions lists reactions for a memo.
ListMemoReactions(context.Context, *connect.Request[v1.ListMemoReactionsRequest]) (*connect.Response[v1.ListMemoReactionsResponse], error)
// UpsertMemoReaction upserts a reaction for a memo.
UpsertMemoReaction(context.Context, *connect.Request[v1.UpsertMemoReactionRequest]) (*connect.Response[v1.Reaction], error)
// DeleteMemoReaction deletes a reaction for a memo.
DeleteMemoReaction(context.Context, *connect.Request[v1.DeleteMemoReactionRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewMemoServiceClient constructs a client for the memos.api.v1.MemoService service. By default, it
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
// connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewMemoServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MemoServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
memoServiceMethods := v1.File_api_v1_memo_service_proto.Services().ByName("MemoService").Methods()
return &memoServiceClient{
createMemo: connect.NewClient[v1.CreateMemoRequest, v1.Memo](
httpClient,
baseURL+MemoServiceCreateMemoProcedure,
connect.WithSchema(memoServiceMethods.ByName("CreateMemo")),
connect.WithClientOptions(opts...),
),
listMemos: connect.NewClient[v1.ListMemosRequest, v1.ListMemosResponse](
httpClient,
baseURL+MemoServiceListMemosProcedure,
connect.WithSchema(memoServiceMethods.ByName("ListMemos")),
connect.WithClientOptions(opts...),
),
getMemo: connect.NewClient[v1.GetMemoRequest, v1.Memo](
httpClient,
baseURL+MemoServiceGetMemoProcedure,
connect.WithSchema(memoServiceMethods.ByName("GetMemo")),
connect.WithClientOptions(opts...),
),
updateMemo: connect.NewClient[v1.UpdateMemoRequest, v1.Memo](
httpClient,
baseURL+MemoServiceUpdateMemoProcedure,
connect.WithSchema(memoServiceMethods.ByName("UpdateMemo")),
connect.WithClientOptions(opts...),
),
deleteMemo: connect.NewClient[v1.DeleteMemoRequest, emptypb.Empty](
httpClient,
baseURL+MemoServiceDeleteMemoProcedure,
connect.WithSchema(memoServiceMethods.ByName("DeleteMemo")),
connect.WithClientOptions(opts...),
),
setMemoAttachments: connect.NewClient[v1.SetMemoAttachmentsRequest, emptypb.Empty](
httpClient,
baseURL+MemoServiceSetMemoAttachmentsProcedure,
connect.WithSchema(memoServiceMethods.ByName("SetMemoAttachments")),
connect.WithClientOptions(opts...),
),
listMemoAttachments: connect.NewClient[v1.ListMemoAttachmentsRequest, v1.ListMemoAttachmentsResponse](
httpClient,
baseURL+MemoServiceListMemoAttachmentsProcedure,
connect.WithSchema(memoServiceMethods.ByName("ListMemoAttachments")),
connect.WithClientOptions(opts...),
),
setMemoRelations: connect.NewClient[v1.SetMemoRelationsRequest, emptypb.Empty](
httpClient,
baseURL+MemoServiceSetMemoRelationsProcedure,
connect.WithSchema(memoServiceMethods.ByName("SetMemoRelations")),
connect.WithClientOptions(opts...),
),
listMemoRelations: connect.NewClient[v1.ListMemoRelationsRequest, v1.ListMemoRelationsResponse](
httpClient,
baseURL+MemoServiceListMemoRelationsProcedure,
connect.WithSchema(memoServiceMethods.ByName("ListMemoRelations")),
connect.WithClientOptions(opts...),
),
createMemoComment: connect.NewClient[v1.CreateMemoCommentRequest, v1.Memo](
httpClient,
baseURL+MemoServiceCreateMemoCommentProcedure,
connect.WithSchema(memoServiceMethods.ByName("CreateMemoComment")),
connect.WithClientOptions(opts...),
),
listMemoComments: connect.NewClient[v1.ListMemoCommentsRequest, v1.ListMemoCommentsResponse](
httpClient,
baseURL+MemoServiceListMemoCommentsProcedure,
connect.WithSchema(memoServiceMethods.ByName("ListMemoComments")),
connect.WithClientOptions(opts...),
),
listMemoReactions: connect.NewClient[v1.ListMemoReactionsRequest, v1.ListMemoReactionsResponse](
httpClient,
baseURL+MemoServiceListMemoReactionsProcedure,
connect.WithSchema(memoServiceMethods.ByName("ListMemoReactions")),
connect.WithClientOptions(opts...),
),
upsertMemoReaction: connect.NewClient[v1.UpsertMemoReactionRequest, v1.Reaction](
httpClient,
baseURL+MemoServiceUpsertMemoReactionProcedure,
connect.WithSchema(memoServiceMethods.ByName("UpsertMemoReaction")),
connect.WithClientOptions(opts...),
),
deleteMemoReaction: connect.NewClient[v1.DeleteMemoReactionRequest, emptypb.Empty](
httpClient,
baseURL+MemoServiceDeleteMemoReactionProcedure,
connect.WithSchema(memoServiceMethods.ByName("DeleteMemoReaction")),
connect.WithClientOptions(opts...),
),
}
}
// memoServiceClient implements MemoServiceClient.
type memoServiceClient struct {
createMemo *connect.Client[v1.CreateMemoRequest, v1.Memo]
listMemos *connect.Client[v1.ListMemosRequest, v1.ListMemosResponse]
getMemo *connect.Client[v1.GetMemoRequest, v1.Memo]
updateMemo *connect.Client[v1.UpdateMemoRequest, v1.Memo]
deleteMemo *connect.Client[v1.DeleteMemoRequest, emptypb.Empty]
setMemoAttachments *connect.Client[v1.SetMemoAttachmentsRequest, emptypb.Empty]
listMemoAttachments *connect.Client[v1.ListMemoAttachmentsRequest, v1.ListMemoAttachmentsResponse]
setMemoRelations *connect.Client[v1.SetMemoRelationsRequest, emptypb.Empty]
listMemoRelations *connect.Client[v1.ListMemoRelationsRequest, v1.ListMemoRelationsResponse]
createMemoComment *connect.Client[v1.CreateMemoCommentRequest, v1.Memo]
listMemoComments *connect.Client[v1.ListMemoCommentsRequest, v1.ListMemoCommentsResponse]
listMemoReactions *connect.Client[v1.ListMemoReactionsRequest, v1.ListMemoReactionsResponse]
upsertMemoReaction *connect.Client[v1.UpsertMemoReactionRequest, v1.Reaction]
deleteMemoReaction *connect.Client[v1.DeleteMemoReactionRequest, emptypb.Empty]
}
// CreateMemo calls memos.api.v1.MemoService.CreateMemo.
func (c *memoServiceClient) CreateMemo(ctx context.Context, req *connect.Request[v1.CreateMemoRequest]) (*connect.Response[v1.Memo], error) {
return c.createMemo.CallUnary(ctx, req)
}
// ListMemos calls memos.api.v1.MemoService.ListMemos.
func (c *memoServiceClient) ListMemos(ctx context.Context, req *connect.Request[v1.ListMemosRequest]) (*connect.Response[v1.ListMemosResponse], error) {
return c.listMemos.CallUnary(ctx, req)
}
// GetMemo calls memos.api.v1.MemoService.GetMemo.
func (c *memoServiceClient) GetMemo(ctx context.Context, req *connect.Request[v1.GetMemoRequest]) (*connect.Response[v1.Memo], error) {
return c.getMemo.CallUnary(ctx, req)
}
// UpdateMemo calls memos.api.v1.MemoService.UpdateMemo.
func (c *memoServiceClient) UpdateMemo(ctx context.Context, req *connect.Request[v1.UpdateMemoRequest]) (*connect.Response[v1.Memo], error) {
return c.updateMemo.CallUnary(ctx, req)
}
// DeleteMemo calls memos.api.v1.MemoService.DeleteMemo.
func (c *memoServiceClient) DeleteMemo(ctx context.Context, req *connect.Request[v1.DeleteMemoRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteMemo.CallUnary(ctx, req)
}
// SetMemoAttachments calls memos.api.v1.MemoService.SetMemoAttachments.
func (c *memoServiceClient) SetMemoAttachments(ctx context.Context, req *connect.Request[v1.SetMemoAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
return c.setMemoAttachments.CallUnary(ctx, req)
}
// ListMemoAttachments calls memos.api.v1.MemoService.ListMemoAttachments.
func (c *memoServiceClient) ListMemoAttachments(ctx context.Context, req *connect.Request[v1.ListMemoAttachmentsRequest]) (*connect.Response[v1.ListMemoAttachmentsResponse], error) {
return c.listMemoAttachments.CallUnary(ctx, req)
}
// SetMemoRelations calls memos.api.v1.MemoService.SetMemoRelations.
func (c *memoServiceClient) SetMemoRelations(ctx context.Context, req *connect.Request[v1.SetMemoRelationsRequest]) (*connect.Response[emptypb.Empty], error) {
return c.setMemoRelations.CallUnary(ctx, req)
}
// ListMemoRelations calls memos.api.v1.MemoService.ListMemoRelations.
func (c *memoServiceClient) ListMemoRelations(ctx context.Context, req *connect.Request[v1.ListMemoRelationsRequest]) (*connect.Response[v1.ListMemoRelationsResponse], error) {
return c.listMemoRelations.CallUnary(ctx, req)
}
// CreateMemoComment calls memos.api.v1.MemoService.CreateMemoComment.
func (c *memoServiceClient) CreateMemoComment(ctx context.Context, req *connect.Request[v1.CreateMemoCommentRequest]) (*connect.Response[v1.Memo], error) {
return c.createMemoComment.CallUnary(ctx, req)
}
// ListMemoComments calls memos.api.v1.MemoService.ListMemoComments.
func (c *memoServiceClient) ListMemoComments(ctx context.Context, req *connect.Request[v1.ListMemoCommentsRequest]) (*connect.Response[v1.ListMemoCommentsResponse], error) {
return c.listMemoComments.CallUnary(ctx, req)
}
// ListMemoReactions calls memos.api.v1.MemoService.ListMemoReactions.
func (c *memoServiceClient) ListMemoReactions(ctx context.Context, req *connect.Request[v1.ListMemoReactionsRequest]) (*connect.Response[v1.ListMemoReactionsResponse], error) {
return c.listMemoReactions.CallUnary(ctx, req)
}
// UpsertMemoReaction calls memos.api.v1.MemoService.UpsertMemoReaction.
func (c *memoServiceClient) UpsertMemoReaction(ctx context.Context, req *connect.Request[v1.UpsertMemoReactionRequest]) (*connect.Response[v1.Reaction], error) {
return c.upsertMemoReaction.CallUnary(ctx, req)
}
// DeleteMemoReaction calls memos.api.v1.MemoService.DeleteMemoReaction.
func (c *memoServiceClient) DeleteMemoReaction(ctx context.Context, req *connect.Request[v1.DeleteMemoReactionRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteMemoReaction.CallUnary(ctx, req)
}
// MemoServiceHandler is an implementation of the memos.api.v1.MemoService service.
type MemoServiceHandler interface {
// CreateMemo creates a memo.
CreateMemo(context.Context, *connect.Request[v1.CreateMemoRequest]) (*connect.Response[v1.Memo], error)
// ListMemos lists memos with pagination and filter.
ListMemos(context.Context, *connect.Request[v1.ListMemosRequest]) (*connect.Response[v1.ListMemosResponse], error)
// GetMemo gets a memo.
GetMemo(context.Context, *connect.Request[v1.GetMemoRequest]) (*connect.Response[v1.Memo], error)
// UpdateMemo updates a memo.
UpdateMemo(context.Context, *connect.Request[v1.UpdateMemoRequest]) (*connect.Response[v1.Memo], error)
// DeleteMemo deletes a memo.
DeleteMemo(context.Context, *connect.Request[v1.DeleteMemoRequest]) (*connect.Response[emptypb.Empty], error)
// SetMemoAttachments sets attachments for a memo.
SetMemoAttachments(context.Context, *connect.Request[v1.SetMemoAttachmentsRequest]) (*connect.Response[emptypb.Empty], error)
// ListMemoAttachments lists attachments for a memo.
ListMemoAttachments(context.Context, *connect.Request[v1.ListMemoAttachmentsRequest]) (*connect.Response[v1.ListMemoAttachmentsResponse], error)
// SetMemoRelations sets relations for a memo.
SetMemoRelations(context.Context, *connect.Request[v1.SetMemoRelationsRequest]) (*connect.Response[emptypb.Empty], error)
// ListMemoRelations lists relations for a memo.
ListMemoRelations(context.Context, *connect.Request[v1.ListMemoRelationsRequest]) (*connect.Response[v1.ListMemoRelationsResponse], error)
// CreateMemoComment creates a comment for a memo.
CreateMemoComment(context.Context, *connect.Request[v1.CreateMemoCommentRequest]) (*connect.Response[v1.Memo], error)
// ListMemoComments lists comments for a memo.
ListMemoComments(context.Context, *connect.Request[v1.ListMemoCommentsRequest]) (*connect.Response[v1.ListMemoCommentsResponse], error)
// ListMemoReactions lists reactions for a memo.
ListMemoReactions(context.Context, *connect.Request[v1.ListMemoReactionsRequest]) (*connect.Response[v1.ListMemoReactionsResponse], error)
// UpsertMemoReaction upserts a reaction for a memo.
UpsertMemoReaction(context.Context, *connect.Request[v1.UpsertMemoReactionRequest]) (*connect.Response[v1.Reaction], error)
// DeleteMemoReaction deletes a reaction for a memo.
DeleteMemoReaction(context.Context, *connect.Request[v1.DeleteMemoReactionRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewMemoServiceHandler builds an HTTP handler from the service implementation. It returns the path
// on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewMemoServiceHandler(svc MemoServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
memoServiceMethods := v1.File_api_v1_memo_service_proto.Services().ByName("MemoService").Methods()
memoServiceCreateMemoHandler := connect.NewUnaryHandler(
MemoServiceCreateMemoProcedure,
svc.CreateMemo,
connect.WithSchema(memoServiceMethods.ByName("CreateMemo")),
connect.WithHandlerOptions(opts...),
)
memoServiceListMemosHandler := connect.NewUnaryHandler(
MemoServiceListMemosProcedure,
svc.ListMemos,
connect.WithSchema(memoServiceMethods.ByName("ListMemos")),
connect.WithHandlerOptions(opts...),
)
memoServiceGetMemoHandler := connect.NewUnaryHandler(
MemoServiceGetMemoProcedure,
svc.GetMemo,
connect.WithSchema(memoServiceMethods.ByName("GetMemo")),
connect.WithHandlerOptions(opts...),
)
memoServiceUpdateMemoHandler := connect.NewUnaryHandler(
MemoServiceUpdateMemoProcedure,
svc.UpdateMemo,
connect.WithSchema(memoServiceMethods.ByName("UpdateMemo")),
connect.WithHandlerOptions(opts...),
)
memoServiceDeleteMemoHandler := connect.NewUnaryHandler(
MemoServiceDeleteMemoProcedure,
svc.DeleteMemo,
connect.WithSchema(memoServiceMethods.ByName("DeleteMemo")),
connect.WithHandlerOptions(opts...),
)
memoServiceSetMemoAttachmentsHandler := connect.NewUnaryHandler(
MemoServiceSetMemoAttachmentsProcedure,
svc.SetMemoAttachments,
connect.WithSchema(memoServiceMethods.ByName("SetMemoAttachments")),
connect.WithHandlerOptions(opts...),
)
memoServiceListMemoAttachmentsHandler := connect.NewUnaryHandler(
MemoServiceListMemoAttachmentsProcedure,
svc.ListMemoAttachments,
connect.WithSchema(memoServiceMethods.ByName("ListMemoAttachments")),
connect.WithHandlerOptions(opts...),
)
memoServiceSetMemoRelationsHandler := connect.NewUnaryHandler(
MemoServiceSetMemoRelationsProcedure,
svc.SetMemoRelations,
connect.WithSchema(memoServiceMethods.ByName("SetMemoRelations")),
connect.WithHandlerOptions(opts...),
)
memoServiceListMemoRelationsHandler := connect.NewUnaryHandler(
MemoServiceListMemoRelationsProcedure,
svc.ListMemoRelations,
connect.WithSchema(memoServiceMethods.ByName("ListMemoRelations")),
connect.WithHandlerOptions(opts...),
)
memoServiceCreateMemoCommentHandler := connect.NewUnaryHandler(
MemoServiceCreateMemoCommentProcedure,
svc.CreateMemoComment,
connect.WithSchema(memoServiceMethods.ByName("CreateMemoComment")),
connect.WithHandlerOptions(opts...),
)
memoServiceListMemoCommentsHandler := connect.NewUnaryHandler(
MemoServiceListMemoCommentsProcedure,
svc.ListMemoComments,
connect.WithSchema(memoServiceMethods.ByName("ListMemoComments")),
connect.WithHandlerOptions(opts...),
)
memoServiceListMemoReactionsHandler := connect.NewUnaryHandler(
MemoServiceListMemoReactionsProcedure,
svc.ListMemoReactions,
connect.WithSchema(memoServiceMethods.ByName("ListMemoReactions")),
connect.WithHandlerOptions(opts...),
)
memoServiceUpsertMemoReactionHandler := connect.NewUnaryHandler(
MemoServiceUpsertMemoReactionProcedure,
svc.UpsertMemoReaction,
connect.WithSchema(memoServiceMethods.ByName("UpsertMemoReaction")),
connect.WithHandlerOptions(opts...),
)
memoServiceDeleteMemoReactionHandler := connect.NewUnaryHandler(
MemoServiceDeleteMemoReactionProcedure,
svc.DeleteMemoReaction,
connect.WithSchema(memoServiceMethods.ByName("DeleteMemoReaction")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.MemoService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case MemoServiceCreateMemoProcedure:
memoServiceCreateMemoHandler.ServeHTTP(w, r)
case MemoServiceListMemosProcedure:
memoServiceListMemosHandler.ServeHTTP(w, r)
case MemoServiceGetMemoProcedure:
memoServiceGetMemoHandler.ServeHTTP(w, r)
case MemoServiceUpdateMemoProcedure:
memoServiceUpdateMemoHandler.ServeHTTP(w, r)
case MemoServiceDeleteMemoProcedure:
memoServiceDeleteMemoHandler.ServeHTTP(w, r)
case MemoServiceSetMemoAttachmentsProcedure:
memoServiceSetMemoAttachmentsHandler.ServeHTTP(w, r)
case MemoServiceListMemoAttachmentsProcedure:
memoServiceListMemoAttachmentsHandler.ServeHTTP(w, r)
case MemoServiceSetMemoRelationsProcedure:
memoServiceSetMemoRelationsHandler.ServeHTTP(w, r)
case MemoServiceListMemoRelationsProcedure:
memoServiceListMemoRelationsHandler.ServeHTTP(w, r)
case MemoServiceCreateMemoCommentProcedure:
memoServiceCreateMemoCommentHandler.ServeHTTP(w, r)
case MemoServiceListMemoCommentsProcedure:
memoServiceListMemoCommentsHandler.ServeHTTP(w, r)
case MemoServiceListMemoReactionsProcedure:
memoServiceListMemoReactionsHandler.ServeHTTP(w, r)
case MemoServiceUpsertMemoReactionProcedure:
memoServiceUpsertMemoReactionHandler.ServeHTTP(w, r)
case MemoServiceDeleteMemoReactionProcedure:
memoServiceDeleteMemoReactionHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedMemoServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedMemoServiceHandler struct{}
func (UnimplementedMemoServiceHandler) CreateMemo(context.Context, *connect.Request[v1.CreateMemoRequest]) (*connect.Response[v1.Memo], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.CreateMemo is not implemented"))
}
func (UnimplementedMemoServiceHandler) ListMemos(context.Context, *connect.Request[v1.ListMemosRequest]) (*connect.Response[v1.ListMemosResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.ListMemos is not implemented"))
}
func (UnimplementedMemoServiceHandler) GetMemo(context.Context, *connect.Request[v1.GetMemoRequest]) (*connect.Response[v1.Memo], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.GetMemo is not implemented"))
}
func (UnimplementedMemoServiceHandler) UpdateMemo(context.Context, *connect.Request[v1.UpdateMemoRequest]) (*connect.Response[v1.Memo], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.UpdateMemo is not implemented"))
}
func (UnimplementedMemoServiceHandler) DeleteMemo(context.Context, *connect.Request[v1.DeleteMemoRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.DeleteMemo is not implemented"))
}
func (UnimplementedMemoServiceHandler) SetMemoAttachments(context.Context, *connect.Request[v1.SetMemoAttachmentsRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.SetMemoAttachments is not implemented"))
}
func (UnimplementedMemoServiceHandler) ListMemoAttachments(context.Context, *connect.Request[v1.ListMemoAttachmentsRequest]) (*connect.Response[v1.ListMemoAttachmentsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.ListMemoAttachments is not implemented"))
}
func (UnimplementedMemoServiceHandler) SetMemoRelations(context.Context, *connect.Request[v1.SetMemoRelationsRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.SetMemoRelations is not implemented"))
}
func (UnimplementedMemoServiceHandler) ListMemoRelations(context.Context, *connect.Request[v1.ListMemoRelationsRequest]) (*connect.Response[v1.ListMemoRelationsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.ListMemoRelations is not implemented"))
}
func (UnimplementedMemoServiceHandler) CreateMemoComment(context.Context, *connect.Request[v1.CreateMemoCommentRequest]) (*connect.Response[v1.Memo], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.CreateMemoComment is not implemented"))
}
func (UnimplementedMemoServiceHandler) ListMemoComments(context.Context, *connect.Request[v1.ListMemoCommentsRequest]) (*connect.Response[v1.ListMemoCommentsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.ListMemoComments is not implemented"))
}
func (UnimplementedMemoServiceHandler) ListMemoReactions(context.Context, *connect.Request[v1.ListMemoReactionsRequest]) (*connect.Response[v1.ListMemoReactionsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.ListMemoReactions is not implemented"))
}
func (UnimplementedMemoServiceHandler) UpsertMemoReaction(context.Context, *connect.Request[v1.UpsertMemoReactionRequest]) (*connect.Response[v1.Reaction], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.UpsertMemoReaction is not implemented"))
}
func (UnimplementedMemoServiceHandler) DeleteMemoReaction(context.Context, *connect.Request[v1.DeleteMemoReactionRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoService.DeleteMemoReaction is not implemented"))
}

View File

@@ -0,0 +1,236 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/shortcut_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// ShortcutServiceName is the fully-qualified name of the ShortcutService service.
ShortcutServiceName = "memos.api.v1.ShortcutService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// ShortcutServiceListShortcutsProcedure is the fully-qualified name of the ShortcutService's
// ListShortcuts RPC.
ShortcutServiceListShortcutsProcedure = "/memos.api.v1.ShortcutService/ListShortcuts"
// ShortcutServiceGetShortcutProcedure is the fully-qualified name of the ShortcutService's
// GetShortcut RPC.
ShortcutServiceGetShortcutProcedure = "/memos.api.v1.ShortcutService/GetShortcut"
// ShortcutServiceCreateShortcutProcedure is the fully-qualified name of the ShortcutService's
// CreateShortcut RPC.
ShortcutServiceCreateShortcutProcedure = "/memos.api.v1.ShortcutService/CreateShortcut"
// ShortcutServiceUpdateShortcutProcedure is the fully-qualified name of the ShortcutService's
// UpdateShortcut RPC.
ShortcutServiceUpdateShortcutProcedure = "/memos.api.v1.ShortcutService/UpdateShortcut"
// ShortcutServiceDeleteShortcutProcedure is the fully-qualified name of the ShortcutService's
// DeleteShortcut RPC.
ShortcutServiceDeleteShortcutProcedure = "/memos.api.v1.ShortcutService/DeleteShortcut"
)
// ShortcutServiceClient is a client for the memos.api.v1.ShortcutService service.
type ShortcutServiceClient interface {
// ListShortcuts returns a list of shortcuts for a user.
ListShortcuts(context.Context, *connect.Request[v1.ListShortcutsRequest]) (*connect.Response[v1.ListShortcutsResponse], error)
// GetShortcut gets a shortcut by name.
GetShortcut(context.Context, *connect.Request[v1.GetShortcutRequest]) (*connect.Response[v1.Shortcut], error)
// CreateShortcut creates a new shortcut for a user.
CreateShortcut(context.Context, *connect.Request[v1.CreateShortcutRequest]) (*connect.Response[v1.Shortcut], error)
// UpdateShortcut updates a shortcut for a user.
UpdateShortcut(context.Context, *connect.Request[v1.UpdateShortcutRequest]) (*connect.Response[v1.Shortcut], error)
// DeleteShortcut deletes a shortcut for a user.
DeleteShortcut(context.Context, *connect.Request[v1.DeleteShortcutRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewShortcutServiceClient constructs a client for the memos.api.v1.ShortcutService service. By
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
// connect.WithGRPC() or connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewShortcutServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ShortcutServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
shortcutServiceMethods := v1.File_api_v1_shortcut_service_proto.Services().ByName("ShortcutService").Methods()
return &shortcutServiceClient{
listShortcuts: connect.NewClient[v1.ListShortcutsRequest, v1.ListShortcutsResponse](
httpClient,
baseURL+ShortcutServiceListShortcutsProcedure,
connect.WithSchema(shortcutServiceMethods.ByName("ListShortcuts")),
connect.WithClientOptions(opts...),
),
getShortcut: connect.NewClient[v1.GetShortcutRequest, v1.Shortcut](
httpClient,
baseURL+ShortcutServiceGetShortcutProcedure,
connect.WithSchema(shortcutServiceMethods.ByName("GetShortcut")),
connect.WithClientOptions(opts...),
),
createShortcut: connect.NewClient[v1.CreateShortcutRequest, v1.Shortcut](
httpClient,
baseURL+ShortcutServiceCreateShortcutProcedure,
connect.WithSchema(shortcutServiceMethods.ByName("CreateShortcut")),
connect.WithClientOptions(opts...),
),
updateShortcut: connect.NewClient[v1.UpdateShortcutRequest, v1.Shortcut](
httpClient,
baseURL+ShortcutServiceUpdateShortcutProcedure,
connect.WithSchema(shortcutServiceMethods.ByName("UpdateShortcut")),
connect.WithClientOptions(opts...),
),
deleteShortcut: connect.NewClient[v1.DeleteShortcutRequest, emptypb.Empty](
httpClient,
baseURL+ShortcutServiceDeleteShortcutProcedure,
connect.WithSchema(shortcutServiceMethods.ByName("DeleteShortcut")),
connect.WithClientOptions(opts...),
),
}
}
// shortcutServiceClient implements ShortcutServiceClient.
type shortcutServiceClient struct {
listShortcuts *connect.Client[v1.ListShortcutsRequest, v1.ListShortcutsResponse]
getShortcut *connect.Client[v1.GetShortcutRequest, v1.Shortcut]
createShortcut *connect.Client[v1.CreateShortcutRequest, v1.Shortcut]
updateShortcut *connect.Client[v1.UpdateShortcutRequest, v1.Shortcut]
deleteShortcut *connect.Client[v1.DeleteShortcutRequest, emptypb.Empty]
}
// ListShortcuts calls memos.api.v1.ShortcutService.ListShortcuts.
func (c *shortcutServiceClient) ListShortcuts(ctx context.Context, req *connect.Request[v1.ListShortcutsRequest]) (*connect.Response[v1.ListShortcutsResponse], error) {
return c.listShortcuts.CallUnary(ctx, req)
}
// GetShortcut calls memos.api.v1.ShortcutService.GetShortcut.
func (c *shortcutServiceClient) GetShortcut(ctx context.Context, req *connect.Request[v1.GetShortcutRequest]) (*connect.Response[v1.Shortcut], error) {
return c.getShortcut.CallUnary(ctx, req)
}
// CreateShortcut calls memos.api.v1.ShortcutService.CreateShortcut.
func (c *shortcutServiceClient) CreateShortcut(ctx context.Context, req *connect.Request[v1.CreateShortcutRequest]) (*connect.Response[v1.Shortcut], error) {
return c.createShortcut.CallUnary(ctx, req)
}
// UpdateShortcut calls memos.api.v1.ShortcutService.UpdateShortcut.
func (c *shortcutServiceClient) UpdateShortcut(ctx context.Context, req *connect.Request[v1.UpdateShortcutRequest]) (*connect.Response[v1.Shortcut], error) {
return c.updateShortcut.CallUnary(ctx, req)
}
// DeleteShortcut calls memos.api.v1.ShortcutService.DeleteShortcut.
func (c *shortcutServiceClient) DeleteShortcut(ctx context.Context, req *connect.Request[v1.DeleteShortcutRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteShortcut.CallUnary(ctx, req)
}
// ShortcutServiceHandler is an implementation of the memos.api.v1.ShortcutService service.
type ShortcutServiceHandler interface {
// ListShortcuts returns a list of shortcuts for a user.
ListShortcuts(context.Context, *connect.Request[v1.ListShortcutsRequest]) (*connect.Response[v1.ListShortcutsResponse], error)
// GetShortcut gets a shortcut by name.
GetShortcut(context.Context, *connect.Request[v1.GetShortcutRequest]) (*connect.Response[v1.Shortcut], error)
// CreateShortcut creates a new shortcut for a user.
CreateShortcut(context.Context, *connect.Request[v1.CreateShortcutRequest]) (*connect.Response[v1.Shortcut], error)
// UpdateShortcut updates a shortcut for a user.
UpdateShortcut(context.Context, *connect.Request[v1.UpdateShortcutRequest]) (*connect.Response[v1.Shortcut], error)
// DeleteShortcut deletes a shortcut for a user.
DeleteShortcut(context.Context, *connect.Request[v1.DeleteShortcutRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewShortcutServiceHandler builds an HTTP handler from the service implementation. It returns the
// path on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewShortcutServiceHandler(svc ShortcutServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
shortcutServiceMethods := v1.File_api_v1_shortcut_service_proto.Services().ByName("ShortcutService").Methods()
shortcutServiceListShortcutsHandler := connect.NewUnaryHandler(
ShortcutServiceListShortcutsProcedure,
svc.ListShortcuts,
connect.WithSchema(shortcutServiceMethods.ByName("ListShortcuts")),
connect.WithHandlerOptions(opts...),
)
shortcutServiceGetShortcutHandler := connect.NewUnaryHandler(
ShortcutServiceGetShortcutProcedure,
svc.GetShortcut,
connect.WithSchema(shortcutServiceMethods.ByName("GetShortcut")),
connect.WithHandlerOptions(opts...),
)
shortcutServiceCreateShortcutHandler := connect.NewUnaryHandler(
ShortcutServiceCreateShortcutProcedure,
svc.CreateShortcut,
connect.WithSchema(shortcutServiceMethods.ByName("CreateShortcut")),
connect.WithHandlerOptions(opts...),
)
shortcutServiceUpdateShortcutHandler := connect.NewUnaryHandler(
ShortcutServiceUpdateShortcutProcedure,
svc.UpdateShortcut,
connect.WithSchema(shortcutServiceMethods.ByName("UpdateShortcut")),
connect.WithHandlerOptions(opts...),
)
shortcutServiceDeleteShortcutHandler := connect.NewUnaryHandler(
ShortcutServiceDeleteShortcutProcedure,
svc.DeleteShortcut,
connect.WithSchema(shortcutServiceMethods.ByName("DeleteShortcut")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.ShortcutService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case ShortcutServiceListShortcutsProcedure:
shortcutServiceListShortcutsHandler.ServeHTTP(w, r)
case ShortcutServiceGetShortcutProcedure:
shortcutServiceGetShortcutHandler.ServeHTTP(w, r)
case ShortcutServiceCreateShortcutProcedure:
shortcutServiceCreateShortcutHandler.ServeHTTP(w, r)
case ShortcutServiceUpdateShortcutProcedure:
shortcutServiceUpdateShortcutHandler.ServeHTTP(w, r)
case ShortcutServiceDeleteShortcutProcedure:
shortcutServiceDeleteShortcutHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedShortcutServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedShortcutServiceHandler struct{}
func (UnimplementedShortcutServiceHandler) ListShortcuts(context.Context, *connect.Request[v1.ListShortcutsRequest]) (*connect.Response[v1.ListShortcutsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.ShortcutService.ListShortcuts is not implemented"))
}
func (UnimplementedShortcutServiceHandler) GetShortcut(context.Context, *connect.Request[v1.GetShortcutRequest]) (*connect.Response[v1.Shortcut], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.ShortcutService.GetShortcut is not implemented"))
}
func (UnimplementedShortcutServiceHandler) CreateShortcut(context.Context, *connect.Request[v1.CreateShortcutRequest]) (*connect.Response[v1.Shortcut], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.ShortcutService.CreateShortcut is not implemented"))
}
func (UnimplementedShortcutServiceHandler) UpdateShortcut(context.Context, *connect.Request[v1.UpdateShortcutRequest]) (*connect.Response[v1.Shortcut], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.ShortcutService.UpdateShortcut is not implemented"))
}
func (UnimplementedShortcutServiceHandler) DeleteShortcut(context.Context, *connect.Request[v1.DeleteShortcutRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.ShortcutService.DeleteShortcut is not implemented"))
}

View File

@@ -0,0 +1,706 @@
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
//
// Source: api/v1/user_service.proto
package apiv1connect
import (
connect "connectrpc.com/connect"
context "context"
errors "errors"
v1 "github.com/usememos/memos/proto/gen/api/v1"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
strings "strings"
)
// This is a compile-time assertion to ensure that this generated file and the connect package are
// compatible. If you get a compiler error that this constant is not defined, this code was
// generated with a version of connect newer than the one compiled into your binary. You can fix the
// problem by either regenerating this code with an older version of connect or updating the connect
// version compiled into your binary.
const _ = connect.IsAtLeastVersion1_13_0
const (
// UserServiceName is the fully-qualified name of the UserService service.
UserServiceName = "memos.api.v1.UserService"
)
// These constants are the fully-qualified names of the RPCs defined in this package. They're
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
//
// Note that these are different from the fully-qualified method names used by
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
// period.
const (
// UserServiceListUsersProcedure is the fully-qualified name of the UserService's ListUsers RPC.
UserServiceListUsersProcedure = "/memos.api.v1.UserService/ListUsers"
// UserServiceGetUserProcedure is the fully-qualified name of the UserService's GetUser RPC.
UserServiceGetUserProcedure = "/memos.api.v1.UserService/GetUser"
// UserServiceCreateUserProcedure is the fully-qualified name of the UserService's CreateUser RPC.
UserServiceCreateUserProcedure = "/memos.api.v1.UserService/CreateUser"
// UserServiceUpdateUserProcedure is the fully-qualified name of the UserService's UpdateUser RPC.
UserServiceUpdateUserProcedure = "/memos.api.v1.UserService/UpdateUser"
// UserServiceDeleteUserProcedure is the fully-qualified name of the UserService's DeleteUser RPC.
UserServiceDeleteUserProcedure = "/memos.api.v1.UserService/DeleteUser"
// UserServiceListAllUserStatsProcedure is the fully-qualified name of the UserService's
// ListAllUserStats RPC.
UserServiceListAllUserStatsProcedure = "/memos.api.v1.UserService/ListAllUserStats"
// UserServiceGetUserStatsProcedure is the fully-qualified name of the UserService's GetUserStats
// RPC.
UserServiceGetUserStatsProcedure = "/memos.api.v1.UserService/GetUserStats"
// UserServiceGetUserSettingProcedure is the fully-qualified name of the UserService's
// GetUserSetting RPC.
UserServiceGetUserSettingProcedure = "/memos.api.v1.UserService/GetUserSetting"
// UserServiceUpdateUserSettingProcedure is the fully-qualified name of the UserService's
// UpdateUserSetting RPC.
UserServiceUpdateUserSettingProcedure = "/memos.api.v1.UserService/UpdateUserSetting"
// UserServiceListUserSettingsProcedure is the fully-qualified name of the UserService's
// ListUserSettings RPC.
UserServiceListUserSettingsProcedure = "/memos.api.v1.UserService/ListUserSettings"
// UserServiceListPersonalAccessTokensProcedure is the fully-qualified name of the UserService's
// ListPersonalAccessTokens RPC.
UserServiceListPersonalAccessTokensProcedure = "/memos.api.v1.UserService/ListPersonalAccessTokens"
// UserServiceCreatePersonalAccessTokenProcedure is the fully-qualified name of the UserService's
// CreatePersonalAccessToken RPC.
UserServiceCreatePersonalAccessTokenProcedure = "/memos.api.v1.UserService/CreatePersonalAccessToken"
// UserServiceDeletePersonalAccessTokenProcedure is the fully-qualified name of the UserService's
// DeletePersonalAccessToken RPC.
UserServiceDeletePersonalAccessTokenProcedure = "/memos.api.v1.UserService/DeletePersonalAccessToken"
// UserServiceListUserWebhooksProcedure is the fully-qualified name of the UserService's
// ListUserWebhooks RPC.
UserServiceListUserWebhooksProcedure = "/memos.api.v1.UserService/ListUserWebhooks"
// UserServiceCreateUserWebhookProcedure is the fully-qualified name of the UserService's
// CreateUserWebhook RPC.
UserServiceCreateUserWebhookProcedure = "/memos.api.v1.UserService/CreateUserWebhook"
// UserServiceUpdateUserWebhookProcedure is the fully-qualified name of the UserService's
// UpdateUserWebhook RPC.
UserServiceUpdateUserWebhookProcedure = "/memos.api.v1.UserService/UpdateUserWebhook"
// UserServiceDeleteUserWebhookProcedure is the fully-qualified name of the UserService's
// DeleteUserWebhook RPC.
UserServiceDeleteUserWebhookProcedure = "/memos.api.v1.UserService/DeleteUserWebhook"
// UserServiceListUserNotificationsProcedure is the fully-qualified name of the UserService's
// ListUserNotifications RPC.
UserServiceListUserNotificationsProcedure = "/memos.api.v1.UserService/ListUserNotifications"
// UserServiceUpdateUserNotificationProcedure is the fully-qualified name of the UserService's
// UpdateUserNotification RPC.
UserServiceUpdateUserNotificationProcedure = "/memos.api.v1.UserService/UpdateUserNotification"
// UserServiceDeleteUserNotificationProcedure is the fully-qualified name of the UserService's
// DeleteUserNotification RPC.
UserServiceDeleteUserNotificationProcedure = "/memos.api.v1.UserService/DeleteUserNotification"
)
// UserServiceClient is a client for the memos.api.v1.UserService service.
type UserServiceClient interface {
// ListUsers returns a list of users.
ListUsers(context.Context, *connect.Request[v1.ListUsersRequest]) (*connect.Response[v1.ListUsersResponse], error)
// GetUser gets a user by ID or username.
// Supports both numeric IDs and username strings:
// - users/{id} (e.g., users/101)
// - users/{username} (e.g., users/steven)
GetUser(context.Context, *connect.Request[v1.GetUserRequest]) (*connect.Response[v1.User], error)
// CreateUser creates a new user.
CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.User], error)
// UpdateUser updates a user.
UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.User], error)
// DeleteUser deletes a user.
DeleteUser(context.Context, *connect.Request[v1.DeleteUserRequest]) (*connect.Response[emptypb.Empty], error)
// ListAllUserStats returns statistics for all users.
ListAllUserStats(context.Context, *connect.Request[v1.ListAllUserStatsRequest]) (*connect.Response[v1.ListAllUserStatsResponse], error)
// GetUserStats returns statistics for a specific user.
GetUserStats(context.Context, *connect.Request[v1.GetUserStatsRequest]) (*connect.Response[v1.UserStats], error)
// GetUserSetting returns the user setting.
GetUserSetting(context.Context, *connect.Request[v1.GetUserSettingRequest]) (*connect.Response[v1.UserSetting], error)
// UpdateUserSetting updates the user setting.
UpdateUserSetting(context.Context, *connect.Request[v1.UpdateUserSettingRequest]) (*connect.Response[v1.UserSetting], error)
// ListUserSettings returns a list of user settings.
ListUserSettings(context.Context, *connect.Request[v1.ListUserSettingsRequest]) (*connect.Response[v1.ListUserSettingsResponse], error)
// ListPersonalAccessTokens returns a list of Personal Access Tokens (PATs) for a user.
// PATs are long-lived tokens for API/script access, distinct from short-lived JWT access tokens.
ListPersonalAccessTokens(context.Context, *connect.Request[v1.ListPersonalAccessTokensRequest]) (*connect.Response[v1.ListPersonalAccessTokensResponse], error)
// CreatePersonalAccessToken creates a new Personal Access Token for a user.
// The token value is only returned once upon creation.
CreatePersonalAccessToken(context.Context, *connect.Request[v1.CreatePersonalAccessTokenRequest]) (*connect.Response[v1.CreatePersonalAccessTokenResponse], error)
// DeletePersonalAccessToken deletes a Personal Access Token.
DeletePersonalAccessToken(context.Context, *connect.Request[v1.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error)
// ListUserWebhooks returns a list of webhooks for a user.
ListUserWebhooks(context.Context, *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error)
// CreateUserWebhook creates a new webhook for a user.
CreateUserWebhook(context.Context, *connect.Request[v1.CreateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error)
// UpdateUserWebhook updates an existing webhook for a user.
UpdateUserWebhook(context.Context, *connect.Request[v1.UpdateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error)
// DeleteUserWebhook deletes a webhook for a user.
DeleteUserWebhook(context.Context, *connect.Request[v1.DeleteUserWebhookRequest]) (*connect.Response[emptypb.Empty], error)
// ListUserNotifications lists notifications for a user.
ListUserNotifications(context.Context, *connect.Request[v1.ListUserNotificationsRequest]) (*connect.Response[v1.ListUserNotificationsResponse], error)
// UpdateUserNotification updates a notification.
UpdateUserNotification(context.Context, *connect.Request[v1.UpdateUserNotificationRequest]) (*connect.Response[v1.UserNotification], error)
// DeleteUserNotification deletes a notification.
DeleteUserNotification(context.Context, *connect.Request[v1.DeleteUserNotificationRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewUserServiceClient constructs a client for the memos.api.v1.UserService service. By default, it
// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
// connect.WithGRPCWeb() options.
//
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
// http://api.acme.com or https://acme.com/grpc).
func NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) UserServiceClient {
baseURL = strings.TrimRight(baseURL, "/")
userServiceMethods := v1.File_api_v1_user_service_proto.Services().ByName("UserService").Methods()
return &userServiceClient{
listUsers: connect.NewClient[v1.ListUsersRequest, v1.ListUsersResponse](
httpClient,
baseURL+UserServiceListUsersProcedure,
connect.WithSchema(userServiceMethods.ByName("ListUsers")),
connect.WithClientOptions(opts...),
),
getUser: connect.NewClient[v1.GetUserRequest, v1.User](
httpClient,
baseURL+UserServiceGetUserProcedure,
connect.WithSchema(userServiceMethods.ByName("GetUser")),
connect.WithClientOptions(opts...),
),
createUser: connect.NewClient[v1.CreateUserRequest, v1.User](
httpClient,
baseURL+UserServiceCreateUserProcedure,
connect.WithSchema(userServiceMethods.ByName("CreateUser")),
connect.WithClientOptions(opts...),
),
updateUser: connect.NewClient[v1.UpdateUserRequest, v1.User](
httpClient,
baseURL+UserServiceUpdateUserProcedure,
connect.WithSchema(userServiceMethods.ByName("UpdateUser")),
connect.WithClientOptions(opts...),
),
deleteUser: connect.NewClient[v1.DeleteUserRequest, emptypb.Empty](
httpClient,
baseURL+UserServiceDeleteUserProcedure,
connect.WithSchema(userServiceMethods.ByName("DeleteUser")),
connect.WithClientOptions(opts...),
),
listAllUserStats: connect.NewClient[v1.ListAllUserStatsRequest, v1.ListAllUserStatsResponse](
httpClient,
baseURL+UserServiceListAllUserStatsProcedure,
connect.WithSchema(userServiceMethods.ByName("ListAllUserStats")),
connect.WithClientOptions(opts...),
),
getUserStats: connect.NewClient[v1.GetUserStatsRequest, v1.UserStats](
httpClient,
baseURL+UserServiceGetUserStatsProcedure,
connect.WithSchema(userServiceMethods.ByName("GetUserStats")),
connect.WithClientOptions(opts...),
),
getUserSetting: connect.NewClient[v1.GetUserSettingRequest, v1.UserSetting](
httpClient,
baseURL+UserServiceGetUserSettingProcedure,
connect.WithSchema(userServiceMethods.ByName("GetUserSetting")),
connect.WithClientOptions(opts...),
),
updateUserSetting: connect.NewClient[v1.UpdateUserSettingRequest, v1.UserSetting](
httpClient,
baseURL+UserServiceUpdateUserSettingProcedure,
connect.WithSchema(userServiceMethods.ByName("UpdateUserSetting")),
connect.WithClientOptions(opts...),
),
listUserSettings: connect.NewClient[v1.ListUserSettingsRequest, v1.ListUserSettingsResponse](
httpClient,
baseURL+UserServiceListUserSettingsProcedure,
connect.WithSchema(userServiceMethods.ByName("ListUserSettings")),
connect.WithClientOptions(opts...),
),
listPersonalAccessTokens: connect.NewClient[v1.ListPersonalAccessTokensRequest, v1.ListPersonalAccessTokensResponse](
httpClient,
baseURL+UserServiceListPersonalAccessTokensProcedure,
connect.WithSchema(userServiceMethods.ByName("ListPersonalAccessTokens")),
connect.WithClientOptions(opts...),
),
createPersonalAccessToken: connect.NewClient[v1.CreatePersonalAccessTokenRequest, v1.CreatePersonalAccessTokenResponse](
httpClient,
baseURL+UserServiceCreatePersonalAccessTokenProcedure,
connect.WithSchema(userServiceMethods.ByName("CreatePersonalAccessToken")),
connect.WithClientOptions(opts...),
),
deletePersonalAccessToken: connect.NewClient[v1.DeletePersonalAccessTokenRequest, emptypb.Empty](
httpClient,
baseURL+UserServiceDeletePersonalAccessTokenProcedure,
connect.WithSchema(userServiceMethods.ByName("DeletePersonalAccessToken")),
connect.WithClientOptions(opts...),
),
listUserWebhooks: connect.NewClient[v1.ListUserWebhooksRequest, v1.ListUserWebhooksResponse](
httpClient,
baseURL+UserServiceListUserWebhooksProcedure,
connect.WithSchema(userServiceMethods.ByName("ListUserWebhooks")),
connect.WithClientOptions(opts...),
),
createUserWebhook: connect.NewClient[v1.CreateUserWebhookRequest, v1.UserWebhook](
httpClient,
baseURL+UserServiceCreateUserWebhookProcedure,
connect.WithSchema(userServiceMethods.ByName("CreateUserWebhook")),
connect.WithClientOptions(opts...),
),
updateUserWebhook: connect.NewClient[v1.UpdateUserWebhookRequest, v1.UserWebhook](
httpClient,
baseURL+UserServiceUpdateUserWebhookProcedure,
connect.WithSchema(userServiceMethods.ByName("UpdateUserWebhook")),
connect.WithClientOptions(opts...),
),
deleteUserWebhook: connect.NewClient[v1.DeleteUserWebhookRequest, emptypb.Empty](
httpClient,
baseURL+UserServiceDeleteUserWebhookProcedure,
connect.WithSchema(userServiceMethods.ByName("DeleteUserWebhook")),
connect.WithClientOptions(opts...),
),
listUserNotifications: connect.NewClient[v1.ListUserNotificationsRequest, v1.ListUserNotificationsResponse](
httpClient,
baseURL+UserServiceListUserNotificationsProcedure,
connect.WithSchema(userServiceMethods.ByName("ListUserNotifications")),
connect.WithClientOptions(opts...),
),
updateUserNotification: connect.NewClient[v1.UpdateUserNotificationRequest, v1.UserNotification](
httpClient,
baseURL+UserServiceUpdateUserNotificationProcedure,
connect.WithSchema(userServiceMethods.ByName("UpdateUserNotification")),
connect.WithClientOptions(opts...),
),
deleteUserNotification: connect.NewClient[v1.DeleteUserNotificationRequest, emptypb.Empty](
httpClient,
baseURL+UserServiceDeleteUserNotificationProcedure,
connect.WithSchema(userServiceMethods.ByName("DeleteUserNotification")),
connect.WithClientOptions(opts...),
),
}
}
// userServiceClient implements UserServiceClient.
type userServiceClient struct {
listUsers *connect.Client[v1.ListUsersRequest, v1.ListUsersResponse]
getUser *connect.Client[v1.GetUserRequest, v1.User]
createUser *connect.Client[v1.CreateUserRequest, v1.User]
updateUser *connect.Client[v1.UpdateUserRequest, v1.User]
deleteUser *connect.Client[v1.DeleteUserRequest, emptypb.Empty]
listAllUserStats *connect.Client[v1.ListAllUserStatsRequest, v1.ListAllUserStatsResponse]
getUserStats *connect.Client[v1.GetUserStatsRequest, v1.UserStats]
getUserSetting *connect.Client[v1.GetUserSettingRequest, v1.UserSetting]
updateUserSetting *connect.Client[v1.UpdateUserSettingRequest, v1.UserSetting]
listUserSettings *connect.Client[v1.ListUserSettingsRequest, v1.ListUserSettingsResponse]
listPersonalAccessTokens *connect.Client[v1.ListPersonalAccessTokensRequest, v1.ListPersonalAccessTokensResponse]
createPersonalAccessToken *connect.Client[v1.CreatePersonalAccessTokenRequest, v1.CreatePersonalAccessTokenResponse]
deletePersonalAccessToken *connect.Client[v1.DeletePersonalAccessTokenRequest, emptypb.Empty]
listUserWebhooks *connect.Client[v1.ListUserWebhooksRequest, v1.ListUserWebhooksResponse]
createUserWebhook *connect.Client[v1.CreateUserWebhookRequest, v1.UserWebhook]
updateUserWebhook *connect.Client[v1.UpdateUserWebhookRequest, v1.UserWebhook]
deleteUserWebhook *connect.Client[v1.DeleteUserWebhookRequest, emptypb.Empty]
listUserNotifications *connect.Client[v1.ListUserNotificationsRequest, v1.ListUserNotificationsResponse]
updateUserNotification *connect.Client[v1.UpdateUserNotificationRequest, v1.UserNotification]
deleteUserNotification *connect.Client[v1.DeleteUserNotificationRequest, emptypb.Empty]
}
// ListUsers calls memos.api.v1.UserService.ListUsers.
func (c *userServiceClient) ListUsers(ctx context.Context, req *connect.Request[v1.ListUsersRequest]) (*connect.Response[v1.ListUsersResponse], error) {
return c.listUsers.CallUnary(ctx, req)
}
// GetUser calls memos.api.v1.UserService.GetUser.
func (c *userServiceClient) GetUser(ctx context.Context, req *connect.Request[v1.GetUserRequest]) (*connect.Response[v1.User], error) {
return c.getUser.CallUnary(ctx, req)
}
// CreateUser calls memos.api.v1.UserService.CreateUser.
func (c *userServiceClient) CreateUser(ctx context.Context, req *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.User], error) {
return c.createUser.CallUnary(ctx, req)
}
// UpdateUser calls memos.api.v1.UserService.UpdateUser.
func (c *userServiceClient) UpdateUser(ctx context.Context, req *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.User], error) {
return c.updateUser.CallUnary(ctx, req)
}
// DeleteUser calls memos.api.v1.UserService.DeleteUser.
func (c *userServiceClient) DeleteUser(ctx context.Context, req *connect.Request[v1.DeleteUserRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteUser.CallUnary(ctx, req)
}
// ListAllUserStats calls memos.api.v1.UserService.ListAllUserStats.
func (c *userServiceClient) ListAllUserStats(ctx context.Context, req *connect.Request[v1.ListAllUserStatsRequest]) (*connect.Response[v1.ListAllUserStatsResponse], error) {
return c.listAllUserStats.CallUnary(ctx, req)
}
// GetUserStats calls memos.api.v1.UserService.GetUserStats.
func (c *userServiceClient) GetUserStats(ctx context.Context, req *connect.Request[v1.GetUserStatsRequest]) (*connect.Response[v1.UserStats], error) {
return c.getUserStats.CallUnary(ctx, req)
}
// GetUserSetting calls memos.api.v1.UserService.GetUserSetting.
func (c *userServiceClient) GetUserSetting(ctx context.Context, req *connect.Request[v1.GetUserSettingRequest]) (*connect.Response[v1.UserSetting], error) {
return c.getUserSetting.CallUnary(ctx, req)
}
// UpdateUserSetting calls memos.api.v1.UserService.UpdateUserSetting.
func (c *userServiceClient) UpdateUserSetting(ctx context.Context, req *connect.Request[v1.UpdateUserSettingRequest]) (*connect.Response[v1.UserSetting], error) {
return c.updateUserSetting.CallUnary(ctx, req)
}
// ListUserSettings calls memos.api.v1.UserService.ListUserSettings.
func (c *userServiceClient) ListUserSettings(ctx context.Context, req *connect.Request[v1.ListUserSettingsRequest]) (*connect.Response[v1.ListUserSettingsResponse], error) {
return c.listUserSettings.CallUnary(ctx, req)
}
// ListPersonalAccessTokens calls memos.api.v1.UserService.ListPersonalAccessTokens.
func (c *userServiceClient) ListPersonalAccessTokens(ctx context.Context, req *connect.Request[v1.ListPersonalAccessTokensRequest]) (*connect.Response[v1.ListPersonalAccessTokensResponse], error) {
return c.listPersonalAccessTokens.CallUnary(ctx, req)
}
// CreatePersonalAccessToken calls memos.api.v1.UserService.CreatePersonalAccessToken.
func (c *userServiceClient) CreatePersonalAccessToken(ctx context.Context, req *connect.Request[v1.CreatePersonalAccessTokenRequest]) (*connect.Response[v1.CreatePersonalAccessTokenResponse], error) {
return c.createPersonalAccessToken.CallUnary(ctx, req)
}
// DeletePersonalAccessToken calls memos.api.v1.UserService.DeletePersonalAccessToken.
func (c *userServiceClient) DeletePersonalAccessToken(ctx context.Context, req *connect.Request[v1.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deletePersonalAccessToken.CallUnary(ctx, req)
}
// ListUserWebhooks calls memos.api.v1.UserService.ListUserWebhooks.
func (c *userServiceClient) ListUserWebhooks(ctx context.Context, req *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error) {
return c.listUserWebhooks.CallUnary(ctx, req)
}
// CreateUserWebhook calls memos.api.v1.UserService.CreateUserWebhook.
func (c *userServiceClient) CreateUserWebhook(ctx context.Context, req *connect.Request[v1.CreateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error) {
return c.createUserWebhook.CallUnary(ctx, req)
}
// UpdateUserWebhook calls memos.api.v1.UserService.UpdateUserWebhook.
func (c *userServiceClient) UpdateUserWebhook(ctx context.Context, req *connect.Request[v1.UpdateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error) {
return c.updateUserWebhook.CallUnary(ctx, req)
}
// DeleteUserWebhook calls memos.api.v1.UserService.DeleteUserWebhook.
func (c *userServiceClient) DeleteUserWebhook(ctx context.Context, req *connect.Request[v1.DeleteUserWebhookRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteUserWebhook.CallUnary(ctx, req)
}
// ListUserNotifications calls memos.api.v1.UserService.ListUserNotifications.
func (c *userServiceClient) ListUserNotifications(ctx context.Context, req *connect.Request[v1.ListUserNotificationsRequest]) (*connect.Response[v1.ListUserNotificationsResponse], error) {
return c.listUserNotifications.CallUnary(ctx, req)
}
// UpdateUserNotification calls memos.api.v1.UserService.UpdateUserNotification.
func (c *userServiceClient) UpdateUserNotification(ctx context.Context, req *connect.Request[v1.UpdateUserNotificationRequest]) (*connect.Response[v1.UserNotification], error) {
return c.updateUserNotification.CallUnary(ctx, req)
}
// DeleteUserNotification calls memos.api.v1.UserService.DeleteUserNotification.
func (c *userServiceClient) DeleteUserNotification(ctx context.Context, req *connect.Request[v1.DeleteUserNotificationRequest]) (*connect.Response[emptypb.Empty], error) {
return c.deleteUserNotification.CallUnary(ctx, req)
}
// UserServiceHandler is an implementation of the memos.api.v1.UserService service.
type UserServiceHandler interface {
// ListUsers returns a list of users.
ListUsers(context.Context, *connect.Request[v1.ListUsersRequest]) (*connect.Response[v1.ListUsersResponse], error)
// GetUser gets a user by ID or username.
// Supports both numeric IDs and username strings:
// - users/{id} (e.g., users/101)
// - users/{username} (e.g., users/steven)
GetUser(context.Context, *connect.Request[v1.GetUserRequest]) (*connect.Response[v1.User], error)
// CreateUser creates a new user.
CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.User], error)
// UpdateUser updates a user.
UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.User], error)
// DeleteUser deletes a user.
DeleteUser(context.Context, *connect.Request[v1.DeleteUserRequest]) (*connect.Response[emptypb.Empty], error)
// ListAllUserStats returns statistics for all users.
ListAllUserStats(context.Context, *connect.Request[v1.ListAllUserStatsRequest]) (*connect.Response[v1.ListAllUserStatsResponse], error)
// GetUserStats returns statistics for a specific user.
GetUserStats(context.Context, *connect.Request[v1.GetUserStatsRequest]) (*connect.Response[v1.UserStats], error)
// GetUserSetting returns the user setting.
GetUserSetting(context.Context, *connect.Request[v1.GetUserSettingRequest]) (*connect.Response[v1.UserSetting], error)
// UpdateUserSetting updates the user setting.
UpdateUserSetting(context.Context, *connect.Request[v1.UpdateUserSettingRequest]) (*connect.Response[v1.UserSetting], error)
// ListUserSettings returns a list of user settings.
ListUserSettings(context.Context, *connect.Request[v1.ListUserSettingsRequest]) (*connect.Response[v1.ListUserSettingsResponse], error)
// ListPersonalAccessTokens returns a list of Personal Access Tokens (PATs) for a user.
// PATs are long-lived tokens for API/script access, distinct from short-lived JWT access tokens.
ListPersonalAccessTokens(context.Context, *connect.Request[v1.ListPersonalAccessTokensRequest]) (*connect.Response[v1.ListPersonalAccessTokensResponse], error)
// CreatePersonalAccessToken creates a new Personal Access Token for a user.
// The token value is only returned once upon creation.
CreatePersonalAccessToken(context.Context, *connect.Request[v1.CreatePersonalAccessTokenRequest]) (*connect.Response[v1.CreatePersonalAccessTokenResponse], error)
// DeletePersonalAccessToken deletes a Personal Access Token.
DeletePersonalAccessToken(context.Context, *connect.Request[v1.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error)
// ListUserWebhooks returns a list of webhooks for a user.
ListUserWebhooks(context.Context, *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error)
// CreateUserWebhook creates a new webhook for a user.
CreateUserWebhook(context.Context, *connect.Request[v1.CreateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error)
// UpdateUserWebhook updates an existing webhook for a user.
UpdateUserWebhook(context.Context, *connect.Request[v1.UpdateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error)
// DeleteUserWebhook deletes a webhook for a user.
DeleteUserWebhook(context.Context, *connect.Request[v1.DeleteUserWebhookRequest]) (*connect.Response[emptypb.Empty], error)
// ListUserNotifications lists notifications for a user.
ListUserNotifications(context.Context, *connect.Request[v1.ListUserNotificationsRequest]) (*connect.Response[v1.ListUserNotificationsResponse], error)
// UpdateUserNotification updates a notification.
UpdateUserNotification(context.Context, *connect.Request[v1.UpdateUserNotificationRequest]) (*connect.Response[v1.UserNotification], error)
// DeleteUserNotification deletes a notification.
DeleteUserNotification(context.Context, *connect.Request[v1.DeleteUserNotificationRequest]) (*connect.Response[emptypb.Empty], error)
}
// NewUserServiceHandler builds an HTTP handler from the service implementation. It returns the path
// on which to mount the handler and the handler itself.
//
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
// and JSON codecs. They also support gzip compression.
func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
userServiceMethods := v1.File_api_v1_user_service_proto.Services().ByName("UserService").Methods()
userServiceListUsersHandler := connect.NewUnaryHandler(
UserServiceListUsersProcedure,
svc.ListUsers,
connect.WithSchema(userServiceMethods.ByName("ListUsers")),
connect.WithHandlerOptions(opts...),
)
userServiceGetUserHandler := connect.NewUnaryHandler(
UserServiceGetUserProcedure,
svc.GetUser,
connect.WithSchema(userServiceMethods.ByName("GetUser")),
connect.WithHandlerOptions(opts...),
)
userServiceCreateUserHandler := connect.NewUnaryHandler(
UserServiceCreateUserProcedure,
svc.CreateUser,
connect.WithSchema(userServiceMethods.ByName("CreateUser")),
connect.WithHandlerOptions(opts...),
)
userServiceUpdateUserHandler := connect.NewUnaryHandler(
UserServiceUpdateUserProcedure,
svc.UpdateUser,
connect.WithSchema(userServiceMethods.ByName("UpdateUser")),
connect.WithHandlerOptions(opts...),
)
userServiceDeleteUserHandler := connect.NewUnaryHandler(
UserServiceDeleteUserProcedure,
svc.DeleteUser,
connect.WithSchema(userServiceMethods.ByName("DeleteUser")),
connect.WithHandlerOptions(opts...),
)
userServiceListAllUserStatsHandler := connect.NewUnaryHandler(
UserServiceListAllUserStatsProcedure,
svc.ListAllUserStats,
connect.WithSchema(userServiceMethods.ByName("ListAllUserStats")),
connect.WithHandlerOptions(opts...),
)
userServiceGetUserStatsHandler := connect.NewUnaryHandler(
UserServiceGetUserStatsProcedure,
svc.GetUserStats,
connect.WithSchema(userServiceMethods.ByName("GetUserStats")),
connect.WithHandlerOptions(opts...),
)
userServiceGetUserSettingHandler := connect.NewUnaryHandler(
UserServiceGetUserSettingProcedure,
svc.GetUserSetting,
connect.WithSchema(userServiceMethods.ByName("GetUserSetting")),
connect.WithHandlerOptions(opts...),
)
userServiceUpdateUserSettingHandler := connect.NewUnaryHandler(
UserServiceUpdateUserSettingProcedure,
svc.UpdateUserSetting,
connect.WithSchema(userServiceMethods.ByName("UpdateUserSetting")),
connect.WithHandlerOptions(opts...),
)
userServiceListUserSettingsHandler := connect.NewUnaryHandler(
UserServiceListUserSettingsProcedure,
svc.ListUserSettings,
connect.WithSchema(userServiceMethods.ByName("ListUserSettings")),
connect.WithHandlerOptions(opts...),
)
userServiceListPersonalAccessTokensHandler := connect.NewUnaryHandler(
UserServiceListPersonalAccessTokensProcedure,
svc.ListPersonalAccessTokens,
connect.WithSchema(userServiceMethods.ByName("ListPersonalAccessTokens")),
connect.WithHandlerOptions(opts...),
)
userServiceCreatePersonalAccessTokenHandler := connect.NewUnaryHandler(
UserServiceCreatePersonalAccessTokenProcedure,
svc.CreatePersonalAccessToken,
connect.WithSchema(userServiceMethods.ByName("CreatePersonalAccessToken")),
connect.WithHandlerOptions(opts...),
)
userServiceDeletePersonalAccessTokenHandler := connect.NewUnaryHandler(
UserServiceDeletePersonalAccessTokenProcedure,
svc.DeletePersonalAccessToken,
connect.WithSchema(userServiceMethods.ByName("DeletePersonalAccessToken")),
connect.WithHandlerOptions(opts...),
)
userServiceListUserWebhooksHandler := connect.NewUnaryHandler(
UserServiceListUserWebhooksProcedure,
svc.ListUserWebhooks,
connect.WithSchema(userServiceMethods.ByName("ListUserWebhooks")),
connect.WithHandlerOptions(opts...),
)
userServiceCreateUserWebhookHandler := connect.NewUnaryHandler(
UserServiceCreateUserWebhookProcedure,
svc.CreateUserWebhook,
connect.WithSchema(userServiceMethods.ByName("CreateUserWebhook")),
connect.WithHandlerOptions(opts...),
)
userServiceUpdateUserWebhookHandler := connect.NewUnaryHandler(
UserServiceUpdateUserWebhookProcedure,
svc.UpdateUserWebhook,
connect.WithSchema(userServiceMethods.ByName("UpdateUserWebhook")),
connect.WithHandlerOptions(opts...),
)
userServiceDeleteUserWebhookHandler := connect.NewUnaryHandler(
UserServiceDeleteUserWebhookProcedure,
svc.DeleteUserWebhook,
connect.WithSchema(userServiceMethods.ByName("DeleteUserWebhook")),
connect.WithHandlerOptions(opts...),
)
userServiceListUserNotificationsHandler := connect.NewUnaryHandler(
UserServiceListUserNotificationsProcedure,
svc.ListUserNotifications,
connect.WithSchema(userServiceMethods.ByName("ListUserNotifications")),
connect.WithHandlerOptions(opts...),
)
userServiceUpdateUserNotificationHandler := connect.NewUnaryHandler(
UserServiceUpdateUserNotificationProcedure,
svc.UpdateUserNotification,
connect.WithSchema(userServiceMethods.ByName("UpdateUserNotification")),
connect.WithHandlerOptions(opts...),
)
userServiceDeleteUserNotificationHandler := connect.NewUnaryHandler(
UserServiceDeleteUserNotificationProcedure,
svc.DeleteUserNotification,
connect.WithSchema(userServiceMethods.ByName("DeleteUserNotification")),
connect.WithHandlerOptions(opts...),
)
return "/memos.api.v1.UserService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case UserServiceListUsersProcedure:
userServiceListUsersHandler.ServeHTTP(w, r)
case UserServiceGetUserProcedure:
userServiceGetUserHandler.ServeHTTP(w, r)
case UserServiceCreateUserProcedure:
userServiceCreateUserHandler.ServeHTTP(w, r)
case UserServiceUpdateUserProcedure:
userServiceUpdateUserHandler.ServeHTTP(w, r)
case UserServiceDeleteUserProcedure:
userServiceDeleteUserHandler.ServeHTTP(w, r)
case UserServiceListAllUserStatsProcedure:
userServiceListAllUserStatsHandler.ServeHTTP(w, r)
case UserServiceGetUserStatsProcedure:
userServiceGetUserStatsHandler.ServeHTTP(w, r)
case UserServiceGetUserSettingProcedure:
userServiceGetUserSettingHandler.ServeHTTP(w, r)
case UserServiceUpdateUserSettingProcedure:
userServiceUpdateUserSettingHandler.ServeHTTP(w, r)
case UserServiceListUserSettingsProcedure:
userServiceListUserSettingsHandler.ServeHTTP(w, r)
case UserServiceListPersonalAccessTokensProcedure:
userServiceListPersonalAccessTokensHandler.ServeHTTP(w, r)
case UserServiceCreatePersonalAccessTokenProcedure:
userServiceCreatePersonalAccessTokenHandler.ServeHTTP(w, r)
case UserServiceDeletePersonalAccessTokenProcedure:
userServiceDeletePersonalAccessTokenHandler.ServeHTTP(w, r)
case UserServiceListUserWebhooksProcedure:
userServiceListUserWebhooksHandler.ServeHTTP(w, r)
case UserServiceCreateUserWebhookProcedure:
userServiceCreateUserWebhookHandler.ServeHTTP(w, r)
case UserServiceUpdateUserWebhookProcedure:
userServiceUpdateUserWebhookHandler.ServeHTTP(w, r)
case UserServiceDeleteUserWebhookProcedure:
userServiceDeleteUserWebhookHandler.ServeHTTP(w, r)
case UserServiceListUserNotificationsProcedure:
userServiceListUserNotificationsHandler.ServeHTTP(w, r)
case UserServiceUpdateUserNotificationProcedure:
userServiceUpdateUserNotificationHandler.ServeHTTP(w, r)
case UserServiceDeleteUserNotificationProcedure:
userServiceDeleteUserNotificationHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
})
}
// UnimplementedUserServiceHandler returns CodeUnimplemented from all methods.
type UnimplementedUserServiceHandler struct{}
func (UnimplementedUserServiceHandler) ListUsers(context.Context, *connect.Request[v1.ListUsersRequest]) (*connect.Response[v1.ListUsersResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListUsers is not implemented"))
}
func (UnimplementedUserServiceHandler) GetUser(context.Context, *connect.Request[v1.GetUserRequest]) (*connect.Response[v1.User], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.GetUser is not implemented"))
}
func (UnimplementedUserServiceHandler) CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.User], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.CreateUser is not implemented"))
}
func (UnimplementedUserServiceHandler) UpdateUser(context.Context, *connect.Request[v1.UpdateUserRequest]) (*connect.Response[v1.User], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.UpdateUser is not implemented"))
}
func (UnimplementedUserServiceHandler) DeleteUser(context.Context, *connect.Request[v1.DeleteUserRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.DeleteUser is not implemented"))
}
func (UnimplementedUserServiceHandler) ListAllUserStats(context.Context, *connect.Request[v1.ListAllUserStatsRequest]) (*connect.Response[v1.ListAllUserStatsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListAllUserStats is not implemented"))
}
func (UnimplementedUserServiceHandler) GetUserStats(context.Context, *connect.Request[v1.GetUserStatsRequest]) (*connect.Response[v1.UserStats], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.GetUserStats is not implemented"))
}
func (UnimplementedUserServiceHandler) GetUserSetting(context.Context, *connect.Request[v1.GetUserSettingRequest]) (*connect.Response[v1.UserSetting], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.GetUserSetting is not implemented"))
}
func (UnimplementedUserServiceHandler) UpdateUserSetting(context.Context, *connect.Request[v1.UpdateUserSettingRequest]) (*connect.Response[v1.UserSetting], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.UpdateUserSetting is not implemented"))
}
func (UnimplementedUserServiceHandler) ListUserSettings(context.Context, *connect.Request[v1.ListUserSettingsRequest]) (*connect.Response[v1.ListUserSettingsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListUserSettings is not implemented"))
}
func (UnimplementedUserServiceHandler) ListPersonalAccessTokens(context.Context, *connect.Request[v1.ListPersonalAccessTokensRequest]) (*connect.Response[v1.ListPersonalAccessTokensResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListPersonalAccessTokens is not implemented"))
}
func (UnimplementedUserServiceHandler) CreatePersonalAccessToken(context.Context, *connect.Request[v1.CreatePersonalAccessTokenRequest]) (*connect.Response[v1.CreatePersonalAccessTokenResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.CreatePersonalAccessToken is not implemented"))
}
func (UnimplementedUserServiceHandler) DeletePersonalAccessToken(context.Context, *connect.Request[v1.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.DeletePersonalAccessToken is not implemented"))
}
func (UnimplementedUserServiceHandler) ListUserWebhooks(context.Context, *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListUserWebhooks is not implemented"))
}
func (UnimplementedUserServiceHandler) CreateUserWebhook(context.Context, *connect.Request[v1.CreateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.CreateUserWebhook is not implemented"))
}
func (UnimplementedUserServiceHandler) UpdateUserWebhook(context.Context, *connect.Request[v1.UpdateUserWebhookRequest]) (*connect.Response[v1.UserWebhook], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.UpdateUserWebhook is not implemented"))
}
func (UnimplementedUserServiceHandler) DeleteUserWebhook(context.Context, *connect.Request[v1.DeleteUserWebhookRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.DeleteUserWebhook is not implemented"))
}
func (UnimplementedUserServiceHandler) ListUserNotifications(context.Context, *connect.Request[v1.ListUserNotificationsRequest]) (*connect.Response[v1.ListUserNotificationsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListUserNotifications is not implemented"))
}
func (UnimplementedUserServiceHandler) UpdateUserNotification(context.Context, *connect.Request[v1.UpdateUserNotificationRequest]) (*connect.Response[v1.UserNotification], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.UpdateUserNotification is not implemented"))
}
func (UnimplementedUserServiceHandler) DeleteUserNotification(context.Context, *connect.Request[v1.DeleteUserNotificationRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.DeleteUserNotification is not implemented"))
}