62 lines
1.2 KiB
TypeScript
62 lines
1.2 KiB
TypeScript
import {
|
|
IsEnum,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString
|
|
} from "class-validator";
|
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
|
import { PermissionAction } from '../enums/PermissionAction';
|
|
import { User } from './User';
|
|
|
|
/**
|
|
* Defines the UserAction entity.
|
|
* Will later be used to document a user's actions.
|
|
*/
|
|
@Entity()
|
|
export class UserAction {
|
|
/**
|
|
* Autogenerated unique id (primary key).
|
|
*/
|
|
@PrimaryGeneratedColumn()
|
|
@IsInt()
|
|
id: number;
|
|
|
|
/**
|
|
* The user that performed the action.
|
|
*/
|
|
@ManyToOne(() => User, user => user.actions)
|
|
user: User
|
|
|
|
/**
|
|
* The actions's target (e.g. Track#2)
|
|
*/
|
|
@Column()
|
|
@IsNotEmpty()
|
|
@IsString()
|
|
target: string;
|
|
|
|
/**
|
|
* The actions's action (e.g. UPDATE).
|
|
* Directly pulled from the PermissionAction Enum.
|
|
*/
|
|
@Column({ type: 'varchar' })
|
|
@IsEnum(PermissionAction)
|
|
action: PermissionAction;
|
|
|
|
/**
|
|
* The description of the change (before-> after; e.g. distance:15->17).
|
|
* Will later be defined in more detail.
|
|
*/
|
|
@Column({ nullable: true })
|
|
@IsOptional()
|
|
@IsString()
|
|
changed: string;
|
|
|
|
/**
|
|
* Turns this entity into it's response class.
|
|
*/
|
|
public toResponse() {
|
|
return new Error("NotImplemented");
|
|
}
|
|
} |