PSAutoRBAC.psm1

#Requires -Version 5.1

# Root module for PSAutoRBAC. Dot-sources private then public functions and
# exports only the public surface. Adding a .ps1 to Public/ or Private/ is all
# that is needed to extend the module.

Set-StrictMode -Version Latest

$script:ModuleRoot   = $PSScriptRoot
$script:RoleMapCache = @{}

$private = @(Get-ChildItem -Path (Join-Path $PSScriptRoot 'Private') -Filter '*.ps1' -ErrorAction SilentlyContinue)
$public  = @(Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public')  -Filter '*.ps1' -ErrorAction SilentlyContinue)

foreach ($file in @($private + $public)) {
    try {
        . $file.FullName
    }
    catch {
        throw "PSAutoRBAC failed to load '$($file.FullName)': $($_.Exception.Message)"
    }
}

Export-ModuleMember -Function $public.BaseName