import { Entity, Column, PrimaryGeneratedColumn, Index } from 'typeorm'
import { ObjectType, Field, Int, ID } from 'type-graphql'

import { ScalarObject } from '@things-factory/shell'

@Entity()
@ObjectType({ description: 'Entity for EvaluationStatus' })
@Index('ix_evaluation_status_0', (evaluationStatus: EvaluationStatus) => [evaluationStatus.type, evaluationStatus.done])
export class EvaluationStatus {
  @PrimaryGeneratedColumn('uuid')
  @Field(type => ID)
  readonly id: string

  @Column()
  @Field()
  type: string

  @Column({ type: 'boolean', default: false })
  @Field(type => Boolean)
  done: boolean

  @Column('simple-json', { nullable: true })
  @Field(type => ScalarObject, { nullable: true })
  result?: any
}
