resource provider and service improvements

This commit is contained in:
root
2026-01-03 13:18:04 -05:00
parent 74f9278749
commit 8f35442335
36 changed files with 1447 additions and 1086 deletions

View File

@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace KTXF\Resource\Provider;
use KTXF\Json\JsonSerializable;
/**
* Resource Provider Interface
*/
interface ResourceProviderBaseInterface extends ProviderInterface, JsonSerializable
{
public const CAPABILITY_SERVICE_LIST = 'ServiceList';
public const CAPABILITY_SERVICE_FETCH = 'ServiceFetch';
public const CAPABILITY_SERVICE_EXTANT = 'ServiceExtant';
public const JSON_TYPE = 'resource.provider';
public const JSON_PROPERTY_TYPE = '@type';
public const JSON_PROPERTY_ID = 'id';
public const JSON_PROPERTY_LABEL = 'label';
public const JSON_PROPERTY_CAPABILITIES = 'capabilities';
/**
* Confirms if specific capability is supported (e.g. 'ServiceList')
*
* @since 2025.11.01
*/
public function capable(string $value): bool;
/**
* Lists all supported capabilities
*
* @since 2025.11.01
*
* @return array<string,bool>
*/
public function capabilities(): array;
/**
* Retrieve collection of services for a specific user
*
* @since 2025.11.01
*
* @param string $tenantId tenant identifier
* @param string $userId user identifier
* @param array $filter filter criteria
*
* @return array<string,ResourceServiceBaseInterface> collection of service objects
*/
public function serviceList(string $tenantId, string $userId, array $filter): array;
/**
* Determine if any services are configured for a specific user
*
* @since 2025.11.01
*
* @param string $tenantId tenant identifier
* @param string $userId user identifier
* @param int|string ...$identifiers variadic collection of service identifiers
*
* @return array<string,bool> collection of service identifiers with boolean values indicating if the service is available
*/
public function serviceExtant(string $tenantId, string $userId, int|string ...$identifiers): array;
/**
* Retrieve a service with a specific identifier
*
* @since 2025.11.01
*
* @param string $tenantId tenant identifier
* @param string $userId user identifier
* @param string|int $identifier service identifier
*
* @return ResourceServiceBaseInterface|null returns service object or null if non found
*/
public function serviceFetch(string $tenantId, string $userId, string|int $identifier): ?ResourceServiceBaseInterface;
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
use KTXF\Json\JsonDeserializable;
interface ResourceProviderServiceMutateInterface extends ResourceProviderBaseInterface, JsonDeserializable {
public const CAPABILITY_SERVICE_FRESH = 'ServiceFresh';
public const CAPABILITY_SERVICE_CREATE = 'ServiceCreate';
public const CAPABILITY_SERVICE_UPDATE = 'ServiceUpdate';
public const CAPABILITY_SERVICE_DESTROY = 'ServiceDestroy';
/**
* construct and new blank service instance
*
* @since 2025.05.01
*/
public function serviceFresh(string $tenantId, ?string $userId): ResourceServiceMutateInterface;
/**
* create a service configuration for a specific user
*
* @since 2025.05.01
*/
public function serviceCreate(string $tenantId, ?string $userId, ResourceServiceMutateInterface $service): string;
/**
* modify a service configuration for a specific user
*
* @since 2025.05.01
*/
public function serviceModify(string $tenantId, ?string $userId, ResourceServiceMutateInterface $service): string;
/**
* delete a service configuration for a specific user
*
* @since 2025.05.01
*/
public function serviceDestroy(string $tenantId, ?string $userId, ResourceServiceMutateInterface $service): bool;
}

View File

@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace KTXF\Resource\Provider;
use KTXF\Json\JsonSerializable;
interface ResourceServiceBaseInterface extends JsonSerializable {
// JSON Constants
public const JSON_TYPE = 'resource.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_ENABLED = 'enabled';
public const JSON_PROPERTY_CAPABILITIES = 'capabilities';
/**
* Confirms if specific capability is supported
*
* @since 2025.11.01
*
* @param string $value required ability e.g. 'EntityList'
*
* @return bool
*/
public function capable(string $value): bool;
/**
* Lists all supported capabilities
*
* @since 2025.11.01
*
* @return array<string,bool>
*/
public function capabilities(): array;
/**
* Unique identifier of the provider this service belongs to
*
* @since 2025.11.01
*/
public function in(): string;
/**
* Unique arbitrary text string identifying this service (e.g. 1 or service1 or anything else)
*
* @since 2025.11.01
*/
public function id(): string|int;
/**
* Gets the localized human friendly name of this service (e.g. ACME Company File Service)
*
* @since 2025.11.01
*/
public function getLabel(): string;
/**
* Gets the active status of this service
*
* @since 2025.11.01
*/
public function getEnabled(): bool;
/**
* Gets the location information of this service
*
* @since 2025.05.01
*
* @return ResourceServiceLocationInterface
*/
public function getLocation(): ResourceServiceLocationInterface;
/**
* Gets the identity information of this service
*
* @since 2025.05.01
*
* @return ResourceServiceIdentityInterface
*/
public function getIdentity(): ResourceServiceIdentityInterface;
}

View File

@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Configurable Interface
*
* Extends base service interface with setter methods for mutable properties.
* Used for service configuration and updates.
*
* @since 2025.05.01
*/
interface ResourceServiceConfigureInterface extends ResourceServiceMutateInterface {
/**
* Sets the location/configuration of this service
*
* @since 2025.05.01
*
* @param ResourceServiceLocationInterface $value Service location/configuration
*
* @return self
*/
public function setLocation(ResourceServiceLocationInterface $value): self;
/**
* Sets the identity used for this service
*
* @since 2025.05.01
*
* @param ResourceServiceIdentityInterface $value Service identity
*
* @return self
*/
public function setIdentity(ResourceServiceIdentityInterface $value): self;
}

View File

@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Identity Basic
*
* Basic authentication (username/password) credentials for resource services.
*
* @since 2025.05.01
*/
interface ResourceServiceIdentityBasic extends ResourceServiceIdentityInterface {
/**
* Gets the identity/username
*
* @since 2025.05.01
*
* @return string
*/
public function getIdentity(): string;
/**
* Sets the identity/username
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setIdentity(string $value): void;
/**
* Gets the secret/password
*
* @since 2025.05.01
*
* @return string
*/
public function getSecret(): string;
/**
* Sets the secret/password
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setSecret(string $value): void;
}

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Identity Bearer
*
* Bearer token authentication credentials for resource services.
*
* @since 2025.05.01
*/
interface ResourceServiceIdentityBearer extends ResourceServiceIdentityInterface {
/**
* Gets the bearer token
*
* @since 2025.05.01
*
* @return string
*/
public function getToken(): string;
/**
* Sets the bearer token
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setToken(string $value): void;
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
use KTXF\Json\JsonSerializable;
/**
* Resource Service Identity Interface
*
* Base interface for authentication credentials used by resource services.
*
* @since 2025.05.01
*/
interface ResourceServiceIdentityInterface extends JsonSerializable {
public const TYPE_NONE = 'NA';
public const TYPE_BASIC = 'BA';
public const TYPE_BEARER = 'BR';
public const TYPE_OAUTH = 'OA';
/**
* Gets the identity/authentication type
*
* @since 2025.05.01
*
* @return string One of: TYPE_NONE, TYPE_BASIC, TYPE_BEARER, TYPE_OAUTH
*/
public function type(): string;
}

View File

@@ -0,0 +1,121 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Identity OAuth
*
* OAuth authentication credentials for resource services, including token management.
*
* @since 2025.05.01
*/
interface ResourceServiceIdentityOAuth extends ResourceServiceIdentityInterface {
/**
* Gets the access token
*
* @since 2025.05.01
*
* @return string
*/
public function getAccessToken(): string;
/**
* Sets the access token
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setAccessToken(string $value): void;
/**
* Gets the access token scope
*
* @since 2025.05.01
*
* @return array
*/
public function getAccessScope(): array;
/**
* Sets the access token scope
*
* @since 2025.05.01
*
* @param array $value
*
* @return void
*/
public function setAccessScope(array $value): void;
/**
* Gets the access token expiry timestamp
*
* @since 2025.05.01
*
* @return int Unix timestamp
*/
public function getAccessExpiry(): int;
/**
* Sets the access token expiry timestamp
*
* @since 2025.05.01
*
* @param int $value Unix timestamp
*
* @return void
*/
public function setAccessExpiry(int $value): void;
/**
* Gets the refresh token
*
* @since 2025.05.01
*
* @return string
*/
public function getRefreshToken(): string;
/**
* Sets the refresh token
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setRefreshToken(string $value): void;
/**
* Gets the token refresh location/endpoint
*
* @since 2025.05.01
*
* @return string
*/
public function getRefreshLocation(): string;
/**
* Sets the token refresh location/endpoint
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setRefreshLocation(string $value): void;
}

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Location File
*
* File-based service location for services using local or network file paths
* (e.g., maildir, mbox, local storage).
*
* @since 2025.05.01
*/
interface ResourceServiceLocationFile extends ResourceServiceLocationInterface {
/**
* Gets the complete file location path
*
* @since 2025.05.01
*
* @return string File path (e.g., "/var/mail/user" or "\\server\share\mail")
*/
public function location(): string;
/**
* Gets the file location path
*
* @since 2025.05.01
*
* @return string File path
*/
public function getLocation(): string;
/**
* Sets the file location path
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setLocation(string $value): void;
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
use JsonSerializable;
/**
* Resource Service Location Interface
*
* Unified interface supporting both URI-based (API services) and socket-based
* (traditional IMAP/SMTP) connection configurations.
*
* @since 2025.05.01
*/
interface ResourceServiceLocationInterface extends JsonSerializable {
public const TYPE_URI = 'URI';
public const TYPE_SOCKET_SOLE = 'SOCKET_SOLE';
public const TYPE_SOCKET_SPLIT = 'SOCKET_SPLIT';
public const TYPE_FILE = 'FILE';
/**
* Gets the service location type
*
* @since 2025.05.01
*
* @return string One of: TYPE_URI, TYPE_SOCKET_SOLE, TYPE_SOCKET_SPLIT, TYPE_FILE
*/
public function type(): string;
}

View File

@@ -0,0 +1,131 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Location Socket Sole
*
* Single socket-based service location for services using a single host/port combination
* (e.g., JMAP, unified mail servers).
*
* @since 2025.05.01
*/
interface ResourceServiceLocationSocketSole extends ResourceServiceLocationInterface {
/**
* Gets the complete location string
*
* @since 2025.05.01
*
* @return string Location (e.g., "mail.example.com:993")
*/
public function location(): string;
/**
* Gets the host
*
* @since 2025.05.01
*
* @return string Host (e.g., "mail.example.com")
*/
public function getHost(): string;
/**
* Sets the host
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setHost(string $value): void;
/**
* Gets the port
*
* @since 2025.05.01
*
* @return int Port number
*/
public function getPort(): int;
/**
* Sets the port
*
* @since 2025.05.01
*
* @param int $value
*
* @return void
*/
public function setPort(int $value): void;
/**
* Gets the encryption/security mode
*
* @since 2025.12.01
*
* @return string One of: 'none', 'ssl', 'tls', 'starttls'
*/
public function getEncryption(): string;
/**
* Sets the encryption/security mode
*
* @since 2025.12.01
*
* @param string $value One of: 'none', 'ssl', 'tls', 'starttls'
*
* @return void
*/
public function setEncryption(string $value): void;
/**
* Gets whether to verify SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @return bool
*/
public function getVerifyPeer(): bool;
/**
* Sets whether to verify SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setVerifyPeer(bool $value): void;
/**
* Gets whether to verify SSL/TLS certificate host
*
* @since 2025.12.01
*
* @return bool
*/
public function getVerifyHost(): bool;
/**
* Sets whether to verify SSL/TLS certificate host
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setVerifyHost(bool $value): void;
}

View File

@@ -0,0 +1,240 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Location Socket Split
*
* Split socket-based service location for services using separate inbound/outbound servers
* (e.g., traditional IMAP/SMTP configurations).
*
* @since 2025.05.01
*/
interface ResourceServiceLocationSocketSplit extends ResourceServiceLocationInterface {
/**
* Gets the complete inbound location string
*
* @since 2025.05.01
*
* @return string Inbound location (e.g., "imap.example.com:993")
*/
public function locationInbound(): string;
/**
* Gets the complete outbound location string
*
* @since 2025.05.01
*
* @return string Outbound location (e.g., "smtp.example.com:465")
*/
public function locationOutbound(): string;
/**
* Gets the inbound host
*
* @since 2025.05.01
*
* @return string Inbound host (e.g., "imap.example.com")
*/
public function getInboundHost(): string;
/**
* Sets the inbound host
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setInboundHost(string $value): void;
/**
* Gets the outbound host
*
* @since 2025.05.01
*
* @return string Outbound host (e.g., "smtp.example.com")
*/
public function getOutboundHost(): string;
/**
* Sets the outbound host
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setOutboundHost(string $value): void;
/**
* Gets the inbound port
*
* @since 2025.05.01
*
* @return int Inbound port number
*/
public function getInboundPort(): int;
/**
* Sets the inbound port
*
* @since 2025.05.01
*
* @param int $value
*
* @return void
*/
public function setInboundPort(int $value): void;
/**
* Gets the outbound port
*
* @since 2025.05.01
*
* @return int Outbound port number
*/
public function getOutboundPort(): int;
/**
* Sets the outbound port
*
* @since 2025.05.01
*
* @param int $value
*
* @return void
*/
public function setOutboundPort(int $value): void;
/**
* Gets the inbound encryption/security mode
*
* @since 2025.12.01
*
* @return string One of: 'none', 'ssl', 'tls', 'starttls'
*/
public function getInboundEncryption(): string;
/**
* Sets the inbound encryption/security mode
*
* @since 2025.12.01
*
* @param string $value One of: 'none', 'ssl', 'tls', 'starttls'
*
* @return void
*/
public function setInboundEncryption(string $value): void;
/**
* Gets the outbound encryption/security mode
*
* @since 2025.12.01
*
* @return string One of: 'none', 'ssl', 'tls', 'starttls'
*/
public function getOutboundEncryption(): string;
/**
* Sets the outbound encryption/security mode
*
* @since 2025.12.01
*
* @param string $value One of: 'none', 'ssl', 'tls', 'starttls'
*
* @return void
*/
public function setOutboundEncryption(string $value): void;
/**
* Gets whether to verify inbound SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @return bool
*/
public function getInboundVerifyPeer(): bool;
/**
* Sets whether to verify inbound SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setInboundVerifyPeer(bool $value): void;
/**
* Gets whether to verify inbound SSL/TLS certificate host
*
* @since 2025.12.01
*
* @return bool
*/
public function getInboundVerifyHost(): bool;
/**
* Sets whether to verify inbound SSL/TLS certificate host
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setInboundVerifyHost(bool $value): void;
/**
* Gets whether to verify outbound SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @return bool
*/
public function getOutboundVerifyPeer(): bool;
/**
* Sets whether to verify outbound SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setOutboundVerifyPeer(bool $value): void;
/**
* Gets whether to verify outbound SSL/TLS certificate host
*
* @since 2025.12.01
*
* @return bool
*/
public function getOutboundVerifyHost(): bool;
/**
* Sets whether to verify outbound SSL/TLS certificate host
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setOutboundVerifyHost(bool $value): void;
}

View File

@@ -0,0 +1,150 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource\Provider;
/**
* Resource Service Location Uri
*
* URI-based service location for API and web services (e.g., https://api.example.com:443/v1/endpoint).
*
* @since 2025.05.01
*/
interface ResourceServiceLocationUri extends ResourceServiceLocationInterface {
/**
* Gets the complete location URI
*
* @since 2025.05.01
*
* @return string Complete URI (e.g., "https://api.example.com:443/v1")
*/
public function location(): string;
/**
* Gets the URI scheme
*
* @since 2025.05.01
*
* @return string Scheme (e.g., "https", "http")
*/
public function getScheme(): string;
/**
* Sets the URI scheme
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setScheme(string $value): void;
/**
* Gets the host
*
* @since 2025.05.01
*
* @return string Host (e.g., "api.example.com")
*/
public function getHost(): string;
/**
* Sets the host
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setHost(string $value): void;
/**
* Gets the port
*
* @since 2025.05.01
*
* @return int Port number
*/
public function getPort(): int;
/**
* Sets the port
*
* @since 2025.05.01
*
* @param int $value
*
* @return void
*/
public function setPort(int $value): void;
/**
* Gets the path
*
* @since 2025.05.01
*
* @return string Path (e.g., "/v1/api")
*/
public function getPath(): string;
/**
* Sets the path
*
* @since 2025.05.01
*
* @param string $value
*
* @return void
*/
public function setPath(string $value): void;
/**
* Gets whether to verify SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @return bool
*/
public function getVerifyPeer(): bool;
/**
* Sets whether to verify SSL/TLS peer certificate
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setVerifyPeer(bool $value): void;
/**
* Gets whether to verify SSL/TLS certificate host
*
* @since 2025.12.01
*
* @return bool
*/
public function getVerifyHost(): bool;
/**
* Sets whether to verify SSL/TLS certificate host
*
* @since 2025.12.01
*
* @param bool $value
*
* @return void
*/
public function setVerifyHost(bool $value): void;
}

View 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\Resource\Provider;
use KTXF\Json\JsonDeserializable;
/**
* Resource Service Configurable Interface
*
* Extends base service interface with setter methods for mutable properties.
* Used for service configuration and updates.
*
* @since 2025.05.01
*/
interface ResourceServiceMutateInterface extends ResourceServiceBaseInterface, JsonDeserializable {
/**
* Sets the localized human-friendly name of this service (e.g. ACME Company Mail Service)
*
* @since 2025.05.01
*
* @param string $value Service label
*
* @return self
*/
public function setLabel(string $value): self;
/**
* Sets the active status of this service
*
* @since 2025.05.01
*
* @param bool $value True to enable, false to disable
*
* @return self
*/
public function setEnabled(bool $value): self;
}