diff --git a/go.mod b/go.mod index 9e12be0426467..1527367935455 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/aws/aws-sdk-go-v2/credentials v1.13.12 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.51 github.com/aws/aws-sdk-go-v2/service/s3 v1.30.3 + github.com/bufbuild/connect-go v1.10.0 github.com/disintegration/imaging v1.6.2 github.com/google/uuid v1.3.0 github.com/gorilla/feeds v1.1.1 @@ -25,6 +26,7 @@ require ( golang.org/x/mod v0.8.0 golang.org/x/net v0.7.0 golang.org/x/oauth2 v0.5.0 + google.golang.org/grpc v1.52.0 modernc.org/sqlite v1.24.0 ) @@ -34,6 +36,7 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect golang.org/x/image v0.7.0 // indirect golang.org/x/tools v0.6.0 // indirect + google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef // indirect lukechampine.com/uint128 v1.2.0 // indirect modernc.org/cc/v3 v3.40.0 // indirect modernc.org/ccgo/v3 v3.16.13 // indirect @@ -89,7 +92,7 @@ require ( golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.1.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.31.0 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index f566adbf31658..3aa7fcbe60cdd 100644 --- a/go.sum +++ b/go.sum @@ -83,6 +83,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiO github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/bufbuild/connect-go v1.10.0 h1:QAJ3G9A1OYQW2Jbk3DeoJbkCxuKArrvZgDt47mjdTbg= +github.com/bufbuild/connect-go v1.10.0/go.mod h1:CAIePUgkDR5pAFaylSMtNK45ANQjp9JvpluG20rhpV8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -592,6 +594,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef h1:uQ2vjV/sHTsWSqdKeLqmwitzgvjMl7o4IdtHwUDXSJY= +google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -608,6 +612,8 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.52.0 h1:kd48UiU7EHsV4rnLyOJRuP/Il/UHE7gdDAQ+SZI7nZk= +google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -620,8 +626,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/proto/apiv2/example.proto b/proto/apiv2/example.proto deleted file mode 100644 index ac4dc7a2c9736..0000000000000 --- a/proto/apiv2/example.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package memos.apiv2; - -option go_package = "gen-go/apiv2"; - -// Person is a simple message type containing information about a person. -// It is an example of the kind of message that one might define in a protobufs file. -message Person { - string name = 1; - int32 id = 2; -} diff --git a/proto/apiv2/tag_service.proto b/proto/apiv2/tag_service.proto new file mode 100644 index 0000000000000..a75dfe3cadcc0 --- /dev/null +++ b/proto/apiv2/tag_service.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package memos.apiv2; + +option go_package = "gen/apiv2"; + +service TagService { + rpc ListTags(ListTagsRequest) returns (ListTagsResponse); +} + +message Tag { + string name = 1; + int32 creator_id = 2; +} + +message ListTagsRequest { + int32 creator_id = 1; +} + +message ListTagsResponse { + repeated Tag tags = 1; +} diff --git a/proto/buf.gen.yaml b/proto/buf.gen.yaml index 1454b7f42cb02..412847e95aac1 100644 --- a/proto/buf.gen.yaml +++ b/proto/buf.gen.yaml @@ -1,5 +1,18 @@ version: v1 +managed: + enabled: true + go_package_prefix: + default: github.com/usememos/memos/proto/gen plugins: - - plugin: go - out: gen-go - opt: paths=source_relative + - plugin: buf.build/grpc/go:v1.3.0 + out: gen + opt: + - paths=source_relative + - plugin: buf.build/bufbuild/connect-go:v1.10.0 + out: gen + opt: + - paths=source_relative + - plugin: buf.build/protocolbuffers/go:v1.31.0 + out: gen + opt: + - paths=source_relative diff --git a/proto/gen-go/apiv2/example.pb.go b/proto/gen-go/apiv2/example.pb.go deleted file mode 100644 index 0211478ab0041..0000000000000 --- a/proto/gen-go/apiv2/example.pb.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.29.0 -// protoc (unknown) -// source: apiv2/example.proto - -package apiv2 - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Person is a simple message type containing information about a person. -// It is an example of the kind of message that one might define in a protobufs file. -type Person struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` -} - -func (x *Person) Reset() { - *x = Person{} - if protoimpl.UnsafeEnabled { - mi := &file_apiv2_example_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Person) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Person) ProtoMessage() {} - -func (x *Person) ProtoReflect() protoreflect.Message { - mi := &file_apiv2_example_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Person.ProtoReflect.Descriptor instead. -func (*Person) Descriptor() ([]byte, []int) { - return file_apiv2_example_proto_rawDescGZIP(), []int{0} -} - -func (x *Person) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Person) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - -var File_apiv2_example_proto protoreflect.FileDescriptor - -var file_apiv2_example_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x76, 0x32, 0x22, 0x2c, 0x0a, 0x06, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, - 0x42, 0x0e, 0x5a, 0x0c, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x76, 0x32, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_apiv2_example_proto_rawDescOnce sync.Once - file_apiv2_example_proto_rawDescData = file_apiv2_example_proto_rawDesc -) - -func file_apiv2_example_proto_rawDescGZIP() []byte { - file_apiv2_example_proto_rawDescOnce.Do(func() { - file_apiv2_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_apiv2_example_proto_rawDescData) - }) - return file_apiv2_example_proto_rawDescData -} - -var file_apiv2_example_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_apiv2_example_proto_goTypes = []interface{}{ - (*Person)(nil), // 0: memos.apiv2.Person -} -var file_apiv2_example_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_apiv2_example_proto_init() } -func file_apiv2_example_proto_init() { - if File_apiv2_example_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_apiv2_example_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Person); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_apiv2_example_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_apiv2_example_proto_goTypes, - DependencyIndexes: file_apiv2_example_proto_depIdxs, - MessageInfos: file_apiv2_example_proto_msgTypes, - }.Build() - File_apiv2_example_proto = out.File - file_apiv2_example_proto_rawDesc = nil - file_apiv2_example_proto_goTypes = nil - file_apiv2_example_proto_depIdxs = nil -} diff --git a/proto/gen/apiv2/apiv2connect/tag_service.connect.go b/proto/gen/apiv2/apiv2connect/tag_service.connect.go new file mode 100644 index 0000000000000..bb6527001defa --- /dev/null +++ b/proto/gen/apiv2/apiv2connect/tag_service.connect.go @@ -0,0 +1,104 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: apiv2/tag_service.proto + +package apiv2connect + +import ( + context "context" + errors "errors" + connect_go "github.com/bufbuild/connect-go" + apiv2 "github.com/usememos/memos/proto/gen/apiv2" + 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_go.IsAtLeastVersion0_1_0 + +const ( + // TagServiceName is the fully-qualified name of the TagService service. + TagServiceName = "memos.apiv2.TagService" +) + +// 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 ( + // TagServiceListTagsProcedure is the fully-qualified name of the TagService's ListTags RPC. + TagServiceListTagsProcedure = "/memos.apiv2.TagService/ListTags" +) + +// TagServiceClient is a client for the memos.apiv2.TagService service. +type TagServiceClient interface { + ListTags(context.Context, *connect_go.Request[apiv2.ListTagsRequest]) (*connect_go.Response[apiv2.ListTagsResponse], error) +} + +// NewTagServiceClient constructs a client for the memos.apiv2.TagService 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 NewTagServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) TagServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &tagServiceClient{ + listTags: connect_go.NewClient[apiv2.ListTagsRequest, apiv2.ListTagsResponse]( + httpClient, + baseURL+TagServiceListTagsProcedure, + opts..., + ), + } +} + +// tagServiceClient implements TagServiceClient. +type tagServiceClient struct { + listTags *connect_go.Client[apiv2.ListTagsRequest, apiv2.ListTagsResponse] +} + +// ListTags calls memos.apiv2.TagService.ListTags. +func (c *tagServiceClient) ListTags(ctx context.Context, req *connect_go.Request[apiv2.ListTagsRequest]) (*connect_go.Response[apiv2.ListTagsResponse], error) { + return c.listTags.CallUnary(ctx, req) +} + +// TagServiceHandler is an implementation of the memos.apiv2.TagService service. +type TagServiceHandler interface { + ListTags(context.Context, *connect_go.Request[apiv2.ListTagsRequest]) (*connect_go.Response[apiv2.ListTagsResponse], error) +} + +// NewTagServiceHandler 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 NewTagServiceHandler(svc TagServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { + tagServiceListTagsHandler := connect_go.NewUnaryHandler( + TagServiceListTagsProcedure, + svc.ListTags, + opts..., + ) + return "/memos.apiv2.TagService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case TagServiceListTagsProcedure: + tagServiceListTagsHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedTagServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedTagServiceHandler struct{} + +func (UnimplementedTagServiceHandler) ListTags(context.Context, *connect_go.Request[apiv2.ListTagsRequest]) (*connect_go.Response[apiv2.ListTagsResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("memos.apiv2.TagService.ListTags is not implemented")) +} diff --git a/proto/gen/apiv2/tag_service.pb.go b/proto/gen/apiv2/tag_service.pb.go new file mode 100644 index 0000000000000..dfb2bb67aa377 --- /dev/null +++ b/proto/gen/apiv2/tag_service.pb.go @@ -0,0 +1,296 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: apiv2/tag_service.proto + +package apiv2 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Tag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + CreatorId int32 `protobuf:"varint,2,opt,name=creator_id,json=creatorId,proto3" json:"creator_id,omitempty"` +} + +func (x *Tag) Reset() { + *x = Tag{} + if protoimpl.UnsafeEnabled { + mi := &file_apiv2_tag_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Tag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tag) ProtoMessage() {} + +func (x *Tag) ProtoReflect() protoreflect.Message { + mi := &file_apiv2_tag_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tag.ProtoReflect.Descriptor instead. +func (*Tag) Descriptor() ([]byte, []int) { + return file_apiv2_tag_service_proto_rawDescGZIP(), []int{0} +} + +func (x *Tag) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Tag) GetCreatorId() int32 { + if x != nil { + return x.CreatorId + } + return 0 +} + +type ListTagsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CreatorId int32 `protobuf:"varint,1,opt,name=creator_id,json=creatorId,proto3" json:"creator_id,omitempty"` +} + +func (x *ListTagsRequest) Reset() { + *x = ListTagsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_apiv2_tag_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListTagsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListTagsRequest) ProtoMessage() {} + +func (x *ListTagsRequest) ProtoReflect() protoreflect.Message { + mi := &file_apiv2_tag_service_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListTagsRequest.ProtoReflect.Descriptor instead. +func (*ListTagsRequest) Descriptor() ([]byte, []int) { + return file_apiv2_tag_service_proto_rawDescGZIP(), []int{1} +} + +func (x *ListTagsRequest) GetCreatorId() int32 { + if x != nil { + return x.CreatorId + } + return 0 +} + +type ListTagsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tags []*Tag `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"` +} + +func (x *ListTagsResponse) Reset() { + *x = ListTagsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_apiv2_tag_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListTagsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListTagsResponse) ProtoMessage() {} + +func (x *ListTagsResponse) ProtoReflect() protoreflect.Message { + mi := &file_apiv2_tag_service_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListTagsResponse.ProtoReflect.Descriptor instead. +func (*ListTagsResponse) Descriptor() ([]byte, []int) { + return file_apiv2_tag_service_proto_rawDescGZIP(), []int{2} +} + +func (x *ListTagsResponse) GetTags() []*Tag { + if x != nil { + return x.Tags + } + return nil +} + +var File_apiv2_tag_service_proto protoreflect.FileDescriptor + +var file_apiv2_tag_service_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x74, 0x61, 0x67, 0x5f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x6d, 0x65, 0x6d, 0x6f, 0x73, + 0x2e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x22, 0x38, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, + 0x22, 0x30, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, + 0x49, 0x64, 0x22, 0x38, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x76, 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x32, 0x55, 0x0a, 0x0a, + 0x54, 0x61, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x08, 0x4c, 0x69, + 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x12, 0x1c, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0x70, 0x69, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x42, 0x9a, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, + 0x73, 0x2e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x42, 0x0f, 0x54, 0x61, 0x67, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, + 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, + 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x65, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x76, 0x32, 0xca, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, + 0x73, 0x5c, 0x41, 0x70, 0x69, 0x76, 0x32, 0xe2, 0x02, 0x17, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, + 0x41, 0x70, 0x69, 0x76, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x76, 0x32, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_apiv2_tag_service_proto_rawDescOnce sync.Once + file_apiv2_tag_service_proto_rawDescData = file_apiv2_tag_service_proto_rawDesc +) + +func file_apiv2_tag_service_proto_rawDescGZIP() []byte { + file_apiv2_tag_service_proto_rawDescOnce.Do(func() { + file_apiv2_tag_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_apiv2_tag_service_proto_rawDescData) + }) + return file_apiv2_tag_service_proto_rawDescData +} + +var file_apiv2_tag_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_apiv2_tag_service_proto_goTypes = []interface{}{ + (*Tag)(nil), // 0: memos.apiv2.Tag + (*ListTagsRequest)(nil), // 1: memos.apiv2.ListTagsRequest + (*ListTagsResponse)(nil), // 2: memos.apiv2.ListTagsResponse +} +var file_apiv2_tag_service_proto_depIdxs = []int32{ + 0, // 0: memos.apiv2.ListTagsResponse.tags:type_name -> memos.apiv2.Tag + 1, // 1: memos.apiv2.TagService.ListTags:input_type -> memos.apiv2.ListTagsRequest + 2, // 2: memos.apiv2.TagService.ListTags:output_type -> memos.apiv2.ListTagsResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_apiv2_tag_service_proto_init() } +func file_apiv2_tag_service_proto_init() { + if File_apiv2_tag_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_apiv2_tag_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Tag); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apiv2_tag_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListTagsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_apiv2_tag_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListTagsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_apiv2_tag_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_apiv2_tag_service_proto_goTypes, + DependencyIndexes: file_apiv2_tag_service_proto_depIdxs, + MessageInfos: file_apiv2_tag_service_proto_msgTypes, + }.Build() + File_apiv2_tag_service_proto = out.File + file_apiv2_tag_service_proto_rawDesc = nil + file_apiv2_tag_service_proto_goTypes = nil + file_apiv2_tag_service_proto_depIdxs = nil +} diff --git a/proto/gen/apiv2/tag_service_grpc.pb.go b/proto/gen/apiv2/tag_service_grpc.pb.go new file mode 100644 index 0000000000000..b29143e3357f8 --- /dev/null +++ b/proto/gen/apiv2/tag_service_grpc.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: apiv2/tag_service.proto + +package apiv2 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + TagService_ListTags_FullMethodName = "/memos.apiv2.TagService/ListTags" +) + +// TagServiceClient is the client API for TagService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type TagServiceClient interface { + ListTags(ctx context.Context, in *ListTagsRequest, opts ...grpc.CallOption) (*ListTagsResponse, error) +} + +type tagServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTagServiceClient(cc grpc.ClientConnInterface) TagServiceClient { + return &tagServiceClient{cc} +} + +func (c *tagServiceClient) ListTags(ctx context.Context, in *ListTagsRequest, opts ...grpc.CallOption) (*ListTagsResponse, error) { + out := new(ListTagsResponse) + err := c.cc.Invoke(ctx, TagService_ListTags_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TagServiceServer is the server API for TagService service. +// All implementations must embed UnimplementedTagServiceServer +// for forward compatibility +type TagServiceServer interface { + ListTags(context.Context, *ListTagsRequest) (*ListTagsResponse, error) + mustEmbedUnimplementedTagServiceServer() +} + +// UnimplementedTagServiceServer must be embedded to have forward compatible implementations. +type UnimplementedTagServiceServer struct { +} + +func (UnimplementedTagServiceServer) ListTags(context.Context, *ListTagsRequest) (*ListTagsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListTags not implemented") +} +func (UnimplementedTagServiceServer) mustEmbedUnimplementedTagServiceServer() {} + +// UnsafeTagServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TagServiceServer will +// result in compilation errors. +type UnsafeTagServiceServer interface { + mustEmbedUnimplementedTagServiceServer() +} + +func RegisterTagServiceServer(s grpc.ServiceRegistrar, srv TagServiceServer) { + s.RegisterService(&TagService_ServiceDesc, srv) +} + +func _TagService_ListTags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListTagsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TagServiceServer).ListTags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TagService_ListTags_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TagServiceServer).ListTags(ctx, req.(*ListTagsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// TagService_ServiceDesc is the grpc.ServiceDesc for TagService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var TagService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "memos.apiv2.TagService", + HandlerType: (*TagServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListTags", + Handler: _TagService_ListTags_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "apiv2/tag_service.proto", +} diff --git a/proto/gen-go/store/tag.pb.go b/proto/gen/store/tag.pb.go similarity index 80% rename from proto/gen-go/store/tag.pb.go rename to proto/gen/store/tag.pb.go index 69eca92656a63..92a203a95aef6 100644 --- a/proto/gen-go/store/tag.pb.go +++ b/proto/gen/store/tag.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.29.0 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: store/tag.proto @@ -83,8 +83,17 @@ var file_store_tag_proto_rawDesc = []byte{ 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x42, 0x0e, 0x5a, 0x0c, 0x67, 0x65, 0x6e, 0x2d, - 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x64, 0x42, 0x93, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, + 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x42, 0x08, 0x54, 0x61, + 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, + 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0xa2, 0x02, 0x03, 0x4d, 0x53, 0x58, 0xaa, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, + 0x73, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0xca, 0x02, 0x0b, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, + 0x53, 0x74, 0x6f, 0x72, 0x65, 0xe2, 0x02, 0x17, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x53, 0x74, + 0x6f, 0x72, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/store/tag.proto b/proto/store/tag.proto index cf57422dfc1da..2202a5bcbbea0 100644 --- a/proto/store/tag.proto +++ b/proto/store/tag.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package memos.store; -option go_package = "gen-go/store"; +option go_package = "gen/store"; message Tag { string name = 1;