* fix: type server models * fix: make ParanoidModel generic * fix: ApiKey * fix: Attachment * fix: AuthenticationProvider * fix: Backlink * fix: Collection * fix: Comment * fix: Document * fix: FileOperation * fix: Group * fix: GroupPermission * fix: GroupUser * fix: Integration * fix: IntegrationAuthentication * fix: Notification * fix: Pin * fix: Revision * fix: SearchQuery * fix: Share * fix: Star * fix: Subscription * fix: TypeError * fix: Imports * fix: Team * fix: TeamDomain * fix: User * fix: UserAuthentication * fix: UserPermission * fix: View * fix: WebhookDelivery * fix: WebhookSubscription * Remove type duplication --------- Co-authored-by: Tom Moor <tom.moor@gmail.com>
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import { InferAttributes, InferCreationAttributes } from "sequelize";
|
|
import {
|
|
DataType,
|
|
Table,
|
|
ForeignKey,
|
|
BelongsTo,
|
|
Column,
|
|
} from "sequelize-typescript";
|
|
import { IntegrationService } from "@shared/types";
|
|
import Team from "./Team";
|
|
import User from "./User";
|
|
import IdModel from "./base/IdModel";
|
|
import Encrypted, {
|
|
getEncryptedColumn,
|
|
setEncryptedColumn,
|
|
} from "./decorators/Encrypted";
|
|
import Fix from "./decorators/Fix";
|
|
|
|
@Table({ tableName: "authentications", modelName: "authentication" })
|
|
@Fix
|
|
class IntegrationAuthentication extends IdModel<
|
|
InferAttributes<IntegrationAuthentication>,
|
|
Partial<InferCreationAttributes<IntegrationAuthentication>>
|
|
> {
|
|
@Column(DataType.STRING)
|
|
service: IntegrationService;
|
|
|
|
@Column(DataType.ARRAY(DataType.STRING))
|
|
scopes: string[];
|
|
|
|
@Column(DataType.BLOB)
|
|
@Encrypted
|
|
get token() {
|
|
return getEncryptedColumn(this, "token");
|
|
}
|
|
|
|
set token(value: string) {
|
|
setEncryptedColumn(this, "token", value);
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
|
|
export default IntegrationAuthentication;
|