installation.ts 953 B

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