mirror of
https://github.com/documenso/documenso.git
synced 2025-11-09 20:12:31 +10:00
chore: update envelope handling and improve field positioning in PDF processing
This commit is contained in:
@ -35,6 +35,7 @@ import { getFileServerSide } from '../../universal/upload/get-file.server';
|
||||
import { putPdfFileServerSide } from '../../universal/upload/put-file.server';
|
||||
import { extractDerivedDocumentMeta } from '../../utils/document';
|
||||
import { createDocumentAuthOptions, createRecipientAuthOptions } from '../../utils/document-auth';
|
||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||
import { buildTeamWhereQuery } from '../../utils/teams';
|
||||
import { incrementDocumentId, incrementTemplateId } from '../envelope/increment-id';
|
||||
import { getTeamSettings } from '../team/get-team-settings';
|
||||
@ -427,16 +428,19 @@ export const createEnvelope = async ({
|
||||
? await makeNormalizedPdf(Buffer.from(buffer))
|
||||
: Buffer.from(buffer);
|
||||
|
||||
const envelopeOptions: EnvelopeIdOptions = {
|
||||
type: 'envelopeId',
|
||||
id: createdEnvelope.id,
|
||||
};
|
||||
|
||||
await insertFieldsFromPlaceholdersInPDF(
|
||||
pdfToProcess,
|
||||
userId,
|
||||
teamId,
|
||||
{
|
||||
type: 'envelopeId',
|
||||
id: createdEnvelope.id,
|
||||
},
|
||||
envelopeOptions,
|
||||
requestMetadata,
|
||||
envelopeItem.id,
|
||||
createdEnvelope.recipients,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -51,9 +51,9 @@ type PlaceholderInfo = {
|
||||
type FieldToCreate = TFieldAndMeta & {
|
||||
envelopeItemId?: string;
|
||||
recipientId: number;
|
||||
pageNumber: number;
|
||||
pageX: number;
|
||||
pageY: number;
|
||||
page: number;
|
||||
positionX: number;
|
||||
positionY: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
@ -327,9 +327,9 @@ export const insertFieldsFromPlaceholdersInPDF = async (
|
||||
...placeholder.fieldAndMeta,
|
||||
envelopeItemId,
|
||||
recipientId: recipient.id,
|
||||
pageNumber: placeholder.page,
|
||||
pageX: xPercent,
|
||||
pageY: yPercent,
|
||||
page: placeholder.page,
|
||||
positionX: xPercent,
|
||||
positionY: yPercent,
|
||||
width: widthPercent,
|
||||
height: finalHeightPercent,
|
||||
});
|
||||
|
||||
@ -4,8 +4,7 @@ import type { Recipient } from '@prisma/client';
|
||||
import { match } from 'ts-pattern';
|
||||
|
||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import { createDocumentRecipients } from '@documenso/lib/server-only/recipient/create-document-recipients';
|
||||
import { createTemplateRecipients } from '@documenso/lib/server-only/recipient/create-template-recipients';
|
||||
import { createEnvelopeRecipients } from '@documenso/lib/server-only/recipient/create-envelope-recipients';
|
||||
import type { ApiRequestMetadata } from '@documenso/lib/universal/extract-request-metadata';
|
||||
import { mapSecondaryIdToTemplateId } from '@documenso/lib/utils/envelope';
|
||||
import type { EnvelopeIdOptions } from '@documenso/lib/utils/envelope';
|
||||
@ -229,7 +228,7 @@ export const createRecipientsFromPlaceholders = async (
|
||||
id: envelope.id,
|
||||
};
|
||||
|
||||
const { recipients } = await createDocumentRecipients({
|
||||
const { recipients } = await createEnvelopeRecipients({
|
||||
userId,
|
||||
teamId,
|
||||
id: envelopeId,
|
||||
@ -242,11 +241,17 @@ export const createRecipientsFromPlaceholders = async (
|
||||
.with(EnvelopeType.TEMPLATE, async () => {
|
||||
const templateId = mapSecondaryIdToTemplateId(envelope.secondaryId ?? '');
|
||||
|
||||
const { recipients } = await createTemplateRecipients({
|
||||
const envelopeId: EnvelopeIdOptions = {
|
||||
type: 'templateId',
|
||||
id: templateId,
|
||||
};
|
||||
|
||||
const { recipients } = await createEnvelopeRecipients({
|
||||
userId,
|
||||
teamId,
|
||||
templateId,
|
||||
id: envelopeId,
|
||||
recipients: recipientsToCreateFiltered,
|
||||
requestMetadata,
|
||||
});
|
||||
|
||||
return recipients;
|
||||
|
||||
Reference in New Issue
Block a user