All files / src/dtos flow.external.dto.ts

80.65% Statements 25/31
0% Branches 0/6
0% Functions 0/4
76% Lines 19/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 681x 1x 1x 1x     1x   1x     1x                           1x       1x   1x     1x     1x       1x         1x   1x     1x     1x     1x       1x            
import { model } from '@loopback/repository';
import { Exclude, Expose, Transform, Type } from 'class-transformer';
import { BaseEntity } from '@logchain/models';
import { Constants } from '@logchain/configs';
 
@Exclude()
export class FlowExternalJourneyPointActionDto extends BaseEntity {
  @Expose()
  id: number;
 
  @Expose({ name: 'type_id' })
  form_id: number;
 
  @Transform(
    ({ value, obj }) => {
      switch (obj.form_id) {
        case Constants.Form.Document:
          return value;
        default:
          return Constants.FormLabel[obj.form_id] ?? '';
      }
    },
    { groups: ['public'] },
  )
  @Expose({ name: 'type_name' })
  title: string;
}
 
@Exclude()
export class FlowExternalJourneyPointDto extends BaseEntity {
  @Expose()
  id: number;
 
  @Expose()
  name: string;
 
  @Expose()
  order: number;
 
  @Expose()
  @Type(() => FlowExternalJourneyPointActionDto)
  actions: FlowExternalJourneyPointActionDto[];
}
 
@Exclude()
@model({ name: 'FlowDto' })
export class FlowExternalDto extends BaseEntity {
  @Expose()
  id: number;
 
  @Expose()
  name: string;
 
  @Expose({ name: 'status_code' })
  status: number;
 
  @Expose()
  status_name: string;
 
  @Expose()
  @Type(() => FlowExternalJourneyPointDto)
  journey_points: FlowExternalJourneyPointDto[];
 
  constructor(data?: Partial<FlowExternalDto>) {
    super(data);
  }
}