Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
For Principal model, use creatorId, updaterId field instead of the full Principal field to avoid recursive issue
天舟29108dad85b7
diff --git a/frontend/src/store/modules/principal.ts b/frontend/src/store/modules/principal.tsindex 361535f508..5c6ffb9211 100644--- a/frontend/src/store/modules/principal.ts+++ b/frontend/src/store/modules/principal.ts@@ -1,7 +1,5 @@import axios from "axios";-import { cloneDeep } from "lodash";import {- UNKNOWN_ID,PrincipalId,Principal,PrincipalNew,@@ -13,24 +11,16 @@ import {empty,EMPTY_ID,PrincipalType,- SYSTEM_BOT_ID,} from "../../types";import { isDevOrDemo, randomString } from "../../utils";function convert(principal: ResourceObject, rootGetters: any): Principal {- const creator = rootGetters["principal/principalById"](- principal.attributes.creatorId- );- const updater = rootGetters["principal/principalById"](- principal.attributes.updaterId- );-const member = rootGetters["member/memberByPrincipalId"](principal.id);return {id: principal.id,- creator,- updater,+ creatorId: principal.attributes.creatorId as PrincipalId,createdTs: principal.attributes.createdTs as number,+ updaterId: principal.attributes.updaterId as PrincipalId,updatedTs: principal.attributes.updatedTs as number,status: principal.attributes.status as PrincipalStatus,type: principal.attributes.type as PrincipalType,@@ -74,20 +64,6 @@ const actions = {async fetchPrincipalList({ state, commit, rootGetters }: any) {const userList: ResourceObject[] = (await axios.get(`/api/principal`)).data.data;-- // Dealing with bootstraping here. The system bot is the first user and we- // assign itself as the creator/updater.- // We also convert the system bot alone first so that the remaining users- // can convert their creater/updater properly.- const systemBot = userList.find((item) => item.id == SYSTEM_BOT_ID);- if (systemBot) {- const theBot = convert(systemBot, rootGetters);- // Use cloneDeep to avoid infinite recursion during JSON.stringify- theBot.creator = cloneDeep(theBot);- theBot.updater = cloneDeep(theBot);- commit("upsertPrincipalInList", theBot);- }-const principalList = userList.map((user) => {return convert(user, rootGetters);});diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex a081ac1a69..f1baf4397f 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -114,7 +114,9 @@ export const unknown = (// Have to omit creator and updater to avoid recursion.const UNKNOWN_PRINCIPAL: Principal = {id: UNKNOWN_ID,+ creatorId: UNKNOWN_ID,createdTs: 0,+ updaterId: UNKNOWN_ID,updatedTs: 0,status: "ACTIVE",type: "END_USER",diff --git a/frontend/src/types/principal.ts b/frontend/src/types/principal.tsindex 84ff2e7517..656905e92c 100644--- a/frontend/src/types/principal.ts+++ b/frontend/src/types/principal.ts@@ -13,9 +13,11 @@ export type Principal = {id: PrincipalId;// Standard fields- creator: Principal;+ // Unlike other models, we use creatorId and updaterId instead of converting+ // them to full principal object to avoid recursive issue.+ creatorId: PrincipalId;createdTs: number;- updater: Principal;+ updaterId: PrincipalId;updatedTs: number;// Domain specific fields