feat: create document in a specific folder (#1965)

This commit is contained in:
Catalin Pit
2025-08-22 17:12:17 +03:00
committed by GitHub
parent 17b36ac8e4
commit 67501b45cf
8 changed files with 77 additions and 3 deletions

View File

@ -284,6 +284,7 @@ export const documentRouter = router({
globalActionAuth,
recipients,
meta,
folderId,
} = input;
const { remaining } = await getServerLimits({ userId: user.id, teamId });
@ -316,6 +317,7 @@ export const documentRouter = router({
globalAccessAuth,
globalActionAuth,
recipients,
folderId,
},
meta,
requestMetadata: ctx.metadata,

View File

@ -209,6 +209,12 @@ export const ZCreateDocumentV2RequestSchema = z.object({
globalAccessAuth: z.array(ZDocumentAccessAuthTypesSchema).optional(),
globalActionAuth: z.array(ZDocumentActionAuthTypesSchema).optional(),
formValues: ZDocumentFormValuesSchema.optional(),
folderId: z
.string()
.describe(
'The ID of the folder to create the document in. If not provided, the document will be created in the root folder.',
)
.optional(),
recipients: z
.array(
ZCreateRecipientSchema.extend({

View File

@ -339,8 +339,14 @@ export const templateRouter = router({
.output(ZCreateDocumentFromTemplateResponseSchema)
.mutation(async ({ ctx, input }) => {
const { teamId } = ctx;
const { templateId, recipients, distributeDocument, customDocumentDataId, prefillFields } =
input;
const {
templateId,
recipients,
distributeDocument,
customDocumentDataId,
prefillFields,
folderId,
} = input;
ctx.logger.info({
input: {
@ -361,6 +367,7 @@ export const templateRouter = router({
recipients,
customDocumentDataId,
requestMetadata: ctx.metadata,
folderId,
prefillFields,
});

View File

@ -117,6 +117,12 @@ export const ZCreateDocumentFromTemplateRequestSchema = z.object({
'The data ID of an alternative PDF to use when creating the document. If not provided, the PDF attached to the template will be used.',
)
.optional(),
folderId: z
.string()
.describe(
'The ID of the folder to create the document in. If not provided, the document will be created in the root folder.',
)
.optional(),
prefillFields: z
.array(ZFieldMetaPrefillFieldsSchema)
.describe(