import { IsInt, IsOptional, IsString } from "class-validator";
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
/**
 * Defines the StatsClient entity.
 * StatsClients can be used to access the protected parts of the stats api (top runners, donators and so on).
*/
@Entity()
export class StatsClient {
    /**
     * Autogenerated unique id (primary key).
     */
    @PrimaryGeneratedColumn()
    @IsInt()
    id: number;

    /**
     * The clients's description.
     * Mostly for better UX when traceing back stuff.
     */
    @Column({ nullable: true })
    @IsOptional()
    @IsString()
    description?: string;

    /**
     * The client's api key prefix.
     * This is used identitfy a client by it's api key.
     */
    @Column({ unique: true })
    @IsString()
    prefix: string;

    /**
     * The client's api key hash.
     * The api key can be used to authenticate against the /stats/** routes.
     */
    @Column()
    @IsString()
    key: string;

    /**
     * The client's api key in plain text.
     * This will only be used to display the full key on creation and updates.
     */
    @IsString()
    @IsOptional()
    cleartextkey?: string;
}