Type server models (#6326)

* 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>
This commit is contained in:
Apoorv Mishra
2024-01-12 22:33:05 +05:30
committed by GitHub
parent 8360c2dec9
commit 7e61a519f1
56 changed files with 337 additions and 171 deletions

View File

@@ -1,7 +1,7 @@
import { InferAttributes, InferCreationAttributes } from "sequelize";
import {
Table,
ForeignKey,
Model,
Column,
PrimaryKey,
IsUUID,
@@ -10,8 +10,10 @@ import {
DataType,
Default,
} from "sequelize-typescript";
import Team from "./Team";
import User from "./User";
import Share from "@server/models/Share";
import Team from "@server/models/Team";
import User from "@server/models/User";
import Model from "@server/models/base/Model";
import Fix from "./decorators/Fix";
@Table({
@@ -20,7 +22,10 @@ import Fix from "./decorators/Fix";
updatedAt: false,
})
@Fix
class SearchQuery extends Model {
class SearchQuery extends Model<
InferAttributes<SearchQuery>,
Partial<InferCreationAttributes<SearchQuery>>
> {
@IsUUID(4)
@PrimaryKey
@Default(DataType.UUIDV4)
@@ -69,11 +74,18 @@ class SearchQuery extends Model {
// associations
@BelongsTo(() => User, "userId")
user: User;
user?: User | null;
@ForeignKey(() => User)
@Column(DataType.UUID)
userId: string;
userId?: string | null;
@BelongsTo(() => Share, "shareId")
share?: Share | null;
@ForeignKey(() => Share)
@Column(DataType.UUID)
shareId?: string | null;
@BelongsTo(() => Team, "teamId")
team: Team;