2024-03-20 16:02:51 -05:00
|
|
|
import { AssetEntity } from 'src/entities/asset.entity';
|
|
|
|
|
import { TagEntity } from 'src/entities/tag.entity';
|
2024-05-22 08:13:36 -04:00
|
|
|
import { UserMetadataEntity } from 'src/entities/user-metadata.entity';
|
2023-02-06 10:24:58 -06:00
|
|
|
import {
|
|
|
|
|
Column,
|
|
|
|
|
CreateDateColumn,
|
|
|
|
|
DeleteDateColumn,
|
|
|
|
|
Entity,
|
|
|
|
|
OneToMany,
|
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
|
UpdateDateColumn,
|
|
|
|
|
} from 'typeorm';
|
2022-02-03 10:06:44 -06:00
|
|
|
|
2024-03-08 17:49:39 -05:00
|
|
|
export enum UserStatus {
|
|
|
|
|
ACTIVE = 'active',
|
|
|
|
|
REMOVING = 'removing',
|
|
|
|
|
DELETED = 'deleted',
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-03 10:06:44 -06:00
|
|
|
@Entity('users')
|
|
|
|
|
export class UserEntity {
|
|
|
|
|
@PrimaryGeneratedColumn('uuid')
|
2022-06-25 19:53:06 +02:00
|
|
|
id!: string;
|
2022-02-03 10:06:44 -06:00
|
|
|
|
2022-07-04 20:20:43 +01:00
|
|
|
@Column({ default: '' })
|
2023-11-11 20:03:32 -05:00
|
|
|
name!: string;
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2022-07-04 20:20:43 +01:00
|
|
|
@Column({ default: false })
|
2022-06-25 19:53:06 +02:00
|
|
|
isAdmin!: boolean;
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2022-12-09 22:16:25 -05:00
|
|
|
@Column({ unique: true })
|
2022-06-25 19:53:06 +02:00
|
|
|
email!: string;
|
2022-02-03 10:06:44 -06:00
|
|
|
|
2023-05-21 23:18:10 -04:00
|
|
|
@Column({ type: 'varchar', unique: true, default: null })
|
|
|
|
|
storageLabel!: string | null;
|
|
|
|
|
|
2022-11-14 21:24:25 -05:00
|
|
|
@Column({ default: '', select: false })
|
2022-06-25 19:53:06 +02:00
|
|
|
password?: string;
|
2022-02-03 10:06:44 -06:00
|
|
|
|
2022-12-26 10:35:52 -05:00
|
|
|
@Column({ default: '' })
|
2022-12-03 22:59:24 -05:00
|
|
|
oauthId!: string;
|
|
|
|
|
|
2022-07-04 20:20:43 +01:00
|
|
|
@Column({ default: '' })
|
2022-06-25 19:53:06 +02:00
|
|
|
profileImagePath!: string;
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2022-07-04 20:20:43 +01:00
|
|
|
@Column({ default: true })
|
2022-06-27 15:13:07 -05:00
|
|
|
shouldChangePassword!: boolean;
|
2022-05-21 02:23:55 -05:00
|
|
|
|
2023-05-30 15:15:56 +02:00
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
|
|
|
createdAt!: Date;
|
2022-11-07 16:53:47 -05:00
|
|
|
|
2023-05-30 15:15:56 +02:00
|
|
|
@DeleteDateColumn({ type: 'timestamptz' })
|
|
|
|
|
deletedAt!: Date | null;
|
2022-12-05 11:56:44 -06:00
|
|
|
|
2024-03-08 17:49:39 -05:00
|
|
|
@Column({ type: 'varchar', default: UserStatus.ACTIVE })
|
|
|
|
|
status!: UserStatus;
|
|
|
|
|
|
2023-02-06 10:24:58 -06:00
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
2023-05-30 15:15:56 +02:00
|
|
|
updatedAt!: Date;
|
2023-02-06 10:24:58 -06:00
|
|
|
|
2022-12-05 11:56:44 -06:00
|
|
|
@OneToMany(() => TagEntity, (tag) => tag.user)
|
|
|
|
|
tags!: TagEntity[];
|
2023-02-26 20:57:34 +01:00
|
|
|
|
|
|
|
|
@OneToMany(() => AssetEntity, (asset) => asset.owner)
|
|
|
|
|
assets!: AssetEntity[];
|
2024-01-12 18:43:36 -06:00
|
|
|
|
|
|
|
|
@Column({ type: 'bigint', nullable: true })
|
|
|
|
|
quotaSizeInBytes!: number | null;
|
|
|
|
|
|
|
|
|
|
@Column({ type: 'bigint', default: 0 })
|
|
|
|
|
quotaUsageInBytes!: number;
|
2024-05-22 08:13:36 -04:00
|
|
|
|
|
|
|
|
@OneToMany(() => UserMetadataEntity, (metadata) => metadata.user)
|
|
|
|
|
metadata!: UserMetadataEntity[];
|
2022-02-03 10:06:44 -06:00
|
|
|
}
|