refactor: people provider
All checks were successful
JS Unit Tests / test (pull_request) Successful in 16s
Build Test / build (pull_request) Successful in 18s
PHP Unit Tests / test (pull_request) Successful in 56s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-25 00:13:51 -05:00
parent 7799787ffb
commit e48ee82530
41 changed files with 1091 additions and 984 deletions

View File

@@ -1,221 +0,0 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use JsonSerializable;
use KTXF\People\Collection\ICollectionBase;
use KTXF\Resource\Filter\IFilter;
use KTXF\Resource\Range\IRange;
use KTXF\Resource\Range\RangeType;
use KTXF\Resource\Sort\ISort;
interface IServiceBase extends JsonSerializable {
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';
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';
public const JSON_TYPE = 'people.service';
public const JSON_PROPERTY_TYPE = '@type';
public const JSON_PROPERTY_PROVIDER = 'provider';
public const JSON_PROPERTY_ID = 'id';
public const JSON_PROPERTY_LABEL = 'label';
public const JSON_PROPERTY_CAPABILITIES = 'capabilities';
public const JSON_PROPERTY_ENABLED = 'enabled';
/**
* Confirms if specific capability is supported
*
* @since 2025.05.01
*
* @param string $value required ability e.g. 'EntityList'
*
* @return bool
*/
public function capable(string $value): bool;
/**
* Lists all supported capabilities
*
* @since 2025.05.01
*
* @return array<string,bool>
*/
public function capabilities(): array;
/**
* Unique identifier of the provider this service belongs to
*
* @since 2025.05.01
*/
public function in(): string;
/**
* Unique arbitrary text string identifying this service (e.g. 1 or service1 or anything else)
*
* @since 2025.05.01
*/
public function id(): string|int;
/**
* Gets the localized human friendly name of this service (e.g. ACME Company Mail Service)
*
* @since 2025.05.01
*/
public function getLabel(): string;
/**
* Gets the active status of this service
*
* @since 2025.05.01
*/
public function getEnabled(): bool;
/**
* List of accessible collection
*
* @since 2025.05.01
*
* @return array<string|int,ICollectionBase>
*/
public function collectionList(?IFilter $filter = null, ?ISort $sort = null): array;
/**
* Fresh filter for collection list
*
* @since 2025.05.01
*
* @return IFilter
*/
public function collectionListFilter(): IFilter;
/**
* Fresh sort for collection list
*
* @since 2025.05.01
*
* @return ISort
*/
public function collectionListSort(): ISort;
/**
* Fetches details about a specific collection
*
* @since 2025.05.01
*
* @param string|int $id collection identifier
*/
public function collectionExtant(string|int $identifier): bool;
/**
* Fetches details about a specific collection
*
* @since 2025.05.01
*
* @param string|int $identifier collection identifier
*/
public function collectionFetch(string|int $identifier): ?ICollectionBase;
/**
* Lists all entities in a specific collection
*
* @since 2025.05.01
*
* @param string|int $collection collection identifier
*
* @return array<string|int,IEntityBase>
*/
public function entityList(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $elements = null): array;
/**
* Fresh filter for entity list
*
* @since 2025.05.01
*
* @return Filter
*/
public function entityListFilter(): IFilter;
/**
* Fresh sort for entity list
*
* @since 2025.05.01
*
* @return ISort
*/
public function entityListSort(): ISort;
/**
* Fresh range for entity list
*
* @since 2025.05.01
*
* @param RangeType $type range type
*
* @return IRange
*/
public function entityListRange(RangeType $type): IRange;
/**
* Lists of all changes from a specific token
*
* @since 2025.05.01
*
* @param string|int $collection collection identifier
* @param string $signature token signature
* @param string $detail detail level ids | meta | full
*
* @return array
*
* [
* 'added' => array<string|int>,
* 'updated' => array<string|int>,
* 'deleted' => array<string|int>,
* 'signature' => string
* ]
*
*/
public function entityDelta(string|int $collection, string $signature, string $detail = 'ids'): array;
/**
* Confirms if specific entity exists in a collection
*
* @since 2025.05.01
*
* @param string|int $collection collection identifier
* @param string|int ...$identifiers list of entity identifiers
*
* @return array<string|int,bool>
*/
public function entityExtant(string|int $collection, string|int ...$identifiers): array;
/**
* Fetches details about a specific entities in a collection
*
* @since 2025.05.01
*
* @param string|int $collection collection identifier
* @param string|int ...$identifiers entity identifier
*
* @return array<string|int,IEntityBase>
*/
public function entityFetch(string|int $collection, string|int ...$identifiers): array;
}

