import{logger as r}from"../../../../tools/notifiers/logger.js";import{VERSION_NOT_SPECIFIED as s}from"@redocly/theme/core/constants";import{entityDatabaseSchema as i}from"../../schemas/database-schemas.js";import{validateWithResult as o}from"../../utils/ajv-validator.js";function d(a){const t=o(i,{...a});if(!t.success)return r.warn(`Invalid database catalog entity for entity ${a.key}, error: ${t.error}`),null;const e=t.data||{};return{id:e.id,organizationId:e.organizationId,projectId:e.projectId,type:e.type,key:e.key||"",title:e.title||"",summary:e.summary||null,tags:e.tags?JSON.parse(e.tags):null,metadata:e.metadata?JSON.parse(e.metadata):null,git:e.git?JSON.parse(e.git):null,contact:e.contact?JSON.parse(e.contact):null,links:e.links?JSON.parse(e.links):null,source:e.source,sourceFile:e.sourceFile||null,version:e.version||s,revision:e.revision??"",hash:e.hash||null,isCurrent:e.isCurrent??!1,isDefaultVersion:e.isDefaultVersion??!1,createdAt:e.createdAt,updatedAt:e.updatedAt,isDeleted:e.isDeleted??!1,object:"catalogEntity",rbacTeams:e.rbacTeams?JSON.parse(e.rbacTeams):[]}}export{d as createEntityReadModel};
