Compare commits

...

10 Commits

Author SHA1 Message Date
0977c16e33 v2.0.5 2025-11-08 16:03:59 +11:00
88d5a636c3 fix: show legacy ids on template and document view page (#2153)
<img width="557" height="455" alt="image"
src="https://github.com/user-attachments/assets/7b669f4a-c6c5-4fdc-bf10-da0def7b0b3f"
/>
2025-11-08 16:03:26 +11:00
1e6292b1d9 v2.0.4 2025-11-08 13:58:11 +11:00
d65866156d fix: remove parallel steps (#2152) 2025-11-08 13:57:26 +11:00
fe8915162f v2.0.3 2025-11-08 12:53:50 +11:00
37a2634aca feat: support optimizeParallelism for inngest jobs (#2151) 2025-11-08 12:53:13 +11:00
eff7d90f43 v2.0.2 2025-11-08 00:48:31 +11:00
db5524f8ce fix: resolve issue with sealing task on inngest (#2146)
Currently on inngest the sealing task fails during decoration stating
that it can not find the step "xxx"

My running theory is that this was due to it being a
Promise.all(map(...)) even though that isn't explicitly disallowed.

This change turns it into a for loop collecting promises to be awaited
after the fact.

Local inngest testing looks promising.
2025-11-08 00:48:13 +11:00
3d539b20ad v2.0.1 2025-11-07 23:42:03 +11:00
48626b9169 fix: support utf8 filenames download (#2145) 2025-11-07 23:41:31 +11:00
10 changed files with 90 additions and 29 deletions

View File

@ -7,6 +7,7 @@ import { DateTime } from 'luxon';
import { useIsMounted } from '@documenso/lib/client-only/hooks/use-is-mounted'; import { useIsMounted } from '@documenso/lib/client-only/hooks/use-is-mounted';
import type { TEnvelope } from '@documenso/lib/types/envelope'; import type { TEnvelope } from '@documenso/lib/types/envelope';
import { mapSecondaryIdToDocumentId } from '@documenso/lib/utils/envelope';
export type DocumentPageViewInformationProps = { export type DocumentPageViewInformationProps = {
userId: number; userId: number;
@ -40,6 +41,10 @@ export const DocumentPageViewInformation = ({
.setLocale(i18n.locales?.[0] || i18n.locale) .setLocale(i18n.locales?.[0] || i18n.locale)
.toRelative(), .toRelative(),
}, },
{
description: msg`Document ID (Legacy)`,
value: mapSecondaryIdToDocumentId(envelope.secondaryId),
},
]; ];
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isMounted, envelope, userId]); }, [isMounted, envelope, userId]);

View File

@ -7,11 +7,13 @@ import type { User } from '@prisma/client';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import { useIsMounted } from '@documenso/lib/client-only/hooks/use-is-mounted'; import { useIsMounted } from '@documenso/lib/client-only/hooks/use-is-mounted';
import { mapSecondaryIdToTemplateId } from '@documenso/lib/utils/envelope';
export type TemplatePageViewInformationProps = { export type TemplatePageViewInformationProps = {
userId: number; userId: number;
template: { template: {
userId: number; userId: number;
secondaryId: string;
createdAt: Date; createdAt: Date;
updatedAt: Date; updatedAt: Date;
user: Pick<User, 'id' | 'name' | 'email'>; user: Pick<User, 'id' | 'name' | 'email'>;
@ -43,6 +45,10 @@ export const TemplatePageViewInformation = ({
.setLocale(i18n.locales?.[0] || i18n.locale) .setLocale(i18n.locales?.[0] || i18n.locale)
.toRelative(), .toRelative(),
}, },
{
description: msg`Template ID (Legacy)`,
value: mapSecondaryIdToTemplateId(template.secondaryId),
},
]; ];
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isMounted, template, userId]); }, [isMounted, template, userId]);

View File

