Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(api): implement bookmark service (#4850)
h3n4l5b80fcd8ae38
diff --git a/backend/api/v1/bookmark_service.go b/backend/api/v1/bookmark_service.gonew file mode 100644index 0000000000..8c646c0452--- /dev/null+++ b/backend/api/v1/bookmark_service.go@@ -0,0 +1,112 @@+package v1++import (+ "context"+ "fmt"++ "google.golang.org/grpc/codes"+ "google.golang.org/grpc/status"+ "google.golang.org/protobuf/types/known/emptypb"++ "github.com/bytebase/bytebase/backend/common"++ "github.com/bytebase/bytebase/backend/store"+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+)++// BookmarkService implments the v1pb.BookmarkServiceServer interface.+type BookmarkService struct {+ v1pb.UnimplementedBookmarkServiceServer+ store *store.Store+}++// NewBookmarkService returns a new BookmarkService.+func NewBookmarkService(store *store.Store) *BookmarkService {+ return &BookmarkService{+ store: store,+ }+}++// CreateBookmark creates a new bookmark.+func (s *BookmarkService) CreateBookmark(ctx context.Context, request *v1pb.CreateBookmarkRequest) (*v1pb.Bookmark, error) {+ currentPincipalUID := ctx.Value(common.PrincipalIDContextKey).(int)+ princialUID, err := getUserID(request.Parent)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, "Invalid parent: %v", err)+ }+ if princialUID != currentPincipalUID {+ return nil, status.Errorf(codes.PermissionDenied, "Permission denied")+ }+ if request.Bookmark == nil {+ return nil, status.Errorf(codes.InvalidArgument, "Missing bookmark")+ }++ bookmark, err := s.store.CreateBookmarkV2(ctx, convertToStoreBookmark(request.Bookmark), princialUID)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "Failed to create bookmark: %v", err)+ }++ return convertToAPIBookmark(bookmark, princialUID), nil+}++// ListBookmarks lists bookmarks.+func (s *BookmarkService) ListBookmarks(ctx context.Context, request *v1pb.ListBookmarksRequest) (*v1pb.ListBookmarksResponse, error) {+ currentPincipalUID := ctx.Value(common.PrincipalIDContextKey).(int)+ princialUID, err := getUserID(request.Parent)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, "Invalid parent: %v", err)+ }+ if princialUID != currentPincipalUID {+ return nil, status.Errorf(codes.PermissionDenied, "Permission denied")+ }++ bookmarkList, err := s.store.ListBookmarkV2(ctx, princialUID)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "Failed to list bookmarks: %v", err)+ }++ var bookmarks []*v1pb.Bookmark+ for _, bookmark := range bookmarkList {+ bookmarks = append(bookmarks, convertToAPIBookmark(bookmark, princialUID))+ }++ return &v1pb.ListBookmarksResponse{+ Bookmarks: bookmarks,+ }, nil+}++// DeleteBookmark deletes a bookmark.+func (s *BookmarkService) DeleteBookmark(ctx context.Context, request *v1pb.DeleteBookmarkRequest) (*emptypb.Empty, error) {+ currentPincipalUID := ctx.Value(common.PrincipalIDContextKey).(int)+ principalUID, bookmarkUID, err := getUserBookmarkID(request.Name)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, "Invalid book mark name: %v", err)+ }+ if principalUID != currentPincipalUID {+ return nil, status.Errorf(codes.PermissionDenied, "Permission denied")+ }++ if err := s.store.DeleteBookmarkV2(ctx, bookmarkUID); err != nil {+ if common.ErrorCode(err) == common.NotFound {+ return nil, status.Errorf(codes.NotFound, "Bookmark not found: %v", err)+ }+ return nil, status.Errorf(codes.Internal, "Failed to delete bookmark: %v", err)+ }++ return &emptypb.Empty{}, nil+}++func convertToStoreBookmark(request *v1pb.Bookmark) *store.BookmarkMessage {+ return &store.BookmarkMessage{+ Name: request.Title,+ Link: request.Link,+ }+}++func convertToAPIBookmark(bookmark *store.BookmarkMessage, principalUID int) *v1pb.Bookmark {+ return &v1pb.Bookmark{+ Name: fmt.Sprintf("%s%d/%s%d", userNamePrefix, principalUID, bookmarkPrefix, bookmark.ID),+ Title: bookmark.Name,+ Link: bookmark.Link,+ }+}diff --git a/backend/api/v1/common.go b/backend/api/v1/common.goindex bc9278025e..5a4b6c32a4 100644--- a/backend/api/v1/common.go+++ b/backend/api/v1/common.go@@ -24,6 +24,7 @@ const (identityProviderNamePrefix = "idps/"settingNamePrefix = "settings/"backupPrefix = "backups/"+ bookmarkPrefix = "bookmarks/"deploymentConfigSuffix = "/deploymentConfig"backupSettingSuffix = "/backupSetting"@@ -132,6 +133,22 @@ func getIdentityProviderID(name string) (string, error) {return tokens[0], nil}+func getUserBookmarkID(name string) (int, int, error) {+ tokens, err := getNameParentTokens(name, userNamePrefix, bookmarkPrefix)+ if err != nil {+ return 0, 0, err+ }+ userID, err := strconv.Atoi(tokens[0])+ if err != nil {+ return 0, 0, errors.Errorf("invalid user ID %q", tokens[0])+ }+ bookmarkID, err := strconv.Atoi(tokens[1])+ if err != nil {+ return 0, 0, errors.Errorf("invalid bookmark ID %q", tokens[1])+ }+ return userID, bookmarkID, nil+}+func trimSuffix(name, suffix string) (string, error) {if !strings.HasSuffix(name, suffix) {return "", errors.Errorf("invalid request %q with suffix %q", name, suffix)diff --git a/backend/legacyapi/bookmark.go b/backend/legacyapi/bookmark.goindex 49b32b7d0c..ed14505e9b 100644--- a/backend/legacyapi/bookmark.go+++ b/backend/legacyapi/bookmark.go@@ -1,16 +1,11 @@package api-import (- "encoding/json"-)-// Bookmark is the API message for a bookmark.type Bookmark struct {ID int `jsonapi:"primary,bookmark"`// Standard fields- CreatorID int- Creator *Principal `jsonapi:"relation,creator"`+ CreatorID int `jsonapi:"attr,creatorID"`// Domain specific fieldsName string `jsonapi:"attr,name"`@@ -27,28 +22,3 @@ type BookmarkCreate struct {Name string `jsonapi:"attr,name"`Link string `jsonapi:"attr,link"`}--// BookmarkFind is the API message for finding bookmarks.-type BookmarkFind struct {- ID *int-- // Standard fields- CreatorID *int-}--func (find *BookmarkFind) String() string {- str, err := json.Marshal(*find)- if err != nil {- return err.Error()- }- return string(str)-}--// BookmarkDelete is the API message for deleting a bookmark.-type BookmarkDelete struct {- ID int-- // Standard fields- // Value is assigned from the jwt subject field passed by the client.- DeleterID int-}diff --git a/backend/server/acl.go b/backend/server/acl.goindex 8f64125d6b..3c0a682d65 100644--- a/backend/server/acl.go+++ b/backend/server/acl.go@@ -347,7 +347,7 @@ func isUpdatingSelf(ctx context.Context, c echo.Context, s *Server, curPrincipalreturn false, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Bookmark ID is not a number: %s"+bookmarkIDStr)).SetInternal(err)}- bookmark, err := s.store.GetBookmarkByID(ctx, bookmarkID)+ bookmark, err := s.store.GetBookmarkV2(ctx, bookmarkID)if err != nil {return false, echo.NewHTTPError(http.StatusInternalServerError, defaultErrMsg).SetInternal(err)}@@ -355,7 +355,7 @@ func isUpdatingSelf(ctx context.Context, c echo.Context, s *Server, curPrincipalreturn false, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Bookmark ID not found: %d", bookmarkID)).SetInternal(err)}- return bookmark.CreatorID == curPrincipalID, nil+ return bookmark.CreatorUID == curPrincipalID, nil}} else if strings.HasPrefix(path, "/inbox") {if inboxIDStr := c.Param("inboxID"); inboxIDStr != "" {diff --git a/backend/server/bookmark.go b/backend/server/bookmark.goindex b9b43bcc61..473b5edd8d 100644--- a/backend/server/bookmark.go+++ b/backend/server/bookmark.go@@ -10,6 +10,7 @@ import ("github.com/bytebase/bytebase/backend/common"api "github.com/bytebase/bytebase/backend/legacyapi"+ "github.com/bytebase/bytebase/backend/store")func (s *Server) registerBookmarkRoutes(g *echo.Group) {@@ -20,9 +21,10 @@ func (s *Server) registerBookmarkRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, "Malformed create bookmark request").SetInternal(err)}- bookmarkCreate.CreatorID = c.Get(getPrincipalIDContextKey()).(int)-- bookmark, err := s.store.CreateBookmark(ctx, bookmarkCreate)+ bookmark, err := s.store.CreateBookmarkV2(ctx, &store.BookmarkMessage{+ Name: bookmarkCreate.Name,+ Link: bookmarkCreate.Link,+ }, c.Get(getPrincipalIDContextKey()).(int))if err != nil {if common.ErrorCode(err) == common.Conflict {return echo.NewHTTPError(http.StatusConflict, fmt.Sprintf("Bookmark already exists: %s", bookmarkCreate.Link))@@ -31,7 +33,7 @@ func (s *Server) registerBookmarkRoutes(g *echo.Group) {}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, bookmark); err != nil {+ if err := jsonapi.MarshalPayload(c.Response().Writer, bookmark.ToAPIBookmark()); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal create bookmark response").SetInternal(err)}return nil@@ -44,16 +46,18 @@ func (s *Server) registerBookmarkRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("User ID is not a number: %s", c.Param("userID"))).SetInternal(err)}- bookmarkFind := &api.BookmarkFind{- CreatorID: &userID,- }- bookmarkList, err := s.store.FindBookmark(ctx, bookmarkFind)+ bookmarkList, err := s.store.ListBookmarkV2(ctx, userID)if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch bookmark list").SetInternal(err)}+ var apiBookmarks []*api.Bookmark+ for _, bookmark := range bookmarkList {+ apiBookmarks = append(apiBookmarks, bookmark.ToAPIBookmark())+ }+c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, bookmarkList); err != nil {+ if err := jsonapi.MarshalPayload(c.Response().Writer, apiBookmarks); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal bookmark list response").SetInternal(err)}return nil@@ -66,12 +70,7 @@ func (s *Server) registerBookmarkRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("bookmarkID"))).SetInternal(err)}- bookmarkDelete := &api.BookmarkDelete{- ID: id,- DeleterID: c.Get(getPrincipalIDContextKey()).(int),- }- err = s.store.DeleteBookmark(ctx, bookmarkDelete)- if err != nil {+ if err := s.store.DeleteBookmarkV2(ctx, id); err != nil {if common.ErrorCode(err) == common.NotFound {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Bookmark ID not found: %d", id))}diff --git a/backend/server/server.go b/backend/server/server.goindex 9ce4ef6c3b..b15a91228b 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -932,11 +932,10 @@ Click "Approve" button to apply the schema update.`,}// Bookmark the issue.- if _, err := s.store.CreateBookmark(ctx, &api.BookmarkCreate{- CreatorID: userID,- Name: "Sample Issue",- Link: fmt.Sprintf("/issue/%s-%d", slug.Make(issue.Name), issue.ID),- }); err != nil {+ if _, err := s.store.CreateBookmarkV2(ctx, &store.BookmarkMessage{+ Name: "Sample Issue",+ Link: fmt.Sprintf("/issue/%s-%d", slug.Make(issue.Name), issue.ID),+ }, userID); err != nil {return errors.Wrapf(err, "failed to bookmark sample issue")}diff --git a/backend/store/bookmark.go b/backend/store/bookmark.goindex 958ce50c14..445cc79af3 100644--- a/backend/store/bookmark.go+++ b/backend/store/bookmark.go@@ -12,279 +12,202 @@ import (api "github.com/bytebase/bytebase/backend/legacyapi")-// bookmarkRaw is the store model for an Bookmark.-// Fields have exactly the same meanings as Bookmark.-type bookmarkRaw struct {- ID int-- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-- // Domain specific fields- Name string+// BookmarkMessage is the message for bookmark.+type BookmarkMessage struct {+ // Link is the link of the bookmark.Link string-}--// toBookmark creates an instance of Bookmark based on the bookmarkRaw.-// This is intended to be called when we need to compose an Bookmark relationship.-func (raw *bookmarkRaw) toBookmark() *api.Bookmark {- return &api.Bookmark{- ID: raw.ID,- // Standard fields- CreatorID: raw.CreatorID,-- // Domain specific fields- Name: raw.Name,- Link: raw.Link,- }-}+ // Name is the name of the bookmark.+ Name string-// CreateBookmark creates an instance of Bookmark.-func (s *Store) CreateBookmark(ctx context.Context, create *api.BookmarkCreate) (*api.Bookmark, error) {- bookmarkRaw, err := s.createBookmarkRaw(ctx, create)- if err != nil {- return nil, errors.Wrapf(err, "failed to create Bookmark with BookmarkCreate[%+v]", create)- }- bookmark, err := s.composeBookmark(ctx, bookmarkRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Bookmark with bookmarkRaw[%+v]", bookmarkRaw)- }- return bookmark, nil+ // Output only fields.+ //+ // ID is the unique ID of the bookmark.+ ID int+ // CreatorUID is the unique ID of the creator.+ CreatorUID int}-// GetBookmarkByID gets an instance of Bookmark.-func (s *Store) GetBookmarkByID(ctx context.Context, id int) (*api.Bookmark, error) {- find := &api.BookmarkFind{ID: &id}- bookmarkRaw, err := s.getBookmarkRaw(ctx, find)- if err != nil {- return nil, errors.Wrapf(err, "failed to get Bookmark with ID %d", id)- }- if bookmarkRaw == nil {- return nil, nil- }- bookmark, err := s.composeBookmark(ctx, bookmarkRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Bookmark with bookmarkRaw[%+v]", bookmarkRaw)- }- return bookmark, nil+// listBookmarkMessage is the message for listing bookmarks.+type listBookmarkMessage struct {+ // id is the unique ID of the bookmark.+ id *int+ // creatorUID is the unique ID of the creator.+ creatorUID *int}-// FindBookmark finds a list of Bookmark instances.-func (s *Store) FindBookmark(ctx context.Context, find *api.BookmarkFind) ([]*api.Bookmark, error) {- bookmarkRawList, err := s.findBookmarkRaw(ctx, find)- if err != nil {- return nil, errors.Wrapf(err, "failed to find Bookmark list with BookmarkFind[%+v]", find)- }- var bookmarkList []*api.Bookmark- for _, raw := range bookmarkRawList {- bookmark, err := s.composeBookmark(ctx, raw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Bookmark with bookmarkRaw[%+v]", raw)- }- bookmarkList = append(bookmarkList, bookmark)+// ToAPIBookmark converts a BookmarkMessage to an API Bookmark.+func (b *BookmarkMessage) ToAPIBookmark() *api.Bookmark {+ return &api.Bookmark{+ ID: b.ID,+ CreatorID: b.CreatorUID,+ Name: b.Name,+ Link: b.Link,}- return bookmarkList, nil}-//-// private function-//--func (s *Store) composeBookmark(ctx context.Context, raw *bookmarkRaw) (*api.Bookmark, error) {- bookmark := raw.toBookmark()-- creator, err := s.GetPrincipalByID(ctx, bookmark.CreatorID)- if err != nil {- return nil, err- }- bookmark.Creator = creator-- return bookmark, nil-}+// CreateBookmarkV2 creates a new bookmark.+func (s *Store) CreateBookmarkV2(ctx context.Context, create *BookmarkMessage, principleUID int) (*BookmarkMessage, error) {+ query := `+ INSERT INTO bookmark (+ creator_id,+ updater_id,+ name,+ link+ )+ VALUES ($1, $2, $3, $4)+ RETURNING id, name, creator_id, link+ `-// createBookmarkRaw creates a new bookmark.-func (s *Store) createBookmarkRaw(ctx context.Context, create *api.BookmarkCreate) (*bookmarkRaw, error) {tx, err := s.db.BeginTx(ctx, nil)if err != nil {- return nil, FormatError(err)+ return nil, errors.Wrapf(err, "failed to begin transaction")}defer tx.Rollback()- bookmark, err := createBookmarkImpl(ctx, tx, create)- if err != nil {- return nil, err+ var bookmark BookmarkMessage+ if err := tx.QueryRowContext(ctx, query,+ principleUID,+ principleUID,+ create.Name,+ create.Link,+ ).Scan(+ &bookmark.ID,+ &bookmark.Name,+ &bookmark.CreatorUID,+ &bookmark.Link,+ ); err != nil {+ if err == sql.ErrNoRows {+ return nil, common.FormatDBErrorEmptyRowWithQuery(query)+ }+ return nil, errors.Wrapf(err, "failed to query row")}if err := tx.Commit(); err != nil {- return nil, FormatError(err)+ return nil, errors.Wrapf(err, "failed to commit transaction")}- return bookmark, nil+ return &bookmark, nil}-// findBookmarkRaw retrieves a list of bookmarks based on find.-func (s *Store) findBookmarkRaw(ctx context.Context, find *api.BookmarkFind) ([]*bookmarkRaw, error) {+// ListBookmarkV2 lists all bookmarks.+func (s *Store) ListBookmarkV2(ctx context.Context, principalUID int) ([]*BookmarkMessage, error) {tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})if err != nil {- return nil, FormatError(err)+ return nil, errors.Wrapf(err, "failed to begin transaction")}- defer tx.Rollback()- list, err := findBookmarkImpl(ctx, tx, find)+ bookmarks, err := s.listBookmarkImplV2(ctx, tx, &listBookmarkMessage{creatorUID: &principalUID})if err != nil {- return nil, err+ return nil, errors.Wrapf(err, "failed to list bookmarks")+ }++ if err := tx.Commit(); err != nil {+ return nil, errors.Wrapf(err, "failed to commit transaction")}- return list, nil+ return bookmarks, nil}-// getBookmarkRaw retrieves a single bookmark based on find.-// Returns ECONFLICT if finding more than 1 matching records.-func (s *Store) getBookmarkRaw(ctx context.Context, find *api.BookmarkFind) (*bookmarkRaw, error) {+// GetBookmarkV2 gets a bookmark by ID.+func (s *Store) GetBookmarkV2(ctx context.Context, bookmarkUID int) (*BookmarkMessage, error) {tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})if err != nil {- return nil, FormatError(err)+ return nil, errors.Wrapf(err, "failed to begin transaction")}defer tx.Rollback()- bookmarkRawList, err := findBookmarkImpl(ctx, tx, find)+ bookmarks, err := s.listBookmarkImplV2(ctx, tx, &listBookmarkMessage{id: &bookmarkUID})if err != nil {return nil, err}-- if len(bookmarkRawList) == 0 {+ if len(bookmarks) == 0 {return nil, nil- } else if len(bookmarkRawList) > 1 {- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d activities with filter %+v, expect 1. ", len(bookmarkRawList), find)}}- return bookmarkRawList[0], nil+ if len(bookmarks) > 1 {+ return nil, errors.Errorf("find %d bookmarks for bookmark ID %d", len(bookmarks), bookmarkUID)+ }++ if err := tx.Commit(); err != nil {+ return nil, errors.Wrapf(err, "failed to commit transaction")+ }+ return bookmarks[0], nil}-// DeleteBookmark deletes an existing bookmark by ID.-// Returns ENOTFOUND if bookmark does not exist.-func (s *Store) DeleteBookmark(ctx context.Context, delete *api.BookmarkDelete) error {+// DeleteBookmarkV2 try to delete a bookmark.+func (s *Store) DeleteBookmarkV2(ctx context.Context, bookmarkUID int) error {+ var args []interface{}+ var where []string+ where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, bookmarkUID)++ query := fmt.Sprintf(`+ DELETE FROM bookmark WHERE %s+ `, strings.Join(where, " AND "))+tx, err := s.db.BeginTx(ctx, nil)if err != nil {- return FormatError(err)+ return errors.Wrapf(err, "failed to begin transaction")}defer tx.Rollback()- if err := s.deleteBookmarkImpl(ctx, tx, delete); err != nil {- return FormatError(err)+ result, err := tx.ExecContext(ctx, query, args...)+ if err != nil {+ return errors.Wrapf(err, "failed to delete bookmark of principal id %d", bookmarkUID)+ }+ rows, _ := result.RowsAffected()+ if rows == 0 {+ return &common.Error{Code: common.NotFound, Err: errors.Errorf("bookmark ID not found: %d", bookmarkUID)}}if err := tx.Commit(); err != nil {- return FormatError(err)+ return errors.Wrapf(err, "failed to commit transaction")}return nil}-// createBookmarkImpl creates a new bookmark.-func createBookmarkImpl(ctx context.Context, tx *Tx, create *api.BookmarkCreate) (*bookmarkRaw, error) {- // Insert row into database.- query := `- INSERT INTO bookmark (- creator_id,- updater_id,- name,- link- )- VALUES ($1, $2, $3, $4)- RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, link- `- var bookmarkRaw bookmarkRaw- if err := tx.QueryRowContext(ctx, query,- create.CreatorID,- create.CreatorID,- create.Name,- create.Link,- ).Scan(- &bookmarkRaw.ID,- &bookmarkRaw.CreatorID,- &bookmarkRaw.CreatedTs,- &bookmarkRaw.UpdaterID,- &bookmarkRaw.UpdatedTs,- &bookmarkRaw.Name,- &bookmarkRaw.Link,- ); err != nil {- if err == sql.ErrNoRows {- return nil, common.FormatDBErrorEmptyRowWithQuery(query)- }- return nil, FormatError(err)- }- return &bookmarkRaw, nil-}--func findBookmarkImpl(ctx context.Context, tx *Tx, find *api.BookmarkFind) ([]*bookmarkRaw, error) {- // Build WHERE clause.+func (*Store) listBookmarkImplV2(ctx context.Context, tx *Tx, list *listBookmarkMessage) ([]*BookmarkMessage, error) {where, args := []string{"TRUE"}, []interface{}{}- if v := find.ID; v != nil {- where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)- }- if v := find.CreatorID; v != nil {+ if v := list.creatorUID; v != nil {where, args = append(where, fmt.Sprintf("creator_id = $%d", len(args)+1)), append(args, *v)}+ if v := list.id; v != nil {+ where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)+ }- rows, err := tx.QueryContext(ctx, `+ query := fmt.Sprintf(`SELECTid,creator_id,- created_ts,- updater_id,- updated_ts,name,link- FROM bookmark- WHERE `+strings.Join(where, " AND "),- args...,- )+ FROM bookmark WHERE %s+ `, strings.Join(where, " AND "))++ rows, err := tx.QueryContext(ctx, query, args...)if err != nil {- return nil, FormatError(err)+ return nil, errors.Wrapf(err, "failed to query bookmark of %v", list)}defer rows.Close()- // Iterate over result set and deserialize rows into bookmarkRawList.- var bookmarkRawList []*bookmarkRaw+ var bookmarks []*BookmarkMessage+for rows.Next() {- var bookmark bookmarkRaw+ var bookmark BookmarkMessageif err := rows.Scan(&bookmark.ID,- &bookmark.CreatorID,- &bookmark.CreatedTs,- &bookmark.UpdaterID,- &bookmark.UpdatedTs,+ &bookmark.CreatorUID,&bookmark.Name,&bookmark.Link,); err != nil {- return nil, FormatError(err)+ return nil, errors.Wrapf(err, "failed to scan bookmark of %v", list)}- bookmarkRawList = append(bookmarkRawList, &bookmark)+ bookmarks = append(bookmarks, &bookmark)}if err := rows.Err(); err != nil {- return nil, FormatError(err)+ return nil, errors.Wrapf(err, "failed to iterate bookmark of %v", list)}- return bookmarkRawList, nil-}--// deleteBookmarkImpl permanently deletes a bookmark by ID.-func (*Store) deleteBookmarkImpl(ctx context.Context, tx *Tx, delete *api.BookmarkDelete) error {- // Remove row from database.- result, err := tx.ExecContext(ctx, `DELETE FROM bookmark WHERE id = $1`, delete.ID)- if err != nil {- return FormatError(err)- }-- rows, _ := result.RowsAffected()- if rows == 0 {- return &common.Error{Code: common.NotFound, Err: errors.Errorf("bookmark ID not found: %d", delete.ID)}- }-- return nil+ return bookmarks, nil}diff --git a/frontend/src/store/modules/bookmark.ts b/frontend/src/store/modules/bookmark.tsindex 5bf4943a26..344ec6c27f 100644--- a/frontend/src/store/modules/bookmark.ts+++ b/frontend/src/store/modules/bookmark.ts@@ -8,19 +8,11 @@ import {ResourceObject,unknown,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";-function convert(- bookmark: ResourceObject,- includedList: ResourceObject[]-): Bookmark {+function convert(bookmark: ResourceObject): Bookmark {return {- ...(bookmark.attributes as Omit<Bookmark, "id" | "creator">),+ ...(bookmark.attributes as Omit<Bookmark, "id">),id: parseInt(bookmark.id),- creator: getPrincipalFromIncludedList(- bookmark.relationships!.creator.data,- includedList- ),};}@@ -35,7 +27,7 @@ export const useBookmarkStore = defineStore("bookmark", {// User info is retrieved from the context.const data = (await axios.get(`/api/bookmark/user/${userId}`)).data;const bookmarkList = data.data.map((bookmark: ResourceObject) => {- return convert(bookmark, data.included);+ return convert(bookmark);});this.setBookmarkListByPrincipalId({ userId, bookmarkList });return bookmarkList;@@ -50,8 +42,7 @@ export const useBookmarkStore = defineStore("bookmark", {},})).data;- const createdBookmark = convert(data.data, data.included);-+ const createdBookmark = convert(data.data);this.appendBookmark(createdBookmark);return createdBookmark;@@ -68,18 +59,18 @@ export const useBookmarkStore = defineStore("bookmark", {},appendBookmark(bookmark: Bookmark) {- const list = this.bookmarkList.get(bookmark.creator.id);+ const list = this.bookmarkList.get(bookmark.creatorID);if (list) {list.push(bookmark);} else {- this.bookmarkList.set(bookmark.creator.id, [bookmark]);+ this.bookmarkList.set(bookmark.creatorID, [bookmark]);}},async deleteBookmark(bookmark: Bookmark) {await axios.delete(`/api/bookmark/${bookmark.id}`);- const list = this.bookmarkList.get(bookmark.creator.id);+ const list = this.bookmarkList.get(bookmark.creatorID);if (list) {const i = list.findIndex((item: Bookmark) => item.id == bookmark.id);if (i != -1) {diff --git a/frontend/src/types/bookmark.ts b/frontend/src/types/bookmark.tsindex 68af722d22..72a7ed12d6 100644--- a/frontend/src/types/bookmark.ts+++ b/frontend/src/types/bookmark.ts@@ -1,11 +1,10 @@-import { BookmarkId } from "./id";-import { Principal } from "./principal";+import { BookmarkId, PrincipalId } from "./id";export type Bookmark = {id: BookmarkId;// Standard fields- creator: Principal;+ creatorID: PrincipalId;// Domain specific fieldsname: string;diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 10c9e6a318..2c0c439a55 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -369,7 +369,7 @@ const makeUnknown = (type: ResourceType) => {const UNKNOWN_BOOKMARK: Bookmark = {id: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,+ creatorID: UNKNOWN_ID,name: "",link: "",};@@ -724,7 +724,7 @@ const makeEmpty = (type: ResourceType) => {const EMPTY_BOOKMARK: Bookmark = {id: EMPTY_ID,- creator: EMPTY_PRINCIPAL,+ creatorID: EMPTY_ID,name: "",link: "",};diff --git a/frontend/src/types/proto/v1/bookmark_service.ts b/frontend/src/types/proto/v1/bookmark_service.tsindex bbb5fb46b0..7f32426d97 100644--- a/frontend/src/types/proto/v1/bookmark_service.ts+++ b/frontend/src/types/proto/v1/bookmark_service.ts@@ -62,6 +62,8 @@ export interface Bookmark {* Format: users/{user}/bookmarks/{bookmark}, user and bookmark are server-generated unique IDs.*/name: string;+ /** The title of the bookmark. */+ title: string;/*** The resource link of the bookmark. Only support issue link for now.* Format:@@ -308,7 +310,7 @@ export const ListBookmarksResponse = {};function createBaseBookmark(): Bookmark {- return { name: "", link: "" };+ return { name: "", title: "", link: "" };}export const Bookmark = {@@ -316,8 +318,11 @@ export const Bookmark = {if (message.name !== "") {writer.uint32(10).string(message.name);}+ if (message.title !== "") {+ writer.uint32(18).string(message.title);+ }if (message.link !== "") {- writer.uint32(18).string(message.link);+ writer.uint32(26).string(message.link);}return writer;},@@ -333,6 +338,9 @@ export const Bookmark = {message.name = reader.string();break;case 2:+ message.title = reader.string();+ break;+ case 3:message.link = reader.string();break;default:@@ -344,12 +352,17 @@ export const Bookmark = {},fromJSON(object: any): Bookmark {- return { name: isSet(object.name) ? String(object.name) : "", link: isSet(object.link) ? String(object.link) : "" };+ return {+ name: isSet(object.name) ? String(object.name) : "",+ title: isSet(object.title) ? String(object.title) : "",+ link: isSet(object.link) ? String(object.link) : "",+ };},toJSON(message: Bookmark): unknown {const obj: any = {};message.name !== undefined && (obj.name = message.name);+ message.title !== undefined && (obj.title = message.title);message.link !== undefined && (obj.link = message.link);return obj;},@@ -357,6 +370,7 @@ export const Bookmark = {fromPartial(object: DeepPartial<Bookmark>): Bookmark {const message = createBaseBookmark();message.name = object.name ?? "";+ message.title = object.title ?? "";message.link = object.link ?? "";return message;},diff --git a/proto/generated-go/v1/bookmark_service.pb.go b/proto/generated-go/v1/bookmark_service.pb.goindex 6eb57825b5..693caa858a 100644--- a/proto/generated-go/v1/bookmark_service.pb.go+++ b/proto/generated-go/v1/bookmark_service.pb.go@@ -271,11 +271,13 @@ type Bookmark struct {// The name of the bookmark.// Format: users/{user}/bookmarks/{bookmark}, user and bookmark are server-generated unique IDs.Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+ // The title of the bookmark.+ Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`// The resource link of the bookmark. Only support issue link for now.// Format:// Issue: /issue/slug(issue_name)-{issue_uid}// Example: /issue/start-here-add-email-column-to-employee-table-101- Link string `protobuf:"bytes,2,opt,name=link,proto3" json:"link,omitempty"`+ Link string `protobuf:"bytes,3,opt,name=link,proto3" json:"link,omitempty"`}func (x *Bookmark) Reset() {@@ -317,6 +319,13 @@ func (x *Bookmark) GetName() string {return ""}+func (x *Bookmark) GetTitle() string {+ if x != nil {+ return x.Title+ }+ return ""+}+func (x *Bookmark) GetLink() string {if x != nil {return x.Link@@ -366,39 +375,41 @@ var file_v1_bookmark_service_proto_rawDesc = []byte{0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f,0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22,- 0x3e, 0x0a, 0x08, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x18, 0x0a, 0x04, 0x6e,+ 0x5a, 0x0a, 0x08, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x18, 0x0a, 0x04, 0x6e,0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52,- 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20,- 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x32,- 0xaa, 0x03, 0x0a, 0x0f, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76,- 0x69, 0x63, 0x65, 0x12, 0x8f, 0x01, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f,- 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,- 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x6d,- 0x61, 0x72, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x62, 0x79, 0x74,- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72,- 0x6b, 0x22, 0x42, 0xda, 0x41, 0x0f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x62, 0x6f, 0x6f,- 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x3a, 0x08, 0x62, 0x6f, 0x6f,- 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65,- 0x6e, 0x74, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x62, 0x6f, 0x6f, 0x6b,- 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x12, 0x7b, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42,- 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b,- 0x6d, 0x61, 0x72, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f,- 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d,- 0x70, 0x74, 0x79, 0x22, 0x2d, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93,- 0x02, 0x20, 0x2a, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73,- 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x2f,- 0x2a, 0x7d, 0x12, 0x87, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x6d,- 0x61, 0x72, 0x6b, 0x73, 0x12, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,- 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73,- 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61,- 0x72, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2f, 0xda, 0x41, 0x06,- 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x12, 0x1e, 0x2f, 0x76,- 0x31, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f,- 0x2a, 0x7d, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x42, 0x11, 0x5a, 0x0f,- 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62,- 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,+ 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02,+ 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c,+ 0x65, 0x12, 0x18, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42,+ 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x32, 0xaa, 0x03, 0x0a, 0x0f,+ 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,+ 0x8f, 0x01, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61,+ 0x72, 0x6b, 0x12, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,+ 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x22, 0x42, 0xda,+ 0x41, 0x0f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x62, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72,+ 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x3a, 0x08, 0x62, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72,+ 0x6b, 0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x75,+ 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b,+ 0x73, 0x12, 0x7b, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x6d,+ 0x61, 0x72, 0x6b, 0x12, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b,+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22,+ 0x2d, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x2a, 0x1e,+ 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f,+ 0x2a, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x87,+ 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73,+ 0x12, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c,+ 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75,+ 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x52,+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2f, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65,+ 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x12, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x70,+ 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x62,+ 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x73, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65,+ 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f,+ 0x74, 0x6f, 0x33,}var (diff --git a/proto/v1/bookmark_service.proto b/proto/v1/bookmark_service.protoindex b3c5bdafb4..8a7c35d2e9 100644--- a/proto/v1/bookmark_service.proto+++ b/proto/v1/bookmark_service.proto@@ -87,9 +87,13 @@ message Bookmark {// The name of the bookmark.// Format: users/{user}/bookmarks/{bookmark}, user and bookmark are server-generated unique IDs.string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];++ // The title of the bookmark.+ string title = 2 [(google.api.field_behavior) = REQUIRED];+// The resource link of the bookmark. Only support issue link for now.// Format:// Issue: /issue/slug(issue_name)-{issue_uid}// Example: /issue/start-here-add-email-column-to-employee-table-101- string link = 2 [(google.api.field_behavior) = REQUIRED];+ string link = 3 [(google.api.field_behavior) = REQUIRED];}