Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): Replace projectId with name and slug in workspace-role response. #432

Merged
merged 7 commits into from
Sep 17, 2024
Merged
28 changes: 25 additions & 3 deletions apps/api/src/workspace-role/service/workspace-role.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ export class WorkspaceRoleService {
include: {
projects: {
select: {
projectId: true
project: {
select: {
id: true,
slug: true,
name: true
}
}
}
}
}
Expand Down Expand Up @@ -228,7 +234,13 @@ export class WorkspaceRoleService {
include: {
projects: {
select: {
projectId: true
project: {
select: {
id: true,
slug: true,
name: true
}
}
}
}
}
Expand Down Expand Up @@ -443,7 +455,17 @@ export class WorkspaceRoleService {
slug: workspaceRoleSlug
},
include: {
projects: true
projects: {
select: {
project: {
select: {
id: true,
slug: true,
name: true
}
}
}
}
}
})) as WorkspaceRoleWithProjects

Expand Down
24 changes: 20 additions & 4 deletions apps/api/src/workspace-role/workspace-role.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,18 @@ describe('Workspace Role Controller Tests', () => {
updatedAt: expect.any(String),
projects: expect.arrayContaining([
{
projectId: projects[0].id
project: {
id: projects[0].id,
name: projects[0].name,
slug: projects[0].slug
}
},
{
projectId: projects[1].id
project: {
id: projects[1].id,
name: projects[1].name,
slug: projects[1].slug
}
}
])
})
Expand Down Expand Up @@ -654,10 +662,18 @@ describe('Workspace Role Controller Tests', () => {
hasAdminAuthority: true,
projects: expect.arrayContaining([
{
projectId: projects[0].id
project: {
id: projects[0].id,
name: projects[0].name,
slug: projects[0].slug
}
},
{
projectId: projects[1].id
project: {
id: projects[1].id,
name: projects[1].name,
slug: projects[1].slug
}
}
])
})
Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/workspace-role/workspace-role.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { Project, WorkspaceRole } from '@prisma/client'

export interface WorkspaceRoleWithProjects extends WorkspaceRole {
projects: {
projectId: Project['id']
project: {
id: Project['id']
name: Project['name']
slug: Project['slug']
}
}[]
}
Loading