mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-07-31 09:07:25 +02:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { Column, Entity, OneToMany, PrimaryColumn, Unique } from 'typeorm';
|
|
import { IsString, Length } from 'class-validator';
|
|
|
|
import type { User } from './User';
|
|
import type { SharedWorkflow } from './SharedWorkflow';
|
|
import type { SharedCredentials } from './SharedCredentials';
|
|
import { AbstractEntity } from './AbstractEntity';
|
|
import { idStringifier } from '../utils/transformers';
|
|
|
|
export type RoleNames = 'owner' | 'member' | 'user' | 'editor';
|
|
export type RoleScopes = 'global' | 'workflow' | 'credential';
|
|
|
|
@Entity()
|
|
@Unique(['scope', 'name'])
|
|
export class Role extends AbstractEntity {
|
|
@PrimaryColumn({ transformer: idStringifier })
|
|
id: string;
|
|
|
|
@Column({ length: 32 })
|
|
@IsString({ message: 'Role name must be of type string.' })
|
|
@Length(1, 32, { message: 'Role name must be 1 to 32 characters long.' })
|
|
name: RoleNames;
|
|
|
|
@Column()
|
|
scope: RoleScopes;
|
|
|
|
@OneToMany('User', 'globalRole')
|
|
globalForUsers: User[];
|
|
|
|
@OneToMany('SharedWorkflow', 'role')
|
|
sharedWorkflows: SharedWorkflow[];
|
|
|
|
@OneToMany('SharedCredentials', 'role')
|
|
sharedCredentials: SharedCredentials[];
|
|
}
|