This commit is contained in:
2024-03-23 12:12:13 +02:00
parent 8526fd471f
commit b8efa5f586
41 changed files with 343 additions and 71 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
namespace Lucent\Account; namespace Lucent\Account;
use Lucent\Channel\ChannelService; use Lucent\Channel\ChannelService;
use Lucent\Primitive\Collection; use Lucent\Support\Collection;
readonly class AccountService readonly class AccountService
{ {
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Lucent\Account;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Lucent\Primitive\Collection; use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
class UserRepo class UserRepo
+2 -2
View File
@@ -2,8 +2,8 @@
namespace Lucent\Channel; namespace Lucent\Channel;
use Lucent\Primitive\Collection; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Schema; use Lucent\Support\Collection;
final class Channel final class Channel
{ {
+2 -2
View File
@@ -3,9 +3,9 @@
namespace Lucent\Channel; namespace Lucent\Channel;
use Lucent\Primitive\Collection; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Schema;
use Lucent\Schema\SchemaService; use Lucent\Schema\SchemaService;
use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
final class ChannelService final class ChannelService
+2 -2
View File
@@ -7,8 +7,8 @@ use Exception;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Intervention\Image\ImageManager; use Intervention\Image\ImageManager;
use Lucent\Channel\ChannelService; use Lucent\Channel\ChannelService;
use Lucent\Schema\Schema; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Type; use Lucent\Schema\Schema\Type;
class RebuildThumbnails extends Command class RebuildThumbnails extends Command
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
<?php <?php
namespace Lucent\Id; namespace Lucent\CommonData;
use Illuminate\Support\Str; use Illuminate\Support\Str;
+2 -2
View File
@@ -7,8 +7,8 @@ use Lucent\Channel\ChannelService;
use Lucent\LucentException; use Lucent\LucentException;
use Lucent\Record\File; use Lucent\Record\File;
use Lucent\Record\QueryRecord; use Lucent\Record\QueryRecord;
use Lucent\Schema\Schema; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Type; use Lucent\Schema\Schema\Type;
class FileService class FileService
{ {
+1 -1
View File
@@ -11,7 +11,7 @@ use Illuminate\Support\Str;
use Intervention\Image\ImageManagerStatic; use Intervention\Image\ImageManagerStatic;
use Lucent\LucentException; use Lucent\LucentException;
use Lucent\Record\File as RecordFile; use Lucent\Record\File as RecordFile;
use Lucent\Schema\Schema; use Lucent\Schema\Schema\Schema;
use Spatie\ImageOptimizer\OptimizerChainFactory; use Spatie\ImageOptimizer\OptimizerChainFactory;
/** /**
+1 -1
View File
@@ -13,7 +13,7 @@ use Lucent\Query\Query;
use Lucent\Record\Manager; use Lucent\Record\Manager;
use Lucent\Record\QueryRecord; use Lucent\Record\QueryRecord;
use Lucent\Record\RecordService; use Lucent\Record\RecordService;
use Lucent\Schema\System; use Lucent\Schema\Schema\System;
use Lucent\Schema\Validator\ValidatorException; use Lucent\Schema\Validator\ValidatorException;
use Lucent\Svelte\Svelte; use Lucent\Svelte\Svelte;
use function Lucent\Response\fail; use function Lucent\Response\fail;
@@ -7,10 +7,10 @@ use Lucent\Channel\ChannelService;
use Lucent\JsonSchema\Definition; use Lucent\JsonSchema\Definition;
use Lucent\JsonSchema\JsonSchemaService; use Lucent\JsonSchema\JsonSchemaService;
use Lucent\JsonSchema\SchemaData; use Lucent\JsonSchema\SchemaData;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Schema\Schema; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Type; use Lucent\Schema\Schema\Type;
use Lucent\Support\Collection;
class GenerateJsonSchema extends Command class GenerateJsonSchema extends Command
{ {
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Lucent\JsonSchema;
use Lucent\JsonSchema\Property\Property; use Lucent\JsonSchema\Property\Property;
use Lucent\JsonSchema\Property\RefProperty; use Lucent\JsonSchema\Property\RefProperty;
use Lucent\Primitive\Collection; use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
class Definition class Definition
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Lucent\JsonSchema\Property; namespace Lucent\JsonSchema\Property;
use Lucent\Primitive\Collection; use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
class RefProperty implements Property class RefProperty implements Property
+1 -1
View File
@@ -3,7 +3,7 @@
namespace Lucent\JsonSchema; namespace Lucent\JsonSchema;
use Lucent\JsonSchema\Property\Property; use Lucent\JsonSchema\Property\Property;
use Lucent\Primitive\Collection; use Lucent\Support\Collection;
class SchemaData class SchemaData
{ {
+1 -1
View File
@@ -3,8 +3,8 @@
namespace Lucent\Query; namespace Lucent\Query;
use Lucent\Edge\Edge; use Lucent\Edge\Edge;
use Lucent\Primitive\Collection;
use Lucent\Record\QueryRecord; use Lucent\Record\QueryRecord;
use Lucent\Support\Collection;
final class Graph final class Graph
{ {
+1 -1
View File
@@ -5,13 +5,13 @@ namespace Lucent\Query;
use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Lucent\Edge\Edge; use Lucent\Edge\Edge;
use Lucent\Primitive\Collection;
use Lucent\Query\DatabaseGraph\DatabaseGraph; use Lucent\Query\DatabaseGraph\DatabaseGraph;
use Lucent\Query\Filter\AndFilter; use Lucent\Query\Filter\AndFilter;
use Lucent\Query\Filter\OrFilter; use Lucent\Query\Filter\OrFilter;
use Lucent\Record\InputFormatter; use Lucent\Record\InputFormatter;
use Lucent\Record\QueryRecord; use Lucent\Record\QueryRecord;
use Lucent\Record\Record; use Lucent\Record\Record;
use Lucent\Support\Collection;
final class Query final class Query
{ {
+2 -2
View File
@@ -5,16 +5,16 @@ namespace Lucent\Record;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Lucent\Account\AuthService; use Lucent\Account\AuthService;
use Lucent\Channel\ChannelService; use Lucent\Channel\ChannelService;
use Lucent\CommonData\Id;
use Lucent\Edge\Edge; use Lucent\Edge\Edge;
use Lucent\Edge\EdgeCollection; use Lucent\Edge\EdgeCollection;
use Lucent\Edge\EdgeService; use Lucent\Edge\EdgeService;
use Lucent\File\FileService; use Lucent\File\FileService;
use Lucent\Id\Id;
use Lucent\LucentException; use Lucent\LucentException;
use Lucent\Query\Query; use Lucent\Query\Query;
use Lucent\Revision\RevisionService; use Lucent\Revision\RevisionService;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Schema\Schema; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Validator\Validator; use Lucent\Schema\Validator\Validator;
use Lucent\Schema\Validator\ValidatorException; use Lucent\Schema\Validator\ValidatorException;
-1
View File
@@ -3,7 +3,6 @@
namespace Lucent\Record; namespace Lucent\Record;
use Carbon\Carbon; use Carbon\Carbon;
use Lucent\Schema\Schema;
readonly class System readonly class System
{ {
-3
View File
@@ -3,14 +3,11 @@
namespace Lucent\Revision; namespace Lucent\Revision;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Lucent\Edge\Edge;
use Lucent\Edge\EdgeCollection; use Lucent\Edge\EdgeCollection;
use Lucent\Primitive\Collection;
use Lucent\Record\File; use Lucent\Record\File;
use Lucent\Record\Record; use Lucent\Record\Record;
use Lucent\Record\RecordData; use Lucent\Record\RecordData;
use Lucent\Record\System; use Lucent\Record\System;
use stdClass;
readonly class Revision readonly class Revision
{ {
+1 -1
View File
@@ -5,10 +5,10 @@ namespace Lucent\Revision;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Lucent\Edge\Edge; use Lucent\Edge\Edge;
use Lucent\Edge\EdgeCollection; use Lucent\Edge\EdgeCollection;
use Lucent\Primitive\Collection;
use Lucent\Record\File; use Lucent\Record\File;
use Lucent\Record\RecordData; use Lucent\Record\RecordData;
use Lucent\Record\System; use Lucent\Record\System;
use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
use stdClass; use stdClass;
+1 -2
View File
@@ -3,10 +3,9 @@
namespace Lucent\Revision; namespace Lucent\Revision;
use Lucent\Channel\ChannelService; use Lucent\Channel\ChannelService;
use Lucent\Edge\Edge;
use Lucent\Edge\EdgeCollection; use Lucent\Edge\EdgeCollection;
use Lucent\Primitive\Collection;
use Lucent\Record\Record; use Lucent\Record\Record;
use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
readonly class RevisionService readonly class RevisionService
+1 -2
View File
@@ -4,12 +4,11 @@ namespace Lucent\Schema\BlockUi;
use Lucent\JsonSchema\Property\Property; use Lucent\JsonSchema\Property\Property;
use Lucent\JsonSchema\Property\RefProperty; use Lucent\JsonSchema\Property\RefProperty;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldDataInterface;
use Lucent\Schema\Field\FieldInfo; use Lucent\Schema\Field\FieldInfo;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Schema\Field\FieldType; use Lucent\Schema\Field\FieldType;
use Lucent\Schema\Validator\MinMaxInterface; use Lucent\Schema\Validator\MinMaxInterface;
use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
class File implements FieldInterface, MinMaxInterface class File implements FieldInterface, MinMaxInterface
+2 -2
View File
@@ -4,9 +4,9 @@ namespace Lucent\Schema\Commands;
use DirectoryIterator; use DirectoryIterator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Lucent\Schema\Schema; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Schema\Type;
use Lucent\Schema\SchemaService; use Lucent\Schema\SchemaService;
use Lucent\Schema\Type;
class CompileSchemas extends Command class CompileSchemas extends Command
{ {
-9
View File
@@ -1,9 +0,0 @@
<?php
namespace Lucent\Schema;
interface Schema
{
}
@@ -1,9 +1,9 @@
<?php <?php
namespace Lucent\Schema; namespace Lucent\Schema\Schema;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Support\Collection;
class BlockSchema implements Schema class BlockSchema implements Schema
{ {
@@ -1,9 +1,9 @@
<?php <?php
namespace Lucent\Schema; namespace Lucent\Schema\Schema;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Support\Collection;
class CollectionSchema implements Schema class CollectionSchema implements Schema
{ {
@@ -1,9 +1,9 @@
<?php <?php
namespace Lucent\Schema; namespace Lucent\Schema\Schema;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldDataInterface; use Lucent\Schema\Field\FieldDataInterface;
use Lucent\Support\Collection;
class EdgeSchema implements Schema class EdgeSchema implements Schema
{ {
@@ -1,9 +1,9 @@
<?php <?php
namespace Lucent\Schema; namespace Lucent\Schema\Schema;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Support\Collection;
class FilesSchema implements Schema class FilesSchema implements Schema
{ {
+9
View File
@@ -0,0 +1,9 @@
<?php
namespace Lucent\Schema\Schema;
interface Schema
{
}
@@ -1,6 +1,6 @@
<?php <?php
namespace Lucent\Schema; namespace Lucent\Schema\Schema;
readonly class System readonly class System
{ {
@@ -1,6 +1,6 @@
<?php <?php
namespace Lucent\Schema; namespace Lucent\Schema\Schema;
enum Type: string enum Type: string
+6 -1
View File
@@ -2,8 +2,13 @@
namespace Lucent\Schema; namespace Lucent\Schema;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Schema\Schema\BlockSchema;
use Lucent\Schema\Schema\CollectionSchema;
use Lucent\Schema\Schema\EdgeSchema;
use Lucent\Schema\Schema\FilesSchema;
use Lucent\Schema\Schema\Schema;
use Lucent\Support\Collection;
class SchemaService class SchemaService
{ {
+1 -1
View File
@@ -2,10 +2,10 @@
namespace Lucent\Schema\Sidebar; namespace Lucent\Schema\Sidebar;
use Lucent\Primitive\Collection;
use Lucent\Schema\Sidebar\Item\Item; use Lucent\Schema\Sidebar\Item\Item;
use Lucent\Schema\Sidebar\Item\LinkItem; use Lucent\Schema\Sidebar\Item\LinkItem;
use Lucent\Schema\Sidebar\Item\SchemaItem; use Lucent\Schema\Sidebar\Item\SchemaItem;
use Lucent\Support\Collection;
class Section class Section
{ {
+1 -7
View File
@@ -2,13 +2,7 @@
namespace Lucent\Schema\Sidebar; namespace Lucent\Schema\Sidebar;
use Hoa\File\Link\Link; use Lucent\Support\Collection;
use Lucent\Channel\Channel;
use Lucent\Primitive\Collection;
use Lucent\Schema\Sidebar\Item\Item;
use Lucent\Schema\Sidebar\Item\LinkItem;
use Lucent\Schema\Sidebar\Item\SchemaItem;
use Lucent\Schema\Sidebar\View\ItemData;
class Sidebar class Sidebar
{ {
+3 -5
View File
@@ -3,12 +3,10 @@
namespace Lucent\Schema\Sidebar; namespace Lucent\Schema\Sidebar;
use Lucent\Channel\Channel;
use Lucent\Channel\ChannelService; use Lucent\Channel\ChannelService;
use Lucent\Primitive\Collection; use Lucent\Schema\Schema\CollectionSchema;
use Lucent\Schema\CollectionSchema; use Lucent\Schema\Schema\FilesSchema;
use Lucent\Schema\FilesSchema; use Lucent\Schema\Schema\Schema;
use Lucent\Schema\Schema;
use Lucent\Schema\Sidebar\Item\Item; use Lucent\Schema\Sidebar\Item\Item;
use Lucent\Schema\Sidebar\Item\LinkItem; use Lucent\Schema\Sidebar\Item\LinkItem;
use Lucent\Schema\Sidebar\Item\SchemaItem; use Lucent\Schema\Sidebar\Item\SchemaItem;
+1 -1
View File
@@ -4,11 +4,11 @@ namespace Lucent\Schema\Ui;
use Lucent\JsonSchema\Property\Property; use Lucent\JsonSchema\Property\Property;
use Lucent\JsonSchema\Property\RefProperty; use Lucent\JsonSchema\Property\RefProperty;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldInfo; use Lucent\Schema\Field\FieldInfo;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Schema\Field\FieldType; use Lucent\Schema\Field\FieldType;
use Lucent\Schema\Validator\MinMaxInterface; use Lucent\Schema\Validator\MinMaxInterface;
use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
class File implements FieldInterface, MinMaxInterface class File implements FieldInterface, MinMaxInterface
+1 -1
View File
@@ -4,11 +4,11 @@ namespace Lucent\Schema\Ui;
use Lucent\JsonSchema\Property\Property; use Lucent\JsonSchema\Property\Property;
use Lucent\JsonSchema\Property\RefProperty; use Lucent\JsonSchema\Property\RefProperty;
use Lucent\Primitive\Collection;
use Lucent\Schema\Field\FieldInfo; use Lucent\Schema\Field\FieldInfo;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Schema\Field\FieldType; use Lucent\Schema\Field\FieldType;
use Lucent\Schema\Validator\MinMaxInterface; use Lucent\Schema\Validator\MinMaxInterface;
use Lucent\Support\Collection;
use PhpOption\Option; use PhpOption\Option;
class Reference implements FieldInterface, MinMaxInterface class Reference implements FieldInterface, MinMaxInterface
+1 -1
View File
@@ -4,9 +4,9 @@ namespace Lucent\Schema\Validator;
use Lucent\Channel\ChannelService; use Lucent\Channel\ChannelService;
use Lucent\Edge\EdgeCollection; use Lucent\Edge\EdgeCollection;
use Lucent\Primitive\Collection;
use Lucent\Record\RecordData; use Lucent\Record\RecordData;
use Lucent\Schema\Field\FieldInterface; use Lucent\Schema\Field\FieldInterface;
use Lucent\Support\Collection;
class Validator class Validator
@@ -1,6 +1,6 @@
<?php <?php
namespace Lucent\Primitive; namespace Lucent\Support;
use Illuminate\Support\Collection as LaravelCollection; use Illuminate\Support\Collection as LaravelCollection;
+111
View File
@@ -0,0 +1,111 @@
<?php
namespace Lucent\Support\Result;
use PhpOption\None;
use PhpOption\Option;
use PhpOption\Some;
/**
* @template T
* @template E
*
* @extends Result<T,E>
*/
final class Error extends Result
{
/**
* @var E
*/
private $value;
/**
* Internal constructor for an error value.
*
* @param E $value
*
* @return void
*/
private function __construct($value)
{
$this->value = $value;
}
/**
* Create a new error value.
*
* @template F
*
* @param F $value
*
* @return Result<T,F>
*/
public static function create($value): Result
{
return new self($value);
}
/**
* Get the success option value.
*
* @return Option<T>
*/
public function success(): Option
{
return None::create();
}
/**
* Map over the success value.
*
* @template S
*
* @param callable(T):S $f
*
* @return Result<S,E>
*/
public function map(callable $f): Result
{
return self::create($this->value);
}
/**
* Flat map over the success value.
*
* @template S
* @template F
*
* @param callable(T):Result<S,F> $f
*
* @return Result<S,F>
*/
public function flatMap(callable $f): Result
{
/* @var Result<S,F> */
return self::create($this->value);
}
/**
* Get the error option value.
*
* @return Option<E>
*/
public function error(): Option
{
return Some::create($this->value);
}
/**
* Map over the error value.
*
* @template F
*
* @param callable(E):F $f
*
* @return Result<T,F>
*/
public function mapError(callable $f): Result
{
return self::create($f($this->value));
}
}
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace Lucent\Support\Result;
use PhpOption\Option;
/**
* @template T
* @template E
*/
abstract class Result
{
/**
* Get the success option value.
*
* @return Option<T>
*/
abstract public function success(): Option;
/**
* Map over the success value.
*
* @template S
*
* @param callable(T):S $f
*
* @return Result<S,E>
*/
abstract public function map(callable $f): Result;
/**
* Flat map over the success value.
*
* @template S
* @template F
*
* @param callable(T): Result<S,F> $f
*
* @return Result<S,F>
*/
abstract public function flatMap(callable $f): Result;
/**
* Get the error option value.
*
* @return Option<E>
*/
abstract public function error(): Option;
/**
* Map over the error value.
*
* @template F
*
* @param callable(E):F $f
*
* @return Result<T,F>
*/
abstract public function mapError(callable $f): Result;
}
+110
View File
@@ -0,0 +1,110 @@
<?php
namespace Lucent\Support\Result;
use PhpOption\None;
use PhpOption\Option;
use PhpOption\Some;
/**
* @template T
* @template E
*
* @extends Result<T,E>
*/
final class Success extends Result
{
/**
* @var T
*/
private $value;
/**
* Internal constructor for a success value.
*
* @param T $value
*
* @return void
*/
private function __construct($value)
{
$this->value = $value;
}
/**
* Create a new error value.
*
* @template S
*
* @param S $value
*
* @return Result<S,E>
*/
public static function create($value): Result
{
return new self($value);
}
/**
* Get the success option value.
*
* @return Option<T>
*/
public function success(): Option
{
return Some::create($this->value);
}
/**
* Map over the success value.
*
* @template S
*
* @param callable(T):S $f
*
* @return Result<S,E>
*/
public function map(callable $f): Result
{
return self::create($f($this->value));
}
/**
* Flat map over the success value.
*
* @template S
* @template F
*
* @param callable(T):Result<S,F> $f
*
* @return Result<S,F>
*/
public function flatMap(callable $f): Result
{
return $f($this->value);
}
/**
* Get the error option value.
*
* @return Option<E>
*/
public function error(): Option
{
return None::create();
}
/**
* Map over the error value.
*
* @template F
*
* @param callable(E):F $f
*
* @return Result<T,F>
*/
public function mapError(callable $f): Result
{
return self::create($this->value);
}
}