Skip to content

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

chore: use `fromPartial` instead of `fromJSON` (#16251)

boojack3fae2ef5c937
diff --git a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
index 3c57f95f1e..12ca4b0ada 100644
--- a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
@@ -365,7 +365,7 @@ const createV1 = async () => {
state.creating = true;
try {
- const planCreate = Plan.fromJSON({
+ const planCreate = Plan.fromPartial({
steps: [{ specs: [spec] }],
creator: currentUserV1.value.name,
});
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
index 57445bde61..061d8b2d01 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
@@ -126,7 +126,7 @@ const reorder = (step: ApprovalStep, index: number, offset: -1 | 1) => {
};
const addStep = () => {
steps.value.push(
- ApprovalStep.fromJSON({
+ ApprovalStep.fromPartial({
type: ApprovalStep_Type.ANY,
nodes: [
{
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.ts b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.ts
index 77fffab656..41cc873a86 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/logic/utils.ts
@@ -1,14 +1,11 @@
import { v4 as uuidv4 } from "uuid";
-import { useCurrentUserV1 } from "@/store";
-import { userNamePrefix } from "@/store/modules/v1/common";
import type { LocalApprovalRule } from "@/types";
import { ApprovalTemplate } from "@/types/proto/v1/issue_service";
export const emptyLocalApprovalRule = (): LocalApprovalRule => {
return {
uid: uuidv4(),
- template: ApprovalTemplate.fromJSON({
- creator: `${userNamePrefix}${useCurrentUserV1().value.email}`,
+ template: ApprovalTemplate.fromPartial({
flow: {
steps: [],
},
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 e9fbe981a1..e59003b852 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
@@ -136,7 +136,7 @@ const applyTemplate = async (template: RuleTemplate) => {
}
const expressions = await batchConvertParsedExprToCELString([celexpr]);
const overrides: Partial<Risk> = {
- condition: Expr.fromJSON({ expression: expressions[0] }),
+ condition: Expr.fromPartial({ expression: expressions[0] }),
level,
title,
};
diff --git a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
index 6355a59b64..5fe1ebbded 100644
--- a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
@@ -277,7 +277,7 @@ const showDetail = (secret?: Secret) => {
return;
}
detail.value = {
- secret: secret ? cloneDeep(secret) : Secret.fromJSON({}),
+ secret: secret ? cloneDeep(secret) : Secret.fromPartial({}),
mode: secret ? "UPDATE" : "CREATE",
loading: false,
dirty: false,
diff --git a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
index e17f3bacaf..6f203fbab1 100644
--- a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
+++ b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
@@ -86,7 +86,7 @@ const update = (rp: RolloutPolicy) => {
};
const toggleAutomaticRollout = (selected: boolean) => {
update(
- RolloutPolicy.fromJSON({
+ RolloutPolicy.fromPartial({
...rolloutPolicy.value,
automatic: selected,
})
diff --git a/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue b/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue
index 6ce1d392aa..99958897a8 100644
--- a/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue
+++ b/frontend/src/components/IssueV1/components/DescriptionSection/DescriptionSection.vue
@@ -123,7 +123,7 @@ const beginEdit = () => {
const saveEdit = async () => {
try {
state.isUpdating = true;
- const issuePatch = Issue.fromJSON({
+ const issuePatch = Issue.fromPartial({
...issue.value,
description: state.description,
});
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Title.vue b/frontend/src/components/IssueV1/components/HeaderSection/Title.vue
index 190e319516..2d397f41f6 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Title.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Title.vue
@@ -76,8 +76,7 @@ const onBlur = async () => {
}
try {
state.isUpdating = true;
- // TODO update name
- const issuePatch = Issue.fromJSON({
+ const issuePatch = Issue.fromPartial({
...issue.value,
title: state.title,
});
diff --git a/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue b/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue
index 0d3c4e284d..5539e25511 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue
@@ -28,7 +28,7 @@ const onLablesUpdate = async (labels: string[]) => {
if (isCreating.value) {
issue.value.labels = labels;
} else {
- const issuePatch = Issue.fromJSON({
+ const issuePatch = Issue.fromPartial({
...issue.value,
labels,
});
diff --git a/frontend/src/components/IssueV1/logic/subscriber.ts b/frontend/src/components/IssueV1/logic/subscriber.ts
index 8cb2caba07..e2e3f25d19 100644
--- a/frontend/src/components/IssueV1/logic/subscriber.ts
+++ b/frontend/src/components/IssueV1/logic/subscriber.ts
@@ -10,7 +10,7 @@ export const updateIssueSubscribers = async (
subscribers: string[],
silent?: boolean // If silent is true, no notification will be pushed
) => {
- const issuePatch = Issue.fromJSON({
+ const issuePatch = Issue.fromPartial({
...issue,
subscribers,
});
diff --git a/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue b/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
index 5fc338c238..0a246583ed 100644
--- a/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/DescriptionSection/DescriptionSection.vue
@@ -138,7 +138,7 @@ const beginEdit = () => {
const saveEdit = async () => {
try {
state.isUpdating = true;
- const planPatch = Plan.fromJSON({
+ const planPatch = Plan.fromPartial({
...plan.value,
description: state.description,
});
diff --git a/frontend/src/components/Plan/components/HeaderSection/Title.vue b/frontend/src/components/Plan/components/HeaderSection/Title.vue
index 776e20da0d..3a157aeea4 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Title.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Title.vue
@@ -100,7 +100,7 @@ const onBlur = async () => {
}
try {
state.isUpdating = true;
- const planPatch = Plan.fromJSON({
+ const planPatch = Plan.fromPartial({
...plan.value,
title: state.title,
});
diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.ts
index 53f6e63e40..e2b6d8d6df 100644
--- a/frontend/src/components/Plan/logic/initialize/create.ts
+++ b/frontend/src/components/Plan/logic/initialize/create.ts
@@ -65,7 +65,7 @@ export const createPlanSkeleton = async (
export const buildPlan = async (params: CreatePlanParams) => {
const { project, query } = params;
const databaseNameList = (query.databaseList ?? "").split(",");
- const plan = Plan.fromJSON({
+ const plan = Plan.fromPartial({
name: `${project.name}/plans/${nextUID()}`,
title: query.name,
description: query.description,
@@ -130,7 +130,7 @@ const buildStepsForDatabaseGroup = async (
params,
extractSheetUID(sheet.name)
);
- const step = Plan_Step.fromJSON({
+ const step = Plan_Step.fromPartial({
specs: [spec],
});
return [step];
@@ -175,11 +175,11 @@ const buildSpecForTarget = async (
) => {
const sheet = `${project.name}/sheets/${sheetUID ?? nextUID()}`;
const template = query.template as IssueType | undefined;
- const spec = Plan_Spec.fromJSON({
+ const spec = Plan_Spec.fromPartial({
id: uuidv4(),
});
if (template === "bb.issue.database.data.update") {
- spec.changeDatabaseConfig = Plan_ChangeDatabaseConfig.fromJSON({
+ spec.changeDatabaseConfig = Plan_ChangeDatabaseConfig.fromPartial({
target,
type: Plan_ChangeDatabaseConfig_Type.DATA,
});
@@ -201,7 +201,7 @@ const buildSpecForTarget = async (
}
if (template === "bb.issue.database.schema.update") {
const type = Plan_ChangeDatabaseConfig_Type.MIGRATE;
- spec.changeDatabaseConfig = Plan_ChangeDatabaseConfig.fromJSON({
+ spec.changeDatabaseConfig = Plan_ChangeDatabaseConfig.fromPartial({
target,
type,
sheet,
diff --git a/frontend/src/components/Plan/logic/sheet.ts b/frontend/src/components/Plan/logic/sheet.ts
index 7438429497..a868d1ead7 100644
--- a/frontend/src/components/Plan/logic/sheet.ts
+++ b/frontend/src/components/Plan/logic/sheet.ts
@@ -4,7 +4,7 @@ import { Sheet } from "@/types/proto/v1/sheet_service";
const sheetsByName = reactive(new Map<string, Sheet>());
export const createEmptyLocalSheet = () => {
- return reactive(Sheet.fromJSON({}));
+ return reactive(Sheet.fromPartial({}));
};
export const getLocalSheetByName = (name: string): Sheet => {
diff --git a/frontend/src/components/Role/Setting/components/RolePanel.vue b/frontend/src/components/Role/Setting/components/RolePanel.vue
index 8e10953450..645875aa3d 100644
--- a/frontend/src/components/Role/Setting/components/RolePanel.vue
+++ b/frontend/src/components/Role/Setting/components/RolePanel.vue
@@ -143,7 +143,7 @@ const roleStore = useRoleStore();
const { hasCustomRoleFeature, showFeatureModal } =
useCustomRoleSettingContext();
const state = reactive<LocalState>({
- role: Role.fromJSON({}),
+ role: Role.fromPartial({}),
dirty: false,
loading: false,
showImportPermissionFromRoleModal: false,
diff --git a/frontend/src/components/SchemaEditorLite/Panels/ViewEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/ViewEditor.vue
index dbbd61af3f..afd3ece032 100644
--- a/frontend/src/components/SchemaEditorLite/Panels/ViewEditor.vue
+++ b/frontend/src/components/SchemaEditorLite/Panels/ViewEditor.vue
@@ -81,7 +81,7 @@ const mocked = computed(() => {
const databaseCatalog = getDatabaseCatalog(database.name);
const mockedView = cloneDeep(view);
- const mockedDatabase = DatabaseMetadata.fromJSON({
+ const mockedDatabase = DatabaseMetadata.fromPartial({
name: database.name,
characterSet: database.characterSet,
collation: database.collation,
diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
index 429015b4e8..265a790e91 100644
--- a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
@@ -158,7 +158,7 @@ const deleteTemplate = async (id: string) => {
"bb.workspace.schema-template"
);
- const settingValue = SchemaTemplateSetting.fromJSON({});
+ const settingValue = SchemaTemplateSetting.fromPartial({});
if (setting?.value?.schemaTemplateSettingValue) {
Object.assign(settingValue, setting.value.schemaTemplateSettingValue);
}
diff --git a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue b/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
index 5a480af3fc..b559c6d52d 100644
--- a/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
+++ b/frontend/src/components/SchemaTemplate/TableTemplateForm.vue
@@ -350,7 +350,7 @@ const onSubmit = async () => {
"bb.workspace.schema-template"
);
- const settingValue = SchemaTemplateSetting.fromJSON({});
+ const settingValue = SchemaTemplateSetting.fromPartial({});
if (setting?.value?.schemaTemplateSettingValue) {
Object.assign(
settingValue,
diff --git a/frontend/src/components/SchemaTemplate/TableTemplateTable.vue b/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
index 894ef9987d..a04d64a0da 100644
--- a/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
@@ -117,7 +117,7 @@ const deleteTemplate = async (id: string) => {
"bb.workspace.schema-template"
);
- const settingValue = SchemaTemplateSetting.fromJSON({});
+ const settingValue = SchemaTemplateSetting.fromPartial({});
if (setting?.value?.schemaTemplateSettingValue) {
Object.assign(settingValue, setting.value.schemaTemplateSettingValue);
}
diff --git a/frontend/src/components/SensitiveData/SemanticTypesView.vue b/frontend/src/components/SensitiveData/SemanticTypesView.vue
index 32afe7408f..3401f8caa6 100644
--- a/frontend/src/components/SensitiveData/SemanticTypesView.vue
+++ b/frontend/src/components/SensitiveData/SemanticTypesView.vue
@@ -91,10 +91,8 @@ const onAdd = () => {
state.semanticItemList.push({
mode: "CREATE",
dirty: false,
- item: SemanticTypeSetting_SemanticType.fromJSON({
+ item: SemanticTypeSetting_SemanticType.fromPartial({
id: uuidv4(),
- fullMaskAlgorithmId: "",
- partialMaskAlgorithmId: "",
}),
});
};
diff --git a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
index 762767925d..72ae3ed92e 100644
--- a/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
+++ b/frontend/src/components/SensitiveData/components/MaskingRuleConfig.vue
@@ -217,7 +217,7 @@ const onConfirm = async () => {
emit("confirm", {
...props.maskingRule,
semanticType: state.semanticType!,
- condition: Expr.fromJSON({
+ condition: Expr.fromPartial({
expression: expressions[0],
title: state.title,
}),
diff --git a/frontend/src/plugins/cel/logic/build.ts b/frontend/src/plugins/cel/logic/build.ts
index 55f84c368f..2f15105d9b 100644
--- a/frontend/src/plugins/cel/logic/build.ts
+++ b/frontend/src/plugins/cel/logic/build.ts
@@ -127,7 +127,7 @@ export const buildCELExpr = async (
};
const wrapCELExpr = (object: any): CELExpr => {
- return CELExpr.fromJSON({
+ return CELExpr.fromPartial({
id: seq.next(),
...object,
});
diff --git a/frontend/src/store/modules/dbGroup.ts b/frontend/src/store/modules/dbGroup.ts
index e9e380a545..e5238d794e 100644
--- a/frontend/src/store/modules/dbGroup.ts
+++ b/frontend/src/store/modules/dbGroup.ts
@@ -269,7 +269,7 @@ export const useDBGroupStore = defineStore("db-group", () => {
databaseGroup: DatabaseGroup.fromPartial({
name: `${projectName}/${databaseGroupNamePrefix}${validateOnlyResourceId}`,
title: validateOnlyResourceId,
- databaseExpr: Expr.fromJSON({
+ databaseExpr: Expr.fromPartial({
expression,
}),
}),
diff --git a/frontend/src/store/modules/sqlEditor/webTerminal.ts b/frontend/src/store/modules/sqlEditor/webTerminal.ts
index ceddeb95d3..008cfef0db 100644
--- a/frontend/src/store/modules/sqlEditor/webTerminal.ts
+++ b/frontend/src/store/modules/sqlEditor/webTerminal.ts
@@ -145,7 +145,7 @@ const createStreamingQueryController = () => {
result.latency = parseDuration(result.latency);
});
}
- const response = AdminExecuteResponse.fromJSON(data.result);
+ const response = AdminExecuteResponse.fromPartial(data.result);
subscriber.next(response);
} else if (data.error) {
const err = new ClientError(
diff --git a/frontend/src/store/modules/v1/projectIamPolicy.ts b/frontend/src/store/modules/v1/projectIamPolicy.ts
index d307337032..f0e75892a8 100644
--- a/frontend/src/store/modules/v1/projectIamPolicy.ts
+++ b/frontend/src/store/modules/v1/projectIamPolicy.ts
@@ -94,7 +94,7 @@ export const useProjectIamPolicyStore = defineStore(
};
const getProjectIamPolicy = (project: string) => {
- return policyMap.value.get(project) ?? IamPolicy.fromJSON({});
+ return policyMap.value.get(project) ?? IamPolicy.fromPartial({});
};
const getOrFetchProjectIamPolicy = async (project: string) => {
@@ -147,7 +147,7 @@ export const useProjectIamPolicy = (project: MaybeRef<string>) => {
{ immediate: true }
);
const policy = computed(() => {
- return store.policyMap.get(unref(project)) ?? IamPolicy.fromJSON({});
+ return store.policyMap.get(unref(project)) ?? IamPolicy.fromPartial({});
});
return { policy, ready };
};
diff --git a/frontend/src/types/release.ts b/frontend/src/types/release.ts
index 5a5a007bd1..3c509a1455 100644
--- a/frontend/src/types/release.ts
+++ b/frontend/src/types/release.ts
@@ -20,10 +20,8 @@ export const UNKNOWN_RELEASE_NAME = `${UNKNOWN_PROJECT_NAME}/releases/${UNKNOWN_
export const unknownRelease = (): ComposedRelease => {
const projectEntity = unknownProject();
- const release = Release.fromJSON({
+ const release = Release.fromPartial({
name: `${projectEntity.name}/releases/${UNKNOWN_ID}`,
- uid: String(UNKNOWN_ID),
- project: projectEntity.name,
});
return {
...release,
diff --git a/frontend/src/types/review.ts b/frontend/src/types/review.ts
index 5cb6264000..ea64f5143c 100644
--- a/frontend/src/types/review.ts
+++ b/frontend/src/types/review.ts
@@ -17,7 +17,7 @@ export type WrappedReviewStep = {
export const emptyFlow = (): ReviewFlow => {
return {
- template: ApprovalTemplate.fromJSON({}),
+ template: ApprovalTemplate.fromPartial({}),
approvers: [],
currentStepIndex: -1,
};
diff --git a/frontend/src/types/rollout.ts b/frontend/src/types/rollout.ts
index 77fb9cc8d7..aa3adef31e 100644
--- a/frontend/src/types/rollout.ts
+++ b/frontend/src/types/rollout.ts
@@ -1,7 +1,7 @@
import { getProjectNameRolloutId } from "@/store/modules/v1/common";
import { EMPTY_ID, UNKNOWN_ID } from "./const";
-import type { User } from "./proto/v1/user_service";
import { Rollout } from "./proto/v1/rollout_service";
+import type { User } from "./proto/v1/user_service";
import { emptyUser, unknownUser } from "./v1";
import {
EMPTY_PROJECT_NAME,
@@ -23,10 +23,8 @@ export const UNKNOWN_ROLLOUT_NAME = `${UNKNOWN_PROJECT_NAME}/rollouts/${UNKNOWN_
export const emptyRollout = (): ComposedRollout => {
const projectEntity = emptyProject();
- const rollout = Rollout.fromJSON({
+ const rollout = Rollout.fromPartial({
name: `${projectEntity.name}/rollouts/${EMPTY_ID}`,
- uid: String(EMPTY_ID),
- project: projectEntity.name,
});
return {
...rollout,
@@ -38,10 +36,8 @@ export const emptyRollout = (): ComposedRollout => {
export const unknownRollout = (): ComposedRollout => {
const projectEntity = unknownProject();
- const rollout = Rollout.fromJSON({
+ const rollout = Rollout.fromPartial({
name: `${projectEntity.name}/rollouts/${UNKNOWN_ID}`,
- uid: String(UNKNOWN_ID),
- project: projectEntity.name,
});
return {
...rollout,
diff --git a/frontend/src/types/v1/database.ts b/frontend/src/types/v1/database.ts
index 2fda4facbb..9e5154494f 100644
--- a/frontend/src/types/v1/database.ts
+++ b/frontend/src/types/v1/database.ts
@@ -2,8 +2,8 @@ import { extractDatabaseResourceName, isNullOrUndefined } from "@/utils";
import { EMPTY_ID, UNKNOWN_ID } from "../const";
import { State } from "../proto/v1/common";
import { Database } from "../proto/v1/database_service";
-import type { Environment } from "../v1/environment";
import type { InstanceResource } from "../proto/v1/instance_service";
+import type { Environment } from "../v1/environment";
import { formatEnvironmentName, unknownEnvironment } from "./environment";
import { unknownInstance, unknownInstanceResource } from "./instance";
import type { ComposedProject } from "./project";
@@ -28,9 +28,8 @@ export const unknownDatabase = (): ComposedDatabase => {
const projectEntity = unknownProject();
const instanceResource = unknownInstanceResource();
const effectiveEnvironmentEntity = unknownEnvironment();
- const database = Database.fromJSON({
+ const database = Database.fromPartial({
name: `${instanceResource.name}/databases/${UNKNOWN_ID}`,
- uid: String(UNKNOWN_ID),
state: State.ACTIVE,
project: projectEntity.name,
effectiveEnvironment: formatEnvironmentName(effectiveEnvironmentEntity.id),
diff --git a/frontend/src/types/v1/issue/issue.ts b/frontend/src/types/v1/issue/issue.ts
index 8ff463526f..47140258c3 100644
--- a/frontend/src/types/v1/issue/issue.ts
+++ b/frontend/src/types/v1/issue/issue.ts
@@ -25,10 +25,9 @@ export const UNKNOWN_ISSUE_NAME = `projects/${UNKNOWN_ID}/issues/${UNKNOWN_ID}`;
export const emptyIssue = (): ComposedIssue => {
return {
- ...Issue.fromJSON({
+ ...Issue.fromPartial({
name: EMPTY_ISSUE_NAME,
rollout: EMPTY_ROLLOUT_NAME,
- uid: String(EMPTY_ID),
type: Issue_Type.DATABASE_CHANGE,
}),
planEntity: undefined,
@@ -41,10 +40,9 @@ export const emptyIssue = (): ComposedIssue => {
export const unknownIssue = (): ComposedIssue => {
return {
- ...Issue.fromJSON({
+ ...Issue.fromPartial({
name: UNKNOWN_ISSUE_NAME,
rollout: UNKNOWN_ROLLOUT_NAME,
- uid: String(UNKNOWN_ID),
type: Issue_Type.DATABASE_CHANGE,
}),
planEntity: undefined,
diff --git a/frontend/src/types/v1/issue/plan.ts b/frontend/src/types/v1/issue/plan.ts
index f262fea43e..2e8ed7781b 100644
--- a/frontend/src/types/v1/issue/plan.ts
+++ b/frontend/src/types/v1/issue/plan.ts
@@ -16,9 +16,8 @@ export const EMPTY_PLAN_NAME = `projects/${EMPTY_ID}/plans/${EMPTY_ID}`;
export const UNKNOWN_PLAN_NAME = `projects/${UNKNOWN_ID}/plans/${UNKNOWN_ID}`;
export const emptyPlan = (): ComposedPlan => {
return {
- ...Plan.fromJSON({
+ ...Plan.fromPartial({
name: EMPTY_PLAN_NAME,
- uid: String(EMPTY_ID),
}),
planCheckRunList: [],
project: EMPTY_PROJECT_NAME,
@@ -26,9 +25,8 @@ export const emptyPlan = (): ComposedPlan => {
};
export const unknownPlan = (): ComposedPlan => {
return {
- ...Plan.fromJSON({
+ ...Plan.fromPartial({
name: UNKNOWN_PLAN_NAME,
- uid: String(UNKNOWN_ID),
}),
planCheckRunList: [],
project: UNKNOWN_PROJECT_NAME,
@@ -36,18 +34,18 @@ export const unknownPlan = (): ComposedPlan => {
};
export const emptyPlanStep = () => {
- return Plan_Step.fromJSON({
+ return Plan_Step.fromPartial({
specs: [],
});
};
export const emptyPlanSpec = () => {
- return Plan_Spec.fromJSON({
+ return Plan_Spec.fromPartial({
id: String(EMPTY_ID),
});
};
export const unknownPlanSpec = () => {
- return Plan_Spec.fromJSON({
+ return Plan_Spec.fromPartial({
id: String(UNKNOWN_ID),
});
};
diff --git a/frontend/src/types/v1/issue/rollout.ts b/frontend/src/types/v1/issue/rollout.ts
index 6ed587863c..970b00d64e 100644
--- a/frontend/src/types/v1/issue/rollout.ts
+++ b/frontend/src/types/v1/issue/rollout.ts
@@ -16,36 +16,28 @@ export const EMPTY_STAGE_NAME = `${EMPTY_ROLLOUT_NAME}/stages/${EMPTY_ID}`;
export const UNKNOWN_STAGE_NAME = `${UNKNOWN_ROLLOUT_NAME}/stages/${UNKNOWN_ID}`;
export const emptyStage = () => {
- return Stage.fromJSON({
+ return Stage.fromPartial({
name: EMPTY_STAGE_NAME,
- uid: String(EMPTY_ID),
environment: EMPTY_ENVIRONMENT_NAME,
- title: "",
});
};
export const unknownStage = () => {
- return Stage.fromJSON({
+ return Stage.fromPartial({
name: UNKNOWN_STAGE_NAME,
- uid: String(UNKNOWN_ID),
environment: UNKNOWN_ENVIRONMENT_NAME,
- title: "<<Unknown stage>>",
});
};
export const EMPTY_TASK_NAME = `${EMPTY_STAGE_NAME}/tasks/${EMPTY_ID}`;
export const UNKNOWN_TASK_NAME = `${UNKNOWN_STAGE_NAME}/tasks/${UNKNOWN_ID}`;
export const emptyTask = () => {
- return Task.fromJSON({
+ return Task.fromPartial({
name: EMPTY_TASK_NAME,
- uid: String(EMPTY_ID),
- title: "",
});
};
export const unknownTask = () => {
- return Task.fromJSON({
+ return Task.fromPartial({
name: UNKNOWN_TASK_NAME,
- uid: String(UNKNOWN_ID),
- title: "<<Unknown task>>",
});
};
diff --git a/frontend/src/types/v1/project.ts b/frontend/src/types/v1/project.ts
index daaeaa47a6..9c1199ffc8 100644
--- a/frontend/src/types/v1/project.ts
+++ b/frontend/src/types/v1/project.ts
@@ -14,14 +14,12 @@ export interface ComposedProject extends Project {
export const emptyProject = (): ComposedProject => {
return {
- ...Project.fromJSON({
+ ...Project.fromPartial({
name: EMPTY_PROJECT_NAME,
- uid: String(EMPTY_ID),
title: "",
- key: "",
state: State.ACTIVE,
}),
- iamPolicy: IamPolicy.fromJSON({}),
+ iamPolicy: IamPolicy.fromPartial({}),
};
};
diff --git a/frontend/src/types/v1/projectWebhook.ts b/frontend/src/types/v1/projectWebhook.ts
index a96722b9f5..459d07df6d 100644
--- a/frontend/src/types/v1/projectWebhook.ts
+++ b/frontend/src/types/v1/projectWebhook.ts
@@ -6,7 +6,7 @@ import {
} from "../proto/v1/project_service";
export const emptyProjectWebhook = () => {
- return Webhook.fromJSON({
+ return Webhook.fromPartial({
type: Webhook_Type.SLACK,
notificationTypes: [Activity_Type.TYPE_ISSUE_STATUS_UPDATE],
});
diff --git a/frontend/src/utils/v1/cel.ts b/frontend/src/utils/v1/cel.ts
index c5e78911b2..d43f940277 100644
--- a/frontend/src/utils/v1/cel.ts
+++ b/frontend/src/utils/v1/cel.ts
@@ -18,7 +18,7 @@ export const batchConvertCELStringToParsedExpr = async (
} catch (error) {
console.error(error);
return Array.from({ length: celList.length }).map((_) =>
- Expr.fromJSON({})
+ Expr.fromPartial({})
);
}
};
diff --git a/frontend/src/utils/workspaceApprovalSetting.ts b/frontend/src/utils/workspaceApprovalSetting.ts
index 947459bc73..22eb2dd3f4 100644
--- a/frontend/src/utils/workspaceApprovalSetting.ts
+++ b/frontend/src/utils/workspaceApprovalSetting.ts
@@ -10,10 +10,7 @@ import {
} from "@/plugins/cel";
import { t } from "@/plugins/i18n";
import type { ParsedApprovalRule, UnrecognizedApprovalRule } from "@/types";
-import {
- DEFAULT_RISK_LEVEL,
- PresetRoleType,
-} 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";
@@ -78,7 +75,7 @@ export const resolveLocalApprovalConfig = async (
const rule = config.rules[i];
const localRule: LocalApprovalRule = {
uid: uuidv4(),
- expr: resolveCELExpr(CELExpr.fromJSON({})),
+ expr: resolveCELExpr(CELExpr.fromPartial({})),
template: cloneDeep(rule.template!),
};
ruleMap.set(localRule.uid, localRule);
@@ -92,7 +89,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.fromJSON({})
+ exprList[i] ?? CELExpr.fromPartial({})
);
}
@@ -183,7 +180,7 @@ export const buildWorkspaceApprovalSetting = async (
const rule = rules[i];
const { uid, template } = rule;
- const approvalRule = ApprovalRule.fromJSON({
+ const approvalRule = ApprovalRule.fromPartial({
template,
condition: { expression: "" },
});
@@ -200,12 +197,12 @@ export const buildWorkspaceApprovalSetting = async (
const expressionList = await batchConvertParsedExprToCELString(exprList);
for (let i = 0; i < expressionList.length; i++) {
const ruleIndex = ruleIndexList[i];
- approvalRuleMap.get(ruleIndex)!.condition = Expr.fromJSON({
+ approvalRuleMap.get(ruleIndex)!.condition = Expr.fromPartial({
expression: expressionList[i],
});
}
- return WorkspaceApprovalSetting.fromJSON({
+ return WorkspaceApprovalSetting.fromPartial({
rules: [...approvalRuleMap.values()],
});
};
@@ -356,4 +353,4 @@ export const seedWorkspaceApprovalSetting = () => {
const description = t(keypath);
return generateRule(title, description, preset.roles);
});
-};
\ No newline at end of file
+};