fix: envelope autosave (#2103)

This commit is contained in:
David Nguyen
2025-10-27 19:53:35 +11:00
committed by GitHub
parent 35250fa308
commit b0b07106b4
9 changed files with 107 additions and 33 deletions

View File

@ -24,7 +24,7 @@ export const setEnvelopeFieldsRoute = authenticatedProcedure
},
});
await match(envelopeType)
const result = await match(envelopeType)
.with(EnvelopeType.DOCUMENT, async () =>
setFieldsForDocument({
userId: ctx.user.id,
@ -63,4 +63,11 @@ export const setEnvelopeFieldsRoute = authenticatedProcedure
}),
)
.exhaustive();
return {
fields: result.fields.map((field) => ({
id: field.id,
formId: field.formId,
})),
};
});

View File

@ -12,6 +12,7 @@ export const ZSetEnvelopeFieldsRequestSchema = z.object({
.number()
.optional()
.describe('The id of the field. If not provided, a new field will be created.'),
formId: z.string().optional().describe('A temporary ID to keep track of new fields created'),
envelopeItemId: z.string().describe('The id of the envelope item to put the field on'),
recipientId: z.number(),
type: z.nativeEnum(FieldType),
@ -45,7 +46,14 @@ export const ZSetEnvelopeFieldsRequestSchema = z.object({
),
});
export const ZSetEnvelopeFieldsResponseSchema = z.void();
export const ZSetEnvelopeFieldsResponseSchema = z.object({
fields: z
.object({
id: z.number(),
formId: z.string().optional(),
})
.array(),
});
export type TSetEnvelopeFieldsRequest = z.infer<typeof ZSetEnvelopeFieldsRequestSchema>;
export type TSetEnvelopeFieldsResponse = z.infer<typeof ZSetEnvelopeFieldsResponseSchema>;