Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: update resource service
Steven7dc4bc571416
diff --git a/api/v1/resource.go b/api/v1/resource.goindex f8ae3d177..3d551640c 100644--- a/api/v1/resource.go+++ b/api/v1/resource.go@@ -47,7 +47,6 @@ type Resource struct {type CreateResourceRequest struct {Filename string `json:"filename"`- InternalPath string `json:"internalPath"`ExternalLink string `json:"externalLink"`Type string `json:"type"`}diff --git a/api/v2/resource_service.go b/api/v2/resource_service.goindex 9daf0fb11..3c550767e 100644--- a/api/v2/resource_service.go+++ b/api/v2/resource_service.go@@ -44,6 +44,29 @@ func (s *ResourceService) ListResources(ctx context.Context, _ *apiv2pb.ListResoreturn response, nil}+func (s *ResourceService) UpdateResource(ctx context.Context, request *apiv2pb.UpdateResourceRequest) (*apiv2pb.UpdateResourceResponse, error) {+ currentTs := time.Now().Unix()+ update := &store.UpdateResource{+ ID: request.Id,+ UpdatedTs: ¤tTs,+ }+ for _, field := range request.UpdateMask {+ if field == "filename" {+ update.Filename = &request.Resource.Filename+ } else if field == "memo_id" {+ update.MemoID = request.Resource.MemoId+ }+ }++ resource, err := s.Store.UpdateResource(ctx, update)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to update resource: %v", err)+ }+ return &apiv2pb.UpdateResourceResponse{+ Resource: convertResourceFromStore(resource),+ }, nil+}+func (s *ResourceService) DeleteResource(ctx context.Context, request *apiv2pb.DeleteResourceRequest) (*apiv2pb.DeleteResourceResponse, error) {user, err := getCurrentUser(ctx, s.Store)if err != nil {diff --git a/api/v2/user_service.go b/api/v2/user_service.goindex 474af0339..ae1d94837 100644--- a/api/v2/user_service.go+++ b/api/v2/user_service.go@@ -76,33 +76,33 @@ func (s *UserService) UpdateUser(ctx context.Context, request *apiv2pb.UpdateUseID: currentUser.ID,UpdatedTs: ¤tTs,}- for _, path := range request.UpdateMask {- if path == "username" {+ for _, field := range request.UpdateMask {+ if field == "username" {if !usernameMatcher.MatchString(strings.ToLower(request.User.Username)) {return nil, status.Errorf(codes.InvalidArgument, "invalid username: %s", request.User.Username)}update.Username = &request.User.Username- } else if path == "nickname" {+ } else if field == "nickname" {update.Nickname = &request.User.Nickname- } else if path == "email" {+ } else if field == "email" {update.Email = &request.User.Email- } else if path == "avatar_url" {+ } else if field == "avatar_url" {update.AvatarURL = &request.User.AvatarUrl- } else if path == "role" {+ } else if field == "role" {role := convertUserRoleToStore(request.User.Role)update.Role = &role- } else if path == "password" {+ } else if field == "password" {passwordHash, err := bcrypt.GenerateFromPassword([]byte(request.User.Password), bcrypt.DefaultCost)if err != nil {return nil, echo.NewHTTPError(http.StatusInternalServerError, "failed to generate password hash").SetInternal(err)}passwordHashStr := string(passwordHash)update.PasswordHash = &passwordHashStr- } else if path == "row_status" {+ } else if field == "row_status" {rowStatus := convertRowStatusToStore(request.User.RowStatus)update.RowStatus = &rowStatus} else {- return nil, status.Errorf(codes.InvalidArgument, "invalid update path: %s", path)+ return nil, status.Errorf(codes.InvalidArgument, "invalid update path: %s", field)}}diff --git a/proto/api/v2/resource_service.proto b/proto/api/v2/resource_service.protoindex 7500acd62..65f49cd6a 100644--- a/proto/api/v2/resource_service.proto+++ b/proto/api/v2/resource_service.proto@@ -9,9 +9,16 @@ import "google/protobuf/timestamp.proto";option go_package = "gen/api/v2";service ResourceService {+ rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) {+ option (google.api.http) = {post: "/api/v2/resources"};+ }rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) {option (google.api.http) = {get: "/api/v2/resources"};}+ rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) {+ option (google.api.http) = {put: "/api/v2/resources/{id}"};+ option (google.api.method_signature) = "id";+ }rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) {option (google.api.http) = {get: "/api/v2/resources/{id}"};option (google.api.method_signature) = "id";@@ -28,12 +35,35 @@ message Resource {optional int32 memo_id = 7;}+message CreateResourceRequest {+ string filename = 1;+ string external_link = 2;+ string type = 3;+ optional int32 memo_id = 4;+}++message CreateResourceResponse {+ Resource resource = 1;+}+message ListResourcesRequest {}message ListResourcesResponse {repeated Resource resources = 1;}+message UpdateResourceRequest {+ int32 id = 1;++ Resource resource = 2;++ repeated string update_mask = 3;+}++message UpdateResourceResponse {+ Resource resource = 1;+}+message DeleteResourceRequest {int32 id = 1;}diff --git a/proto/gen/api/v2/README.md b/proto/gen/api/v2/README.mdindex 9421cbd29..1f9a38612 100644--- a/proto/gen/api/v2/README.md+++ b/proto/gen/api/v2/README.md@@ -24,11 +24,15 @@- [MemoService](#memos-api-v2-MemoService)- [api/v2/resource_service.proto](#api_v2_resource_service-proto)+ - [CreateResourceRequest](#memos-api-v2-CreateResourceRequest)+ - [CreateResourceResponse](#memos-api-v2-CreateResourceResponse)- [DeleteResourceRequest](#memos-api-v2-DeleteResourceRequest)- [DeleteResourceResponse](#memos-api-v2-DeleteResourceResponse)- [ListResourcesRequest](#memos-api-v2-ListResourcesRequest)- [ListResourcesResponse](#memos-api-v2-ListResourcesResponse)- [Resource](#memos-api-v2-Resource)+ - [UpdateResourceRequest](#memos-api-v2-UpdateResourceRequest)+ - [UpdateResourceResponse](#memos-api-v2-UpdateResourceResponse)- [ResourceService](#memos-api-v2-ResourceService)@@ -330,6 +334,39 @@+<a name="memos-api-v2-CreateResourceRequest"></a>++### CreateResourceRequest++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| filename | [string](#string) | | |+| external_link | [string](#string) | | |+| type | [string](#string) | | |+| memo_id | [int32](#int32) | optional | |+++++++<a name="memos-api-v2-CreateResourceResponse"></a>++### CreateResourceResponse++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| resource | [Resource](#memos-api-v2-Resource) | | |++++++<a name="memos-api-v2-DeleteResourceRequest"></a>### DeleteResourceRequest@@ -400,6 +437,38 @@++<a name="memos-api-v2-UpdateResourceRequest"></a>++### UpdateResourceRequest++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| id | [int32](#int32) | | |+| resource | [Resource](#memos-api-v2-Resource) | | |+| update_mask | [string](#string) | repeated | |+++++++<a name="memos-api-v2-UpdateResourceResponse"></a>++### UpdateResourceResponse++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| resource | [Resource](#memos-api-v2-Resource) | | |+++++@@ -414,7 +483,9 @@| Method Name | Request Type | Response Type | Description || ----------- | ------------ | ------------- | ------------|+| CreateResource | [CreateResourceRequest](#memos-api-v2-CreateResourceRequest) | [CreateResourceResponse](#memos-api-v2-CreateResourceResponse) | || ListResources | [ListResourcesRequest](#memos-api-v2-ListResourcesRequest) | [ListResourcesResponse](#memos-api-v2-ListResourcesResponse) | |+| UpdateResource | [UpdateResourceRequest](#memos-api-v2-UpdateResourceRequest) | [UpdateResourceResponse](#memos-api-v2-UpdateResourceResponse) | || DeleteResource | [DeleteResourceRequest](#memos-api-v2-DeleteResourceRequest) | [DeleteResourceResponse](#memos-api-v2-DeleteResourceResponse) | |diff --git a/proto/gen/api/v2/resource_service.pb.go b/proto/gen/api/v2/resource_service.pb.goindex 817409b80..d98b3a257 100644--- a/proto/gen/api/v2/resource_service.pb.go+++ b/proto/gen/api/v2/resource_service.pb.go@@ -117,6 +117,124 @@ func (x *Resource) GetMemoId() int32 {return 0}+type CreateResourceRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`+ ExternalLink string `protobuf:"bytes,2,opt,name=external_link,json=externalLink,proto3" json:"external_link,omitempty"`+ Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`+ MemoId *int32 `protobuf:"varint,4,opt,name=memo_id,json=memoId,proto3,oneof" json:"memo_id,omitempty"`+}++func (x *CreateResourceRequest) Reset() {+ *x = CreateResourceRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_api_v2_resource_service_proto_msgTypes[1]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *CreateResourceRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*CreateResourceRequest) ProtoMessage() {}++func (x *CreateResourceRequest) ProtoReflect() protoreflect.Message {+ mi := &file_api_v2_resource_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 CreateResourceRequest.ProtoReflect.Descriptor instead.+func (*CreateResourceRequest) Descriptor() ([]byte, []int) {+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{1}+}++func (x *CreateResourceRequest) GetFilename() string {+ if x != nil {+ return x.Filename+ }+ return ""+}++func (x *CreateResourceRequest) GetExternalLink() string {+ if x != nil {+ return x.ExternalLink+ }+ return ""+}++func (x *CreateResourceRequest) GetType() string {+ if x != nil {+ return x.Type+ }+ return ""+}++func (x *CreateResourceRequest) GetMemoId() int32 {+ if x != nil && x.MemoId != nil {+ return *x.MemoId+ }+ return 0+}++type CreateResourceResponse struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`+}++func (x *CreateResourceResponse) Reset() {+ *x = CreateResourceResponse{}+ if protoimpl.UnsafeEnabled {+ mi := &file_api_v2_resource_service_proto_msgTypes[2]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *CreateResourceResponse) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*CreateResourceResponse) ProtoMessage() {}++func (x *CreateResourceResponse) ProtoReflect() protoreflect.Message {+ mi := &file_api_v2_resource_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 CreateResourceResponse.ProtoReflect.Descriptor instead.+func (*CreateResourceResponse) Descriptor() ([]byte, []int) {+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{2}+}++func (x *CreateResourceResponse) GetResource() *Resource {+ if x != nil {+ return x.Resource+ }+ return nil+}+type ListResourcesRequest struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -126,7 +244,7 @@ type ListResourcesRequest struct {func (x *ListResourcesRequest) Reset() {*x = ListResourcesRequest{}if protoimpl.UnsafeEnabled {- mi := &file_api_v2_resource_service_proto_msgTypes[1]+ mi := &file_api_v2_resource_service_proto_msgTypes[3]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -139,7 +257,7 @@ func (x *ListResourcesRequest) String() string {func (*ListResourcesRequest) ProtoMessage() {}func (x *ListResourcesRequest) ProtoReflect() protoreflect.Message {- mi := &file_api_v2_resource_service_proto_msgTypes[1]+ mi := &file_api_v2_resource_service_proto_msgTypes[3]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -152,7 +270,7 @@ func (x *ListResourcesRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use ListResourcesRequest.ProtoReflect.Descriptor instead.func (*ListResourcesRequest) Descriptor() ([]byte, []int) {- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{1}+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{3}}type ListResourcesResponse struct {@@ -166,7 +284,7 @@ type ListResourcesResponse struct {func (x *ListResourcesResponse) Reset() {*x = ListResourcesResponse{}if protoimpl.UnsafeEnabled {- mi := &file_api_v2_resource_service_proto_msgTypes[2]+ mi := &file_api_v2_resource_service_proto_msgTypes[4]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -179,7 +297,7 @@ func (x *ListResourcesResponse) String() string {func (*ListResourcesResponse) ProtoMessage() {}func (x *ListResourcesResponse) ProtoReflect() protoreflect.Message {- mi := &file_api_v2_resource_service_proto_msgTypes[2]+ mi := &file_api_v2_resource_service_proto_msgTypes[4]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -192,7 +310,7 @@ func (x *ListResourcesResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use ListResourcesResponse.ProtoReflect.Descriptor instead.func (*ListResourcesResponse) Descriptor() ([]byte, []int) {- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{2}+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{4}}func (x *ListResourcesResponse) GetResources() []*Resource {@@ -202,6 +320,116 @@ func (x *ListResourcesResponse) GetResources() []*Resource {return nil}+type UpdateResourceRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`+ Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"`+ UpdateMask []string `protobuf:"bytes,3,rep,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`+}++func (x *UpdateResourceRequest) Reset() {+ *x = UpdateResourceRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_api_v2_resource_service_proto_msgTypes[5]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *UpdateResourceRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UpdateResourceRequest) ProtoMessage() {}++func (x *UpdateResourceRequest) ProtoReflect() protoreflect.Message {+ mi := &file_api_v2_resource_service_proto_msgTypes[5]+ 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 UpdateResourceRequest.ProtoReflect.Descriptor instead.+func (*UpdateResourceRequest) Descriptor() ([]byte, []int) {+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{5}+}++func (x *UpdateResourceRequest) GetId() int32 {+ if x != nil {+ return x.Id+ }+ return 0+}++func (x *UpdateResourceRequest) GetResource() *Resource {+ if x != nil {+ return x.Resource+ }+ return nil+}++func (x *UpdateResourceRequest) GetUpdateMask() []string {+ if x != nil {+ return x.UpdateMask+ }+ return nil+}++type UpdateResourceResponse struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`+}++func (x *UpdateResourceResponse) Reset() {+ *x = UpdateResourceResponse{}+ if protoimpl.UnsafeEnabled {+ mi := &file_api_v2_resource_service_proto_msgTypes[6]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *UpdateResourceResponse) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UpdateResourceResponse) ProtoMessage() {}++func (x *UpdateResourceResponse) ProtoReflect() protoreflect.Message {+ mi := &file_api_v2_resource_service_proto_msgTypes[6]+ 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 UpdateResourceResponse.ProtoReflect.Descriptor instead.+func (*UpdateResourceResponse) Descriptor() ([]byte, []int) {+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{6}+}++func (x *UpdateResourceResponse) GetResource() *Resource {+ if x != nil {+ return x.Resource+ }+ return nil+}+type DeleteResourceRequest struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -213,7 +441,7 @@ type DeleteResourceRequest struct {func (x *DeleteResourceRequest) Reset() {*x = DeleteResourceRequest{}if protoimpl.UnsafeEnabled {- mi := &file_api_v2_resource_service_proto_msgTypes[3]+ mi := &file_api_v2_resource_service_proto_msgTypes[7]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -226,7 +454,7 @@ func (x *DeleteResourceRequest) String() string {func (*DeleteResourceRequest) ProtoMessage() {}func (x *DeleteResourceRequest) ProtoReflect() protoreflect.Message {- mi := &file_api_v2_resource_service_proto_msgTypes[3]+ mi := &file_api_v2_resource_service_proto_msgTypes[7]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -239,7 +467,7 @@ func (x *DeleteResourceRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use DeleteResourceRequest.ProtoReflect.Descriptor instead.func (*DeleteResourceRequest) Descriptor() ([]byte, []int) {- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{3}+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{7}}func (x *DeleteResourceRequest) GetId() int32 {@@ -258,7 +486,7 @@ type DeleteResourceResponse struct {func (x *DeleteResourceResponse) Reset() {*x = DeleteResourceResponse{}if protoimpl.UnsafeEnabled {- mi := &file_api_v2_resource_service_proto_msgTypes[4]+ mi := &file_api_v2_resource_service_proto_msgTypes[8]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -271,7 +499,7 @@ func (x *DeleteResourceResponse) String() string {func (*DeleteResourceResponse) ProtoMessage() {}func (x *DeleteResourceResponse) ProtoReflect() protoreflect.Message {- mi := &file_api_v2_resource_service_proto_msgTypes[4]+ mi := &file_api_v2_resource_service_proto_msgTypes[8]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -284,7 +512,7 @@ func (x *DeleteResourceResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use DeleteResourceResponse.ProtoReflect.Descriptor instead.func (*DeleteResourceResponse) Descriptor() ([]byte, []int) {- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{4}+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{8}}var File_api_v2_resource_service_proto protoreflect.FileDescriptor@@ -313,45 +541,88 @@ var file_api_v2_resource_service_proto_rawDesc = []byte{0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69,0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x49,0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, 0x64,- 0x22, 0x16, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,- 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4d, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74,- 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,- 0x65, 0x12, 0x34, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01,- 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,- 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65,- 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x27, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74,- 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,- 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64,- 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72,- 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x89, 0x02, 0x0a, 0x0f, 0x52,- 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x73,- 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12,- 0x22, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c,- 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75,- 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e,- 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73,- 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13,- 0x12, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,- 0x63, 0x65, 0x73, 0x12, 0x80, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65,- 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61,- 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f,- 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65,- 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,- 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,- 0x65, 0x22, 0x23, 0xda, 0x41, 0x02, 0x69, 0x64, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16,- 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,- 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xac, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d,- 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x14, 0x52, 0x65, 0x73,- 0x6f, 0x75, 0x72, 0x63, 0x65, 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,+ 0x22, 0x96, 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75,+ 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69,+ 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69,+ 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e,+ 0x61, 0x6c, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65,+ 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x74,+ 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,+ 0x1c, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05,+ 0x48, 0x00, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a,+ 0x08, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x5f, 0x69, 0x64, 0x22, 0x4c, 0x0a, 0x16, 0x43, 0x72, 0x65,+ 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,+ 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18,+ 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70,+ 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72,+ 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x16, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x52,+ 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22,+ 0x4d, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73,+ 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f,+ 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65,+ 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75,+ 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x7c,+ 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,+ 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75,+ 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f,+ 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,+ 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x75,+ 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09,+ 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x4c, 0x0a, 0x16,+ 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65,+ 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,+ 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73,+ 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,+ 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x27, 0x0a, 0x15, 0x44, 0x65,+ 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75,+ 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,+ 0x02, 0x69, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73,+ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x84, 0x04,+ 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,+ 0x65, 0x12, 0x76, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75,+ 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e,+ 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,+ 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73,+ 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65,+ 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19,+ 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f,+ 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x73, 0x0a, 0x0d, 0x4c, 0x69, 0x73,+ 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x22, 0x2e, 0x6d, 0x65, 0x6d,+ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,+ 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23,+ 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69,+ 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,+ 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x61, 0x70,+ 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x80,+ 0x01, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,+ 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32,+ 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61,+ 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f,+ 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0xda, 0x41,+ 0x02, 0x69, 0x64, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x1a, 0x16, 0x2f, 0x61, 0x70, 0x69, 0x2f,+ 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64,+ 0x7d, 0x12, 0x80, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f,+ 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,+ 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72,+ 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f,+ 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,+ 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,+ 0x23, 0xda, 0x41, 0x02, 0x69, 0x64, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16, 0x2f, 0x61,+ 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f,+ 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xac, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d,+ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x14, 0x52, 0x65, 0x73, 0x6f, 0x75,+ 0x72, 0x63, 0x65, 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 (@@ -366,27 +637,38 @@ func file_api_v2_resource_service_proto_rawDescGZIP() []byte {return file_api_v2_resource_service_proto_rawDescData}-var file_api_v2_resource_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)+var file_api_v2_resource_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)var file_api_v2_resource_service_proto_goTypes = []interface{}{(*Resource)(nil), // 0: memos.api.v2.Resource- (*ListResourcesRequest)(nil), // 1: memos.api.v2.ListResourcesRequest- (*ListResourcesResponse)(nil), // 2: memos.api.v2.ListResourcesResponse- (*DeleteResourceRequest)(nil), // 3: memos.api.v2.DeleteResourceRequest- (*DeleteResourceResponse)(nil), // 4: memos.api.v2.DeleteResourceResponse- (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp+ (*CreateResourceRequest)(nil), // 1: memos.api.v2.CreateResourceRequest+ (*CreateResourceResponse)(nil), // 2: memos.api.v2.CreateResourceResponse+ (*ListResourcesRequest)(nil), // 3: memos.api.v2.ListResourcesRequest+ (*ListResourcesResponse)(nil), // 4: memos.api.v2.ListResourcesResponse+ (*UpdateResourceRequest)(nil), // 5: memos.api.v2.UpdateResourceRequest+ (*UpdateResourceResponse)(nil), // 6: memos.api.v2.UpdateResourceResponse+ (*DeleteResourceRequest)(nil), // 7: memos.api.v2.DeleteResourceRequest+ (*DeleteResourceResponse)(nil), // 8: memos.api.v2.DeleteResourceResponse+ (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp}var file_api_v2_resource_service_proto_depIdxs = []int32{- 5, // 0: memos.api.v2.Resource.created_ts:type_name -> google.protobuf.Timestamp- 0, // 1: memos.api.v2.ListResourcesResponse.resources:type_name -> memos.api.v2.Resource- 1, // 2: memos.api.v2.ResourceService.ListResources:input_type -> memos.api.v2.ListResourcesRequest- 3, // 3: memos.api.v2.ResourceService.DeleteResource:input_type -> memos.api.v2.DeleteResourceRequest- 2, // 4: memos.api.v2.ResourceService.ListResources:output_type -> memos.api.v2.ListResourcesResponse- 4, // 5: memos.api.v2.ResourceService.DeleteResource:output_type -> memos.api.v2.DeleteResourceResponse- 4, // [4:6] is the sub-list for method output_type- 2, // [2:4] is the sub-list for method input_type- 2, // [2:2] is the sub-list for extension type_name- 2, // [2:2] is the sub-list for extension extendee- 0, // [0:2] is the sub-list for field type_name+ 9, // 0: memos.api.v2.Resource.created_ts:type_name -> google.protobuf.Timestamp+ 0, // 1: memos.api.v2.CreateResourceResponse.resource:type_name -> memos.api.v2.Resource+ 0, // 2: memos.api.v2.ListResourcesResponse.resources:type_name -> memos.api.v2.Resource+ 0, // 3: memos.api.v2.UpdateResourceRequest.resource:type_name -> memos.api.v2.Resource+ 0, // 4: memos.api.v2.UpdateResourceResponse.resource:type_name -> memos.api.v2.Resource+ 1, // 5: memos.api.v2.ResourceService.CreateResource:input_type -> memos.api.v2.CreateResourceRequest+ 3, // 6: memos.api.v2.ResourceService.ListResources:input_type -> memos.api.v2.ListResourcesRequest+ 5, // 7: memos.api.v2.ResourceService.UpdateResource:input_type -> memos.api.v2.UpdateResourceRequest+ 7, // 8: memos.api.v2.ResourceService.DeleteResource:input_type -> memos.api.v2.DeleteResourceRequest+ 2, // 9: memos.api.v2.ResourceService.CreateResource:output_type -> memos.api.v2.CreateResourceResponse+ 4, // 10: memos.api.v2.ResourceService.ListResources:output_type -> memos.api.v2.ListResourcesResponse+ 6, // 11: memos.api.v2.ResourceService.UpdateResource:output_type -> memos.api.v2.UpdateResourceResponse+ 8, // 12: memos.api.v2.ResourceService.DeleteResource:output_type -> memos.api.v2.DeleteResourceResponse+ 9, // [9:13] is the sub-list for method output_type+ 5, // [5:9] is the sub-list for method input_type+ 5, // [5:5] is the sub-list for extension type_name+ 5, // [5:5] is the sub-list for extension extendee+ 0, // [0:5] is the sub-list for field type_name}func init() { file_api_v2_resource_service_proto_init() }@@ -408,7 +690,7 @@ func file_api_v2_resource_service_proto_init() {}}file_api_v2_resource_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*ListResourcesRequest); i {+ switch v := v.(*CreateResourceRequest); i {case 0:return &v.statecase 1:@@ -420,7 +702,7 @@ func file_api_v2_resource_service_proto_init() {}}file_api_v2_resource_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*ListResourcesResponse); i {+ switch v := v.(*CreateResourceResponse); i {case 0:return &v.statecase 1:@@ -432,7 +714,7 @@ func file_api_v2_resource_service_proto_init() {}}file_api_v2_resource_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*DeleteResourceRequest); i {+ switch v := v.(*ListResourcesRequest); i {case 0:return &v.statecase 1:@@ -444,6 +726,54 @@ func file_api_v2_resource_service_proto_init() {}}file_api_v2_resource_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*ListResourcesResponse); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_api_v2_resource_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*UpdateResourceRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_api_v2_resource_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*UpdateResourceResponse); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_api_v2_resource_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*DeleteResourceRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_api_v2_resource_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {switch v := v.(*DeleteResourceResponse); i {case 0:return &v.state@@ -457,13 +787,14 @@ func file_api_v2_resource_service_proto_init() {}}file_api_v2_resource_service_proto_msgTypes[0].OneofWrappers = []interface{}{}+ file_api_v2_resource_service_proto_msgTypes[1].OneofWrappers = []interface{}{}type x struct{}out := protoimpl.TypeBuilder{File: protoimpl.DescBuilder{GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: file_api_v2_resource_service_proto_rawDesc,NumEnums: 0,- NumMessages: 5,+ NumMessages: 9,NumExtensions: 0,NumServices: 1,},diff --git a/proto/gen/api/v2/resource_service.pb.gw.go b/proto/gen/api/v2/resource_service.pb.gw.goindex 63d3dcaa4..33de59c82 100644--- a/proto/gen/api/v2/resource_service.pb.gw.go+++ b/proto/gen/api/v2/resource_service.pb.gw.go@@ -31,6 +31,42 @@ var _ = runtime.Stringvar _ = utilities.NewDoubleArrayvar _ = metadata.Join+var (+ filter_ResourceService_CreateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}+)++func request_ResourceService_CreateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq CreateResourceRequest+ 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_ResourceService_CreateResource_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := client.CreateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_ResourceService_CreateResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq CreateResourceRequest+ 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_ResourceService_CreateResource_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := server.CreateResource(ctx, &protoReq)+ return msg, metadata, err++}+func request_ResourceService_ListResources_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {var protoReq ListResourcesRequestvar metadata runtime.ServerMetadata@@ -49,6 +85,76 @@ func local_request_ResourceService_ListResources_0(ctx context.Context, marshale}+var (+ filter_ResourceService_UpdateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}}+)++func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UpdateResourceRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["id"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")+ }++ protoReq.Id, err = runtime.Int32(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := client.UpdateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UpdateResourceRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["id"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")+ }++ protoReq.Id, err = runtime.Int32(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := server.UpdateResource(ctx, &protoReq)+ return msg, metadata, err++}+func request_ResourceService_DeleteResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {var protoReq DeleteResourceRequestvar metadata runtime.ServerMetadata@@ -107,6 +213,31 @@ func local_request_ResourceService_DeleteResource_0(ctx context.Context, marshal// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterResourceServiceHandlerFromEndpoint instead.func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ResourceServiceServer) error {+ mux.Handle("POST", pattern_ResourceService_CreateResource_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.ResourceService/CreateResource", runtime.WithHTTPPathPattern("/api/v2/resources"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_ResourceService_CreateResource_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_ResourceService_CreateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+mux.Handle("GET", pattern_ResourceService_ListResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -132,6 +263,31 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv})+ mux.Handle("PUT", pattern_ResourceService_UpdateResource_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.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_ResourceService_UpdateResource_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_ResourceService_UpdateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+mux.Handle("GET", pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -198,6 +354,28 @@ func RegisterResourceServiceHandler(ctx context.Context, mux *runtime.ServeMux,// "ResourceServiceClient" to call the correct interceptors.func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ResourceServiceClient) error {+ mux.Handle("POST", pattern_ResourceService_CreateResource_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.ResourceService/CreateResource", runtime.WithHTTPPathPattern("/api/v2/resources"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_ResourceService_CreateResource_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_ResourceService_CreateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+mux.Handle("GET", pattern_ResourceService_ListResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -220,6 +398,28 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv})+ mux.Handle("PUT", pattern_ResourceService_UpdateResource_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.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_ResourceService_UpdateResource_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_ResourceService_UpdateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+mux.Handle("GET", pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -246,13 +446,21 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv}var (+ pattern_ResourceService_CreateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "resources"}, ""))+pattern_ResourceService_ListResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "resources"}, ""))+ pattern_ResourceService_UpdateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "id"}, ""))+pattern_ResourceService_DeleteResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "id"}, "")))var (+ forward_ResourceService_CreateResource_0 = runtime.ForwardResponseMessage+forward_ResourceService_ListResources_0 = runtime.ForwardResponseMessage+ forward_ResourceService_UpdateResource_0 = runtime.ForwardResponseMessage+forward_ResourceService_DeleteResource_0 = runtime.ForwardResponseMessage)diff --git a/proto/gen/api/v2/resource_service_grpc.pb.go b/proto/gen/api/v2/resource_service_grpc.pb.goindex c4b0f215e..dbaf4a0a6 100644--- a/proto/gen/api/v2/resource_service_grpc.pb.go+++ b/proto/gen/api/v2/resource_service_grpc.pb.go@@ -19,7 +19,9 @@ import (const _ = grpc.SupportPackageIsVersion7const (+ ResourceService_CreateResource_FullMethodName = "/memos.api.v2.ResourceService/CreateResource"ResourceService_ListResources_FullMethodName = "/memos.api.v2.ResourceService/ListResources"+ ResourceService_UpdateResource_FullMethodName = "/memos.api.v2.ResourceService/UpdateResource"ResourceService_DeleteResource_FullMethodName = "/memos.api.v2.ResourceService/DeleteResource")@@ -27,7 +29,9 @@ const (//// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.type ResourceServiceClient interface {+ CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error)ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error)+ UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error)DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error)}@@ -39,6 +43,15 @@ func NewResourceServiceClient(cc grpc.ClientConnInterface) ResourceServiceClientreturn &resourceServiceClient{cc}}+func (c *resourceServiceClient) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) {+ out := new(CreateResourceResponse)+ err := c.cc.Invoke(ctx, ResourceService_CreateResource_FullMethodName, in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}+func (c *resourceServiceClient) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) {out := new(ListResourcesResponse)err := c.cc.Invoke(ctx, ResourceService_ListResources_FullMethodName, in, out, opts...)@@ -48,6 +61,15 @@ func (c *resourceServiceClient) ListResources(ctx context.Context, in *ListResoureturn out, nil}+func (c *resourceServiceClient) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) {+ out := new(UpdateResourceResponse)+ err := c.cc.Invoke(ctx, ResourceService_UpdateResource_FullMethodName, in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}+func (c *resourceServiceClient) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) {out := new(DeleteResourceResponse)err := c.cc.Invoke(ctx, ResourceService_DeleteResource_FullMethodName, in, out, opts...)@@ -61,7 +83,9 @@ func (c *resourceServiceClient) DeleteResource(ctx context.Context, in *DeleteRe// All implementations must embed UnimplementedResourceServiceServer// for forward compatibilitytype ResourceServiceServer interface {+ CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error)ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error)+ UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error)DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error)mustEmbedUnimplementedResourceServiceServer()}@@ -70,9 +94,15 @@ type ResourceServiceServer interface {type UnimplementedResourceServiceServer struct {}+func (UnimplementedResourceServiceServer) CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) {+ return nil, status.Errorf(codes.Unimplemented, "method CreateResource not implemented")+}func (UnimplementedResourceServiceServer) ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) {return nil, status.Errorf(codes.Unimplemented, "method ListResources not implemented")}+func (UnimplementedResourceServiceServer) UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) {+ return nil, status.Errorf(codes.Unimplemented, "method UpdateResource not implemented")+}func (UnimplementedResourceServiceServer) DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) {return nil, status.Errorf(codes.Unimplemented, "method DeleteResource not implemented")}@@ -89,6 +119,24 @@ func RegisterResourceServiceServer(s grpc.ServiceRegistrar, srv ResourceServiceSs.RegisterService(&ResourceService_ServiceDesc, srv)}+func _ResourceService_CreateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(CreateResourceRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(ResourceServiceServer).CreateResource(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: ResourceService_CreateResource_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(ResourceServiceServer).CreateResource(ctx, req.(*CreateResourceRequest))+ }+ return interceptor(ctx, in, info, handler)+}+func _ResourceService_ListResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {in := new(ListResourcesRequest)if err := dec(in); err != nil {@@ -107,6 +155,24 @@ func _ResourceService_ListResources_Handler(srv interface{}, ctx context.Contextreturn interceptor(ctx, in, info, handler)}+func _ResourceService_UpdateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(UpdateResourceRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(ResourceServiceServer).UpdateResource(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: ResourceService_UpdateResource_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(ResourceServiceServer).UpdateResource(ctx, req.(*UpdateResourceRequest))+ }+ return interceptor(ctx, in, info, handler)+}+func _ResourceService_DeleteResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {in := new(DeleteResourceRequest)if err := dec(in); err != nil {@@ -132,10 +198,18 @@ var ResourceService_ServiceDesc = grpc.ServiceDesc{ServiceName: "memos.api.v2.ResourceService",HandlerType: (*ResourceServiceServer)(nil),Methods: []grpc.MethodDesc{+ {+ MethodName: "CreateResource",+ Handler: _ResourceService_CreateResource_Handler,+ },{MethodName: "ListResources",Handler: _ResourceService_ListResources_Handler,},+ {+ MethodName: "UpdateResource",+ Handler: _ResourceService_UpdateResource_Handler,+ },{MethodName: "DeleteResource",Handler: _ResourceService_DeleteResource_Handler,diff --git a/web/src/components/ChangeResourceFilenameDialog.tsx b/web/src/components/ChangeResourceFilenameDialog.tsxdeleted file mode 100644index ffd750ca5..000000000--- a/web/src/components/ChangeResourceFilenameDialog.tsx+++ /dev/null@@ -1,100 +0,0 @@-import { useState } from "react";-import { toast } from "react-hot-toast";-import { useResourceStore } from "@/store/module";-import { useTranslate } from "@/utils/i18n";-import { generateDialog } from "./Dialog";-import Icon from "./Icon";-import "@/less/change-resource-filename-dialog.less";--interface Props extends DialogProps {- resourceId: ResourceId;- resourceFilename: string;-}--const validateFilename = (filename: string): boolean => {- if (filename.length === 0 || filename.length >= 128) {- return false;- }- const startReg = /^([+\-.]).*/;- const illegalReg = /[/@#$%^&*()[\]]/;- if (startReg.test(filename) || illegalReg.test(filename)) {- return false;- }- return true;-};--const ChangeResourceFilenameDialog: React.FC<Props> = (props: Props) => {- const { destroy, resourceId, resourceFilename } = props;- const t = useTranslate();- const resourceStore = useResourceStore();- const [filename, setFilename] = useState<string>(resourceFilename);-- const handleFilenameChanged = (e: React.ChangeEvent<HTMLInputElement>) => {- const nextUsername = e.target.value as string;- setFilename(nextUsername);- };-- const handleCloseBtnClick = () => {- destroy();- };-- const handleSaveBtnClick = async () => {- if (filename === resourceFilename) {- handleCloseBtnClick();- return;- }- if (!validateFilename(filename)) {- toast.error(t("message.invalid-resource-filename"));- return;- }- try {- await resourceStore.patchResource({- id: resourceId,- filename: filename,- });- toast.success(t("message.resource-filename-updated"));- handleCloseBtnClick();- } catch (error: any) {- console.error(error);- toast.error(error.response.data.message);- }- };-- return (- <>- <div className="dialog-header-container">- <p className="title-text">{t("message.change-resource-filename")}</p>- <button className="btn close-btn" onClick={handleCloseBtnClick}>- <Icon.X />- </button>- </div>- <div className="dialog-content-container">- <input className="input-text" type="text" value={filename} onChange={handleFilenameChanged} />- <div className="btns-container">- <button className="btn-text" onClick={handleCloseBtnClick}>- {t("common.cancel")}- </button>- <button className="btn-primary" onClick={handleSaveBtnClick}>- {t("common.save")}- </button>- </div>- </div>- </>- );-};--function showChangeResourceFilenameDialog(resourceId: ResourceId, resourceFilename: string) {- generateDialog(- {- className: "change-resource-filename-dialog",- dialogName: "change-resource-filename-dialog",- },- ChangeResourceFilenameDialog,- {- resourceId,- resourceFilename,- }- );-}--export default showChangeResourceFilenameDialog;diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsxindex 4686b96d3..3b43da30c 100644--- a/web/src/components/MemoEditor/index.tsx+++ b/web/src/components/MemoEditor/index.tsx@@ -226,9 +226,12 @@ const MemoEditor = (props: Props) => {if (resource) {uploadedResourceList.push(resource);if (memoId) {- await resourceStore.patchResource({+ await resourceStore.updateResource({id: resource.id,- memoId,+ resource: Resource.fromPartial({+ memoId,+ }),+ updateMask: ["memo_id"],});}}diff --git a/web/src/helpers/api.ts b/web/src/helpers/api.tsindex 1d44c1aa7..5356dec97 100644--- a/web/src/helpers/api.ts+++ b/web/src/helpers/api.ts@@ -135,10 +135,6 @@ export function deleteMemo(memoId: MemoId) {return axios.delete(`/api/v1/memo/${memoId}`);}-export function getResourceList() {- return axios.get<Resource[]>("/api/v1/resource");-}-export function createResource(resourceCreate: ResourceCreate) {return axios.post<Resource>("/api/v1/resource", resourceCreate);}@@ -147,14 +143,6 @@ export function createResourceWithBlob(formData: FormData) {return axios.post<Resource>("/api/v1/resource/blob", formData);}-export function patchResource(resourcePatch: ResourcePatch) {- return axios.patch<Resource>(`/api/v1/resource/${resourcePatch.id}`, resourcePatch);-}--export function deleteResourceById(id: ResourceId) {- return axios.delete(`/api/v1/resource/${id}`);-}-export function getTagSuggestionList() {return axios.get<string[]>(`/api/v1/tag/suggestion`);}diff --git a/web/src/store/module/resource.ts b/web/src/store/module/resource.tsindex a5666db1f..3731ea80a 100644--- a/web/src/store/module/resource.ts+++ b/web/src/store/module/resource.ts@@ -1,8 +1,9 @@+import { resourceServiceClient } from "@/grpcweb";import * as api from "@/helpers/api";-import { Resource } from "@/types/proto/api/v2/resource_service";+import { Resource, UpdateResourceRequest } from "@/types/proto/api/v2/resource_service";import { useTranslate } from "@/utils/i18n";import store, { useAppSelector } from "../";-import { deleteResource, patchResource, setResources } from "../reducer/resource";+import { patchResource, setResources } from "../reducer/resource";import { useGlobalStore } from "./global";export const useResourceStore = () => {@@ -16,11 +17,6 @@ export const useResourceStore = () => {getState: () => {return store.getState().resource;},- async fetchResourceList(): Promise<Resource[]> {- const { data: resourceList } = await api.getResourceList();- store.dispatch(setResources(resourceList));- return resourceList;- },async createResource(resourceCreate: ResourceCreate): Promise<Resource> {const { data: resource } = await api.createResource(resourceCreate);const resourceList = state.resources;@@ -40,14 +36,13 @@ export const useResourceStore = () => {store.dispatch(setResources([resource, ...resourceList]));return resource;},- async patchResource(resourcePatch: ResourcePatch): Promise<Resource> {- const { data: resource } = await api.patchResource(resourcePatch);+ async updateResource(request: UpdateResourceRequest): Promise<Resource> {+ const { resource } = await resourceServiceClient.updateResource(request);+ if (!resource) {+ throw new Error("resource is null");+ }store.dispatch(patchResource(resource));return resource;},- async deleteResourceById(id: ResourceId) {- await api.deleteResourceById(id);- store.dispatch(deleteResource(id));- },};};diff --git a/web/src/store/reducer/resource.ts b/web/src/store/reducer/resource.tsindex 8efcbbe56..5f87c413d 100644--- a/web/src/store/reducer/resource.ts+++ b/web/src/store/reducer/resource.ts@@ -39,17 +39,9 @@ const resourceSlice = createSlice({}),};},- deleteResource: (state, action: PayloadAction<ResourceId>) => {- return {- ...state,- resources: state.resources.filter((resource) => {- return resource.id !== action.payload;- }),- };- },},});-export const { setResources, upsertResources, patchResource, deleteResource } = resourceSlice.actions;+export const { setResources, upsertResources, patchResource } = resourceSlice.actions;export default resourceSlice.reducer;