chore: bunch of improvements
All checks were successful
JS Unit Tests / test (pull_request) Successful in 33s
Build Test / test (pull_request) Successful in 36s
PHP Unit Tests / test (pull_request) Successful in 1m12s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-04-23 22:00:50 -04:00
parent b617234b40
commit 3362afb7ec
28 changed files with 1717 additions and 1297 deletions

View File

@@ -981,24 +981,105 @@ class Manager {
return $responseData;
}
public function entityDelete(string $tenantId, string $userId, ResourceIdentifiers $sources): array {
$operationOutcome = [];
foreach ($sources->providers() as $providerName) {
$providerSources = $sources->byProvider($providerName);
foreach ($providerSources->services() as $serviceName) {
$serviceSources = $providerSources->byService($serviceName);
$service = null;
try {
$service = $this->serviceFetch($tenantId, $userId, $providerName, $serviceName);
} catch (\Throwable $e) {
// Service not found, mark all identifiers as failed
}
if ($service === null) {
foreach ($serviceSources as $identifier) {
$operationOutcome[(string)$identifier] = [
'success' => false,
'error' => 'serviceNotFound',
];
}
continue;
}
// Temporarily disabled check until all methods are properly implemented from ServiceEntityMutableInterface
/*
if (!($service instanceof ServiceEntityMutableInterface)) {
foreach ($serviceSources as $identifier) {
$operationOutcome[(string)$identifier] = [
'success' => false,
'error' => 'serviceNotEntityMutable',
];
}
continue;
}
if (!$service->capable(ServiceEntityMutableInterface::CAPABILITY_ENTITY_DELETE)) {
foreach ($serviceSources as $identifier) {
$operationOutcome[(string)$identifier] = [
'success' => false,
'error' => 'serviceCannotDeleteEntities',
];
}
continue;
}
*/
try {
$operationResult = $service->entityDelete(...$serviceSources->all());
foreach ($serviceSources as $identifier) {
$sourceIdentifier = (string)$identifier;
$entityIdentifier = $identifier->entity();
$result = $operationResult[$entityIdentifier] ?? null;
if ($result === true) {
$operationOutcome[$sourceIdentifier] = [
'success' => true,
];
continue;
}
$operationOutcome[$sourceIdentifier] = [
'success' => false,
'error' => is_string($result) && $result !== '' ? $result : 'unknownError',
];
}
} catch (\Throwable $e) {
foreach ($serviceSources as $identifier) {
$operationOutcome[(string)$identifier] = [
'success' => false,
'error' => $e->getMessage(),
];
}
}
}
}
return $operationOutcome;
}
public function entityMove(string $tenantId, string $userId, CollectionIdentifier $target, ResourceIdentifiers $sources): array {
$targetService = $this->serviceFetch($tenantId, $userId, $target->provider(), $target->service());
// Check if service supports entity move
// Temporarily disabled check until all methods are properly implemented from ServiceEntityMutableInterface
/*
if ($targetService instanceof ServiceEntityMutableInterface === false) {
//return [];
return [];
}
*/
$operationOutcome = [];
$destinationSources = $sources->byProvider($targetService->provider())->byService((string)$targetService->identifier());
if (!$destinationSources->isEmpty()) {
$entitiesToMove = [];
foreach ($destinationSources as $identifier) {
$entitiesToMove[$identifier->collection()][] = $identifier->entity();
}
$operationResult = $targetService->entityMove($target->collection(), $entitiesToMove);
$operationResult = $targetService->entityMove($target, ...$destinationSources->all());
foreach ($destinationSources as $identifier) {
$sourceIdentifier = (string)$identifier;