diff --git a/src/IdLE.Core/IdLE.Core.psd1 b/src/IdLE.Core/IdLE.Core.psd1 index 7ff00c9b..48385a27 100644 --- a/src/IdLE.Core/IdLE.Core.psd1 +++ b/src/IdLE.Core/IdLE.Core.psd1 @@ -13,7 +13,9 @@ 'New-IdlePlanObject', 'Invoke-IdlePlanObject', 'Export-IdlePlanObject', - 'New-IdleAuthSessionBroker' + 'New-IdleAuthSessionBroker', + 'Invoke-IdleProviderMethod', + 'Test-IdleProviderMethodParameter' ) CmdletsToExport = @() AliasesToExport = @() diff --git a/src/IdLE.Core/IdLE.Core.psm1 b/src/IdLE.Core/IdLE.Core.psm1 index 0575360c..06956a7b 100644 --- a/src/IdLE.Core/IdLE.Core.psm1 +++ b/src/IdLE.Core/IdLE.Core.psm1 @@ -45,5 +45,7 @@ Export-ModuleMember -Function @( 'New-IdlePlanObject', 'Invoke-IdlePlanObject', 'Export-IdlePlanObject', - 'New-IdleAuthSessionBroker' + 'New-IdleAuthSessionBroker', + 'Invoke-IdleProviderMethod', + 'Test-IdleProviderMethodParameter' ) -Alias @() diff --git a/src/IdLE.Steps.Common/Private/Invoke-IdleProviderMethod.ps1 b/src/IdLE.Core/Public/Invoke-IdleProviderMethod.ps1 similarity index 58% rename from src/IdLE.Steps.Common/Private/Invoke-IdleProviderMethod.ps1 rename to src/IdLE.Core/Public/Invoke-IdleProviderMethod.ps1 index a8d28431..e750241a 100644 --- a/src/IdLE.Steps.Common/Private/Invoke-IdleProviderMethod.ps1 +++ b/src/IdLE.Core/Public/Invoke-IdleProviderMethod.ps1 @@ -2,6 +2,49 @@ # Handles auth session acquisition, parameter detection, and backwards-compatible fallback. function Invoke-IdleProviderMethod { + <# + .SYNOPSIS + Invokes a provider method with optional AuthSession support. + + .DESCRIPTION + This is a foundational helper for step implementations that need to invoke + provider methods with proper authentication handling. + + Key features: + - Acquires auth sessions via Context.AcquireAuthSession when With.AuthSessionName is present + - Detects whether provider methods support AuthSession parameter (backwards compatible) + - Passes AuthSession to provider methods that support it + - Validates provider existence and method implementation + + .PARAMETER Context + Execution context created by IdLE.Core. Must contain Providers hashtable and + AcquireAuthSession method. + + .PARAMETER With + Step configuration hashtable. May contain: + - AuthSessionName (string): Name of auth session to acquire + - AuthSessionOptions (hashtable): Optional session selection options + + .PARAMETER ProviderAlias + Key to look up the provider in Context.Providers. + + .PARAMETER MethodName + Name of the provider method to invoke. + + .PARAMETER MethodArguments + Array of arguments to pass to the provider method (excluding AuthSession). + + .OUTPUTS + Object returned by the provider method. + + .EXAMPLE + $result = Invoke-IdleProviderMethod ` + -Context $Context ` + -With @{ AuthSessionName = 'ExchangeOnline' } ` + -ProviderAlias 'ExchangeOnline' ` + -MethodName 'EnsureMailboxType' ` + -MethodArguments @('user@contoso.com', 'Shared') + #> [CmdletBinding()] param( [Parameter(Mandatory)] diff --git a/src/IdLE.Steps.Common/Private/Test-IdleProviderMethodParameter.ps1 b/src/IdLE.Core/Public/Test-IdleProviderMethodParameter.ps1 similarity index 66% rename from src/IdLE.Steps.Common/Private/Test-IdleProviderMethodParameter.ps1 rename to src/IdLE.Core/Public/Test-IdleProviderMethodParameter.ps1 index 870217a6..434a6b61 100644 --- a/src/IdLE.Steps.Common/Private/Test-IdleProviderMethodParameter.ps1 +++ b/src/IdLE.Core/Public/Test-IdleProviderMethodParameter.ps1 @@ -2,6 +2,40 @@ # Supports ScriptMethod (AST inspection) and compiled methods (reflection). function Test-IdleProviderMethodParameter { + <# + .SYNOPSIS + Tests whether a provider method supports a given parameter. + + .DESCRIPTION + This is a foundational helper that inspects provider method signatures to determine + if they accept a specific parameter (e.g., AuthSession). + + Supports: + - ScriptMethod (AST inspection via PowerShell parser) + - Compiled methods (reflection-based inspection) + + Used by Invoke-IdleProviderMethod to detect backwards-compatible method signatures. + + .PARAMETER ProviderMethod + PSMethodInfo object representing the provider method to inspect. + + .PARAMETER ParameterName + Name of the parameter to check for (e.g., 'AuthSession'). + + .OUTPUTS + Boolean. True if the method accepts the specified parameter, False otherwise. + + .EXAMPLE + $provider = [pscustomobject]@{} + $provider | Add-Member -MemberType ScriptMethod -Name MyMethod -Value { + param($Arg1, $AuthSession) + # ... + } + + $method = $provider.PSObject.Methods['MyMethod'] + Test-IdleProviderMethodParameter -ProviderMethod $method -ParameterName 'AuthSession' + # Returns: True + #> [CmdletBinding()] [OutputType([bool])] param( diff --git a/src/IdLE.Steps.Common/IdLE.Steps.Common.psd1 b/src/IdLE.Steps.Common/IdLE.Steps.Common.psd1 index 6958b740..9526e698 100644 --- a/src/IdLE.Steps.Common/IdLE.Steps.Common.psd1 +++ b/src/IdLE.Steps.Common/IdLE.Steps.Common.psd1 @@ -7,6 +7,8 @@ Description = 'Common built-in steps for IdLE.' PowerShellVersion = '7.0' + RequiredModules = @('IdLE.Core') + FunctionsToExport = @( 'Get-IdleStepMetadataCatalog', 'Invoke-IdleStepEmitEvent', diff --git a/src/IdLE.Steps.Common/Public/Get-IdleStepMetadataCatalog.ps1 b/src/IdLE.Steps.Common/Public/Get-IdleStepMetadataCatalog.ps1 index 2f266676..42f2818a 100644 --- a/src/IdLE.Steps.Common/Public/Get-IdleStepMetadataCatalog.ps1 +++ b/src/IdLE.Steps.Common/Public/Get-IdleStepMetadataCatalog.ps1 @@ -1,7 +1,7 @@ function Get-IdleStepMetadataCatalog { <# .SYNOPSIS - Returns metadata for built-in IdLE step types. + Returns metadata for common built-in IdLE step types. .DESCRIPTION This function provides a metadata catalog mapping Step.Type to metadata objects. @@ -16,7 +16,7 @@ function Get-IdleStepMetadataCatalog { .EXAMPLE $metadata = Get-IdleStepMetadataCatalog $metadata['IdLE.Step.DisableIdentity'].RequiredCapabilities - # Returns: @('IdLE.Identity.Disable', 'IdLE.Identity.Read') + # Returns: @('IdLE.Identity.Disable') #> [CmdletBinding()] param() diff --git a/src/IdLE.Steps.DirectorySync/IdLE.Steps.DirectorySync.psd1 b/src/IdLE.Steps.DirectorySync/IdLE.Steps.DirectorySync.psd1 index 6189f3ef..ed07b09c 100644 --- a/src/IdLE.Steps.DirectorySync/IdLE.Steps.DirectorySync.psd1 +++ b/src/IdLE.Steps.DirectorySync/IdLE.Steps.DirectorySync.psd1 @@ -8,6 +8,7 @@ PowerShellVersion = '7.0' RequiredModules = @( + 'IdLE.Core', 'IdLE.Steps.Common' ) diff --git a/src/IdLE.Steps.Mailbox/IdLE.Steps.Mailbox.psd1 b/src/IdLE.Steps.Mailbox/IdLE.Steps.Mailbox.psd1 index 7572d6d4..b07d5d3d 100644 --- a/src/IdLE.Steps.Mailbox/IdLE.Steps.Mailbox.psd1 +++ b/src/IdLE.Steps.Mailbox/IdLE.Steps.Mailbox.psd1 @@ -7,7 +7,7 @@ Description = 'Provider-agnostic mailbox step pack for IdLE.' PowerShellVersion = '7.0' - RequiredModules = @('IdLE.Steps.Common') + RequiredModules = @('IdLE.Core', 'IdLE.Steps.Common') FunctionsToExport = @( 'Get-IdleStepMetadataCatalog',