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
This commit is contained in:
ephraimduncan
2026-08-19 09:35:58 +00:00
parent 4dc9cf5a3b
commit 3337c29002
2 changed files with 71 additions and 50 deletions
@@ -22,10 +22,10 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
| `envelopeId` | string | ID of the parent envelope | | `envelopeId` | string | ID of the parent envelope |
| `envelopeItemId` | string | ID of the PDF item the field is placed on | | `envelopeItemId` | string | ID of the PDF item the field is placed on |
| `page` | number | Page number (1-indexed) | | `page` | number | Page number (1-indexed) |
| `positionX` | number | X coordinate as percentage (0-100) | | `positionX` | string | X coordinate as percentage (0-100), a decimal serialized as a string |
| `positionY` | number | Y coordinate as percentage (0-100) | | `positionY` | string | Y coordinate as percentage (0-100), a decimal serialized as a string |
| `width` | number | Width as percentage of page (0-100) | | `width` | string | Width as percentage of page (0-100), a decimal serialized as a string |
| `height` | number | Height as percentage of page (0-100) | | `height` | string | Height as percentage of page (0-100), a decimal serialized as a string |
| `customText` | string | Value entered by the recipient | | `customText` | string | Value entered by the recipient |
| `inserted` | boolean | Whether the field has been completed | | `inserted` | boolean | Whether the field has been completed |
| `fieldMeta` | object \| null | Type-specific configuration options | | `fieldMeta` | object \| null | Type-specific configuration options |
@@ -38,18 +38,19 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
"secondaryId": "field_abc123", "secondaryId": "field_abc123",
"type": "SIGNATURE", "type": "SIGNATURE",
"recipientId": 123, "recipientId": 123,
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"envelopeItemId": "envelope_item_xyz", "envelopeItemId": "envelope_item_abcdefhiklmnorst",
"page": 1, "page": 1,
"positionX": 10, "positionX": "10",
"positionY": 80, "positionY": "80",
"width": 30, "width": "30",
"height": 5, "height": "5",
"customText": "", "customText": "",
"inserted": false, "inserted": false,
"fieldMeta": { "fieldMeta": {
"type": "signature", "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 "Authorization: api_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d '{
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"data": [ "data": [
{ {
"type": "SIGNATURE", "type": "SIGNATURE",
@@ -199,7 +200,7 @@ const response = await fetch(
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
envelopeId: 'clu1abc2def3ghi4jkl', envelopeId: 'envelope_abcdefhiklmnorst',
data: [ data: [
{ {
type: 'SIGNATURE', type: 'SIGNATURE',
@@ -254,51 +255,56 @@ console.log(`Created ${data.length} fields`);
{ {
"id": 101, "id": 101,
"secondaryId": "field_abc123", "secondaryId": "field_abc123",
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"envelopeItemId": "envelope_item_xyz", "envelopeItemId": "envelope_item_abcdefhiklmnorst",
"type": "SIGNATURE", "type": "SIGNATURE",
"recipientId": 456, "recipientId": 456,
"page": 1, "page": 1,
"positionX": 10, "positionX": "10",
"positionY": 80, "positionY": "80",
"width": 30, "width": "30",
"height": 5, "height": "5",
"customText": "", "customText": "",
"inserted": false, "inserted": false,
"fieldMeta": { "fieldMeta": {
"type": "signature" "type": "signature",
"fontSize": 18,
"overflow": "auto"
} }
}, },
{ {
"id": 102, "id": 102,
"secondaryId": "field_def456", "secondaryId": "field_def456",
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"envelopeItemId": "envelope_item_xyz", "envelopeItemId": "envelope_item_abcdefhiklmnorst",
"type": "DATE", "type": "DATE",
"recipientId": 456, "recipientId": 456,
"page": 1, "page": 1,
"positionX": 50, "positionX": "50",
"positionY": 80, "positionY": "80",
"width": 20, "width": "20",
"height": 3, "height": "3",
"customText": "", "customText": "",
"inserted": false, "inserted": false,
"fieldMeta": { "fieldMeta": {
"type": "date" "type": "date",
"fontSize": 12,
"textAlign": "left",
"overflow": "auto"
} }
}, },
{ {
"id": 103, "id": 103,
"secondaryId": "field_ghi789", "secondaryId": "field_ghi789",
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"envelopeItemId": "envelope_item_xyz", "envelopeItemId": "envelope_item_abcdefhiklmnorst",
"type": "TEXT", "type": "TEXT",
"recipientId": 456, "recipientId": 456,
"page": 1, "page": 1,
"positionX": 10, "positionX": "10",
"positionY": 70, "positionY": "70",
"width": 40, "width": "40",
"height": 4, "height": "4",
"customText": "", "customText": "",
"inserted": false, "inserted": false,
"fieldMeta": { "fieldMeta": {
@@ -338,7 +344,7 @@ curl -X POST "https://app.documenso.com/api/v2/envelope/field/update-many" \
-H "Authorization: api_xxxxxxxxxxxxxxxx" \ -H "Authorization: api_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d '{
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"data": [ "data": [
{ {
"id": 101, "id": 101,
@@ -365,7 +371,7 @@ const response = await fetch(
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
envelopeId: 'clu1abc2def3ghi4jkl', envelopeId: 'envelope_abcdefhiklmnorst',
data: [ data: [
{ id: 101, type: 'SIGNATURE', positionY: 85 }, { id: 101, type: 'SIGNATURE', positionY: 85 },
{ id: 102, type: 'DATE', positionY: 85 }, { id: 102, type: 'DATE', positionY: 85 },
@@ -388,37 +394,42 @@ const { data } = await response.json();
{ {
"id": 101, "id": 101,
"secondaryId": "field_abc123", "secondaryId": "field_abc123",
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"envelopeItemId": "envelope_item_xyz", "envelopeItemId": "envelope_item_abcdefhiklmnorst",
"type": "SIGNATURE", "type": "SIGNATURE",
"recipientId": 456, "recipientId": 456,
"page": 1, "page": 1,
"positionX": 10, "positionX": "10",
"positionY": 85, "positionY": "85",
"width": 30, "width": "30",
"height": 5, "height": "5",
"customText": "", "customText": "",
"inserted": false, "inserted": false,
"fieldMeta": { "fieldMeta": {
"type": "signature" "type": "signature",
"fontSize": 18,
"overflow": "auto"
} }
}, },
{ {
"id": 102, "id": 102,
"secondaryId": "field_def456", "secondaryId": "field_def456",
"envelopeId": "clu1abc2def3ghi4jkl", "envelopeId": "envelope_abcdefhiklmnorst",
"envelopeItemId": "envelope_item_xyz", "envelopeItemId": "envelope_item_abcdefhiklmnorst",
"type": "DATE", "type": "DATE",
"recipientId": 456, "recipientId": 456,
"page": 1, "page": 1,
"positionX": 50, "positionX": "50",
"positionY": 85, "positionY": "85",
"width": 20, "width": "20",
"height": 3, "height": "3",
"customText": "", "customText": "",
"inserted": false, "inserted": false,
"fieldMeta": { "fieldMeta": {
"type": "date" "type": "date",
"fontSize": 12,
"textAlign": "left",
"overflow": "auto"
} }
} }
] ]
@@ -29,7 +29,17 @@ export const updateEnvelopeFieldsRoute = authenticatedProcedure
id: envelopeId, id: envelopeId,
}, },
type: null, 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, requestMetadata: ctx.metadata,
}); });