All files / src/models flow-action.model.ts

78.79% Statements 26/33
100% Branches 0/0
22.22% Functions 2/9
77.42% Lines 24/31

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 1161x   1x     1x 1x 1x 1x 1x                                 1x             1x     1x         1x         1x   222x 1x     1x     1x                 1x     1x               1x                                 1x     1x             1x     1x     4x              
import { AnyObject, belongsTo, model, property } from '@loopback/repository';
import { Transform } from 'class-transformer';
import { BaseEntity, Company, Form, User } from '.';
import { Created, Modified } from '../types';
import { DateUtils } from '../utils/date';
import { FlowJourneyPoint } from './flow-journey-point.model';
import { FlowPersona } from './flow-persona.model';
import { Flow } from './flow.model';
import { Status } from './status';
import { TimeZoneTransform } from '@logchain/decorators';
 
@model({
  settings: {
    postgresql: { table: 'flows_action' },
    foreignKeys: {
      fk_flows_action_flows_journey_point_id: {
        name: 'fk_flows_action_flows_journey_point_id',
        entity: 'FlowJourneyPoint',
        entityKey: 'id',
        foreignKey: 'flow_journey_point_id',
        onDelete: 'CASCADE',
        onUpdate: 'RESTRICT'
      },
    },
  },
})
export class FlowAction extends BaseEntity implements Created, Modified {
  @property({
    type: 'string',
    jsonSchema: {
      nullable: true,
    },
  })
  title: string;
 
  @belongsTo(() => Flow, { name: 'flow' })
  flow_id: number;
 
  @belongsTo(() => FlowJourneyPoint, {
    name: 'flow_journey_point',
  })
  flow_journey_point_id: number;
 
  @property({
    type: 'number',
  })
  container_order: number;
 
  @belongsTo(() => Form, { name: 'form' })
  form_id: number;
 
  @belongsTo(() => Company, { name: 'company_actor' })
  company_id: number;
 
  @belongsTo(() => FlowPersona, { name: 'persona' })
  flow_persona_id: number;
 
  @property({
    type: 'number',
    jsonSchema: {
      enum: Object.values(Status.FlowAction),
      default: 0,
    },
  })
  status: number;
 
  @belongsTo(() => User, { name: 'actor' })
  actor_id: number;
 
  @property({
    type: 'object',
    postgresql: {
      dataType: 'jsonb',
    },
  })
  form_data: AnyObject;
 
  is_actor_company: boolean;
  idx_updated: number;
  needed_info: AnyObject[];
  companies: {
    identifier: string;
    persona_id: number;
    name: string;
  }[];
  readonly: boolean;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  @TimeZoneTransform()
  created_date?: Date;
 
  @belongsTo(() => User, { name: 'creator' })
  created_by?: number;
 
  @property({
    type: 'date',
    defaultFn: 'now',
  })
  @TimeZoneTransform()
  modified_date?: Date;
 
  @belongsTo(() => User, { name: 'modifier' })
  modified_by?: number;
 
  constructor(data?: Partial<FlowAction>) {
    super(data);
  }
}
 
export interface FlowActionRelations { }
 
export type FlowActionWithRelations = FlowAction & FlowActionRelations;