chore: bump dependencies & clear graphql inputs (#1019)

This commit is contained in:
Kyrch
2025-12-10 08:16:01 -03:00
committed by GitHub
parent 696a9882a9
commit 7b786cf911
22 changed files with 472 additions and 831 deletions
@@ -1,68 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Base;
use App\Contracts\GraphQL\Fields\CreatableField;
use App\Contracts\GraphQL\Fields\RequiredOnCreation;
use App\GraphQL\Schema\Fields\Field;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Inputs\Relations\CreateBelongsToInput;
use App\GraphQL\Schema\Inputs\Relations\CreateBelongsToManyInput;
use App\GraphQL\Schema\Inputs\Relations\CreateHasManyInput;
use App\GraphQL\Schema\Relations\BelongsToManyRelation;
use App\GraphQL\Schema\Relations\BelongsToRelation;
use App\GraphQL\Schema\Relations\HasManyRelation;
use App\GraphQL\Schema\Relations\Relation;
use App\GraphQL\Schema\Types\EloquentType;
use App\GraphQL\Support\InputField;
use Illuminate\Support\Arr;
class CreateInput extends Input
{
public function __construct(
protected EloquentType $type,
) {}
public function getName(): string
{
return "Create{$this->type->getName()}Input";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
$fields = [];
$baseType = $this->type;
$fields[] = collect($baseType->fieldClasses())
->filter(fn (Field $field): bool => $field instanceof CreatableField) // and submitable field?
->map(
fn (Field&CreatableField $field): InputField => new InputField($field->getName(), $field->type().($field instanceof RequiredOnCreation ? '!' : ''))
)
->toArray();
$fields[] = collect($baseType->relations())
->mapWithKeys(function (Relation $relation): array {
$baseType = $relation->getBaseType();
if (! $baseType instanceof EloquentType) {
return [];
}
return match (true) {
$relation instanceof BelongsToRelation => [$relation->getName() => new CreateBelongsToInput($baseType)],
$relation instanceof HasManyRelation => [$relation->getName() => new CreateHasManyInput($baseType)],
$relation instanceof BelongsToManyRelation => [$relation->getName() => new CreateBelongsToManyInput($relation->getEdgeType()->getPivotType())],
default => [],
};
})
->map(fn (Input $input, string $name): InputField => new InputField($name, $input->getName()))
->toArray();
return Arr::flatten($fields);
}
}
@@ -1,74 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Base;
use App\Contracts\GraphQL\Fields\BindableField;
use App\Contracts\GraphQL\Fields\RequiredOnUpdate;
use App\Contracts\GraphQL\Fields\UpdatableField;
use App\GraphQL\Schema\Fields\Field;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Inputs\Relations\UpdateBelongsToInput;
use App\GraphQL\Schema\Inputs\Relations\UpdateBelongsToManyInput;
use App\GraphQL\Schema\Inputs\Relations\UpdateHasManyInput;
use App\GraphQL\Schema\Relations\BelongsToManyRelation;
use App\GraphQL\Schema\Relations\BelongsToRelation;
use App\GraphQL\Schema\Relations\HasManyRelation;
use App\GraphQL\Schema\Relations\Relation;
use App\GraphQL\Schema\Types\EloquentType;
use App\GraphQL\Support\InputField;
use Illuminate\Support\Arr;
class UpdateInput extends Input
{
public function __construct(
protected EloquentType $type,
) {}
public function getName(): string
{
return "Update{$this->type->getName()}Input";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
$fields = [];
$baseType = $this->type;
$fields[] = collect($baseType->fieldClasses())
->filter(fn (Field $field): bool => $field instanceof BindableField)
->map(fn (Field&BindableField $field): InputField => new InputField($field->getName(), $field->type()->__toString().'!'))
->toArray();
$fields[] = collect($baseType->fieldClasses())
->filter(fn (Field $field): bool => $field instanceof UpdatableField) // and submitable field?
->map(
fn (Field&UpdatableField $field): InputField => new InputField($field->getName(), $field->type().($field instanceof RequiredOnUpdate ? '!' : ''))
)
->toArray();
$fields[] = collect($baseType->relations())
->mapWithKeys(function (Relation $relation): array {
$baseType = $relation->getBaseType();
if (! $baseType instanceof EloquentType) {
return [];
}
return match (true) {
$relation instanceof BelongsToRelation => [$relation->getName() => new UpdateBelongsToInput($baseType)],
$relation instanceof HasManyRelation => [$relation->getName() => new UpdateHasManyInput($baseType)],
$relation instanceof BelongsToManyRelation => [$relation->getName() => new UpdateBelongsToManyInput($relation->getEdgeType()->getPivotType())],
default => [],
};
})
->map(fn (Input $input, string $name): InputField => new InputField($name, $input->getName()))
->toArray();
return Arr::flatten($fields);
}
}
@@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Relations;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Types\EloquentType;
use App\GraphQL\Support\InputField;
use GraphQL\Type\Definition\Type;
class CreateBelongsToInput extends Input
{
public function __construct(
protected EloquentType $type,
) {}
public function getName(): string
{
return "Create{$this->type->getName()}BelongsTo";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
return [
new InputField('connect', Type::int()),
new InputField('create', "Create{$this->type->getName()}Input"),
new InputField('update', "Update{$this->type->getName()}Input"),
];
}
}
@@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Relations;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Types\Pivot\PivotType;
use App\GraphQL\Support\InputField;
class CreateBelongsToManyInput extends Input
{
public function __construct(
protected PivotType $type,
) {}
public function getName(): string
{
return "Create{$this->type->getName()}BelongsToMany";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
return [
new InputField('create', "[Create{$this->type->getName()}Input!]"),
// new InputField('connect', "[Connect{$this->type->getName()}Input!]"),
];
}
}
@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Relations;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Types\EloquentType;
use App\GraphQL\Support\InputField;
use GraphQL\Type\Definition\Type;
class CreateHasManyInput extends Input
{
public function __construct(
protected EloquentType $type,
) {}
public function getName(): string
{
return "Create{$this->type->getName()}HasMany";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
return [
new InputField('create', "[Create{$this->type->getName()}Input!]"),
new InputField('update', "[Update{$this->type->getName()}Input!]"),
new InputField('connect', Type::listof(Type::nonNull(Type::int()))),
new InputField('disconnect', Type::listof(Type::nonNull(Type::int()))),
new InputField('delete', Type::listof(Type::nonNull(Type::int()))),
];
}
}
@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Relations;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Types\EloquentType;
use App\GraphQL\Support\InputField;
use GraphQL\Type\Definition\Type;
class UpdateBelongsToInput extends Input
{
public function __construct(
protected EloquentType $type,
) {}
public function getName(): string
{
return "Update{$this->type->getName()}BelongsTo";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
return [
new InputField('connect', Type::int()),
new InputField('create', "Create{$this->type->getName()}Input"),
new InputField('update', "Update{$this->type->getName()}Input"),
new InputField('disconnect', Type::boolean()),
new InputField('delete', Type::boolean()),
];
}
}
@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Relations;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Types\Pivot\PivotType;
use App\GraphQL\Support\InputField;
use GraphQL\Type\Definition\Type;
class UpdateBelongsToManyInput extends Input
{
public function __construct(
protected PivotType $type,
) {}
public function getName(): string
{
return "Update{$this->type->getName()}BelongsToMany";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
return [
new InputField('create', "[Create{$this->type->getName()}Input!]"),
new InputField('update', "[Update{$this->type->getName()}Input!]"),
// new InputField('connect', "[Connect{$this->type->getName()}Input!]"),
new InputField('disconnect', Type::listof(Type::nonNull(Type::int()))),
new InputField('delete', Type::listof(Type::nonNull(Type::int()))),
];
}
}
@@ -1,36 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Inputs\Relations;
use App\GraphQL\Schema\Inputs\Input;
use App\GraphQL\Schema\Types\EloquentType;
use App\GraphQL\Support\InputField;
use GraphQL\Type\Definition\Type;
class UpdateHasManyInput extends Input
{
public function __construct(
protected EloquentType $type,
) {}
public function getName(): string
{
return "Update{$this->type->getName()}HasMany";
}
/**
* @return InputField[]
*/
public function fieldClasses(): array
{
return [
new InputField('create', "[Create{$this->type->getName()}Input!]"),
new InputField('update', "[Update{$this->type->getName()}Input!]"),
new InputField('connect', Type::listof(Type::nonNull(Type::int()))),
new InputField('disconnect', Type::listof(Type::nonNull(Type::int()))),
new InputField('delete', Type::listof(Type::nonNull(Type::int()))),
];
}
}
@@ -1,22 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Mutations\Submissions\Base;
use App\GraphQL\Schema\Mutations\Submissions\BaseSubmissionMutation;
use Illuminate\Support\Str;
abstract class UpdateSubmissionMutation extends BaseSubmissionMutation
{
/**
* The input type of the 'input' argument on the top mutation.
*/
public function rootInput(): string
{
return Str::of('Update')
->append($this->baseType()->getName())
->append('Input')
->__toString();
}
}
@@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Mutations\Submissions;
use App\GraphQL\Schema\Mutations\BaseMutation;
use App\GraphQL\Support\Argument\Argument;
use GraphQL\Type\Definition\Type;
abstract class BaseSubmissionMutation extends BaseMutation
{
/**
* The arguments of the mutation.
*
* @return Argument[]
*/
public function arguments(): array
{
return [
new Argument('input', $this->rootInput())
->required(),
];
}
public function type(): Type
{
return Type::nonNull($this->baseType());
}
/**
* The input type of the 'input' argument on the top mutation.
*/
abstract public function rootInput(): string;
}
@@ -1,39 +0,0 @@
<?php
declare(strict_types=1);
namespace App\GraphQL\Schema\Mutations\Submissions\Wiki;
use App\GraphQL\Schema\Mutations\Submissions\Base\UpdateSubmissionMutation;
use App\GraphQL\Schema\Types\Wiki\AnimeType;
use GraphQL\Type\Definition\ResolveInfo;
class AnimeSubmissionMutation extends UpdateSubmissionMutation
{
public function __construct()
{
parent::__construct('submitUpdateAnime');
}
public function description(): string
{
return 'Submission information about an anime page.';
}
/**
* The base return type of the mutation.
*/
public function baseType(): AnimeType
{
return new AnimeType();
}
/**
* @param array<string, mixed> $args
*/
public function resolve($root, array $args, $context, ResolveInfo $resolveInfo): mixed
{
// TODO
return null;
}
}
+12 -12
View File
@@ -29,16 +29,16 @@
"babenkoivan/elastic-scout-driver-plus": "^4.8",
"bepsvpt/secure-headers": "^7.5",
"fakerphp/faker": "^1.24.1",
"filament/filament": "^4.2.4",
"filament/filament": "^4.3.1",
"flowframe/laravel-trend": ">=0.4",
"guzzlehttp/guzzle": "^7.10.0",
"larastan/larastan": "^3.8.0",
"laravel-notification-channels/discord": "^1.7",
"laravel/fortify": "^1.32.1",
"laravel/framework": "^12.40.2",
"laravel/horizon": "^5.40.1",
"laravel/pennant": "^1.18.4",
"laravel/pulse": "^1.4.4",
"laravel/framework": "^12.42.0",
"laravel/horizon": "^5.40.2",
"laravel/pennant": "^1.18.5",
"laravel/pulse": "^1.4.6",
"laravel/sanctum": "^4.2.1",
"laravel/scout": "^10.22.1",
"laravel/tinker": "^2.10.2",
@@ -47,27 +47,27 @@
"mll-lab/graphql-php-scalars": "^6.4.1",
"mll-lab/laravel-graphiql": "^3.3.4",
"owen-it/laravel-auditing": "^14.0.0",
"propaganistas/laravel-disposable-email": "^2.4.20",
"rebing/graphql-laravel": "^9.12",
"spatie/db-dumper": "^3.8.1",
"propaganistas/laravel-disposable-email": "^2.4.21",
"rebing/graphql-laravel": "^9.14",
"spatie/db-dumper": "^3.8.2",
"spatie/laravel-permission": "^6.23.0",
"staudenmeir/belongs-to-through": "^2.17",
"staudenmeir/eloquent-has-many-deep": "1.21.1",
"staudenmeir/laravel-adjacency-list": "^1.25.2",
"symfony/http-client": "^6.4.28",
"symfony/http-client": "^6.4.30",
"symfony/mailgun-mailer": "^6.4.24",
"vinkla/hashids": "^13.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.16.1",
"driftingly/rector-laravel": "^2.1.3",
"driftingly/rector-laravel": "^2.1.6",
"laravel/pint": "^1.26.0",
"laravel/sail": "^1.48.1",
"laravel/sail": "^1.51.0",
"mockery/mockery": "^1.6.12",
"pestphp/pest": "^4.1.6",
"pestphp/pest-plugin-laravel": "^4.0",
"predis/predis": "^2.4.1",
"rector/rector": "^2.2.9"
"rector/rector": "^2.2.14"
},
"config": {
"optimize-autoloader": true,
Generated
+370 -305
View File
File diff suppressed because it is too large Load Diff
@@ -33,6 +33,7 @@ class SubmissionStageFactory extends Factory
return [
SubmissionStage::ATTRIBUTE_SUBMISSION => Submission::factory(),
SubmissionStage::ATTRIBUTE_MODERATOR_NOTES => fake()->text(),
SubmissionStage::ATTRIBUTE_STAGE => fake()->randomDigitNotNull(),
];
}
}
@@ -36,6 +36,7 @@ class SubmissionFactory extends Factory
return [
Submission::ATTRIBUTE_MODERATOR_NOTES => fake()->text(),
Submission::ATTRIBUTE_STATUS => $status->value,
Submission::ATTRIBUTE_TYPE => fake()->text(),
];
}
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
function u({activeTab:a,isTabPersistedInQueryString:e,livewireId:h,tab:o,tabQueryStringKey:s}){return{tab:o,init(){let t=this.getTabs(),i=new URLSearchParams(window.location.search);e&&i.has(s)&&t.includes(i.get(s))&&(this.tab=i.get(s)),this.$watch("tab",()=>this.updateQueryString()),(!this.tab||!t.includes(this.tab))&&(this.tab=t[a-1]),Livewire.hook("commit",({component:r,commit:f,succeed:c,fail:l,respond:b})=>{c(({snapshot:d,effect:m})=>{this.$nextTick(()=>{if(r.id!==h)return;let n=this.getTabs();n.includes(this.tab)||(this.tab=n[a-1]??this.tab)})})})},getTabs(){return this.$refs.tabsData?JSON.parse(this.$refs.tabsData.value):[]},updateQueryString(){if(!e)return;let t=new URL(window.location.href);t.searchParams.set(s,this.tab),history.replaceState(null,document.title,t.toString())}}}export{u as default};
function I({activeTab:w,isScrollable:f,isTabPersistedInQueryString:m,livewireId:g,tab:T,tabQueryStringKey:c}){return{boundResizeHandler:null,isScrollable:f,resizeDebounceTimer:null,tab:T,withinDropdownIndex:null,withinDropdownMounted:!1,init(){let t=this.getTabs(),e=new URLSearchParams(window.location.search);m&&e.has(c)&&t.includes(e.get(c))&&(this.tab=e.get(c)),this.$watch("tab",()=>this.updateQueryString()),(!this.tab||!t.includes(this.tab))&&(this.tab=t[w-1]),Livewire.hook("commit",({component:n,commit:d,succeed:r,fail:h,respond:u})=>{r(({snapshot:p,effect:i})=>{this.$nextTick(()=>{if(n.id!==g)return;let s=this.getTabs();s.includes(this.tab)||(this.tab=s[w-1]??this.tab)})})}),f||(this.boundResizeHandler=this.debouncedUpdateTabsWithinDropdown.bind(this),window.addEventListener("resize",this.boundResizeHandler),this.updateTabsWithinDropdown())},calculateAvailableWidth(t){let e=window.getComputedStyle(t);return Math.floor(t.clientWidth)-Math.ceil(parseFloat(e.paddingLeft))*2},calculateContainerGap(t){let e=window.getComputedStyle(t);return Math.ceil(parseFloat(e.columnGap))},calculateDropdownIconWidth(t){let e=t.querySelector(".fi-icon");return Math.ceil(e.clientWidth)},calculateTabItemGap(t){let e=window.getComputedStyle(t);return Math.ceil(parseFloat(e.columnGap)||8)},calculateTabItemPadding(t){let e=window.getComputedStyle(t);return Math.ceil(parseFloat(e.paddingLeft))+Math.ceil(parseFloat(e.paddingRight))},findOverflowIndex(t,e,n,d,r,h){let u=t.map(i=>Math.ceil(i.clientWidth)),p=t.map(i=>{let s=i.querySelector(".fi-tabs-item-label"),a=i.querySelector(".fi-badge"),o=Math.ceil(s.clientWidth),l=a?Math.ceil(a.clientWidth):0;return{label:o,badge:l,total:o+(l>0?d+l:0)}});for(let i=0;i<t.length;i++){let s=u.slice(0,i+1).reduce((b,y)=>b+y,0),a=i*n,o=p.slice(i+1),l=o.length>0,W=l?Math.max(...o.map(b=>b.total)):0,D=l?r+W+d+h+n:0;if(s+a+D>e)return i}return-1},get isDropdownButtonVisible(){return this.withinDropdownMounted?this.withinDropdownIndex===null?!1:this.getTabs().findIndex(e=>e===this.tab)<this.withinDropdownIndex:!0},getTabs(){return this.$refs.tabsData?JSON.parse(this.$refs.tabsData.value):[]},updateQueryString(){if(!m)return;let t=new URL(window.location.href);t.searchParams.set(c,this.tab),history.replaceState(null,document.title,t.toString())},debouncedUpdateTabsWithinDropdown(){clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=setTimeout(()=>this.updateTabsWithinDropdown(),150)},async updateTabsWithinDropdown(){this.withinDropdownIndex=null,this.withinDropdownMounted=!1,await this.$nextTick();let t=this.$el.querySelector(".fi-tabs"),e=t.querySelector(".fi-tabs-item:last-child"),n=Array.from(t.children).slice(0,-1),d=n.map(a=>a.style.display);n.forEach(a=>a.style.display=""),t.offsetHeight;let r=this.calculateAvailableWidth(t),h=this.calculateContainerGap(t),u=this.calculateDropdownIconWidth(e),p=this.calculateTabItemGap(n[0]),i=this.calculateTabItemPadding(n[0]),s=this.findOverflowIndex(n,r,h,p,i,u);n.forEach((a,o)=>a.style.display=d[o]),s!==-1&&(this.withinDropdownIndex=s),this.withinDropdownMounted=!0},destroy(){this.boundResizeHandler&&window.removeEventListener("resize",this.boundResizeHandler),clearTimeout(this.resizeDebounceTimer)}}}export{I as default};
File diff suppressed because one or more lines are too long