2023-01-12 06:02:26 -06:00
|
|
|
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
|
|
|
|
import { id } from '../id.js';
|
|
|
|
|
2023-01-12 20:03:54 -06:00
|
|
|
type CondFormulaValueAnd = {
|
|
|
|
type: 'and';
|
|
|
|
values: RoleCondFormulaValue[];
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueOr = {
|
|
|
|
type: 'or';
|
|
|
|
values: RoleCondFormulaValue[];
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueNot = {
|
|
|
|
type: 'not';
|
|
|
|
value: RoleCondFormulaValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueIsLocal = {
|
|
|
|
type: 'isLocal';
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueIsRemote = {
|
|
|
|
type: 'isRemote';
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueCreatedLessThan = {
|
|
|
|
type: 'createdLessThan';
|
|
|
|
sec: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueCreatedMoreThan = {
|
|
|
|
type: 'createdMoreThan';
|
|
|
|
sec: number;
|
|
|
|
};
|
|
|
|
|
2023-01-13 17:27:23 -06:00
|
|
|
type CondFormulaValueFollowersLessThanOrEq = {
|
|
|
|
type: 'followersLessThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueFollowersMoreThanOrEq = {
|
|
|
|
type: 'followersMoreThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueFollowingLessThanOrEq = {
|
|
|
|
type: 'followingLessThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
type CondFormulaValueFollowingMoreThanOrEq = {
|
|
|
|
type: 'followingMoreThanOrEq';
|
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
2023-01-12 20:03:54 -06:00
|
|
|
export type RoleCondFormulaValue =
|
|
|
|
CondFormulaValueAnd |
|
|
|
|
CondFormulaValueOr |
|
|
|
|
CondFormulaValueNot |
|
|
|
|
CondFormulaValueIsLocal |
|
|
|
|
CondFormulaValueIsRemote |
|
|
|
|
CondFormulaValueCreatedLessThan |
|
2023-01-13 17:27:23 -06:00
|
|
|
CondFormulaValueCreatedMoreThan |
|
|
|
|
CondFormulaValueFollowersLessThanOrEq |
|
|
|
|
CondFormulaValueFollowersMoreThanOrEq |
|
|
|
|
CondFormulaValueFollowingLessThanOrEq |
|
|
|
|
CondFormulaValueFollowingMoreThanOrEq;
|
2023-01-12 20:03:54 -06:00
|
|
|
|
2023-01-12 06:02:26 -06:00
|
|
|
@Entity()
|
|
|
|
export class Role {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The created date of the Role.',
|
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The updated date of the Role.',
|
|
|
|
})
|
|
|
|
public updatedAt: Date;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
comment: 'The last used date of the Role.',
|
|
|
|
})
|
|
|
|
public lastUsedAt: Date;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public name: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 1024,
|
|
|
|
})
|
|
|
|
public description: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256, nullable: true,
|
|
|
|
})
|
|
|
|
public color: string | null;
|
|
|
|
|
2023-01-12 20:03:54 -06:00
|
|
|
@Column('enum', {
|
|
|
|
enum: ['manual', 'conditional'],
|
|
|
|
default: 'manual',
|
|
|
|
})
|
|
|
|
public target: 'manual' | 'conditional';
|
|
|
|
|
|
|
|
@Column('jsonb', {
|
|
|
|
default: { },
|
|
|
|
})
|
|
|
|
public condFormula: RoleCondFormulaValue;
|
|
|
|
|
2023-01-12 06:02:26 -06:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isPublic: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isModerator: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public isAdministrator: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public canEditMembersByModerator: boolean;
|
|
|
|
|
|
|
|
@Column('jsonb', {
|
|
|
|
default: { },
|
|
|
|
})
|
2023-01-15 05:52:53 -06:00
|
|
|
public policies: Record<string, {
|
2023-01-12 06:02:26 -06:00
|
|
|
useDefault: boolean;
|
2023-01-15 04:10:39 -06:00
|
|
|
priority: number;
|
2023-01-12 06:02:26 -06:00
|
|
|
value: any;
|
|
|
|
}>;
|
|
|
|
}
|