Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

2.2 KB
Raw Blame
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
import {
  GetAnnotationQueueItemByIdQuery,
  GetAnnotationQueueItemByIdResponse,
  UpdateAnnotationQueueItemBody,
  UpdateAnnotationQueueItemResponse,
  DeleteAnnotationQueueItemQuery,
  DeleteAnnotationQueueItemResponse,
} from "@/src/features/public-api/types/annotation-queues";
import {
  deleteAnnotationQueueItemForApi,
  getAnnotationQueueItemForApi,
  updateAnnotationQueueItemForApi,
} from "@/src/features/annotation-queues/server/publicAnnotationQueueService";
export default withMiddlewares({
  GET: createAuthedProjectAPIRoute({
    name: "Get annotation queue item by ID",
    action: "annotationQueues:read",
    querySchema: GetAnnotationQueueItemByIdQuery,
    responseSchema: GetAnnotationQueueItemByIdResponse,
    rateLimitResource: "annotation-queues",
    fn: async ({ query, auth }) =>
      await getAnnotationQueueItemForApi({
        projectId: auth.scope.projectId,
        queueId: query.queueId,
        itemId: query.itemId,
      }),
  }),
  PATCH: createAuthedProjectAPIRoute({
    name: "Update annotation queue item",
    action: "annotationQueues:CUD",
    querySchema: GetAnnotationQueueItemByIdQuery,
    bodySchema: UpdateAnnotationQueueItemBody,
    responseSchema: UpdateAnnotationQueueItemResponse,
    rateLimitResource: "annotation-queues",
    fn: async ({ query, body, auth }) =>
      await updateAnnotationQueueItemForApi({
        projectId: auth.scope.projectId,
        queueId: query.queueId,
        itemId: query.itemId,
        input: body,
        auditScope: auth.scope,
      }),
  }),
  DELETE: createAuthedProjectAPIRoute({
    name: "Delete annotation queue item",
    action: "annotationQueues:CUD",
    querySchema: DeleteAnnotationQueueItemQuery,
    responseSchema: DeleteAnnotationQueueItemResponse,
    rateLimitResource: "annotation-queues",
    fn: async ({ query, auth }) =>
      await deleteAnnotationQueueItemForApi({
        projectId: auth.scope.projectId,
        queueId: query.queueId,
        itemId: query.itemId,
        auditScope: auth.scope,
      }),
  }),
});