feat: establish catalog identity and atomic file ownership

This commit is contained in:
Cline committed 2026-10-12 19:38:38 -05:00
1 parent 390a7a557a
commit 6b9fb54b4f
16 files changed
+1381 -23

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace MeshVault\Catalog;
use MeshVault\Repository\CatalogRepositoryInterface;
final class CatalogService
{
public function __construct(private readonly CatalogRepositoryInterface $catalog)
{
}
public function createModel(string $folderPath, string $modelName): int
{
return $this->catalog->atomic(fn (): int => $this->catalog->createModel($folderPath, $modelName));
}
/** @return array{model: array, folder: array, files: array}|null */
public function aggregate(int $modelId): ?array
{
return $this->catalog->aggregate($modelId);
}
public function assignFiles(int $modelId, array $fileIds): void
{
$this->catalog->atomic(fn () => $this->catalog->changeFileOwner($fileIds, null, $modelId));
}
public function reassignFiles(int $expectedModelId, int $targetModelId, array $fileIds): void
{
$this->catalog->atomic(fn () => $this->catalog->changeFileOwner($fileIds, $expectedModelId, $targetModelId));
}
public function detachFiles(int $expectedModelId, array $fileIds): void
{
$this->catalog->atomic(fn () => $this->catalog->changeFileOwner($fileIds, $expectedModelId, null));
}
}