mirror of
https://github.com/usememos/memos.git
synced 2024-12-18 16:41:44 +03:00
chore: migrate get tag suggestions
This commit is contained in:
parent
0cf280fa9a
commit
bcd8a5a7a9
@ -3,8 +3,11 @@ package v2
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|
||||||
@ -36,7 +39,7 @@ func (s *APIV2Service) UpsertTag(ctx context.Context, request *apiv2pb.UpsertTag
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV2Service) ListTags(ctx context.Context, request *apiv2pb.ListTagsRequest) (*apiv2pb.ListTagsResponse, error) {
|
func (s *APIV2Service) ListTags(ctx context.Context, request *apiv2pb.ListTagsRequest) (*apiv2pb.ListTagsResponse, error) {
|
||||||
username, err := ExtractUsernameFromName(request.Creator)
|
username, err := ExtractUsernameFromName(request.User)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "invalid username: %v", err)
|
return nil, status.Errorf(codes.InvalidArgument, "invalid username: %v", err)
|
||||||
}
|
}
|
||||||
@ -91,6 +94,61 @@ func (s *APIV2Service) DeleteTag(ctx context.Context, request *apiv2pb.DeleteTag
|
|||||||
return &apiv2pb.DeleteTagResponse{}, nil
|
return &apiv2pb.DeleteTagResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *APIV2Service) GetTagSuggestions(ctx context.Context, request *apiv2pb.GetTagSuggestionsRequest) (*apiv2pb.GetTagSuggestionsResponse, error) {
|
||||||
|
username, err := ExtractUsernameFromName(request.User)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "invalid username: %v", err)
|
||||||
|
}
|
||||||
|
user, err := s.Store.GetUser(ctx, &store.FindUser{
|
||||||
|
Username: &username,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
|
||||||
|
}
|
||||||
|
if user == nil {
|
||||||
|
return nil, status.Errorf(codes.NotFound, "user not found")
|
||||||
|
}
|
||||||
|
normalRowStatus := store.Normal
|
||||||
|
memoFind := &store.FindMemo{
|
||||||
|
CreatorID: &user.ID,
|
||||||
|
ContentSearch: []string{"#"},
|
||||||
|
RowStatus: &normalRowStatus,
|
||||||
|
}
|
||||||
|
memoList, err := s.Store.ListMemos(ctx, memoFind)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to list memos: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tagList, err := s.Store.ListTags(ctx, &store.FindTag{
|
||||||
|
CreatorID: user.ID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Errorf(codes.Internal, "failed to list tags: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tagNameList := []string{}
|
||||||
|
for _, tag := range tagList {
|
||||||
|
tagNameList = append(tagNameList, tag.Name)
|
||||||
|
}
|
||||||
|
tagMapSet := make(map[string]bool)
|
||||||
|
for _, memo := range memoList {
|
||||||
|
for _, tag := range findTagListFromMemoContent(memo.Content) {
|
||||||
|
if !slices.Contains(tagNameList, tag) {
|
||||||
|
tagMapSet[tag] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
suggestions := []string{}
|
||||||
|
for tag := range tagMapSet {
|
||||||
|
suggestions = append(suggestions, tag)
|
||||||
|
}
|
||||||
|
sort.Strings(suggestions)
|
||||||
|
|
||||||
|
return &apiv2pb.GetTagSuggestionsResponse{
|
||||||
|
Tags: suggestions,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *APIV2Service) convertTagFromStore(ctx context.Context, tag *store.Tag) (*apiv2pb.Tag, error) {
|
func (s *APIV2Service) convertTagFromStore(ctx context.Context, tag *store.Tag) (*apiv2pb.Tag, error) {
|
||||||
user, err := s.Store.GetUser(ctx, &store.FindUser{
|
user, err := s.Store.GetUser(ctx, &store.FindUser{
|
||||||
ID: &tag.CreatorID,
|
ID: &tag.CreatorID,
|
||||||
@ -103,3 +161,21 @@ func (s *APIV2Service) convertTagFromStore(ctx context.Context, tag *store.Tag)
|
|||||||
Creator: fmt.Sprintf("%s%s", UserNamePrefix, user.Username),
|
Creator: fmt.Sprintf("%s%s", UserNamePrefix, user.Username),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tagRegexp = regexp.MustCompile(`#([^\s#,]+)`)
|
||||||
|
|
||||||
|
func findTagListFromMemoContent(memoContent string) []string {
|
||||||
|
tagMapSet := make(map[string]bool)
|
||||||
|
matches := tagRegexp.FindAllStringSubmatch(memoContent, -1)
|
||||||
|
for _, v := range matches {
|
||||||
|
tagName := v[1]
|
||||||
|
tagMapSet[tagName] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
tagList := []string{}
|
||||||
|
for tag := range tagMapSet {
|
||||||
|
tagList = append(tagList, tag)
|
||||||
|
}
|
||||||
|
sort.Strings(tagList)
|
||||||
|
return tagList
|
||||||
|
}
|
||||||
|
@ -16,6 +16,9 @@ service TagService {
|
|||||||
rpc DeleteTag(DeleteTagRequest) returns (DeleteTagResponse) {
|
rpc DeleteTag(DeleteTagRequest) returns (DeleteTagResponse) {
|
||||||
option (google.api.http) = {delete: "/api/v2/tags"};
|
option (google.api.http) = {delete: "/api/v2/tags"};
|
||||||
}
|
}
|
||||||
|
rpc GetTagSuggestions(GetTagSuggestionsRequest) returns (GetTagSuggestionsResponse) {
|
||||||
|
option (google.api.http) = {get: "/api/v2/tags/suggestion"};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message Tag {
|
message Tag {
|
||||||
@ -36,7 +39,7 @@ message UpsertTagResponse {
|
|||||||
message ListTagsRequest {
|
message ListTagsRequest {
|
||||||
// The creator of tags.
|
// The creator of tags.
|
||||||
// Format: users/{username}
|
// Format: users/{username}
|
||||||
string creator = 1;
|
string user = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListTagsResponse {
|
message ListTagsResponse {
|
||||||
@ -48,3 +51,13 @@ message DeleteTagRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message DeleteTagResponse {}
|
message DeleteTagResponse {}
|
||||||
|
|
||||||
|
message GetTagSuggestionsRequest {
|
||||||
|
// The creator of tags.
|
||||||
|
// Format: users/{username}
|
||||||
|
string user = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTagSuggestionsResponse {
|
||||||
|
repeated string tags = 1;
|
||||||
|
}
|
||||||
|
@ -72,6 +72,8 @@
|
|||||||
- [api/v2/tag_service.proto](#api_v2_tag_service-proto)
|
- [api/v2/tag_service.proto](#api_v2_tag_service-proto)
|
||||||
- [DeleteTagRequest](#memos-api-v2-DeleteTagRequest)
|
- [DeleteTagRequest](#memos-api-v2-DeleteTagRequest)
|
||||||
- [DeleteTagResponse](#memos-api-v2-DeleteTagResponse)
|
- [DeleteTagResponse](#memos-api-v2-DeleteTagResponse)
|
||||||
|
- [GetTagSuggestionsRequest](#memos-api-v2-GetTagSuggestionsRequest)
|
||||||
|
- [GetTagSuggestionsResponse](#memos-api-v2-GetTagSuggestionsResponse)
|
||||||
- [ListTagsRequest](#memos-api-v2-ListTagsRequest)
|
- [ListTagsRequest](#memos-api-v2-ListTagsRequest)
|
||||||
- [ListTagsResponse](#memos-api-v2-ListTagsResponse)
|
- [ListTagsResponse](#memos-api-v2-ListTagsResponse)
|
||||||
- [Tag](#memos-api-v2-Tag)
|
- [Tag](#memos-api-v2-Tag)
|
||||||
@ -938,6 +940,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-GetTagSuggestionsRequest"></a>
|
||||||
|
|
||||||
|
### GetTagSuggestionsRequest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| user | [string](#string) | | The creator of tags. Format: users/{username} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="memos-api-v2-GetTagSuggestionsResponse"></a>
|
||||||
|
|
||||||
|
### GetTagSuggestionsResponse
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| tags | [string](#string) | repeated | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="memos-api-v2-ListTagsRequest"></a>
|
<a name="memos-api-v2-ListTagsRequest"></a>
|
||||||
|
|
||||||
### ListTagsRequest
|
### ListTagsRequest
|
||||||
@ -946,7 +978,7 @@
|
|||||||
|
|
||||||
| Field | Type | Label | Description |
|
| Field | Type | Label | Description |
|
||||||
| ----- | ---- | ----- | ----------- |
|
| ----- | ---- | ----- | ----------- |
|
||||||
| creator | [string](#string) | | The creator of tags. Format: users/{username} |
|
| user | [string](#string) | | The creator of tags. Format: users/{username} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1030,6 +1062,7 @@
|
|||||||
| UpsertTag | [UpsertTagRequest](#memos-api-v2-UpsertTagRequest) | [UpsertTagResponse](#memos-api-v2-UpsertTagResponse) | |
|
| UpsertTag | [UpsertTagRequest](#memos-api-v2-UpsertTagRequest) | [UpsertTagResponse](#memos-api-v2-UpsertTagResponse) | |
|
||||||
| ListTags | [ListTagsRequest](#memos-api-v2-ListTagsRequest) | [ListTagsResponse](#memos-api-v2-ListTagsResponse) | |
|
| ListTags | [ListTagsRequest](#memos-api-v2-ListTagsRequest) | [ListTagsResponse](#memos-api-v2-ListTagsResponse) | |
|
||||||
| DeleteTag | [DeleteTagRequest](#memos-api-v2-DeleteTagRequest) | [DeleteTagResponse](#memos-api-v2-DeleteTagResponse) | |
|
| DeleteTag | [DeleteTagRequest](#memos-api-v2-DeleteTagRequest) | [DeleteTagResponse](#memos-api-v2-DeleteTagResponse) | |
|
||||||
|
| GetTagSuggestions | [GetTagSuggestionsRequest](#memos-api-v2-GetTagSuggestionsRequest) | [GetTagSuggestionsResponse](#memos-api-v2-GetTagSuggestionsResponse) | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ type ListTagsRequest struct {
|
|||||||
|
|
||||||
// The creator of tags.
|
// The creator of tags.
|
||||||
// Format: users/{username}
|
// Format: users/{username}
|
||||||
Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"`
|
User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ListTagsRequest) Reset() {
|
func (x *ListTagsRequest) Reset() {
|
||||||
@ -214,9 +214,9 @@ func (*ListTagsRequest) Descriptor() ([]byte, []int) {
|
|||||||
return file_api_v2_tag_service_proto_rawDescGZIP(), []int{3}
|
return file_api_v2_tag_service_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ListTagsRequest) GetCreator() string {
|
func (x *ListTagsRequest) GetUser() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Creator
|
return x.User
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -353,6 +353,102 @@ func (*DeleteTagResponse) Descriptor() ([]byte, []int) {
|
|||||||
return file_api_v2_tag_service_proto_rawDescGZIP(), []int{6}
|
return file_api_v2_tag_service_proto_rawDescGZIP(), []int{6}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetTagSuggestionsRequest struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// The creator of tags.
|
||||||
|
// Format: users/{username}
|
||||||
|
User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsRequest) Reset() {
|
||||||
|
*x = GetTagSuggestionsRequest{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_api_v2_tag_service_proto_msgTypes[7]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GetTagSuggestionsRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_api_v2_tag_service_proto_msgTypes[7]
|
||||||
|
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 GetTagSuggestionsRequest.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GetTagSuggestionsRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return file_api_v2_tag_service_proto_rawDescGZIP(), []int{7}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsRequest) GetUser() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.User
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetTagSuggestionsResponse struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsResponse) Reset() {
|
||||||
|
*x = GetTagSuggestionsResponse{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_api_v2_tag_service_proto_msgTypes[8]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GetTagSuggestionsResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_api_v2_tag_service_proto_msgTypes[8]
|
||||||
|
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 GetTagSuggestionsResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GetTagSuggestionsResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_api_v2_tag_service_proto_rawDescGZIP(), []int{8}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetTagSuggestionsResponse) GetTags() []string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Tags
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var File_api_v2_tag_service_proto protoreflect.FileDescriptor
|
var File_api_v2_tag_service_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_api_v2_tag_service_proto_rawDesc = []byte{
|
var file_api_v2_tag_service_proto_rawDesc = []byte{
|
||||||
@ -369,49 +465,63 @@ var file_api_v2_tag_service_proto_rawDesc = []byte{
|
|||||||
0x61, 0x6d, 0x65, 0x22, 0x38, 0x0a, 0x11, 0x55, 0x70, 0x73, 0x65, 0x72, 0x74, 0x54, 0x61, 0x67,
|
0x61, 0x6d, 0x65, 0x22, 0x38, 0x0a, 0x11, 0x55, 0x70, 0x73, 0x65, 0x72, 0x74, 0x54, 0x61, 0x67,
|
||||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18,
|
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18,
|
||||||
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70,
|
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70,
|
||||||
0x69, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x2b, 0x0a,
|
0x69, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x25, 0x0a,
|
||||||
0x0f, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
0x0f, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||||
0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||||
0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x39, 0x0a, 0x10, 0x4c, 0x69,
|
0x75, 0x73, 0x65, 0x72, 0x22, 0x39, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73,
|
||||||
0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25,
|
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73,
|
||||||
0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d,
|
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61,
|
||||||
0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52,
|
0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x22,
|
||||||
0x04, 0x74, 0x61, 0x67, 0x73, 0x22, 0x37, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54,
|
0x37, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75,
|
||||||
0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x03, 0x74, 0x61, 0x67,
|
0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61,
|
0x32, 0x11, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e,
|
||||||
0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x13,
|
0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x13, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65,
|
||||||
0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
0x74, 0x65, 0x54, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x0a,
|
||||||
0x6e, 0x73, 0x65, 0x32, 0xb5, 0x02, 0x0a, 0x0a, 0x54, 0x61, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69,
|
0x18, 0x47, 0x65, 0x74, 0x54, 0x61, 0x67, 0x53, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f,
|
||||||
0x63, 0x65, 0x12, 0x62, 0x0a, 0x09, 0x55, 0x70, 0x73, 0x65, 0x72, 0x74, 0x54, 0x61, 0x67, 0x12,
|
0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65,
|
||||||
0x1e, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55,
|
0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x2f, 0x0a,
|
||||||
0x70, 0x73, 0x65, 0x72, 0x74, 0x54, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
0x19, 0x47, 0x65, 0x74, 0x54, 0x61, 0x67, 0x53, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f,
|
||||||
0x1f, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55,
|
0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61,
|
||||||
0x70, 0x73, 0x65, 0x72, 0x74, 0x54, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x32, 0xbd,
|
||||||
0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x22, 0x0c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
|
0x03, 0x0a, 0x0a, 0x54, 0x61, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a,
|
||||||
0x32, 0x2f, 0x74, 0x61, 0x67, 0x73, 0x12, 0x5f, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61,
|
0x09, 0x55, 0x70, 0x73, 0x65, 0x72, 0x74, 0x54, 0x61, 0x67, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x6d,
|
||||||
0x67, 0x73, 0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76,
|
0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x73, 0x65, 0x72, 0x74,
|
||||||
0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
0x54, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6d, 0x65, 0x6d,
|
||||||
0x74, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32,
|
0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x73, 0x65, 0x72, 0x74,
|
||||||
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
0x54, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4,
|
||||||
0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x12, 0x0c, 0x2f, 0x61, 0x70, 0x69, 0x2f,
|
0x93, 0x02, 0x0e, 0x22, 0x0c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x74, 0x61, 0x67,
|
||||||
0x76, 0x32, 0x2f, 0x74, 0x61, 0x67, 0x73, 0x12, 0x62, 0x0a, 0x09, 0x44, 0x65, 0x6c, 0x65, 0x74,
|
0x73, 0x12, 0x5f, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x67, 0x73, 0x12, 0x1d, 0x2e,
|
||||||
0x65, 0x54, 0x61, 0x67, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,
|
0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73,
|
||||||
0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x67, 0x52, 0x65, 0x71,
|
0x74, 0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6d,
|
||||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,
|
0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74,
|
||||||
0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x67, 0x52, 0x65, 0x73,
|
0x54, 0x61, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3,
|
||||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x2a, 0x0c, 0x2f,
|
0xe4, 0x93, 0x02, 0x0e, 0x12, 0x0c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x74, 0x61,
|
||||||
0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x74, 0x61, 0x67, 0x73, 0x42, 0xa7, 0x01, 0x0a, 0x10,
|
0x67, 0x73, 0x12, 0x62, 0x0a, 0x09, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x67, 0x12,
|
||||||
0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32,
|
0x1e, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44,
|
||||||
0x42, 0x0f, 0x54, 0x61, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74,
|
0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||||
0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
0x1f, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44,
|
||||||
0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70,
|
0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b,
|
0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x2a, 0x0c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
|
||||||
0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65,
|
0x32, 0x2f, 0x74, 0x61, 0x67, 0x73, 0x12, 0x85, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x54, 0x61,
|
||||||
0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d,
|
0x67, 0x53, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x2e, 0x6d,
|
||||||
0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f,
|
0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x54,
|
||||||
0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
|
0x61, 0x67, 0x53, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71,
|
||||||
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70,
|
0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,
|
||||||
0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x61, 0x67, 0x53, 0x75, 0x67, 0x67, 0x65, 0x73,
|
||||||
|
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x82,
|
||||||
|
0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x74,
|
||||||
|
0x61, 0x67, 0x73, 0x2f, 0x73, 0x75, 0x67, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xa7,
|
||||||
|
0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,
|
||||||
|
0x2e, 0x76, 0x32, 0x42, 0x0f, 0x54, 0x61, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50,
|
||||||
|
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 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, 0x2f,
|
||||||
|
0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02,
|
||||||
|
0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c,
|
||||||
|
0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, 0x4d,
|
||||||
|
0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d,
|
||||||
|
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a,
|
||||||
|
0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -426,7 +536,7 @@ func file_api_v2_tag_service_proto_rawDescGZIP() []byte {
|
|||||||
return file_api_v2_tag_service_proto_rawDescData
|
return file_api_v2_tag_service_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_api_v2_tag_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
var file_api_v2_tag_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||||
var file_api_v2_tag_service_proto_goTypes = []interface{}{
|
var file_api_v2_tag_service_proto_goTypes = []interface{}{
|
||||||
(*Tag)(nil), // 0: memos.api.v2.Tag
|
(*Tag)(nil), // 0: memos.api.v2.Tag
|
||||||
(*UpsertTagRequest)(nil), // 1: memos.api.v2.UpsertTagRequest
|
(*UpsertTagRequest)(nil), // 1: memos.api.v2.UpsertTagRequest
|
||||||
@ -435,6 +545,8 @@ var file_api_v2_tag_service_proto_goTypes = []interface{}{
|
|||||||
(*ListTagsResponse)(nil), // 4: memos.api.v2.ListTagsResponse
|
(*ListTagsResponse)(nil), // 4: memos.api.v2.ListTagsResponse
|
||||||
(*DeleteTagRequest)(nil), // 5: memos.api.v2.DeleteTagRequest
|
(*DeleteTagRequest)(nil), // 5: memos.api.v2.DeleteTagRequest
|
||||||
(*DeleteTagResponse)(nil), // 6: memos.api.v2.DeleteTagResponse
|
(*DeleteTagResponse)(nil), // 6: memos.api.v2.DeleteTagResponse
|
||||||
|
(*GetTagSuggestionsRequest)(nil), // 7: memos.api.v2.GetTagSuggestionsRequest
|
||||||
|
(*GetTagSuggestionsResponse)(nil), // 8: memos.api.v2.GetTagSuggestionsResponse
|
||||||
}
|
}
|
||||||
var file_api_v2_tag_service_proto_depIdxs = []int32{
|
var file_api_v2_tag_service_proto_depIdxs = []int32{
|
||||||
0, // 0: memos.api.v2.UpsertTagResponse.tag:type_name -> memos.api.v2.Tag
|
0, // 0: memos.api.v2.UpsertTagResponse.tag:type_name -> memos.api.v2.Tag
|
||||||
@ -443,11 +555,13 @@ var file_api_v2_tag_service_proto_depIdxs = []int32{
|
|||||||
1, // 3: memos.api.v2.TagService.UpsertTag:input_type -> memos.api.v2.UpsertTagRequest
|
1, // 3: memos.api.v2.TagService.UpsertTag:input_type -> memos.api.v2.UpsertTagRequest
|
||||||
3, // 4: memos.api.v2.TagService.ListTags:input_type -> memos.api.v2.ListTagsRequest
|
3, // 4: memos.api.v2.TagService.ListTags:input_type -> memos.api.v2.ListTagsRequest
|
||||||
5, // 5: memos.api.v2.TagService.DeleteTag:input_type -> memos.api.v2.DeleteTagRequest
|
5, // 5: memos.api.v2.TagService.DeleteTag:input_type -> memos.api.v2.DeleteTagRequest
|
||||||
2, // 6: memos.api.v2.TagService.UpsertTag:output_type -> memos.api.v2.UpsertTagResponse
|
7, // 6: memos.api.v2.TagService.GetTagSuggestions:input_type -> memos.api.v2.GetTagSuggestionsRequest
|
||||||
4, // 7: memos.api.v2.TagService.ListTags:output_type -> memos.api.v2.ListTagsResponse
|
2, // 7: memos.api.v2.TagService.UpsertTag:output_type -> memos.api.v2.UpsertTagResponse
|
||||||
6, // 8: memos.api.v2.TagService.DeleteTag:output_type -> memos.api.v2.DeleteTagResponse
|
4, // 8: memos.api.v2.TagService.ListTags:output_type -> memos.api.v2.ListTagsResponse
|
||||||
6, // [6:9] is the sub-list for method output_type
|
6, // 9: memos.api.v2.TagService.DeleteTag:output_type -> memos.api.v2.DeleteTagResponse
|
||||||
3, // [3:6] is the sub-list for method input_type
|
8, // 10: memos.api.v2.TagService.GetTagSuggestions:output_type -> memos.api.v2.GetTagSuggestionsResponse
|
||||||
|
7, // [7:11] is the sub-list for method output_type
|
||||||
|
3, // [3:7] is the sub-list for method input_type
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
3, // [3:3] is the sub-list for extension type_name
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
3, // [3:3] is the sub-list for extension extendee
|
||||||
0, // [0:3] is the sub-list for field type_name
|
0, // [0:3] is the sub-list for field type_name
|
||||||
@ -543,6 +657,30 @@ func file_api_v2_tag_service_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_api_v2_tag_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*GetTagSuggestionsRequest); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_api_v2_tag_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*GetTagSuggestionsResponse); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
@ -550,7 +688,7 @@ func file_api_v2_tag_service_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_api_v2_tag_service_proto_rawDesc,
|
RawDescriptor: file_api_v2_tag_service_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 7,
|
NumMessages: 9,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
@ -139,6 +139,42 @@ func local_request_TagService_DeleteTag_0(ctx context.Context, marshaler runtime
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
filter_TagService_GetTagSuggestions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
|
)
|
||||||
|
|
||||||
|
func request_TagService_GetTagSuggestions_0(ctx context.Context, marshaler runtime.Marshaler, client TagServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetTagSuggestionsRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TagService_GetTagSuggestions_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.GetTagSuggestions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_TagService_GetTagSuggestions_0(ctx context.Context, marshaler runtime.Marshaler, server TagServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetTagSuggestionsRequest
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
if err := req.ParseForm(); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TagService_GetTagSuggestions_0); err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.GetTagSuggestions(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterTagServiceHandlerServer registers the http handlers for service TagService to "mux".
|
// RegisterTagServiceHandlerServer registers the http handlers for service TagService to "mux".
|
||||||
// UnaryRPC :call TagServiceServer directly.
|
// UnaryRPC :call TagServiceServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
@ -220,6 +256,31 @@ func RegisterTagServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux,
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_TagService_GetTagSuggestions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.TagService/GetTagSuggestions", runtime.WithHTTPPathPattern("/api/v2/tags/suggestion"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_TagService_GetTagSuggestions_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_TagService_GetTagSuggestions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +388,28 @@ func RegisterTagServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux,
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_TagService_GetTagSuggestions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.TagService/GetTagSuggestions", runtime.WithHTTPPathPattern("/api/v2/tags/suggestion"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_TagService_GetTagSuggestions_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_TagService_GetTagSuggestions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,6 +419,8 @@ var (
|
|||||||
pattern_TagService_ListTags_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "tags"}, ""))
|
pattern_TagService_ListTags_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "tags"}, ""))
|
||||||
|
|
||||||
pattern_TagService_DeleteTag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "tags"}, ""))
|
pattern_TagService_DeleteTag_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "tags"}, ""))
|
||||||
|
|
||||||
|
pattern_TagService_GetTagSuggestions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v2", "tags", "suggestion"}, ""))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -344,4 +429,6 @@ var (
|
|||||||
forward_TagService_ListTags_0 = runtime.ForwardResponseMessage
|
forward_TagService_ListTags_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_TagService_DeleteTag_0 = runtime.ForwardResponseMessage
|
forward_TagService_DeleteTag_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_TagService_GetTagSuggestions_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
@ -22,6 +22,7 @@ const (
|
|||||||
TagService_UpsertTag_FullMethodName = "/memos.api.v2.TagService/UpsertTag"
|
TagService_UpsertTag_FullMethodName = "/memos.api.v2.TagService/UpsertTag"
|
||||||
TagService_ListTags_FullMethodName = "/memos.api.v2.TagService/ListTags"
|
TagService_ListTags_FullMethodName = "/memos.api.v2.TagService/ListTags"
|
||||||
TagService_DeleteTag_FullMethodName = "/memos.api.v2.TagService/DeleteTag"
|
TagService_DeleteTag_FullMethodName = "/memos.api.v2.TagService/DeleteTag"
|
||||||
|
TagService_GetTagSuggestions_FullMethodName = "/memos.api.v2.TagService/GetTagSuggestions"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TagServiceClient is the client API for TagService service.
|
// TagServiceClient is the client API for TagService service.
|
||||||
@ -31,6 +32,7 @@ type TagServiceClient interface {
|
|||||||
UpsertTag(ctx context.Context, in *UpsertTagRequest, opts ...grpc.CallOption) (*UpsertTagResponse, error)
|
UpsertTag(ctx context.Context, in *UpsertTagRequest, opts ...grpc.CallOption) (*UpsertTagResponse, error)
|
||||||
ListTags(ctx context.Context, in *ListTagsRequest, opts ...grpc.CallOption) (*ListTagsResponse, error)
|
ListTags(ctx context.Context, in *ListTagsRequest, opts ...grpc.CallOption) (*ListTagsResponse, error)
|
||||||
DeleteTag(ctx context.Context, in *DeleteTagRequest, opts ...grpc.CallOption) (*DeleteTagResponse, error)
|
DeleteTag(ctx context.Context, in *DeleteTagRequest, opts ...grpc.CallOption) (*DeleteTagResponse, error)
|
||||||
|
GetTagSuggestions(ctx context.Context, in *GetTagSuggestionsRequest, opts ...grpc.CallOption) (*GetTagSuggestionsResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type tagServiceClient struct {
|
type tagServiceClient struct {
|
||||||
@ -68,6 +70,15 @@ func (c *tagServiceClient) DeleteTag(ctx context.Context, in *DeleteTagRequest,
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *tagServiceClient) GetTagSuggestions(ctx context.Context, in *GetTagSuggestionsRequest, opts ...grpc.CallOption) (*GetTagSuggestionsResponse, error) {
|
||||||
|
out := new(GetTagSuggestionsResponse)
|
||||||
|
err := c.cc.Invoke(ctx, TagService_GetTagSuggestions_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// TagServiceServer is the server API for TagService service.
|
// TagServiceServer is the server API for TagService service.
|
||||||
// All implementations must embed UnimplementedTagServiceServer
|
// All implementations must embed UnimplementedTagServiceServer
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
@ -75,6 +86,7 @@ type TagServiceServer interface {
|
|||||||
UpsertTag(context.Context, *UpsertTagRequest) (*UpsertTagResponse, error)
|
UpsertTag(context.Context, *UpsertTagRequest) (*UpsertTagResponse, error)
|
||||||
ListTags(context.Context, *ListTagsRequest) (*ListTagsResponse, error)
|
ListTags(context.Context, *ListTagsRequest) (*ListTagsResponse, error)
|
||||||
DeleteTag(context.Context, *DeleteTagRequest) (*DeleteTagResponse, error)
|
DeleteTag(context.Context, *DeleteTagRequest) (*DeleteTagResponse, error)
|
||||||
|
GetTagSuggestions(context.Context, *GetTagSuggestionsRequest) (*GetTagSuggestionsResponse, error)
|
||||||
mustEmbedUnimplementedTagServiceServer()
|
mustEmbedUnimplementedTagServiceServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +103,9 @@ func (UnimplementedTagServiceServer) ListTags(context.Context, *ListTagsRequest)
|
|||||||
func (UnimplementedTagServiceServer) DeleteTag(context.Context, *DeleteTagRequest) (*DeleteTagResponse, error) {
|
func (UnimplementedTagServiceServer) DeleteTag(context.Context, *DeleteTagRequest) (*DeleteTagResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteTag not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method DeleteTag not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedTagServiceServer) GetTagSuggestions(context.Context, *GetTagSuggestionsRequest) (*GetTagSuggestionsResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetTagSuggestions not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedTagServiceServer) mustEmbedUnimplementedTagServiceServer() {}
|
func (UnimplementedTagServiceServer) mustEmbedUnimplementedTagServiceServer() {}
|
||||||
|
|
||||||
// UnsafeTagServiceServer may be embedded to opt out of forward compatibility for this service.
|
// UnsafeTagServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||||
@ -158,6 +173,24 @@ func _TagService_DeleteTag_Handler(srv interface{}, ctx context.Context, dec fun
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _TagService_GetTagSuggestions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetTagSuggestionsRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(TagServiceServer).GetTagSuggestions(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: TagService_GetTagSuggestions_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(TagServiceServer).GetTagSuggestions(ctx, req.(*GetTagSuggestionsRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
// TagService_ServiceDesc is the grpc.ServiceDesc for TagService service.
|
// TagService_ServiceDesc is the grpc.ServiceDesc for TagService service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
@ -177,6 +210,10 @@ var TagService_ServiceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "DeleteTag",
|
MethodName: "DeleteTag",
|
||||||
Handler: _TagService_DeleteTag_Handler,
|
Handler: _TagService_DeleteTag_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetTagSuggestions",
|
||||||
|
Handler: _TagService_GetTagSuggestions_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "api/v2/tag_service.proto",
|
Metadata: "api/v2/tag_service.proto",
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Button, Input } from "@mui/joy";
|
import { Button, Input } from "@mui/joy";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { getTagSuggestionList } from "@/helpers/api";
|
import { tagServiceClient } from "@/grpcweb";
|
||||||
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { matcher } from "@/labs/marked/matcher";
|
import { matcher } from "@/labs/marked/matcher";
|
||||||
import Tag from "@/labs/marked/parser/Tag";
|
import Tag from "@/labs/marked/parser/Tag";
|
||||||
import { useTagStore } from "@/store/module";
|
import { useTagStore } from "@/store/module";
|
||||||
@ -22,8 +23,9 @@ const validateTagName = (tagName: string): boolean => {
|
|||||||
|
|
||||||
const CreateTagDialog: React.FC<Props> = (props: Props) => {
|
const CreateTagDialog: React.FC<Props> = (props: Props) => {
|
||||||
const { destroy } = props;
|
const { destroy } = props;
|
||||||
const tagStore = useTagStore();
|
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
|
const currentUser = useCurrentUser();
|
||||||
|
const tagStore = useTagStore();
|
||||||
const [tagName, setTagName] = useState<string>("");
|
const [tagName, setTagName] = useState<string>("");
|
||||||
const [suggestTagNameList, setSuggestTagNameList] = useState<string[]>([]);
|
const [suggestTagNameList, setSuggestTagNameList] = useState<string[]>([]);
|
||||||
const [showTagSuggestions, setShowTagSuggestions] = useState<boolean>(false);
|
const [showTagSuggestions, setShowTagSuggestions] = useState<boolean>(false);
|
||||||
@ -31,8 +33,12 @@ const CreateTagDialog: React.FC<Props> = (props: Props) => {
|
|||||||
const shownSuggestTagNameList = suggestTagNameList.filter((tag) => !tagNameList.includes(tag));
|
const shownSuggestTagNameList = suggestTagNameList.filter((tag) => !tagNameList.includes(tag));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getTagSuggestionList().then(({ data }) => {
|
tagServiceClient
|
||||||
setSuggestTagNameList(data.filter((tag) => validateTagName(tag)));
|
.getTagSuggestions({
|
||||||
|
user: currentUser.name,
|
||||||
|
})
|
||||||
|
.then(({ tags }) => {
|
||||||
|
setSuggestTagNameList(tags.filter((tag) => validateTagName(tag)));
|
||||||
});
|
});
|
||||||
}, [tagNameList]);
|
}, [tagNameList]);
|
||||||
|
|
||||||
|
@ -144,10 +144,6 @@ export function createResourceWithBlob(formData: FormData) {
|
|||||||
return axios.post<Resource>("/api/v1/resource/blob", formData);
|
return axios.post<Resource>("/api/v1/resource/blob", formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTagSuggestionList() {
|
|
||||||
return axios.get<string[]>(`/api/v1/tag/suggestion`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getStorageList() {
|
export function getStorageList() {
|
||||||
return axios.get<ObjectStorage[]>(`/api/v1/storage`);
|
return axios.get<ObjectStorage[]>(`/api/v1/storage`);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ export const useTagStore = () => {
|
|||||||
|
|
||||||
const fetchTags = async () => {
|
const fetchTags = async () => {
|
||||||
const { tags } = await tagServiceClient.listTags({
|
const { tags } = await tagServiceClient.listTags({
|
||||||
creator: currentUser.name,
|
user: currentUser.name,
|
||||||
});
|
});
|
||||||
store.dispatch(setTags(tags.map((tag) => tag.name)));
|
store.dispatch(setTags(tags.map((tag) => tag.name)));
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user