import { BaseEntity, transformerJson } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 插件信息
 */
@Entity('plugin_info')
export class PluginInfoEntity extends BaseEntity {
  @Column({ comment: '名称' })
  name: string;

  @Column({ comment: '简介' })
  description: string;

  @Index()
  @Column({ comment: 'Key名' })
  keyName: string;

  @Column({ comment: 'Hook' })
  hook: string;

  @Column({ comment: '描述', type: 'text' })
  readme: string;

  @Column({ comment: '版本' })
  version: string;

  @Column({ comment: 'Logo(base64)', type: 'text', nullable: true })
  logo: string;

  @Column({ comment: '作者' })
  author: string;

  @Column({ comment: '状态 0-禁用 1-启用', default: 0 })
  status: number;

  @Column({ comment: '内容', type: 'json', transformer: transformerJson })
  content: {
    type: 'comm' | 'module';
    data: string;
  };

  @Column({ comment: 'ts内容', type: 'json', transformer: transformerJson })
  tsContent: {
    type: 'ts';
    data: string;
  };

  @Column({
    comment: '插件的plugin.json',
    type: 'json',
    transformer: transformerJson,
    nullable: true,
  })
  pluginJson: any;

  @Column({
    comment: '配置',
    type: 'json',
    transformer: transformerJson,
    nullable: true,
  })
  config: any;
}
