Files
documenso/packages/trpc/server/document-router/share-document.ts
David Nguyen 7f09ba72f4 feat: add envelopes (#2025)
This PR is handles the changes required to support envelopes. The new
envelope editor/signing page will be hidden during release.

The core changes here is to migrate the documents and templates model to
a centralized envelopes model.

Even though Documents and Templates are removed, from the user
perspective they will still exist as we remap envelopes to documents and
templates.
2025-10-14 21:56:36 +11:00

29 lines
861 B
TypeScript

import { createOrGetShareLink } from '@documenso/lib/server-only/share/create-or-get-share-link';
import { procedure } from '../trpc';
import { ZShareDocumentRequestSchema, ZShareDocumentResponseSchema } from './share-document.types';
// Note: This is an unauthenticated route.
export const shareDocumentRoute = procedure
.input(ZShareDocumentRequestSchema)
.output(ZShareDocumentResponseSchema)
.mutation(async ({ input, ctx }) => {
const { documentId, token } = input;
ctx.logger.info({
input: {
documentId,
},
});
if (token) {
return await createOrGetShareLink({ documentId, token });
}
if (!ctx.user?.id) {
throw new Error('You must either provide a token or be logged in to create a sharing link.');
}
return await createOrGetShareLink({ documentId, userId: ctx.user.id });
});