Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: fe connect rpc migrations (#16709)

p0nyf2570d9946c5
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue
index 1fe744a2b4..890ebb90b1 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RiskTips.vue
@@ -20,7 +20,7 @@ import { computed } from "vue";
import { WORKSPACE_ROUTE_RISKS } from "@/router/dashboard/workspaceRoutes";
import { useRiskStore } from "@/store";
import { DEFAULT_RISK_LEVEL } from "@/types";
-import type { Risk_Source } from "@/types/proto/v1/risk_service";
+import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
const props = defineProps<{
level: number;
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vue
index c85ba3836e..64131cd748 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesPanel.vue
@@ -15,7 +15,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import { useSupportedSourceList } from "@/types";
-import { Risk_Source } from "@/types/proto/v1/risk_service";
+import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import { RiskFilter, useRiskFilter } from "../../common";
import RulesSection from "./RulesSection.vue";
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
index 143627d9ae..ce67c3a81d 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
@@ -26,7 +26,7 @@ import { useI18n } from "vue-i18n";
import { pushNotification, useWorkspaceApprovalSettingStore } from "@/store";
import type { ParsedApprovalRule } from "@/types";
import { DEFAULT_RISK_LEVEL, PresetRiskLevelList } from "@/types";
-import type { Risk_Source } from "@/types/proto/v1/risk_service";
+import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import { levelText, sourceText, useRiskFilter } from "../../common";
import { useCustomApprovalContext } from "../context";
import RiskTips from "./RiskTips.vue";
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/types.ts b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/types.ts
index ca37001568..f74a62fe79 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/types.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/types.ts
@@ -1,5 +1,5 @@
-import type { Expr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
-import type { Risk_Source } from "@/types/proto/v1/risk_service";
+import type { Expr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
+import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import type { WorkspaceApprovalSetting_Rule as ApprovalRule } from "@/types/proto-es/v1/setting_service_pb";
export type ParsedApprovalRule = {
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskCenter.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskCenter.vue
index 8e418b5e77..a6471c01da 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskCenter.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskCenter.vue
@@ -23,13 +23,14 @@
</template>
<script lang="ts" setup>
+import { create } from "@bufbuild/protobuf";
import { groupBy } from "lodash-es";
import { PlusIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
import { computed, watch } from "vue";
import { useRiskStore } from "@/store";
import { PresetRiskLevelList, useSupportedSourceList } from "@/types";
-import { Risk, Risk_Source } from "@/types/proto/v1/risk_service";
+import { Risk_Source, RiskSchema } from "@/types/proto-es/v1/risk_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
import { RiskFilter, orderByLevelDesc, useRiskFilter } from "../common";
import RiskSection from "./RiskSection.vue";
@@ -85,9 +86,9 @@ const addRisk = () => {
if (source === Risk_Source.SOURCE_UNSPECIFIED) {
source = supportedSourceList.value[0];
}
- const risk = Risk.fromPartial({
+ const risk = create(RiskSchema, {
level: PresetRiskLevelList[0].level,
- source,
+ source: source,
active: true,
});
if (!hasFeature.value) {
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskDialog.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskDialog.vue
index 234f7a4a1e..de6aa2073d 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskDialog.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskDialog.vue
@@ -28,7 +28,7 @@ import { computed, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BBModal, BBSpin } from "@/bbkit";
import { pushNotification, useRiskStore } from "@/store";
-import type { Risk } from "@/types/proto/v1/risk_service";
+import type { Risk } from "@/types/proto-es/v1/risk_service_pb";
import { defer } from "@/utils";
import { useRiskCenterContext } from "../context";
import RiskForm from "./RiskForm.vue";
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vue
index 208b789c3e..d705370b32 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskForm.vue
@@ -107,8 +107,10 @@ import {
emptySimpleExpr,
} from "@/plugins/cel";
import { useSupportedSourceList } from "@/types";
-import { Expr } from "@/types/proto/google/type/expr";
-import { Risk, Risk_Source } from "@/types/proto/v1/risk_service";
+import { create } from "@bufbuild/protobuf";
+import type { Risk } from "@/types/proto-es/v1/risk_service_pb";
+import { Risk_Source, RiskSchema } from "@/types/proto-es/v1/risk_service_pb";
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
import {
batchConvertCELStringToParsedExpr,
batchConvertParsedExprToCELString,
@@ -145,7 +147,7 @@ const { allowAdmin } = context;
const supportedSourceList = useSupportedSourceList();
const state = reactive<LocalState>({
- risk: Risk.fromPartial({}),
+ risk: create(RiskSchema, {}),
expr: wrapAsGroup(emptySimpleExpr()),
});
const mode = computed(() => context.dialog.value?.mode ?? "CREATE");
@@ -236,7 +238,7 @@ const handleUpsert = async () => {
return;
}
const expressions = await batchConvertParsedExprToCELString([celexpr]);
- risk.condition = Expr.fromPartial({
+ risk.condition = create(ExprSchema, {
expression: expressions[0],
});
emit("save", risk);
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskSourceSelect.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskSourceSelect.vue
index 4c207b1d35..0b36266d4d 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskSourceSelect.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RiskSourceSelect.vue
@@ -14,7 +14,7 @@
import type { SelectOption } from "naive-ui";
import { NSelect, type SelectProps } from "naive-ui";
import { computed } from "vue";
-import type { Risk_Source } from "@/types/proto/v1/risk_service";
+import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import { sourceText } from "../../common";
import { useRiskCenterContext } from "../context";
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
index 77d4d29c6d..c2f9ce6b0d 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
@@ -35,9 +35,10 @@ import { useI18n } from "vue-i18n";
import { BBModal } from "@/bbkit";
import type { ConditionGroupExpr } from "@/plugins/cel";
import { buildCELExpr } from "@/plugins/cel";
-import { Expr } from "@/types/proto/google/type/expr";
-import type { Risk } from "@/types/proto/v1/risk_service";
-import { Risk_Source } from "@/types/proto/v1/risk_service";
+import { create } from "@bufbuild/protobuf";
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
+import type { Risk } from "@/types/proto-es/v1/risk_service_pb";
+import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import { batchConvertParsedExprToCELString, defer } from "@/utils";
import { useRiskCenterContext } from "../context";
import ViewTemplate from "./ViewTemplate.vue";
@@ -132,7 +133,7 @@ const applyTemplate = async (template: RuleTemplate) => {
}
const expressions = await batchConvertParsedExprToCELString([celexpr]);
const overrides: Partial<Risk> = {
- condition: Expr.fromPartial({ expression: expressions[0] }),
+ condition: create(ExprSchema, { expression: expressions[0] }),
level,
title,
};
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/ViewTemplate.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/ViewTemplate.vue
index fcf7a2403d..995e9ece8e 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/ViewTemplate.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/ViewTemplate.vue
@@ -11,7 +11,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import ExprEditor from "@/components/ExprEditor";
-import { Risk_Source } from "@/types/proto/v1/risk_service";
+import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import {
getFactorList,
getOptionConfigMap,
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
index 187eaeee3d..ea4b6af103 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
@@ -5,7 +5,7 @@ import { ExprType, wrapAsGroup } from "@/plugins/cel";
import { t, te } from "@/plugins/i18n";
import { useEnvironmentV1List } from "@/store";
import { PresetRiskLevel, PresetRoleType } from "@/types";
-import { Risk_Source } from "@/types/proto/v1/risk_service";
+import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
/*
The risk for the production environment is considered to be high.
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskSection.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskSection.vue
index cee1b5852c..076cb05874 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskSection.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskSection.vue
@@ -13,7 +13,7 @@
</template>
<script lang="ts" setup>
-import type { Risk, Risk_Source } from "@/types/proto/v1/risk_service";
+import type { Risk, Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import { sourceText } from "../common";
import RiskTable from "./RiskTable.vue";
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue
index 9f4b00bd07..5b1cccd8eb 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue
@@ -15,7 +15,7 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { SpinnerButton, SpinnerSwitch } from "@/components/v2/Form";
import { pushNotification, useRiskStore } from "@/store";
-import type { Risk } from "@/types/proto/v1/risk_service";
+import type { Risk } from "@/types/proto-es/v1/risk_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
import { levelText } from "../common";
import { useRiskCenterContext } from "./context";
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/context.ts b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/context.ts
index c2a04f8d80..8aa3571798 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/context.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/context.ts
@@ -1,5 +1,5 @@
import { inject, provide, type InjectionKey, type Ref } from "vue";
-import type { Risk } from "@/types/proto/v1/risk_service";
+import type { Risk } from "@/types/proto-es/v1/risk_service_pb";
export type DialogContext = {
mode: "EDIT" | "CREATE";
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/SourceFilter.vue b/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/SourceFilter.vue
index 8e4809c5d0..3f0e7c8169 100644
--- a/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/SourceFilter.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/SourceFilter.vue
@@ -7,7 +7,7 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { TabFilter } from "@/components/v2";
import { useSupportedSourceList } from "@/types";
-import { Risk_Source } from "@/types/proto/v1/risk_service";
+import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import { sourceText } from "../../common";
import { useRiskFilter } from "./context";
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/context.ts b/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/context.ts
index 50c64677f2..29f54a5517 100644
--- a/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/context.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/common/RiskFilter/context.ts
@@ -1,5 +1,5 @@
import { type InjectionKey, type Ref, inject, provide, ref } from "vue";
-import { Risk_Source } from "@/types/proto/v1/risk_service";
+import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
export type RiskFilterContext = {
source: Ref<Risk_Source>; // default Risk_Source.SOURCE_UNSPECIFIED to "ALL"
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
index b8f206acbc..3f95262853 100644
--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
@@ -14,8 +14,8 @@ import {
useSupportedSourceList,
type ComposedProject,
} from "@/types";
-import type { Risk } from "@/types/proto/v1/risk_service";
-import { Risk_Source, risk_SourceToJSON } from "@/types/proto/v1/risk_service";
+import type { Risk } from "@/types/proto-es/v1/risk_service_pb";
+import { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import {
displayRoleTitle,
engineNameV1,
@@ -42,7 +42,7 @@ export const sourceText = (source: Risk_Source) => {
case Risk_Source.REQUEST_ROLE:
return t("custom-approval.risk-rule.risk.namespace.request-role");
default:
- return Risk_Source.UNRECOGNIZED;
+ return "UNRECOGNIZED";
}
};
@@ -191,7 +191,7 @@ const getLevelOptions = () => {
const getSourceOptions = () => {
return useSupportedSourceList().value.map<SelectOption>((source) => ({
- label: risk_SourceToJSON(source),
+ label: Risk_Source[source],
value: source,
}));
};
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
index 5bf3b90434..61ab1349e9 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
@@ -89,9 +89,10 @@ import {
getProjectNameAndDatabaseGroupName,
} from "@/store/modules/v1/common";
import type { ComposedProject } from "@/types";
-import { Expr as CELExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
-import { Expr } from "@/types/proto/google/type/expr";
-import type { DatabaseGroup } from "@/types/proto/v1/database_group_service";
+import { create } from "@bufbuild/protobuf";
+import type { Expr as CELExpr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
+import { DatabaseGroupSchema, type DatabaseGroup } from "@/types/proto-es/v1/database_group_service_pb";
import { batchConvertParsedExprToCELString } from "@/utils";
import { ResourceIdField } from "../v2";
import MatchedDatabaseView from "./MatchedDatabaseView.vue";
@@ -220,13 +221,13 @@ const doConfirm = async () => {
const resourceId = formState.resourceId;
await dbGroupStore.createDatabaseGroup({
projectName: props.project.name,
- databaseGroup: {
+ databaseGroup: create(DatabaseGroupSchema, {
name: `${props.project.name}/databaseGroups/${resourceId}`,
title: formState.placeholder,
- databaseExpr: Expr.fromPartial({
+ databaseExpr: create(ExprSchema, {
expression: celString,
}),
- },
+ }),
databaseGroupId: resourceId,
});
emit("created", resourceId);
@@ -242,7 +243,7 @@ const doConfirm = async () => {
if (
!isEqual(
props.databaseGroup.databaseExpr,
- Expr.fromPartial({
+ create(ExprSchema, {
expression: celString,
})
)
@@ -253,7 +254,7 @@ const doConfirm = async () => {
{
...props.databaseGroup!,
title: formState.placeholder,
- databaseExpr: Expr.fromPartial({
+ databaseExpr: create(ExprSchema, {
expression: celString,
}),
},
diff --git a/frontend/src/components/GrantRequestPanel/GrantRequestPanel.vue b/frontend/src/components/GrantRequestPanel/GrantRequestPanel.vue
index dafe0e9569..f69222fe81 100644
--- a/frontend/src/components/GrantRequestPanel/GrantRequestPanel.vue
+++ b/frontend/src/components/GrantRequestPanel/GrantRequestPanel.vue
@@ -60,7 +60,8 @@ import {
IssueSchema,
Issue_Type as NewIssue_Type,
} from "@/types/proto-es/v1/issue_service_pb";
-import { Binding } from "@/types/proto/v1/iam_policy";
+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
+import { BindingSchema } from "@/types/proto-es/v1/iam_policy_pb";
import {
GrantRequest,
Issue,
@@ -99,7 +100,7 @@ const currentUser = useCurrentUserV1();
const projectStore = useProjectV1Store();
const state = reactive<LocalState>({
- binding: Binding.fromPartial({
+ binding: create(BindingSchema, {
role: props.role,
members: [getUserEmailInBinding(currentUser.value.email)],
}),
diff --git a/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue b/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue
index fd9fdcb1f9..5565aa3a40 100644
--- a/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue
+++ b/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue
@@ -18,7 +18,7 @@ import { useI18n } from "vue-i18n";
import { EnvironmentV1Name, InstanceV1Name } from "@/components/v2";
import { useDatabaseV1Store, batchGetOrFetchDatabases } from "@/store";
import type { DatabaseResource } from "@/types";
-import type { DatabaseGroup } from "@/types/proto/v1/database_group_service";
+import type { DatabaseGroup } from "@/types/proto-es/v1/database_group_service_pb";
const props = defineProps<{
databaseResourceList: DatabaseResource[];
diff --git a/frontend/src/components/Member/types.ts b/frontend/src/components/Member/types.ts
index 721927dc45..4ac18ce282 100644
--- a/frontend/src/components/Member/types.ts
+++ b/frontend/src/components/Member/types.ts
@@ -1,5 +1,5 @@
-import type { Group } from "@/types/proto/v1/group_service";
-import type { Binding } from "@/types/proto/v1/iam_policy";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
import { type User } from "@/types/proto/v1/user_service";
export interface MemberRole {
diff --git a/frontend/src/components/Member/utils.ts b/frontend/src/components/Member/utils.ts
index 7acec7dc37..21d3301879 100644
--- a/frontend/src/components/Member/utils.ts
+++ b/frontend/src/components/Member/utils.ts
@@ -11,8 +11,9 @@ import {
} from "@/types";
import { State } from "@/types/proto-es/v1/common_pb";
import { convertStateToOld } from "@/utils/v1/common-conversions";
-import { Group } from "@/types/proto/v1/group_service";
-import { IamPolicy } from "@/types/proto/v1/iam_policy";
+import { create } from "@bufbuild/protobuf";
+import { GroupSchema } from "@/types/proto-es/v1/group_service_pb";
+import type { IamPolicy } from "@/types/proto-es/v1/iam_policy_pb";
import { User, UserType } from "@/types/proto/v1/user_service";
import type { MemberBinding, GroupBinding } from "./types";
@@ -40,12 +41,12 @@ const getMemberBinding = async (
if (!group) {
const email = extractGroupEmail(member);
group = {
- ...Group.create({
+ ...create(GroupSchema, {
name: `${groupNamePrefix}${email}`,
title: email,
}),
deleted: true,
- } as GroupBinding;
+ };
}
memberBinding = {
diff --git a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
index 7a261f0421..012c91ae6d 100644
--- a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
+++ b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMemberForm.vue
@@ -95,7 +95,7 @@ import MembersBindingSelect from "@/components/Member/MembersBindingSelect.vue";
import RequiredStar from "@/components/RequiredStar.vue";
import { RoleSelect } from "@/components/v2/Select";
import { PresetRoleType, type DatabaseResource } from "@/types";
-import type { Binding } from "@/types/proto/v1/iam_policy";
+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { checkRoleContainsAnyPermission } from "@/utils";
import { buildConditionExpr } from "@/utils/issue/cel";
diff --git a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue
index ebf629191d..d7dec0cb26 100644
--- a/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue
+++ b/frontend/src/components/ProjectMember/AddProjectMember/AddProjectMembersPanel.vue
@@ -54,7 +54,9 @@ import {
useProjectIamPolicyStore,
} from "@/store";
import { PresetRoleType, type ComposedProject } from "@/types";
-import { Binding } from "@/types/proto/v1/iam_policy";
+import { create } from "@bufbuild/protobuf";
+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
+import { BindingSchema } from "@/types/proto-es/v1/iam_policy_pb";
import { getBindingIdentifier } from "../utils";
import AddProjectMemberForm from "./AddProjectMemberForm.vue";
@@ -74,7 +76,7 @@ interface LocalState {
const { t } = useI18n();
const state = reactive<LocalState>({
bindings: props.bindings || [
- Binding.fromPartial({
+ create(BindingSchema, {
role: PresetRoleType.PROJECT_VIEWER,
}),
],
@@ -98,7 +100,7 @@ const allowConfirm = computed(() => {
const handleAddMore = () => {
state.bindings.push(
- Binding.fromPartial({
+ create(BindingSchema, {
role: PresetRoleType.PROJECT_VIEWER,
})
);
diff --git a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/EditProjectRolePanel.vue b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/EditProjectRolePanel.vue
index fc4cf680b6..0f899c1a19 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/EditProjectRolePanel.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/EditProjectRolePanel.vue
@@ -140,7 +140,7 @@ import {
import type { ComposedProject, DatabaseResource } from "@/types";
import { PresetRoleType } from "@/types";
import { State } from "@/types/proto-es/v1/common_pb";
-import type { Binding } from "@/types/proto/v1/iam_policy";
+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { convertStateToOld } from "@/utils/v1/common-conversions";
import { displayRoleTitle, checkRoleContainsAnyPermission } from "@/utils";
diff --git a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
index 1f02a57527..8e91dca6e3 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
@@ -125,7 +125,7 @@
v-if="state.showAddMemberPanel"
:project="project"
:bindings="[
- Binding.fromPartial({
+ create(BindingSchema, {
members: [binding.binding],
}),
]"
@@ -135,6 +135,7 @@
<script lang="tsx" setup>
import { cloneDeep, isEqual } from "lodash-es";
+import { create } from "@bufbuild/protobuf";
import { Building2Icon, PenIcon, TrashIcon } from "lucide-vue-next";
import { NButton, NTag, NTooltip, NDataTable, useDialog } from "naive-ui";
import type { DataTableColumn } from "naive-ui";
@@ -158,7 +159,8 @@ import {
import type { ComposedProject, DatabaseResource } from "@/types";
import { PresetRoleType, PRESET_ROLES } from "@/types";
import { State } from "@/types/proto-es/v1/common_pb";
-import { Binding } from "@/types/proto/v1/iam_policy";
+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
+import { BindingSchema } from "@/types/proto-es/v1/iam_policy_pb";
import { convertStateToOld } from "@/utils/v1/common-conversions";
import {
displayRoleTitle,
@@ -323,7 +325,7 @@ const getDataTableColumns = (
text
class="cursor-pointer opacity-60 hover:opacity-100"
onClick={() => {
- editingBinding.value = Binding.fromPartial({
+ editingBinding.value = create(BindingSchema, {
role: role,
members: [props.binding.binding],
condition: singleBinding.rawBinding.condition,
@@ -479,7 +481,7 @@ const handleDeleteCondition = async (
.map((b) => b.databaseResource) as DatabaseResource[];
policy.bindings.push(
- Binding.fromPartial({
+ create(BindingSchema, {
role: item.role,
members: [props.binding.binding],
condition: buildConditionExpr({
diff --git a/frontend/src/components/ProjectMember/utils.ts b/frontend/src/components/ProjectMember/utils.ts
index 96f8adaabf..d755644c0b 100644
--- a/frontend/src/components/ProjectMember/utils.ts
+++ b/frontend/src/components/ProjectMember/utils.ts
@@ -1,4 +1,4 @@
-import type { Binding } from "@/types/proto/v1/iam_policy";
+import type { Binding } from "@/types/proto-es/v1/iam_policy_pb";
import { displayRoleTitle } from "@/utils";
export const getBindingIdentifier = (binding: Binding): string => {
diff --git a/frontend/src/components/Release/ReleaseDetail/NavBar/ApplyToDatabasePanel.vue b/frontend/src/components/Release/ReleaseDetail/NavBar/ApplyToDatabasePanel.vue
index 781c060ee4..0c3ce875b2 100644
--- a/frontend/src/components/Release/ReleaseDetail/NavBar/ApplyToDatabasePanel.vue
+++ b/frontend/src/components/Release/ReleaseDetail/NavBar/ApplyToDatabasePanel.vue
@@ -50,7 +50,6 @@
</template>
<script lang="ts" setup>
-import { create } from "@bufbuild/protobuf";
import { createContextValues } from "@connectrpc/connect";
import { NButton } from "naive-ui";
import { computed, reactive } from "vue";
@@ -68,8 +67,8 @@ import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
import { pushNotification, useDatabaseV1Store, useDBGroupStore } from "@/store";
import { CreatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
import { PreviewRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
-import { DatabaseGroup } from "@/types/proto/v1/database_group_service";
import { Plan } from "@/types/proto/v1/plan_service";
+import { create } from "@bufbuild/protobuf";
import {
extractProjectResourceName,
generateIssueTitle,
@@ -81,6 +80,7 @@ import {
} from "@/utils/v1/plan-conversions";
import { useReleaseDetailContext } from "../context";
import { createIssueFromPlan } from "./utils";
+import { DatabaseGroupSchema } from "@/types/proto-es/v1/database_group_service_pb";
const emit = defineEmits<{
(event: "close"): void;
@@ -119,11 +119,9 @@ const handleCreate = async () => {
const databaseList = state.targetSelectState.selectedDatabaseNameList.map(
(name) => databaseStore.getDatabaseByName(name)
);
- const databaseGroup = DatabaseGroup.fromPartial({
- ...dbGroupStore.getDBGroupByName(
- state.targetSelectState.selectedDatabaseGroup || ""
- ),
- });
+ const databaseGroup = create(DatabaseGroupSchema, dbGroupStore.getDBGroupByName(
+ state.targetSelectState.selectedDatabaseGroup || ""
+ ));
const planData = Plan.fromPartial({
title: `Release "${release.value.title}"`,
description: `Apply release "${release.value.title}" to selected databases.`,
diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
index 98323dd0a9..2cdcbaabd9 100644
--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
@@ -100,7 +100,6 @@ import {
emptySimpleExpr,
} from "@/plugins/cel";
import { useSettingV1Store } from "@/store";
-import { Expr } from "@/types/proto/google/type/expr";
import type { MaskingRulePolicy_MaskingRule } from "@/types/proto/v1/org_policy_service";
import type { SemanticTypeSetting_SemanticType as SemanticType } from "@/types/proto-es/v1/setting_service_pb";
import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";
@@ -221,10 +220,12 @@ const onConfirm = async () => {
emit("confirm", {
...props.maskingRule,
semanticType: state.semanticType!,
- condition: Expr.fromPartial({
+ condition: {
expression: expressions[0],
title: state.title,
- }),
+ description: "",
+ location: "",
+ },
});
state.dirty = false;
};
diff --git a/frontend/src/components/SensitiveData/types.ts b/frontend/src/components/SensitiveData/types.ts
index f198251300..83fb0da4aa 100644
--- a/frontend/src/components/SensitiveData/types.ts
+++ b/frontend/src/components/SensitiveData/types.ts
@@ -4,7 +4,7 @@ import type {
ColumnCatalog,
ObjectSchema,
} from "@/types/proto-es/v1/database_catalog_service_pb";
-import type { Group } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
import type { MaskingExceptionPolicy_MaskingException_Action } from "@/types/proto/v1/org_policy_service";
import { type User } from "@/types/proto/v1/user_service";
diff --git a/frontend/src/components/User/Settings/CreateGroupDrawer.vue b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
index b4cd986926..1b500b0f1a 100644
--- a/frontend/src/components/User/Settings/CreateGroupDrawer.vue
+++ b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
@@ -132,6 +132,7 @@
<script lang="ts" setup>
import { cloneDeep, isEqual } from "lodash-es";
+import { create } from "@bufbuild/protobuf";
import { Trash2Icon } from "lucide-vue-next";
import { NButton, NInput, NTooltip } from "naive-ui";
import { computed, reactive } from "vue";
@@ -150,11 +151,15 @@ import {
groupNamePrefix,
extractUserId,
} from "@/store/modules/v1/common";
-import {
+import type {
Group,
GroupMember,
+} from "@/types/proto-es/v1/group_service_pb";
+import {
+ GroupSchema,
+ GroupMemberSchema,
GroupMember_Role,
-} from "@/types/proto/v1/group_service";
+} from "@/types/proto-es/v1/group_service_pb";
import { isValidEmail, hasWorkspacePermissionV2 } from "@/utils";
import RemoveGroupButton from "./RemoveGroupButton.vue";
import GroupMemberRoleSelect from "./UserDataTableByGroup/cells/GroupMemberRoleSelect.vue";
@@ -190,7 +195,7 @@ const state = reactive<LocalState>({
description: props.group?.description ?? "",
members: cloneDeep(
props.group?.members ?? [
- GroupMember.fromPartial({
+ create(GroupMemberSchema, {
role: GroupMember_Role.OWNER,
member: `${userNamePrefix}${currentUserV1.value.email}`,
}),
@@ -237,7 +242,7 @@ const validGroup = computed(() => {
memberMap.set(member.member, member);
}
}
- return Group.fromPartial({
+ return create(GroupSchema, {
name: `${groupNamePrefix}${state.group.email}`,
title: state.group.title,
description: state.group.description,
@@ -264,7 +269,7 @@ const allowConfirm = computed(() => {
});
const addMember = () => {
- const member = GroupMember.fromPartial({
+ const member = create(GroupMemberSchema, {
role:
state.group.members.length === 0
? GroupMember_Role.OWNER
diff --git a/frontend/src/components/User/Settings/RemoveGroupButton.vue b/frontend/src/components/User/Settings/RemoveGroupButton.vue
index 32ebf4867b..d5c9966287 100644
--- a/frontend/src/components/User/Settings/RemoveGroupButton.vue
+++ b/frontend/src/components/User/Settings/RemoveGroupButton.vue
@@ -38,7 +38,7 @@ import {
} from "@/store";
import { extractUserId } from "@/store/modules/v1/common";
import { getGroupEmailInBinding } from "@/types";
-import { type Group, GroupMember_Role } from "@/types/proto/v1/group_service";
+import { type Group, GroupMember_Role } from "@/types/proto-es/v1/group_service_pb";
import { PolicyType } from "@/types/proto/v1/org_policy_service";
import { hasWorkspacePermissionV2 } from "@/utils";
diff --git a/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue b/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue
index fde20db508..e0ba3a215f 100644
--- a/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTable/cells/GroupsCell.vue
@@ -17,7 +17,7 @@ import { NTag } from "naive-ui";
import { computed } from "vue";
import { useGroupStore } from "@/store";
import { extractUserId } from "@/store/modules/v1/common";
-import type { Group } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
import { type User } from "@/types/proto/v1/user_service";
const props = defineProps<{
diff --git a/frontend/src/components/User/Settings/UserDataTable/index.vue b/frontend/src/components/User/Settings/UserDataTable/index.vue
index 4d23a1ae0d..1c47c891e6 100644
--- a/frontend/src/components/User/Settings/UserDataTable/index.vue
+++ b/frontend/src/components/User/Settings/UserDataTable/index.vue
@@ -27,7 +27,7 @@ import { computed, reactive, h } from "vue";
import { useI18n } from "vue-i18n";
import { BBAlert } from "@/bbkit";
import { useUserStore, useWorkspaceV1Store, pushNotification } from "@/store";
-import type { Group } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
import { type User } from "@/types/proto/v1/user_service";
import { toClipboard } from "@/utils";
import GroupsCell from "./cells/GroupsCell.vue";
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberNameCell.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberNameCell.vue
index dd2fb0e38f..1e000e3fd6 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberNameCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberNameCell.vue
@@ -65,7 +65,7 @@ import { SYSTEM_BOT_USER_NAME } from "@/types";
import { UserType, type User } from "@/types/proto/v1/user_service";
import {
GroupMember_Role,
-} from "@/types/proto/v1/group_service";
+} from "@/types/proto-es/v1/group_service_pb";
withDefaults(
defineProps<{
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberRoleSelect.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberRoleSelect.vue
index d68273f19c..3fa0db871f 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberRoleSelect.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupMemberRoleSelect.vue
@@ -16,7 +16,7 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import {
GroupMember_Role,
-} from "@/types/proto/v1/group_service";
+} from "@/types/proto-es/v1/group_service_pb";
defineProps<{
value: GroupMember_Role;
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue
index a44ecf3aa5..95a311d7ac 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue
@@ -46,7 +46,7 @@ import UserRolesCell from "@/components/Member/MemberDataTable/cells/UserRolesCe
import type { MemberRole } from "@/components/Member/types";
import { WORKSPACE_ROUTE_USERS } from "@/router/dashboard/workspaceRoutes";
import { extractGroupEmail, extractUserId, useCurrentUserV1 } from "@/store";
-import { Group } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
const props = withDefaults(
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue
index 2021266e30..02b36e4554 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/cells/GroupOperationsCell.vue
@@ -25,8 +25,8 @@ import { NButton } from "naive-ui";
import { computed } from "vue";
import { useCurrentUserV1 } from "@/store";
import { extractUserId } from "@/store/modules/v1/common";
-import type { Group } from "@/types/proto/v1/group_service";
-import { GroupMember_Role } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
+import { GroupMember_Role } from "@/types/proto-es/v1/group_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
import RemoveGroupButton from "../../RemoveGroupButton.vue";
diff --git a/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue b/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue
index 47ff16ec9e..0fdb849ce9 100644
--- a/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue
+++ b/frontend/src/components/User/Settings/UserDataTableByGroup/index.vue
@@ -16,7 +16,8 @@ import { NDataTable } from "naive-ui";
import { computed, h } from "vue";
import { useI18n } from "vue-i18n";
import { useUserStore } from "@/store";
-import { Group, GroupMember_Role } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
+import { GroupMember_Role } from "@/types/proto-es/v1/group_service_pb";
import { type User } from "@/types/proto/v1/user_service";
import GroupMemberNameCell from "./cells/GroupMemberNameCell.vue";
import GroupNameCell from "./cells/GroupNameCell.vue";
diff --git a/frontend/src/components/v2/Select/GroupSelect.vue b/frontend/src/components/v2/Select/GroupSelect.vue
index 14a3dbd3e2..a0b99da9db 100644
--- a/frontend/src/components/v2/Select/GroupSelect.vue
+++ b/frontend/src/components/v2/Select/GroupSelect.vue
@@ -22,7 +22,7 @@ import {
import GroupNameCell from "@/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue";
import { useGroupStore, useProjectV1Store, useWorkspaceV1Store } from "@/store";
import { PRESET_WORKSPACE_ROLES } from "@/types";
-import type { Group } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
import ResourceSelect from "./ResourceSelect.vue";
const props = withDefaults(
diff --git a/frontend/src/composables/useExecuteSQL.ts b/frontend/src/composables/useExecuteSQL.ts
index f7b2ff0e2f..445b697523 100644
--- a/frontend/src/composables/useExecuteSQL.ts
+++ b/frontend/src/composables/useExecuteSQL.ts
@@ -41,7 +41,7 @@ import type {
import { isValidDatabaseName } from "@/types";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { Engine } from "@/types/proto-es/v1/common_pb";
-import { DatabaseGroupView } from "@/types/proto/v1/database_group_service";
+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";
import {
Advice,
Advice_Status,
@@ -247,7 +247,7 @@ const useExecuteSQL = () => {
{
skipCache: false,
silent: true,
- view: DatabaseGroupView.DATABASE_GROUP_VIEW_FULL,
+ view: DatabaseGroupView.FULL,
}
);
for (const matchedDatabase of databaseGroup.matchedDatabases) {
diff --git a/frontend/src/plugins/cel/logic/build.ts b/frontend/src/plugins/cel/logic/build.ts
index 1073071fb2..ee90b150bf 100644
--- a/frontend/src/plugins/cel/logic/build.ts
+++ b/frontend/src/plugins/cel/logic/build.ts
@@ -4,8 +4,8 @@ import { createContextValues } from "@connectrpc/connect";
import { celServiceClientConnect } from "@/grpcweb";
import { silentContextKey } from "@/grpcweb/context-key";
import { BatchParseRequestSchema } from "@/types/proto-es/v1/cel_service_pb";
-import { Expr as CELExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
-import { convertNewExprToOld } from "@/utils/v1/cel-conversions";
+import type { Expr as CELExpr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
+import { ExprSchema } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
import type { ConditionExpr, ConditionGroupExpr, SimpleExpr } from "../types";
import {
isEqualityExpr,
@@ -42,14 +42,7 @@ export const buildCELExpr = async (
const response = await celServiceClientConnect.batchParse(request, {
contextValues: createContextValues().set(silentContextKey, true),
});
- // Convert the first expression from new to old format
- const newExpr = head(response.expressions);
- const celExpr = newExpr ? convertNewExprToOld(newExpr) : undefined;
- if (celExpr) {
- return celExpr;
- } else {
- return undefined;
- }
+ return head(response.expressions);
}
throw new Error(`unexpected type "${String(expr)}"`);
};
@@ -129,9 +122,9 @@ export const buildCELExpr = async (
};
const wrapCELExpr = (object: any): CELExpr => {
- return CELExpr.fromPartial({
- id: seq.next(),
- ...object,
+ return create(ExprSchema, {
+ id: BigInt(seq.next()),
+ exprKind: object,
});
};
@@ -139,15 +132,17 @@ const wrapCELExpr = (object: any): CELExpr => {
const wrapConstExpr = (value: number | string | Date): CELExpr => {
if (typeof value === "string") {
return wrapCELExpr({
- constExpr: {
+ case: "constExpr",
+ value: {
stringValue: value,
},
});
}
if (typeof value === "number") {
return wrapCELExpr({
- constExpr: {
- int64Value: value,
+ case: "constExpr",
+ value: {
+ int64Value: BigInt(value),
},
});
}
@@ -156,7 +151,8 @@ const wrapConstExpr = (value: number | string | Date): CELExpr => {
const wrapListExpr = (values: string[] | number[]): CELExpr => {
return wrapCELExpr({
- listExpr: {
+ case: "listExpr",
+ value: {
elements: values.map(wrapConstExpr),
},
});
@@ -164,7 +160,8 @@ const wrapListExpr = (values: string[] | number[]): CELExpr => {
const wrapIdentExpr = (name: string): CELExpr => {
return wrapCELExpr({
- identExpr: {
+ case: "identExpr",
+ value: {
name,
},
});
@@ -183,6 +180,7 @@ const wrapCallExpr = (
object.target = target;
}
return wrapCELExpr({
- callExpr: object,
+ case: "callExpr",
+ value: object,
});
};
diff --git a/frontend/src/plugins/cel/logic/resolve.ts b/frontend/src/plugins/cel/logic/resolve.ts
index d28e216669..2575932bc0 100644
--- a/frontend/src/plugins/cel/logic/resolve.ts
+++ b/frontend/src/plugins/cel/logic/resolve.ts
@@ -1,4 +1,4 @@
-import type { Expr as CELExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
+import type { Expr as CELExpr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
import type {
StringFactor,
Operator,
@@ -30,6 +30,21 @@ import {
} from "../types";
import stringifyExpr from "./stringify";
+// Helper functions to extract constant values from proto-es oneof patterns
+const getConstantInt64Value = (expr: CELExpr): number => {
+ if (expr.exprKind?.case === "constExpr" && expr.exprKind.value.constantKind?.case === "int64Value") {
+ return Number(expr.exprKind.value.constantKind.value);
+ }
+ return 0;
+};
+
+const getConstantStringValue = (expr: CELExpr): string => {
+ if (expr.exprKind?.case === "constExpr" && expr.exprKind.value.constantKind?.case === "stringValue") {
+ return expr.exprKind.value.constantKind.value;
+ }
+ return "";
+};
+
// For simplify UI implementation, the "root" condition need to be a group.
export const wrapAsGroup = (
expr: SimpleExpr,
@@ -46,11 +61,11 @@ export const wrapAsGroup = (
// Convert common expr to simple expr
export const resolveCELExpr = (expr: CELExpr): SimpleExpr => {
const dfs = (expr: CELExpr, negative: boolean = false): SimpleExpr => {
- const { callExpr } = expr;
- if (!callExpr) {
+ if (expr.exprKind?.case !== "callExpr") {
// If no callExpr, we treat it as a raw string.
return resolveRawStringExpr(expr);
}
+ const callExpr = expr.exprKind.value;
try {
const { args } = callExpr;
@@ -103,35 +118,39 @@ export const resolveCELExpr = (expr: CELExpr): SimpleExpr => {
};
const resolveEqualityExpr = (expr: CELExpr): EqualityExpr => {
- const operator = expr.callExpr!.function as EqualityOperator;
- const [factorExpr, valueExpr] = expr.callExpr!.args;
+ const callExpr = expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null;
+ if (!callExpr) throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);
+ const operator = callExpr.function as EqualityOperator;
+ const [factorExpr, valueExpr] = callExpr.args;
const factor = getFactorName(factorExpr);
if (isNumberFactor(factor)) {
return {
type: ExprType.Condition,
operator,
- args: [factor, valueExpr.constExpr!.int64Value!.toNumber() ?? 0],
+ args: [factor, getConstantInt64Value(valueExpr)],
};
}
if (isStringFactor(factor)) {
return {
type: ExprType.Condition,
operator,
- args: [factor, valueExpr.constExpr!.stringValue! ?? ""],
+ args: [factor, getConstantStringValue(valueExpr)],
};
}
throw new Error(`cannot resolve expr ${JSON.stringify(expr)}`);
};
const resolveCompareExpr = (expr: CELExpr): CompareExpr => {
- const operator = expr.callExpr!.function as CompareOperator;
- const [factorExpr, valueExpr] = expr.callExpr!.args;
+ const callExpr = expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null;
+ if (!callExpr) throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);
+ const operator = callExpr.function as CompareOperator;
+ const [factorExpr, valueExpr] = callExpr.args;
const factor = getFactorName(factorExpr);
if (isNumberFactor(factor)) {
return {
type: ExprType.Condition,
operator,
- args: [factor, valueExpr.constExpr!.int64Value!.toNumber()],
+ args: [factor, getConstantInt64Value(valueExpr)],
};
}
if (isTimestampFactor(factor)) {
@@ -140,7 +159,9 @@ const resolveCompareExpr = (expr: CELExpr): CompareExpr => {
operator,
args: [
factor,
- new Date(valueExpr.callExpr!.args[0].constExpr!.stringValue!),
+ valueExpr.exprKind?.case === "callExpr" && valueExpr.exprKind.value.args[0]?.exprKind?.case === "constExpr"
+ ? new Date(getConstantStringValue(valueExpr.exprKind.value.args[0]))
+ : new Date(),
],
};
}
@@ -148,13 +169,15 @@ const resolveCompareExpr = (expr: CELExpr): CompareExpr => {
};
const resolveStringExpr = (expr: CELExpr): StringExpr => {
- const operator = expr.callExpr!.function as StringOperator;
- const factor = getFactorName(expr.callExpr!.target!);
- const value = expr.callExpr!.args[0];
+ const callExpr = expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null;
+ if (!callExpr) throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);
+ const operator = callExpr.function as StringOperator;
+ const factor = getFactorName(callExpr.target!);
+ const value = callExpr.args[0];
return {
type: ExprType.Condition,
operator,
- args: [factor as StringFactor, value.constExpr!.stringValue!],
+ args: [factor as StringFactor, getConstantStringValue(value)],
};
};
@@ -162,11 +185,13 @@ const resolveCollectionExpr = (
expr: CELExpr,
negative: boolean = false
): CollectionExpr => {
- let operator = expr.callExpr!.function as CollectionOperator;
+ const callExpr = expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null;
+ if (!callExpr) throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);
+ let operator = callExpr.function as CollectionOperator;
if (negative) {
operator = "@not_in";
}
- const [factorExpr, valuesExpr] = expr.callExpr!.args;
+ const [factorExpr, valuesExpr] = callExpr.args;
const factor = getFactorName(factorExpr);
if (isNumberFactor(factor)) {
@@ -175,9 +200,9 @@ const resolveCollectionExpr = (
operator,
args: [
factor,
- valuesExpr.listExpr?.elements?.map(
- (constant) => constant.constExpr?.int64Value?.toNumber() ?? 0
- ) ?? [],
+ valuesExpr.exprKind?.case === "listExpr"
+ ? valuesExpr.exprKind.value.elements?.map(getConstantInt64Value) ?? []
+ : [],
],
};
}
@@ -187,9 +212,9 @@ const resolveCollectionExpr = (
operator,
args: [
factor,
- valuesExpr.listExpr?.elements?.map(
- (constant) => constant.constExpr?.stringValue ?? ""
- ) ?? [],
+ valuesExpr.exprKind?.case === "listExpr"
+ ? valuesExpr.exprKind.value.elements?.map(getConstantStringValue) ?? []
+ : [],
],
};
}
@@ -214,11 +239,14 @@ export const emptySimpleExpr = (
};
const getFactorName = (expr: CELExpr): string => {
- if (expr.identExpr !== undefined) {
- return expr.identExpr.name;
- } else if (expr.selectExpr !== undefined) {
- return `${expr.selectExpr.operand!.identExpr!.name!}.${expr.selectExpr
- .field!}`;
+ if (expr.exprKind?.case === "identExpr") {
+ return expr.exprKind.value.name;
+ } else if (expr.exprKind?.case === "selectExpr") {
+ const selectExpr = expr.exprKind.value;
+ const operandName = selectExpr.operand?.exprKind?.case === "identExpr"
+ ? selectExpr.operand.exprKind.value.name
+ : "";
+ return `${operandName}.${selectExpr.field}`;
}
throw new Error(`cannot resolve factor name ${JSON.stringify(expr)}`);
};
diff --git a/frontend/src/plugins/cel/logic/stringify.ts b/frontend/src/plugins/cel/logic/stringify.ts
index aa6eee1b0f..3054b3a520 100644
--- a/frontend/src/plugins/cel/logic/stringify.ts
+++ b/frontend/src/plugins/cel/logic/stringify.ts
@@ -1,85 +1,90 @@
import type {
Constant,
Expr,
-} from "@/types/proto/google/api/expr/v1alpha1/syntax";
+} from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
function stringifyExpr(expr: Expr): string {
- if (expr.constExpr) {
- return stringifyConstant(expr.constExpr);
- } else if (expr.identExpr) {
- return expr.identExpr.name;
- } else if (expr.selectExpr) {
+ if (expr.exprKind?.case === "constExpr") {
+ return stringifyConstant(expr.exprKind.value);
+ } else if (expr.exprKind?.case === "identExpr") {
+ return expr.exprKind.value.name;
+ } else if (expr.exprKind?.case === "selectExpr") {
+ const selectExpr = expr.exprKind.value;
// Check if testOnly flag is used to denote a 'has' operation.
- if (expr.selectExpr.testOnly) {
- return `has(${stringifyExpr(expr.selectExpr.operand!)}.${expr.selectExpr.field})`;
+ if (selectExpr.testOnly) {
+ return `has(${stringifyExpr(selectExpr.operand!)}.${selectExpr.field})`;
} else {
- return `${stringifyExpr(expr.selectExpr.operand!)}.${expr.selectExpr.field}`;
+ return `${stringifyExpr(selectExpr.operand!)}.${selectExpr.field}`;
}
- } else if (expr.callExpr) {
+ } else if (expr.exprKind?.case === "callExpr") {
+ const callExpr = expr.exprKind.value;
// Remove underscores from function name. e.g. "_&&_" -> "&&"
// Reference: https://github.com/google/cel-spec/blob/master/doc/langdef.md#list-of-standard-definitions
- const functionName = expr.callExpr.function.replace(/_/g, "");
- if (expr.callExpr.target) {
- const target = stringifyExpr(expr.callExpr.target);
- const args = expr.callExpr.args
+ const functionName = callExpr.function.replace(/_/g, "");
+ if (callExpr.target) {
+ const target = stringifyExpr(callExpr.target);
+ const args = callExpr.args
.map((arg) => stringifyExpr(arg))
.join(", ");
return `${target}.${functionName}(${args})`;
} else {
- const args = expr.callExpr.args.map((arg) => stringifyExpr(arg));
+ const args = callExpr.args.map((arg) => stringifyExpr(arg));
if (functionName === "&&" || functionName === "||") {
return `(${args.join(` ${functionName} `)})`;
} else {
return args.join(` ${functionName} `);
}
}
- } else if (expr.listExpr) {
- const elements = expr.listExpr.elements
+ } else if (expr.exprKind?.case === "listExpr") {
+ const listExpr = expr.exprKind.value;
+ const elements = listExpr.elements
.map((el) => stringifyExpr(el))
.join(", ");
return `[${elements}]`;
- } else if (expr.structExpr) {
- const entries = expr.structExpr.entries
+ } else if (expr.exprKind?.case === "structExpr") {
+ const structExpr = expr.exprKind.value;
+ const entries = structExpr.entries
.map((entry) => {
- const key = entry.fieldKey
- ? entry.fieldKey
- : stringifyExpr(entry.mapKey!);
+ const key = entry.keyKind?.case === "fieldKey"
+ ? entry.keyKind.value
+ : entry.keyKind?.case === "mapKey" ? stringifyExpr(entry.keyKind.value) : "";
const value = stringifyExpr(entry.value!);
return `${key}: ${value}`;
})
.join(", ");
return `{${entries}}`;
- } else if (expr.comprehensionExpr) {
- const iterRange = stringifyExpr(expr.comprehensionExpr.iterRange!);
- const accuInit = stringifyExpr(expr.comprehensionExpr.accuInit!);
- const loopCondition = stringifyExpr(expr.comprehensionExpr.loopCondition!);
- const loopStep = stringifyExpr(expr.comprehensionExpr.loopStep!);
- const result = stringifyExpr(expr.comprehensionExpr.result!);
- return `comprehension(${expr.comprehensionExpr.iterVar} in ${iterRange}; ${expr.comprehensionExpr.accuVar} = ${accuInit}; ${loopCondition}; ${loopStep}; ${result})`;
+ } else if (expr.exprKind?.case === "comprehensionExpr") {
+ const comprehensionExpr = expr.exprKind.value;
+ const iterRange = stringifyExpr(comprehensionExpr.iterRange!);
+ const accuInit = stringifyExpr(comprehensionExpr.accuInit!);
+ const loopCondition = stringifyExpr(comprehensionExpr.loopCondition!);
+ const loopStep = stringifyExpr(comprehensionExpr.loopStep!);
+ const result = stringifyExpr(comprehensionExpr.result!);
+ return `comprehension(${comprehensionExpr.iterVar} in ${iterRange}; ${comprehensionExpr.accuVar} = ${accuInit}; ${loopCondition}; ${loopStep}; ${result})`;
} else {
return "";
}
}
function stringifyConstant(constant: Constant): string {
- if (constant.nullValue !== undefined) {
+ if (constant.constantKind?.case === "nullValue") {
return "null";
- } else if (constant.boolValue !== undefined) {
- return constant.boolValue.toString();
- } else if (constant.int64Value !== undefined) {
- return constant.int64Value.toString();
- } else if (constant.uint64Value !== undefined) {
- return constant.uint64Value.toString();
- } else if (constant.doubleValue !== undefined) {
- return constant.doubleValue.toString();
- } else if (constant.stringValue !== undefined) {
- return `"${constant.stringValue}"`;
- } else if (constant.bytesValue !== undefined) {
- return `b'${constant.bytesValue.toString()}'`;
- } else if (constant.durationValue !== undefined) {
- return `duration(${constant.durationValue})`;
- } else if (constant.timestampValue !== undefined) {
- return `timestamp(${constant.timestampValue})`;
+ } else if (constant.constantKind?.case === "boolValue") {
+ return constant.constantKind.value.toString();
+ } else if (constant.constantKind?.case === "int64Value") {
+ return constant.constantKind.value.toString();
+ } else if (constant.constantKind?.case === "uint64Value") {
+ return constant.constantKind.value.toString();
+ } else if (constant.constantKind?.case === "doubleValue") {
+ return constant.constantKind.value.toString();
+ } else if (constant.constantKind?.case === "stringValue") {
+ return `"${constant.constantKind.value}"`;
+ } else if (constant.constantKind?.case === "bytesValue") {
+ return `b'${constant.constantKind.value.toString()}'`;
+ } else if (constant.constantKind?.case === "durationValue") {
+ return `duration(${constant.constantKind.value})`;
+ } else if (constant.constantKind?.case === "timestampValue") {
+ return `timestamp(${constant.constantKind.value})`;
} else {
throw new Error("Unknown constant type");
}
diff --git a/frontend/src/store/modules/dbGroup.ts b/frontend/src/store/modules/dbGroup.ts
index 41d29f1154..e4fcee71c0 100644
--- a/frontend/src/store/modules/dbGroup.ts
+++ b/frontend/src/store/modules/dbGroup.ts
@@ -19,27 +19,24 @@ import type {
ComposedDatabaseGroup,
ComposedProject,
} from "@/types";
-import { Expr } from "@/types/proto/google/type/expr";
-import {
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
+import type {
DatabaseGroup,
DatabaseGroupView,
-} from "@/types/proto/v1/database_group_service";
+} from "@/types/proto-es/v1/database_group_service_pb";
import {
CreateDatabaseGroupRequestSchema,
DeleteDatabaseGroupRequestSchema,
GetDatabaseGroupRequestSchema,
ListDatabaseGroupsRequestSchema,
UpdateDatabaseGroupRequestSchema,
+ DatabaseGroupView as DatabaseGroupViewEnum,
+ DatabaseGroupSchema,
} from "@/types/proto-es/v1/database_group_service_pb";
import {
batchConvertCELStringToParsedExpr,
batchConvertParsedExprToCELString,
} from "@/utils";
-import {
- convertNewDatabaseGroupToOld,
- convertOldDatabaseGroupToNew,
- convertOldDatabaseGroupViewToNew,
-} from "@/utils/v1/database-group-conversions";
import { useCache } from "../cache";
import { batchGetOrFetchProjects, useProjectV1Store } from "./v1";
import {
@@ -113,10 +110,10 @@ export const useDBGroupStore = defineStore("db-group", () => {
databaseGroup: ComposedDatabaseGroup,
view: DatabaseGroupView
) => {
- if (view === DatabaseGroupView.DATABASE_GROUP_VIEW_FULL) {
+ if (view === DatabaseGroupViewEnum.FULL) {
cacheByName.invalidateEntity([
databaseGroup.name,
- DatabaseGroupView.DATABASE_GROUP_VIEW_BASIC,
+ DatabaseGroupViewEnum.BASIC,
]);
}
cacheByName.setEntity([databaseGroup.name, view], databaseGroup);
@@ -134,7 +131,7 @@ export const useDBGroupStore = defineStore("db-group", () => {
...{
skipCache: false,
silent: false,
- view: DatabaseGroupView.DATABASE_GROUP_VIEW_BASIC,
+ view: DatabaseGroupViewEnum.BASIC,
},
...options,
};
@@ -145,15 +142,12 @@ export const useDBGroupStore = defineStore("db-group", () => {
const request = create(GetDatabaseGroupRequestSchema, {
name,
- view: convertOldDatabaseGroupViewToNew(view),
+ view,
});
- const newDatabaseGroup = await databaseGroupServiceClientConnect.getDatabaseGroup(
- request,
- {
+ const databaseGroup =
+ await databaseGroupServiceClientConnect.getDatabaseGroup(request, {
contextValues: createContextValues().set(silentContextKey, silent),
- }
- );
- const databaseGroup = convertNewDatabaseGroupToOld(newDatabaseGroup);
+ });
const composedData = await batchComposeDatabaseGroup([databaseGroup]);
const response = composedData[0];
setDatabaseGroupCache(response, view);
@@ -167,14 +161,10 @@ export const useDBGroupStore = defineStore("db-group", () => {
const { databaseGroups } =
await databaseGroupServiceClientConnect.listDatabaseGroups(request);
const composedList = [];
- const oldDatabaseGroups = databaseGroups.map(convertNewDatabaseGroupToOld);
const composeDatabaseGroups =
- await batchComposeDatabaseGroup(oldDatabaseGroups);
+ await batchComposeDatabaseGroup(databaseGroups);
for (const composedData of composeDatabaseGroups) {
- setDatabaseGroupCache(
- composedData,
- DatabaseGroupView.DATABASE_GROUP_VIEW_BASIC
- );
+ setDatabaseGroupCache(composedData, DatabaseGroupViewEnum.BASIC);
composedList.push(composedData);
}
return composedList;
@@ -186,14 +176,8 @@ export const useDBGroupStore = defineStore("db-group", () => {
): ComposedDatabaseGroup | undefined => {
if (!view) {
return (
- cacheByName.getEntity([
- name,
- DatabaseGroupView.DATABASE_GROUP_VIEW_FULL,
- ]) ??
- cacheByName.getEntity([
- name,
- DatabaseGroupView.DATABASE_GROUP_VIEW_BASIC,
- ])
+ cacheByName.getEntity([name, DatabaseGroupViewEnum.FULL]) ??
+ cacheByName.getEntity([name, DatabaseGroupViewEnum.BASIC])
);
}
return cacheByName.getEntity([name, view]);
@@ -206,33 +190,38 @@ export const useDBGroupStore = defineStore("db-group", () => {
validateOnly = false,
}: {
projectName: string;
- databaseGroup: Pick<DatabaseGroup, "name" | "title" | "databaseExpr">;
+ databaseGroup: Pick<
+ DatabaseGroup,
+ "$typeName" | "name" | "title" | "databaseExpr"
+ >;
databaseGroupId: string;
validateOnly?: boolean;
}) => {
- const fullDatabaseGroup = DatabaseGroup.fromPartial(databaseGroup);
- const newDatabaseGroup = convertOldDatabaseGroupToNew(fullDatabaseGroup);
+ const newDatabaseGroup = create(DatabaseGroupSchema, {
+ name: databaseGroup.name,
+ title: databaseGroup.title,
+ databaseExpr: databaseGroup.databaseExpr,
+ matchedDatabases: [],
+ unmatchedDatabases: [],
+ });
const request = create(CreateDatabaseGroupRequestSchema, {
parent: projectName,
databaseGroup: newDatabaseGroup,
databaseGroupId,
validateOnly,
});
- const response = await databaseGroupServiceClientConnect.createDatabaseGroup(
- request,
- {
- contextValues: createContextValues().set(silentContextKey, validateOnly),
- }
- );
- const createdDatabaseGroup = convertNewDatabaseGroupToOld(response);
+ const createdDatabaseGroup =
+ await databaseGroupServiceClientConnect.createDatabaseGroup(request, {
+ contextValues: createContextValues().set(
+ silentContextKey,
+ validateOnly
+ ),
+ });
if (!validateOnly) {
const composedData = await batchComposeDatabaseGroup([
createdDatabaseGroup,
]);
- setDatabaseGroupCache(
- composedData[0],
- DatabaseGroupView.DATABASE_GROUP_VIEW_FULL
- );
+ setDatabaseGroupCache(composedData[0], DatabaseGroupViewEnum.FULL);
}
return createdDatabaseGroup;
};
@@ -241,20 +230,16 @@ export const useDBGroupStore = defineStore("db-group", () => {
databaseGroup: DatabaseGroup,
updateMask: string[]
) => {
- const newDatabaseGroup = convertOldDatabaseGroupToNew(databaseGroup);
const request = create(UpdateDatabaseGroupRequestSchema, {
- databaseGroup: newDatabaseGroup,
+ databaseGroup,
updateMask: { paths: updateMask },
});
- const response = await databaseGroupServiceClientConnect.updateDatabaseGroup(request);
- const updatedDatabaseGroup = convertNewDatabaseGroupToOld(response);
+ const updatedDatabaseGroup =
+ await databaseGroupServiceClientConnect.updateDatabaseGroup(request);
const composedData = await batchComposeDatabaseGroup([
updatedDatabaseGroup,
]);
- setDatabaseGroupCache(
- composedData[0],
- DatabaseGroupView.DATABASE_GROUP_VIEW_FULL
- );
+ setDatabaseGroupCache(composedData[0], DatabaseGroupViewEnum.FULL);
return updatedDatabaseGroup;
};
@@ -263,14 +248,8 @@ export const useDBGroupStore = defineStore("db-group", () => {
name: name,
});
await databaseGroupServiceClientConnect.deleteDatabaseGroup(request);
- cacheByName.invalidateEntity([
- name,
- DatabaseGroupView.DATABASE_GROUP_VIEW_FULL,
- ]);
- cacheByName.invalidateEntity([
- name,
- DatabaseGroupView.DATABASE_GROUP_VIEW_BASIC,
- ]);
+ cacheByName.invalidateEntity([name, DatabaseGroupViewEnum.FULL]);
+ cacheByName.invalidateEntity([name, DatabaseGroupViewEnum.BASIC]);
};
const fetchDatabaseGroupMatchList = async ({
@@ -293,10 +272,10 @@ export const useDBGroupStore = defineStore("db-group", () => {
const result = await createDatabaseGroup({
projectName: projectName,
- databaseGroup: DatabaseGroup.fromPartial({
+ databaseGroup: create(DatabaseGroupSchema, {
name: `${projectName}/${databaseGroupNamePrefix}${validateOnlyResourceId}`,
title: validateOnlyResourceId,
- databaseExpr: Expr.fromPartial({
+ databaseExpr: create(ExprSchema, {
expression,
}),
}),
@@ -349,15 +328,17 @@ export const useDatabaseInGroupFilter = (
const request = create(ListDatabaseGroupsRequestSchema, {
parent: unref(project).name,
});
- const response = await databaseGroupServiceClientConnect.listDatabaseGroups(request);
+ const response =
+ await databaseGroupServiceClientConnect.listDatabaseGroups(request);
return Promise.all(
response.databaseGroups.map(async (group) => {
const getRequest = create(GetDatabaseGroupRequestSchema, {
name: group.name,
- view: convertOldDatabaseGroupViewToNew(DatabaseGroupView.DATABASE_GROUP_VIEW_FULL),
+ view: DatabaseGroupViewEnum.FULL,
});
- const newGroup = await databaseGroupServiceClientConnect.getDatabaseGroup(getRequest);
- return convertNewDatabaseGroupToOld(newGroup);
+ return await databaseGroupServiceClientConnect.getDatabaseGroup(
+ getRequest
+ );
})
);
},
diff --git a/frontend/src/store/modules/risk.ts b/frontend/src/store/modules/risk.ts
index aa3eeecc11..d24035fcea 100644
--- a/frontend/src/store/modules/risk.ts
+++ b/frontend/src/store/modules/risk.ts
@@ -2,26 +2,22 @@ import { create } from "@bufbuild/protobuf";
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { riskServiceClientConnect } from "@/grpcweb";
-import type { Risk as OldRisk } from "@/types/proto/v1/risk_service";
-import type { Risk } from "@/types/proto-es/v1/risk_service_pb";
+import type {
+ Risk,
+} from "@/types/proto-es/v1/risk_service_pb";
import {
CreateRiskRequestSchema,
DeleteRiskRequestSchema,
ListRisksRequestSchema,
UpdateRiskRequestSchema,
} from "@/types/proto-es/v1/risk_service_pb";
-import {
- convertOldRiskToNew,
- convertNewRiskToOld,
-} from "@/utils/v1/risk-conversions";
export const useRiskStore = defineStore("risk", () => {
// Internal state uses proto-es types
const _riskList = ref<Risk[]>([]);
- // Computed property provides old proto type for compatibility
const riskList = computed(() => {
- return _riskList.value.map(convertNewRiskToOld);
+ return _riskList.value;
});
const fetchRiskList = async () => {
@@ -33,13 +29,12 @@ export const useRiskStore = defineStore("risk", () => {
return riskList.value;
};
- const upsertRisk = async (risk: OldRisk) => {
- const newRisk = convertOldRiskToNew(risk);
- const existedRisk = _riskList.value.find((r) => r.name === newRisk.name);
+ const upsertRisk = async (risk: Risk) => {
+ const existedRisk = _riskList.value.find((r) => r.name === risk.name);
if (existedRisk) {
// update
const request = create(UpdateRiskRequestSchema, {
- risk: newRisk,
+ risk: risk,
updateMask: { paths: ["title", "level", "active", "condition", "source"] },
});
const updated = await riskServiceClientConnect.updateRisk(request);
@@ -47,14 +42,14 @@ export const useRiskStore = defineStore("risk", () => {
} else {
// create
const request = create(CreateRiskRequestSchema, {
- risk: newRisk,
+ risk: risk,
});
const created = await riskServiceClientConnect.createRisk(request);
_riskList.value.push(created);
}
};
- const deleteRisk = async (risk: OldRisk) => {
+ const deleteRisk = async (risk: Risk) => {
const request = create(DeleteRiskRequestSchema, {
name: risk.name,
});
diff --git a/frontend/src/store/modules/v1/group.ts b/frontend/src/store/modules/v1/group.ts
index 1da67835b4..20042dd7f8 100644
--- a/frontend/src/store/modules/v1/group.ts
+++ b/frontend/src/store/modules/v1/group.ts
@@ -5,7 +5,7 @@ import { defineStore } from "pinia";
import { computed, reactive } from "vue";
import { groupServiceClientConnect } from "@/grpcweb";
import { silentContextKey } from "@/grpcweb/context-key";
-import type { Group } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
import {
CreateGroupRequestSchema,
DeleteGroupRequestSchema,
@@ -14,7 +14,6 @@ import {
UpdateGroupRequestSchema,
} from "@/types/proto-es/v1/group_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
-import { convertNewGroupToOld, convertOldGroupToNew } from "@/utils/v1/group-conversions";
import { useUserStore } from "../user";
import { groupNamePrefix } from "./common";
@@ -60,11 +59,10 @@ export const useGroupStore = defineStore("group", () => {
const request = create(ListGroupsRequestSchema, {});
const { groups } = await groupServiceClientConnect.listGroups(request);
resetCache();
- const oldGroups = groups.map(convertNewGroupToOld);
- for (const group of oldGroups) {
+ for (const group of groups) {
await composeGroup(group);
}
- return oldGroups;
+ return groups;
};
const getOrFetchGroupByIdentifier = async (id: string) => {
@@ -80,10 +78,9 @@ export const useGroupStore = defineStore("group", () => {
const request = create(GetGroupRequestSchema, {
name: ensureGroupIdentifier(id),
});
- const newGroup = await groupServiceClientConnect.getGroup(request, {
+ const group = await groupServiceClientConnect.getGroup(request, {
contextValues: createContextValues().set(silentContextKey, true),
});
- const group = convertNewGroupToOld(newGroup);
await composeGroup(group);
return group;
};
@@ -95,28 +92,24 @@ export const useGroupStore = defineStore("group", () => {
};
const createGroup = async (group: Group) => {
- const newGroup = convertOldGroupToNew(group);
const request = create(CreateGroupRequestSchema, {
- group: newGroup,
+ group: group,
groupEmail: extractGroupEmail(group.name),
});
const response = await groupServiceClientConnect.createGroup(request);
- const oldGroup = convertNewGroupToOld(response);
- await composeGroup(oldGroup);
- return oldGroup;
+ await composeGroup(response);
+ return response;
};
const updateGroup = async (group: Group) => {
- const newGroup = convertOldGroupToNew(group);
const request = create(UpdateGroupRequestSchema, {
- group: newGroup,
+ group: group,
updateMask: { paths: ["title", "description", "members"] },
allowMissing: false,
});
const response = await groupServiceClientConnect.updateGroup(request);
- const updated = convertNewGroupToOld(response);
- await composeGroup(updated);
- return updated;
+ await composeGroup(response);
+ return response;
};
return {
diff --git a/frontend/src/store/modules/v1/projectIamPolicy.ts b/frontend/src/store/modules/v1/projectIamPolicy.ts
index 3b1f8cfd86..a68566ceef 100644
--- a/frontend/src/store/modules/v1/projectIamPolicy.ts
+++ b/frontend/src/store/modules/v1/projectIamPolicy.ts
@@ -6,11 +6,11 @@ import { projectServiceClientConnect } from "@/grpcweb";
import {
GetIamPolicyRequestSchema,
SetIamPolicyRequestSchema,
+ IamPolicySchema,
} from "@/types/proto-es/v1/iam_policy_pb";
import {
BatchGetIamPolicyRequestSchema,
} from "@/types/proto-es/v1/project_service_pb";
-import { convertNewIamPolicyToOld, convertOldIamPolicyToNew } from "@/utils/v1/project-conversions";
import {
ALL_USERS_USER_EMAIL,
QueryPermissionQueryAny,
@@ -19,8 +19,8 @@ import {
type MaybeRef,
type QueryPermission,
} from "@/types";
-import type { Expr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
-import { IamPolicy } from "@/types/proto/v1/iam_policy";
+import type { Expr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
+import type { IamPolicy } from "@/types/proto-es/v1/iam_policy_pb";
import type { User } from "@/types/proto/v1/user_service";
import { getUserEmailListInBinding } from "@/utils";
import { convertFromExpr } from "@/utils/issue/cel";
@@ -66,11 +66,10 @@ export const useProjectIamPolicyStore = defineStore(
const requestPromise = projectServiceClientConnect
.getIamPolicy(request)
.then((response) => {
- const policy = convertNewIamPolicyToOld(response);
- return setIamPolicy(project, policy);
+ return setIamPolicy(project, response);
});
requestCache.set(project, requestPromise);
- return request;
+ return requestPromise;
};
const batchFetchIamPolicy = async (projectList: string[]) => {
@@ -81,8 +80,7 @@ export const useProjectIamPolicyStore = defineStore(
const response = await projectServiceClientConnect.batchGetIamPolicy(request);
for (const item of response.policyResults) {
if (item.policy) {
- const oldPolicy = convertNewIamPolicyToOld(item.policy);
- await setIamPolicy(item.project, oldPolicy);
+ await setIamPolicy(item.project, item.policy);
}
}
};
@@ -98,18 +96,17 @@ export const useProjectIamPolicyStore = defineStore(
});
const request = create(SetIamPolicyRequestSchema, {
resource: project,
- policy: convertOldIamPolicyToNew(policy),
+ policy: policy,
etag: policy.etag,
});
const response = await projectServiceClientConnect.setIamPolicy(request);
- const updated = convertNewIamPolicyToOld(response);
- policyMap.value.set(project, updated);
+ policyMap.value.set(project, response);
usePermissionStore().invalidCacheByProject(project);
};
const getProjectIamPolicy = (project: string) => {
- return policyMap.value.get(project) ?? IamPolicy.fromPartial({});
+ return policyMap.value.get(project) ?? create(IamPolicySchema, {});
};
const getOrFetchProjectIamPolicy = async (project: string) => {
@@ -162,7 +159,7 @@ export const useProjectIamPolicy = (project: MaybeRef<string>) => {
{ immediate: true }
);
const policy = computed(() => {
- return store.policyMap.get(unref(project)) ?? IamPolicy.fromPartial({});
+ return store.policyMap.get(unref(project)) ?? create(IamPolicySchema, {});
});
return { policy, ready };
};
diff --git a/frontend/src/store/modules/v1/workspace.ts b/frontend/src/store/modules/v1/workspace.ts
index 19bcfefed2..71c9085f78 100644
--- a/frontend/src/store/modules/v1/workspace.ts
+++ b/frontend/src/store/modules/v1/workspace.ts
@@ -15,15 +15,12 @@ import {
import { bindingListInIAM, getUserEmailListInBinding } from "@/utils";
import { extractUserId } from "./common";
import { extractGroupEmail } from "./group";
-import { convertNewIamPolicyToOld } from "@/utils/v1/iam-conversions";
export const useWorkspaceV1Store = defineStore("workspace_v1", () => {
- // Internal state uses proto-es types
const _workspaceIamPolicy = ref<IamPolicy>(create(IamPolicySchema, {}));
- // Computed property that provides old proto type for compatibility
const workspaceIamPolicy = computed(() => {
- return convertNewIamPolicyToOld(_workspaceIamPolicy.value);
+ return _workspaceIamPolicy.value;
});
// roleMapToUsers returns Map<roles/{role}, Set<users/{email}>>
diff --git a/frontend/src/store/modules/workspaceApprovalSetting.ts b/frontend/src/store/modules/workspaceApprovalSetting.ts
index 859daa4969..ab2f0f8bfe 100644
--- a/frontend/src/store/modules/workspaceApprovalSetting.ts
+++ b/frontend/src/store/modules/workspaceApprovalSetting.ts
@@ -12,7 +12,7 @@ import {
ValueSchema as SettingValueSchema,
} from "@/types/proto-es/v1/setting_service_pb";
import { type LocalApprovalConfig, type LocalApprovalRule } from "@/types";
-import type { Risk_Source } from "@/types/proto/v1/risk_service";
+import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
import {
resolveLocalApprovalConfig,
buildWorkspaceApprovalSetting,
diff --git a/frontend/src/types/dbGroup.ts b/frontend/src/types/dbGroup.ts
index 7550c3e696..66601bdf5a 100644
--- a/frontend/src/types/dbGroup.ts
+++ b/frontend/src/types/dbGroup.ts
@@ -1,7 +1,7 @@
import type { ConditionGroupExpr } from "@/plugins/cel";
import { UNKNOWN_ID, type ComposedProject } from "@/types";
import { extractDatabaseGroupName } from "@/utils";
-import type { DatabaseGroup } from "./proto/v1/database_group_service";
+import type { DatabaseGroup } from "./proto-es/v1/database_group_service_pb";
export interface ComposedDatabaseGroup extends DatabaseGroup {
projectName: string;
diff --git a/frontend/src/types/risk.ts b/frontend/src/types/risk.ts
index 5b259e3524..08f05d886e 100644
--- a/frontend/src/types/risk.ts
+++ b/frontend/src/types/risk.ts
@@ -1,6 +1,6 @@
import { computed } from "vue";
import { useAppFeature } from "@/store";
-import { Risk_Source } from "./proto/v1/risk_service";
+import { Risk_Source } from "./proto-es/v1/risk_service_pb";
import { DatabaseChangeMode } from "./proto-es/v1/setting_service_pb";
export const PresetRiskLevel = {
diff --git a/frontend/src/types/v1/group.ts b/frontend/src/types/v1/group.ts
index f541e253f7..6f1262088b 100644
--- a/frontend/src/types/v1/group.ts
+++ b/frontend/src/types/v1/group.ts
@@ -1,11 +1,12 @@
import { groupNamePrefix } from "@/store/modules/v1/common";
import { UNKNOWN_ID } from "../const";
-import { Group } from "../proto/v1/group_service";
+import { GroupSchema } from "../proto-es/v1/group_service_pb";
+import { create as createProto } from "@bufbuild/protobuf";
export const UNKNOWN_GROUP_NAME = `${groupNamePrefix}${UNKNOWN_ID}`;
export const unknownGroup = () => {
- return Group.fromPartial({
+ return createProto(GroupSchema, {
name: UNKNOWN_GROUP_NAME,
title: "<<Unknown group>>",
});
diff --git a/frontend/src/types/v1/project.ts b/frontend/src/types/v1/project.ts
index 73d4d709c7..ecba981271 100644
--- a/frontend/src/types/v1/project.ts
+++ b/frontend/src/types/v1/project.ts
@@ -1,8 +1,10 @@
import { EMPTY_ID, UNKNOWN_ID } from "../const";
import { State } from "../proto-es/v1/common_pb";
import { convertStateToOld } from "@/utils/v1/common-conversions";
-import { IamPolicy } from "../proto/v1/iam_policy";
+import type { IamPolicy } from "../proto-es/v1/iam_policy_pb";
+import { IamPolicySchema } from "../proto-es/v1/iam_policy_pb";
import { Project } from "../proto/v1/project_service";
+import { create as createProto } from "@bufbuild/protobuf";
export const DEFAULT_PROJECT_UID = 1;
export const EMPTY_PROJECT_NAME = `projects/${EMPTY_ID}`;
@@ -20,7 +22,7 @@ export const emptyProject = (): ComposedProject => {
title: "",
state: convertStateToOld(State.ACTIVE),
}),
- iamPolicy: IamPolicy.fromPartial({}),
+ iamPolicy: createProto(IamPolicySchema, {}),
};
};
diff --git a/frontend/src/types/workspaceApprovalSetting.ts b/frontend/src/types/workspaceApprovalSetting.ts
index 0300f9aed0..c7de33e499 100644
--- a/frontend/src/types/workspaceApprovalSetting.ts
+++ b/frontend/src/types/workspaceApprovalSetting.ts
@@ -1,6 +1,6 @@
import type { SimpleExpr } from "@/plugins/cel";
import type { ApprovalTemplate } from "@/types/proto/v1/issue_service";
-import type { Risk_Source } from "@/types/proto/v1/risk_service";
+import type { Risk_Source } from "@/types/proto-es/v1/risk_service_pb";
export type LocalApprovalRule = {
uid: string;
diff --git a/frontend/src/utils/databaseGroup/cel.ts b/frontend/src/utils/databaseGroup/cel.ts
index 52b278f10a..c72c7bf7d9 100644
--- a/frontend/src/utils/databaseGroup/cel.ts
+++ b/frontend/src/utils/databaseGroup/cel.ts
@@ -1,5 +1,5 @@
import { emptySimpleExpr, resolveCELExpr, wrapAsGroup } from "@/plugins/cel";
-import type { Expr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
+import type { Expr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
import { batchConvertCELStringToParsedExpr } from "@/utils";
export const convertCELStringToExpr = async (cel: string) => {
diff --git a/frontend/src/utils/issue/cel.ts b/frontend/src/utils/issue/cel.ts
index f49f9b7182..cb81503bfa 100644
--- a/frontend/src/utils/issue/cel.ts
+++ b/frontend/src/utils/issue/cel.ts
@@ -1,3 +1,4 @@
+import { create } from "@bufbuild/protobuf";
import dayjs from "dayjs";
import { cloneDeep, head } from "lodash-es";
import type { SimpleExpr } from "@/plugins/cel";
@@ -7,8 +8,9 @@ import {
instanceNamePrefix,
} from "@/store/modules/v1/common";
import type { DatabaseResource } from "@/types";
-import type { Expr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
-import { Expr as ConditionExpr } from "@/types/proto/google/type/expr";
+import type { Expr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
+import type { Expr as ConditionExpr } from "@/types/proto-es/google/type/expr_pb";
+import { ExprSchema as ConditionExprSchema } from "@/types/proto-es/google/type/expr_pb";
import {
batchConvertCELStringToParsedExpr,
displayRoleTitle,
@@ -121,7 +123,7 @@ export const buildConditionExpr = ({
databaseResources,
rowLimit,
});
- return ConditionExpr.create({
+ return create(ConditionExprSchema, {
title:
title ||
buildConditionTitle({
@@ -130,7 +132,7 @@ export const buildConditionExpr = ({
expirationTimestampInMS,
}),
description: description,
- expression: expresson || undefined,
+ expression: expresson || "",
});
};
diff --git a/frontend/src/utils/v1/cel.ts b/frontend/src/utils/v1/cel.ts
index 12d99bcdaa..2260722262 100644
--- a/frontend/src/utils/v1/cel.ts
+++ b/frontend/src/utils/v1/cel.ts
@@ -6,8 +6,8 @@ import {
BatchParseRequestSchema,
BatchDeparseRequestSchema
} from "@/types/proto-es/v1/cel_service_pb";
-import { Expr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
-import { convertNewExprToOld, convertOldExprToNew } from "@/utils/v1/cel-conversions";
+import type { Expr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
+import { ExprSchema } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
export const batchConvertCELStringToParsedExpr = async (
celList: string[]
@@ -21,11 +21,11 @@ export const batchConvertCELStringToParsedExpr = async (
});
// Convert new Expr array to old Expr array for compatibility
- return response.expressions.map(convertNewExprToOld);
+ return response.expressions;
} catch (error) {
console.error(error);
return Array.from({ length: celList.length }).map((_) =>
- Expr.fromPartial({})
+ create(ExprSchema, {})
);
}
};
@@ -34,11 +34,8 @@ export const batchConvertParsedExprToCELString = async (
parsedExprList: Expr[]
): Promise<string[]> => {
try {
- // Convert old Expr array to new Expr array
- const newExprList = parsedExprList.map(convertOldExprToNew);
-
const request = create(BatchDeparseRequestSchema, {
- expressions: newExprList,
+ expressions: parsedExprList,
});
const response = await celServiceClientConnect.batchDeparse(request, {
contextValues: createContextValues().set(silentContextKey, true),
diff --git a/frontend/src/utils/v1/common-conversions.ts b/frontend/src/utils/v1/common-conversions.ts
index 2d3d9d6ab5..84c68abb13 100644
--- a/frontend/src/utils/v1/common-conversions.ts
+++ b/frontend/src/utils/v1/common-conversions.ts
@@ -24,6 +24,11 @@ import {
type Duration as NewDuration,
} from "@bufbuild/protobuf/wkt"
+// Expr type imports
+import { Expr as OldExpr } from "@/types/proto/google/type/expr";
+import type { Expr as NewExpr } from "@/types/proto-es/google/type/expr_pb";
+import { ExprSchema as NewExprSchema } from "@/types/proto-es/google/type/expr_pb";
+
// Proto-es imports
import {
@@ -436,4 +441,28 @@ export const convertDurationToNew = (value: OldDuration): NewDuration => {
seconds: value.seconds.toBigInt(),
nanos: value.nanos,
})
-}
\ No newline at end of file
+}
+
+/**
+ * Convert old proto Expr to proto-es Expr
+ */
+export const convertExprToNew = (expr: OldExpr): NewExpr => {
+ return create(NewExprSchema, {
+ expression: expr.expression,
+ title: expr.title,
+ description: expr.description,
+ location: expr.location,
+ });
+};
+
+/**
+ * Convert proto-es Expr to old proto Expr
+ */
+export const convertExprToOld = (expr: NewExpr): OldExpr => {
+ return OldExpr.create({
+ expression: expr.expression,
+ title: expr.title,
+ description: expr.description,
+ location: expr.location,
+ });
+};
\ No newline at end of file
diff --git a/frontend/src/utils/v1/google-type-expr-conversions.ts b/frontend/src/utils/v1/google-type-expr-conversions.ts
new file mode 100644
index 0000000000..e7114e6789
--- /dev/null
+++ b/frontend/src/utils/v1/google-type-expr-conversions.ts
@@ -0,0 +1,19 @@
+import { fromJson, toJson } from "@bufbuild/protobuf";
+import type { Expr as OldExpr } from "@/types/proto/google/type/expr";
+import { Expr as OldExprProto } from "@/types/proto/google/type/expr";
+import type { Expr as NewExpr } from "@/types/proto-es/google/type/expr_pb";
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
+
+// Convert old proto to proto-es
+export const convertOldGoogleTypeExprToNew = (oldExpr: OldExpr): NewExpr => {
+ // Use toJSON to convert old proto to JSON, then fromJson to convert to proto-es
+ const json = OldExprProto.toJSON(oldExpr) as any; // Type assertion needed due to proto type incompatibility
+ return fromJson(ExprSchema, json);
+};
+
+// Convert proto-es to old proto
+export const convertNewGoogleTypeExprToOld = (newExpr: NewExpr): OldExpr => {
+ // Use toJson to convert proto-es to JSON, then fromJSON to convert to old proto
+ const json = toJson(ExprSchema, newExpr);
+ return OldExprProto.fromJSON(json);
+};
\ No newline at end of file
diff --git a/frontend/src/utils/v1/iam.ts b/frontend/src/utils/v1/iam.ts
index 7a664fdf5b..99ad2bcf19 100644
--- a/frontend/src/utils/v1/iam.ts
+++ b/frontend/src/utils/v1/iam.ts
@@ -2,33 +2,13 @@ import { uniq } from "lodash-es";
import { extractUserId, useGroupStore, useWorkspaceV1Store } from "@/store";
import { userNamePrefix } from "@/store/modules/v1/common";
import { groupBindingPrefix, ALL_USERS_USER_EMAIL } from "@/types";
-import type { IamPolicy, Binding } from "@/types/proto/v1/iam_policy";
-import type { IamPolicy as NewIamPolicy, Binding as NewBinding } from "@/types/proto-es/v1/iam_policy_pb";
+import type { IamPolicy, Binding } from "@/types/proto-es/v1/iam_policy_pb";
import { convertFromExpr } from "@/utils/issue/cel";
-import { convertNewBindingToOld, convertNewIamPolicyToOld } from "./iam-conversions";
-// Helper function to work with both old and new binding types
-const normalizeBinding = (binding: Binding | NewBinding): Binding => {
- // Check if it's a new proto-es binding by checking for proto-es specific properties
- if ('$typeName' in binding && binding.$typeName === 'bytebase.v1.Binding') {
- return convertNewBindingToOld(binding as NewBinding);
- }
- return binding as Binding;
-};
-
-// Helper function to work with both old and new policy types
-const normalizeIamPolicy = (policy: IamPolicy | NewIamPolicy): IamPolicy => {
- // Check if it's a new proto-es policy by checking for proto-es specific properties
- if ('$typeName' in policy && policy.$typeName === 'bytebase.v1.IamPolicy') {
- return convertNewIamPolicyToOld(policy as NewIamPolicy);
- }
- return policy as IamPolicy;
-};
-export const isBindingPolicyExpired = (binding: Binding | NewBinding): boolean => {
- const normalizedBinding = normalizeBinding(binding);
- if (normalizedBinding.parsedExpr) {
- const conditionExpr = convertFromExpr(normalizedBinding.parsedExpr);
+export const isBindingPolicyExpired = (binding: Binding): boolean => {
+ if (binding.parsedExpr) {
+ const conditionExpr = convertFromExpr(binding.parsedExpr);
if (conditionExpr.expiredTime) {
const expiration = new Date(conditionExpr.expiredTime);
if (expiration < new Date()) {
@@ -46,18 +26,17 @@ export const getUserEmailListInBinding = ({
binding,
ignoreGroup,
}: {
- binding: Binding | NewBinding;
+ binding: Binding;
ignoreGroup: boolean;
}): string[] => {
if (isBindingPolicyExpired(binding)) {
return [];
}
- const normalizedBinding = normalizeBinding(binding);
const groupStore = useGroupStore();
const emailList = [];
- for (const member of normalizedBinding.members) {
+ for (const member of binding.members) {
if (member.startsWith(groupBindingPrefix)) {
if (ignoreGroup) {
continue;
@@ -81,16 +60,15 @@ export const getUserEmailListInBinding = ({
// memberMapToRolesInProjectIAM return the Map<users/{email}, Set<roles/{role}>>
// the user could includes users/ALL_USERS_USER_EMAIL
export const memberMapToRolesInProjectIAM = (
- iamPolicy: IamPolicy | NewIamPolicy,
+ iamPolicy: IamPolicy,
targetRole?: string
): Map<string, Set<string>> => {
- const normalizedPolicy = normalizeIamPolicy(iamPolicy);
const workspaceStore = useWorkspaceV1Store();
// Map<users/{email}, Set<roles/{role}>>
const rolesMapByName = new Map<string, Set<string>>();
// Handle project level roles.
- for (const binding of normalizedPolicy.bindings) {
+ for (const binding of iamPolicy.bindings) {
if (targetRole && binding.role !== targetRole) {
continue;
}
@@ -130,12 +108,11 @@ export const bindingListInIAM = ({
email,
ignoreGroup,
}: {
- policy: IamPolicy | NewIamPolicy;
+ policy: IamPolicy;
email: string;
ignoreGroup: boolean;
}): Binding[] => {
- const normalizedPolicy = normalizeIamPolicy(policy);
- return normalizedPolicy.bindings.filter((binding) => {
+ return policy.bindings.filter((binding) => {
if (isBindingPolicyExpired(binding)) {
return false;
}
diff --git a/frontend/src/utils/workspaceApprovalSetting.ts b/frontend/src/utils/workspaceApprovalSetting.ts
index 8355bceb2a..c63efc766b 100644
--- a/frontend/src/utils/workspaceApprovalSetting.ts
+++ b/frontend/src/utils/workspaceApprovalSetting.ts
@@ -14,9 +14,10 @@ import type { ParsedApprovalRule, UnrecognizedApprovalRule } from "@/types";
import { DEFAULT_RISK_LEVEL, PresetRoleType } from "@/types";
import type { LocalApprovalConfig, LocalApprovalRule } from "@/types";
import { PresetRiskLevelList, useSupportedSourceList } from "@/types";
-import { Expr as CELExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
import type { Expr as _Expr } from "@/types/proto-es/google/type/expr_pb";
import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
+import type { Expr as CELExpr } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
+import { ExprSchema as CELExprSchema } from "@/types/proto-es/google/api/expr/v1alpha1/syntax_pb";
import type {
ApprovalNode as _ApprovalNode,
ApprovalStep as _ApprovalStep,
@@ -43,8 +44,7 @@ import {
} from "@/types/proto-es/v1/issue_service_pb";
import {
Risk_Source,
- risk_SourceFromJSON,
-} from "@/types/proto/v1/risk_service";
+} from "@/types/proto-es/v1/risk_service_pb";
import type {
WorkspaceApprovalSetting,
WorkspaceApprovalSetting_Rule as ApprovalRule,
@@ -102,7 +102,7 @@ export const resolveLocalApprovalConfig = async (
const rule = config.rules[i];
const localRule: LocalApprovalRule = {
uid: uuidv4(),
- expr: resolveCELExpr(CELExpr.fromPartial({})),
+ expr: resolveCELExpr(createProto(CELExprSchema, {})),
template: cloneDeep(convertNewApprovalTemplateToOld(rule.template!)),
};
ruleMap.set(localRule.uid, localRule);
@@ -116,7 +116,7 @@ export const resolveLocalApprovalConfig = async (
for (let i = 0; i < exprList.length; i++) {
const ruleId = ruleIdList[i];
ruleMap.get(ruleId)!.expr = resolveCELExpr(
- exprList[i] ?? CELExpr.fromPartial({})
+ exprList[i] ?? createProto(CELExprSchema, {})
);
}
@@ -143,7 +143,7 @@ const resolveApprovalConfigRules = (rules: LocalApprovalRule[]) => {
if (operator !== "_&&_") return fail(expr, rule);
if (!args || args.length !== 2) return fail(expr, rule);
const source = resolveSourceExpr(args[0]);
- if (source === Risk_Source.UNRECOGNIZED) return fail(expr, rule);
+ if (source === Risk_Source.SOURCE_UNSPECIFIED) return fail(expr, rule);
const level = resolveLevelExpr(args[1]);
if (Number.isNaN(level)) return fail(expr, rule);
@@ -221,7 +221,9 @@ export const buildWorkspaceApprovalSetting = async (
}
}
- const expressionList = await batchConvertParsedExprToCELString(exprList);
+ const expressionList = await batchConvertParsedExprToCELString(
+ exprList
+ );
for (let i = 0; i < expressionList.length; i++) {
const ruleIndex = ruleIndexList[i];
approvalRuleMap.get(ruleIndex)!.condition = createProto(ExprSchema, {
@@ -236,22 +238,25 @@ export const buildWorkspaceApprovalSetting = async (
const resolveSourceExpr = (expr: SimpleExpr): Risk_Source => {
if (!isConditionExpr(expr)) {
- return Risk_Source.UNRECOGNIZED;
+ return Risk_Source.SOURCE_UNSPECIFIED;
}
const { operator, args } = expr;
if (operator !== "_==_") {
- return Risk_Source.UNRECOGNIZED;
+ return Risk_Source.SOURCE_UNSPECIFIED;
}
if (!args || args.length !== 2) {
- return Risk_Source.UNRECOGNIZED;
+ return Risk_Source.SOURCE_UNSPECIFIED;
}
const factor = args[0];
if (factor !== "source") {
- return Risk_Source.UNRECOGNIZED;
+ return Risk_Source.SOURCE_UNSPECIFIED;
}
- const source = risk_SourceFromJSON(args[1]);
+ const sourceValue = args[1];
+ const source = typeof sourceValue === 'string' ?
+ (Risk_Source[sourceValue as keyof typeof Risk_Source] ?? Risk_Source.SOURCE_UNSPECIFIED) :
+ sourceValue as Risk_Source;
if (!useSupportedSourceList().value.includes(source)) {
- return Risk_Source.UNRECOGNIZED;
+ return Risk_Source.SOURCE_UNSPECIFIED;
}
return source;
};
diff --git a/frontend/src/views/SettingWorkspaceUsers.vue b/frontend/src/views/SettingWorkspaceUsers.vue
index 6bca2dd1e5..877707ea7d 100644
--- a/frontend/src/views/SettingWorkspaceUsers.vue
+++ b/frontend/src/views/SettingWorkspaceUsers.vue
@@ -207,7 +207,7 @@ import {
} from "@/store";
import { groupNamePrefix } from "@/store/modules/v1/common";
import { State } from "@/types/proto-es/v1/common_pb";
-import type { Group } from "@/types/proto/v1/group_service";
+import type { Group } from "@/types/proto-es/v1/group_service_pb";
import { WorkspaceProfileSettingSchema } from "@/types/proto-es/v1/setting_service_pb";
import { create } from "@bufbuild/protobuf";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
diff --git a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
index 252433334b..54df4f8879 100644
--- a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
+++ b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
@@ -65,7 +65,7 @@ import {
databaseGroupNamePrefix,
projectNamePrefix,
} from "@/store/modules/v1/common";
-import { DatabaseGroupView } from "@/types/proto/v1/database_group_service";
+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { hasPermissionToCreateChangeDatabaseIssueInProject } from "@/utils";
import { generateDatabaseGroupIssueRoute } from "@/utils/databaseGroup/issue";
@@ -110,7 +110,7 @@ const hasDatabaseGroupFeature = featureToRef(PlanFeature.FEATURE_DATABASE_GROUPS
watchEffect(async () => {
await dbGroupStore.getOrFetchDBGroupByName(databaseGroupResourceName.value, {
skipCache: true,
- view: DatabaseGroupView.DATABASE_GROUP_VIEW_FULL,
+ view: DatabaseGroupView.FULL,
});
});