import{CatalogEntitiesService as o}from"../../../plugins/catalog-entities/database/catalog-entities-service.js";import{createPaginationParamsValidator as c}from"../../../providers/database/pagination/schemas.js";import{ENTITY_RELATION_FROM_DATABASE as m}from"../../../plugins/catalog-entities/database/mappers/field-transformations.js";const l=["id","key","title","type","summary","source","sourceFile","createdAt","updatedAt"];function g(r){return async e=>{const a=await o.getInstance({baseDbDir:r.serverOutDir});try{const t=e.req.param("entityKey");if(!t)return e.json({message:"Entity key is required"},400);const i=e.req.query(),s=c(l,m).parse(i),n=await a.getRelatedEntities(t,s);return e.json(n)}catch(t){return console.error(t),e.json({message:t.message},500)}}}export{g as bffCatalogRelatedEntitiesHandler};
