## Summary Implements Spec 284 for provider-neutral artifact source taxonomy. - add shared artifact source descriptor, resolver, taxonomy, and provider-detail support - update findings, evidence snapshots, stored reports, inventory items, and tenant review surfaces to disclose descriptor-first artifact summaries - add bounded Pest unit, feature, guard, and browser coverage for the taxonomy slice - include the completed Spec 284 package artifacts under `specs/284-provider-neutral-artifact-source-taxonomy/` ## Notes - branch: `284-provider-neutral-artifact-source-taxonomy` - commit: `bf8d59e0` - this PR was created as part of the requested commit/push/PR flow against `platform-dev` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #343
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Support\Concerns\DerivesWorkspaceIdFromTenant;
|
|
use App\Support\Artifacts\ArtifactProviderDetail;
|
|
use App\Support\Artifacts\ArtifactSourceDescriptor;
|
|
use App\Support\Artifacts\ArtifactSourceResolver;
|
|
use App\Support\Inventory\InventoryPolicyTypeMeta;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class InventoryItem extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\InventoryItemFactory> */
|
|
use DerivesWorkspaceIdFromTenant;
|
|
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'meta_jsonb' => 'array',
|
|
'last_seen_at' => 'datetime',
|
|
];
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ManagedEnvironment::class, 'managed_environment_id');
|
|
}
|
|
|
|
public function lastSeenRun(): BelongsTo
|
|
{
|
|
return $this->belongsTo(OperationRun::class, 'last_seen_operation_run_id');
|
|
}
|
|
|
|
public function lastSeenOperationRun(): BelongsTo
|
|
{
|
|
return $this->belongsTo(OperationRun::class, 'last_seen_operation_run_id');
|
|
}
|
|
|
|
/**
|
|
* @return array{
|
|
* canonical_type: string,
|
|
* provider_object_type: string,
|
|
* provider_display_type: string,
|
|
* legacy_policy_type: ?string
|
|
* }
|
|
*/
|
|
public function inventoryTypeDescriptor(): array
|
|
{
|
|
return InventoryPolicyTypeMeta::typeDescriptorFor(
|
|
is_string($this->policy_type) ? $this->policy_type : null,
|
|
is_array($this->meta_jsonb) ? $this->meta_jsonb : [],
|
|
);
|
|
}
|
|
|
|
public function artifactSourceDescriptor(): ArtifactSourceDescriptor
|
|
{
|
|
return app(ArtifactSourceResolver::class)->forInventoryItem($this);
|
|
}
|
|
|
|
public function artifactProviderDetail(): ArtifactProviderDetail
|
|
{
|
|
return app(ArtifactSourceResolver::class)->providerDetailForInventoryItem($this);
|
|
}
|
|
}
|