Files
outline/server/models/Integration.ts
Tom Moor 8bb88b8550 chore: Audit of all model column validations (#3757)
* chore: Updating all model validations before the white-hatters get to it ;)

* test

* Remove isUrl validation, thinking about it need to account for minio and other weird urls here
2022-07-09 08:04:40 -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: Record<string, 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;