import { PipelineTask } from './../pipeline-task.entity'; import { PipelineUnits } from '../enums/pipeline-units.enum'; import { Field, HideField, ObjectType } from '@nestjs/graphql'; import { Type } from 'class-transformer'; @ObjectType() export class PipelineTaskLogMessage { @HideField() task: PipelineTask; @Field(() => PipelineUnits, { nullable: true }) unit?: PipelineUnits; @Field() @Type(() => Date) time: Date; @Field() message: string; @Field() isError: boolean; static create( task: PipelineTask, unit: PipelineUnits, message: string, isError: boolean, ) { return Object.assign(new PipelineTaskLogMessage(), { task, message, time: new Date(), unit, isError, }); } }