View File

@@ -1,79 +0,0 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use KTXF\People\Collection\ICollectionBase;
use KTXF\People\Collection\ICollectionMutable;
interface IServiceCollectionMutable extends IServiceBase {
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 new, empty collection object
*
* @since 2025.05.01
*
* @return ICollectionMutable
*/
public function collectionFresh(): ICollectionMutable;
/**
* Creates a new collection at the specified location
*
* @since 2025.05.01
*
* @param string|int $location The parent collection to create this collection in, or empty string for root
* @param ICollectionMutable $collection The collection to create
* @param array $options Additional options for the collection creation
*
* @return ICollectionBase
*
* @throws \KTXF\Resource\Exceptions\InvalidArgumentException
* @throws \KTXF\Resource\Exceptions\UnsupportedException
* @throws \KTXF\Resource\Exceptions\UnauthorizedException
*/
public function collectionCreate(string|int $location, ICollectionMutable $collection, array $options): ICollectionBase;
/**
* Modifies an existing collection
*
* @since 2025.05.01
*
* @param string|int $identifier The ID of the collection to modify
* @param ICollectionMutable $collection The collection with modifications
*
* @return ICollectionBase
*
* @throws \KTXF\Resource\Exceptions\InvalidArgumentException
* @throws \KTXF\Resource\Exceptions\UnsupportedException
* @throws \KTXF\Resource\Exceptions\UnauthorizedException
*/
public function collectionModify(string|int $identifier, ICollectionMutable $collection): ICollectionBase;
/**
* Destroys an existing collection
*
* @since 2025.05.01
*
* @param string|int $identifier The ID of the collection to destroy
*
* @return bool
*
* @throws \KTXF\Resource\Exceptions\InvalidArgumentException
* @throws \KTXF\Resource\Exceptions\UnsupportedException
* @throws \KTXF\Resource\Exceptions\UnauthorizedException
*/
public function collectionDestroy(string|int $identifier): bool;
}

View File

@@ -1,82 +0,0 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use KTXF\People\Entity\IEntityBase;
use KTXF\People\Entity\IEntityMutable;
interface IServiceEntityMutable extends IServiceBase {
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 of the specified type
*
* @since 2025.05.01
*
* @return IEntityMutable
*/
public function entityFresh(): IEntityMutable;
/**
* Creates a new entity in the specified collection
*
* @since 2025.05.01
*
* @param string|int $collection The collection to create this entity in
* @param IEntityMutable $entity The entity to create
* @param array $options Additional options for the entity creation
*
* @return IEntityMutable
*
* @throws \KTXF\Resource\Exceptions\InvalidArgumentException
* @throws \KTXF\Resource\Exceptions\UnsupportedException
* @throws \KTXF\Resource\Exceptions\UnauthorizedException
*/
public function entityCreate(string|int $collection, IEntityMutable $entity, array $options): IEntityMutable;
/**
* Modifies an existing entity in the specified collection
*
* @since 2025.05.01
*
* @param string|int $collection The collection containing the entity to modify
* @param string|int $identifier The ID of the entity to modify
* @param IEntityMutable $entity The entity with modifications
*
* @return IEntityMutable
*
* @throws \KTXF\Resource\Exceptions\InvalidArgumentException
* @throws \KTXF\Resource\Exceptions\UnsupportedException
* @throws \KTXF\Resource\Exceptions\UnauthorizedException
*/
public function entityModify(string|int $collection, string|int $identifier, IEntityMutable $entity): IEntityMutable;
/**
* Destroys an existing entity in the specified collection
*
* @since 2025.05.01
*
* @param string|int $collection The collection containing the entity to destroy
* @param string|int $identifier The ID of the entity to destroy
*
* @return bool
*
* @throws \KTXF\Resource\Exceptions\InvalidArgumentException
* @throws \KTXF\Resource\Exceptions\UnsupportedException
* @throws \KTXF\Resource\Exceptions\UnauthorizedException
*/
public function entityDestroy(string|int $collection, string|int $identifier): IEntityBase;
}

