import { Domain, ScalarAny } from '@things-factory/shell'
import { User } from '@things-factory/auth-base'
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
import { Pose, PoseInput } from '../robotarm/robotarm-type'

// type TrackableObject {
//   id: String
//   name: String
//   domain: Domain
//   description: String
//   type: String
//   endpoint: String
//   status: Int
//   active: Boolean
//   config: Object
//   poiOffset: Pose
//   updater: User
//   creator: User
//   updatedAt: String
//   createdAt: String
// }
@ObjectType()
export class TrackableObject {
  @Field(type => ID, { nullable: true })
  id?: string

  @Field()
  name: string

  @Field(type => Domain)
  domain: Domain

  @Field({ nullable: true })
  description?: string

  @Field({ nullable: true })
  type?: string

  @Field({ nullable: true })
  endpoint?: string

  @Field(type => Int, { nullable: true })
  status?: number

  @Field({ nullable: true })
  active: boolean

  // TODO: check object
  @Field(type => ScalarAny, { nullable: true })
  config?: any

  @Field(type => Pose, { nullable: true })
  poiOffset?: Pose

  @Field(type => User, { nullable: true })
  updater: User

  @Field(type => User, { nullable: true })
  creator: User

  @Field({ nullable: true })
  updatedAt: string

  @Field({ nullable: true })
  createdAt: string
}

// type TrackableObjectList {
//   items: [TrackableObject]
//   total: Int
// }
@ObjectType()
export class TrackableObjectList {
  @Field(type => [TrackableObject])
  items: TrackableObject[]

  @Field(type => Int)
  total: number
}

// input TrackableObjectStateInput {
//   pose: PoseInput
//   roi: String
// }
@InputType()
export class TrackableObjectStateInput {
  @Field(type => PoseInput, { nullable: true })
  pose?: PoseInput

  @Field({ nullable: true })
  roi?: string
}
