|
|
import { |
|
|
Entity, |
|
|
PrimaryGeneratedColumn, |
|
|
Column, |
|
|
CreateDateColumn, |
|
|
UpdateDateColumn, |
|
|
OneToMany, |
|
|
OneToOne, |
|
|
} from 'typeorm'; |
|
|
import { Agent } from './Agent'; |
|
|
import { Subscription } from './Subscription'; |
|
|
import { ApiKey } from './ApiKey'; |
|
|
import { Wallet } from './Wallet'; |
|
|
|
|
|
@Entity('users') |
|
|
export class User { |
|
|
@PrimaryGeneratedColumn('uuid') |
|
|
id: string; |
|
|
|
|
|
@Column({ unique: true }) |
|
|
email: string; |
|
|
|
|
|
@Column() |
|
|
password: string; |
|
|
|
|
|
@Column({ nullable: true }) |
|
|
name?: string; |
|
|
|
|
|
@Column({ default: false }) |
|
|
isAdmin: boolean; |
|
|
|
|
|
@Column({ default: false }) |
|
|
isCreator: boolean; |
|
|
|
|
|
@Column({ default: true }) |
|
|
isActive: boolean; |
|
|
|
|
|
@Column({ nullable: true }) |
|
|
passwordResetToken?: string; |
|
|
|
|
|
@Column({ nullable: true }) |
|
|
passwordResetExpires?: Date; |
|
|
|
|
|
@Column({ default: 0 }) |
|
|
failedLoginAttempts: number; |
|
|
|
|
|
@Column({ nullable: true }) |
|
|
lockedUntil?: Date; |
|
|
|
|
|
@OneToMany(() => Agent, (agent) => agent.creator) |
|
|
agents: Agent[]; |
|
|
|
|
|
@OneToMany(() => Subscription, (subscription) => subscription.user) |
|
|
subscriptions: Subscription[]; |
|
|
|
|
|
@OneToMany(() => ApiKey, (apiKey) => apiKey.user) |
|
|
apiKeys: ApiKey[]; |
|
|
|
|
|
@OneToOne(() => Wallet, (wallet) => wallet.user) |
|
|
wallet: Wallet; |
|
|
|
|
|
@CreateDateColumn() |
|
|
createdAt: Date; |
|
|
|
|
|
@UpdateDateColumn() |
|
|
updatedAt: Date; |
|
|
} |
|
|
|