From a8a870ce8636e20f66f8c6b8bc43f629b43e8d58 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sun, 18 Dec 2022 00:15:14 -0800 Subject: [PATCH] Remove comments from DB and API --- cmd/lure-api/api.go | 64 -- cmd/lure-api/internal/api/lure.pb.go | 809 ++++---------------- cmd/lure-api/internal/api/lure.twirp.go | 967 ++---------------------- cmd/lure-api/lure.proto | 47 -- internal/db/db.go | 50 -- 5 files changed, 192 insertions(+), 1745 deletions(-) diff --git a/cmd/lure-api/api.go b/cmd/lure-api/api.go index 2179b1e..ce60140 100644 --- a/cmd/lure-api/api.go +++ b/cmd/lure-api/api.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "strconv" - "time" "github.com/genjidb/genji" "github.com/genjidb/genji/document" @@ -17,69 +16,6 @@ type lureWebAPI struct { db *genji.DB } -func (l lureWebAPI) CreateComment(ctx context.Context, req *api.CreateCommentRequest) (*api.CreateCommentResponse, error) { - count, err := db.CountComments(l.db) - if err != nil { - return nil, err - } - - err = db.InsertComment(l.db, db.Comment{ - CommentID: count, - PackageName: req.PkgName, - PackageRepo: req.Repository, - TimeCreated: time.Now().Unix(), - Contents: req.Contents, - }) - if err != nil { - return nil, err - } - - return &api.CreateCommentResponse{CommentId: count}, nil -} - -func (l lureWebAPI) EditComment(ctx context.Context, req *api.EditCommentRequest) (*api.EmptyResponse, error) { - doc, err := db.GetComment(l.db, "comment_id = ?", req.CommentId) - if err != nil { - return nil, err - } - - var comment db.Comment - err = document.ScanDocument(doc, &comment) - if err != nil { - return nil, err - } - comment.Contents = req.NewContents - - err = db.InsertComment(l.db, comment) - return &api.EmptyResponse{}, err -} - -func (l lureWebAPI) GetComments(ctx context.Context, req *api.GetCommentsRequest) (*api.GetCommentsResponse, error) { - doc, err := db.GetComments( - l.db, - "package_repo = ? AND package_name = ? AND time_created >= ? LIMIT ?", - req.PkgName, - req.Repository, - req.CreatedSince, - req.Limit, - ) - if err != nil { - return nil, err - } - - out := &api.GetCommentsResponse{} - err = doc.Iterate(func(d types.Document) error { - comment := &api.Comment{} - err = document.ScanDocument(d, comment) - if err != nil { - return err - } - out.Comments = append(out.Comments, comment) - return nil - }) - return out, err -} - func (l lureWebAPI) Search(ctx context.Context, req *api.SearchRequest) (*api.SearchResponse, error) { query := "(name LIKE ? OR description LIKE ? OR ? IN provides)" args := []any{"%" + req.Query + "%", "%" + req.Query + "%", req.Query} diff --git a/cmd/lure-api/internal/api/lure.pb.go b/cmd/lure-api/internal/api/lure.pb.go index a328ec9..7950d2f 100644 --- a/cmd/lure-api/internal/api/lure.pb.go +++ b/cmd/lure-api/internal/api/lure.pb.go @@ -123,396 +123,6 @@ func (FILTER_TYPE) EnumDescriptor() ([]byte, []int) { return file_lure_proto_rawDescGZIP(), []int{1} } -// EmptyResponse is an empty API response -type EmptyResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *EmptyResponse) Reset() { - *x = EmptyResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *EmptyResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EmptyResponse) ProtoMessage() {} - -func (x *EmptyResponse) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use EmptyResponse.ProtoReflect.Descriptor instead. -func (*EmptyResponse) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{0} -} - -type Comment struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - CommentId int64 `protobuf:"varint,1,opt,name=comment_id,json=commentId,proto3" json:"comment_id,omitempty"` - TimeCreated int64 `protobuf:"varint,2,opt,name=time_created,json=timeCreated,proto3" json:"time_created,omitempty"` - Contents string `protobuf:"bytes,3,opt,name=contents,proto3" json:"contents,omitempty"` -} - -func (x *Comment) Reset() { - *x = Comment{} - if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Comment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Comment) ProtoMessage() {} - -func (x *Comment) ProtoReflect() protoreflect.Message { - mi := &file_lure_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 Comment.ProtoReflect.Descriptor instead. -func (*Comment) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{1} -} - -func (x *Comment) GetCommentId() int64 { - if x != nil { - return x.CommentId - } - return 0 -} - -func (x *Comment) GetTimeCreated() int64 { - if x != nil { - return x.TimeCreated - } - return 0 -} - -func (x *Comment) GetContents() string { - if x != nil { - return x.Contents - } - return "" -} - -// CreateCommentRequest is a request to create a comment -type CreateCommentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Repository string `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` - PkgName string `protobuf:"bytes,2,opt,name=pkg_name,json=pkgName,proto3" json:"pkg_name,omitempty"` - Contents string `protobuf:"bytes,3,opt,name=contents,proto3" json:"contents,omitempty"` -} - -func (x *CreateCommentRequest) Reset() { - *x = CreateCommentRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateCommentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateCommentRequest) ProtoMessage() {} - -func (x *CreateCommentRequest) ProtoReflect() protoreflect.Message { - mi := &file_lure_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 CreateCommentRequest.ProtoReflect.Descriptor instead. -func (*CreateCommentRequest) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{2} -} - -func (x *CreateCommentRequest) GetRepository() string { - if x != nil { - return x.Repository - } - return "" -} - -func (x *CreateCommentRequest) GetPkgName() string { - if x != nil { - return x.PkgName - } - return "" -} - -func (x *CreateCommentRequest) GetContents() string { - if x != nil { - return x.Contents - } - return "" -} - -// CreateCommentResponse is a response to CreateCommentRequest -type CreateCommentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - CommentId int64 `protobuf:"varint,1,opt,name=comment_id,json=commentId,proto3" json:"comment_id,omitempty"` -} - -func (x *CreateCommentResponse) Reset() { - *x = CreateCommentResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateCommentResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateCommentResponse) ProtoMessage() {} - -func (x *CreateCommentResponse) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[3] - 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 CreateCommentResponse.ProtoReflect.Descriptor instead. -func (*CreateCommentResponse) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{3} -} - -func (x *CreateCommentResponse) GetCommentId() int64 { - if x != nil { - return x.CommentId - } - return 0 -} - -// EditCommentRequest is a request to edit a comment -type EditCommentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - CommentId int64 `protobuf:"varint,1,opt,name=comment_id,json=commentId,proto3" json:"comment_id,omitempty"` - NewContents string `protobuf:"bytes,2,opt,name=new_contents,json=newContents,proto3" json:"new_contents,omitempty"` -} - -func (x *EditCommentRequest) Reset() { - *x = EditCommentRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *EditCommentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EditCommentRequest) ProtoMessage() {} - -func (x *EditCommentRequest) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[4] - 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 EditCommentRequest.ProtoReflect.Descriptor instead. -func (*EditCommentRequest) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{4} -} - -func (x *EditCommentRequest) GetCommentId() int64 { - if x != nil { - return x.CommentId - } - return 0 -} - -func (x *EditCommentRequest) GetNewContents() string { - if x != nil { - return x.NewContents - } - return "" -} - -// EditCommentRequest is a request to get comments on a package -type GetCommentsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Repository string `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` - PkgName string `protobuf:"bytes,2,opt,name=pkg_name,json=pkgName,proto3" json:"pkg_name,omitempty"` - CreatedSince int64 `protobuf:"varint,3,opt,name=created_since,json=createdSince,proto3" json:"created_since,omitempty"` - Limit int64 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"` -} - -func (x *GetCommentsRequest) Reset() { - *x = GetCommentsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetCommentsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetCommentsRequest) ProtoMessage() {} - -func (x *GetCommentsRequest) ProtoReflect() protoreflect.Message { - mi := &file_lure_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 GetCommentsRequest.ProtoReflect.Descriptor instead. -func (*GetCommentsRequest) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{5} -} - -func (x *GetCommentsRequest) GetRepository() string { - if x != nil { - return x.Repository - } - return "" -} - -func (x *GetCommentsRequest) GetPkgName() string { - if x != nil { - return x.PkgName - } - return "" -} - -func (x *GetCommentsRequest) GetCreatedSince() int64 { - if x != nil { - return x.CreatedSince - } - return 0 -} - -func (x *GetCommentsRequest) GetLimit() int64 { - if x != nil { - return x.Limit - } - return 0 -} - -// EditCommentRequest is a response to GetCommentsRequest -type GetCommentsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Comments []*Comment `protobuf:"bytes,1,rep,name=comments,proto3" json:"comments,omitempty"` -} - -func (x *GetCommentsResponse) Reset() { - *x = GetCommentsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetCommentsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetCommentsResponse) ProtoMessage() {} - -func (x *GetCommentsResponse) ProtoReflect() protoreflect.Message { - mi := &file_lure_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 GetCommentsResponse.ProtoReflect.Descriptor instead. -func (*GetCommentsResponse) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{6} -} - -func (x *GetCommentsResponse) GetComments() []*Comment { - if x != nil { - return x.Comments - } - return nil -} - // SearchRequest is a request to search for packages type SearchRequest struct { state protoimpl.MessageState @@ -529,7 +139,7 @@ type SearchRequest struct { func (x *SearchRequest) Reset() { *x = SearchRequest{} if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[7] + mi := &file_lure_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -542,7 +152,7 @@ func (x *SearchRequest) String() string { func (*SearchRequest) ProtoMessage() {} func (x *SearchRequest) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[7] + mi := &file_lure_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -555,7 +165,7 @@ func (x *SearchRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SearchRequest.ProtoReflect.Descriptor instead. func (*SearchRequest) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{7} + return file_lure_proto_rawDescGZIP(), []int{0} } func (x *SearchRequest) GetQuery() string { @@ -605,7 +215,7 @@ type StringList struct { func (x *StringList) Reset() { *x = StringList{} if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[8] + mi := &file_lure_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -618,7 +228,7 @@ func (x *StringList) String() string { func (*StringList) ProtoMessage() {} func (x *StringList) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[8] + mi := &file_lure_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -631,7 +241,7 @@ func (x *StringList) ProtoReflect() protoreflect.Message { // Deprecated: Use StringList.ProtoReflect.Descriptor instead. func (*StringList) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{8} + return file_lure_proto_rawDescGZIP(), []int{1} } func (x *StringList) GetEntries() []string { @@ -667,7 +277,7 @@ type Package struct { func (x *Package) Reset() { *x = Package{} if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[9] + mi := &file_lure_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -680,7 +290,7 @@ func (x *Package) String() string { func (*Package) ProtoMessage() {} func (x *Package) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[9] + mi := &file_lure_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -693,7 +303,7 @@ func (x *Package) ProtoReflect() protoreflect.Message { // Deprecated: Use Package.ProtoReflect.Descriptor instead. func (*Package) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{9} + return file_lure_proto_rawDescGZIP(), []int{2} } func (x *Package) GetName() string { @@ -813,7 +423,7 @@ type GetPackageRequest struct { func (x *GetPackageRequest) Reset() { *x = GetPackageRequest{} if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[10] + mi := &file_lure_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -826,7 +436,7 @@ func (x *GetPackageRequest) String() string { func (*GetPackageRequest) ProtoMessage() {} func (x *GetPackageRequest) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[10] + mi := &file_lure_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -839,7 +449,7 @@ func (x *GetPackageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPackageRequest.ProtoReflect.Descriptor instead. func (*GetPackageRequest) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{10} + return file_lure_proto_rawDescGZIP(), []int{3} } func (x *GetPackageRequest) GetName() string { @@ -868,7 +478,7 @@ type SearchResponse struct { func (x *SearchResponse) Reset() { *x = SearchResponse{} if protoimpl.UnsafeEnabled { - mi := &file_lure_proto_msgTypes[11] + mi := &file_lure_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -881,7 +491,7 @@ func (x *SearchResponse) String() string { func (*SearchResponse) ProtoMessage() {} func (x *SearchResponse) ProtoReflect() protoreflect.Message { - mi := &file_lure_proto_msgTypes[11] + mi := &file_lure_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -894,7 +504,7 @@ func (x *SearchResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead. func (*SearchResponse) Descriptor() ([]byte, []int) { - return file_lure_proto_rawDescGZIP(), []int{11} + return file_lure_proto_rawDescGZIP(), []int{4} } func (x *SearchResponse) GetPackages() []*Package { @@ -908,143 +518,94 @@ var File_lure_proto protoreflect.FileDescriptor var file_lure_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6c, 0x75, - 0x72, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x67, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1d, - 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, - 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, - 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x6d, 0x0a, 0x14, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x6f, 0x72, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x6b, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x36, 0x0a, 0x15, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, - 0x74, 0x49, 0x64, 0x22, 0x56, 0x0a, 0x12, 0x45, 0x64, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x77, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x6e, 0x65, 0x77, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x8a, 0x01, 0x0a, 0x12, - 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, - 0x72, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x6b, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x6b, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, - 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6e, - 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x40, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x43, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x29, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xd0, 0x01, 0x0a, 0x0d, 0x53, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x73, 0x6f, 0x72, 0x74, - 0x5f, 0x62, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, - 0x2e, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x42, 0x59, 0x52, 0x06, 0x73, 0x6f, 0x72, 0x74, 0x42, 0x79, - 0x12, 0x32, 0x0a, 0x0b, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x46, 0x49, 0x4c, - 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x52, 0x0a, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x0a, 0x0c, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x66, 0x69, - 0x6c, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, - 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x26, 0x0a, - 0x0a, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x65, - 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, - 0x74, 0x72, 0x69, 0x65, 0x73, 0x22, 0xe4, 0x05, 0x0a, 0x07, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x07, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x05, 0x65, 0x70, 0x6f, - 0x63, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, - 0x68, 0x88, 0x01, 0x01, 0x12, 0x25, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x68, - 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, - 0x08, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x88, 0x01, 0x01, 0x12, 0x23, 0x0a, 0x0a, - 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, - 0x48, 0x03, 0x52, 0x0a, 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x88, 0x01, - 0x01, 0x12, 0x24, 0x0a, 0x0d, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, - 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, - 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x69, 0x63, 0x65, 0x6e, - 0x73, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x69, 0x63, 0x65, 0x6e, - 0x73, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x73, 0x18, - 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x73, 0x12, - 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, 0x18, 0x0c, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x69, 0x63, 0x74, 0x73, 0x12, 0x1a, 0x0a, - 0x08, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x08, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x07, 0x64, 0x65, 0x70, - 0x65, 0x6e, 0x64, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6c, 0x75, 0x72, - 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x12, - 0x44, 0x0a, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, - 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x65, 0x6e, - 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, - 0x70, 0x65, 0x6e, 0x64, 0x73, 0x1a, 0x4c, 0x0a, 0x0c, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x1a, 0x51, 0x0a, 0x11, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x65, - 0x6e, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6c, 0x75, 0x72, 0x65, - 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, - 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x42, 0x0d, 0x0a, - 0x0b, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x22, 0x47, 0x0a, 0x11, - 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x3b, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, - 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, - 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x73, 0x2a, 0x3e, 0x0a, 0x07, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x42, 0x59, 0x12, 0x0c, 0x0a, - 0x08, 0x55, 0x4e, 0x53, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e, - 0x41, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, - 0x4f, 0x52, 0x59, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, - 0x10, 0x03, 0x2a, 0x42, 0x0a, 0x0b, 0x46, 0x49, 0x4c, 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x5f, 0x46, 0x49, 0x4c, 0x54, 0x45, 0x52, 0x10, 0x00, - 0x12, 0x11, 0x0a, 0x0d, 0x49, 0x4e, 0x5f, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x4f, 0x52, - 0x59, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x53, 0x5f, - 0x41, 0x52, 0x43, 0x48, 0x10, 0x02, 0x32, 0xb8, 0x02, 0x0a, 0x03, 0x41, 0x50, 0x49, 0x12, 0x48, - 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, - 0x1a, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6c, 0x75, - 0x72, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x45, 0x64, 0x69, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x45, - 0x64, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x13, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x18, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x19, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x65, - 0x61, 0x72, 0x63, 0x68, 0x12, 0x13, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, - 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x6c, 0x75, 0x72, 0x65, - 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x30, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x50, 0x6b, 0x67, 0x12, 0x17, 0x2e, 0x6c, 0x75, 0x72, 0x65, - 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x42, 0x0f, 0x5a, 0x0d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, - 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x22, 0xd0, 0x01, 0x0a, 0x0d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, + 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, + 0x12, 0x26, 0x0a, 0x07, 0x73, 0x6f, 0x72, 0x74, 0x5f, 0x62, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x42, 0x59, + 0x52, 0x06, 0x73, 0x6f, 0x72, 0x74, 0x42, 0x79, 0x12, 0x32, 0x0a, 0x0b, 0x66, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, + 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x46, 0x49, 0x4c, 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, + 0x52, 0x0a, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x0a, 0x0c, + 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x26, 0x0a, 0x0a, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4c, + 0x69, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x22, 0xe4, 0x05, + 0x0a, 0x07, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, + 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x12, 0x19, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, + 0x48, 0x00, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x88, 0x01, 0x01, 0x12, 0x25, 0x0a, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x48, 0x01, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x08, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, + 0x65, 0x88, 0x01, 0x01, 0x12, 0x23, 0x0a, 0x0a, 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, 0x69, 0x6e, + 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, 0x0a, 0x6d, 0x61, 0x69, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x88, 0x01, 0x01, 0x12, 0x24, 0x0a, 0x0d, 0x61, 0x72, 0x63, + 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0d, 0x61, 0x72, 0x63, 0x68, 0x69, 0x74, 0x65, 0x63, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, + 0x1a, 0x0a, 0x08, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x08, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x66, 0x6c, + 0x69, 0x63, 0x74, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x66, + 0x6c, 0x69, 0x63, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, + 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, + 0x73, 0x12, 0x34, 0x0a, 0x07, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x0e, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, + 0x65, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, + 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x12, 0x44, 0x0a, 0x0d, 0x62, 0x75, 0x69, 0x6c, 0x64, + 0x5f, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x42, 0x75, + 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x0c, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x1a, 0x4c, 0x0a, + 0x0c, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, + 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x51, 0x0a, 0x11, 0x42, + 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, + 0x0a, 0x06, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x68, 0x6f, 0x6d, + 0x65, 0x70, 0x61, 0x67, 0x65, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x6d, 0x61, 0x69, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x22, 0x47, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, + 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x3b, 0x0a, + 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x29, 0x0a, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x52, 0x08, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x2a, 0x3e, 0x0a, 0x07, 0x53, 0x4f, + 0x52, 0x54, 0x5f, 0x42, 0x59, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x4e, 0x53, 0x4f, 0x52, 0x54, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x41, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x0e, 0x0a, + 0x0a, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x02, 0x12, 0x0b, 0x0a, + 0x07, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x03, 0x2a, 0x42, 0x0a, 0x0b, 0x46, 0x49, + 0x4c, 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x12, 0x0d, 0x0a, 0x09, 0x4e, 0x4f, 0x5f, + 0x46, 0x49, 0x4c, 0x54, 0x45, 0x52, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x49, 0x4e, 0x5f, 0x52, + 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, + 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x53, 0x5f, 0x41, 0x52, 0x43, 0x48, 0x10, 0x02, 0x32, 0x6c, + 0x0a, 0x03, 0x41, 0x50, 0x49, 0x12, 0x33, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, + 0x13, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x06, 0x47, 0x65, + 0x74, 0x50, 0x6b, 0x67, 0x12, 0x17, 0x2e, 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, + 0x6c, 0x75, 0x72, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x42, 0x0f, 0x5a, 0x0d, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1060,49 +621,35 @@ func file_lure_proto_rawDescGZIP() []byte { } var file_lure_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_lure_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_lure_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_lure_proto_goTypes = []interface{}{ - (SORT_BY)(0), // 0: lure.SORT_BY - (FILTER_TYPE)(0), // 1: lure.FILTER_TYPE - (*EmptyResponse)(nil), // 2: lure.EmptyResponse - (*Comment)(nil), // 3: lure.Comment - (*CreateCommentRequest)(nil), // 4: lure.CreateCommentRequest - (*CreateCommentResponse)(nil), // 5: lure.CreateCommentResponse - (*EditCommentRequest)(nil), // 6: lure.EditCommentRequest - (*GetCommentsRequest)(nil), // 7: lure.GetCommentsRequest - (*GetCommentsResponse)(nil), // 8: lure.GetCommentsResponse - (*SearchRequest)(nil), // 9: lure.SearchRequest - (*StringList)(nil), // 10: lure.StringList - (*Package)(nil), // 11: lure.Package - (*GetPackageRequest)(nil), // 12: lure.GetPackageRequest - (*SearchResponse)(nil), // 13: lure.SearchResponse - nil, // 14: lure.Package.DependsEntry - nil, // 15: lure.Package.BuildDependsEntry + (SORT_BY)(0), // 0: lure.SORT_BY + (FILTER_TYPE)(0), // 1: lure.FILTER_TYPE + (*SearchRequest)(nil), // 2: lure.SearchRequest + (*StringList)(nil), // 3: lure.StringList + (*Package)(nil), // 4: lure.Package + (*GetPackageRequest)(nil), // 5: lure.GetPackageRequest + (*SearchResponse)(nil), // 6: lure.SearchResponse + nil, // 7: lure.Package.DependsEntry + nil, // 8: lure.Package.BuildDependsEntry } var file_lure_proto_depIdxs = []int32{ - 3, // 0: lure.GetCommentsResponse.comments:type_name -> lure.Comment - 0, // 1: lure.SearchRequest.sort_by:type_name -> lure.SORT_BY - 1, // 2: lure.SearchRequest.filter_type:type_name -> lure.FILTER_TYPE - 14, // 3: lure.Package.depends:type_name -> lure.Package.DependsEntry - 15, // 4: lure.Package.build_depends:type_name -> lure.Package.BuildDependsEntry - 11, // 5: lure.SearchResponse.packages:type_name -> lure.Package - 10, // 6: lure.Package.DependsEntry.value:type_name -> lure.StringList - 10, // 7: lure.Package.BuildDependsEntry.value:type_name -> lure.StringList - 4, // 8: lure.API.CreateComment:input_type -> lure.CreateCommentRequest - 6, // 9: lure.API.EditComment:input_type -> lure.EditCommentRequest - 7, // 10: lure.API.GetComments:input_type -> lure.GetCommentsRequest - 9, // 11: lure.API.Search:input_type -> lure.SearchRequest - 12, // 12: lure.API.GetPkg:input_type -> lure.GetPackageRequest - 5, // 13: lure.API.CreateComment:output_type -> lure.CreateCommentResponse - 2, // 14: lure.API.EditComment:output_type -> lure.EmptyResponse - 8, // 15: lure.API.GetComments:output_type -> lure.GetCommentsResponse - 13, // 16: lure.API.Search:output_type -> lure.SearchResponse - 11, // 17: lure.API.GetPkg:output_type -> lure.Package - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 0, // 0: lure.SearchRequest.sort_by:type_name -> lure.SORT_BY + 1, // 1: lure.SearchRequest.filter_type:type_name -> lure.FILTER_TYPE + 7, // 2: lure.Package.depends:type_name -> lure.Package.DependsEntry + 8, // 3: lure.Package.build_depends:type_name -> lure.Package.BuildDependsEntry + 4, // 4: lure.SearchResponse.packages:type_name -> lure.Package + 3, // 5: lure.Package.DependsEntry.value:type_name -> lure.StringList + 3, // 6: lure.Package.BuildDependsEntry.value:type_name -> lure.StringList + 2, // 7: lure.API.Search:input_type -> lure.SearchRequest + 5, // 8: lure.API.GetPkg:input_type -> lure.GetPackageRequest + 6, // 9: lure.API.Search:output_type -> lure.SearchResponse + 4, // 10: lure.API.GetPkg:output_type -> lure.Package + 9, // [9:11] is the sub-list for method output_type + 7, // [7:9] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_lure_proto_init() } @@ -1112,90 +659,6 @@ func file_lure_proto_init() { } if !protoimpl.UnsafeEnabled { file_lure_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EmptyResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_lure_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Comment); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_lure_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateCommentRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_lure_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateCommentResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_lure_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EditCommentRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_lure_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetCommentsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_lure_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetCommentsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_lure_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SearchRequest); i { case 0: return &v.state @@ -1207,7 +670,7 @@ func file_lure_proto_init() { return nil } } - file_lure_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_lure_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StringList); i { case 0: return &v.state @@ -1219,7 +682,7 @@ func file_lure_proto_init() { return nil } } - file_lure_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_lure_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Package); i { case 0: return &v.state @@ -1231,7 +694,7 @@ func file_lure_proto_init() { return nil } } - file_lure_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_lure_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetPackageRequest); i { case 0: return &v.state @@ -1243,7 +706,7 @@ func file_lure_proto_init() { return nil } } - file_lure_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_lure_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SearchResponse); i { case 0: return &v.state @@ -1256,15 +719,15 @@ func file_lure_proto_init() { } } } - file_lure_proto_msgTypes[7].OneofWrappers = []interface{}{} - file_lure_proto_msgTypes[9].OneofWrappers = []interface{}{} + file_lure_proto_msgTypes[0].OneofWrappers = []interface{}{} + file_lure_proto_msgTypes[2].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_lure_proto_rawDesc, NumEnums: 2, - NumMessages: 14, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/cmd/lure-api/internal/api/lure.twirp.go b/cmd/lure-api/internal/api/lure.twirp.go index b5cb84c..2df149c 100644 --- a/cmd/lure-api/internal/api/lure.twirp.go +++ b/cmd/lure-api/internal/api/lure.twirp.go @@ -33,15 +33,6 @@ const _ = twirp.TwirpPackageMinVersion_8_1_0 // Web is the LURE Web service type API interface { - // CreateComment creates a new comment on the given package - CreateComment(context.Context, *CreateCommentRequest) (*CreateCommentResponse, error) - - // EditComment edits an existing comment - EditComment(context.Context, *EditCommentRequest) (*EmptyResponse, error) - - // GetComments returns the comments on a particular package - GetComments(context.Context, *GetCommentsRequest) (*GetCommentsResponse, error) - // Search searches through LURE packages in the database Search(context.Context, *SearchRequest) (*SearchResponse, error) @@ -55,7 +46,7 @@ type API interface { type aPIProtobufClient struct { client HTTPClient - urls [5]string + urls [2]string interceptor twirp.Interceptor opts twirp.ClientOptions } @@ -83,10 +74,7 @@ func NewAPIProtobufClient(baseURL string, client HTTPClient, opts ...twirp.Clien // Build method URLs: []/./ serviceURL := sanitizeBaseURL(baseURL) serviceURL += baseServicePath(pathPrefix, "lure", "API") - urls := [5]string{ - serviceURL + "CreateComment", - serviceURL + "EditComment", - serviceURL + "GetComments", + urls := [2]string{ serviceURL + "Search", serviceURL + "GetPkg", } @@ -99,144 +87,6 @@ func NewAPIProtobufClient(baseURL string, client HTTPClient, opts ...twirp.Clien } } -func (c *aPIProtobufClient) CreateComment(ctx context.Context, in *CreateCommentRequest) (*CreateCommentResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "lure") - ctx = ctxsetters.WithServiceName(ctx, "API") - ctx = ctxsetters.WithMethodName(ctx, "CreateComment") - caller := c.callCreateComment - if c.interceptor != nil { - caller = func(ctx context.Context, req *CreateCommentRequest) (*CreateCommentResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*CreateCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*CreateCommentRequest) when calling interceptor") - } - return c.callCreateComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*CreateCommentResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*CreateCommentResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *aPIProtobufClient) callCreateComment(ctx context.Context, in *CreateCommentRequest) (*CreateCommentResponse, error) { - out := new(CreateCommentResponse) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *aPIProtobufClient) EditComment(ctx context.Context, in *EditCommentRequest) (*EmptyResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "lure") - ctx = ctxsetters.WithServiceName(ctx, "API") - ctx = ctxsetters.WithMethodName(ctx, "EditComment") - caller := c.callEditComment - if c.interceptor != nil { - caller = func(ctx context.Context, req *EditCommentRequest) (*EmptyResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*EditCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*EditCommentRequest) when calling interceptor") - } - return c.callEditComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*EmptyResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*EmptyResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *aPIProtobufClient) callEditComment(ctx context.Context, in *EditCommentRequest) (*EmptyResponse, error) { - out := new(EmptyResponse) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *aPIProtobufClient) GetComments(ctx context.Context, in *GetCommentsRequest) (*GetCommentsResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "lure") - ctx = ctxsetters.WithServiceName(ctx, "API") - ctx = ctxsetters.WithMethodName(ctx, "GetComments") - caller := c.callGetComments - if c.interceptor != nil { - caller = func(ctx context.Context, req *GetCommentsRequest) (*GetCommentsResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*GetCommentsRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*GetCommentsRequest) when calling interceptor") - } - return c.callGetComments(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*GetCommentsResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*GetCommentsResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *aPIProtobufClient) callGetComments(ctx context.Context, in *GetCommentsRequest) (*GetCommentsResponse, error) { - out := new(GetCommentsResponse) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - func (c *aPIProtobufClient) Search(ctx context.Context, in *SearchRequest) (*SearchResponse, error) { ctx = ctxsetters.WithPackageName(ctx, "lure") ctx = ctxsetters.WithServiceName(ctx, "API") @@ -268,7 +118,7 @@ func (c *aPIProtobufClient) Search(ctx context.Context, in *SearchRequest) (*Sea func (c *aPIProtobufClient) callSearch(ctx context.Context, in *SearchRequest) (*SearchResponse, error) { out := new(SearchResponse) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { @@ -314,7 +164,7 @@ func (c *aPIProtobufClient) GetPkg(ctx context.Context, in *GetPackageRequest) ( func (c *aPIProtobufClient) callGetPkg(ctx context.Context, in *GetPackageRequest) (*Package, error) { out := new(Package) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out) + ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { @@ -335,7 +185,7 @@ func (c *aPIProtobufClient) callGetPkg(ctx context.Context, in *GetPackageReques type aPIJSONClient struct { client HTTPClient - urls [5]string + urls [2]string interceptor twirp.Interceptor opts twirp.ClientOptions } @@ -363,10 +213,7 @@ func NewAPIJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOpt // Build method URLs: []/./ serviceURL := sanitizeBaseURL(baseURL) serviceURL += baseServicePath(pathPrefix, "lure", "API") - urls := [5]string{ - serviceURL + "CreateComment", - serviceURL + "EditComment", - serviceURL + "GetComments", + urls := [2]string{ serviceURL + "Search", serviceURL + "GetPkg", } @@ -379,144 +226,6 @@ func NewAPIJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOpt } } -func (c *aPIJSONClient) CreateComment(ctx context.Context, in *CreateCommentRequest) (*CreateCommentResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "lure") - ctx = ctxsetters.WithServiceName(ctx, "API") - ctx = ctxsetters.WithMethodName(ctx, "CreateComment") - caller := c.callCreateComment - if c.interceptor != nil { - caller = func(ctx context.Context, req *CreateCommentRequest) (*CreateCommentResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*CreateCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*CreateCommentRequest) when calling interceptor") - } - return c.callCreateComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*CreateCommentResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*CreateCommentResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *aPIJSONClient) callCreateComment(ctx context.Context, in *CreateCommentRequest) (*CreateCommentResponse, error) { - out := new(CreateCommentResponse) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *aPIJSONClient) EditComment(ctx context.Context, in *EditCommentRequest) (*EmptyResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "lure") - ctx = ctxsetters.WithServiceName(ctx, "API") - ctx = ctxsetters.WithMethodName(ctx, "EditComment") - caller := c.callEditComment - if c.interceptor != nil { - caller = func(ctx context.Context, req *EditCommentRequest) (*EmptyResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*EditCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*EditCommentRequest) when calling interceptor") - } - return c.callEditComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*EmptyResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*EmptyResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *aPIJSONClient) callEditComment(ctx context.Context, in *EditCommentRequest) (*EmptyResponse, error) { - out := new(EmptyResponse) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *aPIJSONClient) GetComments(ctx context.Context, in *GetCommentsRequest) (*GetCommentsResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "lure") - ctx = ctxsetters.WithServiceName(ctx, "API") - ctx = ctxsetters.WithMethodName(ctx, "GetComments") - caller := c.callGetComments - if c.interceptor != nil { - caller = func(ctx context.Context, req *GetCommentsRequest) (*GetCommentsResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*GetCommentsRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*GetCommentsRequest) when calling interceptor") - } - return c.callGetComments(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*GetCommentsResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*GetCommentsResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *aPIJSONClient) callGetComments(ctx context.Context, in *GetCommentsRequest) (*GetCommentsResponse, error) { - out := new(GetCommentsResponse) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - func (c *aPIJSONClient) Search(ctx context.Context, in *SearchRequest) (*SearchResponse, error) { ctx = ctxsetters.WithPackageName(ctx, "lure") ctx = ctxsetters.WithServiceName(ctx, "API") @@ -548,7 +257,7 @@ func (c *aPIJSONClient) Search(ctx context.Context, in *SearchRequest) (*SearchR func (c *aPIJSONClient) callSearch(ctx context.Context, in *SearchRequest) (*SearchResponse, error) { out := new(SearchResponse) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { @@ -594,7 +303,7 @@ func (c *aPIJSONClient) GetPkg(ctx context.Context, in *GetPackageRequest) (*Pac func (c *aPIJSONClient) callGetPkg(ctx context.Context, in *GetPackageRequest) (*Package, error) { out := new(Package) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out) + ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) if err != nil { twerr, ok := err.(twirp.Error) if !ok { @@ -706,15 +415,6 @@ func (s *aPIServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { } switch method { - case "CreateComment": - s.serveCreateComment(ctx, resp, req) - return - case "EditComment": - s.serveEditComment(ctx, resp, req) - return - case "GetComments": - s.serveGetComments(ctx, resp, req) - return case "Search": s.serveSearch(ctx, resp, req) return @@ -728,546 +428,6 @@ func (s *aPIServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { } } -func (s *aPIServer) serveCreateComment(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - header := req.Header.Get("Content-Type") - i := strings.Index(header, ";") - if i == -1 { - i = len(header) - } - switch strings.TrimSpace(strings.ToLower(header[:i])) { - case "application/json": - s.serveCreateCommentJSON(ctx, resp, req) - case "application/protobuf": - s.serveCreateCommentProtobuf(ctx, resp, req) - default: - msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) - twerr := badRouteError(msg, req.Method, req.URL.Path) - s.writeError(ctx, resp, twerr) - } -} - -func (s *aPIServer) serveCreateCommentJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "CreateComment") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - d := json.NewDecoder(req.Body) - rawReqBody := json.RawMessage{} - if err := d.Decode(&rawReqBody); err != nil { - s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) - return - } - reqContent := new(CreateCommentRequest) - unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} - if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { - s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) - return - } - - handler := s.API.CreateComment - if s.interceptor != nil { - handler = func(ctx context.Context, req *CreateCommentRequest) (*CreateCommentResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*CreateCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*CreateCommentRequest) when calling interceptor") - } - return s.API.CreateComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*CreateCommentResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*CreateCommentResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *CreateCommentResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *CreateCommentResponse and nil error while calling CreateComment. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} - respBytes, err := marshaler.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/json") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *aPIServer) serveCreateCommentProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "CreateComment") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - buf, err := io.ReadAll(req.Body) - if err != nil { - s.handleRequestBodyError(ctx, resp, "failed to read request body", err) - return - } - reqContent := new(CreateCommentRequest) - if err = proto.Unmarshal(buf, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) - return - } - - handler := s.API.CreateComment - if s.interceptor != nil { - handler = func(ctx context.Context, req *CreateCommentRequest) (*CreateCommentResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*CreateCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*CreateCommentRequest) when calling interceptor") - } - return s.API.CreateComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*CreateCommentResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*CreateCommentResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *CreateCommentResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *CreateCommentResponse and nil error while calling CreateComment. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - respBytes, err := proto.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/protobuf") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *aPIServer) serveEditComment(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - header := req.Header.Get("Content-Type") - i := strings.Index(header, ";") - if i == -1 { - i = len(header) - } - switch strings.TrimSpace(strings.ToLower(header[:i])) { - case "application/json": - s.serveEditCommentJSON(ctx, resp, req) - case "application/protobuf": - s.serveEditCommentProtobuf(ctx, resp, req) - default: - msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) - twerr := badRouteError(msg, req.Method, req.URL.Path) - s.writeError(ctx, resp, twerr) - } -} - -func (s *aPIServer) serveEditCommentJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "EditComment") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - d := json.NewDecoder(req.Body) - rawReqBody := json.RawMessage{} - if err := d.Decode(&rawReqBody); err != nil { - s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) - return - } - reqContent := new(EditCommentRequest) - unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} - if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { - s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) - return - } - - handler := s.API.EditComment - if s.interceptor != nil { - handler = func(ctx context.Context, req *EditCommentRequest) (*EmptyResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*EditCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*EditCommentRequest) when calling interceptor") - } - return s.API.EditComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*EmptyResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*EmptyResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *EmptyResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *EmptyResponse and nil error while calling EditComment. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} - respBytes, err := marshaler.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/json") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *aPIServer) serveEditCommentProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "EditComment") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - buf, err := io.ReadAll(req.Body) - if err != nil { - s.handleRequestBodyError(ctx, resp, "failed to read request body", err) - return - } - reqContent := new(EditCommentRequest) - if err = proto.Unmarshal(buf, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) - return - } - - handler := s.API.EditComment - if s.interceptor != nil { - handler = func(ctx context.Context, req *EditCommentRequest) (*EmptyResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*EditCommentRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*EditCommentRequest) when calling interceptor") - } - return s.API.EditComment(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*EmptyResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*EmptyResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *EmptyResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *EmptyResponse and nil error while calling EditComment. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - respBytes, err := proto.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/protobuf") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *aPIServer) serveGetComments(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - header := req.Header.Get("Content-Type") - i := strings.Index(header, ";") - if i == -1 { - i = len(header) - } - switch strings.TrimSpace(strings.ToLower(header[:i])) { - case "application/json": - s.serveGetCommentsJSON(ctx, resp, req) - case "application/protobuf": - s.serveGetCommentsProtobuf(ctx, resp, req) - default: - msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) - twerr := badRouteError(msg, req.Method, req.URL.Path) - s.writeError(ctx, resp, twerr) - } -} - -func (s *aPIServer) serveGetCommentsJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "GetComments") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - d := json.NewDecoder(req.Body) - rawReqBody := json.RawMessage{} - if err := d.Decode(&rawReqBody); err != nil { - s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) - return - } - reqContent := new(GetCommentsRequest) - unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true} - if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil { - s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err) - return - } - - handler := s.API.GetComments - if s.interceptor != nil { - handler = func(ctx context.Context, req *GetCommentsRequest) (*GetCommentsResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*GetCommentsRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*GetCommentsRequest) when calling interceptor") - } - return s.API.GetComments(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*GetCommentsResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*GetCommentsResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *GetCommentsResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *GetCommentsResponse and nil error while calling GetComments. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults} - respBytes, err := marshaler.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/json") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *aPIServer) serveGetCommentsProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "GetComments") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - buf, err := io.ReadAll(req.Body) - if err != nil { - s.handleRequestBodyError(ctx, resp, "failed to read request body", err) - return - } - reqContent := new(GetCommentsRequest) - if err = proto.Unmarshal(buf, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) - return - } - - handler := s.API.GetComments - if s.interceptor != nil { - handler = func(ctx context.Context, req *GetCommentsRequest) (*GetCommentsResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*GetCommentsRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*GetCommentsRequest) when calling interceptor") - } - return s.API.GetComments(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*GetCommentsResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*GetCommentsResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *GetCommentsResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *GetCommentsResponse and nil error while calling GetComments. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - respBytes, err := proto.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/protobuf") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - func (s *aPIServer) serveSearch(ctx context.Context, resp http.ResponseWriter, req *http.Request) { header := req.Header.Get("Content-Type") i := strings.Index(header, ";") @@ -2209,67 +1369,52 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) } var twirpFileDescriptor0 = []byte{ - // 978 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xef, 0x6e, 0xe3, 0x44, - 0x10, 0xaf, 0x93, 0x26, 0x4e, 0xc6, 0x71, 0x9a, 0xee, 0x15, 0xe1, 0x86, 0x3f, 0x57, 0x7c, 0x50, - 0x95, 0xfb, 0xd0, 0x43, 0x3d, 0x84, 0x10, 0x20, 0x44, 0xdd, 0x86, 0x36, 0x52, 0x49, 0xc2, 0x26, - 0x57, 0xa9, 0x7c, 0xb1, 0x5c, 0x67, 0x2e, 0x5d, 0xc5, 0xff, 0xce, 0xde, 0xf4, 0x94, 0x37, 0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x07, 0x18, 0xf3, 0x94, - 0x45, 0xb3, 0x0b, 0x96, 0x71, 0x62, 0x81, 0x8e, 0x11, 0x4f, 0x19, 0xaa, 0x56, 0x34, 0x69, 0x21, - 0xda, 0x7f, 0xd5, 0x40, 0x1f, 0x79, 0xfe, 0xdc, 0x9b, 0x21, 0x21, 0xb0, 0x29, 0x47, 0xa3, 0x6a, - 0x96, 0xe7, 0x7b, 0x23, 0xad, 0x3c, 0x18, 0xa9, 0x05, 0xfa, 0x2d, 0xa6, 0x19, 0x8b, 0xa3, 0x9c, - 0xb4, 0x85, 0x28, 0x34, 0x29, 0x06, 0xe8, 0x65, 0x98, 0x8f, 0xab, 0x10, 0xc9, 0x2e, 0xd4, 0x30, - 0x89, 0xfd, 0x1b, 0x59, 0x4d, 0xf5, 0x7c, 0x83, 0x2a, 0xf1, 0x9d, 0xa6, 0x91, 0x2f, 0xc0, 0x98, - 0x62, 0xe6, 0xa7, 0x2c, 0xe1, 0x22, 0x64, 0x5d, 0x96, 0xab, 0xd1, 0x32, 0x28, 0xcc, 0x9e, 0x42, - 0xe3, 0x26, 0x0e, 0x31, 0xf1, 0x66, 0x68, 0xe9, 0xd2, 0xa6, 0x42, 0x57, 0x88, 0x30, 0x78, 0x06, - 0x10, 0x7a, 0x2c, 0xe2, 0x1e, 0x8b, 0x30, 0xb5, 0x1a, 0xd2, 0xa4, 0x4a, 0x4b, 0x98, 0x30, 0xfa, - 0x1c, 0x4c, 0x31, 0x73, 0xc6, 0xd1, 0xe7, 0x8b, 0x14, 0x33, 0xab, 0x29, 0x7b, 0xb3, 0x0e, 0x8a, - 0xef, 0x32, 0x60, 0x3e, 0x46, 0x19, 0x66, 0x16, 0x48, 0x83, 0x95, 0x2c, 0x74, 0x49, 0x1a, 0xdf, - 0xb2, 0x29, 0x66, 0x96, 0xa1, 0x74, 0x85, 0x4c, 0x3e, 0x86, 0xa6, 0x1f, 0x47, 0xaf, 0x03, 0xe6, - 0xf3, 0xcc, 0x6a, 0x49, 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x00, 0x00, + // 742 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x5f, 0x8f, 0xda, 0x46, + 0x10, 0x3f, 0x63, 0xfe, 0x79, 0x8c, 0x39, 0xb3, 0x8d, 0x54, 0x17, 0x55, 0x0d, 0xa2, 0x2d, 0xa2, + 0x79, 0xb8, 0x54, 0xa4, 0x0f, 0x55, 0x2b, 0x55, 0x3a, 0xf7, 0x68, 0x0e, 0xe9, 0x0a, 0x74, 0x21, + 0x91, 0xae, 0x2f, 0x96, 0x31, 0x13, 0x6e, 0x75, 0xc6, 0x76, 0x76, 0x97, 0x93, 0xf8, 0x06, 0xf9, + 0x78, 0xfd, 0x10, 0xfd, 0x20, 0xd5, 0x7a, 0x6d, 0x62, 0x94, 0xb7, 0xe6, 0xcd, 0xbf, 0x3f, 0x33, + 0xeb, 0x99, 0x9d, 0x1d, 0x80, 0xf8, 0xc0, 0xf1, 0x2a, 0xe3, 0xa9, 0x4c, 0x49, 0x5d, 0x7d, 0x0f, + 0xff, 0x31, 0xc0, 0x59, 0x61, 0xc8, 0xa3, 0x07, 0x8a, 0xef, 0x0f, 0x28, 0x24, 0x79, 0x06, 0x8d, + 0xf7, 0x07, 0xe4, 0x47, 0xcf, 0x18, 0x18, 0x63, 0x8b, 0x6a, 0xa0, 0xd8, 0x98, 0xed, 0x99, 0xf4, + 0x6a, 0x03, 0x63, 0x6c, 0x52, 0x0d, 0xc8, 0x08, 0x5a, 0x22, 0xe5, 0x32, 0xd8, 0x1c, 0x3d, 0x73, + 0x60, 0x8c, 0xbb, 0x13, 0xe7, 0x2a, 0x3f, 0x61, 0xb5, 0xa0, 0xeb, 0xc0, 0xbf, 0xa7, 0x4d, 0xa5, + 0xfa, 0x47, 0x32, 0x01, 0xfb, 0x1d, 0x8b, 0x25, 0xf2, 0x40, 0x1e, 0x33, 0xf4, 0xea, 0xb9, 0xb7, + 0xa7, 0xbd, 0x7f, 0xcc, 0xee, 0xd6, 0x53, 0x1a, 0xac, 0xef, 0x97, 0x53, 0x0a, 0xda, 0xb5, 0x3e, + 0x66, 0x48, 0x46, 0xd0, 0x29, 0x62, 0x9e, 0xc2, 0xf8, 0x80, 0x5e, 0x43, 0xfd, 0xce, 0xed, 0x05, + 0x2d, 0x32, 0xbd, 0x55, 0xe4, 0x07, 0xc3, 0xf0, 0x2f, 0xc1, 0x09, 0xaa, 0xc6, 0xe1, 0x08, 0x60, + 0x25, 0x39, 0x4b, 0x76, 0x77, 0x4c, 0x48, 0xe2, 0x41, 0x0b, 0x13, 0xc9, 0x19, 0x0a, 0xcf, 0x18, + 0x98, 0x63, 0x8b, 0x96, 0x70, 0xf8, 0x6f, 0x03, 0x5a, 0xcb, 0x30, 0x7a, 0x0c, 0x77, 0x48, 0x08, + 0xd4, 0x93, 0x70, 0x8f, 0x45, 0xcd, 0xf9, 0x37, 0xf9, 0x06, 0x80, 0x63, 0x96, 0x0a, 0x26, 0x53, + 0x7e, 0xcc, 0xeb, 0xb6, 0x68, 0x85, 0x51, 0x99, 0x9f, 0x90, 0x0b, 0x96, 0x26, 0x79, 0xf1, 0x16, + 0x2d, 0xa1, 0x52, 0x38, 0xc6, 0x18, 0x0a, 0x5d, 0xaa, 0x49, 0x4b, 0x48, 0xbe, 0x82, 0x06, 0x66, + 0x69, 0xf4, 0x90, 0x57, 0x63, 0xde, 0x5e, 0x50, 0x0d, 0x3f, 0x18, 0x06, 0xf9, 0x1e, 0xec, 0x2d, + 0x8a, 0x88, 0xb3, 0x4c, 0xaa, 0x94, 0xcd, 0xbc, 0x5c, 0x83, 0x56, 0x49, 0x65, 0x7b, 0x0e, 0xed, + 0x87, 0x74, 0x8f, 0x59, 0xb8, 0x43, 0xaf, 0x95, 0x7b, 0x6a, 0xf4, 0xc4, 0x28, 0xc3, 0xb7, 0x00, + 0xfb, 0x90, 0x25, 0x32, 0x64, 0x09, 0x72, 0xaf, 0x9d, 0x5b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66, 0xbe, 0x77, 0x5f, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0x66, 0xd2, + 0xb6, 0xc4, 0x85, 0x05, 0x00, 0x00, } diff --git a/cmd/lure-api/lure.proto b/cmd/lure-api/lure.proto index 30f4fbe..410c7ea 100644 --- a/cmd/lure-api/lure.proto +++ b/cmd/lure-api/lure.proto @@ -2,46 +2,6 @@ syntax = "proto3"; package lure; option go_package = "/internal/api"; -// EmptyResponse is an empty API response -message EmptyResponse {} - -message Comment { - int64 comment_id = 1; - int64 time_created = 2; - string contents = 3; -} - -// CreateCommentRequest is a request to create a comment -message CreateCommentRequest { - string repository = 1; - string pkg_name = 2; - string contents = 3; -} - -// CreateCommentResponse is a response to CreateCommentRequest -message CreateCommentResponse { - int64 comment_id = 1; -} - -// EditCommentRequest is a request to edit a comment -message EditCommentRequest { - int64 comment_id = 1; - string new_contents = 2; -} - -// EditCommentRequest is a request to get comments on a package -message GetCommentsRequest { - string repository = 1; - string pkg_name = 2; - int64 created_since = 3; - int64 limit = 4; -} - -// EditCommentRequest is a response to GetCommentsRequest -message GetCommentsResponse { - repeated Comment comments = 1; -} - // SORT_BY represents possible things to sort packages by enum SORT_BY { UNSORTED = 0; @@ -102,13 +62,6 @@ message SearchResponse { // Web is the LURE Web service service API { - // CreateComment creates a new comment on the given package - rpc CreateComment(CreateCommentRequest) returns (CreateCommentResponse); - // EditComment edits an existing comment - rpc EditComment(EditCommentRequest) returns (EmptyResponse); - // GetComments returns the comments on a particular package - rpc GetComments(GetCommentsRequest) returns (GetCommentsResponse); - // Search searches through LURE packages in the database rpc Search(SearchRequest) returns (SearchResponse); // GetPkg gets a single LURE package from the database diff --git a/internal/db/db.go b/internal/db/db.go index 5083c8a..da1e84f 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -3,7 +3,6 @@ package db import ( "github.com/genjidb/genji" "github.com/genjidb/genji/document" - "github.com/genjidb/genji/types" ) // Package is a LURE package's database representation @@ -55,16 +54,6 @@ func Init(db *genji.DB) error { builddepends (...), UNIQUE(name, repository) ); - - CREATE TABLE IF NOT EXISTS comments ( - comment_id INT PRIMARY KEY, - package_name TEXT NOT NULL, - package_repo TEXT NOT NULL, - time_created INT NOT NULL, - contents TEXT NOT NULL, - UNIQUE(comment_id), - UNIQUE(package_name, package_repo) - ); `) } @@ -98,42 +87,3 @@ func GetPkg(db *genji.DB, where string, args ...any) (*Package, error) { func DeletePkgs(db *genji.DB, where string, args ...any) error { return db.Exec("DELETE FROM pkgs WHERE "+where, args...) } - -func InsertComment(db *genji.DB, c Comment) error { - return db.Exec("INSERT INTO comments VALUES ? ON CONFLICT DO REPLACE;", c) -} - -func CountComments(db *genji.DB) (int64, error) { - doc, err := db.QueryDocument("SELECT count(*) FROM comments;") - if err != nil { - return 0, err - } - val, err := doc.GetByField("COUNT(*)") - if err != nil { - return 0, err - } - return val.V().(int64), nil -} - -// GetComments returns a result containing comments that match the where conditions -func GetComments(db *genji.DB, where string, args ...any) (*genji.Result, error) { - stream, err := db.Query("SELECT * FROM comments WHERE "+where, args...) - if err != nil { - return nil, err - } - return stream, nil -} - -// GetComment returns a comment that matches the where conditions -func GetComment(db *genji.DB, where string, args ...any) (types.Document, error) { - doc, err := db.QueryDocument("SELECT * FROM comments WHERE "+where+" LIMIT 1", args...) - if err != nil { - return nil, err - } - return doc, nil -} - -// DeleteComments deletes all comments matching the where conditions -func DeleteComments(db *genji.DB, where string, args ...any) error { - return db.Exec("DELETE FROM comments WHERE "+where, args...) -}