Files
outline/server/models/Integration.ts
Tom Moor ac07724f21 chore: Synchronizing refactor and small fixes from enterprise codebase (#3634)
* chore: Syncronizing refactor and small fixes from enterprise codebase

* fix
2022-06-05 00:59:41 -07:00

74 lines
1.4 KiB
TypeScript

import {
ForeignKey,
BelongsTo,
Column,
Table,
DataType,
Scopes,
} from "sequelize-typescript";
import Collection from "./Collection";
import IntegrationAuthentication from "./IntegrationAuthentication";
import Team from "./Team";
import User from "./User";
import IdModel from "./base/IdModel";
import Fix from "./decorators/Fix";
@Scopes(() => ({
withAuthentication: {
include: [
{
model: IntegrationAuthentication,
as: "authentication",
required: true,
},
],
},
}))
@Table({ tableName: "integrations", modelName: "integration" })
@Fix
class Integration extends IdModel {
@Column
type: string;
@Column
service: string;
@Column(DataType.JSONB)
settings: any;
@Column(DataType.ARRAY(DataType.STRING))
events: string[];
// associations
@BelongsTo(() => User, "userId")
user: User;
@ForeignKey(() => User)
@Column(DataType.UUID)
userId: string;
@BelongsTo(() => Team, "teamId")
team: Team;
@ForeignKey(() => Team)
@Column(DataType.UUID)
teamId: string;
@BelongsTo(() => Collection, "collectionId")
collection: Collection;
@ForeignKey(() => Collection)
@Column(DataType.UUID)
collectionId: string;
@BelongsTo(() => IntegrationAuthentication, "authenticationId")
authentication: IntegrationAuthentication;
@ForeignKey(() => IntegrationAuthentication)
@Column(DataType.UUID)
authenticationId: string;
}
export default Integration;