Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Code hygine, simplify parameter interface
Tianzhou Chendc5bf7436edc
diff --git a/frontend/src/store/modules/command.ts b/frontend/src/store/modules/command.tsindex 29acd30831..4e50939d8b 100644--- a/frontend/src/store/modules/command.ts+++ b/frontend/src/store/modules/command.ts@@ -14,6 +14,7 @@ const actions = {commit("appendCommand", newCommand);return newCommand;},+unregisterCommand({ commit }: any,{@@ -29,6 +30,7 @@ const actions = {registerId,});},+dispatchCommand({ state }: any, commandId: CommandId) {const list = state.commandListById.get(commandId);list?.forEach((cmd: Command) => {@@ -54,6 +56,7 @@ const mutations = {state.commandListById.set(command.id, [command]);}},+removeCommand(state: CommandState,{diff --git a/frontend/src/store/modules/datasource.ts b/frontend/src/store/modules/datasource.tsindex eca845e8d3..75ae1c45a8 100644--- a/frontend/src/store/modules/datasource.ts+++ b/frontend/src/store/modules/datasource.ts@@ -26,11 +26,13 @@ const getters = {}return null;},+dataSourceListByInstanceId: (state: DataSourceState) => (instanceId: InstanceId) => {return state.dataSourceListByInstanceId.get(instanceId);},+dataSourceById: (state: DataSourceState) => (dataSourceId: DataSourceId) => {return state.dataSourceById.get(dataSourceId);},@@ -84,19 +86,19 @@ const actions = {return createdDataSource;},- async patchDataSourceById(+ async patchDataSource({ commit }: any,{- dataSourceId,+ instanceId,dataSource,}: {- dataSourceId: DataSourceId;+ instanceId: InstanceId;dataSource: DataSource;}) {const updatedDataSource = (await axios.patch(- `/api/instance/${dataSourceId.instanceId}/datasource/${dataSourceId.id}`,+ `/api/instance/${instanceId}/datasource/${dataSource.id}`,{data: dataSource,}@@ -104,12 +106,12 @@ const actions = {).data.data;commit("setDataSourceById", {- instanceId: dataSourceId.instanceId,+ instanceId: instanceId,updatedDataSource,});commit("replaceDataSourceInListByInstanceId", {- instanceId: dataSourceId.instanceId,+ instanceId: instanceId,updatedDataSource,});@@ -118,11 +120,7 @@ const actions = {async deleteDataSourceById({ state, commit }: { state: DataSourceState; commit: any },- {- dataSourceId,- }: {- dataSourceId: DataSourceId;- }+ dataSourceId: DataSourceId) {await axios.delete(`/api/instance/${dataSourceId.instanceId}/datasource/${dataSourceId.id}`@@ -133,9 +131,7 @@ const actions = {dataSource: null,});- commit("deleteDataSourceInListById", {- dataSourceId,- });+ commit("deleteDataSourceInListById", dataSourceId);},};@@ -152,6 +148,7 @@ const mutations = {) {state.dataSourceListByInstanceId.set(instanceId, dataSourceList);},+setDataSourceById(state: DataSourceState,{@@ -164,6 +161,7 @@ const mutations = {) {state.dataSourceById.set(dataSourceId, dataSource);},+appendDataSourceByInstanceId(state: DataSourceState,{@@ -181,6 +179,7 @@ const mutations = {state.dataSourceListByInstanceId.set(instanceId, [dataSource]);}},+replaceDataSourceInListByInstanceId(state: DataSourceState,{@@ -201,13 +200,10 @@ const mutations = {}}},+deleteDataSourceInListById(state: DataSourceState,- {- dataSourceId,- }: {- dataSourceId: DataSourceId;- }+ dataSourceId: DataSourceId) {const list = state.dataSourceListByInstanceId.get(dataSourceId.instanceId);if (list) {diff --git a/frontend/src/store/modules/environment.ts b/frontend/src/store/modules/environment.tsindex aa3e0bf19f..d035f01243 100644--- a/frontend/src/store/modules/environment.ts+++ b/frontend/src/store/modules/environment.ts@@ -1,5 +1,10 @@import axios from "axios";-import { EnvironmentId, Environment, EnvironmentState } from "../../types";+import {+ EnvironmentId,+ Environment,+ EnvironmentNew,+ EnvironmentState,+} from "../../types";const state: () => EnvironmentState = () => ({environmentList: [],@@ -9,6 +14,7 @@ const getters = {environmentList: (state: EnvironmentState) => () => {return state.environmentList;},+environmentById: (state: EnvironmentState) => (environmentId: EnvironmentId) => {@@ -25,26 +31,19 @@ const actions = {async fetchEnvironmentList({ commit }: any) {const environmentList = (await axios.get(`/api/environment`)).data.data;- commit("setEnvironmentList", {- environmentList,- });+ commit("setEnvironmentList", environmentList);return environmentList;},- async createEnvironment(- { commit }: any,- { newEnvironment }: { newEnvironment: Environment }- ) {+ async createEnvironment({ commit }: any, newEnvironment: EnvironmentNew) {const createdEnvironment = (await axios.post(`/api/environment`, {data: newEnvironment,})).data.data;- commit("appendEnvironment", {- newEnvironment: createdEnvironment,- });+ commit("appendEnvironment", createdEnvironment);return createdEnvironment;},@@ -66,43 +65,26 @@ const actions = {})).data.data;- commit("setEnvironmentList", {- environmentList,- });+ commit("setEnvironmentList", environmentList);return environmentList;},- async patchEnvironmentById(- { commit }: any,- {- environmentId,- environment,- }: {- environmentId: EnvironmentId;- environment: Environment;- }- ) {+ async patchEnvironment({ commit }: any, environment: Environment) {const updatedEnvironment = (- await axios.patch(`/api/environment/${environmentId}`, {+ await axios.patch(`/api/environment/${environment.id}`, {data: environment,})).data.data;- commit("replaceEnvironmentInList", {- updatedEnvironment,- });+ commit("replaceEnvironmentInList", updatedEnvironment);return updatedEnvironment;},async deleteEnvironmentById({ state, commit }: { state: EnvironmentState; commit: any },- {- id,- }: {- id: EnvironmentId;- }+ id: EnvironmentId) {await axios.delete(`/api/environment/${id}`);@@ -110,41 +92,22 @@ const actions = {return item.id != id;});- commit("setEnvironmentList", {- environmentList: newList,- });+ commit("setEnvironmentList", newList);},};const mutations = {- setEnvironmentList(- state: EnvironmentState,- {- environmentList,- }: {- environmentList: Environment[];- }- ) {+ setEnvironmentList(state: EnvironmentState, environmentList: Environment[]) {state.environmentList = environmentList;},- appendEnvironment(- state: EnvironmentState,- {- newEnvironment,- }: {- newEnvironment: Environment;- }- ) {++ appendEnvironment(state: EnvironmentState, newEnvironment: Environment) {state.environmentList.push(newEnvironment);},replaceEnvironmentInList(state: EnvironmentState,- {- updatedEnvironment,- }: {- updatedEnvironment: Environment;- }+ updatedEnvironment: Environment) {const i = state.environmentList.findIndex((item: Environment) => item.id == updatedEnvironment.iddiff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.tsindex a0207d65a0..23f33c6154 100644--- a/frontend/src/store/modules/instance.ts+++ b/frontend/src/store/modules/instance.ts@@ -1,5 +1,5 @@import axios from "axios";-import { InstanceId, Instance, InstanceState } from "../../types";+import { InstanceId, Instance, InstanceNew, InstanceState } from "../../types";const state: () => InstanceState = () => ({instanceList: [],@@ -10,6 +10,7 @@ const getters = {instanceList: (state: InstanceState) => () => {return state.instanceList;},+instanceById: (state: InstanceState) => (instanceId: InstanceId) => {return state.instanceById.get(instanceId);},@@ -19,7 +20,7 @@ const actions = {async fetchInstanceList({ commit }: any) {const instanceList = (await axios.get(`/api/instance`)).data.data;- commit("setInstanceList", { instanceList });+ commit("setInstanceList", instanceList);return instanceList;},@@ -33,53 +34,33 @@ const actions = {return instance;},- async createInstance(- { commit }: any,- { newInstance }: { newInstance: Instance }- ) {+ async createInstance({ commit }: any, newInstance: InstanceNew) {const createdInstance = (await axios.post(`/api/instance`, {data: newInstance,})).data.data;- commit("appendInstance", {- newInstance: createdInstance,- });+ commit("appendInstance", createdInstance);return createdInstance;},- async patchInstanceById(- { commit }: any,- {- instanceId,- instance,- }: {- instanceId: InstanceId;- instance: Instance;- }- ) {+ async patchInstance({ commit }: any, instance: Instance) {const updatedInstance = (- await axios.patch(`/api/instance/${instanceId}`, {+ await axios.patch(`/api/instance/${instance.id}`, {data: instance,})).data.data;- commit("replaceInstanceInList", {- updatedInstance,- });+ commit("replaceInstanceInList", updatedInstance);return updatedInstance;},async deleteInstanceById({ state, commit }: { state: InstanceState; commit: any },- {- instanceId,- }: {- instanceId: InstanceId;- }+ instanceId: InstanceId) {await axios.delete(`/api/instance/${instanceId}`);@@ -87,23 +68,15 @@ const actions = {return item.id != instanceId;});- commit("setInstanceList", {- instanceList: newList,- });+ commit("setInstanceList", newList);},};const mutations = {- setInstanceList(- state: InstanceState,- {- instanceList,- }: {- instanceList: Instance[];- }- ) {+ setInstanceList(state: InstanceState, instanceList: Instance[]) {state.instanceList = instanceList;},+setInstanceById(state: InstanceState,{@@ -116,25 +89,12 @@ const mutations = {) {state.instanceById.set(instanceId, instance);},- appendInstance(- state: InstanceState,- {- newInstance,- }: {- newInstance: Instance;- }- ) {++ appendInstance(state: InstanceState, newInstance: Instance) {state.instanceList.push(newInstance);},- replaceInstanceInList(- state: InstanceState,- {- updatedInstance,- }: {- updatedInstance: Instance;- }- ) {+ replaceInstanceInList(state: InstanceState, updatedInstance: Instance) {const i = state.instanceList.findIndex((item: Instance) => item.id == updatedInstance.id);diff --git a/frontend/src/store/modules/notification.ts b/frontend/src/store/modules/notification.tsindex 27191e7c99..888c3a71bc 100644--- a/frontend/src/store/modules/notification.ts+++ b/frontend/src/store/modules/notification.ts@@ -32,9 +32,11 @@ const actions = {};commit("appendNotification", notification);},+peekNotification({ state }: any, filter: NotificationFilter) {return findNotification(state, filter);},+popNotification({ state, commit }: any, filter: NotificationFilter) {const notification = findNotification(state, filter);commit("removeNotification", notification);@@ -51,6 +53,7 @@ const mutations = {state.notificationByModule.set(notification.module, [notification]);}},+removeNotification(state: NotificationState, notification: Notification) {const list = state.notificationByModule.get(notification.module);if (list) {diff --git a/frontend/src/store/modules/pipeline.ts b/frontend/src/store/modules/pipeline.tsindex 8d651d6c6f..f19a71ccb9 100644--- a/frontend/src/store/modules/pipeline.ts+++ b/frontend/src/store/modules/pipeline.ts@@ -10,6 +10,7 @@ const getters = {pipelineListByUser: (state: PipelineState) => (userId: UserId) => {return state.pipelineListByUser.get(userId);},+pipelineById: (state: PipelineState) => (pipelineId: PipelineId) => {return state.pipelineById.get(pipelineId);},@@ -46,6 +47,7 @@ const mutations = {) {state.pipelineListByUser.set(userId, pipelineList);},+setPipelineById(state: PipelineState,{diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.tsindex 8ec8a5f626..ef171605ea 100644--- a/frontend/src/store/modules/project.ts+++ b/frontend/src/store/modules/project.ts@@ -10,9 +10,11 @@ const getters = {projectListByGroup: (state: ProjectState) => (groupId: GroupId) => {return state.projectListByGroup.get(groupId);},+projectListByUser: (state: ProjectState) => (userId: UserId) => {return state.projectListByUser.get(userId);},+projectByNamespaceAndSlug: (state: ProjectState) => (namespace: string,slug: string@@ -41,6 +43,7 @@ const actions = {});return projectList;},+async fetchProjectListForUser({ commit }: any, userId: UserId) {const projectList = (await axios.get(`/api/project?userid=${userId}`)).data.data;@@ -65,6 +68,7 @@ const mutations = {) {state.projectListByGroup.set(groupId, projectList);},+setProjectListForUser(state: ProjectState,{diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.tsindex b43caa2731..bf8af77da0 100644--- a/frontend/src/store/modules/router.ts+++ b/frontend/src/store/modules/router.ts@@ -7,6 +7,7 @@ const getters = {backPath: (state: RouterState) => (): string => {return localStorage.getItem("ui.backPath") || "/";},+routeSlug: (state: RouterState) => (currentRoute: RouteLocationNormalized): RouterSlug => {diff --git a/frontend/src/store/modules/uistate.ts b/frontend/src/store/modules/uistate.tsindex cb8c5b9ae9..2c1f898938 100644--- a/frontend/src/store/modules/uistate.ts+++ b/frontend/src/store/modules/uistate.ts@@ -39,6 +39,7 @@ const getters = {const key = ["grp", groupId].join(".");return expandStateByKey(state, key);},+expandStateByProject: (state: UIState) => (projectId: ProjectId) => {const key = ["proj", projectId].join(".");return expandStateByKey(state, key);@@ -92,6 +93,7 @@ const mutations = {}state.expandStateByKey = newMap;},+setExpandStateByKey(state: UIState,{diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vueindex c0e6d19dc2..376d333f0d 100644--- a/frontend/src/views/EnvironmentDashboard.vue+++ b/frontend/src/views/EnvironmentDashboard.vue@@ -154,9 +154,7 @@ export default {const doCreate = (newEnvironment: EnvironmentNew) => {store- .dispatch("environment/createEnvironment", {- newEnvironment,- })+ .dispatch("environment/createEnvironment", newEnvironment).then((createdEnvironment) => {state.showCreateModal = false;selectEnvironment(environmentList.value.length - 1);@@ -212,9 +210,7 @@ export default {const doDelete = (environment: Environment) => {store- .dispatch("environment/deleteEnvironmentById", {- id: environment.id,- })+ .dispatch("environment/deleteEnvironmentById", environment.id).then(() => {if (environmentList.value.length > 0) {selectEnvironment(0);diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vueindex 993dc7b684..7482a4dd39 100644--- a/frontend/src/views/EnvironmentDetail.vue+++ b/frontend/src/views/EnvironmentDetail.vue@@ -61,12 +61,9 @@ export default {state.environment = environment;};- const doUpdate = (newEnvironment: Environment) => {+ const doUpdate = (updatedEnvironment: Environment) => {store- .dispatch("environment/patchEnvironmentById", {- environmentId: props.environment.id,- environment: newEnvironment,- })+ .dispatch("environment/patchEnvironment", updatedEnvironment).then((environment) => {assignEnvironment(environment);})diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vueindex 0de66db87d..675c27c1f7 100644--- a/frontend/src/views/InstanceDetail.vue+++ b/frontend/src/views/InstanceDetail.vue@@ -472,9 +472,7 @@ export default {newAdminDataSource: DataSourceNew) => {store- .dispatch("instance/createInstance", {- newInstance,- })+ .dispatch("instance/createInstance", newInstance).then((instance) => {store.dispatch("dataSource/createDataSource", {@@ -505,19 +503,13 @@ export default {updatedAdminDataSource: DataSource) => {store- .dispatch("instance/patchInstanceById", {- instanceId: idFromSlug(props.instanceSlug),- instance: updatedInstance,- })+ .dispatch("instance/patchInstance", updatedInstance).then((instance) => {assignInstance(instance);store- .dispatch("dataSource/patchDataSourceById", {- dataSourceId: {- id: updatedAdminDataSource.id,- instanceId: updatedInstance.id,- },+ .dispatch("dataSource/patchDataSource", {+ instanceId: updatedInstance.id,dataSource: updatedAdminDataSource,}).then((dataSource) => {@@ -543,16 +535,12 @@ export default {const doDelete = () => {store.dispatch("dataSource/deleteDataSourceById", {- dataSourceId: {- id: state.originalAdminDataSource!.id,- instanceId: state.originalInstance!.id,- },+ id: state.originalAdminDataSource!.id,+ instanceId: state.originalInstance!.id,}).then(() => {store- .dispatch("instance/deleteInstanceById", {- instanceId: state.originalInstance!.id,- })+ .dispatch("instance/deleteInstanceById", state.originalInstance!.id).then(() => {store.dispatch("notification/pushNotification", {module: "bytebase",