All files / src/models flow-journey-point.model.ts

91.89% Statements 34/37
100% Branches 0/0
66.67% Functions 6/9
91.43% Lines 32/35

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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 1601x   1x                   1x 1x                                 1x   1x           1x         1x               1x         1x         1x         1x                 1x                 1x           1x             1x         1x         1x     1x             1x     1x   232x 1x   232x         1x   232x         1x       232x 1x   232x 1x   7x                        
import { AnyObject, belongsTo, hasMany, hasOne, model, property } from '@loopback/repository';
import { Transform } from 'class-transformer';
import {
  BaseEntity,
  FlowAction,
  FlowGroup,
  FlowPersona,
  FlowReference,
  Persona,
  User,
} from '.';
import { DateUtils } from '../utils/date';
import { Flow } from './flow.model';
import { TimeZoneTransform } from '@logchain/decorators';
 
@model({
  settings: {
    postgresql: { table: 'flows_journey_point' },
    foreignKeys: {
      fk_flows_journey_point_flows_id: {
        name: 'fk_flows_journey_point_flows_id',
        entity: 'Flow',
        entityKey: 'id',
        foreignKey: 'flow_id',
        onDelete: 'CASCADE',
        onUpdate: 'RESTRICT'
      },
    },
  },
})
export class FlowJourneyPoint extends BaseEntity {
  @belongsTo(() => Flow, { name: 'flow' })
  flow_id?: number;
 
  @property({
    type: 'number',
    required: true,
  })
  persona_id: number;
 
  @property({
    type: 'number',
  })
  flow_persona_id: number;
 
  @property({
    jsonSchema: {
      nullable: true,
      default: false,
    },
  })
  validator_is_required: boolean;
 
  @property({
    type: 'number',
  })
  validator_flow_persona_id: number;
 
  @property({
    type: 'number',
  })
  container_order: number;
 
  @property({
    type: 'number',
  })
  container_interval: number;
 
  @property({
    type: 'array',
    itemType: 'object',
    postgresql: {
      dataType: 'jsonb',
    },
  })
  container_info: AnyObject[];
 
  @property({
    type: 'string',
    required: true,
    jsonSchema: {
      maxLength: 200,
    },
  })
  name: string;
 
  @property({
    type: 'number',
    required: true,
  })
  order: number;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  @TimeZoneTransform()
  created_date: Date;
 
  @property({
    type: 'date',
  })
  expected_date: Date;
 
  @property({
    type: 'string',
  })
  reason_for_change: string;
 
  @belongsTo(() => User, { name: 'creator' })
  created_by: number;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  @TimeZoneTransform()
  modified_date: Date;
 
  @belongsTo(() => User, { name: 'modifier' })
  modified_by?: number;
 
  @hasOne(() => Persona, { keyTo: 'id', keyFrom: 'persona_id', name: 'persona' })
  persona: Persona;
 
  @hasOne(() => FlowPersona, {
    keyTo: 'id',
    keyFrom: 'flow_persona_id',
    name: 'flow_persona',
  })
  flow_persona: FlowPersona;
 
  @hasOne(() => FlowPersona, {
    keyTo: 'id',
    keyFrom: 'validator_flow_persona_id',
    name: 'validator_flow_persona',
  })
  validator_flow_persona: FlowPersona;
 
  groups?: FlowGroup[];
  
  @hasMany(() => FlowAction, {keyTo: 'flow_journey_point_id'})
  actions?: FlowAction[];
 
  @hasMany(() => FlowAction, {keyTo: 'flow_journey_point_id'})
  ref_documents?: FlowReference[];
  constructor(data?: Partial<FlowJourneyPoint>) {
    super(data);
  }
}
 
export interface FlowJourneyPointRelations {
  // describe navigational properties here
  creator?: User;
  modifier?: User;
}
 
export type FlowJourneyPointWithRelations = FlowJourneyPoint &
  FlowJourneyPointRelations;