@ -41,6 +41,7 @@
"@simplewebauthn/server": "^9.0.3", "@simplewebauthn/server": "^9.0.3",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",
"colord": "^2.9.3", "colord": "^2.9.3",
"content-disposition": "^0.5.4",
"framer-motion": "^10.12.8", "framer-motion": "^10.12.8",
"hono": "4.7.0", "hono": "4.7.0",
"hono-rate-limiter": "^0.4.2", "hono-rate-limiter": "^0.4.2",
@ -87,6 +88,7 @@
"@rollup/plugin-node-resolve": "^16.0.0", "@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-typescript": "^12.1.2", "@rollup/plugin-typescript": "^12.1.2",
"@simplewebauthn/types": "^9.0.1", "@simplewebauthn/types": "^9.0.1",
"@types/content-disposition": "^0.5.9",
"@types/formidable": "^2.0.6", "@types/formidable": "^2.0.6",
"@types/luxon": "^3.3.1", "@types/luxon": "^3.3.1",
"@types/node": "^20", "@types/node": "^20",
@ -104,5 +106,5 @@
"vite-plugin-babel-macros": "^1.0.6", "vite-plugin-babel-macros": "^1.0.6",
"vite-tsconfig-paths": "^5.1.4" "vite-tsconfig-paths": "^5.1.4"
}, },
"version": "2.0.0" "version": "2.0.5"
} }

View File

