Skip to content

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

feat: fe connect migration: org_policy & sql review fix (#16712)

p0nybc55492e5cf1
diff --git a/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue b/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue
index bddcacd28d..66ffe63887 100644
--- a/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue
+++ b/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue
@@ -90,7 +90,9 @@ import {
ObjectSchema_Type,
type ObjectSchema,
} from "@/types/proto-es/v1/database_catalog_service_pb";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { create } from "@bufbuild/protobuf";
+import { MaskingExceptionPolicySchema } from "@/types/proto-es/v1/org_policy_service_pb";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { hasProjectPermissionV2, instanceV1MaskingForNoSQL } from "@/utils";
const props = defineProps<{
@@ -273,7 +275,9 @@ const removeMaskingExceptions = async (sensitiveColumn: MaskData) => {
}
const exceptions = (
- policy.maskingExceptionPolicy?.maskingExceptions ?? []
+ policy.policy?.case === "maskingExceptionPolicy"
+ ? policy.policy.value.maskingExceptions
+ : []
).filter(
(exception) =>
!isCurrentColumnException(exception, {
@@ -282,9 +286,11 @@ const removeMaskingExceptions = async (sensitiveColumn: MaskData) => {
})
);
- policy.maskingExceptionPolicy = {
- ...(policy.maskingExceptionPolicy ?? {}),
- maskingExceptions: exceptions,
+ policy.policy = {
+ case: "maskingExceptionPolicy",
+ value: create(MaskingExceptionPolicySchema, {
+ maskingExceptions: exceptions,
+ }),
};
await policyStore.upsertPolicy({
parentPath: props.database.project,
diff --git a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
index 716de9e2e7..7629710c2e 100644
--- a/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
+++ b/frontend/src/components/EnvironmentForm/AccessControlConfigure.vue
@@ -102,17 +102,22 @@
</template>
<script setup lang="ts">
+import { create as createProto } from "@bufbuild/protobuf";
import { cloneDeep, isEqual } from "lodash-es";
import { NRadio, NRadioGroup } from "naive-ui";
import { computed, reactive, watchEffect } from "vue";
import { hasFeature, usePolicyV1Store } from "@/store";
import { environmentNamePrefix } from "@/store/modules/v1/common";
-import {
+import type {
DataSourceQueryPolicy,
- DataSourceQueryPolicy_Restriction,
DisableCopyDataPolicy,
+} from "@/types/proto-es/v1/org_policy_service_pb";
+import {
+ DataSourceQueryPolicySchema,
+ DataSourceQueryPolicy_Restriction,
+ DisableCopyDataPolicySchema,
PolicyType,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
import { FeatureBadge } from "../FeatureGuard";
@@ -132,18 +137,26 @@ const policyStore = usePolicyV1Store();
const getInitialState = (): LocalState => {
return {
- disableCopyDataPolicy: cloneDeep(
- policyStore.getPolicyByParentAndType({
+ disableCopyDataPolicy: (() => {
+ const policy = policyStore.getPolicyByParentAndType({
parentPath: props.resource,
policyType: PolicyType.DISABLE_COPY_DATA,
- })?.disableCopyDataPolicy ?? DisableCopyDataPolicy.fromPartial({})
- ),
- dataSourceQueryPolicy: cloneDeep(
- policyStore.getPolicyByParentAndType({
+ });
+ if (policy?.policy.case === "disableCopyDataPolicy") {
+ return cloneDeep(policy.policy.value);
+ }
+ return createProto(DisableCopyDataPolicySchema, {});
+ })(),
+ dataSourceQueryPolicy: (() => {
+ const policy = policyStore.getPolicyByParentAndType({
parentPath: props.resource,
policyType: PolicyType.DATA_SOURCE_QUERY,
- })?.dataSourceQueryPolicy ?? DataSourceQueryPolicy.fromPartial({})
- ),
+ });
+ if (policy?.policy.case === "dataSourceQueryPolicy") {
+ return cloneDeep(policy.policy.value);
+ }
+ return createProto(DataSourceQueryPolicySchema, {});
+ })(),
};
};
@@ -195,8 +208,11 @@ const updateDisableCopyDataPolicy = async () => {
parentPath: props.resource,
policy: {
type: PolicyType.DISABLE_COPY_DATA,
- disableCopyDataPolicy: {
- ...state.disableCopyDataPolicy,
+ policy: {
+ case: "disableCopyDataPolicy",
+ value: {
+ ...state.disableCopyDataPolicy,
+ },
},
},
});
@@ -213,9 +229,12 @@ const updateAdminDataSourceQueryRestrctionPolicy = async () => {
parentPath: props.resource,
policy: {
type: PolicyType.DATA_SOURCE_QUERY,
- dataSourceQueryPolicy: DataSourceQueryPolicy.fromPartial({
- ...state.dataSourceQueryPolicy,
- }),
+ policy: {
+ case: "dataSourceQueryPolicy",
+ value: createProto(DataSourceQueryPolicySchema, {
+ ...state.dataSourceQueryPolicy,
+ }),
+ },
},
});
};
diff --git a/frontend/src/components/EnvironmentForm/Buttons.vue b/frontend/src/components/EnvironmentForm/Buttons.vue
index 91ac245d4d..7cdba90e9c 100644
--- a/frontend/src/components/EnvironmentForm/Buttons.vue
+++ b/frontend/src/components/EnvironmentForm/Buttons.vue
@@ -35,7 +35,7 @@ import { cloneDeep, isEqual } from "lodash-es";
import { NButton } from "naive-ui";
import { useI18n } from "vue-i18n";
import { pushNotification } from "@/store";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { useEnvironmentFormContext } from "./context";
const { t } = useI18n();
diff --git a/frontend/src/components/EnvironmentForm/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm/EnvironmentForm.vue
index 60b4c19fcf..50a26b9754 100644
--- a/frontend/src/components/EnvironmentForm/EnvironmentForm.vue
+++ b/frontend/src/components/EnvironmentForm/EnvironmentForm.vue
@@ -12,8 +12,8 @@
import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";
import { hasFeature } from "@/store";
import { VirtualRoleType } from "@/types";
-import type { Policy } from "@/types/proto/v1/org_policy_service";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import type { Policy } from "@/types/proto-es/v1/org_policy_service_pb";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import type { Environment } from "@/types/v1/environment";
import { useEventListener } from "@vueuse/core";
@@ -88,7 +88,7 @@ useEmitteryEventListener(events, "create", (params) => {
return;
}
}
- const rp = rolloutPolicy.rolloutPolicy;
+ const rp = rolloutPolicy.policy.case === "rolloutPolicy" ? rolloutPolicy.policy.value : undefined;
if (rp?.automatic === false) {
if (rp.issueRoles.includes(VirtualRoleType.LAST_APPROVER)) {
if (!hasFeature(PlanFeature.FEATURE_APPROVAL_WORKFLOW)) {
@@ -114,7 +114,7 @@ useEmitteryEventListener(events, "update", (environment) => {
useEmitteryEventListener(events, "update-policy", (params) => {
const { policyType, policy } = params;
if (policyType === PolicyType.ROLLOUT_POLICY) {
- const rp = policy.rolloutPolicy;
+ const rp = policy.policy.case === "rolloutPolicy" ? policy.policy.value : undefined;
if (rp?.automatic === false) {
if (rp.issueRoles.includes(VirtualRoleType.LAST_APPROVER)) {
if (!hasFeature(PlanFeature.FEATURE_APPROVAL_WORKFLOW)) {
diff --git a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
index 6f203fbab1..4b8fa7cdf6 100644
--- a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
+++ b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
@@ -50,11 +50,11 @@
<script setup lang="ts">
import { cloneDeep, uniq } from "lodash-es";
import { NCheckbox } from "naive-ui";
-import { ref, watch } from "vue";
-import { computed } from "vue";
+import { ref, watch, computed } from "vue";
+import { create } from "@bufbuild/protobuf";
import { VirtualRoleType } from "@/types";
-import type { Policy } from "@/types/proto/v1/org_policy_service";
-import { RolloutPolicy } from "@/types/proto/v1/org_policy_service";
+import type { Policy, RolloutPolicy } from "@/types/proto-es/v1/org_policy_service_pb";
+import { RolloutPolicySchema } from "@/types/proto-es/v1/org_policy_service_pb";
import { RoleSelect } from "../v2";
const props = defineProps<{
@@ -66,7 +66,13 @@ const emit = defineEmits<{
(event: "update:policy", policy: Policy): void;
}>();
-const rolloutPolicy = ref(cloneDeep(props.policy.rolloutPolicy!));
+const rolloutPolicy = ref<RolloutPolicy>(
+ cloneDeep(
+ props.policy.policy?.case === "rolloutPolicy"
+ ? props.policy.policy.value
+ : create(RolloutPolicySchema)
+ )
+);
const isAutomaticRolloutChecked = computed(() => {
return rolloutPolicy.value.automatic;
@@ -81,19 +87,22 @@ const isIssueLastApproverChecked = computed(() => {
const update = (rp: RolloutPolicy) => {
emit("update:policy", {
...props.policy,
- rolloutPolicy: rp,
+ policy: {
+ case: "rolloutPolicy",
+ value: rp,
+ },
});
};
const toggleAutomaticRollout = (selected: boolean) => {
update(
- RolloutPolicy.fromPartial({
+ create(RolloutPolicySchema, {
...rolloutPolicy.value,
automatic: selected,
})
);
};
const toggleIssueRoles = (checked: boolean, role: string) => {
- const issueRoles = rolloutPolicy.value.issueRoles;
+ const issueRoles = [...rolloutPolicy.value.issueRoles];
if (checked) {
issueRoles.push(role);
} else {
@@ -103,7 +112,7 @@ const toggleIssueRoles = (checked: boolean, role: string) => {
}
}
update(
- RolloutPolicy.fromPartial({
+ create(RolloutPolicySchema, {
...rolloutPolicy.value,
issueRoles: uniq(issueRoles),
})
@@ -111,7 +120,7 @@ const toggleIssueRoles = (checked: boolean, role: string) => {
};
const updateRoles = (roles: string[]) => {
update(
- RolloutPolicy.fromPartial({
+ create(RolloutPolicySchema, {
...rolloutPolicy.value,
roles: roles,
})
@@ -119,9 +128,11 @@ const updateRoles = (roles: string[]) => {
};
watch(
- () => props.policy.rolloutPolicy!,
+ () => props.policy.policy?.case === "rolloutPolicy" ? props.policy.policy.value : undefined,
(p) => {
- rolloutPolicy.value = cloneDeep(p);
+ if (p) {
+ rolloutPolicy.value = cloneDeep(p);
+ }
},
{ immediate: true, deep: true }
);
diff --git a/frontend/src/components/EnvironmentForm/context.ts b/frontend/src/components/EnvironmentForm/context.ts
index 93626148c7..eaab356f44 100644
--- a/frontend/src/components/EnvironmentForm/context.ts
+++ b/frontend/src/components/EnvironmentForm/context.ts
@@ -4,7 +4,7 @@ import { useDialog } from "naive-ui";
import type { InjectionKey, Ref } from "vue";
import { provide, inject, computed, ref, watch } from "vue";
import type { ResourceIdField } from "@/components/v2";
-import { PolicyType, type Policy } from "@/types/proto/v1/org_policy_service";
+import { PolicyType, type Policy } from "@/types/proto-es/v1/org_policy_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import type { Environment } from "@/types/v1/environment";
import { hasWorkspacePermissionV2 } from "@/utils";
diff --git a/frontend/src/components/GeneralSetting/QueryDataPolicySetting.vue b/frontend/src/components/GeneralSetting/QueryDataPolicySetting.vue
index 5922c3147b..c30272069a 100644
--- a/frontend/src/components/GeneralSetting/QueryDataPolicySetting.vue
+++ b/frontend/src/components/GeneralSetting/QueryDataPolicySetting.vue
@@ -45,9 +45,9 @@ import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import {
PolicyResourceType,
PolicyType,
-} from "@/types/proto/v1/org_policy_service";
+ QueryDataPolicySchema,
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
-import { convertDurationToOld } from "@/utils/v1/common-conversions";
import { FeatureBadge } from "../FeatureGuard";
const policyV1Store = usePolicyV1Store();
@@ -67,9 +67,13 @@ const allowEdit = computed(
);
const initialState = () => {
- return (
- queryDataPolicy.value?.queryDataPolicy?.timeout?.seconds.toNumber() ?? 0
- );
+ if (
+ queryDataPolicy.value?.policy.case === "queryDataPolicy" &&
+ queryDataPolicy.value.policy.value.timeout
+ ) {
+ return Number(queryDataPolicy.value.policy.value.timeout.seconds);
+ }
+ return 0;
};
// limit in seconds.
@@ -85,10 +89,11 @@ const updateChange = async () => {
policy: {
type: PolicyType.DATA_QUERY,
resourceType: PolicyResourceType.WORKSPACE,
- queryDataPolicy: {
- timeout: convertDurationToOld(
- create(DurationSchema, { seconds: BigInt(seconds.value) })
- ),
+ policy: {
+ case: "queryDataPolicy",
+ value: create(QueryDataPolicySchema, {
+ timeout: create(DurationSchema, { seconds: BigInt(seconds.value) }),
+ }),
},
},
});
diff --git a/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue b/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue
index 0204fab91d..be0a6f79c7 100644
--- a/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue
+++ b/frontend/src/components/GeneralSetting/RestrictIssueCreationConfigure.vue
@@ -25,6 +25,7 @@
</template>
<script setup lang="ts">
+import { create } from "@bufbuild/protobuf";
import {
usePolicyByParentAndType,
usePolicyV1Store
@@ -32,7 +33,8 @@ import {
import {
PolicyResourceType,
PolicyType,
-} from "@/types/proto/v1/org_policy_service";
+ RestrictIssueCreationForSQLReviewPolicySchema,
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
import { computed, ref, watch } from "vue";
import { Switch } from "../v2";
@@ -68,7 +70,9 @@ const restrictIssueCreationForSQLReview = ref<boolean>(false);
const resetState = () => {
restrictIssueCreationForSQLReview.value =
- policy.value?.restrictIssueCreationForSqlReviewPolicy?.disallow ?? false;
+ policy.value?.policy?.case === "restrictIssueCreationForSqlReviewPolicy"
+ ? policy.value.policy.value.disallow
+ : false;
};
watch(
@@ -86,8 +90,11 @@ const handleRestrictIssueCreationForSQLReviewToggle = async () => {
policy: {
type: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
resourceType: PolicyResourceType.PROJECT,
- restrictIssueCreationForSqlReviewPolicy: {
- disallow: restrictIssueCreationForSQLReview.value,
+ policy: {
+ case: "restrictIssueCreationForSqlReviewPolicy",
+ value: create(RestrictIssueCreationForSQLReviewPolicySchema, {
+ disallow: restrictIssueCreationForSQLReview.value,
+ }),
},
},
});
@@ -97,7 +104,9 @@ defineExpose({
isDirty: computed(
() =>
restrictIssueCreationForSQLReview.value !==
- (policy.value?.restrictIssueCreationForSqlReviewPolicy?.disallow ?? false)
+ (policy.value?.policy?.case === "restrictIssueCreationForSqlReviewPolicy"
+ ? policy.value.policy.value.disallow
+ : false)
),
update: handleRestrictIssueCreationForSQLReviewToggle,
revert: resetState,
diff --git a/frontend/src/components/GeneralSetting/SecuritySetting.vue b/frontend/src/components/GeneralSetting/SecuritySetting.vue
index eb0dad9276..e6a22644b2 100644
--- a/frontend/src/components/GeneralSetting/SecuritySetting.vue
+++ b/frontend/src/components/GeneralSetting/SecuritySetting.vue
@@ -77,9 +77,10 @@ import {
useSettingV1Store,
} from "@/store";
import {
+ ExportDataPolicySchema,
PolicyResourceType,
PolicyType,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { Setting_SettingName, ValueSchema as SettingValueSchema } from "@/types/proto-es/v1/setting_service_pb";
import { create } from "@bufbuild/protobuf";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
@@ -138,7 +139,7 @@ const getInitialState = (): LocalState => {
}
return {
enableWatermark,
- enableDataExport: !exportDataPolicy.value?.exportDataPolicy?.disable,
+ enableDataExport: exportDataPolicy.value?.policy?.case === "exportDataPolicy" ? !exportDataPolicy.value.policy.value.disable : true,
};
};
@@ -159,8 +160,11 @@ const handleDataExportToggle = async () => {
policy: {
type: PolicyType.DATA_EXPORT,
resourceType: PolicyResourceType.WORKSPACE,
- exportDataPolicy: {
- disable: !state.enableDataExport,
+ policy: {
+ case: "exportDataPolicy",
+ value: create(ExportDataPolicySchema, {
+ disable: !state.enableDataExport,
+ }),
},
},
});
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
index 77176b77d7..4f6f257ddd 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue
@@ -85,7 +85,7 @@ import { emptyIssue } from "@/types";
import { CreateIssueRequestSchema } from "@/types/proto-es/v1/issue_service_pb";
import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
import { Issue, IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { PlanCheckRun_Result_Status } from "@/types/proto/v1/plan_service";
import {
extractProjectResourceName,
@@ -179,7 +179,8 @@ watchEffect(async () => {
parentPath: "",
policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
});
- if (workspaceLevelPolicy?.restrictIssueCreationForSqlReviewPolicy?.disallow) {
+ if (workspaceLevelPolicy?.policy?.case === "restrictIssueCreationForSqlReviewPolicy" &&
+ workspaceLevelPolicy.policy.value.disallow) {
restrictIssueCreationForSqlReviewPolicy.value = true;
return;
}
@@ -189,7 +190,8 @@ watchEffect(async () => {
parentPath: project.value.name,
policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
});
- if (projectLevelPolicy?.restrictIssueCreationForSqlReviewPolicy?.disallow) {
+ if (projectLevelPolicy?.policy?.case === "restrictIssueCreationForSqlReviewPolicy" &&
+ projectLevelPolicy.policy.value.disallow) {
restrictIssueCreationForSqlReviewPolicy.value = true;
return;
}
diff --git a/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue b/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue
index d0f7d453cd..321a13740d 100644
--- a/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue
+++ b/frontend/src/components/PlanCheckRun/PlanCheckRunDetail.vue
@@ -259,7 +259,7 @@ import {
ruleTemplateMapV2,
convertPolicyRuleToRuleTemplate,
} from "@/types";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import {
PlanCheckRun,
PlanCheckRun_Result,
diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vue
index 6421763b9f..4d863932a8 100644
--- a/frontend/src/components/ProvideDashboardContext.vue
+++ b/frontend/src/components/ProvideDashboardContext.vue
@@ -23,7 +23,7 @@ import {
useUIStateStore,
useGroupStore,
} from "@/store";
-import { PolicyResourceType } from "@/types/proto/v1/org_policy_service";
+import { PolicyResourceType } from "@/types/proto-es/v1/org_policy_service_pb";
import MaskSpinner from "./misc/MaskSpinner.vue";
const router = useRouter();
diff --git a/frontend/src/components/ProvideSQLEditorContext.vue b/frontend/src/components/ProvideSQLEditorContext.vue
index 7abe51f196..b7888335a7 100644
--- a/frontend/src/components/ProvideSQLEditorContext.vue
+++ b/frontend/src/components/ProvideSQLEditorContext.vue
@@ -51,7 +51,7 @@ import {
isValidInstanceName,
isValidProjectName,
} from "@/types";
-import { PolicyResourceType } from "@/types/proto/v1/org_policy_service";
+import { PolicyResourceType } from "@/types/proto-es/v1/org_policy_service_pb";
import {
emptySQLEditorConnection,
extractProjectResourceName,
diff --git a/frontend/src/components/SQLCheck/SQLCheckPanel.vue b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
index 95cabac2d3..bd9e4e1e81 100644
--- a/frontend/src/components/SQLCheck/SQLCheckPanel.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
@@ -61,7 +61,7 @@ import { BBModal } from "@/bbkit";
import PlanCheckRunDetail from "@/components/PlanCheckRun/PlanCheckRunDetail.vue";
import { usePolicyV1Store } from "@/store";
import type { ComposedDatabase } from "@/types";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import {
PlanCheckRun,
PlanCheckRun_Result,
@@ -128,7 +128,8 @@ watchEffect(async () => {
parentPath: "",
policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
});
- if (workspaceLevelPolicy?.restrictIssueCreationForSqlReviewPolicy?.disallow) {
+ if (workspaceLevelPolicy?.policy?.case === "restrictIssueCreationForSqlReviewPolicy" &&
+ workspaceLevelPolicy.policy.value.disallow) {
restrictIssueCreationForSqlReviewPolicy.value = true;
return;
}
@@ -138,7 +139,8 @@ watchEffect(async () => {
parentPath: props.project,
policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
});
- if (projectLevelPolicy?.restrictIssueCreationForSqlReviewPolicy?.disallow) {
+ if (projectLevelPolicy?.policy?.case === "restrictIssueCreationForSqlReviewPolicy" &&
+ projectLevelPolicy.policy.value.disallow) {
restrictIssueCreationForSqlReviewPolicy.value = true;
return;
}
diff --git a/frontend/src/components/SQLReview/SQLReviewCreation.vue b/frontend/src/components/SQLReview/SQLReviewCreation.vue
index 42bac0263b..1cce32438b 100644
--- a/frontend/src/components/SQLReview/SQLReviewCreation.vue
+++ b/frontend/src/components/SQLReview/SQLReviewCreation.vue
@@ -72,7 +72,7 @@ import {
TEMPLATE_LIST_V2 as builtInTemplateList,
} from "@/types";
import { Engine } from "@/types/proto-es/v1/common_pb";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import { hasWorkspacePermissionV2, sqlReviewPolicySlug } from "@/utils";
import SQLReviewConfig from "./SQLReviewConfig.vue";
import SQLReviewInfo from "./SQLReviewInfo.vue";
diff --git a/frontend/src/components/SQLReview/components/RuleLevelSwitch.vue b/frontend/src/components/SQLReview/components/RuleLevelSwitch.vue
index d2a6f54e74..06359af529 100644
--- a/frontend/src/components/SQLReview/components/RuleLevelSwitch.vue
+++ b/frontend/src/components/SQLReview/components/RuleLevelSwitch.vue
@@ -15,7 +15,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
const props = withDefaults(
defineProps<{
diff --git a/frontend/src/components/SQLReview/components/SQLReviewLevelFilter.vue b/frontend/src/components/SQLReview/components/SQLReviewLevelFilter.vue
index 0c10707677..cacd1b6b9f 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewLevelFilter.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewLevelFilter.vue
@@ -9,7 +9,7 @@
class="flex items-center gap-x-2 text-sm text-gray-600"
>
<NCheckbox
- :id="sQLReviewRuleLevelToJSON(level)"
+ :id="sqlReviewRuleLevelToString(level)"
:checked="isCheckedLevel(level)"
@update:checked="
(checked) => $emit('toggle-checked-level', level, checked)
@@ -25,8 +25,7 @@
<script lang="ts" setup>
import { NCheckbox } from "naive-ui";
import { computed } from "vue";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
-import { sQLReviewRuleLevelToJSON } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import type { RuleListWithCategory } from "./SQLReviewCategoryTabFilter.vue";
import SQLRuleLevelBadge from "./SQLRuleLevelBadge.vue";
@@ -64,4 +63,20 @@ const errorLevelList = computed(() => {
}
return map;
});
+
+// Helper function to convert SQLReviewRuleLevel to string
+const sqlReviewRuleLevelToString = (level: SQLReviewRuleLevel): string => {
+ switch (level) {
+ case SQLReviewRuleLevel.LEVEL_UNSPECIFIED:
+ return "LEVEL_UNSPECIFIED";
+ case SQLReviewRuleLevel.ERROR:
+ return "ERROR";
+ case SQLReviewRuleLevel.WARNING:
+ return "WARNING";
+ case SQLReviewRuleLevel.DISABLED:
+ return "DISABLED";
+ default:
+ return "UNKNOWN";
+ }
+};
</script>
diff --git a/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue b/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue
index f69ccdccb5..084f924412 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewPolicyDataTable.vue
@@ -20,7 +20,7 @@ import { BBButtonConfirm } from "@/bbkit";
import Resource from "@/components/v2/ResourceOccupiedModal/Resource.vue";
import { pushNotification, useSQLReviewStore } from "@/store";
import type { SQLReviewPolicy } from "@/types";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
import { getHighlightHTMLByRegExp } from "@/utils";
diff --git a/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vue b/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vue
index a9734ec22c..0a272c1690 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewTemplateSelector.vue
@@ -98,7 +98,7 @@ import Resource from "@/components/v2/ResourceOccupiedModal/Resource.vue";
import { useSQLReviewPolicyList } from "@/store";
import type { SQLReviewPolicyTemplateV2 } from "@/types";
import { TEMPLATE_LIST_V2 as builtInTemplateList } from "@/types";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import { rulesToTemplate } from "./utils";
const props = withDefaults(
diff --git a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue
index cf3367ba53..409a419d19 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleEditDialog.vue
@@ -93,7 +93,7 @@ import { nextTick, reactive, watch, ref } from "vue";
import { BBModal, BBTextField } from "@/bbkit";
import { payloadValueListToComponentList } from "@/components/SQLReview/components";
import { RichEngineName } from "@/components/v2";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import type { RuleTemplateV2 } from "@/types/sqlReview";
import { getRuleLocalization } from "@/types/sqlReview";
import RuleConfig from "./RuleConfigComponents/RuleConfig.vue";
diff --git a/frontend/src/components/SQLReview/components/SQLRuleFilter.vue b/frontend/src/components/SQLReview/components/SQLRuleFilter.vue
index ab4b5857a5..d76f086c5c 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleFilter.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleFilter.vue
@@ -54,7 +54,7 @@ import { NCheckbox, NDivider } from "naive-ui";
import { SearchBox } from "@/components/v2";
import type { RuleTemplateV2 } from "@/types";
import { getRuleLocalization } from "@/types";
-import type { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import type { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import SQLReviewCategoryTabFilter from "./SQLReviewCategoryTabFilter.vue";
import type { RuleListWithCategory } from "./SQLReviewCategoryTabFilter.vue";
import SQLReviewLevelFilter from "./SQLReviewLevelFilter.vue";
diff --git a/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue b/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue
index 0b21a4f5b1..5cf5065c20 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue
@@ -12,10 +12,7 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { BBBadge } from "@/bbkit";
import type { BBBadgeStyle } from "@/bbkit/BBBadge.vue";
-import {
- SQLReviewRuleLevel,
- sQLReviewRuleLevelToJSON,
-} from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
const props = withDefaults(
defineProps<{
@@ -40,10 +37,26 @@ const style = computed((): BBBadgeStyle => {
}
});
+// Helper function to convert SQLReviewRuleLevel to string
+const sqlReviewRuleLevelToString = (level: SQLReviewRuleLevel): string => {
+ switch (level) {
+ case SQLReviewRuleLevel.LEVEL_UNSPECIFIED:
+ return "LEVEL_UNSPECIFIED";
+ case SQLReviewRuleLevel.ERROR:
+ return "ERROR";
+ case SQLReviewRuleLevel.WARNING:
+ return "WARNING";
+ case SQLReviewRuleLevel.DISABLED:
+ return "DISABLED";
+ default:
+ return "UNKNOWN";
+ }
+};
+
const text = computed(() => {
const { level, suffix } = props;
const parts = [
- t(`sql-review.level.${sQLReviewRuleLevelToJSON(level).toLowerCase()}`),
+ t(`sql-review.level.${sqlReviewRuleLevelToString(level).toLowerCase()}`),
];
if (suffix) {
parts.push(suffix);
diff --git a/frontend/src/components/SQLReview/components/SQLRuleTable.vue b/frontend/src/components/SQLReview/components/SQLRuleTable.vue
index eafb72370a..da0b63ae95 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleTable.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleTable.vue
@@ -136,7 +136,7 @@ import {
getRuleLocalization,
ruleIsAvailableInSubscription,
} from "@/types";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import RuleConfig from "./RuleConfigComponents/RuleConfig.vue";
import RuleLevelSwitch from "./RuleLevelSwitch.vue";
import type { RuleListWithCategory } from "./SQLReviewCategoryTabFilter.vue";
diff --git a/frontend/src/components/SQLReview/components/useSQLRuleFilter.ts b/frontend/src/components/SQLReview/components/useSQLRuleFilter.ts
index f2d58de9e7..9a3faa8423 100644
--- a/frontend/src/components/SQLReview/components/useSQLRuleFilter.ts
+++ b/frontend/src/components/SQLReview/components/useSQLRuleFilter.ts
@@ -1,6 +1,6 @@
import { reactive } from "vue";
import { useRoute } from "vue-router";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
export type SQLRuleFilterParams = {
checkedLevel: Set<SQLReviewRuleLevel>;
diff --git a/frontend/src/components/SQLReview/components/utils.ts b/frontend/src/components/SQLReview/components/utils.ts
index 033c816e66..6a8f884891 100644
--- a/frontend/src/components/SQLReview/components/utils.ts
+++ b/frontend/src/components/SQLReview/components/utils.ts
@@ -4,7 +4,7 @@ import type {
SQLReviewPolicy,
} from "@/types";
import { convertPolicyRuleToRuleTemplate, ruleTemplateMapV2 } from "@/types";
-import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import type { PayloadValueType } from "./RuleConfigComponents";
export const getRuleKey = (rule: RuleTemplateV2) =>
diff --git a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
index 45c8fb88e7..a1a2ae38a2 100644
--- a/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
+++ b/frontend/src/components/SensitiveData/GlobalMaskingRulesView.vue
@@ -137,12 +137,14 @@ import {
useProjectV1Store,
useInstanceV1Store,
} from "@/store";
-import type { Policy } from "@/types/proto/v1/org_policy_service";
+import { create } from "@bufbuild/protobuf";
+import type { Policy } from "@/types/proto-es/v1/org_policy_service_pb";
+import type { MaskingRulePolicy_MaskingRule } from "@/types/proto-es/v1/org_policy_service_pb";
+import { MaskingRulePolicySchema, MaskingRulePolicy_MaskingRuleSchema } from "@/types/proto-es/v1/org_policy_service_pb";
import {
PolicyType,
PolicyResourceType,
- MaskingRulePolicy_MaskingRule,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import {
arraySwap,
@@ -200,14 +202,16 @@ const updateList = async () => {
return;
}
- state.maskingRuleItemList = (policy.maskingRulePolicy?.rules ?? []).map(
- (rule) => {
- return {
- mode: "NORMAL",
- rule,
- };
- }
- );
+ state.maskingRuleItemList = (
+ policy.policy?.case === "maskingRulePolicy"
+ ? policy.policy.value.rules
+ : []
+ ).map((rule) => {
+ return {
+ mode: "NORMAL",
+ rule,
+ };
+ });
};
onMounted(async () => {
@@ -217,7 +221,7 @@ onMounted(async () => {
const addNewRule = () => {
state.maskingRuleItemList.push({
mode: "CREATE",
- rule: MaskingRulePolicy_MaskingRule.fromPartial({
+ rule: create(MaskingRulePolicy_MaskingRuleSchema, {
id: uuidv4(),
}),
});
@@ -318,10 +322,13 @@ const onPolicyUpsert = async () => {
const patch: Partial<Policy> = {
type: PolicyType.MASKING_RULE,
resourceType: PolicyResourceType.WORKSPACE,
- maskingRulePolicy: {
- rules: state.maskingRuleItemList
- .filter((item) => item.mode === "NORMAL")
- .map((item) => item.rule),
+ policy: {
+ case: "maskingRulePolicy",
+ value: create(MaskingRulePolicySchema, {
+ rules: state.maskingRuleItemList
+ .filter((item) => item.mode === "NORMAL")
+ .map((item) => item.rule),
+ }),
},
};
diff --git a/frontend/src/components/SensitiveData/GrantAccessForm.vue b/frontend/src/components/SensitiveData/GrantAccessForm.vue
index 889b6b97a3..54502598fc 100644
--- a/frontend/src/components/SensitiveData/GrantAccessForm.vue
+++ b/frontend/src/components/SensitiveData/GrantAccessForm.vue
@@ -33,9 +33,7 @@
>
{{
$t(
- `settings.sensitive-data.action.${maskingExceptionPolicy_MaskingException_ActionToJSON(
- action
- ).toLowerCase()}`
+ `settings.sensitive-data.action.${MaskingExceptionPolicy_MaskingException_Action[action].toLowerCase()}`
)
}}
</NCheckbox>
@@ -108,17 +106,19 @@ import MembersBindingSelect from "@/components/Member/MembersBindingSelect.vue";
import FormLayout from "@/components/v2/Form/FormLayout.vue";
import { usePolicyV1Store, pushNotification } from "@/store";
import type { DatabaseResource } from "@/types";
-import { Expr } from "@/types/proto/google/type/expr";
+import { create } from "@bufbuild/protobuf";
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
import type {
Policy,
MaskingExceptionPolicy_MaskingException,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import {
PolicyType,
PolicyResourceType,
MaskingExceptionPolicy_MaskingException_Action,
- maskingExceptionPolicy_MaskingException_ActionToJSON,
-} from "@/types/proto/v1/org_policy_service";
+ MaskingExceptionPolicySchema,
+ MaskingExceptionPolicy_MaskingExceptionSchema,
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import type { SensitiveColumn } from "./types";
import {
@@ -233,17 +233,19 @@ const getPendingUpdatePolicy = async (
const resourceExpression = [...expressionList, ...expressions].filter(
(e) => e
);
- maskingExceptions.push({
- member,
- action,
- condition: Expr.fromPartial({
- description: state.description,
- expression:
- resourceExpression.length > 0
- ? resourceExpression.join(" && ")
- : undefined,
- }),
- });
+ maskingExceptions.push(
+ create(MaskingExceptionPolicy_MaskingExceptionSchema, {
+ member,
+ action,
+ condition: create(ExprSchema, {
+ description: state.description,
+ expression:
+ resourceExpression.length > 0
+ ? resourceExpression.join(" && ")
+ : "",
+ }),
+ })
+ );
}
}
}
@@ -252,13 +254,19 @@ const getPendingUpdatePolicy = async (
parentPath,
policyType: PolicyType.MASKING_EXCEPTION,
});
- const existed = policy?.maskingExceptionPolicy?.maskingExceptions ?? [];
+ const existed =
+ policy?.policy?.case === "maskingExceptionPolicy"
+ ? policy.policy.value.maskingExceptions
+ : [];
return {
name: policy?.name,
type: PolicyType.MASKING_EXCEPTION,
resourceType: PolicyResourceType.PROJECT,
- maskingExceptionPolicy: {
- maskingExceptions: [...existed, ...maskingExceptions],
+ policy: {
+ case: "maskingExceptionPolicy",
+ value: create(MaskingExceptionPolicySchema, {
+ maskingExceptions: [...existed, ...maskingExceptions],
+ }),
},
};
};
diff --git a/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue b/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
index aca06e1047..6f68d01a9e 100644
--- a/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
+++ b/frontend/src/components/SensitiveData/MaskingExceptionUserTable.vue
@@ -48,10 +48,12 @@ import {
isValidDatabaseName,
type ComposedProject,
} from "@/types";
-import { Expr } from "@/types/proto/google/type/expr";
-import { MaskingExceptionPolicy_MaskingException_Action } from "@/types/proto/v1/org_policy_service";
-import type { MaskingExceptionPolicy_MaskingException } from "@/types/proto/v1/org_policy_service";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { create } from "@bufbuild/protobuf";
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
+import { MaskingExceptionPolicy_MaskingException_Action } from "@/types/proto-es/v1/org_policy_service_pb";
+import type { MaskingExceptionPolicy_MaskingException } from "@/types/proto-es/v1/org_policy_service_pb";
+import { MaskingExceptionPolicySchema } from "@/types/proto-es/v1/org_policy_service_pb";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { autoDatabaseRoute, hasProjectPermissionV2 } from "@/utils";
import {
type ConditionExpression,
@@ -233,7 +235,7 @@ const updateAccessUserList = async () => {
return;
}
- if (!policy.value || !policy.value.maskingExceptionPolicy) {
+ if (!policy.value || policy.value.policy?.case !== "maskingExceptionPolicy") {
state.rawAccessList = [];
state.loading = false;
return;
@@ -251,7 +253,7 @@ const updateAccessUserList = async () => {
// - 2 cannot merge: user1, action:export, level:FULL, expires at 2023-09-04
// - 3 & 4 is merged: user1, action:export+action, level:PARTIAL, expires at 2023-09-04
const memberMap = new Map<string, AccessUser>();
- const { maskingExceptions } = policy.value.maskingExceptionPolicy;
+ const { maskingExceptions } = policy.value.policy.value;
const expressionList = maskingExceptions.map((e) =>
e.condition?.expression ? e.condition?.expression : "true"
);
@@ -577,7 +579,7 @@ const updateExceptionPolicy = async () => {
exceptions.push({
action,
member,
- condition: Expr.fromPartial({
+ condition: create(ExprSchema, {
description: accessUser.description,
expression: expressions.join(" && "),
}),
@@ -585,9 +587,11 @@ const updateExceptionPolicy = async () => {
}
}
- policy.maskingExceptionPolicy = {
- ...(policy.maskingExceptionPolicy ?? {}),
- maskingExceptions: exceptions,
+ policy.policy = {
+ case: "maskingExceptionPolicy",
+ value: create(MaskingExceptionPolicySchema, {
+ maskingExceptions: exceptions,
+ }),
};
await policyStore.upsertPolicy({
parentPath: props.project.name,
diff --git a/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue b/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue
index 7191bb4f48..de346b279a 100644
--- a/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingActionDropdown.vue
@@ -14,10 +14,7 @@ import type { SelectOption } from "naive-ui";
import { NSelect } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import {
- type MaskingExceptionPolicy_MaskingException_Action as Action,
- maskingExceptionPolicy_MaskingException_ActionToJSON as actionToJSON,
-} from "@/types/proto/v1/org_policy_service";
+import { MaskingExceptionPolicy_MaskingException_Action as Action } from "@/types/proto-es/v1/org_policy_service_pb";
const props = defineProps<{
disabled?: boolean;
@@ -32,10 +29,24 @@ defineEmits<{
const { t } = useI18n();
+// Helper function to convert Action enum to string
+const actionToString = (action: Action): string => {
+ switch (action) {
+ case Action.ACTION_UNSPECIFIED:
+ return "ACTION_UNSPECIFIED";
+ case Action.QUERY:
+ return "QUERY";
+ case Action.EXPORT:
+ return "EXPORT";
+ default:
+ return "UNKNOWN";
+ }
+};
+
const options = computed(() => {
return props.actionList.map<SelectOption>((action) => ({
label: t(
- `settings.sensitive-data.action.${actionToJSON(action).toLowerCase()}`
+ `settings.sensitive-data.action.${actionToString(action).toLowerCase()}`
),
value: action,
}));
diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
index 2cdcbaabd9..9d2ef61eec 100644
--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
@@ -100,7 +100,7 @@ import {
emptySimpleExpr,
} from "@/plugins/cel";
import { useSettingV1Store } from "@/store";
-import type { MaskingRulePolicy_MaskingRule } from "@/types/proto/v1/org_policy_service";
+import type { MaskingRulePolicy_MaskingRule } from "@/types/proto-es/v1/org_policy_service_pb";
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";
import {
@@ -108,6 +108,8 @@ import {
batchConvertParsedExprToCELString,
} from "@/utils";
import { factorSupportDropdown, factorOperatorOverrideMap } from "./utils";
+import { create } from "@bufbuild/protobuf";
+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";
export interface SemanticTypeSelectOption extends SelectOption {
value: string;
@@ -220,12 +222,12 @@ const onConfirm = async () => {
emit("confirm", {
...props.maskingRule,
semanticType: state.semanticType!,
- condition: {
+ condition: create(ExprSchema, {
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 83fb0da4aa..05c401f869 100644
--- a/frontend/src/components/SensitiveData/types.ts
+++ b/frontend/src/components/SensitiveData/types.ts
@@ -5,8 +5,8 @@ import type {
ObjectSchema,
} from "@/types/proto-es/v1/database_catalog_service_pb";
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";
+import type { MaskingExceptionPolicy_MaskingException_Action } from "@/types/proto-es/v1/org_policy_service_pb";
+import type { User } from "@/types/proto/v1/user_service";
export interface MaskData {
schema: string;
diff --git a/frontend/src/components/SensitiveData/utils.ts b/frontend/src/components/SensitiveData/utils.ts
index edbd4e2fa1..0038d93939 100644
--- a/frontend/src/components/SensitiveData/utils.ts
+++ b/frontend/src/components/SensitiveData/utils.ts
@@ -1,6 +1,6 @@
import type { MaskData } from "@/components/SensitiveData/types";
import type { DatabaseResource } from "@/types";
-import type { MaskingExceptionPolicy_MaskingException } from "@/types/proto/v1/org_policy_service";
+import type { MaskingExceptionPolicy_MaskingException } from "@/types/proto-es/v1/org_policy_service_pb";
import { extractDatabaseResourceName } from "@/utils";
import type { SensitiveColumn } from "./types";
diff --git a/frontend/src/components/User/Settings/RemoveGroupButton.vue b/frontend/src/components/User/Settings/RemoveGroupButton.vue
index d5c9966287..b10183dc79 100644
--- a/frontend/src/components/User/Settings/RemoveGroupButton.vue
+++ b/frontend/src/components/User/Settings/RemoveGroupButton.vue
@@ -39,7 +39,7 @@ import {
import { extractUserId } from "@/store/modules/v1/common";
import { getGroupEmailInBinding } from "@/types";
import { type Group, GroupMember_Role } from "@/types/proto-es/v1/group_service_pb";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
const props = defineProps<{
@@ -92,8 +92,11 @@ const resourcesOccupied = computedAsync(async () => {
policyType: PolicyType.MASKING_EXCEPTION,
});
- for (const exception of policy?.maskingExceptionPolicy?.maskingExceptions ??
- []) {
+ const exceptions =
+ policy?.policy?.case === "maskingExceptionPolicy"
+ ? policy.policy.value.maskingExceptions
+ : [];
+ for (const exception of exceptions) {
if (exception.member === member) {
resources.add(project.name);
break;
diff --git a/frontend/src/layouts/SQLEditorLayout.vue b/frontend/src/layouts/SQLEditorLayout.vue
index f58b93f01c..7b0be7453c 100644
--- a/frontend/src/layouts/SQLEditorLayout.vue
+++ b/frontend/src/layouts/SQLEditorLayout.vue
@@ -27,7 +27,7 @@ import {
useRoleStore,
useSettingV1Store,
} from "@/store";
-import { PolicyResourceType } from "@/types/proto/v1/org_policy_service";
+import { PolicyResourceType } from "@/types/proto-es/v1/org_policy_service_pb";
import { provideSheetContext } from "@/views/sql-editor/Sheet";
import { provideSQLEditorContext } from "@/views/sql-editor/context";
diff --git a/frontend/src/plugins/i18n.test.ts b/frontend/src/plugins/i18n.test.ts
index fbeef4b902..5338906e7f 100644
--- a/frontend/src/plugins/i18n.test.ts
+++ b/frontend/src/plugins/i18n.test.ts
@@ -1,7 +1,8 @@
import { describe, expect, test } from "vitest";
-import { sQLReviewRuleLevelToJSON } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
import { TEMPLATE_LIST_V2, getRuleLocalizationKey } from "../types/sqlReview";
import { mergedLocalMessage } from "./i18n-messages";
+import { Engine } from "@/types/proto-es/v1/common_pb";
describe("Test i18n messages", () => {
for (const keyA of Object.keys(mergedLocalMessage)) {
@@ -46,28 +47,31 @@ describe("Test i18n for SQL review", () => {
for (const rule of template.ruleList) {
test(`check i18n for rule ${rule.type}`, () => {
const key = getRuleLocalizationKey(rule.type);
- expect(!!i18nForSQLReview["rule"][key]).toBe(true);
- expect(!!i18nForSQLReview["rule"][key]["title"]).toBe(true);
- expect(!!i18nForSQLReview["rule"][key]["description"]).toBe(true);
+ expect(!!i18nForSQLReview["rule"][key], "rule-key").toBe(true);
+ expect(!!i18nForSQLReview["rule"][key]["title"], "rule-key-title").toBe(true);
+ expect(!!i18nForSQLReview["rule"][key]["description"], "rule-key-description").toBe(true);
expect(
- !!i18nForSQLReview["category"][rule.category.toLowerCase()]
+ !!i18nForSQLReview["category"][rule.category.toLowerCase()],
+ "category-rule.category"
).toBe(true);
expect(
!!i18nForSQLReview["level"][
- sQLReviewRuleLevelToJSON(rule.level).toLowerCase()
- ]
+ sqlReviewRuleLevelToString(rule.level).toLowerCase()
+ ],
+ 'level-rule.level'
).toBe(true);
expect(
!!i18nForSQLReview["engine"][
- String(rule.engine).toLowerCase()
- ]
+ Engine[rule.engine].toLowerCase()
+ ],
+ 'engine.rule-engine'
).toBe(true);
for (const component of rule.componentList) {
- expect(!!i18nForSQLReview["rule"][key]["component"]).toBe(true);
+ expect(!!i18nForSQLReview["rule"][key]["component"], 'rule-key-component').toBe(true);
expect(
- !!i18nForSQLReview["rule"][key]["component"][component.key]
+ !!i18nForSQLReview["rule"][key]["component"][component.key], 'rule-key-component-component.key'
).toBe(true);
}
});
@@ -76,6 +80,22 @@ describe("Test i18n for SQL review", () => {
}
});
+// Helper function to convert SQLReviewRuleLevel to string
+const sqlReviewRuleLevelToString = (level: SQLReviewRuleLevel): string => {
+ switch (level) {
+ case SQLReviewRuleLevel.LEVEL_UNSPECIFIED:
+ return "LEVEL_UNSPECIFIED";
+ case SQLReviewRuleLevel.ERROR:
+ return "ERROR";
+ case SQLReviewRuleLevel.WARNING:
+ return "WARNING";
+ case SQLReviewRuleLevel.DISABLED:
+ return "DISABLED";
+ default:
+ return "UNKNOWN";
+ }
+};
+
const compareMessages = (
localA: { [k: string]: any },
localB: { [k: string]: any }
diff --git a/frontend/src/store/modules/sqlReview.ts b/frontend/src/store/modules/sqlReview.ts
index 39ee5f2da7..aa05750653 100644
--- a/frontend/src/store/modules/sqlReview.ts
+++ b/frontend/src/store/modules/sqlReview.ts
@@ -20,8 +20,8 @@ import {
} from "@/types/proto-es/v1/review_config_service_pb";
import {
PolicyType,
- policyTypeToJSON,
-} from "@/types/proto/v1/org_policy_service";
+ TagPolicySchema,
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { ReviewConfig } from "@/types/proto/v1/review_config_service";
import {
convertNewReviewConfigToOld,
@@ -29,6 +29,7 @@ import {
} from "@/utils/v1/review-config-conversions";
import { usePolicyV1Store } from "./v1/policy";
import { convertEngineToNew, convertEngineToOld } from "@/utils/v1/common-conversions";
+import { convertOldSQLReviewRuleLevelToNew, convertNewSQLReviewRuleLevelToOld } from "@/utils/v1/org-policy-conversions";
const reviewConfigTagName = "bb.tag.review_config";
@@ -44,10 +45,13 @@ const upsertReviewConfigTag = async (
policy: {
name: getTagPolicyName(resourcePath),
type: PolicyType.TAG,
- tagPolicy: {
- tags: {
- [reviewConfigTagName]: configName,
- },
+ policy: {
+ case: "tagPolicy",
+ value: create(TagPolicySchema, {
+ tags: {
+ [reviewConfigTagName]: configName,
+ },
+ }),
},
},
});
@@ -71,7 +75,7 @@ const convertToSQLReviewPolicy = (
for (const r of reviewConfig.rules) {
const rule: SchemaPolicyRule = {
type: r.type,
- level: r.level,
+ level: convertOldSQLReviewRuleLevelToNew(r.level),
engine: convertEngineToNew(r.engine),
comment: r.comment,
};
@@ -95,9 +99,7 @@ interface SQLReviewState {
}
const getTagPolicyName = (environmentPath: string): string => {
- return `${environmentPath}/${policyNamePrefix}${policyTypeToJSON(
- PolicyType.TAG
- ).toLowerCase()}`;
+ return `${environmentPath}/${policyNamePrefix}tag`;
};
export const useSQLReviewStore = defineStore("sqlReview", {
@@ -198,7 +200,7 @@ export const useSQLReviewStore = defineStore("sqlReview", {
patch.rules = ruleList.map((r) => {
return {
type: r.type as string,
- level: r.level,
+ level: convertNewSQLReviewRuleLevelToOld(r.level),
engine: convertEngineToOld(r.engine),
comment: r.comment,
payload: r.payload ? JSON.stringify(r.payload) : "{}",
@@ -307,7 +309,9 @@ export const useSQLReviewStore = defineStore("sqlReview", {
if (!policy) {
return;
}
- const sqlReviewName = policy.tagPolicy?.tags[reviewConfigTagName];
+ const sqlReviewName = policy.policy?.case === "tagPolicy"
+ ? policy.policy.value.tags[reviewConfigTagName]
+ : undefined;
if (!sqlReviewName) {
return;
}
diff --git a/frontend/src/store/modules/v1/policy.ts b/frontend/src/store/modules/v1/policy.ts
index 36dacfe4f4..c988fb1178 100644
--- a/frontend/src/store/modules/v1/policy.ts
+++ b/frontend/src/store/modules/v1/policy.ts
@@ -6,27 +6,23 @@ import { silentContextKey } from "@/grpcweb/context-key";
import { policyNamePrefix } from "@/store/modules/v1/common";
import type { MaybeRef } from "@/types";
import { UNKNOWN_USER_NAME } from "@/types";
-import { Policy, PolicyResourceType, PolicyType, policyTypeToJSON } from "@/types/proto/v1/org_policy_service";
-import type { Policy as NewPolicy } from "@/types/proto-es/v1/org_policy_service_pb";
+import type { Policy } from "@/types/proto-es/v1/org_policy_service_pb";
import {
+ PolicyResourceType,
+ PolicyType,
GetPolicyRequestSchema,
ListPoliciesRequestSchema,
PolicySchema,
UpdatePolicyRequestSchema,
DeletePolicyRequestSchema,
+ RolloutPolicySchema,
} from "@/types/proto-es/v1/org_policy_service_pb";
-import {
- convertNewPolicyToOld,
- convertOldPolicyToNew,
- convertOldPolicyTypeToNew,
- convertOldPolicyResourceTypeToNew,
-} from "@/utils/v1/org-policy-conversions";
import { defineStore } from "pinia";
import { computed, ref, unref, watchEffect } from "vue";
import { useCurrentUserV1 } from "./auth";
interface PolicyState {
- policyMapByName: Map<string, NewPolicy>;
+ policyMapByName: Map<string, Policy>;
}
const replacePolicyTypeNameToLowerCase = (name: string) => {
@@ -62,7 +58,7 @@ export const usePolicyV1Store = defineStore("policy_v1", {
}),
getters: {
policyList(state) {
- return Array.from(state.policyMapByName.values()).map(convertNewPolicyToOld);
+ return Array.from(state.policyMapByName.values());
},
},
actions: {
@@ -79,7 +75,7 @@ export const usePolicyV1Store = defineStore("policy_v1", {
}) {
const request = create(ListPoliciesRequestSchema, {
parent: parent ?? getPolicyParentByResourceType(resourceType),
- policyType: policyType ? convertOldPolicyTypeToNew(policyType) : undefined,
+ policyType: policyType,
showDeleted,
});
const response = await orgPolicyServiceClientConnect.listPolicies(request);
@@ -87,7 +83,7 @@ export const usePolicyV1Store = defineStore("policy_v1", {
for (const policy of policies) {
this.policyMapByName.set(policy.name, policy);
}
- return policies.map(convertNewPolicyToOld);
+ return policies;
},
getPolicies({
resourceType,
@@ -99,16 +95,14 @@ export const usePolicyV1Store = defineStore("policy_v1", {
showDeleted?: boolean;
}) {
const response: Policy[] = [];
- const newResourceType = convertOldPolicyResourceTypeToNew(resourceType);
- const newPolicyType = convertOldPolicyTypeToNew(policyType);
for (const [_, policy] of this.policyMapByName) {
- if (policy.resourceType != newResourceType || policy.type != newPolicyType) {
+ if (policy.resourceType != resourceType || policy.type != policyType) {
continue;
}
if (!showDeleted && !policy.enforce) {
continue;
}
- response.push(convertNewPolicyToOld(policy));
+ response.push(policy);
}
return response;
},
@@ -122,7 +116,7 @@ export const usePolicyV1Store = defineStore("policy_v1", {
refresh?: boolean;
}) {
const name = replacePolicyTypeNameToLowerCase(
- `${parentPath}/${policyNamePrefix}${policyTypeToJSON(policyType)}`
+ `${parentPath}/${policyNamePrefix}${PolicyType[policyType]}`
);
return this.getOrFetchPolicyByName(name, refresh);
},
@@ -139,7 +133,7 @@ export const usePolicyV1Store = defineStore("policy_v1", {
contextValues: createContextValues().set(silentContextKey, true)
});
this.policyMapByName.set(policy.name, policy);
- return convertNewPolicyToOld(policy);
+ return policy;
} catch (error) {
if (error instanceof ConnectError && error.code === Code.NotFound) {
// To prevent unnecessary requests, cache empty policies if not found.
@@ -156,13 +150,13 @@ export const usePolicyV1Store = defineStore("policy_v1", {
policyType: PolicyType;
}) {
const name = replacePolicyTypeNameToLowerCase(
- `${parentPath}/${policyNamePrefix}${policyTypeToJSON(policyType)}`
+ `${parentPath}/${policyNamePrefix}${PolicyType[policyType]}`
);
return this.getPolicyByName(name);
},
getPolicyByName(name: string) {
const policy = this.policyMapByName.get(replacePolicyTypeNameToLowerCase(name));
- return policy ? convertNewPolicyToOld(policy) : undefined;
+ return policy;
},
async upsertPolicy({
parentPath,
@@ -174,20 +168,25 @@ export const usePolicyV1Store = defineStore("policy_v1", {
if (!policy.type) {
throw new Error("policy type is required");
}
- policy.name = replacePolicyTypeNameToLowerCase(
- `${parentPath}/${policyNamePrefix}${policyTypeToJSON(policy.type)}`
+ const policyName = replacePolicyTypeNameToLowerCase(
+ `${parentPath}/${policyNamePrefix}${PolicyType[policy.type]}`
);
- const fullPolicy = Policy.fromPartial(policy);
- const newPolicy = convertOldPolicyToNew(fullPolicy);
+ const fullPolicy = create(PolicySchema, {
+ name: policyName,
+ inheritFromParent: policy.inheritFromParent ?? false,
+ type: policy.type,
+ resourceType: policy.resourceType ?? PolicyResourceType.RESOURCE_TYPE_UNSPECIFIED,
+ enforce: policy.enforce ?? false,
+ policy: policy.policy,
+ });
const request = create(UpdatePolicyRequestSchema, {
- policy: newPolicy,
+ policy: fullPolicy,
updateMask: { paths: ["payload"] },
allowMissing: true,
});
const response = await orgPolicyServiceClientConnect.updatePolicy(request);
- const updatedPolicy = convertNewPolicyToOld(response);
this.policyMapByName.set(response.name, response);
- return updatedPolicy;
+ return response;
},
async deletePolicy(name: string) {
const request = create(DeletePolicyRequestSchema, { name });
@@ -243,7 +242,7 @@ export const usePolicyByParentAndType = (
const policy = computed(() => {
const { parentPath, policyType } = unref(params);
const name = replacePolicyTypeNameToLowerCase(
- `${parentPath}/${policyNamePrefix}${policyTypeToJSON(policyType)}`
+ `${parentPath}/${policyNamePrefix}${PolicyType[policyType]}`
);
const res = store.getPolicyByName(name);
return res;
@@ -261,20 +260,21 @@ export const getEmptyRolloutPolicy = (
resourceType: PolicyResourceType
): Policy => {
const name = replacePolicyTypeNameToLowerCase(
- `${parentPath}/${policyNamePrefix}${policyTypeToJSON(
- PolicyType.ROLLOUT_POLICY
- )}`
+ `${parentPath}/${policyNamePrefix}${PolicyType[PolicyType.ROLLOUT_POLICY]}`
);
- return Policy.fromPartial({
+ return create(PolicySchema, {
name,
inheritFromParent: false,
type: PolicyType.ROLLOUT_POLICY,
resourceType,
enforce: true,
- rolloutPolicy: {
- automatic: false,
- roles: [],
- issueRoles: [],
+ policy: {
+ case: "rolloutPolicy",
+ value: create(RolloutPolicySchema, {
+ automatic: false,
+ roles: [],
+ issueRoles: [],
+ }),
},
});
};
diff --git a/frontend/src/types/sqlReview.ts b/frontend/src/types/sqlReview.ts
index e8f2b47d3c..bcfde4d335 100644
--- a/frontend/src/types/sqlReview.ts
+++ b/frontend/src/types/sqlReview.ts
@@ -1,10 +1,9 @@
import { t, te } from "@/plugins/i18n";
-import type { Engine } from "@/types/proto-es/v1/common_pb";
+import { Engine } from "@/types/proto-es/v1/common_pb";
import { engineToString } from "@/utils/v1/common-conversions";
import {
SQLReviewRuleLevel,
- sQLReviewRuleLevelFromJSON,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import type { PlanType } from "@/types/proto-es/v1/subscription_service_pb";
import sqlReviewSchema from "./sql-review-schema.yaml";
import sqlReviewDevTemplate from "./sql-review.dev.yaml";
@@ -133,6 +132,17 @@ export interface SQLReviewPolicy {
resources: string[];
}
+// engine and level are enum strings.
+// we need to convert them first.
+interface RuleTemplateV2Raw {
+ type: string;
+ category: string;
+ engine: string; // keyof typeof Engine
+ level: string; // keyof typeof SQLReviewRuleLevel
+ componentList: RuleConfigComponent[];
+ comment?: string;
+}
+
// RuleTemplateV2 is the rule template. Used by the frontend
export interface RuleTemplateV2 {
type: string;
@@ -165,10 +175,30 @@ export const getRuleMapByEngine = (
});
return map;
}, new Map<Engine, Map<string, RuleTemplateV2>>());
-};;
+};
+
+const convertRuleTemplateV2Raw = (sqlReviewSchema: RuleTemplateV2Raw[]): RuleTemplateV2[] => {
+ return sqlReviewSchema.map((rawRule) => {
+ // Convert engine string key to enum value
+ const engineKey = rawRule.engine as keyof typeof Engine;
+ const engine = Engine[engineKey] ?? Engine.ENGINE_UNSPECIFIED;
+
+ // Convert level string key to enum value
+ const levelKey = rawRule.level as keyof typeof SQLReviewRuleLevel;
+ const level = SQLReviewRuleLevel[levelKey] ?? SQLReviewRuleLevel.DISABLED;
+
+ return {
+ ...rawRule,
+ engine,
+ level,
+ };
+ });
+}
export const ruleTemplateMapV2 = getRuleMapByEngine(
- sqlReviewSchema as RuleTemplateV2[]
+ convertRuleTemplateV2Raw(
+ sqlReviewSchema as RuleTemplateV2Raw[]
+ )
);
// Build the frontend template list based on schema and template.
@@ -184,9 +214,9 @@ export const TEMPLATE_LIST_V2: SQLReviewPolicyTemplateV2[] = (function () {
id: string;
ruleList: {
type: string;
- level: SQLReviewRuleLevel;
+ level: string; // keyof typeof SQLReviewRuleLevel
payload?: PayloadObject;
- engine: Engine;
+ engine: string; // keyof typeof Engine
}[];
}[];
@@ -194,16 +224,24 @@ export const TEMPLATE_LIST_V2: SQLReviewPolicyTemplateV2[] = (function () {
const ruleList: RuleTemplateV2[] = [];
for (const rule of template.ruleList) {
+ // Convert engine string to enum for map lookup
+ const engineKey = rule.engine as keyof typeof Engine;
+ const engine = Engine[engineKey] ?? Engine.ENGINE_UNSPECIFIED;
+
const ruleTemplate = ruleTemplateMapV2
- .get(rule.engine) // Engine is already numeric
+ .get(engine)
?.get(rule.type);
if (!ruleTemplate) {
continue;
}
+ // Convert level string to enum
+ const levelKey = rule.level as keyof typeof SQLReviewRuleLevel;
+ const level = SQLReviewRuleLevel[levelKey] ?? SQLReviewRuleLevel.DISABLED;
+
ruleList.push({
...ruleTemplate,
- level: sQLReviewRuleLevelFromJSON(rule.level),
+ level,
// Using template rule payload to override the component list.
componentList: ruleTemplate.componentList.map((component) => {
if (rule.payload && rule.payload[component.key]) {
diff --git a/frontend/src/utils/sqlEditor.ts b/frontend/src/utils/sqlEditor.ts
index 4e7b1daacb..f6a9cee675 100644
--- a/frontend/src/utils/sqlEditor.ts
+++ b/frontend/src/utils/sqlEditor.ts
@@ -27,7 +27,7 @@ import {
import {
DataSourceQueryPolicy_Restriction,
PolicyType,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { instanceV1AllowsCrossDatabaseQuery } from "./v1/instance";
export const defaultSQLEditorTab = (): SQLEditorTab => {
@@ -178,13 +178,17 @@ export const getAdminDataSourceRestrictionOfDatabase = (
policyType: PolicyType.DATA_SOURCE_QUERY,
});
const projectLevelAdminDSRestriction =
- projectLevelPolicy?.dataSourceQueryPolicy?.adminDataSourceRestriction;
+ projectLevelPolicy?.policy?.case === "dataSourceQueryPolicy"
+ ? projectLevelPolicy.policy.value.adminDataSourceRestriction
+ : undefined;
const envLevelPolicy = policyStore.getPolicyByParentAndType({
parentPath: database.effectiveEnvironment,
policyType: PolicyType.DATA_SOURCE_QUERY,
});
const envLevelAdminDSRestriction =
- envLevelPolicy?.dataSourceQueryPolicy?.adminDataSourceRestriction;
+ envLevelPolicy?.policy?.case === "dataSourceQueryPolicy"
+ ? envLevelPolicy.policy.value.adminDataSourceRestriction
+ : undefined;
return {
environmentPolicy:
envLevelAdminDSRestriction ??
diff --git a/frontend/src/utils/v1/org-policy-conversions.ts b/frontend/src/utils/v1/org-policy-conversions.ts
index 2b8160e011..3cb7203716 100644
--- a/frontend/src/utils/v1/org-policy-conversions.ts
+++ b/frontend/src/utils/v1/org-policy-conversions.ts
@@ -7,6 +7,8 @@ import { PolicyResourceType as OldPolicyResourceType } from "@/types/proto/v1/or
import { PolicyResourceType as NewPolicyResourceType } from "@/types/proto-es/v1/org_policy_service_pb";
import { PolicyType as OldPolicyType } from "@/types/proto/v1/org_policy_service";
import { PolicyType as NewPolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
+import { SQLReviewRuleLevel as OldSQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
+import { SQLReviewRuleLevel as NewSQLReviewRuleLevel } from "@/types/proto-es/v1/org_policy_service_pb";
// Convert old proto to proto-es
export const convertOldPolicyToNew = (oldPolicy: OldPolicy): NewPolicy => {
@@ -78,4 +80,27 @@ export const convertNewPolicyTypeToOld = (newType: NewPolicyType): OldPolicyType
[NewPolicyType.DATA_QUERY]: OldPolicyType.DATA_QUERY,
};
return mapping[newType] ?? OldPolicyType.UNRECOGNIZED;
+};
+
+// Convert old SQLReviewRuleLevel enum to new (string to numeric)
+export const convertOldSQLReviewRuleLevelToNew = (oldLevel: OldSQLReviewRuleLevel): NewSQLReviewRuleLevel => {
+ const mapping: Record<OldSQLReviewRuleLevel, NewSQLReviewRuleLevel> = {
+ [OldSQLReviewRuleLevel.LEVEL_UNSPECIFIED]: NewSQLReviewRuleLevel.LEVEL_UNSPECIFIED,
+ [OldSQLReviewRuleLevel.ERROR]: NewSQLReviewRuleLevel.ERROR,
+ [OldSQLReviewRuleLevel.WARNING]: NewSQLReviewRuleLevel.WARNING,
+ [OldSQLReviewRuleLevel.DISABLED]: NewSQLReviewRuleLevel.DISABLED,
+ [OldSQLReviewRuleLevel.UNRECOGNIZED]: NewSQLReviewRuleLevel.LEVEL_UNSPECIFIED,
+ };
+ return mapping[oldLevel] ?? NewSQLReviewRuleLevel.LEVEL_UNSPECIFIED;
+};
+
+// Convert new SQLReviewRuleLevel enum to old (numeric to string)
+export const convertNewSQLReviewRuleLevelToOld = (newLevel: NewSQLReviewRuleLevel): OldSQLReviewRuleLevel => {
+ const mapping: Record<NewSQLReviewRuleLevel, OldSQLReviewRuleLevel> = {
+ [NewSQLReviewRuleLevel.LEVEL_UNSPECIFIED]: OldSQLReviewRuleLevel.LEVEL_UNSPECIFIED,
+ [NewSQLReviewRuleLevel.ERROR]: OldSQLReviewRuleLevel.ERROR,
+ [NewSQLReviewRuleLevel.WARNING]: OldSQLReviewRuleLevel.WARNING,
+ [NewSQLReviewRuleLevel.DISABLED]: OldSQLReviewRuleLevel.DISABLED,
+ };
+ return mapping[newLevel] ?? OldSQLReviewRuleLevel.UNRECOGNIZED;
};
\ No newline at end of file
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index f21510b12b..d5240a548c 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -115,8 +115,8 @@ import {
getEmptyRolloutPolicy,
} from "@/store/modules/v1/policy";
import { formatEnvironmentName } from "@/types";
-import type { Policy } from "@/types/proto/v1/org_policy_service";
-import { PolicyResourceType } from "@/types/proto/v1/org_policy_service";
+import type { Policy } from "@/types/proto-es/v1/org_policy_service_pb";
+import { PolicyResourceType } from "@/types/proto-es/v1/org_policy_service_pb";
import { EnvironmentSetting_EnvironmentSchema } from "@/types/proto-es/v1/setting_service_pb";
import type { Environment } from "@/types/v1/environment";
import { create } from "@bufbuild/protobuf";
diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vue
index d1d7d69be4..c584a35440 100644
--- a/frontend/src/views/EnvironmentDetail.vue
+++ b/frontend/src/views/EnvironmentDetail.vue
@@ -30,11 +30,11 @@ import {
getEmptyRolloutPolicy,
} from "@/store/modules/v1/policy";
import { formatEnvironmentName, unknownEnvironment } from "@/types";
-import type { Policy } from "@/types/proto/v1/org_policy_service";
+import type { Policy } from "@/types/proto-es/v1/org_policy_service_pb";
import {
PolicyType,
PolicyResourceType,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import type { Environment } from "@/types/v1/environment";
import { type VueClass } from "@/utils";
diff --git a/frontend/src/views/project/ProjectMaskingExemption.vue b/frontend/src/views/project/ProjectMaskingExemption.vue
index 6aede5e2e8..38f732ccb3 100644
--- a/frontend/src/views/project/ProjectMaskingExemption.vue
+++ b/frontend/src/views/project/ProjectMaskingExemption.vue
@@ -81,7 +81,7 @@ import { PROJECT_V1_ROUTE_MASKING_EXEMPTION_CREATE } from "@/router/dashboard/pr
import { useProjectByName, hasFeature } from "@/store";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import { projectNamePrefix } from "@/store/modules/v1/common";
-import { MaskingExceptionPolicy_MaskingException_Action as Action } from "@/types/proto/v1/org_policy_service";
+import { MaskingExceptionPolicy_MaskingException_Action as Action } from "@/types/proto-es/v1/org_policy_service_pb";
import { hasProjectPermissionV2 } from "@/utils";
interface LocalState {
diff --git a/frontend/src/views/project/ProjectSettingPanel.vue b/frontend/src/views/project/ProjectSettingPanel.vue
index 05dd41f471..95a5bdf558 100644
--- a/frontend/src/views/project/ProjectSettingPanel.vue
+++ b/frontend/src/views/project/ProjectSettingPanel.vue
@@ -8,7 +8,7 @@ import ProjectSettingPanel from "@/components/ProjectSettingPanel.vue";
import { useBodyLayoutContext } from "@/layouts/common";
import { usePolicyV1Store, useProjectByName } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
-import { PolicyResourceType } from "@/types/proto/v1/org_policy_service";
+import { PolicyResourceType } from "@/types/proto-es/v1/org_policy_service_pb";
const props = defineProps<{
projectId: string;
diff --git a/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue b/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue
index a061c107c1..9be44b7eb0 100644
--- a/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue
@@ -135,7 +135,7 @@ import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";
import {
DataSourceQueryPolicy_Restriction,
PolicyType,
-} from "@/types/proto/v1/org_policy_service";
+} from "@/types/proto-es/v1/org_policy_service_pb";
import { QueryOption_RedisRunCommandsOn } from "@/types/proto/v1/sql_service";
import { getValidDataSourceByPolicy, readableDataSourceType } from "@/utils";
import { getAdminDataSourceRestrictionOfDatabase } from "@/utils";
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
index 67b5e2aeaa..9fb9ce4144 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ResultViewV1.vue
@@ -139,7 +139,7 @@ import type {
SQLEditorQueryParams,
SQLResultSetV1,
} from "@/types";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { hasWorkspacePermissionV2 } from "@/utils";
import { provideBinaryFormatContext } from "./DataTable/binary-format-store";
import DetailPanel from "./DetailPanel";
@@ -252,7 +252,7 @@ const disallowCopyingData = computed(() => {
parentPath: props.database?.project,
policyType: PolicyType.DISABLE_COPY_DATA,
});
- if (projectLevelPolicy?.disableCopyDataPolicy?.active) {
+ if (projectLevelPolicy?.policy?.case === "disableCopyDataPolicy" && projectLevelPolicy.policy.value.active) {
return true;
}
// If the database is provided, use its effective environment.
@@ -264,7 +264,7 @@ const disallowCopyingData = computed(() => {
parentPath: environment,
policyType: PolicyType.DISABLE_COPY_DATA,
});
- if (policy?.disableCopyDataPolicy?.active) {
+ if (policy?.policy?.case === "disableCopyDataPolicy" && policy.policy.value.active) {
return true;
}
return false;
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
index 2212c22365..8a2727c133 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
@@ -236,7 +236,7 @@ import {
} from "@/types";
import { Engine, ExportFormat } from "@/types/proto-es/v1/common_pb";
import { convertExportFormatToOld } from "@/utils/v1/common-conversions";
-import { PolicyType } from "@/types/proto/v1/org_policy_service";
+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";
import { DatabaseChangeMode } from "@/types/proto-es/v1/setting_service_pb";
import type {
QueryResult,
@@ -321,7 +321,9 @@ const { policy: exportDataPolicy } = usePolicyByParentAndType(
);
const disallowExportQueryData = computed(() => {
- return exportDataPolicy.value?.exportDataPolicy?.disable ?? false;
+ return exportDataPolicy.value?.policy?.case === "exportDataPolicy"
+ ? exportDataPolicy.value.policy.value.disable
+ : false;
});
const viewMode = computed((): ViewMode => {