import { UsersSession } from 'src/core/sessions';
import { OPERATION } from './base.constants';
import { SelectQueryBuilder } from 'typeorm';

export interface EventTopics {
  topic: any;
  data?: any;
  relations?: string[];
}

export interface validateRelations {
  // nama relasi
  relation: string;

  // query digunakan untuk query optional jika ingin specifik data
  query?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>;

  // query ini sama dengan yang diatas, akan tetapi ini khusus untuk ManyToOne relation
  singleQuery?: [string, any, any];

  // custom message
  message?: string;
}

export interface columnUniques {
  column: string;
  query?: any;
}

export interface IEvent<Entity = any> {
  id: string;
  old: null | Entity;
  data: null | Entity;
  user: UsersSession;
  description: null | string;
  module: string;
  op: OPERATION;
}

export interface IEventAuth {
  id: string;
  type: string;
  timestamp: number;
}
