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: migrate activity (#6607)
ecmadaoc5837a76e072
diff --git a/backend/api/v1/logging_service.go b/backend/api/v1/logging_service.goindex eef59becae..a9b6d4d3c1 100644--- a/backend/api/v1/logging_service.go+++ b/backend/api/v1/logging_service.go@@ -266,6 +266,28 @@ func (s *LoggingService) ListLogs(ctx context.Context, request *v1pb.ListLogsReqreturn resp, nil}+// GetLog gets the log.+func (s *LoggingService) GetLog(ctx context.Context, request *v1pb.GetLogRequest) (*v1pb.LogEntity, error) {+ activityUID, err := getUIDFromName(request.Name, logNamePrefix)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ activity, err := s.store.GetActivityV2(ctx, activityUID)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to find activity with error: %v", err.Error())+ }+ if activity == nil {+ return nil, status.Errorf(codes.NotFound, "cannot found activity %s", request.Name)+ }++ logEntity, err := s.convertToLogEntity(ctx, activity)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to convert log entity, error: %v", err)+ }+ return logEntity, nil+}+func (s *LoggingService) convertToLogEntity(ctx context.Context, activity *store.ActivityMessage) (*v1pb.LogEntity, error) {resource := ""switch activity.Type {@@ -339,6 +361,7 @@ func (s *LoggingService) convertToLogEntity(ctx context.Context, activity *storeAction: convertToActionType(activity.Type),Level: convertToLogLevel(activity.Level),CreateTime: timestamppb.New(time.Unix(activity.CreatedTs, 0)),+ UpdateTime: timestamppb.New(time.Unix(activity.UpdatedTs, 0)),Comment: activity.Comment,Payload: activity.Payload,}, nildiff --git a/backend/legacyapi/activity.go b/backend/legacyapi/activity.goindex bb16256972..d3bce7afeb 100644--- a/backend/legacyapi/activity.go+++ b/backend/legacyapi/activity.go@@ -1,8 +1,6 @@package apiimport (- "encoding/json"-"github.com/bytebase/bytebase/backend/plugin/advisor""github.com/bytebase/bytebase/backend/plugin/vcs")@@ -308,34 +306,6 @@ type ActivityCreate struct {Payload string `jsonapi:"attr,payload"`}-// ActivityFind is the API message for finding activities.-type ActivityFind struct {- ID *int-- // Domain specific fields- CreatorID *int- TypePrefixList []string- LevelList []ActivityLevel- ContainerID *int- Limit *int- CreatedTsAfter *int64- CreatedTsBefore *int64- // If specified, only find activities whose ID is smaller than SinceID.- SinceID *int- // If specified, sorts the returned list by created_ts in <<ORDER>>- // Different use cases want different orders.- // e.g. Issue activity list wants ASC, while view recent activity list wants DESC.- Order *SortOrder-}--func (find *ActivityFind) String() string {- str, err := json.Marshal(*find)- if err != nil {- return err.Error()- }- return string(str)-}-// ActivityPatch is the API message for patching an activity.type ActivityPatch struct {ID int `jsonapi:"primary,activityPatch"`diff --git a/backend/legacyapi/inbox.go b/backend/legacyapi/inbox.goindex 8a44e68073..ecbc97e575 100644--- a/backend/legacyapi/inbox.go+++ b/backend/legacyapi/inbox.go@@ -20,7 +20,7 @@ type Inbox struct {// Domain specific fieldsReceiverID int `jsonapi:"attr,receiverId"`- Activity *Activity `jsonapi:"relation,activity"`+ ActivityID int `jsonapi:"attr,activityId"`Status InboxStatus `jsonapi:"attr,status"`}diff --git a/backend/server/acl.go b/backend/server/acl.goindex 301912dc20..eafaaed344 100644--- a/backend/server/acl.go+++ b/backend/server/acl.go@@ -315,7 +315,7 @@ func isUpdatingSelf(ctx context.Context, c echo.Context, s *Server, curPrincipalreturn false, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Activity ID is not a number: %s"+activityIDStr)).SetInternal(err)}- activity, err := s.store.GetActivityByID(ctx, activityID)+ activity, err := s.store.GetActivityV2(ctx, activityID)if err != nil {return false, echo.NewHTTPError(http.StatusInternalServerError, defaultErrMsg).SetInternal(err)}diff --git a/backend/server/acl_casbin_policy_dba.csv b/backend/server/acl_casbin_policy_dba.csvindex bc6bc3d09c..ef9660d6f6 100644--- a/backend/server/acl_casbin_policy_dba.csv+++ b/backend/server/acl_casbin_policy_dba.csv@@ -74,7 +74,6 @@ p, DBA, /issue/{issueID}/subscriber, GETp, DBA, /issue/{issueID}/subscriber, POSTp, DBA, /issue/{issueID}/subscriber/{subscriberID}, DELETEp, DBA, /activity, POST-p, DBA, /activity, GETp, DBA, /activity/{activityID}, PATCH_SELFp, DBA, /inbox/user/{userID}, GET_SELFp, DBA, /inbox/user/{userID}/summary, GET_SELFdiff --git a/backend/server/acl_casbin_policy_developer.csv b/backend/server/acl_casbin_policy_developer.csvindex 0f317d02f3..f792e7efc5 100644--- a/backend/server/acl_casbin_policy_developer.csv+++ b/backend/server/acl_casbin_policy_developer.csv@@ -62,7 +62,6 @@ p, DEVELOPER, /issue/{issueID}/subscriber, GETp, DEVELOPER, /issue/{issueID}/subscriber, POSTp, DEVELOPER, /issue/{issueID}/subscriber/{subscriberID}, DELETEp, DEVELOPER, /activity, POST-p, DEVELOPER, /activity, GETp, DEVELOPER, /activity/{activityID}, PATCH_SELFp, DEVELOPER, /inbox/user/{userID}, GET_SELFp, DEVELOPER, /inbox/user/{userID}/summary, GET_SELFdiff --git a/backend/server/acl_casbin_policy_owner.csv b/backend/server/acl_casbin_policy_owner.csvindex 8ed1cf3224..f8596053d8 100644--- a/backend/server/acl_casbin_policy_owner.csv+++ b/backend/server/acl_casbin_policy_owner.csv@@ -77,7 +77,6 @@ p, OWNER, /issue/{issueID}/subscriber, GETp, OWNER, /issue/{issueID}/subscriber, POSTp, OWNER, /issue/{issueID}/subscriber/{subscriberID}, DELETEp, OWNER, /activity, POST-p, OWNER, /activity, GETp, OWNER, /activity/{activityID}, PATCH_SELFp, OWNER, /inbox/user/{userID}, GET_SELFp, OWNER, /inbox/user/{userID}/summary, GET_SELFdiff --git a/backend/server/activity.go b/backend/server/activity.goindex a18e4faeee..58d8971f22 100644--- a/backend/server/activity.go+++ b/backend/server/activity.go@@ -5,7 +5,6 @@ import ("fmt""net/http""strconv"- "time""github.com/google/jsonapi""github.com/labstack/echo/v4"@@ -62,101 +61,6 @@ func (s *Server) registerActivityRoutes(g *echo.Group) {return nil})- g.GET("/activity", func(c echo.Context) error {- ctx := c.Request().Context()- activityFind := &api.ActivityFind{}-- pageToken := c.QueryParams().Get("token")- // We use descending order by default for activities.- sinceID, err := unmarshalPageToken(pageToken, api.DESC)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Malformed page token").SetInternal(err)- }- activityFind.SinceID = &sinceID-- if creatorIDStr := c.QueryParams().Get("user"); creatorIDStr != "" {- creatorID, err := strconv.Atoi(creatorIDStr)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Query parameter user is not a number: %s", creatorIDStr)).SetInternal(err)- }- activityFind.CreatorID = &creatorID- }- if typePrefixList := c.QueryParams()["typePrefix"]; typePrefixList != nil {- activityFind.TypePrefixList = typePrefixList- }- if levelList := c.QueryParams()["level"]; levelList != nil {- list := make([]api.ActivityLevel, len(levelList))- for i, level := range levelList {- list[i] = api.ActivityLevel(level)- }- activityFind.LevelList = list- }- if containerIDStr := c.QueryParams().Get("container"); containerIDStr != "" {- containerID, err := strconv.Atoi(containerIDStr)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Query parameter container is not a number: %s", containerIDStr)).SetInternal(err)- }- activityFind.ContainerID = &containerID- }- if limitStr := c.QueryParam("limit"); limitStr != "" {- limit, err := strconv.Atoi(limitStr)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Query parameter limit is not a number: %s", limitStr)).SetInternal(err)- }- activityFind.Limit = &limit- } else {- limit := api.DefaultPageSize- activityFind.Limit = &limit- }- if orderStr := c.QueryParams().Get("order"); orderStr != "" {- order, err := api.StringToSortOrder(orderStr)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Query parameter order is invalid").SetInternal(err)- }- activityFind.Order = &order- }- if createdTsAfterStr := c.QueryParam("createdTsAfter"); createdTsAfterStr != "" {- createdTsAfter, err := strconv.ParseInt(createdTsAfterStr, 10, 64)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Query parameter createdTsAfter is invalid").SetInternal(err)- }- // Frontend pass it in milliseconds but we store it in seconds.- createdTsAfter = time.UnixMilli(createdTsAfter).Unix()- activityFind.CreatedTsAfter = &createdTsAfter- }- if createdTsBeforeStr := c.QueryParam("createdTsBefore"); createdTsBeforeStr != "" {- createdTsBefore, err := strconv.ParseInt(createdTsBeforeStr, 10, 64)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Query parameter createdTsBefore is invalid").SetInternal(err)- }- // Frontend pass it in milliseconds but we store it in seconds.- createdTsBefore = time.UnixMilli(createdTsBefore).Unix()- activityFind.CreatedTsBefore = &createdTsBefore- }- activityList, err := s.store.FindActivity(ctx, activityFind)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch activity list").SetInternal(err)- }-- activityResponse := &api.ActivityResponse{}- activityResponse.ActivityList = activityList-- nextSinceID := sinceID- if len(activityList) > 0 {- // Decrement the ID as we use decreasing order by default.- nextSinceID = activityList[len(activityList)-1].ID - 1- }- if activityResponse.NextToken, err = marshalPageToken(nextSinceID); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal page token").SetInternal(err)- }-- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, activityResponse); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal activity list response").SetInternal(err)- }- return nil- })-g.PATCH("/activity/:activityID", func(c echo.Context) error {ctx := c.Request().Context()id, err := strconv.Atoi(c.Param("activityID"))diff --git a/backend/store/activity.go b/backend/store/activity.goindex 34f8f42a56..65948d6c76 100644--- a/backend/store/activity.go+++ b/backend/store/activity.go@@ -91,39 +91,6 @@ func (s *Store) BatchCreateActivity(ctx context.Context, creates []*api.Activityreturn activityList, nil}-// GetActivityByID gets an instance of Activity.-func (s *Store) GetActivityByID(ctx context.Context, id int) (*api.Activity, error) {- activityRaw, err := s.getActivityRawByID(ctx, id)- if err != nil {- return nil, errors.Wrapf(err, "failed to get Activity with ID %d", id)- }- if activityRaw == nil {- return nil, nil- }- activity, err := s.composeActivity(ctx, activityRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Activity with activityRaw[%+v]", activityRaw)- }- return activity, nil-}--// FindActivity finds a list of Activity instances.-func (s *Store) FindActivity(ctx context.Context, find *api.ActivityFind) ([]*api.Activity, error) {- activityRawList, err := s.findActivityRaw(ctx, find)- if err != nil {- return nil, errors.Wrapf(err, "failed to find Activity list with ActivityFind[%+v]", find)- }- var activityList []*api.Activity- for _, raw := range activityRawList {- activity, err := s.composeActivity(ctx, raw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Activity with activityRaw[%+v]", raw)- }- activityList = append(activityList, activity)- }- return activityList, nil-}-// PatchActivity patches an instance of Activity.func (s *Store) PatchActivity(ctx context.Context, patch *api.ActivityPatch) (*api.Activity, error) {activityRaw, err := s.patchActivityRaw(ctx, patch)@@ -184,45 +151,6 @@ func (s *Store) createActivityRaw(ctx context.Context, create *api.ActivityCreatreturn activityRawList[0], nil}-// findActivityRaw retrieves a list of activities based on the find condition.-func (s *Store) findActivityRaw(ctx context.Context, find *api.ActivityFind) ([]*activityRaw, error) {- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})- if err != nil {- return nil, err- }- defer tx.Rollback()-- list, err := findActivityImpl(ctx, tx, find)- if err != nil {- return nil, err- }-- return list, nil-}--// getActivityRawByID retrieves a single activity based on ID.-// Returns ECONFLICT if finding more than 1 matching records.-func (s *Store) getActivityRawByID(ctx context.Context, id int) (*activityRaw, error) {- find := &api.ActivityFind{ID: &id}- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})- if err != nil {- return nil, err- }- defer tx.Rollback()-- list, err := findActivityImpl(ctx, tx, find)- if err != nil {- return nil, err- }-- if len(list) == 0 {- return nil, nil- } else if len(list) > 1 {- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d activities with filter %+v, expect 1. ", len(list), find)}- }- return list[0], nil-}-// patchActivityRaw updates an existing activity by ID.// Returns ENOTFOUND if activity does not exist.func (s *Store) patchActivityRaw(ctx context.Context, patch *api.ActivityPatch) (*activityRaw, error) {@@ -342,101 +270,6 @@ func createActivityImpl(ctx context.Context, tx *Tx, creates ...*api.ActivityCrereturn activityRawList, nil}-func findActivityImpl(ctx context.Context, tx *Tx, find *api.ActivityFind) ([]*activityRaw, error) {- // Build WHERE clause.- where, args := []string{"TRUE"}, []any{}- if v := find.ID; v != nil {- where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)- }- if v := find.ContainerID; v != nil {- where, args = append(where, fmt.Sprintf("container_id = $%d", len(args)+1)), append(args, *v)- }- if v := find.CreatorID; v != nil {- where, args = append(where, fmt.Sprintf("creator_id = $%d", len(args)+1)), append(args, *v)- }- if v := find.TypePrefixList; len(v) > 0 {- var queryValues []string- // Iterate over the typePrefix list and join each one with an OR condition.- for _, str := range v {- queryValues, args = append(queryValues, fmt.Sprintf("type LIKE $%d", len(args)+1)), append(args, fmt.Sprintf("%s%%", str))- }- where = append(where, fmt.Sprintf("(%s)", strings.Join(queryValues, " OR ")))- }- if v := find.LevelList; len(v) > 0 {- var queryValues []string- for _, level := range v {- queryValues, args = append(queryValues, fmt.Sprintf("level = $%d", len(args)+1)), append(args, level)- }- where = append(where, fmt.Sprintf("(%s)", strings.Join(queryValues, " OR ")))- }- if v := find.SinceID; v != nil {- where, args = append(where, fmt.Sprintf("id <= $%d", len(args)+1)), append(args, *v)- }- if v := find.CreatedTsAfter; v != nil {- where, args = append(where, fmt.Sprintf("created_ts >= $%d", len(args)+1)), append(args, *v)- }- if v := find.CreatedTsBefore; v != nil {- where, args = append(where, fmt.Sprintf("created_ts <= $%d", len(args)+1)), append(args, *v)- }-- var query = `- SELECT- id,- creator_id,- created_ts,- updater_id,- updated_ts,- container_id,- type,- level,- comment,- payload- FROM activity- WHERE ` + strings.Join(where, " AND ")- if v := find.Order; v != nil {- query += fmt.Sprintf(" ORDER BY id %s", *v)- }- if v := find.Limit; v != nil {- query += fmt.Sprintf(" LIMIT %d", *v)- }-- rows, err := tx.QueryContext(ctx, query, args...)- if err != nil {- return nil, err- }- defer rows.Close()-- // Iterate over result set and deserialize rows into activityRawList.- var activityRawList []*activityRaw- for rows.Next() {- var activity activityRaw- var protoPayload string- if err := rows.Scan(- &activity.ID,- &activity.CreatorID,- &activity.CreatedTs,- &activity.UpdaterID,- &activity.UpdatedTs,- &activity.ContainerID,- &activity.Type,- &activity.Level,- &activity.Comment,- &protoPayload,- ); err != nil {- return nil, err- }- if activity.Payload, err = convertProtoPayloadToAPIPayload(activity.Type, protoPayload); err != nil {- return nil, err- }- activityRawList = append(activityRawList, &activity)- }- if err := rows.Err(); err != nil {- return nil, err- }-- return activityRawList, nil-}-// patchActivityImpl updates a activity by ID. Returns the new state of the activity after update.func patchActivityImpl(ctx context.Context, tx *Tx, patch *api.ActivityPatch) (*activityRaw, error) {// Build UPDATE clause.@@ -695,9 +528,11 @@ func convertStorePBStatusToAPIApprovalEventStatus(status storepb.ActivityIssueCotype ActivityMessage struct {UID intCreatedTs int64+ UpdatedTs int64// Related fieldsCreatorID int+ UpdaterID int// The object where this activity belongs// e.g if Type is "bb.issue.xxx", then this field refers to the corresponding issue's id.ContainerUID int@@ -726,6 +561,27 @@ type FindActivityMessage struct {Order *api.SortOrder}+// GetActivityV2 gets the activity.+// Returns ECONFLICT if finding more than 1 matching records.+func (s *Store) GetActivityV2(ctx context.Context, uid int) (*ActivityMessage, error) {+ tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})+ if err != nil {+ return nil, err+ }+ defer tx.Rollback()++ activity, err := getActivityImplV2(ctx, tx, uid)+ if err != nil {+ return nil, err+ }++ if err := tx.Commit(); err != nil {+ return nil, err+ }++ return activity, nil+}+// ListActivityV2 lists the activity.func (s *Store) ListActivityV2(ctx context.Context, find *FindActivityMessage) ([]*ActivityMessage, error) {tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})@@ -739,9 +595,29 @@ func (s *Store) ListActivityV2(ctx context.Context, find *FindActivityMessage) (return nil, err}+ if err := tx.Commit(); err != nil {+ return nil, err+ }+return list, nil}+func getActivityImplV2(ctx context.Context, tx *Tx, uid int) (*ActivityMessage, error) {+ list, err := listActivityImplV2(ctx, tx, &FindActivityMessage{+ UID: &uid,+ })+ if err != nil {+ return nil, err+ }++ if len(list) == 0 {+ return nil, nil+ } else if len(list) > 1 {+ return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d activities with id %+v, expect 1. ", len(list), uid)}+ }+ return list[0], nil+}+func listActivityImplV2(ctx context.Context, tx *Tx, find *FindActivityMessage) ([]*ActivityMessage, error) {// Build WHERE clause.where, args := []string{"TRUE"}, []any{}@@ -779,7 +655,9 @@ func listActivityImplV2(ctx context.Context, tx *Tx, find *FindActivityMessage)SELECTid,creator_id,+ updater_id,created_ts,+ updated_ts,container_id,type,level,@@ -812,7 +690,9 @@ func listActivityImplV2(ctx context.Context, tx *Tx, find *FindActivityMessage)if err := rows.Scan(&activity.UID,&activity.CreatorID,+ &activity.UpdaterID,&activity.CreatedTs,+ &activity.UpdatedTs,&activity.ContainerUID,&activity.Type,&activity.Level,@@ -821,6 +701,9 @@ func listActivityImplV2(ctx context.Context, tx *Tx, find *FindActivityMessage)); err != nil {return nil, err}+ if protoPayload == "" {+ protoPayload = "{}"+ }if activity.Payload, err = convertProtoPayloadToAPIPayload(activity.Type, protoPayload); err != nil {return nil, err}diff --git a/backend/store/inbox.go b/backend/store/inbox.goindex 1adb9c6d9d..2714c4fc6c 100644--- a/backend/store/inbox.go+++ b/backend/store/inbox.go@@ -18,9 +18,9 @@ type inboxRaw struct {ID int// Domain specific fields- ReceiverID int- ActivityRaw *activityRaw- Status api.InboxStatus+ ReceiverID int+ ActivityID int+ Status api.InboxStatus}// toInbox creates an instance of Inbox based on the inboxRaw.@@ -30,6 +30,7 @@ func (raw *inboxRaw) toInbox() *api.Inbox {ID: raw.ID,ReceiverID: raw.ReceiverID,+ ActivityID: raw.ActivityID,Status: raw.Status,}}@@ -40,11 +41,7 @@ func (s *Store) CreateInbox(ctx context.Context, create *api.InboxCreate) (*api.if err != nil {return nil, errors.Wrapf(err, "failed to create Inbox with InboxCreate[%+v]", create)}- inbox, err := s.composeInbox(ctx, inboxRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Inbox with inboxRaw[%+v]", inboxRaw)- }- return inbox, nil+ return inboxRaw.toInbox(), nil}// GetInboxByID gets an instance of Inbox.@@ -57,11 +54,7 @@ func (s *Store) GetInboxByID(ctx context.Context, id int) (*api.Inbox, error) {if inboxRaw == nil {return nil, nil}- inbox, err := s.composeInbox(ctx, inboxRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Inbox with inboxRaw[%+v]", inboxRaw)- }- return inbox, nil+ return inboxRaw.toInbox(), nil}// FindInbox finds a list of Inbox instances.@@ -72,11 +65,7 @@ func (s *Store) FindInbox(ctx context.Context, find *api.InboxFind) ([]*api.Inbo}var inboxList []*api.Inboxfor _, raw := range inboxRawList {- inbox, err := s.composeInbox(ctx, raw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Inbox with inboxRaw[%+v]", raw)- }- inboxList = append(inboxList, inbox)+ inboxList = append(inboxList, raw.toInbox())}return inboxList, nil}@@ -87,11 +76,7 @@ func (s *Store) PatchInbox(ctx context.Context, patch *api.InboxPatch) (*api.Inbif err != nil {return nil, errors.Wrapf(err, "failed to patch Inbox with InboxPatch[%+v]", patch)}- inbox, err := s.composeInbox(ctx, inboxRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Inbox with inboxRaw[%+v]", inboxRaw)- }- return inbox, nil+ return inboxRaw.toInbox(), nil}// FindInboxSummary returns the inbox summary for a particular principal.@@ -130,19 +115,6 @@ func (s *Store) FindInboxSummary(ctx context.Context, principalID int) (*api.Inb// private function//-// composeInbox composes an instance of Inbox by inboxRaw.-func (s *Store) composeInbox(ctx context.Context, raw *inboxRaw) (*api.Inbox, error) {- inbox := raw.toInbox()-- activity, err := s.composeActivity(ctx, raw.ActivityRaw)- if err != nil {- return nil, err- }- inbox.Activity = activity-- return inbox, nil-}-// createInboxRaw creates a new inbox.func (s *Store) createInboxRaw(ctx context.Context, create *api.InboxCreate) (*inboxRaw, error) {tx, err := s.db.BeginTx(ctx, nil)@@ -151,7 +123,7 @@ func (s *Store) createInboxRaw(ctx context.Context, create *api.InboxCreate) (*i}defer tx.Rollback()- inbox, err := s.createInboxImpl(ctx, tx, create)+ inbox, err := createInboxImpl(ctx, tx, create)if err != nil {return nil, err}@@ -210,7 +182,7 @@ func (s *Store) patchInboxRaw(ctx context.Context, patch *api.InboxPatch) (*inbo}defer tx.Rollback()- inbox, err := s.patchInboxImpl(ctx, tx, patch)+ inbox, err := patchInboxImpl(ctx, tx, patch)if err != nil {return nil, err}@@ -223,7 +195,7 @@ func (s *Store) patchInboxRaw(ctx context.Context, patch *api.InboxPatch) (*inbo}// createInboxImpl creates a new inbox.-func (s *Store) createInboxImpl(ctx context.Context, tx *Tx, create *api.InboxCreate) (*inboxRaw, error) {+func createInboxImpl(ctx context.Context, tx *Tx, create *api.InboxCreate) (*inboxRaw, error) {// Insert row into database.query := `INSERT INTO inbox (@@ -235,14 +207,13 @@ func (s *Store) createInboxImpl(ctx context.Context, tx *Tx, create *api.InboxCrRETURNING id, receiver_id, activity_id, status`var inboxRaw inboxRaw- var activityID intif err := tx.QueryRowContext(ctx, query,create.ReceiverID,create.ActivityID,).Scan(&inboxRaw.ID,&inboxRaw.ReceiverID,- &activityID,+ &inboxRaw.ActivityID,&inboxRaw.Status,); err != nil {if err == sql.ErrNoRows {@@ -250,18 +221,12 @@ func (s *Store) createInboxImpl(ctx context.Context, tx *Tx, create *api.InboxCr}return nil, err}- activityRaw, err := s.getActivityRawByID(ctx, activityID)- if err != nil {- return nil, err- }- inboxRaw.ActivityRaw = activityRawreturn &inboxRaw, nil}func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRaw, error) {// Build WHERE clause.where, args := []string{"TRUE"}, []any{}- where = append(where, "inbox.activity_id = activity.id")if v := find.ID; v != nil {where, args = append(where, fmt.Sprintf("inbox.id = $%d", len(args)+1)), append(args, *v)}@@ -275,19 +240,11 @@ func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRarows, err := tx.QueryContext(ctx, `SELECTinbox.id,- receiver_id,- status,- activity.id,- activity.creator_id,- activity.created_ts,- activity.updater_id,- activity.updated_ts,- activity.container_id,- activity.type,- activity.level,- activity.comment,- activity.payload- FROM inbox, activity+ inbox.receiver_id,+ inbox.activity_id,+ inbox.status+ FROM inbox+ LEFT JOIN activity ON inbox.activity_id = activity.idWHERE `+strings.Join(where, " AND ")+`ORDER BY activity.created_ts DESC`,args...,@@ -301,21 +258,11 @@ func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRavar inboxRawList []*inboxRawfor rows.Next() {var inboxRaw inboxRaw- inboxRaw.ActivityRaw = &activityRaw{}if err := rows.Scan(&inboxRaw.ID,&inboxRaw.ReceiverID,+ &inboxRaw.ActivityID,&inboxRaw.Status,- &inboxRaw.ActivityRaw.ID,- &inboxRaw.ActivityRaw.CreatorID,- &inboxRaw.ActivityRaw.CreatedTs,- &inboxRaw.ActivityRaw.UpdaterID,- &inboxRaw.ActivityRaw.UpdatedTs,- &inboxRaw.ActivityRaw.ContainerID,- &inboxRaw.ActivityRaw.Type,- &inboxRaw.ActivityRaw.Level,- &inboxRaw.ActivityRaw.Comment,- &inboxRaw.ActivityRaw.Payload,); err != nil {return nil, err}@@ -329,13 +276,12 @@ func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRa}// patchInboxImpl updates a inbox by ID. Returns the new state of the inbox after update.-func (s *Store) patchInboxImpl(ctx context.Context, tx *Tx, patch *api.InboxPatch) (*inboxRaw, error) {+func patchInboxImpl(ctx context.Context, tx *Tx, patch *api.InboxPatch) (*inboxRaw, error) {// Build UPDATE clause.set, args := []string{"status = $1"}, []any{patch.Status}args = append(args, patch.ID)var inboxRaw inboxRaw- var activityID int// Execute update query with RETURNING.if err := tx.QueryRowContext(ctx, `UPDATE inbox@@ -347,7 +293,7 @@ func (s *Store) patchInboxImpl(ctx context.Context, tx *Tx, patch *api.InboxPatc).Scan(&inboxRaw.ID,&inboxRaw.ReceiverID,- &activityID,+ &inboxRaw.ActivityID,&inboxRaw.Status,); err != nil {if err == sql.ErrNoRows {@@ -355,10 +301,5 @@ func (s *Store) patchInboxImpl(ctx context.Context, tx *Tx, patch *api.InboxPatc}return nil, err}- activityRaw, err := s.getActivityRawByID(ctx, activityID)- if err != nil {- return nil, err- }- inboxRaw.ActivityRaw = activityRawreturn &inboxRaw, nil}diff --git a/frontend/src/components/ActivityTable.vue b/frontend/src/components/ActivityTable.vuedeleted file mode 100644index 7f226ed847..0000000000--- a/frontend/src/components/ActivityTable.vue+++ /dev/null@@ -1,88 +0,0 @@-<template>- <BBTable- :column-list="columnList"- :data-source="activityList"- :show-header="true"- :row-clickable="false"- :left-bordered="true"- :right-bordered="true"- >- <template #body="{ rowData: activity }">- <BBTableCell :left-padding="4" class="w-[20%]">- <div class="flex flew-row space-x-1">- <span- v-if="activity.level != `INFO`"- class="w-5 h-5 flex items-center justify-center rounded-full select-none"- >- <template v-if="activity.level === `WARN`">- <heroicons-outline:information-circle class="text-warning" />- </template>- <template v-else-if="activity.level === `ERROR`">- <heroicons-outline:exclamation-circle class="text-error" />- </template>- </span>- <span class="capitalize">{{ activityName(activity.type) }}</span>- <ActivityTypeLink :activity="activity" />- </div>- </BBTableCell>- <BBTableCell>- <div class="flex flex-row space-x-1">- <span>{{ activity.comment }}</span>- <ActivityCommentLink :activity="activity" />- </div>- </BBTableCell>- <BBTableCell class="w-[12%]">- {{ humanizeTs(activity.createdTs) }}- </BBTableCell>- <BBTableCell class="w-[12%]">- <div class="flex flex-row items-center">- <BBAvatar :size="'SMALL'" :username="activity.creator.name" />- <span class="ml-2">{{ activity.creator.name }}</span>- </div>- </BBTableCell>- </template>- </BBTable>-</template>--<script lang="ts">-import { computed, PropType } from "vue";-import { useI18n } from "vue-i18n";-import { BBTableColumn } from "../bbkit/types";-import { Activity, activityName } from "../types";-import ActivityTypeLink from "./ActivityTable/ActivityTypeLink.vue";-import ActivityCommentLink from "./ActivityTable/ActivityCommentLink.vue";--export default {- name: "ActivityTable",- components: { ActivityTypeLink, ActivityCommentLink },- props: {- activityList: {- required: true,- type: Object as PropType<Activity[]>,- },- },- setup() {- const { t } = useI18n();-- const columnList = computed((): BBTableColumn[] => [- {- title: t("activity.name"),- },- {- title: t("activity.comment"),- },- {- title: t("activity.created"),- },- {- title: t("activity.invoker"),- },- ]);-- return {- activityName,- columnList,- };- },-};-</script>diff --git a/frontend/src/components/ActivityTable/ActivityCommentLink.vue b/frontend/src/components/ActivityTable/ActivityCommentLink.vueindex d379ad66e0..704483677d 100644--- a/frontend/src/components/ActivityTable/ActivityCommentLink.vue+++ b/frontend/src/components/ActivityTable/ActivityCommentLink.vue@@ -15,40 +15,37 @@</template></template>-<script lang="ts">-import { computed, defineComponent, PropType } from "vue";-import { Activity, ActivityProjectRepositoryPushPayload } from "../../types";+<script lang="ts" setup>+import { computed, PropType } from "vue";+import { ActivityProjectRepositoryPushPayload } from "../../types";import { issueSlug } from "../../utils/slug";import { Link } from "./types";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";-export default defineComponent({- name: "ActivityCommentLink",- props: {- activity: {- type: Object as PropType<Activity>,- required: true,- },+const props = defineProps({+ activity: {+ type: Object as PropType<LogEntity>,+ required: true,},- setup(props) {- const link = computed((): Link | undefined => {- const { activity } = props;- switch (activity.type) {- case "bb.project.repository.push": {- const payload =- activity.payload as ActivityProjectRepositoryPushPayload;- if (payload.issueId && payload.issueName) {- return {- title: `issue/${payload.issueId}`,- path: `/issue/${issueSlug(payload.issueName!, payload.issueId!)}`,- external: false,- };- }- break;- }+});++const link = computed((): Link | undefined => {+ const { activity } = props;+ switch (activity.action) {+ case LogEntity_Action.ACTION_PROJECT_REPOSITORY_PUSH: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityProjectRepositoryPushPayload;+ if (payload.issueId && payload.issueName) {+ return {+ title: `issue/${payload.issueId}`,+ path: `/issue/${issueSlug(payload.issueName!, payload.issueId!)}`,+ external: false,+ };}- return undefined;- });- return { link };- },+ break;+ }+ }+ return undefined;});</script>diff --git a/frontend/src/components/ActivityTable/ActivityTable.vue b/frontend/src/components/ActivityTable/ActivityTable.vuenew file mode 100644index 0000000000..1ffec1152d--- /dev/null+++ b/frontend/src/components/ActivityTable/ActivityTable.vue@@ -0,0 +1,87 @@+<template>+ <BBTable+ :column-list="columnList"+ :data-source="activityList"+ :show-header="true"+ :row-clickable="false"+ :left-bordered="true"+ :right-bordered="true"+ >+ <template #body="{ rowData: activity }">+ <BBTableCell :left-padding="4" class="w-[20%]">+ <div class="flex flew-row space-x-1">+ <span+ v-if="activity.level != LogEntity_Level.LEVEL_INFO"+ class="w-5 h-5 flex items-center justify-center rounded-full select-none"+ >+ <template v-if="activity.level === LogEntity_Level.LEVEL_WARNING">+ <heroicons-outline:information-circle class="text-warning" />+ </template>+ <template+ v-else-if="activity.level === LogEntity_Level.LEVEL_ERROR"+ >+ <heroicons-outline:exclamation-circle class="text-error" />+ </template>+ </span>+ <span class="capitalize">{{ activityName(activity.action) }}</span>+ <ActivityTypeLink :activity="activity" />+ </div>+ </BBTableCell>+ <BBTableCell>+ <div class="flex flex-row space-x-1">+ <span>{{ activity.comment }}</span>+ <ActivityCommentLink :activity="activity" />+ </div>+ </BBTableCell>+ <BBTableCell class="w-[12%]">+ {{ humanizeTs((activity.createTime?.getTime() ?? 0) / 1000) }}+ </BBTableCell>+ <BBTableCell class="w-[12%]">+ <div class="flex flex-row items-center">+ <BBAvatar :size="'SMALL'" :username="getUser(activity)?.title" />+ <span class="ml-2">{{ getUser(activity)?.title }}</span>+ </div>+ </BBTableCell>+ </template>+ </BBTable>+</template>++<script lang="ts" setup>+import { computed, PropType } from "vue";+import { useI18n } from "vue-i18n";+import { BBTableColumn } from "../../bbkit/types";+import { activityName } from "@/types";+import { LogEntity, LogEntity_Level } from "@/types/proto/v1/logging_service";+import { extractUserResourceName } from "@/utils";+import { useUserStore } from "@/store";++defineProps({+ activityList: {+ type: Object as PropType<LogEntity[]>,+ required: true,+ },+});++const { t } = useI18n();++const columnList = computed((): BBTableColumn[] => [+ {+ title: t("activity.name"),+ },+ {+ title: t("activity.comment"),+ },+ {+ title: t("activity.created"),+ },+ {+ title: t("activity.invoker"),+ },+]);++const getUser = (activity: LogEntity) => {+ return useUserStore().getUserByEmail(+ extractUserResourceName(activity.creator)+ );+};+</script>diff --git a/frontend/src/components/ActivityTable/ActivityTypeLink.vue b/frontend/src/components/ActivityTable/ActivityTypeLink.vueindex de9f2ebe56..37b84afb61 100644--- a/frontend/src/components/ActivityTable/ActivityTypeLink.vue+++ b/frontend/src/components/ActivityTable/ActivityTypeLink.vue@@ -15,57 +15,54 @@</template></template>-<script lang="ts">-import { computed, defineComponent, PropType } from "vue";+<script lang="ts" setup>+import { computed, PropType } from "vue";import { head } from "lodash-es";import {- Activity,ActivityProjectRepositoryPushPayload,ActivityProjectDatabaseTransferPayload,} from "../../types";import { Link } from "./types";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";-export default defineComponent({- name: "ActivityTypeLink",- props: {- activity: {- type: Object as PropType<Activity>,- required: true,- },+const props = defineProps({+ activity: {+ type: Object as PropType<LogEntity>,+ required: true,},- setup(props) {- const link = computed((): Link | undefined => {- const { activity } = props;- switch (activity.type) {- case "bb.project.repository.push": {- const payload =- activity.payload as ActivityProjectRepositoryPushPayload;- const commit =- head(payload.pushEvent.commits) ?? payload.pushEvent.fileCommit;- if (commit && commit.id && commit.url) {- return {- title: commit.id.substring(0, 7),- path: commit.url,- external: true,- };- }- // Downgrade for legacy data.- return undefined;- }- case "bb.project.database.transfer": {- const payload =- activity.payload as ActivityProjectDatabaseTransferPayload;- return {- title: payload.databaseName,- path: `/db/${payload.databaseId}`,- external: false,- };- }+});++const link = computed((): Link | undefined => {+ const { activity } = props;+ switch (activity.action) {+ case LogEntity_Action.ACTION_PROJECT_REPOSITORY_PUSH: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityProjectRepositoryPushPayload;+ const commit =+ head(payload.pushEvent.commits) ?? payload.pushEvent.fileCommit;+ if (commit && commit.id && commit.url) {+ return {+ title: commit.id.substring(0, 7),+ path: commit.url,+ external: true,+ };}+ // Downgrade for legacy data.return undefined;- });- return { link };- },+ }+ case LogEntity_Action.ACTION_PROJECT_DATABASE_TRANSFER: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityProjectDatabaseTransferPayload;+ return {+ title: payload.databaseName,+ path: `/db/${payload.databaseId}`,+ external: false,+ };+ }+ }+ return undefined;});</script>diff --git a/frontend/src/components/AuditLog/PagedAuditLogTable.vue b/frontend/src/components/AuditLog/PagedAuditLogTable.vuedeleted file mode 100644index f71ffffa6a..0000000000--- a/frontend/src/components/AuditLog/PagedAuditLogTable.vue+++ /dev/null@@ -1,184 +0,0 @@-<template>- <slot name="table" :list="state.auditLogList" :loading="state.loading" />-- <div- v-if="state.loading"- class="flex items-center justify-center py-2 text-gray-400 text-sm"- >- <BBSpin />- </div>-- <slot- v-if="!state.loading"- name="more"- :has-more="state.hasMore"- :fetch-next-page="fetchNextPage"- >- <div- v-if="!hideLoadMore && pageSize > 0 && state.hasMore"- class="flex items-center justify-center py-2 text-gray-400 text-sm hover:bg-gray-200 cursor-pointer"- @click="fetchNextPage"- >- {{ $t("common.load-more") }}- </div>- </slot>-</template>--<script lang="ts" setup>-import { computed, PropType, reactive, watch } from "vue";--import { useIsLoggedIn, useActivityV1Store } from "@/store";-import { FindActivityMessage } from "@/types";-import { useSessionStorage } from "@vueuse/core";-import { stringify } from "qs";-import { LogEntity } from "@/types/proto/v1/logging_service";--type LocalState = {- loading: boolean;- auditLogList: LogEntity[];- paginationToken: string;- hasMore: boolean;-};--/**- * It's complex and dangerous to cache the activity list.- * So we just memorize how many times the user clicks the "load more" button.- * And load the first N pages in the first fetch.- * E.g., the user clicked "load more" 4 times, then the first time will set limit- * to `pageSize * 5`.- */-type SessionState = {- // How many times the user clicks the "load more" button.- page: number;- // Help us to check if the session is outdated.- updatedTs: number;-};--const MAX_PAGE_SIZE = 1000;-const SESSION_LIFE = 1 * 60 * 1000; // 1 minute--const props = defineProps({- // A unique key to identify the session state.- sessionKey: {- type: String,- required: true,- },- activityFind: {- type: Object as PropType<FindActivityMessage>,- default: () => ({- order: "desc",- }),- },- pageSize: {- type: Number,- default: 10,- },- hideLoadMore: {- type: Boolean,- default: false,- },-});--const state = reactive<LocalState>({- loading: false,- auditLogList: [],- paginationToken: "",- hasMore: true,-});--const sessionState = useSessionStorage<SessionState>(- `bb.page-audit-log-table.${props.sessionKey}`,- {- page: 1,- updatedTs: 0,- }-);--const activityV1Store = useActivityV1Store();-const isLoggedIn = useIsLoggedIn();--const limit = computed(() => {- if (props.pageSize <= 0) return MAX_PAGE_SIZE;- return props.pageSize;-});--const condition = computed(() => {- const activityFind = {- ...props.activityFind,- limit: limit.value,- };- return stringify(activityFind, {- arrayFormat: "repeat",- });-});--const fetchData = async (refresh = false) => {- state.loading = true;-- const isFirstFetch = state.paginationToken === "";- const expectedRowCount = isFirstFetch- ? // Load one or more page for the first fetch to restore the session- limit.value * sessionState.value.page- : // Always load one page if NOT the first fetch- limit.value;-- try {- const { nextPageToken, logEntities } =- await activityV1Store.fetchActivityList({- ...props.activityFind,- pageSize: expectedRowCount,- pageToken: state.paginationToken,- });- if (refresh) {- state.auditLogList = logEntities;- } else {- state.auditLogList.push(...logEntities);- }-- if (logEntities.length < expectedRowCount) {- state.hasMore = false;- } else if (!isFirstFetch) {- // If we didn't reach the end, memorize we've clicked the "load more" button.- sessionState.value.page++;- }-- sessionState.value.updatedTs = Date.now();- state.paginationToken = nextPageToken;- } catch (e) {- console.error(e);- } finally {- state.loading = false;- }-};--const resetSession = () => {- sessionState.value = {- page: 1,- updatedTs: 0,- };-};--const refresh = () => {- state.paginationToken = "";- state.hasMore = true;- resetSession();- fetchData(true);-};--const fetchNextPage = () => {- fetchData(false);-};--if (Date.now() - sessionState.value.updatedTs > SESSION_LIFE) {- // Reset session if it's outdated.- resetSession();-}-fetchData(true);-watch(condition, refresh);-watch(isLoggedIn, () => {- // Reset session when logged out.- if (!isLoggedIn.value) {- resetSession();- }-});-</script>diff --git a/frontend/src/components/InboxList.vue b/frontend/src/components/InboxList.vueindex 807eca00ff..0470a0663c 100644--- a/frontend/src/components/InboxList.vue+++ b/frontend/src/components/InboxList.vue@@ -9,7 +9,7 @@><div class="flex space-x-3"><PrincipalAvatar- :principal="inbox.activity.creator"+ :username="getUser(inbox.activity)?.title":size="'SMALL'":class="inbox.activity.comment ? '' : '-mt-0.5'"/>@@ -20,26 +20,32 @@><template v-if="showCreator(inbox.activity)"><router-link- :to="`/u/${inbox.activity.creator.id}`"+ :to="`/u/${getUserId(inbox.activity)}`"class="mr-1 font-medium text-main hover:underline"@click.stop- >{{ inbox.activity.creator.name }}</router-link+ >{{ getUser(inbox.activity)?.title }}</router-link></template><span> {{ actionSentence(inbox.activity) }}</span>- <template v-if="inbox.activity.level == 'WARN'">+ <template+ v-if="inbox.activity.level == LogEntity_Level.LEVEL_WARNING"+ ><heroicons-outline:exclamationclass="ml-1 h-6 w-6 text-warning"/></template>- <template v-else-if="inbox.activity.level == 'ERROR'">+ <template+ v-else-if="inbox.activity.level == LogEntity_Level.LEVEL_ERROR"+ ><heroicons-outline:exclamation-circleclass="ml-1 w-6 h-6 text-error"/></template></h3><p class="text-sm text-control whitespace-nowrap">- {{ humanizeTs(inbox.activity.createdTs) }}+ {{+ humanizeTs((inbox.activity.createTime?.getTime() ?? 0) / 1000)+ }}</p></div><div v-if="inbox.activity.comment" class="text-sm text-control">@@ -52,8 +58,8 @@<div v-else class="text-center text-control-light">No items</div></template>-<script lang="ts">-import { defineComponent, PropType } from "vue";+<script lang="ts" setup>+import { PropType } from "vue";import PrincipalAvatar from "../components/PrincipalAvatar.vue";import {ActivityIssueCommentCreatePayload,@@ -63,7 +69,6 @@ import {ActivityTaskStatusUpdatePayload,ActivityTaskStatementUpdatePayload,ActivityTaskEarliestAllowedTimeUpdatePayload,- Activity,Inbox,} from "../types";import { useRouter } from "vue-router";@@ -71,149 +76,181 @@ import { isEmpty } from "lodash-es";import { issueActivityActionSentence } from "../utils";import { useI18n } from "vue-i18n";import dayjs from "dayjs";-import { useCurrentUser, useInboxStore } from "@/store";+import { useCurrentUser, useInboxStore, useActivityV1Store } from "@/store";+import {+ LogEntity,+ LogEntity_Action,+ LogEntity_Level,+} from "@/types/proto/v1/logging_service";+import { extractUserResourceName, extractUserUID } from "@/utils";+import { useUserStore } from "@/store";++interface LocalInbox extends Inbox {+ activity: LogEntity;+}-export default defineComponent({- name: "InboxList",- components: { PrincipalAvatar },- props: {- inboxList: {- required: true,- type: Object as PropType<Inbox[]>,- },+defineProps({+ inboxList: {+ required: true,+ type: Object as PropType<LocalInbox[]>,},- setup() {- const { t } = useI18n();- const inboxStore = useInboxStore();- const router = useRouter();+});- const currentUser = useCurrentUser();+const { t } = useI18n();+const inboxStore = useInboxStore();+const activityV1Store = useActivityV1Store();+const router = useRouter();- const actionLink = (activity: Activity): string => {- if (activity.type.startsWith("bb.issue.")) {- return `/issue/${activity.containerId}`;- } else if (activity.type == "bb.pipeline.task.status.update") {- const payload = activity.payload as ActivityTaskStatusUpdatePayload;- return `/issue/${activity.containerId}?task=${payload.taskId}`;- }+const currentUser = useCurrentUser();- return "";- };+const getUser = (activity: LogEntity) => {+ const email = extractUserResourceName(activity.creator);+ return useUserStore().getUserByEmail(email);+};- const showCreator = (activity: Activity): boolean => {- return (- activity.type.startsWith("bb.issue.") ||- activity.type == "bb.pipeline.task.statement.update" ||- activity.type == "bb.pipeline.task.general.earliest-allowed-time.update"- );- };+const getUserId = (activity: LogEntity) => {+ const username = getUser(activity)?.name ?? "";+ return extractUserUID(username);+};- const actionSentence = (activity: Activity): string => {- if (activity.type.startsWith("bb.issue.")) {- const [tid, params] = issueActivityActionSentence(activity);- const actionStr = t(tid, params);- switch (activity.type) {- case "bb.issue.create": {- const payload = activity.payload as ActivityIssueCreatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- case "bb.issue.comment.create": {- const payload =- activity.payload as ActivityIssueCommentCreatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- case "bb.issue.field.update": {- const payload = activity.payload as ActivityIssueFieldUpdatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- case "bb.issue.status.update": {- const payload =- activity.payload as ActivityIssueStatusUpdatePayload;- return `${actionStr} - '${payload?.issueName || ""}'`;- }- }- return actionStr;+const actionLink = (activity: LogEntity): string => {+ if (activity.resource.startsWith("issues")) {+ return `/issue/${activityV1Store.getResourceId(activity)}`;+ } else if (+ activity.action == LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE+ ) {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskStatusUpdatePayload;+ return `/issue/${activityV1Store.getResourceId(activity)}?task=${+ payload.taskId+ }`;+ }++ return "";+};++const showCreator = (activity: LogEntity): boolean => {+ return (+ activity.resource.startsWith("issues") ||+ activity.action == LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE ||+ activity.action ==+ LogEntity_Action.ACTION_PIPELINE_TASK_EARLIEST_ALLOWED_TIME_UPDATE+ );+};++const actionSentence = (activity: LogEntity): string => {+ if (activity.resource.startsWith("issues")) {+ const [tid, params] = issueActivityActionSentence(activity);+ const actionStr = t(tid, params);+ switch (activity.action) {+ case LogEntity_Action.ACTION_ISSUE_CREATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityIssueCreatePayload;+ return `${actionStr} - '${payload?.issueName || ""}'`;+ }+ case LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityIssueCommentCreatePayload;+ return `${actionStr} - '${payload?.issueName || ""}'`;+ }+ case LogEntity_Action.ACTION_ISSUE_FIELD_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityIssueFieldUpdatePayload;+ return `${actionStr} - '${payload?.issueName || ""}'`;}- switch (activity.type) {- case "bb.pipeline.task.status.update": {- const payload = activity.payload as ActivityTaskStatusUpdatePayload;- let actionStr = t(`activity.sentence.changed`);- switch (payload.newStatus) {- case "PENDING": {- if (payload.oldStatus == "RUNNING") {- actionStr = t(`activity.sentence.canceled`);- } else if (payload.oldStatus == "PENDING_APPROVAL") {- actionStr = t(`activity.sentence.approved`);- }- break;- }- case "RUNNING": {- actionStr = t(`activity.sentence.started`);- break;- }- case "DONE": {- actionStr = t(`activity.sentence.completed`);- break;- }- case "FAILED": {- actionStr = t(`activity.sentence.failed`);- break;- }+ case LogEntity_Action.ACTION_ISSUE_STATUS_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityIssueStatusUpdatePayload;+ return `${actionStr} - '${payload?.issueName || ""}'`;+ }+ }+ return actionStr;+ }+ switch (activity.action) {+ case LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskStatusUpdatePayload;+ let actionStr = t(`activity.sentence.changed`);+ switch (payload.newStatus) {+ case "PENDING": {+ if (payload.oldStatus == "RUNNING") {+ actionStr = t(`activity.sentence.canceled`);+ } else if (payload.oldStatus == "PENDING_APPROVAL") {+ actionStr = t(`activity.sentence.approved`);}- return `${t("activity.subject-prefix.task")} '${- payload.taskName- }' ${actionStr} - '${payload?.issueName || ""}'`;+ break;}- case "bb.pipeline.task.statement.update": {- const payload =- activity.payload as ActivityTaskStatementUpdatePayload;- return t("activity.sentence.changed-from-to", {- name: "SQL",- oldValue: payload.oldStatement,- newValue: payload.newStatement,- });+ case "RUNNING": {+ actionStr = t(`activity.sentence.started`);+ break;}- case "bb.pipeline.task.general.earliest-allowed-time.update": {- const payload =- activity.payload as ActivityTaskEarliestAllowedTimeUpdatePayload;- const oldTs = payload.oldEarliestAllowedTs;- const newTs = payload.newEarliestAllowedTs;-- return t("activity.sentence.changed-from-to", {- name: "earliest allowed time",- oldValue: oldTs- ? dayjs(oldTs * 1000)- : t("task.earliest-allowed-time-unset"),- newValue: newTs- ? dayjs(newTs * 1000)- : t("task.earliest-allowed-time-unset"),- });+ case "DONE": {+ actionStr = t(`activity.sentence.completed`);+ break;+ }+ case "FAILED": {+ actionStr = t(`activity.sentence.failed`);+ break;}}+ return `${t("activity.subject-prefix.task")} '${+ payload.taskName+ }' ${actionStr} - '${payload?.issueName || ""}'`;+ }+ case LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskStatementUpdatePayload;+ return t("activity.sentence.changed-from-to", {+ name: "SQL",+ oldValue: payload.oldStatement,+ newValue: payload.newStatement,+ });+ }+ case LogEntity_Action.ACTION_PIPELINE_TASK_EARLIEST_ALLOWED_TIME_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskEarliestAllowedTimeUpdatePayload;+ const oldTs = payload.oldEarliestAllowedTs;+ const newTs = payload.newEarliestAllowedTs;- return "";- };+ return t("activity.sentence.changed-from-to", {+ name: "earliest allowed time",+ oldValue: oldTs+ ? dayjs(oldTs * 1000)+ : t("task.earliest-allowed-time-unset"),+ newValue: newTs+ ? dayjs(newTs * 1000)+ : t("task.earliest-allowed-time-unset"),+ });+ }+ }- const clickInbox = (inbox: Inbox) => {- if (inbox.status == "UNREAD") {- inboxStore- .patchInbox({- inboxId: inbox.id,- inboxPatch: {- status: "READ",- },- })- .then(() => {- inboxStore.fetchInboxSummaryByUser(currentUser.value.id);- });- }- const link = actionLink(inbox.activity);- if (!isEmpty(link)) {- router.push(link);- }- };+ return "";+};- return { actionLink, showCreator, actionSentence, clickInbox };- },-});+const clickInbox = (inbox: LocalInbox) => {+ if (inbox.status == "UNREAD") {+ inboxStore+ .patchInbox({+ inboxId: inbox.id,+ inboxPatch: {+ status: "READ",+ },+ })+ .then(() => {+ inboxStore.fetchInboxSummaryByUser(currentUser.value.id);+ });+ }+ const link = actionLink(inbox.activity);+ if (!isEmpty(link)) {+ router.push(link);+ }+};</script>diff --git a/frontend/src/components/Issue/IssueActivityPanel.vue b/frontend/src/components/Issue/IssueActivityPanel.vueindex a25a165e52..0af1d052b6 100644--- a/frontend/src/components/Issue/IssueActivityPanel.vue+++ b/frontend/src/components/Issue/IssueActivityPanel.vue@@ -11,7 +11,7 @@<ul><ActivityItemv-for="(item, index) in activityList"- :key="item.activity.id"+ :key="item.activity.name":activity-list="activityList":issue="issue":index="index"@@ -23,7 +23,7 @@<templatev-if="state.editCommentMode &&- state.activeActivity?.id === item.activity.id+ state.activeActivity?.name === item.activity.name"><button@@ -59,7 +59,7 @@<divv-if="state.editCommentMode &&- state.activeActivity?.id === item.activity.id+ state.activeActivity?.name === item.activity.name"class="mt-2 text-sm text-control whitespace-pre-wrap">@@ -155,17 +155,17 @@ import { useRoute } from "vue-router";import UserAvatar from "../User/UserAvatar.vue";import type {Issue,- Activity,ActivityIssueFieldUpdatePayload,ActivityCreate,IssueSubscriber,ActivityIssueCommentCreatePayload,} from "@/types";-import { extractUserUID, sizeToFit } from "@/utils";+import { extractUserResourceName, sizeToFit } from "@/utils";import { IssueBuiltinFieldId } from "@/plugins";import {useIssueSubscriberStore,- useActivityStore,+ useActivityLegacyStore,+ useActivityV1Store,useCurrentUserV1,useCurrentUser,} from "@/store";@@ -177,13 +177,16 @@ import {Comment as ActivityComment,isSimilarActivity,} from "./activity";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";+import { getLogId } from "@/store/modules/v1/common";interface LocalState {editCommentMode: boolean;- activeActivity?: Activity;+ activeActivity?: LogEntity;}-const activityStore = useActivityStore();+const activityLegacyStore = useActivityLegacyStore();+const activityV1Store = useActivityV1Store();const route = useRoute();const newComment = ref("");@@ -224,24 +227,24 @@ const currentUser = useCurrentUser();const currentUserV1 = useCurrentUserV1();const prepareActivityList = () => {- activityStore.fetchActivityListForIssue(issue.value);+ activityV1Store.fetchActivityListForIssue(issue.value);};watchEffect(prepareActivityList);// Need to use computed to make list reactive to activity list changes.const activityList = computed((): DistinctActivity[] => {- const list = activityStore+ const list = activityV1Store.getActivityListByIssue(issue.value.id)- .filter((activity: Activity) => {- if (activity.type === "bb.issue.approval.notify") {+ .filter((activity) => {+ if (activity.action === LogEntity_Action.ACTION_ISSUE_APPROVAL_NOTIFY) {return false;}- if (activity.type === "bb.issue.field.update") {+ if (activity.action === LogEntity_Action.ACTION_ISSUE_FIELD_UPDATE) {const containUserVisibleChange =- (activity.payload as ActivityIssueFieldUpdatePayload).fieldId !==- IssueBuiltinFieldId.SUBSCRIBER_LIST;+ (JSON.parse(activity.payload) as ActivityIssueFieldUpdatePayload)+ .fieldId !== IssueBuiltinFieldId.SUBSCRIBER_LIST;return containUserVisibleChange;}return true;@@ -282,7 +285,7 @@ const doCreateComment = (comment: string, clear = true) => {containerId: issue.value.id,comment,};- activityStore.createActivity(createActivity).then(() => {+ activityLegacyStore.createActivity(createActivity).then(() => {if (clear) {newComment.value = "";nextTick(() => sizeToFit(newCommentTextArea.value));@@ -303,23 +306,23 @@ const doCreateComment = (comment: string, clear = true) => {});};-const allowEditActivity = (activity: Activity) => {- if (activity.type !== "bb.issue.comment.create") {+const allowEditActivity = (activity: LogEntity) => {+ if (activity.action !== LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE) {return false;}- if (- extractUserUID(currentUserV1.value.name) !== String(activity.creator.id)- ) {+ if (currentUserV1.value.email !== extractUserResourceName(activity.creator)) {return false;}- const payload = activity.payload as ActivityIssueCommentCreatePayload;+ const payload = JSON.parse(+ activity.payload+ ) as ActivityIssueCommentCreatePayload;if (payload && payload.externalApprovalEvent) {return false;}return true;};-const onUpdateComment = (activity: Activity) => {+const onUpdateComment = (activity: LogEntity) => {editComment.value = activity.comment;state.activeActivity = activity;state.editCommentMode = true;@@ -329,9 +332,14 @@ const onUpdateComment = (activity: Activity) => {};const doUpdateComment = () => {- activityStore+ if (!state.activeActivity) {+ return;+ }+ const activityId = getLogId(state.activeActivity.name);+ activityLegacyStore.updateComment({- activityId: state.activeActivity!.id,+ activityId,+ issueId: issue.value.id,updatedComment: editComment.value,}).then(() => {diff --git a/frontend/src/components/Issue/activity/ActionCreator.vue b/frontend/src/components/Issue/activity/ActionCreator.vueindex d8b474b0bf..fe1283f815 100644--- a/frontend/src/components/Issue/activity/ActionCreator.vue+++ b/frontend/src/components/Issue/activity/ActionCreator.vue@@ -1,14 +1,14 @@<template><router-link- v-if="activity.creator.id !== SYSTEM_BOT_ID"- :to="`/u/${activity.creator.id}`"+ v-if="userEmail !== SYSTEM_BOT_EMAIL"+ :to="`/u/${userId}`"class="font-medium text-main whitespace-nowrap hover:underline"exact-active-class=""- >{{ activity.creator.name }}</router-link+ >{{ user?.title }}</router-link><div v-else class="inline-flex items-center"><span class="font-medium text-main whitespace-nowrap">- {{ activity.creator.name }}+ {{ user?.title }}</span><spanclass="ml-0.5 inline-flex items-center px-1 py-0.5 rounded-lg text-xs font-semibold bg-green-100 text-green-800"@@ -19,9 +19,26 @@</template><script lang="ts" setup>-import { Activity, SYSTEM_BOT_ID } from "@/types";+import { computed } from "vue";+import { SYSTEM_BOT_EMAIL } from "@/types";+import { LogEntity } from "@/types/proto/v1/logging_service";+import { extractUserResourceName, extractUserUID } from "@/utils";+import { useUserStore } from "@/store";-defineProps<{- activity: Activity;+const props = defineProps<{+ activity: LogEntity;}>();++const userEmail = computed(() => {+ return extractUserResourceName(props.activity.creator);+});++const user = computed(() => {+ return useUserStore().getUserByEmail(userEmail.value);+});++const userId = computed(() => {+ const username = user.value?.name ?? "";+ return extractUserUID(username);+});</script>diff --git a/frontend/src/components/Issue/activity/ActionIcon.vue b/frontend/src/components/Issue/activity/ActionIcon.vueindex e716545cce..b8f0171833 100644--- a/frontend/src/components/Issue/activity/ActionIcon.vue+++ b/frontend/src/components/Issue/activity/ActionIcon.vue@@ -12,7 +12,7 @@class="w-7 h-7 bg-white rounded-full ring-4 ring-white flex items-center justify-center"><PrincipalAvatar- :principal="activity.creator"+ :username="user?.title"override-class="w-7 h-7 font-medium"override-text-size="0.8rem"/>@@ -105,14 +105,16 @@<script lang="ts" setup>import { computed } from "vue";import {- Activity,ActivityIssueCommentCreatePayload,ActivityStageStatusUpdatePayload,ActivityTaskStatusUpdatePayload,- SYSTEM_BOT_ID,+ SYSTEM_BOT_EMAIL,} from "@/types";import PrincipalAvatar from "@/components/PrincipalAvatar.vue";import { SkipIcon } from "@/components/Icon";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";+import { extractUserResourceName } from "@/utils";+import { useUserStore } from "@/store";type ActionIconType =| "avatar"@@ -131,17 +133,26 @@ type ActionIconType =| "commit";const props = defineProps<{- activity: Activity;+ activity: LogEntity;}>();+const user = computed(() => {+ const email = extractUserResourceName(props.activity.creator);+ return useUserStore().getUserByEmail(email);+});+const icon = computed((): ActionIconType => {const { activity } = props;- if (activity.type == "bb.issue.create") {+ if (activity.action == LogEntity_Action.ACTION_ISSUE_CREATE) {return "create";- } else if (activity.type == "bb.issue.field.update") {+ } else if (activity.action == LogEntity_Action.ACTION_ISSUE_FIELD_UPDATE) {return "update";- } else if (activity.type == "bb.pipeline.task.status.update") {- const payload = activity.payload as ActivityTaskStatusUpdatePayload;+ } else if (+ activity.action == LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE+ ) {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskStatusUpdatePayload;switch (payload.newStatus) {case "PENDING": {if (payload.oldStatus == "RUNNING") {@@ -171,8 +182,12 @@ const icon = computed((): ActionIconType => {return "avatar"; // stale approval dismissed.}}- } else if (activity.type == "bb.pipeline.stage.status.update") {- const payload = activity.payload as ActivityStageStatusUpdatePayload;+ } else if (+ activity.action == LogEntity_Action.ACTION_PIPELINE_STAGE_STATUS_UPDATE+ ) {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityStageStatusUpdatePayload;switch (payload.stageStatusUpdateType) {case "BEGIN": {return "run";@@ -181,16 +196,23 @@ const icon = computed((): ActionIconType => {return "complete";}}- } else if (activity.type == "bb.pipeline.task.file.commit") {+ } else if (+ activity.action == LogEntity_Action.ACTION_PIPELINE_TASK_FILE_COMMIT+ ) {return "commit";- } else if (activity.type == "bb.pipeline.task.statement.update") {+ } else if (+ activity.action == LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE+ ) {return "update";} else if (- activity.type == "bb.pipeline.task.general.earliest-allowed-time.update"+ activity.action ==+ LogEntity_Action.ACTION_PIPELINE_TASK_EARLIEST_ALLOWED_TIME_UPDATE) {return "update";- } else if (activity.type === "bb.issue.comment.create") {- const payload = activity.payload as ActivityIssueCommentCreatePayload;+ } else if (activity.action === LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE) {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityIssueCommentCreatePayload;if (payload.approvalEvent) {const { status } = payload.approvalEvent;switch (status) {@@ -204,6 +226,8 @@ const icon = computed((): ActionIconType => {}}- return activity.creator.id == SYSTEM_BOT_ID ? "system" : "avatar";+ return extractUserResourceName(activity.creator) == SYSTEM_BOT_EMAIL+ ? "system"+ : "avatar";});</script>diff --git a/frontend/src/components/Issue/activity/ActionSentence.vue b/frontend/src/components/Issue/activity/ActionSentence.vueindex 00bae90e83..85e3950665 100644--- a/frontend/src/components/Issue/activity/ActionSentence.vue+++ b/frontend/src/components/Issue/activity/ActionSentence.vue@@ -8,7 +8,6 @@ import dayjs from "dayjs";import { Translation, useI18n } from "vue-i18n";import {- Activity,ActivityIssueCommentCreatePayload,ActivityStageStatusUpdatePayload,ActivityTaskEarliestAllowedTimeUpdatePayload,@@ -16,7 +15,8 @@ import {ActivityTaskStatementUpdatePayload,ActivityTaskStatusUpdatePayload,Issue,- SYSTEM_BOT_ID,+ SYSTEM_BOT_EMAIL,+ empty,} from "@/types";import {findStageById,@@ -27,12 +27,14 @@ import { useSheetV1Store, useSheetStatementByUid } from "@/store";import TaskName from "./TaskName.vue";import SQLPreviewPopover from "@/components/misc/SQLPreviewPopover.vue";import StageName from "./StageName.vue";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";+import { extractUserResourceName } from "@/utils";type RenderedContent = string | ReturnType<typeof h>;const props = defineProps({activity: {- type: Object as PropType<Activity>,+ type: Object as PropType<LogEntity>,required: true,},issue: {@@ -50,9 +52,11 @@ const renderActionSentence = () => {};const { activity, issue } = props;- if (activity.type.startsWith("bb.issue.")) {- if (activity.type === "bb.issue.comment.create") {- const payload = activity.payload as ActivityIssueCommentCreatePayload;+ if (activity.resource.startsWith("issues")) {+ if (activity.action === LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE) {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityIssueCommentCreatePayload;if (payload.externalApprovalEvent) {if (payload.externalApprovalEvent.action == "REJECT") {let imName = "";@@ -88,13 +92,18 @@ const renderActionSentence = () => {const [tid, params] = issueActivityActionSentence(activity);return renderSpan(t(tid, params));}- switch (activity.type) {- case "bb.pipeline.task.status.update": {- const payload = activity.payload as ActivityTaskStatusUpdatePayload;+ switch (activity.action) {+ case LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskStatusUpdatePayload;if (payload.newStatus === "PENDING_APPROVAL") {// stale approval dismissed.- const task = findTaskById(issue.pipeline, payload.taskId);+ const task = findTaskById(+ issue.pipeline ?? empty("PIPELINE"),+ payload.taskId+ );const taskName = t("activity.sentence.task-name", {name: task.name,});@@ -143,7 +152,10 @@ const renderActionSentence = () => {default:params.verb = t("activity.sentence.changed");}- const task = findTaskById(issue.pipeline, payload.taskId);+ const task = findTaskById(+ issue.pipeline ?? empty("PIPELINE"),+ payload.taskId+ );if (task) {params.target = h(TaskName, { issue, task });}@@ -151,9 +163,14 @@ const renderActionSentence = () => {tag: "span",});}- case "bb.pipeline.stage.status.update": {- const payload = activity.payload as ActivityStageStatusUpdatePayload;- const stage = findStageById(issue.pipeline, payload.stageId);+ case LogEntity_Action.ACTION_PIPELINE_STAGE_STATUS_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityStageStatusUpdatePayload;+ const stage = findStageById(+ issue.pipeline ?? empty("PIPELINE"),+ payload.stageId+ );const params: VerbTypeTarget = {activity,verb: "",@@ -178,8 +195,10 @@ const renderActionSentence = () => {tag: "span",});}- case "bb.pipeline.task.file.commit": {- const payload = activity.payload as ActivityTaskFileCommitPayload;+ case LogEntity_Action.ACTION_PIPELINE_TASK_FILE_COMMIT: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskFileCommitPayload;// return `committed ${payload.filePath} to ${payload.branch}@${payload.repositoryFullPath}`;return t("activity.sentence.committed-to-at", {file: payload.filePath,@@ -187,8 +206,10 @@ const renderActionSentence = () => {repo: payload.repositoryFullPath,});}- case "bb.pipeline.task.statement.update": {- const payload = activity.payload as ActivityTaskStatementUpdatePayload;+ case LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskStatementUpdatePayload;const oldStatement =useSheetStatementByUid(payload.oldSheetId).value ||payload.oldStatement;@@ -211,9 +232,10 @@ const renderActionSentence = () => {));}- case "bb.pipeline.task.general.earliest-allowed-time.update": {- const payload =- activity.payload as ActivityTaskEarliestAllowedTimeUpdatePayload;+ case LogEntity_Action.ACTION_PIPELINE_TASK_EARLIEST_ALLOWED_TIME_UPDATE: {+ const payload = JSON.parse(+ activity.payload+ ) as ActivityTaskEarliestAllowedTimeUpdatePayload;const newVal = payload.newEarliestAllowedTs;const oldVal = payload.oldEarliestAllowedTs;return t("activity.sentence.changed-from-to", {@@ -226,8 +248,8 @@ const renderActionSentence = () => {return "";};-const maybeAutomaticallyVerb = (activity: Activity, verb: string): string => {- if (activity.creator.id !== SYSTEM_BOT_ID) {+const maybeAutomaticallyVerb = (activity: LogEntity, verb: string): string => {+ if (extractUserResourceName(activity.creator) !== SYSTEM_BOT_EMAIL) {return verb;}return t("activity.sentence.xxx-automatically", {@@ -236,7 +258,7 @@ const maybeAutomaticallyVerb = (activity: Activity, verb: string): string => {};type VerbTypeTarget = {- activity: Activity;+ activity: LogEntity;verb: RenderedContent;type: RenderedContent;target?: RenderedContent;@@ -244,7 +266,7 @@ type VerbTypeTarget = {const renderVerbTypeTarget = (params: VerbTypeTarget, props: object = {}) => {const keypath =- params.activity.creator.id === SYSTEM_BOT_ID+ extractUserResourceName(params.activity.creator) === SYSTEM_BOT_EMAIL? "activity.sentence.verb-type-target-by-system-bot": "activity.sentence.verb-type-target-by-people";return h(@@ -280,12 +302,16 @@ watch(async () => {const activity = props.activity;// Prepare sheet data for renderering.- if (activity.type === "bb.pipeline.task.statement.update") {+ if (+ activity.action === LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE+ ) {sheetV1Store.getOrFetchSheetByUid(- (activity.payload as ActivityTaskStatementUpdatePayload).newSheetId+ (JSON.parse(activity.payload) as ActivityTaskStatementUpdatePayload)+ .newSheetId);sheetV1Store.getOrFetchSheetByUid(- (activity.payload as ActivityTaskStatementUpdatePayload).oldSheetId+ (JSON.parse(activity.payload) as ActivityTaskStatementUpdatePayload)+ .oldSheetId);}},diff --git a/frontend/src/components/Issue/activity/ActivityAction.vue b/frontend/src/components/Issue/activity/ActivityAction.vueindex c2d6aea431..05b91f9e73 100644--- a/frontend/src/components/Issue/activity/ActivityAction.vue+++ b/frontend/src/components/Issue/activity/ActivityAction.vue@@ -4,24 +4,30 @@<div class="text-sm text-control-light space-x-1"><ActionCreatorv-if="- activity.creator.id !== SYSTEM_BOT_ID ||- activity.type === 'bb.issue.comment.create'+ extractUserResourceName(activity.creator) !== SYSTEM_BOT_EMAIL ||+ activity.action === LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE":activity="activity"/><ActionSentence :issue="issue" :activity="activity" />- <HumanizeTs :ts="activity.createdTs" class="ml-1" />+ <HumanizeTs+ :ts="(activity.createTime?.getTime() ?? 0) / 1000"+ class="ml-1"+ /><spanv-if="- activity.createdTs != activity.updatedTs &&- activity.type == 'bb.issue.comment.create'+ activity.createTime?.getTime() !== activity.updateTime?.getTime() &&+ activity.action == LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE"><span>({{ $t("common.edited") }}</span>- <HumanizeTs :ts="activity.updatedTs" class="ml-1" />)+ <HumanizeTs+ :ts="(activity.updateTime?.getTime() ?? 0) / 1000"+ class="ml-1"+ />)</span><span@@ -43,7 +49,11 @@<Comment :activity="activity" /></slot>- <template v-if="activity.type == 'bb.pipeline.task.file.commit'">+ <template+ v-if="+ activity.action == LogEntity_Action.ACTION_PIPELINE_TASK_FILE_COMMIT+ "+ ><a:href="fileCommitActivityUrl(activity)"target="__blank"@@ -60,23 +70,24 @@<script lang="ts" setup>import {Issue,- Activity,ActivityTaskFileCommitPayload,- SYSTEM_BOT_ID,+ SYSTEM_BOT_EMAIL,} from "@/types";import Comment from "./Comment";import ActionCreator from "./ActionCreator.vue";import ActionSentence from "./ActionSentence.vue";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";+import { extractUserResourceName } from "@/utils";defineProps<{issue: Issue;index: number;- activity: Activity;- similar: Activity[];+ activity: LogEntity;+ similar: LogEntity[];}>();-const fileCommitActivityUrl = (activity: Activity) => {- const payload = activity.payload as ActivityTaskFileCommitPayload;+const fileCommitActivityUrl = (activity: LogEntity) => {+ const payload = JSON.parse(activity.payload) as ActivityTaskFileCommitPayload;if (payload.vcsInstanceUrl.includes("https://github.com"))return `${payload.vcsInstanceUrl}/${payload.repositoryFullPath}/commit/${payload.commitId}`;return `${payload.vcsInstanceUrl}/${payload.repositoryFullPath}/-/commit/${payload.commitId}`;diff --git a/frontend/src/components/Issue/activity/ActivityItem.vue b/frontend/src/components/Issue/activity/ActivityItem.vueindex 1369b25ac9..c898edc8f1 100644--- a/frontend/src/components/Issue/activity/ActivityItem.vue+++ b/frontend/src/components/Issue/activity/ActivityItem.vue@@ -1,6 +1,6 @@<template><li>- <div :id="`#activity${activity.id}`" class="relative pb-4">+ <div :id="`#${activity.name}`" class="relative pb-4"><spanv-if="index !== activityList.length - 1"class="absolute left-4 -ml-px h-full w-0.5 bg-block-border"@@ -29,16 +29,17 @@</template><script lang="ts" setup>-import { Issue, Activity } from "@/types";+import { Issue } from "@/types";import ActionIcon from "./ActionIcon.vue";import ActivityAction from "./ActivityAction.vue";import { DistinctActivity } from "./common";+import { LogEntity } from "@/types/proto/v1/logging_service";defineProps<{issue: Issue;activityList: DistinctActivity[];index: number;- activity: Activity;- similar: Activity[];+ activity: LogEntity;+ similar: LogEntity[];}>();</script>diff --git a/frontend/src/components/Issue/activity/Comment.ts b/frontend/src/components/Issue/activity/Comment.tsindex 1688d99964..7654e2f110 100644--- a/frontend/src/components/Issue/activity/Comment.ts+++ b/frontend/src/components/Issue/activity/Comment.ts@@ -1,12 +1,12 @@import { h, defineComponent, PropType } from "vue";-import { Activity } from "@/types";+import { LogEntity } from "@/types/proto/v1/logging_service";// Render activity comments and render "#{issue_id}" patterns as issue links.export default defineComponent({name: "ActivityComment",props: {activity: {- type: Object as PropType<Activity>,+ type: Object as PropType<LogEntity>,required: true,},},diff --git a/frontend/src/components/Issue/activity/TaskName.vue b/frontend/src/components/Issue/activity/TaskName.vueindex fdad70f53c..57f498e842 100644--- a/frontend/src/components/Issue/activity/TaskName.vue+++ b/frontend/src/components/Issue/activity/TaskName.vue@@ -40,9 +40,10 @@ const link = computed(() => {task: task.id,};- const stageIndex = issue.pipeline.stageList.findIndex((stage) => {- return stage.taskList.findIndex((t) => t.id === task.id) >= 0;- });+ const stageIndex =+ issue.pipeline?.stageList.findIndex((stage) => {+ return stage.taskList.findIndex((t) => t.id === task.id) >= 0;+ }) ?? -1;if (stageIndex >= 0) {query.stage = stageIndex + 1;}diff --git a/frontend/src/components/Issue/activity/common.ts b/frontend/src/components/Issue/activity/common.tsindex cd62485b2c..3372d58712 100644--- a/frontend/src/components/Issue/activity/common.ts+++ b/frontend/src/components/Issue/activity/common.ts@@ -1,24 +1,28 @@import type {- Activity,ActivityTaskStatementUpdatePayload,ActivityTaskStatusUpdatePayload,} from "@/types";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";export type DistinctActivity = {- activity: Activity;- similar: Activity[];+ activity: LogEntity;+ similar: LogEntity[];};-export const isSimilarActivity = (a: Activity, b: Activity): boolean => {+export const isSimilarActivity = (a: LogEntity, b: LogEntity): boolean => {// Now, we recognize two "Change SQL from .... to ...." activities are similar// when they have the same "from" and "to" values.if (- a.type === "bb.pipeline.task.statement.update" &&- b.type === "bb.pipeline.task.statement.update" &&- a.containerId === b.containerId+ a.action === LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE &&+ a.action === b.action &&+ a.resource === b.resource) {- const payloadA = a.payload as ActivityTaskStatementUpdatePayload;- const payloadB = b.payload as ActivityTaskStatementUpdatePayload;+ const payloadA = JSON.parse(+ a.payload+ ) as ActivityTaskStatementUpdatePayload;+ const payloadB = JSON.parse(+ b.payload+ ) as ActivityTaskStatementUpdatePayload;if (payloadA.oldStatement === payloadB.oldStatement &&payloadB.newStatement === payloadB.newStatement@@ -28,13 +32,13 @@ export const isSimilarActivity = (a: Activity, b: Activity): boolean => {}if (- a.type === "bb.pipeline.task.status.update" &&- b.type === "bb.pipeline.task.status.update" &&- a.containerId === b.containerId &&- a.creator.id === b.creator.id+ a.action === LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE &&+ a.action === b.action &&+ a.resource === b.resource &&+ a.creator === b.creator) {- const payloadA = a.payload as ActivityTaskStatusUpdatePayload;- const payloadB = b.payload as ActivityTaskStatusUpdatePayload;+ const payloadA = JSON.parse(a.payload) as ActivityTaskStatusUpdatePayload;+ const payloadB = JSON.parse(b.payload) as ActivityTaskStatusUpdatePayload;if (payloadA.oldStatus === payloadB.oldStatus &&payloadB.newStatus === payloadB.newStatusdiff --git a/frontend/src/components/Issue/rollback/RollbackStatus.vue b/frontend/src/components/Issue/rollback/RollbackStatus.vueindex 2120dbcc09..5ca450efdf 100644--- a/frontend/src/components/Issue/rollback/RollbackStatus.vue+++ b/frontend/src/components/Issue/rollback/RollbackStatus.vue@@ -81,8 +81,9 @@ import { useRollbackLogic } from "./common";import IssueStatusIcon from "../IssueStatusIcon.vue";import LogButton from "./LogButton.vue";import LoggingButton from "./LoggingButton.vue";-import { useActivityStore, useIssueById, useSheetV1Store } from "@/store";+import { useActivityV1Store, useIssueById, useSheetV1Store } from "@/store";import LearnMoreLink from "@/components/LearnMoreLink.vue";+import { LogEntity_Action } from "@/types/proto/v1/logging_service";type LocalState = {loading: boolean;@@ -117,14 +118,15 @@ const allowPreviewRollback = computed(() => {});const taskRollbackBy = computed((): TaskRollbackBy | undefined => {- const activityList = useActivityStore().getActivityListByIssue(+ const activityList = useActivityV1Store().getActivityListByIssue(issue.value.id);// Find the latest comment activity with TaskRollbackBy struct if possible.for (let i = activityList.length - 1; i >= 0; i--) {const activity = activityList[i];- if (activity.type !== "bb.issue.comment.create") continue;- const payload = activity.payload as+ if (activity.action !== LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE)+ continue;+ const payload = JSON.parse(activity.payload) as| ActivityIssueCommentCreatePayload| undefined;if (!payload) continue;diff --git a/frontend/src/components/Issue/rollback/common.ts b/frontend/src/components/Issue/rollback/common.tsindex 60e3558a6f..ba825e5668 100644--- a/frontend/src/components/Issue/rollback/common.ts+++ b/frontend/src/components/Issue/rollback/common.ts@@ -25,7 +25,7 @@ import {} from "@/utils";import { flattenTaskList, useIssueLogic } from "../logic";import {- useActivityStore,+ useActivityLegacyStore,useCurrentUserV1,useDatabaseV1Store,useIssueStore,@@ -201,7 +201,7 @@ export const useRollbackLogic = () => {payload,};try {- await useActivityStore().createActivity(createActivity);+ await useActivityLegacyStore().createActivity(createActivity);} catch {// do nothing// failing to comment to won't be too bad@@ -284,7 +284,7 @@ export const maybeCreateBackTraceComments = async (newIssue: Issue) => {payload,};try {- await useActivityStore().createActivity(createActivity);+ await useActivityLegacyStore().createActivity(createActivity);} catch {// do nothing// failing to comment to won't be too baddiff --git a/frontend/src/components/PagedActivityTable.vue b/frontend/src/components/PagedActivityTable.vueindex bbf7dd6549..3feaf7e7af 100644--- a/frontend/src/components/PagedActivityTable.vue+++ b/frontend/src/components/PagedActivityTable.vue@@ -1,9 +1,5 @@<template>- <slot- name="table"- :activity-list="state.activityList"- :loading="state.loading"- />+ <slot name="table" :list="state.auditLogList" :loading="state.loading" /><divv-if="state.loading"@@ -31,14 +27,15 @@<script lang="ts" setup>import { computed, PropType, reactive, watch } from "vue";-import { useIsLoggedIn, useActivityStore } from "@/store";-import { Activity, ActivityFind } from "@/types";+import { useIsLoggedIn, useActivityV1Store } from "@/store";+import { FindActivityMessage } from "@/types";import { useSessionStorage } from "@vueuse/core";import { stringify } from "qs";+import { LogEntity } from "@/types/proto/v1/logging_service";type LocalState = {loading: boolean;- activityList: Activity[];+ auditLogList: LogEntity[];paginationToken: string;hasMore: boolean;};@@ -67,10 +64,9 @@ const props = defineProps({required: true,},activityFind: {- type: Object as PropType<ActivityFind>,+ type: Object as PropType<FindActivityMessage>,default: () => ({- typePrefix: "",- order: "DESC",+ order: "desc",}),},pageSize: {@@ -85,20 +81,17 @@ const props = defineProps({const state = reactive<LocalState>({loading: false,- activityList: [],+ auditLogList: [],paginationToken: "",hasMore: true,});-const sessionState = useSessionStorage<SessionState>(- `bb.page-activity-table.${props.sessionKey}`,- {- page: 1,- updatedTs: 0,- }-);+const sessionState = useSessionStorage<SessionState>(props.sessionKey, {+ page: 1,+ updatedTs: 0,+});-const activityStore = useActivityStore();+const activityV1Store = useActivityV1Store();const isLoggedIn = useIsLoggedIn();const limit = computed(() => {@@ -116,7 +109,7 @@ const condition = computed(() => {});});-const fetchData = (refresh = false) => {+const fetchData = async (refresh = false) => {state.loading = true;const isFirstFetch = state.paginationToken === "";@@ -126,32 +119,33 @@ const fetchData = (refresh = false) => {: // Always load one page if NOT the first fetchlimit.value;- activityStore- .fetchPagedActivityList({- ...props.activityFind,- limit: expectedRowCount,- token: state.paginationToken,- })- .then(({ nextToken, activityList }) => {- if (refresh) {- state.activityList = activityList;- } else {- state.activityList.push(...activityList);- }-- if (activityList.length < expectedRowCount) {- state.hasMore = false;- } else if (!isFirstFetch) {- // If we didn't reach the end, memorize we've clicked the "load more" button.- sessionState.value.page++;- }-- sessionState.value.updatedTs = Date.now();- state.paginationToken = nextToken;- })- .finally(() => {- state.loading = false;- });+ try {+ const { nextPageToken, logEntities } =+ await activityV1Store.fetchActivityList({+ ...props.activityFind,+ pageSize: expectedRowCount,+ pageToken: state.paginationToken,+ });+ if (refresh) {+ state.auditLogList = logEntities;+ } else {+ state.auditLogList.push(...logEntities);+ }++ if (logEntities.length < expectedRowCount) {+ state.hasMore = false;+ } else if (!isFirstFetch) {+ // If we didn't reach the end, memorize we've clicked the "load more" button.+ sessionState.value.page++;+ }++ sessionState.value.updatedTs = Date.now();+ state.paginationToken = nextPageToken;+ } catch (e) {+ console.error(e);+ } finally {+ state.loading = false;+ }};const resetSession = () => {diff --git a/frontend/src/components/PrincipalAvatar.vue b/frontend/src/components/PrincipalAvatar.vueindex 97949f66c8..fde86a66b0 100644--- a/frontend/src/components/PrincipalAvatar.vue+++ b/frontend/src/components/PrincipalAvatar.vue@@ -1,6 +1,6 @@<template><BBAvatar- :username="username"+ :username="name":size="size":override-class="overrideClass":override-text-size="overrideTextSize"@@ -23,6 +23,10 @@ export default defineComponent({type: Object as PropType<Principal>,default: () => unknown("PRINCIPAL"),},+ username: {+ type: String,+ default: "?",+ },size: {type: String as PropType<BBAvatarSizeType>,default: "NORMAL",@@ -37,13 +41,13 @@ export default defineComponent({},},setup(props) {- const username = computed((): string => {+ const name = computed((): string => {if (props.principal.id == UNKNOWN_ID) {- return "?";+ return props.username;}return props.principal.name;});- return { username };+ return { name };},});</script>diff --git a/frontend/src/components/ProjectActivityPanel.vue b/frontend/src/components/ProjectActivityPanel.vueindex 6814559e35..00ea3e78af 100644--- a/frontend/src/components/ProjectActivityPanel.vue+++ b/frontend/src/components/ProjectActivityPanel.vue@@ -4,27 +4,24 @@<p class="text-lg font-medium leading-7 text-main">{{ $t("common.activity") }}</p>- <PagedActivityTableVue+ <PagedActivityTable:activity-find="{- typePrefix: ['bb.project.', 'bb.database.'],- container: project.uid,- order: 'DESC',+ resource: project.name,+ order: 'desc',}"- session-key="project-activity-panel"+ session-key="bb.page-activity-table.project-activity-panel":page-size="10">- <template #table="{ activityList }">- <ActivityTable :activity-list="activityList" />+ <template #table="{ list }">+ <ActivityTable :activity-list="list" /></template>- </PagedActivityTableVue>+ </PagedActivityTable></div></div></template><script lang="ts" setup>import { PropType } from "vue";-import ActivityTable from "../components/ActivityTable.vue";-import PagedActivityTableVue from "@/components/PagedActivityTable.vue";import { Project } from "@/types/proto/v1/project_service";defineProps({diff --git a/frontend/src/components/ProjectOverviewPanel.vue b/frontend/src/components/ProjectOverviewPanel.vueindex 3cfcdc1a98..30e1276cea 100644--- a/frontend/src/components/ProjectOverviewPanel.vue+++ b/frontend/src/components/ProjectOverviewPanel.vue@@ -7,20 +7,19 @@<div class="relative"><!-- show the first 5 activities --><!-- But won't show "Load more", since we have a "View all" link below -->- <PagedActivityTableVue+ <PagedActivityTable:activity-find="{- typePrefix: ['bb.project.', 'bb.database.'],- container: project.uid,- order: 'DESC',+ resource: project.name,+ order: 'desc',}"- session-key="project-activity"+ session-key="bb.page-activity-table.project-activity":page-size="5":hide-load-more="true">- <template #table="{ activityList }">- <ActivityTable :activity-list="activityList" />+ <template #table="{ list }">+ <ActivityTable :activity-list="list" /></template>- </PagedActivityTableVue>+ </PagedActivityTable><divv-if="state.isFetchingActivityList"class="absolute inset-0 flex flex-col items-center justify-center bg-white/70"@@ -119,11 +118,9 @@<script lang="ts" setup>import { reactive, PropType } from "vue";-import ActivityTable from "../components/ActivityTable.vue";import { IssueTable } from "../components/Issue";import { Issue } from "../types";import PagedIssueTable from "@/components/Issue/table/PagedIssueTable.vue";-import PagedActivityTableVue from "./PagedActivityTable.vue";import { featureToRef } from "@/store";import { Project } from "@/types/proto/v1/project_service";diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.tsindex 9c0b6316ca..f797d544f5 100644--- a/frontend/src/store/modules/activity.ts+++ b/frontend/src/store/modules/activity.ts@@ -1,196 +1,11 @@import { defineStore } from "pinia";import axios from "axios";-import { stringify } from "qs";import { cloneDeep } from "lodash-es";-import {- Activity,- ActivityCreate,- ActivityId,- ActivityPatch,- ActivityState,- Issue,- IssueId,- PrincipalId,- ResourceObject,- UNKNOWN_ID,- isPagedResponse,- ResourceIdentifier,- empty,- ActivityFind,-} from "@/types";-import { extractUserUID, isDatabaseRelatedIssueType } from "@/utils";-import { convertEntityList } from "./utils";-import { useCurrentUserV1 } from "./auth";-import { getPrincipalFromIncludedList } from "./principal";-import { useIssueStore } from "./issue";+import { ActivityCreate, ActivityId, ActivityPatch, IssueId } from "@/types";+import { useActivityV1Store } from "./v1";-function convert(- activity: ResourceObject,- includedList: ResourceObject[]-): Activity {- const payload = activity.attributes.payload- ? JSON.parse((activity.attributes.payload as string) || "{}")- : {};- return {- ...(activity.attributes as Omit<Activity, "id" | "creator" | "updater">),- creator: getPrincipalFromIncludedList(- activity.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- activity.relationships!.updater.data,- includedList- ),- id: parseInt(activity.id),- payload,- };-}--function getActivityFromIncludedList(- data:- | ResourceIdentifier<ResourceObject>- | ResourceIdentifier<ResourceObject>[]- | undefined,- includedList: ResourceObject[]-): Activity {- if (data == null) {- return empty("ACTIVITY");- }- for (const item of includedList || []) {- if (item.type !== "activity") {- continue;- }- if (item.id == (data as ResourceIdentifier).id) {- return convert(item, includedList);- }- }- return empty("ACTIVITY");-}--export const useActivityStore = defineStore("activity", {- state: (): ActivityState => ({- activityListByUser: new Map(),- activityListByIssue: new Map(),- }),+export const useActivityLegacyStore = defineStore("activity", {actions: {- convert(- activity: ResourceObject,- includedList: ResourceObject[]- ): Activity {- return convert(activity, includedList || []);- },- getActivityListByUser(userId: PrincipalId): Activity[] {- return this.activityListByUser.get(userId) || [];- },- getActivityListByIssue(issueId: IssueId): Activity[] {- return this.activityListByIssue.get(issueId) || [];- },- setActivityListForUser({- userId,- activityList,- }: {- userId: PrincipalId;- activityList: Activity[];- }) {- this.activityListByUser.set(userId, activityList);- },- setActivityListForIssue({- issueId,- activityList,- }: {- issueId: IssueId;- activityList: Activity[];- }) {- this.activityListByIssue.set(issueId, activityList);- },- async fetchActivityListForUser(userId: PrincipalId) {- const data = (await axios.get(`/api/activity?order=DESC`)).data;- const activityList: Activity[] = data.data.map(- (activity: ResourceObject) => {- return convert(activity, data.included);- }- );-- this.setActivityListForUser({ userId, activityList });- return activityList;- },- async fetchPagedActivityList(params: ActivityFind) {- const url = `/api/activity?${stringify(params, {- arrayFormat: "repeat",- })}`;- const responseData = (await axios.get(url)).data;- const activityList = convertEntityList(- responseData,- "activityList",- convert,- getActivityFromIncludedList- );- const nextToken = isPagedResponse(responseData, "activityList")- ? responseData.data.attributes.nextToken- : "";- return {- nextToken,- activityList,- };- },- async fetchActivityList(params: ActivityFind) {- const result = await this.fetchPagedActivityList(params);- return result.activityList;- },- async fetchActivityListForIssue(issue: Issue) {- // We should use two separate requests here because we are using different container ids.- const requestListForIssue = this.fetchActivityList({- typePrefix: "bb.issue.",- container: issue.id,- order: "ASC",- });- const requestListForPipeline = isDatabaseRelatedIssueType(issue.type)- ? this.fetchActivityList({- typePrefix: "bb.pipeline.",- container: issue.pipeline.id,- order: "ASC",- })- : [];- const [listForIssue, listForPipeline] = await Promise.all([- requestListForIssue,- requestListForPipeline,- ]);-- const mergedList = [...listForIssue, ...listForPipeline];- mergedList.sort((a, b) => {- if (a.createdTs !== b.createdTs) {- return a.createdTs - b.createdTs;- }-- return +a.id - +b.id;- });-- this.setActivityListForIssue({- issueId: issue.id,- activityList: mergedList,- });- return mergedList;- },- async fetchActivityListByIssueId(issueId: IssueId) {- const issue = useIssueStore().getIssueById(issueId);- if (issue.id === UNKNOWN_ID) {- return;- }- this.fetchActivityListForIssue(issue);- },- async fetchActivityListForQueryHistory({ limit }: { limit: number }) {- const currentUserV1 = useCurrentUserV1();- const activityList = await this.fetchActivityList({- typePrefix: "bb.sql-editor.query",- user: Number(extractUserUID(currentUserV1.value.name)),- order: "DESC",- limit,- level: ["INFO", "WARN"],- });-- // return the first `limit` rows- return activityList.slice(0, limit);- },async createActivity(newActivity: ActivityCreate) {const postData = {data: {@@ -203,39 +18,33 @@ export const useActivityStore = defineStore("activity", {postData.data.attributes.payload);}- const data = (await axios.post(`/api/activity`, postData)).data;- const createdActivity = convert(data.data, data.included);-+ await axios.post(`/api/activity`, postData);// There might exist other activities happened since the last fetch, so we do a full refetch.if (newActivity.type.startsWith("bb.issue.")) {- this.fetchActivityListByIssueId(newActivity.containerId);+ useActivityV1Store().fetchActivityListByIssueId(+ newActivity.containerId+ );}-- return createdActivity;},async updateComment({activityId,+ issueId,updatedComment,}: {activityId: ActivityId;+ issueId: IssueId;updatedComment: string;}) {const activityPatch: ActivityPatch = {comment: updatedComment,};- const data = (- await axios.patch(`/api/activity/${activityId}`, {- data: {- type: "activityPatch",- attributes: activityPatch,- },- })- ).data;- const updatedActivity = convert(data.data, data.included);-- this.fetchActivityListByIssueId(updatedActivity.containerId);-- return updatedActivity;+ await axios.patch(`/api/activity/${activityId}`, {+ data: {+ type: "activityPatch",+ attributes: activityPatch,+ },+ });+ useActivityV1Store().fetchActivityListByIssueId(issueId);},},});diff --git a/frontend/src/store/modules/inbox.ts b/frontend/src/store/modules/inbox.tsindex 2efb8241be..1e7768c48e 100644--- a/frontend/src/store/modules/inbox.ts+++ b/frontend/src/store/modules/inbox.ts@@ -1,37 +1,31 @@import { defineStore } from "pinia";import axios from "axios";import {- Activity,Inbox,InboxId,InboxPatch,InboxState,InboxSummary,PrincipalId,- ResourceIdentifier,ResourceObject,- unknown,} from "@/types";-import { useActivityStore } from "./activity";+import { useActivityV1Store } from "./v1";-function convert(inbox: ResourceObject, includedList: ResourceObject[]): Inbox {- const activityId = (inbox.relationships!.activity.data as ResourceIdentifier)- .id;- let activity: Activity = unknown("ACTIVITY") as Activity;- activity.id = parseInt(activityId);+async function convert(raw: ResourceObject): Promise<Inbox> {+ const inbox: Inbox = {+ ...(raw.attributes as Omit<Inbox, "id">),+ id: parseInt(raw.id),+ };- const activityStore = useActivityStore();- for (const item of includedList || []) {- if (item.type == "activity" && item.id == activityId) {- activity = activityStore.convert(item, includedList);- }+ try {+ const activity = await useActivityV1Store().fetchActivityByUID(+ inbox.activityId+ );+ inbox.activity = activity;+ } catch {+ // nothing, we will skip inbox with undefined activity.}-- return {- ...(inbox.attributes as Omit<Inbox, "id">),- id: parseInt(inbox.id),- activity,- };+ return inbox;}export const useInboxStore = defineStore("inbox", {@@ -88,12 +82,17 @@ export const useInboxStore = defineStore("inbox", {if (readCreatedAfterTs) {url += `?created=${readCreatedAfterTs}`;}- const data = (await axios.get(url)).data;- const inboxList = data.data.map((inbox: ResourceObject) => {- return convert(inbox, data.included);- });+ const { data } = (await axios.get(url)).data;+ const inboxList = await Promise.all(+ (data as ResourceObject[]).map((inbox: ResourceObject) => {+ return convert(inbox);+ })+ );- this.setInboxListByUser({ userId, inboxList });+ this.setInboxListByUser({+ userId,+ inboxList,+ });return inboxList;},async fetchInboxSummaryByUser(userId: PrincipalId) {@@ -119,8 +118,7 @@ export const useInboxStore = defineStore("inbox", {},})).data;- const updatedInbox = convert(data.data, data.included);-+ const updatedInbox = await convert(data.data);this.updateInboxById({ inboxId, inbox: updatedInbox });return updatedInbox;diff --git a/frontend/src/store/modules/issue.ts b/frontend/src/store/modules/issue.tsindex 0b64c3aea9..fdd12b3b0c 100644--- a/frontend/src/store/modules/issue.ts+++ b/frontend/src/store/modules/issue.ts@@ -23,12 +23,15 @@ import {} from "@/types";import { isDatabaseRelatedIssueType } from "@/utils";import { getPrincipalFromIncludedList } from "./principal";-import { useActivityStore } from "./activity";import { useLegacyDatabaseStore } from "./database";import { usePipelineStore } from "./pipeline";import { useLegacyProjectStore } from "./project";import { convertEntityList } from "./utils";-import { useDatabaseV1Store, useInstanceV1Store } from "./v1";+import {+ useDatabaseV1Store,+ useInstanceV1Store,+ useActivityV1Store,+} from "./v1";function convert(issue: ResourceObject, includedList: ResourceObject[]): Issue {const result: Issue = {@@ -290,7 +293,7 @@ export const useIssueStore = defineStore("issue", {issue: updatedIssue,});- useActivityStore().fetchActivityListByIssueId(issueId);+ useActivityV1Store().fetchActivityListByIssueId(issueId);return updatedIssue;},@@ -316,7 +319,7 @@ export const useIssueStore = defineStore("issue", {issue: updatedIssue,});- useActivityStore().fetchActivityListByIssueId(issueId);+ useActivityV1Store().fetchActivityListByIssueId(issueId);return updatedIssue;},diff --git a/frontend/src/store/modules/sqlEditor.ts b/frontend/src/store/modules/sqlEditor.tsindex 4db21c5c4b..aa135b1da0 100644--- a/frontend/src/store/modules/sqlEditor.ts+++ b/frontend/src/store/modules/sqlEditor.ts@@ -1,5 +1,4 @@import { defineStore } from "pinia";-import dayjs from "dayjs";import {SQLEditorState,QueryInfo,@@ -8,11 +7,10 @@ import {SingleSQLResult,} from "@/types";import { UNKNOWN_ID } from "@/types";-import { useActivityStore } from "./activity";import { useLegacySQLStore } from "./sql";import { useTabStore } from "./tab";import { useDatabaseV1Store } from "./v1/database";-import { useInstanceV1Store, useSQLStore } from "./v1";+import { useInstanceV1Store, useSQLStore, useActivityV1Store } from "./v1";// set the limit to 10000 temporarily to avoid the query timeout and page crashexport const RESULT_ROWS_LIMIT = 1000;@@ -72,31 +70,30 @@ export const useSQLEditorStore = defineStore("sqlEditor", {async fetchQueryHistoryList() {this.setIsFetchingQueryHistory(true);const activityList =- await useActivityStore().fetchActivityListForQueryHistory({+ await useActivityV1Store().fetchActivityListForQueryHistory({limit: 20,+ order: "desc",});- const queryHistoryList: QueryHistory[] = activityList.map((history) => {- const payload = history.payload as ActivitySQLEditorQueryPayload;- return {- id: history.id,- creator: history.creator,- createdTs: history.createdTs,- updatedTs: history.updatedTs,- statement: payload.statement,- durationNs: payload.durationNs,- instanceId: payload.instanceId || UNKNOWN_ID,- instanceName: payload.instanceName,- databaseId: payload.databaseId || UNKNOWN_ID,- databaseName: payload.databaseName,- error: payload.error,- createdAt: dayjs(history.createdTs * 1000).format(- "YYYY-MM-DD HH:mm:ss"- ),- };- });- this.setQueryHistoryList(- queryHistoryList.sort((a, b) => b.createdTs - a.createdTs)+ const queryHistoryList: QueryHistory[] = activityList.map(+ (history): QueryHistory => {+ const payload = JSON.parse(+ history.payload+ ) as ActivitySQLEditorQueryPayload;+ return {+ name: history.name,+ creator: history.creator,+ createTime: history.createTime ?? new Date(),+ statement: payload.statement,+ durationNs: payload.durationNs,+ instanceId: payload.instanceId || UNKNOWN_ID,+ instanceName: payload.instanceName,+ databaseId: payload.databaseId || UNKNOWN_ID,+ databaseName: payload.databaseName,+ error: payload.error,+ };+ });+ this.setQueryHistoryList(queryHistoryList);this.setIsFetchingQueryHistory(false);},},diff --git a/frontend/src/store/modules/v1/activity.ts b/frontend/src/store/modules/v1/activity.tsindex 1c9ff040ee..87f77f2a50 100644--- a/frontend/src/store/modules/v1/activity.ts+++ b/frontend/src/store/modules/v1/activity.ts@@ -1,18 +1,66 @@import { defineStore } from "pinia";import dayjs from "dayjs";+import { reactive } from "vue";import utc from "dayjs/plugin/utc";import { loggingServiceClient } from "@/grpcweb";-import { FindActivityMessage } from "@/types";-import { userNamePrefix } from "./common";import {+ IdType,+ FindActivityMessage,+ Issue,+ UNKNOWN_ID,+ EMPTY_ID,+} from "@/types";+import { userNamePrefix, getLogId, logNamePrefix } from "./common";+import {+ LogEntity,+ LogEntity_Action,+ LogEntity_Level,logEntity_ActionToJSON,logEntity_LevelToJSON,} from "@/types/proto/v1/logging_service";+import { isDatabaseRelatedIssueType } from "@/utils";+import { useIssueStore } from "../issue";+import { useCurrentUserV1 } from "../auth";dayjs.extend(utc);+const buildFilter = (find: FindActivityMessage): string => {+ const filter: string[] = [];+ if (find.resource) {+ filter.push(`resource = "${find.resource}"`);+ }+ if (find.creatorEmail) {+ filter.push(`creator = "${userNamePrefix}${find.creatorEmail}"`);+ }+ if (find.level) {+ filter.push(+ `level = "${find.level.map((l) => logEntity_LevelToJSON(l)).join(" | ")}"`+ );+ }+ if (find.action) {+ filter.push(+ `action = "${find.action+ .map((a) => logEntity_ActionToJSON(a))+ .join(" | ")}"`+ );+ }+ if (find.createdTsAfter) {+ filter.push(+ `create_time >= "${dayjs(find.createdTsAfter).utc().format()}"`+ );+ }+ if (find.createdTsBefore) {+ filter.push(+ `create_time <= "${dayjs(find.createdTsBefore).utc().format()}"`+ );+ }+ return filter.join(" && ");+};+export const useActivityV1Store = defineStore("activity_v1", () => {+ const activityListByIssue = reactive(new Map<IdType, LogEntity[]>());+const fetchActivityList = async (find: FindActivityMessage) => {const resp = await loggingServiceClient.listLogs({orderBy: find.order ? `create_time ${find.order}` : "",@@ -24,42 +72,89 @@ export const useActivityV1Store = defineStore("activity_v1", () => {return resp;};- const buildFilter = (find: FindActivityMessage): string => {- const filter: string[] = [];- if (find.resource) {- filter.push(`resource = "${find.resource}"`);- }- if (find.creatorEmail) {- filter.push(`creator = "${userNamePrefix}${find.creatorEmail}"`);- }- if (find.level) {- filter.push(- `level = "${find.level- .map((l) => logEntity_LevelToJSON(l))- .join(" | ")}"`- );- }- if (find.action) {- filter.push(- `action = "${find.action- .map((a) => logEntity_ActionToJSON(a))- .join(" | ")}"`+ const getActivityListByIssue = (issueId: IdType): LogEntity[] => {+ return activityListByIssue.get(issueId) || [];+ };++ const fetchActivityListForIssue = async (issue: Issue) => {+ const requests = [+ fetchActivityList({+ resource: `issues/${issue.id}`,+ order: "asc",+ }).then((resp) => resp.logEntities),+ ];+ if (isDatabaseRelatedIssueType(issue.type) && issue.pipeline) {+ requests.push(+ fetchActivityList({+ resource: `pipelines/${issue.pipeline.id}`,+ order: "asc",+ }).then((resp) => resp.logEntities));+ } else {+ requests.push(Promise.resolve([]));}- if (find.createdTsAfter) {- filter.push(- `create_time >= "${dayjs(find.createdTsAfter).utc().format()}"`- );++ const [listForIssue, listForPipeline] = await Promise.all(requests);+ const mergedList = [...listForIssue, ...listForPipeline];+ mergedList.sort((a, b) => {+ if (a.createTime !== b.createTime) {+ return (a.createTime?.getTime() ?? 0) - (b.createTime?.getTime() ?? 0);+ }++ return getLogId(a.name) - getLogId(b.name);+ });++ activityListByIssue.set(issue.id, mergedList);+ return mergedList;+ };++ const fetchActivityListByIssueId = async (issueId: IdType) => {+ const issue = useIssueStore().getIssueById(issueId);+ if (issue.id === UNKNOWN_ID) {+ return;}- if (find.createdTsBefore) {- filter.push(- `create_time <= "${dayjs(find.createdTsBefore).utc().format()}"`- );+ return fetchActivityListForIssue(issue);+ };++ const fetchActivityListForQueryHistory = async ({+ limit,+ order,+ }: {+ limit: number;+ order: "asc" | "desc";+ }) => {+ const currentUserV1 = useCurrentUserV1();++ return fetchActivityList({+ action: [LogEntity_Action.ACTION_DATABASE_SQL_EDITOR_QUERY],+ creatorEmail: currentUserV1.value.email,+ order,+ pageSize: limit,+ level: [LogEntity_Level.LEVEL_INFO, LogEntity_Level.LEVEL_WARNING],+ }).then((resp) => resp.logEntities);+ };++ const fetchActivityByUID = async (uid: IdType) => {+ if (uid == EMPTY_ID || uid == UNKNOWN_ID) {+ return;}- return filter.join(" && ");+ const entity = await loggingServiceClient.getLog({+ name: `${logNamePrefix}${uid}`,+ });+ return entity;+ };++ const getResourceId = (activity: LogEntity): IdType => {+ return activity.resource.split("/").slice(-1)[0];};return {fetchActivityList,+ fetchActivityListForIssue,+ fetchActivityListByIssueId,+ fetchActivityListForQueryHistory,+ fetchActivityByUID,+ getActivityListByIssue,+ getResourceId,};});diff --git a/frontend/src/store/modules/v1/common.ts b/frontend/src/store/modules/v1/common.tsindex c90d75cc1a..d0aac6d12e 100644--- a/frontend/src/store/modules/v1/common.ts+++ b/frontend/src/store/modules/v1/common.ts@@ -12,6 +12,7 @@ export const sheetNamePrefix = "sheets/";export const databaseGroupNamePrefix = "databaseGroups/";export const schemaGroupNamePrefix = "schemaGroups/";export const externalVersionControlPrefix = "externalVersionControls/";+export const logNamePrefix = "logs/";export const getNameParentTokens = (name: string,@@ -41,6 +42,15 @@ export const getUserId = (name: string): number => {return userId;};+export const getNumberId = (name: string, prefix: string): number => {+ const tokens = getNameParentTokens(name, [prefix]);+ return Number(tokens[0] || UNKNOWN_ID);+};++export const getLogId = (name: string): number => {+ return getNumberId(name, logNamePrefix);+};+export const getProjectAndSheetId = (name: string): string[] => {const tokens = getNameParentTokens(name, [projectNamePrefix,diff --git a/frontend/src/store/modules/v1/sheet.ts b/frontend/src/store/modules/v1/sheet.tsindex 73ff77e783..7b22cd53b4 100644--- a/frontend/src/store/modules/v1/sheet.ts+++ b/frontend/src/store/modules/v1/sheet.ts@@ -158,6 +158,9 @@ export const useSheetV1Store = defineStore("sheet_v1", {}},async getOrFetchSheetByUid(uid: SheetId) {+ if (uid === UNKNOWN_ID) {+ return;+ }const sheet = this.getSheetByUid(uid);if (sheet) {return sheet;@@ -168,15 +171,10 @@ export const useSheetV1Store = defineStore("sheet_v1", {return cached;}- const runner = async () => {- try {- const sheet = await sheetServiceClient.getSheet({- name: `${projectNamePrefix}-/${sheetNamePrefix}${uid}`,- });- return sheet;- } catch {- return;- }+ const runner = () => {+ return this.fetchSheetByName(+ `${projectNamePrefix}-/${sheetNamePrefix}${uid}`+ );};const request = runner();diff --git a/frontend/src/types/activity.ts b/frontend/src/types/activity.tsindex 6817e53d3c..d4a3110421 100644--- a/frontend/src/types/activity.ts+++ b/frontend/src/types/activity.ts@@ -1,7 +1,6 @@import { ExternalApprovalEvent } from "./externalApproval";import { FieldId } from "../plugins";import {- ActivityId,ContainerId,DatabaseId,InstanceId,@@ -14,7 +13,6 @@ import {import { IssueStatus } from "./issue";import { MemberStatus, RoleType } from "./member";import { StageStatusUpdateType, TaskStatus } from "./pipeline";-import { Principal } from "./principal";import { VCSPushEvent } from "./vcs";import { Advice } from "./sqlAdvice";import { t } from "../plugins/i18n";@@ -24,84 +22,48 @@ import {LogEntity_Level,} from "@/types/proto/v1/logging_service";-export type IssueActivityType =- | "bb.issue.create"- | "bb.issue.comment.create"- | "bb.issue.field.update"- | "bb.issue.status.update"- | "bb.issue.approval.notify"- | "bb.pipeline.stage.status.update"- | "bb.pipeline.task.status.update"- | "bb.pipeline.task.file.commit"- | "bb.pipeline.task.statement.update"- | "bb.pipeline.task.general.earliest-allowed-time.update";--export type MemberActivityType =- | "bb.member.create"- | "bb.member.role.update"- | "bb.member.activate"- | "bb.member.deactivate";--export type ProjectActivityType =- | "bb.project.repository.push"- | "bb.project.database.transfer"- | "bb.project.member.create"- | "bb.project.member.delete"- | "bb.project.member.role.update";--export type DatabaseActivityType = "bb.database.recovery.pitr.done";--export type SQLEditorActivityType = "bb.sql-editor.query";--export type ActivityType =- | IssueActivityType- | MemberActivityType- | ProjectActivityType- | DatabaseActivityType- | SQLEditorActivityType;--export function activityName(type: ActivityType): string {- switch (type) {- case "bb.issue.create":+export function activityName(action: LogEntity_Action): string {+ switch (action) {+ case LogEntity_Action.ACTION_ISSUE_CREATE:return t("activity.type.issue-create");- case "bb.issue.comment.create":+ case LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE:return t("activity.type.comment-create");- case "bb.issue.field.update":+ case LogEntity_Action.ACTION_ISSUE_FIELD_UPDATE:return t("activity.type.issue-field-update");- case "bb.issue.status.update":+ case LogEntity_Action.ACTION_ISSUE_STATUS_UPDATE:return t("activity.type.issue-status-update");- case "bb.pipeline.stage.status.update":+ case LogEntity_Action.ACTION_PIPELINE_STAGE_STATUS_UPDATE:return t("activity.type.pipeline-stage-status-update");- case "bb.pipeline.task.status.update":+ case LogEntity_Action.ACTION_PIPELINE_TASK_STATUS_UPDATE:return t("activity.type.pipeline-task-status-update");- case "bb.pipeline.task.file.commit":+ case LogEntity_Action.ACTION_PIPELINE_TASK_FILE_COMMIT:return t("activity.type.pipeline-task-file-commit");- case "bb.pipeline.task.statement.update":+ case LogEntity_Action.ACTION_PIPELINE_TASK_STATEMENT_UPDATE:return t("activity.type.pipeline-task-statement-update");- case "bb.pipeline.task.general.earliest-allowed-time.update":+ case LogEntity_Action.ACTION_PIPELINE_TASK_EARLIEST_ALLOWED_TIME_UPDATE:return t("activity.type.pipeline-task-earliest-allowed-time-update");- case "bb.member.create":+ case LogEntity_Action.ACTION_MEMBER_CREATE:return t("activity.type.member-create");- case "bb.member.role.update":+ case LogEntity_Action.ACTION_MEMBER_ROLE_UPDATE:return t("activity.type.member-role-update");- case "bb.member.activate":+ case LogEntity_Action.ACTION_MEMBER_ACTIVATE:return t("activity.type.member-activate");- case "bb.member.deactivate":+ case LogEntity_Action.ACTION_MEMBER_DEACTIVE:return t("activity.type.member-deactivate");- case "bb.project.repository.push":+ case LogEntity_Action.ACTION_PROJECT_REPOSITORY_PUSH:return t("activity.type.project-repository-push");- case "bb.project.database.transfer":+ case LogEntity_Action.ACTION_PROJECT_DATABASE_TRANSFER:return t("activity.type.project-database-transfer");- case "bb.project.member.create":+ case LogEntity_Action.ACTION_PROJECT_MEMBER_CREATE:return t("activity.type.project-member-create");- case "bb.project.member.delete":+ case LogEntity_Action.ACTION_PROJECT_MEMBER_DELETE:return t("activity.type.project-member-delete");- case "bb.project.member.role.update":+ case LogEntity_Action.ACTION_PROJECT_MEMBER_ROLE_UPDATE:return t("activity.type.project-member-role-update");- case "bb.database.recovery.pitr.done":+ case LogEntity_Action.ACTION_PROJECT_DATABASE_RECOVERY_PITR_DONE:return t("activity.type.database-recovery-pitr-done");}- console.assert(false, `undefined text for activity type "${type}"`);+ console.assert(false, `undefined text for activity type "${action}"`);return "";}@@ -242,29 +204,10 @@ export type ActionPayloadType =| ActivityProjectDatabaseTransferPayload| ActivitySQLEditorQueryPayload;-export type Activity = {- id: ActivityId;-- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-- // Domain specific fields- // The object where this activity belongs- // e.g if type is "bb.issue.xxx", then this field refers to the corresponding issue's id.- containerId: ContainerId;- type: ActivityType;- level: ActivityLevel;- comment: string;- payload?: ActionPayloadType;-};-export type ActivityCreate = {// Domain specific fieldscontainerId: ContainerId;- type: ActivityType;+ type: "bb.issue.comment.create";comment: string;payload?: ActionPayloadType;};@@ -274,18 +217,6 @@ export type ActivityPatch = {comment: string;};-export type ActivityFind = {- typePrefix?: string | string[];- container?: number | string;- order?: "ASC" | "DESC";- user?: number;- limit?: number;- level?: string | string[];- token?: string;- createdTsAfter?: number;- createdTsBefore?: number;-};-export interface FindActivityMessage {resource?: string;creatorEmail?: string;@@ -293,7 +224,7 @@ export interface FindActivityMessage {action?: LogEntity_Action[];createdTsAfter?: number;createdTsBefore?: number;- order?: "acs" | "desc";+ order?: "asc" | "desc";pageSize?: number;pageToken?: string;}diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 465ecf656d..7755ebb0c2 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -1,4 +1,3 @@-import { Activity } from "./activity";import { Anomaly } from "./anomaly";import { BackupSetting } from "./backup";import { Bookmark } from "./bookmark";@@ -118,7 +117,6 @@ interface ResourceMaker {(type: "STAGE"): Stage;(type: "TASK_PROGRESS"): TaskProgress;(type: "TASK"): Task;- (type: "ACTIVITY"): Activity;(type: "INBOX"): Inbox;(type: "BOOKMARK"): Bookmark;(type: "VCS"): VCS;@@ -294,22 +292,9 @@ const makeUnknown = (type: ResourceType) => {progress: { ...UNKNOWN_TASK_PROGRESS },};- const UNKNOWN_ACTIVITY: Activity = {- id: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,- createdTs: 0,- updater: UNKNOWN_PRINCIPAL,- updatedTs: 0,- containerId: UNKNOWN_ID,- type: "bb.issue.create",- level: "INFO",- comment: "<<Unknown comment>>",- };-const UNKNOWN_INBOX: Inbox = {id: UNKNOWN_ID,- receiver_id: UNKNOWN_ID,- activity: UNKNOWN_ACTIVITY,+ activityId: UNKNOWN_ID,status: "READ",};@@ -377,8 +362,6 @@ const makeUnknown = (type: ResourceType) => {return UNKNOWN_TASK_PROGRESS;case "TASK":return UNKNOWN_TASK;- case "ACTIVITY":- return UNKNOWN_ACTIVITY;case "INBOX":return UNKNOWN_INBOX;case "BOOKMARK":@@ -560,22 +543,9 @@ const makeEmpty = (type: ResourceType) => {progress: { ...EMPTY_TASK_PROGRESS },};- const EMPTY_ACTIVITY: Activity = {- id: EMPTY_ID,- creator: EMPTY_PRINCIPAL,- createdTs: 0,- updater: EMPTY_PRINCIPAL,- updatedTs: 0,- containerId: EMPTY_ID,- type: "bb.issue.create",- level: "INFO",- comment: "",- };-const EMPTY_INBOX: Inbox = {id: EMPTY_ID,- receiver_id: EMPTY_ID,- activity: EMPTY_ACTIVITY,+ activityId: EMPTY_ID,status: "READ",};@@ -643,8 +613,6 @@ const makeEmpty = (type: ResourceType) => {return EMPTY_TASK_PROGRESS;case "TASK":return EMPTY_TASK;- case "ACTIVITY":- return EMPTY_ACTIVITY;case "INBOX":return EMPTY_INBOX;case "BOOKMARK":diff --git a/frontend/src/types/inbox.ts b/frontend/src/types/inbox.tsindex 764c014ced..7f7f625e5a 100644--- a/frontend/src/types/inbox.ts+++ b/frontend/src/types/inbox.ts@@ -1,5 +1,5 @@-import { Activity } from "./activity";-import { InboxId, PrincipalId } from "./id";+import { IdType, InboxId } from "./id";+import { LogEntity } from "@/types/proto/v1/logging_service";export type InboxStatus = "UNREAD" | "READ";@@ -7,8 +7,8 @@ export type Inbox = {id: InboxId;// Domain specific fields- receiver_id: PrincipalId;- activity: Activity;+ activityId: IdType;+ activity?: LogEntity;status: InboxStatus;};diff --git a/frontend/src/types/proto/v1/logging_service.ts b/frontend/src/types/proto/v1/logging_service.tsindex 86595b2c41..1f99dc8fb9 100644--- a/frontend/src/types/proto/v1/logging_service.ts+++ b/frontend/src/types/proto/v1/logging_service.ts@@ -30,7 +30,7 @@ export interface ListLogsRequest {* The order by of the log.* Only support order by create_time.* For example:- * - order_by = "create_time acs"+ * - order_by = "create_time asc"* - order_by = "create_time desc"*/orderBy: string;@@ -59,6 +59,14 @@ export interface ListLogsResponse {nextPageToken: string;}+export interface GetLogRequest {+ /**+ * The name of the log to retrieve.+ * Format: logs/{uid}+ */+ name: string;+}+export interface LogEntity {/*** The name of the log.@@ -70,8 +78,8 @@ export interface LogEntity {* Format: users/{email}*/creator: string;- /** The timestamp when the backup resource was created initally. */createTime?: Date;+ updateTime?: Date;action: LogEntity_Action;level: LogEntity_Level;/**@@ -514,8 +522,74 @@ export const ListLogsResponse = {},};+function createBaseGetLogRequest(): GetLogRequest {+ return { name: "" };+}++export const GetLogRequest = {+ encode(message: GetLogRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.name !== "") {+ writer.uint32(10).string(message.name);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): GetLogRequest {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseGetLogRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.name = reader.string();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): GetLogRequest {+ return { name: isSet(object.name) ? String(object.name) : "" };+ },++ toJSON(message: GetLogRequest): unknown {+ const obj: any = {};+ message.name !== undefined && (obj.name = message.name);+ return obj;+ },++ create(base?: DeepPartial<GetLogRequest>): GetLogRequest {+ return GetLogRequest.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<GetLogRequest>): GetLogRequest {+ const message = createBaseGetLogRequest();+ message.name = object.name ?? "";+ return message;+ },+};+function createBaseLogEntity(): LogEntity {- return { name: "", creator: "", createTime: undefined, action: 0, level: 0, resource: "", payload: "", comment: "" };+ return {+ name: "",+ creator: "",+ createTime: undefined,+ updateTime: undefined,+ action: 0,+ level: 0,+ resource: "",+ payload: "",+ comment: "",+ };}export const LogEntity = {@@ -529,20 +603,23 @@ export const LogEntity = {if (message.createTime !== undefined) {Timestamp.encode(toTimestamp(message.createTime), writer.uint32(26).fork()).ldelim();}+ if (message.updateTime !== undefined) {+ Timestamp.encode(toTimestamp(message.updateTime), writer.uint32(34).fork()).ldelim();+ }if (message.action !== 0) {- writer.uint32(32).int32(message.action);+ writer.uint32(40).int32(message.action);}if (message.level !== 0) {- writer.uint32(40).int32(message.level);+ writer.uint32(48).int32(message.level);}if (message.resource !== "") {- writer.uint32(50).string(message.resource);+ writer.uint32(58).string(message.resource);}if (message.payload !== "") {- writer.uint32(58).string(message.payload);+ writer.uint32(66).string(message.payload);}if (message.comment !== "") {- writer.uint32(66).string(message.comment);+ writer.uint32(74).string(message.comment);}return writer;},@@ -576,38 +653,45 @@ export const LogEntity = {message.createTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));continue;case 4:- if (tag !== 32) {+ if (tag !== 34) {break;}- message.action = reader.int32() as any;+ message.updateTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));continue;case 5:if (tag !== 40) {break;}- message.level = reader.int32() as any;+ message.action = reader.int32() as any;continue;case 6:- if (tag !== 50) {+ if (tag !== 48) {break;}- message.resource = reader.string();+ message.level = reader.int32() as any;continue;case 7:if (tag !== 58) {break;}- message.payload = reader.string();+ message.resource = reader.string();continue;case 8:if (tag !== 66) {break;}+ message.payload = reader.string();+ continue;+ case 9:+ if (tag !== 74) {+ break;+ }+message.comment = reader.string();continue;}@@ -624,6 +708,7 @@ export const LogEntity = {name: isSet(object.name) ? String(object.name) : "",creator: isSet(object.creator) ? String(object.creator) : "",createTime: isSet(object.createTime) ? fromJsonTimestamp(object.createTime) : undefined,+ updateTime: isSet(object.updateTime) ? fromJsonTimestamp(object.updateTime) : undefined,action: isSet(object.action) ? logEntity_ActionFromJSON(object.action) : 0,level: isSet(object.level) ? logEntity_LevelFromJSON(object.level) : 0,resource: isSet(object.resource) ? String(object.resource) : "",@@ -637,6 +722,7 @@ export const LogEntity = {message.name !== undefined && (obj.name = message.name);message.creator !== undefined && (obj.creator = message.creator);message.createTime !== undefined && (obj.createTime = message.createTime.toISOString());+ message.updateTime !== undefined && (obj.updateTime = message.updateTime.toISOString());message.action !== undefined && (obj.action = logEntity_ActionToJSON(message.action));message.level !== undefined && (obj.level = logEntity_LevelToJSON(message.level));message.resource !== undefined && (obj.resource = message.resource);@@ -654,6 +740,7 @@ export const LogEntity = {message.name = object.name ?? "";message.creator = object.creator ?? "";message.createTime = object.createTime ?? undefined;+ message.updateTime = object.updateTime ?? undefined;message.action = object.action ?? 0;message.level = object.level ?? 0;message.resource = object.resource ?? "";@@ -682,15 +769,32 @@ export const LoggingServiceDefinition = {},},},+ getLog: {+ name: "GetLog",+ requestType: GetLogRequest,+ requestStream: false,+ responseType: LogEntity,+ responseStream: false,+ options: {+ _unknownFields: {+ 8410: [new Uint8Array([4, 110, 97, 109, 101])],+ 578365826: [+ new Uint8Array([19, 18, 17, 47, 118, 49, 47, 123, 110, 97, 109, 101, 61, 108, 111, 103, 115, 47, 42, 125]),+ ],+ },+ },+ },},} as const;export interface LoggingServiceImplementation<CallContextExt = {}> {listLogs(request: ListLogsRequest, context: CallContext & CallContextExt): Promise<DeepPartial<ListLogsResponse>>;+ getLog(request: GetLogRequest, context: CallContext & CallContextExt): Promise<DeepPartial<LogEntity>>;}export interface LoggingServiceClient<CallOptionsExt = {}> {listLogs(request: DeepPartial<ListLogsRequest>, options?: CallOptions & CallOptionsExt): Promise<ListLogsResponse>;+ getLog(request: DeepPartial<GetLogRequest>, options?: CallOptions & CallOptionsExt): Promise<LogEntity>;}type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;diff --git a/frontend/src/types/sqlEditor.ts b/frontend/src/types/sqlEditor.tsindex b973afe1c0..984fb4c290 100644--- a/frontend/src/types/sqlEditor.ts+++ b/frontend/src/types/sqlEditor.ts@@ -1,6 +1,5 @@import type * as monaco from "monaco-editor";-import { InstanceId, DatabaseId, ActivityId, EngineType } from "../types";-import { Principal } from "./principal";+import { InstanceId, DatabaseId, EngineType } from "../types";import { Engine } from "./proto/v1/common";export type EditorModel = monaco.editor.ITextModel;@@ -73,12 +72,12 @@ export enum SortText {}export interface QueryHistory {- id: ActivityId;+ name: string;// Standard fields- creator: Principal;- createdTs: number;- updatedTs: number;+ // creator in users/{email} format.+ creator: string;+ createTime: Date;// Domain fieldsstatement: string;@@ -88,7 +87,4 @@ export interface QueryHistory {instanceId: InstanceId;databaseId: DatabaseId;error: string;-- // Customized fields- createdAt: string;}diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.tsindex 9e3e8f86d5..cc8d3d8fa4 100644--- a/frontend/src/types/store.ts+++ b/frontend/src/types/store.ts@@ -1,5 +1,4 @@import { MigrationHistoryId, QueryHistory, OnboardingGuideType } from ".";-import { Activity } from "./activity";import { Backup } from "./backup";import { Bookmark } from "./bookmark";import { Command } from "./common";@@ -25,13 +24,8 @@ import { Principal } from "./principal";import { Project } from "./project";import { VCS } from "./vcs";import { Label } from "./label";-import type { AuditLog } from "@/types/auditLog";import { DatabaseMetadata } from "./proto/store/database";-export interface AuditLogState {- auditLogList: AuditLog[];-}-export interface PrincipalState {principalList: Principal[];}@@ -40,11 +34,6 @@ export interface BookmarkState {bookmarkList: Map<PrincipalId, Bookmark[]>;}-export interface ActivityState {- activityListByUser: Map<PrincipalId, Activity[]>;- activityListByIssue: Map<IssueId, Activity[]>;-}-export interface InboxState {inboxListByUser: Map<PrincipalId, Inbox[]>;inboxSummaryByUser: Map<PrincipalId, InboxSummary>;diff --git a/frontend/src/utils/activity.ts b/frontend/src/utils/activity.tsindex 9090a792db..5ee1cfe571 100644--- a/frontend/src/utils/activity.ts+++ b/frontend/src/utils/activity.ts@@ -2,23 +2,25 @@ import { useUserStore } from "@/store";import { IssueBuiltinFieldId } from "../plugins";import { t } from "@/plugins/i18n";import {- Activity,ActivityIssueFieldUpdatePayload,ActivityIssueStatusUpdatePayload,unknownUser,} from "../types";+import { LogEntity, LogEntity_Action } from "@/types/proto/v1/logging_service";export function issueActivityActionSentence(- activity: Activity+ activity: LogEntity): [string, Record<string, any>] {- switch (activity.type) {- case "bb.issue.create":+ switch (activity.action) {+ case LogEntity_Action.ACTION_ISSUE_CREATE:return ["activity.sentence.created-issue", {}];- case "bb.issue.comment.create":+ case LogEntity_Action.ACTION_ISSUE_COMMENT_CREATE:return ["activity.sentence.commented", {}];- case "bb.issue.field.update": {+ case LogEntity_Action.ACTION_ISSUE_FIELD_UPDATE: {const userStore = useUserStore();- const update = activity.payload as ActivityIssueFieldUpdatePayload;+ const update = JSON.parse(+ activity.payload+ ) as ActivityIssueFieldUpdatePayload;switch (update.fieldId) {case IssueBuiltinFieldId.NAME: {@@ -84,8 +86,10 @@ export function issueActivityActionSentence(return ["activity.sentence.updated", {}];}- case "bb.issue.status.update": {- const update = activity.payload as ActivityIssueStatusUpdatePayload;+ case LogEntity_Action.ACTION_ISSUE_STATUS_UPDATE: {+ const update = JSON.parse(+ activity.payload+ ) as ActivityIssueStatusUpdatePayload;switch (update.newStatus) {case "OPEN":return ["activity.sentence.reopened-issue", {}];diff --git a/frontend/src/views/Inbox.vue b/frontend/src/views/Inbox.vueindex 7f7d884f5b..d89f60ed55 100644--- a/frontend/src/views/Inbox.vue+++ b/frontend/src/views/Inbox.vue@@ -80,6 +80,9 @@ export default {state.unreadList = [];for (const item of list) {+ if (!item.activity) {+ continue;+ }if (item.status == "READ") {state.readList.push(item);} else if (item.status == "UNREAD") {diff --git a/frontend/src/views/SettingWorkspaceAuditLog.vue b/frontend/src/views/SettingWorkspaceAuditLog.vueindex db6d697fdc..a9ce4ce5bf 100644--- a/frontend/src/views/SettingWorkspaceAuditLog.vue+++ b/frontend/src/views/SettingWorkspaceAuditLog.vue@@ -33,7 +33,7 @@</NDatePicker></div></div>- <PagedAuditLogTable+ <PagedActivityTablev-if="hasAuditLogFeature":activity-find="{action:@@ -45,13 +45,13 @@createdTsAfter: selectedTimeRange ? selectedTimeRange[0] : undefined,createdTsBefore: selectedTimeRange ? selectedTimeRange[1] : undefined,}"- session-key="settings-audit-log-table"+ session-key="bb.page-audit-log-table.settings-audit-log-table":page-size="10"><template #table="{ list }"><AuditLogTable :audit-log-list="list" @view-detail="handleViewDetail" /></template>- </PagedAuditLogTable>+ </PagedActivityTable><template v-else><AuditLogTable :audit-log-list="[]" /><div class="w-full h-full flex flex-col items-center justify-center">diff --git a/frontend/src/views/sql-editor/AsidePanel/QueryHistoryContainer.vue b/frontend/src/views/sql-editor/AsidePanel/QueryHistoryContainer.vueindex 4f4a2712c8..d967ac4fbe 100644--- a/frontend/src/views/sql-editor/AsidePanel/QueryHistoryContainer.vue+++ b/frontend/src/views/sql-editor/AsidePanel/QueryHistoryContainer.vue@@ -16,12 +16,14 @@<div class="w-full flex flex-col justify-start items-start overflow-y-auto"><divv-for="history in data"- :key="history.id"+ :key="history.name"class="w-full px-1 pr-2 py-2 border-b flex flex-col justify-start items-start cursor-pointer hover:bg-gray-50"@click="handleQueryHistoryClick(history)"><div class="w-full flex flex-row justify-between items-center">- <span class="text-xs text-gray-500">{{ history.createdAt }}</span>+ <span class="text-xs text-gray-500">{{+ dayjs(history.createTime).format("YYYY-MM-DD HH:mm:ss")+ }}</span><spanclass="p-1 rounded text-gray-500 hover:text-gray-700 hover:bg-gray-200">diff --git a/frontend/src/views/sql-editor/EditorHeader.vue b/frontend/src/views/sql-editor/EditorHeader.vueindex 6b1faeae7a..cb98f20c0f 100644--- a/frontend/src/views/sql-editor/EditorHeader.vue+++ b/frontend/src/views/sql-editor/EditorHeader.vue@@ -19,7 +19,7 @@><router-linkv-if="showAuditLogItem"- to="/setting/audit-log?type=bb.sql-editor.query"+ :to="`/setting/audit-log?type=${sqlQueryAction}`"class="router-link"exact-active-class="anchor-link">{{ $t("settings.sidebar.audit-log") }}</router-link@@ -77,7 +77,7 @@</router-link><router-linkv-if="showAuditLogItem"- to="/setting/audit-log?type=bb.sql-editor.query"+ :to="`/setting/audit-log?type=${sqlQueryAction}`"class="bar-link rounded-md block px-3 py-2">{{ $t("settings.sidebar.audit-log") }}@@ -99,6 +99,7 @@ import { UNKNOWN_ID } from "@/types";import { useCurrentUser, useCurrentUserV1, useInboxStore } from "@/store";import { hasWorkspacePermissionV1 } from "@/utils";import { useSettingV1Store } from "@/store/modules/v1/setting";+import { LogEntity_Action } from "@/types/proto/v1/logging_service";interface LocalState {showMobileMenu: boolean;@@ -206,6 +207,7 @@ export default defineComponent({inboxSummary,logoUrl,goBack,+ sqlQueryAction: LogEntity_Action.ACTION_DATABASE_SQL_EDITOR_QUERY,};},});diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 91f68e3d33..58d769c25e 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -231,6 +231,7 @@- [InstanceService](#bytebase-v1-InstanceService)- [v1/logging_service.proto](#v1_logging_service-proto)+ - [GetLogRequest](#bytebase-v1-GetLogRequest)- [ListLogsRequest](#bytebase-v1-ListLogsRequest)- [ListLogsResponse](#bytebase-v1-ListLogsResponse)- [LogEntity](#bytebase-v1-LogEntity)@@ -3817,6 +3818,21 @@ The instance's `name` field is used to identify the instance to update. Form+<a name="bytebase-v1-GetLogRequest"></a>++### GetLogRequest++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| name | [string](#string) | | The name of the log to retrieve. Format: logs/{uid} |++++++<a name="bytebase-v1-ListLogsRequest"></a>### ListLogsRequest@@ -3826,7 +3842,7 @@ The instance's `name` field is used to identify the instance to update. Form| Field | Type | Label | Description || ----- | ---- | ----- | ----------- || filter | [string](#string) | | filter is the filter to apply on the list logs request, follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax. The field only support in filter: - creator, example: - creator = "users/{email}" - resource, example: - resource = "projects/{project resource id}" - level, example: - level = "INFO" - level = "ERROR | WARN" - action, example: - action = "ACTION_MEMBER_CREATE" | "ACTION_ISSUE_CREATE" - create_time, example: - create_time <= "2022-01-01T12:00:00.000Z" - create_time >= "2022-01-01T12:00:00.000Z" For example: List the logs of type 'ACTION_ISSUE_COMMENT_CREATE' in issue/123: 'action="ACTION_ISSUE_COMMENT_CREATE", resource="issue/123"' |-| order_by | [string](#string) | | The order by of the log. Only support order by create_time. For example: - order_by = "create_time acs" - order_by = "create_time desc" |+| order_by | [string](#string) | | The order by of the log. Only support order by create_time. For example: - order_by = "create_time asc" - order_by = "create_time desc" || page_size | [int32](#int32) | | Not used. The maximum number of logs to return. The service may return fewer than this value. If unspecified, at most 100 log entries will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. || page_token | [string](#string) | | Not used. A page token, received from a previous `ListLogs` call. Provide this to retrieve the subsequent page. |@@ -3861,7 +3877,8 @@ The instance's `name` field is used to identify the instance to update. Form| ----- | ---- | ----- | ----------- || name | [string](#string) | | The name of the log. Format: logs/{uid} || creator | [string](#string) | | The creator of the log entity. Format: users/{email} |-| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The timestamp when the backup resource was created initally. |+| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |+| update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | || action | [LogEntity.Action](#bytebase-v1-LogEntity-Action) | | || level | [LogEntity.Level](#bytebase-v1-LogEntity-Level) | | || resource | [string](#string) | | The name of the resource associated with this log entity. For example, the resource user associated with log entity type of "ACTION_MEMBER_CREATE". Format: For ACTION_MEMBER_*: users/{email} For ACTION_ISSUE_*: issues/{issue uid} For ACTION_PIPELINE_*: pipelines/{pipeline uid} For ACTION_PROJECT_*: projects/{project resource id} For ACTION_DATABASE_*: instances/{instance resource id} |@@ -3942,6 +3959,7 @@ ACTION_DATABASE_SQL_EDITOR_QUERY is the type for SQL editor query. || Method Name | Request Type | Response Type | Description || ----------- | ------------ | ------------- | ------------|| ListLogs | [ListLogsRequest](#bytebase-v1-ListLogsRequest) | [ListLogsResponse](#bytebase-v1-ListLogsResponse) | |+| GetLog | [GetLogRequest](#bytebase-v1-GetLogRequest) | [LogEntity](#bytebase-v1-LogEntity) | |diff --git a/proto/generated-go/v1/logging_service.pb.go b/proto/generated-go/v1/logging_service.pb.goindex d14a14b27b..751c43a785 100644--- a/proto/generated-go/v1/logging_service.pb.go+++ b/proto/generated-go/v1/logging_service.pb.go@@ -162,7 +162,7 @@ func (x LogEntity_Action) Number() protoreflect.EnumNumber {// Deprecated: Use LogEntity_Action.Descriptor instead.func (LogEntity_Action) EnumDescriptor() ([]byte, []int) {- return file_v1_logging_service_proto_rawDescGZIP(), []int{2, 0}+ return file_v1_logging_service_proto_rawDescGZIP(), []int{3, 0}}type LogEntity_Level int32@@ -217,7 +217,7 @@ func (x LogEntity_Level) Number() protoreflect.EnumNumber {// Deprecated: Use LogEntity_Level.Descriptor instead.func (LogEntity_Level) EnumDescriptor() ([]byte, []int) {- return file_v1_logging_service_proto_rawDescGZIP(), []int{2, 1}+ return file_v1_logging_service_proto_rawDescGZIP(), []int{3, 1}}type ListLogsRequest struct {@@ -251,7 +251,7 @@ type ListLogsRequest struct {// The order by of the log.// Only support order by create_time.// For example:- // - order_by = "create_time acs"+ // - order_by = "create_time asc"// - order_by = "create_time desc"OrderBy string `protobuf:"bytes,2,opt,name=order_by,json=orderBy,proto3" json:"order_by,omitempty"`// Not used. The maximum number of logs to return.@@ -383,6 +383,55 @@ func (x *ListLogsResponse) GetNextPageToken() string {return ""}+type GetLogRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The name of the log to retrieve.+ // Format: logs/{uid}+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+}++func (x *GetLogRequest) Reset() {+ *x = GetLogRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_logging_service_proto_msgTypes[2]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *GetLogRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*GetLogRequest) ProtoMessage() {}++func (x *GetLogRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_logging_service_proto_msgTypes[2]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use GetLogRequest.ProtoReflect.Descriptor instead.+func (*GetLogRequest) Descriptor() ([]byte, []int) {+ return file_v1_logging_service_proto_rawDescGZIP(), []int{2}+}++func (x *GetLogRequest) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}+type LogEntity struct {state protoimpl.MessageStatesizeCache protoimpl.SizeCache@@ -393,11 +442,11 @@ type LogEntity struct {Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`// The creator of the log entity.// Format: users/{email}- Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`- // The timestamp when the backup resource was created initally.+ Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`CreateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`- Action LogEntity_Action `protobuf:"varint,4,opt,name=action,proto3,enum=bytebase.v1.LogEntity_Action" json:"action,omitempty"`- Level LogEntity_Level `protobuf:"varint,5,opt,name=level,proto3,enum=bytebase.v1.LogEntity_Level" json:"level,omitempty"`+ UpdateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"`+ Action LogEntity_Action `protobuf:"varint,5,opt,name=action,proto3,enum=bytebase.v1.LogEntity_Action" json:"action,omitempty"`+ Level LogEntity_Level `protobuf:"varint,6,opt,name=level,proto3,enum=bytebase.v1.LogEntity_Level" json:"level,omitempty"`// The name of the resource associated with this log entity. For example, the resource user associated with log entity type of "ACTION_MEMBER_CREATE".// Format:// For ACTION_MEMBER_*: users/{email}@@ -405,17 +454,17 @@ type LogEntity struct {// For ACTION_PIPELINE_*: pipelines/{pipeline uid}// For ACTION_PROJECT_*: projects/{project resource id}// For ACTION_DATABASE_*: instances/{instance resource id}- Resource string `protobuf:"bytes,6,opt,name=resource,proto3" json:"resource,omitempty"`+ Resource string `protobuf:"bytes,7,opt,name=resource,proto3" json:"resource,omitempty"`// The payload of the log entity.// TODO: use oneof- Payload string `protobuf:"bytes,7,opt,name=payload,proto3" json:"payload,omitempty"`- Comment string `protobuf:"bytes,8,opt,name=comment,proto3" json:"comment,omitempty"`+ Payload string `protobuf:"bytes,8,opt,name=payload,proto3" json:"payload,omitempty"`+ Comment string `protobuf:"bytes,9,opt,name=comment,proto3" json:"comment,omitempty"`}func (x *LogEntity) Reset() {*x = LogEntity{}if protoimpl.UnsafeEnabled {- mi := &file_v1_logging_service_proto_msgTypes[2]+ mi := &file_v1_logging_service_proto_msgTypes[3]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -428,7 +477,7 @@ func (x *LogEntity) String() string {func (*LogEntity) ProtoMessage() {}func (x *LogEntity) ProtoReflect() protoreflect.Message {- mi := &file_v1_logging_service_proto_msgTypes[2]+ mi := &file_v1_logging_service_proto_msgTypes[3]if protoimpl.UnsafeEnabled && x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -441,7 +490,7 @@ func (x *LogEntity) ProtoReflect() protoreflect.Message {// Deprecated: Use LogEntity.ProtoReflect.Descriptor instead.func (*LogEntity) Descriptor() ([]byte, []int) {- return file_v1_logging_service_proto_rawDescGZIP(), []int{2}+ return file_v1_logging_service_proto_rawDescGZIP(), []int{3}}func (x *LogEntity) GetName() string {@@ -465,6 +514,13 @@ func (x *LogEntity) GetCreateTime() *timestamppb.Timestamp {return nil}+func (x *LogEntity) GetUpdateTime() *timestamppb.Timestamp {+ if x != nil {+ return x.UpdateTime+ }+ return nil+}+func (x *LogEntity) GetAction() LogEntity_Action {if x != nil {return x.Action@@ -507,114 +563,128 @@ var file_v1_logging_service_proto_rawDesc = []byte{0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x62, 0x79, 0x74, 0x65,0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,- 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72,- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70,- 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,- 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74,- 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x66,- 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c,- 0x74, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x18,- 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x12, 0x1b,- 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,- 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70,- 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,- 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x7a, 0x0a, 0x10, 0x4c, 0x69,- 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e,- 0x0a, 0x0c, 0x6c, 0x6f, 0x67, 0x5f, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01,- 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,- 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x42, 0x03, 0xe0, 0x41,- 0x03, 0x52, 0x0b, 0x6c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 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, 0xdb, 0x09, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x45, 0x6e,- 0x74, 0x69, 0x74, 0x79, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,- 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a,- 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03,- 0xe0, 0x41, 0x03, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x40, 0x0a, 0x0b,- 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,- 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,- 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x03, 0xe0,- 0x41, 0x03, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3a,- 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d,+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,+ 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f,+ 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64,+ 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,+ 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,+ 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,+ 0x22, 0x80, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71,+ 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01,+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08,+ 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,+ 0x6f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f,+ 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65,+ 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b,+ 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f,+ 0x6b, 0x65, 0x6e, 0x22, 0x7a, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52,+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x6c, 0x6f, 0x67, 0x5f, 0x65,+ 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x45,+ 0x6e, 0x74, 0x69, 0x74, 0x79, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0b, 0x6c, 0x6f, 0x67, 0x45,+ 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 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,+ 0x28, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,+ 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03,+ 0xe0, 0x41, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x9d, 0x0a, 0x0a, 0x09, 0x4c, 0x6f,+ 0x67, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,+ 0x12, 0x1d, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28,+ 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12,+ 0x40, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03,+ 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,+ 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,+ 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d,+ 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65,+ 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,+ 0x6d, 0x70, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54,+ 0x69, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20,+ 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x63, 0x74, 0x69,+ 0x6f, 0x6e, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12,+ 0x37, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c,0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67,- 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x03, 0xe0,- 0x41, 0x02, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x05, 0x6c, 0x65,- 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65,- 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x69, 0x74,- 0x79, 0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x05, 0x6c, 0x65,- 0x76, 0x65, 0x6c, 0x12, 0x1f, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18,- 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f,- 0x75, 0x72, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18,- 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c,- 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x08,- 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0xb0, 0x06,- 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x12, 0x41, 0x43, 0x54, 0x49,- 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00,- 0x12, 0x18, 0x0a, 0x14, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45,- 0x52, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x1d, 0x0a, 0x19, 0x41, 0x43,- 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x52, 0x4f, 0x4c, 0x45,- 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x41, 0x43, 0x54,- 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56,- 0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x1a, 0x0a, 0x16, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f,- 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x44, 0x45, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10,- 0x04, 0x12, 0x17, 0x0a, 0x13, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55,- 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x15, 0x12, 0x1f, 0x0a, 0x1b, 0x41, 0x43,- 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x45,- 0x4e, 0x54, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x16, 0x12, 0x1d, 0x0a, 0x19, 0x41,- 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f, 0x46, 0x49, 0x45, 0x4c,- 0x44, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x17, 0x12, 0x1e, 0x0a, 0x1a, 0x41, 0x43,- 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55,- 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x18, 0x12, 0x20, 0x0a, 0x1c, 0x41, 0x43,- 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f, 0x41, 0x50, 0x50, 0x52, 0x4f,- 0x56, 0x41, 0x4c, 0x5f, 0x4e, 0x4f, 0x54, 0x49, 0x46, 0x59, 0x10, 0x19, 0x12, 0x27, 0x0a, 0x23,- 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49, 0x50, 0x45, 0x4c, 0x49, 0x4e, 0x45, 0x5f,- 0x53, 0x54, 0x41, 0x47, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x50, 0x44,- 0x41, 0x54, 0x45, 0x10, 0x1f, 0x12, 0x26, 0x0a, 0x22, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f,- 0x50, 0x49, 0x50, 0x45, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x54, 0x41, 0x53, 0x4b, 0x5f, 0x53, 0x54,- 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x20, 0x12, 0x24, 0x0a,- 0x20, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49, 0x50, 0x45, 0x4c, 0x49, 0x4e, 0x45,- 0x5f, 0x54, 0x41, 0x53, 0x4b, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x5f, 0x43, 0x4f, 0x4d, 0x4d, 0x49,- 0x54, 0x10, 0x21, 0x12, 0x29, 0x0a, 0x25, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49,- 0x50, 0x45, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x54, 0x41, 0x53, 0x4b, 0x5f, 0x53, 0x54, 0x41, 0x54,- 0x45, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x22, 0x12, 0x35,- 0x0a, 0x31, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49, 0x50, 0x45, 0x4c, 0x49, 0x4e,- 0x45, 0x5f, 0x54, 0x41, 0x53, 0x4b, 0x5f, 0x45, 0x41, 0x52, 0x4c, 0x49, 0x45, 0x53, 0x54, 0x5f,- 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x45, 0x44, 0x5f, 0x54, 0x49, 0x4d, 0x45, 0x5f, 0x55, 0x50, 0x44,- 0x41, 0x54, 0x45, 0x10, 0x23, 0x12, 0x22, 0x0a, 0x1e, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f,- 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x52, 0x45, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x4f,- 0x52, 0x59, 0x5f, 0x50, 0x55, 0x53, 0x48, 0x10, 0x29, 0x12, 0x20, 0x0a, 0x1c, 0x41, 0x43, 0x54,- 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x4d, 0x45, 0x4d, 0x42,- 0x45, 0x52, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x2a, 0x12, 0x20, 0x0a, 0x1c, 0x41,- 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x4d, 0x45,- 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x2b, 0x12, 0x25, 0x0a,- 0x21, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f,- 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41,- 0x54, 0x45, 0x10, 0x2c, 0x12, 0x2e, 0x0a, 0x2a, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50,- 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x5f,- 0x52, 0x45, 0x43, 0x4f, 0x56, 0x45, 0x52, 0x59, 0x5f, 0x50, 0x49, 0x54, 0x52, 0x5f, 0x44, 0x4f,- 0x4e, 0x45, 0x10, 0x2d, 0x12, 0x24, 0x0a, 0x20, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50,- 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x5f,- 0x54, 0x52, 0x41, 0x4e, 0x53, 0x46, 0x45, 0x52, 0x10, 0x2e, 0x12, 0x24, 0x0a, 0x20, 0x41, 0x43,- 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x53, 0x51,- 0x4c, 0x5f, 0x45, 0x44, 0x49, 0x54, 0x4f, 0x52, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x3d,- 0x12, 0x1e, 0x0a, 0x1a, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42,- 0x41, 0x53, 0x45, 0x5f, 0x53, 0x51, 0x4c, 0x5f, 0x45, 0x58, 0x50, 0x4f, 0x52, 0x54, 0x10, 0x3e,- 0x22, 0x52, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x15, 0x0a, 0x11, 0x4c, 0x45, 0x56,- 0x45, 0x4c, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00,- 0x12, 0x0e, 0x0a, 0x0a, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x01,- 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e,- 0x47, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x45, 0x52, 0x52,- 0x4f, 0x52, 0x10, 0x03, 0x32, 0x72, 0x0a, 0x0e, 0x4c, 0x6f, 0x67, 0x67, 0x69, 0x6e, 0x67, 0x53,- 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x6f,- 0x67, 0x73, 0x12, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,- 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,- 0x1a, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c,- 0x69, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,- 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x6f, 0x67,- 0x73, 0x3a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 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,+ 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x42, 0x03, 0xe0, 0x41,+ 0x02, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1f, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f,+ 0x75, 0x72, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52,+ 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x07, 0x70, 0x61, 0x79,+ 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x02, 0x52,+ 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d,+ 0x65, 0x6e, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65,+ 0x6e, 0x74, 0x22, 0xb0, 0x06, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a,+ 0x12, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,+ 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f,+ 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12,+ 0x1d, 0x0a, 0x19, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52,+ 0x5f, 0x52, 0x4f, 0x4c, 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x1a,+ 0x0a, 0x16, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f,+ 0x41, 0x43, 0x54, 0x49, 0x56, 0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x1a, 0x0a, 0x16, 0x41, 0x43,+ 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x44, 0x45, 0x41, 0x43,+ 0x54, 0x49, 0x56, 0x45, 0x10, 0x04, 0x12, 0x17, 0x0a, 0x13, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e,+ 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x15, 0x12,+ 0x1f, 0x0a, 0x1b, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f,+ 0x43, 0x4f, 0x4d, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x16,+ 0x12, 0x1d, 0x0a, 0x19, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45,+ 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x17, 0x12,+ 0x1e, 0x0a, 0x1a, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f,+ 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x18, 0x12,+ 0x20, 0x0a, 0x1c, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x5f,+ 0x41, 0x50, 0x50, 0x52, 0x4f, 0x56, 0x41, 0x4c, 0x5f, 0x4e, 0x4f, 0x54, 0x49, 0x46, 0x59, 0x10,+ 0x19, 0x12, 0x27, 0x0a, 0x23, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49, 0x50, 0x45,+ 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x47, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55,+ 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x1f, 0x12, 0x26, 0x0a, 0x22, 0x41, 0x43,+ 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49, 0x50, 0x45, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x54, 0x41,+ 0x53, 0x4b, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45,+ 0x10, 0x20, 0x12, 0x24, 0x0a, 0x20, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49, 0x50,+ 0x45, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x54, 0x41, 0x53, 0x4b, 0x5f, 0x46, 0x49, 0x4c, 0x45, 0x5f,+ 0x43, 0x4f, 0x4d, 0x4d, 0x49, 0x54, 0x10, 0x21, 0x12, 0x29, 0x0a, 0x25, 0x41, 0x43, 0x54, 0x49,+ 0x4f, 0x4e, 0x5f, 0x50, 0x49, 0x50, 0x45, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x54, 0x41, 0x53, 0x4b,+ 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x4d, 0x45, 0x4e, 0x54, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54,+ 0x45, 0x10, 0x22, 0x12, 0x35, 0x0a, 0x31, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x49,+ 0x50, 0x45, 0x4c, 0x49, 0x4e, 0x45, 0x5f, 0x54, 0x41, 0x53, 0x4b, 0x5f, 0x45, 0x41, 0x52, 0x4c,+ 0x49, 0x45, 0x53, 0x54, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x45, 0x44, 0x5f, 0x54, 0x49, 0x4d,+ 0x45, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x23, 0x12, 0x22, 0x0a, 0x1e, 0x41, 0x43,+ 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x52, 0x45, 0x50,+ 0x4f, 0x53, 0x49, 0x54, 0x4f, 0x52, 0x59, 0x5f, 0x50, 0x55, 0x53, 0x48, 0x10, 0x29, 0x12, 0x20,+ 0x0a, 0x1c, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54,+ 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x2a,+ 0x12, 0x20, 0x0a, 0x1c, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45,+ 0x43, 0x54, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45,+ 0x10, 0x2b, 0x12, 0x25, 0x0a, 0x21, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f,+ 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x5f, 0x52, 0x4f, 0x4c, 0x45,+ 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x2c, 0x12, 0x2e, 0x0a, 0x2a, 0x41, 0x43, 0x54,+ 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x44, 0x41, 0x54, 0x41,+ 0x42, 0x41, 0x53, 0x45, 0x5f, 0x52, 0x45, 0x43, 0x4f, 0x56, 0x45, 0x52, 0x59, 0x5f, 0x50, 0x49,+ 0x54, 0x52, 0x5f, 0x44, 0x4f, 0x4e, 0x45, 0x10, 0x2d, 0x12, 0x24, 0x0a, 0x20, 0x41, 0x43, 0x54,+ 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x44, 0x41, 0x54, 0x41,+ 0x42, 0x41, 0x53, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x46, 0x45, 0x52, 0x10, 0x2e, 0x12,+ 0x24, 0x0a, 0x20, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x42, 0x41,+ 0x53, 0x45, 0x5f, 0x53, 0x51, 0x4c, 0x5f, 0x45, 0x44, 0x49, 0x54, 0x4f, 0x52, 0x5f, 0x51, 0x55,+ 0x45, 0x52, 0x59, 0x10, 0x3d, 0x12, 0x1e, 0x0a, 0x1a, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f,+ 0x44, 0x41, 0x54, 0x41, 0x42, 0x41, 0x53, 0x45, 0x5f, 0x53, 0x51, 0x4c, 0x5f, 0x45, 0x58, 0x50,+ 0x4f, 0x52, 0x54, 0x10, 0x3e, 0x22, 0x52, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x15,+ 0x0a, 0x11, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,+ 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x49,+ 0x4e, 0x46, 0x4f, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x5f, 0x57,+ 0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x4c, 0x45, 0x56, 0x45,+ 0x4c, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x32, 0xd2, 0x01, 0x0a, 0x0e, 0x4c, 0x6f,+ 0x67, 0x67, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x08,+ 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x1c, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73,+ 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f,+ 0x76, 0x31, 0x2f, 0x6c, 0x6f, 0x67, 0x73, 0x3a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x5e,+ 0x0a, 0x06, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x12, 0x1a, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71,+ 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,+ 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x22, 0x20, 0xda, 0x41,+ 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x31,+ 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x6c, 0x6f, 0x67, 0x73, 0x2f, 0x2a, 0x7d, 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 (@@ -630,27 +700,31 @@ func file_v1_logging_service_proto_rawDescGZIP() []byte {}var file_v1_logging_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)-var file_v1_logging_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3)+var file_v1_logging_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)var file_v1_logging_service_proto_goTypes = []interface{}{(LogEntity_Action)(0), // 0: bytebase.v1.LogEntity.Action(LogEntity_Level)(0), // 1: bytebase.v1.LogEntity.Level(*ListLogsRequest)(nil), // 2: bytebase.v1.ListLogsRequest(*ListLogsResponse)(nil), // 3: bytebase.v1.ListLogsResponse- (*LogEntity)(nil), // 4: bytebase.v1.LogEntity- (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp+ (*GetLogRequest)(nil), // 4: bytebase.v1.GetLogRequest+ (*LogEntity)(nil), // 5: bytebase.v1.LogEntity+ (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp}var file_v1_logging_service_proto_depIdxs = []int32{- 4, // 0: bytebase.v1.ListLogsResponse.log_entities:type_name -> bytebase.v1.LogEntity- 5, // 1: bytebase.v1.LogEntity.create_time:type_name -> google.protobuf.Timestamp- 0, // 2: bytebase.v1.LogEntity.action:type_name -> bytebase.v1.LogEntity.Action- 1, // 3: bytebase.v1.LogEntity.level:type_name -> bytebase.v1.LogEntity.Level- 2, // 4: bytebase.v1.LoggingService.ListLogs:input_type -> bytebase.v1.ListLogsRequest- 3, // 5: bytebase.v1.LoggingService.ListLogs:output_type -> bytebase.v1.ListLogsResponse- 5, // [5:6] is the sub-list for method output_type- 4, // [4:5] is the sub-list for method input_type- 4, // [4:4] is the sub-list for extension type_name- 4, // [4:4] is the sub-list for extension extendee- 0, // [0:4] is the sub-list for field type_name+ 5, // 0: bytebase.v1.ListLogsResponse.log_entities:type_name -> bytebase.v1.LogEntity+ 6, // 1: bytebase.v1.LogEntity.create_time:type_name -> google.protobuf.Timestamp+ 6, // 2: bytebase.v1.LogEntity.update_time:type_name -> google.protobuf.Timestamp+ 0, // 3: bytebase.v1.LogEntity.action:type_name -> bytebase.v1.LogEntity.Action+ 1, // 4: bytebase.v1.LogEntity.level:type_name -> bytebase.v1.LogEntity.Level+ 2, // 5: bytebase.v1.LoggingService.ListLogs:input_type -> bytebase.v1.ListLogsRequest+ 4, // 6: bytebase.v1.LoggingService.GetLog:input_type -> bytebase.v1.GetLogRequest+ 3, // 7: bytebase.v1.LoggingService.ListLogs:output_type -> bytebase.v1.ListLogsResponse+ 5, // 8: bytebase.v1.LoggingService.GetLog:output_type -> bytebase.v1.LogEntity+ 7, // [7:9] is the sub-list for method output_type+ 5, // [5:7] is the sub-list for method input_type+ 5, // [5:5] is the sub-list for extension type_name+ 5, // [5:5] is the sub-list for extension extendee+ 0, // [0:5] is the sub-list for field type_name}func init() { file_v1_logging_service_proto_init() }@@ -684,6 +758,18 @@ func file_v1_logging_service_proto_init() {}}file_v1_logging_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*GetLogRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_logging_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {switch v := v.(*LogEntity); i {case 0:return &v.state@@ -702,7 +788,7 @@ func file_v1_logging_service_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: file_v1_logging_service_proto_rawDesc,NumEnums: 2,- NumMessages: 3,+ NumMessages: 4,NumExtensions: 0,NumServices: 1,},diff --git a/proto/generated-go/v1/logging_service.pb.gw.go b/proto/generated-go/v1/logging_service.pb.gw.goindex cd2832971e..038b2b9887 100644--- a/proto/generated-go/v1/logging_service.pb.gw.go+++ b/proto/generated-go/v1/logging_service.pb.gw.go@@ -67,6 +67,58 @@ func local_request_LoggingService_ListLogs_0(ctx context.Context, marshaler runt}+func request_LoggingService_GetLog_0(ctx context.Context, marshaler runtime.Marshaler, client LoggingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq GetLogRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := client.GetLog(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_LoggingService_GetLog_0(ctx context.Context, marshaler runtime.Marshaler, server LoggingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq GetLogRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := server.GetLog(ctx, &protoReq)+ return msg, metadata, err++}+// RegisterLoggingServiceHandlerServer registers the http handlers for service LoggingService to "mux".// UnaryRPC :call LoggingServiceServer directly.// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.@@ -98,6 +150,31 @@ func RegisterLoggingServiceHandlerServer(ctx context.Context, mux *runtime.Serve})+ mux.Handle("GET", pattern_LoggingService_GetLog_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.LoggingService/GetLog", runtime.WithHTTPPathPattern("/v1/{name=logs/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_LoggingService_GetLog_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_LoggingService_GetLog_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+return nil}@@ -161,13 +238,39 @@ func RegisterLoggingServiceHandlerClient(ctx context.Context, mux *runtime.Serve})+ mux.Handle("GET", pattern_LoggingService_GetLog_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.LoggingService/GetLog", runtime.WithHTTPPathPattern("/v1/{name=logs/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_LoggingService_GetLog_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_LoggingService_GetLog_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })+return nil}var (pattern_LoggingService_ListLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "logs"}, "search"))++ pattern_LoggingService_GetLog_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "logs", "name"}, "")))var (forward_LoggingService_ListLogs_0 = runtime.ForwardResponseMessage++ forward_LoggingService_GetLog_0 = runtime.ForwardResponseMessage)diff --git a/proto/generated-go/v1/logging_service_grpc.pb.go b/proto/generated-go/v1/logging_service_grpc.pb.goindex d170320fbf..11a3c20a30 100644--- a/proto/generated-go/v1/logging_service_grpc.pb.go+++ b/proto/generated-go/v1/logging_service_grpc.pb.go@@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion7const (LoggingService_ListLogs_FullMethodName = "/bytebase.v1.LoggingService/ListLogs"+ LoggingService_GetLog_FullMethodName = "/bytebase.v1.LoggingService/GetLog")// LoggingServiceClient is the client API for LoggingService service.@@ -27,6 +28,7 @@ const (// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.type LoggingServiceClient interface {ListLogs(ctx context.Context, in *ListLogsRequest, opts ...grpc.CallOption) (*ListLogsResponse, error)+ GetLog(ctx context.Context, in *GetLogRequest, opts ...grpc.CallOption) (*LogEntity, error)}type loggingServiceClient struct {@@ -46,11 +48,21 @@ func (c *loggingServiceClient) ListLogs(ctx context.Context, in *ListLogsRequestreturn out, nil}+func (c *loggingServiceClient) GetLog(ctx context.Context, in *GetLogRequest, opts ...grpc.CallOption) (*LogEntity, error) {+ out := new(LogEntity)+ err := c.cc.Invoke(ctx, LoggingService_GetLog_FullMethodName, in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}+// LoggingServiceServer is the server API for LoggingService service.// All implementations must embed UnimplementedLoggingServiceServer// for forward compatibilitytype LoggingServiceServer interface {ListLogs(context.Context, *ListLogsRequest) (*ListLogsResponse, error)+ GetLog(context.Context, *GetLogRequest) (*LogEntity, error)mustEmbedUnimplementedLoggingServiceServer()}@@ -61,6 +73,9 @@ type UnimplementedLoggingServiceServer struct {func (UnimplementedLoggingServiceServer) ListLogs(context.Context, *ListLogsRequest) (*ListLogsResponse, error) {return nil, status.Errorf(codes.Unimplemented, "method ListLogs not implemented")}+func (UnimplementedLoggingServiceServer) GetLog(context.Context, *GetLogRequest) (*LogEntity, error) {+ return nil, status.Errorf(codes.Unimplemented, "method GetLog not implemented")+}func (UnimplementedLoggingServiceServer) mustEmbedUnimplementedLoggingServiceServer() {}// UnsafeLoggingServiceServer may be embedded to opt out of forward compatibility for this service.@@ -92,6 +107,24 @@ func _LoggingService_ListLogs_Handler(srv interface{}, ctx context.Context, decreturn interceptor(ctx, in, info, handler)}+func _LoggingService_GetLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(GetLogRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(LoggingServiceServer).GetLog(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: LoggingService_GetLog_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(LoggingServiceServer).GetLog(ctx, req.(*GetLogRequest))+ }+ return interceptor(ctx, in, info, handler)+}+// LoggingService_ServiceDesc is the grpc.ServiceDesc for LoggingService service.// It's only intended for direct use with grpc.RegisterService,// and not to be introspected or modified (even as a copy)@@ -103,6 +136,10 @@ var LoggingService_ServiceDesc = grpc.ServiceDesc{MethodName: "ListLogs",Handler: _LoggingService_ListLogs_Handler,},+ {+ MethodName: "GetLog",+ Handler: _LoggingService_GetLog_Handler,+ },},Streams: []grpc.StreamDesc{},Metadata: "v1/logging_service.proto",diff --git a/proto/v1/logging_service.proto b/proto/v1/logging_service.protoindex 21e33631a1..64d8f3c5e5 100644--- a/proto/v1/logging_service.proto+++ b/proto/v1/logging_service.proto@@ -3,6 +3,7 @@ syntax = "proto3";package bytebase.v1;import "google/api/annotations.proto";+import "google/api/client.proto";import "google/api/field_behavior.proto";import "google/protobuf/timestamp.proto";@@ -12,6 +13,11 @@ service LoggingService {rpc ListLogs(ListLogsRequest) returns (ListLogsResponse) {option (google.api.http) = {get: "/v1/logs:search"};}++ rpc GetLog(GetLogRequest) returns (LogEntity) {+ option (google.api.http) = {get: "/v1/{name=logs/*}"};+ option (google.api.method_signature) = "name";+ }}message ListLogsRequest {@@ -37,7 +43,7 @@ message ListLogsRequest {// The order by of the log.// Only support order by create_time.// For example:- // - order_by = "create_time acs"+ // - order_by = "create_time asc"// - order_by = "create_time desc"string order_by = 2;@@ -62,6 +68,12 @@ message ListLogsResponse {string next_page_token = 2;}+message GetLogRequest {+ // The name of the log to retrieve.+ // Format: logs/{uid}+ string name = 1 [(google.api.field_behavior) = REQUIRED];+}+message LogEntity {// The name of the log.// Format: logs/{uid}@@ -71,9 +83,10 @@ message LogEntity {// Format: users/{email}string creator = 2 [(google.api.field_behavior) = OUTPUT_ONLY];- // The timestamp when the backup resource was created initally.google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];+ google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];+enum Action {ACTION_UNSPECIFIED = 0;// In worksapce resource only.@@ -142,7 +155,7 @@ message LogEntity {// ACTION_DATABASE_SQL_EXPORT is the type for exporting SQL.ACTION_DATABASE_SQL_EXPORT = 62;}- Action action = 4 [(google.api.field_behavior) = REQUIRED];+ Action action = 5 [(google.api.field_behavior) = REQUIRED];enum Level {LEVEL_UNSPECIFIED = 0;@@ -153,7 +166,7 @@ message LogEntity {// LEVEL_ERROR is the type for error.LEVEL_ERROR = 3;}- Level level = 5 [(google.api.field_behavior) = REQUIRED];+ Level level = 6 [(google.api.field_behavior) = REQUIRED];// The name of the resource associated with this log entity. For example, the resource user associated with log entity type of "ACTION_MEMBER_CREATE".// Format:@@ -162,11 +175,11 @@ message LogEntity {// For ACTION_PIPELINE_*: pipelines/{pipeline uid}// For ACTION_PROJECT_*: projects/{project resource id}// For ACTION_DATABASE_*: instances/{instance resource id}- string resource = 6 [(google.api.field_behavior) = REQUIRED];+ string resource = 7 [(google.api.field_behavior) = REQUIRED];// The payload of the log entity.// TODO: use oneof- string payload = 7 [(google.api.field_behavior) = REQUIRED];+ string payload = 8 [(google.api.field_behavior) = REQUIRED];- string comment = 8;+ string comment = 9;}