Private/New-GraphMappingObject.ps1

function New-GraphMappingObject {
    <#
    .SYNOPSIS
        Builds the PowerShell object returned by Get-GraphMapping.
    .DESCRIPTION
        Wraps a compact index record into a consistent, pipeline-friendly object, optionally
        enriched with permission/output-type/documentation details loaded from the matching
        detail shard, and with rename information from the official breaking-changes catalog.
        This function only builds an in-memory object; it never changes persisted state, so
        ShouldProcess support is intentionally not implemented despite the "New-" verb.
    #>

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
    [CmdletBinding()]
    [OutputType([pscustomobject])]
    param(
        [Parameter(Mandatory)]
        [object]$Record,

        [Parameter(Mandatory)]
        [string]$MatchedBy,

        [object]$RenameIndex,

        [switch]$IncludeDetails
    )

    $permissions = $null
    $outputType = $null
    $apiReferenceLink = $null
    $commandAlias = $null

    if ($IncludeDetails -and $Record.detailShard) {
        $shard = Get-GraphDetailShard -Shard $Record.detailShard
        if ($shard) {
            $detail = $null
            if ($shard.ById.TryGetValue($Record.id, [ref]$detail)) {
                $permissions = $detail.original.Permissions |
                    Select-Object -Property Name, PermissionType, IsAdmin, IsLeastPrivilege -Unique
                $outputType = $detail.original.OutputType
                $apiReferenceLink = $detail.original.ApiReferenceLink
                $commandAlias = $detail.original.CommandAlias
            }
        }
    }

    $renamedFrom = $null
    if ($RenameIndex) {
        $renameList = $null
        if ($RenameIndex.ByNewCmdlet.TryGetValue($Record.command, [ref]$renameList)) {
            $renamedFrom = ($renameList | Select-Object -ExpandProperty oldCmdlet) -join ', '
        }
    }

    [pscustomobject]@{
        PSTypeName        = 'GraphShell.Mapping'
        Cmdlet            = $Record.command
        Module            = $Record.module
        ModuleName        = $Record.moduleName
        Method            = $Record.method
        Endpoint          = $Record.uri
        ApiVersion        = $Record.apiVersion
        Aliases           = $Record.aliases
        Variants          = $Record.variants
        CommandAlias      = $commandAlias
        Permissions       = $permissions
        OutputType        = $outputType
        ApiReferenceLink  = $apiReferenceLink
        MatchedBy         = $MatchedBy
        MatchedPermission = $null
        RenamedFrom       = $renamedFrom
        Id                = $Record.id
        DetailShard       = $Record.detailShard
    }
}