From 3337c29002a59abcd84fdc37404352fc9ce5b2f1 Mon Sep 17 00:00:00 2001 From: ephraimduncan Date: Thu, 30 Jul 2026 22:02:20 +0000 Subject: [PATCH] fix(trpc): map v2 field update coordinates to service names - ZUpdateEnvelopeFieldsRequestSchema accepts page/positionX/positionY but the service consumes pageNumber/pageX/pageY, so position updates via POST /envelope/field/update-many were silently dropped; map the names in the route before calling updateEnvelopeFields - docs: show Decimal coordinates as serialized strings in field responses - docs: include the defaulted fieldMeta values returned when the request omits fieldMeta - docs: use real envelope/envelope-item ID formats in samples --- .../content/docs/developers/api/fields.mdx | 109 ++++++++++-------- .../envelope-fields/update-envelope-fields.ts | 12 +- 2 files changed, 71 insertions(+), 50 deletions(-) diff --git a/apps/docs/content/docs/developers/api/fields.mdx b/apps/docs/content/docs/developers/api/fields.mdx index f0f5106f8..ce31d1588 100644 --- a/apps/docs/content/docs/developers/api/fields.mdx +++ b/apps/docs/content/docs/developers/api/fields.mdx @@ -22,10 +22,10 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; | `envelopeId` | string | ID of the parent envelope | | `envelopeItemId` | string | ID of the PDF item the field is placed on | | `page` | number | Page number (1-indexed) | -| `positionX` | number | X coordinate as percentage (0-100) | -| `positionY` | number | Y coordinate as percentage (0-100) | -| `width` | number | Width as percentage of page (0-100) | -| `height` | number | Height as percentage of page (0-100) | +| `positionX` | string | X coordinate as percentage (0-100), a decimal serialized as a string | +| `positionY` | string | Y coordinate as percentage (0-100), a decimal serialized as a string | +| `width` | string | Width as percentage of page (0-100), a decimal serialized as a string | +| `height` | string | Height as percentage of page (0-100), a decimal serialized as a string | | `customText` | string | Value entered by the recipient | | `inserted` | boolean | Whether the field has been completed | | `fieldMeta` | object \| null | Type-specific configuration options | @@ -38,18 +38,19 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs'; "secondaryId": "field_abc123", "type": "SIGNATURE", "recipientId": 123, - "envelopeId": "clu1abc2def3ghi4jkl", - "envelopeItemId": "envelope_item_xyz", + "envelopeId": "envelope_abcdefhiklmnorst", + "envelopeItemId": "envelope_item_abcdefhiklmnorst", "page": 1, - "positionX": 10, - "positionY": 80, - "width": 30, - "height": 5, + "positionX": "10", + "positionY": "80", + "width": "30", + "height": "5", "customText": "", "inserted": false, "fieldMeta": { "type": "signature", - "required": true + "required": true, + "overflow": "auto" } } ``` @@ -148,7 +149,7 @@ curl -X POST "https://app.documenso.com/api/v2/envelope/field/create-many" \ -H "Authorization: api_xxxxxxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{ - "envelopeId": "clu1abc2def3ghi4jkl", + "envelopeId": "envelope_abcdefhiklmnorst", "data": [ { "type": "SIGNATURE", @@ -199,7 +200,7 @@ const response = await fetch( 'Content-Type': 'application/json', }, body: JSON.stringify({ - envelopeId: 'clu1abc2def3ghi4jkl', + envelopeId: 'envelope_abcdefhiklmnorst', data: [ { type: 'SIGNATURE', @@ -254,51 +255,56 @@ console.log(`Created ${data.length} fields`); { "id": 101, "secondaryId": "field_abc123", - "envelopeId": "clu1abc2def3ghi4jkl", - "envelopeItemId": "envelope_item_xyz", + "envelopeId": "envelope_abcdefhiklmnorst", + "envelopeItemId": "envelope_item_abcdefhiklmnorst", "type": "SIGNATURE", "recipientId": 456, "page": 1, - "positionX": 10, - "positionY": 80, - "width": 30, - "height": 5, + "positionX": "10", + "positionY": "80", + "width": "30", + "height": "5", "customText": "", "inserted": false, "fieldMeta": { - "type": "signature" + "type": "signature", + "fontSize": 18, + "overflow": "auto" } }, { "id": 102, "secondaryId": "field_def456", - "envelopeId": "clu1abc2def3ghi4jkl", - "envelopeItemId": "envelope_item_xyz", + "envelopeId": "envelope_abcdefhiklmnorst", + "envelopeItemId": "envelope_item_abcdefhiklmnorst", "type": "DATE", "recipientId": 456, "page": 1, - "positionX": 50, - "positionY": 80, - "width": 20, - "height": 3, + "positionX": "50", + "positionY": "80", + "width": "20", + "height": "3", "customText": "", "inserted": false, "fieldMeta": { - "type": "date" + "type": "date", + "fontSize": 12, + "textAlign": "left", + "overflow": "auto" } }, { "id": 103, "secondaryId": "field_ghi789", - "envelopeId": "clu1abc2def3ghi4jkl", - "envelopeItemId": "envelope_item_xyz", + "envelopeId": "envelope_abcdefhiklmnorst", + "envelopeItemId": "envelope_item_abcdefhiklmnorst", "type": "TEXT", "recipientId": 456, "page": 1, - "positionX": 10, - "positionY": 70, - "width": 40, - "height": 4, + "positionX": "10", + "positionY": "70", + "width": "40", + "height": "4", "customText": "", "inserted": false, "fieldMeta": { @@ -338,7 +344,7 @@ curl -X POST "https://app.documenso.com/api/v2/envelope/field/update-many" \ -H "Authorization: api_xxxxxxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{ - "envelopeId": "clu1abc2def3ghi4jkl", + "envelopeId": "envelope_abcdefhiklmnorst", "data": [ { "id": 101, @@ -365,7 +371,7 @@ const response = await fetch( 'Content-Type': 'application/json', }, body: JSON.stringify({ - envelopeId: 'clu1abc2def3ghi4jkl', + envelopeId: 'envelope_abcdefhiklmnorst', data: [ { id: 101, type: 'SIGNATURE', positionY: 85 }, { id: 102, type: 'DATE', positionY: 85 }, @@ -388,37 +394,42 @@ const { data } = await response.json(); { "id": 101, "secondaryId": "field_abc123", - "envelopeId": "clu1abc2def3ghi4jkl", - "envelopeItemId": "envelope_item_xyz", + "envelopeId": "envelope_abcdefhiklmnorst", + "envelopeItemId": "envelope_item_abcdefhiklmnorst", "type": "SIGNATURE", "recipientId": 456, "page": 1, - "positionX": 10, - "positionY": 85, - "width": 30, - "height": 5, + "positionX": "10", + "positionY": "85", + "width": "30", + "height": "5", "customText": "", "inserted": false, "fieldMeta": { - "type": "signature" + "type": "signature", + "fontSize": 18, + "overflow": "auto" } }, { "id": 102, "secondaryId": "field_def456", - "envelopeId": "clu1abc2def3ghi4jkl", - "envelopeItemId": "envelope_item_xyz", + "envelopeId": "envelope_abcdefhiklmnorst", + "envelopeItemId": "envelope_item_abcdefhiklmnorst", "type": "DATE", "recipientId": 456, "page": 1, - "positionX": 50, - "positionY": 85, - "width": 20, - "height": 3, + "positionX": "50", + "positionY": "85", + "width": "20", + "height": "3", "customText": "", "inserted": false, "fieldMeta": { - "type": "date" + "type": "date", + "fontSize": 12, + "textAlign": "left", + "overflow": "auto" } } ] diff --git a/packages/trpc/server/envelope-router/envelope-fields/update-envelope-fields.ts b/packages/trpc/server/envelope-router/envelope-fields/update-envelope-fields.ts index 390caea84..735dd5ab3 100644 --- a/packages/trpc/server/envelope-router/envelope-fields/update-envelope-fields.ts +++ b/packages/trpc/server/envelope-router/envelope-fields/update-envelope-fields.ts @@ -29,7 +29,17 @@ export const updateEnvelopeFieldsRoute = authenticatedProcedure id: envelopeId, }, type: null, - fields, + fields: fields.map((field) => ({ + id: field.id, + type: field.type, + pageNumber: field.page, + pageX: field.positionX, + pageY: field.positionY, + width: field.width, + height: field.height, + fieldMeta: field.fieldMeta, + envelopeItemId: field.envelopeItemId, + })), requestMetadata: ctx.metadata, });