Initial Version
This commit is contained in:
105
shared/lib/Files/Node/INodeBase.php
Normal file
105
shared/lib/Files/Node/INodeBase.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Files\Node;
|
||||
|
||||
use DateTimeImmutable;
|
||||
|
||||
interface INodeBase extends \JsonSerializable {
|
||||
|
||||
public const JSON_TYPE = 'files.node';
|
||||
public const JSON_PROPERTY_TYPE = '@type';
|
||||
public const JSON_PROPERTY_IN = 'in';
|
||||
public const JSON_PROPERTY_ID = 'id';
|
||||
public const JSON_PROPERTY_CREATED_ON = 'createdOn';
|
||||
public const JSON_PROPERTY_CREATED_BY = 'createdBy';
|
||||
public const JSON_PROPERTY_MODIFIED_ON = 'modifiedOn';
|
||||
public const JSON_PROPERTY_MODIFIED_BY = 'modifiedBy';
|
||||
public const JSON_PROPERTY_OWNER = 'owner';
|
||||
public const JSON_PROPERTY_SIGNATURE = 'signature';
|
||||
public const JSON_PROPERTY_LABEL = 'label';
|
||||
|
||||
/**
|
||||
* Unique identifier of the parent node (folder) this node belongs to
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function in(): string|int|null;
|
||||
|
||||
/**
|
||||
* Unique identifier of this node
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function id(): string|int;
|
||||
|
||||
/**
|
||||
* Node type (collection or entity)
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function type(): NodeType;
|
||||
|
||||
/**
|
||||
* Creator user ID
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function createdBy(): string|null;
|
||||
|
||||
/**
|
||||
* Creation timestamp
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function createdOn(): DateTimeImmutable|null;
|
||||
|
||||
/**
|
||||
* Last modifier user ID
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function modifiedBy(): string|null;
|
||||
|
||||
/**
|
||||
* Last modification timestamp
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function modifiedOn(): DateTimeImmutable|null;
|
||||
|
||||
/**
|
||||
* Signature/etag for sync and caching
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function signature(): string|null;
|
||||
|
||||
/**
|
||||
* Check if this node is a collection (folder)
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function isCollection(): bool;
|
||||
|
||||
/**
|
||||
* Check if this node is an entity (file)
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function isEntity(): bool;
|
||||
|
||||
/**
|
||||
* Human-readable name/label of this node
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function getLabel(): string|null;
|
||||
|
||||
}
|
||||
22
shared/lib/Files/Node/INodeCollectionBase.php
Normal file
22
shared/lib/Files/Node/INodeCollectionBase.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Files\Node;
|
||||
|
||||
/**
|
||||
* Interface for collection (folder) nodes
|
||||
*
|
||||
* Collections are containers that can hold other nodes (both collections and entities).
|
||||
* They inherit common properties from INodeBase and add collection-specific properties.
|
||||
*/
|
||||
interface INodeCollectionBase extends INodeBase {
|
||||
|
||||
public const JSON_TYPE = 'files.collection';
|
||||
|
||||
}
|
||||
35
shared/lib/Files/Node/INodeCollectionMutable.php
Normal file
35
shared/lib/Files/Node/INodeCollectionMutable.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Files\Node;
|
||||
|
||||
/**
|
||||
* Interface for mutable collection (folder) nodes
|
||||
*/
|
||||
interface INodeCollectionMutable extends INodeCollectionBase {
|
||||
|
||||
/**
|
||||
* Deserialize from JSON data
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*
|
||||
* @param array|string $data JSON data to deserialize
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function jsonDeserialize(array|string $data): static;
|
||||
|
||||
/**
|
||||
* Sets the human-readable name/label of this collection
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function setLabel(string $value): static;
|
||||
|
||||
}
|
||||
54
shared/lib/Files/Node/INodeEntityBase.php
Normal file
54
shared/lib/Files/Node/INodeEntityBase.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Files\Node;
|
||||
|
||||
/**
|
||||
* Interface for entity (file) nodes
|
||||
*
|
||||
* Entities are leaf nodes that contain actual file data.
|
||||
* They inherit common properties from INodeBase and add file-specific properties.
|
||||
*/
|
||||
interface INodeEntityBase extends INodeBase {
|
||||
|
||||
public const JSON_TYPE = 'files.entity';
|
||||
public const JSON_PROPERTY_SIZE = 'size';
|
||||
public const JSON_PROPERTY_MIME = 'mime';
|
||||
public const JSON_PROPERTY_FORMAT = 'format';
|
||||
public const JSON_PROPERTY_ENCODING = 'encoding';
|
||||
|
||||
/**
|
||||
* File size in bytes
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function size(): int;
|
||||
|
||||
/**
|
||||
* MIME type of the file (e.g., 'application/pdf', 'image/png')
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function getMime(): string|null;
|
||||
|
||||
/**
|
||||
* File format/extension (e.g., 'pdf', 'png', 'txt')
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function getFormat(): string|null;
|
||||
|
||||
/**
|
||||
* Character encoding (e.g., 'utf-8')
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function getEncoding(): string|null;
|
||||
|
||||
}
|
||||
56
shared/lib/Files/Node/INodeEntityMutable.php
Normal file
56
shared/lib/Files/Node/INodeEntityMutable.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Files\Node;
|
||||
|
||||
/**
|
||||
* Interface for mutable entity (file) nodes
|
||||
*/
|
||||
interface INodeEntityMutable extends INodeEntityBase {
|
||||
|
||||
/**
|
||||
* Deserialize from JSON data
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*
|
||||
* @param array|string $data JSON data to deserialize
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function jsonDeserialize(array|string $data): static;
|
||||
|
||||
/**
|
||||
* Sets the human-readable name/label of this entity
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function setLabel(string $value): static;
|
||||
|
||||
/**
|
||||
* Sets the MIME type of the file
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function setMime(string $value): static;
|
||||
|
||||
/**
|
||||
* Sets the file format/extension
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function setFormat(string $value): static;
|
||||
|
||||
/**
|
||||
* Sets the character encoding
|
||||
*
|
||||
* @since 2025.11.01
|
||||
*/
|
||||
public function setEncoding(string $value): static;
|
||||
|
||||
}
|
||||
23
shared/lib/Files/Node/NodeType.php
Normal file
23
shared/lib/Files/Node/NodeType.php
Normal 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\Files\Node;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
enum NodeType: string implements JsonSerializable {
|
||||
|
||||
case Collection = 'C';
|
||||
case Entity = 'E';
|
||||
|
||||
public function jsonSerialize(): string {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user