import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Transformation } from './transformation';
import { TransformationTypeName } from './transformation-type-name';

/**
 * This entity describes a transformation type.
 * Possible type: translation, decensor, collection, ...
 */
@Entity()
export class TransformationType implements IIdentifiableEntity, IMultiNamedEntity, IDescribableEntity {
  @PrimaryGeneratedColumn()
  public id!: number;

  @Column({
    nullable: false,
    default: '',
  })
  public nameCanonical!: string;

  @OneToMany(
    () => TransformationTypeName,
    (transformationTypeName: TransformationTypeName) => transformationTypeName.entity
  )
  public names!: Promise<TransformationTypeName[]>;

  @Column({
    nullable: false,
    default: '',
  })
  public description!: string;

  /**
   * the transformations of this type
   */
  @OneToMany(() => Transformation, (transformation: Transformation) => transformation.type)
  public transformations!: Promise<Transformation[]>;

  /**
   * if that transformation conserves the tags of the original work
   */
  @Column({
    nullable: false,
    default: false,
  })
  public conservesTags!: boolean;
}
