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,5 +1,5 @@
import { Comment, Event } from "@server/models";
import { buildDocument, buildUser } from "@server/test/factories";
import { buildComment, buildDocument, buildUser } from "@server/test/factories";
import commentDestroyer from "./commentDestroyer";
describe("commentDestroyer", () => {
@@ -12,24 +12,9 @@ describe("commentDestroyer", () => {
teamId: user.teamId,
});
const comment = await Comment.create({
teamId: document.teamId,
const comment = await buildComment({
userId: user.id,
documentId: document.id,
data: {
type: "doc",
content: [
{
type: "paragraph",
content: [
{
type: "text",
text: "test",
},
],
},
],
},
createdById: user.id,
});
await commentDestroyer({

View File

@@ -78,7 +78,6 @@ export default async function documentCreator({
editorVersion,
collectionId,
teamId: user.teamId,
userId: user.id,
createdAt,
updatedAt: updatedAt ?? createdAt,
lastModifiedById: user.id,

View File

@@ -40,10 +40,8 @@ describe("starCreator", () => {
});
await Star.create({
teamId: document.teamId,
documentId: document.id,
userId: user.id,
createdById: user.id,
index: "P",
});

View File

@@ -13,10 +13,8 @@ describe("starDestroyer", () => {
});
const star = await Star.create({
teamId: document.teamId,
documentId: document.id,
userId: user.id,
createdById: user.id,
index: "P",
});

View File

@@ -13,10 +13,8 @@ describe("starUpdater", () => {
});
let star = await Star.create({
teamId: document.teamId,
documentId: document.id,
userId: user.id,
createdById: user.id,
index: "P",
});

View File

@@ -1,4 +1,4 @@
import { Transaction } from "sequelize";
import { InferCreationAttributes, Transaction } from "sequelize";
import slugify from "slugify";
import { RESERVED_SUBDOMAINS } from "@shared/utils/domains";
import { traceFunction } from "@server/logging/tracing";
@@ -50,7 +50,7 @@ async function teamCreator({
name,
avatarUrl,
authenticationProviders,
},
} as Partial<InferCreationAttributes<Team>>,
{
include: ["authenticationProviders"],
transaction,

View File

@@ -70,7 +70,8 @@ describe("teamPermanentDeleter", () => {
expect(
await Collection.unscoped().count({
where: {
id: document.collectionId,
// buildDocument() above guarantees this to be non-null
id: document.collectionId!,
},
paranoid: false,
})

View File

@@ -58,7 +58,6 @@ export default async function userInviter({
teamId: user.teamId,
name: invite.name,
email: invite.email,
service: null,
isAdmin: invite.role === UserRole.Admin,
isViewer: invite.role === UserRole.Viewer,
invitedById: user.id,

View File

@@ -1,3 +1,4 @@
import { InferCreationAttributes } from "sequelize";
import InviteAcceptedEmail from "@server/emails/templates/InviteAcceptedEmail";
import {
DomainNotAllowedError,
@@ -236,9 +237,8 @@ export default async function userProvisioner({
isViewer: isAdmin === true ? false : defaultUserRole === "viewer",
teamId,
avatarUrl,
service: null,
authentications: authentication ? [authentication] : [],
},
} as Partial<InferCreationAttributes<User>>,
{
include: "authentications",
transaction,