* 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
74 lines
1.4 KiB
TypeScript
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;
|