mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: add envelopes api
This commit is contained in:
@ -2,15 +2,12 @@ import { EnvelopeType } from '@prisma/client';
|
||||
|
||||
import { completeDocumentWithToken } from '@documenso/lib/server-only/document/complete-document-with-token';
|
||||
import { rejectDocumentWithToken } from '@documenso/lib/server-only/document/reject-document-with-token';
|
||||
import { createDocumentRecipients } from '@documenso/lib/server-only/recipient/create-document-recipients';
|
||||
import { createTemplateRecipients } from '@documenso/lib/server-only/recipient/create-template-recipients';
|
||||
import { deleteDocumentRecipient } from '@documenso/lib/server-only/recipient/delete-document-recipient';
|
||||
import { deleteTemplateRecipient } from '@documenso/lib/server-only/recipient/delete-template-recipient';
|
||||
import { createEnvelopeRecipients } from '@documenso/lib/server-only/recipient/create-envelope-recipients';
|
||||
import { deleteEnvelopeRecipient } from '@documenso/lib/server-only/recipient/delete-envelope-recipient';
|
||||
import { getRecipientById } from '@documenso/lib/server-only/recipient/get-recipient-by-id';
|
||||
import { setDocumentRecipients } from '@documenso/lib/server-only/recipient/set-document-recipients';
|
||||
import { setTemplateRecipients } from '@documenso/lib/server-only/recipient/set-template-recipients';
|
||||
import { updateDocumentRecipients } from '@documenso/lib/server-only/recipient/update-document-recipients';
|
||||
import { updateTemplateRecipients } from '@documenso/lib/server-only/recipient/update-template-recipients';
|
||||
import { updateEnvelopeRecipients } from '@documenso/lib/server-only/recipient/update-envelope-recipients';
|
||||
|
||||
import { ZGenericSuccessResponse, ZSuccessResponseSchema } from '../document-router/schema';
|
||||
import { authenticatedProcedure, procedure, router } from '../trpc';
|
||||
@ -108,7 +105,7 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
const createdRecipients = await createDocumentRecipients({
|
||||
const createdRecipients = await createEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
id: {
|
||||
@ -147,7 +144,7 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
return await createDocumentRecipients({
|
||||
return await createEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
id: {
|
||||
@ -184,7 +181,7 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
const updatedRecipients = await updateDocumentRecipients({
|
||||
const updatedRecipients = await updateEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
id: {
|
||||
@ -223,7 +220,7 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
return await updateDocumentRecipients({
|
||||
return await updateEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
id: {
|
||||
@ -259,7 +256,7 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
await deleteDocumentRecipient({
|
||||
await deleteEnvelopeRecipient({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
recipientId,
|
||||
@ -363,11 +360,15 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
const createdRecipients = await createTemplateRecipients({
|
||||
const createdRecipients = await createEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
templateId,
|
||||
id: {
|
||||
id: templateId,
|
||||
type: 'templateId',
|
||||
},
|
||||
recipients: [recipient],
|
||||
requestMetadata: ctx.metadata,
|
||||
});
|
||||
|
||||
return createdRecipients.recipients[0];
|
||||
@ -398,11 +399,15 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
return await createTemplateRecipients({
|
||||
return await createEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
templateId,
|
||||
id: {
|
||||
id: templateId,
|
||||
type: 'templateId',
|
||||
},
|
||||
recipients,
|
||||
requestMetadata: ctx.metadata,
|
||||
});
|
||||
}),
|
||||
|
||||
@ -431,11 +436,15 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
const updatedRecipients = await updateTemplateRecipients({
|
||||
const updatedRecipients = await updateEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
templateId,
|
||||
id: {
|
||||
type: 'templateId',
|
||||
id: templateId,
|
||||
},
|
||||
recipients: [recipient],
|
||||
requestMetadata: ctx.metadata,
|
||||
});
|
||||
|
||||
return updatedRecipients.recipients[0];
|
||||
@ -466,11 +475,15 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
return await updateTemplateRecipients({
|
||||
return await updateEnvelopeRecipients({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
templateId,
|
||||
id: {
|
||||
type: 'templateId',
|
||||
id: templateId,
|
||||
},
|
||||
recipients,
|
||||
requestMetadata: ctx.metadata,
|
||||
});
|
||||
}),
|
||||
|
||||
@ -498,10 +511,11 @@ export const recipientRouter = router({
|
||||
},
|
||||
});
|
||||
|
||||
await deleteTemplateRecipient({
|
||||
await deleteEnvelopeRecipient({
|
||||
recipientId,
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
requestMetadata: ctx.metadata,
|
||||
});
|
||||
|
||||
return ZGenericSuccessResponse;
|
||||
|
||||
Reference in New Issue
Block a user