fix: cleanup

This commit is contained in:
David Nguyen
2025-10-13 16:02:22 +11:00
parent 6f70548bb5
commit 50572435ad
12 changed files with 53 additions and 35 deletions

View File

@ -99,19 +99,13 @@ export const run = async ({
});
// This is the same case as above.
let envelopeItems: typeof envelope.envelopeItems = await io.runTask(
'get-document-data-id', // Todo: Envelopes [PRE-MAIN] - Fix these messed up types.
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-explicit-any
async (): Promise<any> => {
return envelope.envelopeItems.map((envelopeItem) => ({
...envelopeItem,
fields: envelopeItem.field.map((field) => ({
...field,
positionX: Number(field.positionX),
positionY: Number(field.positionY),
width: Number(field.width),
height: Number(field.height),
})),
let envelopeItems = await io.runTask(
'get-document-data-id',
// eslint-disable-next-line @typescript-eslint/require-await
async () => {
// eslint-disable-next-line unused-imports/no-unused-vars
return envelope.envelopeItems.map(({ field, ...rest }) => ({
...rest,
}));
},
);
@ -186,16 +180,25 @@ export const run = async ({
const newDocumentData = await Promise.all(
envelopeItems.map(async (envelopeItem) =>
io.runTask('decorate-and-sign-pdf', async () =>
decorateAndSignPdf({
io.runTask('decorate-and-sign-pdf', async () => {
const envelopeItemFields = envelope.envelopeItems.find(
(item) => item.id === envelopeItem.id,
)?.field;
if (!envelopeItemFields) {
throw new Error(`Envelope item fields not found for envelope item ${envelopeItem.id}`);
}
return decorateAndSignPdf({
envelope,
envelopeItem,
envelopeItemFields,
isRejected,
rejectionReason,
certificateData,
auditLogData,
}),
),
});
}),
),
);
@ -293,7 +296,8 @@ export const run = async ({
type DecorateAndSignPdfOptions = {
envelope: Pick<Envelope, 'id' | 'title' | 'useLegacyFieldInsertion' | 'internalVersion'>;
envelopeItem: EnvelopeItem & { documentData: DocumentData; field: Field[] };
envelopeItem: EnvelopeItem & { documentData: DocumentData };
envelopeItemFields: Field[];
isRejected: boolean;
rejectionReason: string;
certificateData: Buffer | null;
@ -306,6 +310,7 @@ type DecorateAndSignPdfOptions = {
const decorateAndSignPdf = async ({
envelope,
envelopeItem,
envelopeItemFields,
isRejected,
rejectionReason,
certificateData,
@ -348,7 +353,7 @@ const decorateAndSignPdf = async ({
});
}
for (const field of envelopeItem.field) {
for (const field of envelopeItemFields) {
if (field.inserted) {
if (envelope.internalVersion === 2) {
await insertFieldInPDFV2(pdfDoc, field);

View File

@ -257,7 +257,6 @@ const injectFormValuesIntoDocument = async (
id: envelopeItem.id,
},
data: {
// Todo: Envelopes [PRE-MAIN] - Should this also replace the initial data? Because if it's resealed we use the initial data thus lose the form values.
documentDataId: newDocumentData.id,
},
});

View File

@ -88,7 +88,7 @@ export const createEnvelopeFields = async ({
// The item to attach the fields to MUST belong to the document.
if (
field.envelopeItemId &&
!envelope.envelopeItems.find((envelopeItem) => envelopeItem.id === field.envelopeItemId) // Todo: Migration test this
!envelope.envelopeItems.find((envelopeItem) => envelopeItem.id === field.envelopeItemId)
) {
throw new AppError(AppErrorCode.INVALID_REQUEST, {
message: 'Item to attach fields to must belong to the document',

View File

@ -395,7 +395,6 @@ export const createDocumentFromTemplate = async ({
const oldEnvelopeItemToNewEnvelopeItemIdMap: Record<string, string> = {};
// Duplicate the envelope item data.
// Todo: Envelopes - Ask if it's okay to just use the documentDataId? Or should it be duplicated?
// Note: This is duplicated in createDocumentFromDirectTemplate
const envelopeItemsToCreate = await Promise.all(
template.envelopeItems.map(async (item, i) => {
@ -424,9 +423,6 @@ export const createDocumentFromTemplate = async ({
const buffer = await getFileServerSide(documentDataToDuplicate);
// Todo: Envelopes [PRE-MAIN] - Should we normalize? Should be part of the upload.
// const normalizedPdf = await makeNormalizedPdf(Buffer.from(buffer));
const titleToUse = item.title || finalEnvelopeTitle;
const duplicatedFile = await putPdfFileServerSide({

View File

@ -3301,7 +3301,6 @@ msgstr ""
msgid "Document found in your account"
msgstr "Dokument in Ihrem Konto gefunden"
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
#: apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx
msgid "Document ID"
msgstr "Dokument-ID"
@ -3962,6 +3961,10 @@ msgstr ""
msgid "Envelope Duplicated"
msgstr ""
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
msgid "Envelope ID"
msgstr ""
#: apps/remix/app/components/dialogs/envelope-redistribute-dialog.tsx
msgid "Envelope resent"
msgstr ""

View File

@ -3296,7 +3296,6 @@ msgstr "Document external ID updated"
msgid "Document found in your account"
msgstr "Document found in your account"
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
#: apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx
msgid "Document ID"
msgstr "Document ID"
@ -3957,6 +3956,10 @@ msgstr "Envelope distributed"
msgid "Envelope Duplicated"
msgstr "Envelope Duplicated"
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
msgid "Envelope ID"
msgstr "Envelope ID"
#: apps/remix/app/components/dialogs/envelope-redistribute-dialog.tsx
msgid "Envelope resent"
msgstr "Envelope resent"

View File

@ -3301,7 +3301,6 @@ msgstr ""
msgid "Document found in your account"
msgstr "Documento encontrado en tu cuenta"
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
#: apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx
msgid "Document ID"
msgstr "ID del documento"
@ -3962,6 +3961,10 @@ msgstr ""
msgid "Envelope Duplicated"
msgstr ""
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
msgid "Envelope ID"
msgstr ""
#: apps/remix/app/components/dialogs/envelope-redistribute-dialog.tsx
msgid "Envelope resent"
msgstr ""

View File

@ -3301,7 +3301,6 @@ msgstr ""
msgid "Document found in your account"
msgstr "Document trouvé dans votre compte"
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
#: apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx
msgid "Document ID"
msgstr "ID du document"
@ -3962,6 +3961,10 @@ msgstr ""
msgid "Envelope Duplicated"
msgstr ""
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
msgid "Envelope ID"
msgstr ""
#: apps/remix/app/components/dialogs/envelope-redistribute-dialog.tsx
msgid "Envelope resent"
msgstr ""

View File

@ -3301,7 +3301,6 @@ msgstr ""
msgid "Document found in your account"
msgstr "Documento trovato nel tuo account"
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
#: apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx
msgid "Document ID"
msgstr "ID del documento"
@ -3962,6 +3961,10 @@ msgstr ""
msgid "Envelope Duplicated"
msgstr ""
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
msgid "Envelope ID"
msgstr ""
#: apps/remix/app/components/dialogs/envelope-redistribute-dialog.tsx
msgid "Envelope resent"
msgstr ""

View File

@ -3301,7 +3301,6 @@ msgstr ""
msgid "Document found in your account"
msgstr "Dokument znaleziony na Twoim koncie"
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
#: apps/remix/app/routes/_authenticated+/t.$teamUrl+/documents.$id.logs.tsx
msgid "Document ID"
msgstr "Identyfikator dokumentu"
@ -3962,6 +3961,10 @@ msgstr ""
msgid "Envelope Duplicated"
msgstr ""
#: apps/remix/app/routes/_internal+/[__htmltopdf]+/audit-log.tsx
msgid "Envelope ID"
msgstr ""
#: apps/remix/app/components/dialogs/envelope-redistribute-dialog.tsx
msgid "Envelope resent"
msgstr ""