Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: worksheet filter (#15928)
ecmadaob11a4c463b3e
diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.goindex 63d97360a5..cf7865ac13 100644--- a/backend/api/v1/database_service.go+++ b/backend/api/v1/database_service.go@@ -248,7 +248,7 @@ func getListDatabaseFilter(filter string) (*store.ListResourceFilter, error) {}return fmt.Sprintf("(db.metadata->>'drifted')::boolean %s TRUE", condition), nilcase "exclude_unassigned":- if _, ok := value.(bool); ok {+ if excludeUnassigned, ok := value.(bool); excludeUnassigned && ok {positionalArgs = append(positionalArgs, base.DefaultProjectID)return fmt.Sprintf("db.project != $%d", len(positionalArgs)), nil}diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.goindex c69f1bfc32..9ccfc215ff 100644--- a/backend/api/v1/project_service.go+++ b/backend/api/v1/project_service.go@@ -138,7 +138,7 @@ func getListProjectFilter(filter string) (*store.ListResourceFilter, error) {positionalArgs = append(positionalArgs, value.(string))return fmt.Sprintf("project.resource_id = $%d", len(positionalArgs)), nilcase "exclude_default":- if _, ok := value.(bool); ok {+ if excludeDefault, ok := value.(bool); excludeDefault && ok {positionalArgs = append(positionalArgs, base.DefaultProjectID)return fmt.Sprintf("project.resource_id != $%d", len(positionalArgs)), nil}diff --git a/backend/api/v1/worksheet_service.go b/backend/api/v1/worksheet_service.goindex 1a1a1fa24c..424fb9a12f 100644--- a/backend/api/v1/worksheet_service.go+++ b/backend/api/v1/worksheet_service.go@@ -12,6 +12,10 @@ import ("google.golang.org/protobuf/types/known/emptypb""google.golang.org/protobuf/types/known/timestamppb"+ "github.com/google/cel-go/cel"+ celast "github.com/google/cel-go/common/ast"+ celoperators "github.com/google/cel-go/common/operators"+"github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/iam"@@ -141,6 +145,127 @@ func (s *WorksheetService) GetWorksheet(ctx context.Context, request *v1pb.GetWoreturn v1pbWorksheet, nil}+func (s *WorksheetService) getListSheetFilter(ctx context.Context, callerID int, filter string) (*store.ListResourceFilter, error) {+ if filter == "" {+ return nil, nil+ }+ e, err := cel.NewEnv()+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to create cel env")+ }+ ast, iss := e.Parse(filter)+ if iss != nil {+ return nil, status.Errorf(codes.InvalidArgument, "failed to parse filter %v, error: %v", filter, iss.String())+ }++ var getFilter func(expr celast.Expr) (string, error)+ var positionalArgs []any++ getUserID := func(name string) (int, error) {+ creatorEmail := strings.TrimPrefix(name, "users/")+ if creatorEmail == "" {+ return 0, status.Errorf(codes.InvalidArgument, "invalid empty creator identifier")+ }+ user, err := s.store.GetUserByEmail(ctx, creatorEmail)+ if err != nil {+ return 0, status.Errorf(codes.Internal, "failed to get user: %v", err)+ }+ if user == nil {+ return 0, status.Errorf(codes.NotFound, "user with email %s not found", creatorEmail)+ }+ return user.ID, nil+ }++ parseToSQL := func(variable, value any) (string, error) {+ switch variable {+ case "creator":+ userID, err := getUserID(value.(string))+ if err != nil {+ return "", err+ }+ positionalArgs = append(positionalArgs, userID)+ return fmt.Sprintf("worksheet.creator_id = $%d", len(positionalArgs)), nil+ case "starred":+ if starred, ok := value.(bool); ok {+ positionalArgs = append(positionalArgs, callerID)+ return fmt.Sprintf("worksheet.id IN (SELECT worksheet_id FROM worksheet_organizer WHERE principal_id = $%d AND starred = %v)", len(positionalArgs), starred), nil+ }+ return "TRUE", nil+ case "visibility":+ visibility, err := convertToStoreWorksheetVisibility(v1pb.Worksheet_Visibility(v1pb.Worksheet_Visibility_value[value.(string)]))+ if err != nil {+ return "", err+ }+ positionalArgs = append(positionalArgs, visibility)+ return fmt.Sprintf("worksheet.visibility = $%d", len(positionalArgs)), nil+ default:+ return "", status.Errorf(codes.InvalidArgument, "unsupport variable %q", variable)+ }+ }++ getFilter = func(expr celast.Expr) (string, error) {+ switch expr.Kind() {+ case celast.CallKind:+ functionName := expr.AsCall().FunctionName()+ switch functionName {+ case celoperators.LogicalOr:+ return getSubConditionFromExpr(expr, getFilter, "OR")+ case celoperators.LogicalAnd:+ return getSubConditionFromExpr(expr, getFilter, "AND")+ case celoperators.Equals:+ variable, value := getVariableAndValueFromExpr(expr)+ return parseToSQL(variable, value)+ case celoperators.NotEquals:+ variable, value := getVariableAndValueFromExpr(expr)+ if variable != "creator" {+ return "", status.Errorf(codes.InvalidArgument, `only "creator" support "!=" operator`)+ }+ userID, err := getUserID(value.(string))+ if err != nil {+ return "", err+ }+ positionalArgs = append(positionalArgs, userID)+ return fmt.Sprintf("worksheet.creator_id != $%d", len(positionalArgs)), nil+ case celoperators.In:+ variable, value := getVariableAndValueFromExpr(expr)+ if variable != "visibility" {+ return "", status.Errorf(codes.InvalidArgument, `only "visibility" support "visibility in [xx]" filter`)+ }+ rawList, ok := value.([]any)+ if !ok {+ return "", status.Errorf(codes.InvalidArgument, "invalid visibility value %q", value)+ }+ if len(rawList) == 0 {+ return "", status.Errorf(codes.InvalidArgument, "empty visibility filter")+ }+ visibilityList := []string{}+ for _, raw := range rawList {+ visibility, err := convertToStoreWorksheetVisibility(v1pb.Worksheet_Visibility(v1pb.Worksheet_Visibility_value[raw.(string)]))+ if err != nil {+ return "", err+ }+ visibilityList = append(visibilityList, fmt.Sprintf(`'%s'`, visibility))+ }+ return fmt.Sprintf(`worksheet.visibility IN (%s)`, strings.Join(visibilityList, ",")), nil+ default:+ return "", status.Errorf(codes.InvalidArgument, "unexpected function %v", functionName)+ }+ default:+ return "", status.Errorf(codes.InvalidArgument, "unexpected expr kind %v", expr.Kind())+ }+ }++ where, err := getFilter(ast.NativeRep().Expr())+ if err != nil {+ return nil, err+ }++ return &store.ListResourceFilter{+ Args: positionalArgs,+ Where: "(" + where + ")",+ }, nil+}+// SearchWorksheets returns a list of worksheets based on the search filters.func (s *WorksheetService) SearchWorksheets(ctx context.Context, request *v1pb.SearchWorksheetsRequest) (*v1pb.SearchWorksheetsResponse, error) {principalID, ok := ctx.Value(common.PrincipalIDContextKey).(int)@@ -158,59 +283,12 @@ func (s *WorksheetService) SearchWorksheets(ctx context.Context, request *v1pb.Sreturn nil, status.Errorf(codes.InvalidArgument, "filter should not be empty")}- specs, err := ParseFilter(request.Filter)+ filter, err := s.getListSheetFilter(ctx, principalID, request.Filter)if err != nil {- return nil, status.Error(codes.InvalidArgument, err.Error())- }- for _, spec := range specs {- switch spec.Key {- case "creator":- creatorEmail := strings.TrimPrefix(spec.Value, "users/")- if creatorEmail == "" {- return nil, status.Errorf(codes.InvalidArgument, "invalid empty creator identifier")- }- user, err := s.store.GetUserByEmail(ctx, creatorEmail)- if err != nil {- return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)- }- if user == nil {- return nil, status.Errorf(codes.NotFound, "user with email %s not found", creatorEmail)- }- switch spec.Operator {- case ComparatorTypeEqual:- worksheetFind.CreatorID = &user.ID- case ComparatorTypeNotEqual:- worksheetFind.ExcludedCreatorID = &user.ID- default:- return nil, status.Errorf(codes.InvalidArgument, "invalid operator %q for creator", spec.Operator)- }- case "starred":- if spec.Operator != ComparatorTypeEqual {- return nil, status.Errorf(codes.InvalidArgument, "invalid operator %q for starred", spec.Operator)- }- switch spec.Value {- case "true":- worksheetFind.OrganizerPrincipalIDStarred = &principalID- case "false":- worksheetFind.OrganizerPrincipalIDNotStarred = &principalID- default:- return nil, status.Errorf(codes.InvalidArgument, "invalid value %q for starred", spec.Value)- }- case "visibility":- if spec.Operator != ComparatorTypeEqual {- return nil, status.Errorf(codes.InvalidArgument, "invalid operator %q for starred", spec.Operator)- }- for _, rawVisibility := range strings.Split(spec.Value, " | ") {- visibility, err := convertToStoreWorksheetVisibility(v1pb.Worksheet_Visibility(v1pb.Worksheet_Visibility_value[rawVisibility]))- if err != nil {- return nil, err- }- worksheetFind.Visibilities = append(worksheetFind.Visibilities, visibility)- }- default:- return nil, status.Errorf(codes.InvalidArgument, "invalid filter key %q", spec.Key)- }+ return nil, err}+ worksheetFind.Filter = filter+worksheetList, err := s.store.ListWorkSheets(ctx, worksheetFind, principalID)if err != nil {return nil, status.Errorf(codes.Internal, "failed to list worksheets: %v", err)diff --git a/backend/store/worksheet.go b/backend/store/worksheet.goindex 72f4459616..f0510500a2 100644--- a/backend/store/worksheet.go+++ b/backend/store/worksheet.go@@ -53,23 +53,10 @@ type WorkSheetMessage struct {type FindWorkSheetMessage struct {UID *int- // Used to find the creator's sheet list.- // When finding shared PROJECT/PUBLIC sheets, this value should be empty.- // It does not make sense to set both `CreatorID` and `ExcludedCreatorID`.- CreatorID *int- // Used to find the sheets that are not created by the creator.- ExcludedCreatorID *int-// LoadFull is used if we want to load the full sheet.LoadFull bool- // Domain fields- Visibilities []WorkSheetVisibility-- // Used to find (un)starred sheet list, could be PRIVATE/PROJECT/PUBLIC sheet.- // For now, we only need the starred sheets.- OrganizerPrincipalIDStarred *int- OrganizerPrincipalIDNotStarred *int+ Filter *ListResourceFilter}// PatchWorkSheetMessage is the message to patch a sheet.@@ -102,33 +89,15 @@ func (s *Store) GetWorkSheet(ctx context.Context, find *FindWorkSheetMessage, cu// ListWorkSheets returns a list of sheets.func (s *Store) ListWorkSheets(ctx context.Context, find *FindWorkSheetMessage, currentPrincipalID int) ([]*WorkSheetMessage, error) {where, args := []string{"TRUE"}, []any{}+ if filter := find.Filter; filter != nil {+ where = append(where, filter.Where)+ args = append(args, filter.Args...)+ }if v := find.UID; v != nil {where, args = append(where, fmt.Sprintf("worksheet.id = $%d", len(args)+1)), append(args, *v)}- // Standard fields- if v := find.CreatorID; v != nil {- where, args = append(where, fmt.Sprintf("worksheet.creator_id = $%d", len(args)+1)), append(args, *v)- }- if v := find.ExcludedCreatorID; v != nil {- where, args = append(where, fmt.Sprintf("worksheet.creator_id != $%d", len(args)+1)), append(args, *v)- }-- // Domain fields- visibilitiesWhere := []string{}- for _, v := range find.Visibilities {- visibilitiesWhere, args = append(visibilitiesWhere, fmt.Sprintf("visibility = $%d", len(args)+1)), append(args, v)- }- if len(visibilitiesWhere) > 0 {- where = append(where, fmt.Sprintf("(%s)", strings.Join(visibilitiesWhere, " OR ")))- }- if v := find.OrganizerPrincipalIDStarred; v != nil {- where, args = append(where, fmt.Sprintf("worksheet.id IN (SELECT worksheet_id FROM worksheet_organizer WHERE principal_id = $%d AND starred = true)", len(args)+1)), append(args, *v)- }- if v := find.OrganizerPrincipalIDNotStarred; v != nil {- where, args = append(where, fmt.Sprintf("worksheet.id IN (SELECT worksheet_id FROM worksheet_organizer WHERE principal_id = $%d AND starred = false)", len(args)+1)), append(args, *v)- }statementField := fmt.Sprintf("LEFT(worksheet.statement, %d)", common.MaxSheetSize)if find.LoadFull {statementField = "worksheet.statement"diff --git a/frontend/src/store/modules/v1/worksheet.ts b/frontend/src/store/modules/v1/worksheet.tsindex c14bf7401a..b8dbe252df 100644--- a/frontend/src/store/modules/v1/worksheet.ts+++ b/frontend/src/store/modules/v1/worksheet.ts@@ -176,7 +176,7 @@ export const useWorkSheetStore = defineStore("worksheet_v1", () => {const fetchMyWorksheetList = async () => {const me = useCurrentUserV1();const { worksheets } = await worksheetServiceClient.searchWorksheets({- filter: `creator = users/${me.value.email}`,+ filter: `creator == "users/${me.value.email}"`,});await setListCache(worksheets);return worksheets;@@ -184,7 +184,7 @@ export const useWorkSheetStore = defineStore("worksheet_v1", () => {const fetchSharedWorksheetList = async () => {const me = useCurrentUserV1();const { worksheets } = await worksheetServiceClient.searchWorksheets({- filter: `creator != "users/${me.value.email}" && visibility = "${Worksheet_Visibility.VISIBILITY_PROJECT_READ} | ${Worksheet_Visibility.VISIBILITY_PROJECT_WRITE}"`,+ filter: `creator != "users/${me.value.email}" && visibility in ["${Worksheet_Visibility.VISIBILITY_PROJECT_READ}","${Worksheet_Visibility.VISIBILITY_PROJECT_WRITE}"]`,});await setListCache(worksheets);return worksheets;@@ -192,7 +192,7 @@ export const useWorkSheetStore = defineStore("worksheet_v1", () => {const fetchStarredWorksheetList = async () => {const { worksheets } = await worksheetServiceClient.searchWorksheets({- filter: `starred = true`,+ filter: `starred == true`,});await setListCache(worksheets);return worksheets;diff --git a/frontend/src/types/proto/v1/database_service.ts b/frontend/src/types/proto/v1/database_service.tsindex ded01240d0..59752546f1 100644--- a/frontend/src/types/proto/v1/database_service.ts+++ b/frontend/src/types/proto/v1/database_service.ts@@ -129,6 +129,7 @@ export interface ListDatabasesRequest {* - engine* - label* - exclude_unassigned: Not show unassigned databases if specified+ * - drifted** For example:* environment == "environments/{environment resource id}"@@ -142,6 +143,7 @@ export interface ListDatabasesRequest {* label == "tenant:asia,europe"* label == "region:asia" && label == "tenant:bytebase"* exclude_unassigned == true+ * drifted == true* You can combine filter conditions like:* environment == "environments/prod" && name.matches("employee")*/@@ -201,7 +203,7 @@ export interface BatchSyncDatabasesRequest {* If the operation spans parents, a dash (-) may be accepted as a wildcard.*/parent: string;- /** The list of database names to retrieve. */+ /** The list of database names to sync. */names: string[];}diff --git a/frontend/src/types/proto/v1/worksheet_service.ts b/frontend/src/types/proto/v1/worksheet_service.tsindex 7006036c9b..1474b31954 100644--- a/frontend/src/types/proto/v1/worksheet_service.ts+++ b/frontend/src/types/proto/v1/worksheet_service.ts@@ -89,11 +89,18 @@ export interface DeleteWorksheetRequest {export interface SearchWorksheetsRequest {/*** To filter the search result.- * Format: only support the following spec for now:- * - `creator = users/{email}`, `creator != users/{email}`- * - `starred = true`, `starred = false`.- * - `visibility = "VISIBILITY_PRIVATE"`, `visibility = "VISIBILITY_PROJECT_READ | VISIBILITY_PROJECT_WRITE"`, etc.- * Not support empty filter for now.+ * Supported filter:+ * - creator+ * - starred+ * - visibility+ *+ * For example:+ * creator == "users/{email}"+ * creator != "users/{email}"+ * starred == true+ * starred == false+ * visibility in ["VISIBILITY_PRIVATE", "VISIBILITY_PROJECT_READ", "VISIBILITY_PROJECT_WRITE"]+ * visibility == "VISIBILITY_PRIVATE"*/filter: string;/**diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex a49a10a0d3..345cf70898 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -1095,6 +1095,7 @@ paths:- engine- label- exclude_unassigned: Not show unassigned databases if specified+ - driftedFor example:environment == "environments/{environment resource id}"@@ -1108,6 +1109,7 @@ paths:label == "tenant:asia,europe"label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == true+ drifted == trueYou can combine filter conditions like:environment == "environments/prod" && name.matches("employee")schema:@@ -3864,6 +3866,7 @@ paths:- engine- label- exclude_unassigned: Not show unassigned databases if specified+ - driftedFor example:environment == "environments/{environment resource id}"@@ -3877,6 +3880,7 @@ paths:label == "tenant:asia,europe"label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == true+ drifted == trueYou can combine filter conditions like:environment == "environments/prod" && name.matches("employee")schema:@@ -7448,6 +7452,7 @@ paths:- engine- label- exclude_unassigned: Not show unassigned databases if specified+ - driftedFor example:environment == "environments/{environment resource id}"@@ -7461,6 +7466,7 @@ paths:label == "tenant:asia,europe"label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == true+ drifted == trueYou can combine filter conditions like:environment == "environments/prod" && name.matches("employee")schema:@@ -8243,7 +8249,7 @@ components:type: arrayitems:type: string- description: The list of database names to retrieve.+ description: The list of database names to sync.BatchSyncDatabasesResponse:type: objectproperties: {}@@ -12623,11 +12629,18 @@ components:type: stringdescription: |-To filter the search result.- Format: only support the following spec for now:- - `creator = users/{email}`, `creator != users/{email}`- - `starred = true`, `starred = false`.- - `visibility = "VISIBILITY_PRIVATE"`, `visibility = "VISIBILITY_PROJECT_READ | VISIBILITY_PROJECT_WRITE"`, etc.- Not support empty filter for now.+ Supported filter:+ - creator+ - starred+ - visibility++ For example:+ creator == "users/{email}"+ creator != "users/{email}"+ starred == true+ starred == false+ visibility in ["VISIBILITY_PRIVATE", "VISIBILITY_PROJECT_READ", "VISIBILITY_PROJECT_WRITE"]+ visibility == "VISIBILITY_PRIVATE"pageSize:type: integerdescription: |-diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 3515684e9a..a53ae771c6 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -1855,7 +1855,7 @@ The instance's `name` field is used to identify the instance to update. Form| Field | Type | Label | Description || ----- | ---- | ----- | ----------- || parent | [string](#string) | | The parent resource shared by all databases being updated. Format: instances/{instance} If the operation spans parents, a dash (-) may be accepted as a wildcard. |-| names | [string](#string) | repeated | The list of database names to retrieve. |+| names | [string](#string) | repeated | The list of database names to sync. |@@ -2621,9 +2621,9 @@ Combine multiple functions with "&&" and "||", we MUST u| page_token | [string](#string) | | A page token, received from a previous `ListDatabases` call. Provide this to retrieve the subsequent page.When paginating, all other parameters provided to `ListDatabases` must match the call that provided the page token. |-| filter | [string](#string) | | Filter is used to filter databases returned in the list. Supported filter: - environment - name - project - instance - engine - label - exclude_unassigned: Not show unassigned databases if specified+| filter | [string](#string) | | Filter is used to filter databases returned in the list. Supported filter: - environment - name - project - instance - engine - label - exclude_unassigned: Not show unassigned databases if specified - drifted-For example: environment == "environments/{environment resource id}" project == "projects/{project resource id}" instance == "instances/{instance resource id}" name.matches("database name") engine == "MYSQL" engine in ["MYSQL", "POSTGRES"] !(engine in ["MYSQL", "POSTGRES"]) label == "region:asia" label == "tenant:asia,europe" label == "region:asia" && label == "tenant:bytebase" exclude_unassigned == true You can combine filter conditions like: environment == "environments/prod" && name.matches("employee") |+For example: environment == "environments/{environment resource id}" project == "projects/{project resource id}" instance == "instances/{instance resource id}" name.matches("database name") engine == "MYSQL" engine in ["MYSQL", "POSTGRES"] !(engine in ["MYSQL", "POSTGRES"]) label == "region:asia" label == "tenant:asia,europe" label == "region:asia" && label == "tenant:bytebase" exclude_unassigned == true drifted == true You can combine filter conditions like: environment == "environments/prod" && name.matches("employee") || show_deleted | [bool](#bool) | | Show deleted database if specified. |@@ -10881,7 +10881,9 @@ Type of the SheetPayload.| Field | Type | Label | Description || ----- | ---- | ----- | ----------- |-| filter | [string](#string) | | To filter the search result. Format: only support the following spec for now: - `creator = users/{email}`, `creator != users/{email}` - `starred = true`, `starred = false`. - `visibility = "VISIBILITY_PRIVATE"`, `visibility = "VISIBILITY_PROJECT_READ | VISIBILITY_PROJECT_WRITE"`, etc. Not support empty filter for now. |+| filter | [string](#string) | | To filter the search result. Supported filter: - creator - starred - visibility++For example: creator == "users/{email}" creator != "users/{email}" starred == true starred == false visibility in ["VISIBILITY_PRIVATE", "VISIBILITY_PROJECT_READ", "VISIBILITY_PROJECT_WRITE"] visibility == "VISIBILITY_PRIVATE" || page_size | [int32](#int32) | | Not used. The maximum number of worksheets to return. The service may return fewer than this value. If unspecified, at most 10 worksheets 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 `SearchWorksheets` call. Provide this to retrieve the subsequent page.diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 6a3228a472..d40891af70 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -5892,7 +5892,7 @@ If the operation spans parents, a dash (-) may be accepted as a wildcard. </p></<td>names</td><td><a href="#string">string</a></td><td>repeated</td>- <td><p>The list of database names to retrieve. </p></td>+ <td><p>The list of database names to sync. </p></td></tr></tbody>@@ -7880,6 +7880,7 @@ Supported filter:- engine- label- exclude_unassigned: Not show unassigned databases if specified+- driftedFor example:environment == "environments/{environment resource id}"@@ -7893,6 +7894,7 @@ label == "region:asia"label == "tenant:asia,europe"label == "region:asia" && label == "tenant:bytebase"exclude_unassigned == true+drifted == trueYou can combine filter conditions like:environment == "environments/prod" && name.matches("employee") </p></td></tr>@@ -29856,11 +29858,18 @@ Format: worksheets/{worksheet} </p></td><td><a href="#string">string</a></td><td></td><td><p>To filter the search result.-Format: only support the following spec for now:-- `creator = users/{email}`, `creator != users/{email}`-- `starred = true`, `starred = false`.-- `visibility = "VISIBILITY_PRIVATE"`, `visibility = "VISIBILITY_PROJECT_READ | VISIBILITY_PROJECT_WRITE"`, etc.-Not support empty filter for now. </p></td>+Supported filter:+- creator+- starred+- visibility++For example:+creator == "users/{email}"+creator != "users/{email}"+starred == true+starred == false+visibility in ["VISIBILITY_PRIVATE", "VISIBILITY_PROJECT_READ", "VISIBILITY_PROJECT_WRITE"]+visibility == "VISIBILITY_PRIVATE" </p></td></tr><tr>diff --git a/proto/generated-go/v1/database_service.pb.go b/proto/generated-go/v1/database_service.pb.goindex 45da891f1a..8738c7283d 100644--- a/proto/generated-go/v1/database_service.pb.go+++ b/proto/generated-go/v1/database_service.pb.go@@ -746,6 +746,7 @@ type ListDatabasesRequest struct {// - engine// - label// - exclude_unassigned: Not show unassigned databases if specified+ // - drifted//// For example:// environment == "environments/{environment resource id}"@@ -759,6 +760,7 @@ type ListDatabasesRequest struct {// label == "tenant:asia,europe"// label == "region:asia" && label == "tenant:bytebase"// exclude_unassigned == true+ // drifted == true// You can combine filter conditions like:// environment == "environments/prod" && name.matches("employee")Filter string `protobuf:"bytes,4,opt,name=filter,proto3" json:"filter,omitempty"`@@ -1054,7 +1056,7 @@ type BatchSyncDatabasesRequest struct {// Format: instances/{instance}// If the operation spans parents, a dash (-) may be accepted as a wildcard.Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`- // The list of database names to retrieve.+ // The list of database names to sync.Names []string `protobuf:"bytes,2,rep,name=names,proto3" json:"names,omitempty"`unknownFields protoimpl.UnknownFieldssizeCache protoimpl.SizeCachediff --git a/proto/generated-go/v1/worksheet_service.pb.go b/proto/generated-go/v1/worksheet_service.pb.goindex f21c7a9bea..8f6dc218e6 100644--- a/proto/generated-go/v1/worksheet_service.pb.go+++ b/proto/generated-go/v1/worksheet_service.pb.go@@ -399,11 +399,18 @@ func (x *DeleteWorksheetRequest) GetName() string {type SearchWorksheetsRequest struct {state protoimpl.MessageState `protogen:"open.v1"`// To filter the search result.- // Format: only support the following spec for now:- // - `creator = users/{email}`, `creator != users/{email}`- // - `starred = true`, `starred = false`.- // - `visibility = "VISIBILITY_PRIVATE"`, `visibility = "VISIBILITY_PROJECT_READ | VISIBILITY_PROJECT_WRITE"`, etc.- // Not support empty filter for now.+ // Supported filter:+ // - creator+ // - starred+ // - visibility+ //+ // For example:+ // creator == "users/{email}"+ // creator != "users/{email}"+ // starred == true+ // starred == false+ // visibility in ["VISIBILITY_PRIVATE", "VISIBILITY_PROJECT_READ", "VISIBILITY_PROJECT_WRITE"]+ // visibility == "VISIBILITY_PRIVATE"Filter string `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"`// Not used.// The maximum number of worksheets to return. The service may return fewer thandiff --git a/proto/v1/database_service.proto b/proto/v1/database_service.protoindex bcaa2d49a4..571940469f 100644--- a/proto/v1/database_service.proto+++ b/proto/v1/database_service.proto@@ -246,6 +246,7 @@ message ListDatabasesRequest {// - engine// - label// - exclude_unassigned: Not show unassigned databases if specified+ // - drifted//// For example:// environment == "environments/{environment resource id}"@@ -259,6 +260,7 @@ message ListDatabasesRequest {// label == "tenant:asia,europe"// label == "region:asia" && label == "tenant:bytebase"// exclude_unassigned == true+ // drifted == true// You can combine filter conditions like:// environment == "environments/prod" && name.matches("employee")string filter = 4;@@ -310,7 +312,7 @@ message BatchSyncDatabasesRequest {// If the operation spans parents, a dash (-) may be accepted as a wildcard.string parent = 1;- // The list of database names to retrieve.+ // The list of database names to sync.repeated string names = 2 [(google.api.field_behavior) = REQUIRED,(google.api.resource_reference) = {type: "bytebase.com/Database"}diff --git a/proto/v1/worksheet_service.proto b/proto/v1/worksheet_service.protoindex b3c62cdb8a..eb32d7d074 100644--- a/proto/v1/worksheet_service.proto+++ b/proto/v1/worksheet_service.proto@@ -139,11 +139,18 @@ message DeleteWorksheetRequest {message SearchWorksheetsRequest {// To filter the search result.- // Format: only support the following spec for now:- // - `creator = users/{email}`, `creator != users/{email}`- // - `starred = true`, `starred = false`.- // - `visibility = "VISIBILITY_PRIVATE"`, `visibility = "VISIBILITY_PROJECT_READ | VISIBILITY_PROJECT_WRITE"`, etc.- // Not support empty filter for now.+ // Supported filter:+ // - creator+ // - starred+ // - visibility+ //+ // For example:+ // creator == "users/{email}"+ // creator != "users/{email}"+ // starred == true+ // starred == false+ // visibility in ["VISIBILITY_PRIVATE", "VISIBILITY_PROJECT_READ", "VISIBILITY_PROJECT_WRITE"]+ // visibility == "VISIBILITY_PRIVATE"string filter = 1;// Not used.