{"version":3,"file":"draft-relations.mjs","sources":["../../../../server/src/services/utils/draft-relations.ts"],"sourcesContent":["import type { Schema } from '@strapi/types';\n\ntype RelationAttribute = Schema.Attribute.Relation & {\n target?: string;\n inversedBy?: string;\n mappedBy?: string;\n};\n\nexport interface DraftRelationCounts {\n unpublishedRelations: number;\n draftM2mLinks: number;\n}\n\nexport const EMPTY_DRAFT_RELATION_COUNTS: DraftRelationCounts = {\n unpublishedRelations: 0,\n draftM2mLinks: 0,\n};\n\n/**\n * Bidirectional manyToMany links share a join-table row and are kept on publish; they become\n * visible on the live site once the related entry is published. xToOne-style links are stripped.\n */\nexport const isBidirectionalManyToMany = (attribute: RelationAttribute) =>\n attribute.relation === 'manyToMany' && Boolean(attribute.inversedBy || attribute.mappedBy);\n\nexport const mergeDraftRelationCounts = (\n left: DraftRelationCounts,\n right: DraftRelationCounts\n): DraftRelationCounts => ({\n unpublishedRelations: left.unpublishedRelations + right.unpublishedRelations,\n draftM2mLinks: left.draftM2mLinks + right.draftM2mLinks,\n});\n"],"names":["isBidirectionalManyToMany","attribute","relation","Boolean","inversedBy","mappedBy"],"mappings":"AAkBA;;;AAGC,IACM,MAAMA,yBAAAA,GAA4B,CAACC,YACxCA,SAAAA,CAAUC,QAAQ,KAAK,YAAA,IAAgBC,QAAQF,SAAAA,CAAUG,UAAU,IAAIH,SAAAA,CAAUI,QAAQ;;;;"}