mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
* add tests * ci: Setup cypress tasks for resetting DB, and setting up an owner * add test tests to check for settings * add more tests * clean up * rename tag * update test id Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm';
|
|
import { IsString, Length } from 'class-validator';
|
|
|
|
import { User } from './User';
|
|
import { SharedWorkflow } from './SharedWorkflow';
|
|
import { SharedCredentials } from './SharedCredentials';
|
|
import { AbstractEntity } from './AbstractEntity';
|
|
|
|
export type RoleNames = 'owner' | 'member' | 'user' | 'editor';
|
|
export type RoleScopes = 'global' | 'workflow' | 'credential';
|
|
|
|
@Entity()
|
|
@Unique(['scope', 'name'])
|
|
export class Role extends AbstractEntity {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@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, (user) => user.globalRole)
|
|
globalForUsers: User[];
|
|
|
|
@OneToMany(() => SharedWorkflow, (sharedWorkflow) => sharedWorkflow.role)
|
|
sharedWorkflows: SharedWorkflow[];
|
|
|
|
@OneToMany(() => SharedCredentials, (sharedCredentials) => sharedCredentials.role)
|
|
sharedCredentials: SharedCredentials[];
|
|
}
|