feat: implement ServiceNodeListInterface

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-09-04 20:47:12 -04:00
parent 68ed8fbabe
commit 4d589fff31
2 changed files with 75 additions and 24 deletions
+52 -1
View File
@@ -17,6 +17,7 @@ use KTXF\Documents\Entity\EntityPropertiesMutableInterface;
use KTXF\Documents\Service\ServiceBaseInterface;
use KTXF\Documents\Service\ServiceCollectionMutableInterface;
use KTXF\Documents\Service\ServiceEntityMutableInterface;
use KTXF\Documents\Service\ServiceNodeListInterface;
use KTXF\Files\Node\NodeType;
use KTXF\Resource\Delta\Delta;
use KTXF\Resource\Exceptions\InvalidParameterException;
@@ -34,7 +35,7 @@ use KTXF\Resource\Sort\Sort;
use KTXM\ProviderLocalDocuments\Store\BlobStore;
use KTXM\ProviderLocalDocuments\Store\MetaStore;
class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableInterface, ServiceEntityMutableInterface {
class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableInterface, ServiceEntityMutableInterface, ServiceNodeListInterface {
public const ROOT_ID = '00000000-0000-0000-0000-000000000000';
public const ROOT_LABEL = 'Personal Local Documents';
@@ -75,6 +76,9 @@ class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableI
self::CAPABILITY_ENTITY_LIST_SORT => [
self::CAPABILITY_ENTITY_SORT_ID,
self::CAPABILITY_ENTITY_SORT_LABEL,
ServiceNodeListInterface::CAPABILITY_NODE_SORT_SIZE,
ServiceNodeListInterface::CAPABILITY_NODE_SORT_CREATED_ON,
ServiceNodeListInterface::CAPABILITY_NODE_SORT_MODIFIED_ON,
],
self::CAPABILITY_ENTITY_LIST_RANGE => [
self::CAPABILITY_ENTITY_RANGE_TALLY => [
@@ -92,6 +96,22 @@ class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableI
self::CAPABILITY_ENTITY_COPY => true,
self::CAPABILITY_ENTITY_READ => true,
self::CAPABILITY_ENTITY_WRITE => true,
ServiceNodeListInterface::CAPABILITY_NODE_LIST => true,
ServiceNodeListInterface::CAPABILITY_NODE_LIST_FILTER => [
ServiceNodeListInterface::CAPABILITY_NODE_FILTER_LABEL => 's:100:256:256',
],
ServiceNodeListInterface::CAPABILITY_NODE_LIST_SORT => [
ServiceNodeListInterface::CAPABILITY_NODE_SORT_LABEL,
ServiceNodeListInterface::CAPABILITY_NODE_SORT_SIZE,
ServiceNodeListInterface::CAPABILITY_NODE_SORT_CREATED_ON,
ServiceNodeListInterface::CAPABILITY_NODE_SORT_MODIFIED_ON,
],
ServiceNodeListInterface::CAPABILITY_NODE_LIST_RANGE => [
ServiceNodeListInterface::CAPABILITY_NODE_RANGE_TALLY => [
ServiceNodeListInterface::CAPABILITY_NODE_RANGE_TALLY_ABSOLUTE,
ServiceNodeListInterface::CAPABILITY_NODE_RANGE_TALLY_RELATIVE,
],
],
];
public function __construct(
@@ -785,6 +805,37 @@ class PersonalService implements ServiceBaseInterface, ServiceCollectionMutableI
return $bytes;
}
// Node operations (unified collections + entities)
public function nodeList(string|int|null $location, ?IFilter $filter = null, ?ISort $sort = null, ?IRange $range = null): array {
$location = $this->normalizeLocation($location);
$entries = $this->metaStore->nodeList($this->serviceTenantId, $this->serviceUserId, $location, false, $filter, $sort, $range);
// cache nodes
foreach ($entries as $id => $node) {
if ($node instanceof CollectionResource) {
$this->serviceCollectionCache[$id] = $node;
} elseif ($node instanceof EntityResource) {
$this->serviceEntityCache[$id] = $node;
}
}
return $entries;
}
public function nodeListFilter(): IFilter {
return new Filter($this->serviceAbilities[self::CAPABILITY_NODE_LIST_FILTER] ?? []);
}
public function nodeListSort(): ISort {
return new Sort($this->serviceAbilities[self::CAPABILITY_NODE_LIST_SORT] ?? []);
}
public function nodeListRange(RangeType $type): IRange {
if ($type !== RangeType::TALLY) {
throw new InvalidParameterException("Invalid: Node range of type '{$type->value}' is not supported");
}
return new RangeTally();
}
/**
* Build metadata array for an entity to store in .meta file