import { Column, CreateDateColumn, Entity, OneToMany, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; import { Upload } from '../upload/upload.entity'; import { User } from '../user/user.entity'; import { OAuth2ClientURL } from './oauth2-client-url.entity'; @Entity() export class OAuth2Client { @PrimaryGeneratedColumn() id: number; @Column({ type: 'uuid', length: 36, nullable: false, unique: true }) client_id: string; @Column({ type: 'text', nullable: false }) client_secret: string; @Column({ nullable: false }) title: string; @Column({ type: 'text', nullable: true }) description: string; @Column({ type: 'text', nullable: true }) scope: string; @Column({ type: 'text', default: 'authorization_code' }) grants: string; @Column({ default: false }) activated: boolean; @Column({ default: false }) verified: boolean; @CreateDateColumn({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP(6)', }) public created_at: Date; @UpdateDateColumn({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP(6)', onUpdate: 'CURRENT_TIMESTAMP(6)', }) public updated_at: Date; @OneToOne(() => Upload, { nullable: true, onDelete: 'SET NULL' }) public picture: Upload; @OneToOne(() => User, { nullable: true, onDelete: 'SET NULL' }) public owner: User; @OneToMany(() => OAuth2ClientURL, (url) => url.client) public urls: OAuth2ClientURL[]; }