mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
feat: return fields in GET /documents/:id endpoint (#1317)
To be able to use the PATCH `/api/v1/documents/{id}/fields/{fieldId}`
endpoint, we need to know the fields ID of a particular document. The
issue #1178 suggested to create a new endpoint for this. To be
consistent with the `/templates` endpoint, I propose in this PR to
directly add the `fields` field to the `/documents/:id` endpoint.
This commit is contained in:
@ -58,6 +58,22 @@ export const ZSuccessfulDocumentResponseSchema = z.object({
|
||||
|
||||
export const ZSuccessfulGetDocumentResponseSchema = ZSuccessfulDocumentResponseSchema.extend({
|
||||
recipients: z.lazy(() => z.array(ZSuccessfulRecipientResponseSchema)),
|
||||
fields: z.lazy(() =>
|
||||
ZFieldSchema.pick({
|
||||
id: true,
|
||||
recipientId: true,
|
||||
type: true,
|
||||
page: true,
|
||||
positionX: true,
|
||||
positionY: true,
|
||||
width: true,
|
||||
height: true,
|
||||
})
|
||||
.extend({
|
||||
fieldMeta: ZFieldMetaSchema.nullish(),
|
||||
})
|
||||
.array(),
|
||||
),
|
||||
});
|
||||
|
||||
export type TSuccessfulGetDocumentResponseSchema = z.infer<
|
||||
@ -424,7 +440,7 @@ export const ZSuccessfulSigningResponseSchema = z
|
||||
.object({
|
||||
message: z.string(),
|
||||
})
|
||||
.and(ZSuccessfulGetDocumentResponseSchema);
|
||||
.and(ZSuccessfulGetDocumentResponseSchema.omit({ fields: true }));
|
||||
|
||||
export type TSuccessfulSigningResponseSchema = z.infer<typeof ZSuccessfulSigningResponseSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user