Initial Version
This commit is contained in:
197
shared/lib/Chrono/Service/IServiceBase.php
Normal file
197
shared/lib/Chrono/Service/IServiceBase.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Chrono\Service;
|
||||
|
||||
use JsonSerializable;
|
||||
use KTXF\Chrono\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 CAPABILITY_FILTER_ANY = '*';
|
||||
public const CAPABILITY_FILTER_ID = 'id';
|
||||
public const CAPABILITY_FILTER_URID = 'urid';
|
||||
public const CAPABILITY_FILTER_LABEL = 'label';
|
||||
public const CAPABILITY_FILTER_DESCRIPTION = 'description';
|
||||
|
||||
public const CAPABILITY_SORT_ID = 'id';
|
||||
public const CAPABILITY_SORT_URID = 'urid';
|
||||
public const CAPABILITY_SORT_LABEL = 'label';
|
||||
public const CAPABILITY_SORT_PRIORITY = 'priority';
|
||||
|
||||
public const CAPABILITY_RANGE_TALLY = 'tally';
|
||||
public const CAPABILITY_RANGE_TALLY_ABSOLUTE = 'absolute';
|
||||
public const CAPABILITY_RANGE_TALLY_RELATIVE = 'relative';
|
||||
public const CAPABILITY_RANGE_DATE = 'date';
|
||||
|
||||
public const JSON_TYPE = 'chrono.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 Calendar Service)
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function getLabel(): string;
|
||||
|
||||
/**
|
||||
* Gets the active status of this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function getEnabled(): bool;
|
||||
|
||||
/**
|
||||
* Retrieve collection of collections for this service
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function collectionList(?IFilter $filter = null, ?ISort $sort = null): array;
|
||||
|
||||
/**
|
||||
* Retrieve filter object for collection list
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function collectionListFilter(): IFilter;
|
||||
|
||||
/**
|
||||
* Retrieve sort object for collection list
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function collectionListSort(): ISort;
|
||||
|
||||
/**
|
||||
* Determine if a collection exists
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function collectionExtant(string|int $identifier): bool;
|
||||
|
||||
/**
|
||||
* Retrieve a specific collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function collectionFetch(string|int $identifier): ?ICollectionBase;
|
||||
|
||||
/**
|
||||
* Retrieve collection of entities from a specific collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function entityList(string|int $collection, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null, ?array $elements = null): array;
|
||||
|
||||
/**
|
||||
* Retrieve filter object for entity list
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function entityListFilter(): IFilter;
|
||||
|
||||
/**
|
||||
* Retrieve sort object for entity list
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function entityListSort(): ISort;
|
||||
|
||||
/**
|
||||
* Retrieve range object for entity list
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function entityListRange(RangeType $type): IRange;
|
||||
|
||||
/**
|
||||
* Retrieve collection of entities that have changed since a given signature
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection collection identifier
|
||||
* @param string $signature signature to compare against
|
||||
* @param string $detail level of detail to return (ids, full, etc)
|
||||
*
|
||||
* @return array collection of entities or entity identifiers
|
||||
*/
|
||||
public function entityDelta(string|int $collection, string $signature, string $detail = 'ids'): array;
|
||||
|
||||
/**
|
||||
* Determine if entities exist in a specific collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function entityExtant(string|int $collection, string|int ...$identifiers): array;
|
||||
|
||||
/**
|
||||
* Retrieve specific entities from a specific collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function entityFetch(string|int $collection, string|int ...$identifiers): array;
|
||||
|
||||
}
|
||||
79
shared/lib/Chrono/Service/IServiceCollectionMutable.php
Normal file
79
shared/lib/Chrono/Service/IServiceCollectionMutable.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Chrono\Service;
|
||||
|
||||
use KTXF\Chrono\Collection\ICollectionBase;
|
||||
use KTXF\Chrono\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 $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 $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 $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;
|
||||
|
||||
}
|
||||
81
shared/lib/Chrono/Service/IServiceEntityMutable.php
Normal file
81
shared/lib/Chrono/Service/IServiceEntityMutable.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Chrono\Service;
|
||||
|
||||
use KTXF\Chrono\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 $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 $collection The collection containing the entity to modify
|
||||
* @param string $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 $collection The collection containing the entity to destroy
|
||||
* @param string $identifier The ID of the entity to destroy
|
||||
*
|
||||
* @return IEntityMutable
|
||||
*
|
||||
* @throws \KTXF\Resource\Exceptions\InvalidArgumentException
|
||||
* @throws \KTXF\Resource\Exceptions\UnsupportedException
|
||||
* @throws \KTXF\Resource\Exceptions\UnauthorizedException
|
||||
*/
|
||||
public function entityDestroy(string|int $collection, string|int $identifier): IEntityMutable;
|
||||
|
||||
}
|
||||
30
shared/lib/Chrono/Service/IServiceMutable.php
Normal file
30
shared/lib/Chrono/Service/IServiceMutable.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Chrono\Service;
|
||||
|
||||
use KTXF\Json\JsonDeserializable;
|
||||
|
||||
interface IServiceMutable extends IServiceBase, JsonDeserializable {
|
||||
|
||||
/**
|
||||
* Sets the localized human friendly name of this service (e.g. ACME Company Calendar 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;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user