mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +10:00
feat: add get recipient route (#1553)
This commit is contained in:
@ -33,7 +33,8 @@ export const fieldRouter = router({
|
||||
method: 'GET',
|
||||
path: '/field/{fieldId}',
|
||||
summary: 'Get field',
|
||||
description: 'Returns a document or template field',
|
||||
description:
|
||||
'Returns a single field. If you want to retrieve all the fields for a document or template, use the "Get Document" or "Get Template" request.',
|
||||
tags: ['Fields'],
|
||||
},
|
||||
})
|
||||
@ -119,7 +120,7 @@ export const fieldRouter = router({
|
||||
}),
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @private
|
||||
*/
|
||||
signFieldWithToken: procedure
|
||||
.input(ZSignFieldWithTokenMutationSchema)
|
||||
@ -138,7 +139,7 @@ export const fieldRouter = router({
|
||||
}),
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @private
|
||||
*/
|
||||
removeSignedFieldWithToken: procedure
|
||||
.input(ZRemovedSignedFieldWithTokenMutationSchema)
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
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 {
|
||||
ZGetRecipientByIdResponseSchema,
|
||||
getRecipientById,
|
||||
} from '@documenso/lib/server-only/recipient/get-recipient-by-id';
|
||||
import {
|
||||
ZSetRecipientsForDocumentResponseSchema,
|
||||
setRecipientsForDocument,
|
||||
@ -15,12 +19,39 @@ import {
|
||||
ZAddSignersMutationSchema,
|
||||
ZAddTemplateSignersMutationSchema,
|
||||
ZCompleteDocumentWithTokenMutationSchema,
|
||||
ZGetRecipientQuerySchema,
|
||||
ZRejectDocumentWithTokenMutationSchema,
|
||||
} from './schema';
|
||||
|
||||
export const recipientRouter = router({
|
||||
/**
|
||||
* @internal
|
||||
* @public
|
||||
*/
|
||||
getRecipient: authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'GET',
|
||||
path: '/recipient/{recipientId}',
|
||||
summary: 'Get recipient',
|
||||
description:
|
||||
'Returns a single recipient. If you want to retrieve all the recipients for a document or template, use the "Get Document" or "Get Template" request.',
|
||||
tags: ['Recipients'],
|
||||
},
|
||||
})
|
||||
.input(ZGetRecipientQuerySchema)
|
||||
.output(ZGetRecipientByIdResponseSchema)
|
||||
.query(async ({ input, ctx }) => {
|
||||
const { recipientId, teamId } = input;
|
||||
|
||||
return await getRecipientById({
|
||||
userId: ctx.user.id,
|
||||
teamId,
|
||||
recipientId,
|
||||
});
|
||||
}),
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
addSigners: authenticatedProcedure
|
||||
.meta({
|
||||
@ -53,7 +84,7 @@ export const recipientRouter = router({
|
||||
}),
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @public
|
||||
*/
|
||||
addTemplateSigners: authenticatedProcedure
|
||||
.meta({
|
||||
@ -85,7 +116,7 @@ export const recipientRouter = router({
|
||||
}),
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @private
|
||||
*/
|
||||
completeDocumentWithToken: procedure
|
||||
.input(ZCompleteDocumentWithTokenMutationSchema)
|
||||
@ -102,7 +133,7 @@ export const recipientRouter = router({
|
||||
}),
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @private
|
||||
*/
|
||||
rejectDocumentWithToken: procedure
|
||||
.input(ZRejectDocumentWithTokenMutationSchema)
|
||||
|
||||
@ -6,6 +6,11 @@ import {
|
||||
} from '@documenso/lib/types/document-auth';
|
||||
import { RecipientRole } from '@documenso/prisma/client';
|
||||
|
||||
export const ZGetRecipientQuerySchema = z.object({
|
||||
recipientId: z.number(),
|
||||
teamId: z.number().optional(),
|
||||
});
|
||||
|
||||
export const ZAddSignersMutationSchema = z
|
||||
.object({
|
||||
documentId: z.number(),
|
||||
|
||||
@ -445,7 +445,7 @@ export const templateRouter = router({
|
||||
}),
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @private
|
||||
*/
|
||||
updateTemplateTypedSignatureSettings: authenticatedProcedure
|
||||
.input(ZUpdateTemplateTypedSignatureSettingsMutationSchema)
|
||||
|
||||
Reference in New Issue
Block a user