Some checks are pending
Main Confidence / confidence (push) Waiting to run
## Summary - add a shared provider target-scope descriptor, normalizer, identity-context metadata, and surface-summary layer - update provider connection list, detail, create, edit, and onboarding surfaces to use neutral target-scope vocabulary while keeping Microsoft identity contextual - align provider connection audit and resolver output with the neutral target-scope contract and add focused guard/unit/feature coverage for regressions ## Validation - browser smoke: opened the tenant-scoped provider connection list, drilled into detail, and verified the edit/create surfaces in local admin context ## Notes - this PR comes from the session branch created for the active feature work - no additional runtime or persistence layer was introduced in this slice Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #274
79 lines
2.9 KiB
PHP
79 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Providers;
|
|
|
|
use App\Models\ProviderConnection;
|
|
use App\Support\Providers\ProviderReasonCodes;
|
|
use App\Support\Providers\TargetScope\ProviderConnectionTargetScopeDescriptor;
|
|
use App\Support\Providers\TargetScope\ProviderConnectionTargetScopeNormalizer;
|
|
use App\Support\Providers\TargetScope\ProviderIdentityContextMetadata;
|
|
|
|
final class ProviderConnectionResolution
|
|
{
|
|
/**
|
|
* @param list<ProviderIdentityContextMetadata> $contextualIdentityDetails
|
|
*/
|
|
private function __construct(
|
|
public readonly bool $resolved,
|
|
public readonly ?ProviderConnection $connection,
|
|
public readonly ?string $reasonCode,
|
|
public readonly ?string $extensionReasonCode,
|
|
public readonly ?string $message,
|
|
public readonly ?ProviderConnectionTargetScopeDescriptor $targetScope,
|
|
public readonly array $contextualIdentityDetails,
|
|
) {}
|
|
|
|
public static function resolved(ProviderConnection $connection): self
|
|
{
|
|
/** @var ProviderConnectionTargetScopeNormalizer $normalizer */
|
|
$normalizer = app(ProviderConnectionTargetScopeNormalizer::class);
|
|
|
|
return new self(
|
|
resolved: true,
|
|
connection: $connection,
|
|
reasonCode: null,
|
|
extensionReasonCode: null,
|
|
message: null,
|
|
targetScope: $normalizer->descriptorForConnection($connection),
|
|
contextualIdentityDetails: $normalizer->contextualIdentityDetailsForConnection($connection),
|
|
);
|
|
}
|
|
|
|
public static function blocked(
|
|
string $reasonCode,
|
|
?string $message = null,
|
|
?string $extensionReasonCode = null,
|
|
?ProviderConnection $connection = null,
|
|
): self {
|
|
/** @var ProviderConnectionTargetScopeNormalizer $normalizer */
|
|
$normalizer = app(ProviderConnectionTargetScopeNormalizer::class);
|
|
$targetScope = null;
|
|
$contextualIdentityDetails = [];
|
|
|
|
if ($connection instanceof ProviderConnection) {
|
|
$normalization = $normalizer->normalizeConnection($connection);
|
|
$descriptor = $normalization['target_scope'] ?? null;
|
|
|
|
if ($descriptor instanceof ProviderConnectionTargetScopeDescriptor) {
|
|
$targetScope = $descriptor;
|
|
$contextualIdentityDetails = $normalizer->contextualIdentityDetailsForConnection($connection);
|
|
}
|
|
}
|
|
|
|
return new self(
|
|
resolved: false,
|
|
connection: $connection,
|
|
reasonCode: ProviderReasonCodes::isKnown($reasonCode) ? $reasonCode : ProviderReasonCodes::UnknownError,
|
|
extensionReasonCode: $extensionReasonCode,
|
|
message: $message,
|
|
targetScope: $targetScope,
|
|
contextualIdentityDetails: $contextualIdentityDetails,
|
|
);
|
|
}
|
|
|
|
public function effectiveReasonCode(): string
|
|
{
|
|
return $this->reasonCode ?? ProviderReasonCodes::UnknownError;
|
|
}
|
|
}
|