import{ulid as g}from"ulid";import{normalizeRelation as l}from"../../utils/normalize-relation.js";function R({relation:e,sourceFile:n,fileHash:s,sourceKey:a,sourceVersion:r,sourceRevision:o,organizationId:c,projectId:u}){const i=new Date().toISOString(),t=l({type:e.type,sourceKey:a,targetKey:e.key,sourceVersion:r&&e.version?r:null,targetVersion:r&&e.version?e.version:null,sourceRevision:o&&e.revision?o:null,targetRevision:o&&e.revision?e.revision:null});return{id:`cer_${g()}`,organizationId:c,projectId:u,sourceKey:t.sourceKey,sourceVersion:t.sourceVersion??"",sourceRevision:t.sourceRevision??"",sourceToTargetRelation:t.type,targetKey:t.targetKey,targetVersion:t.targetVersion??"",targetRevision:t.targetRevision??"",targetToSourceRelation:`reverse:${t.type}`,sourceFile:n,fileHash:s,isDeleted:!1,createdAt:i,updatedAt:i}}export{R as createEntityRelationDbRecordFromFileSchema};
