mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
## Description General enhancements for templates. ## Changes Made Added the following changes to the template flow: - Allow adding document meta settings - Allow adding email settings - Allow adding document access & action authentication - Allow adding recipient action authentication - Save the state between template steps similar to how it works for documents Other changes: - Extract common fields between document and template flows - Remove the title field from "Use template" since we now have it as part of the template flow - Add new API endpoint for generating templates ## Testing Performed Added E2E tests for templates and creating documents from templates
39 lines
774 B
TypeScript
39 lines
774 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import type { TemplateWithDetails } from '@documenso/prisma/types/template';
|
|
|
|
export type GetTemplateWithDetailsByIdOptions = {
|
|
id: number;
|
|
userId: number;
|
|
};
|
|
|
|
export const getTemplateWithDetailsById = async ({
|
|
id,
|
|
userId,
|
|
}: GetTemplateWithDetailsByIdOptions): Promise<TemplateWithDetails> => {
|
|
return await prisma.template.findFirstOrThrow({
|
|
where: {
|
|
id,
|
|
OR: [
|
|
{
|
|
userId,
|
|
},
|
|
{
|
|
team: {
|
|
members: {
|
|
some: {
|
|
userId,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
include: {
|
|
templateDocumentData: true,
|
|
templateMeta: true,
|
|
Recipient: true,
|
|
Field: true,
|
|
},
|
|
});
|
|
};
|