Initial Version
This commit is contained in:
237
shared/lib/Mail/Service/ServiceBaseInterface.php
Normal file
237
shared/lib/Mail/Service/ServiceBaseInterface.php
Normal file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use KTXF\Mail\Collection\CollectionBaseInterface;
|
||||
use KTXF\Mail\Object\AddressInterface;
|
||||
use KTXF\Resource\Delta\Delta;
|
||||
use KTXF\Resource\Filter\IFilter;
|
||||
use KTXF\Resource\Provider\ResourceServiceBaseInterface;
|
||||
use KTXF\Resource\Range\IRange;
|
||||
use KTXF\Resource\Range\RangeType;
|
||||
use KTXF\Resource\Sort\ISort;
|
||||
|
||||
/**
|
||||
* Mail Service Base Interface
|
||||
*
|
||||
* Core interface for mail services with full protocol support (IMAP, JMAP, EWS, ActiveSync, Gmail API, etc.)
|
||||
* Provides identity, addressing, capability information, and collection/message operations.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceBaseInterface extends ResourceServiceBaseInterface {
|
||||
|
||||
// Collection capabilities
|
||||
public const CAPABILITY_COLLECTION_LIST = 'CollectionList';
|
||||
public const CAPABILITY_COLLECTION_LIST_FILTER = 'CollectionListFilter';
|
||||
public const CAPABILITY_COLLECTION_LIST_SORT = 'CollectionListSort';
|
||||
public const CAPABILITY_COLLECTION_EXTANT = 'CollectionExtant';
|
||||
public const CAPABILITY_COLLECTION_FETCH = 'CollectionFetch';
|
||||
// Collection Filter
|
||||
public const CAPABILITY_COLLECTION_FILTER_LABEL = 'label';
|
||||
public const CAPABILITY_COLLECTION_FILTER_ROLE = 'role';
|
||||
// Collection Sort
|
||||
public const CAPABILITY_COLLECTION_SORT_LABEL = 'label';
|
||||
public const CAPABILITY_COLLECTION_SORT_RANK = 'rank';
|
||||
// Entity capabilities
|
||||
public const CAPABILITY_ENTITY_LIST = 'EntityList';
|
||||
public const CAPABILITY_ENTITY_LIST_FILTER = 'EntityListFilter';
|
||||
public const CAPABILITY_ENTITY_LIST_SORT = 'EntityListSort';
|
||||
public const CAPABILITY_ENTITY_LIST_RANGE = 'EntityListRange';
|
||||
public const CAPABILITY_ENTITY_DELTA = 'EntityDelta';
|
||||
public const CAPABILITY_ENTITY_EXTANT = 'EntityExtant';
|
||||
public const CAPABILITY_ENTITY_FETCH = 'EntityFetch';
|
||||
// Filter capabilities
|
||||
public const CAPABILITY_ENTITY_FILTER_ALL = '*';
|
||||
public const CAPABILITY_ENTITY_FILTER_FROM = 'from';
|
||||
public const CAPABILITY_ENTITY_FILTER_TO = 'to';
|
||||
public const CAPABILITY_ENTITY_FILTER_CC = 'cc';
|
||||
public const CAPABILITY_ENTITY_FILTER_BCC = 'bcc';
|
||||
public const CAPABILITY_ENTITY_FILTER_SUBJECT = 'subject';
|
||||
public const CAPABILITY_ENTITY_FILTER_BODY = 'body';
|
||||
public const CAPABILITY_ENTITY_FILTER_DATE_BEFORE = 'before';
|
||||
public const CAPABILITY_ENTITY_FILTER_DATE_AFTER = 'after';
|
||||
public const CAPABILITY_ENTITY_FILTER_SIZE_MIN = 'min';
|
||||
public const CAPABILITY_ENTITY_FILTER_SIZE_MAX = 'max';
|
||||
// Sort capabilities
|
||||
public const CAPABILITY_ENTITY_SORT_FROM = 'from';
|
||||
public const CAPABILITY_ENTITY_SORT_TO = 'to';
|
||||
public const CAPABILITY_ENTITY_SORT_SUBJECT = 'subject';
|
||||
public const CAPABILITY_ENTITY_SORT_DATE_RECEIVED = 'received';
|
||||
public const CAPABILITY_ENTITY_SORT_DATE_SENT = 'sent';
|
||||
public const CAPABILITY_ENTITY_SORT_SIZE = 'size';
|
||||
|
||||
public const JSON_TYPE = 'mail.service';
|
||||
public const JSON_PROPERTY_PRIMARY_ADDRESS = 'primaryAddress';
|
||||
public const JSON_PROPERTY_SECONDARY_ADDRESSES = 'secondaryAddresses';
|
||||
|
||||
/**
|
||||
* Gets the primary mailing address for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return AddressInterface
|
||||
*/
|
||||
public function getPrimaryAddress(): AddressInterface;
|
||||
|
||||
/**
|
||||
* Gets the secondary mailing addresses (aliases) for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return array<int,AddressInterface>
|
||||
*/
|
||||
public function getSecondaryAddresses(): array;
|
||||
|
||||
/**
|
||||
* Checks if this service handles a specific email address
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string $address Email address to check
|
||||
*
|
||||
* @return bool True if address matches primary or any secondary address
|
||||
*/
|
||||
public function hasAddress(string $address): bool;
|
||||
|
||||
/**
|
||||
* Lists all collections in this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param IFilter|null $filter Optional filter criteria
|
||||
* @param ISort|null $sort Optional sort order
|
||||
*
|
||||
* @return array<string|int,CollectionBaseInterface> Collections indexed by ID
|
||||
*/
|
||||
public function collectionList(string|int $location, ?IFilter $filter = null, ?ISort $sort = null): array;
|
||||
|
||||
/**
|
||||
* Creates a filter builder for collections
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return IFilter
|
||||
*/
|
||||
public function collectionListFilter(): IFilter;
|
||||
|
||||
/**
|
||||
* Creates a sort builder for collections
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return ISort
|
||||
*/
|
||||
public function collectionListSort(): ISort;
|
||||
|
||||
/**
|
||||
* Checks if collections exist
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int ...$identifiers Collection IDs to check
|
||||
*
|
||||
* @return array<string|int,bool> Map of ID => exists
|
||||
*/
|
||||
public function collectionExtant(string|int $location, string|int ...$identifiers): array;
|
||||
|
||||
/**
|
||||
* Fetches a single collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $identifier Collection ID
|
||||
*
|
||||
* @return CollectionBaseInterface|null Collection or null if not found
|
||||
*/
|
||||
public function collectionFetch(string|int $identifier): ?CollectionBaseInterface;
|
||||
|
||||
/**
|
||||
* Lists messages in a collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection ID
|
||||
* @param IFilter|null $filter Optional filter criteria
|
||||
* @param ISort|null $sort Optional sort order
|
||||
* @param IRange|null $range Optional pagination
|
||||
* @param array|null $properties Optional message properties to fetch
|
||||
*
|
||||
* @return array<string|int,EntityBaseInterface> Messages indexed by ID
|
||||
*/
|
||||
public function entityList(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $properties = null): array;
|
||||
|
||||
/**
|
||||
* Creates a filter builder for messages
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return IFilter
|
||||
*/
|
||||
public function entityListFilter(): IFilter;
|
||||
|
||||
/**
|
||||
* Creates a sort builder for messages
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return ISort
|
||||
*/
|
||||
public function entityListSort(): ISort;
|
||||
|
||||
/**
|
||||
* Creates a range builder for messages
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param RangeType $type Range type (offset, cursor, etc.)
|
||||
*
|
||||
* @return IRange
|
||||
*/
|
||||
public function entityListRange(RangeType $type): IRange;
|
||||
|
||||
/**
|
||||
* Gets incremental changes since last sync
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection ID
|
||||
* @param string $signature Sync token from previous sync
|
||||
* @param string $detail Detail level: 'ids', 'minimal', 'full'
|
||||
*
|
||||
* @return array ['signature' => string, 'added' => array, 'modified' => array, 'removed' => array]
|
||||
*/
|
||||
public function entityDelta(string|int $collection, string $signature, string $detail = 'ids'): Delta;
|
||||
|
||||
/**
|
||||
* Checks if messages exist
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection ID
|
||||
* @param string|int ...$identifiers Message IDs to check
|
||||
*
|
||||
* @return array<string|int,bool> Map of ID => exists
|
||||
*/
|
||||
public function entityExtant(string|int $collection, string|int ...$identifiers): array;
|
||||
|
||||
/**
|
||||
* Fetches one or more entities
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection ID
|
||||
* @param string|int ...$identifiers Message IDs to fetch
|
||||
*
|
||||
* @return array<string|int,EntityBaseInterface> Messages indexed by ID
|
||||
*/
|
||||
public function entityFetch(string|int $collection, string|int ...$identifiers): array;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use KTXF\Mail\Collection\CollectionBaseInterface;
|
||||
use KTXF\Mail\Collection\CollectionMutableInterface;
|
||||
|
||||
/**
|
||||
* Mail Service Collection Mutable Interface
|
||||
*
|
||||
* Optional interface for services that support collection CRUD operations.
|
||||
* Provides mailbox/folder creation, modification, deletion, and moving.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceCollectionMutableInterface extends ServiceBaseInterface {
|
||||
|
||||
public const CAPABILITY_COLLECTION_CREATE = 'CollectionCreate';
|
||||
public const CAPABILITY_COLLECTION_MODIFY = 'CollectionModify';
|
||||
public const CAPABILITY_COLLECTION_DESTROY = 'CollectionDestroy';
|
||||
public const CAPABILITY_COLLECTION_MOVE = 'CollectionMove';
|
||||
|
||||
/**
|
||||
* Creates a fresh collection instance for configuration
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return CollectionMutableInterface Fresh collection object
|
||||
*/
|
||||
public function collectionFresh(): CollectionMutableInterface;
|
||||
|
||||
/**
|
||||
* Creates a new collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int|null $location Parent collection ID (null for root)
|
||||
* @param CollectionMutableInterface $collection Collection to create
|
||||
* @param array $options Protocol-specific options
|
||||
*
|
||||
* @return CollectionBaseInterface Created collection with assigned ID
|
||||
*/
|
||||
public function collectionCreate(string|int|null $location, CollectionMutableInterface $collection, array $options = []): CollectionBaseInterface;
|
||||
|
||||
/**
|
||||
* Modifies an existing collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $identifier Collection ID
|
||||
* @param CollectionMutableInterface $collection Updated collection data
|
||||
*
|
||||
* @return CollectionBaseInterface Modified collection
|
||||
*/
|
||||
public function collectionModify(string|int $identifier, CollectionMutableInterface $collection): CollectionBaseInterface;
|
||||
|
||||
/**
|
||||
* Destroys a collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $identifier Collection ID
|
||||
* @param bool $force Force destruction even if not empty
|
||||
* @param bool $recursive Recursively destroy contents
|
||||
*
|
||||
* @return bool True if destroyed
|
||||
*/
|
||||
public function collectionDestroy(string|int $identifier, bool $force = false, bool $recursive = false): bool;
|
||||
|
||||
/**
|
||||
* Moves a collection to a new parent
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $identifier Collection ID
|
||||
* @param string|int|null $targetLocation New parent ID (null for root)
|
||||
*
|
||||
* @return CollectionBaseInterface Moved collection
|
||||
*/
|
||||
public function collectionMove(string|int $identifier, string|int|null $targetLocation): CollectionBaseInterface;
|
||||
|
||||
}
|
||||
26
shared/lib/Mail/Service/ServiceConfigurableInterface.php
Normal file
26
shared/lib/Mail/Service/ServiceConfigurableInterface.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use KTXF\Resource\Provider\ResourceServiceConfigureInterface;
|
||||
|
||||
/**
|
||||
* Mail Service Mutable Interface
|
||||
*
|
||||
* Extends base service interface with setter methods for mutable properties.
|
||||
* Used for service configuration and updates.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceConfigurableInterface extends ServiceMutableInterface, ResourceServiceConfigureInterface {
|
||||
|
||||
public const JSON_TYPE = ServiceBaseInterface::JSON_TYPE;
|
||||
|
||||
}
|
||||
103
shared/lib/Mail/Service/ServiceEntityMutableInterface.php
Normal file
103
shared/lib/Mail/Service/ServiceEntityMutableInterface.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use KTXF\Mail\Entity\EntityBaseInterface;
|
||||
use KTXF\Mail\Entity\EntityMutableInterface;
|
||||
|
||||
/**
|
||||
* Mail Service Entity Mutable Interface
|
||||
*
|
||||
* Optional interface for services that support entity CRUD operations.
|
||||
* Provides entity creation, modification, deletion, copying, moving, and flag management.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceEntityMutableInterface extends ServiceBaseInterface {
|
||||
|
||||
public const CAPABILITY_ENTITY_CREATE = 'EntityCreate';
|
||||
public const CAPABILITY_ENTITY_MODIFY = 'EntityModify';
|
||||
public const CAPABILITY_ENTITY_DESTROY = 'EntityDestroy';
|
||||
public const CAPABILITY_ENTITY_COPY = 'EntityCopy';
|
||||
public const CAPABILITY_ENTITY_MOVE = 'EntityMove';
|
||||
|
||||
/**
|
||||
* Creates a fresh entity instance for composition
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return EntityMutableInterface Fresh entity object
|
||||
*/
|
||||
public function entityFresh(): EntityMutableInterface;
|
||||
|
||||
/**
|
||||
* Creates/imports an entity into a collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection collection identifier
|
||||
* @param EntityMutableInterface $entity Entity data
|
||||
* @param array $options additional options
|
||||
*
|
||||
* @return EntityBaseInterface Created entity
|
||||
*/
|
||||
public function entityCreate(string|int $collection, EntityMutableInterface $entity, array $options = []): EntityBaseInterface;
|
||||
|
||||
/**
|
||||
* Modifies an existing entity
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection identifier
|
||||
* @param string|int $identifier Entity identifier
|
||||
* @param EntityMutableInterface $entity Entity data
|
||||
*
|
||||
* @return EntityBaseInterface Modified entity
|
||||
*/
|
||||
public function entityModify(string|int $collection, string|int $identifier, EntityMutableInterface $entity): EntityBaseInterface;
|
||||
/**
|
||||
* Destroys one or more entities
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection identifier
|
||||
* @param string|int ...$identifiers Entity identifiers to destroy
|
||||
*
|
||||
* @return array<string|int,bool> List of destroyed entity identifiers
|
||||
*/
|
||||
public function entityDestroy(string|int $collection, string|int ...$identifiers): array;
|
||||
|
||||
/**
|
||||
* Copies entities to another collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $sourceCollection Source collection identifier
|
||||
* @param string|int $targetCollection Target collection identifier
|
||||
* @param string|int ...$identifiers Entity identifiers to copy
|
||||
*
|
||||
* @return array<string|int,string|int> Map of source identifier => new identifier
|
||||
*/
|
||||
public function entityCopy(string|int $sourceCollection, string|int $targetCollection, string|int ...$identifiers): array;
|
||||
|
||||
/**
|
||||
* Moves entities to another collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $sourceCollection Source collection identifier
|
||||
* @param string|int $targetCollection Target collection identifier
|
||||
* @param string|int ...$identifiers Entity identifiers to move
|
||||
*
|
||||
* @return array<string|int,bool> List of moved entity identifiers
|
||||
*/
|
||||
public function entityMove(string|int $sourceCollection, string|int $targetCollection, string|int ...$identifiers): array;
|
||||
|
||||
}
|
||||
48
shared/lib/Mail/Service/ServiceEntityTransmitInterface.php
Normal file
48
shared/lib/Mail/Service/ServiceEntityTransmitInterface.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use KTXF\Mail\Entity\EntityMutableInterface;
|
||||
use KTXF\Mail\Exception\SendException;
|
||||
|
||||
/**
|
||||
* Mail Service Transmit Interface
|
||||
*
|
||||
* Interface for mail services capable of transmitting outbound entities.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceEntityTransmitInterface extends ServiceBaseInterface {
|
||||
|
||||
public const CAPABILITY_ENTITY_TRANSMIT = 'EntityTransmit';
|
||||
|
||||
/**
|
||||
* Creates a fresh entity instance for composition
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return EntityMutableInterface Fresh entity object
|
||||
*/
|
||||
public function entityFresh(): EntityMutableInterface;
|
||||
|
||||
/**
|
||||
* Transmits an outbound entity
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param EntityMutableInterface $entity Entity to transmit
|
||||
*
|
||||
* @return string Entity identifier assigned by the transport
|
||||
*
|
||||
* @throws SendException On delivery failure
|
||||
*/
|
||||
public function entitySend(EntityMutableInterface $entity): string;
|
||||
|
||||
}
|
||||
46
shared/lib/Mail/Service/ServiceMutableInterface.php
Normal file
46
shared/lib/Mail/Service/ServiceMutableInterface.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
use KTXF\Mail\Object\AddressInterface;
|
||||
|
||||
/**
|
||||
* Mail Service Mutable Interface
|
||||
*
|
||||
* Extends base service interface with setter methods for mutable properties.
|
||||
* Used for service configuration and updates.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceMutableInterface extends ServiceBaseInterface {
|
||||
|
||||
/**
|
||||
* Sets the primary mailing address for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param AddressInterface $value Primary email address
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setPrimaryAddress(AddressInterface $value): static;
|
||||
|
||||
/**
|
||||
* Sets the secondary mailing addresses (aliases) for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array<int,AddressInterface> $value Array of secondary addresses
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setSecondaryAddresses(array $value): static;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user