import { Column, Entity, PrimaryColumn } from 'typeorm';
import {
  encodeBigNumberKey,
  decodeBigNumberKey,
} from '../utils/big-number-key';

@Entity('event_triggers', { schema: 'public' })
export class EventTriggerEntity {
  @PrimaryColumn({
    name: 'project_id',
    nullable: false,
    transformer: {
      from: (x) => encodeBigNumberKey(x),
      to: (x) => decodeBigNumberKey(x),
    },
  })
  projectId: string;

  @PrimaryColumn('uuid', {
    name: 'id',
    nullable: false,
  })
  id: string;

  @Column('uuid', {
    array: true,
    name: 'filter_type_ids',
    nullable: true,
  })
  filterTypeIds: string[] | null;

  @Column('varchar', {
    name: 'filter_name',
    nullable: true,
  })
  filterName: string | null;

  @Column('bigint', {
    name: 'target_block_key',
    nullable: true,
  })
  targetBlockKey: string | null;

  @Column('varchar', {
    name: 'target_prop',
    nullable: true,
  })
  targetProp: string | null;

  @Column('varchar', {
    name: 'event_name',
    nullable: false,
  })
  eventName: string;
}
