mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
- Updated DocumentEditForm to include attachments in the document data. - Modified getDocumentWithDetailsById to fetch attachments. - Updated ZDocumentSchema to validate attachments. - Enhanced AddSettingsFormPartial to handle attachments with default values and updated field names.
42 lines
894 B
TypeScript
42 lines
894 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
|
import { getDocumentWhereInput } from './get-document-by-id';
|
|
|
|
export type GetDocumentWithDetailsByIdOptions = {
|
|
documentId: number;
|
|
userId: number;
|
|
teamId?: number;
|
|
};
|
|
|
|
export const getDocumentWithDetailsById = async ({
|
|
documentId,
|
|
userId,
|
|
teamId,
|
|
}: GetDocumentWithDetailsByIdOptions) => {
|
|
const documentWhereInput = await getDocumentWhereInput({
|
|
documentId,
|
|
userId,
|
|
teamId,
|
|
});
|
|
|
|
const document = await prisma.document.findFirst({
|
|
where: documentWhereInput,
|
|
include: {
|
|
documentData: true,
|
|
documentMeta: true,
|
|
recipients: true,
|
|
fields: true,
|
|
attachments: true,
|
|
},
|
|
});
|
|
|
|
if (!document) {
|
|
throw new AppError(AppErrorCode.NOT_FOUND, {
|
|
message: 'Document not found',
|
|
});
|
|
}
|
|
|
|
return document;
|
|
};
|