View File

@@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use KTXF\Json\JsonDeserializable;
interface IServiceMutable extends IServiceBase, JsonDeserializable {
/**
* Sets the localized human friendly name of this service (e.g. ACME Company Mail Service)
*
* @since 2025.05.01
*/
public function setLabel(string $value): self;
/**
* Sets the active status of this service
*
* @since 2025.05.01
*/
public function setEnabled(bool $value): self;
}

View File

@@ -0,0 +1,199 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use KTXF\People\Collection\CollectionBaseInterface;
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;
/**
* Service Base Interface
*
* Minimum interface for a service, providing read-only access to collections and entities.
*
* @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_CONTENTS = 'contents';
// 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_ID = 'id';
public const CAPABILITY_ENTITY_FILTER_URID = 'urid';
public const CAPABILITY_ENTITY_FILTER_LABEL = 'label';
// Sort capabilities
public const CAPABILITY_ENTITY_SORT_ID = 'id';
public const CAPABILITY_ENTITY_SORT_URID = 'urid';
public const CAPABILITY_ENTITY_SORT_LABEL = 'label';
public const CAPABILITY_ENTITY_SORT_PRIORITY = 'priority';
// Range capabilities
public const CAPABILITY_ENTITY_RANGE_TALLY = 'tally';
public const CAPABILITY_ENTITY_RANGE_TALLY_ABSOLUTE = 'absolute';
public const CAPABILITY_ENTITY_RANGE_TALLY_RELATIVE = 'relative';
public const JSON_TYPE = 'people:service';
/**
* 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;
}

View File

@@ -0,0 +1,75 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use KTXF\People\Collection\CollectionBaseInterface;
use KTXF\People\Collection\CollectionMutableInterface;
/**
* Service Collection Mutable Interface
*
* Optional interface for services that support collection CRUD operations.
*
* @since 2025.05.01
*/
interface ServiceCollectionMutableInterface {
public const CAPABILITY_COLLECTION_CREATE = 'CollectionCreate';
public const CAPABILITY_COLLECTION_UPDATE = 'CollectionUpdate';
public const CAPABILITY_COLLECTION_DELETE = 'CollectionDelete';
/**
* 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;
/**
* Updates an existing collection
*
* @since 2025.05.01
*
* @param string|int $identifier Collection ID
* @param CollectionMutableInterface $collection Updated collection data
*
* @return CollectionBaseInterface Updated collection
*/
public function collectionUpdate(string|int $identifier, CollectionMutableInterface $collection): CollectionBaseInterface;
/**
* Deletes a collection
*
* @since 2025.05.01
*
* @param string|int $identifier Collection ID
* @param bool $force Force deletion even if not empty
* @param bool $recursive Recursively delete contents
*
* @return bool True if deleted
*/
public function collectionDelete(string|int $identifier, bool $force = false, bool $recursive = false): bool;
}

View File

@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use KTXF\Resource\Provider\ResourceServiceConfigureInterface;
/**
* Service Configurable Interface
*
* Optional interface for services that require configuration
*
* @since 2025.05.01
*/
interface ServiceConfigurableInterface extends ResourceServiceConfigureInterface {
}

View File

@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
use KTXF\People\Entity\EntityBaseInterface;
use KTXF\People\Entity\EntityMutableInterface;
/**
* Service Entity Mutable Interface
*
* Optional interface for services that support entity CRUD operations.
*
* @since 2025.05.01
*/
interface ServiceEntityMutableInterface {
public const CAPABILITY_ENTITY_CREATE = 'EntityCreate';
public const CAPABILITY_ENTITY_UPDATE = 'EntityUpdate';
public const CAPABILITY_ENTITY_DELETE = 'EntityDelete';
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 entityUpdate(string|int $collection, string|int $identifier, EntityMutableInterface $entity): EntityBaseInterface;
/**
* Deletes an existing entity in the specified collection
*
* @since 2025.05.01
*
* @param string|int $collection Collection identifier
* @param string|int $identifier Entity identifier to delete
*
* @return EntityBaseInterface Deleted entity
*/
public function entityDelete(string|int $collection, string|int $identifier): EntityBaseInterface;
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\People\Service;
/**
* Service Mutable Interface
*
* Marker interface for services that support mutable operations
*
* @since 2025.05.01
*/
interface ServiceMutableInterface {
}