chore: standardize protocol

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-14 11:45:34 -05:00
parent 169b7b4c91
commit fefa0a0384
18 changed files with 3090 additions and 1239 deletions

View File

@@ -226,34 +226,39 @@ class DefaultController extends ControllerAbstract {
return match ($operation) {
// Provider operations
'provider.list' => $this->providerList($tenantId, $userId, $data),
'provider.fetch' => $this->providerFetch($tenantId, $userId, $data),
'provider.extant' => $this->providerExtant($tenantId, $userId, $data),
// Service operations
'service.list' => $this->serviceList($tenantId, $userId, $data),
'service.extant' => $this->serviceExtant($tenantId, $userId, $data),
'service.fetch' => $this->serviceFetch($tenantId, $userId, $data),
'service.discover' => $this->serviceDiscover($tenantId, $userId, $data),
'service.test' => $this->serviceTest($tenantId, $userId, $data),
'service.extant' => $this->serviceExtant($tenantId, $userId, $data),
'service.create' => $this->serviceCreate($tenantId, $userId, $data),
'service.update' => $this->serviceUpdate($tenantId, $userId, $data),
'service.delete' => $this->serviceDelete($tenantId, $userId, $data),
'service.discover' => $this->serviceDiscover($tenantId, $userId, $data),
'service.test' => $this->serviceTest($tenantId, $userId, $data),
// Collection operations
'collection.list' => $this->collectionList($tenantId, $userId, $data),
'collection.extant' => $this->collectionExtant($tenantId, $userId, $data),
'collection.fetch' => $this->collectionFetch($tenantId, $userId, $data),
'collection.extant' => $this->collectionExtant($tenantId, $userId, $data),
'collection.create' => $this->collectionCreate($tenantId, $userId, $data),
'collection.modify' => $this->collectionModify($tenantId, $userId, $data),
'collection.destroy' => $this->collectionDestroy($tenantId, $userId, $data),
'collection.update' => $this->collectionUpdate($tenantId, $userId, $data),
'collection.delete' => $this->collectionDelete($tenantId, $userId, $data),
'collection.delta' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
'collection.move' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
// Entity operations
'entity.list' => $this->entityList($tenantId, $userId, $data),
'entity.delta' => $this->entityDelta($tenantId, $userId, $data),
'entity.extant' => $this->entityExtant($tenantId, $userId, $data),
'entity.fetch' => $this->entityFetch($tenantId, $userId, $data),
'entity.extant' => $this->entityExtant($tenantId, $userId, $data),
'entity.create' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
'entity.update' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
'entity.delete' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
'entity.delta' => $this->entityDelta($tenantId, $userId, $data),
'entity.move' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
'entity.copy' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
'entity.transmit' => $this->entityTransmit($tenantId, $userId, $data),
default => throw new InvalidArgumentException('Unknown operation: ' . $operation)
@@ -289,6 +294,18 @@ class DefaultController extends ControllerAbstract {
}
private function providerFetch(string $tenantId, string $userId, array $data): mixed {
if (!isset($data['identifier'])) {
throw new InvalidArgumentException(self::ERR_MISSING_IDENTIFIER);
}
if (!is_string($data['identifier'])) {
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
}
return $this->mailManager->providerFetch($tenantId, $userId, $data['identifier']);
}
// ==================== Service Operations =====================
private function serviceList(string $tenantId, string $userId, array $data): mixed {
@@ -536,7 +553,7 @@ class DefaultController extends ControllerAbstract {
);
}
private function collectionModify(string $tenantId, string $userId, array $data): mixed {
private function collectionUpdate(string $tenantId, string $userId, array $data): mixed {
if (!isset($data['provider'])) {
throw new InvalidArgumentException(self::ERR_MISSING_PROVIDER);
}
@@ -562,7 +579,7 @@ class DefaultController extends ControllerAbstract {
throw new InvalidArgumentException(self::ERR_INVALID_DATA);
}
return $this->mailManager->collectionModify(
return $this->mailManager->collectionUpdate(
$tenantId,
$userId,
$data['provider'],
@@ -572,7 +589,7 @@ class DefaultController extends ControllerAbstract {
);
}
private function collectionDestroy(string $tenantId, string $userId, array $data): mixed {
private function collectionDelete(string $tenantId, string $userId, array $data): mixed {
if (!isset($data['provider'])) {
throw new InvalidArgumentException(self::ERR_MISSING_PROVIDER);
}
@@ -592,7 +609,7 @@ class DefaultController extends ControllerAbstract {
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
}
return $this->mailManager->collectionDestroy(
return $this->mailManager->collectionDelete(
$tenantId,
$userId,
$data['provider'],

View File

@@ -621,7 +621,7 @@ class Manager {
* @return CollectionBaseInterface
* @throws InvalidArgumentException
*/
public function collectionModify(string $tenantId, string $userId, string $providerId, string|int $serviceId, string|int $collectionId, CollectionMutableInterface|array $object): CollectionBaseInterface {
public function collectionUpdate(string $tenantId, string $userId, string $providerId, string|int $serviceId, string|int $collectionId, CollectionMutableInterface|array $object): CollectionBaseInterface {
// retrieve service
$service = $this->serviceFetch($tenantId, $userId, $providerId, $serviceId);
@@ -629,8 +629,8 @@ class Manager {
if (!($service instanceof ServiceCollectionMutableInterface)) {
throw new InvalidArgumentException("Service does not support collection mutations");
}
if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_MODIFY)) {
throw new InvalidArgumentException("Service is not capable of modifying collections");
if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_UPDATE)) {
throw new InvalidArgumentException("Service is not capable of updating collections");
}
if (is_array($object)) {
@@ -640,12 +640,12 @@ class Manager {
$collection = $object;
}
// Modify collection
return $service->collectionModify($collectionId, $collection);
// Update collection
return $service->collectionUpdate($collectionId, $collection);
}
/**
* Destroy a specific collection
* Delete a specific collection
*
* @since 2025.05.01
*
@@ -657,23 +657,23 @@ class Manager {
*
* @return CollectionBaseInterface|null
*/
public function collectionDestroy(string $tenantId, ?string $userId, string $providerId, string|int $serviceId, string|int $collectionId, array $options = []): bool {
public function collectionDelete(string $tenantId, ?string $userId, string $providerId, string|int $serviceId, string|int $collectionId, array $options = []): bool {
// retrieve service
$service = $this->serviceFetch($tenantId, $userId, $providerId, $serviceId);
// Check if service supports collection destruction
// Check if service supports collection deletion
if (!($service instanceof ServiceCollectionMutableInterface)) {
throw new InvalidArgumentException("Service does not support collection mutations");
}
if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_DESTROY)) {
throw new InvalidArgumentException("Service is not capable of destroying collections");
if (!$service->capable(ServiceCollectionMutableInterface::CAPABILITY_COLLECTION_DELETE)) {
throw new InvalidArgumentException("Service is not capable of deleting collections");
}
$force = $options['force'] ?? false;
$recursive = $options['recursive'] ?? false;
// destroy collection
return $service->collectionDestroy($collectionId, $force, $recursive);
// delete collection
return $service->collectionDelete($collectionId, $force, $recursive);
}
// ==================== Message Operations ====================