feat(core): Rebuild project roles to load from the database (#17909)

This commit is contained in:
Guillaume Jacquart
2025-08-28 11:00:31 +02:00
committed by GitHub
parent ab7998b441
commit f757790394
63 changed files with 546 additions and 305 deletions

View File

@@ -1,3 +1,5 @@
import { PROJECT_OWNER_ROLE_SLUG } from '@n8n/permissions';
import { ChangeUserRoleInProject } from '../change-user-role-in-project.dto';
describe('ChangeUserRoleInProject', () => {
@@ -38,7 +40,7 @@ describe('ChangeUserRoleInProject', () => {
},
{
name: 'personal owner role',
request: { role: 'project:personalOwner' },
request: { role: PROJECT_OWNER_ROLE_SLUG },
expectedErrorPath: ['role'],
},
])('should reject $name', ({ request, expectedErrorPath }) => {

View File

@@ -1,6 +1,6 @@
import { projectRoleSchema } from '@n8n/permissions';
import { teamRoleSchema } from '@n8n/permissions';
import { Z } from 'zod-class';
export class ChangeUserRoleInProject extends Z.class({
role: projectRoleSchema.exclude(['project:personalOwner']),
role: teamRoleSchema,
}) {}

View File

@@ -1,4 +1,4 @@
import { projectRoleSchema } from '@n8n/permissions';
import { teamRoleSchema } from '@n8n/permissions';
import { z } from 'zod';
export const projectNameSchema = z.string().min(1).max(255);
@@ -16,6 +16,6 @@ export const projectDescriptionSchema = z.string().max(512);
export const projectRelationSchema = z.object({
userId: z.string().min(1),
role: projectRoleSchema.exclude(['project:personalOwner']),
role: teamRoleSchema,
});
export type ProjectRelation = z.infer<typeof projectRelationSchema>;