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:
@@ -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({
|
||||
|
||||
@@ -78,7 +78,6 @@ export default async function documentCreator({
|
||||
editorVersion,
|
||||
collectionId,
|
||||
teamId: user.teamId,
|
||||
userId: user.id,
|
||||
createdAt,
|
||||
updatedAt: updatedAt ?? createdAt,
|
||||
lastModifiedById: user.id,
|
||||
|
||||
@@ -40,10 +40,8 @@ describe("starCreator", () => {
|
||||
});
|
||||
|
||||
await Star.create({
|
||||
teamId: document.teamId,
|
||||
documentId: document.id,
|
||||
userId: user.id,
|
||||
createdById: user.id,
|
||||
index: "P",
|
||||
});
|
||||
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user