import {
  Column,
  Entity,
  PrimaryColumn
} from 'typeorm';

export type ServerPluginEventDirection = 'clientToServer' | 'serverRelay' | 'p2pHint';
export type ServerPluginEventScope = 'server' | 'channel' | 'user' | 'plugin';

@Entity('server_plugin_event_definitions')
export class ServerPluginEventDefinitionEntity {
  @PrimaryColumn('text')
  serverId!: string;

  @PrimaryColumn('text')
  pluginId!: string;

  @PrimaryColumn('text')
  eventName!: string;

  @Column('text')
  direction!: ServerPluginEventDirection;

  @Column('text')
  scope!: ServerPluginEventScope;

  @Column('text', { nullable: true })
  schemaJson!: string | null;

  @Column('integer')
  maxPayloadBytes!: number;

  @Column('text', { nullable: true })
  rateLimitJson!: string | null;

  @Column('integer')
  createdAt!: number;

  @Column('integer')
  updatedAt!: number;
}