@ -1,4 +1,5 @@
import { type DocumentDataType, DocumentStatus } from '@prisma/client'; import { type DocumentDataType, DocumentStatus } from '@prisma/client';
import contentDisposition from 'content-disposition';
import { type Context } from 'hono'; import { type Context } from 'hono';
import { sha256 } from '@documenso/lib/universal/crypto'; import { sha256 } from '@documenso/lib/universal/crypto';
@ -34,7 +35,7 @@ export const handleEnvelopeItemFileRequest = async ({
const etag = Buffer.from(sha256(documentDataToUse)).toString('hex'); const etag = Buffer.from(sha256(documentDataToUse)).toString('hex');
if (c.req.header('If-None-Match') === etag) { if (c.req.header('If-None-Match') === etag && !isDownload) {
return c.body(null, 304); return c.body(null, 304);
} }
@ -58,7 +59,6 @@ export const handleEnvelopeItemFileRequest = async ({
if (status === DocumentStatus.COMPLETED) { if (status === DocumentStatus.COMPLETED) {
c.header('Cache-Control', 'public, max-age=31536000, immutable'); c.header('Cache-Control', 'public, max-age=31536000, immutable');
} else { } else {
// Set a tiny 1 minute cache, with must-revalidate to ensure the client always checks for updates.
c.header('Cache-Control', 'public, max-age=0, must-revalidate'); c.header('Cache-Control', 'public, max-age=0, must-revalidate');
} }
} }
@ -69,7 +69,7 @@ export const handleEnvelopeItemFileRequest = async ({
const suffix = version === 'signed' ? '_signed.pdf' : '.pdf'; const suffix = version === 'signed' ? '_signed.pdf' : '.pdf';
const filename = `${baseTitle}${suffix}`; const filename = `${baseTitle}${suffix}`;
c.header('Content-Disposition', `attachment; filename="${filename}"`); c.header('Content-Disposition', contentDisposition(filename));
// For downloads, prevent caching to ensure fresh data // For downloads, prevent caching to ensure fresh data
c.header('Cache-Control', 'no-cache, no-store, must-revalidate'); c.header('Cache-Control', 'no-cache, no-store, must-revalidate');

15
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@documenso/root", "name": "@documenso/root",
"version": "2.0.0", "version": "2.0.5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@documenso/root", "name": "@documenso/root",
"version": "2.0.0", "version": "2.0.5",
"workspaces": [ "workspaces": [
"apps/*", "apps/*",
"packages/*" "packages/*"
@ -100,7 +100,7 @@
}, },
"apps/remix": { "apps/remix": {
"name": "@documenso/remix", "name": "@documenso/remix",
"version": "2.0.0", "version": "2.0.5",
"dependencies": { "dependencies": {
"@cantoo/pdf-lib": "^2.5.2", "@cantoo/pdf-lib": "^2.5.2",
"@documenso/api": "*", "@documenso/api": "*",
@ -129,6 +129,7 @@
"@simplewebauthn/server": "^9.0.3", "@simplewebauthn/server": "^9.0.3",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",
"colord": "^2.9.3", "colord": "^2.9.3",
"content-disposition": "^0.5.4",
"framer-motion": "^10.12.8", "framer-motion": "^10.12.8",
"hono": "4.7.0", "hono": "4.7.0",
"hono-rate-limiter": "^0.4.2", "hono-rate-limiter": "^0.4.2",
@ -175,6 +176,7 @@
"@rollup/plugin-node-resolve": "^16.0.0", "@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-typescript": "^12.1.2", "@rollup/plugin-typescript": "^12.1.2",
"@simplewebauthn/types": "^9.0.1", "@simplewebauthn/types": "^9.0.1",
"@types/content-disposition": "^0.5.9",
"@types/formidable": "^2.0.6", "@types/formidable": "^2.0.6",
"@types/luxon": "^3.3.1", "@types/luxon": "^3.3.1",
"@types/node": "^20", "@types/node": "^20",
@ -12315,6 +12317,13 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/@types/content-disposition": {
"version": "0.5.9",
"resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.9.tgz",
"integrity": "sha512-8uYXI3Gw35MhiVYhG3s295oihrxRyytcRHjSjqnqZVDDy/xcGBRny7+Xj1Wgfhv5QzRtN2hB2dVRBUX9XW3UcQ==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/cross-spawn": { "node_modules/@types/cross-spawn": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/@types/cross-spawn/-/cross-spawn-6.0.2.tgz", "resolved": "https://registry.npmjs.org/@types/cross-spawn/-/cross-spawn-6.0.2.tgz",

View File

@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"version": "2.0.0", "version": "2.0.5",
"scripts": { "scripts": {
"build": "turbo run build", "build": "turbo run build",
"dev": "turbo run dev --filter=@documenso/remix", "dev": "turbo run dev --filter=@documenso/remix",

View File

@ -32,6 +32,7 @@ export type JobDefinition<Name extends string = string, Schema = any> = {
name: string; name: string;
version: string; version: string;
enabled?: boolean; enabled?: boolean;
optimizeParallelism?: boolean;
trigger: { trigger: {
name: Name; name: Name;
schema?: z.ZodType<Schema>; schema?: z.ZodType<Schema>;

View File

@ -40,6 +40,7 @@ export class InngestJobProvider extends BaseJobProvider {
{ {
id: job.id, id: job.id,
name: job.name, name: job.name,
optimizeParallelism: job.optimizeParallelism ?? false,
}, },
{ {
event: job.trigger.name, event: job.trigger.name,

View File

@ -189,29 +189,65 @@ export const run = async ({
settings, settings,
}); });
const newDocumentData = await Promise.all( // !: The commented out code is our desired implementation but we're seemingly
envelopeItems.map(async (envelopeItem) => // !: running into issues with inngest parallelism in production.
io.runTask(`decorate-and-sign-envelope-item-${envelopeItem.id}`, async () => { // !: Until this is resolved we will do this sequentially which is slower but
const envelopeItemFields = envelope.envelopeItems.find( // !: will actually work.
(item) => item.id === envelopeItem.id, // const decoratePromises: Array<Promise<{ oldDocumentDataId: string; newDocumentDataId: string }>> =
)?.field; // [];
if (!envelopeItemFields) { // for (const envelopeItem of envelopeItems) {
throw new Error(`Envelope item fields not found for envelope item ${envelopeItem.id}`); // const task = io.runTask(`decorate-${envelopeItem.id}`, async () => {
} // const envelopeItemFields = envelope.envelopeItems.find(
// (item) => item.id === envelopeItem.id,
// )?.field;
return decorateAndSignPdf({ // if (!envelopeItemFields) {
envelope, // throw new Error(`Envelope item fields not found for envelope item ${envelopeItem.id}`);
envelopeItem, // }
envelopeItemFields,
isRejected, // return decorateAndSignPdf({
rejectionReason, // envelope,
certificateData, // envelopeItem,
auditLogData, // envelopeItemFields,
}); // isRejected,
}), // rejectionReason,
), // certificateData,
); // auditLogData,
// });
// });
// decoratePromises.push(task);
// }
// const newDocumentData = await Promise.all(decoratePromises);
// TODO: Remove once parallelization is working
const newDocumentData: Array<{ oldDocumentDataId: string; newDocumentDataId: string }> = [];
for (const envelopeItem of envelopeItems) {
const result = await io.runTask(`decorate-${envelopeItem.id}`, 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,
});
});
newDocumentData.push(result);
}
const postHog = PostHogServerClient(); const postHog = PostHogServerClient();

View File

@ -18,6 +18,7 @@ export const SEAL_DOCUMENT_JOB_DEFINITION = {
id: SEAL_DOCUMENT_JOB_DEFINITION_ID, id: SEAL_DOCUMENT_JOB_DEFINITION_ID,
name: 'Seal Document', name: 'Seal Document',
version: '1.0.0', version: '1.0.0',
optimizeParallelism: true,
trigger: { trigger: {
name: SEAL_DOCUMENT_JOB_DEFINITION_ID, name: SEAL_DOCUMENT_JOB_DEFINITION_ID,
schema: SEAL_DOCUMENT_JOB_DEFINITION_SCHEMA, schema: SEAL_DOCUMENT_JOB_DEFINITION_SCHEMA,