installation.ts 951 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Installation as SlackInstallation } from '@slack/oauth';
  2. import {
  3. Required,
  4. } from '@tsed/schema';
  5. import {
  6. Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn,
  7. } from 'typeorm';
  8. @Entity()
  9. export class Installation {
  10. @PrimaryGeneratedColumn()
  11. readonly id: number;
  12. @Column({ type: 'json' })
  13. @Required()
  14. data: SlackInstallation;
  15. @CreateDateColumn()
  16. readonly createdAt: Date;
  17. @UpdateDateColumn()
  18. readonly updatedAt: Date;
  19. @Column({ nullable: true })
  20. isEnterpriseInstall?: boolean;
  21. @Column({ nullable: true, unique: true })
  22. teamId?: string;
  23. @Column({ nullable: true, unique: true })
  24. enterpriseId?: string;
  25. setData(slackInstallation: SlackInstallation): void {
  26. this.data = slackInstallation;
  27. this.isEnterpriseInstall = slackInstallation.isEnterpriseInstall;
  28. this.teamId = slackInstallation.team?.id;
  29. this.enterpriseId = slackInstallation.enterprise?.id;
  30. }
  31. }