Skip to content

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

Return Principal object directly instead of including it in the relationship

天舟ecce679ed075
diff --git a/backend/api/activity.go b/backend/api/activity.go
index 3c1bbbfc80..4aedd711ad 100644
--- a/backend/api/activity.go
+++ b/backend/api/activity.go
@@ -34,10 +34,10 @@ type Activity struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/dataSource.go b/backend/api/dataSource.go
index 803bb57570..cd17f9b29e 100644
--- a/backend/api/dataSource.go
+++ b/backend/api/dataSource.go
@@ -27,10 +27,10 @@ type DataSource struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/database.go b/backend/api/database.go
index a56ae100ed..1d9dc9d6a4 100644
--- a/backend/api/database.go
+++ b/backend/api/database.go
@@ -32,10 +32,10 @@ type Database struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/environment.go b/backend/api/environment.go
index 4365f1e9b4..7d34ce9647 100644
--- a/backend/api/environment.go
+++ b/backend/api/environment.go
@@ -8,10 +8,10 @@ type Environment struct {
// Standard fields
RowStatus RowStatus `jsonapi:"attr,rowStatus"`
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/instance.go b/backend/api/instance.go
index b48752078b..1809a45423 100644
--- a/backend/api/instance.go
+++ b/backend/api/instance.go
@@ -8,10 +8,10 @@ type Instance struct {
// Standard fields
RowStatus RowStatus `jsonapi:"attr,rowStatus"`
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/issue.go b/backend/api/issue.go
index 93e0ce17e0..b4d6cd6aad 100644
--- a/backend/api/issue.go
+++ b/backend/api/issue.go
@@ -55,10 +55,10 @@ type Issue struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
@@ -74,7 +74,7 @@ type Issue struct {
Type IssueType `jsonapi:"attr,type"`
Description string `jsonapi:"attr,description"`
AssigneeId int `jsonapi:"attr,assigneeId"`
- Assignee *Principal `jsonapi:"relation,assignee"`
+ Assignee *Principal `jsonapi:"attr,assignee"`
SubscriberIdList []int `jsonapi:"attr,subscriberIdList"`
Sql string `jsonapi:"attr,sql"`
RollbackSql string `jsonapi:"attr,rollbackSql"`
diff --git a/backend/api/member.go b/backend/api/member.go
index be2faeb767..7540f4271e 100644
--- a/backend/api/member.go
+++ b/backend/api/member.go
@@ -23,21 +23,21 @@ func (e Role) String() string {
}
type Member struct {
- ID int `jsonapi:"primary,principal"`
+ ID int `jsonapi:"primary,member"`
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
// Domain specific fields
Role Role `jsonapi:"attr,role"`
PrincipalId int
- Principal *Principal `jsonapi:"relation,principal"`
+ Principal *Principal `jsonapi:"attr,principal"`
}
type MemberCreate struct {
diff --git a/backend/api/pipeline.go b/backend/api/pipeline.go
index 08d746fcdf..3e2e4af019 100644
--- a/backend/api/pipeline.go
+++ b/backend/api/pipeline.go
@@ -28,10 +28,10 @@ type Pipeline struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/principal.go b/backend/api/principal.go
index d928782bd5..5d5b7e0d27 100644
--- a/backend/api/principal.go
+++ b/backend/api/principal.go
@@ -1,6 +1,10 @@
package api
-import "context"
+import (
+ "context"
+ "encoding/json"
+ "strconv"
+)
const SYSTEM_BOT_ID = 1
@@ -57,6 +61,36 @@ type Principal struct {
Email string `jsonapi:"attr,email"`
// No need to return to the client
PasswordHash string
+ // From member
+ Role Role
+}
+
+// Customize the Principal Marshal method so the returned object
+// can map directly to the frontend Principal object without any conversion.
+func (p *Principal) MarshalJSON() ([]byte, error) {
+ return json.Marshal(&struct {
+ ID string `json:"id"`
+ CreatorId string `json:"creatorId"`
+ CreatedTs int64 `json:"createdTs"`
+ UpdaterId string `json:"updaterId"`
+ UpdatedTs int64 `json:"updatedTs"`
+ Status PrincipalStatus `json:"status"`
+ Type PrincipalType `json:"type"`
+ Name string `json:"name"`
+ Email string `json:"email"`
+ Role Role `json:"role"`
+ }{
+ ID: strconv.Itoa(p.ID),
+ CreatorId: strconv.Itoa(p.CreatorId),
+ CreatedTs: p.CreatedTs,
+ UpdaterId: strconv.Itoa(p.UpdaterId),
+ UpdatedTs: p.UpdatedTs,
+ Status: p.Status,
+ Type: p.Type,
+ Name: p.Name,
+ Email: p.Email,
+ Role: p.Role,
+ })
}
type PrincipalCreate struct {
diff --git a/backend/api/project.go b/backend/api/project.go
index d125d3d48a..b524a1b651 100644
--- a/backend/api/project.go
+++ b/backend/api/project.go
@@ -8,10 +8,10 @@ type Project struct {
// Standard fields
RowStatus RowStatus `jsonapi:"attr,rowStatus"`
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/stage.go b/backend/api/stage.go
index 8462043900..2fc63f99f8 100644
--- a/backend/api/stage.go
+++ b/backend/api/stage.go
@@ -30,10 +30,10 @@ type Stage struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/api/task.go b/backend/api/task.go
index 33e1f7273b..be3adb2aaf 100644
--- a/backend/api/task.go
+++ b/backend/api/task.go
@@ -48,10 +48,10 @@ type Task struct {
// Standard fields
CreatorId int
- Creator *Principal `jsonapi:"relation,creator"`
+ Creator *Principal `jsonapi:"attr,creator"`
CreatedTs int64 `jsonapi:"attr,createdTs"`
UpdaterId int
- Updater *Principal `jsonapi:"relation,updater"`
+ Updater *Principal `jsonapi:"attr,updater"`
UpdatedTs int64 `jsonapi:"attr,updatedTs"`
WorkspaceId int
diff --git a/backend/server/member.go b/backend/server/member.go
index f2dcbf33a2..77ae76aac2 100644
--- a/backend/server/member.go
+++ b/backend/server/member.go
@@ -124,7 +124,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {
func (s *Server) ComposeMemberRelationship(ctx context.Context, member *api.Member, includeList []string) error {
var err error
- member.Creator, err = s.ComposePrincipalById(context.Background(), member.CreatorId, includeList)
+ member.Creator, err = s.ComposePrincipalById(ctx, member.CreatorId, includeList)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch creator for member ID: %v", member.ID)).SetInternal(err)
}
diff --git a/backend/server/principal.go b/backend/server/principal.go
index 388abd05d4..a49c86fca4 100644
--- a/backend/server/principal.go
+++ b/backend/server/principal.go
@@ -110,6 +110,25 @@ func (s *Server) ComposePrincipalById(ctx context.Context, id int, includeList [
}
return nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch principal ID: %v", id)).SetInternal(err)
}
+ workspaceId := api.DEFAULT_WORKPSACE_ID
+ memberFind := &api.MemberFind{
+ WorkspaceId: &workspaceId,
+ PrincipalId: &principal.ID,
+ }
+
+ // We don't store the system bot membership for the workspace, thus returns OWNER role on the fly here.
+ if principal.ID == api.SYSTEM_BOT_ID {
+ principal.Role = api.Owner
+ } else {
+ member, err := s.MemberService.FindMember(ctx, memberFind)
+ if err != nil {
+ if bytebase.ErrorCode(err) == bytebase.ENOTFOUND {
+ return nil, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Membership not found for principal: %v", principal.Name))
+ }
+ return nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch membership for principal: %v", principal.Name)).SetInternal(err)
+ }
+ principal.Role = member.Role
+ }
return principal, nil
}
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index b2ac680bfe..b8cee43204 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -18,31 +18,8 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): Activity {
- const creatorId = (activity.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (activity.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
-
- for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (activity.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (activity.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
- }
+ const creator = activity.attributes.creator as Principal;
+ const updater = activity.attributes.updater as Principal;
return {
...(activity.attributes as Omit<Activity, "id" | "creator" | "updater">),
diff --git a/frontend/src/store/modules/dataSource.ts b/frontend/src/store/modules/dataSource.ts
index 8c48c1325a..af0c4e91e9 100644
--- a/frontend/src/store/modules/dataSource.ts
+++ b/frontend/src/store/modules/dataSource.ts
@@ -16,6 +16,7 @@ import {
DataSourcePatch,
EMPTY_ID,
empty,
+ Principal,
} from "../../types";
function convert(
@@ -23,12 +24,8 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): DataSource {
- const creator = rootGetters["principal/principalById"](
- dataSource.attributes.creatorId
- );
- const updater = rootGetters["principal/principalById"](
- dataSource.attributes.updaterId
- );
+ const creator = dataSource.attributes.creator as Principal;
+ const updater = dataSource.attributes.updater as Principal;
const databaseId = (
dataSource.relationships!.database.data as ResourceIdentifier
).id;
diff --git a/frontend/src/store/modules/database.ts b/frontend/src/store/modules/database.ts
index f7ab6c59a6..dc7bd6694e 100644
--- a/frontend/src/store/modules/database.ts
+++ b/frontend/src/store/modules/database.ts
@@ -24,15 +24,8 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): Database {
- const creatorId = (database.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (database.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
+ const creator = database.attributes.creator as Principal;
+ const updater = database.attributes.updater as Principal;
// We first populate the id for instance, project and dataSourceList.
// And if we also provide the detail info for those objects in the includedList,
@@ -58,20 +51,6 @@ function convert(
}
for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (database.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (database.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
if (item.type == "instance" && item.id == instanceId) {
instance = rootGetters["instance/convert"](item, includedList);
}
@@ -85,9 +64,11 @@ function convert(
const databaseWithoutDataSourceList = {
...(database.attributes as Omit<
Database,
- "id" | "instance" | "project" | "dataSourceList"
+ "id" | "creator" | "updater" | "instance" | "project" | "dataSourceList"
>),
id: database.id,
+ creator,
+ updater,
instance,
project,
dataSourceList: [],
diff --git a/frontend/src/store/modules/environment.ts b/frontend/src/store/modules/environment.ts
index 3351880530..1490c140c7 100644
--- a/frontend/src/store/modules/environment.ts
+++ b/frontend/src/store/modules/environment.ts
@@ -20,38 +20,14 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): Environment {
- const creatorId = (
- environment.relationships!.creator.data as ResourceIdentifier
- ).id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (
- environment.relationships!.updater.data as ResourceIdentifier
- ).id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
-
- for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (environment.relationships!.creator.data as ResourceIdentifier).id ==
- item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (environment.relationships!.updater.data as ResourceIdentifier).id ==
- item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
- }
+ const creator = environment.attributes.creator as Principal;
+ const updater = environment.attributes.updater as Principal;
return {
- ...(environment.attributes as Omit<Environment, "id">),
+ ...(environment.attributes as Omit<
+ Environment,
+ "id" | "creator" | "updater"
+ >),
id: environment.id,
creator,
updater,
diff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.ts
index 2ff52dac79..794edb4a6e 100644
--- a/frontend/src/store/modules/instance.ts
+++ b/frontend/src/store/modules/instance.ts
@@ -21,15 +21,8 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): Instance {
- const creatorId = (instance.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (instance.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
+ const creator = instance.attributes.creator as Principal;
+ const updater = instance.attributes.updater as Principal;
const environmentId = (
instance.relationships!.environment.data as ResourceIdentifier
@@ -40,20 +33,6 @@ function convert(
let username = undefined;
let password = undefined;
for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (instance.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (instance.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
if (
item.type == "dataSource" &&
item.attributes.type == "ADMIN" &&
diff --git a/frontend/src/store/modules/issue.ts b/frontend/src/store/modules/issue.ts
index 1b4bc87f73..51e814268c 100644
--- a/frontend/src/store/modules/issue.ts
+++ b/frontend/src/store/modules/issue.ts
@@ -29,20 +29,9 @@ function convert(
}
);
- const creatorId = (issue.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (issue.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
-
- const assigneeId = (issue.relationships!.assignee.data as ResourceIdentifier)
- .id;
- let assignee: Principal = unknown("PRINCIPAL") as Principal;
- assignee.id = assigneeId;
+ const creator = issue.attributes.creator as Principal;
+ const updater = issue.attributes.updater as Principal;
+ const assignee = issue.attributes.assignee as Principal;
const projectId = (issue.relationships!.project.data as ResourceIdentifier)
.id;
@@ -55,27 +44,6 @@ function convert(
pipeline.id = pipelineId;
for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (issue.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (issue.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (issue.relationships!.assignee.data as ResourceIdentifier).id == item.id
- ) {
- assignee = rootGetters["principal/convert"](item);
- }
-
if (
item.type == "project" &&
(issue.relationships!.project.data as ResourceIdentifier).id == item.id
diff --git a/frontend/src/store/modules/member.ts b/frontend/src/store/modules/member.ts
index 501484cec2..310f58215f 100644
--- a/frontend/src/store/modules/member.ts
+++ b/frontend/src/store/modules/member.ts
@@ -19,43 +19,9 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): Member {
- const creatorId = (member.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (member.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
-
- const principalId = (member.relationships!.updater.data as ResourceIdentifier)
- .id;
- let principal: Principal = unknown("PRINCIPAL") as Principal;
- principal.id = principalId;
-
- for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (member.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (member.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (member.relationships!.principal.data as ResourceIdentifier).id == item.id
- ) {
- principal = rootGetters["principal/convert"](item);
- }
- }
+ const creator = member.attributes.creator as Principal;
+ const updater = member.attributes.updater as Principal;
+ const principal = member.attributes.principal as Principal;
return {
...(member.attributes as Omit<
diff --git a/frontend/src/store/modules/pipeline.ts b/frontend/src/store/modules/pipeline.ts
index 317088028e..eb0c44da09 100644
--- a/frontend/src/store/modules/pipeline.ts
+++ b/frontend/src/store/modules/pipeline.ts
@@ -21,32 +21,11 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): Pipeline {
- const creatorId = (pipeline.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (pipeline.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
+ const creator = pipeline.attributes.creator as Principal;
+ const updater = pipeline.attributes.updater as Principal;
const stageList: Stage[] = [];
for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (pipeline.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (pipeline.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
if (item.type == "stage") {
const stageIdList = pipeline.relationships!.stage
.data as ResourceIdentifier[];
diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.ts
index bf2462f786..b53a33b2c0 100644
--- a/frontend/src/store/modules/project.ts
+++ b/frontend/src/store/modules/project.ts
@@ -24,31 +24,8 @@ function convert(
includedList: ResourceObject[],
rootGetters: any
): Project {
- const creatorId = (project.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (project.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
-
- for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (project.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (project.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
- }
+ const creator = project.attributes.creator as Principal;
+ const updater = project.attributes.updater as Principal;
const attrs = project.attributes as Omit<
Project,
diff --git a/frontend/src/store/modules/stage.ts b/frontend/src/store/modules/stage.ts
index 9b45dd41c3..0cd0251941 100644
--- a/frontend/src/store/modules/stage.ts
+++ b/frontend/src/store/modules/stage.ts
@@ -24,15 +24,8 @@ function convertPartial(
includedList: ResourceObject[],
rootGetters: any
): Omit<Stage, "pipeline"> {
- const creatorId = (stage.relationships!.creator.data as ResourceIdentifier)
- .id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (stage.relationships!.updater.data as ResourceIdentifier)
- .id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
+ const creator = stage.attributes.creator as Principal;
+ const updater = stage.attributes.updater as Principal;
const environmentId = (
stage.relationships!.environment.data as ResourceIdentifier
@@ -42,20 +35,6 @@ function convertPartial(
const taskList: Task[] = [];
for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (stage.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (stage.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
if (
item.type == "environment" &&
(stage.relationships!.environment.data as ResourceIdentifier).id ==
diff --git a/frontend/src/store/modules/task.ts b/frontend/src/store/modules/task.ts
index b2194cd0cb..aaf2dc4523 100644
--- a/frontend/src/store/modules/task.ts
+++ b/frontend/src/store/modules/task.ts
@@ -24,33 +24,14 @@ function convertPartial(
includedList: ResourceObject[],
rootGetters: any
): Omit<Task, "pipeline" | "stage"> {
- const creatorId = (task.relationships!.creator.data as ResourceIdentifier).id;
- let creator: Principal = unknown("PRINCIPAL") as Principal;
- creator.id = creatorId;
-
- const updaterId = (task.relationships!.updater.data as ResourceIdentifier).id;
- let updater: Principal = unknown("PRINCIPAL") as Principal;
- updater.id = updaterId;
+ const creator = task.attributes.creator as Principal;
+ const updater = task.attributes.updater as Principal;
const databaseId = (task.relationships!.database.data as ResourceIdentifier)
.id;
let database: Database = empty("DATABASE") as Database;
database.id = databaseId;
for (const item of includedList || []) {
- if (
- item.type == "principal" &&
- (task.relationships!.creator.data as ResourceIdentifier).id == item.id
- ) {
- creator = rootGetters["principal/convert"](item);
- }
-
- if (
- item.type == "principal" &&
- (task.relationships!.updater.data as ResourceIdentifier).id == item.id
- ) {
- updater = rootGetters["principal/convert"](item);
- }
-
if (
item.type == "database" &&
(task.relationships!.database.data as ResourceIdentifier).id == item.id