chore: Typescript database models (#2886)

closes #2798
This commit is contained in:
Tom Moor
2022-01-06 18:24:28 -08:00
committed by GitHub
parent d3cbf250e6
commit b20a341f0c
207 changed files with 5624 additions and 5315 deletions

View File

@@ -1,4 +1,5 @@
import { Attachment } from "@server/models";
import { Document } from "@server/models";
import Attachment from "@server/models/Attachment";
import parseAttachmentIds from "@server/utils/parseAttachmentIds";
import { getSignedUrl } from "@server/utils/s3";
import presentUser from "./user";
@@ -25,7 +26,7 @@ async function replaceImageAttachments(text: string) {
}
export default async function present(
document: any,
document: Document,
options: Options | null | undefined = {}
) {
options = {
@@ -36,7 +37,8 @@ export default async function present(
const text = options.isPublic
? await replaceImageAttachments(document.text)
: document.text;
const data = {
const data: Record<string, any> = {
id: document.id,
url: document.url,
urlId: document.urlId,
@@ -70,9 +72,7 @@ export default async function present(
if (!options.isPublic) {
data.collectionId = document.collectionId;
data.parentDocumentId = document.parentDocumentId;
// @ts-expect-error ts-migrate(2322) FIXME: Type 'UserPresentation | null | undefined' is not ... Remove this comment to see the full error message
data.createdBy = presentUser(document.createdBy);
// @ts-expect-error ts-migrate(2322) FIXME: Type 'UserPresentation | null | undefined' is not ... Remove this comment to see the full error message
data.updatedBy = presentUser(document.updatedBy);
data.collaboratorIds = document.collaboratorIds;
}