feat: add get field endpoints (#1599)

This commit is contained in:
David Nguyen
2025-01-20 15:53:12 +11:00
committed by GitHub
parent 80dfbeb16f
commit a28cdf437b
2 changed files with 64 additions and 10 deletions

View File

@@ -47,15 +47,15 @@ export const fieldRouter = router({
/**
* @public
*/
getField: authenticatedProcedure
getDocumentField: authenticatedProcedure
.meta({
openapi: {
method: 'GET',
path: '/field/{fieldId}',
summary: 'Get field',
path: '/document/field/{fieldId}',
summary: 'Get document field',
description:
'Returns a single field. If you want to retrieve all the fields for a document or template, use the "Get Document" or "Get Template" request.',
tags: ['Document Fields', 'Template Fields'],
'Returns a single field. If you want to retrieve all the fields for a document, use the "Get Document" endpoint.',
tags: ['Document Fields'],
},
})
.input(ZGetFieldRequestSchema)
@@ -273,6 +273,33 @@ export const fieldRouter = router({
return createdFields.fields[0];
}),
/**
* @public
*/
getTemplateField: authenticatedProcedure
.meta({
openapi: {
method: 'GET',
path: '/template/field/{fieldId}',
summary: 'Get template field',
description:
'Returns a single field. If you want to retrieve all the fields for a template, use the "Get Template" endpoint.',
tags: ['Template Fields'],
},
})
.input(ZGetFieldRequestSchema)
.output(ZGetFieldResponseSchema)
.query(async ({ input, ctx }) => {
const { teamId } = ctx;
const { fieldId } = input;
return await getFieldById({
userId: ctx.user.id,
teamId,
fieldId,
});
}),
/**
* @public
*/