mirror of
https://github.com/documenso/documenso.git
synced 2026-08-15 11:01:47 +10:00
- 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
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { updateEnvelopeFields } from '@documenso/lib/server-only/field/update-envelope-fields';
|
|
|
|
import { authenticatedProcedure } from '../../trpc';
|
|
import {
|
|
updateEnvelopeFieldsMeta,
|
|
ZUpdateEnvelopeFieldsRequestSchema,
|
|
ZUpdateEnvelopeFieldsResponseSchema,
|
|
} from './update-envelope-fields.types';
|
|
|
|
export const updateEnvelopeFieldsRoute = authenticatedProcedure
|
|
.meta(updateEnvelopeFieldsMeta)
|
|
.input(ZUpdateEnvelopeFieldsRequestSchema)
|
|
.output(ZUpdateEnvelopeFieldsResponseSchema)
|
|
.mutation(async ({ input, ctx }) => {
|
|
const { user, teamId } = ctx;
|
|
const { envelopeId, data: fields } = input;
|
|
|
|
ctx.logger.info({
|
|
input: {
|
|
envelopeId,
|
|
},
|
|
});
|
|
|
|
const { fields: data } = await updateEnvelopeFields({
|
|
userId: user.id,
|
|
teamId,
|
|
id: {
|
|
type: 'envelopeId',
|
|
id: envelopeId,
|
|
},
|
|
type: null,
|
|
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,
|
|
});
|
|
|
|
return {
|
|
data,
|
|
};
|
|
});
|