Pax8API/Pax8API.psm1
|
<# .SYNOPSIS Pax8API — Kritical-authored PowerShell client for the Pax8 partner API. .DESCRIPTION Headless OAuth client_credentials grant against token-manager.pax8.com. Spec-generated from the Pax8 OpenAPI surface. Safe for cron / supervisor / Hermes / Kritical autopilot — never opens a browser. Sister module: Krit.Pax8Mcp (https://mcp.pax8.com hosted MCP path for chat agents). .AUTHOR Joshua Finley — Kritical Pty Ltd — https://kritical.net #> param ( [switch]$DisableUpdateCheck, [switch]$NoBanner ) # Brand banner — render on import unless suppressed if (-not $NoBanner.IsPresent -and -not $env:KRIT_NO_BANNER) { $bannerCandidates = @( (Join-Path $env:USERPROFILE 'OneDrive - Kritical Pty Ltd\Github-SecretsOutsideOfGitRepos\KriticalLogo.txt'), (Join-Path $PSScriptRoot 'Assets/kritical-logo.txt') ) foreach ($c in $bannerCandidates) { if (Test-Path -LiteralPath $c) { try { $logo = Get-Content -LiteralPath $c -Raw Write-Host $logo -ForegroundColor DarkCyan Write-Host '--- Kritical Pax8API (headless partner API client) ---' -ForegroundColor Yellow } catch {} break } } } $script:Pax8ModuleRoot = $PSScriptRoot $script:Pax8OperationMap = @{} $script:Pax8Session = [ordered]@{ AccessToken = $null ExpiresAt = [datetimeoffset]::MinValue Audience = $null Credential = $null BaseUri = $null TokenUri = $null LastConnectedAt = $null } $operationPath = Join-Path -Path $script:Pax8ModuleRoot -ChildPath 'data/Pax8Operations.json' if (Test-Path -LiteralPath $operationPath) { $operationData = Get-Content -LiteralPath $operationPath -Raw | ConvertFrom-Json foreach ($operation in $operationData.operations) { $script:Pax8OperationMap[$operation.CommandName] = $operation foreach ($alias in @($operation.Aliases)) { if ($alias) { $script:Pax8OperationMap[$alias] = $operation } } } } $privateScripts = Get-ChildItem -Path (Join-Path $script:Pax8ModuleRoot 'Private') -Filter '*.ps1' -Recurse -ErrorAction SilentlyContinue foreach ($script in $privateScripts) { . $script.FullName } $publicScripts = Get-ChildItem -Path (Join-Path $script:Pax8ModuleRoot 'Public') -Filter '*.ps1' -Recurse -ErrorAction SilentlyContinue foreach ($script in $publicScripts) { . $script.FullName } if (-not $DisableUpdateCheck) { Start-Pax8OpenApiUpdateCheck } Export-ModuleMember -Function $publicScripts.BaseName -Alias * |